Reputation: 111
I'm loading a .usdz model (downloaded from Apple) into my ARSCNSceneView
which works. But unfortunately the model is always rendered without any texture and appears black.
// Get the url to the .usdz file
guard let usdzURL = Bundle.main.url(forResource: "toy_robot_vintage", withExtension: "usdz")
else {
return
}
// Load the SCNNode from file
let referenceNode = SCNReferenceNode(url: usdzURL)!
referenceNode.load()
// Add node to scene
sceneView.scene.rootNode.addChildNode(referenceNode)
Upvotes: 3
Views: 2978
Reputation: 58093
If you have already implemented lights in your 3D scene and these lights have necessary intensity level (default is 1000 lumens), that's Ok. If not, just use the following code for implementing an automatic lighting:
let sceneView = ARSCNView()
sceneView.autoenablesDefaultLighting = true
sceneView.automaticallyUpdatesLighting = true
But if you still don't see a shader of robot model:
Scene Inspector
just turn on Procedural Sky
value of Environment
property from drop-down menu.Upvotes: 1
Reputation: 19708
Your scene has no light, that's why the object is showing dark. Just add a directional light to your scene:
let spotLight = SCNNode()
spotLight.light = SCNLight()
spotLight.light?.type = .directional
sceneView.scene.rootNode.addChildNode(spotLight)
Upvotes: 5