@playcanvas/splat-transform 0.16.1 → 1.0.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.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +161 -2
  3. package/bin/cli.mjs +1 -1
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/node-device.d.ts +7 -0
  6. package/dist/cli/node-file-system.d.ts +16 -0
  7. package/dist/cli.mjs +16212 -0
  8. package/dist/cli.mjs.map +1 -0
  9. package/dist/index.mjs +1728 -61270
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/lib/data-table/combine.d.ts +3 -0
  12. package/dist/lib/data-table/data-table.d.ts +32 -0
  13. package/dist/lib/data-table/morton-order.d.ts +3 -0
  14. package/dist/lib/data-table/summary.d.ts +17 -0
  15. package/dist/lib/data-table/transform.d.ts +4 -0
  16. package/dist/lib/gpu/gpu-clustering.d.ts +8 -0
  17. package/dist/lib/index.d.ts +34 -0
  18. package/dist/lib/io/read/file-system.d.ts +91 -0
  19. package/dist/lib/io/read/index.d.ts +5 -0
  20. package/dist/lib/io/read/memory-file-system.d.ts +22 -0
  21. package/dist/lib/io/read/url-file-system.d.ts +14 -0
  22. package/dist/lib/io/read/zip-file-system.d.ts +51 -0
  23. package/dist/lib/io/write/crc.d.ts +7 -0
  24. package/dist/lib/io/write/file-system.d.ts +9 -0
  25. package/dist/lib/io/write/index.d.ts +4 -0
  26. package/dist/lib/io/write/memory-file-system.d.ts +7 -0
  27. package/dist/lib/io/write/write-helpers.d.ts +3 -0
  28. package/dist/lib/io/write/zip-file-system.d.ts +8 -0
  29. package/dist/lib/process.d.ts +52 -0
  30. package/dist/lib/read.d.ts +14 -0
  31. package/dist/lib/readers/decompress-ply.d.ts +5 -0
  32. package/dist/lib/readers/read-ksplat.d.ts +4 -0
  33. package/dist/lib/readers/read-lcc.d.ts +5 -0
  34. package/dist/lib/readers/read-mjs.d.ts +4 -0
  35. package/dist/lib/readers/read-ply.d.ts +11 -0
  36. package/dist/lib/readers/read-sog.d.ts +10 -0
  37. package/dist/lib/readers/read-splat.d.ts +4 -0
  38. package/dist/lib/readers/read-spz.d.ts +4 -0
  39. package/dist/lib/spatial/b-tree.d.ts +22 -0
  40. package/dist/lib/spatial/k-means.d.ts +7 -0
  41. package/dist/lib/spatial/kd-tree.d.ts +18 -0
  42. package/dist/lib/types.d.ts +25 -0
  43. package/dist/lib/utils/base64.d.ts +2 -0
  44. package/dist/lib/utils/logger.d.ts +66 -0
  45. package/dist/lib/utils/math.d.ts +2 -0
  46. package/dist/lib/utils/rotate-sh.d.ts +6 -0
  47. package/dist/lib/utils/webp-codec.d.ts +21 -0
  48. package/dist/lib/write.d.ts +16 -0
  49. package/dist/lib/writers/compressed-chunk.d.ts +14 -0
  50. package/dist/lib/writers/write-compressed-ply.d.ts +8 -0
  51. package/dist/lib/writers/write-csv.d.ts +8 -0
  52. package/dist/lib/writers/write-html.d.ts +13 -0
  53. package/dist/lib/writers/write-lod.d.ts +14 -0
  54. package/dist/lib/writers/write-ply.d.ts +8 -0
  55. package/dist/lib/writers/write-sog.d.ts +18 -0
  56. package/lib/BUILD.md +1 -1
  57. package/lib/webp.mjs +1 -1
  58. package/lib/webp.wasm +0 -0
  59. package/package.json +28 -12
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2025 PlayCanvas Ltd.
1
+ Copyright (c) 2011-2026 PlayCanvas Ltd.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -9,15 +9,18 @@
9
9
 
10
10
  | [User Guide](https://developer.playcanvas.com/user-manual/gaussian-splatting/editing/splat-transform/) | [Blog](https://blog.playcanvas.com/) | [Forum](https://forum.playcanvas.com/) |
11
11
 
12
- SplatTransform is an open source CLI tool for converting and editing Gaussian splats. It can:
12
+ SplatTransform is an open source library and CLI tool for converting and editing Gaussian splats. It can:
13
13
 
14
14
  📥 Read PLY, Compressed PLY, SOG, SPLAT, KSPLAT, SPZ and LCC formats
15
15
  📤 Write PLY, Compressed PLY, SOG, CSV, HTML Viewer and LOD (streaming) formats
16
+ 📊 Generate statistical summaries for data analysis
16
17
  🔗 Merge multiple splats
17
18
  🔄 Apply transformations to input splats
18
19
  🎛️ Filter out Gaussians or spherical harmonic bands
19
20
  ⚙️ Procedurally generate splats using JavaScript generators
20
21
 
22
+ The library is platform-agnostic and can be used in both Node.js and browser environments.
23
+
21
24
  ## Installation
22
25
 
23
26
  Install or update to the latest version:
@@ -26,7 +29,13 @@ Install or update to the latest version:
26
29
  npm install -g @playcanvas/splat-transform
27
30
  ```
28
31
 
29
- ## Usage
32
+ For library usage, install as a dependency:
33
+
34
+ ```bash
35
+ npm install @playcanvas/splat-transform
36
+ ```
37
+
38
+ ## CLI Usage
30
39
 
31
40
  ```bash
32
41
  splat-transform [GLOBAL] input [ACTIONS] ... output [ACTIONS]
@@ -35,6 +44,7 @@ splat-transform [GLOBAL] input [ACTIONS] ... output [ACTIONS]
35
44
  **Key points:**
36
45
  - Input files become the working set; ACTIONS are applied in order
37
46
  - The last file is the output; actions after it modify the final result
47
+ - Use `null` as output to discard file output
38
48
 
39
49
  ## Supported Formats
40
50
 
@@ -68,6 +78,7 @@ Actions can be repeated and applied in any order:
68
78
  cmp ∈ {lt,lte,gt,gte,eq,neq}
69
79
  -p, --params <key=val,...> Pass parameters to .mjs generator script
70
80
  -l, --lod <n> Specify the level of detail of this model, n >= 0.
81
+ -m, --summary Print per-column statistics to stdout
71
82
  ```
72
83
 
73
84
  ## Global Options
@@ -169,6 +180,23 @@ splat-transform -w cloudA.ply -r 0,90,0 cloudB.ply -s 2 merged.compressed.ply
169
180
  splat-transform input1.ply input2.ply output.ply -t 0,0,10 -s 0.5
170
181
  ```
171
182
 
183
+ ### Statistical Summary
184
+
185
+ Generate per-column statistics for data analysis or test validation:
186
+
187
+ ```bash
188
+ # Print summary, then write output
189
+ splat-transform input.ply --summary output.ply
190
+
191
+ # Print summary without writing a file (discard output)
192
+ splat-transform input.ply -m null
193
+
194
+ # Print summary before and after a transform
195
+ splat-transform input.ply --summary -s 0.5 --summary output.ply
196
+ ```
197
+
198
+ The summary includes min, max, median, mean, stdDev, nanCount and infCount for each column in the data.
199
+
172
200
  ### Generators (Beta)
173
201
 
174
202
  Generator scripts can be used to synthesize gaussian splat data. See [gen-grid.mjs](generators/gen-grid.mjs) for an example.
@@ -211,3 +239,134 @@ splat-transform --version
211
239
  # Show help
212
240
  splat-transform --help
213
241
  ```
242
+
243
+ ---
244
+
245
+ ## Library Usage
246
+
247
+ SplatTransform exposes a programmatic API for reading, processing, and writing Gaussian splat data.
248
+
249
+ ### Basic Import
250
+
251
+ ```typescript
252
+ import {
253
+ readFile,
254
+ writeFile,
255
+ getInputFormat,
256
+ getOutputFormat,
257
+ DataTable,
258
+ processDataTable
259
+ } from '@playcanvas/splat-transform';
260
+ ```
261
+
262
+ ### Key Exports
263
+
264
+ | Export | Description |
265
+ | ------ | ----------- |
266
+ | `readFile` | Read splat data from various formats |
267
+ | `writeFile` | Write splat data to various formats |
268
+ | `getInputFormat` | Detect input format from filename |
269
+ | `getOutputFormat` | Detect output format from filename |
270
+ | `DataTable`, `Column` | Core data structures for splat data |
271
+ | `combine` | Merge multiple DataTables into one |
272
+ | `transform` | Apply spatial transformations |
273
+ | `processDataTable` | Apply a sequence of processing actions |
274
+ | `computeSummary` | Generate statistical summary of data |
275
+
276
+ ### File System Abstractions
277
+
278
+ The library uses abstract file system interfaces for maximum flexibility:
279
+
280
+ **Reading:**
281
+ - `UrlReadFileSystem` - Read from URLs (browser/Node.js)
282
+ - `MemoryReadFileSystem` - Read from in-memory buffers
283
+ - `ZipReadFileSystem` - Read from ZIP archives
284
+
285
+ **Writing:**
286
+ - `MemoryFileSystem` - Write to in-memory buffers
287
+ - `ZipFileSystem` - Write to ZIP archives
288
+
289
+ ### Example: Reading and Processing
290
+
291
+ ```typescript
292
+ import { Vec3 } from 'playcanvas';
293
+ import {
294
+ readFile,
295
+ writeFile,
296
+ getInputFormat,
297
+ getOutputFormat,
298
+ processDataTable,
299
+ UrlReadFileSystem,
300
+ MemoryFileSystem
301
+ } from '@playcanvas/splat-transform';
302
+
303
+ // Read a PLY file from URL
304
+ const fileSystem = new UrlReadFileSystem();
305
+ const inputFormat = getInputFormat('scene.ply');
306
+
307
+ const dataTables = await readFile({
308
+ filename: 'https://example.com/scene.ply',
309
+ inputFormat,
310
+ options: { iterations: 10 },
311
+ params: [],
312
+ fileSystem
313
+ });
314
+
315
+ // Apply transformations
316
+ const processed = processDataTable(dataTables[0], [
317
+ { kind: 'scale', value: 0.5 },
318
+ { kind: 'translate', value: new Vec3(0, 1, 0) },
319
+ { kind: 'filterNaN' }
320
+ ]);
321
+
322
+ // Write to in-memory buffer
323
+ const memFs = new MemoryFileSystem();
324
+ const outputFormat = getOutputFormat('output.ply', {});
325
+
326
+ await writeFile({
327
+ filename: 'output.ply',
328
+ outputFormat,
329
+ dataTable: processed,
330
+ options: {}
331
+ }, memFs);
332
+
333
+ // Get the output data
334
+ const outputBuffer = memFs.files.get('output.ply');
335
+ ```
336
+
337
+ ### Processing Actions
338
+
339
+ The `processDataTable` function accepts an array of actions:
340
+
341
+ ```typescript
342
+ type ProcessAction =
343
+ | { kind: 'translate'; value: Vec3 }
344
+ | { kind: 'rotate'; value: Vec3 } // Euler angles in degrees
345
+ | { kind: 'scale'; value: number }
346
+ | { kind: 'filterNaN' }
347
+ | { kind: 'filterByValue'; columnName: string; comparator: 'lt'|'lte'|'gt'|'gte'|'eq'|'neq'; value: number }
348
+ | { kind: 'filterBands'; value: 0|1|2|3 }
349
+ | { kind: 'filterBox'; min: Vec3; max: Vec3 }
350
+ | { kind: 'filterSphere'; center: Vec3; radius: number }
351
+ | { kind: 'lod'; value: number }
352
+ | { kind: 'summary' };
353
+ ```
354
+
355
+ ### Custom Logging
356
+
357
+ Configure the logger for your environment:
358
+
359
+ ```typescript
360
+ import { logger } from '@playcanvas/splat-transform';
361
+
362
+ logger.setLogger({
363
+ log: console.log,
364
+ warn: console.warn,
365
+ error: console.error,
366
+ debug: console.debug,
367
+ progress: (text) => process.stdout.write(text),
368
+ output: console.log
369
+ });
370
+
371
+ logger.setQuiet(true); // Suppress non-error output
372
+ ```
package/bin/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { main } from '../dist/index.mjs';
3
+ import { main } from '../dist/cli.mjs';
4
4
 
5
5
  await main();
@@ -0,0 +1,2 @@
1
+ declare const main: () => Promise<never>;
2
+ export { main };
@@ -0,0 +1,7 @@
1
+ import { GraphicsDevice } from 'playcanvas';
2
+ declare const enumerateAdapters: () => Promise<{
3
+ index: number;
4
+ name: string;
5
+ }[]>;
6
+ declare const createDevice: (adapterName?: string) => Promise<GraphicsDevice>;
7
+ export { createDevice, enumerateAdapters };
@@ -0,0 +1,16 @@
1
+ import { type ReadFileSystem, type ProgressCallback, type ReadSource } from '../lib/io/read';
2
+ import { type FileSystem, type Writer } from '../lib/io/write';
3
+ /**
4
+ * ReadFileSystem for reading from the local filesystem using Node.js fs module.
5
+ */
6
+ declare class NodeReadFileSystem implements ReadFileSystem {
7
+ createSource(filename: string, progress?: ProgressCallback): Promise<ReadSource>;
8
+ }
9
+ /**
10
+ * FileSystem for writing to the local filesystem using Node.js fs module.
11
+ */
12
+ declare class NodeFileSystem implements FileSystem {
13
+ createWriter(filename: string): Promise<Writer>;
14
+ mkdir(path: string): Promise<void>;
15
+ }
16
+ export { NodeReadFileSystem, NodeFileSystem };