Skip to content
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

Merged
merged 2 commits into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/renderers/WebGLRenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

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.

Copy link
Collaborator

@Mugen87 Mugen87 Jan 14, 2022

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
};

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator Author

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


this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;
Expand Down