@manycore/aholo-splat-transform 1.2.6
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 +102 -0
- package/README.md +33 -0
- package/bin/cli.js +118 -0
- package/dist/SplatData.d.ts +67 -0
- package/dist/SplatData.js +156 -0
- package/dist/constant.d.ts +3 -0
- package/dist/constant.js +13 -0
- package/dist/file/IFile.d.ts +5 -0
- package/dist/file/IFile.js +1 -0
- package/dist/file/index.d.ts +7 -0
- package/dist/file/index.js +6 -0
- package/dist/file/ksplat.d.ts +12 -0
- package/dist/file/ksplat.js +232 -0
- package/dist/file/lcc.d.ts +11 -0
- package/dist/file/lcc.js +157 -0
- package/dist/file/ply.d.ts +13 -0
- package/dist/file/ply.js +388 -0
- package/dist/file/sog.d.ts +80 -0
- package/dist/file/sog.js +504 -0
- package/dist/file/splat.d.ts +6 -0
- package/dist/file/splat.js +99 -0
- package/dist/file/spz.d.ts +8 -0
- package/dist/file/spz.js +400 -0
- package/dist/file/voxel.d.ts +37 -0
- package/dist/file/voxel.js +280 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +54 -0
- package/dist/native/cpp/bin/linux/binding.node +0 -0
- package/dist/native/cpp/bin/windows/binding.node +0 -0
- package/dist/native/index.d.ts +54 -0
- package/dist/native/index.js +128 -0
- package/dist/tasks/AutoChunkLodTask.d.ts +13 -0
- package/dist/tasks/AutoChunkLodTask.js +117 -0
- package/dist/tasks/AutoLodTask.d.ts +10 -0
- package/dist/tasks/AutoLodTask.js +20 -0
- package/dist/tasks/BaseTask.d.ts +15 -0
- package/dist/tasks/BaseTask.js +5 -0
- package/dist/tasks/FlexLodTask.d.ts +12 -0
- package/dist/tasks/FlexLodTask.js +44 -0
- package/dist/tasks/ModifyTask.d.ts +9 -0
- package/dist/tasks/ModifyTask.js +156 -0
- package/dist/tasks/ReadTask.d.ts +8 -0
- package/dist/tasks/ReadTask.js +29 -0
- package/dist/tasks/SkeletonLodTask.d.ts +10 -0
- package/dist/tasks/SkeletonLodTask.js +156 -0
- package/dist/tasks/VoxelTask.d.ts +30 -0
- package/dist/tasks/VoxelTask.js +37 -0
- package/dist/tasks/WriteTask.d.ts +11 -0
- package/dist/tasks/WriteTask.js +70 -0
- package/dist/utils/BufferReader.d.ts +12 -0
- package/dist/utils/BufferReader.js +47 -0
- package/dist/utils/Logger.d.ts +11 -0
- package/dist/utils/Logger.js +38 -0
- package/dist/utils/StreamChunkDecoder.d.ts +16 -0
- package/dist/utils/StreamChunkDecoder.js +36 -0
- package/dist/utils/index.d.ts +27 -0
- package/dist/utils/index.js +101 -0
- package/dist/utils/k-means.d.ts +4 -0
- package/dist/utils/k-means.js +350 -0
- package/dist/utils/math.d.ts +46 -0
- package/dist/utils/math.js +351 -0
- package/dist/utils/quantize-1d.d.ts +4 -0
- package/dist/utils/quantize-1d.js +164 -0
- package/dist/utils/sh-rotate.d.ts +2 -0
- package/dist/utils/sh-rotate.js +175 -0
- package/dist/utils/splat.d.ts +20 -0
- package/dist/utils/splat.js +378 -0
- package/dist/utils/voxel/common.d.ts +162 -0
- package/dist/utils/voxel/common.js +1700 -0
- package/dist/utils/voxel/coplanar-merge.d.ts +63 -0
- package/dist/utils/voxel/coplanar-merge.js +819 -0
- package/dist/utils/voxel/gpu-dilation.d.ts +2 -0
- package/dist/utils/voxel/gpu-dilation.js +665 -0
- package/dist/utils/voxel/marching-cubes.d.ts +42 -0
- package/dist/utils/voxel/marching-cubes.js +1657 -0
- package/dist/utils/voxel/mesh.d.ts +3 -0
- package/dist/utils/voxel/mesh.js +130 -0
- package/dist/utils/voxel/nav.d.ts +29 -0
- package/dist/utils/voxel/nav.js +1043 -0
- package/dist/utils/voxel/postprocess.d.ts +23 -0
- package/dist/utils/voxel/postprocess.js +375 -0
- package/dist/utils/voxel/voxel-faces.d.ts +18 -0
- package/dist/utils/voxel/voxel-faces.js +663 -0
- package/dist/utils/voxel/voxelize.d.ts +33 -0
- package/dist/utils/voxel/voxelize.js +1193 -0
- package/dist/utils/webgpu.d.ts +8 -0
- package/dist/utils/webgpu.js +122 -0
- package/package.json +32 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# ChangeLOG
|
|
2
|
+
|
|
3
|
+
## 1.2.6
|
|
4
|
+
|
|
5
|
+
- 体素化新增 cpu 实现以及部分算法优化
|
|
6
|
+
- 体素化输出格式优化
|
|
7
|
+
|
|
8
|
+
## 1.2.5
|
|
9
|
+
|
|
10
|
+
- 修复 SplatData.counts = 0 时构造 lod 异常
|
|
11
|
+
|
|
12
|
+
## 1.2.4
|
|
13
|
+
|
|
14
|
+
- 支持生成体素碰撞体
|
|
15
|
+
- avif 编解码支持多任务
|
|
16
|
+
- 使用 glibc 构建 linux 版本
|
|
17
|
+
- 修复小文件生成 lod chunk 失败
|
|
18
|
+
- 优化 logger
|
|
19
|
+
|
|
20
|
+
## 1.2.3
|
|
21
|
+
|
|
22
|
+
- 优化内部代码,移除无用实现
|
|
23
|
+
- 修改 chunk-lod 的 forward box 计算逻辑,匹配业务需求
|
|
24
|
+
|
|
25
|
+
## 1.2.2
|
|
26
|
+
|
|
27
|
+
- 添加`libavif`
|
|
28
|
+
- 整理文件结构,删除 IData 结构
|
|
29
|
+
- 修复 modify 和 chunk-lod 冲突造成删除失败
|
|
30
|
+
|
|
31
|
+
## 1.2.1
|
|
32
|
+
|
|
33
|
+
- 支持`GPU`设备选择
|
|
34
|
+
- write 支持 MortonSort 用以提升压缩率
|
|
35
|
+
|
|
36
|
+
## 1.2.0
|
|
37
|
+
|
|
38
|
+
- 重构 cli 命令
|
|
39
|
+
- 底层修改成 pipeline task 支持组合,减少文件保存数量
|
|
40
|
+
- 过程计算采用双精度,移除无效代码
|
|
41
|
+
- 增加`getOrCreateDevice`用于共享 GPU 设备
|
|
42
|
+
- 改进`auto-lod`使其更接近目标值
|
|
43
|
+
- 优化输出
|
|
44
|
+
|
|
45
|
+
## 1.1.2
|
|
46
|
+
|
|
47
|
+
- 加入 nanogs 检索算法
|
|
48
|
+
- 增加 --max-chunk-counts 参数
|
|
49
|
+
|
|
50
|
+
## 1.1.1
|
|
51
|
+
|
|
52
|
+
- 优化 lod 参数,防止出现长时间执行
|
|
53
|
+
|
|
54
|
+
## 1.1.0
|
|
55
|
+
|
|
56
|
+
- 修改 cli 调用参数
|
|
57
|
+
- 优化 lod:auto 时内存无法及时释放导致 oom 的情况
|
|
58
|
+
- 新增 lod:auto-chunk 命令
|
|
59
|
+
- 多级 lod 支持指数步进
|
|
60
|
+
- auto-chunk 优化输出结果
|
|
61
|
+
|
|
62
|
+
## 1.0.8
|
|
63
|
+
|
|
64
|
+
- 优化高斯空间分割
|
|
65
|
+
- 优化高斯包围盒,移除偏移过大的数据
|
|
66
|
+
- 修复`webP`有损编码`quality`读取错误的问题
|
|
67
|
+
- 修复 lod 命令异常
|
|
68
|
+
- 优化`cluster_average`并行粒度
|
|
69
|
+
|
|
70
|
+
## 1.0.7
|
|
71
|
+
|
|
72
|
+
- 支持 SOG 格式输出
|
|
73
|
+
|
|
74
|
+
## 1.0.6
|
|
75
|
+
|
|
76
|
+
- 优化 lod 内置参数
|
|
77
|
+
|
|
78
|
+
## 1.0.5
|
|
79
|
+
|
|
80
|
+
- 优化 lod 内置参数
|
|
81
|
+
|
|
82
|
+
## 1.0.4
|
|
83
|
+
|
|
84
|
+
- 修复`create`解析`deletedIndicesBitMap`异常
|
|
85
|
+
|
|
86
|
+
## 1.0.3
|
|
87
|
+
|
|
88
|
+
- 优化`autoLod`效果和实现
|
|
89
|
+
|
|
90
|
+
## 1.0.2
|
|
91
|
+
|
|
92
|
+
- 支持流式解析和写入,减少内存占用
|
|
93
|
+
- 支持`autoLod`对 3dgs 生成 lod 结果
|
|
94
|
+
- `splat-transform lod --type auto --ratio 0.3 simiao.ply simiao-lod.spz`
|
|
95
|
+
|
|
96
|
+
## 1.0.1
|
|
97
|
+
|
|
98
|
+
- 新增`bin.est`防止和`@playcanvas/splat-transform`一起使用时出现冲突
|
|
99
|
+
|
|
100
|
+
## 1.0.0
|
|
101
|
+
|
|
102
|
+
- 发包正式包
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# splat-transform
|
|
2
|
+
|
|
3
|
+
A 3DGS modifier used by aholo
|
|
4
|
+
|
|
5
|
+
## Requirement
|
|
6
|
+
|
|
7
|
+
- node >= 20.19.0
|
|
8
|
+
- system
|
|
9
|
+
- windows: windows 22H2+, D3D12 or Vulkan compatible GPU(When use GPU features, dedicated GPU for better performance)
|
|
10
|
+
- linux: glibc >=2.34, libstdc++ >= 3.4.30, Vulkan compatible GPU(When use GPU features, dedicated GPU for better performance)
|
|
11
|
+
- osx: Not Supported
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
splat-transform --help
|
|
17
|
+
|
|
18
|
+
Execute a task pipeline from configuration file
|
|
19
|
+
|
|
20
|
+
Arguments:
|
|
21
|
+
path pipeline config filepath
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
-V, --version output the version number
|
|
25
|
+
-h, --help display help for command
|
|
26
|
+
|
|
27
|
+
Commands:
|
|
28
|
+
create <input> <output> Merge & Transform gaussian splat file
|
|
29
|
+
lod:loading [options] <input> <output> Generate loading-lod for gaussian splat file
|
|
30
|
+
lod:flex [options] <input> <output> Generate flex-lod for gaussian splat file
|
|
31
|
+
lod:auto [options] <input> <output> Generate auto-lod for gaussian splat file
|
|
32
|
+
lod:auto-chunk [options] <input> <output> Generate auto-chunk-lod for gaussian splat file
|
|
33
|
+
```
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
5
|
+
import { runner } from '../dist/index.js';
|
|
6
|
+
|
|
7
|
+
const ExtraText = `
|
|
8
|
+
Transform Gaussian splats file
|
|
9
|
+
===================================
|
|
10
|
+
SUPPORTED INPUTS
|
|
11
|
+
.ply .compressed.ply .sog meta.json .ksplat .splat .spz .lcc
|
|
12
|
+
|
|
13
|
+
SUPPORTED OUTPUTS
|
|
14
|
+
.ply .spz .uspz .splat .sog
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.name(packageJson.name)
|
|
19
|
+
.version(packageJson.version)
|
|
20
|
+
.addHelpText('beforeAll', ExtraText);
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.description('Execute a task pipeline from configuration file')
|
|
24
|
+
.argument('<path>', 'pipeline config filepath')
|
|
25
|
+
.action((path) => {
|
|
26
|
+
const content = fs.readFileSync(path, { encoding: 'utf-8' });
|
|
27
|
+
runner(JSON.parse(content));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command('create')
|
|
32
|
+
.description('Merge & Transform gaussian splat file')
|
|
33
|
+
.argument('<input>', 'input filepath')
|
|
34
|
+
.argument('<output>', 'output filepath')
|
|
35
|
+
.action((input, output) => {
|
|
36
|
+
runner({
|
|
37
|
+
version: 1,
|
|
38
|
+
tasks: [
|
|
39
|
+
{ id: '0', type: 'Read', config: { inputs: [input], output: 'cache0' } },
|
|
40
|
+
{ id: '1', type: 'Modify', config: { input: 'cache0', output: 'cache0' } },
|
|
41
|
+
{ id: '2', type: 'Write', config: { input: 'cache0', output: output } },
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
program
|
|
47
|
+
.command('lod:loading')
|
|
48
|
+
.description('Generate loading-lod for gaussian splat file')
|
|
49
|
+
.option('--ratio <number>')
|
|
50
|
+
.argument('<input>', 'input filepath')
|
|
51
|
+
.argument('<output>', 'output filepath')
|
|
52
|
+
.action(async (input, output, arg) => {
|
|
53
|
+
runner({
|
|
54
|
+
version: 1,
|
|
55
|
+
tasks: [
|
|
56
|
+
{ id: '0', type: 'Read', config: { inputs: [input], output: 'cache0' } },
|
|
57
|
+
{ id: '1', type: 'SkeletonLod', config: { input: 'cache0', output: 'cache0', ratio: arg.ratio } },
|
|
58
|
+
{ id: '2', type: 'Write', config: { input: 'cache0', output: output } },
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
program
|
|
64
|
+
.command('lod:flex')
|
|
65
|
+
.description('Generate flex-lod for gaussian splat file')
|
|
66
|
+
.requiredOption('--score <string>')
|
|
67
|
+
.option('--ratio <number>')
|
|
68
|
+
.argument('<input>', 'input filepath')
|
|
69
|
+
.argument('<output>', 'output filepath')
|
|
70
|
+
.action(async (input, output, arg) => {
|
|
71
|
+
runner({
|
|
72
|
+
version: 1,
|
|
73
|
+
tasks: [
|
|
74
|
+
{ id: '0', type: 'Read', config: { inputs: [input], output: 'cache0' } },
|
|
75
|
+
{ id: '1', type: 'FlexLod', config: { input: 'cache0', output: 'cache0', ratio: arg.ratio, scorePath: arg.score } },
|
|
76
|
+
{ id: '2', type: 'Write', config: { input: 'cache0', output: output } },
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
program
|
|
82
|
+
.command('lod:auto')
|
|
83
|
+
.description('Generate auto-lod for gaussian splat file')
|
|
84
|
+
.option('--ratio <number>')
|
|
85
|
+
.argument('<input>', 'input filepath')
|
|
86
|
+
.argument('<output>', 'output filepath')
|
|
87
|
+
.action(async (input, output, arg) => {
|
|
88
|
+
runner({
|
|
89
|
+
version: 1,
|
|
90
|
+
tasks: [
|
|
91
|
+
{ id: '0', type: 'Read', config: { inputs: [input], output: 'cache0' } },
|
|
92
|
+
{ id: '1', type: 'AutoLod', config: { input: 'cache0', output: 'cache0', ratio: arg.ratio } },
|
|
93
|
+
{ id: '2', type: 'Write', config: { input: 'cache0', output: output } },
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const fileTypeOption = program.createOption('-t, --type <type>', 'output file type').choices(['ply', 'spz', 'splat', 'sog']);
|
|
99
|
+
fileTypeOption.required = true;
|
|
100
|
+
program
|
|
101
|
+
.command('lod:auto-chunk')
|
|
102
|
+
.description('Generate auto-chunk-lod for gaussian splat file')
|
|
103
|
+
.addOption(fileTypeOption)
|
|
104
|
+
.option('--max-chunk-counts <number>')
|
|
105
|
+
.argument('<input>', 'input filepath')
|
|
106
|
+
.argument('<output>', 'output directory')
|
|
107
|
+
.action(async (input, output, arg) => {
|
|
108
|
+
runner({
|
|
109
|
+
version: 1,
|
|
110
|
+
tasks: [
|
|
111
|
+
{ id: '0', type: 'Read', config: { inputs: [input], output: 'cache0' } },
|
|
112
|
+
{ id: '1', type: 'AutoChunkLod', config: { input: 'cache0', output: 'cache0', type: arg.type, maxChunkCounts: arg.maxChunkCounts } },
|
|
113
|
+
{ id: '2', type: 'Write', config: { input: 'cache0', output: output } },
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
program.parse();
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface ISingleSplat {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
z: number;
|
|
5
|
+
sx: number;
|
|
6
|
+
sy: number;
|
|
7
|
+
sz: number;
|
|
8
|
+
qx: number;
|
|
9
|
+
qy: number;
|
|
10
|
+
qz: number;
|
|
11
|
+
qw: number;
|
|
12
|
+
r: number;
|
|
13
|
+
g: number;
|
|
14
|
+
b: number;
|
|
15
|
+
a: number;
|
|
16
|
+
shN: number[];
|
|
17
|
+
}
|
|
18
|
+
export declare const enum ColIdx {
|
|
19
|
+
x = 0,
|
|
20
|
+
y = 1,
|
|
21
|
+
z = 2,
|
|
22
|
+
sx = 3,
|
|
23
|
+
sy = 4,
|
|
24
|
+
sz = 5,
|
|
25
|
+
qx = 6,
|
|
26
|
+
qy = 7,
|
|
27
|
+
qz = 8,
|
|
28
|
+
qw = 9,
|
|
29
|
+
r = 10,
|
|
30
|
+
g = 11,
|
|
31
|
+
b = 12,
|
|
32
|
+
a = 13,
|
|
33
|
+
shOffset = 14
|
|
34
|
+
}
|
|
35
|
+
export declare class SplatData {
|
|
36
|
+
counts: number;
|
|
37
|
+
shDegree: number;
|
|
38
|
+
shCounts: number;
|
|
39
|
+
maxShDegree: number;
|
|
40
|
+
table: Float32Array[];
|
|
41
|
+
constructor(blockCounts?: number, maxShDegree?: number);
|
|
42
|
+
blockOffsets: number[];
|
|
43
|
+
blockContentCounts: number[];
|
|
44
|
+
private blockCounts;
|
|
45
|
+
private totalBlockCounts;
|
|
46
|
+
private totalBlockShDegree;
|
|
47
|
+
private blockExecs;
|
|
48
|
+
private currentBlockIndex;
|
|
49
|
+
initBlock(counts: number, shDegree: number): Promise<number>;
|
|
50
|
+
finishBlock(): void;
|
|
51
|
+
init(counts: number, shDegree: number): this;
|
|
52
|
+
set(i: number, single: ISingleSplat): void;
|
|
53
|
+
setCenter(i: number, x: number, y: number, z: number): void;
|
|
54
|
+
setScale(i: number, sx: number, sy: number, sz: number): void;
|
|
55
|
+
setQuat(i: number, qx: number, qy: number, qz: number, qw: number): void;
|
|
56
|
+
setColor(i: number, r: number, g: number, b: number): void;
|
|
57
|
+
setAlpha(i: number, a: number): void;
|
|
58
|
+
setShN(i: number, shN: number[]): void;
|
|
59
|
+
get(i: number, single: ISingleSplat): void;
|
|
60
|
+
getCenter(i: number, single: ISingleSplat): void;
|
|
61
|
+
getScale(i: number, single: ISingleSplat): void;
|
|
62
|
+
getQuat(i: number, single: ISingleSplat): void;
|
|
63
|
+
getColor(i: number, single: ISingleSplat): void;
|
|
64
|
+
getAlpha(i: number, single: ISingleSplat): void;
|
|
65
|
+
getShN(i: number, shN: number[]): void;
|
|
66
|
+
destroy(): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Quaternion, deferred } from './utils/index.js';
|
|
2
|
+
import { SH_MAPS } from './constant.js';
|
|
3
|
+
const tempQuat = new Quaternion(0, 0, 0, 1);
|
|
4
|
+
export class SplatData {
|
|
5
|
+
counts;
|
|
6
|
+
shDegree;
|
|
7
|
+
shCounts;
|
|
8
|
+
maxShDegree;
|
|
9
|
+
table;
|
|
10
|
+
constructor(blockCounts = 1, maxShDegree = 3) {
|
|
11
|
+
this.blockCounts = blockCounts;
|
|
12
|
+
this.maxShDegree = maxShDegree;
|
|
13
|
+
}
|
|
14
|
+
blockOffsets = [];
|
|
15
|
+
blockContentCounts = [];
|
|
16
|
+
blockCounts;
|
|
17
|
+
totalBlockCounts = 0;
|
|
18
|
+
totalBlockShDegree = 3;
|
|
19
|
+
blockExecs = [];
|
|
20
|
+
currentBlockIndex = 0;
|
|
21
|
+
initBlock(counts, shDegree) {
|
|
22
|
+
this.blockContentCounts.push(counts);
|
|
23
|
+
this.blockOffsets.push(this.totalBlockCounts);
|
|
24
|
+
this.totalBlockCounts += counts;
|
|
25
|
+
this.totalBlockShDegree = Math.min(shDegree, this.totalBlockShDegree);
|
|
26
|
+
const { promise, resolve } = deferred();
|
|
27
|
+
this.blockExecs.push(resolve);
|
|
28
|
+
if (this.blockOffsets.length === this.blockCounts) {
|
|
29
|
+
this.init(this.totalBlockCounts, this.totalBlockShDegree);
|
|
30
|
+
this.blockExecs[this.currentBlockIndex](this.blockOffsets[0]);
|
|
31
|
+
}
|
|
32
|
+
return promise;
|
|
33
|
+
}
|
|
34
|
+
finishBlock() {
|
|
35
|
+
this.currentBlockIndex++;
|
|
36
|
+
this.blockExecs[this.currentBlockIndex]?.(this.blockOffsets[this.currentBlockIndex]);
|
|
37
|
+
}
|
|
38
|
+
init(counts, shDegree) {
|
|
39
|
+
this.counts = counts;
|
|
40
|
+
this.shDegree = Math.min(shDegree, this.maxShDegree);
|
|
41
|
+
const shCounts = this.shCounts = SH_MAPS[this.shDegree];
|
|
42
|
+
this.table = new Array(14 + shCounts).fill(0).map(() => new Float32Array(counts));
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
set(i, single) {
|
|
46
|
+
const { table } = this;
|
|
47
|
+
table[0 /* ColIdx.x */][i] = single.x;
|
|
48
|
+
table[1 /* ColIdx.y */][i] = single.y;
|
|
49
|
+
table[2 /* ColIdx.z */][i] = single.z;
|
|
50
|
+
table[3 /* ColIdx.sx */][i] = single.sx;
|
|
51
|
+
table[4 /* ColIdx.sy */][i] = single.sy;
|
|
52
|
+
table[5 /* ColIdx.sz */][i] = single.sz;
|
|
53
|
+
tempQuat.set(single.qx, single.qy, single.qz, single.qw).normalize();
|
|
54
|
+
table[6 /* ColIdx.qx */][i] = tempQuat.x;
|
|
55
|
+
table[7 /* ColIdx.qy */][i] = tempQuat.y;
|
|
56
|
+
table[8 /* ColIdx.qz */][i] = tempQuat.z;
|
|
57
|
+
table[9 /* ColIdx.qw */][i] = tempQuat.w;
|
|
58
|
+
table[10 /* ColIdx.r */][i] = single.r;
|
|
59
|
+
table[11 /* ColIdx.g */][i] = single.g;
|
|
60
|
+
table[12 /* ColIdx.b */][i] = single.b;
|
|
61
|
+
table[13 /* ColIdx.a */][i] = single.a;
|
|
62
|
+
}
|
|
63
|
+
setCenter(i, x, y, z) {
|
|
64
|
+
const { table } = this;
|
|
65
|
+
table[0 /* ColIdx.x */][i] = x;
|
|
66
|
+
table[1 /* ColIdx.y */][i] = y;
|
|
67
|
+
table[2 /* ColIdx.z */][i] = z;
|
|
68
|
+
}
|
|
69
|
+
setScale(i, sx, sy, sz) {
|
|
70
|
+
const { table } = this;
|
|
71
|
+
table[3 /* ColIdx.sx */][i] = sx;
|
|
72
|
+
table[4 /* ColIdx.sy */][i] = sy;
|
|
73
|
+
table[5 /* ColIdx.sz */][i] = sz;
|
|
74
|
+
}
|
|
75
|
+
setQuat(i, qx, qy, qz, qw) {
|
|
76
|
+
const { table } = this;
|
|
77
|
+
tempQuat.set(qx, qy, qz, qw).normalize();
|
|
78
|
+
table[6 /* ColIdx.qx */][i] = tempQuat.x;
|
|
79
|
+
table[7 /* ColIdx.qy */][i] = tempQuat.y;
|
|
80
|
+
table[8 /* ColIdx.qz */][i] = tempQuat.z;
|
|
81
|
+
table[9 /* ColIdx.qw */][i] = tempQuat.w;
|
|
82
|
+
}
|
|
83
|
+
setColor(i, r, g, b) {
|
|
84
|
+
const { table } = this;
|
|
85
|
+
table[10 /* ColIdx.r */][i] = r;
|
|
86
|
+
table[11 /* ColIdx.g */][i] = g;
|
|
87
|
+
table[12 /* ColIdx.b */][i] = b;
|
|
88
|
+
}
|
|
89
|
+
setAlpha(i, a) {
|
|
90
|
+
const { table } = this;
|
|
91
|
+
table[13 /* ColIdx.a */][i] = a;
|
|
92
|
+
}
|
|
93
|
+
setShN(i, shN) {
|
|
94
|
+
const { table, shCounts } = this;
|
|
95
|
+
for (let j = 0; j < shCounts; j++) {
|
|
96
|
+
table[14 /* ColIdx.shOffset */ + j][i] = shN[j];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
;
|
|
100
|
+
get(i, single) {
|
|
101
|
+
const { table } = this;
|
|
102
|
+
single.x = table[0 /* ColIdx.x */][i];
|
|
103
|
+
single.y = table[1 /* ColIdx.y */][i];
|
|
104
|
+
single.z = table[2 /* ColIdx.z */][i];
|
|
105
|
+
single.sx = table[3 /* ColIdx.sx */][i];
|
|
106
|
+
single.sy = table[4 /* ColIdx.sy */][i];
|
|
107
|
+
single.sz = table[5 /* ColIdx.sz */][i];
|
|
108
|
+
single.qx = table[6 /* ColIdx.qx */][i];
|
|
109
|
+
single.qy = table[7 /* ColIdx.qy */][i];
|
|
110
|
+
single.qz = table[8 /* ColIdx.qz */][i];
|
|
111
|
+
single.qw = table[9 /* ColIdx.qw */][i];
|
|
112
|
+
single.r = table[10 /* ColIdx.r */][i];
|
|
113
|
+
single.g = table[11 /* ColIdx.g */][i];
|
|
114
|
+
single.b = table[12 /* ColIdx.b */][i];
|
|
115
|
+
single.a = table[13 /* ColIdx.a */][i];
|
|
116
|
+
}
|
|
117
|
+
getCenter(i, single) {
|
|
118
|
+
const { table } = this;
|
|
119
|
+
single.x = table[0 /* ColIdx.x */][i];
|
|
120
|
+
single.y = table[1 /* ColIdx.y */][i];
|
|
121
|
+
single.z = table[2 /* ColIdx.z */][i];
|
|
122
|
+
}
|
|
123
|
+
getScale(i, single) {
|
|
124
|
+
const { table } = this;
|
|
125
|
+
single.sx = table[3 /* ColIdx.sx */][i];
|
|
126
|
+
single.sy = table[4 /* ColIdx.sy */][i];
|
|
127
|
+
single.sz = table[5 /* ColIdx.sz */][i];
|
|
128
|
+
}
|
|
129
|
+
getQuat(i, single) {
|
|
130
|
+
const { table } = this;
|
|
131
|
+
single.qx = table[6 /* ColIdx.qx */][i];
|
|
132
|
+
single.qy = table[7 /* ColIdx.qy */][i];
|
|
133
|
+
single.qz = table[8 /* ColIdx.qz */][i];
|
|
134
|
+
single.qw = table[9 /* ColIdx.qw */][i];
|
|
135
|
+
}
|
|
136
|
+
getColor(i, single) {
|
|
137
|
+
const { table } = this;
|
|
138
|
+
single.r = table[10 /* ColIdx.r */][i];
|
|
139
|
+
single.g = table[11 /* ColIdx.g */][i];
|
|
140
|
+
single.b = table[12 /* ColIdx.b */][i];
|
|
141
|
+
}
|
|
142
|
+
getAlpha(i, single) {
|
|
143
|
+
const { table } = this;
|
|
144
|
+
single.a = table[13 /* ColIdx.a */][i];
|
|
145
|
+
}
|
|
146
|
+
getShN(i, shN) {
|
|
147
|
+
const { shCounts, table } = this;
|
|
148
|
+
for (let j = 0; j < shCounts; j++) {
|
|
149
|
+
shN[j] = table[14 /* ColIdx.shOffset */ + j][i];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
destroy() {
|
|
153
|
+
this.counts = 0;
|
|
154
|
+
this.table = [];
|
|
155
|
+
}
|
|
156
|
+
}
|
package/dist/constant.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SplatData } from '../SplatData.js';
|
|
2
|
+
export interface IFile {
|
|
3
|
+
read(stream: ReadableStream<Uint8Array>, contentLength: number, data: SplatData): Promise<void>;
|
|
4
|
+
write(stream: WritableStream<Uint8Array>, data: SplatData, indices?: Uint32Array): Promise<void>;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { IFile } from './IFile.js';
|
|
2
|
+
export { KsplatFile } from './ksplat.js';
|
|
3
|
+
export { PlyFile } from './ply.js';
|
|
4
|
+
export { SogFile } from './sog.js';
|
|
5
|
+
export { SplatFile } from './splat.js';
|
|
6
|
+
export { SpzFile } from './spz.js';
|
|
7
|
+
export { LccFile } from './lcc.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SplatData } from '../SplatData.js';
|
|
2
|
+
import { IFile } from './IFile.js';
|
|
3
|
+
export declare class KsplatFile implements IFile {
|
|
4
|
+
private counts;
|
|
5
|
+
private shDegree;
|
|
6
|
+
private header;
|
|
7
|
+
private sections;
|
|
8
|
+
private buffer;
|
|
9
|
+
private load;
|
|
10
|
+
read(stream: ReadableStream<Uint8Array>, contentLength: number, data: SplatData): Promise<void>;
|
|
11
|
+
write(_stream: WritableStream<Uint8Array>, _data: SplatData): Promise<void>;
|
|
12
|
+
}
|