From 81d75b46b887fa4bc3478017728a5cdf2473a77f Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Fri, 10 Jan 2025 18:09:40 +0900 Subject: [PATCH] Fix #910 --- src/three/TilesRenderer.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/three/TilesRenderer.js b/src/three/TilesRenderer.js index 7962c468..4e1e0397 100644 --- a/src/three/TilesRenderer.js +++ b/src/three/TilesRenderer.js @@ -707,13 +707,6 @@ export class TilesRenderer extends TilesRendererBase { } ); - // exit early if a new request has already started - if ( abortSignal.aborted ) { - - return; - - } - // ensure the matrix is up to date in case the scene has a transform applied scene.updateMatrix(); scene.matrix.premultiply( cachedTransform ); @@ -725,6 +718,7 @@ export class TilesRenderer extends TilesRendererBase { } ); updateFrustumCulled( scene, ! this.autoDisableRendererCulling ); + // collect all original geometries, materials, etc to be disposed of later const materials = []; const geometry = []; const textures = []; @@ -756,6 +750,30 @@ export class TilesRenderer extends TilesRendererBase { } ); + // exit early if a new request has already started + if ( abortSignal.aborted ) { + + // dispose of any image bitmaps that have been opened. + // TODO: share this code with the "disposeTile" code below, possibly allow for the tiles + // renderer base to trigger a disposal of unneeded data + for ( let i = 0, l = textures.length; i < l; i ++ ) { + + const texture = textures[ i ]; + + if ( texture.image instanceof ImageBitmap ) { + + texture.image.close(); + + } + + texture.dispose(); + + } + + return; + + } + cached.materials = materials; cached.geometry = geometry; cached.textures = textures;