/** * Shared PLY header reader. * * PLY is a container, not a format: the same `.ply` extension carries the * uncompressed "INRIA flavor" 3DGS export (see `parse-splat-ply.ts`) and * SuperSplat/PlayCanvas's compressed flavor (`parse-compressed-ply.ts`). * Both need the same thing first - the element list, their property layouts, * and where each element's records start - so that lives here. */ /** One scalar property of an element. */ export interface PlyProperty { readonly type: string; /** Byte offset within one record of the element. */ readonly offset: number; } /** * One list property (`property list `), such as a * mesh's `face` indices. Only the types are recorded - the data is variable-size * and must be walked record by record (see `parse-mesh-ply.ts`). */ export interface PlyListProperty { /** Type of the per-record item count, e.g. `uchar`. */ readonly countType: string; /** Type of each item, e.g. `int`. */ readonly itemType: string; } /** One PLY element (`element `) and its record layout. */ export interface PlyElement { readonly name: string; readonly count: number; readonly properties: ReadonlyMap; /** Property names in declaration order. */ readonly propertyNames: readonly string[]; /** List properties by name; empty unless {@link hasListProperty}. */ readonly listProperties: ReadonlyMap; /** * Bytes per record - meaningless when {@link hasListProperty}, since a list * makes each record's size depend on its contents. */ readonly stride: number; /** * Byte offset of this element's first record within the file, or -1 when a * preceding element has a variable-size record and no arithmetic can find it. */ readonly offset: number; /** A list property makes this element's records variable-size. */ readonly hasListProperty: boolean; } /** A parsed PLY header. */ export interface PlyHeader { readonly elements: readonly PlyElement[]; /** The element of that name, or undefined. */ element(name: string): PlyElement | undefined; } /** * Reads a binary little-endian PLY header and resolves every element's byte * offset by walking the elements in declaration order. * * Whether the declared records actually fit in the buffer is deliberately not * checked here - call {@link assertPlyElementFits} once the caller has * validated the properties it needs, so a wrong property type is reported as * such rather than as the truncation it happens to imply. * * @throws {Error} if the file is not a binary little-endian PLY, or declares a * property type this reader cannot size. */ export declare function parsePlyHeader(buffer: ArrayBuffer): PlyHeader; /** * Asserts an element's records are actually present in a file of `totalBytes`. * * Takes a size rather than a buffer so it works for a streamed parse, which * only ever holds a window of the file. * * @throws {Error} if the element sits behind a variable-size one, or its * records run past the end of the file. */ export declare function assertPlyElementFits(element: PlyElement, totalBytes: number): void; /** * Byte size of a PLY scalar type. * * @throws {Error} if the type is not one PLY can declare. */ export declare function plyTypeSize(type: string): number; /** The byte offset of `property` within `element`'s record. */ export declare function plyPropertyOffset(element: PlyElement, property: string): number; /** Asserts every named property exists on `element` with the given type. */ export declare function assertPlyPropertyTypes(element: PlyElement, properties: readonly string[], types: readonly string[], what: string): void;