Skip to content
Shapemetry

Model - Model runtime

API reference for src/schema/modelRuntime 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.

EvaluateDiagnostic

type

type EvaluateDiagnostic
// = {
    /** Runtime id of the node the failure is attributed to, when known. */
    nodeId?: string;
    /** The pass that produced it: "load" (expression syntax), "render"
     *  (entity tessellation), "texture" (texture-chain resolve). */
    phase: "load" | "render" | "texture";
    message: string;
}

EvaluateResult

type

type EvaluateResult
// = {
    name: string;
    geometry: GeometryNode[];
    materials: MaterialData[];
    /** The document's font ASSET records (`{ name, url }`), not the kernel's
     *  registry handles — `collectFonts` reads ModelScope.fonts. Was declared
     *  `FontData` (`{ ids, name }`), which the runtime never produced. */
    fonts: AssetFile[];
    layers: Layer[];
    params: ParamInfo[];
    /** Fail-soft failures from this evaluation (render/texture/load). Empty
     *  when nothing went wrong. NOTE: `.geometry` is lazy — render diagnostics
     *  land here when it is first read, not when evaluate() returns. */
    diagnostics: EvaluateDiagnostic[];
    nodes: NodeCollectionHost<ChildNode>;
    /** The evaluated Model itself — the ONLY object that can emit the FULL
     *  document (`toJSON()` carries every lane: materials/fonts/textures/
     *  views/components/sheets + unit). A host that persists a doc must build it
     *  from here, never by hand-partitioning `nodes` (that drops the lanes —
     *  the exact bug this field exists to prevent). */
    model: ModelHost;
    /** Runtime group-definition registry (id → shared geometry) for baking values. */
    definitions?: Map<string, BlockDefinition>;
}

GeometryItem

type

type GeometryItem
// = Record<string, unknown>

GeometryNode

type

type GeometryNode
// = {
    key: string;
    material?: string;
    items: GeometryItem[];
    children: GeometryNode[];
    source?: ContainerNodeHost | EntitiesNodeHost;
    /** ≥2 placements of the shared `items` (single-definition instance path). Absent = baked or multi-pack. */
    instances?: GeometryPlacement[];
    /**
     * Multi-member instance path: each pack is one BlockDefinition rendered
     * once (`items`) with its own placements. Used when array* copies several
     * different source shapes step-aligned (each source keeps its own def).
     */
    packs?: Array<{
        items: GeometryItem[];
        instances: GeometryPlacement[];
    }>;
}

ParamInfo

type

type ParamInfo
// = {
    key: string;
    type: string;
    value: unknown;
}
Last updated: 📖 1 min readEdit on GitHub