1
0
Эх сурвалжийг харах

WebGPURenderer: Array-Based RenderTarget Refactor (#30959)

* ShadowNode: Inherit camera.layers only if shadow.layers is not set

* Fix layers check

* invert condition

* restore after render

* move array creation to module scope

* WebGPURenderer: Refactor Texture Arrays

* fix conflicts

* cleanup and fix multiview

* revert webgpu pipeline utils

* Fix StorageTexture depth

* fix fbo setSize

* update build

* fix xrmanager depth missing arg

* bump build

* revert build
Renaud Rohlinger 10 сар өмнө
parent
commit
84b6feb783

+ 4 - 4
examples/jsm/helpers/TextureHelperGPU.js

@@ -51,7 +51,7 @@ class TextureHelper extends Mesh {
 
 
 			colorNode = texture3D( texture ).sample( uvw );
 			colorNode = texture3D( texture ).sample( uvw );
 
 
-		} else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
+		} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
 
 
 			colorNode = textureNode( texture ).sample( uvw.xy ).depth( uvw.z );
 			colorNode = textureNode( texture ).sample( uvw.xy ).depth( uvw.z );
 
 
@@ -100,7 +100,7 @@ function getImageCount( texture ) {
 
 
 		return 6;
 		return 6;
 
 
-	} else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
+	} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
 
 
 		return texture.image.depth;
 		return texture.image.depth;
 
 
@@ -122,7 +122,7 @@ function getAlpha( texture ) {
 
 
 		return 1;
 		return 1;
 
 
-	} else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
+	} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
 
 
 		return Math.max( 1 / texture.image.depth, 0.25 );
 		return Math.max( 1 / texture.image.depth, 0.25 );
 
 
@@ -192,7 +192,7 @@ function createSliceGeometry( texture, width, height, depth ) {
 			const v = texture.flipY ? uv.getY( j ) : 1 - uv.getY( j );
 			const v = texture.flipY ? uv.getY( j ) : 1 - uv.getY( j );
 			const w = sliceCount === 1
 			const w = sliceCount === 1
 				? 1
 				? 1
-				: texture.isDataArrayTexture || texture.isCompressedArrayTexture
+				: texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture
 					? i
 					? i
 					: i / ( sliceCount - 1 );
 					: i / ( sliceCount - 1 );
 
 

+ 3 - 3
examples/jsm/tsl/shadows/TileShadowNode.js

@@ -4,7 +4,7 @@ import {
 	ShadowBaseNode,
 	ShadowBaseNode,
 	Plane,
 	Plane,
 	Line3,
 	Line3,
-	DepthArrayTexture,
+	DepthTexture,
 	LessCompare,
 	LessCompare,
 	Vector2,
 	Vector2,
 	RedFormat,
 	RedFormat,
@@ -159,10 +159,10 @@ class TileShadowNode extends ShadowBaseNode {
 		// Clear existing lights/nodes if re-initializing
 		// Clear existing lights/nodes if re-initializing
 		this.disposeLightsAndNodes();
 		this.disposeLightsAndNodes();
 
 
-		const depthTexture = new DepthArrayTexture( shadowWidth, shadowHeight, tileCount );
+		const depthTexture = new DepthTexture( shadowWidth, shadowHeight, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, tileCount );
 		depthTexture.compareFunction = LessCompare;
 		depthTexture.compareFunction = LessCompare;
 		depthTexture.name = 'ShadowDepthArrayTexture';
 		depthTexture.name = 'ShadowDepthArrayTexture';
-		const shadowMap = builder.createRenderTargetArray( shadowWidth, shadowHeight, tileCount, { format: RedFormat } );
+		const shadowMap = builder.createRenderTarget( shadowWidth, shadowHeight, { format: RedFormat, depth: tileCount } );
 		shadowMap.depthTexture = depthTexture;
 		shadowMap.depthTexture = depthTexture;
 		shadowMap.texture.name = 'ShadowTexture';
 		shadowMap.texture.name = 'ShadowTexture';
 		this.shadowMap = shadowMap;
 		this.shadowMap = shadowMap;

+ 2 - 1
examples/webgpu_rendertarget_2d-array_3d.html

@@ -211,8 +211,9 @@
 						materialQuad.depthTest = false;
 						materialQuad.depthTest = false;
 						materialQuad.outputNode = vec4( texture( mapArray ).depth( uZCoord ).rgb, 1 );
 						materialQuad.outputNode = vec4( texture( mapArray ).depth( uZCoord ).rgb, 1 );
 
 
-						const fboArray = new THREE.RenderTargetArray( size.width, size.height, size.depth, {
+						const fboArray = new THREE.RenderTarget( size.width, size.height, {
 							depthBuffer: false,
 							depthBuffer: false,
+							depth: size.depth
 						} );
 						} );
 						fboArray.texture.name = 'RenderTargetArray';
 						fboArray.texture.name = 'RenderTargetArray';
 
 

+ 2 - 3
examples/webgpu_shadowmap_array.html

@@ -45,7 +45,7 @@
 			async function init() {
 			async function init() {
 
 
 				// Renderer setup
 				// Renderer setup
-				renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: false } );
+				renderer = new THREE.WebGPURenderer( { antialias: true } );
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setAnimationLoop( animate );
 				renderer.setAnimationLoop( animate );
@@ -87,8 +87,7 @@
 				// Set up the tile shadow mapping
 				// Set up the tile shadow mapping
 				const tsm = new TileShadowNode( dirLight, {
 				const tsm = new TileShadowNode( dirLight, {
 					tilesX: 2,
 					tilesX: 2,
-					tilesY: 2,
-					debug: true
+					tilesY: 2
 				} );
 				} );
 
 
 
 

+ 0 - 2
src/Three.Core.js

@@ -34,7 +34,6 @@ export { CompressedCubeTexture } from './textures/CompressedCubeTexture.js';
 export { CubeTexture } from './textures/CubeTexture.js';
 export { CubeTexture } from './textures/CubeTexture.js';
 export { CanvasTexture } from './textures/CanvasTexture.js';
 export { CanvasTexture } from './textures/CanvasTexture.js';
 export { DepthTexture } from './textures/DepthTexture.js';
 export { DepthTexture } from './textures/DepthTexture.js';
-export { DepthArrayTexture } from './textures/DepthArrayTexture.js';
 export { Texture } from './textures/Texture.js';
 export { Texture } from './textures/Texture.js';
 export * from './geometries/Geometries.js';
 export * from './geometries/Geometries.js';
 export * from './materials/Materials.js';
 export * from './materials/Materials.js';
@@ -89,7 +88,6 @@ export { AnimationClip } from './animation/AnimationClip.js';
 export { AnimationAction } from './animation/AnimationAction.js';
 export { AnimationAction } from './animation/AnimationAction.js';
 export { RenderTarget } from './core/RenderTarget.js';
 export { RenderTarget } from './core/RenderTarget.js';
 export { RenderTarget3D } from './core/RenderTarget3D.js';
 export { RenderTarget3D } from './core/RenderTarget3D.js';
-export { RenderTargetArray } from './core/RenderTargetArray.js';
 export { Uniform } from './core/Uniform.js';
 export { Uniform } from './core/Uniform.js';
 export { UniformsGroup } from './core/UniformsGroup.js';
 export { UniformsGroup } from './core/UniformsGroup.js';
 export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
 export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';

+ 24 - 16
src/core/RenderTarget.js

@@ -35,6 +35,7 @@ class RenderTarget extends EventDispatcher {
 	 * @property {?Texture} [depthTexture=null] - Reference to a depth texture.
 	 * @property {?Texture} [depthTexture=null] - Reference to a depth texture.
 	 * @property {number} [samples=0] - The MSAA samples count.
 	 * @property {number} [samples=0] - The MSAA samples count.
 	 * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.
 	 * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.
+	 * @property {number} [depth=1] - The texture depth.
 	 * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering.
 	 * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering.
 	 */
 	 */
 
 
@@ -49,6 +50,21 @@ class RenderTarget extends EventDispatcher {
 
 
 		super();
 		super();
 
 
+		options = Object.assign( {
+			generateMipmaps: false,
+			internalFormat: null,
+			minFilter: LinearFilter,
+			depthBuffer: true,
+			stencilBuffer: false,
+			resolveDepthBuffer: true,
+			resolveStencilBuffer: true,
+			depthTexture: null,
+			samples: 0,
+			count: 1,
+			depth: 1,
+			multiview: false
+		}, options );
+
 		/**
 		/**
 		 * This flag can be used for type testing.
 		 * This flag can be used for type testing.
 		 *
 		 *
@@ -80,7 +96,7 @@ class RenderTarget extends EventDispatcher {
 		 * @type {number}
 		 * @type {number}
 		 * @default 1
 		 * @default 1
 		 */
 		 */
-		this.depth = options.depth ? options.depth : 1;
+		this.depth = options.depth;
 
 
 		/**
 		/**
 		 * A rectangular area inside the render target's viewport. Fragments that are
 		 * A rectangular area inside the render target's viewport. Fragments that are
@@ -108,21 +124,7 @@ class RenderTarget extends EventDispatcher {
 		 */
 		 */
 		this.viewport = new Vector4( 0, 0, width, height );
 		this.viewport = new Vector4( 0, 0, width, height );
 
 
-		const image = { width: width, height: height, depth: this.depth };
-
-		options = Object.assign( {
-			generateMipmaps: false,
-			internalFormat: null,
-			minFilter: LinearFilter,
-			depthBuffer: true,
-			stencilBuffer: false,
-			resolveDepthBuffer: true,
-			resolveStencilBuffer: true,
-			depthTexture: null,
-			samples: 0,
-			count: 1,
-			multiview: false
-		}, options );
+		const image = { width: width, height: height, depth: options.depth };
 
 
 		const texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
 		const texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
 
 
@@ -263,6 +265,12 @@ class RenderTarget extends EventDispatcher {
 				this.textures[ i ].image.height = height;
 				this.textures[ i ].image.height = height;
 				this.textures[ i ].image.depth = depth;
 				this.textures[ i ].image.depth = depth;
 
 
+				if ( this.textures[ i ].image.depth > 1 ) {
+
+					this.textures[ i ].isArrayTexture = true;
+
+				}
+
 			}
 			}
 
 
 			this.dispose();
 			this.dispose();

+ 0 - 40
src/core/RenderTargetArray.js

@@ -1,40 +0,0 @@
-import { RenderTarget } from './RenderTarget.js';
-import { DataArrayTexture } from '../textures/DataArrayTexture.js';
-
-/**
- * Represents an array render target.
- *
- * @augments RenderTarget
- */
-class RenderTargetArray extends RenderTarget {
-
-	/**
-	 * Constructs a new 3D render target.
-	 *
-	 * @param {number} [width=1] - The width of the render target.
-	 * @param {number} [height=1] - The height of the render target.
-	 * @param {number} [depth=1] - The height of the render target.
-	 * @param {RenderTarget~Options} [options] - The configuration object.
-	 */
-	constructor( width = 1, height = 1, depth = 1, options = {} ) {
-
-		super( width, height, options );
-
-		this.isRenderTargetArray = true;
-
-		this.depth = depth;
-
-		/**
-		 * Overwritten with a different texture type.
-		 *
-		 * @type {DataArrayTexture}
-		 */
-		this.texture = new DataArrayTexture( null, width, height, depth );
-
-		this.texture.isRenderTargetTexture = true;
-
-	}
-
-}
-
-export { RenderTargetArray };

+ 13 - 2
src/nodes/accessors/StorageTextureNode.js

@@ -98,6 +98,8 @@ class StorageTextureNode extends TextureNode {
 		const properties = builder.getNodeProperties( this );
 		const properties = builder.getNodeProperties( this );
 		properties.storeNode = this.storeNode;
 		properties.storeNode = this.storeNode;
 
 
+		return properties;
+
 	}
 	}
 
 
 	/**
 	/**
@@ -181,18 +183,27 @@ class StorageTextureNode extends TextureNode {
 
 
 		const properties = builder.getNodeProperties( this );
 		const properties = builder.getNodeProperties( this );
 
 
-		const { uvNode, storeNode } = properties;
+		const { uvNode, storeNode, depthNode } = properties;
 
 
 		const textureProperty = super.generate( builder, 'property' );
 		const textureProperty = super.generate( builder, 'property' );
 		const uvSnippet = uvNode.build( builder, 'uvec2' );
 		const uvSnippet = uvNode.build( builder, 'uvec2' );
 		const storeSnippet = storeNode.build( builder, 'vec4' );
 		const storeSnippet = storeNode.build( builder, 'vec4' );
+		const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
 
 
-		const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, storeSnippet );
+		const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, depthSnippet, storeSnippet );
 
 
 		builder.addLineFlowCode( snippet, this );
 		builder.addLineFlowCode( snippet, this );
 
 
 	}
 	}
 
 
+	clone() {
+
+		const newNode = super.clone();
+		newNode.storeNode = this.storeNode;
+		return newNode;
+
+	}
+
 }
 }
 
 
 export default StorageTextureNode;
 export default StorageTextureNode;

+ 0 - 17
src/nodes/core/NodeBuilder.js

@@ -26,7 +26,6 @@ import BindGroup from '../../renderers/common/BindGroup.js';
 
 
 import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter } from '../../constants.js';
 import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter } from '../../constants.js';
 import { RenderTarget } from '../../core/RenderTarget.js';
 import { RenderTarget } from '../../core/RenderTarget.js';
-import { RenderTargetArray } from '../../core/RenderTargetArray.js';
 import { Color } from '../../math/Color.js';
 import { Color } from '../../math/Color.js';
 import { Vector2 } from '../../math/Vector2.js';
 import { Vector2 } from '../../math/Vector2.js';
 import { Vector3 } from '../../math/Vector3.js';
 import { Vector3 } from '../../math/Vector3.js';
@@ -458,22 +457,6 @@ class NodeBuilder {
 
 
 	}
 	}
 
 
-	/**
-	 * Factory method for creating an instance of {@link RenderTargetArray} with the given
-	 * dimensions and options.
-	 *
-	 * @param {number} width - The width of the render target.
-	 * @param {number} height - The height of the render target.
-	 * @param {number} depth - The depth of the render target.
-	 * @param {Object} options - The options of the render target.
-	 * @return {RenderTargetArray} The render target.
-	 */
-	createRenderTargetArray( width, height, depth, options ) {
-
-		return new RenderTargetArray( width, height, depth, options );
-
-	}
-
 	/**
 	/**
 	 * Factory method for creating an instance of {@link CubeRenderTarget} with the given
 	 * Factory method for creating an instance of {@link CubeRenderTarget} with the given
 	 * dimensions and options.
 	 * dimensions and options.

+ 4 - 4
src/nodes/lighting/ShadowFilterNode.js

@@ -24,7 +24,7 @@ export const BasicShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord
 
 
 	let basic = texture( depthTexture, shadowCoord.xy ).label( 't_basic' );
 	let basic = texture( depthTexture, shadowCoord.xy ).label( 't_basic' );
 
 
-	if ( depthTexture.isDepthArrayTexture ) {
+	if ( depthTexture.isArrayTexture ) {
 
 
 		basic = basic.depth( depthLayer );
 		basic = basic.depth( depthLayer );
 
 
@@ -50,7 +50,7 @@ export const PCFShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord,
 
 
 		let depth = texture( depthTexture, uv );
 		let depth = texture( depthTexture, uv );
 
 
-		if ( depthTexture.isDepthArrayTexture ) {
+		if ( depthTexture.isArrayTexture ) {
 
 
 			depth = depth.depth( depthLayer );
 			depth = depth.depth( depthLayer );
 
 
@@ -111,7 +111,7 @@ export const PCFSoftShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoo
 
 
 		let depth = texture( depthTexture, uv );
 		let depth = texture( depthTexture, uv );
 
 
-		if ( depthTexture.isDepthArrayTexture ) {
+		if ( depthTexture.isArrayTexture ) {
 
 
 			depth = depth.depth( depthLayer );
 			depth = depth.depth( depthLayer );
 
 
@@ -189,7 +189,7 @@ export const VSMShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord,
 
 
 	let distribution = texture( depthTexture ).sample( shadowCoord.xy );
 	let distribution = texture( depthTexture ).sample( shadowCoord.xy );
 
 
-	if ( depthTexture.isDepthArrayTexture || depthTexture.isDataArrayTexture ) {
+	if ( depthTexture.isArrayTexture ) {
 
 
 		distribution = distribution.depth( depthLayer );
 		distribution = distribution.depth( depthLayer );
 
 

+ 8 - 8
src/nodes/lighting/ShadowNode.js

@@ -110,7 +110,7 @@ const VSMPassVertical = /*@__PURE__*/ Fn( ( { samples, radius, size, shadowPass,
 
 
 		let depth = shadowPass.sample( add( screenCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( size ) );
 		let depth = shadowPass.sample( add( screenCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( size ) );
 
 
-		if ( shadowPass.value.isDepthArrayTexture || shadowPass.value.isDataArrayTexture ) {
+		if ( shadowPass.value.isArrayTexture ) {
 
 
 			depth = depth.depth( depthLayer );
 			depth = depth.depth( depthLayer );
 
 
@@ -156,7 +156,7 @@ const VSMPassHorizontal = /*@__PURE__*/ Fn( ( { samples, radius, size, shadowPas
 
 
 		let distribution = shadowPass.sample( add( screenCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( size ) );
 		let distribution = shadowPass.sample( add( screenCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( size ) );
 
 
-		if ( shadowPass.value.isDepthArrayTexture || shadowPass.value.isDataArrayTexture ) {
+		if ( shadowPass.value.isArrayTexture ) {
 
 
 			distribution = distribution.depth( depthLayer );
 			distribution = distribution.depth( depthLayer );
 
 
@@ -421,11 +421,11 @@ class ShadowNode extends ShadowBaseNode {
 
 
 			depthTexture.compareFunction = null; // VSM does not use textureSampleCompare()/texture2DCompare()
 			depthTexture.compareFunction = null; // VSM does not use textureSampleCompare()/texture2DCompare()
 
 
-			if ( shadowMap.isRenderTargetArray ) {
+			if ( shadowMap.depth > 1 ) {
 
 
 				if ( ! shadowMap._vsmShadowMapVertical ) {
 				if ( ! shadowMap._vsmShadowMapVertical ) {
 
 
-					shadowMap._vsmShadowMapVertical = builder.createRenderTargetArray( shadow.mapSize.width, shadow.mapSize.height, shadowMap.depth, { format: RGFormat, type: HalfFloatType, depthBuffer: false } );
+					shadowMap._vsmShadowMapVertical = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height, { format: RGFormat, type: HalfFloatType, depth: shadowMap.depth, depthBuffer: false } );
 					shadowMap._vsmShadowMapVertical.texture.name = 'VSMVertical';
 					shadowMap._vsmShadowMapVertical.texture.name = 'VSMVertical';
 
 
 				}
 				}
@@ -434,7 +434,7 @@ class ShadowNode extends ShadowBaseNode {
 
 
 				if ( ! shadowMap._vsmShadowMapHorizontal ) {
 				if ( ! shadowMap._vsmShadowMapHorizontal ) {
 
 
-					shadowMap._vsmShadowMapHorizontal = builder.createRenderTargetArray( shadow.mapSize.width, shadow.mapSize.height, shadowMap.depth, { format: RGFormat, type: HalfFloatType, depthBuffer: false } );
+					shadowMap._vsmShadowMapHorizontal = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height, { format: RGFormat, type: HalfFloatType, depth: shadowMap.depth, depthBuffer: false } );
 					shadowMap._vsmShadowMapHorizontal.texture.name = 'VSMHorizontal';
 					shadowMap._vsmShadowMapHorizontal.texture.name = 'VSMHorizontal';
 
 
 				}
 				}
@@ -451,7 +451,7 @@ class ShadowNode extends ShadowBaseNode {
 
 
 			let shadowPassVertical = texture( depthTexture );
 			let shadowPassVertical = texture( depthTexture );
 
 
-			if ( depthTexture.isDepthArrayTexture ) {
+			if ( depthTexture.isArrayTexture ) {
 
 
 				shadowPassVertical = shadowPassVertical.depth( this.depthLayer );
 				shadowPassVertical = shadowPassVertical.depth( this.depthLayer );
 
 
@@ -459,7 +459,7 @@ class ShadowNode extends ShadowBaseNode {
 
 
 			let shadowPassHorizontal = texture( this.vsmShadowMapVertical.texture );
 			let shadowPassHorizontal = texture( this.vsmShadowMapVertical.texture );
 
 
-			if ( depthTexture.isDepthArrayTexture ) {
+			if ( depthTexture.isArrayTexture ) {
 
 
 				shadowPassHorizontal = shadowPassHorizontal.depth( this.depthLayer );
 				shadowPassHorizontal = shadowPassHorizontal.depth( this.depthLayer );
 
 
@@ -503,7 +503,7 @@ class ShadowNode extends ShadowBaseNode {
 
 
 		let shadowColor = texture( shadowMap.texture, shadowCoord );
 		let shadowColor = texture( shadowMap.texture, shadowCoord );
 
 
-		if ( depthTexture.isDepthArrayTexture ) {
+		if ( depthTexture.isArrayTexture ) {
 
 
 			shadowColor = shadowColor.depth( this.depthLayer );
 			shadowColor = shadowColor.depth( this.depthLayer );
 
 

+ 2 - 12
src/renderers/common/Textures.js

@@ -2,7 +2,6 @@ import DataMap from './DataMap.js';
 
 
 import { Vector3 } from '../../math/Vector3.js';
 import { Vector3 } from '../../math/Vector3.js';
 import { DepthTexture } from '../../textures/DepthTexture.js';
 import { DepthTexture } from '../../textures/DepthTexture.js';
-import { DepthArrayTexture } from '../../textures/DepthArrayTexture.js';
 import { DepthStencilFormat, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedByteType } from '../../constants.js';
 import { DepthStencilFormat, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedByteType } from '../../constants.js';
 
 
 const _size = /*@__PURE__*/ new Vector3();
 const _size = /*@__PURE__*/ new Vector3();
@@ -77,15 +76,7 @@ class Textures extends DataMap {
 
 
 		if ( depthTexture === undefined && useDepthTexture ) {
 		if ( depthTexture === undefined && useDepthTexture ) {
 
 
-			if ( renderTarget.multiview === true && size.depth > 1 ) {
-
-				depthTexture = new DepthArrayTexture();
-
-			} else {
-
-				depthTexture = new DepthTexture();
-
-			}
+			depthTexture = new DepthTexture();
 
 
 			depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
 			depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
 			depthTexture.type = renderTarget.stencilBuffer ? UnsignedInt248Type : UnsignedIntType; // FloatType
 			depthTexture.type = renderTarget.stencilBuffer ? UnsignedInt248Type : UnsignedIntType; // FloatType
@@ -106,7 +97,7 @@ class Textures extends DataMap {
 				depthTexture.needsUpdate = true;
 				depthTexture.needsUpdate = true;
 				depthTexture.image.width = mipWidth;
 				depthTexture.image.width = mipWidth;
 				depthTexture.image.height = mipHeight;
 				depthTexture.image.height = mipHeight;
-				depthTexture.image.depth = depthTexture.isDepthArrayTexture ? depthTexture.image.depth : 1;
+				depthTexture.image.depth = depthTexture.isArrayTexture ? depthTexture.image.depth : 1;
 
 
 			}
 			}
 
 
@@ -147,7 +138,6 @@ class Textures extends DataMap {
 
 
 				const texture = textures[ i ];
 				const texture = textures[ i ];
 
 
-				texture.isTextureArray = renderTarget.multiview === true && size.depth > 1;
 				if ( textureNeedsUpdate ) texture.needsUpdate = true;
 				if ( textureNeedsUpdate ) texture.needsUpdate = true;
 
 
 				this.updateTexture( texture, options );
 				this.updateTexture( texture, options );

+ 2 - 14
src/renderers/common/XRManager.js

@@ -9,7 +9,6 @@ import { Vector4 } from '../../math/Vector4.js';
 import { WebXRController } from '../webxr/WebXRController.js';
 import { WebXRController } from '../webxr/WebXRController.js';
 import { AddEquation, BackSide, CustomBlending, DepthFormat, DepthStencilFormat, FrontSide, RGBAFormat, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, ZeroFactor } from '../../constants.js';
 import { AddEquation, BackSide, CustomBlending, DepthFormat, DepthStencilFormat, FrontSide, RGBAFormat, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, ZeroFactor } from '../../constants.js';
 import { DepthTexture } from '../../textures/DepthTexture.js';
 import { DepthTexture } from '../../textures/DepthTexture.js';
-import { DepthArrayTexture } from '../../textures/DepthArrayTexture.js';
 import { XRRenderTarget } from './XRRenderTarget.js';
 import { XRRenderTarget } from './XRRenderTarget.js';
 import { CylinderGeometry } from '../../geometries/CylinderGeometry.js';
 import { CylinderGeometry } from '../../geometries/CylinderGeometry.js';
 import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
 import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
@@ -875,19 +874,8 @@ class XRManager extends EventDispatcher {
 				renderer.setPixelRatio( 1 );
 				renderer.setPixelRatio( 1 );
 				renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
 				renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
 
 
-				let depthTexture;
-				if ( this._useMultiview ) {
-
-					depthTexture = new DepthArrayTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, 2 );
-					depthTexture.type = depthType;
-					depthTexture.format = depthFormat;
-
-				} else {
-
-					depthTexture = new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat );
-
-				}
-
+				const depth = this._useMultiview ? 2 : 1;
+				const depthTexture = new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat, depth );
 
 
 				this._xrRenderTarget = new XRRenderTarget(
 				this._xrRenderTarget = new XRRenderTarget(
 					glProjLayer.textureWidth,
 					glProjLayer.textureWidth,

+ 1 - 1
src/renderers/common/nodes/Nodes.js

@@ -696,7 +696,7 @@ class Nodes extends DataMap {
 		const renderer = this.renderer;
 		const renderer = this.renderer;
 		const cacheKey = this.getOutputCacheKey();
 		const cacheKey = this.getOutputCacheKey();
 
 
-		const output = outputTarget.isTextureArray ?
+		const output = outputTarget.isArrayTexture ?
 			texture3D( outputTarget, vec3( screenUV, builtin( 'gl_ViewID_OVR' ) ) ).renderOutput( renderer.toneMapping, renderer.currentColorSpace ) :
 			texture3D( outputTarget, vec3( screenUV, builtin( 'gl_ViewID_OVR' ) ) ).renderOutput( renderer.toneMapping, renderer.currentColorSpace ) :
 			texture( outputTarget, screenUV ).renderOutput( renderer.toneMapping, renderer.currentColorSpace );
 			texture( outputTarget, screenUV ).renderOutput( renderer.toneMapping, renderer.currentColorSpace );
 
 

+ 3 - 3
src/renderers/webgl-fallback/WebGLBackend.js

@@ -971,7 +971,7 @@ class WebGLBackend extends Backend {
 	 */
 	 */
 	_isRenderCameraDepthArray( renderContext ) {
 	_isRenderCameraDepthArray( renderContext ) {
 
 
-		return renderContext.depthTexture && renderContext.depthTexture.isDepthArrayTexture && renderContext.camera.isArrayCamera;
+		return renderContext.depthTexture && renderContext.depthTexture.isArrayTexture && renderContext.camera.isArrayCamera;
 
 
 	}
 	}
 
 
@@ -1992,7 +1992,7 @@ class WebGLBackend extends Backend {
 
 
 			const isCube = renderTarget.isWebGLCubeRenderTarget === true;
 			const isCube = renderTarget.isWebGLCubeRenderTarget === true;
 			const isRenderTarget3D = renderTarget.isRenderTarget3D === true;
 			const isRenderTarget3D = renderTarget.isRenderTarget3D === true;
-			const isRenderTargetArray = renderTarget.isRenderTargetArray === true;
+			const isRenderTargetArray = renderTarget.depth > 1;
 			const isXRRenderTarget = renderTarget.isXRRenderTarget === true;
 			const isXRRenderTarget = renderTarget.isXRRenderTarget === true;
 			const hasExternalTextures = ( isXRRenderTarget === true && renderTarget.hasExternalTextures === true );
 			const hasExternalTextures = ( isXRRenderTarget === true && renderTarget.hasExternalTextures === true );
 
 
@@ -2109,7 +2109,7 @@ class WebGLBackend extends Backend {
 
 
 						} else {
 						} else {
 
 
-							if ( descriptor.depthTexture.isDepthArrayTexture ) {
+							if ( descriptor.depthTexture.isArrayTexture ) {
 
 
 								const layer = this.renderer._activeCubeFace;
 								const layer = this.renderer._activeCubeFace;
 
 

+ 3 - 3
src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js

@@ -557,13 +557,13 @@ ${ flowData.code }
 
 
 				}
 				}
 
 
-				if ( uniform.type === 'texture3D' && texture.isTextureArray === false ) {
+				if ( uniform.type === 'texture3D' && texture.isArrayTexture === false ) {
 
 
 					snippet = `${typePrefix}sampler3D ${ uniform.name };`;
 					snippet = `${typePrefix}sampler3D ${ uniform.name };`;
 
 
 				} else if ( texture.compareFunction ) {
 				} else if ( texture.compareFunction ) {
 
 
-					if ( texture.isDepthArrayTexture === true ) {
+					if ( texture.isArrayTexture === true ) {
 
 
 						snippet = `sampler2DArrayShadow ${ uniform.name };`;
 						snippet = `sampler2DArrayShadow ${ uniform.name };`;
 
 
@@ -573,7 +573,7 @@ ${ flowData.code }
 
 
 					}
 					}
 
 
-				} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true || texture.isTextureArray === true ) {
+				} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
 
 
 					snippet = `${typePrefix}sampler2DArray ${ uniform.name };`;
 					snippet = `${typePrefix}sampler2DArray ${ uniform.name };`;
 
 

+ 6 - 6
src/renderers/webgl-fallback/utils/WebGLTextureUtils.js

@@ -112,7 +112,7 @@ class WebGLTextureUtils {
 
 
 			glTextureType = gl.TEXTURE_CUBE_MAP;
 			glTextureType = gl.TEXTURE_CUBE_MAP;
 
 
-		} else if ( texture.isDepthArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true || texture.isTextureArray === true ) {
+		} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
 
 
 			glTextureType = gl.TEXTURE_2D_ARRAY;
 			glTextureType = gl.TEXTURE_2D_ARRAY;
 
 
@@ -307,7 +307,7 @@ class WebGLTextureUtils {
 		if ( textureType === gl.TEXTURE_3D || textureType === gl.TEXTURE_2D_ARRAY ) {
 		if ( textureType === gl.TEXTURE_3D || textureType === gl.TEXTURE_2D_ARRAY ) {
 
 
 			// WebGL 2 does not support wrapping for depth 2D array textures
 			// WebGL 2 does not support wrapping for depth 2D array textures
-			if ( texture.isDepthArrayTexture !== true && texture.isTextureArray === false ) {
+			if ( ! texture.isArrayTexture ) {
 
 
 				gl.texParameteri( textureType, gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
 				gl.texParameteri( textureType, gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
 
 
@@ -409,7 +409,7 @@ class WebGLTextureUtils {
 
 
 		this.setTextureParameters( glTextureType, texture );
 		this.setTextureParameters( glTextureType, texture );
 
 
-		if ( texture.isDepthArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture || texture.isTextureArray ) {
+		if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
 
 
 			gl.texStorage3D( gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, width, height, depth );
 			gl.texStorage3D( gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, width, height, depth );
 
 
@@ -571,7 +571,7 @@ class WebGLTextureUtils {
 
 
 			}
 			}
 
 
-		} else if ( texture.isDataArrayTexture || texture.isDepthArrayTexture ) {
+		} else if ( texture.isDataArrayTexture || texture.isArrayTexture ) {
 
 
 			const image = options.image;
 			const image = options.image;
 
 
@@ -736,7 +736,7 @@ class WebGLTextureUtils {
 			width = Math.floor( image.width * levelScale );
 			width = Math.floor( image.width * levelScale );
 			height = Math.floor( image.height * levelScale );
 			height = Math.floor( image.height * levelScale );
 
 
-			if ( srcTexture.isDataArrayTexture || srcTexture.isDepthArrayTexture ) {
+			if ( srcTexture.isDataArrayTexture || srcTexture.isArrayTexture ) {
 
 
 				depth = image.depth;
 				depth = image.depth;
 
 
@@ -789,7 +789,7 @@ class WebGLTextureUtils {
 		gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, minZ );
 		gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, minZ );
 
 
 		// set up the src texture
 		// set up the src texture
-		const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture || dstTexture.isDepthArrayTexture;
+		const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture || dstTexture.isArrayTexture;
 		if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
 		if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
 
 
 			const srcTextureData = backend.get( srcTexture );
 			const srcTextureData = backend.get( srcTexture );

+ 3 - 3
src/renderers/webgpu/WebGPUBackend.js

@@ -362,7 +362,7 @@ class WebGPUBackend extends Backend {
 	 */
 	 */
 	_isRenderCameraDepthArray( renderContext ) {
 	_isRenderCameraDepthArray( renderContext ) {
 
 
-		return renderContext.depthTexture && renderContext.depthTexture.isDepthArrayTexture && renderContext.camera.isArrayCamera;
+		return renderContext.depthTexture && renderContext.depthTexture.image.depth > 1 && renderContext.camera.isArrayCamera;
 
 
 	}
 	}
 
 
@@ -444,7 +444,7 @@ class WebGPUBackend extends Backend {
 					viewDescriptor.dimension = GPUTextureViewDimension.ThreeD;
 					viewDescriptor.dimension = GPUTextureViewDimension.ThreeD;
 					viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
 					viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
 
 
-				} else if ( renderTarget.isRenderTargetArray ) {
+				} else if ( renderTarget.isRenderTarget && textures[ i ].image.depth > 1 ) {
 
 
 					if ( isRenderCameraDepthArray === true ) {
 					if ( isRenderCameraDepthArray === true ) {
 
 
@@ -509,7 +509,7 @@ class WebGPUBackend extends Backend {
 
 
 				const depthTextureData = this.get( renderContext.depthTexture );
 				const depthTextureData = this.get( renderContext.depthTexture );
 				const options = {};
 				const options = {};
-				if ( renderContext.depthTexture.isDepthArrayTexture ) {
+				if ( renderContext.depthTexture.isArrayTexture ) {
 
 
 					options.dimension = GPUTextureViewDimension.TwoD;
 					options.dimension = GPUTextureViewDimension.TwoD;
 					options.arrayLayerCount = 1;
 					options.arrayLayerCount = 1;

+ 23 - 10
src/renderers/webgpu/nodes/WGSLNodeBuilder.js

@@ -453,7 +453,7 @@ class WGSLNodeBuilder extends NodeBuilder {
 
 
 			textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
 			textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
 
 
-			if ( texture.isDataArrayTexture || texture.isDepthArrayTexture || texture.isData3DTexture ) {
+			if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
 
 
 				textureData.arrayLayerCount = new VarNode(
 				textureData.arrayLayerCount = new VarNode(
 					new ExpressionNode(
 					new ExpressionNode(
@@ -536,7 +536,7 @@ class WGSLNodeBuilder extends NodeBuilder {
 
 
 		let snippet;
 		let snippet;
 
 
-		if ( texture.isVideoTexture === true || texture.isStorageTexture === true ) {
+		if ( texture.isVideoTexture === true ) {
 
 
 			snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
 			snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
 
 
@@ -566,12 +566,25 @@ class WGSLNodeBuilder extends NodeBuilder {
 	 * @param {Texture} texture - The texture.
 	 * @param {Texture} texture - The texture.
 	 * @param {string} textureProperty - The name of the texture uniform in the shader.
 	 * @param {string} textureProperty - The name of the texture uniform in the shader.
 	 * @param {string} uvIndexSnippet - A WGSL snippet that represents texture coordinates used for sampling.
 	 * @param {string} uvIndexSnippet - A WGSL snippet that represents texture coordinates used for sampling.
+	 * @param {?string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
 	 * @param {string} valueSnippet - A WGSL snippet that represent the new texel value.
 	 * @param {string} valueSnippet - A WGSL snippet that represent the new texel value.
 	 * @return {string} The WGSL snippet.
 	 * @return {string} The WGSL snippet.
 	 */
 	 */
-	generateTextureStore( texture, textureProperty, uvIndexSnippet, valueSnippet ) {
+	generateTextureStore( texture, textureProperty, uvIndexSnippet, depthSnippet, valueSnippet ) {
+
+		let snippet;
+
+		if ( depthSnippet ) {
+
+			snippet = `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, ${ valueSnippet } )`;
+
+		} else {
+
+			snippet = `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ valueSnippet } )`;
 
 
-		return `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ valueSnippet } )`;
+		}
+
+		return snippet;
 
 
 	}
 	}
 
 
@@ -676,7 +689,7 @@ class WGSLNodeBuilder extends NodeBuilder {
 
 
 		if ( shaderStage === 'fragment' ) {
 		if ( shaderStage === 'fragment' ) {
 
 
-			if ( texture.isDepthArrayTexture ) {
+			if ( texture.isDepthTexture === true && texture.isArrayTexture === true ) {
 
 
 				return `textureSampleCompare( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ compareSnippet } )`;
 				return `textureSampleCompare( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ compareSnippet } )`;
 
 
@@ -1681,10 +1694,6 @@ ${ flowData.code }
 
 
 					textureType = 'texture_cube<f32>';
 					textureType = 'texture_cube<f32>';
 
 
-				} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true || texture.isTextureArray === true ) {
-
-					textureType = 'texture_2d_array<f32>';
-
 				} else if ( texture.isDepthTexture === true ) {
 				} else if ( texture.isDepthTexture === true ) {
 
 
 					if ( this.renderer.backend.compatibilityMode && texture.compareFunction === null ) {
 					if ( this.renderer.backend.compatibilityMode && texture.compareFunction === null ) {
@@ -1693,10 +1702,14 @@ ${ flowData.code }
 
 
 					} else {
 					} else {
 
 
-						textureType = `texture_depth${ multisampled }_2d${ texture.isDepthArrayTexture === true ? '_array' : '' }`;
+						textureType = `texture_depth${ multisampled }_2d${ texture.isArrayTexture === true ? '_array' : '' }`;
 
 
 					}
 					}
 
 
+				} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
+
+					textureType = 'texture_2d_array<f32>';
+
 				} else if ( texture.isVideoTexture === true ) {
 				} else if ( texture.isVideoTexture === true ) {
 
 
 					textureType = 'texture_external';
 					textureType = 'texture_external';

+ 2 - 2
src/renderers/webgpu/utils/WebGPUBindingUtils.js

@@ -202,7 +202,7 @@ class WebGPUBindingUtils {
 
 
 					texture.viewDimension = GPUTextureViewDimension.Cube;
 					texture.viewDimension = GPUTextureViewDimension.Cube;
 
 
-				} else if ( binding.texture.isDataArrayTexture || binding.texture.isDepthArrayTexture || binding.texture.isCompressedArrayTexture ) {
+				} else if ( binding.texture.isArrayTexture || binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
 
 
 					texture.viewDimension = GPUTextureViewDimension.TwoDArray;
 					texture.viewDimension = GPUTextureViewDimension.TwoDArray;
 
 
@@ -432,7 +432,7 @@ class WebGPUBindingUtils {
 
 
 							dimensionViewGPU = GPUTextureViewDimension.ThreeD;
 							dimensionViewGPU = GPUTextureViewDimension.ThreeD;
 
 
-						} else if ( binding.texture.isDataArrayTexture || binding.texture.isDepthArrayTexture || binding.texture.isCompressedArrayTexture ) {
+						} else if ( binding.texture.isArrayTexture || binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
 
 
 							dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
 							dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
 
 

+ 3 - 3
src/renderers/webgpu/utils/WebGPUTextureUtils.js

@@ -464,7 +464,7 @@ class WebGPUTextureUtils {
 
 
 			this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
 			this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
 
 
-		} else if ( texture.isDataArrayTexture || texture.isDepthArrayTexture || texture.isData3DTexture ) {
+		} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
 
 
 			for ( let i = 0; i < options.image.depth; i ++ ) {
 			for ( let i = 0; i < options.image.depth; i ++ ) {
 
 
@@ -830,7 +830,7 @@ class WebGPUTextureUtils {
 		const device = this.backend.device;
 		const device = this.backend.device;
 
 
 		const blockData = this._getBlockData( textureDescriptorGPU.format );
 		const blockData = this._getBlockData( textureDescriptorGPU.format );
-		const isTextureArray = textureDescriptorGPU.size.depthOrArrayLayers > 1;
+		const isArrayTexture = textureDescriptorGPU.size.depthOrArrayLayers > 1;
 
 
 		for ( let i = 0; i < mipmaps.length; i ++ ) {
 		for ( let i = 0; i < mipmaps.length; i ++ ) {
 
 
@@ -838,7 +838,7 @@ class WebGPUTextureUtils {
 
 
 			const width = mipmap.width;
 			const width = mipmap.width;
 			const height = mipmap.height;
 			const height = mipmap.height;
-			const depth = isTextureArray ? textureDescriptorGPU.size.depthOrArrayLayers : 1;
+			const depth = isArrayTexture ? textureDescriptorGPU.size.depthOrArrayLayers : 1;
 
 
 			const bytesPerRow = Math.ceil( width / blockData.width ) * blockData.byteLength;
 			const bytesPerRow = Math.ceil( width / blockData.width ) * blockData.byteLength;
 			const bytesPerImage = bytesPerRow * Math.ceil( height / blockData.height );
 			const bytesPerImage = bytesPerRow * Math.ceil( height / blockData.height );

+ 0 - 101
src/textures/DepthArrayTexture.js

@@ -1,101 +0,0 @@
-import { DepthTexture } from './DepthTexture.js';
-
-/**
- * Creates an array of depth textures.
- *
- * @augments DepthTexture
- */
-class DepthArrayTexture extends DepthTexture {
-
-	/**
-	 * Constructs a new depth array texture.
-	 *
-	 * @param {number} [width=1] - The width of the texture.
-	 * @param {number} [height=1] - The height of the texture.
-	 * @param {number} [depth=1] - The depth of the texture.
-	 */
-	constructor( width = 1, height = 1, depth = 1 ) {
-
-		super( width, height );
-
-		/**
-		 * This flag can be used for type testing.
-		 *
-		 * @type {boolean}
-		 * @readonly
-		 * @default true
-		 */
-		this.isDepthArrayTexture = true;
-
-		/**
-		 * The image definition of a depth texture.
-		 *
-		 * @type {{width:number,height:number,depth:number}}
-		 */
-		this.image = { width: width, height: height, depth: depth };
-
-		/**
-		 * If set to `true`, the texture is flipped along the vertical axis when
-		 * uploaded to the GPU.
-		 *
-		 * Overwritten and set to `false` by default.
-		 *
-		 * @type {boolean}
-		 * @default false
-		 */
-		this.flipY = false;
-
-		/**
-		 * Whether to generate mipmaps (if possible) for a texture.
-		 *
-		 * Overwritten and set to `false` by default.
-		 *
-		 * @type {boolean}
-		 * @default false
-		 */
-		this.generateMipmaps = false;
-
-		/**
-		 * Code corresponding to the depth compare function.
-		 *
-		 * @type {?(NeverCompare|LessCompare|EqualCompare|LessEqualCompare|GreaterCompare|NotEqualCompare|GreaterEqualCompare|AlwaysCompare)}
-		 * @default null
-		 */
-		this.compareFunction = null;
-
-		/**
-		 * A set of all layers which need to be updated in the texture.
-		 *
-		 * @type {Set<number>}
-		 */
-		this.layerUpdates = new Set();
-
-	}
-
-	/**
-	 * Describes that a specific layer of the texture needs to be updated.
-	 * Normally when {@link Texture#needsUpdate} is set to `true`, the
-	 * entire slice is sent to the GPU. Marking specific
-	 * layers will only transmit subsets of all mipmaps associated with a
-	 * specific depth in the array which is often much more performant.
-	 *
-	 * @param {number} layerIndex - The layer index that should be updated.
-	 */
-	addLayerUpdate( layerIndex ) {
-
-		this.layerUpdates.add( layerIndex );
-
-	}
-
-	/**
-	 * Resets the layer updates registry.
-	 */
-	clearLayerUpdates() {
-
-		this.layerUpdates.clear();
-
-	}
-
-}
-
-export { DepthArrayTexture };

+ 5 - 9
src/textures/DepthTexture.js

@@ -23,8 +23,9 @@ class DepthTexture extends Texture {
 	 * @param {number} [minFilter=LinearFilter] - The min filter value.
 	 * @param {number} [minFilter=LinearFilter] - The min filter value.
 	 * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
 	 * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
 	 * @param {number} [format=DepthFormat] - The texture format.
 	 * @param {number} [format=DepthFormat] - The texture format.
+	 * @param {number} [depth=1] - The depth of the texture.
 	 */
 	 */
-	constructor( width, height, type = UnsignedIntType, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, format = DepthFormat ) {
+	constructor( width, height, type = UnsignedIntType, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, format = DepthFormat, depth = 1 ) {
 
 
 		if ( format !== DepthFormat && format !== DepthStencilFormat ) {
 		if ( format !== DepthFormat && format !== DepthStencilFormat ) {
 
 
@@ -32,7 +33,9 @@ class DepthTexture extends Texture {
 
 
 		}
 		}
 
 
-		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
+		const image = { width: width, height: height, depth: depth };
+
+		super( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
 
 
 		/**
 		/**
 		 * This flag can be used for type testing.
 		 * This flag can be used for type testing.
@@ -43,13 +46,6 @@ class DepthTexture extends Texture {
 		 */
 		 */
 		this.isDepthTexture = true;
 		this.isDepthTexture = true;
 
 
-		/**
-		 * The image property of a depth texture just defines its dimensions.
-		 *
-		 * @type {{width:number,height:number}}
-		 */
-		this.image = { width: width, height: height };
-
 		/**
 		/**
 		 * If set to `true`, the texture is flipped along the vertical axis when
 		 * If set to `true`, the texture is flipped along the vertical axis when
 		 * uploaded to the GPU.
 		 * uploaded to the GPU.

+ 2 - 2
src/textures/Texture.js

@@ -347,7 +347,7 @@ class Texture extends EventDispatcher {
 		 * @readonly
 		 * @readonly
 		 * @default false
 		 * @default false
 		 */
 		 */
-		this.isTextureArray = false;
+		this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
 
 
 		/**
 		/**
 		 * Indicates whether this texture should be processed by `PMREMGenerator` or not
 		 * Indicates whether this texture should be processed by `PMREMGenerator` or not
@@ -470,7 +470,7 @@ class Texture extends EventDispatcher {
 
 
 		this.renderTarget = source.renderTarget;
 		this.renderTarget = source.renderTarget;
 		this.isRenderTargetTexture = source.isRenderTargetTexture;
 		this.isRenderTargetTexture = source.isRenderTargetTexture;
-		this.isTextureArray = source.isTextureArray;
+		this.isArrayTexture = source.isArrayTexture;
 
 
 		this.userData = JSON.parse( JSON.stringify( source.userData ) );
 		this.userData = JSON.parse( JSON.stringify( source.userData ) );
 
 

粤ICP备19079148号