diff --git a/src/framework/components/element/component.js b/src/framework/components/element/component.js index 92ba4cd6bd8..f3b0cdac02b 100644 --- a/src/framework/components/element/component.js +++ b/src/framework/components/element/component.js @@ -2560,14 +2560,10 @@ class ElementComponent extends Component { this.system.app.elementInput.addElement(this); } - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this.onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this.onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this.onLayerRemoved, this); } diff --git a/src/framework/components/element/image-element.js b/src/framework/components/element/image-element.js index 69af6ed69ca..6a5e4c9c46b 100644 --- a/src/framework/components/element/image-element.js +++ b/src/framework/components/element/image-element.js @@ -797,7 +797,6 @@ class ImageElement { // Hook up event handlers on sprite asset _bindSprite(sprite) { - this._evtSetMeshes?.off(); this._evtSetMeshes = sprite.on('set:meshes', this._onSpriteMeshesChange, this); sprite.on('set:pixelsPerUnit', this._onSpritePpuChange, this); sprite.on('set:atlas', this._onAtlasTextureChange, this); diff --git a/src/framework/components/gsplat/component.js b/src/framework/components/gsplat/component.js index 463c3e77f6e..4cfbbb37f10 100644 --- a/src/framework/components/gsplat/component.js +++ b/src/framework/components/gsplat/component.js @@ -337,14 +337,10 @@ class GSplatComponent extends Component { const scene = this.system.app.scene; const layers = scene.layers; - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this.onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this.onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this.onLayerRemoved, this); } diff --git a/src/framework/components/light/component.js b/src/framework/components/light/component.js index 316abf97a20..1923d5ef8da 100644 --- a/src/framework/components/light/component.js +++ b/src/framework/components/light/component.js @@ -1247,14 +1247,10 @@ class LightComponent extends Component { this.light.enabled = true; - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this.onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this.onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this.onLayerRemoved, this); } diff --git a/src/framework/components/model/component.js b/src/framework/components/model/component.js index 20176188dfa..69a03bfcc04 100644 --- a/src/framework/components/model/component.js +++ b/src/framework/components/model/component.js @@ -953,14 +953,10 @@ class ModelComponent extends Component { const scene = app.scene; const layers = scene?.layers; - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this.onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this.onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this.onLayerRemoved, this); } diff --git a/src/framework/components/particle-system/component.js b/src/framework/components/particle-system/component.js index 670590a329b..b8b5748af3e 100644 --- a/src/framework/components/particle-system/component.js +++ b/src/framework/components/particle-system/component.js @@ -1974,14 +1974,10 @@ class ParticleSystemComponent extends Component { this.addMeshInstanceToLayers(); } - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this.onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this.onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this.onLayerRemoved, this); } diff --git a/src/framework/components/render/component.js b/src/framework/components/render/component.js index e4f2f457394..d0b47aca093 100644 --- a/src/framework/components/render/component.js +++ b/src/framework/components/render/component.js @@ -818,14 +818,10 @@ class RenderComponent extends Component { this._cloneSkinInstances(); - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this.onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this.onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this.onLayerRemoved, this); } diff --git a/src/framework/components/sprite/component.js b/src/framework/components/sprite/component.js index d15ab9cf8e8..24e0bb8743e 100644 --- a/src/framework/components/sprite/component.js +++ b/src/framework/components/sprite/component.js @@ -677,14 +677,10 @@ class SpriteComponent extends Component { const scene = app.scene; const layers = scene.layers; - this._evtLayersChanged?.off(); this._evtLayersChanged = scene.on('set:layers', this._onLayersChanged, this); if (layers) { - this._evtLayerAdded?.off(); this._evtLayerAdded = layers.on('add', this._onLayerAdded, this); - - this._evtLayerRemoved?.off(); this._evtLayerRemoved = layers.on('remove', this._onLayerRemoved, this); }