@manycore/aholo-splat-transform 1.2.7-alpha.0 → 1.2.8
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/CHANGELOG.md +11 -0
- package/COPYRIGHT.md +17 -0
- package/README.md +9 -3
- package/THIRD_PARTY_LICENSES.txt +1373 -0
- package/bin/cli.js +3 -3
- package/dist/SplatData.js +6 -12
- package/dist/file/esz.d.ts +11 -0
- package/dist/file/esz.js +322 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +1 -0
- package/dist/file/ksplat.js +4 -5
- package/dist/file/lcc.js +5 -4
- package/dist/file/ply.js +8 -6
- package/dist/file/sog.js +8 -18
- package/dist/file/spz.d.ts +4 -1
- package/dist/file/spz.js +358 -175
- package/dist/native/cpp/bin/linux/binding.node +0 -0
- package/dist/native/cpp/bin/windows/binding.node +0 -0
- package/dist/native/index.js +4 -3
- package/dist/tasks/ReadTask.d.ts +1 -0
- package/dist/tasks/ReadTask.js +2 -2
- package/dist/tasks/WriteTask.d.ts +1 -0
- package/dist/tasks/WriteTask.js +6 -6
- package/dist/utils/BufferReader.js +2 -4
- package/dist/utils/Logger.js +4 -2
- package/dist/utils/StreamChunkDecoder.js +1 -6
- package/dist/utils/k-means.js +0 -9
- package/dist/utils/math.js +7 -12
- package/dist/utils/splat.d.ts +3 -2
- package/dist/utils/splat.js +12 -3
- package/dist/utils/voxel/common.js +10 -28
- package/dist/utils/voxel/gpu-dilation.js +3 -12
- package/package.json +13 -6
package/dist/tasks/WriteTask.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Writable } from 'node:stream';
|
|
|
4
4
|
import { SplatData } from '../SplatData.js';
|
|
5
5
|
import { createSplatFile, detectSplatFileType, SplatFileType } from '../utils/index.js';
|
|
6
6
|
import { BaseTask } from './BaseTask.js';
|
|
7
|
-
async function writeSplatFile(filepath, data, enableMortonSort, compressLevel) {
|
|
7
|
+
async function writeSplatFile(filepath, data, enableMortonSort, compressLevel, spzVersion) {
|
|
8
8
|
let indices;
|
|
9
9
|
if (!enableMortonSort) {
|
|
10
10
|
indices = new Uint32Array(data.counts);
|
|
@@ -12,17 +12,17 @@ async function writeSplatFile(filepath, data, enableMortonSort, compressLevel) {
|
|
|
12
12
|
indices[i] = i;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const file = createSplatFile(filepath, undefined, compressLevel);
|
|
15
|
+
const file = createSplatFile(filepath, undefined, compressLevel, spzVersion);
|
|
16
16
|
const stream = Writable.toWeb(fs.createWriteStream(filepath));
|
|
17
17
|
await file.write(stream, data, indices);
|
|
18
18
|
}
|
|
19
19
|
export class WriteTask extends BaseTask {
|
|
20
20
|
async exec(config, { logger, resources }) {
|
|
21
|
-
const { input, output, enableMortonSort = true, compressLevel } = config;
|
|
21
|
+
const { input, output, enableMortonSort = true, compressLevel, spzVersion } = config;
|
|
22
22
|
const source = resources.get(input);
|
|
23
23
|
if (source instanceof SplatData) {
|
|
24
24
|
logger.info(`writing splat -> file="${output}" count=${source.counts} SH=${source.shDegree}`);
|
|
25
|
-
await writeSplatFile(output, source, enableMortonSort, compressLevel);
|
|
25
|
+
await writeSplatFile(output, source, enableMortonSort, compressLevel, spzVersion);
|
|
26
26
|
logger.info(`writing done`);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@ export class WriteTask extends BaseTask {
|
|
|
30
30
|
fs.rmSync(output, { recursive: true });
|
|
31
31
|
logger.info(`exist dir ${output}, removed`);
|
|
32
32
|
}
|
|
33
|
-
fs.mkdirSync(output);
|
|
33
|
+
fs.mkdirSync(output, { recursive: true });
|
|
34
34
|
logger.info(`writing bundle -> dir="${output}" files=${source.length}`);
|
|
35
35
|
logger.silent = true;
|
|
36
36
|
const sogList = [];
|
|
@@ -51,7 +51,7 @@ export class WriteTask extends BaseTask {
|
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
53
|
logger.info(`- ${filepath} (${idx++}/${totals})`, true);
|
|
54
|
-
const promise = writeSplatFile(filepath, content, enableMortonSort && !preserveOrder, compressLevel);
|
|
54
|
+
const promise = writeSplatFile(filepath, content, enableMortonSort && !preserveOrder, compressLevel, spzVersion);
|
|
55
55
|
promises.push(promise);
|
|
56
56
|
}
|
|
57
57
|
await Promise.all(promises);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
export class BufferReader {
|
|
2
|
-
head = 0;
|
|
3
|
-
tail = 0;
|
|
4
|
-
buffer;
|
|
5
|
-
view;
|
|
6
2
|
get remaining() {
|
|
7
3
|
return this.tail - this.head;
|
|
8
4
|
}
|
|
9
5
|
constructor(buffer = new Uint8Array()) {
|
|
6
|
+
this.head = 0;
|
|
7
|
+
this.tail = 0;
|
|
10
8
|
this.buffer = buffer;
|
|
11
9
|
this.view = new DataView(this.buffer.buffer);
|
|
12
10
|
}
|
package/dist/utils/Logger.js
CHANGED
package/dist/utils/k-means.js
CHANGED
|
@@ -138,15 +138,6 @@ function interleaveData(result, dataTable, numRows, rowOffset) {
|
|
|
138
138
|
}
|
|
139
139
|
const MAX_CONCURRENCY_BATCHES = 10;
|
|
140
140
|
class GpuClustering {
|
|
141
|
-
device;
|
|
142
|
-
numPoints;
|
|
143
|
-
numColumns;
|
|
144
|
-
numCentroids;
|
|
145
|
-
batchSize;
|
|
146
|
-
resource;
|
|
147
|
-
numBatches;
|
|
148
|
-
concurrencyBatches;
|
|
149
|
-
concurrencyRuns;
|
|
150
141
|
constructor(device, numPoints, numColumns, numCentroids) {
|
|
151
142
|
this.device = device;
|
|
152
143
|
this.numPoints = numPoints;
|
package/dist/utils/math.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
export class Quaternion {
|
|
2
|
-
|
|
3
|
-
y;
|
|
4
|
-
z;
|
|
5
|
-
w;
|
|
6
|
-
static ONE = new Quaternion(0, 0, 0, 1);
|
|
2
|
+
static { this.ONE = new Quaternion(0, 0, 0, 1); }
|
|
7
3
|
constructor(x, y, z, w) {
|
|
8
4
|
this.x = x;
|
|
9
5
|
this.y = y;
|
|
@@ -101,10 +97,7 @@ export class Quaternion {
|
|
|
101
97
|
}
|
|
102
98
|
}
|
|
103
99
|
export class Vector3 {
|
|
104
|
-
|
|
105
|
-
y;
|
|
106
|
-
z;
|
|
107
|
-
static ONE = new Vector3(1, 1, 1);
|
|
100
|
+
static { this.ONE = new Vector3(1, 1, 1); }
|
|
108
101
|
constructor(x, y, z) {
|
|
109
102
|
this.x = x;
|
|
110
103
|
this.y = y;
|
|
@@ -142,9 +135,9 @@ export class Vector3 {
|
|
|
142
135
|
}
|
|
143
136
|
}
|
|
144
137
|
export class Matrix4 {
|
|
145
|
-
static ONE = new Matrix4();
|
|
146
|
-
elements = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
138
|
+
static { this.ONE = new Matrix4(); }
|
|
147
139
|
constructor(elements, isRow = false) {
|
|
140
|
+
this.elements = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
148
141
|
if (elements) {
|
|
149
142
|
this.set(elements);
|
|
150
143
|
}
|
|
@@ -327,7 +320,9 @@ export class Matrix4 {
|
|
|
327
320
|
}
|
|
328
321
|
}
|
|
329
322
|
export class Matrix3 {
|
|
330
|
-
|
|
323
|
+
constructor() {
|
|
324
|
+
this.elements = new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
325
|
+
}
|
|
331
326
|
set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
|
|
332
327
|
const te = this.elements;
|
|
333
328
|
te[0] = n11;
|
package/dist/utils/splat.d.ts
CHANGED
|
@@ -7,10 +7,11 @@ export declare enum SplatFileType {
|
|
|
7
7
|
SPLAT = 3,
|
|
8
8
|
KSPLAT = 4,
|
|
9
9
|
SOG = 5,
|
|
10
|
-
LCC = 6
|
|
10
|
+
LCC = 6,
|
|
11
|
+
ESZ = 7
|
|
11
12
|
}
|
|
12
13
|
export declare function detectSplatFileType(filename: string, buffer?: Uint8Array): SplatFileType | undefined;
|
|
13
|
-
export declare function createSplatFile(path: string, buffer?: Uint8Array, compressLevel?: number): IFile;
|
|
14
|
+
export declare function createSplatFile(path: string, buffer?: Uint8Array, compressLevel?: number, spzVersion?: number): IFile;
|
|
14
15
|
export declare function combineSplatData(source: SplatData[]): SplatData;
|
|
15
16
|
export declare function computeDenseBox(data: SplatData, ratio?: number): {
|
|
16
17
|
min: number[];
|
package/dist/utils/splat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unzipSync } from 'fflate';
|
|
2
|
-
import { PlyFile, SpzFile, KsplatFile, SplatFile, SogFile, LccFile } from '../file/index.js';
|
|
2
|
+
import { PlyFile, SpzFile, KsplatFile, SplatFile, SogFile, LccFile, EszFile } from '../file/index.js';
|
|
3
3
|
import { SplatData } from '../SplatData.js';
|
|
4
4
|
import { SH_MAPS } from '../constant.js';
|
|
5
5
|
export var SplatFileType;
|
|
@@ -11,6 +11,7 @@ export var SplatFileType;
|
|
|
11
11
|
SplatFileType[SplatFileType["KSPLAT"] = 4] = "KSPLAT";
|
|
12
12
|
SplatFileType[SplatFileType["SOG"] = 5] = "SOG";
|
|
13
13
|
SplatFileType[SplatFileType["LCC"] = 6] = "LCC";
|
|
14
|
+
SplatFileType[SplatFileType["ESZ"] = 7] = "ESZ";
|
|
14
15
|
})(SplatFileType || (SplatFileType = {}));
|
|
15
16
|
export function detectSplatFileType(filename, buffer = new Uint8Array()) {
|
|
16
17
|
let ext = filename.split('.').pop();
|
|
@@ -66,13 +67,17 @@ export function detectSplatFileType(filename, buffer = new Uint8Array()) {
|
|
|
66
67
|
type = SplatFileType.LCC;
|
|
67
68
|
break;
|
|
68
69
|
}
|
|
70
|
+
case 'esz': {
|
|
71
|
+
type = SplatFileType.ESZ;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
69
74
|
default: {
|
|
70
75
|
break;
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
return type;
|
|
74
79
|
}
|
|
75
|
-
export function createSplatFile(path, buffer = new Uint8Array(), compressLevel = 6) {
|
|
80
|
+
export function createSplatFile(path, buffer = new Uint8Array(), compressLevel = 6, spzVersion = 3) {
|
|
76
81
|
const type = detectSplatFileType(path, buffer);
|
|
77
82
|
if (type === undefined) {
|
|
78
83
|
throw new Error(`Unsupported file format: ${path}`);
|
|
@@ -84,7 +89,7 @@ export function createSplatFile(path, buffer = new Uint8Array(), compressLevel =
|
|
|
84
89
|
break;
|
|
85
90
|
}
|
|
86
91
|
case SplatFileType.SPZ: {
|
|
87
|
-
file = new SpzFile(compressLevel);
|
|
92
|
+
file = new SpzFile(compressLevel, spzVersion);
|
|
88
93
|
break;
|
|
89
94
|
}
|
|
90
95
|
case SplatFileType.USPZ: {
|
|
@@ -107,6 +112,10 @@ export function createSplatFile(path, buffer = new Uint8Array(), compressLevel =
|
|
|
107
112
|
file = new LccFile();
|
|
108
113
|
break;
|
|
109
114
|
}
|
|
115
|
+
case SplatFileType.ESZ: {
|
|
116
|
+
file = new EszFile();
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
110
119
|
}
|
|
111
120
|
return file;
|
|
112
121
|
}
|
|
@@ -163,12 +163,7 @@ const quickselect = (axisData, idx, k) => {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
export class GaussianBVH {
|
|
166
|
-
static MAX_LEAF_SIZE = 64;
|
|
167
|
-
x;
|
|
168
|
-
y;
|
|
169
|
-
z;
|
|
170
|
-
extents;
|
|
171
|
-
root;
|
|
166
|
+
static { this.MAX_LEAF_SIZE = 64; }
|
|
172
167
|
constructor(x, y, z, extents) {
|
|
173
168
|
this.x = x;
|
|
174
169
|
this.y = y;
|
|
@@ -323,13 +318,15 @@ const growUint32 = (src, newCap) => {
|
|
|
323
318
|
* the grid dimensions; the buffer itself is dimension-agnostic.
|
|
324
319
|
*/
|
|
325
320
|
export class BlockMaskBuffer {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
321
|
+
constructor() {
|
|
322
|
+
this.solidIdx = new Float64Array(0);
|
|
323
|
+
this.solidCountValue = 0;
|
|
324
|
+
this.solidCap = 0;
|
|
325
|
+
this.mixedIdx = new Float64Array(0);
|
|
326
|
+
this.mixedCountValue = 0;
|
|
327
|
+
this.mixedCap = 0;
|
|
328
|
+
this.mixedMasks = new Uint32Array(0);
|
|
329
|
+
}
|
|
333
330
|
addBlock(blockIdx, lo, hi) {
|
|
334
331
|
if ((lo | hi) === 0) {
|
|
335
332
|
return;
|
|
@@ -399,12 +396,6 @@ const writeBlockType = (types, blockIdx, blockType) => {
|
|
|
399
396
|
};
|
|
400
397
|
const EMPTY = -1;
|
|
401
398
|
class BlockMaskMap {
|
|
402
|
-
keys;
|
|
403
|
-
lo;
|
|
404
|
-
hi;
|
|
405
|
-
_size;
|
|
406
|
-
_capacity;
|
|
407
|
-
_mask;
|
|
408
399
|
constructor(initialCapacity = 4096) {
|
|
409
400
|
const cap = 1 << (32 - Math.clz32(Math.max(15, initialCapacity - 1)));
|
|
410
401
|
this._capacity = cap;
|
|
@@ -504,15 +495,6 @@ class BlockMaskMap {
|
|
|
504
495
|
}
|
|
505
496
|
}
|
|
506
497
|
class SparseVoxelGrid {
|
|
507
|
-
nx;
|
|
508
|
-
ny;
|
|
509
|
-
nz;
|
|
510
|
-
nbx;
|
|
511
|
-
nby;
|
|
512
|
-
nbz;
|
|
513
|
-
bStride;
|
|
514
|
-
types;
|
|
515
|
-
masks;
|
|
516
498
|
constructor(nx, ny, nz) {
|
|
517
499
|
this.nx = nx;
|
|
518
500
|
this.ny = ny;
|
|
@@ -356,19 +356,10 @@ const applyChunkToDst = (dst, typesOut, masksOut, cx, cy, cz, innerNx, innerNy,
|
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
358
|
class GpuDilation {
|
|
359
|
-
|
|
360
|
-
extractPipeline;
|
|
361
|
-
compactPipeline;
|
|
362
|
-
dilateXPipeline;
|
|
363
|
-
dilateYZPipeline;
|
|
364
|
-
slots = [];
|
|
365
|
-
srcTypesBuffer;
|
|
366
|
-
srcKeysBuffer;
|
|
367
|
-
srcLoBuffer;
|
|
368
|
-
srcHiBuffer;
|
|
369
|
-
srcMeta = { nbx: 0, nby: 0, nbz: 0, bStride: 0, capMinusOne: 0 };
|
|
370
|
-
static NUM_SLOTS = 2;
|
|
359
|
+
static { this.NUM_SLOTS = 2; }
|
|
371
360
|
constructor(device) {
|
|
361
|
+
this.slots = [];
|
|
362
|
+
this.srcMeta = { nbx: 0, nby: 0, nbz: 0, bStride: 0, capMinusOne: 0 };
|
|
372
363
|
this.device = device;
|
|
373
364
|
this.extractPipeline = createStoragePipeline(device, extractWgsl());
|
|
374
365
|
this.compactPipeline = createStoragePipeline(device, compactWgsl());
|
package/package.json
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manycore/aholo-splat-transform",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Transform & filter Gaussian splats file",
|
|
5
5
|
"author": "egs",
|
|
6
|
+
"repository": "https://github.com/manycoretech/aholo-viewer.git",
|
|
6
7
|
"license": "UNLICENSED",
|
|
7
8
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
9
|
+
"node": ">= 22.22.1"
|
|
9
10
|
},
|
|
10
11
|
"type": "module",
|
|
11
12
|
"bin": {
|
|
12
13
|
"splat-transform": "bin/cli.js"
|
|
13
14
|
},
|
|
15
|
+
"os": [
|
|
16
|
+
"win32",
|
|
17
|
+
"linux"
|
|
18
|
+
],
|
|
19
|
+
"cpu": [
|
|
20
|
+
"x64"
|
|
21
|
+
],
|
|
14
22
|
"files": [
|
|
15
23
|
"dist/",
|
|
16
|
-
"CHANGELOG.md"
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"COPYRIGHT.md",
|
|
26
|
+
"THIRD_PARTY_LICENSES.txt"
|
|
17
27
|
],
|
|
18
28
|
"dependencies": {
|
|
19
|
-
"cmake-js": "^8.0.0",
|
|
20
29
|
"commander": "^14.0.2",
|
|
21
30
|
"fflate": "^0.8.2",
|
|
22
|
-
"fs-extra": "^11.3.3",
|
|
23
|
-
"node-addon-api": "^8.6.0",
|
|
24
31
|
"tslib": "^2.8.1",
|
|
25
32
|
"webgpu": "^0.4.0"
|
|
26
33
|
},
|