Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove all nodes from a scenekit scene?

Hi I am trying to remove all nodes from my Scenekit scene but I cannot for the life of me figure out a way.

It seems logical to me that there must be a function for doing this automatically but I cannot find it.

In context, I am trying to remove all nodes so I can reset my scene, which will happen reasonably often. Perhaps there is another way of doing this and I would be fine with that, I'm not stuck with having to remove all nodes.

Thanks!

like image 591
Tim Andrews Avatar asked Feb 26 '15 09:02

Tim Andrews


2 Answers

Try this (assuming you are using Swift):

rootNode.enumerateChildNodes { (node, stop) in
        node.removeFromParentNode()
    }

Works for me.

like image 166
Alan Avatar answered Oct 11 '22 13:10

Alan


For me worked like below:

sceneView.scene.rootNode.enumerateChildNodes { (node, stop) in
node.removeFromParentNode() }
like image 23
Alessandro Mattiuzzi Avatar answered Oct 11 '22 13:10

Alessandro Mattiuzzi