@ferret/vfx
Special effects: fire and smoke, explosions and weapons, water, steam and dust, energy. Effects are JSON definitions with parameters and expressions, drawn on a ladder of volume, GPU particles, impostors and dots, fed by the physics events or placed by hand, with their sound, and acting on sight, light and fire spread.
Classes
BakedVolumePlayer class
class BakedVolumePlayer implements VolumeSourcea baked sequence played at the instance's time, the two nearest frames blended
readonly n: number | voxels along each side of the texture |
readonly size: number | metres along each side of the box the volume fills |
readonly scale: number | a point of the box at uvw in 0..1 reads the texture at uvw * scale + bias |
readonly bias: number | |
readonly data: Uint8Array | two bytes per voxel: density, heat |
readonly densityMax: number | |
readonly heatMax: number | the temperature a full heat byte means, and the air's (a zero one), kelvin |
readonly ambient: number | |
version: number | changes whenever data does, so the view uploads only what is new |
constructor(private readonly src: BakedVolumeData, private readonly def: VolumeRender) | |
origin(inst: Instance, out: [number, number, number]): void | the lowest corner of the box in the world |
update(inst: Instance, _dt: number): boolean | advances to the time of the instance; true when data changed |
packages/vfx/src/volume.ts:159
BatchData class
class BatchDatathe arrays of one batch of billboards, streaks or ribbon segments (four floats each, ready for the instance buffers)
n: number | |
cap: number | |
pos: Float32Array | x, y, z (relative to the batch origin) and size; a ribbon segment: its start and the width there |
col: Float32Array | r, g, b, alpha |
misc: Float32Array | rotation (radians), the position in the flipbook 0..1, glow multiplier, soft-fade distance (streak: length in metres) |
vel: Float32Array | velocity (streak) or the end point and the width there (ribbon segment) |
keys: Float32Array | the sort key, larger drawn first |
constructor(cap = 256) | |
grow(cap: number) | |
next(): number | a free slot (the arrays grow by doubling) |
clear() |
packages/vfx/src/gather.ts:11
DecalScheduler class
class DecalSchedulerdecides when the decals of instances appear: once each, at start, at a number of seconds, or at end (stopped or ended)
due(inst: Instance): DecalSpec[] | the decals due now for this instance (their positions are the instance's, the view puts them on the ground) |
forget(live: ReadonlySet<number>): void |
packages/vfx/src/parts.ts:127
DropletPool class
class DropletPoolreadonly capacity: number | |
readonly parcels: Float32Array | |
readonly emitterData: Float32Array | |
readonly impacts: Float32Array | |
impactCount: number | |
head: number | |
time: number | |
readonly liquid: LiquidProps | |
readonly diffusivity: number | |
readonly cloud0: number | |
readonly maxImpacts: number | |
readonly seed: number | |
alive: number | parcels alive after the last step |
constructor(o: DropletPoolOptions) | |
plan(emitters: readonly DropletEmitter[], dt: number): number | pack this step's emission: the number of new parcels; the GPU execution uses the same packing |
advance(total: number): void | advance the head after total parcels were emitted (the ring) |
step(emitters: readonly DropletEmitter[], dt: number, air: DropletAir, surface: SurfaceGrid | null): void | one step on the CPU: emit, move, break up, land |
packages/vfx/src/droplets.ts:183
DropletView class
class DropletViewreadonly gpu: boolean | |
readonly capacity: number | |
readonly mesh: BABYLON.Mesh | |
readonly material: BABYLON.ShaderMaterial | |
impacts: Float32Array | impacts on water of the last step that came back: x z diameter speed, impactCount of them |
impactCount: number | |
get alive(): number | parcels alive (the CPU path counts them; the GPU path does not read them back: -1) |
constructor(readonly scene: BABYLON.Scene, readonly o: DropletViewOptions = {}) | |
step(emitters: readonly DropletEmitter[], dt: number, air: DropletAir, surface: SurfaceGrid | null): void | one step: the emitters shed parcels, all parcels move in the air and land; on WebGPU this only records compute passes |
dispose(): void |
packages/vfx/src/droplets-view.ts:90
Exposure class
class Exposurea target that accumulates heating over time: the share of its time to ignition it has used (exposure adds as dt over the ignition time at that flux)
constructor(readonly material: Combustible, readonly T0 = 293.15) | |
add(flux: number, dt: number): boolean | adds dt seconds at the given flux; true once the surface has reached its ignition temperature |
get fraction() | |
reset() |
packages/vfx/src/spread.ts:290
ExprError class
class ExprError extends Errorconstructor(message: string, readonly at: number) |
packages/vfx/src/expr.ts:6
FireBridge class
class FireBridgeconstructor(private sim: VfxSim, readonly spread: FireSpread | null, private o: BridgeOptions = {}) | |
addTarget(t: Target) | |
apply(events: SpreadEvent[]) | puts the model's events in the world: call after spread.step(t) with what it returned |
adopt(events: SpreadEvent[], find: (def: string, seed: number) => VfxHandle | undefined, cellEffect = this.o.cellEffect ?? 'fire.grass') | After a late join: the cells that burn now already have their effects (they came in the simulation's snapshot); this finds them again by (effect, seed) so
apply can stop them when the cell goes out. events are what the front's replay gave; find looks up a live effect by its definition name and seed. |
heat(fires: Array<{ at: Vec3; power: number }>, dt: number) | the heat the fires of the scene deliver to the targets in dt seconds; targets that reach ignition catch (vfx:ignite with cause heat) |
burning(): Array<{ at: Vec3; power: number }> | the fire effects burning now, as (position, power) for heat |
water(targetId: number, flow: number, efficiency = 1): boolean | water of mass flow flow (kg/s) reaches the burning target : its power falls by the energy balance (a rate against a rate), and at zero it is out (vfx:out, cause water) |
packages/vfx/src/spread-bridge.ts:25
FireSpread class
class FireSpreadA fire front on a grid of fuel cells. A cell burns from its arrival for the residence time of its fuel. The arrival at a neighbour is the arrival here plus the distance over the speed along that edge, taken from the ellipse of a point fire under the wind and slope at the moment the source cell ignites; the earliest arrival wins. Time is advanced by step(t); everything is a function of the inputs, so the same inputs give the same fire.
readonly cells: Cell[] | |
constructor(readonly grid: SpreadGrid, private env: SpreadEnv, private o: SpreadOptions = {}) | |
index(ix: number, iz: number) | |
cellAt(x: number, z: number): number | |
centre(i: number): [number, number] | |
setFuel(i: number, bed: FuelBed | null, moisture?: number) | |
setMoisture(i: number, m: number) | |
wet(i: number, moisture: number, t: number, events?: SpreadEvent[]) | rain or water on a cell wets its fuel; a wet enough cell cannot burn and one that is burning is put out |
ignite(i: number, t: number, from?: number): boolean | lights a cell at time t; false if it cannot burn |
get burningCells(): ReadonlySet<number> | |
get spots() | |
step(t: number): SpreadEvent[] | advances the fire to time t; returns what happened since the last call, in time order |
packages/vfx/src/spread.ts:172
FluidGrid class
class FluidGrida cubic grid of cells with a solid one-cell wall around (the floor and the sides), velocity, density and temperature
readonly nx: number | |
readonly ny: number | |
readonly nz: number | |
readonly u: Float32Array | |
readonly v: Float32Array | |
readonly w: Float32Array | |
readonly d: Float32Array | |
readonly t: Float32Array | |
readonly o: GridOptions | |
time: number | |
constructor(nx: number, ny: number, nz: number, readonly seed: number, o: Partial<GridOptions> = {}) | |
get size(): number | |
idx(x: number, y: number, z: number): number | |
addSphere(cx: number, cy: number, cz: number, r: number, s: { density?: number; temperature?: number; up?: number; out?: number; set?: boolean }): void | adds a soft sphere of density, heat and an outward + upward velocity; (cx, cy, cz) and r are in cells |
step(dt: number): void | one step of dt seconds |
project(): void | subtracts the gradient of the pressure that makes the velocity divergence-free |
sample(f: Float32Array, x: number, y: number, z: number): number | trilinear sample of a field at a position in cells (clamped inside the grid) |
divergence(): number | the divergence of the velocity, summed in absolute value (for tests) |
mass(): number | total density (for tests) |
packages/vfx/src/grid.ts:40
Governor class
class Governorlevel: number | |
constructor(readonly o: GovernorOptions) | |
get step(): GovernorStep | |
update(frameMs: number, particles = 0): boolean | feed one frame: the time effects took and the number of live particles; returns true if the level changed |
apply(sys: VfxSystem) | puts the current step on a simulation (the rung cap is read by the view from step.cap) |
reset() |
packages/vfx/src/governor.ts:41
LibraryTextures class
class LibraryTextures implements TextureProviderThe library's flipbooks (baked in F2) under the ids the definitions already use. preload brings the images from the library and decodes them; until an id is
loaded, or when the library does not have it, get falls back to the provider it was given (the generated one), so an effect never waits and never fails to draw.
constructor(private load: (id: string) => Promise<LibraryFlipbook>, private fallback: TextureProvider = new ProceduralTextures()) | |
async preload(ids: string[], scene: BABYLON.Scene): Promise<string[]> | loads these ids into the scene; an id the library lacks is skipped (and reported in the returned list) |
put(id: string, lf: LibraryFlipbook, scene: BABYLON.Scene): boolean | uses these images for the id at once (a flipbook just baked, or one the caller loaded itself); replaces any earlier one; false if there is no color image |
get(id: string | undefined, scene: BABYLON.Scene): Flipbook | |
dispose(): void |
packages/vfx/src/textures.ts:80
LightBudget class
class LightBudgetWhich lights the frame can afford. The score is the light's contribution at the camera, intensity x range^2 / (distance^2 + 1); the best max win, the ones that were
lit last frame get a bonus so two close scores do not swap every frame, and a light fades in and out over fade seconds so none pops.
constructor(public max: number, readonly fade = 0.3, readonly bonus = 1.3) | |
update(cands: ReadonlyArray<LightState>, cam: readonly [number, number, number], dt: number): Array<{ light: LightState; weight: number }> | returns the lights to show with their fade weight (0..1); dt seconds since the last call |
get lit(): number | lights that are lit or fading now |
packages/vfx/src/parts.ts:76
LiveVolume class
class LiveVolume implements VolumeSourcea live grid, fed by particles
readonly n: number | voxels along each side of the texture |
readonly size: number | metres along each side of the box the volume fills |
readonly scale: number | a point of the box at uvw in 0..1 reads the texture at uvw * scale + bias |
readonly bias: number | |
readonly data: Uint8Array | two bytes per voxel: density, heat |
readonly densityMax: number | |
readonly heatMax: number | the temperature a full heat byte means, and the air's (a zero one), kelvin |
readonly ambient: 300 | |
version: number | changes whenever data does, so the view uploads only what is new |
readonly grid: FluidGrid | |
constructor(private readonly def: VolumeRender, o: LiveOptions = {}) | |
origin(inst: Instance, out: [number, number, number]): void | the lowest corner of the box in the world |
update(inst: Instance, dt: number): boolean | advances to the time of the instance; true when data changed |
packages/vfx/src/volume.ts:45
PartsLayer class
class PartsLayerstats: { lights: number; strips: number; dots: number; decals: number; glows: number; } | |
constructor(private readonly scene: BABYLON.Scene, private readonly o: PartsViewOptions = {}) | |
get maxLights(): number | |
begin(): void | |
setLights(chosen: ReadonlyArray<{ light: LightState; weight: number }>): void | the lights the budget chose, with their fade weight |
addStrip(foot: readonly [number, number, number], s: StripShape, fade: number): void | a distant plume: a strip standing on foot (camera-relative); fade is the cross-fade weight of the rung |
addDot(at: readonly [number, number, number], d: DotLook, fade: number): void | a dot: at camera-relative, sized in the world to be a few pixels across |
addGlow(at: readonly [number, number, number], rgb: readonly [number, number, number], radius: number, alpha: number): void | the cheap glow of a light that did not fit the budget: a soft additive disc, radius metres, alpha by distance |
placeDecal(spec: DecalSpec): void | puts a decal on the ground (or on the first mesh below it) and keeps it for its life |
dropDecals(owners: ReadonlySet<number>): void | removes the decals of effects that were taken away by hand (an editor's remove or undo) |
drawDecals(dt: number, cam: readonly [number, number, number]): void | advances the clock and writes the live decals; cam is the camera's position |
end(): void | |
bind(view: BABYLON.Matrix, proj: BABYLON.Matrix, light: BABYLON.Vector3): void | light is the scene's light on things that do not glow (the covering strips and smudges take it; fire glow does not) |
get decalCount(): number | |
dispose(): void |
packages/vfx/src/parts-view.ts:149
Pool class
class Poolthe structure of arrays that holds the live particles of one emitter of one instance; views read it directly
n: number | |
cap: number | |
px: Float64Array | |
py: Float64Array | |
pz: Float64Array | |
vx: Float32Array | |
vy: Float32Array | |
vz: Float32Array | |
age: Float32Array | |
life: Float32Array | |
size0: Float32Array | |
size: Float32Array | |
rot: Float32Array | |
spin: Float32Array | |
temp: Float32Array | |
rnd: Float32Array | |
id: Uint32Array | the spawn index of the particle in its emitter: stable, and ascending with age |
constructor(readonly max: number) | |
push(): number | a free slot, or -1 when the pool is at its maximum |
remove(i: number) | removes slot i by moving the last particle into it (the order of slots is not the order of age: sort by id when order matters) |
clear() | |
toJSON() | |
static fromJSON(max: number, j: { n: number } & Record<string, number[]>): Pool |
packages/vfx/src/sim.ts:31
ProceduralTextures class
class ProceduralTextures implements TextureProvidermakes the generated flipbooks on demand, once per scene and id; an id it does not know gets the soft disc
get(id: string | undefined, scene: BABYLON.Scene): Flipbook | |
dispose() |
packages/vfx/src/textures.ts:47
RungTracker class
class RungTrackerthe rung of one effect over time, with its cross-fade
rung: Rung | |
from: Rung | null | |
fade: number | 0..1, how far the cross-fade from from to rung has gone (1 when there is no cross-fade) |
pixels: number | |
constructor(readonly def: Pick<VfxDef, 'emitters' | 'volume' | 'impostor' | 'dot' | 'rungs'>, readonly fadeTime = 0.25) | |
update(pixels: number, tier: VfxTier, dt: number, cap: Rung = 'volume'): RungState | |
get state(): RungState |
packages/vfx/src/select.ts:47
SmokeSight class
class SmokeSight implements VfxSightthe smoke of a simulation as a sight contract; at is a hook for extra volumes of the host (a room full of smoke)
constructor(private sim: VfxSystem) | |
addSphere(c: Vec3, r: number, extinction: number): number | a volume of the host's own: the sphere of a room, an area of fog; returns an id to remove it by |
remove(id: number) | |
volumeOf(inst: Instance): { shape: 'sphere' | 'column' | 'slab'; c: Vec3; r: number; y0: number; h: number; K: number } | null | the smoke volumes of one instance now: shape, centre, radius, height and extinction |
opticalDepth(a: Vec3, b: Vec3): number | the optical depth (integral of extinction, dimensionless) along the segment a..b through every smoke in the sim |
transmittance(a: Vec3, b: Vec3): number | exp(-opticalDepth): the share of light that gets through, 1 clear .. 0 hidden |
visible(a: Vec3, b: Vec3, minContrast = 0.02): boolean | can an eye at a see a thing at b through the smoke (contrast left of at least 2 %, or the minContrast given) |
packages/vfx/src/sight.ts:59
SurfaceGrid class
class SurfaceGridThe surface the parcels fall onto round a moving centre: per cell the ground height and the water level (NaN-free: no water is -1e9). Cells are asked of the game only when they come into the window (the window scrolls in whole cells), so a costly height query runs for one row at a time.
readonly data: Float32Array | |
originX: number | |
originZ: number | |
constructor(readonly n: number, readonly cell: number, readonly query: (x: number, z: number) => { ground: number; water: number }) | |
follow(x: number, z: number): boolean | centre the window on x, z; returns true when cells changed |
at(x: number, z: number): { y: number; water: boolean } | the surface under x, z: the higher of ground and water, and whether it is water; outside the window: no surface |
packages/vfx/src/droplets.ts:128
VfxBabylonView class
class VfxBabylonView implements VfxViewreadonly budget: { particles: number; lights: number; overdraw: number; } | the budget the governor holds the view to: particles drawn, lights, and the share of overdraw |
readonly stats: VfxViewStats | |
cap: Rung | the richest rung the governor allows now |
readonly textures: TextureProvider | |
constructor(readonly scene: BABYLON.Scene, readonly sys: VfxSystem, readonly camera: BABYLON.Camera, readonly o: VfxBabylonViewOptions = {}) | |
draw(frame: ViewFrame): void | |
partsStats(): { lights: number; strips: number; dots: number; decals: number; glows: number } | what the lights, decals and far rungs drew in the last frame |
rungOf(h: VfxHandle): RungState | undefined | |
dispose(): void |
packages/vfx/src/view.ts:157
VfxReplica class
class VfxReplicalate: number | commands that arrived after their time |
applied: number | commands applied |
synced: boolean | true once the state of an answering peer has been taken (a peer that is the first in the room never gets one and is alone after a while: the game decides). A peer that has just joined should wait for it before it gives commands: those it gives before are dropped by the sync |
constructor(readonly sys: VfxSystem, private o: ReplicaOptions) | |
spawn(def: string, o: { at: Vec3; dir?: Vec3; params?: Record<string, number>; seed?: number; attach?: { entity: number; node?: string } }): string | starts an effect everywhere; returns its network id. The seed is chosen from the id, so every peer makes the same particles |
stop(net: string, immediate = false): void | |
setParam(net: string, name: string, value: number): void | |
ignite(cell: number): void | |
wet(cell: number, moisture: number): void | |
receive(m: VfxMsg): void | a command from another peer |
hello(from: string): void | a peer says hello (it has just joined): answer it with the state |
sync(): VfxSync | |
join(): void | says hello to the others: call when this peer has joined |
adopt(s: VfxSync): void | the state of an answering peer: restore it (the commands queued before it are dropped: the snapshot already has their effect) |
step(dt: number): void | one fixed step: applies the commands whose time has come, advances the simulation by dt, and the fire front to the new time |
asSim(): VfxSim | A VfxSim whose spawns, stops and parameters go through the replica, for driveFromPhysics(bus, replica.asSim(), ...) on the peer that owns the physics:
the effects its events start then appear on every peer. (If every peer runs the physics, drive the plain sim on each instead and do not replicate: the same
events make the same effects everywhere.) Handles are local numbers for the network ids it started. |
handleOf(net: string): { id: number } | undefined | the local handle of an effect by its network id |
packages/vfx/src/vfx-net.ts:53
VfxService class
class VfxServiceThe service a game adds to its world (world.addService(new VfxService(session))): it registers the commands, steps the simulation in the fixed step (through the replica when there is one, so the network's order holds) and takes the level's vfx block while the level is loaded (the level loader finds it as the service named vfx, as it finds physics.host). Structural, so it needs no import of the engine core.
readonly name: "vfx" | |
constructor(readonly session: VfxSession, readonly o: { replica?: { step(dt: number): void }; view?: { cap: Rung } } = {}) | |
qualityKnobs(): { id: string; label: string; load: 'both'; steps: number; visibility: (l: number) => number; apply(l: number): void }[] | a knob for the quality regulator (QualityService finds it): the governor's steps, richest first (no volume, fewer spawns, shorter lives) |
init(world: { commands?: CommandHost }): void | |
fixedUpdate(dt: number): void | |
beginLevel(block: VfxBlock): string[] | |
endLevel(): void | |
dispose(): void |
packages/vfx/src/vfx-commands.ts:271
VfxSession class
class VfxSessionreadonly placed: Map<string, VfxPlacement & { handle: number; }> | what an author placed in the level, in order |
constructor(readonly sys: VfxSystem, readonly o: { sight?: SmokeSight; depth?: number } = {}) | |
get canUndo(): boolean | |
get canRedo(): boolean | |
undo(): string | null | |
redo(): string | null | |
spawn(def: string, o: { at: Vec3; dir?: Vec3; params?: Record<string, number>; seed?: number; attach?: { entity: number; node?: string }; delay?: number }): number | starts an effect; undo removes it, redo puts back the same effect |
stop(id: number, immediate = false): boolean | |
remove(id: number): boolean | |
setParam(id: number, name: string, value: number): number | |
attach(id: number, attach: { entity: number; node?: string } | null): boolean | |
place(p: VfxPlacement): number | |
unplace(id: string): boolean | |
manifest(): VfxBlock | the vfx block that holds what has been placed and the definitions the session made |
defCreate(def: VfxDef): void | registers a definition (or replaces the one of that name); throws with every problem listed; undo puts the old one back |
defPatch(name: string, ops: PatchOp[]): VfxDef | |
defRemove(name: string): boolean | |
validate(def: unknown): Issue[] | |
beginLevel(block: VfxBlock): string[] | registers the level's definitions and starts its placements; returns warnings (a bad entry is skipped, the rest is made) |
endLevel(): void | the level goes: its placements are removed and its definitions forgotten |
packages/vfx/src/vfx-commands.ts:85
VfxSoundPlayer class
class VfxSoundPlayerconstructor(private o: SoundPlayerOptions) | |
spawned(id: number, defName: string, at: Vec3, params: Record<string, number> = {}): void | an effect started at at with params (the ones set for it; the rest are the definition's defaults) |
setParam(id: number, name: string, value: number): void | a parameter of a running effect changed: the loops follow it |
stopped(id: number, fade = 0.8): void | an effect ended: its loops fade out |
update(): void | every frame (or a few times a second): loops start inside the audible radius and stop outside it (the distance law itself is the audio service's panner: inverse from a thirtieth of the radius to the radius, as loudnessAt; the lowpass is set when a sound starts) |
get count(): number | the number of effects whose sound is being tracked |
dispose(): void |
packages/vfx/src/sound-play.ts:36
VfxSystem class
class VfxSystem implements VfxSimreadonly defs: Map<string, CompiledDef> | |
host: VfxHost | |
quality: { spawn: number; life: number; } | the share of spawns that go ahead (thinning, by particle index) and the share of life kept: set by the governor, 1 and 1 when nothing is given up |
time: number | |
register(def: VfxDef): void | validates the definition (its parts are looked up when it is spawned) and makes it ready to run; throws with every problem listed |
registerAll(defs: VfxDef[]): void | registers a set together and checks the parts across them (that they exist, that their parameters exist, that no two include each other) |
has(name: string) | |
get(id: number): Instance | undefined | |
instances(): IterableIterator<Instance> | |
get count() | |
get particles(): number | live particles over all instances |
spawn(name: string, o: SpawnOptions): VfxHandle | |
stop(h: VfxHandle, o: StopOptions = {}) | |
setParam(h: VfxHandle, name: string, value: number) | |
alive(h: VfxHandle): boolean | the effect's own time and whether it still has anything to show |
step(dt: number) | advance by one fixed step, seconds |
snapshot(): VfxSnapshot | |
restore(s: VfxSnapshot) | |
exportEffect(id: number): InstJson[] | null | the effect and its parts, as plain data (for an exact undo of a stop or a removal); null if there is no such effect |
importEffect(parts: InstJson[]): void | puts back what exportEffect took out (the definitions must still be registered) |
readonly removedIds: number[] | ids of the effects remove took away since the view last asked (the view drops their decals) |
takeRemoved(): number[] | the ids removed by hand since the last call, and forgets them |
remove(h: VfxHandle): boolean | removes an effect and its parts at once, without letting the particles finish; false if it is not there |
defOf(name: string): VfxDef | undefined | the definition as registered, or undefined |
names(): string[] | the names of the registered definitions |
unregister(name: string): boolean | forgets a definition (the effects that run from it go on until they end); false if it was not registered |
setAttach(h: VfxHandle, attach: { entity: number; node?: string } | null): boolean | moves an effect to follow an entity (and a node of it), or lets it go (null) |
packages/vfx/src/sim.ts:134
VolumeLayer class
class VolumeLayerstats: { volumes: number; steps: number; } | |
constructor(private readonly scene: BABYLON.Scene, private readonly o: VolumeLayerOptions) | |
begin(): void | a new frame: nothing is drawn unless show is called for it |
show(inst: Instance, src: VolumeSource, def: VolumeRender, alpha: number, cam: readonly [number, number, number], dt: number): void | draws the volume of an instance this frame at alpha (0..1); cam is the camera's position in the world |
end(): void | the frame is over: boxes that were not shown are hidden, and dropped after a while |
bind(proj: BABYLON.Matrix, viewRot: BABYLON.Matrix, fwd: BABYLON.Vector3, res: BABYLON.Vector2): void | per camera, just before it renders |
dispose(): void |
packages/vfx/src/volume-view.ts:114
Functions
absorptionCutoff function
function absorptionCutoff(distance: number, a: AirState = {}, medium: 'air' | 'water' = 'air'): numberThe frequency above which a sound that has crossed distance metres of air has lost more than 3 dB to absorption: the cutoff of the lowpass a far sound is played through. Clamped to 150 Hz .. 20 kHz; in water absorption is small and the cutoff stays high.
packages/vfx/src/sound-fx.ts:34
airAbsorption function
function airAbsorption(freq: number, a: AirState = {}): numberthe absorption of sound in air, dB per metre, at freq Hz (ISO 9613-1, the pure-tone formula); humidity is relative, percent
packages/vfx/src/sound-fx.ts:18
airAt function
function airAt(air: DropletAir, x: number, y: number, z: number, ground: number): [number, number, number]the air at a point: the grid's horizontal velocity blended by height above the surface, plus the wind
packages/vfx/src/droplets.ts:253
arrival function
function arrival(s: { radius: number; gain?: number; at?: number; medium?: 'air' | 'water'; delayBySpeed?: boolean }, distance: number, air: AirState = {}): SoundArrivalwhat a listener distance metres away hears of a sound block with its numbers worked out (gain, radius, at already evaluated)
packages/vfx/src/sound-fx.ts:57
availableRungs function
function availableRungs(def: Pick<VfxDef, 'emitters' | 'volume' | 'impostor' | 'dot'>): Availablewhich rungs an effect has: particles if it has emitters, volume, impostor and dot if it declares them
packages/vfx/src/select.ts:17
bake function
function bake(r: BakeRecipe): BakedFlipbookruns a recipe: warms the solver up, then renders every frame (and keeps the voxels, when the recipe asks for them)
packages/vfx/src/bake.ts:162
bakeSoftDisc function
function bakeSoftDisc(size = 64): BakedFlipbooka soft round blob
packages/vfx/src/bake.ts:197
bakeSpark function
function bakeSpark(size = 32): BakedFlipbooka spark: a bright point with a short falling tail
packages/vfx/src/bake.ts:202
blackbody function
function blackbody(T: number): [number, number, number]Colour of a black body at T kelvin (Tanner Helland's fit of the Planck locus; within a few percent from 1000 K to 40000 K), 0..1.
packages/vfx/src/color.ts:6
blastDef function
function blastDef: (name: string) => VfxDef | undefinedpackages/vfx/src/catalog-blast.ts:256
breakupTime function
function breakupTime(w: number, d: number, liquid: LiquidProps = WATER): numberthe time a drop takes to break (Pilch and Erdman: about 5 characteristic times d/w sqrt(rho_l/rho_a) near the critical Weber number)
packages/vfx/src/droplets.ts:54
breathVisible function
function breathVisible: (tempC: number) => numberhow much of a breath is visible as a cloud at an air temperature (C): none above 10 C and all below -5 C, in between by a ramp (an art ramp of the physical fact that the breath, saturated at body temperature, condenses when the air is cold)
packages/vfx/src/world-fx.ts:27
byramFlameLength function
function byramFlameLength: (I_kWm: number) => numberByram's flame length of a fire front (grass, ground, crown fires): L = 0.0775 I^0.46, I the fireline intensity in kW per metre of front, L in metres
packages/vfx/src/plume.ts:72
chooseRung function
function chooseRung(pixels: number, tier: VfxTier, ladder: ResolvedLadder, avail: Available, o: ChooseOptions = {}): Rungpackages/vfx/src/select.ts:33
chordColumn function
function chordColumn(a: Vec3, b: Vec3, c: Vec3, r: number, y0: number, h: number): numberthe length of the segment a..b inside a vertical cylinder of radius r from y0 to y0 + h with its axis through c (x, z)
packages/vfx/src/sight.ts:39
chordSphere function
function chordSphere(a: Vec3, b: Vec3, c: Vec3, r: number): numberthe length of the segment a..b that lies inside a sphere
packages/vfx/src/sight.ts:27
clampParam function
function clampParam(def: Pick<VfxDef, 'params'>, name: string, value: number): numberclamp one value to the limits of a parameter of the definition (the value itself if the parameter has no limits or does not exist)
packages/vfx/src/params.ts:29
cloudRadius function
function cloudRadius(age: number, r0: number, k: number): numberthe radius of a parcel's cloud of drops at an age: it starts as r0 and spreads by the air's turbulence, sqrt(r0^2 + 2 K age)
packages/vfx/src/droplets.ts:60
columnHeight function
function columnHeight: (tnt: number) => numberpackages/vfx/src/blast-fx.ts:38
compile function
function compile(source: string): Compiledparse and compile; throws ExprError with the position of the problem
packages/vfx/src/expr.ts:177
compiled function
function compiled(e: number | string): Compileda number is itself; a string is compiled (cached by text)
packages/vfx/src/expr.ts:186
compileDef function
function compileDef(def: VfxDef): CompiledDefcompile a definition that already passed validateDef
packages/vfx/src/compile.ts:100
composeMatrix function
function composeMatrix(out: Float32Array, o: number, x: number, y: number, z: number, scale: number, yaw: number, tilt: number): voidthe matrix of a mesh particle (Babylon's row-major layout, row vectors): uniform scale, a turn about y by yaw and a tilt about x by tilt, then the position
packages/vfx/src/gather.ts:161
coreShape function
function coreShape(inst: Instance, spec: ImpostorRender, flame: { height: number; width: number } | null): StripShape | nullThe glow of the flames of an effect as a strip: the height and width of its additive particles, in the colour of the fire's own temperature, as bright as the share of the plume that is flame. Null for an effect with no additive emitter or one that asks for no core.
packages/vfx/src/parts.ts:184
cr function
function cr: (v: Range) => CRangepackages/vfx/src/compile.ts:14
criticalFlux function
function criticalFlux: (m: Combustible, T0?: number, h?: number) => numberthe least flux that can ever ignite a surface (below it the surface loses as much as it gains before it gets hot enough): q_cr = h (T_ig - T0), h the film coefficient, W/m^2 K
packages/vfx/src/spread.ts:281
curl3 function
function curl3(seed: number, x: number, y: number, z: number, out: [number, number, number]): voidThe curl of a vector potential made of three noise fields: a divergence-free swirl (smoke curls and never piles up or thins out). Central differences at a fifth of the noise cell. Writes the unit-scale swirl into out.
packages/vfx/src/rng.ts:43
curlLookup function
function curlLookup(x: number, y: number, z: number, out: [number, number, number]): voidthe swirl at a point of noise space (period 16): the same divergence-free field as curl3, read from the grid; writes into out
packages/vfx/src/rng.ts:85
curlOffset function
function curlOffset(seed: number, out: [number, number, number]): voidthe offset of an instance in the field, from its seed: three numbers in 0..16
packages/vfx/src/rng.ts:102
cx function
function cx: (v: string | number) => CExprpackages/vfx/src/compile.ts:12
cxOpt function
function cxOpt: (v: string | number | undefined) => CExpr | undefinedpackages/vfx/src/compile.ts:13
decalAlpha function
function decalAlpha(d: Pick<DecalSpec, 'life' | 'fade'>, age: number): numberthe opacity of a decal age seconds old: 0 at birth growing in over a moment, 1 through its life, then fading to 0
packages/vfx/src/parts.ts:118
decalEnd function
function decalEnd: (d: Pick<DecalSpec, "life" | "fade">) => numberpackages/vfx/src/parts.ts:124
densityAt function
function densityAt(v: VolumeSource, origin: readonly [number, number, number], x: number, y: number, z: number): numberthe density of a source at a point of the world (for tests and for what reads a volume): trilinear over the bytes, in density units
packages/vfx/src/volume.ts:202
detailNoise function
function detailNoise(n = 32, seed = 7): Uint8Arraya tileable 3D noise (three octaves of value noise on a periodic lattice), one byte per voxel, n x n x n: the fine detail the raymarch erodes smoke with
packages/vfx/src/volume.ts:134
digest function
function digest(...parts: Uint8Array[]): stringa stable digest of the arrays (FNV-1a over the bytes), for tests and for the item's record of what it holds
packages/vfx/src/bake.ts:269
dotLook function
function dotLook(inst: Instance, spec: DotRender, distance: number, fov: number, heightPx: number, projectedPx: number, night: number): DotLookA dot: a point of light or a smudge never smaller than a pixel and a half on screen, so a distant fire does not wink out as it shrinks, and fading out below that only by getting dimmer in proportion to its real size, so it goes quietly.
packages/vfx/src/parts.ts:203
dragAcceleration function
function dragAcceleration(w: number, d: number, liquid: LiquidProps = WATER): numberthe acceleration the air gives a drop of diameter d moving at relative velocity w (m/s), along -w: 3/4 (rho_a/rho_l) Cd |w|^2 / d
packages/vfx/src/droplets.ts:32
dragCoefficient function
function dragCoefficient(re: number): numberdrag coefficient of a sphere at Reynolds number re (Schiller-Naumann below 1000, Newton's 0.44 above)
packages/vfx/src/droplets.ts:29
driveFromPhysics function
function driveFromPhysics(bus: EventSource, sim: VfxSim, o: DriveOptions = {}): () => voidsubscribes the simulation to the physics events; returns the function that stops it
packages/vfx/src/drive.ts:36
dropletRand function
function dropletRand(seed: number, k: number): numbera number in [0, 1) from a seed and a stream index
packages/vfx/src/droplets.ts:73
dustPuffPixels function
function dustPuffPixels(cols = 4, rows = 4, tile = 96): FlipbookPixelsa dry-mud / dust puff: like smoke but flatter and browner in its shading; the tint comes from the particle colour
packages/vfx/src/pixels.ts:97
effectiveWind function
function effectiveWind(bed: FuelBed, factor: number): numberthe effective wind speed (m/s) at which the wind factor alone would equal factor: the inverse of the wind factor
packages/vfx/src/spread.ts:97
effectTemperature function
function effectTemperature(def: VfxDef, vars: Readonly<Record<string, number>>): numberthe hottest initial temperature an emitter of the effect gives (kelvin), which is what a light or a dot "of temperature" is: the effect's own fire, not a constant
packages/vfx/src/parts.ts:15
ellipse function
function ellipse(effWind: number): { Z: number; e: number }the ellipse of a fire from a point under an effective wind (m/s): length-to-width Z = 1 + 0.25 U_E (U_E in mi/h), eccentricity e = sqrt(Z^2 - 1) / Z
packages/vfx/src/spread.ts:105
emitOne function
function emitOne(p: Float32Array, em: Float32Array, count: number, head: number, capacity: number, k: number, seed: number, time: number): voidthe k-th new parcel of this step, written at the ring position head + k (WGSL emit does the same)
packages/vfx/src/droplets.ts:233
energyDef function
function energyDef: (name: string) => VfxDef | undefinedpackages/vfx/src/catalog-energy.ts:186
evaluate function
function evaluate: (e: string | number, vars?: Readonly<Record<string, number>>) => numberone-shot evaluation of a number or an expression
packages/vfx/src/expr.ts:194
extinguishingFlow function
function extinguishingFlow: (power: number, efficiency?: number, T?: number) => numberthe smallest water flow (kg/s) that puts a fire of power out at the given efficiency
packages/vfx/src/spread.ts:319
fireDef function
function fireDef: (name: string) => VfxDef | undefinedpackages/vfx/src/catalog-fire.ts:294
firelineIntensity function
function firelineIntensity: (heatKJkg: number, fuelKgM2: number, spreadMs: number) => numberfireline intensity, kW/m (Byram): I = H w r, heat of combustion of the fuel (kJ/kg) x fuel consumed (kg/m^2) x rate of spread (m/s)
packages/vfx/src/plume.ts:75
flameHeight function
function flameHeight(Q: number, D: number): numbermean flame height above the fuel, metres: L = 0.235 Q^(2/5) - 1.02 D (Q in kW). Never below a fifth of the diameter: a small fire still has a flame.
packages/vfx/src/plume.ts:11
flamePixels function
function flamePixels(cols = 4, rows = 4, tile = 96, seed = 3): FlipbookPixelsFlame: a licking teardrop, hot white-yellow at the core and orange-red at the edge; meant for additive blending
packages/vfx/src/pixels.ts:72
flameTipTemperature function
function flameTipTemperature: (Q: number, D: number) => numberthe temperature of the gas at the flame tip, kelvin (the plume above it is cooler)
packages/vfx/src/plume.ts:40
flashoverPower function
function flashoverPower(hk: number, wallArea: number, openingArea: number, openingHeight: number): numberthe heat release of a compartment fire at flashover, W (McCaffrey, Quintiere, Harkleroad): Q = 610 (h_k A_T A_o sqrt(H_o))^(1/2) kW, h_k the wall's effective conductance W/m^2 K, A_T the bounding surface area less the opening, A_o and H_o the opening's area and height
packages/vfx/src/spread.ts:304
fountainHeight function
function fountainHeight: (gaugePressure: number) => numberthe height a jet of water reaches, m: Bernoulli, p / (rho g) for a gauge pressure p (Pa) at the nozzle; Torricelli, v^2 / (2 g), for a speed v
packages/vfx/src/world-fx.ts:13
fuelFireballDiameter function
function fuelFireballDiameter: (fuelKg: number) => numberthe largest diameter of the fireball of fuelKg kg of fuel burning in a ball (CCPS): 5.8 M^(1/3), m
packages/vfx/src/blast-fx.ts:25
fuelFireballDuration function
function fuelFireballDuration: (fuelKg: number) => numberits duration, s: 0.45 M^(1/3) up to 30 t, 2.6 M^(1/6) above
packages/vfx/src/blast-fx.ts:27
gatherEmitter function
function gatherEmitter(batch: BatchData, inst: Instance, c: CEmitter, p: Pool, g: Gather): voidWrites the live particles of one emitter into batch. Billboards and streaks: one entry each. Ribbons: one segment between each particle and the one spawned right after it (the trail of a moving emitter), so the strip follows the path and breaks where particles were not spawned in sequence.
packages/vfx/src/gather.ts:101
generatedKind function
function generatedKind(id: string | undefined): string | undefinedthe id of a flipbook that the generators make, or undefined
packages/vfx/src/textures.ts:33
glow function
function glow(o: GlowOpts): EmitterDefadditive glowing sprites: energy, plasma, magic, flares
packages/vfx/src/catalog-kit.ts:56
hash4 function
function hash4(a: number, b: number, c: number, d: number): numbera 32-bit hash of four integers
packages/vfx/src/rng.ts:12
headFire function
function headFire(bed: FuelBed, moisture: number, wind: [number, number], slope: [number, number]): { rate: number; dir: number; e: number; Z: number }the head fire of a fuel under a wind and over a slope: wind (m/s, midflame) and slope (tan, a vector pointing uphill) combine as vectors of their factors
packages/vfx/src/spread.ts:114
heFireballRadius function
function heFireballRadius(tnt: number): numberThe radius of the fireball of a detonation of tnt kg TNT, m: the products start in the charge's own volume at the Chapman-Jouguet pressure and expand isentropically until they are at ambient pressure, r = r0 (P_CJ / P_atm)^(1/(3 gamma)) with r0 the radius of the charge. About 1.4 m for 1 kg. Scales as the cube root of the mass.
packages/vfx/src/blast-fx.ts:19
ignitionTime function
function ignitionTime(m: Combustible, flux: number, T0 = 293.15, h = 15): numbertime for a thermally thick solid under a constant flux q to reach its ignition temperature, s (semi-infinite solid, Drysdale): t = (pi / 4) k rho c (T_ig - T0)^2 / q^2; Infinity at or below the critical flux
packages/vfx/src/spread.ts:284
impostorShape function
function impostorShape(inst: Instance, spec: ImpostorRender, wind: readonly [number, number, number], measured: { height: number; width: number }): StripShapeThe size and colour of the strip or card an effect becomes at a distance. Height and width come from the definition when it gives them and otherwise from the
particles the effect actually has now (the top of the highest, the spread of the widest, smoothed by the caller), so a plume drawn far away is as tall as the plume
that was drawn near. wind leans it downwind. The colour is the effect's own: the definition's, else the first emitter's, so smoke stays grey and fire stays orange.
packages/vfx/src/parts.ts:168
installVfxNet function
function installVfxNet(net: NetLike, replica: VfxReplica): () => voidConnects a replica to a net service: commands, hello and sync travel as the messages vfx:op, vfx:hello and vfx:sync; a peer that joins is greeted by
the others' answers (the first one wins, later ones are dropped), and says hello itself when it starts. Returns the function that disconnects it.
packages/vfx/src/vfx-net.ts:182
jetHeight function
function jetHeight: (speed: number) => numberpackages/vfx/src/world-fx.ts:14
ladderProblems function
function ladderProblems(at: Record<DrawnRung, number>): string[]the thresholds must fall as the rung gets cheaper: volume >= particles >= impostor >= dot >= 0; returns the problems found
packages/vfx/src/ladder.ts:35
lightOf function
function lightOf(inst: Instance, out?: LightState): LightState | nullthe light of an instance now, or null when it has none or is dark
packages/vfx/src/parts.ts:52
loudnessAt function
function loudnessAt(distance: number, radius: number): numberThe loudness (0..1 of the source's own gain) at distance for a sound audible out to radius (design: the inverse law from a reference distance of a thirtieth of the radius, 1/(1 + d/r1), then faded to zero over the last tenth of the radius so nothing cuts off).
packages/vfx/src/sound-fx.ts:48
N function
function N: (v: string | number) => stringpackages/vfx/src/catalog-kit.ts:6
noise3 function
function noise3(seed: number, x: number, y: number, z: number): numberpackages/vfx/src/rng.ts:29
noticed function
function noticed(eye: Vec3, signs: Sign[], night: number, sight?: SmokeSight, gain = NIGHT_NOTICE_GAIN): Sign[]the signs an observer at eye notices at this time of day: within the range, and (for fire, light and smoke, which are seen) through the smoke between
packages/vfx/src/sight.ts:121
noticeRange function
function noticeRange(kind: 'fire' | 'light' | 'noise' | 'smoke', radius: number, night: number, gain = NIGHT_NOTICE_GAIN): numberthe distance a sign is noticed from, m: the effect's stimulus.radius by day; for fire and light it grows towards radius * gain as it gets dark (night 0..1)
packages/vfx/src/sight.ts:101
opticalDepth function
function opticalDepth(volume: number, d: number, r: number): numberoptical depth through a cloud of drops of diameter d holding liquid volume V spread over a disc of radius r: the drops' total cross-section over its area
packages/vfx/src/droplets.ts:63
orderFarFirst function
function orderFarFirst(keys: Float32Array, n: number, out: Uint32Array, scratch: Uint32Array, buckets = 4096): voidCounting sort of n keys into out (indices): larger keys first. Keys are quantised into buckets steps between 0 and the largest, which is exact enough for ordering transparent sprites, and the cost is linear in the number of particles.
packages/vfx/src/gather.ts:42
packEmitters function
function packEmitters(list: readonly DropletEmitter[], dt: number, carry: number[], out: Float32Array): numberpack the emitters and this step's parcel counts (a fractional rate carries over) into the layout the step and the compute shader read
packages/vfx/src/droplets.ts:102
packParams function
function packParams(o: { dt: number; time: number; capacity: number; head: number; total: number; emitters: number; liquid: LiquidProps; seed: number; air: DropletAir; surface: SurfaceGrid | null; maxImpacts: number }, out: Float32Array): voidpackages/vfx/src/droplets.ts:174
particleLook function
function particleLook(c: CEmitter, p: Pool, i: number, out: number[] | Float32Array, glow: number): voidthe colour, alpha and glow of particle i at the age it has; writes r, g, b, a, glow into out
packages/vfx/src/gather.ts:87
pcg function
function pcg(v: number): numberpackages/vfx/src/droplets.ts:67
permute function
function permute(src: BatchData, dst: BatchData, order: Uint32Array, n: number): voidreorders the arrays of src into dst by order
packages/vfx/src/gather.ts:55
plumeMass function
function plumeMass(Q: number, D: number, z: number, chi = CONVECTIVE_FRACTION): numberair entrained by the plume by height, kg/s (Heskestad, z above the flame tip): m = 0.071 Qc^(1/3) (z - z0)^(5/3) (1 + 0.026 Qc^(2/3) (z - z0)^(-5/3)), Qc in kW
packages/vfx/src/plume.ts:43
plumeTempRise function
function plumeTempRise(Q: number, D: number, z: number, chi = CONVECTIVE_FRACTION): numbercentreline temperature rise above ambient, kelvin: dT = 25 (Qc^(2/5) / (z - z0))^(5/3), Qc in kW
packages/vfx/src/plume.ts:31
plumeVelocity function
function plumeVelocity(Q: number, D: number, z: number, chi = CONVECTIVE_FRACTION): numbercentreline velocity above the flame, m/s: u = 1.0 Qc^(1/3) (z - z0)^(-1/3), Qc in kW, z above the fuel in metres
packages/vfx/src/plume.ts:25
plumeWidth function
function plumeWidth: (D: number, z: number) => numberhow wide the plume is at height z above the fuel, metres (a half-angle near 10 degrees, starting from the fire's own width)
packages/vfx/src/plume.ts:49
poolPower function
function poolPower(fuel: string, D: number): numberthe heat release of a pool of diameter D of a fuel, W
packages/vfx/src/catalog-fire.ts:44
powerAfterWater function
function powerAfterWater(power: number, flow: number, efficiency = 1, T = 293.15): numberthe fire power left after water of mass flow flow (kg/s) reaches it, of which efficiency (0..1) is used on the fire: P - efficiency flow (cp dT + L), never below 0
packages/vfx/src/spread.ts:314
projectedPixels function
function projectedPixels(radius: number, distance: number, fov: number, heightPx: number): numberthe diameter of a sphere of radius at distance, in pixels of a render target heightPx tall with the vertical field of view fov (radians)
packages/vfx/src/select.ts:10
puff function
function puff(o: PuffOpts): EmitterDefsoft alpha-blended sprites: smoke, steam, dust, spray, mist
packages/vfx/src/catalog-kit.ts:31
radianceRatio function
function radianceRatio: (T: number) => numberhow bright a hot gas glows against a flame at 1200 K, by the Stefan-Boltzmann law: (T / 1200)^4, capped at 1.5 (a hotter core does not blow out the picture)
packages/vfx/src/plume.ts:62
radiantFlux function
function radiantFlux: (Q: number, distance: number, chi?: number) => numberradiant heat flux at a distance from a fire, W/m^2, by the point-source model: q = chi_r Q / (4 pi r^2)
packages/vfx/src/spread.ts:275
rainDropRate function
function rainDropRate: (mmPerHour: number, diameter?: number) => numberthe number of raindrops that fall on a square metre in a second at a rain rate (mm/h) and a drop diameter (m): the flux of volume over the volume of a drop
packages/vfx/src/world-fx.ts:24
rand function
function rand: (seed: number, a: number, b?: number, c?: number) => numbera number in [0, 1) from (seed, a, b, c)
packages/vfx/src/rng.ts:20
rateAtAngle function
function rateAtAngle: (head: number, e: number, theta: number) => numberthe rate of spread (m/s) at angle theta from the direction of maximum spread, given the head rate and the eccentricity
packages/vfx/src/spread.ts:111
recipe function
function recipe: (id: string) => BakeRecipe | undefinedthe recipe of an id, or undefined
packages/vfx/src/bake.ts:260
registerVfxCommands function
function registerVfxCommands(host: CommandHost, s: VfxSession): voidthe vfx.* commands on a host; vfx.bake and vfx.view are the viewer's and the Node tool's, not here
packages/vfx/src/vfx-commands.ts:229
resolveLadder function
function resolveLadder(o?: RungOverrides): ResolvedLadderthe defaults with an effect's overrides on top
packages/vfx/src/ladder.ts:24
resolveParams function
function resolveParams(def: Pick<VfxDef, 'params'>, given: Readonly<Record<string, number>> = {}): ResolvedParamsthe values an instance starts with; a non-finite value counts as not given
packages/vfx/src/params.ts:15
rothermel function
function rothermel(bed: FuelBed, moisture: number, wind: number, slope = 0): RothermelResultThe rate of spread. moisture is the dead fuel moisture (fraction, oven-dry basis), wind the wind at midflame height along the direction of spread in m/s, slope tan(phi) of the slope along it (positive uphill). At or above the moisture of extinction the fire does not spread (rate 0).
packages/vfx/src/spread.ts:71
sampleCurve function
function sampleCurve(c: Curve | null | undefined, a: number, dflt = 1): numberpackages/vfx/src/compile.ts:130
sampleGradient function
function sampleGradient(g: Gradient, a: number, out: number[] | Float32Array, o = 0): voidwrites r, g, b, alpha into out
packages/vfx/src/compile.ts:140
shockRingRadius function
function shockRingRadius: (tnt: number) => numberpackages/vfx/src/blast-fx.ts:34
shockSpeed function
function shockSpeed: (overpressure: number, ambient?: number, a?: number, gamma?: number) => numberthe speed of a shock front of overpressure ratio p/p0 in air at sound speed a, by the Rankine-Hugoniot relation U = a sqrt(1 + (gamma + 1) / (2 gamma) p/p0), m/s
packages/vfx/src/blast-fx.ts:30
signsOf function
function signsOf(sim: VfxSystem): Sign[]the stimuli of the effects of a simulation now (those whose definition has game.stimulus)
packages/vfx/src/sight.ts:110
smokeExtinction function
function smokeExtinction: (sootKgM3: number, K?: number) => numberextinction coefficient of smoke, 1/m, from the soot's mass per cubic metre (kg/m^3)
packages/vfx/src/sight.ts:19
smokePuffPixels function
function smokePuffPixels(cols = 4, rows = 4, tile = 96, seed = 1): FlipbookPixelsSmoke: a puff that swells and thins over its frames. White-grey with a shaded side, so the particle colour tints it; the alpha is eroded by noise that moves from frame to frame, and the motion atlas is the swelling (outward from the centre), which lets the shader blend frames without ghosting.
packages/vfx/src/pixels.ts:58
softDiscPixels function
function softDiscPixels(tile = 64): FlipbookPixelsa soft round blob, one frame
packages/vfx/src/pixels.ts:50
soundDelay function
function soundDelay: (distance: number, medium?: "water" | "air", tempC?: number) => numberthe time a sound takes to cover distance metres, s
packages/vfx/src/sound-fx.ts:13
soundFor function
function soundFor(def: VfxDef): SoundDef | undefinedthe sound block of the catalogue item name (dust is by pattern dust.<cause>-<surface>), if it has one
packages/vfx/src/catalog-sound.ts:133
sparkPixels function
function sparkPixels(tile = 32): FlipbookPixelsA spark: a bright point with a short falling tail, one frame
packages/vfx/src/pixels.ts:89
speedOfSound function
function speedOfSound: (tempC?: number) => numberthe speed of sound in air, m/s, at tempC degrees Celsius
packages/vfx/src/sound-fx.ts:10
splashRadius function
function splashRadius: (energy: number) => numberpackages/vfx/src/world-fx.ts:18
stableDiameter function
function stableDiameter(w: number, liquid: LiquidProps = WATER): numberthe largest diameter that survives a relative air speed w: We = WE_CRIT
packages/vfx/src/droplets.ts:51
steamPower function
function steamPower: (flowKgS: number) => numberheat power carried by a steam flow, W: the plume rises as a buoyant plume of this heat release, like a fire of the same power (Heskestad's plume velocity applies to it)
packages/vfx/src/world-fx.ts:10
stepOne function
function stepOne(p: Float32Array, i: number, dt: number, air: DropletAir, surface: SurfaceGrid | null, liquid: LiquidProps): numberone parcel through one step; 0 dead, 1 alive, 2 landed on water now (an impact), 3 landed on ground now
packages/vfx/src/droplets.ts:266
streaks function
function streaks(o: StreakOpts): EmitterDefthin streaks along the motion: sparks, drops, spray, rain, tracers
packages/vfx/src/catalog-kit.ts:44
subSeed function
function subSeed: (seed: number, n: number) => numberthe seed of a child (an emitter of an instance, a part of an effect): different inputs give unrelated seeds
packages/vfx/src/rng.ts:23
terminalVelocity function
function terminalVelocity(d: number, liquid: LiquidProps = WATER): numberthe speed a drop of diameter d falls at in still air (drag equals weight), by bisection of the drag law
packages/vfx/src/droplets.ts:38
tierAllows function
function tierAllows(rung: Rung, tier: VfxTier, ladder: ResolvedLadder = resolveLadder()): booleanmay this tier use the rung
packages/vfx/src/ladder.ts:29
tierRank function
function tierRank: (t: VfxTier) => numberpackages/vfx/src/ladder.ts:16
validateDef function
function validateDef(def: unknown, opts: ValidateOptions = {}): Issue[]packages/vfx/src/validate.ts:34
validateVfxBlock function
function validateVfxBlock(block: unknown, known: (name: string) => VfxDef | undefined = () => undefined): BlockIssue[]checks a vfx block: every definition is valid, every placement names a definition (of the block or of known), a place, and parameters the definition has within their limits
packages/vfx/src/vfx-commands.ts:23
virtualOrigin function
function virtualOrigin(Q: number, D: number): numberthe virtual origin of the plume above the fuel surface, metres: z0 = 0.083 Q^(2/5) - 1.02 D (Q in kW); negative for a big, wide fire
packages/vfx/src/plume.ts:17
visualRange function
function visualRange: (extinction: number) => numbervisual range in smoke of a given extinction coefficient: 3.912 / K (Koschmieder)
packages/vfx/src/sight.ts:24
warmCurl function
function warmCurl(): voidbuilds the field now (about 40 ms), so the first frame of a smoke does not pay for it; harmless to call twice
packages/vfx/src/rng.ts:71
waterHeatSink function
function waterHeatSink: (T?: number) => numberthe heat water takes from a fire by heating to boiling and evaporating, J/kg: cp (373.15 - T) + L with cp 4186 J/kg K and L 2.257 MJ/kg
packages/vfx/src/spread.ts:311
weber function
function weber(w: number, d: number, liquid: LiquidProps = WATER): numberthe Weber number of a drop: the air's dynamic pressure against the surface tension
packages/vfx/src/droplets.ts:45
withSound function
function withSound(defs: readonly VfxDef[]): VfxDef[]copies of the definitions with a sound block added to each that has none and has a rule (a definition's own block is kept)
packages/vfx/src/catalog-sound.ts:143
worldDef function
function worldDef: (name: string) => VfxDef | undefinedpackages/vfx/src/catalog-world.ts:166
Interfaces
AirState interface
interface AirStatetempC?: number | |
humidity?: number | |
pressureKPa?: number |
packages/vfx/src/sound-fx.ts:15
AudioHandle interface
interface AudioHandlestop(fade?: number): void | |
setVolume(v: number, fade?: number): void | |
set(param: string, value: number): void |
packages/vfx/src/sound-play.ts:11
AudioLike interface
interface AudioLikeplay(name: string, o: { at?: unknown; volume?: number; loop?: boolean; fadeIn?: number; delay?: number; params?: Record<string, number>; lowpass?: number; spatial?: { min?: number; max?: number; model?: 'inverse' } }): AudioHandle |
packages/vfx/src/sound-play.ts:12
BakedFlipbook interface
interface BakedFlipbookcols: number | |
rows: number | |
frames: number | |
frameSize: number | |
fps: number | |
color: Uint8Array | RGBA8 atlases of cols*frameSize x rows*frameSize pixels |
light: Uint8Array | |
light2: Uint8Array | |
motion: Uint8Array | |
depth: Uint8Array | |
motionScale: number | |
extent: number | metres the picture spans (the width of the box that was looked at) |
volume?: BakedVolume |
packages/vfx/src/bake.ts:50
BakedVolume interface
interface BakedVolumeresolution: [number, number, number] | |
frames: number | |
voxel: number | |
channels: Array<'density' | 'temperature'> | |
voxels: Uint8Array | |
densityMax: number | |
temperatureMax: number | |
ambient: number |
packages/vfx/src/bake.ts:60
BakedVolumeData interface
interface BakedVolumeDatawhat the library gives for a volume (AssetLibrary.volume(id))
item: { resolution: [number, number, number]; frames: number; fps: number; voxel: number; loop?: boolean; densityMax?: number; temperatureMax?: number; ambient?: number } | |
bytes: Uint8Array |
packages/vfx/src/volume.ts:153
BakeRecipe interface
interface BakeRecipeid: string | |
name: string | |
tags: string[] | |
seed: number | |
n: number | cells along each axis of the cubic grid |
grid: Partial<GridOptions> | |
warmup: number | seconds simulated before the first frame, and the frames of the flipbook (cols x rows cells of size pixels) played at fps |
frames: number | |
cols: number | |
rows: number | |
size: number | |
fps: number | |
substeps: number | solver steps per frame |
source: (g: FluidGrid, t: number) => void | the sources of the effect: called before each step with the grid and the time since the start of the effect (negative while warming up) |
shading: Shading | |
view?: { cx?: number; cy?: number; half: number } | the window of the grid the tile shows: the centre as fractions of the box (x, y) and the half size as a fraction of it; the default is the whole box |
volume?: { n: number; densityMax: number; temperatureMax: number } | the volume sequence to keep as well: voxels along each axis, the density that maps to 255 and the temperature that does |
packages/vfx/src/bake.ts:28
BlockIssue interface
interface BlockIssuepath: string | |
message: string |
packages/vfx/src/vfx-commands.ts:18
BridgeOptions interface
interface BridgeOptionscellEffect?: string | the effect of a burning cell (default fire.grass) |
stride?: number | one effect for every this many burning cells, chosen by cell index (default 1) |
emit?: (name: 'vfx:ignite' | 'vfx:spread' | 'vfx:out', payload: VfxIgniteEvent | VfxSpreadEvent | VfxOutEvent) => void | emit an event: the host forwards these to world.events |
height?: (x: number, z: number) => number | the height of the ground, m, for placing effects |
packages/vfx/src/spread-bridge.ts:11
BurstDef interface
interface BurstDefpackages/vfx/src/def.ts:37
CCollide interface
interface CCollidereadonly with: 'ground' | 'bodies' | 'both' | |
readonly onHit: 'bounce' | 'die' | 'stick' | |
readonly bounce: CExpr | |
readonly friction: CExpr |
packages/vfx/src/compile.ts:32
CEmitter interface
interface CEmitterreadonly def: EmitterDef | |
readonly name: string | |
readonly index: number | |
readonly max: number | |
readonly rate?: CExpr | |
readonly perMetre?: CExpr | |
readonly delay?: CExpr | |
readonly runFor?: CExpr | |
readonly bursts: ReadonlyArray<{ at: CExpr; count: CExpr }> | |
readonly shape: CShape | |
readonly lifetime: CRange | |
readonly speed: CRange | null | |
readonly direction: 'out' | 'up' | 'forward' | Vec3 | |
readonly spread: CExpr | null | |
readonly inherit: CExpr | null | |
readonly size: CRange | |
readonly rotation: CRange | null | |
readonly spin: CRange | null | |
readonly temperature: CRange | null | |
readonly sizeCurve: Curve | null | |
readonly alphaCurve: Curve | null | |
readonly gradient: Gradient | null | |
readonly color: Vec3 | null | |
readonly modules: readonly CModule[] | |
readonly collide: CCollide | null | |
readonly subs: readonly CSub[] | |
readonly render: ParticleRender | |
readonly rx: { readonly soft: CExpr | null; readonly emissive: CExpr | null; readonly stretch: CExpr | null; readonly width: CExpr | null } | the expressions of the renderer, compiled once; evaluated per particle by the gatherer (they may read age, rnd and i) |
packages/vfx/src/compile.ts:35
CExpr interface
interface CExprstamp and val memoise the value of an expression that does not depend on the particle, once per instance step (see sim.ts)
readonly e: Compiled | |
readonly dyn: boolean | |
stamp: number | |
val: number |
packages/vfx/src/compile.ts:8
ChooseOptions interface
interface ChooseOptionscurrent?: Rung | the rung used now: moving to a richer rung needs hysteresis more than the threshold, staying needs hysteresis less |
hysteresis?: number | share of the threshold, default 0.15 |
cap?: Rung | the richest rung allowed (the governor lowers it first); default volume |
packages/vfx/src/select.ts:24
Combustible interface
interface Combustiblea combustible surface: the properties of a physics-heat material (density, specific heat, conductivity, ignition temperature)
density: number | |
c: number | |
k: number | |
ignition: number |
packages/vfx/src/spread.ts:278
CommandHost interface
interface CommandHostregister(name: string, description: string, fn: (args: any) => unknown | Promise<unknown>): void |
packages/vfx/src/vfx-commands.ts:12
Compiled interface
interface Compiledreadonly source: string | the source text |
readonly names: readonly string[] | names the expression reads (constants excluded), sorted, without duplicates |
evaluate(vars: Vars): number | a missing variable reads as 0 |
packages/vfx/src/expr.ts:121
CompiledDef interface
interface CompiledDefreadonly def: VfxDef | |
readonly name: string | |
readonly seed: number | |
readonly duration: CExpr | null | |
readonly radius: CExpr | null | |
readonly emitters: readonly CEmitter[] |
packages/vfx/src/compile.ts:67
CRange interface
interface CRangepackages/vfx/src/compile.ts:9
CSub interface
interface CSubreadonly on: 'death' | 'collision' | |
readonly target: number | |
readonly count: CExpr | |
readonly chance: CExpr |
packages/vfx/src/compile.ts:33
DecalDef interface
interface DecalDefkind: 'scorch' | 'crater' | 'soot' | 'wet' | 'impact' | |
texture?: string | |
size: Expr | |
at?: 'start' | 'end' | number | when it appears: start, end, or seconds after the start |
life: Expr | seconds it lasts before it fades |
fade?: Expr |
packages/vfx/src/def.ts:190
DecalSpec interface
interface DecalSpecowner?: number | the effect (instance id) it belongs to: a decal goes with the effect when an editor removes it, and stays when the effect ends |
kind: DecalDef['kind'] | |
texture?: string | |
pos: [number, number, number] | |
size: number | metres across |
life: number | seconds from birth until it starts to fade, and how long the fade takes |
fade: number | |
seed: number | a stable number for the look of it (rotation, which variant) |
packages/vfx/src/parts.ts:102
DistortDef interface
interface DistortDefkind: 'heat-haze' | 'shock-ring' | |
strength: Expr | |
radius: Expr | |
speed?: Expr | shock ring: the ring grows at this speed, m/s |
packages/vfx/src/def.ts:201
DotLook interface
interface DotLooksize: number | the world size that makes the dot pixels across at this distance |
pixels: number | |
rgb: Rgb | |
alpha: number | |
glow: boolean |
packages/vfx/src/parts.ts:190
DotRender interface
interface DotRenderthe dot rung: a point of light, or a dark smudge, so a fire at night or a smoke column stays visible from far away
packages/vfx/src/def.ts:137
DriveOptions interface
interface DriveOptionspositionOf?: (entity: unknown) => Vec3 | undefined | where an entity is, m |
materialOf?: (entity: unknown, at: Vec3) => string | undefined | what an entity (or the ground at a point) is made of: concrete, metal, wood, soil, sand, water; the default for a thing that says nothing is concrete |
dustAt?: (at: Vec3) => [number, number, number] | undefined | the colour of dust at a point, from the ground under it (the soil and the surface of the terrain) |
placeOf?: (name: string) => Vec3 | undefined | where a named chamber or gun is |
minImpactEnergy?: number | the energy of an impact below which nothing is drawn, J |
onSpawn?: (name: string, handle: VfxHandle, cause: string) => void | called for each effect started |
packages/vfx/src/drive.ts:11
DropletAir interface
interface DropletAirThe air the parcels move in: a horizontal velocity grid in two height layers (the FlowMap layout: n*n cells of low.x low.z high.x high.z) plus the wind.
data: Float32Array | null | |
n: number | |
cell: number | |
originX: number | |
originZ: number | |
lowHeight: number | |
highHeight: number | |
wind: [number, number, number] |
packages/vfx/src/droplets.ts:122
DropletEmitter interface
interface DropletEmitterA line along which a surface sheds liquid into the air (an edge, a ring of segments, a point when a = b).
a: [number, number, number] | |
b: [number, number, number] | |
out: [number, number] | the horizontal direction the liquid leaves in (normalised here) |
rate: number | parcels per second |
speed: number | launch speed (m/s) and its relative spread 0..1 |
speedSpread?: number | |
elevation: number | elevation above the horizontal (rad) and its spread |
elevationSpread?: number | |
azimuthSpread?: number | azimuth spread round out (rad), default 0.35 |
diameter: number | median diameter of the drops (m) and the log-normal sigma |
sigma?: number | |
life: number | the longest a parcel lives (s): its drops fall or evaporate before |
flux: number | liquid volume per second over the whole emitter (m^3/s), split among its parcels |
carrier?: [number, number, number] | the velocity of what sheds it (a moving hull), added to every parcel |
tag?: number |
packages/vfx/src/droplets.ts:78
DropletPoolOptions interface
interface DropletPoolOptionscapacity: number | parcels the pool holds (a ring: the oldest is overwritten when it is full) |
liquid?: LiquidProps | |
diffusivity?: number | turbulent diffusivity of the air near the surface (m^2/s) that spreads a parcel's cloud, default 0.05 |
cloud0?: number | the radius of a parcel's cloud when it is shed (m), default 0.04 |
maxImpacts?: number | most impacts kept per step, default 256 |
seed?: number |
packages/vfx/src/droplets.ts:159
DropletViewOptions interface
interface DropletViewOptionscapacity?: number | parcels on WebGPU (default 65536) and on the CPU path (default 4096) |
cpuCapacity?: number | |
liquid?: LiquidProps | |
diffusivity?: number | turbulent diffusivity that spreads a parcel's cloud (m^2/s), default 0.05; the cloud's first radius (m), default 0.04 |
cloud0?: number | |
exposure?: number | the exposure the drops streak over (s), default 1/60 |
sun?: () => { dir: [number, number, number]; color: [number, number, number] } | undefined | the sun: direction toward it and its colour (linear), and the sky's colour; default from the scene's first directional and hemispheric light |
sky?: () => [number, number, number] | |
depth?: BABYLON.Texture | the scene's camera-space depth (DepthRenderer with storeCameraSpaceZ) for soft edges where the cloud meets a surface |
cpu?: boolean | force the CPU path even on WebGPU (tests, comparisons) |
maxImpacts?: number | |
seed?: number |
packages/vfx/src/droplets-view.ts:18
EmitterDef interface
interface EmitterDefname: string | |
max: number | capacity of the pool; the emitter never holds more |
rate?: Expr | spawn rate per second, particles per metre moved, and timed bursts: at least one |
perMetre?: Expr | |
bursts?: BurstDef[] | |
delay?: Expr | seconds the emitter waits after the effect starts, and the time it runs (default: the effect's duration) |
runFor?: Expr | |
shape: SpawnShape | |
lifetime: Range | |
velocity?: VelocityDef | |
size: Range | |
sizeOverLife?: Curve | |
rotation?: Range | degrees, and degrees per second |
spin?: Range | |
temperature?: Range | initial temperature, K; drives emission colour and buoyancy |
color?: Rgb | |
colorOverLife?: Gradient | |
alphaOverLife?: Curve | |
modules?: ModuleDef[] | |
subEmitters?: SubEmitterDef[] | |
render: ParticleRender |
packages/vfx/src/def.ts:145
EventSource interface
interface EventSourcethe part of the world's event bus the drive needs: on returns the function that unsubscribes
on(name: string, fn: (payload: any) => void): () => void |
packages/vfx/src/drive.ts:9
Flipbook interface
interface Flipbooktexture: BABYLON.BaseTexture | |
cols: number | |
rows: number | |
frames: number | |
motion?: BABYLON.BaseTexture | per-frame motion vectors in the red and green channels (0.5 = still), in tile units per frame, for blending between frames; absent: plain cross-fade |
motionScale?: number | how far the vectors reach, in tiles, at 0 / 1 |
packages/vfx/src/textures.ts:7
FlipbookPixels interface
interface FlipbookPixelsthe pixels of a flipbook, RGBA8, cols x rows tiles of tile pixels, and the motion atlas if there is one
width: number | |
height: number | |
cols: number | |
rows: number | |
frames: number | |
rgba: Uint8ClampedArray | |
motion?: Uint8ClampedArray | |
motionScale?: number |
packages/vfx/src/pixels.ts:26
Fuel interface
interface FuelmassFlux?: number | mass loss per area of a burning pool, kg/(m^2 s), and heat of combustion, MJ/kg: their product is the heat release per area of the pool |
heatMJkg?: number | |
soot: number | the soot share (art, see above) and the colours |
smoke: Rgb | |
flame: Gradient | |
glow: number | how much the flame glows: 1 for a luminous sooty flame, low for a blue one |
packages/vfx/src/catalog-fire.ts:13
FuelBed interface
interface FuelBeda surface fuel bed of one size class of dead fuel, in SI units (the report's input table, metric)
name: string | |
load: number | oven-dry fuel load, kg/m^2 |
sav: number | surface-area-to-volume ratio, 1/m (the report's 1/ft divided by 0.3048) |
depth: number | fuel bed depth, m |
moistureExtinction: number | dead fuel moisture of extinction, fraction |
heat: number | low heat content, kJ/kg |
density: number | oven-dry particle density, kg/m^3 |
mineralTotal: number | total and effective mineral content, fraction |
mineralEffective: number |
packages/vfx/src/spread.ts:18
GameDef interface
interface GameDefwhat the effect does to the game
occlusion?: { extinction: Expr; radius: Expr; height?: Expr; shape?: 'sphere' | 'column' | 'slab'; rise?: Expr } | smoke against sight: an extinction coefficient per metre (Beer-Lambert), inside a volume that follows the plume |
stimulus?: { kind: 'fire' | 'light' | 'noise' | 'smoke'; intensity: Expr; radius: Expr } | a thing the AI can notice, from as far as radius (more at night for fire and light) |
fire?: { power: Expr; radius: Expr; fuel?: string; spreads?: boolean; promote?: boolean } | the effect is a fire: heat power in W over a radius; it spreads and can be put out; promote makes it a combustion source in the physics world |
tags?: string[] | names for finding and stopping groups of effects |
packages/vfx/src/def.ts:232
Gather interface
interface Gatherorigin: readonly [number, number, number] | the batch origin in world metres: positions are written relative to it, so the GPU's floats stay small |
camera: readonly [number, number, number] | |
alpha: number | multiplies every particle's alpha (a cross-fade between rungs) |
sort: 'distance' | 'age' | 'none' | adds the sort key: distance to the camera, or age |
packages/vfx/src/gather.ts:70
GlowOpts interface
interface GlowOptsname: string | |
max?: number | |
rate?: Expr | |
bursts?: Array<{ at: Expr; count: Expr }> | |
runFor?: Expr | |
delay?: Expr | |
shape?: SpawnShape | |
life: Range | |
velocity?: VelocityDef | |
size: Range | |
sizeCurve?: Array<[number, number]> | |
rgb?: Rgb | |
gradient?: Gradient | |
alpha?: Array<[number, number]> | |
emissive?: number | string | |
modules?: ModuleDef[] | |
flip?: string | |
spin?: Range |
packages/vfx/src/catalog-kit.ts:53
GovernorOptions interface
interface GovernorOptionstargetMs: number | the frame time the effects must fit in, milliseconds (the share of the frame given to effects, measured by the caller) |
maxParticles?: number | a ceiling on live particles; above it counts as over budget |
downAfter?: number | frames over the target in a row before a step down (default 8) |
upAfter?: number | frames under margin of the target in a row before a step back up (default 120) |
margin?: number | a frame is comfortable under this share of the target (default 0.7) |
packages/vfx/src/governor.ts:28
GovernorStep interface
interface GovernorStepreadonly name: string | |
readonly cap: Rung | the richest rung allowed |
readonly spawn: number | the share of spawns that go ahead (thinning by particle index) |
readonly life: number | the share of its life a new particle keeps |
packages/vfx/src/governor.ts:8
GradientKey interface
interface GradientKeyat: number | |
rgb: Rgb | |
alpha?: number |
packages/vfx/src/def.ts:15
GridOptions interface
interface GridOptionscell: number | the cell size in metres (sets the scale of buoyancy and of the velocities) |
ambient: number | ambient temperature, in the same arbitrary unit as the heat sources (kelvin is natural) |
buoyancy: number | the acceleration (m/s^2) of gas much hotter than the air: g (T - ambient) / T, so the value is about 9.8 for gas that is free to rise |
weight: number | downward acceleration (m/s^2) per unit of density: heavy smoke sinks, cold smoke settles |
vorticity: number | vorticity confinement strength (0: smooth, 1: very curly) |
fade: number | per-second: the fraction of density lost (1/s) |
cooling: number | per-second: the temperature relaxes toward ambient at this rate (1/s) |
turbulence: number | strength of the noise force (m/s^2) and the size of its cells in grid cells |
turbulenceScale: number | |
iterations: number | pressure iterations per step |
drag: number | velocity damping (1/s) |
openTop: boolean | is the top open (the flow leaves), or a lid |
maccormack: boolean | the scalars are advected with MacCormack (sharper, three samples a cell) or plain semi-Lagrangian (one; for the live solver) |
packages/vfx/src/grid.ts:7
ImpostorRender interface
interface ImpostorRenderthe impostor rung: one cheap object for the whole effect
kind: 'strip' | 'card' | 'flash' | |
asset?: string | |
height?: Expr | |
width?: Expr | |
lean?: Expr | how far the strip leans downwind per metre of height |
color?: Rgb | the colour and opacity of the strip; default: the first emitter's colour (grey for smoke), 0.6 (0.9 for glow) |
alpha?: Expr | |
glow?: boolean | added to the picture instead of covering it (fire); a flash is always glow |
core?: boolean | a strip of an effect with flames also draws the glow of the flames (a hot additive strip the height of the flame, coloured by the fire's temperature); default true, false to leave it out |
packages/vfx/src/def.ts:120
Instance interface
interface Instancereadonly id: number | |
readonly cdef: CompiledDef | |
readonly seed: number | |
readonly params: Record<string, number> | |
readonly vars: Record<string, number> | |
readonly emitters: EmitterState[] | |
readonly attach?: { entity: number; node?: string } | |
readonly parent: number | |
readonly children: number[] | |
readonly axis: Vec3 | |
readonly curlOff: [number, number, number] | where this instance reads the curl field, from its seed |
t: number | seconds since the effect started (it waits startIn first) |
startIn: number | |
duration: number | |
pos: Vec3 | |
prev: Vec3 | |
vel: Vec3 | |
stopped: boolean | |
ended: boolean | |
started: boolean | |
queue: QueuedSpawn[] |
packages/vfx/src/sim.ts:101
Issue interface
interface Issuepath: string | |
message: string |
packages/vfx/src/validate.ts:9
LibraryFlipbook interface
interface LibraryFlipbookwhat the asset library gives for a flipbook (AssetLibrary.flipbook(id)): the item and the encoded images by name
item: { cols: number; rows: number; frames: number; motionScale?: number } | |
files: Partial<Record<'color' | 'light' | 'light2' | 'motion' | 'depth', Uint8Array>> |
packages/vfx/src/textures.ts:68
LightDef interface
interface LightDefrgb: Rgb | 'temperature' | |
intensity: Expr | candela for point lights |
range: Expr | |
offset?: Vec3 | |
flicker?: { amount: Expr; rate: Expr } | flicker as a fraction of the intensity and its rate per second |
over?: Curve | scales the intensity over the effect's life (position 0..1 of its duration) |
shadow?: boolean | |
farGlow?: Expr | metres out to which the glow still lights the ground and clouds by a cheap term |
packages/vfx/src/def.ts:175
LightState interface
interface LightStateid: number | |
pos: [number, number, number] | |
rgb: Rgb | |
intensity: number | candela |
range: number | |
shadow: boolean | |
farGlow: number | metres out to which the cheap glow still counts |
packages/vfx/src/parts.ts:39
LiquidProps interface
interface LiquidPropsdensity: number | |
surfaceTension: number |
packages/vfx/src/droplets.ts:23
LiveOptions interface
interface LiveOptionsresolution?: number | cells along a side (the walls take two of them), default 20 |
stepHz?: number | the solver's steps per second, default 20 |
maxSteps?: number | most steps one update may take (a stall must not become a spiral), default 1 |
seed?: number |
packages/vfx/src/volume.ts:34
LoopSound interface
interface LoopSound extends SoundBasepackages/vfx/src/def.ts:228
NetLike interface
interface NetLikethe part of the net service the replica uses (NetService of @ferret/net is this)
readonly id: string | |
send(name: string, data: unknown, to?: string): void | |
on(name: string, fn: (data: any, from: string) => void): () => void |
packages/vfx/src/vfx-net.ts:29
OneShotSound interface
interface OneShotSound extends SoundBaseat: Expr | seconds after the effect starts |
delayBySpeed?: boolean | arrives later by distance at the speed of sound in the medium; default true |
packages/vfx/src/def.ts:222
ParamDef interface
interface ParamDefunit?: string | the unit, for the editor and the docs: 'W', 'kg', 'm', 'K', '' |
default: number | |
min?: number | |
max?: number | |
doc?: string |
packages/vfx/src/def.ts:19
ParticleRender interface
interface ParticleRenderthe particles rung: GPU particles with flipbooks
kind: 'billboard' | 'streak' | 'ribbon' | 'mesh' | |
flipbook?: string | library asset ids; the flipbook is a sprite sheet, optionally with motion vectors and six-way light |
texture?: string | |
mesh?: string | |
blend: BlendMode | |
soft?: Expr | depth fade distance, metres; 0 or absent: hard edge |
lit?: boolean | takes the scene's light (six-way lightmaps for smoke) |
emissive?: Expr | emission multiplier; with a temperature the colour follows the blackbody |
motionBlend?: boolean | blend between flipbook frames by motion vectors |
stretch?: Expr | streak: length in seconds of travel; ribbon: width in metres |
width?: Expr | |
sort?: 'distance' | 'age' | 'none' |
packages/vfx/src/def.ts:71
PartRef interface
interface PartRefcomposition: an explosion is a fireball plus a flash, debris, dust, a smoke column, a scorch and a sound, each an effect of its own
def: string | the name of another effect definition |
offset?: Vec3 | |
delay?: Expr | |
params?: Record<string, Expr> | parameters of that effect, set from this effect's scope |
packages/vfx/src/def.ts:244
PartsViewOptions interface
interface PartsViewOptionsmaxLights?: number | the most point lights the effects may light at once; default 4 (the number a standard material takes) |
groundHeight?: (x: number, z: number) => number | the height of the ground at a point, for decals and the foot of far plumes |
shadowCasters?: () => BABYLON.AbstractMesh[] | meshes that cast the shadow of a light that asks for shadows (the strongest such light gets one) |
maxDecals?: number | most decals alive at once; the oldest go first; default 256 |
maxFar?: number | most strips and dots drawn; default 2048 |
candelaScale?: number | scale from candela to Babylon's light intensity; default 1/400 |
maxLightIntensity?: number | the most Babylon intensity one effect light may take, so that a huge fire does not burn the picture out; default none |
steadyLights?: boolean | keep the pool's lights switched on, at intensity 0 while unused: the number of lights a material sees then never changes, so no material recompiles when an effect lights up or goes out (a switched light changes every lit material's shader; while the new shaders compile Babylon draws nothing of those meshes). Costs the shading of the idle lights; default false |
maxTotalIntensity?: number | the most the pool's lights may add up to: when several effects light the same place (a blast over a burning tanker and its pool fires) their intensities are scaled down together to this sum, so that the picture is lit and not burnt out; default none |
packages/vfx/src/parts-view.ts:126
PuffOpts interface
interface PuffOptsname: string | |
max?: number | |
rate?: Expr | |
perMetre?: Expr | |
bursts?: Array<{ at: Expr; count: Expr }> | |
runFor?: Expr | |
delay?: Expr | |
shape?: SpawnShape | |
life: Range | |
velocity?: VelocityDef | |
size: Range | |
grow?: number | |
rgb: Rgb | |
alpha: number | string | |
flip?: 'smoke-puff' | 'dust-puff' | 'explosion-smoke' | 'soft-disc' | |
modules?: ModuleDef[] | |
temperature?: Range | |
lit?: boolean | |
alphaCurve?: Array<[number, number]> |
packages/vfx/src/catalog-kit.ts:8
ReplicaOptions interface
interface ReplicaOptionspeer: string | this peer's id |
send: (name: 'vfx:op' | 'vfx:hello' | 'vfx:sync', data: unknown, to?: string) => void | send a message to the other peers (to: one peer, absent: all) |
lead?: number | seconds ahead a command is stamped, so that it reaches the others before it takes effect (default 0.25) |
fire?: FireSpread | the fire front and its bridge, if the game has one |
bridge?: FireBridge | |
cellEffect?: string | the effect the bridge gives each burning cell (to find it again after a late join); default fire.grass |
now?: () => number | the wall clock, seconds (default performance.now() / 1000): a peer that joins measures the round trip of its hello and the answer, to bring its sim clock level with the answerer's |
packages/vfx/src/vfx-net.ts:35
ResolvedLadder interface
interface ResolvedLadderpackages/vfx/src/ladder.ts:18
ResolvedParams interface
interface ResolvedParamsvalues: Record<string, number> | every parameter of the definition, the given value clamped to its limits or the default |
unknown: string[] | names given that the definition does not have |
clamped: string[] | names whose given value was outside the limits and was clamped |
packages/vfx/src/params.ts:5
RothermelResult interface
interface RothermelResultrate: number | rate of spread of the head fire, m/s |
reactionIntensity: number | reaction intensity, kW/m^2 |
windLimit: number | the largest wind that the model counts (Albini's limit), m/s |
windFactor: number | the wind and slope factors of the model (dimensionless) |
slopeFactor: number | |
packing: number | packing ratio and the optimum packing ratio |
packingOptimum: number | |
residence: number | residence time of the flame front, s |
packages/vfx/src/spread.ts:50
RungOverrides interface
interface RungOverridesper-effect overrides of the ladder (ladder.ts has the defaults)
at?: Partial<Record<Exclude<Rung, 'none'>, number>> | projected diameter in pixels at which the rung starts being used |
minTier?: Partial<Record<Exclude<Rung, 'none'>, VfxTier>> | the lowest quality tier that may use the rung |
packages/vfx/src/def.ts:257
RungState interface
interface RungStatethe rung an instance is drawn with now, and how far a cross-fade to the next one has gone
packages/vfx/src/contracts.ts:68
Shading interface
interface Shadingkappa: number | extinction of the smoke per unit density per metre |
albedo: [number, number, number] | the colour smoke scatters, 0..1 |
glow?: { k: number; from: number; full: number; shift: number; gain: number } | glow: extinction per metre per unit of heat, the temperature (K) above which the gas glows, the temperature (K) of full heat, a shift added to the temperature before it is turned into a colour (the flame of a candle is cooler than the colour of a black body at its temperature), and the brightness |
packages/vfx/src/bake.ts:18
Sign interface
interface Signa sign an observer can notice: a stimulus of an effect in the world
id: number | |
kind: 'fire' | 'light' | 'noise' | 'smoke' | |
at: Vec3 | |
intensity: number | |
radius: number |
packages/vfx/src/sight.ts:107
SoundArrival interface
interface SoundArrivaldelay: number | |
gain: number | |
cutoff: number | |
audible: boolean |
packages/vfx/src/sound-fx.ts:54
SoundDef interface
interface SoundDefoneShots?: OneShotSound[] | |
loops?: LoopSound[] |
packages/vfx/src/def.ts:229
SoundPlayerOptions interface
interface SoundPlayerOptionsaudio: AudioLike | |
defOf: (name: string) => VfxDef | undefined | |
listener: () => Vec3 | where the listener is (the camera), m |
position?: (p: Vec3) => unknown | makes the position an audio service wants from a point (a Babylon vector for AudioService); default: the array itself |
air?: () => AirState | the air: temperature, humidity, pressure; default 20 C, 70 %, 101.325 kPa |
prefix?: string | put before the name of every preset (what defineSynthPresets was given) |
onPlay?: (effect: number, name: string, kind: 'oneshot' | 'loop', hears: ReturnType<typeof arrival>) => void | called for each sound started: the effect, the block and what the listener hears of it |
packages/vfx/src/sound-play.ts:16
SpawnOptions interface
interface SpawnOptionsat: Vec3 | |
direction?: Vec3 | the effect's forward axis; default up for plumes, world +z for beams |
params?: Params | values of the definition's parameters; the rest take their defaults |
seed?: number | default: derived from the definition's seed and the spawn count, the same on every peer |
attach?: { entity: number; node?: string } | follow an entity, or one of its nodes |
delay?: number | seconds to wait before it starts |
packages/vfx/src/contracts.ts:11
SpreadEnv interface
interface SpreadEnvwind(x: number, z: number, t: number): [number, number] | wind at midflame height, m/s, at a point and time (x, z, t) -> [x, z] components; the host's flow/weather |
height(x: number, z: number): number | ground height, m |
packages/vfx/src/spread.ts:128
SpreadEvent interface
interface SpreadEventkind: 'ignite' | 'out' | 'spot' | |
cell: number | |
x: number | |
z: number | |
t: number | |
from?: number |
packages/vfx/src/spread.ts:134
SpreadGrid interface
interface SpreadGridnx: number | |
nz: number | |
cell: number | |
x0: number | |
z0: number |
packages/vfx/src/spread.ts:127
SpreadOptions interface
interface SpreadOptionsspotRate?: number | the chance (0..1) that a cell lighting at the highest fireline intensity throws an ember that lights a spot fire; 0 turns spotting off (the default) |
windAdjust?: number | the fraction of the wind the host gives that is felt at midflame height; 1 when the host already gives midflame wind (the default) |
emberFall?: number | ember fall speed, m/s: an ember is carried by the wind for the time it takes to fall from the flame tip (the art number of the ember model, not a published one) |
packages/vfx/src/spread.ts:158
StopOptions interface
interface StopOptionsimmediate?: boolean | let the live particles finish (default) or remove them now |
packages/vfx/src/contracts.ts:25
StreakOpts interface
interface StreakOptsname: string | |
max?: number | |
rate?: Expr | |
bursts?: Array<{ at: Expr; count: Expr }> | |
runFor?: Expr | |
shape?: SpawnShape | |
life: Range | |
velocity: VelocityDef | |
size?: Range | |
rgb: Rgb | |
glow?: boolean | |
stretch?: number | |
modules?: ModuleDef[] | |
temperature?: Range | |
emissive?: number | |
alpha?: Array<[number, number]> |
packages/vfx/src/catalog-kit.ts:41
StripShape interface
interface StripShapeheight: number | the foot of the plume and its top, relative to the camera (the view adds the origin), metres |
width: number | |
lean: [number, number] | the top leans this far along the wind, metres (x, z) |
rgb: Rgb | |
alpha: number | |
glow: boolean | adds to the picture (fire, a flash) instead of covering it |
packages/vfx/src/parts.ts:151
SubEmitterDef interface
interface SubEmitterDefon: 'death' | 'collision' | |
emitter: string | the name of another emitter of the same effect |
count?: Expr | |
chance?: Expr |
packages/vfx/src/def.ts:59
Sun interface
interface SuntoSun: [number, number, number] | |
color: [number, number, number] |
packages/vfx/src/volume-view.ts:89
SweepHit interface
interface SweepHitwhat the simulation asks of the world; every part is optional (no host: still air, no ground)
x: number | |
y: number | |
z: number | |
nx: number | |
ny: number | |
nz: number |
packages/vfx/src/sim.ts:16
Target interface
interface Targeta thing that can catch fire from the radiation of fires: a part of a building, a vehicle, a stack of supplies
id: number | |
at: Vec3 | |
material: Combustible | |
burn: { effect: string; params?: Record<string, number> } | |
entity?: number |
packages/vfx/src/spread-bridge.ts:23
TextureProvider interface
interface TextureProviderget(id: string | undefined, scene: BABYLON.Scene): Flipbook |
packages/vfx/src/textures.ts:18
ValidateOptions interface
interface ValidateOptionsknown?: (name: string) => VfxDef | undefined | finds another definition by name; with it the parts of a composed effect are checked (they exist, their parameters exist, no cycle) |
packages/vfx/src/validate.ts:11
VelocityDef interface
interface VelocityDefspeed: Range | |
direction?: 'out' | 'up' | 'forward' | Vec3 | out from the spawn point; up; forward (the effect's axis); or a fixed direction |
spread?: Expr | half-angle of the cone round the direction, degrees; default 0 |
inherit?: Expr | share of the emitter's own velocity the particle inherits (a moving vehicle's dust); default 0 |
packages/vfx/src/def.ts:39
VfxBabylonViewOptions interface
interface VfxBabylonViewOptionstextures?: TextureProvider | where flipbooks come from; default the generated ones |
meshes?: (id: string) => BABYLON.Mesh | undefined | mesh particles: the source mesh of a library mesh id |
supports?: readonly DrawnRung[] | the rungs this view can draw (F3 and F4 add the others); default particles only |
fadeTime?: number | seconds a change of rung is faded over; default 0.25 |
maxParticles?: number | the budget: particles drawn per frame (the nearest effects first) |
soft?: boolean | soft particles need the scene's depth; true builds a depth renderer on the camera |
light?: () => [number, number, number] | the light that lit particles take, 0..1; default derived from the scene's lights |
volumes?: (id: string) => BakedVolumeData | undefined | baked volumes: the data of a library volume id, loaded already (AssetLibrary.volume); absent or undefined: that effect falls back to its particles |
sun?: () => Sun | undefined | the sun for volumes; default the scene's first directional light |
volumeSteps?: number | raymarching steps per pixel of a volume, default 48 |
parts?: PartsViewOptions | lights, decals and the far rungs: the light budget, ground height, shadow casters |
keepBatches?: boolean | keep the batch (mesh and shader) of an effect kind that has had no particles for 600 frames; default false (it is disposed, and drawing it again compiles its shader again, a stall at the first blast after a quiet spell) |
packages/vfx/src/view.ts:19
VfxBlock interface
interface VfxBlockthe vfx block of a level manifest: definitions of the level's own, and the effects placed in it
defs?: VfxDef[] | |
place?: VfxPlacement[] |
packages/vfx/src/vfx-commands.ts:17
VfxDef interface
interface VfxDefversion: 1 | |
name: string | the id used by vfx.spawn, parts and the library: letters, digits, ., _, - |
description?: string | |
seed?: number | |
params?: Record<string, ParamDef> | |
duration?: Expr | seconds; absent: runs until stopped |
radius?: Expr | bounding radius in metres, for the projected size that picks the rung |
emitters?: EmitterDef[] | |
volume?: VolumeRender | |
impostor?: ImpostorRender | |
dot?: DotRender | |
light?: LightDef | |
decals?: DecalDef[] | |
distort?: DistortDef[] | |
sound?: SoundDef | |
game?: GameDef | |
parts?: PartRef[] | |
rungs?: RungOverrides |
packages/vfx/src/def.ts:264
VfxEndEvent interface
interface VfxEndEventid: number | |
def: string | |
stopped: boolean |
packages/vfx/src/events.ts:24
VfxHandle interface
interface VfxHandlereadonly id: number |
packages/vfx/src/contracts.ts:9
VfxHost interface
interface VfxHostwind?(x: number, y: number, z: number, t: number, out: [number, number, number]): void | the air's velocity at a point and time, m/s, written to out |
groundHeight?(x: number, z: number): number | height of the ground at (x, z) |
sweep?(ax: number, ay: number, az: number, bx: number, by: number, bz: number, out: SweepHit): boolean | the first body hit by the segment a to b; false if none |
attachment?(a: { entity: number; node?: string }, out: [number, number, number]): boolean | where an attached entity (or node) is now; false if it is gone |
surfacePoint?(a: { entity: number; node?: string }, u: number, v: number, w: number, out: SweepHit): boolean | a point on the surface of the attached mesh for u, v, w in [0, 1), and the normal there |
packages/vfx/src/sim.ts:17
VfxIgniteEvent interface
interface VfxIgniteEventat: Vec3 | |
power: number | |
fuel?: string | |
entity?: number | |
cause: 'spread' | 'ember' | 'heat' | 'explosion' | 'manual' |
packages/vfx/src/events.ts:25
VfxMsg interface
interface VfxMsgan operation on the wire: when it takes effect (sim seconds), who sent it, its number from that sender
op: VfxOp | |
time: number | |
peer: string | |
n: number |
packages/vfx/src/vfx-net.ts:25
VfxOutEvent interface
interface VfxOutEventat: Vec3 | |
cause: 'fuel' | 'rain' | 'water' | 'manual' |
packages/vfx/src/events.ts:27
VfxPlacement interface
interface VfxPlacementa placement in a level: an effect at a place, with its parameters
id: string | |
def: string | |
at: Vec3 | |
dir?: Vec3 | |
params?: Record<string, number> | |
seed?: number | |
attach?: { entity: number; node?: string } | |
delay?: number |
packages/vfx/src/vfx-commands.ts:15
VfxSight interface
interface VfxSightsmoke against sight (stage F7): what the AI and the visibility rays ask of the simulation
opticalDepth(a: Vec3, b: Vec3): number | the optical depth (integral of extinction, dimensionless) along the segment a..b through every smoke in the sim |
transmittance(a: Vec3, b: Vec3): number | exp(-opticalDepth): the share of light that gets through, 1 clear .. 0 hidden |
packages/vfx/src/contracts.ts:47
VfxSim interface
interface VfxSimthe deterministic side
register(def: VfxDef): void | |
has(name: string): boolean | |
spawn(name: string, o: SpawnOptions): VfxHandle | |
stop(h: VfxHandle, o?: StopOptions): void | |
setParam(h: VfxHandle, name: string, value: number): void | |
step(dt: number): void | advance by one fixed step, seconds |
snapshot(): VfxSnapshot | |
restore(s: VfxSnapshot): void |
packages/vfx/src/contracts.ts:34
VfxSmokeEvent interface
interface VfxSmokeEvententity: number | |
extinction: number |
packages/vfx/src/events.ts:28
VfxSnapshot interface
interface VfxSnapshota serialisable copy of the whole simulation, for replication, late join and golden traces
version: 1 | |
time: number | |
nextId: number | |
spawns: number | |
data: unknown |
packages/vfx/src/contracts.ts:31
VfxSpawnEvent interface
interface VfxSpawnEventid: number | |
def: string | |
at: Vec3 | |
seed: number |
packages/vfx/src/events.ts:23
VfxSpreadEvent interface
interface VfxSpreadEventpackages/vfx/src/events.ts:26
VfxSync interface
interface VfxSynctime: number | |
snapshot: VfxSnapshot | |
fire: VfxMsg[] | |
pending: VfxMsg[] | |
nets: Array<[string, number]> | |
counter: number |
packages/vfx/src/vfx-net.ts:26
VfxView interface
interface VfxViewthe drawing side: never changes the game, may differ by tier
draw(frame: ViewFrame): void | |
rungOf(h: VfxHandle): RungState | undefined | |
readonly budget: { particles: number; lights: number; overdraw: number } | the budget the governor holds the view to: particles drawn, lights, and the share of overdraw |
dispose(): void |
packages/vfx/src/contracts.ts:71
VfxViewStats interface
interface VfxViewStatsinstances: number | |
rungs: Record<Rung, number> | |
particles: number | |
batches: number | |
culled: number | particles left out because the budget was reached |
drawMs: number | CPU milliseconds of the last draw() |
packages/vfx/src/view.ts:142
ViewFrame interface
interface ViewFramewhat the view is told about the camera and the budget each frame
cameraPosition: Vec3 | |
fov: number | vertical field of view, radians, and the height of the render target in pixels: together they give the projected size |
heightPx: number | |
tier: VfxTier | |
dt: number | seconds since the last frame |
night?: number | how dark the scene is, 0 (day) to 1 (night): lights count for more and smudges for less in the dark; absent: read from the scene's own lights |
packages/vfx/src/contracts.ts:55
VolumeLayerOptions interface
interface VolumeLayerOptionsdepth?: BABYLON.DepthRenderer | null | the scene's depth (storeCameraSpaceZ) for hiding what is behind walls; absent: the volume draws over everything |
sun?: () => Sun | undefined | the sun, default: the scene's first directional light, or a mild one from above |
sky: () => [number, number, number] | the sky and ambient light that smoke takes, 0..1 |
steps?: number | marching steps per pixel, default 48 |
packages/vfx/src/volume-view.ts:91
VolumeRender interface
interface VolumeRenderthe volume rung: raymarched density and temperature in a box
source: 'live' | 'baked' | live: a small grid solver near the camera; baked: a volume sequence from the library |
asset?: string | |
feeds?: string[] | names of emitters whose particles inject density and heat into the grid |
resolution?: number | grid cells along the longest side |
density: Expr | density injected per second at each source (a particle of a fed emitter), in units where 1 is thick smoke |
temperature?: Expr | temperature of the gas injected, kelvin; absent: the particle's own temperature, or the air's |
size?: number | the edge of the box the volume fills, metres (it stands on the effect's origin, centred); default 4 |
densityMax?: number | the density that is full white in the volume, and the temperature that is fully hot (the data are bytes) |
heatMax?: number | |
extinction?: number | extinction per metre per unit of density; default 4 |
detail?: number | how much the smoke is eroded into wisps by fine noise at draw time, 0..1; default 0.6 (the grid is too coarse for small detail) |
scattering?: Rgb | |
emission?: Expr | |
selfShadow?: boolean |
packages/vfx/src/def.ts:93
VolumeSource interface
interface VolumeSourcereadonly n: number | voxels along each side of the texture |
readonly size: number | metres along each side of the box the volume fills |
readonly scale: number | a point of the box at uvw in 0..1 reads the texture at uvw * scale + bias |
readonly bias: number | |
readonly data: Uint8Array | two bytes per voxel: density, heat |
version: number | changes whenever data does, so the view uploads only what is new |
readonly densityMax: number | |
readonly heatMax: number | the temperature a full heat byte means, and the air's (a zero one), kelvin |
readonly ambient: number | |
update(inst: Instance, dt: number): boolean | advances to the time of the instance; true when data changed |
origin(inst: Instance, out: [number, number, number]): void | the lowest corner of the box in the world |
packages/vfx/src/volume.ts:12
Types
Available type
type Available = Record<DrawnRung, boolean>packages/vfx/src/select.ts:14
BlendMode type
type BlendMode = 'alpha' | 'add' | 'premultiplied' | 'multiply'packages/vfx/src/def.ts:68
CModule type
type CModule = | { kind: 'gravity'; scale: CExpr } | { kind: 'drag'; coefficient: CExpr } | { kind: 'buoyancy'; accel: CExpr } | { kind: 'wind'; influence: CExpr } | { kind: 'curl'; strength: CExpr; scale: CExpr; speed: CExpr } | { kind: 'cooling'; halfLife: CExpr; ambient: CExpr }packages/vfx/src/compile.ts:24
CShape type
type CShape = | { kind: 'point' } | { kind: 'sphere'; radius: CExpr; surface: boolean } | { kind: 'disc'; radius: CExpr; ring: boolean } | { kind: 'box'; size: [CExpr, CExpr, CExpr] } | { kind: 'line'; length: CExpr } | { kind: 'surface' }packages/vfx/src/compile.ts:16
Curve type
type Curve = Array<[number, number]>[position 0..1, value], ascending by position
packages/vfx/src/def.ts:14
DrawnRung type
type DrawnRung = Exclude<Rung, 'none'>packages/vfx/src/ladder.ts:9
DrivenEventName type
type DrivenEventName = keyof typeof DRIVEN_EVENTSpackages/vfx/src/events.ts:46
Expr type
type Expr = number | stringa number, or an expression over parameters and the scope's variables
packages/vfx/src/def.ts:7
Gradient type
type Gradient = GradientKey[]packages/vfx/src/def.ts:16
InstJson type
type InstJson = { id: number; def: string; seed: number; params: Record<string, number>; attach?: { entity: number; node?: string }; parent: number; children: number[]; axis: Vec3; t: number; startIn: number; duration: number | null; pos: Vec3; prev: Vec3; vel: Vec3; stopped: boolean; ended: boolean; started: boolean; queue: any[]; emitters: EJ[] }packages/vfx/src/sim.ts:547
ModuleDef type
type ModuleDef = | { module: 'gravity'; scale?: Expr } | { module: 'drag'; coefficient: Expr } // velocity decays as exp(-coefficient * dt), per second | { module: 'buoyancy'; accel: Expr } // hot gas rises: upward acceleration accel * (T / 293.15 K - 1); accel 9.81 is the physical value | { module: 'wind'; influence?: Expr } // the velocity relaxes to the wind and flow field with a time constant of 0.5 s / influence (0: none) | { module: 'curl'; strength: Expr; scale: Expr; speed?: Expr } // swirling noise force | { module: 'cooling'; halfLife: Expr; ambient?: Expr } // the particle's temperature (K) relaxes to ambient | { module: 'collide'; with?: 'ground' | 'bodies' | 'both'; onHit?: 'bounce' | 'die' | 'stick'; bounce?: Expr; friction?: Expr }packages/vfx/src/def.ts:50
Params type
type Params = Readonly<Record<string, number>>packages/vfx/src/contracts.ts:7
PatchOp type
type PatchOp = { op: 'replace' | 'add' | 'remove'; path: string; value?: unknown }packages/vfx/src/vfx-commands.ts:66
Range type
type Range = Expr | [Expr, Expr]one value, or [min, max] drawn from the effect's seeded generator
packages/vfx/src/def.ts:9
Rgb type
type Rgb = [number, number, number]red, green, blue; may exceed 1 for emission
packages/vfx/src/def.ts:12
Rung type
type Rung = 'volume' | 'particles' | 'impostor' | 'dot' | 'none'packages/vfx/src/def.ts:253
SoundBlock type
type SoundBlock = OneShotSound | LoopSoundpackages/vfx/src/sound-fx.ts:63
SpawnShape type
type SpawnShape = | { shape: 'point' } | { shape: 'sphere'; radius: Expr; surface?: boolean } | { shape: 'disc'; radius: Expr; ring?: boolean } // in the horizontal plane | { shape: 'box'; size: [Expr, Expr, Expr] } | { shape: 'line'; length: Expr } // along the effect's forward axis | { shape: 'surface' }packages/vfx/src/def.ts:29
Vars type
type Vars = Readonly<Record<string, number>>packages/vfx/src/expr.ts:120
Vec3 type
type Vec3 = [number, number, number]packages/vfx/src/def.ts:10
VfxEventName type
type VfxEventName = (typeof VFX_EVENTS)[keyof typeof VFX_EVENTS]packages/vfx/src/events.ts:21
VfxOp type
type VfxOp = | { k: 'spawn'; net: string; def: string; at: Vec3; dir?: Vec3; params?: Record<string, number>; seed: number; attach?: { entity: number; node?: string } } | { k: 'stop'; net: string; immediate?: boolean } | { k: 'param'; net: string; name: string; value: number } | { k: 'ignite'; cell: number } | { k: 'wet'; cell: number; moisture: number }packages/vfx/src/vfx-net.ts:17
VfxTier type
type VfxTier = 'low' | 'medium' | 'high' | 'xr'packages/vfx/src/def.ts:254
Constants
AMBIENT_AIR_K const
const AMBIENT_AIR_K: 293.15packages/vfx/src/plume.ts:8
AMBIENT_K const
const AMBIENT_K: 293.15packages/vfx/src/sim.ts:13
BAKE_VERSION const
const BAKE_VERSION: 2bump when a recipe or the renderer changes what it makes: the item records it, so an old bake is told from a new one
packages/vfx/src/bake.ts:16
BLAST_CATALOG const
const BLAST_CATALOG: readonly VfxDef[]packages/vfx/src/catalog-blast.ts:255
BLAST_EXPR const
const BLAST_EXPR: { readonly heFireballRadius: "(pow(3 * tnt / (4 * 3.14159265 * 1630), 0.3333333) * pow(21000000000 / 101325, 0.26666666666666666))"; readonly fuelFireballDiameter: "(5.8 * pow(fuel, 0.3333333))"; readonly fuelFireballDuration: "(if(step(fuel, 30000), 0.45 * pow(fuel, 0.3333333), 2.6 * pow(fuel, 0.1666667)))"; readonly shockRingRadius: "(10 * pow(tnt, 0.3333333))"; readonly columnHeight: "(6 * pow( …the expression forms of the above, for definitions with the parameter tnt (kg) or fuel (kg)
packages/vfx/src/blast-fx.ts:41
COLUMN_K const
const COLUMN_K: 6the top of the smoke column over a ground burst, m: art, scaled as the cube root of the charge like every length of the blast (k = 6 m per kg^(1/3))
packages/vfx/src/blast-fx.ts:37
CONSTANTS const
const CONSTANTS: Readonly<Record<string, number>>packages/vfx/src/expr.ts:23
CONVECTIVE_FRACTION const
const CONVECTIVE_FRACTION: 0.7the convective share of the heat release (the rest is radiated): 0.7 for the usual luminous hydrocarbon and wood fires
packages/vfx/src/plume.ts:22
DEFAULT_GRID const
const DEFAULT_GRID: GridOptionspackages/vfx/src/grid.ts:35
DEFAULT_RUNG_AT const
const DEFAULT_RUNG_AT: Readonly<Record<DrawnRung, number>>INITIAL projected diameters in pixels at which a rung starts; replaced by measured values (see above)
packages/vfx/src/ladder.ts:12
DEFAULT_RUNG_MIN_TIER const
const DEFAULT_RUNG_MIN_TIER: Readonly<Record<DrawnRung, VfxTier>>the lowest tier that may use a rung: the raymarched volume needs a strong GPU
packages/vfx/src/ladder.ts:14
DRIVEN_EVENTS const
const DRIVEN_EVENTS: { readonly 'explosion:blast': "physics-explosions"; readonly 'explosion:crater': "physics-explosions"; readonly 'explosion:camouflet': "physics-explosions"; readonly 'explosion:fragments': "physics-explosions"; readonly 'explosion:exposure': "physics-explosions"; readonly 'explosion:spall': "physics-explosions"; readonly 'explosion:break': "physics-explosions"; readonly 'explosion:hit': "physics-e …the physics events the drive turns into effects, with the capability that sends each
packages/vfx/src/events.ts:31
DROPLET_WGSL_CLEAR const
const DROPLET_WGSL_CLEAR: "\nstruct Impacts { count: atomic<u32>, a: u32, b: u32, c: u32, items: array<vec4<f32>> };\n@group(0) @binding(0) var<storage, read_write> impacts: Impacts;\n@compute @workgroup_size(1)\nfn main() { atomicStore(&impacts.count, 0u); }\n"packages/vfx/src/droplets.ts:417
DROPLET_WGSL_COMMON const
const DROPLET_WGSL_COMMON: "\nstruct Params {\n dt: f32, time: f32, capacity: f32, head: f32, total: f32, emitters: f32, rhoL: f32, sigma: f32,\n airN: f32, airCell: f32, airX: f32, airZ: f32, lowH: f32, highH: f32, seed: f32, maxImpacts: f32,\n wind: vec4<f32>,\n surfN: f32, surfCell: f32, surfX: f32, surfZ: f32, p0: f32, p1: f32, p2: f32, p3: f32,\n q0: f32, q1: f32, q2: f32, q3: f32,\n};\nfn pcg(v: u32) -> u32 {\n …packages/vfx/src/droplets.ts:296
DROPLET_WGSL_EMIT const
const DROPLET_WGSL_EMIT: stringpackages/vfx/src/droplets.ts:312
DROPLET_WGSL_STEP const
const DROPLET_WGSL_STEP: stringpackages/vfx/src/droplets.ts:344
EMITTER_FLOATS const
const EMITTER_FLOATS: 24floats per emitter: a.xyz count | b.xyz first | out.xyz speed | speedSpread elevation elevationSpread diameter | sigma life volume tag | carrier.xyz azimuthSpread
packages/vfx/src/droplets.ts:15
ENERGY_CATALOG const
const ENERGY_CATALOG: readonly VfxDef[]packages/vfx/src/catalog-energy.ts:185
EXPR const
const EXPR: { readonly flameHeight: "max(0.2 * D, 0.235 * pow(heat / 1000, 0.4) - 1.02 * D)"; readonly virtualOrigin: "(0.083 * pow(heat / 1000, 0.4) - 1.02 * D)"; readonly tipVelocity: "pow(heat / 1000 * 0.7, 0.3333333) * pow(max(max(0.2 * D, 0.235 * pow(heat / 1000, 0.4) - 1.02 * D) - (0.083 * pow(heat / 1000, 0.4) - 1.02 * D), 0.05), -0.3333333)"; readonly tipRise: "min(800, 25 * pow(pow(heat / 1000 * 0.7, …the same quantities as expressions of the definition's parameters heat (W) and D (m), as strings the expression language takes (the catalogue embeds them)
packages/vfx/src/plume.ts:52
FIRE_CATALOG const
const FIRE_CATALOG: readonly VfxDef[]packages/vfx/src/catalog-fire.ts:293
FLAT const
const FLAT: { id: string; name: string; tags: string[]; make: () => BakedFlipbook; }[]the flat (no solver) flipbooks of the library: id, name, tags, and the maker
packages/vfx/src/bake.ts:263
FUEL_MODEL_1 const
const FUEL_MODEL_1: FuelBedstandard fuel model 1, short grass (Anderson 1982; RMRS-GTR-371 table of standard fuel models): 0.74 tons/acre, SAV 3500 1/ft, depth 1.0 ft, Mx 12 %; the report's constants for every standard model: 8000 Btu/lb, 32 lb/ft^3, mineral 0.0555 and 0.010
packages/vfx/src/spread.ts:38
FUELS const
const FUELS: Record<string, Fuel>burning-rate data (Babrauskas, in the SFPE Handbook): gasoline 0.055 kg/m^2 s and 43.7 MJ/kg, kerosene 0.039 and 43.2, ethanol 0.015 and 26.8, heavy fuel oil 0.035 and 39.7
packages/vfx/src/catalog-fire.ts:30
FULL_CATALOG const
const FULL_CATALOG: readonly VfxDef[]the whole catalogue (fire and smoke, explosions and weapons, water steam and dust, energy) with sounds
packages/vfx/src/catalog-sound.ts:148
FUNCTIONS const
const FUNCTIONS: Readonly<Record<string, [number, number]>>[min args, max args] of every function; max Infinity means "any number"
packages/vfx/src/expr.ts:18
G const
const G: 9.80665packages/vfx/src/world-fx.ts:5
GOVERNOR_STEPS const
const GOVERNOR_STEPS: readonly GovernorStep[]the order in which detail is given up; the first step is full detail
packages/vfx/src/governor.ts:19
GRAVITY const
const GRAVITY: 9.81packages/vfx/src/sim.ts:12
IMPACT_FLOATS const
const IMPACT_FLOATS: 4floats per impact: x z diameter speed
packages/vfx/src/droplets.ts:17
KELVIN_ANGLE const
const KELVIN_ANGLE: numberthe angle of the wake behind a ship at any speed in deep water, radians: the Kelvin wedge, asin(1/3) = 19.47 degrees
packages/vfx/src/world-fx.ts:21
LOST_TAU const
const LOST_TAU: numberthe optical depth at which a dark object on a light background is lost: contrast exp(-tau) under 2 %, tau = ln 50
packages/vfx/src/sight.ts:22
MAX_RISE_K const
const MAX_RISE_K: 800the plume's temperature rise is capped by what a flame can be: nothing above this rise over ambient (mean flame temperature is about 900-1100 K)
packages/vfx/src/plume.ts:37
MOTION_SCALE const
const MOTION_SCALE: 0.08packages/vfx/src/bake.ts:62
MU_AIR const
const MU_AIR: 0.0000181packages/vfx/src/droplets.ts:21
NIGHT_NOTICE_GAIN const
const NIGHT_NOTICE_GAIN: 4how much farther a fire or a light is noticed in full night than in full day; the eye's threshold for a point of light falls by orders of magnitude with the dark (a design value, set per game)
packages/vfx/src/sight.ts:98
PARAM_FLOATS const
const PARAM_FLOATS: 32the step's constants, in the order of the WGSL Params struct
packages/vfx/src/droplets.ts:173
PARCEL_FLOATS const
const PARCEL_FLOATS: 12floats per parcel: pos.xyz age | vel.xyz life | diameter seed tag volume
packages/vfx/src/droplets.ts:13
PRODUCTS_GAMMA const
const PRODUCTS_GAMMA: 1.25the effective adiabatic exponent of the products as they expand down to ambient pressure (a derivation constant, 1.25)
packages/vfx/src/blast-fx.ts:11
RADIANCE_EXPR const
const RADIANCE_EXPR: "clamp(pow(temp / 1200, 4), 0, 1.5)"the same as an expression of the particle's own temperature temp (kelvin)
packages/vfx/src/plume.ts:64
RADIATIVE_FRACTION const
const RADIATIVE_FRACTION: 0.3the share of the heat release radiated from a luminous hydrocarbon or wood fire (the rest is carried by the plume): 1 - CONVECTIVE_FRACTION
packages/vfx/src/spread.ts:272
RECIPES const
const RECIPES: BakeRecipe[]packages/vfx/src/bake.ts:215
RHO_AIR const
const RHO_AIR: 1.225packages/vfx/src/droplets.ts:20
RING_Z const
const RING_Z: 10the scaled distance, m/kg^(1/3), out to which the ring of the shock is drawn: where the overpressure of the Kinney-Graham curve has fallen to about 10 kPa (Z of about 10)
packages/vfx/src/blast-fx.ts:33
RUNG_ORDER const
const RUNG_ORDER: readonly Rung[]from the richest to the cheapest
packages/vfx/src/ladder.ts:7
SATELLITE_SHARE const
const SATELLITE_SHARE: 0.2the share of a breaking parcel's liquid that goes into fine satellite drops (a tenth of the parent's diameter) per breakup
packages/vfx/src/droplets.ts:57
SCOPE_EFFECT const
const SCOPE_EFFECT: readonly string[]variables an expression may read, by where it is evaluated
packages/vfx/src/validate.ts:17
SCOPE_PARTICLE const
const SCOPE_PARTICLE: readonly string[]packages/vfx/src/validate.ts:19
SCOPE_SPAWN const
const SCOPE_SPAWN: readonly string[]packages/vfx/src/validate.ts:18
SILENT const
const SILENT: Readonly<Record<string, string>>items with no sound of their own, and why: a candle, a thin chimney and a fog bank make no noise a game would hear at any distance a listener could be at
packages/vfx/src/catalog-sound.ts:126
SOOT_EXTINCTION_M2KG const
const SOOT_EXTINCTION_M2KG: 8700specific extinction coefficient of flaming soot, m^2 per kg: 8.7 m^2/g (Mulholland and Croarkin, Fire and Materials 24, 2000)
packages/vfx/src/sight.ts:17
SOOT_FULL_YIELD const
const SOOT_FULL_YIELD: 0.12the soot yield (g of soot per g of fuel, sootYield of
packages/vfx/src/plume.ts:67
SOUND_PRESETS const
const SOUND_PRESETS: readonly string[]the names of the synth presets the catalogue uses, for defineSynthPresets(audio, { names })
packages/vfx/src/catalog-sound.ts:150
SOUND_SPEED_WATER const
const SOUND_SPEED_WATER: 1480packages/vfx/src/sound-fx.ts:8
SPLASH_K const
const SPLASH_K: 0.5the radius of the splash crown of a body that falls into water with kinetic energy E (J): R = k (E / (rho g))^(1/4), the gravity-regime cavity scaling; k = 0.5 is an art constant
packages/vfx/src/world-fx.ts:17
STEAM_LATENT const
const STEAM_LATENT: 2257000latent heat of vaporisation of water at 100 C, J/kg
packages/vfx/src/world-fx.ts:7
TIER_ORDER const
const TIER_ORDER: readonly VfxTier[]packages/vfx/src/ladder.ts:8
TNT_CJ_PRESSURE const
const TNT_CJ_PRESSURE: 21000000000packages/vfx/src/blast-fx.ts:9
TNT_DENSITY const
const TNT_DENSITY: 1630density of cast TNT, kg/m^3, and its Chapman-Jouguet pressure, Pa (Cooper, Explosives Engineering: 1630 kg/m^3, 21 GPa)
packages/vfx/src/blast-fx.ts:9
VFX_EVENTS const
const VFX_EVENTS: { readonly spawn: "vfx:spawn"; readonly end: "vfx:end"; readonly ignite: "vfx:ignite"; readonly spread: "vfx:spread"; readonly out: "vfx:out"; readonly smokeEnter: "vfx:smoke-enter"; readonly smokeLeave: "vfx:smoke-leave"; }packages/vfx/src/events.ts:6
WATER const
const WATER: LiquidPropspackages/vfx/src/droplets.ts:24
WATER_DENSITY const
const WATER_DENSITY: 1000packages/vfx/src/world-fx.ts:5
WE_CRIT const
const WE_CRIT: 12the critical Weber number above which a drop breaks (bag breakup)
packages/vfx/src/droplets.ts:48
WORLD_CATALOG const
const WORLD_CATALOG: readonly VfxDef[]packages/vfx/src/catalog-world.ts:165
WORLD_EXPR const
const WORLD_EXPR: { readonly steamPower: "(flow * 2257000)"; readonly fountainHeight: "(pressure / 9806.65)"; readonly jetHeight: "(speed * speed / 19.6133)"; readonly splashRadius: "(0.5 * pow(energy / 9806.65, 0.25))"; readonly breathVisible: "saturate((10 - tempC) / 15)"; }packages/vfx/src/world-fx.ts:29