@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.
- package/LICENSE +1 -1
- package/README.md +161 -2
- package/bin/cli.mjs +1 -1
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/node-device.d.ts +7 -0
- package/dist/cli/node-file-system.d.ts +16 -0
- package/dist/cli.mjs +16212 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.mjs +1728 -61270
- package/dist/index.mjs.map +1 -1
- package/dist/lib/data-table/combine.d.ts +3 -0
- package/dist/lib/data-table/data-table.d.ts +32 -0
- package/dist/lib/data-table/morton-order.d.ts +3 -0
- package/dist/lib/data-table/summary.d.ts +17 -0
- package/dist/lib/data-table/transform.d.ts +4 -0
- package/dist/lib/gpu/gpu-clustering.d.ts +8 -0
- package/dist/lib/index.d.ts +34 -0
- package/dist/lib/io/read/file-system.d.ts +91 -0
- package/dist/lib/io/read/index.d.ts +5 -0
- package/dist/lib/io/read/memory-file-system.d.ts +22 -0
- package/dist/lib/io/read/url-file-system.d.ts +14 -0
- package/dist/lib/io/read/zip-file-system.d.ts +51 -0
- package/dist/lib/io/write/crc.d.ts +7 -0
- package/dist/lib/io/write/file-system.d.ts +9 -0
- package/dist/lib/io/write/index.d.ts +4 -0
- package/dist/lib/io/write/memory-file-system.d.ts +7 -0
- package/dist/lib/io/write/write-helpers.d.ts +3 -0
- package/dist/lib/io/write/zip-file-system.d.ts +8 -0
- package/dist/lib/process.d.ts +52 -0
- package/dist/lib/read.d.ts +14 -0
- package/dist/lib/readers/decompress-ply.d.ts +5 -0
- package/dist/lib/readers/read-ksplat.d.ts +4 -0
- package/dist/lib/readers/read-lcc.d.ts +5 -0
- package/dist/lib/readers/read-mjs.d.ts +4 -0
- package/dist/lib/readers/read-ply.d.ts +11 -0
- package/dist/lib/readers/read-sog.d.ts +10 -0
- package/dist/lib/readers/read-splat.d.ts +4 -0
- package/dist/lib/readers/read-spz.d.ts +4 -0
- package/dist/lib/spatial/b-tree.d.ts +22 -0
- package/dist/lib/spatial/k-means.d.ts +7 -0
- package/dist/lib/spatial/kd-tree.d.ts +18 -0
- package/dist/lib/types.d.ts +25 -0
- package/dist/lib/utils/base64.d.ts +2 -0
- package/dist/lib/utils/logger.d.ts +66 -0
- package/dist/lib/utils/math.d.ts +2 -0
- package/dist/lib/utils/rotate-sh.d.ts +6 -0
- package/dist/lib/utils/webp-codec.d.ts +21 -0
- package/dist/lib/write.d.ts +16 -0
- package/dist/lib/writers/compressed-chunk.d.ts +14 -0
- package/dist/lib/writers/write-compressed-ply.d.ts +8 -0
- package/dist/lib/writers/write-csv.d.ts +8 -0
- package/dist/lib/writers/write-html.d.ts +13 -0
- package/dist/lib/writers/write-lod.d.ts +14 -0
- package/dist/lib/writers/write-ply.d.ts +8 -0
- package/dist/lib/writers/write-sog.d.ts +18 -0
- package/lib/BUILD.md +1 -1
- package/lib/webp.mjs +1 -1
- package/lib/webp.wasm +0 -0
- package/package.json +28 -12
package/LICENSE
CHANGED
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
|
-
|
|
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
|
@@ -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 };
|