小编use*_*707的帖子

旋转后如何在SceneKit中获取子节点的实际位置?

我正在使用SceneKit开发一个场景.我有一个带有子节点的主节点:

// Main node
SCNNode* planet = [SCNNode node];
planet.geometry = [SCNSphere sphereWithRadius:2];
planet.position = SCNVector3Make(0, -3, 5);
// sub-node
SCNNode* satellite = [SCNNode node];
satellite.geometry = [SCNSphere sphereWithRadius:0.4];
satellite.position = SCNVector3Make(4, 0, 0);
[planet addChildNode:satellite];
[scene.rootNode addChildNode:planet];
Run Code Online (Sandbox Code Playgroud)

我使用NSTimer来制作一些动作和一些动画.在计时器事件中,我这样做:

planetRotation + = 0.1; planet.rotation = SCNVector4Make(0,1,0,planetRotation);

但是,如果我试图获得卫星节点的位置,我总是得到相同的值.我试图让位置节点知道卫星节点的真实位置,但没有任何变化.

当我改变父节点的旋转时,如何获得子节点的实际位置?

提前致谢

objective-c scenekit

7
推荐指数
2
解决办法
4630
查看次数

标签 统计

objective-c ×1

scenekit ×1