# @ferret/vfx: API (continued)

### PuffOpts

*interface* · `packages/vfx/src/catalog-kit.ts:8`

```ts
interface PuffOpts
```

- `name: 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]>`

### ReplicaOptions

*interface* · `packages/vfx/src/vfx-net.ts:35`

```ts
interface ReplicaOptions
```

- `peer: 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

### ResolvedLadder

*interface* · `packages/vfx/src/ladder.ts:18`

```ts
interface ResolvedLadder
```

- `at: Record<DrawnRung, number>`
- `minTier: Record<DrawnRung, VfxTier>`

### ResolvedParams

*interface* · `packages/vfx/src/params.ts:5`

```ts
interface ResolvedParams
```

- `values: 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

### RothermelResult

*interface* · `packages/vfx/src/spread.ts:50`

```ts
interface RothermelResult
```

- `rate: 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

### RungOverrides

*interface* · `packages/vfx/src/def.ts:257`

```ts
interface RungOverrides
```

per-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

### RungState

*interface* · `packages/vfx/src/contracts.ts:68`

```ts
interface RungState
```

the rung an instance is drawn with now, and how far a cross-fade to the next one has gone

- `rung: Rung`
- `from: Rung | null`
- `fade: number`
- `pixels: number`

### Shading

*interface* · `packages/vfx/src/bake.ts:18`

```ts
interface Shading
```

- `kappa: 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

### Sign

*interface* · `packages/vfx/src/sight.ts:107`

```ts
interface Sign
```

a 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`

### SoundArrival

*interface* · `packages/vfx/src/sound-fx.ts:54`

```ts
interface SoundArrival
```

- `delay: number`
- `gain: number`
- `cutoff: number`
- `audible: boolean`

### SoundDef

*interface* · `packages/vfx/src/def.ts:229`

```ts
interface SoundDef
```

- `oneShots?: OneShotSound[]`
- `loops?: LoopSound[]`

### SoundPlayerOptions

*interface* · `packages/vfx/src/sound-play.ts:16`

```ts
interface SoundPlayerOptions
```

- `audio: 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

### SpawnOptions

*interface* · `packages/vfx/src/contracts.ts:11`

```ts
interface SpawnOptions
```

- `at: 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

### SpreadEnv

*interface* · `packages/vfx/src/spread.ts:128`

```ts
interface SpreadEnv
```

- `wind(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

### SpreadEvent

*interface* · `packages/vfx/src/spread.ts:134`

```ts
interface SpreadEvent
```

- `kind: 'ignite' | 'out' | 'spot'`
- `cell: number`
- `x: number`
- `z: number`
- `t: number`
- `from?: number`

### SpreadGrid

*interface* · `packages/vfx/src/spread.ts:127`

```ts
interface SpreadGrid
```

- `nx: number`
- `nz: number`
- `cell: number`
- `x0: number`
- `z0: number`

### SpreadOptions

*interface* · `packages/vfx/src/spread.ts:158`

```ts
interface SpreadOptions
```

- `spotRate?: 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)

### StopOptions

*interface* · `packages/vfx/src/contracts.ts:25`

```ts
interface StopOptions
```

- `immediate?: boolean` — let the live particles finish (default) or remove them now

### StreakOpts

*interface* · `packages/vfx/src/catalog-kit.ts:41`

```ts
interface StreakOpts
```

- `name: 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]>`

### StripShape

*interface* · `packages/vfx/src/parts.ts:151`

```ts
interface StripShape
```

- `height: 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

### SubEmitterDef

*interface* · `packages/vfx/src/def.ts:59`

```ts
interface SubEmitterDef
```

- `on: 'death' | 'collision'`
- `emitter: string` — the name of another emitter of the same effect
- `count?: Expr`
- `chance?: Expr`

### Sun

*interface* · `packages/vfx/src/volume-view.ts:89`

```ts
interface Sun
```

- `toSun: [number, number, number]`
- `color: [number, number, number]`

### SweepHit

*interface* · `packages/vfx/src/sim.ts:16`

```ts
interface SweepHit
```

what 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`

### Target

*interface* · `packages/vfx/src/spread-bridge.ts:23`

```ts
interface Target
```

a 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`

### TextureProvider

*interface* · `packages/vfx/src/textures.ts:18`

```ts
interface TextureProvider
```

- `get(id: string | undefined, scene: BABYLON.Scene): Flipbook`

### ValidateOptions

*interface* · `packages/vfx/src/validate.ts:11`

```ts
interface ValidateOptions
```

- `known?: (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)

### VelocityDef

*interface* · `packages/vfx/src/def.ts:39`

```ts
interface VelocityDef
```

- `speed: 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

### VfxBabylonViewOptions

*interface* · `packages/vfx/src/view.ts:19`

```ts
interface VfxBabylonViewOptions
```

- `textures?: 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)

### VfxBlock

*interface* · `packages/vfx/src/vfx-commands.ts:17`

```ts
interface VfxBlock
```

the `vfx` block of a level manifest: definitions of the level's own, and the effects placed in it

- `defs?: VfxDef[]`
- `place?: VfxPlacement[]`

### VfxDef

*interface* · `packages/vfx/src/def.ts:264`

```ts
interface VfxDef
```

- `version: 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`

### VfxEndEvent

*interface* · `packages/vfx/src/events.ts:24`

```ts
interface VfxEndEvent
```

- `id: number`
- `def: string`
- `stopped: boolean`

### VfxHandle

*interface* · `packages/vfx/src/contracts.ts:9`

```ts
interface VfxHandle
```

- `readonly id: number`

### VfxHost

*interface* · `packages/vfx/src/sim.ts:17`

```ts
interface VfxHost
```

- `wind?(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

### VfxIgniteEvent

*interface* · `packages/vfx/src/events.ts:25`

```ts
interface VfxIgniteEvent
```

- `at: Vec3`
- `power: number`
- `fuel?: string`
- `entity?: number`
- `cause: 'spread' | 'ember' | 'heat' | 'explosion' | 'manual'`

### VfxMsg

*interface* · `packages/vfx/src/vfx-net.ts:25`

```ts
interface VfxMsg
```

an 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`

### VfxOutEvent

*interface* · `packages/vfx/src/events.ts:27`

```ts
interface VfxOutEvent
```

- `at: Vec3`
- `cause: 'fuel' | 'rain' | 'water' | 'manual'`

### VfxPlacement

*interface* · `packages/vfx/src/vfx-commands.ts:15`

```ts
interface VfxPlacement
```

a 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`

### VfxSight

*interface* · `packages/vfx/src/contracts.ts:47`

```ts
interface VfxSight
```

smoke 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

### VfxSim

*interface* · `packages/vfx/src/contracts.ts:34`

```ts
interface VfxSim
```

the 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`

### VfxSmokeEvent

*interface* · `packages/vfx/src/events.ts:28`

```ts
interface VfxSmokeEvent
```

- `entity: number`
- `extinction: number`

### VfxSnapshot

*interface* · `packages/vfx/src/contracts.ts:31`

```ts
interface VfxSnapshot
```

a serialisable copy of the whole simulation, for replication, late join and golden traces

- `version: 1`
- `time: number`
- `nextId: number`
- `spawns: number`
- `data: unknown`

### VfxSpawnEvent

*interface* · `packages/vfx/src/events.ts:23`

```ts
interface VfxSpawnEvent
```

- `id: number`
- `def: string`
- `at: Vec3`
- `seed: number`

### VfxSpreadEvent

*interface* · `packages/vfx/src/events.ts:26`

```ts
interface VfxSpreadEvent
```

- `from: Vec3`
- `to: Vec3`
- `rate: number`

### VfxSync

*interface* · `packages/vfx/src/vfx-net.ts:26`

```ts
interface VfxSync
```

- `time: number`
- `snapshot: VfxSnapshot`
- `fire: VfxMsg[]`
- `pending: VfxMsg[]`
- `nets: Array<[string, number]>`
- `counter: number`

### VfxView

*interface* · `packages/vfx/src/contracts.ts:71`

```ts
interface VfxView
```

the 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`

### VfxViewStats

*interface* · `packages/vfx/src/view.ts:142`

```ts
interface VfxViewStats
```

- `instances: 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()

### ViewFrame

*interface* · `packages/vfx/src/contracts.ts:55`

```ts
interface ViewFrame
```

what 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

### VolumeLayerOptions

*interface* · `packages/vfx/src/volume-view.ts:91`

```ts
interface VolumeLayerOptions
```

- `depth?: 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

### VolumeRender

*interface* · `packages/vfx/src/def.ts:93`

```ts
interface VolumeRender
```

the `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`

### VolumeSource

*interface* · `packages/vfx/src/volume.ts:12`

```ts
interface VolumeSource
```

- `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
- `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

## Types

### Available

*type* · `packages/vfx/src/select.ts:14`

```ts
type Available = Record<DrawnRung, boolean>
```

### BlendMode

*type* · `packages/vfx/src/def.ts:68`

```ts
type BlendMode = 'alpha' | 'add' | 'premultiplied' | 'multiply'
```

### CModule

*type* · `packages/vfx/src/compile.ts:24`

```ts
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 }
```

### CShape

*type* · `packages/vfx/src/compile.ts:16`

```ts
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' }
```

### Curve

*type* · `packages/vfx/src/def.ts:14`

```ts
type Curve = Array<[number, number]>
```

[position 0..1, value], ascending by position

### DrawnRung

*type* · `packages/vfx/src/ladder.ts:9`

```ts
type DrawnRung = Exclude<Rung, 'none'>
```

### DrivenEventName

*type* · `packages/vfx/src/events.ts:46`

```ts
type DrivenEventName = keyof typeof DRIVEN_EVENTS
```

### Expr

*type* · `packages/vfx/src/def.ts:7`

```ts
type Expr = number | string
```

a number, or an expression over parameters and the scope's variables

### Gradient

*type* · `packages/vfx/src/def.ts:16`

```ts
type Gradient = GradientKey[]
```

### InstJson

*type* · `packages/vfx/src/sim.ts:547`

```ts
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[] }
```

### ModuleDef

*type* · `packages/vfx/src/def.ts:50`

```ts
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 }
```

### Params

*type* · `packages/vfx/src/contracts.ts:7`

```ts
type Params = Readonly<Record<string, number>>
```

### PatchOp

*type* · `packages/vfx/src/vfx-commands.ts:66`

```ts
type PatchOp = { op: 'replace' | 'add' | 'remove'; path: string; value?: unknown }
```

### Range

*type* · `packages/vfx/src/def.ts:9`

```ts
type Range = Expr | [Expr, Expr]
```

one value, or [min, max] drawn from the effect's seeded generator

### Rgb

*type* · `packages/vfx/src/def.ts:12`

```ts
type Rgb = [number, number, number]
```

red, green, blue; may exceed 1 for emission

### Rung

*type* · `packages/vfx/src/def.ts:253`

```ts
type Rung = 'volume' | 'particles' | 'impostor' | 'dot' | 'none'
```

### SoundBlock

*type* · `packages/vfx/src/sound-fx.ts:63`

```ts
type SoundBlock = OneShotSound | LoopSound
```

### SpawnShape

*type* · `packages/vfx/src/def.ts:29`

```ts
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' }
```

### Vars

*type* · `packages/vfx/src/expr.ts:120`

```ts
type Vars = Readonly<Record<string, number>>
```

### Vec3

*type* · `packages/vfx/src/def.ts:10`

```ts
type Vec3 = [number, number, number]
```

### VfxEventName

*type* · `packages/vfx/src/events.ts:21`

```ts
type VfxEventName = (typeof VFX_EVENTS)[keyof typeof VFX_EVENTS]
```

### VfxOp

*type* · `packages/vfx/src/vfx-net.ts:17`

```ts
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 }
```

### VfxTier

*type* · `packages/vfx/src/def.ts:254`

```ts
type VfxTier = 'low' | 'medium' | 'high' | 'xr'
```

## Constants

### AMBIENT_AIR_K

*const* · `packages/vfx/src/plume.ts:8`

```ts
const AMBIENT_AIR_K: 293.15
```

### AMBIENT_K

*const* · `packages/vfx/src/sim.ts:13`

```ts
const AMBIENT_K: 293.15
```

### BAKE_VERSION

*const* · `packages/vfx/src/bake.ts:16`

```ts
const BAKE_VERSION: 2
```

bump when a recipe or the renderer changes what it makes: the item records it, so an old bake is told from a new one

### BLAST_CATALOG

*const* · `packages/vfx/src/catalog-blast.ts:255`

```ts
const BLAST_CATALOG: readonly VfxDef[]
```

### BLAST_EXPR

*const* · `packages/vfx/src/blast-fx.ts:41`

```ts
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)

### COLUMN_K

*const* · `packages/vfx/src/blast-fx.ts:37`

```ts
const COLUMN_K: 6
```

the 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))

### CONSTANTS

*const* · `packages/vfx/src/expr.ts:23`

```ts
const CONSTANTS: Readonly<Record<string, number>>
```

### CONVECTIVE_FRACTION

*const* · `packages/vfx/src/plume.ts:22`

```ts
const CONVECTIVE_FRACTION: 0.7
```

the convective share of the heat release (the rest is radiated): 0.7 for the usual luminous hydrocarbon and wood fires

### DEFAULT_GRID

*const* · `packages/vfx/src/grid.ts:35`

```ts
const DEFAULT_GRID: GridOptions
```

### DEFAULT_RUNG_AT

*const* · `packages/vfx/src/ladder.ts:12`

```ts
const DEFAULT_RUNG_AT: Readonly<Record<DrawnRung, number>>
```

INITIAL projected diameters in pixels at which a rung starts; replaced by measured values (see above)

### DEFAULT_RUNG_MIN_TIER

*const* · `packages/vfx/src/ladder.ts:14`

```ts
const DEFAULT_RUNG_MIN_TIER: Readonly<Record<DrawnRung, VfxTier>>
```

the lowest tier that may use a rung: the raymarched volume needs a strong GPU

### DRIVEN_EVENTS

*const* · `packages/vfx/src/events.ts:31`

```ts
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

### DROPLET_WGSL_CLEAR

*const* · `packages/vfx/src/droplets.ts:417`

```ts
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"
```

### DROPLET_WGSL_COMMON

*const* · `packages/vfx/src/droplets.ts:296`

```ts
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   …
```

### DROPLET_WGSL_EMIT

*const* · `packages/vfx/src/droplets.ts:312`

```ts
const DROPLET_WGSL_EMIT: string
```

### DROPLET_WGSL_STEP

*const* · `packages/vfx/src/droplets.ts:344`

```ts
const DROPLET_WGSL_STEP: string
```

### EMITTER_FLOATS

*const* · `packages/vfx/src/droplets.ts:15`

```ts
const EMITTER_FLOATS: 24
```

floats per emitter: a.xyz count | b.xyz first | out.xyz speed | speedSpread elevation elevationSpread diameter | sigma life volume tag | carrier.xyz azimuthSpread

### ENERGY_CATALOG

*const* · `packages/vfx/src/catalog-energy.ts:185`

```ts
const ENERGY_CATALOG: readonly VfxDef[]
```

### EXPR

*const* · `packages/vfx/src/plume.ts:52`

```ts
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)

### FIRE_CATALOG

*const* · `packages/vfx/src/catalog-fire.ts:293`

```ts
const FIRE_CATALOG: readonly VfxDef[]
```

### FLAT

*const* · `packages/vfx/src/bake.ts:263`

```ts
const FLAT: { id: string; name: string; tags: string[]; make: () => BakedFlipbook; }[]
```

the flat (no solver) flipbooks of the library: id, name, tags, and the maker

### FUEL_MODEL_1

*const* · `packages/vfx/src/spread.ts:38`

```ts
const FUEL_MODEL_1: FuelBed
```

standard 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

### FUELS

*const* · `packages/vfx/src/catalog-fire.ts:30`

```ts
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

### FULL_CATALOG

*const* · `packages/vfx/src/catalog-sound.ts:148`

```ts
const FULL_CATALOG: readonly VfxDef[]
```

the whole catalogue (fire and smoke, explosions and weapons, water steam and dust, energy) with sounds

### FUNCTIONS

*const* · `packages/vfx/src/expr.ts:18`

```ts
const FUNCTIONS: Readonly<Record<string, [number, number]>>
```

[min args, max args] of every function; max Infinity means "any number"

### G

*const* · `packages/vfx/src/world-fx.ts:5`

```ts
const G: 9.80665
```

### GOVERNOR_STEPS

*const* · `packages/vfx/src/governor.ts:19`

```ts
const GOVERNOR_STEPS: readonly GovernorStep[]
```

the order in which detail is given up; the first step is full detail

### GRAVITY

*const* · `packages/vfx/src/sim.ts:12`

```ts
const GRAVITY: 9.81
```

### IMPACT_FLOATS

*const* · `packages/vfx/src/droplets.ts:17`

```ts
const IMPACT_FLOATS: 4
```

floats per impact: x z diameter speed

### KELVIN_ANGLE

*const* · `packages/vfx/src/world-fx.ts:21`

```ts
const KELVIN_ANGLE: number
```

the angle of the wake behind a ship at any speed in deep water, radians: the Kelvin wedge, asin(1/3) = 19.47 degrees

### LOST_TAU

*const* · `packages/vfx/src/sight.ts:22`

```ts
const LOST_TAU: number
```

the optical depth at which a dark object on a light background is lost: contrast exp(-tau) under 2 %, tau = ln 50

### MAX_RISE_K

*const* · `packages/vfx/src/plume.ts:37`

```ts
const MAX_RISE_K: 800
```

the 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)

### MOTION_SCALE

*const* · `packages/vfx/src/bake.ts:62`

```ts
const MOTION_SCALE: 0.08
```

### MU_AIR

*const* · `packages/vfx/src/droplets.ts:21`

```ts
const MU_AIR: 0.0000181
```

### NIGHT_NOTICE_GAIN

*const* · `packages/vfx/src/sight.ts:98`

```ts
const NIGHT_NOTICE_GAIN: 4
```

how 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)

### PARAM_FLOATS

*const* · `packages/vfx/src/droplets.ts:173`

```ts
const PARAM_FLOATS: 32
```

the step's constants, in the order of the WGSL `Params` struct

### PARCEL_FLOATS

*const* · `packages/vfx/src/droplets.ts:13`

```ts
const PARCEL_FLOATS: 12
```

floats per parcel: pos.xyz age | vel.xyz life | diameter seed tag volume

### PRODUCTS_GAMMA

*const* · `packages/vfx/src/blast-fx.ts:11`

```ts
const PRODUCTS_GAMMA: 1.25
```

the effective adiabatic exponent of the products as they expand down to ambient pressure (a derivation constant, 1.25)

### RADIANCE_EXPR

*const* · `packages/vfx/src/plume.ts:64`

```ts
const RADIANCE_EXPR: "clamp(pow(temp / 1200, 4), 0, 1.5)"
```

the same as an expression of the particle's own temperature `temp` (kelvin)

### RADIATIVE_FRACTION

*const* · `packages/vfx/src/spread.ts:272`

```ts
const RADIATIVE_FRACTION: 0.3
```

the share of the heat release radiated from a luminous hydrocarbon or wood fire (the rest is carried by the plume): 1 - CONVECTIVE_FRACTION

### RECIPES

*const* · `packages/vfx/src/bake.ts:215`

```ts
const RECIPES: BakeRecipe[]
```

### RHO_AIR

*const* · `packages/vfx/src/droplets.ts:20`

```ts
const RHO_AIR: 1.225
```

### RING_Z

*const* · `packages/vfx/src/blast-fx.ts:33`

```ts
const RING_Z: 10
```

the 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)

### RUNG_ORDER

*const* · `packages/vfx/src/ladder.ts:7`

```ts
const RUNG_ORDER: readonly Rung[]
```

from the richest to the cheapest

### SATELLITE_SHARE

*const* · `packages/vfx/src/droplets.ts:57`

```ts
const SATELLITE_SHARE: 0.2
```

the share of a breaking parcel's liquid that goes into fine satellite drops (a tenth of the parent's diameter) per breakup

### SCOPE_EFFECT

*const* · `packages/vfx/src/validate.ts:17`

```ts
const SCOPE_EFFECT: readonly string[]
```

variables an expression may read, by where it is evaluated

### SCOPE_PARTICLE

*const* · `packages/vfx/src/validate.ts:19`

```ts
const SCOPE_PARTICLE: readonly string[]
```

### SCOPE_SPAWN

*const* · `packages/vfx/src/validate.ts:18`

```ts
const SCOPE_SPAWN: readonly string[]
```

### SILENT

*const* · `packages/vfx/src/catalog-sound.ts:126`

```ts
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

### SOOT_EXTINCTION_M2KG

*const* · `packages/vfx/src/sight.ts:17`

```ts
const SOOT_EXTINCTION_M2KG: 8700
```

specific extinction coefficient of flaming soot, m^2 per kg: 8.7 m^2/g (Mulholland and Croarkin, Fire and Materials 24, 2000)

### SOOT_FULL_YIELD

*const* · `packages/vfx/src/plume.ts:67`

```ts
const SOOT_FULL_YIELD: 0.12
```

the soot yield (g of soot per g of fuel, `sootYield` of

### SOUND_PRESETS

*const* · `packages/vfx/src/catalog-sound.ts:150`

```ts
const SOUND_PRESETS: readonly string[]
```

the names of the synth presets the catalogue uses, for `defineSynthPresets(audio, { names })`

### SOUND_SPEED_WATER

*const* · `packages/vfx/src/sound-fx.ts:8`

```ts
const SOUND_SPEED_WATER: 1480
```

### SPLASH_K

*const* · `packages/vfx/src/world-fx.ts:17`

```ts
const SPLASH_K: 0.5
```

the 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

### STEAM_LATENT

*const* · `packages/vfx/src/world-fx.ts:7`

```ts
const STEAM_LATENT: 2257000
```

latent heat of vaporisation of water at 100 C, J/kg

### TIER_ORDER

*const* · `packages/vfx/src/ladder.ts:8`

```ts
const TIER_ORDER: readonly VfxTier[]
```

### TNT_CJ_PRESSURE

*const* · `packages/vfx/src/blast-fx.ts:9`

```ts
const TNT_CJ_PRESSURE: 21000000000
```

### TNT_DENSITY

*const* · `packages/vfx/src/blast-fx.ts:9`

```ts
const TNT_DENSITY: 1630
```

density of cast TNT, kg/m^3, and its Chapman-Jouguet pressure, Pa (Cooper, Explosives Engineering: 1630 kg/m^3, 21 GPa)

### VFX_EVENTS

*const* · `packages/vfx/src/events.ts:6`

```ts
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"; }
```

### WATER

*const* · `packages/vfx/src/droplets.ts:24`

```ts
const WATER: LiquidProps
```

### WATER_DENSITY

*const* · `packages/vfx/src/world-fx.ts:5`

```ts
const WATER_DENSITY: 1000
```

### WE_CRIT

*const* · `packages/vfx/src/droplets.ts:48`

```ts
const WE_CRIT: 12
```

the critical Weber number above which a drop breaks (bag breakup)

### WORLD_CATALOG

*const* · `packages/vfx/src/catalog-world.ts:165`

```ts
const WORLD_CATALOG: readonly VfxDef[]
```

### WORLD_EXPR

*const* · `packages/vfx/src/world-fx.ts:29`

```ts
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)"; }
```

