我有两个SCNNode,几何类型设置为SCNBox .
let node1 = SCNNode(geometry: SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 0.0))
let node2 = SCNNode(geometry: SCNBox(width: 20.0, height: 10.0, length: 10.0, chamferRadius: 0.0))
node1.position.x = 0.0
node2.position.x = 10.0
scene.rootNode.addChildNode(node1)
scene.rootNode.addChildNode(node2)
当我看到我的场景然后节点重叠,但它们不应该,或者它们应该?我不会同时操纵相机 . 现在我没有任何物理场设置 .
当我打印以下内容时:
node1.presentationNode.position.x
node2.presentationNode.position.x
要么
(node1.geometry as! SCNBox).width
(node2.geometry as! SCNBox).width
然后打印的值与最初设置的值相同 . 默认情况下,节点的锚点是左下角吗?奇怪的是,当我在touchesBegan / touchesEnded中移动节点并将其定位在相同位置时,节点不会重叠 . 如何正确放置SceneKit的节点?
2 回答
谢谢你的帮助 . 我找到了解决方案 . 节点基于锚点定位,该锚点位于节点宽度的中间 .
我相信你让你的轴混乱了 . node2的宽度为20,但是你只将node1(宽度为10)移动10.请尝试将其移动20(或小的间隙为23) .