Skip to content

Commit 783d2ac

Browse files
Mugen87RuthySheffi
authored andcommitted
Examples: Call ImageBitmap.close() in webgl_loader_imagebitmap. (mrdoob#30977)
1 parent e5ee3a4 commit 783d2ac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

examples/webgl_loader_imagebitmap.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@
3838
texture.colorSpace = THREE.SRGBColorSpace;
3939
const material = new THREE.MeshBasicMaterial( { map: texture } );
4040

41-
/* ImageBitmap should be disposed when done with it
42-
Can't be done until it's actually uploaded to WebGLTexture */
41+
// ImageBitmap should be disposed when done with it.
4342

44-
// imageBitmap.close();
43+
texture.onUpdate = disposeImageBitmap;
4544

4645
addCube( material );
4746

@@ -148,6 +147,13 @@
148147

149148
}
150149

150+
function disposeImageBitmap( texture ) {
151+
152+
texture.source.data.close();
153+
texture.onUpdate = null; // make sure this callback is executed only once per texture
154+
155+
}
156+
151157
</script>
152158

153159
</body>

0 commit comments

Comments
 (0)