How do I extract the image from an ImageBitmap in Threejs when there is no src and texture size is large?

80 Views Asked by At

I am trying to get image from ImageBitmap of a loaded model but since ImageBitmap (child.material.map.image) does not have src, I am using canvas.toDataURL().

small size images are getting painted fine without any problem but a 4mb texture is not loading completely.

Since child.material.map does not have src, I am not able to use image.onload.

const c = document.createElement('canvas');
c.width = child.material.map.image.width;
c.height = child.material.map.image.height;
const ctx = c.getContext('2d');

ctx.drawImage(child.material.map.image, 0, 0, child.material.map.image.width, child.material.map.image.height, 0, 0, c.width, c.height);
console.log(c.toDataURL());

I have load a model with GLTFLoader. The model has some textures. I am trying to load original texture if user wants to reset the changes.

0

There are 0 best solutions below