@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
62 lines (61 loc) • 2.28 kB
TypeScript
import { DataTable } from './data-table';
import { ReadFileSystem } from './io/read';
import { Options, Param } from './types';
/**
* Supported input file formats for Gaussian splat data.
*
* - `ply` - PLY format (standard 3DGS training output)
* - `splat` - Antimatter15 splat format
* - `ksplat` - Kevin Kwok's compressed splat format
* - `spz` - Niantic Labs compressed format
* - `sog` - PlayCanvas SOG format (WebP-compressed)
* - `lcc` - XGrids LCC format
* - `mjs` - JavaScript module generator
*/
type InputFormat = 'mjs' | 'ksplat' | 'splat' | 'sog' | 'ply' | 'spz' | 'lcc';
declare const getInputFormat: (filename: string) => InputFormat;
/**
* Options for reading a Gaussian splat file.
*/
type ReadFileOptions = {
/** Path to the input file. */
filename: string;
/** The format of the input file. */
inputFormat: InputFormat;
/** Processing options. */
options: Options;
/** Parameters for generator modules (.mjs files). */
params: Param[];
/** File system abstraction for reading files. */
fileSystem: ReadFileSystem;
};
/**
* Reads a Gaussian splat file and returns its data as one or more DataTables.
*
* Supports multiple input formats including PLY, splat, ksplat, spz, SOG, and LCC.
* Some formats (like LCC) may return multiple DataTables for different LOD levels.
*
* Per-format progress (decoding bars, multi-payload bars) is emitted directly
* by each reader through the global {@link logger}; install a renderer via
* `logger.setRenderer(...)` to consume those events.
*
* @param readFileOptions - Options specifying the file to read and how to read it.
* @returns Promise resolving to an array of DataTables containing the splat data.
*
* @example
* ```ts
* import { readFile, getInputFormat, UrlReadFileSystem } from '@playcanvas/splat-transform';
*
* const filename = 'scene.ply';
* const fileSystem = new UrlReadFileSystem('https://example.com/');
* const tables = await readFile({
* filename,
* inputFormat: getInputFormat(filename),
* options: {},
* params: [],
* fileSystem
* });
* ```
*/
declare const readFile: (readFileOptions: ReadFileOptions) => Promise<DataTable[]>;
export { readFile, getInputFormat, type InputFormat, type ReadFileOptions };