Three.js shares the images between multiple textures. I have a case where I want to “deep” copy a texture by storing a new image even if it’s the same.
What I’m trying to do is have a list of “screenshots” in an array so I can use the keyboard keys to go through them to spot rendering issues.
I’ve been fighting with this code below but no luck so far.
renderer.render( finalScene, camera );
var dataURL = renderer.domElement.toDataURL();
// var img = new Image();
// img.src = dataURL;
// document.body.appendChild(img); // Is this needed?
var rtTexture2 = textureLoader.load(dataURL);
rtTexture2.needsUpdate = true;
rtTextures.push(rtTexture2);
As it stands the array gets filled with new textures but they all reference the same image which gets stomped every time a new frame is rendered.