Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Set lighting
- let light = SCNLight()
- light.type = .ambient
- node.light = light
- // if light estimation is enabled, update the intensity
- // of the model's lights and the environment map
- if let lightEstimate = self.session.currentFrame?.lightEstimate {
- self.enableEnvironmentMapWithIntensity(lightEstimate.ambientIntensity / 1000.0)
- } else {
- self.enableEnvironmentMapWithIntensity(6)
- }
- // Call environment Map
- func enableEnvironmentMapWithIntensity(_ intensity: CGFloat) {
- if sceneView.scene.lightingEnvironment.contents == nil {
- if let environmentMap = UIImage(named: "Models.scnassets/sharedImages/environment_blur.exr") {
- sceneView.scene.lightingEnvironment.contents = environmentMap
- }
- }
- sceneView.scene.lightingEnvironment.intensity = intensity
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement