I'm trying to move pivot point to the center of an object so it rotates around its center. How can I do this?
I see no option in Xcode editor for doing this. I tried changing the pivot point programmatically:
// create a new scene
let scene = SCNScene(named: "art.scnassets/Heart.scn")!
// change pivot point
scene.rootNode.pivot = SCNMatrix4MakeTranslation(0.5, 0.5, 0.5)
But it doesn't work either, the object still rotates around its old pivot point.
The heart is (probably) not the root node of your scene. It is a child of the root node (as are the default camera and any lights). So you could try
// (use the Scene Editor to figure out what the node name really is)
if let heart = scene.rootNode.childNodeWithName("HEART", recursively: true) {
heart.pivot = SCNMatrix4MakeTranslation(0.5, 0.5, 0.5)
}
As for the Scene Editor...are you sure you're manipulating the heart, and not the entire scene? I've also seen some SO and Devforum traffic that suggests (but doesn't prove) that some parameters set in the Scene Editor aren't honored at runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With