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

RenderTarget: Fix copy of images. (#30570)

Michael Herzog 11 месяцев назад
Родитель
Сommit
2ab9aea318
2 измененных файлов с 6 добавлено и 5 удалено
  1. 4 4
      src/core/RenderTarget.js
  2. 2 1
      src/textures/DepthTexture.js

+ 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 - 1
src/textures/DepthTexture.js

@@ -1,5 +1,6 @@
 import { Texture } from './Texture.js';
 import { NearestFilter, UnsignedIntType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js';
+import { Source } from './Source.js';
 
 class DepthTexture extends Texture {
 
@@ -30,11 +31,11 @@ class DepthTexture extends Texture {
 
 	}
 
-
 	copy( source ) {
 
 		super.copy( source );
 
+		this.source = new Source( Object.assign( {}, source.image ) ); // see #30540
 		this.compareFunction = source.compareFunction;
 
 		return this;

粤ICP备19079148号