Skip to content
Shapemetry

Model - Store

API reference for src/schema/store, src/Store on @huukhanhnguyen/model, reachable from ..

See the Guide for the ModelJSON / evaluate pipeline.

API reference

Signatures are generated from the live package .d.ts - not hand-written.

AssetFailure

type

One failed fetch/decode from the async pre-load phase. The sync graph stays fail-soft on its own (a missing font falls back, the texture image op reports at resolve) — this record exists so a HOST can surface "asset X didn't load" instead of degrading silently.

type AssetFailure
// = {
    type: "font" | "image" | "glb";
    /** The registration key — for a font, its url (fonts are keyed by URL,
     *  same as images). */
    name?: string;
    url: string;
    message: string;
}

Store

class

Per-session asset registry. Every consumer builds its own instance — new Store() — there is no shared singleton.

Responsibilities (JSON-level only, never instantiates a Model):

  1. Store raw model JSONs by ID (host-facing lookup, e.g. catalog opens).
  2. Scan a document's parameters lane (root AND each components[] entry's own parameters, 2026-07-22 — a component may carry its OWN attached files, share.ts's law) for url-method parameters (an attached file IS such a parameter — type inferred from the url via assetTypeOf: font/image/glb) plus the textures[] lane's image ops → pre-load by URL. All three maps are keyed by URL.

Typical session flow: const assets = new Store() assets.registerFromModel(json) // scan parameters/textures lanes await assets.loadFonts() // ASYNC phase (+ loadImages/loadGlbs) const model = await Model.fromJSON(json, { store: assets })

class Store

Members: getFont, getGlb, getImage, getModel, loadFonts, loadGlbs, loadImages, queueGlb, queueImage, registerFont, registerFromModel, registerGlb, registerImage, reset

Last updated: 📖 1 min readEdit on GitHub