Skip to main content

setCameraFeed

@zylem/game-lib


@zylem/game-lib / core / setCameraFeed

Function: setCameraFeed()

setCameraFeed(entity, camera, options?): void

Defined in: packages/game-lib/src/lib/camera/camera-feed.ts:44

Display a camera's live feed on an entity's mesh surface.

This is the primary user-facing function for "jumbotron", security-camera, or broadcast-style effects. It ensures the camera has an offscreen render target and replaces the entity's mesh material with one that shows the camera's rendered output.

Parameters​

entity​

StageEntity

The entity whose mesh will display the camera feed.

camera​

CameraWrapper

The camera whose view will be rendered to the texture.

options?​

CameraFeedOptions

Optional dimensions for the render target.

Returns​

void

Example​

const feedCam = createCamera({
perspective: Perspectives.ThirdPerson,
position: new Vector3(0, 30, 60),
target: new Vector3(0, 0, 0),
renderToTexture: { width: 1024, height: 576 },
});

const screen = createBox({ size: { x: 16, y: 9, z: 0.2 } });
screen.onSetup(({ me }) => {
setCameraFeed(me, feedCam);
});