0

I am loading a 3D model using SCNScene in SwiftUI, my object looks better in lambert or phong shading. I am trying to change the lighting model like this:

var scene: SCNScene? {
        let scene = SCNScene(named: "model.usdz")
        scene?.rootNode.geometry?.firstMaterial?.lightingModel = .lambert
        scene?.rootNode.scale = SCNVector3(scale, scale, scale)
        return scene
    }

and then load the scene in body:

var body: some View {
    
            SceneView(
                scene: scene,
                pointOfView: cameraNode,
                options: [.allowsCameraControl, .autoenablesDefaultLighting]
            )
}

but changing the lighting model doesn't affect the model, or even tried manually in the scene kit editor but still no luck, any solution would be great.

enter image description here

Asperi
  • 228,894
  • 20
  • 464
  • 690
Mc.Lover
  • 4,813
  • 9
  • 46
  • 80

1 Answers1

0

Your code, as far as I can see, changes the Lighting Model of the RootNode (this changes nothing, because the rootnode itself stays invisible). To Change the Lighting Model of your T-Rex-Scull Model, you must fetch the exact Node containing the geometry of that Model, which is usually a childNode or a child of a childNode. This should work then.

ZAY
  • 3,882
  • 2
  • 13
  • 21