矩形光帮助器设置。

This commit is contained in:
tengge1 2019-03-16 10:59:34 +08:00
parent 430cbc0395
commit 1d06cd2c1f

View File

@ -18,12 +18,14 @@ RectAreaLightHelpers.prototype.start = function () {
this.app.on(`objectAdded.${this.id}`, this.onObjectAdded.bind(this));
this.app.on(`objectRemoved.${this.id}`, this.onObjectRemoved.bind(this));
this.app.on(`objectChanged.${this.id}`, this.onObjectChanged.bind(this));
this.app.on(`storageChanged.${this.id}`, this.onStorageChanged.bind(this));
};
RectAreaLightHelpers.prototype.stop = function () {
this.app.on(`objectAdded.${this.id}`, null);
this.app.on(`objectRemoved.${this.id}`, null);
this.app.on(`objectChanged.${this.id}`, null);
this.app.on(`storageChanged.${this.id}`, null);
};
RectAreaLightHelpers.prototype.onObjectAdded = function (object) {
@ -33,6 +35,8 @@ RectAreaLightHelpers.prototype.onObjectAdded = function (object) {
var helper = new VolumeRectAreaLightHelper(object, 0xffffff);
helper.visible = this.app.storage.get('showRectAreaLight');
this.helpers.push(helper);
this.app.editor.sceneHelpers.add(helper);
@ -74,4 +78,14 @@ RectAreaLightHelpers.prototype.onObjectChanged = function (object) {
this.helpers[index].update();
};
RectAreaLightHelpers.prototype.onStorageChanged = function (key, value) {
if (key !== 'showRectAreaLight') {
return;
}
this.helpers.forEach(n => {
n.visible = value;
});
};
export default RectAreaLightHelpers;