-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebGLRenderTarget: clone texture image data when cloning render target #21719
Conversation
What about #20328 (comment)? Well, cloning data textures and changing the size is probably no common operation (compared to render targets where the resize can happen in context of post-processing). |
While that case can be confusing right now the biggest issue is that when the image data is updated the cloned texture isn't automatically updated. I've thought about how to solve it but given that In the case of |
Thanks! |
@@ -89,6 +89,7 @@ class WebGLRenderTarget extends EventDispatcher { | |||
this.viewport.copy( source.viewport ); | |||
|
|||
this.texture = source.texture.clone(); | |||
this.texture.image = { ...this.texture.image }; // See #20328. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be:
this.texture.image = { ...source.texture.image }; // See #20328.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better like so to avoid #22618:
this.texture.image = {
width: source.texture.image.width,
height: source.texture.image.height,
depth: source.texture.image.depth
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.texture.image = { ...source.texture.image }; // See #20328.
This is the same as { ...this.texture.image }
since after source.texture.clone()
the source
values are the same object between the two instances.
I don't have an issue with changing it since it's the only location in core that's using spread. Though there are quite a few others it looks like in the examples files.
@Mugen87 suggestion looks good but Object.assign( {}, this.texture.image )
would work, as well
Related issue: #20328
Description
Clone the
WebGLRenderTarget.texture
image data object when cloning the render target. If it's not cloned then modifying the cloned render target will modify the original render targets image object causing it to be out of sync. See this case:This shouldn't be a breaking change because I can't see how you'd be relying on this behavior.