Xcode9/Scenekit - .Dae File Not Loading into Scnscene - Returns Nil

xcode9 / SceneKit - .dae file not loading into SCNScene - returns nil

In case somebody runs into a similar newbie problem, the issue gets resolved by adding the .scnassets folder into "Copy Bundle Resources" under Build Phases of the project - cleaning the project might be required in some cases before you rebuild again. This solved my issue.

Not able to load .dae file while creating a SCNScene object in ARKit

It seems that the problem was with the .dae file's size/orientation. I rotated it by 90 degrees and scaled the image down and it seems to work now.

ARKit – Getting Unexpectedly found nil when using SCN file 300 MB

When load a 3D model with 1.5M polygons into SceneKit/ARKit, into RealityKit, or into AR Quick Look you'll always fail. That's because a robust number of polygons per 3D model must be not greater that 10K (with UV-texture having max resolution 2Kx2K, or with a regular texture rez 1Kx1K), and a maximum number of polygons per 3D scene must be not greater that 100K. You have exceeded the "unspoken" AR limit in 15 times.

Game engines and AR frameworks, like SceneKit, RealityKit and AR Quick Look, are incapable of rendering such a huge number of polygons using 60 fps framerate on iOS device (even most desktop computers fail to do this). The best solution for an ARKit/RealityKit applications is to use an optimized low-poly models. The most preferred format for working with AR on mobile platform is Pixar USDZ. A USDZ file is a no compression, unencrypted zip archive of USD file.

Look at this low-poly model from Turbosquid. It has just 5K polygons and it looks fine, doesn't it?

Sample Image

P.S.

You can convert obj, fbx or abc in usdz using command line tools. Read about it HERE.

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

// add a SCNScene as childNode to another SCNScene (in this case to scene)
func addSceneToScene() {
let geoScene = SCNScene(named: "art.scnassets/ball.dae")
scene.rootNode.addChildNode(geoScene.rootNode.childNodeWithName("Ball", recursively: true))
}
addSceneToScene()

Swift 3 load .dae file into SCNNode

A .dae file is always loaded as a SCNScene. You need to name the node containing the geometry you want to add.
Than you can load the scene, filter it for the node with the given name and add it to your scene.

func addNode(named nodeName, fromSceneNamed: sceneName, to scene: SCNScene) {
if let loadedScene = SCNScene(named: sceneName),
let node = loadedScene.rootNode.childNode(withName: nodeName, recursivly: true) {
scene.rootNode.addChildNode(node)
}
}


Related Topics



Leave a reply



Submit