luma.gl/docs/api-reference/core/resources/external-texture.md
2023-08-18 17:52:53 -04:00

747 B

ExternalTexture

:::caution The luma.gl v9 API is currently in public review and may be subject to change. :::

:::info WebGPU only. :::

While it is possible to use a normal Texture for a video element, the ExternalTexture class provides a way to create a cheap-to-construct, disposable view of the video.

The performance and memory savings can be significant.

Since a new external texture is created every frame, new bindings must be prepared:

function onFrame() {
  requestAnimationFrame(onFrame);

  const externalTexture = device.createExternalTexture({source: video});

  model.setBindings([
    externalTexture,
    sampler
  ])

  model.draw(renderPass);
}
requestAnimationFrame(onFrame);