1 | import {
|
2 | MagnificationTextureFilter,
|
3 | Mapping,
|
4 | MinificationTextureFilter,
|
5 | PixelFormat,
|
6 | TextureDataType,
|
7 | Wrapping,
|
8 | } from "../constants.js";
|
9 | import { OffscreenCanvas, Texture } from "./Texture.js";
|
10 |
|
11 | /**
|
12 | * Creates a texture from a {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas | canvas element}.
|
13 | * @remarks
|
14 | * This is almost the same as the base {@link Texture | Texture} class,
|
15 | * except that it sets {@link Texture.needsUpdate | needsUpdate} to `true` immediately.
|
16 | * @see {@link THREE.Texture | Texture}
|
17 | * @see {@link https://threejs.org/docs/index.html#api/en/textures/CanvasTexture | Official Documentation}
|
18 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/CanvasTexture.js | Source}
|
19 | */
|
20 | export class CanvasTexture extends Texture {
|
21 | /**
|
22 | * This creates a new {@link THREE.CanvasTexture | CanvasTexture} object.
|
23 | * @param canvas The HTML canvas element from which to load the texture.
|
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.LinearFilter}
|
28 | * @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.LinearMipmapLinearFilter}
|
29 | * @param format See {@link Texture.format | .format}. Default {@link THREE.RGBAFormat}
|
30 | * @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
|
31 | * @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
|
32 | */
|
33 | constructor(
|
34 | canvas: TexImageSource | OffscreenCanvas,
|
35 | mapping?: Mapping,
|
36 | wrapS?: Wrapping,
|
37 | wrapT?: Wrapping,
|
38 | magFilter?: MagnificationTextureFilter,
|
39 | minFilter?: MinificationTextureFilter,
|
40 | format?: PixelFormat,
|
41 | type?: TextureDataType,
|
42 | anisotropy?: number,
|
43 | );
|
44 |
|
45 | /**
|
46 | * Read-only flag to check if a given object is of type { CanvasTexture}.
|
47 | * This is a _constant_ value
|
48 | * `true`
|
49 | */
|
50 | readonly isCanvasTexture: true;
|
51 | }
|