# @ferret/levels: API (continued)

### SoundSink

*interface* · `packages/levels/src/library.ts:135`

```ts
interface SoundSink
```

What `AssetLibrary.sound` needs of the audio service (`AudioService` of `@ferret/media` is one): take the bytes of a file and define a sound over them.

- `addFile(key: string, data: Uint8Array): unknown`
- `define(name: string, def: Record<string, unknown>): unknown`
- `has(name: string): boolean`

### SpawnPoint

*interface* · `packages/levels/src/levels.ts:8`

```ts
interface SpawnPoint
```

- `id: string`
- `position: BABYLON.Vector3`
- `yaw: number`
- `human?: string`

### StageModel

*interface* · `packages/levels/src/fmdl-motion.ts:289`

```ts
interface StageModel
```

what the stage can place by id: the loader's `FmdlModel` is one (`stage.addModel`), a test gives its own

- `id: string`
- `resolved?: ResolvedModel` — the resolved model and a reader of its files by qualified path: what its motions are found and read from (`ModelPrograms`)
- `read?: (qualified: string) => Promise<Uint8Array>`
- `make(level: number, name: string): { root: Node; plan: AssemblyPlan }` — the nodes of a level, not parented, and the plan they were made from

### StageOptions

*interface* · `packages/levels/src/fmdl-motion.ts:311`

```ts
interface StageOptions
```

- `scene?: BABYLON.Scene`
- `emit?: (name: string, payload: unknown) => void` — the events of the world (`world.events.emit`); none in a plain test

### StageWatcher

*interface* · `packages/levels/src/fmdl-motion.ts:318`

```ts
interface StageWatcher
```

Who is told of the models of a stage (the code of models).

- `appearing?(model: StageModel): void` — a model is about to appear: throwing refuses it, and nothing is built
- `appeared?(actor: Actor): void` — an actor has appeared, placed; throwing takes it away again
- `vanishing?(name: string): void` — an actor is about to go (its nodes are still there)
- `step?(dt: number): void` — a fixed step of the stage

### StreamCellDef

*interface* · `packages/levels/src/manifest.ts:34`

```ts
interface StreamCellDef
```

One grid cell of a streamed level: visual content only; collision is whole-level and resident. `bounds` = [minX, minY, minZ, maxX, maxY, maxZ].

- `bounds: [number, number, number, number, number, number]`
- `file: string`
- `size?: number`
- `priority?: number`
- `pinned?: boolean` — always resident (the play area round the spawn): fetched first, part of the ready gate, never released and never evicted for memory
- `layer?: string` — a key of `layers`: the cell uses that layer's radii instead of the block's (foliage is wanted closer than houses)
- `memory?: number` — bytes the cell takes once resident (geometry plus decoded textures); counted against `memoryBudget`. Default: `size`
- `lod?: string` — a low-poly stand-in shown while the cell is farther than `loadRadius` but within `lodRadius` (a few percent of the cell's triangles, no textures worth the name)
- `details?: StreamDetailDef[]` — Lighter variants of the same cell (fewer triangles, smaller textures), nearest first: the cell is made of its `file` within `fullRadius` of the player and of the first variant whose `radius` reaches it farther out (the last one up to `loadRadius`). A variant has the cell's mesh names for what it keeps but may leave small things out, so an entity that `needs` the cell exists only while the full file is the resident one.

### StreamDetailDef

*interface* · `packages/levels/src/manifest.ts:51`

```ts
interface StreamDetailDef
```

One lighter variant of a streamed cell (`StreamCellDef.details`): `radius` is the distance from the player up to which it is wanted (increasing along the list, at most `loadRadius`); `size` / `memory` are what it takes once resident.

- `file: string`
- `radius: number`
- `size?: number`
- `memory?: number`

### StreamingBlock

*interface* · `packages/levels/src/manifest.ts:54`

```ts
interface StreamingBlock
```

The `streaming` block. A level without it loads whole, as before.

- `cell: number` — the grid size in metres the cells were cut with (informational for tools)
- `cells: Record<string, StreamCellDef>`
- `loadRadius: number` — metres from the player: cells inside are loaded (and are part of the ready gate at the spawn)
- `unloadRadius: number` — cells farther than this are released; must be at least `loadRadius`
- `bundles?: Record<string, { files: string[]; trigger?: string }>` — groups of files loaded together when a zone is entered (or on demand)
- `lodRadius?: number` — metres from the player within which a cell's `lod` stand-in is shown; at least `loadRadius` (default: `unloadRadius`)
- `fullRadius?: number` — metres from the player within which a cell is made of its full file; farther (up to `loadRadius`) it is made of its `details` variants. Default: `loadRadius` (the variants are not used). A change of variant has `detailHysteresis` metres of margin (default 8), so a player standing on a border does not make a cell swap back and forth.
- `detailHysteresis?: number`
- `readyRadius?: number` — metres from the player within which the cells are what `ready()` waits for (the start screen); the rest of `loadRadius` streams in behind the player, nearest first, under the memory budget. Default: `loadRadius`.
- `layers?: Record<string, { loadRadius?: number; unloadRadius?: number; lodRadius?: number; fullRadius?: number }>` — radii per kind of cell, over the block's: a cell names its layer in `layer`. `unloadRadius` must not be below `loadRadius` (that gap is the hysteresis)
- `memoryBudget?: number` — bytes of cells that may be resident at once (this tier's cap: every tier package has its own block). Pinned cells are counted but never evicted; a nearer cell takes the place of farther ones, and when it still does not fit it waits (event `stream:budget`)
- `maxPerFrame?: number` — pacing over the service's defaults (2 cells and 4 ms per update, 3 fetches at once); the host's options win
- `budgetMs?: number`
- `concurrency?: number`
- `texturesProgressive?: boolean` — reserved: low mips first, upgrade later; nothing acts on it yet

### StreamingOptions

*interface* · `packages/levels/src/streaming.ts:28`

```ts
interface StreamingOptions
```

- `at(file: string): string` — where the level's files are (cell and bundle file names are relative to it)
- `focus?: () => Focus[]` — the places that matter, asked every update; when it gives none (or is left out): the persistent entities of the level service, else the active camera
- `radiusScale?: number` — scale both radii (a tier may ask for less)
- `memoryBudget?: number` — bytes of resident cells, over the block's `memoryBudget` (a tier or a device may ask for less)
- `maxPerFrame?: number` — most cells instantiated in one update
- `budgetMs?: number` — milliseconds of instantiation work per update; at least one cell is always added when something waits, so streaming cannot starve
- `concurrency?: number` — most cells fetched at once
- `now?: () => number`

### SunShadows

*interface* · `packages/levels/src/sun-shadows.ts:49`

```ts
interface SunShadows
```

- `readonly generator: BABYLON.CascadedShadowGenerator`
- `add(meshes: Iterable<BABYLON.AbstractMesh>): void` — let these meshes (and their thin instances) cast and receive the sun's shadows
- `dispose(): void`

### SunShadowsDef

*interface* · `packages/levels/src/sun-shadows.ts:14`

```ts
interface SunShadowsDef
```

- `cascades?: number` — number of cascades, 2 to 4 (default 4)
- `distance?: number` — how far from the camera the sun's shadows are drawn, metres (default 200)
- `mapSize?: number` — side of each cascade's depth map, texels (default 2048)
- `bias?: number` — depth bias of the map (default 0.0005)
- `normalBias?: number` — bias along the normal, metres (default 0.05)
- `blend?: number` — the share of a cascade over which it blends into the next (default 0.1)
- `lambda?: number` — 0 = evenly spaced cascades, 1 = logarithmic: near cascades finer (default 0.95)
- `filter?: 'pcf' | 'hard'` — the edge: `pcf` (soft, the default) or `hard`

### SwarmDef

*interface* · `packages/levels/src/swarm.ts:10`

```ts
interface SwarmDef
```

A swarm of small flyers (butterflies, a moth round a lamp, fireflies): each agent is pushed by the forces Unreal's Niagara "hanging particulates" stack uses, summed and
integrated with drag and a speed limit: a curl-noise field (a swirling, divergence-free drift), a vortex round a vertical axis through the centre, an attraction to the
centre, the wind, and an optional repulsion near the centre (a moth bumping off the lamp). Plain numbers, deterministic from the seed; metres, seconds.
The Babylon part (`buildSwarm`) draws every agent as an instance of one mesh, turned along its flight.

- `name?: string`
- `position: [number, number, number]` — centre of the swarm
- `count: number`
- `radius: number` — the agents start inside a sphere of this radius about `position` + `offset`
- `offset?: [number, number, number]`
- `scale?: [number, number]` — uniform scale range of the mesh
- `drag?: number` — 1/s
- `speedLimit?: number` — m/s
- `curl?: Array<{ strength: number; frequency: number }>` — curl noise layers: strength is m/s^2, frequency 1/m
- `vortex?: { amount: number; radius: number; pull?: number }`
- `attraction?: { radius: number; strength: number; exponent?: number }` — pulls towards the centre inside `radius` with a strength falling off as (1 - d/radius)^exponent
- `repulsion?: { radius: number; strength: number; exponent?: number }` — pushes away from the centre inside `radius` (negative attraction), `kill` m: an agent closer is put back at the edge
- `windAir?: number` — m/s^2 added along x/z of the level's wind, times this (default 0)
- `seed?: number`
- `distance?: number` — the swarm runs only while the camera is within this many metres (default 40)

### Transition

*interface* · `packages/levels/src/transitions.ts:37`

```ts
interface Transition
```

- `enter(ctx: TransitionContext): Promise<void> | void` — The travel starts. Show something at once. Resolve when it is on screen (after 2 s the engine's bar takes over).
- `update(p: TransitionProgress): void` — The target's progress, many times a second.
- `ready(ctx: TransitionContext): Promise<void> | void` — The target is ready. Resolve when the game wants to leave: a door has opened, a button was pressed, a timer ran out.
- `fail(ctx: TransitionContext, err: StreamError): boolean | void | Promise<boolean | void>` — The target failed or the player cancelled. Return true when the transition shows the failure itself (Retry / Back); otherwise the engine's screen is shown.
- `dispose(): void`

### TransitionContext

*interface* · `packages/levels/src/transitions.ts:16`

```ts
interface TransitionContext
```

- `from: LevelDef | null`
- `to: LevelDef`
- `plan: LevelPlan` — what the travel will download; `cached` means a short wait is expected
- `world: World`
- `events: EventBus`
- `ui?: UIService` — the services a game's splash usually wants, when the game has them
- `audio?: unknown`
- `input?: unknown`
- `xr?: { active: boolean; state: string }` — the VR session service when the game has one: a transition may show its interlude world in the headset; `xr.active` says whether a session runs
- `persistent: Set<Entity>` — the player and what travels with them
- `host?: SceneHost` — the scene host (5.3): make a second world for an interlude with `host.create`, show it with `host.show`. The engine shows the level's world again when the player is let in. Present when the game added a `SceneHost`.
- `signal: AbortSignal` — the player cancelled

### TransitionProgress

*interface* · `packages/levels/src/transitions.ts:14`

```ts
interface TransitionProgress
```

What a transition is told, many times a second, while the target downloads. Numbers are honest bytes of what the target needs.

- `loaded: number`
- `total: number`
- `files: number`
- `rate: number`
- `eta: number`
- `phase: string`

### TravelOptions

*interface* · `packages/levels/src/levels.ts:68`

```ts
interface TravelOptions
```

- `spawn?: string`
- `keep?: Entity[]` — keep these entities: they move to the new level's spawn instead of being removed (the player)
- `keepOld?: boolean` — Keep the old level's way back: if the new one fails after the old was released, build the old one again and put the player where they were (default: LevelOptions.keepOldUntilReady, else the hub).
- `signal?: AbortSignal` — Cancel from a menu: before the old level is released the player simply stays; later they are put back.
- `transition?: string` — The game's transition for this travel, by the name it registered (else its chooser, else `default`, else the engine's bar).

### ValidateOptions

*interface* · `packages/levels/src/ferret.ts:182`

```ts
interface ValidateOptions
```

- `packages?: PackageSet` — the other open packages, for `ferret://` references and dependencies
- `behaviours?: Iterable<string>` — behaviours the game registers itself (besides those packages provide); when given, an unknown behaviour is an issue
- `checksums?: boolean` — check the sha256 of every file (default true)
- `engine?: EngineVersions | false` — the engine that is running; default this build's (`FERRET_VERSION`, `BABYLON_VERSION`); `false` skips the check of the manifest's `engine`
- `tierView?: boolean` — set when `pkg` is already one tier's view of a game (its own call for each tier)
- `fetched?: boolean` — a build: a dependency that is not open need not be, when the package names `catalogs` (the player fetches it from there and checks it before the start)

### VirtualTextureDef

*interface* · `packages/levels/src/landscape.ts:108`

```ts
interface VirtualTextureDef
```

- `resolution?: number` — texels along the longer side of the rectangle (default 2048)
- `blendHeight?: number` — metres above the ground over which a prop's albedo fades from the ground colour to its own (default 1.5)
- `strength?: number` — 0..1, how much of the ground colour a prop takes at its foot (default 1)
- `meshes: string` — regex source: the meshes (by name, anywhere in the level) whose materials sample the virtual texture

### VisibilityBlock

*interface* · `packages/levels/src/manifest.ts:150`

```ts
interface VisibilityBlock
```

The `visibility` block: a level of many rooms (a castle) draws only what can be seen from where the player stands. The level's nodes are
split into named groups (a room, a corridor); the floor plan is cut by a grid of `cell` metres in x and z (origin 0, key "ix_iz" with
ix = floor(x / cell)); `see[key]` lists the groups that can be seen from anywhere in that grid cell. A tool computes the lists (rays against
the level's collision, tools/visibility.mjs). The player in a cell that has no entry sees everything: a gap in the table is never a hole.

- `cell: number`
- `groups: Record<string, { nodes: string[] }>` — group id -> the glTF node names that make it up (each node with all it carries)
- `always?: string[]` — groups that are always drawn (a landmark seen from everywhere)
- `see: Record<string, string[]>`
- `mode?: 'visible' | 'enable'` — 'visible' (default): meshes of an unseen group are not drawn but keep their collision; 'enable': the nodes are disabled (cheapest; collision goes too)

### VisibilityOptions

*interface* · `packages/levels/src/visibility.ts:5`

```ts
interface VisibilityOptions
```

- `focus?: () => { x: number; z: number } | null` — where the viewer stands; default the camera

### Waitable

*interface* · `packages/levels/src/fmdl-motion.ts:36`

```ts
interface Waitable
```

- `done(): boolean`
- `result?: unknown`

### WakeRow

*interface* · `packages/levels/src/wake.ts:22`

```ts
interface WakeRow
```

- `dist: number`
- `tau: number`
- `coreHalf: number`
- `coreAlpha: number`
- `armOffset: number`
- `armHalf: number`
- `armAlpha: number`

### WaterDef

*interface* · `packages/levels/src/water.ts:21`

```ts
interface WaterDef
```

- `level: number` — y of the surface at rest
- `centre?: [number, number]` — centre (x, z) and size (x, z) of the surface, metres
- `size?: [number, number]`
- `absorption?: Vec3` — the colour of the water seen from above when deep: Unreal's single-layer water `Absorption` is the distance per colour channel (cm) light goes before it is gone, `Scattering` how much the water sends back; the colour is the scattering tinted by those distances
- `scattering?: Vec3`
- `deepBrightness?: number` — a factor on that deep colour (default 1): a scattering of 1 asks for the full colour, which the original shows dimmed by the light that reaches the water in the shade of its banks
- `sky?: { top?: Vec3; horizon?: Vec3 }` — the colour of the sky it reflects (default the sky's horizon / top)
- `roughness?: number` — 0..1 (default 0.02)
- `specular?: number` — 0..1, the part of the sky a calm surface reflects head-on (default 0.02, about water's Fresnel at normal incidence)
- `waves?: WaterWave[]`
- `opacity?: number` — 0..1, how opaque the surface draws (default 0.92)
- `foam?: number` — 0..1, how strongly breaking crests turn to white water (default 0.8; a gentle sea has none whatever this is)
- `meso?: number` — 0..1: patches, wind streaks and whitecaps that show from high above, where real waves are smaller than a pixel (default 0: off)
- `river?: RiverDef` — a river instead of a rectangle (Unreal's WaterBodyRiver: a spline with a width): the surface is a ribbon along the centre line, its ripples run downstream at `flow`, the banks get a rim of foam. With a river `level` is the height of the first point, `centre`, `size` and `waves` are not used.
- `shore?: ShoreDef` — a lake with a shore (Unreal's WaterBodyLake: a closed spline): the surface is cut to this outline ([x, z] points in metres, 3..64, either winding) and a band of `width` metres inside the edge turns to foam (a lapping shore). The surface's extent is the outline's bounding box; `centre` and `size` are not used.

### WaterResponseMap

*interface* · `packages/levels/src/water.ts:279`

```ts
interface WaterResponseMap
```

a height field of what moves the surface (a jet's dent, rings, a wash) laid over a river: size x size cells of 4 floats (surface height above rest m, slope x, slope z, foam 0..1); `@ferret/physics-response` fills it from a `WaterSurface`. Without one a river is drawn as before.

- `readonly size: number`
- `readonly cell: number`
- `readonly originX: number`
- `readonly originZ: number`
- `readonly data: Float32Array`
- `readonly active: boolean`
- `readonly version: number`
- `readonly rings?: { readonly packed: Float32Array; readonly max: number }` — the ring sources (RingField of

### WaterSurfaceView

*interface* · `packages/levels/src/water.ts:283`

```ts
interface WaterSurfaceView
```

- `mesh: BABYLON.Mesh`
- `material: BABYLON.ShaderMaterial`
- `setWaves(waves: WaterWave[]): void`
- `setReflection(tex: BABYLON.BaseTexture | null): void`
- `dispose(): void`

### WaterWave

*interface* · `packages/levels/src/water.ts:10`

```ts
interface WaterWave
```

- `wavelength: number` — metres crest to crest
- `amplitude: number` — metres, crest above the rest level
- `steepness?: number` — 0..1: how sharp the crests are (Gerstner Q)
- `direction?: number` — degrees about the vertical, the way the wave travels (0 = +x)

## Types

### EnvironmentPart

*type* · `packages/levels/src/levels.ts:49`

```ts
type EnvironmentPart = 'sun' | 'ambient' | 'fog' | 'sky' | 'water'
```

a part of a level's environment a game may leave out (`LevelDef.environment.skip`)

### FileReader

*type* · `packages/levels/src/fmdl.ts:16`

```ts
type FileReader = (qualified: string) => Promise<Uint8Array>
```

### Interp

*type* · `packages/levels/src/sequence.ts:15`

```ts
type Interp = 'linear' | 'cubic' | 'step'
```

A level sequence (Unreal's LevelSequence): tracks that move nodes and the camera over time, played once or looped, on level begin or on a trigger.
The JSON is what the exporter (vschool_ferret export/ue/probe_sequences.py, tools/sequences.mjs) writes for each sequence; lengths are metres, angles are quaternions
in the engine's frame (the exporter converts from Unreal's cm / Z-up), time is seconds.

  { name, length, loop?, play: 'begin' | 'trigger' | 'manual', trigger?: string (a trigger volume's id), rate?: 1,
    tracks: [ { target: string | { camera: true }, position?: Key3[], rotation?: Key4[], scale?: Key3[], fov?: Key1[] } ],
    events?: [ { t, name } ] }
  Key = { t, v, interp?: 'linear' | 'cubic' | 'step' }        (v: number | [x,y,z] | [x,y,z,w])
`target` is a scene node ("Actor>Component" or a name); `{ camera: true }` drives the active camera. Events are emitted on the world bus as `sequence:event`.

### LevelCodec

*type* · `packages/levels/src/level-materials.ts:33`

```ts
type LevelCodec = 'etc1s' | 'uastc'
```

### LevelCodecPolicy

*type* · `packages/levels/src/level-materials.ts:36`

```ts
type LevelCodecPolicy = 'best' | 'light' | 'chosen'
```

which file of a texture that exists in both codecs is read: `best` UASTC, `light` ETC1S, `chosen` the one the encoder's check chose

### LookScope

*type* · `packages/levels/src/material-look.ts:44`

```ts
type LookScope = 'type' | 'instance'
```

### LookTable

*type* · `packages/levels/src/material-look.ts:42`

```ts
type LookTable = Record<string, Record<string, MaterialLookDef>>
```

uid → glTF material name → look

### MaterialMapSlot

*type* · `packages/levels/src/material-look.ts:27`

```ts
type MaterialMapSlot = 'baseColor' | 'normal' | 'orm' | 'emissive' | 'opacity'
```

The look of the glTF materials of a level, set in the manifest (`materialLooks`) and changed live by the editor (`edit.material.*`).

A material is never addressed by its name across the whole scene (the same name stands in twenty places). Two scopes:
 - `types[typeUid][materialName]`: the TYPE, the model as an asset: the look goes to the named material of that model in ALL its instances ("all boards");
 - `instances[instanceUid][materialName]`: ONE concrete object (a node and what hangs on it, an entity, one placed actor): it goes over the type's look ("this board").
Inside a model the material is named by its glTF material name.

Where a uid comes from (the first that the scene offers wins, the others are fallbacks, so an old level without any extras still works):
 - type: glTF node `extras.ferret.uid.type` (the exporter writes the Unreal asset path) | the key of a placement list's `models` | the library id of that model | the glTF MESH name;
 - instance: glTF node `extras.ferret.uid.instance` (the exporter writes the actor name) | the manifest entity `id` | the placement `actor` | the node path (names from the scene root, joined with "/").
An address that more than one thing answers to (two glTF meshes of one name, two nodes of one path) is AMBIGUOUS: it still applies on load to everything it matches,
`edit.material.list` shows it, and the editor refuses to write on it (give the object a uid in the export instead).

The values are the ones of a library material (`MaterialDef` of

### ModelState

*type* · `packages/levels/src/runtime.ts:34`

```ts
type ModelState = 'loading' | 'ready' | 'failed'
```

### PlaceholderSpec

*type* · `packages/levels/src/runtime.ts:23`

```ts
type PlaceholderSpec = 'box' | 'none' | { size?: number | [number, number, number]; color?: [number, number, number] } | ((scene: BABYLON.Scene) => BABYLON.TransformNode)
```

### ProgramType

*type* · `packages/levels/src/material-program.ts:13`

```ts
type ProgramType = 1 | 2 | 3 | 4
```

### RefKind

*type* · `packages/levels/src/runtime.ts:14`

```ts
type RefKind = 'package' | 'remote' | 'relative'
```

### RegisterFn

*type* · `packages/levels/src/fmdl-docks.ts:262`

```ts
type RegisterFn = (name: string, description: string, fn: (args: any) => unknown) => void
```

### ResolvedAtmosphere

*type* · `packages/levels/src/atmosphere.ts:59`

```ts
type ResolvedAtmosphere = Required<AtmosphereDef>
```

### TextureCodecPolicy

*type* · `packages/levels/src/library.ts:34`

```ts
type TextureCodecPolicy = 'chosen' | 'best' | 'light'
```

### TransitionChooser

*type* · `packages/levels/src/transitions.ts:53`

```ts
type TransitionChooser = (from: LevelDef | null, to: LevelDef, plan: LevelPlan) => string | undefined | null
```

## Constants

### ARM_REACH

*const* · `packages/levels/src/wake.ts:28`

```ts
const ARM_REACH: 200
```

### ARM_STRENGTH

*const* · `packages/levels/src/wake.ts:28`

```ts
const ARM_STRENGTH: 0.14
```

The arms of the Kelvin wedge are a train of waves, not foam: faint next to the hull (a fifth of the core's strength at the stern) and spread over a widening band, they are
damped and lose their crests within a few hundred metres, while the turbulent core goes on for kilometres. `ARM_REACH` is the distance over which an arm falls to 1/e.

### ATMOSPHERE_EXPOSURE

*const* · `packages/levels/src/atmosphere.ts:47`

```ts
const ATMOSPHERE_EXPOSURE: 30
```

### ATMOSPHERE_FRAGMENT

*const* · `packages/levels/src/atmosphere.ts:198`

```ts
const ATMOSPHERE_FRAGMENT: "precision highp float;\nvarying vec3 vDir;\n#define N 24\nuniform vec3 rayleigh[N]; uniform vec3 mie[N];\nuniform vec3 sunDir; uniform vec3 sunColor; uniform vec3 sunDisc; uniform vec3 lum; uniform vec3 ground; uniform vec3 horizonFill;\nuniform float g; uniform float ms; uniform float exposure;\nvoid main() {\n  vec3 d = normalize(vDir);\n  float h = d.y;\n  vec3 toSun = -sunDir;\n  float c = do …
```

the sky dome's fragment shader body for the table (arrays of `LUT_SIZE` entries); uniforms: rayleigh[], mie[], sunDir, sunColor (already x strength), g, ms, lum, ground, exposure

### BAR

*const* · `packages/levels/src/transitions.ts:50`

```ts
const BAR: "bar"
```

The engine's own transition: it draws nothing itself, the loading screen of

### barTransition

*const* · `packages/levels/src/transitions.ts:51`

```ts
const barTransition: Transition
```

### COLOUR_ATTRIBUTE

*const* · `packages/levels/src/material-models.ts:409`

```ts
const COLOUR_ATTRIBUTE: "#if !defined(VERTEXCOLOR) && !defined(FERRET_COLOR_ATTR)\n#define FERRET_COLOR_ATTR\nattribute vec4 color;\n#endif"
```

the `color` attribute, declared once however many plugins (this and the foliage wind) read it; a mesh that uses vertex colours has it declared by Babylon already

### DEFAULT_LIBRARY_URL

*const* · `packages/levels/src/library.ts:32`

```ts
const DEFAULT_LIBRARY_URL: "/lib/ferret-assets/catalog.json"
```

### DISTANCE_FIELD_GLSL

*const* · `packages/levels/src/distance-field.ts:104`

```ts
const DISTANCE_FIELD_GLSL: "uniform highp sampler3D ferretMpDfTable;\nuniform highp sampler3D ferretMpDfValues;\nfloat ferretMpDfByte(vec3 w) {\n  vec3 v = (w - ferretMpDfOrigin.xyz) / ferretMpDfOrigin.w, b = floor(v / ferretMpDfAtlas.w);\n  if (any(lessThan(b, vec3(0.0))) || any(greaterThanEqual(b, ferretMpDfGrid.xyz))) return 1.0;\n  vec4 e = texelFetch(ferretMpDfTable, ivec3(b), 0);\n  if (e.a < 0.5) return 1.0;\n  vec3  …
```

the lookup: `ferretMpDfByte(world metres)` is the stored value 0..1 (1: far), `ferretMpDfMetres` the distance

### ENGINE_GLOBAL

*const* · `packages/levels/src/dock-engine.ts:8`

```ts
const ENGINE_GLOBAL: "__ferretEngine"
```

The engine a docked level's code shares with its parent. A level's code is built like a game's: an ES module that imports `@ferret/*`. A parent whose engine
is ES modules with an import map needs nothing more. A parent that ships its engine inside its own bundle (Ilion) publishes the packages it holds in `globalThis.__ferretEngine`
(`shareEngine`) and the code loader rewrites the imports of the module's text to read from there (`useSharedEngine`), so the level and the parent are one engine: one `World`, one set of
registries, one scheduler. A package the parent does not hold is an error that names it; a level that needs one carries it inside its own code (the converter and the scene builder inline it).

### HEIGHT_TRANSITION

*const* · `packages/levels/src/landscape.ts:142`

```ts
const HEIGHT_TRANSITION: 0.2
```

how much height a height-blended layer needs to beat the others (score units), as a transition width

### LEVEL_CODEC_POLICIES

*const* · `packages/levels/src/level-materials.ts:37`

```ts
const LEVEL_CODEC_POLICIES: readonly LevelCodecPolicy[]
```

### LEVEL_CODECS

*const* · `packages/levels/src/level-materials.ts:34`

```ts
const LEVEL_CODECS: readonly LevelCodec[]
```

### LEVEL_MATERIALS_FORMAT

*const* · `packages/levels/src/level-materials.ts:30`

```ts
const LEVEL_MATERIALS_FORMAT: "ferret-materials/1"
```

### LEVEL_TEXTURES_FORMAT

*const* · `packages/levels/src/level-materials.ts:31`

```ts
const LEVEL_TEXTURES_FORMAT: "ferret-textures/1"
```

### LOOK_SCOPES

*const* · `packages/levels/src/material-look.ts:45`

```ts
const LOOK_SCOPES: readonly LookScope[]
```

### LUT_SIZE

*const* · `packages/levels/src/atmosphere.ts:49`

```ts
const LUT_SIZE: 24
```

### MACRO_BLEND_DEFAULT

*const* · `packages/levels/src/material-models.ts:40`

```ts
const MACRO_BLEND_DEFAULT: 1.5
```

WorldCoordinate3Way's own default of its four blend inputs (Blend Exponent X / Y Z, Blend Mult X / Y Z): all 1.5 in the exported function

### MANIFEST_VERSION

*const* · `packages/levels/src/manifest.ts:14`

```ts
const MANIFEST_VERSION: 1
```

### MATERIAL_MAP_SLOTS

*const* · `packages/levels/src/material-look.ts:28`

```ts
const MATERIAL_MAP_SLOTS: readonly MaterialMapSlot[]
```

### MAX_LANDSCAPE_LAYERS

*const* · `packages/levels/src/landscape.ts:138`

```ts
const MAX_LANDSCAPE_LAYERS: 8
```

### MAX_LANDSCAPE_SAMPLERS

*const* · `packages/levels/src/landscape.ts:140`

```ts
const MAX_LANDSCAPE_SAMPLERS: 13
```

WebGL guarantees 16 texture units; the PBR material uses a few, so layers + normals + weightmaps stay under this

### MAX_MATERIAL_LIGHTS

*const* · `packages/levels/src/light-budget.ts:166`

```ts
const MAX_MATERIAL_LIGHTS: 8
```

most lights one material may light with (uniform-block limit of D3D11 through ANGLE, 12 vertex blocks, 4 taken by scene/material/mesh/bones)

### MOVEMENT_KEYS

*const* · `packages/levels/src/manifest.ts:161`

```ts
const MOVEMENT_KEYS: readonly ["radius", "height", "crouchHeight", "eyeHeight", "walkSpeed", "runSpeed", "crouchSpeed", "jumpVelocity", "gravity", "maxStepHeight", "walkableAngle", "acceleration", "braking", "airControl", "swimSpeed", "buoyancy", "swimAcceleration", "outOfWaterZ", "jumpOutOfWaterPitch", "maxOutOfWaterStepHeight"]
```

### MULTI_SCATTER

*const* · `packages/levels/src/atmosphere.ts:48`

```ts
const MULTI_SCATTER: 0.3
```

### PIXEL_DEPTH_THRESHOLD

*const* · `packages/levels/src/material-models.ts:42`

```ts
const PIXEL_DEPTH_THRESHOLD: 0.5
```

DitherTemporalAA's Alpha Threshold input default

### PLACEMENTS_FORMAT

*const* · `packages/levels/src/placements.ts:26`

```ts
const PLACEMENTS_FORMAT: "ferret-placements/1"
```

### programTime

*const* · `packages/levels/src/material-program.ts:270`

```ts
const programTime: { now: () => number; }
```

seconds since the module was loaded: the Time of every program (one clock, so equal materials blink together as in the original)

### RELIEF_DECAL_LAYER

*const* · `packages/levels/src/decal-buffer.ts:13`

```ts
const RELIEF_DECAL_LAYER: 268435456
```

the layer of the relief decals: outside a camera's default mask (0x0FFFFFFF)

### SCREEN_DECAL_LAYER

*const* · `packages/levels/src/screen-decals.ts:15`

```ts
const SCREEN_DECAL_LAYER: 536870912
```

the layer of the decal boxes: outside a camera's default mask (0x0FFFFFFF) and the relief decals' (0x10000000)

### SCREEN_DECAL_PASS

*const* · `packages/levels/src/screen-decals.ts:18`

```ts
const SCREEN_DECAL_PASS: { readonly colour: 0; readonly surface: 1; }
```

the two passes a decal's shader draws: its colour and opacity, then its roughness and metallic

### UE_UNITS_PER_METRE

*const* · `packages/levels/src/material-models.ts:38`

```ts
const UE_UNITS_PER_METRE: 100
```

### UNREAL_FILM_GLSL

*const* · `packages/levels/src/unreal-film.ts:20`

```ts
const UNREAL_FILM_GLSL: string
```

GLSL: `vec3 ferretUnrealFilm(vec3 linearSRGB)` -> linear sRGB in 0..1 (the caller encodes the gamma)

### UNREAL_FILM_TONEMAPPING

*const* · `packages/levels/src/unreal-film.ts:71`

```ts
const UNREAL_FILM_TONEMAPPING: 2
```

the Babylon tone mapping type that draws Unreal's film curve once `installUnrealFilm()` has run (it takes the place of the unused glTF PBR Neutral type)

