Capítulo 240 de 859

Chapter 240: VideoTexture

Core Idea

A texture for use with a video.

Note: When using video textures with WebGPURenderer, Texture#colorSpace must be set to THREE.SRGBColorSpace.

Note: After the initial use of a texture, its dimensions, format, and type cannot be changed. Instead, call Texture#dispose on the texture and instantiate a new one.

Key Concepts

  • generateMipmaps : boolean: Whether to generate mipmaps (if possible) for a texture.
  • isVideoTexture : boolean (readonly): This flag can be used for type testing.

Code Examples

// assuming you have created a HTML video element with id="video"
const video = document.getElementById( 'video' );
const texture = new THREE.VideoTexture( video );
  • What it demonstrates: Typical usage of VideoTexture.

Reference Tables

Constructor

Signature
new VideoTexture( video : HTMLVideoElement, mapping : number, wrapS : number, wrapT : number, magFilter : number, minFilter : number, format : number, type : number, anisotropy : number )

Properties

PropertyDescription
.generateMipmaps : booleanWhether to generate mipmaps (if possible) for a texture.
.isVideoTexture : boolean (readonly)This flag can be used for type testing.

Methods

MethodDescription
.update()This method is called automatically by the renderer and sets Texture#needsUpdate to true every time a new frame is available.

Key Takeaways

  1. VideoTexture extends: EventDispatcher → Texture
  2. Most relevant properties: generateMipmaps, isVideoTexture.
  3. Key methods: update.

Connects To