@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.
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 ​
new CameraDirector(world, camera?): CameraDirector;Defined in: camera/CameraDirector.ts:107
Parameters ​
| Parameter | Type |
|---|---|
world | World |
camera? | Camera |
Returns ​
CameraDirector
Accessors ​
isPlaying ​
Get Signature ​
get isPlaying(): boolean;Defined in: camera/CameraDirector.ts:115
A cutscene has the camera, so player controls should wait.
Returns ​
boolean
Methods ​
play() ​
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 ​
| Parameter | Type |
|---|---|
shots | CameraShot[] |
options | CameraPlayOptions |
Returns ​
Promise<void>
stop() ​
stop(blendOut?): void;Defined in: camera/CameraDirector.ts:147
End a cutscene early, as a Skip button would.
Parameters ​
| Parameter | Type |
|---|---|
blendOut? | number |
Returns ​
void
shake() ​
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 ​
| Parameter | Type | Default value |
|---|---|---|
strength | number | 0.15 |
seconds | number | 0.4 |
Returns ​
void
moveDirection() ​
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 ​
| Parameter | Type |
|---|---|
strafe | number |
forward | number |
Returns ​
{
x: number;
z: number;
}| Name | Type | Defined in |
|---|---|---|
x | number | camera/CameraDirector.ts:168 |
z | number | camera/CameraDirector.ts:168 |

