@playcanvas/splat-transform 1.8.3 → 1.9.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.
@@ -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 };
@@ -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/filter-visibility';
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, FilterVisibility } from './process';
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';
@@ -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/filter-visibility';
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, FilterVisibility } from './process';
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';
@@ -120,14 +120,15 @@ type MortonOrder = {
120
120
  kind: 'mortonOrder';
121
121
  };
122
122
  /**
123
- * Filter splats by visibility score, keeping only the most visible ones.
123
+ * Simplify splats to a target count using NanoGS progressive pairwise merging.
124
124
  *
125
- * Visibility is computed as: linear_opacity * volume
126
- * where opacity is converted from logit and scales from log space.
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 FilterVisibility = {
129
+ type Decimate = {
129
130
  /** Action type identifier. */
130
- kind: 'filterVisibility';
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
- * - `filterVisibility` - Keep only the most visible splats by opacity * volume
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 | FilterVisibility;
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 FilterVisibility };
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 };
@@ -14,5 +14,9 @@ declare class KdTree {
14
14
  distanceSqr: number;
15
15
  cnt: number;
16
16
  };
17
+ findKNearest(point: Float32Array, k: number, filterFunc?: (index: number) => boolean): {
18
+ indices: Int32Array<ArrayBuffer>;
19
+ distances: Float32Array<ArrayBuffer>;
20
+ };
17
21
  }
18
22
  export { KdTreeNode, KdTree };
@@ -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.8.3",
3
+ "version": "1.9.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",
@@ -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 };