-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Labels
Description
Here's a snippet to reproduce the issue:
const x = new THREE.WebGLRenderTarget();
const y = new THREE.WebGLRenderTarget();
console.log( x.texture.image === y.texture.image ); // false
x.copy( y );
console.log( x.texture.image === y.texture.image ); // trueWhat this means is that when x.setSize is called the object at y.texture.image is inadvertently modified but and is now out of sync with the true dimensions of render target y.
This line is the problem in Texture.copy:
this.image = source.image;I assume this was originally intended to handle moving over an <img> tag without duplicating it -- maybe it makes sense to duplicate the image tag? Or maybe it should clone the object in some cases:
this.image = source.image instanceof Image ? source.image : { ...source.image };I imagine copy would behave a bit confusingly for DataTexture, as well.
Edit: I see now that retaining the image data reference is important for dealing with cloning textures before they've been fully loaded and is valuable for minimizing data duplication.