load a collada (dae) file into SCNNode (Swift - SceneKit)

后端 未结 4 1553
暖寄归人
暖寄归人 2021-01-05 04:47

This works

let scene = SCNScene(named: \"house.dae\")

Is there an equivalent for a node?

let node = SCNNode(geometry: SCNGe         


        
4条回答
  •  迷失自我
    2021-01-05 05:40

    That's what I use in real project:

    extension SCNNode {
    
        convenience init(named name: String) {
            self.init()
    
            guard let scene = SCNScene(named: name) else {
                return
            }
    
            for childNode in scene.rootNode.childNodes {
                addChildNode(childNode)
            }
        }
    
    }
    

    After that you can call:

    let node = SCNNode(named: "art.scnassets/house.dae")
    

提交回复
热议问题