Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate SCNNode relative local coordinates

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?

like image 637
Nikita Ermolenko Avatar asked Dec 23 '22 15:12

Nikita Ermolenko


1 Answers

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))
like image 142
AlexKorovyansky Avatar answered Dec 26 '22 04:12

AlexKorovyansky