useCaptureTexture
useCaptureTexture(
camera,options):CaptureTextureResult
Draws the scene from a camera of the game’s own into a texture the
game shows in the world, such as a monitor, a security feed or a
portrait on a card. It draws the scene straight, at the texture’s size,
in linear light: no post-processing, no tone mapping, so the main
view’s look finishes the surface that shows it once, as it finishes
every other. A material shows it with its own tone mapping, as a
meshBasicMaterial does by default, and a feed brighter than white
blooms where the look blooms.
camera is a bookmarked view or a three camera of the game’s, such as a
<perspectiveCamera> parented under a turret: its world transform,
field of view or height, clip planes, zoom, layers and focus draw at
the texture’s aspect; a projection matrix of its own, a film offset or
a view offset does not carry. A camera the game moves in its own frame
callback shows in the next frame, since the texture draws before them.
Gizmos and screen overlays stay out; the scene’s fog stays in.
CaptureUpdate.OnChange draws a whole frame after it mounts, once
nothing on the page loads, then in each frame its camera, the camera’s
focus or its size changes, and after each capture().
CaptureUpdate.EveryFrame draws in every frame the canvas draws, and
costs a draw of the scene at the texture’s size each frame. The texture
is opaque black until its first draw, and a material in the feed’s own
view shows the draw before. A draw waits while a headset presents or
the canvas has lost its context, and draws again once it is back. A
hook under the game’s canvas.
const { texture } = useCaptureTexture( { eye: [0, 6, 12], target: [0, 0, 0], fov: 40 }, { width: 512, height: 288, update: CaptureUpdate.EveryFrame },);return <meshBasicMaterial map={texture} />;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
camera |
CaptureCamera |
options |
CaptureTextureOptions |