Skip to main content

CameraPipeline

@zylem/game-lib


@zylem/game-lib / core / CameraPipeline

Class: CameraPipeline

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:19

CameraPipeline runs a deterministic per-frame update:

Perspective -> Behaviors (priority) -> Actions (deltas) -> Smoothing -> finalPose

It separates "desired pose" from "final pose". Everything writes to desired; only smoothing converts desired into the final committed pose.

Constructors​

Constructor​

new CameraPipeline(perspective?): CameraPipeline

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:41

Parameters​

perspective?​

CameraPerspective

Returns​

CameraPipeline

Properties​

damping​

damping: number = 0.15

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:39

Smoothing factor: 0 = no movement, 1 = instant snap.


perspective​

perspective: CameraPerspective | null = null

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:21

Active perspective (exactly one at a time).

Methods​

addAction()​

addAction(action): void

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:132

Add a transient action. Actions self-expire via isDone().

Parameters​

action​

CameraAction

Returns​

void


addBehavior()​

addBehavior(key, behavior, ctx?): void

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:97

Add or replace a behavior by key (idempotent). Calls onDetach on the old behavior and onAttach on the new one.

Parameters​

key​

string

behavior​

CameraBehavior

ctx?​

CameraContext

Returns​

void


getState()​

getState(): CameraPipelineState

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:141

Return a debug snapshot of the pipeline state.

Returns​

CameraPipelineState


hasBehavior()​

hasBehavior(key): boolean

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:123

Check whether a behavior with the given key exists.

Parameters​

key​

string

Returns​

boolean


removeBehavior()​

removeBehavior(key, ctx?): boolean

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:111

Remove a behavior by key. Calls onDetach if a context is provided.

Parameters​

key​

string

ctx?​

CameraContext

Returns​

boolean


run()​

run(ctx): CameraPose

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:54

Run the full pipeline for one frame. Returns the final pose that should be committed to the Three.js camera.

Parameters​

ctx​

CameraContext

Returns​

CameraPose


setPerspective()​

setPerspective(perspective): void

Defined in: packages/game-lib/src/lib/camera/camera-pipeline.ts:155

Set a new perspective. Resets the pipeline initialization flag so the first frame with the new perspective snaps instead of lerping from the old pose.

Parameters​

perspective​

CameraPerspective

Returns​

void