Model - Model
API reference for src/schema/model, src/Model 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.
AnimationChainSchema
const
const AnimationChainSchema: z.ZodObject<{ key: z.ZodStringAreaUnitSchema
const
const AreaUnitSchema: z.ZodEnum<{ mm2: "mm2"ArgumentSchema
const
const ArgumentSchema: z.ZodObject<{ key: z.ZodStringassetTypeOf
function
Classify an attached file's url: font / image / glb mesh / generic file. Data URIs classify by their MIME prefix (data:font/… → font, data:image/… → image, data:model/gltf-binary → glb, any other data: → file); everything else classifies by its lowercased extension (query/hash stripped) — an unknown or missing extension is a plain "file".
assetTypeOf(url: string): "font" | "image" | "glb" | "file"CameraNodeSchema
const
cameras[] lane — camera only.
const CameraNodeSchema: z.ZodType<CameraNode, unknown, z.core.$ZodTypeInternals<CameraNode, unknown>>CameraSchema
const
The 3D VIEWPORT's own live camera-state contract (packages/three's Viewport.getCameraState/setCameraState) — its own type toggles the viewport's perspective/orthographic PROJECTION MATRIX for live navigation, an ENTIRELY SEPARATE type from a folded view's projection config (Camera above). The viewport's live ortho toggle stays ephemeral UI state, same class as axes/grid visibility, deliberately not persisted through either type.
const CameraSchema: z.ZodObject<{ type: z.ZodOptional<z.ZodEnum<{ perspective: "perspective"ComponentSchema
const
const ComponentSchema: z.ZodObject<{ key: z.ZodStringContainerSchema
const
const ContainerSchema: z.ZodType<Container>DEFAULT_UNITS
const
Default when settings.units is absent — ONE place (Model.unit reads this).
const DEFAULT_UNITS: UnitConfigEntitiesSchema
const
One step of an ENTITY-streaming chain — see Entities in @huukhanhnguyen/types. .strict() is the enforcement: a document that still carries flat, locked, children or animation on an entity step is REJECTED by name, not silently ignored.
const EntitiesSchema: z.ZodType<Entities>EntityContainerSchema
const
The SAME Container shape, parsing an ENTITY chain: its operations admit only EntitiesSchema steps and further entity containers. One type, two parses — a container is display grouping in every lane, and the lane is what decides which node vocabulary sits inside it. Splitting the TYPE would be wrong: nodeMethods/skeleton.ts walks joint children and track children THROUGH containers, and a parameters[] container holds value nodes carrying animation — both legal, neither an entity chain.
const EntityContainerSchema: z.ZodType<Container>EntityNodeSchema
const
An entity-streaming chain's list shape: an EntitiesSchema step or an EntityContainerSchema grouping, and nothing else. The objects[] bodies, component bodies/openings and sheet content parse with THIS, not with NodeSchema — which is what keeps children and animation out of the entity chain while the skeleton / animation / parameter lanes (whose nodes legitimately carry them) keep NodeSchema.
const EntityNodeSchema: z.ZodType<(Entities | Container)>EXPR_MAX_LENGTH
const
const EXPR_MAX_LENGTH = 8000exprSchema
const
const exprSchema: z.ZodStringFLAT_LANE_METHODS
const
const FLAT_LANE_METHODS: Set<string>generatorKeySchema
const
const generatorKeySchema: z.ZodStringisContainerJSON
function
isContainerJSON(node: (Operation | Container)): node is ContainerisPointArgType
function
True when an arg TYPE is point-ish (a "point" / "point[]" branch, alone or inside a union) — the arg shapes that become Point values. Vectors/ directions are deliberately NOT gated: an out-of-plane direction (a rotation axis, a move offset) stays legal in 2D; the per-step flatten net absorbs its effect, same as in a flat lane.
isPointArgType(type: string | undefined): booleanLengthUnitSchema
const
const LengthUnitSchema: z.ZodEnum<{ in: "in"MassUnitSchema
const
const MassUnitSchema: z.ZodEnum<{ mg: "mg"Method
type
type Method
// = z.infer<typeof MethodSchema>MethodSchema
const
const MethodSchema: z.ZodStringModel
class
A compiled parametric model: value nodes (the parameters header) plus one flat body fold (the operations list / scene role) that evaluates to a scene tree.
Root = container
The root IS a container: its top-level body nodes fold exactly like any nested operations list (producers/containers concat into the root stream, root-level transforms process it, in listed order — rootFoldSlices). It is a DEFINITION — it has no instances lane, because a model carries no transform of its own. Placement is the consumer's job: clone/ placeComponent supply the instances when this definition (once installed as a components[] entry, see share.ts's installModel) is placed inside another model.
Assets (materials / layers / views / attached files)
materials[] and layers[] are both NODE lanes (material/layer methods, expression args → resolved Material/Layer via evaluateMaterials()/evaluateLayers()). Consumed BY NAME — applyMaterial/applyLayer stamp names. Runtime they are SnapshotLaneNode-backed: evaluateMaterials/evaluateLayers dirty-gate the lane, pattern texture pulls register edges, and every graph consumer (views/sheets/placePart) goes through those resolves so a material/layer edit cascades via markDirty — same pull law as the cameras lane. views[] is already one ChainNode per key (evaluateView). Attached files (fonts/images) are url-method parameters (ordinary graph nodes).
class ModelMembers: _animationNodes, _annotationStylesNode, _argOverrides, _camerasNode, _collections, _componentAnimationNodes, _componentNodes, _componentSkeletonNodes, _installScenePull, _isAnalysisCopy, _layersNode, _loggedTextureErrors, _materialRecords, _materialsNode, _objectAnnouncedEpochs, _objectListeners, _objectNodes, _objectSignatures, _sceneNode, _sheetNodes, _sheetWarnings, _skeletonNodes, _stylesNode, _tableNodes, _textStylesNode, _textureDataCache, _textureNodes, _viewNodes, animations, applyDocument, bakeValue, buffer, cameras, clearArgOverrides, clip, clips, collection, components, convertUnit, data, evaluate, evaluateAnimations, evaluateAnnotationStyles, evaluateCameras, evaluateComponent, evaluateComponentAnimations, evaluateComponentSkeletons, evaluateDrawingSet, evaluateLayers, evaluateMaterials, evaluateObject, evaluatePart, evaluateSheet, evaluateSheetOperations, evaluateSkeletons, evaluateStyles, evaluateTable, evaluateTextStyles, evaluateTexture, evaluateView, foldView, fromJSON, graphSnapshot, id, laneCarrier, name, nodes, objectKeys, refreshTextures, registry, sceneFrame, setArgOverride, settings, sheets, skeletons, subscribeObject, tables, tessellateScene, textures, toJSON, trackPool, tracks, unit, views
ModelJSON
type
type ModelJSON
// = ModelJSON$1<CameraMethod>modelNodesOf
function
modelNodesOf(json: unknown): (Operation | Container)[]ModelSchema
const
const ModelSchema: z.ZodType<ModelJSON>ModelSettingsSchema
const
const ModelSettingsSchema: z.ZodObject<{ units: z.ZodOptional<z.ZodObject<{ length: z.ZodDefault<z.ZodEnum<{ in: "in"NodeSchema
const
const NodeSchema: z.ZodType<(Operation | Container)>ObjectSchema
const
const ObjectSchema: z.ZodType<Container & { key: stringOperationSchema
const
const OperationSchema: z.ZodType<Operation>OptionSchema
const
const OptionSchema: z.ZodObject<{ label: z.ZodStringpointArgHasNonZeroZ
function
True when an evaluated point-ish arg VALUE carries z≠0 anywhere — a bare [x,y,z] point or any row of a point array. [x,y] rows (z omitted = 0, the flat-authoring shorthand) pass.
pointArgHasNonZeroZ(value: unknown): booleanquotedStringLiteral
function
Shared quoted-literal unquote for expression INPUT strings. Returns the inner string when the whole expression is a plain single- or double-quoted literal (with basic escape support); undefined when the input is missing, non-string, or not a pure literal (an identifier / expression cannot be resolved statically). ONE implementation for materials/layers/styles name args, applyMaterial checks, etc.
quotedStringLiteral(input: unknown): string | undefinedRawModel
type
type RawModel
// = RawModel$1<CameraMethod>SCHEMA_VERSION
const
55: the helpers[] lane is DELETED (2026-08-16) — the lane, its axes / grid method vocabulary, the datum evaluator, the HelperVisual / AxesHelper / GridHelper records, and the datum channel that carried their entities into every view and sheet. Both methods' own tooltips said "Not product geometry", and the lane reached NO file format: measured 2026-08-16, helper|grid|datum|axes occurs zero times across crates/io's usd / dxf / ifc / svg / step writers (the two hits in gltf_scene are the English phrase "Field helpers"), and three.js — where the shape was copied from — exports no helper either. A coordinate triad is a habit of the person LOOKING, not an intent of the author, so it is an editor setting in the viewer now (opening the file on another machine with a different axis display breaks nothing). No migration and no strip: a document still carrying helpers is REJECTED by name (RETIRED_ROOT_MESSAGES) rather than silently emptied.
const SCHEMA_VERSION = 55SheetSchema
const
const SheetSchema: z.ZodObject<{ key: z.ZodStringSkeletonChainSchema
const
const SkeletonChainSchema: z.ZodObject<{ key: z.ZodStringTableChainSchema
const
const TableChainSchema: z.ZodObject<{ key: z.ZodStringTextureChainSchema
const
const TextureChainSchema: z.ZodObject<{ key: z.ZodStringtitleValue
function
Title VALUE LAW (owner 2026-07-26 — "everything is an expression unless there's a reason"): a title string is an EXPRESSION. Parse + eval succeeds → its result; no evaluator wired, a parse error, or a ReferenceError → the string IS the literal ("GROUND FLOOR PLAN" keeps working, "'Plan ' + level" renders evaluated). ONE impl so sheets cannot drift from it.
titleValue(raw: string | undefined, evaluateExpression?: (expr: string) => unknown): stringUnitConfigSchema
const
const UnitConfigSchema: z.ZodObject<{ length: z.ZodDefault<z.ZodEnum<{ in: "in"urlInputLiteral
function
Extract the literal url from a url-method parameter's primary-arg INPUT (an unevaluated expression string): strip one layer of surrounding single/double quotes when present, else use the raw input. Static — no evaluation — so the Store's pre-load scan, the scope's computed fonts/ images views, and Model._imageUrlOf all agree on the same url string.
urlInputLiteral(input: unknown): stringViewCameraSchema
const
Structural validation of a complete Camera value — the zod mirror of the type: a pose, plus fov XOR height, and no type tag (the present field IS the tag). .strict() is what rejects a document written against the retired shape: type/zoom/left/right/top/bottom are now unrecognized keys, not silently-ignored ones.
const ViewCameraSchema: z.ZodObject<{ position: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>ViewSchema
const
Chain View — operations required (may be empty for a headless preset).
const ViewSchema: z.ZodObject<{ key: z.ZodStringVolumeUnitSchema
const
const VolumeUnitSchema: z.ZodEnum<{ mm3: "mm3"