Skip to content

Cut beta ​

Class of @v12-engine/client

ts
export declare class Cut

The staging of a cinematic, handed to its script. Everything timed in it (a camera move, a wait, a line, the lanes of a def) counts the seconds of its clock (CutClock): the screen moves the clock every frame (frame), a pause menu holds it, slow motion is its rate, the editor seeks it. A seek plays a def's lanes again from the new time (the camera is where its keys say, a line that spans the time shows with what is left of it); a script's own steps go on from where they are, as code has no past to play again

Members ​

constructor ​

ts
constructor(
    stage: Stage, options?: {
        clock?: CutClock;
    });

Constructs a new instance of the Cut class

all ​

ts
all(steps: readonly Promise<void>[]): Promise<void>;

Goes on once every one of the steps is over

at ​

ts
at(marker: string): number | undefined;

The time of the cut a marker of a def played is at, or nothing for a name no def played has

audio ​

ts
readonly audio: CutAudio;

Sound (D1, CutAudio): music crossfaded in, stingers, sounds, voices, a bus's volume; the map's music back after

camera ​

ts
camera(key: CameraKey | string, seconds?: number, ease?: Ease | string): Promise<void>;

Moves the camera to a key in seconds, along a curve; at once with none. Stops following. A key leaves what it does not say as it is. A name is a view of the map saved under it in the editor: cut.camera('gate', 2). The short form of shot

choose ​

ts
choose(options: readonly ChoiceOption[], settings?: ChooseOptions): Choosing;

Asks the player (C3): the answers (ChoiceOption: id, words, key, a condition) in the HUD's choice menu, picked by their key (1, 2, 3...), a click or pick, or the default once seconds are up. Settles with the answer's id, kept as the cut's param name, and sent to the rules (cinematicChoice) for a cinematic of the view's

clip ​

ts
clip(id: number, clip: string, options?: Omit<ClipOptions, 'onEnd'>): CutStep;

Plays a clip of an entity's model (see ClipOptions), and settles when it ends: played to its end, stopped (stopClip), or cut off by another clip or the unit's death; at once when it has no such clip. With loop it plays until it is stopped. .stop() on what it gives back stops the clip there and no longer waits for it, as a skip does

clock ​

ts
readonly clock: CutClock;

The clock everything in the cut goes by

condition ​

ts
condition(name: string, answer: (cut: Cut) => boolean): void;

Code that answers a { hook: name } condition of a clip: played where it says yes

conditions ​

ts
readonly conditions: Map<string, (cut: Cut) => boolean>;

Code answering a { hook } condition, by the name the condition gives; true when it holds

cue ​

ts
cue(name: string, params?: Record<string, unknown>): void;

Cues the cinematic: what waits for the cue goes on (untilCue), and its hooks run (cue:<name>). The rules' cues (cueCinematic) come here; code may cue its own. A cue nothing waits for is kept for the next wait of its name

defs ​

ts
readonly defs: CutDefs;

What it plays of cinematics as data (CutDefs): the defs on its clock, their markers, sections, cues and loops. play, section, seekTo, cue and the rest below are this

dialog ​

ts
readonly dialog: CutDialog;

The dialog: the lines said (say), queued behind the one showing with the rules' own, the history, and moving them on (CutDialog)

dolly ​

ts
dolly(by: number, seconds?: number, ease?: Ease | string): Promise<void>;

Dollies: the camera closer by by units of its distance (farther when more than 0, as a dolly out), in seconds. It keeps looking where it looks

eases ​

ts
get eases(): EaseRegistry;

The eases a key or a shot may name: the stage's (kit.eases: the client's own and the game's)

emit ​

ts
emit(hook: string, fields?: Omit<CutEvent, 'hook' | 'time'>): void;

Runs the hooks of a name, now, with what they are told (CutEvent): what the cut and the lanes do at their moments, and a lane's or a script's own (lane:melee.cheer:done). A hook that throws is said in the log and the others run; one that returns a promise is waited for before the cinematic is over

end ​

ts
end(): void;

Ends the defs playing as if they had reached their end: a branch that goes to the end

endLoop ​

ts
endLoop(): void;

Ends the loops of the defs playing (CinematicDef.loop): each plays on past its loop's end, to its own

entity ​

ts
entity(name: string, depth?: number): number | undefined;

The entity a name stands for: one a script gave the name (play(def, { units })), a ref of a def played that is a unit (resolved now: ref), or the one placed on the map under it in the editor; nothing for a name no one knows

env ​

ts
readonly env: CutEnv;

The world's look on this screen (B6, CutEnv): the hour drawn, weather, wind, mist; put back after

fade ​

ts
fade(opacity: number, seconds?: number): Promise<void>;

Blacks the screen out (opacity 1), or brings it back (0), over seconds, and settles when it is done. It stays as it was left, after the cinematic too: a game that ends on black has its end shown over it. The short form of screen.fade to the look's colour; on a stage with no screen of its own, the stage's fade

filter ​

ts
filter(keep: ClipFilter): () => void;

Leaves clips out by code: those it says no to are not played (with their when). Returns what takes it away

fit ​

ts
fit(targets: readonly (number | string)[], options?: {
        padding?: number;
        seconds?: number;
        ease?: Ease | string;
        pitch?: number;
        yaw?: number;
        fov?: number;
    }): Promise<void>;

Frames a group: the camera moved over their middle, as far as it takes to have all of them in the picture with padding units round them, in seconds (1 when left out). Stops following. For a group kept framed as it moves, follow(group, { fit: true })

focus ​

ts
focus(target: number | string, options?: {
        distance?: number;
        seconds?: number;
        ease?: Ease | string;
        pitch?: number;
        fov?: number;
    }): Promise<void>;

Pushes in on a unit: the camera over it, distance from it (12 when left out), in seconds (1 when left out)

follow ​

ts
follow(target: number | string | readonly (number | string)[] | null, options?: FollowOptions): void;

Keeps the camera on an entity (an id, or a unit's name) or a group from now on, catching up with it as options say (FollowOptions: distance, pitch, yaw, the lens; lag, lead, deadzone, offset, keep, fit for a group kept whole in the picture); until told to follow something else, moved by a shot, or all of it is gone. Null stops following. The code form of a follow clip of the camera lane

frame ​

ts
frame(dt: number): void;

Moves the cinematic on by a frame of the screen: its clock goes by dt at its rate (nothing while paused), its timers go off, and the camera keeps on what it follows. The client calls it every frame

fx ​

ts
fx(name: string, options?: Parameters<CutThings['fx']>[1]): FxHandle | undefined;

An effect of the game's at a spot or on a unit (a name, a ref, an id); stopped when the cinematic is over

handheld ​

ts
handheld(options?: HandheldOptions | null): void;

A camera held by hand: where it looks and which way wander a little (amount units, at speed), noise of the cut's clock, the same for the same seed (the cut's, seed, when left out). Null steadies it

hud ​

ts
readonly hud: CutHud;

The parts of the HUD that stay while it plays (B6, CutHud)

id ​

ts
id?: string;

The id of the cinematic it plays (the view's), set by the director: what the rules hear a choice of

input ​

ts
readonly input: CutInputs;

The player's keys and clicks while their hands are off, for the cinematic (CutInputs: key, click, on)

lane ​

ts
lane(kind: string): {
        state: Record<string, unknown>;
    };

What a lane keeps between its clips: a record of its own, by the lane's kind, cleared when the cut is skipped

lanes ​

ts
get lanes(): LaneRegistry;

The lanes a def is played with: the stage's (kit.lanes: the client's own and the game's)

log ​

ts
log: Logger;

Where it says what went wrong: the log of the game it is part of, once that has taken it (GameClient.log)

lookAt ​

ts
lookAt(target: number | string | null): void;

Keeps the camera turned to a unit wherever it stands or goes, whatever the shots do, until lookAt(null). The camera stays where the shots put it; only what it looks at is the unit

nextLine ​

ts
nextLine(): void;

Moves on from the line on the screen now, as Enter or a click on it does (CutDialog.next)

on ​

ts
on(hook: string, run: CutHook): () => void;

Hears a hook of the cinematic (see CutHooks for the names): cut.on('marker:gate', (cut) => cut.fx('flare')). What the view's entry gives as hooks is heard the same way. Returns what stops hearing it

orbit ​

ts
orbit(center: Vec2 | {
        entity: number;
    }, options: {
        radians: number;
        seconds?: number;
        distance?: number;
        pitch?: number;
        ease?: Ease | string;
    }): Promise<void>;

Orbits: the camera turned by radians around a spot or an entity (where it is then), in seconds, at the distance and the pitch given, or as it looks now. A full turn is 2π; the way round is the sign's

pan ​

ts
pan(by: Vec2, seconds?: number, ease?: Ease | string): Promise<void>;

Pans: the point looked at moved by by on the ground, in seconds; the rest as it is

params ​

ts
params: Record<string, unknown>;

What it was handed (PlayOptions.params, the script's params), with the defaults of the defs played filled in (A5): what { param } refs and conditions read

pick ​

ts
pick(id: string): boolean;

Picks an answer of the choice asked now, as a key or a click would. Whether one was asked

picking ​

ts
picking: ((id: string) => void) | undefined;

What picks the choice asked now: set while one is (choose)

picture ​

ts
readonly picture: CutPicture;

The picture (B5): its grade, bloom, sharpening, vignette, and the lens (depth of field, grain, aberration), eased on the cut's clock and taken away when it is over (CutPicture): the code form of the picture lane

play ​

ts
play(cinematic: CinematicDef | string, options?: {
        units?: Record<string, number>;
        at?: number;
    }): CutStep;

Plays a cinematic as data (CinematicDef, or one of the game's by its id: GameView.cinematics.defs): each of its lanes on the cut's time, by the lane's def (LaneDef: the client's own and the game's, stage.lanes), and settles when it is over. A sampled lane is set at every frame's time; a run lane's clips start at their moments and end when they are over; a seek plays everything again from the new time. A muted lane is passed over, and so is one of a kind no lane plays (a game's not registered here, or one whose item is not built yet). units are entities by the names the def calls them, where the screen cannot know them by their names on the map

plays ​

ts
plays(clip: Clip, lane: LaneData): boolean;

Whether a clip of a lane is played: its condition holds, and no filter of the script's leaves it out

preload ​

ts
preload(what: string | CinematicDef | readonly (string | CinematicDef)[], options?: {
        types?: string[];
        models?: string[];
    }): Promise<void>;

Loads ahead what cinematics of the game's (by id) or defs need, the models of unit types (types) and models by their path (models), so what comes next plays without a wait or a model popping in (D3). Settles when it is all loaded; not a step of the clock

prop ​

ts
prop(model: Parameters<CutThings['prop']>[0], at: Vec2, options?: Parameters<CutThings['prop']>[2]): Promise<CutProp | undefined>;

A model placed for the cinematic alone (B6): a ModelDef or a unit type's, at a spot, turned and sized, playing a clip where given; taken away when it is over. Settles with it once its model has loaded

race ​

ts
race(steps: readonly Promise<void>[]): Promise<void>;

Goes on once the first of the steps is over, and lets go of the others

rail ​

ts
rail(path: string, options?: RailOptions): Promise<void>;

A run along a path of the map by its name (MapPath: a road), as a camera on tracks: cut to where the run starts, then along the path for seconds, facing the way it goes, its bends rounded when smooth (cut.rail('road', { seconds: 6, distance: 15, pitch: 0.7, smooth: true })). Stops following. Nothing but a warning for a path the map has not. The code form of a rail key of the camera lane

ref ​

ts
ref(name: string, depth?: number): RefValue | undefined;

What a name of the cinematic stands for now (A5): a unit a script named, a ref of a def played (a unit of the map, a param, the unit that answers a query of what the screen sees, a region's middle, a view, the game's code), or a unit of the map by its name. Resolved as it is asked: the unit nearest the gate when the clip runs

resolve ​

ts
resolve(name: string, resolver: RefResolver): void;

Code that answers a { code: name } ref; what it gives back is the ref (an id, a point, a unit's name, a RefValue)

resolvers ​

ts
readonly resolvers: Map<string, RefResolver>;

Code answering { code } refs and { hook } conditions, by name: the view's entry's and the script's

running ​

ts
running(of?: {
        lane?: string;
        id?: string;
    }): RunningClip[];

The clips of its defs playing now, each with what its lane gives code to reach (RunningClip.handle): every one, those of a lane's kind ({ lane: 'video' }), or the one with an id ({ id: 'intro-film' })

runningOf ​

ts
runningOf(of: string | LaneItem): RunningClip | undefined;

The clip playing now with this id (or this item), where one is: cut.runningOf('intro-film')?.handle

say ​

ts
say(speaker: string, text: string | MessageRef, options?: number | SayOptions): Promise<void>;

Says a line of dialog: a speaker of the view's (GameView.cinematics.speakers) and the words (or a message of the game's, by its key), shown for seconds (as long as they take to read when left out), then taken away, and settles then. Said while another line shows, it waits its turn, and its seconds count from when it shows. Enter or a click moves it on early. options says the rest of how (SayOptions: it waits to be moved on, the side, a typewriter, the voice, the box); a number is its seconds, Infinity a line that waits

screen ​

ts
readonly screen: CutScreen;

The screen: the letterbox, the aspect, a fade, a vignette, a tint, an overlay, a crop, a blur, eased on the cut's clock (CutScreen): the code form of the screen lane

screenTimers ​

ts
readonly screenTimers: ViewTimers;

Timers of the screen's time while the cinematic is not paused, moving while something holds its clock still (a wait, a line that waits): what a wait's timeout counts (D2)

section ​

ts
section(name: string): Promise<void>;

Plays a section of the defs playing (D3): from its marker (kind: 'section') to the next section's, or the end; settles when the clock gets there. The defs play on after it unless the script does otherwise

seed ​

ts
seed: number;

The seed of what is random to look at in it (a handheld camera's wander): the same seed, the same picture, on every screen and in the editor. The director sets it from PlayOptions.seed, or the cinematic's id

seek ​

ts
seek(time: number): void;

Jumps the cinematic to a time (see CutClock.seek): a def playing is where it says at that moment

seekTo ​

ts
seekTo(marker: string): boolean;

Jumps to a marker of a def played (see seek). Whether there is one by that name

sequence ​

ts
sequence(steps: readonly UnitStep[], unit?: string): CutStep;

Has units do things one after another, as a sequence of the units lane does: each step starts as the one before ends (an order's end: the unit idle, or the unit it was sent at dead; a clip's end; its for), together starts several at once. unit is whose a step is that names none. As a step of the cut: over when the last is

settled ​

ts
settled(): Promise<void>;

Settles once what the hooks returned has: a hook's last step is done before the cinematic is over

shake ​

ts
shake(strength?: number): void;

Shakes the camera, so hard (as a blast nearby does): it settles by itself. Nothing on a stage that cannot

shot ​

ts
shot(key: CameraKey | string | readonly (CameraKey | string)[], options?: ShotOptions): Promise<void>;

A shot: the camera moved to a pose in seconds (at once when none), along a curve (ease, gently when left out), and the hook shot as it gets there. The pose is a key (what it leaves out stays as it is: at: entity: id , distance: 15, fov: 50 ), a view of the map by its name, or several of either: a move through them all, along a smooth curve (path), with the time shared out by the distance. Stops following. The code form of a key of the camera lane; dolly, zoom, orbit, pan and tilt make shots of their own

shots ​

ts
readonly shots: CutShots;

The camera (CutShots): shots, moves, a group framed, a unit followed or looked at, a handheld wander, a shake, the transitions between shots. camera, shot, follow and the rest below are this

skip ​

ts
skip(): void;

Ends every step, and with them the script: the player skipped it

skipped ​

ts
skipped: boolean;

Set once it is skipped: every step from then on is over at once

soundSeconds ​

ts
soundSeconds(name: string): number | undefined;

How long a sound of the game's is, in seconds, once it is loaded: a voice's, for a line as long as it (CI2). Nothing where the stage does not know

speed ​

ts
readonly speed: CutTime;

Slow motion and freezes (B6, CutTime): the game's speed where it runs in this page, the animations' everywhere. (time is the clock's seconds)

stage ​

ts
readonly stage: Stage;

What it is played on: the client, as far as cinematics go, or a stage of a test's or the editor's

state ​

ts
readonly state: {
        entities(): readonly CutEntity[];
        get(id: number): CutEntity | undefined;
    };

What the screen sees of the game now, read-only: its entities (CutEntity), one by id. Indexed by id once a frame, the first time one is asked for in it

step ​

ts
step(start: (done: () => void) => () => void): CutStep;

A step of the cut's own, waited for: it settles when start calls the done it is given, and throws Skipped when the cut is skipped, calling what start gave back so the step takes away what it put up. Every step of the cut (a shot, a wait, a line) is one; a game's own steps may be too

stopClip ​

ts
stopClip(id: number): void;

Stops the clip an entity plays on demand (clip, a units lane's, client.playClip), once or over and over, where it is: back to what it keeps doing, and a cut.clip waiting for it settles

tilt ​

ts
tilt(radians: number, seconds?: number, ease?: Ease | string): Promise<void>;

Tilts: the pitch changed by radians (down towards the ground when more than 0), in seconds

time ​

ts
get time(): number;

Seconds of the cinematic gone by, on its clock

timers ​

ts
readonly timers: ViewTimers;

The cut's own timers, moved by its clock: nothing in a cinematic goes by the screen's

track ​

ts
track(track: CinematicTrack | string, units?: Record<string, number>): Promise<void>;

Deprecated

A track is a cinematic of three lanes: cut.play(def) plays one as data, with any lanes

Plays a track (CinematicTrack, or a game's by its name): the camera from key to key, the lines at their moments, the clips on their units, and settles when it is over. units are the entities of names the track plays clips on, where the screen cannot know them by their names on the map

transition ​

ts
transition(which: string | TransitionDef, options?: TransitionOptions): Promise<void>;

A transition at a cut (B3): the last frame drawn is kept, and the new shot comes in over it for seconds (0.6 when left out), as the transition's mask has it (a dissolve, a wipe, an iris opening on a unit, a fade through a colour). Called just before the camera cuts (or with shot(..., { transition })), and settles when it is over. By id among transitions, or a def; the hook transition hears it. A skip lets go of it at once

transitions ​

ts
get transitions(): TransitionRegistry;

The transitions a cut may name: the stage's (client.transitions: the client's own and the game's)

tween ​

ts
tween(seconds: number, step: (t: number) => void, ease?: Ease | string): Promise<void>;

A step of the cut's own: step every frame for seconds of the cut's clock with how far along it is (0..1, through ease, 1 at the end), and settles then. What a script's own easing of anything goes on: a pause holds it, a skip ends it

ui ​

ts
readonly ui: CutUi;

The cinematic's own interface (C4): elements and components on the screen, over the HUD, or pinned in the world; Babylon's GUI. Everything it puts up is taken away when it is over (CutUi)

uiParts ​

ts
readonly uiParts: Map<string, CutUiContent>;

The parts of interface the ui lane's clips name, by name: the view's cinematic entry's (ui), or the script's

units ​

ts
readonly units: CutUnits;

Units hidden, tinted, inked, flashed, pinged (B6, CutUnits); put back after

until ​

ts
until(test: () => boolean, seconds?: number): Promise<void>;

Waits until test holds, checked every frame; or seconds at most

untilClick ​

ts
untilClick(seconds?: number): Promise<void>;

Waits for a click on the picture, seconds at most

untilCue ​

ts
untilCue(name: string, seconds?: number): Promise<void>;

Waits for a cue (cue, or the rules' cueCinematic), or seconds at most: one heard before that nothing waited for ends it at once. Every wait for a name goes on at its cue

untilEvent ​

ts
untilEvent(type: string, filter?: {
        unit?: string;
        match?: Record<string, unknown> | ((event: SessionEvent) => boolean);
    }, seconds?: number): Promise<void>;

Waits for an event of the game's ('death', 'line', a game's own 'game' event...), one that is about a unit (unit: a name or a ref whose entity is the event's id) or has fields of values (match, or a test of it), seconds at most: a unit's death, a line said

untilKey ​

ts
untilKey(key?: string, seconds?: number): Promise<void>;

Waits for a key (its code, 'Enter', 'KeyE', or what it makes, 'e'; any but Esc when left out), seconds at most: the player's hands are off, but this key is the cinematic's. Enter on a line moves the line on instead

untilMarker ​

ts
untilMarker(name: string): Promise<void>;

Waits until the time reaches a marker of a def playing (its hook marker:<name>): at once for one already passed. A def played after the wait began counts: its marker is heard when it is reached

untilWhen ​

ts
untilWhen(condition: Condition, seconds?: number): Promise<void>;

Waits until a condition holds ({ ref: 'gate', alive: false }, the world's { arrived: 'hero' }, { dead: 'gate' }, { inRange: ['hero', 'gate', 6] }), checked each frame, seconds at most

video ​

ts
video(src: string, options?: VideoOptions): CutVideo | undefined;

A video file over the scene (CN51), as a clip of the video lane plays one from now (VideoOptions: its box, its look, its coming in and going out, for seconds or until the file ends), on the cut's clock. Gives back what code reaches of it (CutVideo: its element, stop, done), heard as a clip of the video lane (lane:video:start, item:<id>:end...) and among those running; taken off the screen when it is over, or skipped. Nothing where the stage has no such file, or nowhere to draw it

wait ​

ts
wait(seconds: number): Promise<void>;

Waits seconds of the screen's time

where ​

ts
where(id: number): Vec2 | undefined;

Where an entity is on the screen now, or nothing for one gone or out of sight: for until

zoom ​

ts
zoom(to: {
        fov?: number;
        distance?: number;
    }, seconds?: number, ease?: Ease | string): Promise<void>;

Zooms: to a lens (fov, degrees: a long lens is a small angle) and, or, a distance, in seconds. A zoom of the lens flattens the picture as a real one does; a dolly does not