UNPKG

3.79 kBTypeScriptView Raw
1import {
2 CompressedPixelFormat,
3 MagnificationTextureFilter,
4 Mapping,
5 MinificationTextureFilter,
6 TextureDataType,
7 Wrapping,
8} from "../constants.js";
9import { TypedArray } from "../core/BufferAttribute.js";
10import { Texture } from "./Texture.js";
11
12export interface CompressedTextureMipmap {
13 data: TypedArray;
14 width: number;
15 height: number;
16}
17
18/**
19 * Creates a texture based on data in compressed form, for example from a {@link https://en.wikipedia.org/wiki/DirectDraw_Surface | DDS} file.
20 * @remarks For use with the {@link THREE.CompressedTextureLoader | CompressedTextureLoader}.
21 * @see {@link https://threejs.org/docs/index.html#api/en/textures/CompressedTexture | Official Documentation}
22 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/CompressedTexture.js | Source}
23 */
24export class CompressedTexture extends Texture {
25 /**
26 * This creates a new {@link THREE.CompressedTexture | CompressedTexture} object.
27 * @param mipmaps The mipmaps array should contain objects with data, width and height. The mipmaps should be of the
28 * correct format and type.
29 * @param width The width of the biggest mipmap.
30 * @param height The height of the biggest mipmap.
31 * @param format The format used in the mipmaps. See {@link THREE.CompressedPixelFormat}.
32 * @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
33 * @param mapping See {@link Texture.mapping | .mapping}. Default {@link THREE.Texture.DEFAULT_MAPPING}
34 * @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
35 * @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
36 * @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.LinearFilter}
37 * @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.LinearMipmapLinearFilter}
38 * @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
39 * @param colorSpace See {@link Texture.colorSpace .colorSpace}. Default {@link NoColorSpace}
40 */
41 constructor(
42 mipmaps?: CompressedTextureMipmap[],
43 width?: number,
44 height?: number,
45 format?: CompressedPixelFormat,
46 type?: TextureDataType,
47 mapping?: Mapping,
48 wrapS?: Wrapping,
49 wrapT?: Wrapping,
50 magFilter?: MagnificationTextureFilter,
51 minFilter?: MinificationTextureFilter,
52 anisotropy?: number,
53 colorSpace?: string,
54 );
55
56 /**
57 * Read-only flag to check if a given object is of type {@link CompressedTexture}.
58 * @remarks This is a _constant_ value
59 * @defaultValue `true`
60 */
61 readonly isCompressedTexture: true;
62
63 /**
64 * Overridden with a object containing width and height.
65 * @override
66 */
67 get image(): { width: number; height: number };
68 set image(value: { width: number; height: number });
69
70 /**
71 * The mipmaps array should contain objects with data, width and height. The mipmaps should be of the correct
72 * format and type.
73 */
74 mipmaps: CompressedTextureMipmap[] | undefined;
75
76 /**
77 * @override
78 * @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
79 * @see {@link THREE.CompressedPixelFormat}
80 */
81 format: CompressedPixelFormat;
82
83 /**
84 * @override No flipping for cube textures. (also flipping doesn't work for compressed textures)
85 * @defaultValue `false`
86 */
87 flipY: boolean;
88
89 /**
90 * @override Can't generate mipmaps for compressed textures. mips must be embedded in DDS files
91 * @defaultValue `false`
92 */
93 generateMipmaps: boolean;
94}