# @ferret/levels: API (continued)

### LibrarySound

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

```ts
interface LibrarySound
```

- `readonly id: string`
- `readonly name: string`
- `readonly item: SoundItem`
- `readonly format: 'wav' | 'mp3'`

### LightBudgetDef

*interface* · `packages/levels/src/light-budget.ts:42`

```ts
interface LightBudgetDef
```

- `budget: number` — how many real lights at most. A quality tier sets it in its own manifest (a weak GPU 2-3, a strong one 8-12)
- `items: BudgetLight[]`
- `perMesh?: number` — how many real lights one material draws (the cost per pixel), default the budget, at most MAX_MATERIAL_LIGHTS - 2. Each mesh takes the pool's lights that reach it first (see sortMeshLights), so a pool larger than this costs no more per pixel: a big pool with a small `perMesh` lights a hall of hundreds of lamps where each surface sees its own nearest few
- `interval?: number` — seconds between two re-rankings (default 0.25)
- `fade?: number` — seconds a light takes to fade out of / into a real light (default 0.35)
- `hysteresis?: number` — a new light must be nearer than the one it replaces by this share to take its place (default 0.15): no flapping between two equal lamps
- `maxDistance?: number` — lights farther from the camera than this are nothing at all (default 200 m)
- `rank?: 'distance' | 'view'` — how the real lights are chosen. 'distance' (default): the nearest to the camera. 'view': the ones whose reach (sphere of `range`) is in the camera's view, largest on screen first (range / distance): a lamp behind the camera that lights nothing in view gives way to the lamps that light what the player sees (Castle: the lamps at a door 20 m ahead lost to the candles over the player's head)
- `falloff?: 'gltf' | 'linear' | 'unreal'` — how a light fades with distance. 'gltf' (default): 1/d^2 cut off at `range` (physical, Unreal's inverse-squared lights). 'linear': 1 - d/range, the intensity is the value at the source (Babylon's standard falloff): Unreal's legacy lights fade as (1 - (d/R)^2)^8 and stay near their source, which a line through the same half-value point follows closely (tools/ue-export/lights.mjs `falloff`), but its edge is a visible ring on a near wall. 'unreal': Unreal's own curve (1 - (d/range)^2)^8 with `range` the attenuation radius, soft to zero at its edge. It replaces Babylon's standard falloff in the PBR shader for the whole page (see useUnrealFalloff; nothing else in Ferret uses the standard falloff)
- `excludeMeshes?: string` — a regular expression on mesh names: the pool's real lights do not light these meshes (a surface that already carries its lamps' light baked in, see tools/ue-export/bake-direct.mjs: the real light would count twice, and the baked one shows at any distance)
- `glow?: { enabled?: boolean; /** colour multiplier (above 1 feeds bloom), default 2 */ boost?: number; /** metres, default from each light's range */ size?: number }` — the dot for lamps that are not real lights
- `clustered?: boolean` — every lamp is a real light, drawn through Babylon's clustered lighting (`ClusteredLightContainer`: lights are binned into screen tiles and depth slices, a material reads only its tile's lights) instead of a pool of the nearest few: no 8-light limit per material, no ranking, no glow dots, no per-mesh sorting. `budget` is ignored (every item is a light). Needs WebGL2 / WebGPU and spot or point lights; where the engine cannot (`BABYLON.ClusteredLightContainer` missing or unsupported) the pool works as before. `excludeMeshes` does not apply to clustered lights
- `sounds?: { budget: number; maxDistance?: number }` — the nearest lamps that have a `sound`: events tell which to start and stop

### LightBudgetOptions

*interface* · `packages/levels/src/light-budget.ts:157`

```ts
interface LightBudgetOptions
```

- `name?: string`
- `viewer?: () => Vec3 | undefined` — where the viewer is, in the level's metres; default the active camera
- `materials?: boolean` — raise the materials' light limit to fit the pool plus the sun and ambient lights (default true)

### LightBudgetStats

*interface* · `packages/levels/src/light-budget.ts:155`

```ts
interface LightBudgetStats
```

- `items: number`
- `budget: number`
- `real: number`
- `glowing: number`
- `reranks: number`
- `soundsOn: number`

### LoadableModel

*interface* · `packages/levels/src/fmdl-code.ts:66`

```ts
interface LoadableModel
```

what `load` takes: a resolved model with the reader of its chain's files (`FmdlModel.stageModel()`, a `ResolveResult`)

- `resolved?: ResolvedModel`
- `read?: (qualified: string) => Promise<Uint8Array>`

### LoadedCode

*interface* · `packages/levels/src/code.ts:39`

```ts
interface LoadedCode
```

- `id: string`
- `version: string`
- `exports: LibraryModule | null` — the module's exports; null for a package without code (only its dependencies were loaded)
- `commands: string[]` — commands and behaviours that appeared while `install` ran
- `behaviours: string[]`

### LookDef

*interface* · `packages/levels/src/material-models.ts:145`

```ts
interface LookDef
```

- `colourLayers?: ColourLayersDef`
- `macro?: MacroVariationDef[]`
- `groundBlend?: GroundBlendDef`
- `vertexMasks?: VertexMasksDef`
- `aoOnIndirect?: boolean`
- `pixelDepth?: PixelDepthDef`
- `detailNormal?: DetailNormalDef`
- `patternLayer?: PatternLayerDef`
- `flatten?: number` — Unreal's FlattenNormal of the material's own normal map: `n' = normalize(vec3(n.xy * s, 1 - (1 - n.z) * s))`; a level material's `normalScale` (not 1)
- `opacityGradient?: OpacityGradientDef`
- `depthFade?: DepthFadeDef`
- `opacity?: number`
- `graph?: GraphDef`
- `srgb?: readonly string[]` — names of the pictures of `masks` that are sRGB colour

### LookStructure

*interface* · `packages/levels/src/material-models.ts:117`

```ts
interface LookStructure
```

What the shader is built from: part of the define's name, so two materials of one structure share a program and two of different structure never do. Fields that are off are absent.

- `base: 'albedo' | 'colour' | 'graph' | 'none'`
- `layers: { mask: string; channel: MaskChannel; uv?: true; invert?: true }[]` — `uv`: its mask is read at a scale of its own; `invert`: the colour is painted where the mask is 0
- `macro: { mask: string }[]`
- `ground: boolean`
- `vc?: { ao: boolean; opacity: boolean }` — vertex colours read as masks: the red channel as occlusion, the alpha as a factor of the opacity mask
- `depth?: true` — pixel depth offset
- `flat?: true` — the material's own normal is flattened exactly as Unreal's FlattenNormal (the tilt and the z term scaled)
- `detail?: { map: string }` — the detail normal's picture
- `pattern?: { mask: string; channel: MaskChannel; normal?: string; occlusion?: string; occlusionChannel: 'r' | 'g' | 'b' | 'a' }` — a pattern's normal and occlusion over the material's own by a mask
- `fade?: { gradient?: { axis: 'u' | 'v'; invert: boolean }; opacity?: true; depth?: true }` — the opacity: a gradient along u or v, a constant, the depth behind the surface
- `gview?: true` — the graph reads the pixel's depth: the view matrix is bound
- `graph?: GraphDef` — the master as an expression tree (which outputs it sets is read off the tree)
- `srgb?: string[]` — names of the pictures that are colour (sRGB), decoded in the shader
- `aoIndirect?: true` — the material's occlusion dims indirect light only

### LookTarget

*interface* · `packages/levels/src/material-look.ts:152`

```ts
interface LookTarget
```

an address the scene answers to

- `scope: LookScope`
- `uid: string`
- `via: string[]` — where the uid comes from: extras, model, library, mesh (type); extras, entity, actor, path (instance)
- `meshes: number` — meshes (placed actors count once each) it covers
- `materials: string[]` — the glTF material names found on them
- `ambiguous?: string` — why a write on it is refused (absent: it is one thing)

### MacroBlend

*interface* · `packages/levels/src/material-models.ts:61`

```ts
interface MacroBlend
```

- `exponentX: number`
- `multX: number`
- `exponentYZ: number`
- `multYZ: number`

### ManifestEntity

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

```ts
interface ManifestEntity
```

- `id: string`
- `behaviour?: string` — a behaviour or component registered in the world (`world.components`)
- `components?: { name: string; params?: Record<string, unknown> }[]` — several components, each with its own parameters, when one behaviour is not enough
- `node?: string` — the name of a glTF node to wrap; without it a new empty node is made
- `transform?: { position?: [number, number, number]; rotation?: [number, number, number]; scale?: [number, number, number] }` — local transform applied to the node (or the new node)
- `params?: Record<string, unknown>`
- `tags?: string[]`
- `needs?: string` — the id of a streaming bundle this entity depends on: it is created once the bundle is in, and a placeholder stands at its position until then. It may also be the id of a streaming cell: the entity wraps a node of that cell, is made whenever the cell is resident and destroyed when the cell is released (no placeholder)

### ManifestIssue

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

```ts
interface ManifestIssue
```

- `path: string`
- `message: string`

### ManifestSpawn

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

```ts
interface ManifestSpawn
```

- `id: string`
- `position: [number, number, number]`
- `yaw?: number`
- `human?: string`

### MaterialInfo

*interface* · `packages/levels/src/material-look.ts:145`

```ts
interface MaterialInfo
```

- `name: string`
- `meshes: number`
- `look: boolean`
- `baseColor: [number, number, number, number]`
- `metallic: number | null`
- `roughness: number | null`
- `emissive: [number, number, number]`
- `emissiveStrength: number`
- `normalScale: number | null`
- `alphaMode: 'opaque' | 'mask' | 'blend'`
- `doubleSided: boolean`
- `maps: Partial<Record<MaterialMapSlot, boolean>>`

### MaterialLookDef

*interface* · `packages/levels/src/material-look.ts:30`

```ts
interface MaterialLookDef
```

- `baseColor?: [number, number, number] | [number, number, number, number]`
- `metallic?: number`
- `roughness?: number`
- `emissive?: [number, number, number]`
- `emissiveStrength?: number`
- `normalScale?: number`
- `alpha?: { mode: 'opaque' | 'mask' | 'blend'; cutoff?: number }`
- `doubleSided?: boolean`
- `maps?: Partial<Record<MaterialMapSlot, string>>`

### MaterialLooks

*interface* · `packages/levels/src/material-look.ts:43`

```ts
interface MaterialLooks
```

- `types?: LookTable`
- `instances?: LookTable`

### MaterialLooksHandle

*interface* · `packages/levels/src/material-look.ts:164`

```ts
interface MaterialLooksHandle
```

- `update(looks: MaterialLooks | undefined): void` — replace the looks: only what changed is touched
- `targets(scope: LookScope, o?: { filter?: string; limit?: number; aliases?: boolean }): Promise<{ entries: LookTarget[]; total: number; truncated: boolean }>` — the scene's addresses of a scope (regex `filter` on the uid; the most used first, `limit` of them). A model is listed by its best uid; `aliases` lists its other names (placement key, library id, glTF mesh name) too: they all work as addresses
- `resolve(scope: LookScope, uid: string): Promise<LookTarget | null>` — one address, or null when nothing of the scene answers to it
- `read(scope: LookScope, uid: string, material: string): MaterialInfo | null` — the values of that material on the first mesh the address covers, now (what the screen shows)
- `ready(): Promise<void>` — resolves when the names the looks need are read and the scene is in step with them
- `dispose(): void` — takes every look off and stops watching

### MaterialLooksOptions

*interface* · `packages/levels/src/material-look.ts:136`

```ts
interface MaterialLooksOptions
```

- `textureUrl?: (ref: string) => Promise<string> | string` — the URL a map reference is read from (a file of the level's folder, a URL, a `ferret://` file); default: absolute URLs as they are
- `warn?: (message: string) => void` — a problem to report (a map that could not be read, an ambiguous address)
- `glbIndex?: () => Promise<GlbIndex | null>` — the names of the scene glb (for the type fallback by glTF mesh name); read only when a look or a listing needs it

### MaterialOptions

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

```ts
interface MaterialOptions
```

- `variant?: string`
- `name?: string`
- `scene?: BABYLON.Scene`

### MaterialOverride

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

```ts
interface MaterialOverride
```

A library material standing in for a material of the model.

- `library: string`
- `variant?: string`

### MaterialScaleDef

*interface* · `packages/levels/src/material-scale.ts:18`

```ts
interface MaterialScaleDef
```

Repair of baked materials that came out wrong from the Unreal export.
`match` is a regular expression over the glTF material name; then
 - `flat: [r, g, b]` (0..255, sRGB) replaces the albedo picture by one colour (the picture's average over its painted texels, kept in the build config).
   The exporter bakes some materials over the lightmap UVs, so the picture is an atlas of islands on a black background while the mesh reads it through
   its first UV set: part of the surface lands on black. The surface turns matte (the bake's metal/roughness picture is the same wrong atlas); the normal map stays;
 - `flatLinear: [r, g, b]` (0..1, LINEAR, as a material parameter of the original gives it) does the same with the colour as the shader takes it: `flat` divides
   its sRGB numbers by 255 and hands them to the shader as they are, so it draws lighter than the picture it was read from (kept as it is for the levels built on it);
 - `albedo` is a LINEAR multiplier of the albedo (the light the surface returns): 2 makes it twice as bright;
 - `noVertexColors: true` stops the meshes of the material from tinting it with their vertex colours. Unreal's painted vertex colours are masks the
   material blends with (moss, dirt), already baked into the picture, but glTF viewers multiply the albedo by them: violet and cyan blotches on the walls.
   (An InstancedMesh draws with its source mesh's flag, so the source is the one switched.)
It covers the materials that exist now and every one a streamed cell adds later (they are handled once their picture or mesh is set, at most 300 frames later).

- `match: string`
- `flat?: [number, number, number]`
- `flatLinear?: [number, number, number]`
- `albedo?: number`
- `noVertexColors?: boolean`

### ModelCodeGame

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

```ts
interface ModelCodeGame
```

the part of the game language's binding the code gives its functions to (`installGame`)

- `provide(functions: Record<string, (...args: any[]) => unknown>, declarations?: Array<{ name: string; kind: ModelFunctionKind; args?: ModelValueType[] | null; returns?: ModelValueType | null }>): () => void`

### ModelCodeOptions

*interface* · `packages/levels/src/fmdl-code.ts:53`

```ts
interface ModelCodeOptions
```

- `world?: World` — the world: its physics host runs the `step` hooks, and it gets the commands `model.functions` and `model.call`
- `origin?: (pkg: string, manifest: PackageManifest) => boolean` — does this package come from where the game does (shipped with it, its own site)? Then its code is the game's
- `trusted?: () => Iterable<string> | undefined` — key ids whose signatures are trusted; without them any valid signature is enough
- `sharedEngine?: () => Iterable<string>` — the parent ships its engine inside its bundle (`shareEngine`): the names of the packages it holds
- `importModule?: (bytes: Uint8Array, path: string) => Promise<ModuleExports>` — import a module from its checked bytes (default: a blob URL and `import()`)

### ModelDescribed

*interface* · `packages/levels/src/fmdl-catalogue.ts:21`

```ts
interface ModelDescribed
```

- `id: string`
- `abstract: boolean`
- `lineage: string[]`
- `description: ModelDescription`
- `markdown: string`

### ModelFunctionInfo

*interface* · `packages/levels/src/fmdl-code.ts:71`

```ts
interface ModelFunctionInfo
```

- `name: string`
- `kind: ModelFunctionKind`
- `params: NonNullable<ModelFunction['params']>`
- `returns?: ModelValueType`
- `description: string`
- `model: string`

### ModelHandle

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

```ts
interface ModelHandle
```

A model on its way. `node` is the placeholder until the model is in, then the model's root.

- `readonly ref: string`
- `readonly state: ModelState`
- `readonly node: BABYLON.TransformNode | null`
- `readonly ready: Promise<{ root: BABYLON.TransformNode; dispose(): void } | null>` — resolves with the instance, or null when it failed or was disposed (the reason is in `error` and the `asset:failed` event)
- `readonly error?: StreamError`
- `dispose(): void`

### ModelInstance

*interface* · `packages/levels/src/fmdl-code.ts:27`

```ts
interface ModelInstance
```

What a function and a hook of a model's code get first: the instance it works on.

- `readonly name: string` — the name of the actor on the stage
- `readonly model: string` — the id of its model, and of the chain it comes from (the root ancestor first)
- `readonly lineage: string[]`
- `readonly data: ModelJson` — the merged `model.json`: the model's own data is in its `physics` and in its `x-` fields
- `readonly actor: Actor`
- `readonly root: Actor['root']`
- `readonly rig: PartRig`
- `readonly stage: ModelStage`
- `readonly world: World | undefined`
- `readonly time: number` — the stage's time, seconds of fixed steps
- `readonly state: Record<string, any>` — what this instance keeps between calls and steps
- `call(fn: string, ...args: unknown[]): unknown` — a function of this instance
- `other(name: string): ModelInstance | undefined` — another instance that has code
- `read(path: string): Promise<Uint8Array>` — a file of the model by the path `data` names it with

### ModelListing

*interface* · `packages/levels/src/fmdl-catalogue.ts:20`

```ts
interface ModelListing
```

- `id: string`
- `summary?: string`
- `kind?: string`
- `category?: string`
- `tags: string[]`
- `abstract: boolean`
- `extends?: string`
- `score: number`

### ModelOptions

*interface* · `packages/levels/src/runtime.ts:25`

```ts
interface ModelOptions extends Pick<RequireOptions, 'priority' | 'signal' | 'sha256' | 'size' | 'pkg'>
```

- `placeholder?: PlaceholderSpec` — shown at once, replaced by the model (default: a small box); `'none'` shows nothing until the model is in
- `parent?: BABYLON.TransformNode` — the node the model hangs from (an entity's node): the placeholder and then the model are its children
- `position?: [number, number, number]`
- `name?: string`

### ModelPlacement

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

```ts
interface ModelPlacement extends Omit<ModelOptions, 'pkg'>
```

- `tier?: LibraryTier`
- `yaw?: number`

### MountAssets

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

```ts
interface MountAssets extends PackageAssets
```

What the mount needs from the asset cache (an AssetCache fits).

- `load(url: string, ext?: string): Promise<void>`

### MountOptions

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

```ts
interface MountOptions
```

- `packages?: PackageSet` — the packages that are open together (default: a new set); `ferret://<id>/<path>` is looked up in it
- `loader?: Partial<PackageLoaderOptions>` — passed on to the level loader (collisions, an editor's draft manifests ...)
- `fetch?: (url: string) => Promise<FetchResult>` — replace `fetch` for urls that are not in a package

### OcclusionOptions

*interface* · `packages/levels/src/occlusion-culling.ts:10`

```ts
interface OcclusionOptions
```

Occlusion queries for the big meshes of an interior: the GPU says which large meshes are hidden behind others (a castle's walls hide
most of the level), and the CPU stops recording their draws. Babylon runs the queries on WebGL2 (`mesh.occlusionType`); a query's answer is a frame late,
so only meshes that are large and heavy enough to be worth a query get one (`minRadius` metres of bounding sphere, `minIndices` indices), and the type is
optimistic: a mesh with no answer yet is drawn. Meshes under `root` only; `unapply` gives them back. Where the engine has no occlusion queries nothing happens.

- `root: string` — the level root's name: only meshes named `<root>/...` get queries
- `minRadius?: number` — bounding sphere radius a mesh needs, metres (default 3)
- `minIndices?: number` — indices a mesh needs (default 3000)
- `algorithm?: 'conservative' | 'accurate'` — 'conservative' (default: a query is skipped for a frame after it was seen) or 'accurate' (a query every frame)

### OceanOptions

*interface* · `packages/levels/src/ocean.ts:17`

```ts
interface OceanOptions
```

- `name?: string`
- `radius?: number` — how far the grid reaches, metres (default 150 km: the horizon from 6 km up is 280 km away, but the haze has the rest)
- `rings?: number`
- `sectors?: number`
- `depthAt?: (x: number, z: number) => number` — metres of water under (x, z), negative on land; omitted: deep everywhere
- `far?: number` — the three depth boxes round the camera: edge length in metres (default 400 km, 48 km and 8 km) and texels (default 256); the far one tells the land from the sea to the horizon, so the sea is never drawn under distant land (where the depth buffer could not keep them apart)
- `coarse?: number`
- `fine?: number`
- `texels?: number`
- `rowsPerFrame?: number` — rows of a depth texture baked per frame once it has to move (default 24)
- `fog?: 'exp' | 'exp2'` — the fog: 'exp' (density per metre) or 'exp2'

### OceanWave

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

```ts
interface OceanWave
```

- `wavelength: number`
- `amplitude: number`
- `steepness?: number`
- `direction?: number`

### OpenedDependency

*interface* · `packages/levels/src/dependencies.ts:24`

```ts
interface OpenedDependency
```

A dependency that was opened: which catalog it came from and the URL of the file that was read.

- `id: string`
- `version: string`
- `range: string`
- `catalog: string`
- `url: string`
- `pkg: FerretPackage`
- `libraryVersion?: string`

### PackageAssets

*interface* · `packages/levels/src/package.ts:27`

```ts
interface PackageAssets
```

What the loader needs from `@ferret/assets` (an AssetCache fits).

- `load(url: string): Promise<void>`
- `instantiate(url: string, name?: string): Promise<{ root: BABYLON.TransformNode; dispose(): void }>`
- `release(url: string): void`

### PackageCommandHooks

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

```ts
interface PackageCommandHooks
```

- `resolve?: (url: string) => PackageInput | Promise<PackageInput>` — turn a url or name into something `FerretPackage.open` reads (default: the url itself)
- `opened?: (pkg: FerretPackage, url: string) => void` — told when a package was opened from `url` (so a host can write changes back to where it came from)
- `write?: (pkg: FerretPackage, name: string, bytes: Uint8Array) => Promise<void>` — write a built `.ferret` (a file next to the source, a download); without it `pkg.pack` only reports what it built
- `publish?: (files: Record<string, Uint8Array>) => Promise<void>` — put the files of `pkg.publish` where the server serves them: { path: bytes }, paths relative to the site root (a folder to upload, a CDN)
- `persist?: (pkg: FerretPackage) => Promise<{ files?: number; bytes?: number; appended?: number; dead?: number; compacted?: boolean } | void>` — keep an edited package: a folder package writes its changed files, a zip is packed again. Called by \`pkg.save\`
- `compact?: (pkg: FerretPackage) => Promise<{ before: number; after: number }>` — write a project (`.fprj`) again without the bytes its saves left behind (`compactZip`): where it came from, or a download. Called by `pkg.compact`
- `behaviours?: () => Iterable<string>` — behaviours the game registers itself (for \`pkg.validate\`)
- `trusted?: () => Iterable<string> | undefined` — key ids the reader trusts (for \`pkg.verify\` and the code check)

### PackageLoaderOptions

*interface* · `packages/levels/src/package.ts:33`

```ts
interface PackageLoaderOptions
```

- `assets: PackageAssets`
- `fetch?: (url: string) => Promise<{ ok: boolean; status: number; json(): Promise<any>; arrayBuffer(): Promise<ArrayBuffer> }>` — replace `fetch` (tests, a Platform file API)
- `collisions?: boolean` — make the level's meshes collide (default true)
- `manifest?: (def: LevelDef) => LevelManifest | undefined` — a manifest to use instead of the one in the package: the editor's draft (return undefined to load the file)
- `streamingRadiusScale?: number` — scale the streaming radii of every streamed level (a tier may ask for less)
- `forceNavBuild?: (def: LevelDef) => boolean` — build the NavMesh from `navBuild` even if navmesh.bin exists (the editor, after a rebuild)
- `placements?: PlacementResolver` — finds library models and materials by id for placement lists (`*.placements.json`; an `AssetLibrary` gives it: `placementResolver()`); lists that name only `ferret://` files need none

### Placement

*interface* · `packages/levels/src/placements.ts:46`

```ts
interface Placement
```

- `actor: string`
- `model: string` — a key of `models`
- `position: Vec3`
- `rotation?: Quat`
- `scale?: number | Vec3`
- `materials?: Record<string, MaterialOverride | LevelMaterialOverride>`
- `node?: string` — Draw this actor on its own, not as a thin instance: a node of this name (`Actor>Component`: a node `Actor` with a child `Component`, as an entity's `node` names it) that a behaviour can move (a door that swings). `Actor` holds the actor's position and rotation, `Component` is the part that is turned (identity), and the model's meshes hang under it with the actor's scale; the cell that holds the list is the `needs` of the entity. Without a `>` the single node holds position and rotation.

### PlacementBuildOptions

*interface* · `packages/levels/src/placements.ts:170`

```ts
interface PlacementBuildOptions
```

- `scene: BABYLON.Scene`
- `instantiate(url: string, name?: string): Promise<{ root: BABYLON.TransformNode; dispose(): void }>` — make an instance of a loaded model file (an asset cache's `instantiate`)
- `urls: Map<string, string>` — the file reference of each model name of the placement list (resolved before; see `PlacementSource.load`)
- `resolver?: PlacementResolver`
- `materials?: Map<string, Promise<BABYLON.Material>>` — library materials already made, by `id#variant` (shared by the cells of one level: a material is made once, the library owns it)
- `levelMaterials?: LevelMaterials` — the level's own materials: a mesh slot named like one of them takes it, and `{ material }` overrides pick one by name
- `warn?: PlacementWarnings`
- `name?: string` — the root of the new nodes is named so (default `placements`)

### PlacementFile

*interface* · `packages/levels/src/placements.ts:59`

```ts
interface PlacementFile
```

- `format: typeof PLACEMENTS_FORMAT`
- `models: Record<string, PlacementModel>`
- `actors: Placement[]`
- `levelMaterials?: LevelMaterialsRef`

### PlacementGroup

*interface* · `packages/levels/src/placements.ts:133`

```ts
interface PlacementGroup
```

- `key: string`
- `model: string`
- `mirrored?: boolean`
- `materials?: Record<string, MaterialOverride | LevelMaterialOverride>`
- `actors: Placement[]`
- `node?: string`

### PlacementInstance

*interface* · `packages/levels/src/placements.ts:161`

```ts
interface PlacementInstance
```

- `root: BABYLON.TransformNode`
- `groups: { key: string; model: string; meshes: BABYLON.Mesh[]; actors: string[] }[]` — one entry per drawn group: the meshes that carry its thin instances and the actors in their order
- `count: number` — instances drawn
- `dispose(): void`

### PlacementModel

*interface* · `packages/levels/src/placements.ts:35`

```ts
interface PlacementModel
```

A model by library item id, or by a file reference of a package.

- `library?: string`
- `ref?: string`
- `tier?: LibraryTier`

### PlacementResolver

*interface* · `packages/levels/src/placements.ts:62`

```ts
interface PlacementResolver
```

What the placement needs to find models and materials of the library by id (an `AssetLibrary` gives it: `placementResolver()`).

- `modelRef(m: PlacementModel): Promise<string> | string` — the `ferret://` file of a library model (its tier chosen)
- `material(o: MaterialOverride): Promise<BABYLON.Material>` — a library material to put on the model's meshes

### PlacementWarnings

*interface* · `packages/levels/src/placements.ts:160`

```ts
interface PlacementWarnings
```

- `(message: string): void`

### PrefetchOptions

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

```ts
interface PrefetchOptions
```

- `settleMs?: number` — wait this long after a level is ready before the first background download (the level's own first seconds come first)
- `margin?: number` — safety factor on the estimate: start early enough to finish in `eta * margin` (default 1.5)
- `assumedRate?: number` — assumed link speed in bytes/s until something has been measured (default: unknown, so hints start at once)
- `now?: () => number`
- `setTimer?: (fn: () => void, ms: number) => unknown`
- `clearTimer?: (t: unknown) => void`

### PreviewOptions

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

```ts
interface PreviewOptions
```

- `seconds?: number` — how long the fake download lasts
- `bytes?: number`
- `files?: number`
- `fail?: boolean` — end with a failure instead of readiness (to see the game's failure screen)
- `cached?: boolean` — `cached`: plan says the wait is short
- `signal?: AbortSignal`

### ProbeVolumeDef

*interface* · `packages/levels/src/probe-volume.ts:7`

```ts
interface ProbeVolumeDef
```

Baked global illumination: a regular grid of L1 spherical harmonics (the radiance arriving at each point, RGB), written by
`tools/ue-export/bake-gi`. The shader of every PBR material looks up the grid trilinearly at the surface and adds the diffuse light the
lamps, the sky and the bounces give there. It replaces the flat hemispheric ambient light (which the loader turns off when a volume exists).

- `file: string` — the baked grid, relative to the package: `probes.bin`
- `origin: [number, number, number]` — the position of the first probe, metres
- `spacing: number` — metres between probes
- `dims: [number, number, number]` — probes along x, y, z
- `gain?: number` — scale of the baked light (default 1)
- `fill?: number` — how much of the level's flat `ambient` light stays on beside the baked light, 0..1 (default 0: none). A hemispheric fill that brightens ceilings and darkens floors where the bake's bounce light is short
- `down?: number` — the share of the baked light that faces turned down (ceilings) get, 0..1 (default 1: all of it)
- `specular?: number` — the baked light mirrored by every surface, 0 and more (default 0: none; 1: as much as arrives). What Unreal's SkyLight and reflection captures give: the radiance the grid holds toward the reflection (the sky outdoors, the dim room indoors), blurred with the roughness, times the surface's F0 and the split sum's environment BRDF (Karis' fit), dimmed by the ambient occlusion as Unreal's specular occlusion does. Wet planks and stone seen at a low angle lose their saturation to it.

### ProgramBridgeLike

*interface* · `packages/levels/src/fmdl-programs.ts:134`

```ts
interface ProgramBridgeLike
```

- `lasting(name: string, sig: { args: string[]; min?: number; rest?: string; returns?: string }, fn: (ctx: any, ...args: any[]) => { done(): boolean; result?: unknown }): unknown`

### ProgramHost

*interface* · `packages/levels/src/fmdl-programs.ts:24`

```ts
interface ProgramHost
```

- `run(program: string, o: { target?: string; params: Record<string, Value> }): Program` — start a program text with its parameters on a target (the runtime's: the actuators' `cap.run`)
- `knows(name: string): boolean` — is `name` a word of the language

### ProgramUses

*interface* · `packages/levels/src/material-program.ts:16`

```ts
interface ProgramUses
```

What the shader of a program reads from the surface and the scene.

- `uv0: boolean`
- `uv1: boolean`
- `uv2: boolean`
- `vertexColor: boolean`
- `matrix: boolean`
- `local: boolean`
- `bounds: boolean`
- `near: boolean`
- `time: boolean`
- `view: boolean`
- `depth: boolean`
- `screen: boolean`
- `tangent: boolean`

### PropellerViewOptions

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

```ts
interface PropellerViewOptions
```

The picture of a spinning propeller. The shaft speed comes from the flight model (`Aeroplane.propOmega`, rad/s): a real propeller turns at 1000..1500 rpm, 3 or 4 blades
pass a point 60..100 times a second, and the screen shows 60 frames: a blade seen at its true angle strobes, and looks slow or runs backwards. So the blades are drawn
at their true angle only while a blade moves a small part of the blade spacing in a frame (taxiing, starting); as the speed rises they fade into the disc the eye sees at
speed (a faint disc, darker where the blades sweep, the tips a ring), which fades in. `propellerBlur` is that blend, pure, for the picture and for tests.

Nodes: the propeller's node (`Prop`, or `Prop_L` and `Prop_R`) has its pivot on the shaft, which is its local X axis.

- `blades?: number` — blades on the propeller (default 3)
- `radius?: number` — the disc's radius, m (default: read off the blades' bounds, else 1.6)
- `blurFrom?: number` — the blur starts when a blade moves this share of the blade spacing in one frame (default 0.25) ...
- `blurTo?: number` — ... and is complete at this share (default 0.7)

### PropulsorBindOptions

*interface* · `packages/levels/src/fmdl-propulsors.ts:10`

```ts
interface PropulsorBindOptions
```

- `field: FlowField`
- `actuator?: (name: string) => { force: V3; on: boolean } | undefined` — the state of a named actuator: its force (N) and whether it is running; undefined when the physics does not run
- `surface?: SurfaceQuery`
- `scale?: number` — the multiplier of every jet (the game's override)
- `onGroundEffect?: (actor: string, id: string, extra: V3, at: V3) => void`

### RelevanceBlock

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

```ts
interface RelevanceBlock
```

- `modes?: Record<string, { omega?: number; horizon?: number; floorOmega?: number }>`
- `hold?: number` — seconds a thing stays in a finer class before it may go to a coarser one
- `gonePx?: number` — below this many pixels a thing is not drawn at all

### RiverDef

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

```ts
interface RiverDef
```

- `points: Vec3[]` — the centre line, close points [x, y, z] in metres (y is the surface there); the spline is sampled by the exporter, a metre or so apart
- `widths: number[]` — the width at each point, metres
- `flow: number` — metres per second the surface moves downstream (the first point to the last)

### RoomReflection

*interface* · `packages/levels/src/room-reflection.ts:42`

```ts
interface RoomReflection
```

- `readonly cube?: BABYLON.RenderTargetTexture`
- `readonly drawn: Promise<void>` — settles when the room has been drawn into the cube (or the capture failed or was disposed): a game keeps its loading screen up until then, the first draw compiles shaders
- `refresh(): void` — draw the room again (after a change of light or furniture)
- `dispose(): void`

### RoomReflectionDef

*interface* · `packages/levels/src/room-reflection.ts:15`

```ts
interface RoomReflectionDef
```

What the glossy and the clear surfaces of an interior reflect: the room itself. The level is drawn once into a cube map from a point of the room (the lit
walls, the windows, the furniture, with the baked light on them) after it has loaded, and that cube becomes the scene's environment texture. Without it an
interior has no sky to reflect, and dark ceramic, glass, metal and polished floors draw as dull flat colour.

With a `box` the lookup is box-projected: a reflection ray is cut against the room's walls instead of read at infinity, so a floor shows the window
where the window is. One capture serves the whole room; a mirror or a very large room wants more than one point (not done).

- `position?: Vec3` — where the cube is drawn from, metres (the package's frame). Default: the box's centre at 1.4 m above its floor.
- `box?: { center: Vec3; size: Vec3 }` — the room: the box the reflection rays are cut against. Default: the baked probe grid's bounds.
- `resolution?: number` — side of a cube face in pixels (default 256: 6 x 256 x 256 half floats, about 3 MB with its mip levels)
- `intensity?: number` — scale of the reflected light (default 1: the picture's own exposure is taken out, see `capture`)

### RunOptions

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

```ts
interface RunOptions
```

- `enterTimeoutMs?: number`
- `log?: (event: string, detail: Record<string, unknown>) => void`

### RuntimeAssetsOptions

*interface* · `packages/levels/src/runtime.ts:47`

```ts
interface RuntimeAssetsOptions
```

- `store: AssetStore`
- `models: MountAssets` — loads and instantiates glTF (an `AssetCache`, or `mount.assets` when packages are in use)
- `mount?: PackageMount` — needed for `ferret://` references

### SamplerPlan

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

```ts
interface SamplerPlan
```

The samplers beyond the layers' own albedo images: far images, the pictures of world aligned layers, the macro variation picture (a file a layer already has as its albedo shares that layer's sampler).
`packed`: the pictures are layers of two texture arrays instead (`albedoArray`, `naoArray`: their files in order); a sampler is then "#<index>" (colour) or "@<index>" (normal and occlusion), and only the macro picture is a sampler.

- `extras: { file: string; srgb: boolean }[]`
- `sampler(file: string): string`
- `albedoArray: string[]`
- `naoArray: string[]`
- `nao(file: string): string`

### ScreenDecalSpec

*interface* · `packages/levels/src/screen-decals.ts:21`

```ts
interface ScreenDecalSpec
```

One decal of a level, in the engine's frame (metres): the box's centre, its three unit axes (x is the projection's), and half extents along them.

- `material: string` — the level material (a master carried whole, `decal: true`) the box projects
- `position: [number, number, number]`
- `axes: [[number, number, number], [number, number, number], [number, number, number]]` — the decal's local x (the projection axis), y and z in the engine's frame
- `half: [number, number, number]` — half extents along the axes, m
- `sortOrder?: number`

### SequenceDef

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

```ts
interface SequenceDef
```

- `name: string`
- `length: number`
- `loop?: boolean`
- `play?: 'begin' | 'trigger' | 'manual'`
- `trigger?: string`
- `rate?: number`
- `tracks: SequenceTrack[]`
- `events?: Array<{ t: number; name: string }>`

### SequenceTrack

*interface* · `packages/levels/src/sequence.ts:17`

```ts
interface SequenceTrack
```

- `target: string | { camera: true }`
- `position?: Key<[number, number, number]>[]`
- `positionAxes?: [boolean, boolean, boolean]` — which of x, y, z the position keys animate (default all); the others keep the node's own value (Unreal: a transform track with only some channels keyed)
- `scaleAxes?: [boolean, boolean, boolean]` — the same for scale
- `rotation?: Key<[number, number, number, number]>[]`
- `scale?: Key<[number, number, number]>[]`
- `fov?: Key<number>[]`

### SettleOptions

*interface* · `packages/levels/src/level-ready.ts:11`

```ts
interface SettleOptions
```

- `meshes: BABYLON.AbstractMesh[]` — the meshes the level draws (the thin-instance groups of the placements and the level's own)
- `materials?: LevelMaterials[]` — the level's materials: their textures are awaited
- `shadows?: BABYLON.ShadowGenerator[]` — shadow generators whose depth programs are compiled too
- `warn?: (message: string) => void`
- `timeoutMs?: number` — the longest the final readiness check polls (default 15000 ms)
- `parallel?: number` — how many programs compile at once (default 12: the driver compiles them in parallel, and a job mostly waits)

### SettleReport

*interface* · `packages/levels/src/level-ready.ts:25`

```ts
interface SettleReport
```

- `meshes: number`
- `programs: number`
- `notReady: string[]`
- `ms: number`

### ShadowRoleOptions

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

```ts
interface ShadowRoleOptions
```

- `casts?: (m: BABYLON.AbstractMesh) => boolean` — which of the meshes that take shadows also cast them; default: all of them. A game names its casters by what they are (a node's name, a parent, a material's name)
- `includeDescendants?: boolean` — casters keep their children out of the shadow generator's `includeDescendants` (default false: the mesh alone, as the group's other meshes are visited too)

### ShadowRoleResult

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

```ts
interface ShadowRoleResult
```

- `casters: number`
- `receivers: number`
- `skipped: number`

### ShipWakeOptions

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

```ts
interface ShipWakeOptions
```

The long wake of a ship on the sea, drawn. A ship's turbulent track runs for kilometres behind a destroyer and hundreds of metres behind a
submarine and is seen from any height. It is laid along the path the ship took (each row is where the ship was some seconds ago, so it bends in a turn): a narrow
white core that spreads and thins, and the two faint arms of the Kelvin wedge (half angle 19.5 degrees: 0.354 m sideways for every metre astern).
`Wake` of

- `length: number` — how far astern the track runs, m (a destroyer: 2500; a submarine: 450)
- `beam: number` — the hull's beam, m
- `speed: number` — the ship's speed, m/s: the time a row of the track is behind the ship is its distance over this
- `sternBack?: number` — where the track starts behind the ship's reference point (its stern), m
- `rows?: number` — rows along the track (default 72)
- `height?: number` — the height over the water, m (default 1.8: above the waves of a fresh sea)

### ShoreDef

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

```ts
interface ShoreDef
```

- `outline: [number, number][]`
- `width?: number` — metres of foam inside the edge (default 1.5)

### SlopeRamp

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

```ts
interface SlopeRamp
```

Unreal's WorldAlignedBlend parameters (Blend Sharpness, Blend Bias), as the material instance has them: `slopeAlpha(up, ramp)`.

- `sharpness: number`
- `bias: number`

### SnapshotOptions

*interface* · `packages/levels/src/snapshot-rendering.ts:15`

```ts
interface SnapshotOptions
```

Snapshot rendering of a level that does not change its draw list. On a WebGPU engine Babylon can record the commands of a frame once
(render bundles) and replay them: the CPU stops recording thousands of draws. A replay keeps the draw list of the frame it recorded, so the service
watches what changes it: meshes, materials, lights and particle systems added or removed, the number of active meshes, the visibility service's cell, a level
loading or unloading, and anything the game reports with `invalidate()` (a node enabled or hidden, a material swapped). When the list changes, the snapshot is
switched off, the frame is drawn as usual for `settleFrames` frames, and a new snapshot is recorded. Nodes that only MOVE (doors, gates, characters, the
camera) need nothing: in `standard` mode uniforms and world matrices are still updated every frame and only the recorded draws are replayed.

`fast` mode skips the scene's own work while replaying (no uniform updates: only for a scene that does not move at all, a still frame); `standard` is the
default. The mode, and so the whole service, does nothing on the WebGL2 engine. The regulator's knob `levels.snapshot` (CPU): level 0 is off, 1 is on (the cheaper step).

- `settleFrames?: number` — frames drawn normally after a change before a new snapshot is recorded (default 20)
- `mode?: 'standard' | 'fast'` — 'standard' (default) or 'fast'
- `auto?: boolean` — when false (default) the service is idle until `enable()`: a level that declares itself static turns it on

### SoundOptions

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

```ts
interface SoundOptions
```

- `audio: SoundSink`
- `name?: string` — the name to play it by (default the item id)
- `format?: 'wav' | 'mp3'` — the file to use; default by tier: the MP3 (smaller) on `mobile` and `low`, the WAV on `desktop`, whichever there is when only one is
- `tier?: LibraryTier`

