Cameras and shots · class
CinematicPlayer
Plays a CinematicScript: a clock, the shot it is currently in, and the line
that is currently up.
Explained in Cameras and cinematics.
class CinematicPlayerimport { CinematicPlayer } from '@driftengine/core';In depth
It knows about time, camera placements and timed strings, and nothing else.
Which shot suits which moment is the script's business, what a look means
is the presentation's, and what any of it is about is the game's.
Everything is derived from accumulated time rather than advanced per frame, so a script plays identically on a 144 Hz desktop and a phone dropping frames — a playback that steps an index per frame tells a different story at a different frame rate, and only one of the two was ever written down.
The caller drives a CinematicCamera from it:
player.update(dt);
if (player.shotChanged) camera.cut(player.shot, player.timeSec);
camera.update(dt, x, y, z, yaw);shotChanged is true only at a cut. A keyframed shot moves while it holds,
and the object handed out by shot is a live view that keeps moving — so the
rig damps its way along the authored path instead of snapping to it every
frame. Copy it if you need to keep it past the next update.
Constructor
new
constructor(script: CinematicScript, name?: string)| Parameter | Type | Description |
|---|---|---|
script | CinematicScript | |
name? | string |
Accessors
| Name | Type | Description |
|---|---|---|
timeSecget | number | |
finishedget | boolean | |
shotget | ShotParams | null | The placement the camera should be holding, or null before the first shot. |
shotChangedget | boolean | True on the frame a cut lands — the cue to cut the rig. |
lineget | CinematicLine | null | The one line on screen, or null. Never two: the script cannot express it. |
Methods
update
update(frameDt: number): void| Parameter | Type | Description |
|---|---|---|
frameDt | number |
skip
skip(): voidStraight to the end, holding nothing.
More
Every returning player takes this path, so it has to leave the player inert rather than merely finished: a skip that leaves a cinematic shot behind hands somebody a run they cannot see.
reset
reset(): voidBack to the top, for a replay from the menu.