How to get the real position of a sub node in SceneKit after rotation?

前端 未结 2 1247
盖世英雄少女心
盖世英雄少女心 2021-01-11 21:25

I am developing a scene with SceneKit. I have a main node with a subnode:

// Main node
SCNNode* planet = [SCNNode node];
planet.geometry = [SCNSphere sphereW         


        
相关标签:
2条回答
  • 2021-01-11 22:06

    the position of a node is expressed in its parent coordinate system. Just like for views in UIKIt/AppKit. If you change the frame of a view, the frame of its subviews does not change.

    What you want is what we call the world transform of the subnode (i.e. its transform expressed in the coordinate system of the scene's root node).

    You can have a look at worldTransform and -convertPosition:toNode:.

    0 讨论(0)
  • 2021-01-11 22:11

    The node's position won't change due to physics, that is why you aren't seeing it change. You need to call the node's presentationNode to get the position of the node as it is presented onscreen:

    node.presentationNode.position
    
    0 讨论(0)
提交回复
热议问题