flickShot ShotCam maths, with no engine state: the high three-quarter
chase pose behind a shooter body looking toward a target (`goal`), the
portrait/landscape field of view (`fovFor`), the lifted fly-to sweep
(`flyPose`), exponential follow smoothing and a look-rotation quaternion.
The ShotCam component drives a camera with these; games and tests can
call them directly.
lookRotation(f: vector) → void
Quaternion { x, y, z, w } that turns a camera's forward (-Z) onto the unit direction `f`.
| arg | type | description |
|---|
| f | vector | |
heading(subject: vector, target: vector?, yaw: number?) → vector
The horizontal unit heading from `subject` toward `target`, or the `yaw` heading (degrees from -Z) when there is no target or it is right above the subject.
| arg | type | description |
|---|
| subject | vector | |
| target | vector? | |
| yaw | number? | |
goal(subject: vector, target: vector?, cfg: any, ease: number?) → void
Where the camera wants to be for a subject at `subject` looking toward `target` (nil: the yaw heading): behind it and above it, scaled by `ease` (1 normal, aimEaseOut while aiming). Answers eye, lookAt.
| arg | type | description |
|---|
| subject | vector | |
| target | vector? | |
| cfg | any | |
| ease | number? | |
fovFor(w: number, h: number, landscape: number, portrait: number) → number
Vertical field of view for a w x h view: `landscape` at aspect 1 or wider, rising to `portrait` at a 9:16 phone held upright, so the shot keeps its width when the phone turns.
| arg | type | description |
|---|
| w | number | |
| h | number | |
| landscape | number | |
| portrait | number | |
orbitPose(centre: vector, angle: number, radius: number, height: number, drop: number) → void
The pose of a slow orbit around `centre` (a backdrop for a title or a lobby): the eye stands `radius` metres out and `height` metres up at `angle` radians around the vertical (0 = on +Z), looking at a point `drop` metres below the centre. Answers eye, lookAt.
| arg | type | description |
|---|
| centre | vector | |
| angle | number | |
| radius | number | |
| height | number | |
| drop | number | |
toVector(p: any) → vector
A world position from a vector, an { x, y, z } or { x, y, z } array table, or an entity (its position); nil for anything else. Safe on entities, which throw on fields they do not have.
smoothstep(x: number) → number
0..1 ease in and out.
| arg | type | description |
|---|
| x | number | |
followAlpha(rate: number, dt: number) → number
Exponential follow: the share of the way to move this frame for a smoothing `rate` (per second) over `dt`.
| arg | type | description |
|---|
| rate | number | |
| dt | number | |
flyPose(eye0: vector, at0: vector, eye1: vector, at1: vector, t: number, lift: number) → void
The pose part way through a fly-to sweep: from (`eye0`, `at0`) to (`eye1`, `at1`) at progress `t` 0..1 (eased), lifted by up to `lift` metres mid-way. Answers eye, lookAt.
| arg | type | description |
|---|
| eye0 | vector | |
| at0 | vector | |
| eye1 | vector | |
| at1 | vector | |
| t | number | |
| lift | number | |