From 9decc7cac11a95c98ed352d7bb18b4eebb59cfd1 Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Thu, 30 Jul 2015 18:15:07 +0100 Subject: [PATCH 1/3] fix light change type --- src/framework/components/light/light_system.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/framework/components/light/light_system.js b/src/framework/components/light/light_system.js index 0acbbd06776..ba44b1af71b 100644 --- a/src/framework/components/light/light_system.js +++ b/src/framework/components/light/light_system.js @@ -72,6 +72,7 @@ pc.extend(pc, function () { var light = new pc.Light(); light.setType(lightTypes[data.type]); light._node = component.entity; + light._scene = this.app.scene; this.app.scene.addLight(light); component.data.light = light; @@ -107,7 +108,17 @@ pc.extend(pc, function () { }, changeType: function (component, oldValue, newValue) { - component.light.setType(lightTypes[newValue]); + // remove old light + this.app.scene.removeLight(component.light); + // create new light + var light = new pc.Light(); + light.setType(lightTypes[newValue]); + light._node = component.entity; + // add to scene + this.app.scene.addLight(light); + // add to component + component.light = light; + component.data.light = light; } }); From 57e5dd7e8d5fbce1d61bb6b3709233ecff0bb57a Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Thu, 30 Jul 2015 18:16:35 +0100 Subject: [PATCH 2/3] fix light change type --- src/framework/components/light/light_system.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/framework/components/light/light_system.js b/src/framework/components/light/light_system.js index ba44b1af71b..0a87ca1f5ec 100644 --- a/src/framework/components/light/light_system.js +++ b/src/framework/components/light/light_system.js @@ -126,5 +126,3 @@ pc.extend(pc, function () { LightComponentSystem: LightComponentSystem }; }()); - - From 56b1dd99cf4e410ceb4a9e147370324c5fe152cc Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Thu, 30 Jul 2015 18:18:33 +0100 Subject: [PATCH 3/3] remove unnecessary _scene definition --- src/framework/components/light/light_system.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/framework/components/light/light_system.js b/src/framework/components/light/light_system.js index 0a87ca1f5ec..e25f25c822d 100644 --- a/src/framework/components/light/light_system.js +++ b/src/framework/components/light/light_system.js @@ -72,7 +72,6 @@ pc.extend(pc, function () { var light = new pc.Light(); light.setType(lightTypes[data.type]); light._node = component.entity; - light._scene = this.app.scene; this.app.scene.addLight(light); component.data.light = light;