Rotate SCNNode relative local coordinates

后端 未结 2 634
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 19:25

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 sy

2条回答
  •  伪装坚强ぢ
    2021-01-19 20:00

    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))
    

提交回复
热议问题