UNPKG

3.47 kBTypeScriptView Raw
1import {
2 CubeTextureMapping,
3 MagnificationTextureFilter,
4 MinificationTextureFilter,
5 PixelFormat,
6 TextureDataType,
7 Wrapping,
8} from "../constants.js";
9import { Texture } from "./Texture.js";
10
11/**
12 * Creates a cube texture made up of six images.
13 * @remarks
14 * {@link CubeTexture} is almost equivalent in functionality and usage to {@link Texture}.
15 * The only differences are that the images are an array of _6_ images as opposed to a single image,
16 * and the mapping options are {@link THREE.CubeReflectionMapping} (default) or {@link THREE.CubeRefractionMapping}
17 * @example
18 * ```typescript
19 * const loader = new THREE.CubeTextureLoader();
20 * loader.setPath('textures/cube/pisa/');
21 * const textureCube = loader.load(['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']);
22 * const material = new THREE.MeshBasicMaterial({
23 * color: 0xffffff,
24 * envMap: textureCube
25 * });
26 * ```
27 * @see {@link https://threejs.org/docs/index.html#api/en/textures/CubeTexture | Official Documentation}
28 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/CubeTexture.js | Source}
29 */
30export class CubeTexture extends Texture {
31 /**
32 * This creates a new {@link THREE.CubeTexture | CubeTexture} object.
33 * @param images
34 * @param mapping See {@link CubeTexture.mapping | .mapping}. Default {@link THREE.CubeReflectionMapping}
35 * @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
36 * @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
37 * @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.LinearFilter}
38 * @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.LinearMipmapLinearFilter}
39 * @param format See {@link Texture.format | .format}. Default {@link THREE.RGBAFormat}
40 * @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
41 * @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
42 * @param colorSpace See {@link Texture.colorSpace | .colorSpace}. Default {@link NoColorSpace}
43 */
44 constructor(
45 images?: any[], // HTMLImageElement or HTMLCanvasElement
46 mapping?: CubeTextureMapping,
47 wrapS?: Wrapping,
48 wrapT?: Wrapping,
49 magFilter?: MagnificationTextureFilter,
50 minFilter?: MinificationTextureFilter,
51 format?: PixelFormat,
52 type?: TextureDataType,
53 anisotropy?: number,
54 colorSpace?: string,
55 );
56
57 /**
58 * Read-only flag to check if a given object is of type {@link CubeTexture}.
59 * @remarks This is a _constant_ value
60 * @defaultValue `true`
61 */
62 readonly isCubeTexture: true;
63
64 /**
65 * An image object, typically created using the {@link THREE.CubeTextureLoader.load | CubeTextureLoader.load()} method.
66 * @see {@link Texture.image}
67 */
68 get image(): any;
69 set image(data: any);
70
71 /**
72 * An image object, typically created using the {@link THREE.CubeTextureLoader.load | CubeTextureLoader.load()} method.
73 * @see {@link Texture.image}
74 */
75 get images(): any;
76 set images(data: any);
77
78 /**
79 * @inheritDoc
80 * @defaultValue {@link THREE.CubeReflectionMapping}
81 */
82 mapping: CubeTextureMapping;
83
84 /**
85 * @inheritDoc
86 * @defaultValue `false`
87 */
88 flipY: boolean;
89}