Search code examples
swiftscenekitarkitusdz

SceneKit – Not rendering USDZ model


I have a valid .USDZ file format for a 3d model from the following link I would like to add to my SceneKit application in Xcode.

https://solarsystem.nasa.gov/resources/2392/earth-with-clouds-3d-model/

However, as seen in the following error:

Error Image

XCode is not rendering my .USDZ file format.

I am on a MAC VM - Montery OS 12.6.1 using VMWare. Everything is valid in terms of trust with apple servers and for other apps I can run them on my iPhone. Also, I have Python 3.7 as well as USDCONVERTER installed on my VM. However, I also have Reality Converter installed and whenever I run the application it says "Reality Converter quit unexpectedly."

Likewise, in Xcode when I click on the Earth.usdz file nothing renders and again I get the "Not Applicable" in the side bar.

I have no idea why this is occuring and would like to know why I am unable to render these objects in XCode. Any help is greatly appreciated. Thank you!


Solution

  • Your .usdz scene may be damaged or corrupted. But somehow it's rendered SOMETIMES. There's also a problem with its scale: the sphere is bigger 1000 times (i.e. its local size is 1000 meters).

    import SceneKit
    
    class GameViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            
            let sceneView = self.view as! SCNView
            sceneView.autoenablesDefaultLighting = true
            sceneView.allowsCameraControl = true
            sceneView.backgroundColor = .black
            let scene = SCNScene(named: "art.scnassets/Earth.usdz")!
            sceneView.scene = scene
    
            if let earth = scene.rootNode.childNode(withName: "Cube_002", 
                                                 recursively: true) {
                earth.scale = SCNVector3(0.09, 0.09, 0.09)
            }
        }
    }
    

    Xcode 14.1 RC 2, macOS 13.0, iOS 16.1 simulator.

    enter image description here