作者:Perz | 来源:互联网 | 2022-12-02 16:57
熟悉使用弯曲的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度线的弯曲角。
提前致谢!
更新:
左侧是初始SCNShape,UIBezierPath平坦度设置为0.6。右侧是平坦度设置为0.001的同一SCNShape。
1> Jan-Michael ..:
我找到了解决方案。基本上,UIBezierPath的平坦度变量用于控制曲率。在我的情况下,默认值0.6太大。我最终使用了0.001的平坦度
https://developer.apple.com/documentation/scenekit/scnshape/1523432-init