我有兩個SCNNode,它們的幾何類型設置爲SCNBox。節點的SceneKit定位
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的節點?
當你看到分離的不同時會發生什麼事件?這是在你操縱相機時發生的嗎? – bpedit
請看看我的編輯。在上面的示例代碼中,節點總是重疊。但是,當我在touchesBegan中移動節點並將其放置在完全相同的位置時,它們不會重疊。 – BlueLettuce16