Jelajahi Sumber

WebGLCubeRenderTarget: Use CubeTexture.image. (#23433)

Michael Herzog 3 tahun lalu
induk
melakukan
9f78f5e220

+ 0 - 2
examples/webgl_materials_cubemap_dynamic.html

@@ -76,12 +76,10 @@
 				const envSize = 64; // minimum size for roughness >= 0.1
 
 				cubeRenderTarget1 = new THREE.WebGLCubeRenderTarget( envSize );
-				cubeRenderTarget1.texture.image[0] = {width: envSize, height: envSize};
 
 				cubeCamera1 = new THREE.CubeCamera( 1, 1000, cubeRenderTarget1 );
 
 				cubeRenderTarget2 = new THREE.WebGLCubeRenderTarget( envSize );
-				cubeRenderTarget2.texture.image[0] = {width: envSize, height: envSize};
 
 				cubeCamera2 = new THREE.CubeCamera( 1, 1000, cubeRenderTarget2 );
 

+ 4 - 1
src/renderers/WebGLCubeRenderTarget.js

@@ -31,7 +31,10 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
 		// and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture
 		// as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures).
 
-		this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+		const image = { width: size, height: size, depth: 1 };
+		const images = [ image, image, image, image, image, image ];
+
+		this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 		this.texture.isRenderTargetTexture = true;
 
 		this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;

+ 3 - 3
src/renderers/WebGLRenderTarget.js

@@ -23,10 +23,10 @@ class WebGLRenderTarget extends EventDispatcher {
 
 		this.viewport = new Vector4( 0, 0, width, height );
 
-		this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
-		this.texture.isRenderTargetTexture = true;
+		const image = { width: width, height: height, depth: 1 };
 
-		this.texture.image = { width: width, height: height, depth: 1 };
+		this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+		this.texture.isRenderTargetTexture = true;
 
 		this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
 		this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;