SceneKit 获取旋转后的节点位置 [英] SceneKit get node position after rotation

查看:56
本文介绍了SceneKit 获取旋转后的节点位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有两个 SCNNodes 和 SCNBox 几何体一个接一个地定位增加 x 位置属性:

SCNBox(width: 0, height: 0, length: 0.02, chamferRadius: 0)

然后我想使用 rotation 属性和 SCNVector4 旋转第一个,但是当旋转发生时,我希望我的第二个节点跟随第一个节点并根据旋转第一个.

我发现

http://appleengine.hatenablog.com/entry/2017/08/17/154852

For example I have two SCNNodes with SCNBox geometry positioned one after another increasing x position property:

SCNBox(width: 0, height: 0, length: 0.02, chamferRadius: 0)

Then I want to rotate the first one using rotation property with SCNVector4, but when rotation happens I want my second node to follow the first one and change its position according rotation of the first one.

I found this solution on the web and tried to print node's position, worldPosition and presentation.position but they are all the same value.

Can someone help me to find out how can I obtain node's position after rotation?

解决方案

The position of a node does not change when it rotates. Maybe you could look at connecting the nodes with a physics mechanism such as SCNPhysicsHingeJoint? I found this example which could be useful for your scenario:

http://lepetit-prince.net/ios/?p=3540

Another example:

http://appleengine.hatenablog.com/entry/2017/08/17/154852

这篇关于SceneKit 获取旋转后的节点位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆