0

I have a bunch of SCNNode's that all share the same parent. I can rotate a group them around their own axes using

func handleTap(gestureRecognize: UIGestureRecognizer) {
    let sceneView = self.view as SCNView
    let action = SCNAction.rotateByAngle(CGFloat(M_PI_2), aroundAxis: SCNVector3Make(-1, 0, 0), duration: 1)
    let slice = self.cubes[18...26]

    for node: SCNNode in slice {
        node.runAction(action, completionHandler: { () -> Void in
            println("hmm")
        })
    }

}

But ideally what I would like to do is rotate them around their parent's axis instead. I can rotate the entire parent but that rotates many more nodes than I'd like, and I've tried grouping them into their own parent, but when I add them back to their previous parent they don't maintain their new position.

JuJoDi
  • 14,627
  • 23
  • 80
  • 126
  • does it make sense to group all these nodes under a child node of the parent? The parent would have as child nodes the nodes that you want to move individually and that new "group" node. And under the "group" node you would find all the nodes that you want to move together. – mnuages Mar 08 '15 at 12:07
  • The group of nodes that needs to rotate changes frequently, but yes, the solution I have right now groups them under a new node then rotates that node. – JuJoDi Mar 08 '15 at 13:10
  • good. If you want to periodically reparent the nodes you can have a look at `-convertTransform:fromNode:` to preserve their world orientation. – mnuages Mar 08 '15 at 13:35
  • I wish you would have told me that when I asked [this question](http://stackoverflow.com/questions/28819698/node-groups-position-is-reset-at-the-start-of-scnnode-runaction) haha, took me a while to figure out – JuJoDi Mar 08 '15 at 13:37

0 Answers0