Skip to content
Shapemetry

Types - USD

API reference for ./io/usd on @huukhanhnguyen/types — the option and result records of @huukhanhnguyen/io's USD reader/writer.

See the Guide for the package's role.

API reference

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

AnimationEmit

type

type AnimationEmit
// = {
    /** Placed inside Scene (SkelAnimation prims under Scope Animations). */
    scenePart: string;
    /** Placed after Root closes (nested over → Skeleton.animationSource). */
    afterRoot: string;
}

ClipSkeletonState

type

One clip's per-joint samples while the USD writer accumulates them.

type ClipSkeletonState
// = {
    perJoint: Map<string, JointSamples>;
    hasTranslateAnimation: boolean;
    hasRotateAnimation: boolean;
    allTimes: Set<number>;
    duration: number;
}

DefBlock

type

One def TYPE "name" (meta) { body } block lifted out of USDA text by the reader — the format's own bracket structure, before any interpretation.

type DefBlock
// = {
    type: string;
    name: string;
    meta: string;
    body: string;
}

JointSamples

type

type JointSamples
// = {
    translate: Map<number, string>;
    rotate: Map<number, string>;
}

PrototypeContext

type

Block prototypes threaded through the USD walk: definition id → its content and the root path of the class prim a placement references.

type PrototypeContext
// = {
    nodes: Map<string, EntityTreeNode[]>;
    pathById: Map<string, string>;
}

TextureRef

type

type TextureRef
// = {
    path: string;
    id: string;
    wrap: string;
    uvSet: number;
    scaleS: number;
    scaleT: number;
}

UsdDocument

type

type UsdDocument
// = {
    /** Primary layer (`model.usda`). */
    modelUsda: string;
    /** Extra files inside the USDZ (texture PNGs keyed by archive path). */
    files: Record<string, Uint8Array>;
}

UsdOptions

type

type UsdOptions
// = {
    materials?: MaterialData[];
    /** Emitting entities reduced to point/spot records (model's
     *  `collectLights`) — the emitting SHAPE picks the UsdLux prim:
     *  SphereLight, DiskLight, RectLight or CylinderLight. */
    lights?: LightEntity[];
    /** The document's resolved sun/sky — UsdLux `DistantLight` for the sun,
     *  `DomeLight` for a sky fill or an HDRI. */
    environment?: ResolvedEnvironment;
    cameras?: GltfCamera[];
    skeletons?: Skeleton[];
    /** The full evaluated track pool, keyed by `Track.key` — see
     *  `GltfOptions.tracks` (same shape, same resolve-by-reference contract). */
    tracks?: Track[];
    animations?: AnimationClip[];
    variants?: GltfMaterialVariant[];
    warnings?: string[];
    /** Block definitions a `BlockEntity` places. USD INSTANCES them: one `class`
     *  prototype prim per definition, each placement an Xform that
     *  `references` it with `instanceable = true`. */
    definitions?: Map<string, import("../evaluate/block.js").BlockDefinition> | ReadonlyMap<string, import("../evaluate/block.js").BlockDefinition>;
    /**
     * Tessellator for `entitiesToUsda`'s B-rep `faceEntity` branch — the ONE
     * thing this port could not bring across. Turning a `ShellEntity` into
     * triangles is the parametric engine's render pass (parashape
     * `domains/render.ts`), which the move manifest keeps in parashape, and
     * this package has no tessellator for a scene FACE (its kernel bridge
     * tessellates a B-Rep handle, a different input).
     *
     * Absent, `entitiesToUsda` emits stream `meshEntity` n-gons only and skips
     * faces. Every other entry point (`tessellationToUsda` / `Usdz`) consumes
     * already-tessellated Entity[] and needs nothing here.
     */
    tessellate?: (face: Entity) => MeshEntity | undefined;
}

UsdStage

type

A USDA stage decoded into this repo's own vocabulary — what readUsda answers with, and everything a consumer needs to build entities from it.

Mesh loops are polygons exactly as faceVertexCounts declares them (no triangulation: how to split an n-gon is the consumer's choice, not the format's), already converted from the stage's Y-up metres to the entity stream's Z-up millimetres.

type UsdStage
// = {
    meshes: Array<{
        name: string;
        material?: string;
        loops: Point[][];
    }>;
    materials: Material[];
    warnings: string[];
}
Last updated: 📖 1 min readEdit on GitHub