How do you load a .dae file into an SCNNode in iOS SceneKit?

前端 未结 6 1177
你的背包
你的背包 2021-01-31 10:14

I am having trouble understanding how geometry from .dae files should be loaded into an iOS SceneKit scene graph.

I know that you can load .dae

6条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 10:50

    I had a similar problem where I had one .dae file and I wanted to load multiple nodes from that file into a node. This worked for me:

    var node = SCNNode()
    let scene = SCNScene(named: "helloScene.dae")
    var nodeArray = scene.rootNode.childNodes
    
    for childNode in nodeArray {
      node.addChildNode(childNode as SCNNode)
    }
    

    First, I set a node that will hold it all together so it looks like it does in the original file. Next we import the .dae file we want and copy all the nodes inside of it. Lastly, for each node in the array I added it to the node.

提交回复
热议问题