3

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)

enter image description here

Lukas Würzburger
  • 6,543
  • 7
  • 41
  • 75
Pikebu
  • 101
  • 2
  • 6

2 Answers2

4

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)
M Reza
  • 18,350
  • 14
  • 66
  • 71
1

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:

  • in Xcode in the Scene Inspector just turn on Procedural Sky value of Environment property from drop-down menu.

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220