@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
76 lines (75 loc) • 2.93 kB
TypeScript
import { DataTable } from './data-table';
import { type FileSystem } from './io/write';
import { type DeviceCreator, type Options } from './types';
/**
* Supported output file formats for Gaussian splat data.
*
* - `ply` - Standard PLY format
* - `compressed-ply` - Compressed PLY format
* - `spz` - Niantic Labs SPZ format
* - `glb` - Binary glTF with KHR_gaussian_splatting extension
* - `csv` - CSV text format (for debugging/analysis)
* - `sog` - PlayCanvas SOG format (separate files)
* - `sog-bundle` - PlayCanvas SOG format (bundled into single .sog file)
* - `lod` - Multi-LOD format with chunked data
* - `html` - Self-contained HTML viewer (separate assets)
* - `html-bundle` - Self-contained HTML viewer (all assets embedded)
* - `voxel` - Sparse voxel octree format for collision detection
* - `image` - Rasterized RGBA image (lossless WebP) rendered from a camera view
*/
type OutputFormat = 'csv' | 'sog' | 'sog-bundle' | 'lod' | 'compressed-ply' | 'ply' | 'spz' | 'glb' | 'html' | 'html-bundle' | 'voxel' | 'image';
/**
* Options for writing a Gaussian splat file.
*/
type WriteOptions = {
/** Path to the output file. */
filename: string;
/** The format to write. */
outputFormat: OutputFormat;
/** The splat data to write. */
dataTable: DataTable;
/** Optional environment/skybox splat data (for LOD format). */
envDataTable?: DataTable;
/** Processing options. */
options: Options;
/** Optional function to create a GPU device for compression. */
createDevice?: DeviceCreator;
};
/**
* Determines the output format based on file extension and options.
*
* @param filename - The filename to analyze.
* @param options - Options that may affect format selection.
* @returns The detected output format.
* @throws Error if the file extension is not recognized.
*
* @example
* ```ts
* const format = getOutputFormat('scene.ply', {}); // returns 'ply'
* const format2 = getOutputFormat('scene.sog', {}); // returns 'sog-bundle'
* ```
*/
declare const getOutputFormat: (filename: string, options: Options) => OutputFormat;
/**
* Writes Gaussian splat data to a file in the specified format.
*
* Supports multiple output formats including PLY, compressed PLY, CSV, SOG, LOD, and HTML.
*
* @param writeOptions - Options specifying the data and format to write.
* @param fs - File system abstraction for writing files.
*
* @example
* ```ts
* import { writeFile, getOutputFormat, MemoryFileSystem } from '@playcanvas/splat-transform';
*
* const fs = new MemoryFileSystem();
* await writeFile({
* filename: 'output.sog',
* outputFormat: getOutputFormat('output.sog', {}),
* dataTable: myDataTable,
* options: { iterations: 8 }
* }, fs);
* ```
*/
declare const writeFile: (writeOptions: WriteOptions, fs: FileSystem) => Promise<void>;
export { getOutputFormat, writeFile, type OutputFormat, type WriteOptions };