@playcanvas/splat-transform 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.mjs +352 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +5478 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +352 -5
- package/dist/index.mjs.map +1 -1
- package/dist/lib/data-table/combine.d.ts +16 -0
- package/dist/lib/data-table/data-table.d.ts +48 -0
- package/dist/lib/data-table/summary.d.ts +33 -0
- package/dist/lib/data-table/transform.d.ts +19 -0
- package/dist/lib/index.d.cts +34 -0
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/io/read/index.d.ts +1 -1
- package/dist/lib/io/read/zip-file-system.d.ts +1 -1
- package/dist/lib/io/write/memory-file-system.d.ts +15 -0
- package/dist/lib/io/write/zip-file-system.d.ts +20 -0
- package/dist/lib/process.d.ts +96 -1
- package/dist/lib/read.d.ts +57 -1
- package/dist/lib/readers/read-ksplat.d.ts +11 -0
- package/dist/lib/readers/read-lcc.d.ts +13 -0
- package/dist/lib/readers/read-mjs.d.ts +12 -0
- package/dist/lib/readers/read-ply.d.ts +10 -0
- package/dist/lib/readers/read-sog.d.ts +1 -0
- package/dist/lib/readers/read-splat.d.ts +10 -0
- package/dist/lib/readers/read-spz.d.ts +12 -0
- package/dist/lib/types.d.ts +1 -0
- package/dist/lib/write.d.ts +57 -1
- package/dist/lib/writers/write-compressed-ply.d.ts +11 -0
- package/dist/lib/writers/write-csv.d.ts +10 -0
- package/dist/lib/writers/write-html.d.ts +10 -0
- package/dist/lib/writers/write-lod.d.ts +11 -0
- package/dist/lib/writers/write-ply.d.ts +10 -0
- package/dist/lib/writers/write-sog.d.ts +16 -1
- package/package.json +13 -4
package/dist/lib/write.d.ts
CHANGED
|
@@ -2,15 +2,71 @@ import { DataTable } from './data-table/data-table';
|
|
|
2
2
|
import { type FileSystem } from './io/write';
|
|
3
3
|
import { Options } from './types';
|
|
4
4
|
import { type DeviceCreator } from './writers/write-sog';
|
|
5
|
+
/**
|
|
6
|
+
* Supported output file formats for Gaussian splat data.
|
|
7
|
+
*
|
|
8
|
+
* - `ply` - Standard PLY format
|
|
9
|
+
* - `compressed-ply` - Compressed PLY format
|
|
10
|
+
* - `csv` - CSV text format (for debugging/analysis)
|
|
11
|
+
* - `sog` - PlayCanvas SOG format (separate files)
|
|
12
|
+
* - `sog-bundle` - PlayCanvas SOG format (bundled into single .sog file)
|
|
13
|
+
* - `lod` - Multi-LOD format with chunked data
|
|
14
|
+
* - `html` - Self-contained HTML viewer (separate assets)
|
|
15
|
+
* - `html-bundle` - Self-contained HTML viewer (all assets embedded)
|
|
16
|
+
*/
|
|
5
17
|
type OutputFormat = 'csv' | 'sog' | 'sog-bundle' | 'lod' | 'compressed-ply' | 'ply' | 'html' | 'html-bundle';
|
|
18
|
+
/**
|
|
19
|
+
* Options for writing a Gaussian splat file.
|
|
20
|
+
*/
|
|
6
21
|
type WriteOptions = {
|
|
22
|
+
/** Path to the output file. */
|
|
7
23
|
filename: string;
|
|
24
|
+
/** The format to write. */
|
|
8
25
|
outputFormat: OutputFormat;
|
|
26
|
+
/** The splat data to write. */
|
|
9
27
|
dataTable: DataTable;
|
|
28
|
+
/** Optional environment/skybox splat data (for LOD format). */
|
|
10
29
|
envDataTable?: DataTable;
|
|
30
|
+
/** Processing options. */
|
|
11
31
|
options: Options;
|
|
32
|
+
/** Optional function to create a GPU device for compression. */
|
|
12
33
|
createDevice?: DeviceCreator;
|
|
13
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Determines the output format based on file extension and options.
|
|
37
|
+
*
|
|
38
|
+
* @param filename - The filename to analyze.
|
|
39
|
+
* @param options - Options that may affect format selection.
|
|
40
|
+
* @returns The detected output format.
|
|
41
|
+
* @throws Error if the file extension is not recognized.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const format = getOutputFormat('scene.ply', {}); // returns 'ply'
|
|
46
|
+
* const format2 = getOutputFormat('scene.sog', {}); // returns 'sog-bundle'
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
14
49
|
declare const getOutputFormat: (filename: string, options: Options) => OutputFormat;
|
|
50
|
+
/**
|
|
51
|
+
* Writes Gaussian splat data to a file in the specified format.
|
|
52
|
+
*
|
|
53
|
+
* Supports multiple output formats including PLY, compressed PLY, CSV, SOG, LOD, and HTML.
|
|
54
|
+
*
|
|
55
|
+
* @param writeOptions - Options specifying the data and format to write.
|
|
56
|
+
* @param fs - File system abstraction for writing files.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { writeFile, getOutputFormat, MemoryFileSystem } from '@playcanvas/splat-transform';
|
|
61
|
+
*
|
|
62
|
+
* const fs = new MemoryFileSystem();
|
|
63
|
+
* await writeFile({
|
|
64
|
+
* filename: 'output.sog',
|
|
65
|
+
* outputFormat: getOutputFormat('output.sog', {}),
|
|
66
|
+
* dataTable: myDataTable,
|
|
67
|
+
* options: { iterations: 8 }
|
|
68
|
+
* }, fs);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
15
71
|
declare const writeFile: (writeOptions: WriteOptions, fs: FileSystem) => Promise<void>;
|
|
16
|
-
export { getOutputFormat, writeFile, type OutputFormat };
|
|
72
|
+
export { getOutputFormat, writeFile, type OutputFormat, type WriteOptions };
|
|
@@ -4,5 +4,16 @@ type WriteCompressedPlyOptions = {
|
|
|
4
4
|
filename: string;
|
|
5
5
|
dataTable: DataTable;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Writes Gaussian splat data to compressed PLY format.
|
|
9
|
+
*
|
|
10
|
+
* Uses quantization and chunking to reduce file size while maintaining
|
|
11
|
+
* compatibility with PLY-based viewers. Data is sorted using Morton order
|
|
12
|
+
* for better compression and streaming performance.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Options including filename and data table to write.
|
|
15
|
+
* @param fs - File system for writing the output file.
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
7
18
|
declare const writeCompressedPly: (options: WriteCompressedPlyOptions, fs: FileSystem) => Promise<void>;
|
|
8
19
|
export { writeCompressedPly };
|
|
@@ -4,5 +4,15 @@ type WriteCSVOptions = {
|
|
|
4
4
|
filename: string;
|
|
5
5
|
dataTable: DataTable;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Writes Gaussian splat data to a CSV text file.
|
|
9
|
+
*
|
|
10
|
+
* Useful for debugging, analysis, or importing into spreadsheet applications.
|
|
11
|
+
* Each row represents one splat with all column values separated by commas.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Options including filename and data table to write.
|
|
14
|
+
* @param fs - File system for writing the output file.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
7
17
|
declare const writeCsv: (options: WriteCSVOptions, fs: FileSystem) => Promise<void>;
|
|
8
18
|
export { writeCsv };
|
|
@@ -9,5 +9,15 @@ type WriteHtmlOptions = {
|
|
|
9
9
|
iterations: number;
|
|
10
10
|
createDevice?: DeviceCreator;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Writes Gaussian splat data as a self-contained HTML viewer.
|
|
14
|
+
*
|
|
15
|
+
* Creates an interactive 3D viewer that can be opened directly in a browser.
|
|
16
|
+
* Uses the PlayCanvas SuperSplat viewer for rendering.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Options including filename, data, and viewer settings.
|
|
19
|
+
* @param fs - File system for writing output files.
|
|
20
|
+
* @ignore
|
|
21
|
+
*/
|
|
12
22
|
declare const writeHtml: (options: WriteHtmlOptions, fs: FileSystem) => Promise<void>;
|
|
13
23
|
export { writeHtml };
|
|
@@ -10,5 +10,16 @@ type WriteLodOptions = {
|
|
|
10
10
|
chunkCount: number;
|
|
11
11
|
chunkExtent: number;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Writes Gaussian splat data to multi-LOD format with spatial chunking.
|
|
15
|
+
*
|
|
16
|
+
* Creates a hierarchical structure with multiple LOD levels, each stored
|
|
17
|
+
* in separate SOG files. Includes spatial indexing via a binary tree for
|
|
18
|
+
* efficient streaming and view-dependent loading.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Options including filename, data, and chunking parameters.
|
|
21
|
+
* @param fs - File system for writing output files.
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
13
24
|
declare const writeLod: (options: WriteLodOptions, fs: FileSystem) => Promise<void>;
|
|
14
25
|
export { writeLod };
|
|
@@ -4,5 +4,15 @@ type WritePlyOptions = {
|
|
|
4
4
|
filename: string;
|
|
5
5
|
plyData: PlyData;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Writes Gaussian splat data to a binary PLY file.
|
|
9
|
+
*
|
|
10
|
+
* The PLY format is the standard output from 3D Gaussian Splatting training
|
|
11
|
+
* and is widely supported by visualization tools.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Options including filename and PLY data to write.
|
|
14
|
+
* @param fs - File system for writing the output file.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
7
17
|
declare const writePly: (options: WritePlyOptions, fs: FileSystem) => Promise<void>;
|
|
8
18
|
export { writePly };
|
|
@@ -2,8 +2,12 @@ import { GraphicsDevice } from 'playcanvas';
|
|
|
2
2
|
import { DataTable } from '../data-table/data-table';
|
|
3
3
|
import { type FileSystem } from '../io/write';
|
|
4
4
|
/**
|
|
5
|
-
* A function that creates a GraphicsDevice on demand.
|
|
5
|
+
* A function that creates a PlayCanvas GraphicsDevice on demand.
|
|
6
|
+
*
|
|
7
|
+
* Used for GPU-accelerated k-means clustering during SOG compression.
|
|
6
8
|
* The application is responsible for caching if needed.
|
|
9
|
+
*
|
|
10
|
+
* @returns Promise resolving to a GraphicsDevice instance.
|
|
7
11
|
*/
|
|
8
12
|
type DeviceCreator = () => Promise<GraphicsDevice>;
|
|
9
13
|
type WriteSogOptions = {
|
|
@@ -14,5 +18,16 @@ type WriteSogOptions = {
|
|
|
14
18
|
iterations: number;
|
|
15
19
|
createDevice?: DeviceCreator;
|
|
16
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Writes Gaussian splat data to the PlayCanvas SOG format.
|
|
23
|
+
*
|
|
24
|
+
* SOG (Splat Optimized Graphics) uses WebP lossless compression and k-means
|
|
25
|
+
* clustering to achieve high compression ratios. Data is stored in textures
|
|
26
|
+
* for efficient GPU loading.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Options including filename, data, and compression settings.
|
|
29
|
+
* @param fs - File system for writing output files.
|
|
30
|
+
* @ignore
|
|
31
|
+
*/
|
|
17
32
|
declare const writeSog: (options: WriteSogOptions, fs: FileSystem) => Promise<void>;
|
|
18
33
|
export { writeSog, type DeviceCreator };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/splat-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"author": "PlayCanvas<support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://playcanvas.com",
|
|
6
6
|
"description": "Library and CLI tool for 3D Gaussian splat format conversion and transformation",
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
"types": "dist/lib/index.d.ts",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"
|
|
22
|
-
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/lib/index.d.ts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/lib/index.d.cts",
|
|
27
|
+
"default": "./dist/index.cjs"
|
|
28
|
+
}
|
|
23
29
|
},
|
|
24
30
|
"./lib/*": "./lib/*"
|
|
25
31
|
},
|
|
@@ -57,13 +63,16 @@
|
|
|
57
63
|
"publint": "0.3.16",
|
|
58
64
|
"rollup": "4.54.0",
|
|
59
65
|
"tslib": "2.8.1",
|
|
66
|
+
"typedoc": "0.28.15",
|
|
67
|
+
"typedoc-plugin-mdn-links": "5.0.10",
|
|
60
68
|
"typescript": "5.9.3"
|
|
61
69
|
},
|
|
62
70
|
"peerDependencies": {
|
|
63
71
|
"playcanvas": ">=2.0.0"
|
|
64
72
|
},
|
|
65
73
|
"scripts": {
|
|
66
|
-
"build": "rollup -c",
|
|
74
|
+
"build": "rollup -c && node -e \"fs=require('fs');fs.copyFileSync('dist/lib/index.d.ts','dist/lib/index.d.cts')\"",
|
|
75
|
+
"docs": "typedoc",
|
|
67
76
|
"lint": "eslint src",
|
|
68
77
|
"lint:fix": "eslint src --fix",
|
|
69
78
|
"publint": "publint",
|