FERRETGame engine over Babylon.js
Ferret

@ferret/assets

Loading and caching of glTF, KTX2 and packed assets, .ferret packages and their security checks.

298 exports · source in packages/assets/src

Classes

AssetCache class

class AssetCache

Loads glTF/GLB models once and hands out instances. The source stays in memory (not in the scene) while anything uses it; each instance is its own copy of the nodes, skeletons and animation groups, with materials and geometry shared. A URL, a data: URL, a blob URL or a File all work. Reference counting: release the url when the level that asked for it goes.

onProgress?: (p: LoadProgress) => voidCalled with the bytes loaded so far, for a loading screen.
constructor(readonly scene: BABYLON.Scene)
get size(): number
has(url: string): boolean
refs(url: string): number
async load(url: string, ext = guessExt(url)): Promise<void>Load (or reuse) a model and take a reference to it.
async preload(urls: string[]): Promise<void>Load several models; resolves when all are in.
async instantiate(url: string, name?: string): Promise<ModelInstance>A new copy of a loaded model in the scene. The model must have been loaded (load).
release(url: string): voidDrop one reference; at zero the source and its instances are freed.
dispose(): void

packages/assets/src/cache.ts:31

AssetStore class

class AssetStore
constructor(o: StoreOptions = {})
resolve(ref: string): stringResolve a ref to an absolute URL and check the rules of section 6. Throws StreamError('origin').
require(ref: string, opts: RequireOptions = {}): Promise<Handle>
prefetch(refs: string[], opts: RequireOptions = {}): voidAsk for files nobody waits for. Failures are kept in status, not thrown.
stats(): { queued: number; loading: number; done: number; failed: number; bytes: number }What the store holds and is doing now: files by state and the bytes in them (for stream.status).
status(ref: string): StoreStatus
plan(refs: { ref: string; size?: number }[]): { bytes: number; files: number; cached: boolean }What asking for these refs would download now: files not yet held, their bytes (sizes given by the caller).
release(ref: string): void
progress(group: string): StreamProgress
onProgress(fn: (group: string, p: StreamProgress) => void): () => void
cancelGroup(group: string): voidAbort everything queued or running that belongs to a group (a travel to another level).
async byteSource(ref: string, o: { block?: number; maxBlocks?: number; signal?: AbortSignal } = {}): Promise<ByteSource>A ByteSource over a URL read through the store: blocks of block bytes (read-ahead merges neighbouring ranges), kept in memory, retried like any file. FerretPackage.open(source) then costs the bytes of the entries it reads, not the package.
get cache(): PersistentCache | undefinedThe persistent cache this store writes to, if any.
async fetchFresh(ref: string, o: { signal?: AbortSignal } = {}): Promise<Uint8Array>A mutable file (a catalog, an index): always asked of the server, never from the cache, retried like any file. Not queued, because what a travel needs next must not wait behind downloads.
keep(key: string, bytes: Uint8Array, meta: { pkg?: string; version?: string; url?: string } = {}): voidKeep verified bytes under their hash (or another key) in the persistent cache. Never fails the caller: a full or broken cache is only a missed saving.
async flushCache(): Promise<void>Resolves when every cache write started so far has finished (tests, and before the page is suspended).
cacheInfo(): Promise<CacheInfo | null>
pin(pkg: string): void
unpin(pkg: string): void
async pinPack(name: string, files: { ref: string; sha256: string; size?: number }[], o: { priority?: StreamPriority; signal?: AbortSignal } = {}): Promise<{ ok: number; missing: string[] }>A pack of files the game wants always on the device (a transition's images, videos, sounds): fetched at low priority, kept in the cache under the pack's name and pinned there, so the wait of a travel never depends on the network for them. Returns what could not be fetched; status(ref) tells later whether one is there.
async clear(pkg?: string): Promise<void>Forget downloaded content: one package, or everything.

packages/assets/src/store.ts:69

CacheStorageBackend class

class CacheStorageBackend implements CacheBackend

Cache Storage (caches): browsers and the Android WebView. A synthetic URL per key.

readonly name: "cache-storage"
constructor(private readonly cache: Cache, private readonly origin = 'https://ferret-cache.invalid/')
static async open(caches: CacheStorage, name = 'ferret-assets'): Promise<CacheStorageBackend>
async get(k: string)
async put(k: string, b: Uint8Array)
async delete(k: string)
async keys()

packages/assets/src/persist.ts:24

CatalogError class

class CatalogError extends Error
constructor(public readonly code: CatalogFailure, message: string, public readonly issues: PackageIssue[] = [])

packages/assets/src/catalog.ts:118

ChunkedBackend class

class ChunkedBackend implements CacheBackend

Splits big values into parts: Chromium refused a single Cache Storage entry above 128 MB (S0). A value of at most chunk bytes is stored as is; a bigger one as parts key~0..n and then a small record key!m. The record is written last, so a cut write leaves no half value visible (the orphan parts are removed by sweep).

constructor(private readonly inner: CacheBackend, private readonly chunk = 32 * 1048576)
get name()
async get(k: string)
async put(k: string, b: Uint8Array)
async delete(k: string)
async keys()Logical keys only.
async sweep()Remove parts whose record is missing (a write that was cut).

packages/assets/src/persist.ts:64

FerretPackage class

class FerretPackage
get source(): PackageSourcethe files as they can be read now: decrypted once the package is unlocked
get encrypted(): boolean
get dirty(): booleanthe changes made through draft() that are not packed yet
draft(): PackageDraftStart editing: from now on this package reads through a draft, so writes (draft().set(path, data)) show in everything that reads the package (a mounted level reloads with them). pack writes the result.
async appendSave(base: ByteSource): Promise<{ at: number; tail: Uint8Array; dead: number; changed: string[]; commit(): void }>Save a project (.fprj) by appending: the files changed through draft() since the last save are written after the last byte of the file base (the package as it stands on disk, the bytes it was opened from plus the tails appended since), then a new directory and end record. Write tail at offset at, flush, then call commit(); a save cut off anywhere leaves the previous content. dead is the share of the file the saves left unused, so a tool can compactZip above a half. A project holds no hashes or signature, so nothing else changes. Only a project may be saved this way; any other package is written whole by pack.
async pack(o: PackOptions = {}): Promise<{ bytes: Uint8Array; manifest: PackageManifest }>Build the .ferret bytes of the package as it is now. An encrypted package is sealed again with the password or key it was unlocked with (pass decrypt for plain files, encrypt for another key). The old signature does not survive a change: pass sign to sign the new package.
get locked(): booleanencrypted and the key not given yet: the names can be listed, the files cannot be read
static async open(input: PackageInput, o: { fetch?: typeof fetch; /** the file's name (a Blob has none; a URL string is its own): `.fex` must be a game and `.fprj` a project */ fileName?: string } & Partial<KeyInput> = {}): Promise<FerretPackage>Open a package: a .ferret file (a Blob or File, bytes, or a URL — read by range requests when the server allows), or a folder (a URL ending in /, or a PackageSource). Fails when ferret.json is missing or invalid.
async unlock(input: KeyInput): Promise<void>Give the password or key of an encrypted package. Throws WrongKeyError when it does not fit.
get id(): string
get version(): string
has(path: string): boolean
read(path: string): Promise<Uint8Array>
async readText(path: string): Promise<string>
async readJson<T = unknown>(path: string): Promise<T>
levels(): string[]Ids of the levels: those provides names, else every levels/<id>/manifest.json.
get hasCode(): booleanDoes the package hold code? (kinds assets and levels must not.)
get codeEntry(): string | undefinedThe module the code loader runs: code.entry, else a game's entry.code; undefined when the package names none.
info(): PackageInfo
async verify(o: { trusted?: Iterable<string>; checksums?: boolean } = {}): Promise<VerifyResult>Is the signature there, does it match, and is the key one the reader trusts? (default true) also reads every file and compares it with the manifest, which needs the package unlocked. Unsigned is not a failure here: says so, and what to do about it is the reader's decision.
async codeAllowed(policy: CodePolicy = {}): Promise<{ allowed: boolean; reason?: string }>May this package's code run? Packages without code always can. Otherwise the code must come from the game's own origin, or the package must carry a valid signature (from a trusted key, if the reader keeps a list). Returns the reason when it may not.
async validate(o: { checksums?: boolean; engine?: EngineVersions; engineRequired?: boolean } = {}): Promise<PackageIssue[]>Check the package: the manifest, that the files it names exist, that kinds without code hold none, and (checksums, default true when the manifest has them) that every file has the sha256 the manifest gives. References between levels and assets are checked by @ferret/levels (validatePackage), which knows the level manifest.

packages/assets/src/package.ts:432

IndexedDbBackend class

class IndexedDbBackend implements CacheBackend

IndexedDB blobs: one record per key.

readonly name: "indexeddb"
static open(idb: IDBFactory, name = 'ferret-assets'): Promise<IndexedDbBackend>
async get(k: string)
async put(k: string, b: Uint8Array)
async delete(k: string)
async keys()

packages/assets/src/persist.ts:36

LockedError class

class LockedError extends Error

Opening an encrypted package without its key, or reading a file of it.

constructor(m = 'the package is encrypted: give its password or key (unlock)')

packages/assets/src/package.ts:413

MemoryBackend class

class MemoryBackend implements CacheBackend
readonly name: "memory"
async get(k: string)
async put(k: string, b: Uint8Array)
async delete(k: string)
async keys()

packages/assets/src/persist.ts:14

PackageDraft class

class PackageDraft implements PackageSource

A package kept in memory, with changes on top of another source: what the editor works on and pack writes.

readonly kind: "memory"
constructor(readonly base: PackageSource | null = null)
get changed(): string[]the paths changed (written or deleted) since the last commit
get dirty(): boolean
commit(): voidRemember that everything now in the draft is kept somewhere (appended to the file): changed and dirty start again from nothing. The files stay readable.
list(): string[]every file path (the manifest included)
has(p: string): boolean
size(p: string): numberbytes of the file in the package (uncompressed); 0 when unknown
async read(p: string): Promise<Uint8Array>
set(path: string, data: Uint8Array | string): void
delete(path: string): void

packages/assets/src/package.ts:366

PackageSet class

class PackageSet

The packages that are open together, so ferret://<id>/<path> and dependencies resolve.

add(pkg: FerretPackage): this
remove(id: string): void
get(id: string): FerretPackage | undefined
get all(): FerretPackage[]
resolve(ref: string, from: FerretPackage, base = ''): { pkg: FerretPackage; path: string } | nullWhere a reference points: ferret://id/path in another package (which must be a declared dependency of from), or a path inside from.
deps(pkg: FerretPackage, seen = new Set<string>()): DependencyReport[]pkg.deps: every dependency of a package, found or not, and whether its version fits (and, down the tree, theirs).

packages/assets/src/package.ts:749

PersistentCache class

class PersistentCache
constructor(readonly backend: CacheBackend, private readonly o: PersistentCacheOptions = {})
async flush(): Promise<void>
async has(key: string): Promise<boolean>
async get(key: string): Promise<Uint8Array | null>
async put(key: string, bytes: Uint8Array, meta: { pkg?: string; version?: string; url?: string } = {}): Promise<void>Keep verified bytes. The blob goes in first and the index after it, so an interrupted write leaves a blob the index does not know (swept later) and never an entry without bytes. Makes room by evicting the least recently used unpinned packages once; throws QuotaError when that is not enough.
pin(pkg: string): void
unpin(pkg: string): void
async clear(pkg?: string): Promise<void>
async info(): Promise<CacheInfo>
async putPartial(key: string, bytes: Uint8Array, etag: string): Promise<void>Keep what arrived of a file the network cut, with the validator the server gave, so a later session can resume it.
async getPartial(key: string): Promise<{ bytes: Uint8Array; etag: string } | null>
async dropPartial(key: string): Promise<void>
async cleanPartials(): Promise<void>Remove old partial files and blobs that no index knows (a write cut between the blob and the index).
static async requestPersistence(storage: Pick<StorageManager, 'persist' | 'persisted'> | undefined = (globalThis as { navigator?: Navigator }).navigator?.storage): Promise<boolean>Ask the browser not to drop the cache under pressure; call it after the first level loaded.

packages/assets/src/persist.ts:133

QuotaError class

class QuotaError extends Error
constructor(public readonly needed: number)

packages/assets/src/persist.ts:119

Sha256 class

class Sha256
update(data: Uint8Array): this
hex(): stringThe digest as hex. The hasher is spent afterwards.

packages/assets/src/sha256.ts:11

StreamError class

class StreamError extends Error
constructor(public readonly ref: string, public readonly reason: StreamFailure, message: string, public readonly status?: number)

packages/assets/src/stream-error.ts:6

WrongKeyError class

class WrongKeyError extends Error
constructor(m = 'wrong password or key')

packages/assets/src/security.ts:136

ZipWriter class

class ZipWriter

A zip written to a sink as it goes, so a package bigger than memory (a streamed level of several GB) is written to a file one file at a time. Same records as writeZip (sorted by the caller, no dates, the same bytes every time); the directory goes at the end, in zip64 form when it must (offsets past 4 GB, over 65534 files). One file is held whole while it is written, so it is under 4 GB. sink is called in order and awaited.

constructor(private readonly sink: (chunk: Uint8Array) => void | Promise<void>)
get size(): numberthe bytes written so far
async add(f: ZipFile): Promise<ZipEntryInfo>
async finish(): Promise<number>write the directory and the end; returns the size of the whole file

packages/assets/src/zip.ts:301

Functions

appendToZip function

async function appendToZip(src: ByteSource, changes: { set?: ZipFile[]; remove?: string[] }): Promise<{ at: number; tail: Uint8Array; entries: Map<string, ZipEntryInfo>; dead: number }>

Change a zip by appending: the new and changed files are written after the last byte, then a new directory that lists every live file, then a new end record. Nothing before them is touched, so the cost of a save is the size of the change, not of the project, and a save cut off at any byte leaves the previous directory the last complete one (readZipDirectory finds it). Replaced and removed files stay in the file as dead bytes until compactZip. Write tail at offset at (the size of the file now), then flush. dead is the share of the file that no directory entry uses.

packages/assets/src/zip.ts:341

blobSource function

function blobSource(blob: Blob): ByteSource

packages/assets/src/zip.ts:15

buildCatalog function

async function buildCatalog(i: BuildCatalogInput): Promise<{ catalog: Catalog; files: Record<string, Uint8Array> }>

pkg.catalog + pkg.publish: the catalog, and the files to put on the server, as { path: bytes }.

packages/assets/src/catalog.ts:357

bytesSource function

function bytesSource(bytes: Uint8Array): ByteSource

packages/assets/src/zip.ts:18

canonicalJson function

function canonicalJson(v: unknown): string

JSON with the keys sorted and no whitespace: the same value always gives the same text.

packages/assets/src/model-resolve.ts:103

canonicalManifest function

function canonicalManifest(m: object): Uint8Array

The bytes that are signed: the manifest without its signature, as JSON with sorted keys.

packages/assets/src/security.ts:71

catalogAtVersion function

function catalogAtVersion(c: Catalog, pkgId: string, version: string = DEFAULT_REF_VERSION): Catalog

The catalog seen at one version of a package: the package's entry is that version's (what openCatalogPackage opens).

packages/assets/src/catalog.ts:78

catalogLoader function

function catalogLoader(store: AssetStore, catalogs: Catalog[]): ModelLoader

A loader over catalogs (the catalogs a package names, in order): the package is opened through the store's cache and its files are checked against the catalog's hashes.

packages/assets/src/model-resolve.ts:64

checkCatalog function

async function checkCatalog(raw: unknown, policy: CatalogPolicy = {}): Promise<{ catalog: Catalog; unsigned: boolean; keyId?: string }>

Validate, check the signature against the keys the game trusts, and the engine range. Throws CatalogError.

packages/assets/src/catalog.ts:210

checkComputedPhysics function

async function checkComputedPhysics(r: ResolvedModel, read: Read): Promise<{ path: string; message: string }[]>

What physics.computed of a model that asks for computed values must hold, or the issues when it is missing or stale. Used by check and written by pack.

packages/assets/src/model-physics.ts:302

checkEngine function

function checkEngine(engine: PackageManifest['engine'], running: EngineVersions, o: { required?: boolean } = {}): PackageIssue[]

Compare the engine field of a manifest with the engine that is running. The ranges are those of dependencies; Babylon is usually an exact version. Only the numbers count: a build stamp after + is ignored. A field that is absent is no problem unless required is set (a finished game needs both). Returns the issues; empty means it fits.

packages/assets/src/package.ts:291

checkFileName function

function checkFileName(name: string, kind: PackageKind): PackageIssue[]

Does the file name's extension agree with the package kind? .fex is a game, .fprj a project and .fmdl a model; other names are free.

packages/assets/src/package.ts:134

checkImpostor function

function checkImpostor(v: unknown, tiers: unknown, bad: (path: string, message: string) => void, file: (path: string, p: unknown) => void, at = '/impostor'): void

The problems of an impostor entry; the tier it names must be one the item has.

packages/assets/src/library.ts:466

checkMaterialDef function

function checkMaterialDef(m: Record<string, any>, at: string, bad: (p: string, msg: string) => void, deps?: ReadonlySet<string>, own?: string, baseMasks?: Iterable<string>)

The problems of a material definition (MaterialDef); maps must be ferret:// references (a .fmdl checks its own maps itself).

packages/assets/src/library.ts:368

checkModelFolder function

async function checkModelFolder(files: Map<string, Uint8Array>): Promise<PackageIssue[]>

The problems of a model folder that has not been packed yet (so no hashes): check on a directory.

packages/assets/src/model.ts:753

checkModelReferences function

function checkModelReferences(m: ModelJson, o: { concrete?: boolean } = {}): PackageIssue[]

The references between the names inside a model: a part's material, a collision shape's part and material, the parts of a body and the bodies of a joint, a moving part's link, the docks an include is placed at, the forms a motion needs. Run on a model that states everything itself (one with no parent), and by the resolver on the resolved model of any other (stage M2). With concrete, also what a model that can be placed must have.

packages/assets/src/model.ts:492

cleanPath function

function cleanPath(p: unknown): string | null

A path inside a package: a/b/c.ext, no .., no leading slash. Returns it normalised, or null.

packages/assets/src/package.ts:236

compactZip function

async function compactZip(src: ByteSource): Promise<Uint8Array>

A zip with only its live files, copied as they are (no recompression), in the order they were first written: drops what appends left behind.

packages/assets/src/zip.ts:370

compareVersions function

function compareVersions(a: string, b: string): number

Order of two versions by their numbers (a pre-release tag is ignored): negative when a is older.

packages/assets/src/package.ts:276

computeLevelKey function

async function computeLevelKey(model: ModelJson, i: number, sources: Sources, includeHashes: string[] = []): Promise<string>

SPEC 4.5: the key of what the thresholds of level i were measured from: the sha256 of this level's file, the next level's file, every file the node edits bring and the resolved hashes of the included instances (a level is drawn with its includes). The same bytes and the same includes give the same key.

packages/assets/src/model-resolve.ts:455

computeModelPhysics function

async function computeModelPhysics(r: ResolvedModel, read: Read): Promise<ComputedPhysics & Totals & { sum: MassSum }>

The mass, charge, centre of mass and inertia of a resolved model, from its own parts (volume x density of every part whose material states a density) and from its included instances (each one's totals, placed), less the binding energy as a mass (E / c^2). hash names what they were computed from, so a reader can tell that they are stale. Throws when something needed is missing.

packages/assets/src/model-physics.ts:271

computeResolvedHash function

async function computeResolvedHash(model: ModelJson, sources: Sources, includeHashes: string[] = []): Promise<string>

packages/assets/src/model-resolve.ts:467

configureKtx2 function

function configureKtx2(o: Ktx2Options = {}): { base: string; workers: number }

Point Babylon's KTX2 decoder at the files of ktx2/. Idempotent: the first call wins (the worker pool starts with the first KTX2 texture).

packages/assets/src/ktx2.ts:56

crc32 function

function crc32(data: Uint8Array): number

packages/assets/src/zip.ts:217

createEncryption function

async function createEncryption(input: KeyInput, iterations = DEFAULT_ITERATIONS): Promise<{ encryption: PackageEncryption; key: CryptoKey }>

Make the encryption block (and the key) for a new encrypted package.

packages/assets/src/security.ts:117

deflate function

function deflate: (b: Uint8Array<ArrayBufferLike>) => Promise<Uint8Array<ArrayBufferLike>>

Deterministic (see deflate.ts): the platform's CompressionStream gives different bytes in each engine.

packages/assets/src/zip.ts:214

describeResolved function

function describeResolved(r: ResolvedModel): ModelDescription

The whole description of a resolved model: what the chain says, with everything the model has, the includes counted by their placed instances.

packages/assets/src/model-describe.ts:94

detectBackend function

async function detectBackend(env: CacheEnv = globalThis as unknown as CacheEnv, chunk?: number): Promise<CacheBackend>

Pick the first backend that really writes, reads and deletes (a private window may offer the API and refuse the write).

packages/assets/src/persist.ts:101

downloadedContentItem function

function downloadedContentItem(store: AssetStore, o: { onChange?: () => void; close?: () => void } = {}): CacheMenuItem & { refresh(): Promise<void> }

value() is read by a menu on every draw, so it shows the last size seen; refresh() reads the cache and calls onChange.

packages/assets/src/cache-menu.ts:18

etc1sTarget function

function etc1sTarget(caps: Ktx2Caps, alpha = true): Ktx2Target

the block format Babylon picks for ETC1S data (the colour maps of --ktx2)

packages/assets/src/ktx2.ts:84

folderSource function

async function folderSource(io: FolderIO): Promise<PackageSource>

packages/assets/src/package.ts:331

formatBytes function

function formatBytes(n: number): string

packages/assets/src/cache-menu.ts:11

fromBase64 function

function fromBase64(b: string): Uint8Array

packages/assets/src/security.ts:47

generateDescription function

function generateDescription(model: ModelJson, author: ModelDescription = {}, counts: Record<string, number> = {}): ModelDescription

The description the packer writes for a model package: author (its description.json as it is) with the structured fields filled from model.json. What the model states itself (a dock's text, a motion's summary) is written exactly as it is, since check compares them; the author's words win for parts, includes, materials, physics and size. counts gives the number of places of an include when the model is resolved.

packages/assets/src/model-describe.ts:65

generateEncryptionKey function

function generateEncryptionKey(): string

packages/assets/src/security.ts:106

generateSigningKey function

async function generateSigningKey(): Promise<SigningKey>

packages/assets/src/security.ts:63

getPointer function

function getPointer(root: unknown, pointer: string): unknown

The value a JSON Pointer reaches in root, or undefined.

packages/assets/src/model.ts:477

glbBounds function

function glbBounds(bytes: Uint8Array): { min: Vec3; max: Vec3 }

the bounds of the whole glb

packages/assets/src/model-import.ts:74

glbNodes function

function glbNodes(bytes: Uint8Array): GlbNode[]

The named nodes of a glb with the world bounds of everything at and below each (from the POSITION accessors' min and max, which glTF requires).

packages/assets/src/model-import.ts:45

glbOfMeshes function

function glbOfMeshes(meshes: MeshInput[], materials: Record<string, MaterialInput> = {}, generator = '@ferret/assets'): Uint8Array

a glb of raw meshes, one node and one primitive each (positions, normals, vertex colours, uvs, 32-bit indices)

packages/assets/src/model-import.ts:94

httpFolderSource function

async function httpFolderSource(base: string, fetchFn: typeof fetch = (u, i) => fetch(u, i)): Promise<PackageSource>

A folder package on a server. The file names come from index (a list of paths) or, when the folder is served with an index file named ferret-index.json, from that; otherwise from the files of its ferret.json.

packages/assets/src/package.ts:347

includeLevel function

function includeLevel(level: number, included: { levels?: { maxTier?: ModelTier }[] }, tier: ModelTier = 'desktop'): number

The level of an included model drawn on level level of the whole: the same index, no finer than the device tier lets the included model go, and no coarser than its last. An included model is always on the level of the whole (the loader's rule, SPEC 4.1), never one of its own.

packages/assets/src/model-plan.ts:55

inflate function

function inflate: (b: Uint8Array<ArrayBufferLike>, max?: number) => Promise<Uint8Array<ArrayBufferLike>>

packages/assets/src/zip.ts:212

inRubric function

function inRubric: (rubric: string | undefined, under: string) => boolean

is the rubric rubric the rubric under or beneath it

packages/assets/src/library.ts:811

isCompressedFormat function

function isCompressedFormat(path: string): boolean

Files that are compressed already are stored, so a package is read by slices without inflating (PLAN.md 4.9).

packages/assets/src/zip.ts:227

isVersionRange function

function isVersionRange(range: string): boolean

Is range a version range (1.2.0, ^1.2.0, ~1.2.0, >=1.2.0, *)?

packages/assets/src/package.ts:274

itemPath function

function itemPath: (id: string) => string

Path of the item file of an id inside a package.

packages/assets/src/library.ts:719

joinPath function

function joinPath(base: string, ref: string): string | null

Resolve ref against the folder base (levels/yard/ + ../../assets/a.glb = assets/a.glb).

packages/assets/src/package.ts:247

keepContainerInStep function

function keepContainerInStep(container: BABYLON.AssetContainer): void

Keep a container's sources in step with the scene it was loaded for: the lights the scene has now, and every later change of what a shader depends on (an environment, fog, a material plugin such as the baked light of

packages/assets/src/cache.ts:152

keyIdOf function

async function keyIdOf(spki: Uint8Array): Promise<string>

packages/assets/src/security.ts:59

ktx2Base function

function ktx2Base(o: Ktx2Options = {}): string

where the transcoder files are for this page (absolute: Babylon's worker is a blob, which resolves nothing relative)

packages/assets/src/ktx2.ts:47

ktx2GpuBytes function

function ktx2GpuBytes(width: number, height: number, target: Ktx2Target, mips = true): number

Video memory of a texture of width x height with a full mip chain in target (4/3 of the top level, rounded up by the blocks).

packages/assets/src/ktx2.ts:101

ktx2Targets function

function ktx2Targets(engine: { getCaps(): Ktx2Caps }): { caps: Required<Ktx2Caps>; uastc: Ktx2Target; uastcNonColour: Ktx2Target; etc1s: Ktx2Target }

The formats a running engine will transcode to: for logs, tests and the memory estimate (Engine.getCaps() is read).

packages/assets/src/ktx2.ts:94

lazyLoader function

function lazyLoader(entries: { id: string; version: string; open: () => Promise<ModelSource | null> }[]): ModelLoader

A loader over packages that are known by id and version and opened on demand (a folder of .fmdl files, say). The highest version that fits is opened, once.

packages/assets/src/model-resolve.ts:45

levelIds function

function levelIds(files: string[]): string[]

packages/assets/src/package.ts:646

levelsForTier function

function levelsForTier(levels: readonly ModelLevel[], tier: ModelTier = 'desktop'): { index: number; level: ModelLevel }[]

SPEC 4.1: the levels a device of tier may load, as { index, level } in order, finest first. maxTier of a level is the finest device tier that may load it, so a device loads from the first level whose maxTier is its own tier or a coarser one (a level with none counts as desktop); the levels below that one stay, they are what it draws far away. There is always at least the coarsest level.

packages/assets/src/model.ts:26

loadCatalog function

async function loadCatalog(store: AssetStore, url: string, policy: CatalogPolicy = {}, o: { signal?: AbortSignal } = {}): Promise<LoadedCatalog>

Fetch a catalog (never from the HTTP cache) and check it. When the network fails, the last good copy kept in the persistent cache is used and marked stale; with none, the failure is thrown. A good fresh copy replaces the kept one.

packages/assets/src/catalog.ts:234

massProperties function

function massProperties(s: MassSum): { mass: number; centerOfMass: Vec3; inertia: Vec3 }

The mass, centre of mass and the diagonal of the inertia about it (axes of the model) of a sum.

packages/assets/src/model-physics.ts:157

measureModelFolder function

async function measureModelFolder(files: Map<string, Uint8Array>): Promise<{ files: Map<string, Uint8Array>; changed: string[]; issues: PackageIssue[] }>

The files of a model folder ready to pack: the cost of every level written into model.json from its glTF (bytes, triangles, draw calls, bones; what the packer measures, never typed by hand). Everything else is the author's. Returns the files and what it changed.

packages/assets/src/model.ts:729

memoryLoader function

function memoryLoader(sources: ModelSource[]): ModelLoader

A loader over model sources already in hand.

packages/assets/src/model-resolve.ts:56

meshVolume function

function meshVolume(positions: ArrayLike<number>, indices: ArrayLike<number>): number

the volume of a closed triangle mesh, m3 (the divergence theorem); for a mesh that is not closed the number is not a volume

packages/assets/src/model-import.ts:130

modelFilesFromGlb function

async function modelFilesFromGlb(spec: ImportSpec): Promise<Map<string, Uint8Array>>

The files of a model folder for the pack: see the header. Throws, naming it, when something the path has to give is missing or wrong.

packages/assets/src/model-import.ts:170

modelSourceOf function

async function modelSourceOf(source: PackageSource): Promise<ModelSource>

Read the model of a package (a folder, a zip, a draft, a catalog package). Throws with the reason when ferret.json or model.json cannot be read.

packages/assets/src/model-resolve.ts:29

modelSourceOfFiles function

function modelSourceOfFiles(files: Map<string, Uint8Array>): Promise<ModelSource>

The files of a folder (as readFolder of the command line gives them) as a model source.

packages/assets/src/model-resolve.ts:40

nodeNamesOf function

function nodeNamesOf(m: ModelJson): { at: string; node: string }[]

The node names the model states itself that every level must hold (parts, moving parts, docks, collision, nodes of node edits that are replaced).

packages/assets/src/model.ts:649

openCatalogPackage function

async function openCatalogPackage(store: AssetStore, c: Catalog, pkgId: string, o: { tier?: string; signal?: AbortSignal } = {}): Promise<CatalogPackageSource>

Open a package of the catalog. ferret.json is checked against the catalog's manifest hash, and every file read afterwards against the hash that manifest holds, so nothing the signed catalog does not vouch for is handed on. Files are looked up in the persistent cache by their hash first; a miss reads the package by range requests (only then is the network used) and keeps the file. The package's index is cached under the manifest hash, so a package seen once can be opened, and its cached files read, with the network gone.

packages/assets/src/catalog.ts:270

openEncryption function

async function openEncryption(e: PackageEncryption, input: KeyInput): Promise<CryptoKey>

The key for an existing encrypted package; throws WrongKeyError when it does not open the package's check value.

packages/assets/src/security.ts:139

packageSetLoader function

function packageSetLoader(set: PackageSet): ModelLoader

A loader over the packages that are open together (PackageSet); a package that is encrypted and locked is not found.

packages/assets/src/model-resolve.ts:60

packageUrl function

function packageUrl(c: Catalog, pkgId: string, tier?: string): string

Absolute URL of a package file for a tier (falls back to the plain one), relative to the catalog's base.

packages/assets/src/catalog.ts:253

packageVersion function

function packageVersion(c: Catalog, pkgId: string, version: string = DEFAULT_REF_VERSION): CatalogVersion | undefined

One version of a package (default 1.0.0); undefined when the catalog has none such.

packages/assets/src/catalog.ts:73

packageVersions function

function packageVersions(c: Catalog, pkgId: string): CatalogVersion[]

The versions of a package, oldest first. A catalog without a versions list (every catalog made before this) has one version, 1.0.0, whatever its package entry says: the packages that were in the library at the move are version 1.0.0.

packages/assets/src/catalog.ts:65

packFiles function

async function packFiles(files: { path: string; data: Uint8Array | string }[], o: PackOptions = {}): Promise<{ bytes: Uint8Array; manifest: PackageManifest }>

A folder's files (read from disk by the caller) packed into a package (ferret pack). The folder must hold ferret.json.

packages/assets/src/package.ts:808

packModelFolder function

async function packModelFolder(input: Map<string, Uint8Array>, loader: ModelLoader, o: PackOptions = {}): Promise<{ bytes: Uint8Array; manifest: Awaited<ReturnType<typeof packFiles>>['manifest']; prepared: PreparedModel }>

prepare and pack; throws, naming the problems, when the folder is not good

packages/assets/src/model-pack.ts:63

packPackage function

async function packPackage(source: PackageSource, o: PackOptions = {}): Promise<{ bytes: Uint8Array; manifest: PackageManifest }>

packages/assets/src/package.ts:679

packPackageTo function

async function packPackageTo(source: PackageSource, sink: (chunk: Uint8Array) => void | Promise<void>, o: Omit<PackOptions, 'encrypt' | 'decrypt' | 'iterations'> = {}): Promise<{ size: number; manifest: PackageManifest; manifestBytes: Uint8Array }>

packPackage for a package that does not fit in memory (a streamed level of several GB): the zip goes to sink one file at a time (ZipWriter), so only the biggest file is held. Every file is read twice (once for the hash the manifest holds, once to write it). Not for an encrypted package. Returns what a catalog needs: the size of the file, the manifest and its bytes.

packages/assets/src/package.ts:715

parseFerretRef function

function parseFerretRef(ref: string): { pkg: string; path: string } | null

ferret://<package>/<path> -> its parts, or null

packages/assets/src/library.ts:362

parseQualified function

function parseQualified(p: string): { pkg: string; path: string } | null

packages/assets/src/model-resolve.ts:74

physicsPlan function

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

packages/assets/src/model-physics.ts:339

planFiles function

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.

packages/assets/src/model-plan.ts:94

planLevel function

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.

packages/assets/src/model-plan.ts:63

prepareModelFolder function

async function prepareModelFolder(input: Map<string, Uint8Array>, loader: ModelLoader): Promise<PreparedModel>

packages/assets/src/model-pack.ts:28

publishedPath function

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

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

packages/assets/src/catalog.ts:354

qualifyModel function

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

packages/assets/src/model-resolve.ts:99

qualifyPath function

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

packages/assets/src/model-resolve.ts:73

readGlb function

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.

packages/assets/src/model.ts:576

readZipDirectory function

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

packages/assets/src/zip.ts:142

readZipEntry function

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.

packages/assets/src/zip.ts:184

renderDescriptionMd function

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.

packages/assets/src/model-describe.ts:106

resolveModel function

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.

packages/assets/src/model-resolve.ts:225

rubricTree function

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

packages/assets/src/library.ts:814

satisfies function

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

Does version fit range?

packages/assets/src/package.ts:278

seal function

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.

packages/assets/src/security.ts:154

searchText function

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

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

packages/assets/src/model-describe.ts:141

segmentSource function

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.

packages/assets/src/zip.ts:25

sha256 function

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

packages/assets/src/package.ts:652

signCatalog function

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

packages/assets/src/catalog.ts:195

signManifest function

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

packages/assets/src/security.ts:77

splitAssetRef function

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)

packages/assets/src/catalog.ts:56

splitAuthorText function

function splitAuthorText(md: string | undefined): string

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

packages/assets/src/model-describe.ts:134

summarizeModel function

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

packages/assets/src/model.ts:773

tierSource function

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.

packages/assets/src/package.ts:825

toBase64 function

function toBase64(u: Uint8Array): string

packages/assets/src/security.ts:42

totalsOf function

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.

packages/assets/src/model-physics.ts:188

uastcTarget function

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)

packages/assets/src/ktx2.ts:76

unpackFiles function

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.

packages/assets/src/package.ts:800

unqualifyModel function

function unqualifyModel: (m: ModelJson) => ModelJson

packages/assets/src/model-resolve.ts:100

unseal function

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

packages/assets/src/security.ts:164

urlSource function

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

packages/assets/src/zip.ts:51

validateCatalog function

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.

packages/assets/src/catalog.ts:127

validateCatalogAssets function

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.

packages/assets/src/library.ts:748

validateDescriptionJson function

function validateDescriptionJson(d: unknown): PackageIssue[]

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

packages/assets/src/model.ts:529

validateGameBlock function

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

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

packages/assets/src/package.ts:100

validateLibraryItem function

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.

packages/assets/src/library.ts:504

validateModelJson function

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.

packages/assets/src/model.ts:340

validateModelPackage function

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

packages/assets/src/model.ts:664

validatePackageManifest function

function validatePackageManifest(m: unknown): PackageIssue[]

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

packages/assets/src/package.ts:141

validatePlacementList function

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

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

packages/assets/src/model.ts:307

validateRubrics function

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.

packages/assets/src/library.ts:789

verifyManifestSignature function

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

packages/assets/src/security.ts:88

writeComputedPhysics function

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

packages/assets/src/model-physics.ts:313

writeZip function

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

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

packages/assets/src/zip.ts:269

zipDeadShare function

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.

packages/assets/src/zip.ts:362

zipSource function

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

packages/assets/src/package.ts:317

Interfaces

AssemblyPlan interface

interface AssemblyPlan
id: string
level: numberthe level of the model this plan draws
file: stringthe 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[]

packages/assets/src/model-plan.ts:35

BodyPart interface

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

packages/assets/src/library.ts:159

BuildCatalogInput interface

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

packages/assets/src/catalog.ts:340

ByteSource interface

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>

packages/assets/src/zip.ts:10

CacheBackend interface

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[]>

packages/assets/src/persist.ts:6

CacheEntry interface

interface CacheEntry
size: number
used: number
pkg: string
version?: string
url?: string

packages/assets/src/persist.ts:117

CacheEnv interface

interface CacheEnv
caches?: CacheStorage
indexedDB?: IDBFactory

packages/assets/src/persist.ts:98

CacheInfo interface

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

packages/assets/src/persist.ts:118

CacheMenuItem interface

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

packages/assets/src/cache-menu.ts:6

Catalog interface

interface Catalog
format: number
id: string
version: stringchanges with every publish
engine?: stringthe 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

packages/assets/src/catalog.ts:98

CatalogAsset interface

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?: stringthe rubric of the library tree (a path in the catalog's rubrics): one per item
preview?: stringpath 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?: stringcharacters 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?: numbersounds: 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?: stringthe 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?: stringa description written for the AI that picks among candidates (ENGLISH ONLY)

packages/assets/src/library.ts:722

CatalogLevel interface

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?: booleaninside the app: never fetched

packages/assets/src/catalog.ts:85

CatalogPackage interface

interface CatalogPackage
url: stringrelative to base, or absolute
version: string
size: numberbytes of the whole file: the progress total
sha256?: stringsha256 of the whole file (the publisher's check, pkg.verify of a downloaded copy)
manifest: stringsha256 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?: stringthe 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

packages/assets/src/catalog.ts:14

CatalogPolicy interface

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

packages/assets/src/catalog.ts:200

CatalogVersion interface

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: stringthe version the server issued: what scenes refer to (id@version)
manifestVersion?: stringthe 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?: stringwhen the server accepted it (a local-time stamp)

packages/assets/src/catalog.ts:36

CharacterItem interface

interface CharacterItem extends ItemBase
type: 'character'
kind: CharacterKind
tiers: Partial<Record<LibraryTier, TierFile>>
impostor?: ImpostorEntrythe 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?: stringskeleton 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?: numbermetres, 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

packages/assets/src/library.ts:193

ClipsItem interface

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)

packages/assets/src/library.ts:220

CodePolicy interface

interface CodePolicy
origin?: booleanthe 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

packages/assets/src/package.ts:415

ColourLayer interface

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: stringname of a picture in the item's masks
channel?: MaskChannel
power?: numberexponent of the mask before it mixes (Unreal: Edges_Contrast); default 1

packages/assets/src/library.ts:99

ColourLayersDef interface

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[]

packages/assets/src/library.ts:109

ComputedPhysics interface

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[]

packages/assets/src/model-physics.ts:177

DependencyReport interface

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

packages/assets/src/package.ts:742

EngineVersions interface

interface EngineVersions

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

ferret: string
babylon: string

packages/assets/src/package.ts:284

FlipbookItem interface

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: numberframes across and down; the frames run left to right, top to bottom
rows: number
frames: numberhow many of the grid's cells hold a frame (the rest are empty)
frameSize: numberpixels of one frame
fps: numberframes per second at which it was made to be played; the effect may scale it
loop?: booleandoes the last frame lead into the first
files: { color: string; light?: string; light2?: string; motion?: string; depth?: string }
motionScale?: numberhow far the motion image moves a pixel, in frame widths per frame, at full value

packages/assets/src/library.ts:315

FmdlItem interface

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

packages/assets/src/library.ts:256

FolderIO interface

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>

packages/assets/src/package.ts:329

GameBlock interface

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)

packages/assets/src/package.ts:23

GlbInfo interface

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

packages/assets/src/model.ts:569

GlbNode interface

interface GlbNode
name: string
mesh: boolean
material?: string
min: Vec3
max: Vec3
origin: Vec3
triangles: number

packages/assets/src/model-import.ts:42

GrassWindDef interface

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

packages/assets/src/library.ts:92

GroundBlendDef interface

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: numberVT_FallOff
blendHigh: numberVT_Blend_High
sideContrast: numberStretches_Side_Contrast
enabled?: booleanthe static switch UseVT?; default true
landscape?: stringname of the landscape whose ground colour it is (default: the landscape that has a virtual texture)

packages/assets/src/library.ts:131

Handle interface

interface Handle
readonly ref: string
readonly bytes: Uint8Array
readonly size: number
blobUrl(): string

packages/assets/src/store.ts:51

ImportSpec interface

interface ImportSpec
id: string
name?: string
version?: string
summary: stringwhat 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: numberkg
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?: ModelDescriptionthe rest of description.json the author states

packages/assets/src/model-import.ts:142

ImpostorEntry interface

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: stringpath inside the package of the packed atlas (impostor/<id>.fpia)
bytes: number
tier: LibraryTierthe tier file the atlas was baked from, and its sha256: a changed model is then known to need a new bake
modelHash: string
views: numberviews per side of the octahedral grid, pixels per view side, the directions covered
cell: number
mode: 'sphere' | 'hemisphere'
radius: numberthe bounding sphere radius the views were framed with, metres
bakeVersion: numberthe 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?: booleandrawn 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

packages/assets/src/library.ts:165

ItemCheckOptions interface

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) => booleandoes a path exist in the package? When given, files an item names are checked

packages/assets/src/library.ts:495

Ktx2Caps interface

interface Ktx2Caps
astc?: boolean
bptc?: boolean
s3tc?: boolean
pvrtc?: boolean
etc2?: boolean
etc1?: boolean

packages/assets/src/ktx2.ts:34

Ktx2Options interface

interface Ktx2Options
base?: stringthe folder of KTX2_FILES (default: ktx2/ under globalThis.FERRET_LIB, else lib/ferret/); relative to the page
workers?: numberdecoder workers (default: Babylon's: half the cores, at most 4); 0 decodes on the page's own thread

packages/assets/src/ktx2.ts:25

LibraryRubric interface

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

packages/assets/src/library.ts:784

LibrarySource interface

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

packages/assets/src/library.ts:16

LoadedCatalog interface

interface LoadedCatalog
catalog: Catalog
url: string
stale: boolean
unsigned: boolean
keyId?: string

packages/assets/src/catalog.ts:228

LoadProgress interface

interface LoadProgress
url: string
loaded: number
total: number

packages/assets/src/cache.ts:15

MacroVariationDef interface

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: numberUnreal units (1 = 1 cm) of the world one repeat of the picture covers (MacroVar_Scale)
power: numberMacro_Var_Power
sharpness?: numberhow sharply the three projections give way to each other along the surface normal: weight = |normal|^sharpness, normalised (default 1)

packages/assets/src/library.ts:116

MassSum interface

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

packages/assets/src/model-physics.ts:149

MaterialDef interface

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?: ColourLayersDefcolour 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?: GroundBlendDefthe foot of the object takes the colour of the ground under it (Unreal's runtime virtual texture blend, MF_Virtual_Texturing)
vertexMasks?: VertexMasksDefvertex colours as masks (Unreal's VertexColor node): the albedo is never tinted by them; see VertexMasksDef
grassWind?: GrassWindDefwind 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

packages/assets/src/library.ts:57

MaterialInput interface

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

packages/assets/src/model-import.ts:91

MaterialItem interface

interface MaterialItem extends ItemBase, MaterialDef
type: 'material'
variants?: Record<string, MaterialDef>values that differ per variant, over the base values

packages/assets/src/library.ts:144

MeshInput interface

interface MeshInput
name: string
positions: Float32Array
normals?: Float32Array
indices: Uint32Array | Uint16Array
colors?: Float32Array
uvs?: Float32Array
material: string

packages/assets/src/model-import.ts:90

ModelCollision interface

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]

packages/assets/src/library.ts:232

ModelCollisionShape interface

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

packages/assets/src/model.ts:76

ModelDescription interface

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

packages/assets/src/model.ts:114

ModelDock interface

interface ModelDock
node?: string
frame?: { position?: Vec3; rotation?: Quat }
description: string

packages/assets/src/model.ts:92

ModelInclude interface

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

packages/assets/src/model.ts:94

ModelInstance interface

interface ModelInstance

What a loaded model gives a game.

root: BABYLON.TransformNodethe 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(): voidremove this instance from the scene; the cached source stays until released

packages/assets/src/cache.ts:4

ModelItem interface

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?: ImpostorEntrythe 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)

packages/assets/src/library.ts:235

ModelJson interface

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

packages/assets/src/model.ts:101

ModelLevel interface

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)

packages/assets/src/model.ts:36

ModelMaterial interface

interface ModelMaterial
gltf?: string
render?: Record<string, unknown>
physical?: string | Record<string, number>
response?: ModelResponse

packages/assets/src/model.ts:50

ModelMotion interface

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[] }

packages/assets/src/model.ts:95

ModelMovingPart interface

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

packages/assets/src/model.ts:91

ModelPart interface

interface ModelPart
node?: string
role?: string
description?: string
material?: string
optional?: boolean

packages/assets/src/model.ts:47

ModelPhysics interface

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?: numberthe 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

packages/assets/src/model.ts:77

ModelPlacement interface

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

packages/assets/src/model.ts:93

ModelPropulsor interface

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?: stringthe node the propulsor rides on (a gimbal turns the jet with it); the model's root when missing
position: Vec3
axis: Vec3
diameter?: numberthe 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?: stringthe physics actuator, or the moving part whose running state gives the thrust: the force the actuator exerts on the body, N
hoverShare?: numberits share of the weight in hover (the fallback when the model's physics is not running); default 1 over the number of propulsors
temperature?: numberthe temperature excess at the exit, K (a hot exhaust)
wash?: false | numberfalse: this propulsor makes no wash; a number scales its jet

packages/assets/src/model.ts:59

ModelSource interface

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

packages/assets/src/model-resolve.ts:23

ModelSummary interface

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

packages/assets/src/model.ts:766

ModuleItem interface

interface ModuleItem extends ItemBase

A ready-made package of code: a package of kind library whose one ES module (code.entry) exports install(ctx) and the functions and classes a game calls (a sea, a sky, a shader, a generator). The code reads the engine's other packages from the shared engine (globalThis.Ferret), so it carries only its own code; AssetLibrary.module(id) runs it under the code policy and returns its exports.

type: 'module'
exports: string[]what the module exports (names), so a list can show them without running it
engine?: string[]the engine's packages the code reads from the shared engine (@ferret/terrain): the game must have them
usage?: stringone line that shows how it is used
docs?: stringa README (Markdown) in the package
sources?: string[]the source files it was built from, for the record

packages/assets/src/library.ts:295

Moments interface

interface Moments

Integrals over a solid of unit density, in the units of the geometry: volume, first moments and second moments about the origin.

v: number
x: number
y: number
z: number
xx: number
yy: number
zz: number

packages/assets/src/model-physics.ts:64

PackageEncryption interface

interface PackageEncryption
alg: 'AES-256-GCM'
kdf: 'PBKDF2-SHA256' | 'none'
salt?: stringbase64 (kdf PBKDF2)
iterations?: number
check: stringa sealed constant: opening it tells a wrong password from a damaged file (kdf none: the key's id)

packages/assets/src/security.ts:25

PackageInfo interface

interface PackageInfo
id: string
name: string
version: string
kind: PackageKind
format: number
files: number
bytes: number
levels: string[]
assets: string[]
behaviours: string[]
dependencies: Record<string, string>
hasCode: boolean
signed: boolean
encrypted: boolean
locked: boolean
entry?: PackageManifest['entry']
codeEntry?: stringthe module the code loader runs, if any (code.entry, else a game's entry.code)

packages/assets/src/package.ts:399

PackageIssue interface

interface PackageIssue
path: string
message: string

packages/assets/src/package.ts:92

PackageManifest interface

interface PackageManifest
format: number
id: stringlower case letters, digits, ., _, -
name: string
version: stringsemver major.minor.patch
kind: PackageKind
engine?: { ferret?: string; babylon?: string; /** the parts of Babylon the game loads at start, and the ones a feature may ask for later (stage P6; without them the full build is loaded) */ parts?: string[]; lazyParts?: string[]; /** a standalone game: the exact release whose engine files are inside the package, under `engine/` */ bundled?: string }the versions it was built and tested with
dependencies?: Record<string, string>other packages by id and version range (1.2.0, ^1.2.0, ~1.2.0, >=1.2.0, *)
catalogs?: string[]catalogs (catalog.json) where the player looks for the dependencies that are not open yet, in order: absolute URLs, or relative ones read from where this package itself was loaded. A dependency's own catalogs are searched for its dependencies, after these.
modules?: string[]a game only: the engine modules its code and levels use, written by the compiler (a project has none)
babylon?: string[]a game only: the Babylon parts it uses, written by the compiler
keep?: string[]a game or a project: files the compiler must keep although no literal path reaches them (globs, * within a folder, ** across)
game?: GameBlocka game or a project: what createGame gets
for?: { game: string; version: string }a package of levels made for a game: which game and versions it fits
entry?: { code?: string; /** the level to start in; a game whose code builds its own world names none (then `code` is required) */ level?: string; spawn?: string; ui?: string }a game or a project: the code module (a game: built, under code/; a project: the source), the level to start in, the spawn, the UI fragment
code?: { entry: string }a game or a library: the code module the code loader runs (one bundled ES module under code/ exporting install)
provides?: PackageProvideswhat it offers to others
files?: Record<string, string>sha256 (hex) of every file but this one
encryption?: PackageEncryptionpresent when the files are encrypted (see ./security); ferret.json itself never is
signature?: PackageSignaturea signature over the whole manifest (so over files) made by the publisher; checked by whoever decides to trust the code

packages/assets/src/package.ts:38

PackageProvides interface

interface PackageProvides

What a package offers, so that a level or a program can be resolved to the packages it needs without running their code. The lists after behaviours are names a library's code registers: physics capabilities, actuator kinds, flow sources, forms of the motion language, commands and level manifest keys.

levels?: string[]
assets?: string[]
behaviours?: { name: string; params?: Record<string, unknown> }[]
capabilities?: string[]
kinds?: string[]
flowSources?: string[]
forms?: string[]
commands?: string[]
levelKeys?: string[]

packages/assets/src/package.ts:84

PackageSignature interface

interface PackageSignature
alg: 'ES256'
key: stringthe public key, SPKI in base64
keyId: stringfirst 16 bytes of the sha256 of the public key, in hex
value: stringbase64 of the raw (r || s) signature

packages/assets/src/security.ts:15

PackageSource interface

interface PackageSource

Reads the files of a package, whether it is a zip or a folder.

readonly kind: 'zip' | 'folder' | 'memory'
list(): string[]every file path (the manifest included)
has(path: string): boolean
size(path: string): numberbytes of the file in the package (uncompressed); 0 when unknown
read(path: string): Promise<Uint8Array>

packages/assets/src/package.ts:307

PackedPackage interface

interface PackedPackage
bytes?: Uint8Arraythe package file in memory; a package too big for that (packPackageTo) leaves this out and gives file
file?: { size: number; sha256: string; manifestSha256: string }a package written to disk by packPackageTo: its size, the sha256 of the whole file and of its ferret.json; the publisher puts the file at publishedPath(sha256) itself
manifest: PackageManifest
tiers?: Record<string, Uint8Array>packed again for a device tier
ext?: stringthe extension of the published file

packages/assets/src/catalog.ts:328

PackOptions interface

interface PackOptions

Build a .ferret from a source (a folder, another package, a draft): the manifest gets the sha256 of every file, the levels and assets it provides when they are not named, and the zip is written the same way every time (sorted, no dates). Files that are compressed already are stored, so a reader slices them out without inflating.

manifest?: Partial<PackageManifest>
engine?: PackageManifest['engine']
encrypt?: KeyInputseal every file but the manifest (a password, or a 32-byte key in base64)
iterations?: numberPBKDF2 rounds for a password (default 310000; tests use less)
sign?: { privateKey: string }sign the finished manifest with this private key (base64 PKCS8, from generateSigningKey)
decrypt?: booleanpack an encrypted package's files as plain ones (without it, repacking an encrypted package needs encrypt)

packages/assets/src/package.ts:666

PersistentCacheOptions interface

interface PersistentCacheOptions
cap?: numberHard cap in bytes (defaults: 400 MB desktop, 200 MB phone, 100 MB console: the caller picks).
quota?: () => Promise<number | undefined>The browser's quota (navigator.storage.estimate().quota) when it has one; the cache stays under 80% of it.
now?: () => number
partialMaxAgeMs?: numberPartial downloads older than this are removed (24 h).

packages/assets/src/persist.ts:121

PhysicsPlan interface

interface PhysicsPlan
id: string
bodies: PlanBody[]
joints: PlanJoint[]
mass: number
charge: number

packages/assets/src/model-physics.ts:331

PlanBody interface

interface PlanBody

A rigid body of the whole: its mass properties (true SI, in the whole's drawn frame), its shapes, and the instance it comes from (none for the whole's own).

name: string
kind: 'static' | 'dynamic' | 'kinematic'
mass: number
charge: number
centerOfMass: Vec3
inertia: Vec3
shapes: PlanShape[]
instance?: string
parts: string[]

packages/assets/src/model-physics.ts:329

PlanEdit interface

interface PlanEdit
op: 'replace' | 'add' | 'hide' | 'material'
node: string
parent?: stringadd: the node of the level the new node goes under
from?: stringreplace, add: the qualified path of the glTF the node comes from, for this level
material?: stringmaterial: the name in the model's materials

packages/assets/src/model-plan.ts:10

PlanInstance interface

interface PlanInstance
name: stringthe instance's name, its address (<instance>/<part>)
include: stringthe name of the include this instance is of
id: stringthe id of the included model
placement: Omit<ModelPlacement, 'name' | 'overrides'>
fuse: 'body' | 'rigid'
level: numberthe level of the included model the instance is drawn on
plan: AssemblyPlan

packages/assets/src/model-plan.ts:21

PlanJoint interface

interface PlanJoint
name: string
between: [string, string]
kind: 'fixed' | 'hinge' | 'ball' | 'slider'
anchor?: Vec3
axis?: Vec3
limits?: number[]
breakForce?: number
breakTorque?: number

packages/assets/src/model-physics.ts:330

PlanShape interface

interface PlanShape

A collision shape in a body's frame, with its physical material.

name: string
shape: ModelCollisionShape['shape']
size?: number[]
center?: Vec3
material?: string
physical?: unknown
frame: number[]

packages/assets/src/model-physics.ts:327

PreparedModel interface

interface PreparedModel
files: Map<string, Uint8Array>the folder as it must be packed
written: string[]the files the preparation wrote (model.json, description.json, description.md), with what changed in model.json
changed: string[]
issues: PackageIssue[]

packages/assets/src/model-pack.ts:19

RequireOptions interface

interface RequireOptions
priority?: StreamPriority
signal?: AbortSignal
sha256?: stringsha256 (hex) from a signed catalog or package manifest. Without it the file is not verified (development only).
size?: numberSize in bytes when the catalog knows it: the progress total is exact from the start.
mirrors?: string[]
pkg?: stringThe package (or level) the file belongs to: the unit of eviction, pinning and clear.
version?: string
group?: stringFiles asked with the same group add up into one progress (a travel).

packages/assets/src/store.ts:36

ResolvedInclude interface

interface ResolvedInclude
id: string
version?: stringthe version of the package that was found
fuse: 'body' | 'rigid'
optional?: boolean
missing?: truean optional include whose package was not found
instances: ResolvedInstance[]

packages/assets/src/model-resolve.ts:198

ResolvedInstance interface

interface ResolvedInstance

One place of an included model in the whole: its name (<include> for a single placement, <include>.<index> in a list, or the placement's own), where it sits, and the model resolved with the overlays.

name: string
placement: Omit<ModelPlacement, 'name' | 'overrides'>
resolved: ResolvedModel

packages/assets/src/model-resolve.ts:197

ResolvedModel interface

interface ResolvedModel
fmdl: 1
id: string
abstract: boolean
lineage: string[]the ids of the chain, the root ancestor first (SPEC 8.6)
chain: { id: string; version: string }[]the packages the chain was read from, with their versions
resolvedHash: stringSPEC 8.5: what an impostor's modelHash is
model: ModelJsonthe merged model; its paths are qualified (fmdl://<package>/<path>)
description: ModelDescriptionthe merged description.json, with lineage
texts?: { id: string; summary?: string; text?: string }[]what each member of the chain says of itself, the root first (description.md shows them in this order)
includes?: Record<string, ResolvedInclude>the included models, resolved (SPEC 8.4); absent when the model includes nothing
levelKeys: string[]the key of each level (SPEC 4.5): what a measurement of the level's thresholds is made of

packages/assets/src/model-resolve.ts:175

ResolveResult interface

interface ResolveResult
resolved?: ResolvedModel
issues: PackageIssue[]
read?: (qualified: string) => Promise<Uint8Array>reads a file of any package the model was made from (the whole chain and every included model) by its qualified path (fmdl://<package>/<path>)

packages/assets/src/model-resolve.ts:208

RubricNode interface

interface RubricNode extends LibraryRubric
count: number
own: number
children: RubricNode[]

packages/assets/src/library.ts:786

SigningKey interface

interface SigningKey
publicKey: string
privateKey: string
keyId: string

packages/assets/src/security.ts:57

Socket interface

interface Socket

A place on a body where something is held: a bone and an offset from it (metres, radians as a quaternion), kept in the item so every game puts a weapon in a hand the same way.

bone: string
position?: [number, number, number]
rotation?: [number, number, number, number]
grip?: { point: [number, number, number]; axis: [number, number, number]; radius: number; spacing?: number; edge?: [number, number, number] }how the thing in this socket is held, in the frame of bone: the middle of the grip, its axis (toward the blade), its radius, the distance to the second hand (toward the pommel), and for a blade the way its edge faces (across the axis; a two-edged blade cuts along it either way)

packages/assets/src/library.ts:151

SoundFile interface

interface SoundFile

One file of a sound item: a WAV (exact, big) or an MP3 (small), the same sound.

file: string
bytes: number
bitrate?: number

packages/assets/src/library.ts:259

SoundItem interface

interface SoundItem extends ItemBase

A sound: the same recording as a WAV and/or an MP3 (a device on the low or mobile tier takes the MP3 when there is one, the others the WAV), with what a game needs to place it - how long it is, whether and where it loops, the bus it belongs on and how it falls with distance.

type: 'sound'
files: Partial<Record<'wav' | 'mp3', SoundFile>>
rate: numberframes per second of the recording
channels: number
duration: numberseconds
peak?: numberthe largest sample, 0..1 (a game can raise the quiet ones)
loop?: boolean | { start: number; end: number }the sound repeats; start and end in seconds when only a part of it does (a WAV smpl loop)
bus?: SoundBus
volume?: number0..1
spatial?: { min?: number; max?: number; model?: 'linear' | 'inverse' | 'exponential'; rolloff?: number }how it falls with distance when played at a place (metres)
marks?: { name: string; time: number }[]moments named in the sound, seconds (cue marks of the WAV: hit, step)
wave?: number[]the shape of the wave for a picture of it: lowest and highest sample of equal parts, interleaved (min0, max0, min1, max1...)

packages/assets/src/library.ts:267

StoreOptions interface

interface StoreOptions
fetch?: typeof fetch
origins?: string[]Origins files may come from (https://cdn.example.com). Empty or missing: any origin that passes the https rule.
base?: stringRelative refs are resolved against this.
concurrency?: number
stallMs?: numberNo bytes for this long: the attempt is abandoned and retried (resumed when it can).
retries?: number
backoffMs?: number
maxFileBytes?: numberA file bigger than this is refused (the catalog's size is the usual limit; this is the engine's cap).
cache?: PersistentCacheThe persistent cache; without one every file lives in memory for the session.
random?: () => number
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>

packages/assets/src/store.ts:17

StreamProgress interface

interface StreamProgress
loaded: number
total: number
files: number
filesDone: number
rate: number
eta: number

packages/assets/src/store.ts:15

TextureItem interface

interface TextureItem extends ItemBase
type: 'texture'
maps: Partial<Record<TextureChannel, string>>the maps present: path inside the package per channel (basecolor, normal, orm, emissive, height), per tier a folder or file set
tiling?: numbermetres of the world one repeat of the texture covers; absent when unknown
seamless?: boolean
size?: numberpixels of the largest side at full size
tiers?: Partial<Record<LibraryTier, { bytes: number; side: number }>>
aliases?: string[]other names of the same image (the same pixels exported under another name)
layers?: string[]the ground layers (LAYER_SET of

packages/assets/src/library.ts:36

TierFile interface

interface TierFile
file: string
bytes: number
triangles?: number
texCap?: number
bones?: number

packages/assets/src/library.ts:18

Totals interface

interface Totals

The mass properties of a resolved model as the whole sees them: stated, or the computed values (which must be written and fresh).

mass: number
charge: number
centerOfMass: Vec3
inertia: Vec3

packages/assets/src/model-physics.ts:180

VerifyResult interface

interface VerifyResult
signed: boolean
valid: booleanthe signature matches the manifest (and, when files could be read, every file matches the manifest)
keyId?: string
trusted: booleanvalid, and the key is in (true for any valid signature when no list was given)
problems: string[]

packages/assets/src/package.ts:422

VertexMasksDef interface

interface VertexMasksDef

opacity: the alpha of the surface is multiplied by the vertex colour's alpha (OpacityMask = texture alpha x vertex alpha); ao: ambient occlusion = the vertex colour's red channel.

opacity?: boolean
ao?: boolean

packages/assets/src/library.ts:89

VolumeItem interface

interface VolumeItem extends ItemBase

A sequence of density volumes (a baked smoke or fire), the near rung of the effect ladder: frames volumes of resolution voxels, one byte per voxel per channel, laid out frame after frame, then z, then y, then x, then channel, in one file file. channels says what the bytes are (density, temperature) in order.

type: 'volume'
resolution: [number, number, number]
frames: number
fps: number
channels: Array<'density' | 'temperature'>
voxel: numbermetres one voxel edge spans at the size it was made for
densityMax?: numberwhat a full byte means: the density, and the temperature (kelvin) of the heat channel; ambient is the air's (a zero heat byte)
temperatureMax?: number
ambient?: number
file: string
loop?: boolean

packages/assets/src/library.ts:337

ZipEntryInfo interface

interface ZipEntryInfo
path: string
size: number
compressedSize: number
method: 0 | 8
crc: number
offset: number

packages/assets/src/zip.ts:73

ZipFile interface

interface ZipFile
path: string
data: Uint8Array
compress?: boolean

packages/assets/src/zip.ts:224

Types

AlphaMode type

type AlphaMode = 'opaque' | 'mask' | 'blend'

packages/assets/src/library.ts:52

CatalogFailure type

type CatalogFailure = 'invalid' | 'signature' | 'untrusted' | 'unsigned' | 'engine' | 'network'

packages/assets/src/catalog.ts:117

CatalogPackageSource type

type CatalogPackageSource = PackageSource & { manifest: PackageManifest; cached(paths: string[]): Promise<boolean>; /** `id@version`: the unit the cache evicts and pins */ tag: string }

packages/assets/src/catalog.ts:324

CharacterKind type

type CharacterKind = 'human' | 'animal' | 'creature' | 'part' | 'vehicle'

vehicle: a machine with moving parts (an aircraft with its gear and canopy) kept as a rigged model, not a person or an animal

packages/assets/src/library.ts:12

KeyInput type

type KeyInput = { password: string } | { key: string }

What opens an encrypted package: a password, or the 32-byte key in base64.

packages/assets/src/security.ts:36

Ktx2Target type

type Ktx2Target = 'ASTC4x4' | 'BC7' | 'ETC2' | 'ETC1' | 'BC3' | 'BC1' | 'PVRTC' | 'RGBA8'

the block format a KTX2 map ends up in on a device

packages/assets/src/ktx2.ts:33

LibraryItem type

type LibraryItem = TextureItem | MaterialItem | CharacterItem | ClipsItem | ModelItem | FmdlItem | SoundItem | ModuleItem | FlipbookItem | VolumeItem

packages/assets/src/library.ts:353

LibraryItemType type

type LibraryItemType = 'texture' | 'material' | 'character' | 'clips' | 'model' | 'fmdl' | 'sound' | 'module' | 'flipbook' | 'volume'

packages/assets/src/library.ts:7

LibraryTier type

type LibraryTier = 'desktop' | 'mobile' | 'low'

packages/assets/src/library.ts:9

MapSlot type

type MapSlot = 'baseColor' | 'normal' | 'orm' | 'emissive' | 'opacity'

packages/assets/src/library.ts:53

MaskChannel type

type MaskChannel = 'r' | 'g' | 'b' | 'a' | 'rgb'

Which channel of a mask picture a colour layer reads: one channel, or rgb (each colour channel mixed by its own channel of the picture).

packages/assets/src/library.ts:95

ModelLoader type

type ModelLoader = (id: string, range: string) => Promise<ModelSource | null> | ModelSource | null

Finds the package of a model by its id and a version range (the highest version that fits), or null when there is none.

packages/assets/src/model-resolve.ts:26

ModelResponse type

type ModelResponse = false | { class: string; [parameter: string]: string | number | boolean }

how a material answers a moving medium (@ferret/physics-response): one of its classes with the class's parameters, or false for no response

packages/assets/src/model.ts:49

ModelTier type

type ModelTier = 'desktop' | 'mobile' | 'low'

packages/assets/src/model.ts:18

NodeEdit type

type NodeEdit = | { op: 'replace'; node: string; from: string | Record<string, string>; levels?: number[] } | { op: 'add'; node: string; parent: string; from: string | Record<string, string>; levels?: number[] } | { op: 'hide'; node: string; levels?: number[] } | { op: 'material'; node: string; material: string; levels?: number[] }

packages/assets/src/model.ts:42

PackageInput type

type PackageInput = Blob | Uint8Array | ArrayBuffer | string | ByteSource | PackageSource

packages/assets/src/package.ts:410

PackageKind type

type PackageKind = 'game' | 'levels' | 'assets' | 'library' | 'project' | 'model'

packages/assets/src/package.ts:13

Quat type

type Quat = [number, number, number, number]

packages/assets/src/model.ts:33

SoundBus type

type SoundBus = 'music' | 'sfx' | 'ambient' | 'voice'

packages/assets/src/library.ts:261

StoreStatus type

type StoreStatus = 'missing' | 'queued' | 'loading' | 'cached' | 'failed'

packages/assets/src/store.ts:52

StreamFailure type

type StreamFailure = 'network' | 'http' | 'timeout' | 'integrity' | 'origin' | 'aborted' | 'size' | 'build'

packages/assets/src/stream-error.ts:4

StreamPriority type

type StreamPriority = 'high' | 'normal' | 'low' | 'idle'

packages/assets/src/store.ts:11

TextureChannel type

type TextureChannel = 'basecolor' | 'normal' | 'orm' | 'emissive' | 'height'

the channels of a texture item: height is one channel, 0..1 over the set's relief (ground sets blend their layers by it)

packages/assets/src/library.ts:34

Vec3 type

type Vec3 = [number, number, number]

packages/assets/src/model.ts:32

ZipLimits type

type ZipLimits = typeof ZIP_LIMITS

packages/assets/src/zip.ts:93

Constants

AUTHOR_MARKER const

const AUTHOR_MARKER: "<!-- author -->"

packages/assets/src/model-describe.ts:17

CATALOG_FORMAT const

const CATALOG_FORMAT: 1

packages/assets/src/catalog.ts:12

CATALOG_ZIP_LIMITS const

const CATALOG_ZIP_LIMITS: { maxEntries: number; maxEntryBytes: number; maxTotalBytes: number; maxJsonBytes: number; }

The limits for the packages of a signed catalog (openCatalogPackage): what the signature vouches for is not a hostile package, and a big level (a streamed town of thousands of cells, a castle's 400 MB scene) is the reason for the catalog. Every file is still checked against its hash, a file is read whole (so it is capped at 1 GiB) and the declared sizes are still checked against what a deflate stream can give. Packages opened any other way keep ZIP_LIMITS.

packages/assets/src/zip.ts:99

CHARACTER_KINDS const

const CHARACTER_KINDS: readonly CharacterKind[]

packages/assets/src/library.ts:13

DEFAULT_REF_VERSION const

const DEFAULT_REF_VERSION: "1.0.0"

The version a reference without a version means: the version of the move to the server, never "the latest".

packages/assets/src/catalog.ts:53

DESCRIPTION_FILE const

const DESCRIPTION_FILE: "description.json"

packages/assets/src/model.ts:15

DESCRIPTION_MD const

const DESCRIPTION_MD: "description.md"

packages/assets/src/model.ts:16

ELECTRON_VOLT const

const ELECTRON_VOLT: 1.602176634e-19

One electron-volt in joules (the binding energies of nuclei are told in MeV).

packages/assets/src/model-physics.ts:19

FMDL_FORMAT const

const FMDL_FORMAT: 1

packages/assets/src/model.ts:13

GAME_TIERS const

const GAME_TIERS: readonly ["desktop", "mobile", "low"]

packages/assets/src/package.ts:36

KTX2_BYTES_PER_TEXEL const

const KTX2_BYTES_PER_TEXEL: Record<Ktx2Target, number>

video memory per texel (RGBA unless noted; BC1, ETC1 and PVRTC 4 bpp carry no alpha and take half a byte)

packages/assets/src/ktx2.ts:37

KTX2_FILES const

const KTX2_FILES: readonly ["babylon.ktx2Decoder.js", "msc_basis_transcoder.js", "msc_basis_transcoder.wasm", "zstddec.wasm", "uastc_astc.wasm", "uastc_bc7.wasm", "uastc_r8_unorm.wasm", "uastc_rg8_unorm.wasm", "uastc_rgba8_srgb_v2.wasm", "uastc_rgba8_unorm_v2.wasm"]

the files ktx2/ holds, as the build copies them (tools/build.mjs, tools/modules/build.mjs, the game builds)

packages/assets/src/ktx2.ts:20

LIBRARY_ITEM_TYPES const

const LIBRARY_ITEM_TYPES: readonly LibraryItemType[]

packages/assets/src/library.ts:8

LIBRARY_TIERS const

const LIBRARY_TIERS: readonly LibraryTier[]

packages/assets/src/library.ts:10

MANIFEST_FILE const

const MANIFEST_FILE: "ferret.json"

packages/assets/src/package.ts:12

MAP_SLOTS const

const MAP_SLOTS: readonly MapSlot[]

packages/assets/src/library.ts:54

MASK_CHANNELS const

const MASK_CHANNELS: readonly MaskChannel[]

packages/assets/src/library.ts:96

MODEL_FILE const

const MODEL_FILE: "model.json"

packages/assets/src/model.ts:14

MODEL_TIERS const

const MODEL_TIERS: readonly ModelTier[]

packages/assets/src/model.ts:19

PACKAGE_EXTENSIONS const

const PACKAGE_EXTENSIONS: Partial<Record<PackageKind, string>>

The file name extension a kind goes by. .fex is a finished game, .fprj a project in development, .fmdl a model and .level a level for a parent game; all are .ferret packages. A name ending in .fex, .fprj, .fmdl or .level must carry the matching kind; other names (.ferret) are not checked, so a package of kind levels kept under .ferret stays valid.

packages/assets/src/package.ts:20

PACKAGE_FORMAT const

const PACKAGE_FORMAT: 1

packages/assets/src/package.ts:11

PROPULSOR_KINDS const

const PROPULSOR_KINDS: readonly ["ducted-fan", "rotor", "propeller", "nozzle", "exhaust"]

packages/assets/src/model.ts:53

PROVIDED_NAMES const

const PROVIDED_NAMES: readonly ["capabilities", "kinds", "flowSources", "forms", "commands", "levelKeys"]

The provides lists that are plain names.

packages/assets/src/package.ts:90

RESPONSE_CLASSES const

const RESPONSE_CLASSES: readonly ["rigid", "elastic", "membrane", "granular", "flake", "liquid-surface", "bed", "stone", "floating", "heat"]

the classes of the response of a material; @ferret/physics-response has the same list (its test compares the two)

packages/assets/src/model.ts:52

RUBRIC_PATH const

const RUBRIC_PATH: RegExp

a rubric path: lower case words joined by / (vehicles/aircraft/bombers); the first word is the top of the tree

packages/assets/src/library.ts:781

SEAL_OVERHEAD const

const SEAL_OVERHEAD: number

What a sealed file adds to its size.

packages/assets/src/security.ts:174

SPEED_OF_LIGHT const

const SPEED_OF_LIGHT: 299792458

The speed of light, m/s: the mass of a binding energy is E / c^2.

packages/assets/src/model-physics.ts:16

TEXTURE_CHANNELS const

const TEXTURE_CHANNELS: readonly TextureChannel[]

packages/assets/src/library.ts:35

ZIP_LIMITS const

const ZIP_LIMITS: { maxEntries: number; maxEntryBytes: number; maxTotalBytes: number; maxJsonBytes: number; }

Limits that keep a hostile package from exhausting memory: a zip bomb is a few kilobytes that inflate to gigabytes, or a directory of millions of entries. An engine cap, checked on the declared sizes when the directory is read and on the real output while a file inflates. Change them before reading (a game with huge cooked files may raise maxEntryBytes).

packages/assets/src/zip.ts:92