# @ferret/assets: API (continued)

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

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

### signCatalog

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

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

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

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

### tierSource

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

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

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

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

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

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

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

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

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

### validateGameBlock

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### ColourLayersDef

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

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

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

### EngineVersions

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

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

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

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

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

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

```ts
interface GlbNode
```

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

### GrassWindDef

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

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

### GroundBlendDef

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

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

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

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

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

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

### LibraryRubric

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

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

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

```ts
interface LoadedCatalog
```

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

### LoadProgress

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

```ts
interface LoadProgress
```

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

### MacroVariationDef

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

```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` — how sharply the three projections give way to each other along the surface normal: weight = |normal|^sharpness, normalised (default 1)

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

### MaterialDef

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

```ts
interface MaterialDef
```

A superset of glTF's PBR material that maps to Babylon's `PBRMaterial` one to one.

- `model?: 'pbr' | 'unlit'`
- `baseColor?: [number, number, number, number]`
- `metallic?: number`
- `roughness?: number`
- `maps?: Partial<Record<MapSlot, string>>` — `ferret://<package>/<path>` references to the maps; the package must be a dependency of the one holding the material
- `normalScale?: number`
- `uv?: { scale?: [number, number]; offset?: [number, number]; rotation?: number }`
- `worldAligned?: { size: number }` — projected by world position (triplanar), one repeat per `size` metres
- `alpha?: { mode: AlphaMode; cutoff?: number }`
- `doubleSided?: boolean`
- `specular?: number`
- `ior?: number`
- `emissive?: [number, number, number]`
- `emissiveStrength?: number`
- `masks?: Record<string, string>` — extra pictures the colour model below reads, by name (`ferret://` references; mask and grunge images are data, never sRGB)
- `colourLayers?: ColourLayersDef` — colour layers by mask channel: the albedo is a base colour (or the albedo map) painted over by colours through masks (Unreal's chain of LinearInterpolate nodes)
- `macro?: MacroVariationDef[]` — world-space macro variation: the albedo times `pow(picture, power)`, the picture projected from the three axes by world position (Unreal's WorldCoordinate3Way)
- `groundBlend?: GroundBlendDef` — the foot of the object takes the colour of the ground under it (Unreal's runtime virtual texture blend, `MF_Virtual_Texturing`)
- `vertexMasks?: VertexMasksDef` — vertex colours as masks (Unreal's VertexColor node): the albedo is never tinted by them; see `VertexMasksDef`
- `grassWind?: GrassWindDef` — wind of the leaf masters: the engine's SimpleGrassWind with its inputs as the material instance gives them (see `GrassWindDef`); played by `applyFoliageWind` when its block says `fromMaterials`

### MaterialInput

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

```ts
interface MaterialInput
```

- `color?: [number, number, number, number]`
- `roughness?: number`
- `metallic?: number`
- `doubleSided?: boolean`
- `alpha?: 'opaque' | 'mask' | 'blend'`

### MaterialItem

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

```ts
interface MaterialItem extends ItemBase, MaterialDef
```

- `type: 'material'`
- `variants?: Record<string, MaterialDef>` — values that differ per variant, over the base values

### MeshInput

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

```ts
interface MeshInput
```

- `name: string`
- `positions: Float32Array`
- `normals?: Float32Array`
- `indices: Uint32Array | Uint16Array`
- `colors?: Float32Array`
- `uvs?: Float32Array`
- `material: string`

### ModelCollision

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

```ts
interface ModelCollision
```

How a model collides when a game does not want its triangles: a box or a cylinder from the model's own base, in metres.

- `shape: 'box' | 'cylinder'`
- `size: [number, number, number]`
- `center: [number, number, number]`

### ModelCollisionShape

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

```ts
interface ModelCollisionShape
```

- `part?: string`
- `node?: string`
- `shape: 'box' | 'sphere' | 'cylinder' | 'capsule' | 'hull' | 'mesh'`
- `size?: number[]`
- `center?: Vec3`
- `material?: string`

### ModelDescription

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

```ts
interface ModelDescription
```

- `summary?: string`
- `kind?: string`
- `category?: string`
- `tags?: string[]`
- `purpose?: string`
- `size?: { height?: number; length?: number; width?: number; span?: number; mass?: number; drawScale?: number }`
- `period?: string`
- `place?: string`
- `parts?: Record<string, string | null>`
- `includes?: Record<string, string | null>`
- `motions?: Record<string, { summary: string; params?: Record<string, string> } | null>`
- `docks?: Record<string, string | null>`
- `materials?: string | Record<string, string | null>`
- `physics?: string`
- `levels?: { triangles?: number; bytes?: number; tier?: ModelTier }[]`
- `lineage?: string[]`
- `source?: { author?: string; licence?: string; url?: string; project?: string }`
- `text?: string`
- `[extension: `x-${string}`]: unknown`

### ModelDock

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

```ts
interface ModelDock
```

- `node?: string`
- `frame?: { position?: Vec3; rotation?: Quat }`
- `description: string`

### ModelInclude

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

```ts
interface ModelInclude
```

- `id: string`
- `version: string`
- `at: ModelPlacement | ModelPlacement[] | { file: string }`
- `fuse?: 'body' | 'rigid'`
- `overrides?: Record<string, unknown>`
- `optional?: boolean`
- `levels?: number[]`

### ModelInstance

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

```ts
interface ModelInstance
```

What a loaded model gives a game.

- `root: BABYLON.TransformNode` — the model's top node(s): move this to place the model
- `meshes: BABYLON.AbstractMesh[]`
- `skeletons: BABYLON.Skeleton[]`
- `animations: Record<string, BABYLON.AnimationGroup>` — animation groups by name (stopped: a graph or a viewer plays them)
- `dispose(): void` — remove this instance from the scene; the cached source stays until released

### ModelItem

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

```ts
interface ModelItem extends ItemBase
```

A static mesh with its materials and textures in one glTF per tier (trees, rocks, props): placed by a game as many times as it likes (thin instances).

- `type: 'model'`
- `impostor?: ImpostorEntry` — the baked impostor for the far levels of `@ferret/perspective`
- `tiers: Partial<Record<LibraryTier, TierFile>>`
- `bounds: { min: [number, number, number]; max: [number, number, number] }` — bounding box in metres of the model at its origin
- `materials?: { name: string; alpha?: AlphaMode; doubleSided?: boolean }[]` — the materials in the file and how they draw (`mask` for leaves)
- `collision?: ModelCollision`
- `up?: '+Y'` — the axis that is up in the file (always `+Y`; written so a reader need not guess)
- `data?: Record<string, string>` — files that belong to the model and ride in its package, by what they are: the airship's `physics` contract and the `spec` it was built from (a package path each)

### ModelJson

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

```ts
interface ModelJson
```

- `fmdl: 1`
- `id: string`
- `abstract?: boolean`
- `extends?: { id: string; version: string }`
- `up?: '+Y'`
- `forward?: '+X' | '-X' | '+Z' | '-Z'`
- `scale?: { drawn?: number }`
- `levels?: ModelLevel[]`
- `levelEdits?: Record<string, Partial<ModelLevel> | null>`
- `nodeEdits?: NodeEdit[]`
- `impostors?: Record<string, Record<string, unknown> | null>`
- `parts?: Record<string, ModelPart | null>`
- `materials?: Record<string, ModelMaterial | null>`
- `physics?: ModelPhysics`
- `movingParts?: Record<string, ModelMovingPart | null>`
- `docks?: Record<string, ModelDock | null>`
- `includes?: Record<string, ModelInclude | null>`
- `clips?: Record<string, string | null>`
- `motions?: Record<string, ModelMotion | null>`
- `requires?: { forms?: string[]; capabilities?: string[] }`
- `final?: string[]`
- `required?: string[]`
- `[extension: `x-${string}`]: unknown`

### ModelLevel

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

```ts
interface ModelLevel
```

One quality level of a model, index 0 the richest. The cost fields are written by the packer.

- `file: string`
- `bytes?: number`
- `triangles?: number`
- `texCap?: number`
- `bones?: number`
- `drawCalls?: number`
- `load?: 'cpu' | 'gpu' | 'both'`
- `maxTier?: ModelTier`
- `thresholds?: { px: number; tolerance: number; /** what the measurement was made of (`levelKey`): a changed level or include makes it stale */ of?: string }` — the size in pixels below which the next level is within `tolerance` of this one (measured, never typed)

### ModelMaterial

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

```ts
interface ModelMaterial
```

- `gltf?: string`
- `render?: Record<string, unknown>`
- `physical?: string | Record<string, number>`
- `response?: ModelResponse`

### ModelMotion

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

```ts
interface ModelMotion
```

- `file: string`
- `description: string`
- `duration?: number`
- `params?: Record<string, { type: 'number' | 'boolean' | 'string' | 'vector'; default?: unknown; unit?: string; description: string }>`
- `requires?: { forms?: string[] }`

### ModelMovingPart

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

```ts
interface ModelMovingPart
```

- `node?: string`
- `kind: 'hinge' | 'slider' | 'rotor'`
- `axis?: Vec3`
- `pivot?: Vec3`
- `limits?: [number, number]`
- `rest?: number`
- `unit?: 'rad' | 'm'`
- `link?: { to: string; ratio: number; offset?: number }`
- `description?: string`

### ModelPart

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

```ts
interface ModelPart
```

- `node?: string`
- `role?: string`
- `description?: string`
- `material?: string`
- `optional?: boolean`

### ModelPhysics

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

```ts
interface ModelPhysics
```

- `mass?: number | 'computed'`
- `centerOfMass?: Vec3`
- `inertia?: Vec3`
- `charge?: number | 'computed'` — the charge of the whole in coulombs, or "computed": the sum of the included models' charges
- `bindingEnergy?: number` — the energy that holds the whole together, in joules: its mass is the sum less this over c^2 (a nucleus's mass defect)
- `computed?: { hash: string; mass: number; charge?: number; centerOfMass?: Vec3; inertia?: Vec3; counted?: string[] }`
- `collision?: Record<string, ModelCollisionShape | null>`
- `bodies?: Record<string, { parts: string[]; kind?: 'static' | 'dynamic' | 'kinematic' } | null>`
- `joints?: Record<string, { between: [string, string]; kind: 'fixed' | 'hinge' | 'ball' | 'slider'; anchor?: Vec3; axis?: Vec3; limits?: [number, number]; breakForce?: number; breakTorque?: number } | null>`
- `modules?: Record<string, Record<string, unknown> | null>`
- `propulsors?: Record<string, ModelPropulsor | null>` — the propulsors that throw a medium: the jets of the model; absent: the model makes no wash

### ModelPlacement

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

```ts
interface ModelPlacement
```

- `name?: string`
- `dock?: string`
- `to?: string`
- `node?: string`
- `position?: Vec3`
- `rotation?: Quat`
- `scale?: number | Vec3`
- `overrides?: Record<string, unknown>`

### ModelPropulsor

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

```ts
interface ModelPropulsor
```

A propulsor of a model: a fan, a rotor, a propeller, a nozzle or an exhaust that throws a medium. The engine makes its jet and, where it
meets the ground, the water or a body, the wall jet from this and the thrust. Positions and axes are in the frame the model is drawn in; the jet runs along `axis`
(the direction the medium is thrown, so the thrust on the body is the other way).

- `kind: typeof PROPULSOR_KINDS[number]`
- `node?: string` — the node the propulsor rides on (a gimbal turns the jet with it); the model's root when missing
- `position: Vec3`
- `axis: Vec3`
- `diameter?: number` — the disc (rotor, propeller) or the exit (fan, nozzle, exhaust) diameter, m; the exit area of a duct that is not round instead
- `exitArea?: number`
- `medium?: 'air' | 'water'`
- `actuator?: string` — the physics actuator, or the moving part whose running state gives the thrust: the force the actuator exerts on the body, N
- `hoverShare?: number` — its share of the weight in hover (the fallback when the model's physics is not running); default 1 over the number of propulsors
- `temperature?: number` — the temperature excess at the exit, K (a hot exhaust)
- `wash?: false | number` — `false`: this propulsor makes no wash; a number scales its jet

### ModelSource

*interface* · `packages/assets/src/model-resolve.ts:23`

```ts
interface ModelSource
```

A model package read far enough to resolve it: its manifest, `model.json`, `description.json`, and the files (levels, node sources) by path.

- `manifest: PackageManifest`
- `model: ModelJson`
- `description?: ModelDescription`
- `source: PackageSource`

### ModelSummary

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

```ts
interface ModelSummary
```

What `ferret fmdl info` shows: the model in a few lines, from the files, without resolving the parent.

- `id: string`
- `name: string`
- `version: string`
- `abstract: boolean`
- `extends?: string`
- `levels: { file: string; triangles?: number; bytes?: number }[]`
- `impostors: string[]`
- `parts: string[]`
- `movingParts: string[]`
- `docks: string[]`
- `includes: string[]`
- `motions: string[]`
- `clips: string[]`
- `mass?: number | 'computed'`
- `materials: string[]`
- `dependencies: Record<string, string>`
- `summary?: string`
- `kind?: string`
- `signed: boolean`
- `encrypted: boolean`

