# @ferret/assets: API (continued)

### physicsPlan

*function* · `packages/assets/src/model-physics.ts:340`

```ts
async function physicsPlan(r: ResolvedModel, read: Read, prefix = '', outer: Mat = IDENT): Promise<PhysicsPlan>
```

The bodies and joints of a whole, the includes counted: the whole's own bodies (the ones in `physics.bodies`, or one body of everything), the included
models fused `rigid` merged into the body that holds them (their shapes and their mass), the ones fused `body` as bodies of their own joined to the
including body by a `fixed` joint at their place (the dock is where they meet). Each body holds the mass of what is in it; the sum of the bodies is the mass
of the whole. Shapes carry the matrix that places them (in drawing units: the loader and the engine apply `scale.drawn`).

### planFiles

*function* · `packages/assets/src/model-plan.ts:94`

```ts
function planFiles(plan: AssemblyPlan): { files: string[]; instances: number }
```

Every distinct (model, level) a plan draws, with the number of instances of each: what a loader has to load, and the cost of the whole.

### planLevel

*function* · `packages/assets/src/model-plan.ts:63`

```ts
function planLevel(resolved: ResolvedModel, level: number, o: { tier?: ModelTier } = {}): AssemblyPlan
```

The plan to draw `level` of a resolved model, with every included instance resolved down to its own plan. Throws for a level the model has not.

### prepareModelFolder

*function* · `packages/assets/src/model-pack.ts:50`

```ts
async function prepareModelFolder(input: Map<string, Uint8Array>, loader: ModelLoader, o: PrepareOptions = {}): Promise<PreparedModel>
```

### prewarmKtx2

*function* · `packages/assets/src/ktx2.ts:58`

```ts
function prewarmKtx2(): void
```

Start Babylon's KTX2 worker pool and transcoder now (it starts with the first KTX2 texture otherwise). Safe to call again; does nothing without Babylon or with 0 workers.

### publishedPath

*function* · `packages/assets/src/catalog.ts:373`

```ts
function publishedPath: (hash: string, ext?: string) => string
```

Where a published package file lives: content addressed, so it never changes and can be cached forever.

### qualifyModel

*function* · `packages/assets/src/model-resolve.ts:136`

```ts
function qualifyModel: (m: ModelJson, pkg: string) => ModelJson
```

### qualifyPath

*function* · `packages/assets/src/model-resolve.ts:109`

```ts
function qualifyPath: (pkg: string, path: string) => string
```

### readGlb

*function* · `packages/assets/src/model.ts:641`

```ts
function readGlb(bytes: Uint8Array): GlbInfo
```

Read the JSON chunk of a glTF 2.0 binary. Throws with the reason when the file is not one.

### readZipDirectory

*function* · `packages/assets/src/zip.ts:142`

```ts
async function readZipDirectory(src: ByteSource, limits: ZipLimits = ZIP_LIMITS): Promise<Map<string, ZipEntryInfo>>
```

### readZipEntry

*function* · `packages/assets/src/zip.ts:184`

```ts
async function readZipEntry(src: ByteSource, info: ZipEntryInfo, limits: ZipLimits = ZIP_LIMITS): Promise<Uint8Array>
```

Read one file out of a zip: slice, inflate when needed, check the length and the CRC.

### renderDescriptionMd

*function* · `packages/assets/src/model-describe.ts:118`

```ts
function renderDescriptionMd(r: ResolvedModel, authorText = ''): string
```

The markdown a reader (an agent) opens: lineage texts root first, then the fields, then the author's free part after the marker.

### resolveModel

*function* · `packages/assets/src/model-resolve.ts:262`

```ts
function resolveModel(root: ModelSource, load: ModelLoader): Promise<ResolveResult>
```

Resolve a model: find its parents through `load`, check every member of the chain, merge, check the result. `issues` is empty when the model is
good; `resolved` is returned whenever the chain could be merged, so a tool can still show it. A chain that is broken (a parent that is not found,
a cycle, a member that is not valid) returns no model.

### rubricTree

*function* · `packages/assets/src/library.ts:1052`

```ts
function rubricTree(rubrics: readonly LibraryRubric[], assets: Record<string, { rubric?: string }> = {}): RubricNode[]
```

the tree with the number of items in each node (`assets` is the catalog's section); the order is that of the list

### satisfies

*function* · `packages/assets/src/package.ts:388`

```ts
function satisfies(version: string, range: string): boolean
```

Does `version` fit `range`?

### seal

*function* · `packages/assets/src/security.ts:154`

```ts
async function seal(key: CryptoKey, path: string, plain: Uint8Array, compress: boolean): Promise<Uint8Array>
```

`flag(1) iv(12) ciphertext+tag`: flag 1 = the plaintext was deflated first. The path is authenticated, not secret.

### searchText

*function* · `packages/assets/src/model-describe.ts:154`

```ts
function searchText(id: string, d: ModelDescription): string
```

every word of a description an agent's search may look through, lower case, one string

### segmentSource

*function* · `packages/assets/src/zip.ts:25`

```ts
function segmentSource(parts: Uint8Array[]): ByteSource
```

One file kept as pieces: the bytes it was opened from and the tails appended to it since. A save then costs the size of its tail, not a copy of
the file; `slice` joins only the pieces the range touches.

### sha256

*function* · `packages/assets/src/package.ts:768`

```ts
async function sha256(data: Uint8Array): Promise<string>
```

### signCatalog

*function* · `packages/assets/src/catalog.ts:213`

```ts
async function signCatalog(catalog: Omit<Catalog, 'signature'> | Catalog, privateKey: string): Promise<Catalog>
```

### signManifest

*function* · `packages/assets/src/security.ts:77`

```ts
async function signManifest(manifest: object, privateKey: string): Promise<PackageSignature>
```

### splitAssetRef

*function* · `packages/assets/src/catalog.ts:56`

```ts
function splitAssetRef(ref: string): { id: string; version?: string }
```

`id@1.2.0` -> { id, version: '1.2.0' }; `id` -> { id, version: undefined } (the caller decides what that means: DEFAULT_REF_VERSION)

### splitAuthorText

*function* · `packages/assets/src/model-describe.ts:147`

```ts
function splitAuthorText(md: string | undefined): string
```

The free part of an existing `description.md` (after the marker), which the packer keeps.

### summarizeModel

*function* · `packages/assets/src/model.ts:846`

```ts
function summarizeModel(manifest: PackageManifest, model: ModelJson, desc?: ModelDescription): ModelSummary
```

### tierSource

*function* · `packages/assets/src/package.ts:948`

```ts
function tierSource(source: PackageSource, game: GameBlock | undefined, tier: 'desktop' | 'mobile' | 'low'): PackageSource
```

A package seen through one quality tier: the files under the tier's folder (`game.tiers.<tier>`, ending in `/`) replace
the files of the same path in the root, and the tier folders themselves disappear from the listing. A tier the game does not name is the root.

### toBase64

*function* · `packages/assets/src/security.ts:42`

```ts
function toBase64(u: Uint8Array): string
```

### totalsOf

*function* · `packages/assets/src/model-physics.ts:188`

```ts
function totalsOf(r: ResolvedModel): Totals
```

The totals of an included model, as written in its package: a stated number, or its `computed`. Throws, naming it, when `computed` is missing.

### uastcTarget

*function* · `packages/assets/src/ktx2.ts:87`

```ts
function uastcTarget(caps: Ktx2Caps, nonColour = false): Ktx2Target
```

the block format Babylon picks for UASTC data (`nonColour`: a normal / roughness map, which skips the RGBA-less fallbacks)

### unpackFiles

*function* · `packages/assets/src/package.ts:923`

```ts
async function unpackFiles(pkg: FerretPackage): Promise<{ path: string; data: Uint8Array }[]>
```

The files of a package as a plain list, the manifest first, for writing out as a folder (`ferret unpack`). An encrypted package must be unlocked.

### unqualifyModel

*function* · `packages/assets/src/model-resolve.ts:137`

```ts
function unqualifyModel: (m: ModelJson) => ModelJson
```

### unseal

*function* · `packages/assets/src/security.ts:164`

```ts
async function unseal(key: CryptoKey, path: string, sealed: Uint8Array): Promise<Uint8Array>
```

### urlSource

*function* · `packages/assets/src/zip.ts:51`

```ts
async function urlSource(url: string, fetchFn: typeof fetch = (u, i) => fetch(u, i)): Promise<ByteSource>
```

A package on a server. Uses range requests when the server has them (only the pieces asked for travel); otherwise the whole file
is downloaded once. `fetchFn` replaces `fetch` (tests, a platform file API).

### validateCatalog

*function* · `packages/assets/src/catalog.ts:145`

```ts
function validateCatalog(c: unknown): PackageIssue[]
```

The problems of a catalog, each with a JSON path and a message (like the level manifest's). Empty when it is valid.

### validateCatalogAssets

*function* · `packages/assets/src/library.ts:986`

```ts
function validateCatalogAssets(assets: unknown, packages: Record<string, unknown> | undefined, rubrics?: readonly LibraryRubric[]): PackageIssue[]
```

Problems of the catalog's `assets` section. `packages` is the catalog's own list.

### validateDescriptionJson

*function* · `packages/assets/src/model.ts:588`

```ts
function validateDescriptionJson(d: unknown): PackageIssue[]
```

The problems of a `description.json` (docs/fmdl/SPEC.md section 9).

### validateDockingBlock

*function* · `packages/assets/src/package.ts:185`

```ts
function validateDockingBlock(d: unknown, base = '/docking'): PackageIssue[]
```

The `docking` block against its schema; issue paths start at `base` (`/docking`).

### validateGameBlock

*function* · `packages/assets/src/package.ts:150`

```ts
function validateGameBlock(g: unknown, base = '/game'): PackageIssue[]
```

The game block against its schema; issue paths start at `base` (`/game`).

### validateLibraryItem

*function* · `packages/assets/src/library.ts:731`

```ts
function validateLibraryItem(item: unknown, o: ItemCheckOptions = {}): PackageIssue[]
```

The problems of an item file (a JSON path and a message each). Empty when it is usable.

### validateModelJson

*function* · `packages/assets/src/model.ts:368`

```ts
function validateModelJson(input: unknown, o: { manifest?: Pick<PackageManifest, 'id' | 'dependencies'>; /** the resolved model of the resolver: it has no parent but holds the node edits the chain gave */ resolved?: boolean } = {}): PackageIssue[]
```

The problems of a `model.json` taken by itself (docs/fmdl/SPEC.md section 3). `manifest` adds the checks that need the package: the id, and that
the parent and every included model are dependencies. Whether a name refers to something is `checkModelReferences`. A model with a parent
(`extends`) may state its collections' entries in part (a dock with a new node and no description, a motion with a new file): what each entry needs
is checked on the resolved model, which is validated with `resolved` and has no parent.

### validateModelPackage

*function* · `packages/assets/src/model.ts:730`

```ts
async function validateModelPackage(src: PackageSource, manifest: PackageManifest): Promise<PackageIssue[]>
```

Everything `check` verifies of a package of kind `model` that is not the manifest or the hashes (docs/fmdl/SPEC.md section 10): the two JSON files,
the files they name, the glTF levels (their node names and the costs written for them), the description against the structured fields, and for a
model with no parent the references and completeness (a model with a parent is completed by the resolver).

### validatePackageManifest

*function* · `packages/assets/src/package.ts:241`

```ts
function validatePackageManifest(m: unknown): PackageIssue[]
```

Check a `ferret.json` against the schema. An empty list means it is usable.

### validatePlacementList

*function* · `packages/assets/src/model.ts:335`

```ts
function validatePlacementList(list: unknown, at = ''): PackageIssue[]
```

The placements of a `{ file }` include: a JSON list of placements, checked as inline ones are.

### validateRubrics

*function* · `packages/assets/src/library.ts:1027`

```ts
function validateRubrics(rubrics: unknown): PackageIssue[]
```

Problems of the catalog's `rubrics`: a valid path, no path twice, every parent in the list, a name and a description for each.

### verifyManifestSignature

*function* · `packages/assets/src/security.ts:88`

```ts
async function verifyManifestSignature(manifest: { signature?: PackageSignature }): Promise<{ valid: boolean; keyId?: string; reason?: string }>
```

Does the signature in the manifest match its content? (Says nothing about whether the key is one to trust.)

### writeComputedPhysics

*function* · `packages/assets/src/model-physics.ts:314`

```ts
async function writeComputedPhysics(r: ResolvedModel, read: Read): Promise<ComputedPhysics | undefined>
```

The values to write under `physics.computed` for a model that asks for them (`undefined` when it states all of them itself).

### writeZip

*function* · `packages/assets/src/zip.ts:269`

```ts
async function writeZip(files: ZipFile[]): Promise<Uint8Array>
```

Write a zip. Paths use `/`; files are written in the order given.

### zipDeadShare

*function* · `packages/assets/src/zip.ts:365`

```ts
async function zipDeadShare(src: ByteSource): Promise<number>
```

The share (0..1) of a zip that no live file and no current directory uses: what `compactZip` would drop.

### zipSource

*function* · `packages/assets/src/package.ts:429`

```ts
async function zipSource(src: ByteSource, limits: ZipLimits = ZIP_LIMITS): Promise<PackageSource>
```

## Interfaces

### AssemblyPlan

*interface* · `packages/assets/src/model-plan.ts:35`

```ts
interface AssemblyPlan
```

- `id: string`
- `level: number` — the level of the model this plan draws
- `file: string` — the qualified path of the level's glTF
- `edits: PlanEdit[]`
- `materials: Record<string, { gltf: string; render?: ModelMaterial['render'] }>` — the model's materials, by name: the glTF material they belong to and the render side (`MaterialDef`)
- `docks: Record<string, { node?: string; frame?: { position?: number[]; rotation?: number[] } }>` — the docks of the model by name: the node and the frame on it
- `movingParts: Record<string, ModelMovingPart>` — the moving parts of the model by name (SPEC 5.4): hinges, sliders and rotors on nodes of the level; the loader's `PartRig` moves them
- `instances: PlanInstance[]`

### BodyPart

*interface* · `packages/assets/src/library.ts:253`

```ts
interface BodyPart
```

A part of a body split out into a node of its own, so it can be hidden alone (the head from its own first-person camera).

- `node: string`
- `triangles?: number`

### BuildCatalogInput

*interface* · `packages/assets/src/catalog.ts:359`

```ts
interface BuildCatalogInput
```

- `id: string`
- `version: string`
- `base: string`
- `engine?: string`
- `packages: PackedPackage[]`
- `levels: Record<string, CatalogLevel>`
- `assets?: Record<string, CatalogAsset>` — library items (see library.ts): the section is built in before the catalog is validated and signed
- `rubrics?: LibraryRubric[]`
- `signKey?: string`

### ByteSource

*interface* · `packages/assets/src/zip.ts:10`

```ts
interface ByteSource
```

Where bytes come from. A Blob (a File, a download), a byte array, or a URL read by HTTP range requests.

- `readonly size: number`
- `slice(start: number, end: number): Promise<Uint8Array>`

### CacheBackend

*interface* · `packages/assets/src/persist.ts:6`

```ts
interface CacheBackend
```

Byte storage keyed by string. A key is a content hash, or `u:<url>`; the cache above decides what is kept.

- `readonly name: string`
- `get(key: string): Promise<Uint8Array | null>`
- `put(key: string, bytes: Uint8Array): Promise<void>`
- `delete(key: string): Promise<void>`
- `keys(): Promise<string[]>`

### CacheEntry

*interface* · `packages/assets/src/persist.ts:117`

```ts
interface CacheEntry
```

- `size: number`
- `used: number`
- `pkg: string`
- `version?: string`
- `url?: string`

### CacheEnv

*interface* · `packages/assets/src/persist.ts:98`

```ts
interface CacheEnv
```

- `caches?: CacheStorage`
- `indexedDB?: IDBFactory`

### CacheInfo

*interface* · `packages/assets/src/persist.ts:118`

```ts
interface CacheInfo
```

- `backend: string`
- `used: number`
- `cap: number`
- `entries: number`
- `packages: Record<string, { bytes: number; files: number; pinned: boolean }>`

### CacheMenuItem

*interface* · `packages/assets/src/cache-menu.ts:6`

```ts
interface CacheMenuItem
```

- `id: string`
- `label: string`
- `value: () => string`
- `disabled?: boolean`
- `submenu: { title: string; items: { id: string; label: string; action?: () => void }[] }`

### Catalog

*interface* · `packages/assets/src/catalog.ts:116`

```ts
interface Catalog
```

- `format: number`
- `id: string`
- `version: string` — changes with every publish
- `engine?: string` — the Ferret versions this content needs (a range)
- `base: string`
- `packages: Record<string, CatalogPackage>`
- `levels: Record<string, CatalogLevel>`
- `assets?: Record<string, CatalogAsset>` — library items: where to find a texture, material, character or clip set without opening a package
- `versions?: Record<string, CatalogVersion[]>` — every version of every package (the `packages` entry is the newest); absent in a catalog made before versions: each package is then version 1.0.0
- `rubrics?: LibraryRubric[]` — the tree of the library: every item of `assets` is in one of these (`rubric`), see library.ts
- `signature?: PackageSignature`

### CatalogAsset

*interface* · `packages/assets/src/library.ts:960`

```ts
interface CatalogAsset
```

The `assets` section of a catalog: where to find an item without opening any package.

- `package: string`
- `type: LibraryItemType`
- `name: string`
- `tags?: string[]`
- `rubric?: string` — the rubric of the library tree (a path in the catalog's `rubrics`): one per item
- `preview?: string` — path of the small preview, relative to the catalog's `base`
- `bytes?: Partial<Record<LibraryTier | 'all', number>>` — bytes per tier (characters), or one `all` entry
- `skeleton?: string` — characters and clip sets: the skeleton id, so a clip set that fits a body is found without opening any package
- `compatible?: string[]` — clip sets: other skeletons whose bone names these clips bind to
- `duration?: number` — sounds: seconds, so a list can show the length without opening the package
- `exports?: string[]` — modules: what they export, so a list can show it without running the code
- `uid?: string` — the asset's uid, issued by the server at the first submission (assets made from now on have no names, only a uid, tags and a description); absent for the assets of the move, whose id is their uid
- `description?: string` — a description written for the AI that picks among candidates (ENGLISH ONLY)

### CatalogLevel

*interface* · `packages/assets/src/catalog.ts:103`

```ts
interface CatalogLevel
```

- `package: string`
- `level: string`
- `name?: string`
- `tags?: string[]`
- `data?: Record<string, unknown>` — free: handed to the game, never interpreted by the engine
- `prefetch?: string[]` — started at idle priority once this level is running
- `bundled?: boolean` — inside the app: never fetched

### CatalogPackage

*interface* · `packages/assets/src/catalog.ts:14`

```ts
interface CatalogPackage
```

- `url: string` — relative to `base`, or absolute
- `version: string`
- `size: number` — bytes of the whole file: the progress total
- `sha256?: string` — sha256 of the whole file (the publisher's check, `pkg.verify` of a downloaded copy)
- `manifest: string` — sha256 of the package's `ferret.json`: it holds the hash of every file, so this one hash vouches for all of them (packages are read by range, not whole)
- `tiers?: Record<string, string>` — another file per device tier, by tier name (`low`, `high`)
- `mirrors?: string[]` — the same file elsewhere, tried when the first copy fails its hash
- `libraryVersion?: string` — the version the library server issued for this file (1.0.0, 1.1.0 ...); `version` stays the one inside the package. Absent: 1.0.0

### CatalogPolicy

*interface* · `packages/assets/src/catalog.ts:218`

```ts
interface CatalogPolicy
```

- `trustedKeys?: Iterable<string>` — key ids the game ships. A signed catalog from another key is refused.
- `allowUnsigned?: boolean` — development builds only: accept an unsigned catalog (the UI shows a badge: `unsigned` in the result)
- `engineVersion?: string` — the engine's own version, checked against the catalog's `engine` range

### CatalogVersion

*interface* · `packages/assets/src/catalog.ts:36`

```ts
interface CatalogVersion
```

One version of a package. The server issues the number (1.0.0, then 1.1.0, 1.2.0 ...); every version stays for good, because a scene
refers to a concrete version of an asset and a new version never changes a scene. `items` are the library items the version holds (a new version may hold fewer).

- `version: string` — the version the server issued: what scenes refer to (`id@version`)
- `manifestVersion?: string` — the version in the package's own `ferret.json` (what dependency ranges compare); absent: the same as `version`
- `url: string`
- `size: number`
- `sha256?: string`
- `manifest: string`
- `tiers?: Record<string, string>`
- `items?: string[]` — the library items in this version (item ids); absent: the same as the package's items today
- `at?: string` — when the server accepted it (a local-time stamp)

### CharacterItem

*interface* · `packages/assets/src/library.ts:311`

```ts
interface CharacterItem extends ItemBase
```

- `type: 'character'`
- `kind: CharacterKind`
- `tiers: Partial<Record<LibraryTier, TierFile>>`
- `impostor?: ImpostorEntry` — the baked impostor for the far levels of `@ferret/perspective`
- `impostors?: Record<string, ImpostorEntry>` — impostors of the character in several poses (stand, sit, walk...), each baked from a clip: a game picks the one for what the figure is doing
- `vat?: VatBakeEntry` — the baked vertex animation of the figure for a GPU crowd
- `skeleton?: string` — skeleton id (a clip set is for one skeleton)
- `clips?: string[]` — clip set item ids, resolved by the skeleton's bone names
- `graph?: string`
- `movement?: string`
- `morphs?: string`
- `height?: number` — metres, measured from the bind pose
- `facing?: '+Z' | '-Z' | '+X' | '-X'` — the axis the toes point along in the model
- `bodyParts?: Record<string, BodyPart>` — body parts that sit in nodes of their own in the model file (`head`): same node name in every tier
- `sockets?: Record<string, Socket>` — named places to hold things: `grip_r`, `grip_l`, `saddle` (`attach` of the library)
- `parts?: { id: string; tint?: [number, number, number, number] }[]` — an assembled character: the ids of the parts it was made of

### ClipsItem

*interface* · `packages/assets/src/library.ts:340`

```ts
interface ClipsItem extends ItemBase
```

- `type: 'clips'`
- `skeleton: string`
- `compatible?: string[]` — other skeleton ids whose bone names make these clips bind without a retarget
- `file: string`
- `bytes: number`
- `clips: { name: string; duration: number; additive?: boolean; loop?: boolean; notifies?: { name: string; time: number }[] }[]` — per clip: its length, whether it loops, and the moments named in it (`hit-start`, `hit-end`, `parry-start`...; clips made in Ferret carry them, D4 of the fight demo)

### CodePolicy

*interface* · `packages/assets/src/package.ts:527`

```ts
interface CodePolicy
```

- `origin?: boolean` — the package comes from where the game itself does (its own site, or inside the signed OS Beroun app): its code is the game's
- `trusted?: Iterable<string>` — key ids the reader trusts; without it any valid signature is enough

### ColourLayer

*interface* · `packages/assets/src/library.ts:184`

```ts
interface ColourLayer
```

One step of the chain: `colour = mix(colour, color, pow(mask[channel], power))`.

- `color: [number, number, number]` — linear colour (a parameter of the Unreal material instance, as it gives it)
- `mask: string` — name of a picture in the item's `masks`
- `channel?: MaskChannel`
- `power?: number` — exponent of the mask before it mixes (Unreal: `Edges_Contrast`); default 1
- `uvScale?: [number, number]` — the mask is read at the first UV set times this (the tiling of the Unreal node; default 1, 1), whatever `uv.scale` of the material's own maps is
- `invert?: boolean` — Unreal's `lerp(color, chain, mask)`: the colour is painted over the chain where the mask is 0: `mix(colour, color, 1 - pow(mask, power))` (default: `lerp(chain, color, mask)`)

### ColourLayersDef

*interface* · `packages/assets/src/library.ts:198`

```ts
interface ColourLayersDef
```

- `base: [number, number, number] | 'albedo'` — the colour the chain starts from: a linear colour, or `albedo` for the albedo map times the base colour
- `layers: ColourLayer[]`

### ComputedPhysics

*interface* · `packages/assets/src/model-physics.ts:177`

```ts
interface ComputedPhysics
```

What the packer writes under `physics.computed` (SPEC 5.3), and what the resolver of an including model reads of an included one.

- `hash: string`
- `mass: number`
- `charge?: number`
- `centerOfMass?: Vec3`
- `inertia?: Vec3`
- `counted?: string[]`

### DependencyReport

*interface* · `packages/assets/src/package.ts:865`

```ts
interface DependencyReport
```

- `id: string`
- `deps: { id: string; range: string; found?: string; ok: boolean; message?: string }[]` — direct dependencies, in order, each with what was found

### DepthFadeDef

*interface* · `packages/assets/src/library.ts:143`

```ts
interface DepthFadeDef
```

- `opacity: number`
- `distance: number`

### DetailNormalDef

*interface* · `packages/assets/src/library.ts:129`

```ts
interface DetailNormalDef
```

Unreal's DetailTexturing: `normal = N + detail(uv * scale) * (intensity, intensity, 0)` on the unpacked normals, then the material normalises. `map` is a name of `masks` or a texture
reference itself (a tangent normal map); `scale` multiplies the first UV set, `intensity` is `Detail_Normal_Int` (it may be negative).

- `map: string`
- `scale: number`
- `intensity: number`

### DockingBlock

*interface* · `packages/assets/src/package.ts:51`

```ts
interface DockingBlock
```

The `docking` block of a package of kind `levels`: what makes it a level with mechanics of its own that is docked into a parent game.
A package of kind `levels` without the block holds no code, as ever; with it the package may hold `code/` (signed or same-origin, like any code).

- `entry?: { level?: string; spawn?: string }` — the level and spawn the parent's door leads to
- `exits?: string[]` — the level's own ways out: ids the parent answers with its return point
- `needs?: DockingRole[]` — the roles the level takes from the parent
- `has?: DockingRole[]` — the roles the level brings itself (they stay its own when docked)
- `provides?: { behaviours?: string[]; commands?: string[]; events?: string[] }` — what the parent may use: behaviours, commands and events of the level
- `namespace?: string` — the prefix of everything the level registers (default: the package id)
- `input?: { actions?: Record<string, unknown>; bindings?: Record<string, unknown> }` — the level's own actions and bindings, merged into the parent's input under the namespace
- `physicsLayers?: string[]` — physics layers added to the parent's
- `ui?: string` — the level's HUD fragment (a path inside the package), put over the parent's while the level is current
- `view?: Record<string, unknown>` — what the game it came from set for the view (clear colour, field of view, VR, touch controls, graphics API): for a completion layer; the dock itself puts on the clear colour (`clearColor`) while the level is current
- `workers?: string[]` — the level's own Web Worker scripts and engine kernel modules (paths inside the package, built from the game's `entry.workers` and `entry.kernels`)
- `kernels?: string[]`
- `packages?: string[]` — the engine packages the level's code imports that the parent does not hold in its own bundle: the parent loads each from its library (a package `engine-<name>` of the catalog, in the level's `dependencies`) before the level's code runs
- `tiers?: Partial<Record<'desktop' | 'mobile' | 'low', string>>` — the folders that hold the files of each quality tier (as `game.tiers`): the level's `ctx.url(path)` reads `<folder>/<path>` when the package has it, the root's file otherwise, for the parent's tier

### EngineVersions

*interface* · `packages/assets/src/package.ts:394`

```ts
interface EngineVersions
```

The versions of the engine that is running (`FERRET_VERSION` and `BABYLON_VERSION` of `@ferret/core`).

- `ferret: string`
- `babylon: string`

### FlipbookItem

*interface* · `packages/assets/src/library.ts:435`

```ts
interface FlipbookItem extends ItemBase
```

A flipbook for particles (@ferret/vfx): the frames of a puff of smoke, a flame or a burst laid out in a grid on one image, with the images that go with it.
`files.color` holds the colour (straight alpha; a flame carries its glow in it, for additive or alpha blending); `light` the two atlases (`light`: +x -x +y -y, `light2`: +z -z) of the light
from six sides that lets a lit puff take the light of the scene; `motion` the screen-space motion of each pixel to the next frame (rg), for blending frames;
`depth` the thickness along the view (r), for soft edges against the ground.

- `type: 'flipbook'`
- `cols: number` — frames across and down; the frames run left to right, top to bottom
- `rows: number`
- `frames: number` — how many of the grid's cells hold a frame (the rest are empty)
- `frameSize: number` — pixels of one frame
- `fps: number` — frames per second at which it was made to be played; the effect may scale it
- `loop?: boolean` — does the last frame lead into the first
- `files: { color: string; light?: string; light2?: string; motion?: string; depth?: string }`
- `motionScale?: number` — how far the motion image moves a pixel, in frame widths per frame, at full value

### FmdlItem

*interface* · `packages/assets/src/library.ts:376`

```ts
interface FmdlItem extends ItemBase
```

A `.fmdl` model package of the library: the package IS the model (kind `model`, its levels, parts, docks and description inside), so the item only names it. The catalog entry
is made from the package's own manifest and `description.json` (name, summary, tags), and the package's id is the item's id. It has no tiers: a game opens it with the
model tools (`ModelCatalogue`, `ModelStage`), not with `library.model()`.

- `type: 'fmdl'`
- `summary?: string`
- `kind?: string`

### FolderIO

*interface* · `packages/assets/src/package.ts:441`

```ts
interface FolderIO
```

What a folder package needs: its file names and a way to read one. (Node's fs, a server's index, a platform file API.)

- `list(): Promise<string[]> | string[]`
- `read(path: string): Promise<Uint8Array>`

### GameBlock

*interface* · `packages/assets/src/package.ts:23`

```ts
interface GameBlock
```

What `createGame` is given, as data in the manifest of a game or a project.

- `input?: { actions?: Record<string, unknown>; bindings?: Record<string, unknown> }`
- `fov?: { baseVertical?: number; minHorizontal?: number }`
- `physicsLayers?: string[]`
- `clearColor?: [number, number, number]`
- `touchControls?: boolean`
- `neverLowerQuality?: boolean` — never lower quality: the regulator off, the knobs at their richest, no saved levels (`GameOptions.neverLowerQuality`)
- `gpu?: 'webgl2' | 'webgpu'` — the graphics API the game asks for (absent: the engine's default, WebGPU with a fall back to WebGL2; scenes that existed on 2026-11-20 pin `webgl2`)
- `xr?: { enabled?: boolean }` — VR through WebXR: `{ enabled: true }` adds the VR service where the browser has WebXR (`game.xrReady` resolves to it, else to nothing)
- `tiers?: Partial<Record<'desktop' | 'mobile' | 'low', string>>` — quality variants of the levels in one package: a folder per tier, chosen by the player (`desktop`, `mobile`, `low`)

### GlbInfo

*interface* · `packages/assets/src/model.ts:634`

```ts
interface GlbInfo
```

What a level's glTF binary says about itself: the names the model's parts refer to, and its cost.

- `nodes: string[]`
- `materials: string[]`
- `triangles: number`
- `drawCalls: number`
- `bones: number`
- `images: number`
- `descendants: Record<string, string[]>` — for every named node, the named nodes below it (an unnamed node in between does not break the line): what a node edit replaces or hides with it

### GlbNode

*interface* · `packages/assets/src/model-import.ts:43`

```ts
interface GlbNode
```

- `name: string`
- `mesh: boolean`
- `material?: string`
- `min: Vec3`
- `max: Vec3`
- `origin: Vec3`
- `triangles: number`

### GraphDef

*interface* · `packages/assets/src/library.ts:156`

```ts
interface GraphDef
```

The master as expressions, evaluated per pixel (colour and roughness clamped to 0..1). `lerp(a, b, t)` = a + (b - a) * t; `clamp(x, min, max)` takes constants for the last two; `mask:r` the first
channel; `cameraDepthFade(length, offset)` = saturate((pixel depth - offset) / length) with the pixel's distance along the view axis in centimetres; a picture of the `Normal` sampler is unpacked
to -1..1 (a tangent normal, `normal` takes it as the material's own).

- `baseColor?: GraphExpr`
- `roughness?: GraphExpr`
- `metallic?: GraphExpr`
- `normal?: GraphExpr`
- `occlusion?: GraphExpr`
- `emissive?: GraphExpr`

### GrassWindDef

*interface* · `packages/assets/src/library.ts:173`

```ts
interface GrassWindDef
```

SimpleGrassWind: `influence` is its WindIntensity input (`ssWind_Intensity`), `weight` WindWeight (`Wind_Weight`), `speed` WindSpeed (default 1), `push` AdditionalWPO (`WPO`, one value for all three axes, Unreal cm). The level's own wind intensity does not scale it, as in the original.

- `influence: number`
- `weight?: number`
- `speed?: number`
- `push?: number`
- `weightMap?: { map: string; channel: 'r' | 'g' | 'b' | 'a' }` — the wind is multiplied by one channel of a picture read at the vertex's first texture coordinates (`lerp(0, SimpleGrassWind, map.channel)` of a master): `map` is a picture reference like those of `maps`

### GroundBlendDef

*interface* · `packages/assets/src/library.ts:225`

```ts
interface GroundBlendDef
```

The parameters of Unreal's `MF_Virtual_Texturing` as a material instance has them (Unreal units: 1 = 1 cm). With the height of the pixel over the ground
`h`, the object's own height `H` (its local bounds) and the up component `nz` of the vertex normal:
`weight = (1 - saturate((h + H - H * blendHigh) / fallOff)) * saturate(nz * sideContrast)`, `colour = mix(own, ground, weight)`.

- `fallOff: number` — `VT_FallOff`
- `blendHigh: number` — `VT_Blend_High`
- `sideContrast: number` — `Stretches_Side_Contrast`
- `enabled?: boolean` — the static switch `UseVT?`; default true. The weight also takes the metallic to 0, the roughness, the occlusion (to 1) and the normal of the baked ground (BlendMaterialAttributes blends them all)
- `landscape?: string` — name of the landscape whose ground colour it is (default: the landscape that has a virtual texture)

### Handle

*interface* · `packages/assets/src/store.ts:51`

```ts
interface Handle
```

- `readonly ref: string`
- `readonly bytes: Uint8Array`
- `readonly size: number`
- `blobUrl(): string`

### ImportSpec

*interface* · `packages/assets/src/model-import.ts:143`

```ts
interface ImportSpec
```

- `id: string`
- `name?: string`
- `version?: string`
- `summary: string` — what it is, for the description: both are required of a model that can be placed
- `kind: string`
- `category?: string`
- `tags?: string[]`
- `purpose?: string`
- `text?: string`
- `source?: ModelDescription['source']`
- `levels: { glb: Uint8Array; maxTier?: ModelTier }[]` — the glTF of each quality level, the best first; `maxTier` is the heaviest tier that may draw it
- `mass: number` — kg
- `materials: Record<string, string | Record<string, number>>` — the physical side of each glTF material: a name of the physics material table or numbers; `*` stands for every material not named
- `parts?: Record<string, ModelPart>` — by default one part for every node of the first level that carries a mesh
- `collision?: Record<string, ModelCollisionShape>` — by default one box of the first level's bounds
- `model?: Partial<ModelJson>` — anything else of the model: `physics.modules`, docks, motions, `scale`, `forward` ... merged over what is made here (an object is merged by key)
- `files?: Record<string, Uint8Array>` — files that ride in the package beside the model (motion programs, data), by path
- `dependencies?: Record<string, string>`
- `description?: ModelDescription` — the rest of `description.json` the author states

### ImpostorEntry

*interface* · `packages/assets/src/library.ts:259`

```ts
interface ImpostorEntry
```

A baked octahedral impostor of a model: the file is the packed atlas of `@ferret/perspective` (`atlas-file.ts`), made at build time by
`tools/perspective/bake.mjs` from the tier named in `tier`. The rest is what a game needs to use it without opening the file.

- `file: string` — path inside the package of the packed atlas (`impostor/<id>.fpia`)
- `bytes: number`
- `tier: LibraryTier` — the tier file the atlas was baked from, and its sha256: a changed model is then known to need a new bake
- `modelHash: string`
- `views: number` — views per side of the octahedral grid, pixels per view side, the directions covered
- `cell: number`
- `mode: 'sphere' | 'hemisphere'`
- `radius: number` — the bounding sphere radius the views were framed with, metres
- `bakeVersion: number` — the bake version of `@ferret/perspective` that made it
- `look: { color: [number, number, number]; fill: number }` — mean linear albedo of what the views cover, and the share of the bounding disc they fill: what the point level draws the model with
- `hide?: string[]` — nodes left out of the bake and nodes drawn in place of others (a spinning propeller and its disc), as asked of the bake
- `replace?: Record<string, string>`
- `anim?: { clip: string; frames: number; duration: number; at?: number }` — an animated impostor: the clip of the character's clip sets it was baked from, the frames of its loop side by side in the atlas, the clip's length in seconds; `at` (s) is the moment a one-frame pose is taken
- `flat?: boolean` — drawn as flat pictures blended on the billboard (people and animals: no depth march)
- `thresholds?: { mesh?: number; impostor?: number; point?: number; none?: number; tolerance: number }` — measured thresholds in pixels: the sizes below which a cheaper level is within `tolerance` of the richer one

### ItemCheckOptions

*interface* · `packages/assets/src/library.ts:722`

```ts
interface ItemCheckOptions
```

- `dependencies?: Iterable<string>` — ids of the packages this one depends on (and its own id as `own`): `ferret://` references outside them are refused
- `own?: string`
- `has?: (path: string) => boolean` — does a path exist in the package? When given, files an item names are checked

### Ktx2Caps

*interface* · `packages/assets/src/ktx2.ts:36`

```ts
interface Ktx2Caps
```

- `astc?: boolean`
- `bptc?: boolean`
- `s3tc?: boolean`
- `pvrtc?: boolean`
- `etc2?: boolean`
- `etc1?: boolean`

### Ktx2Options

*interface* · `packages/assets/src/ktx2.ts:25`

```ts
interface Ktx2Options
```

- `base?: string` — the folder of KTX2_FILES (default: `ktx2/` under `globalThis.FERRET_LIB`, else `lib/ferret/`); relative to the page
- `workers?: number` — decoder workers (default: Babylon's: half the cores, at most 4); 0 decodes on the page's own thread
- `prewarm?: boolean` — start the worker pool and load the transcoder now (at the splash) instead of with the first KTX2 texture: the textures of a level then find the workers up (default false)

### LibraryRubric

*interface* · `packages/assets/src/library.ts:1022`

```ts
interface LibraryRubric
```

a node of the tree of the library, kept once in the catalog (`rubrics`): every item is in one rubric, tags run across them

- `path: string`
- `name: string`
- `description: string`

### LibrarySource

*interface* · `packages/assets/src/library.ts:17`

```ts
interface LibrarySource
```

Where an item came from: informational, nothing reads it at run time.

- `project?: string`
- `ue?: string`
- `master?: string`
- `exported?: string`
- `params?: Record<string, unknown>`
- `generator?: { name: string; version: number; seed: number }`
- `url?: string`
- `author?: string`
- `licence?: string`

### LoadedCatalog

*interface* · `packages/assets/src/catalog.ts:246`

```ts
interface LoadedCatalog
```

- `catalog: Catalog`
- `url: string`
- `stale: boolean`
- `unsigned: boolean`
- `keyId?: string`

### LoadProgress

*interface* · `packages/assets/src/cache.ts:16`

```ts
interface LoadProgress
```

- `url: string`
- `loaded: number`
- `total: number`

### MacroVariationDef

*interface* · `packages/assets/src/library.ts:205`

```ts
interface MacroVariationDef
```

`colour *= pow(sample, power)`; the picture (a name in `masks`) is read at the world position over `scale` Unreal units (centimetres), blended from three axes.

- `mask: string`
- `scale: number` — Unreal units (1 = 1 cm) of the world one repeat of the picture covers (`MacroVar_Scale`)
- `power: number` — `Macro_Var_Power`
- `sharpness?: number`
- `blend?: { exponentX?: number; multX?: number; exponentYZ?: number; multYZ?: number }` — WorldCoordinate3Way's own blend of the three projections (the engine function's graph): `lerp(lerp(XZ, YZ, sat(|nx|^exponentYZ * multYZ)), XY, sat(|nz|^exponentX * multX))` with n the world normal, z up (Unreal). All four inputs default to the function's own 1.5, which is what the masters get when they leave them unconnected.

### MassSum

*interface* · `packages/assets/src/model-physics.ts:149`

```ts
interface MassSum
```

A body's mass properties: the sums `m`, `m*c` and the second moments about the origin, in true SI. Several add up.

- `m: number`
- `x: number`
- `y: number`
- `z: number`
- `xx: number`
- `yy: number`
- `zz: number`

