/** * Decode the compressed/instanced shape format. * * The instanced format wraps a standard Shapes object: * ``` * { instances: [ { vertices: {shape,dtype,buffer,codec}, ... }, ... ], * shapes: { version, parts, loc, name, id, bb, ... } } * ``` * * Each instance contains base64-encoded geometry buffers. Parts reference * instances via `"shape": { "ref": N }`. After decoding, the result is a * standard Shapes tree with TypedArrays — identical to the existing format. */ import type { Shapes } from "../core/types.js"; /** A single base64-encoded buffer entry. */ interface EncodedBuffer { shape: number[]; dtype: "float32" | "int32" | "uint32"; buffer: string; codec: "b64"; } /** An encoded geometry instance (all 9 buffer fields + optional uvs). */ interface EncodedInstance { vertices: EncodedBuffer; triangles: EncodedBuffer; normals: EncodedBuffer; edges: EncodedBuffer; obj_vertices: EncodedBuffer; face_types: EncodedBuffer; edge_types: EncodedBuffer; triangles_per_face: EncodedBuffer; segments_per_edge: EncodedBuffer; uvs?: EncodedBuffer; } /** Top-level structure of the instanced format. */ interface InstancedData { instances: EncodedInstance[]; shapes: Shapes; } /** * Walk the shapes tree and decode any inline encoded buffers found in * part.shape objects. This handles edge/vertex-only objects that embed * encoded buffers directly (not via instance refs). */ declare function decodeInlineBuffers(shapes: Shapes): void; /** * Type guard: check if data is in the instanced format. * Detected by the presence of an `instances` array and a `shapes` object. */ declare function isInstancedFormat(data: unknown): data is InstancedData; /** * Decode the instanced format into a standard Shapes object. * * 1. Decode all instance buffers from base64 → TypedArrays * 2. Walk the shapes tree and replace { ref: N } with decoded instances * 3. Return the unwrapped Shapes object */ declare function decodeInstancedFormat(data: InstancedData): Shapes; export { isInstancedFormat, decodeInstancedFormat, decodeInlineBuffers }; export type { InstancedData, EncodedBuffer, EncodedInstance };