diff --git a/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js b/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js index 4cd76328..5fd5d3b4 100644 --- a/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js +++ b/ShadowEditor.Web/src/helper/light/RectAreaLightHelpers.js @@ -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; \ No newline at end of file