Renderer · class

CinematicCamera

Explained in Hello world.

class CinematicCamera
import { CinematicCamera } from '@driftengine/core';

Constructor

new

constructor(colliders: ColliderSet)
ParameterTypeDescription
collidersColliderSet

Properties

NameTypeDescription
camerareadonlyCamera

Accessors

NameTypeDescription
shotAgeSecgetnumberSeconds since the current shot began.

Methods

cut

cut(shot: ShotParams, atSec: number): void

Switch shots, now.

ParameterTypeDescription
shotShotParams
atSecnumber
More

atSec is the shot's own start time, used by anything that animates within a shot — an orbit's angle, for instance — so a shot looks the same whenever in the run it is used.

snap

snap(): void

Drop the smoothing history, keeping the shot.

More

For a subject that teleports — a character who died and is back on a checkpoint, or a scrub bar dropped somewhere else in the run. Smoothing across that is a camera flying the length of the route with nothing in frame, measured at 124 m inside a single shot, and it looks far more like a bug than a cut does.

A threshold inside update would be the wrong place for this. Only the caller can tell a teleport from a legitimately fast frame: a replay catching up after a freeze advances several simulation ticks in one frame, and a browser that dropped a frame advances a dozen. That is also why this is not cut — the two differ over whether the speed across the frame means anything, and the caller is the only one who knows.

update

update(frameDt: number, subjectX: number, subjectY: number, subjectZ: number, subjectYaw: number): void
ParameterTypeDescription
frameDtnumber
subjectXnumber
subjectYnumber
subjectZnumber
subjectYawnumber