1 | import { MagnificationTextureFilter, MinificationTextureFilter, Wrapping } from "../constants.js";
|
2 | import { TextureImageData } from "./DataTexture.js";
|
3 | import { Texture } from "./Texture.js";
|
4 |
|
5 | /**
|
6 | * Creates a three-dimensional texture from raw data, with parameters to divide it into width, height, and depth
|
7 | * @example
|
8 | * ```typescript
|
9 | * This creates a[name] with repeating data, 0 to 255
|
10 | * // create a buffer with some data
|
11 | * const sizeX = 64;
|
12 | * const sizeY = 64;
|
13 | * const sizeZ = 64;
|
14 | * const data = new Uint8Array(sizeX * sizeY * sizeZ);
|
15 | * let i = 0;
|
16 | * for (let z = 0; z & lt; sizeZ; z++) {
|
17 | * for (let y = 0; y & lt; sizeY; y++) {
|
18 | * for (let x = 0; x & lt; sizeX; x++) {
|
19 | * data[i] = i % 256;
|
20 | * i++;
|
21 | * }
|
22 | * }
|
23 | * }
|
24 | * // use the buffer to create the texture
|
25 | * const texture = new THREE.Data3DTexture(data, sizeX, sizeY, sizeZ);
|
26 | * texture.needsUpdate = true;
|
27 | * ```
|
28 | * @see Example: {@link https://threejs.org/examples/#webgl2_materials_texture3d | WebGL2 / materials / texture3d}
|
29 | * @see Example: {@link https://threejs.org/examples/#webgl2_materials_texture3d_partialupdate | WebGL2 / materials / texture3d / partialupdate}
|
30 | * @see Example: {@link https://threejs.org/examples/#webgl2_volume_cloud | WebGL2 / volume / cloud}
|
31 | * @see Example: {@link https://threejs.org/examples/#webgl2_volume_perlin | WebGL2 / volume / perlin}
|
32 | * @see {@link https://threejs.org/docs/index.html#api/en/textures/Data3DTexture | Official Documentation}
|
33 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/Data3DTexture.js | Source}
|
34 | */
|
35 | export class Data3DTexture extends Texture {
|
36 | /**
|
37 | * Create a new instance of {@link Data3DTexture}
|
38 | * @param data {@link https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView | ArrayBufferView} of the texture. Default `null`.
|
39 | * @param width Width of the texture. Default `1`.
|
40 | * @param height Height of the texture. Default `1`.
|
41 | * @param depth Depth of the texture. Default `1`.
|
42 | */
|
43 | constructor(data?: BufferSource | null, width?: number, height?: number, depth?: number);
|
44 |
|
45 | /**
|
46 | * Read-only flag to check if a given object is of type { Data3DTexture}.
|
47 | * This is a _constant_ value
|
48 | * `true`
|
49 | */
|
50 | readonly isData3DTexture: true;
|
51 |
|
52 | /**
|
53 | * Overridden with a record type holding data, width and height and depth.
|
54 | * @override
|
55 | */
|
56 | get image(): Texture3DImageData;
|
57 | set image(data: Texture3DImageData);
|
58 |
|
59 | /**
|
60 | * @override
|
61 | * @defaultValue {@link THREE.NearestFilter}
|
62 | */
|
63 | magFilter: MagnificationTextureFilter;
|
64 |
|
65 | /**
|
66 | * @override
|
67 | * @defaultValue {@link THREE.NearestFilter}
|
68 | */
|
69 | minFilter: MinificationTextureFilter;
|
70 |
|
71 | /**
|
72 | * @override
|
73 | * @defaultValue {@link THREE.ClampToEdgeWrapping}
|
74 | */
|
75 | wrapR: Wrapping;
|
76 |
|
77 | /**
|
78 | * @override
|
79 | * @defaultValue `false`
|
80 | */
|
81 | flipY: boolean;
|
82 |
|
83 | /**
|
84 | * @override
|
85 | * @defaultValue `false`
|
86 | */
|
87 | generateMipmaps: boolean;
|
88 |
|
89 | /**
|
90 | * @override
|
91 | * @defaultValue `1`
|
92 | */
|
93 | unpackAlignment: number;
|
94 | }
|
95 |
|
96 | export interface Texture3DImageData extends TextureImageData {
|
97 | depth: number;
|
98 | }
|