Skip to content

Commit 3bb6e70

Browse files
authored
RenderTarget: Fix copy of images. (#30585)
1 parent 498be07 commit 3bb6e70

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

docs/api/en/renderers/WebGLRenderTarget.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ <h3>[method:WebGLRenderTarget clone]()</h3>
133133
<p>Creates a copy of this render target.</p>
134134

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

138142
<h3>[method:undefined dispose]()</h3>
139143
<p>

src/core/RenderTarget.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ class RenderTarget extends EventDispatcher {
148148
this.textures[ i ].isRenderTargetTexture = true;
149149
this.textures[ i ].renderTarget = this;
150150

151-
}
151+
// ensure image object is not shared, see #20328
152152

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

155-
const image = Object.assign( {}, source.texture.image );
156-
this.texture.source = new Source( image );
156+
}
157157

158158
this.depthBuffer = source.depthBuffer;
159159
this.stencilBuffer = source.stencilBuffer;

src/textures/DepthTexture.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Source } from './Source.js';
12
import { Texture } from './Texture.js';
23
import { NearestFilter, UnsignedIntType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js';
34

@@ -35,6 +36,7 @@ class DepthTexture extends Texture {
3536

3637
super.copy( source );
3738

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

4042
return this;

0 commit comments

Comments
 (0)