@manycore/aholo-splat-transform 1.2.7 → 1.2.9
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 +120 -106
- package/COPYRIGHT.md +17 -0
- package/README.md +39 -39
- package/THIRD_PARTY_LICENSES.txt +1373 -0
- package/bin/cli.js +125 -118
- package/dist/SplatData.d.ts +67 -67
- package/dist/SplatData.js +167 -156
- package/dist/constant.d.ts +3 -3
- package/dist/constant.js +13 -13
- package/dist/file/IFile.d.ts +5 -5
- package/dist/file/IFile.js +1 -1
- package/dist/file/esz.d.ts +11 -0
- package/dist/file/esz.js +337 -0
- package/dist/file/index.d.ts +8 -7
- package/dist/file/index.js +7 -6
- package/dist/file/ksplat.d.ts +12 -12
- package/dist/file/ksplat.js +293 -232
- package/dist/file/lcc.d.ts +11 -11
- package/dist/file/lcc.js +161 -157
- package/dist/file/ply.d.ts +13 -13
- package/dist/file/ply.js +439 -388
- package/dist/file/sog.d.ts +80 -80
- package/dist/file/sog.js +525 -504
- package/dist/file/splat.d.ts +6 -6
- package/dist/file/splat.js +119 -99
- package/dist/file/spz.d.ts +11 -8
- package/dist/file/spz.js +597 -400
- package/dist/file/voxel.d.ts +43 -37
- package/dist/file/voxel.js +411 -280
- package/dist/index.d.ts +33 -33
- package/dist/index.js +54 -54
- package/dist/native/index.d.ts +54 -54
- package/dist/native/index.js +122 -128
- package/dist/native/utils.d.ts +1 -0
- package/dist/native/utils.js +54 -0
- package/dist/tasks/AutoChunkLodTask.d.ts +13 -13
- package/dist/tasks/AutoChunkLodTask.js +117 -117
- package/dist/tasks/AutoLodTask.d.ts +10 -10
- package/dist/tasks/AutoLodTask.js +20 -20
- package/dist/tasks/BaseTask.d.ts +15 -15
- package/dist/tasks/BaseTask.js +5 -5
- package/dist/tasks/FlexLodTask.d.ts +12 -12
- package/dist/tasks/FlexLodTask.js +54 -44
- package/dist/tasks/ModifyTask.d.ts +9 -9
- package/dist/tasks/ModifyTask.js +166 -156
- package/dist/tasks/ReadTask.d.ts +9 -9
- package/dist/tasks/ReadTask.js +29 -29
- package/dist/tasks/SkeletonLodTask.d.ts +10 -10
- package/dist/tasks/SkeletonLodTask.js +176 -156
- package/dist/tasks/VoxelTask.d.ts +35 -30
- package/dist/tasks/VoxelTask.js +40 -37
- package/dist/tasks/WriteTask.d.ts +12 -11
- package/dist/tasks/WriteTask.js +70 -70
- package/dist/utils/BufferReader.d.ts +12 -12
- package/dist/utils/BufferReader.js +45 -47
- package/dist/utils/Logger.d.ts +11 -11
- package/dist/utils/Logger.js +40 -38
- package/dist/utils/StreamChunkDecoder.d.ts +16 -16
- package/dist/utils/StreamChunkDecoder.js +31 -36
- package/dist/utils/index.d.ts +27 -27
- package/dist/utils/index.js +101 -101
- package/dist/utils/k-means.d.ts +4 -4
- package/dist/utils/k-means.js +340 -350
- package/dist/utils/math.d.ts +46 -46
- package/dist/utils/math.js +350 -351
- package/dist/utils/quantize-1d.d.ts +4 -4
- package/dist/utils/quantize-1d.js +164 -164
- package/dist/utils/sh-rotate.d.ts +2 -2
- package/dist/utils/sh-rotate.js +236 -175
- package/dist/utils/splat.d.ts +21 -20
- package/dist/utils/splat.js +397 -378
- package/dist/utils/voxel/binary.d.ts +8 -0
- package/dist/utils/voxel/binary.js +176 -0
- package/dist/utils/voxel/common.d.ts +178 -162
- package/dist/utils/voxel/common.js +1752 -1700
- package/dist/utils/voxel/coplanar-merge.d.ts +63 -63
- package/dist/utils/voxel/coplanar-merge.js +818 -819
- package/dist/utils/voxel/filter-cluster.d.ts +20 -0
- package/dist/utils/voxel/filter-cluster.js +628 -0
- package/dist/utils/voxel/gpu-dilation.d.ts +2 -2
- package/dist/utils/voxel/gpu-dilation.js +677 -665
- package/dist/utils/voxel/marching-cubes.d.ts +42 -42
- package/dist/utils/voxel/marching-cubes.js +1645 -1657
- package/dist/utils/voxel/mesh.d.ts +3 -3
- package/dist/utils/voxel/mesh.js +130 -130
- package/dist/utils/voxel/nav.d.ts +29 -29
- package/dist/utils/voxel/nav.js +1068 -1043
- package/dist/utils/voxel/postprocess.d.ts +23 -23
- package/dist/utils/voxel/postprocess.js +408 -375
- package/dist/utils/voxel/voxel-faces.d.ts +18 -18
- package/dist/utils/voxel/voxel-faces.js +662 -663
- package/dist/utils/voxel/voxelize.d.ts +34 -33
- package/dist/utils/voxel/voxelize.js +1208 -1193
- package/dist/utils/webgpu.d.ts +8 -8
- package/dist/utils/webgpu.js +122 -122
- package/package.json +37 -30
- package/dist/native/cpp/bin/linux/binding.node +0 -0
- package/dist/native/cpp/bin/windows/binding.node +0 -0
package/dist/tasks/ModifyTask.js
CHANGED
|
@@ -1,156 +1,166 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { createSHRotateFn, fastDeleteSplat, Matrix3, Matrix4, Quaternion, Vector3 } from '../utils/index.js';
|
|
3
|
-
import { BaseTask } from './BaseTask.js';
|
|
4
|
-
async function createSplatModify(path, counts) {
|
|
5
|
-
if (!path) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
const { isRowMatrix = true, transform, deletedIndices: deletedIndicesBitMap = [], indicesTransform = [], } = JSON.parse(fs.readFileSync(path, 'utf-8'));
|
|
9
|
-
const used = new Uint8Array(counts);
|
|
10
|
-
let usedCounts = 0;
|
|
11
|
-
const deletedIndices = [];
|
|
12
|
-
for (let i = 0; i < deletedIndicesBitMap.length; i++) {
|
|
13
|
-
const v = deletedIndicesBitMap[i];
|
|
14
|
-
for (let j = 0; j < 8; j++) {
|
|
15
|
-
if (v & (1 << j)) {
|
|
16
|
-
const idx = i * 8 + j;
|
|
17
|
-
deletedIndices.push(idx);
|
|
18
|
-
used[idx] = 1;
|
|
19
|
-
usedCounts++;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const groupIndices = [];
|
|
24
|
-
const groupTransforms = [];
|
|
25
|
-
const modelMatrix = new Matrix4(transform, isRowMatrix);
|
|
26
|
-
const transforms = indicesTransform.map(v => new Matrix4(v.transform, isRowMatrix).multiply(modelMatrix));
|
|
27
|
-
for (let i = 0; i < transforms.length; i++) {
|
|
28
|
-
const { indices } = indicesTransform[i];
|
|
29
|
-
for (let j = 0; j < indices.length; j++) {
|
|
30
|
-
used[indices[j]] = 1;
|
|
31
|
-
}
|
|
32
|
-
usedCounts += indices.length;
|
|
33
|
-
const matrix = transforms[i];
|
|
34
|
-
if (matrix.equals(Matrix4.ONE)) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
const scale = new Vector3(1, 1, 1);
|
|
38
|
-
const quat = new Quaternion(0, 0, 0, 1);
|
|
39
|
-
matrix.decompose(new Vector3(1, 1, 1), quat, scale);
|
|
40
|
-
groupIndices.push(indices);
|
|
41
|
-
groupTransforms.push({
|
|
42
|
-
isScale: !scale.equals(Vector3.ONE),
|
|
43
|
-
isRotate: !quat.equals(Quaternion.ONE),
|
|
44
|
-
matrix,
|
|
45
|
-
scale,
|
|
46
|
-
quat,
|
|
47
|
-
shRotateFn: createSHRotateFn(new Matrix3().setFromMatrix4(new Matrix4().compose(new Vector3(0, 0, 0), quat, new Vector3(1, 1, 1)))),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (!modelMatrix.equals(Matrix4.ONE)) {
|
|
51
|
-
const indices = new Array(counts - usedCounts);
|
|
52
|
-
for (let i = 0; i < used.length; i++) {
|
|
53
|
-
if (used[i]) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
indices.push(i);
|
|
57
|
-
}
|
|
58
|
-
const matrix = modelMatrix;
|
|
59
|
-
const scale = new Vector3(1, 1, 1);
|
|
60
|
-
const quat = new Quaternion(0, 0, 0, 1);
|
|
61
|
-
matrix.decompose(new Vector3(1, 1, 1), quat, scale);
|
|
62
|
-
groupIndices.unshift(indices);
|
|
63
|
-
groupTransforms.unshift({
|
|
64
|
-
isScale: !scale.equals(Vector3.ONE),
|
|
65
|
-
isRotate: !quat.equals(Quaternion.ONE),
|
|
66
|
-
matrix,
|
|
67
|
-
scale,
|
|
68
|
-
quat,
|
|
69
|
-
shRotateFn: createSHRotateFn(new Matrix3().setFromMatrix4(new Matrix4().compose(new Vector3(0, 0, 0), quat, new Vector3(1, 1, 1)))),
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
deletedIndices,
|
|
74
|
-
groupIndices,
|
|
75
|
-
groupTransforms,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export class ModifyTask extends BaseTask {
|
|
79
|
-
async exec(config, { logger, resources }) {
|
|
80
|
-
const { input, modifyPaths = [], output } = config;
|
|
81
|
-
const splat = resources.get(input);
|
|
82
|
-
logger.info(`loaded -> "${input}"`);
|
|
83
|
-
const modifies = await Promise.all(modifyPaths.map((p, i) => createSplatModify(p, splat.blockContentCounts[i])));
|
|
84
|
-
const tempVec = new Vector3(0, 0, 0);
|
|
85
|
-
const tempQuat = new Quaternion(0, 0, 0, 1);
|
|
86
|
-
const single = {
|
|
87
|
-
x: 0,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
single.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
splat.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { createSHRotateFn, fastDeleteSplat, Matrix3, Matrix4, Quaternion, Vector3 } from '../utils/index.js';
|
|
3
|
+
import { BaseTask } from './BaseTask.js';
|
|
4
|
+
async function createSplatModify(path, counts) {
|
|
5
|
+
if (!path) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const { isRowMatrix = true, transform, deletedIndices: deletedIndicesBitMap = [], indicesTransform = [], } = JSON.parse(fs.readFileSync(path, 'utf-8'));
|
|
9
|
+
const used = new Uint8Array(counts);
|
|
10
|
+
let usedCounts = 0;
|
|
11
|
+
const deletedIndices = [];
|
|
12
|
+
for (let i = 0; i < deletedIndicesBitMap.length; i++) {
|
|
13
|
+
const v = deletedIndicesBitMap[i];
|
|
14
|
+
for (let j = 0; j < 8; j++) {
|
|
15
|
+
if (v & (1 << j)) {
|
|
16
|
+
const idx = i * 8 + j;
|
|
17
|
+
deletedIndices.push(idx);
|
|
18
|
+
used[idx] = 1;
|
|
19
|
+
usedCounts++;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const groupIndices = [];
|
|
24
|
+
const groupTransforms = [];
|
|
25
|
+
const modelMatrix = new Matrix4(transform, isRowMatrix);
|
|
26
|
+
const transforms = indicesTransform.map(v => new Matrix4(v.transform, isRowMatrix).multiply(modelMatrix));
|
|
27
|
+
for (let i = 0; i < transforms.length; i++) {
|
|
28
|
+
const { indices } = indicesTransform[i];
|
|
29
|
+
for (let j = 0; j < indices.length; j++) {
|
|
30
|
+
used[indices[j]] = 1;
|
|
31
|
+
}
|
|
32
|
+
usedCounts += indices.length;
|
|
33
|
+
const matrix = transforms[i];
|
|
34
|
+
if (matrix.equals(Matrix4.ONE)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const scale = new Vector3(1, 1, 1);
|
|
38
|
+
const quat = new Quaternion(0, 0, 0, 1);
|
|
39
|
+
matrix.decompose(new Vector3(1, 1, 1), quat, scale);
|
|
40
|
+
groupIndices.push(indices);
|
|
41
|
+
groupTransforms.push({
|
|
42
|
+
isScale: !scale.equals(Vector3.ONE),
|
|
43
|
+
isRotate: !quat.equals(Quaternion.ONE),
|
|
44
|
+
matrix,
|
|
45
|
+
scale,
|
|
46
|
+
quat,
|
|
47
|
+
shRotateFn: createSHRotateFn(new Matrix3().setFromMatrix4(new Matrix4().compose(new Vector3(0, 0, 0), quat, new Vector3(1, 1, 1)))),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (!modelMatrix.equals(Matrix4.ONE)) {
|
|
51
|
+
const indices = new Array(counts - usedCounts);
|
|
52
|
+
for (let i = 0; i < used.length; i++) {
|
|
53
|
+
if (used[i]) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
indices.push(i);
|
|
57
|
+
}
|
|
58
|
+
const matrix = modelMatrix;
|
|
59
|
+
const scale = new Vector3(1, 1, 1);
|
|
60
|
+
const quat = new Quaternion(0, 0, 0, 1);
|
|
61
|
+
matrix.decompose(new Vector3(1, 1, 1), quat, scale);
|
|
62
|
+
groupIndices.unshift(indices);
|
|
63
|
+
groupTransforms.unshift({
|
|
64
|
+
isScale: !scale.equals(Vector3.ONE),
|
|
65
|
+
isRotate: !quat.equals(Quaternion.ONE),
|
|
66
|
+
matrix,
|
|
67
|
+
scale,
|
|
68
|
+
quat,
|
|
69
|
+
shRotateFn: createSHRotateFn(new Matrix3().setFromMatrix4(new Matrix4().compose(new Vector3(0, 0, 0), quat, new Vector3(1, 1, 1)))),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
deletedIndices,
|
|
74
|
+
groupIndices,
|
|
75
|
+
groupTransforms,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export class ModifyTask extends BaseTask {
|
|
79
|
+
async exec(config, { logger, resources }) {
|
|
80
|
+
const { input, modifyPaths = [], output } = config;
|
|
81
|
+
const splat = resources.get(input);
|
|
82
|
+
logger.info(`loaded -> "${input}"`);
|
|
83
|
+
const modifies = await Promise.all(modifyPaths.map((p, i) => createSplatModify(p, splat.blockContentCounts[i])));
|
|
84
|
+
const tempVec = new Vector3(0, 0, 0);
|
|
85
|
+
const tempQuat = new Quaternion(0, 0, 0, 1);
|
|
86
|
+
const single = {
|
|
87
|
+
x: 0,
|
|
88
|
+
y: 0,
|
|
89
|
+
z: 0,
|
|
90
|
+
sx: 0,
|
|
91
|
+
sy: 0,
|
|
92
|
+
sz: 0,
|
|
93
|
+
qx: 0,
|
|
94
|
+
qy: 0,
|
|
95
|
+
qz: 0,
|
|
96
|
+
qw: 0,
|
|
97
|
+
r: 0,
|
|
98
|
+
g: 0,
|
|
99
|
+
b: 0,
|
|
100
|
+
a: 0,
|
|
101
|
+
shN: new Array(splat.shCounts),
|
|
102
|
+
};
|
|
103
|
+
const shN = single.shN;
|
|
104
|
+
const shCoeffs = new Array(splat.shCounts / 3).fill(0);
|
|
105
|
+
const deletedTotalIndices = [];
|
|
106
|
+
for (let i = 0; i < modifies.length; i++) {
|
|
107
|
+
const modify = modifies[i];
|
|
108
|
+
if (!modify) {
|
|
109
|
+
logger.info(`modify[${i}] is null, skip`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const offset = splat.blockOffsets[i];
|
|
113
|
+
const { deletedIndices, groupIndices, groupTransforms } = modify;
|
|
114
|
+
logger.info(`modify[${i}] offset=${offset} groups=${groupIndices.length} delete=${deletedIndices.length}`);
|
|
115
|
+
for (let j = 0; j < groupIndices.length; j++) {
|
|
116
|
+
const indices = groupIndices[j];
|
|
117
|
+
const { isScale, isRotate, matrix, scale, quat, shRotateFn } = groupTransforms[j];
|
|
118
|
+
logger.info(`group[${i}:${j}] size=${indices.length} scale=${isScale} rotate=${isRotate}`);
|
|
119
|
+
for (let k = 0; k < indices.length; k++) {
|
|
120
|
+
const idx = offset + indices[k];
|
|
121
|
+
splat.get(idx, single);
|
|
122
|
+
tempVec.set(single.x, single.y, single.z).applyMatrix4(matrix);
|
|
123
|
+
single.x = tempVec.x;
|
|
124
|
+
single.y = tempVec.y;
|
|
125
|
+
single.z = tempVec.z;
|
|
126
|
+
if (isScale) {
|
|
127
|
+
tempVec.set(single.sx, single.sy, single.sz).mul(scale);
|
|
128
|
+
single.sx = tempVec.x;
|
|
129
|
+
single.sy = tempVec.y;
|
|
130
|
+
single.sz = tempVec.z;
|
|
131
|
+
}
|
|
132
|
+
if (isRotate) {
|
|
133
|
+
tempQuat.set(single.qx, single.qy, single.qz, single.qw).premultiply(quat);
|
|
134
|
+
single.qx = tempQuat.x;
|
|
135
|
+
single.qy = tempQuat.y;
|
|
136
|
+
single.qz = tempQuat.z;
|
|
137
|
+
single.qw = tempQuat.w;
|
|
138
|
+
}
|
|
139
|
+
splat.set(idx, single);
|
|
140
|
+
if (isRotate) {
|
|
141
|
+
splat.getShN(idx, shN);
|
|
142
|
+
for (let m = 0; m < 3; m++) {
|
|
143
|
+
for (let n = 0; n < shCoeffs.length; n++) {
|
|
144
|
+
shCoeffs[n] = shN[n * 3 + m];
|
|
145
|
+
}
|
|
146
|
+
shRotateFn(shCoeffs);
|
|
147
|
+
for (let n = 0; n < shCoeffs.length; n++) {
|
|
148
|
+
shN[n * 3 + m] = shCoeffs[n];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
splat.setShN(idx, shN);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
for (let j = 0; j < deletedIndices.length; j++) {
|
|
156
|
+
deletedTotalIndices.push(offset + deletedIndices[j]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (deletedTotalIndices.length > 0) {
|
|
160
|
+
fastDeleteSplat(splat, deletedTotalIndices);
|
|
161
|
+
logger.info(`delete ${deletedTotalIndices.length} splat`);
|
|
162
|
+
}
|
|
163
|
+
resources.set(output, splat);
|
|
164
|
+
logger.info(`stored -> key="${output}"`);
|
|
165
|
+
}
|
|
166
|
+
}
|
package/dist/tasks/ReadTask.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Context, BaseTask } from './BaseTask.js';
|
|
2
|
-
export interface Config {
|
|
3
|
-
inputs: string[];
|
|
4
|
-
output: string;
|
|
5
|
-
maxShDegree?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class ReadTask extends BaseTask<Config> {
|
|
8
|
-
exec(config: Config, { logger, resources }: Context): Promise<void>;
|
|
9
|
-
}
|
|
1
|
+
import { type Context, BaseTask } from './BaseTask.js';
|
|
2
|
+
export interface Config {
|
|
3
|
+
inputs: string[];
|
|
4
|
+
output: string;
|
|
5
|
+
maxShDegree?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ReadTask extends BaseTask<Config> {
|
|
8
|
+
exec(config: Config, { logger, resources }: Context): Promise<void>;
|
|
9
|
+
}
|
package/dist/tasks/ReadTask.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
3
|
-
import { SplatData } from '../SplatData.js';
|
|
4
|
-
import { createSplatFile } from '../utils/index.js';
|
|
5
|
-
import { BaseTask } from './BaseTask.js';
|
|
6
|
-
export class ReadTask extends BaseTask {
|
|
7
|
-
async exec(config, { logger, resources }) {
|
|
8
|
-
const { inputs, output, maxShDegree } = config;
|
|
9
|
-
const splat = new SplatData(inputs.length, maxShDegree);
|
|
10
|
-
const promises = [];
|
|
11
|
-
let totalBytes = 0;
|
|
12
|
-
for (let i = 0; i < inputs.length; i++) {
|
|
13
|
-
const path = inputs[i];
|
|
14
|
-
const { size } = fs.statSync(path);
|
|
15
|
-
totalBytes += size;
|
|
16
|
-
const stream = Readable.toWeb(fs.createReadStream(path));
|
|
17
|
-
const promise = createSplatFile(path).read(stream, size, splat);
|
|
18
|
-
promises.push(promise);
|
|
19
|
-
}
|
|
20
|
-
await Promise.all(promises);
|
|
21
|
-
logger.info(`load: ${inputs.length} files | sizes=${(totalBytes / 1024 / 1024).toFixed(2)}MB`);
|
|
22
|
-
for (let i = 0; i < inputs.length; i++) {
|
|
23
|
-
logger.info(` - ${inputs[i]}`);
|
|
24
|
-
}
|
|
25
|
-
logger.info(`counts: ${splat.counts}, SH: ${splat.shDegree}`);
|
|
26
|
-
resources.set(output, splat);
|
|
27
|
-
logger.info(`stored -> "${output}"`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { SplatData } from '../SplatData.js';
|
|
4
|
+
import { createSplatFile } from '../utils/index.js';
|
|
5
|
+
import { BaseTask } from './BaseTask.js';
|
|
6
|
+
export class ReadTask extends BaseTask {
|
|
7
|
+
async exec(config, { logger, resources }) {
|
|
8
|
+
const { inputs, output, maxShDegree } = config;
|
|
9
|
+
const splat = new SplatData(inputs.length, maxShDegree);
|
|
10
|
+
const promises = [];
|
|
11
|
+
let totalBytes = 0;
|
|
12
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
13
|
+
const path = inputs[i];
|
|
14
|
+
const { size } = fs.statSync(path);
|
|
15
|
+
totalBytes += size;
|
|
16
|
+
const stream = Readable.toWeb(fs.createReadStream(path));
|
|
17
|
+
const promise = createSplatFile(path).read(stream, size, splat);
|
|
18
|
+
promises.push(promise);
|
|
19
|
+
}
|
|
20
|
+
await Promise.all(promises);
|
|
21
|
+
logger.info(`load: ${inputs.length} files | sizes=${(totalBytes / 1024 / 1024).toFixed(2)}MB`);
|
|
22
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
23
|
+
logger.info(` - ${inputs[i]}`);
|
|
24
|
+
}
|
|
25
|
+
logger.info(`counts: ${splat.counts}, SH: ${splat.shDegree}`);
|
|
26
|
+
resources.set(output, splat);
|
|
27
|
+
logger.info(`stored -> "${output}"`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Context, BaseTask } from './BaseTask.js';
|
|
2
|
-
export interface Config {
|
|
3
|
-
input: string;
|
|
4
|
-
output: string;
|
|
5
|
-
counts?: number;
|
|
6
|
-
ratio?: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class SkeletonLodTask extends BaseTask<Config> {
|
|
9
|
-
exec(config: Config, { logger, resources }: Context): Promise<void>;
|
|
10
|
-
}
|
|
1
|
+
import { type Context, BaseTask } from './BaseTask.js';
|
|
2
|
+
export interface Config {
|
|
3
|
+
input: string;
|
|
4
|
+
output: string;
|
|
5
|
+
counts?: number;
|
|
6
|
+
ratio?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class SkeletonLodTask extends BaseTask<Config> {
|
|
9
|
+
exec(config: Config, { logger, resources }: Context): Promise<void>;
|
|
10
|
+
}
|