Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / index / CameraDirector

Class: CameraDirector ​

Defined in: camera/CameraDirector.ts:97

Takes the camera for cutscenes and gives it back. Reached with this.cameras from a Behaviour, or world.getCameraDirector().

It works over whatever else drives the camera, a Camera Rig or a script, and that keeps running underneath, so the way back ends exactly on the live player camera with no jump.

ts
await this.cameras.play([
  { at: "Crane Start", moveTo: "Crane End", lookAt: "Gate", duration: 4, blendIn: 0.8 },
  { at: "Gate Close-up", lookAt: this.entityId, duration: 2 },
]);

Constructors ​

Constructor ​

ts
new CameraDirector(world, camera?): CameraDirector;

Defined in: camera/CameraDirector.ts:107

Parameters ​

ParameterType
worldWorld
camera?Camera

Returns ​

CameraDirector

Accessors ​

isPlaying ​

Get Signature ​

ts
get isPlaying(): boolean;

Defined in: camera/CameraDirector.ts:115

A cutscene has the camera, so player controls should wait.

Returns ​

boolean

Methods ​

play() ​

ts
play(shots, options?): Promise<void>;

Defined in: camera/CameraDirector.ts:129

Run shots in order and return to the player's camera. Resolves once the player has it back, or at once if there's nothing to play. A new cutscene replaces one that's running.

Parameters ​

ParameterType
shotsCameraShot[]
optionsCameraPlayOptions

Returns ​

Promise<void>


stop() ​

ts
stop(blendOut?): void;

Defined in: camera/CameraDirector.ts:147

End a cutscene early, as a Skip button would.

Parameters ​

ParameterType
blendOut?number

Returns ​

void


shake() ​

ts
shake(strength?, seconds?): void;

Defined in: camera/CameraDirector.ts:157

Shake the camera, fading over seconds. 0.05 is a footstep, 0.4 an explosion.

Parameters ​

ParameterTypeDefault value
strengthnumber0.15
secondsnumber0.4

Returns ​

void


moveDirection() ​

ts
moveDirection(strafe, forward): {
  x: number;
  z: number;
};

Defined in: camera/CameraDirector.ts:168

Turn stick or key input into a direction on the ground, relative to the camera: strafe is right, forward is ahead. So "W moves away from the camera" works in every view, including looking straight down.

Parameters ​

ParameterType
strafenumber
forwardnumber

Returns ​

ts
{
  x: number;
  z: number;
}
NameTypeDefined in
xnumbercamera/CameraDirector.ts:168
znumbercamera/CameraDirector.ts:168