Arkit - Getting "Unexpectedly Found Nil" When Using Scn File > 300 Mb

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.

SceneKit – Fatal Error: unexpectedly found nil while unwrapping an Optional value when getting child node

You probably don't have a node named pyramid in your DAE file, so the childNodeWithName is returning nil, and since you're force-unwrapping that return value you crash.

You can look at that file in Xcode and examine node names there to make sure you have the name right.

Also, you might consider restructuring your code to report meaningful errors when your find a nil you aren't expecting:

if let pyramid = scene.rootNode.childNodeWithName(...) {
...
} else {
fatalError("missing pyramid mode in scene file")
}

[Swift]nil when loading scn files downloaded in runtime

Where is your download code? You shouldn't attempt to load the file until the completion handler is called. In any case you can check the file size with FileManager.default.attributesOfItem(atPath: ) and see if that matches what you expect.

EDIT:
Your problem is you call self.Modelscene = SCNScene(named: "max.scn", inDirectory: ls) right after downloadTask.resume(). That means you are opening the scene when the download has just started, not after it has finished. You need to put the scene assignment inside the completion handler so it happens when the download is complete.

Converted OBJ to SCN and now the object won't load

Model I/O does not support opening SceneKit files (see file formats supported by the Model I/O).

Instead you should use SceneKit's +[SCNScene sceneNamed:] or +sceneWithURL:options:error:.

ARKit and .dae file , strange space between object

Make your floor plane of type "concavePolyhedron" like so:

let body = SCNPhysicsBody(type: .static, shape: SCNPhysicsShape(geometry: yourGeometry, options: [SCNPhysicsShape.Option.type: SCNPhysicsShape.ShapeType.concavePolyhedron]))


Related Topics



Leave a reply



Submit