UNPKG

3.74 kBTypeScriptView Raw
1import {
2 DepthTexturePixelFormat,
3 MagnificationTextureFilter,
4 Mapping,
5 MinificationTextureFilter,
6 TextureComparisonFunction,
7 TextureDataType,
8 Wrapping,
9} from "../constants.js";
10import { Texture } from "./Texture.js";
11
12/**
13 * This class can be used to automatically save the depth information of a rendering into a texture
14 * @see Example: {@link https://threejs.org/examples/#webgl_depth_texture | depth / texture}
15 * @see {@link https://threejs.org/docs/index.html#api/en/textures/DepthTexture | Official Documentation}
16 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/DepthTexture.js | Source}
17 */
18export class DepthTexture extends Texture {
19 /**
20 * Create a new instance of {@link DepthTexture}
21 * @param width Width of the texture.
22 * @param height Height of the texture.
23 * @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType} or {@link THREE.UnsignedInt248Type}
24 * @param mapping See {@link Texture.mapping | .mapping}. Default {@link THREE.Texture.DEFAULT_MAPPING}
25 * @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
26 * @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
27 * @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.NearestFilter}
28 * @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.NearestFilter}
29 * @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
30 * @param format See {@link DepthTexture.format | .format}. Default {@link THREE.DepthFormat}
31 */
32 constructor(
33 width: number,
34 height: number,
35 type?: TextureDataType,
36 mapping?: Mapping,
37 wrapS?: Wrapping,
38 wrapT?: Wrapping,
39 magFilter?: MagnificationTextureFilter,
40 minFilter?: MinificationTextureFilter,
41 anisotropy?: number,
42 format?: DepthTexturePixelFormat,
43 );
44
45 /**
46 * Read-only flag to check if a given object is of type {@link DepthTexture}.
47 * @remarks This is a _constant_ value
48 * @defaultValue `true`
49 */
50 readonly isDepthTexture: true;
51
52 /**
53 * Overridden with a record type holding width and height.
54 * @override
55 */
56 get image(): { width: number; height: number };
57 set image(value: { width: number; height: number });
58
59 /**
60 * @override
61 * @defaultValue `false`
62 */
63 flipY: boolean;
64
65 /**
66 * @override
67 * @defaultValue {@link THREE.NearestFilter}
68 */
69 magFilter: MagnificationTextureFilter;
70
71 /**
72 * @override
73 * @defaultValue {@link THREE.NearestFilter}
74 */
75 minFilter: MinificationTextureFilter;
76
77 /**
78 * @override Depth textures do not use mipmaps.
79 * @defaultValue `false`
80 */
81 generateMipmaps: boolean;
82
83 /**
84 * @override
85 * @see {@link Texture.format | Texture.format}
86 * @defaultValue {@link THREE.DepthFormat}.
87 */
88 format: DepthTexturePixelFormat;
89
90 /**
91 * @override
92 * @defaultValue {@link THREE.UnsignedByteType} when {@link format | .format} === {@link THREE.DepthFormat}
93 * @defaultValue {@link THREE.UnsignedInt248Type} when {@link format | .format} === {@link THREE.DepthStencilFormat}
94 */
95 type: TextureDataType;
96
97 /**
98 * This is used to define the comparison function used when comparing texels in the depth texture to the value in
99 * the depth buffer. Default is `null` which means comparison is disabled.
100 *
101 * See {@link THREE.TextureComparisonFunction} for functions.
102 */
103 compareFunction: TextureComparisonFunction | null;
104}