diff --git a/examples/webgl_loader_imagebitmap.html b/examples/webgl_loader_imagebitmap.html index 8e59fdf9dc100f..9cd7493a6025b9 100644 --- a/examples/webgl_loader_imagebitmap.html +++ b/examples/webgl_loader_imagebitmap.html @@ -38,10 +38,9 @@ texture.colorSpace = THREE.SRGBColorSpace; const material = new THREE.MeshBasicMaterial( { map: texture } ); - /* ImageBitmap should be disposed when done with it - Can't be done until it's actually uploaded to WebGLTexture */ + // ImageBitmap should be disposed when done with it. - // imageBitmap.close(); + texture.onUpdate = disposeImageBitmap; addCube( material ); @@ -148,6 +147,13 @@ } + function disposeImageBitmap( texture ) { + + texture.source.data.close(); + texture.onUpdate = null; // make sure this callback is executed only once per texture + + } +