repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 44cc52f9386f0160ba24f8ff89307996228f8593:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 44cc52f9386f0160ba24f8ff89307996228f8593
Author: James Baicoianu 
Date:   Thu Apr 5 03:15:36 2018 -0700

    Handle missing light object

diff --git a/scripts/januslight.js b/scripts/januslight.js
index 46359e505d0095bfe90c4204706f83bc16fea59a..
index ..15b9aeb0baef4af2cd9fab460e178f3b43a27a0c 100644
--- a/scripts/januslight.js
+++ b/scripts/januslight.js
@@ -45,16 +45,27 @@ elation.require(['janusweb.janusbase'], function() {
       this.localToWorld(this.light.target.position.set(0,0,-1));
       this.light.target.updateMatrixWorld();
     }
+    this.update = function() {
+      if (!this.light) {
+        this.createLight();
+        this.updateLight();
+      }
+      if (this.light && !this.light.parent) {
+        this.objects['3d'].add(this.light);
+      }
+    }
     this.createLight = function() {
-      if (this.light_directional) {
-        this.light = new THREE.DirectionalLight(this.properties.color, this.light_intensity);
-      } else if (this.light_cone_angle == 0) {
-        this.light = new THREE.PointLight(this.properties.color, 1, this.light_range);
-        this.light.position.set(0,0,0);
-      } else if (this.light_cone_angle > 0) {
-        var angle = Math.acos(this.light_cone_angle);
-        this.light = new THREE.SpotLight(this.properties.color, 1, this.light_range, angle);
-        //this.light.position.set(0,0,0);
+      if (!this.light) {
+        if (this.light_directional) {
+          this.light = new THREE.DirectionalLight(this.properties.color, this.light_intensity);
+        } else if (this.light_cone_angle == 0) {
+          this.light = new THREE.PointLight(this.properties.color, 1, this.light_range);
+          this.light.position.set(0,0,0);
+        } else if (this.light_cone_angle > 0) {
+          var angle = Math.acos(this.light_cone_angle);
+          this.light = new THREE.SpotLight(this.properties.color, 1, this.light_range, angle);
+          //this.light.position.set(0,0,0);
+        }
       }
     }
     this.updateLight = function() {

-----END OF PAGE-----