diff --git a/examples/interactivity/index.html b/examples/interactivity/index.html index 4b5c53ff..74303e6a 100644 --- a/examples/interactivity/index.html +++ b/examples/interactivity/index.html @@ -176,7 +176,6 @@

Food scans by Tipatat; + if (dyno instanceof DynoUniform) { + const texture = dyno.value; + if (texture?.isTexture) { + texture.dispose(); + texture.source.data = null; + } + } + } + this.extra = {}; } // Ensures that this.packedArray can fit numSplats Gsplats. If it's too small, @@ -432,7 +454,9 @@ export class PackedSplats { if (this.target && (maxSplats ?? 1) <= this.maxSplats) { return false; } - this.dispose(); + if (this.target) { + this.target.dispose(); + } const textureSize = getTextureSize(maxSplats ?? 1); const { width, height, depth } = textureSize; @@ -687,7 +711,7 @@ export class PackedSplats { static programTemplate: DynoProgramTemplate | null = null; // Cache for GsplatGenerator programs - static generatorProgram = new Map(); + static generatorProgram = new WeakMap(); // Static full-screen quad for pseudo-compute shader rendering static fullScreenQuad = new FullScreenQuad( diff --git a/src/dyno/program.ts b/src/dyno/program.ts index 97c2897f..6023a4ce 100644 --- a/src/dyno/program.ts +++ b/src/dyno/program.ts @@ -98,7 +98,7 @@ export class DynoProgramTemplate { } } -const programMaterial = new Map(); +const programMaterial = new WeakMap(); function getMaterial(program: DynoProgram): THREE.RawShaderMaterial { let material = programMaterial.get(program);