Search code examples
iosswiftscenekitscene

SceneKit – Display multiple scenes in same SCNView


Is there a way I can display multiple scenes in the same SCNView at the same time? So let's say I have a ball in ball.dae and a pyramid in pyramid.dae. So these are separate scenes and I would like to show both at the same time.

Currently I only have one and I create it like this:

let scene = SCNScene(named: "world1.dae")!

If I just create another one below then it just displays the second one... :/

Thanks in advance!


Solution

  • Ok I already figured it out. The thing is to not add another scene but nodes from the 2nd scene to the first like this:

    let scene = SCNScene(named: "world1.dae")!
    let subScene = SCNScene(named: "pyramid.dae")!
    
    let pyramid = subScene.rootNode.childNodeWithName("pyramid", recursively: true)!
    
    scene.rootNode.addChildNode(pyramid)