Swift SceneKit 也不是圆形球体
Posted
技术标签:
【中文标题】Swift SceneKit 也不是圆形球体【英文标题】:Swift SceneKit nor rounded sphere 【发布时间】:2021-08-27 05:29:54 【问题描述】:我添加了一个球体节点,但是当我旋转节点(从触摸)时,球体的边缘不平滑。有没有办法解决这个问题?
在 X 上旋转时一切都很好,但在 Y 球体上不平滑:(
sceneView.scene = scene
cameraOrbit = SCNNode()
cameraNode = SCNNode()
camera = SCNCamera()
// camera stuff
camera.usesOrthographicProjection = true
camera.orthographicScale = 5
camera.zNear = 1
camera.zFar = 100
cameraNode.position = SCNVector3(x: 0, y: 0, z: 70)
cameraNode.camera = camera
cameraOrbit = SCNNode()
cameraOrbit.addChildNode(cameraNode)
scene.rootNode.addChildNode(cameraNode)
let sphere = SCNSphere(radius: 2)
sphere.firstMaterial?.diffuse.contents = UIColor.red
let earthNode = SCNNode(geometry: sphere)
earthNode.name = "sphere"
earthNode.geometry?.materials = [blueMaterial]
scene.rootNode.addChildNode(earthNode)
earthNode.rotation = SCNVector4(0, 1, 0, 0)
let lightNode = SCNNode()
let light = SCNLight()
light.type = .ambient
light.intensity = 200
lightNode.light = light
scene.rootNode.addChildNode(lightNode)
sceneView.allowsCameraControl = true
sceneView.backgroundColor = UIColor.clear
sceneView.cameraControlConfiguration.allowsTranslation = true
sceneView.cameraControlConfiguration.rotationSensitivity = 0.4
【问题讨论】:
developer.apple.com/documentation/scenekit/scnsphere谈segmentCount:developer.apple.com/documentation/scenekit/scnsphere/…geodesic
属性也可以带来更好的结果。
@Shadowrun 谢谢!
【参考方案1】:
你也可以细分你的几何:
node.geometry.subdivisionlevel = 2 // Don't make that more than 3!
注意:这将消耗更多内存,因为几何现在包含更多顶点(网格数据)
【讨论】:
以上是关于Swift SceneKit 也不是圆形球体的主要内容,如果未能解决你的问题,请参考以下文章