Skip to content

Commit

Permalink
fix light change type
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksims Mihejevs committed Jul 30, 2015
1 parent 5c66bb7 commit 9decc7c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/framework/components/light/light_system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
});

Expand Down

0 comments on commit 9decc7c

Please sign in to comment.