【发布时间】:2017-02-07 00:51:08
【问题描述】:
我有两个 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 的节点?
【问题讨论】:
-
当您看到分离的差异时发生了什么?操作相机时会发生这种情况吗?
-
请看看我的编辑。在上面的示例代码中,节点总是重叠的。但是,当我在 touchesBegan 中移动节点并将其放置在完全相同的位置时,它们不会重叠。