Просмотр исходного кода

RenderTarget: Fix copy of images. (#30585)

Michael Herzog 1 год назад
Родитель
Сommit
3bb6e70ca2

+ 5 - 1
docs/api/en/renderers/WebGLRenderTarget.html

@@ -133,7 +133,11 @@
 		<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>

+ 4 - 4
src/core/RenderTarget.js

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

+ 2 - 0
src/textures/DepthTexture.js

@@ -1,3 +1,4 @@
+import { Source } from './Source.js';
 import { Texture } from './Texture.js';
 import { NearestFilter, UnsignedIntType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js';
 
@@ -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;

粤ICP备19079148号