From 7287d304edf64ba073926e977c6788236833bed3 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Mon, 2 Sep 2024 11:17:02 +0200 Subject: [PATCH] ignore loaded texture if entity was removed --- src/components/street-environment.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/street-environment.js b/src/components/street-environment.js index 349b8bdd..904ae7a6 100644 --- a/src/components/street-environment.js +++ b/src/components/street-environment.js @@ -108,7 +108,11 @@ AFRAME.registerComponent('street-environment', { const scene = this.el.sceneEl.object3D; this.textureLoader.load(imagePath, (texture) => { // If we changed to color preset in the meantime or we switched to an other image, ignore this texture - if (this.data.preset === 'color' || imagePath !== this.backgroundImage) { + if ( + this.data.preset === 'color' || + imagePath !== this.backgroundImage || + this.el.parentNode === null + ) { texture.dispose(); } else { if (scene.background?.isTexture) {