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


i having trouble understanding how geometry .dae files should loaded ios scenekit scene graph.

i know can load .dae files directly scnscene:

// create new scene let scene = scnscene("test.scnassets/test.dae") 

i know can create empty scnscene , add built-in 3d objects child nodes:

let scene = scnscene() var spherenode = scnnode() spherenode.geometry = scnsphere(radius: 1.0) scene.rootnode.addchildnode(spherenode) 

in second case, can load .dae file scnnode instead of using built in objects? or expected .dae files need loaded scnscene first?

if latter true, how place scnnode objects right place in scene graph hierarchy under scnscene?edit #1:

this working me now, modified version of @flippinfun suggested.

let url = nsbundle.mainbundle().urlforresource("test.scnassets/test", withextension: "dae") let source = scnscenesource(url: url, options: nil) let block = source.entrywithidentifier("id10", withclass: scngeometry.self) scngeometry scene.rootnode.addchildnode(scnnode(geometry: block)) 

but perhaps there's better way? above involves manually loading each identifier .dae tree. in file, there's node "sketchup" child identifiers "id2" , "id10". method not let load root "sketchup". (i runtime error.)

the usual pattern load scene , retrieve node interested in name using

[scene.rootnode childnodewithname:aname recursively:yes];

then reparent node main scene.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -