UNPKG

3.56 kBTypeScriptView Raw
1import {
2 MagnificationTextureFilter,
3 Mapping,
4 MinificationTextureFilter,
5 PixelFormat,
6 TextureDataType,
7 Wrapping,
8} from "../constants.js";
9import { Texture } from "./Texture.js";
10
11/**
12 * Creates a texture for use with a video.
13 * @remarks
14 * Note: After the initial use of a texture, the video cannot be changed
15 * Instead, call {@link dispose | .dispose()} on the texture and instantiate a new one.
16 * @example
17 * ```typescript
18 * // assuming you have created a HTML video element with id="video"
19 * const video = document.getElementById('video');
20 * const texture = new THREE.VideoTexture(video);
21 * ```
22 * @see Example: {@link https://threejs.org/examples/#webgl_materials_video | materials / video}
23 * @see Example: {@link https://threejs.org/examples/#webgl_materials_video_webcam | materials / video / webcam}
24 * @see Example: {@link https://threejs.org/examples/#webgl_video_kinect | video / kinect}
25 * @see Example: {@link https://threejs.org/examples/#webgl_video_panorama_equirectangular | video / panorama / equirectangular}
26 * @see Example: {@link https://threejs.org/examples/#webxr_vr_video | vr / video}
27 * @see {@link https://threejs.org/docs/index.html#api/en/textures/VideoTexture | Official Documentation}
28 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/VideoTexture.js | Source}
29 */
30export class VideoTexture extends Texture {
31 /**
32 * Create a new instance of {@link VideoTexture}
33 * @param video The video element to use as the texture.
34 * @param mapping See {@link Texture.mapping | .mapping}. Default {@link THREE.Texture.DEFAULT_MAPPING}
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.LinearFilter}
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 */
43 constructor(
44 video: HTMLVideoElement,
45 mapping?: Mapping,
46 wrapS?: Wrapping,
47 wrapT?: Wrapping,
48 magFilter?: MagnificationTextureFilter,
49 minFilter?: MinificationTextureFilter,
50 format?: PixelFormat,
51 type?: TextureDataType,
52 anisotropy?: number,
53 );
54
55 /**
56 * Read-only flag to check if a given object is of type {@link VideoTexture}.
57 * @remarks This is a _constant_ value
58 * @defaultValue `true`
59 */
60 readonly isVideoTexture: true;
61
62 /**
63 * @override
64 * @defaultValue {@link THREE.LinearFilter}
65 */
66 magFilter: MagnificationTextureFilter;
67
68 /**
69 * @override
70 * @defaultValue {@link THREE.LinearFilter}
71 */
72 minFilter: MinificationTextureFilter;
73
74 /**
75 * @override
76 * @defaultValue `false`
77 */
78 generateMipmaps: boolean;
79
80 /**
81 * @override
82 * You will **not** need to set this manually here as it is handled by the {@link update | update()} method.
83 */
84 set needsUpdate(value: boolean);
85
86 /**
87 * This is called automatically and sets {@link needsUpdate | .needsUpdate } to `true` every time a new frame is available.
88 */
89 update(): void;
90}