UNPKG

2.97 kBTypeScriptView Raw
1import { CompressedPixelFormat, TextureDataType, Wrapping } from "../constants.js";
2import { CompressedTexture, CompressedTextureMipmap } from "./CompressedTexture.js";
3
4/**
5 * Creates an texture 2D array based on data in compressed form, for example from a
6 * {@link https://en.wikipedia.org/wiki/DirectDraw_Surface | DDS} file.
7 * @remarks For use with the {@link THREE.CompressedTextureLoader | CompressedTextureLoader}.
8 * @see {@link https://threejs.org/docs/index.html#api/en/textures/CompressedArrayTexture | Official Documentation}
9 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/CompressedArrayTexture.js | Source}
10 */
11export class CompressedArrayTexture extends CompressedTexture {
12 /**
13 * Read-only flag to check if a given object is of type {@link CompressedArrayTexture}.
14 * @remarks This is a _constant_ value
15 * @defaultValue `true`
16 */
17 readonly isCompressedArrayTexture: true;
18
19 /**
20 * Overridden with a object containing width and height.
21 * @override
22 */
23 get image(): { width: number; height: number; depth: number };
24 set image(value: { width: number; height: number; depth: number });
25
26 /**
27 * This defines how the texture is wrapped in the depth direction.
28 * @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
29 * @defaultValue {@link THREE.ClampToEdgeWrapping}
30 */
31 wrapR: Wrapping;
32
33 /**
34 * A set of all layers which need to be updated in the texture. See {@link CompressedArrayTexture.addLayerUpdate}.
35 */
36 layerUpdates: Set<number>;
37
38 /**
39 * Create a new instance of {@link CompressedArrayTexture}
40 * @param mipmaps The mipmaps array should contain objects with data, width and height. The mipmaps should be of the
41 * correct format and type.
42 * @param width The width of the biggest mipmap.
43 * @param height The height of the biggest mipmap.
44 * @param depth The number of layers of the 2D array texture
45 * @param format The format used in the mipmaps. See {@link THREE.CompressedPixelFormat}.
46 * @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
47 */
48 constructor(
49 mipmaps: CompressedTextureMipmap[],
50 width: number,
51 height: number,
52 depth: number,
53 format: CompressedPixelFormat,
54 type?: TextureDataType,
55 );
56
57 /**
58 * Describes that a specific layer of the texture needs to be updated. Normally when {@link Texture.needsUpdate} is
59 * set to true, the entire compressed texture array is sent to the GPU. Marking specific layers will only transmit
60 * subsets of all mipmaps associated with a specific depth in the array which is often much more performant.
61 */
62 addLayerUpdate(layerIndex: number): void;
63
64 /**
65 * Resets the layer updates registry. See {@link CompressedArrayTexture.addLayerUpdate}.
66 */
67 clearLayoutUpdates(): void;
68}