How can I get a base64 string from a texture? I can load the texture and access it’s resources but Im getting lost after it
Thanks in advance
Yohami
How can I get a base64 string from a texture? I can load the texture and access it’s resources but Im getting lost after it
Thanks in advance
Yohami
Thanks, solved. Leaving it here for reference
var myTexture = image.resources[0];
var canvas = document.createElement( 'canvas' );
var ctx = canvas.getContext( '2d' );
canvas.width = myTexture._width;
canvas.height = myTexture._height;
var img = new Image();
img.src = myTexture.getSource().src;
img.setAttribute( 'crossOrigin', 'anonymous' );
ctx.drawImage( img, 0, 0 );
var base64 = canvas.toDataURL( "image/png" );
log("BASE 64", base64 );