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

RenderTarget: Fix copy of images. #30585

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion docs/api/en/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ <h3>[method:WebGLRenderTarget clone]()</h3>
<p>Creates a copy of this render target.</p>

<h3>[method:this copy]( [param:WebGLRenderTarget source] )</h3>
<p>Adopts the settings of the given render target.</p>
<p>
Adopts the settings of the given render target. This is a structural copy so
no resources are shared between render targets after the copy. That includes
all MRT textures and the depth texture.
</p>

<h3>[method:undefined dispose]()</h3>
<p>
Expand Down
8 changes: 4 additions & 4 deletions src/core/RenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ class RenderTarget extends EventDispatcher {
this.textures[ i ].isRenderTargetTexture = true;
this.textures[ i ].renderTarget = this;

}
// ensure image object is not shared, see #20328

// ensure image object is not shared, see #20328
const image = Object.assign( {}, source.textures[ i ].image );
this.textures[ i ].source = new Source( image );

const image = Object.assign( {}, source.texture.image );
this.texture.source = new Source( image );
}

this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;
Expand Down
2 changes: 2 additions & 0 deletions src/textures/DepthTexture.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Source } from './Source.js';
import { Texture } from './Texture.js';
import { NearestFilter, UnsignedIntType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js';

Expand Down Expand Up @@ -35,6 +36,7 @@ class DepthTexture extends Texture {

super.copy( source );

this.source = new Source( Object.assign( {}, source.image ) ); // see #30540
this.compareFunction = source.compareFunction;

return this;
Expand Down
Loading