Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //Set lighting
  2. let light = SCNLight()
  3. light.type = .ambient
  4. node.light = light
  5.  
  6. // if light estimation is enabled, update the intensity
  7. // of the model's lights and the environment map
  8. if let lightEstimate = self.session.currentFrame?.lightEstimate {
  9. self.enableEnvironmentMapWithIntensity(lightEstimate.ambientIntensity / 1000.0)
  10. } else {
  11. self.enableEnvironmentMapWithIntensity(6)
  12. }
  13.  
  14. // Call environment Map
  15. func enableEnvironmentMapWithIntensity(_ intensity: CGFloat) {
  16.  
  17. if sceneView.scene.lightingEnvironment.contents == nil {
  18. if let environmentMap = UIImage(named: "Models.scnassets/sharedImages/environment_blur.exr") {
  19. sceneView.scene.lightingEnvironment.contents = environmentMap
  20. }
  21. }
  22. sceneView.scene.lightingEnvironment.intensity = intensity
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement