|
|
@@ -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
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
</body>
|