@playcanvas/splat-transform 1.8.3 → 1.9.1
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 +7 -6
- package/dist/cli.mjs +1309 -141
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +1294 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1293 -127
- package/dist/index.mjs.map +1 -1
- package/dist/lib/data-table/decimate.d.ts +14 -0
- package/dist/lib/index.d.cts +3 -2
- package/dist/lib/index.d.ts +3 -2
- package/dist/lib/process.d.ts +9 -8
- package/dist/lib/spatial/kd-tree.d.ts +5 -0
- package/dist/lib/utils/logger.d.ts +6 -0
- package/dist/lib/write.d.ts +2 -1
- package/dist/lib/writers/write-glb.d.ts +15 -0
- package/package.json +1 -1
- package/dist/lib/data-table/filter-visibility.d.ts +0 -17
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataTable } from './data-table';
|
|
2
|
+
declare const sortByVisibility: (dataTable: DataTable, indices: Uint32Array) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Simplifies a Gaussian splat DataTable to a target number of splats using the
|
|
5
|
+
* NanoGS progressive pairwise merging algorithm.
|
|
6
|
+
*
|
|
7
|
+
* Reference: "NanoGS: Training-Free Gaussian Splat Simplification" (Xiong et al.)
|
|
8
|
+
*
|
|
9
|
+
* @param dataTable - The input splat DataTable.
|
|
10
|
+
* @param targetCount - The desired number of output splats.
|
|
11
|
+
* @returns A new DataTable with approximately `targetCount` splats.
|
|
12
|
+
*/
|
|
13
|
+
declare const simplifyGaussians: (dataTable: DataTable, targetCount: number) => DataTable;
|
|
14
|
+
export { sortByVisibility, simplifyGaussians };
|
package/dist/lib/index.d.cts
CHANGED
|
@@ -5,13 +5,13 @@ export { transform } from './data-table/transform';
|
|
|
5
5
|
export { computeSummary } from './data-table/summary';
|
|
6
6
|
export type { ColumnStats, SummaryData } from './data-table/summary';
|
|
7
7
|
export { sortMortonOrder } from './data-table/morton-order';
|
|
8
|
-
export { sortByVisibility } from './data-table/
|
|
8
|
+
export { sortByVisibility, simplifyGaussians } from './data-table/decimate';
|
|
9
9
|
export { readFile, getInputFormat } from './read';
|
|
10
10
|
export type { InputFormat, ReadFileOptions } from './read';
|
|
11
11
|
export { writeFile, getOutputFormat } from './write';
|
|
12
12
|
export type { OutputFormat, WriteOptions } from './write';
|
|
13
13
|
export { processDataTable } from './process';
|
|
14
|
-
export type { ProcessAction, Translate, Rotate, Scale, FilterNaN, FilterByValue, FilterBands, FilterBox, FilterSphere, Param as ProcessParam, Lod, Summary, MortonOrder,
|
|
14
|
+
export type { ProcessAction, Translate, Rotate, Scale, FilterNaN, FilterByValue, FilterBands, FilterBox, FilterSphere, Param as ProcessParam, Lod, Summary, MortonOrder, Decimate } from './process';
|
|
15
15
|
export { ReadStream, BufferedReadStream, MemoryReadFileSystem, UrlReadFileSystem, ZipReadFileSystem } from './io/read';
|
|
16
16
|
export type { ReadSource, ReadFileSystem, ProgressCallback, ZipEntry } from './io/read';
|
|
17
17
|
export { MemoryFileSystem, ZipFileSystem } from './io/write';
|
|
@@ -31,6 +31,7 @@ export { writeCompressedPly } from './writers/write-compressed-ply';
|
|
|
31
31
|
export { writeCsv } from './writers/write-csv';
|
|
32
32
|
export { writeHtml } from './writers/write-html';
|
|
33
33
|
export { writeLod } from './writers/write-lod';
|
|
34
|
+
export { writeGlb } from './writers/write-glb';
|
|
34
35
|
export { writeVoxel } from './writers/write-voxel';
|
|
35
36
|
export type { WriteVoxelOptions, VoxelMetadata } from './writers/write-voxel';
|
|
36
37
|
export type { Options, Param } from './types';
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ export { transform } from './data-table/transform';
|
|
|
5
5
|
export { computeSummary } from './data-table/summary';
|
|
6
6
|
export type { ColumnStats, SummaryData } from './data-table/summary';
|
|
7
7
|
export { sortMortonOrder } from './data-table/morton-order';
|
|
8
|
-
export { sortByVisibility } from './data-table/
|
|
8
|
+
export { sortByVisibility, simplifyGaussians } from './data-table/decimate';
|
|
9
9
|
export { readFile, getInputFormat } from './read';
|
|
10
10
|
export type { InputFormat, ReadFileOptions } from './read';
|
|
11
11
|
export { writeFile, getOutputFormat } from './write';
|
|
12
12
|
export type { OutputFormat, WriteOptions } from './write';
|
|
13
13
|
export { processDataTable } from './process';
|
|
14
|
-
export type { ProcessAction, Translate, Rotate, Scale, FilterNaN, FilterByValue, FilterBands, FilterBox, FilterSphere, Param as ProcessParam, Lod, Summary, MortonOrder,
|
|
14
|
+
export type { ProcessAction, Translate, Rotate, Scale, FilterNaN, FilterByValue, FilterBands, FilterBox, FilterSphere, Param as ProcessParam, Lod, Summary, MortonOrder, Decimate } from './process';
|
|
15
15
|
export { ReadStream, BufferedReadStream, MemoryReadFileSystem, UrlReadFileSystem, ZipReadFileSystem } from './io/read';
|
|
16
16
|
export type { ReadSource, ReadFileSystem, ProgressCallback, ZipEntry } from './io/read';
|
|
17
17
|
export { MemoryFileSystem, ZipFileSystem } from './io/write';
|
|
@@ -31,6 +31,7 @@ export { writeCompressedPly } from './writers/write-compressed-ply';
|
|
|
31
31
|
export { writeCsv } from './writers/write-csv';
|
|
32
32
|
export { writeHtml } from './writers/write-html';
|
|
33
33
|
export { writeLod } from './writers/write-lod';
|
|
34
|
+
export { writeGlb } from './writers/write-glb';
|
|
34
35
|
export { writeVoxel } from './writers/write-voxel';
|
|
35
36
|
export type { WriteVoxelOptions, VoxelMetadata } from './writers/write-voxel';
|
|
36
37
|
export type { Options, Param } from './types';
|
package/dist/lib/process.d.ts
CHANGED
|
@@ -120,14 +120,15 @@ type MortonOrder = {
|
|
|
120
120
|
kind: 'mortonOrder';
|
|
121
121
|
};
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
123
|
+
* Simplify splats to a target count using NanoGS progressive pairwise merging.
|
|
124
124
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
125
|
+
* Instead of discarding low-visibility splats, this iteratively merges nearby
|
|
126
|
+
* similar splats into single approximating Gaussians using Mass-Preserving
|
|
127
|
+
* Moment Matching (MPMM), preserving scene structure and appearance.
|
|
127
128
|
*/
|
|
128
|
-
type
|
|
129
|
+
type Decimate = {
|
|
129
130
|
/** Action type identifier. */
|
|
130
|
-
kind: '
|
|
131
|
+
kind: 'decimate';
|
|
131
132
|
/** Target number of splats to keep, or null for percentage mode. */
|
|
132
133
|
count: number | null;
|
|
133
134
|
/** Percentage of splats to keep (0-100), or null for count mode. */
|
|
@@ -148,9 +149,9 @@ type FilterVisibility = {
|
|
|
148
149
|
* - `lod` - Assign LOD level to all splats
|
|
149
150
|
* - `summary` - Print statistical summary to logger
|
|
150
151
|
* - `mortonOrder` - Reorder splats by Morton code for spatial locality
|
|
151
|
-
* - `
|
|
152
|
+
* - `decimate` - Simplify to target count via progressive pairwise merging
|
|
152
153
|
*/
|
|
153
|
-
type ProcessAction = Translate | Rotate | Scale | FilterNaN | FilterByValue | FilterBands | FilterBox | FilterSphere | Param | Lod | Summary | MortonOrder |
|
|
154
|
+
type ProcessAction = Translate | Rotate | Scale | FilterNaN | FilterByValue | FilterBands | FilterBox | FilterSphere | Param | Lod | Summary | MortonOrder | Decimate;
|
|
154
155
|
/**
|
|
155
156
|
* Applies a sequence of processing actions to splat data.
|
|
156
157
|
*
|
|
@@ -175,4 +176,4 @@ type ProcessAction = Translate | Rotate | Scale | FilterNaN | FilterByValue | Fi
|
|
|
175
176
|
* ```
|
|
176
177
|
*/
|
|
177
178
|
declare const processDataTable: (dataTable: DataTable, processActions: ProcessAction[]) => DataTable;
|
|
178
|
-
export { processDataTable, type ProcessAction, type Translate, type Rotate, type Scale, type FilterNaN, type FilterByValue, type FilterBands, type FilterBox, type FilterSphere, type Param, type Lod, type Summary, type MortonOrder, type
|
|
179
|
+
export { processDataTable, type ProcessAction, type Translate, type Rotate, type Scale, type FilterNaN, type FilterByValue, type FilterBands, type FilterBox, type FilterSphere, type Param, type Lod, type Summary, type MortonOrder, type Decimate };
|
|
@@ -8,11 +8,16 @@ interface KdTreeNode {
|
|
|
8
8
|
declare class KdTree {
|
|
9
9
|
centroids: DataTable;
|
|
10
10
|
root: KdTreeNode;
|
|
11
|
+
private colData;
|
|
11
12
|
constructor(centroids: DataTable);
|
|
12
13
|
findNearest(point: Float32Array, filterFunc?: (index: number) => boolean): {
|
|
13
14
|
index: number;
|
|
14
15
|
distanceSqr: number;
|
|
15
16
|
cnt: number;
|
|
16
17
|
};
|
|
18
|
+
findKNearest(point: Float32Array, k: number, filterFunc?: (index: number) => boolean): {
|
|
19
|
+
indices: Int32Array<ArrayBuffer>;
|
|
20
|
+
distances: Float32Array<ArrayBuffer>;
|
|
21
|
+
};
|
|
17
22
|
}
|
|
18
23
|
export { KdTreeNode, KdTree };
|
|
@@ -43,6 +43,12 @@ declare class Progress {
|
|
|
43
43
|
* @param totalSteps - Total number of steps in the operation.
|
|
44
44
|
*/
|
|
45
45
|
begin(totalSteps: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Cancel the current progress node, popping it from the stack without
|
|
48
|
+
* completing remaining steps. Use this before early exits (e.g. break)
|
|
49
|
+
* to keep the progress stack balanced.
|
|
50
|
+
*/
|
|
51
|
+
cancel(): void;
|
|
46
52
|
/**
|
|
47
53
|
* Advance to the next step. Auto-increments the step counter.
|
|
48
54
|
* Auto-ends when all steps are complete.
|
package/dist/lib/write.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { type DeviceCreator } from './writers/write-sog';
|
|
|
7
7
|
*
|
|
8
8
|
* - `ply` - Standard PLY format
|
|
9
9
|
* - `compressed-ply` - Compressed PLY format
|
|
10
|
+
* - `glb` - Binary glTF with KHR_gaussian_splatting extension
|
|
10
11
|
* - `csv` - CSV text format (for debugging/analysis)
|
|
11
12
|
* - `sog` - PlayCanvas SOG format (separate files)
|
|
12
13
|
* - `sog-bundle` - PlayCanvas SOG format (bundled into single .sog file)
|
|
@@ -15,7 +16,7 @@ import { type DeviceCreator } from './writers/write-sog';
|
|
|
15
16
|
* - `html-bundle` - Self-contained HTML viewer (all assets embedded)
|
|
16
17
|
* - `voxel` - Sparse voxel octree format for collision detection
|
|
17
18
|
*/
|
|
18
|
-
type OutputFormat = 'csv' | 'sog' | 'sog-bundle' | 'lod' | 'compressed-ply' | 'ply' | 'html' | 'html-bundle' | 'voxel';
|
|
19
|
+
type OutputFormat = 'csv' | 'sog' | 'sog-bundle' | 'lod' | 'compressed-ply' | 'ply' | 'glb' | 'html' | 'html-bundle' | 'voxel';
|
|
19
20
|
/**
|
|
20
21
|
* Options for writing a Gaussian splat file.
|
|
21
22
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataTable } from '../data-table/data-table';
|
|
2
|
+
import { type FileSystem } from '../io/write';
|
|
3
|
+
type WriteGlbOptions = {
|
|
4
|
+
filename: string;
|
|
5
|
+
dataTable: DataTable;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Writes Gaussian splat data to a GLB file using the KHR_gaussian_splatting extension.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Options including filename and data table to write.
|
|
11
|
+
* @param fs - File system for writing the output file.
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
declare const writeGlb: (options: WriteGlbOptions, fs: FileSystem) => Promise<void>;
|
|
15
|
+
export { writeGlb };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/splat-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
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",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DataTable } from './data-table';
|
|
2
|
-
/**
|
|
3
|
-
* Sorts the provided indices by visibility score (descending order).
|
|
4
|
-
*
|
|
5
|
-
* Visibility is computed as: linear_opacity * volume
|
|
6
|
-
* where:
|
|
7
|
-
* - linear_opacity = sigmoid(opacity) = 1 / (1 + exp(-opacity))
|
|
8
|
-
* - volume = exp(scale_0) * exp(scale_1) * exp(scale_2)
|
|
9
|
-
*
|
|
10
|
-
* After calling this function, indices[0] will contain the index of the most
|
|
11
|
-
* visible splat, indices[1] the second most visible, and so on.
|
|
12
|
-
*
|
|
13
|
-
* @param dataTable - The DataTable containing splat data.
|
|
14
|
-
* @param indices - Array of indices to sort in-place.
|
|
15
|
-
*/
|
|
16
|
-
declare const sortByVisibility: (dataTable: DataTable, indices: Uint32Array) => void;
|
|
17
|
-
export { sortByVisibility };
|