Skip to content

Commit

Permalink
ignore loaded texture if entity was removed
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentfretin committed Sep 2, 2024
1 parent 8081e50 commit 7287d30
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/street-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7287d30

Please sign in to comment.