three
Version:
JavaScript 3D library
102 lines (83 loc) • 2.31 kB
JavaScript
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 };