Skip to content
Shapemetry

Model - Evaluation snapshot

API reference for src/core/evaluationSnapshot, src/schema/evaluationSnapshot 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.

captureEvaluationSnapshot

function

Capture a just-evaluated model into a worker-safe snapshot. Call after model.evaluate() (or with a completed EvaluateResult).

captureEvaluationSnapshot(model: Model, result?: EvaluateResult): EvaluationSnapshot

evaluateResultFromSnapshot

function

Build an EvaluateResult after install — same host-facing shape as model.evaluate(), without running the fold on this thread. Viewport uses .nodes + collectRenderFrame (SceneNode cache). The lazy .geometry mesh export path is empty until a full tessellate is requested on a thread that can afford it (export still may call model.tessellateScene).

evaluateResultFromSnapshot(model: Model, snapshot: EvaluationSnapshot): EvaluateResult

EvaluationSliceEntry

type

One root-body slice: the fold output attributed to a top-level key.

type EvaluationSliceEntry
// = {
    key: string;
    entities: Entity[];
    error?: string;
}

EvaluationSnapshot

type

Clone-safe evaluation result for worker → main handoff. Materials omit textureData (ImageBitmap / non-cloneable); the host re-attaches textures via refreshTextures() / Store after install.

type EvaluationSnapshot
// = {
    name: string;
    params: ParamInfo[];
    materials: MaterialData[];
    layers: Layer[];
    diagnostics: EvaluateDiagnostic[];
    frame: RenderFrameSlice[];
    slices: EvaluationSliceEntry[];
    definitions: Array<{
        id: string;
        entities: Entity[];
    }>;
}

installEvaluationSnapshot

function

Install a worker snapshot onto a Model that was just fromJSON'd and has NOT been evaluated on this thread. Seeds SceneNode + root body values so collectRenderFrame / sceneFrame serve geometry without a main-thread fold.

installEvaluationSnapshot(model: Model, snapshot: EvaluationSnapshot): void
Last updated: 📖 1 min readEdit on GitHub