0
votes

I was looking for a clue to this since 2 days without a luck.

Basically, I want to animate rotation of a node in Scenekit but around one axis. Something like A door opening animation.

The thing is when I rotate it, it rotates from the middle, not from the side of the door as needed. Here's an example code of what I was trying to do:

let oldTransform = node.transform
let rotation = SCNMatrix4MakeRotation(Float(-Double.pi / 2.0), 5.0, 0.0, 0.0);
SCNTransaction.begin()
SCNTransaction.animationDuration = 1.5
node.transform = SCNMatrix4Mult(rotation, oldTransform)
SCNTransaction.commit()

Any hint on what I should do I will be really grateful. I'm new to Scenekit, hopefully you guys would understand that.

1
Either change the anchor point of the node, or add it as a child of of another node and rotate that. - James P

1 Answers

0
votes

Move the pivot of the SCNNode to the side of the door/model before rotating it. You can do this in code by changing its pivot property, or in most 3D modeling software.