geom-export-obj
Version:
Convert one (or more) simplicial complex geometry (positions/cells/normals/uvs/vertexColors) into an OBJ string (optionally optimized with number precision to reduce its size).
54 lines (53 loc) • 1.08 kB
TypeScript
/**
* Geometry definition. All optional.
*/
export type SimplicialComplex = {
positions: number[];
normals: number[];
uvs: number[];
cells: number[];
/**
* The object name.
*/
name: string;
/**
* The object material name.
*/
materialName?: string;
};
/**
* Offsets to for cells. Useful if appending to another obj string. Used internally.
*/
export type GeomExportObjOffsets = {
positions: number;
normals: number;
uvs: number;
};
/**
* Options for exporter.
*/
export type GeomExportObjOptions = {
/**
* geom-export-obj\n] Header to be prepended to the file.
*/
header?: string;
/**
* Prefix for object names.
*/
prefix?: string;
/**
* The initial offsets for cells.
*/
offsets?: GeomExportObjOffsets;
/**
* Decimal digit precision for positions/normals/uvs/vertexColors.
*/
precision?: number;
};
export type GeomExportObjReturnValue = {
/**
* The obj as a string.
*/
output: string;
offsets: GeomExportObjOffsets;
};