# @ferret/levels: API (continued)

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

### LookScope

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

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

### LookTable

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

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

uid → glTF material name → look

### MaterialMapSlot

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

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

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

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

### DEFAULT_LIBRARY_URL

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

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

### HEIGHT_TRANSITION

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

```ts
const HEIGHT_TRANSITION: 0.2
```

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

### LOOK_SCOPES

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

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

### LUT_SIZE

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

```ts
const LUT_SIZE: 24
```

### MACRO_DEFAULT_SHARPNESS

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

```ts
const MACRO_DEFAULT_SHARPNESS: 1
```

Exponent of the world-normal weights that blend the three projections of a macro picture. WorldCoordinate3Way leaves its `Blend Exponent` inputs unconnected in the
exported graphs, so the engine function's own default decides in Unreal: that function is not part of the export. 1 (weight = |n|, normalised) until its text is exported.

### MANIFEST_VERSION

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

```ts
const MANIFEST_VERSION: 1
```

### MATERIAL_MAP_SLOTS

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

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

### MAX_LANDSCAPE_LAYERS

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

```ts
const MAX_LANDSCAPE_LAYERS: 8
```

### MAX_LANDSCAPE_SAMPLERS

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

```ts
const MAX_LANDSCAPE_SAMPLERS: 11
```

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

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

### PLACEMENTS_FORMAT

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

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

### UE_UNITS_PER_METRE

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

```ts
const UE_UNITS_PER_METRE: 100
```

