【问题标题】:Unable to create circle using UIBezierPath and SCNShape无法使用 UIBezierPath 和 SCNShape 创建圆
【发布时间】:2019-03-14 18:58:06
【问题描述】:

任何熟悉使用弯曲 UIBezierPaths 在 ARKit 中创建 SCNShape 的人?我正在创建一个封闭的圆形路径,但我的 ARKit 场景中出现了菱形。

这是我用来创建贝塞尔路径和 SCNShape 的代码:

let radius : CGFloat = 1.0
let outerPath = UIBezierPath(ovalIn: CGRect(x: -radius, y: -radius, width: 2* radius, height: 2* radius))

let material = SCNMaterial()
material.diffuse.contents = UIColor.blue
material.isDoubleSided = true
material.ambient.contents = UIColor.black
material.lightingModel = .constant
material.emission.contents = UIColor.blue

let shape = SCNShape(path: outerPath, extrusionDepth: 0.01)
shape.materials = [material]

let shapeNode = SCNNode(geometry: shape)
positioningNode.addChildNode(shapeNode)

我已经成功测试了一个矩形贝塞尔路径,但甚至在圆角矩形贝塞尔路径上也遇到了问题(使用UIBezierPath(roundedRect:)。对于圆角矩形贝塞尔路径,ARKit 以 45 度线显示弯曲的角。

提前致谢!

更新:

左侧是 UIBezierPath 平坦度设置为 0.6 的初始 SCNShape。右边是相同的 SCNShape,平面度设置为 0.001。

【问题讨论】:

    标签: ios swift scenekit arkit uibezierpath


    【解决方案1】:

    我找到了解决方案。基本上 UIBezierPath 的 flatness 变量用于控制曲率。在我的情况下,默认值 0.6 太大了。我最终使用了 0.001 的平坦度

    https://developer.apple.com/documentation/scenekit/scnshape/1523432-init

    【讨论】:

      猜你喜欢
      • 2018-04-02
      • 2018-07-15
      • 2014-01-07
      • 1970-01-01
      • 2021-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      相关资源
      最近更新 更多