Skip to content
Shapemetry

Model - Root fold

API reference for src/core/rootFold 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.

collectFonts

function

collectFonts(nodes: NodeCollection<ChildNode>): AssetFile[]

collectGeometryFromSlices

function

collectGeometryFromSlices(nodes: NodeCollection<ChildNode>, slices: Map<string, Entity[]> | null, diagnostics?: EvaluateDiagnostic[]): GeometryNode[]

collectMaterials

function

Exported for render hosts: the resolved material records reaching this collection (materials[] nodes evaluated + texture-attached, via the owning Model's SnapshotLaneNode pull — see materialsResolverOf) — a host syncs these into its material table on every render pass so node edits show up live. A registry may supply its own builtinMaterials (e.g. the tree node's bark/leaf textures, stamped by name with no doc-lane record) — merged UNDER the doc lane here so a doc record with the same name always wins.

collectMaterials(nodes: NodeCollection<ChildNode>): MaterialData[]

collectParams

function

collectParams(nodes: NodeCollection<ChildNode>): ParamInfo[]

collectRenderFrame

function

One SNAPSHOT of everything renderable. When nodes is a Model-owned collection, pulls the SceneNode cache (single fold with tessellate/sceneFrame). Bare collections (tests without a Model) fold directly.

collectRenderFrame(nodes: NodeCollection<ChildNode>): RenderFrameSlice[]

frameFromSlices

function

Build a render frame from fold slices (or container values when no fold). Pure over already-collected slices — does NOT re-run the root fold.

frameFromSlices(nodes: NodeCollection<ChildNode>, slices: Map<string, Entity[]> | null): RenderFrameSlice[]

materialsResolverOf

const

const materialsResolverOf: WeakMap<NodeCollection<any>, () => MaterialData[]>

modelCombinationFromSlices

function

modelCombinationFromSlices(nodes: NodeCollection<ChildNode>, slices: Map<string, Entity[]> | null, options?: { expandBlocks?: boolean; }): Entity[]

nodeGeometry

function

Render a single generator node's value into its GeometryNode content: { items, instances?, material? } (or null if it renders nothing). The definition of the split — instanced vs baked — lives HERE so both the engine's collectGeometry and the host's incremental re-render use the same rule.

Instanced path: value = blockEntity wrappers only → geometry once per BlockDefinition + placements. Single shared definition → items+instances. Several definitions (multi-member array) → packs[] (each def once). Baked path (mixed / explode / raw): flatten to concrete leaf geometry.

nodeGeometry(node: ContainerNode | EntitiesNode, definitions?: Map<string, BlockDefinition>, entitiesOverride?: Entity[], diagnostics?: EvaluateDiagnostic[]): { items: GeometryItem[]; instances?: GeometryPlacement[]; material?: string; packs?: Array<{ items: GeometryItem[]; instances: GeometryPlacement[]; }>; } | null

rootBodyNodes

function

Top-level body nodes (the root fold list), in declaration order.

rootBodyNodes(nodes: NodeCollection<ChildNode>): (EntitiesNode | ContainerNode)[]

rootFoldSlices

function

Run the root fold and slice the result per source node key. Returns null when the model has no root-level scene steps (container values render directly — no fold pass needed). Throws a named "Circular dependency" error when a self-referential whole-scene embed (cycleGate) re-enters.

rootFoldSlices(nodes: NodeCollection<ChildNode>): Map<string, Entity[]> | null

sceneNodeOf

const

const sceneNodeOf: WeakMap<NodeCollection<any>, SceneNode<ScenePull>>
Last updated: 📖 2 min readEdit on GitHub