Skip to main content

FirstPersonPerspective

@zylem/game-lib


@zylem/game-lib / core / FirstPersonPerspective

Class: FirstPersonPerspective

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:63

First-person camera perspective.

Position is derived from the attached target entity (+ eye height). Rotation is driven via look() / setLook() methods called by game code or a future FPS behavior. Supports smooth FOV zoom and lerp'd look-at.

Implements​

Constructors​

Constructor​

new FirstPersonPerspective(options?): FirstPersonPerspective

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:90

Parameters​

options?​

FirstPersonOptions

Returns​

FirstPersonPerspective

Properties​

defaults​

readonly defaults: object

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:66

Optional defaults for smoothing and other pipeline settings.

damping​

damping: number = 1

Implementation of​

CameraPerspective.defaults


id​

readonly id: "first-person" = 'first-person'

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:64

Implementation of​

CameraPerspective.id


initialPosition?​

optional initialPosition?: Vector3

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:70

Fallback position when no target entity is attached. Mutate directly for manual movement.


projection​

readonly projection: "perspective"

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:65

Projection the Three.js camera must use. When omitted, the runtime keeps a perspective camera. Orthographic perspectives set this so a runtime switch replaces the camera instance.

Implementation of​

CameraPerspective.projection

Accessors​

currentFov​

Get Signature​

get currentFov(): number

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:149

Current field of view.

Returns​

number


pitch​

Get Signature​

get pitch(): number

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:136

Current pitch in radians.

Returns​

number


yaw​

Get Signature​

get yaw(): number

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:133

Current yaw in radians.

Returns​

number

Methods​

clearLookAt()​

clearLookAt(): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:163

Disable look-at and return to manual yaw/pitch control.

Returns​

void


getBasePose()​

getBasePose(ctx): CameraPose

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:172

Compute the raw desired pose for this frame given the current context.

Parameters​

ctx​

CameraContext

Returns​

CameraPose

Implementation of​

CameraPerspective.getBasePose


look()​

look(deltaYaw, deltaPitch): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:112

Accumulate yaw and pitch deltas. Pitch is clamped to the configured limit.

Parameters​

deltaYaw​

number

deltaPitch​

number

Returns​

void


lookAt()​

lookAt(target, lerpSpeed?): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:155

Enable smooth look-at toward a world position. The camera will slerp from the current rotation toward the look-at direction.

Parameters​

target​

Vector3

lerpSpeed?​

number

Returns​

void


resetZoom()​

resetZoom(): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:144

Return to the default FOV.

Returns​

void


setEyeHeight()​

setEyeHeight(height): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:128

Set eye height above the followed target (used when syncing from FirstPersonBehavior).

Parameters​

height​

number

Returns​

void


setLook()​

setLook(yaw, pitch): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:122

Set absolute yaw and pitch. Pitch is clamped to the configured limit.

Parameters​

yaw​

number

pitch​

number

Returns​

void


zoom()​

zoom(fov): void

Defined in: packages/game-lib/src/lib/camera/perspectives/first-person-perspective.ts:139

Set the target FOV for a smooth zoom transition (e.g. sniper scope).

Parameters​

fov​

number

Returns​

void