Rotate SCNNode relative local coordinates

别等时光非礼了梦想. 提交于 2019-12-20 01:14:27

问题


I'm trying to rotate a node by SCNAction, but it rotates relative to parent’s coordinate space. Is it possible to rotate a node relative local's coordinate system?


回答1:


Sure. You can obtain parent's space coordinates for rotation axis with convertVector method.

For example, this action will do 180 degrees rotation around local x-axis:

SCNAction.rotate(by: .pi, around: node.convertVector(SCNVector3(1, 0, 0), to: node.parent), duration: TimeInterval(5))



回答2:


Have you tried:

[node runAction:[SCNAction rotateByX:0 y:1 z:0 duration:5.0]]; //Rotates the node along the y axis for 5 seconds.


来源:https://stackoverflow.com/questions/45357020/rotate-scnnode-relative-local-coordinates

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!