@manycore/aholo-splat-transform 1.2.8 → 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.
Files changed (97) hide show
  1. package/CHANGELOG.md +120 -113
  2. package/README.md +39 -39
  3. package/THIRD_PARTY_LICENSES.txt +1373 -1373
  4. package/bin/cli.js +125 -118
  5. package/dist/SplatData.d.ts +67 -67
  6. package/dist/SplatData.js +167 -150
  7. package/dist/constant.d.ts +3 -3
  8. package/dist/constant.js +13 -13
  9. package/dist/file/IFile.d.ts +5 -5
  10. package/dist/file/IFile.js +1 -1
  11. package/dist/file/esz.d.ts +11 -11
  12. package/dist/file/esz.js +337 -322
  13. package/dist/file/index.d.ts +8 -8
  14. package/dist/file/index.js +7 -7
  15. package/dist/file/ksplat.d.ts +12 -12
  16. package/dist/file/ksplat.js +293 -231
  17. package/dist/file/lcc.d.ts +11 -11
  18. package/dist/file/lcc.js +161 -158
  19. package/dist/file/ply.d.ts +13 -13
  20. package/dist/file/ply.js +439 -390
  21. package/dist/file/sog.d.ts +80 -80
  22. package/dist/file/sog.js +525 -494
  23. package/dist/file/splat.d.ts +6 -6
  24. package/dist/file/splat.js +119 -99
  25. package/dist/file/spz.d.ts +11 -11
  26. package/dist/file/spz.js +597 -583
  27. package/dist/file/voxel.d.ts +43 -37
  28. package/dist/file/voxel.js +411 -280
  29. package/dist/index.d.ts +33 -33
  30. package/dist/index.js +54 -54
  31. package/dist/native/index.d.ts +54 -54
  32. package/dist/native/index.js +122 -129
  33. package/dist/native/utils.d.ts +1 -0
  34. package/dist/native/utils.js +54 -0
  35. package/dist/tasks/AutoChunkLodTask.d.ts +13 -13
  36. package/dist/tasks/AutoChunkLodTask.js +117 -117
  37. package/dist/tasks/AutoLodTask.d.ts +10 -10
  38. package/dist/tasks/AutoLodTask.js +20 -20
  39. package/dist/tasks/BaseTask.d.ts +15 -15
  40. package/dist/tasks/BaseTask.js +5 -5
  41. package/dist/tasks/FlexLodTask.d.ts +12 -12
  42. package/dist/tasks/FlexLodTask.js +54 -44
  43. package/dist/tasks/ModifyTask.d.ts +9 -9
  44. package/dist/tasks/ModifyTask.js +166 -156
  45. package/dist/tasks/ReadTask.d.ts +9 -9
  46. package/dist/tasks/ReadTask.js +29 -29
  47. package/dist/tasks/SkeletonLodTask.d.ts +10 -10
  48. package/dist/tasks/SkeletonLodTask.js +176 -156
  49. package/dist/tasks/VoxelTask.d.ts +35 -30
  50. package/dist/tasks/VoxelTask.js +40 -37
  51. package/dist/tasks/WriteTask.d.ts +12 -12
  52. package/dist/tasks/WriteTask.js +70 -70
  53. package/dist/utils/BufferReader.d.ts +12 -12
  54. package/dist/utils/BufferReader.js +45 -45
  55. package/dist/utils/Logger.d.ts +11 -11
  56. package/dist/utils/Logger.js +40 -40
  57. package/dist/utils/StreamChunkDecoder.d.ts +16 -16
  58. package/dist/utils/StreamChunkDecoder.js +31 -31
  59. package/dist/utils/index.d.ts +27 -27
  60. package/dist/utils/index.js +101 -101
  61. package/dist/utils/k-means.d.ts +4 -4
  62. package/dist/utils/k-means.js +340 -341
  63. package/dist/utils/math.d.ts +46 -46
  64. package/dist/utils/math.js +350 -346
  65. package/dist/utils/quantize-1d.d.ts +4 -4
  66. package/dist/utils/quantize-1d.js +164 -164
  67. package/dist/utils/sh-rotate.d.ts +2 -2
  68. package/dist/utils/sh-rotate.js +236 -175
  69. package/dist/utils/splat.d.ts +21 -21
  70. package/dist/utils/splat.js +397 -387
  71. package/dist/utils/voxel/binary.d.ts +8 -0
  72. package/dist/utils/voxel/binary.js +176 -0
  73. package/dist/utils/voxel/common.d.ts +178 -162
  74. package/dist/utils/voxel/common.js +1752 -1682
  75. package/dist/utils/voxel/coplanar-merge.d.ts +63 -63
  76. package/dist/utils/voxel/coplanar-merge.js +818 -819
  77. package/dist/utils/voxel/filter-cluster.d.ts +20 -0
  78. package/dist/utils/voxel/filter-cluster.js +628 -0
  79. package/dist/utils/voxel/gpu-dilation.d.ts +2 -2
  80. package/dist/utils/voxel/gpu-dilation.js +677 -656
  81. package/dist/utils/voxel/marching-cubes.d.ts +42 -42
  82. package/dist/utils/voxel/marching-cubes.js +1645 -1657
  83. package/dist/utils/voxel/mesh.d.ts +3 -3
  84. package/dist/utils/voxel/mesh.js +130 -130
  85. package/dist/utils/voxel/nav.d.ts +29 -29
  86. package/dist/utils/voxel/nav.js +1068 -1043
  87. package/dist/utils/voxel/postprocess.d.ts +23 -23
  88. package/dist/utils/voxel/postprocess.js +408 -375
  89. package/dist/utils/voxel/voxel-faces.d.ts +18 -18
  90. package/dist/utils/voxel/voxel-faces.js +662 -663
  91. package/dist/utils/voxel/voxelize.d.ts +34 -33
  92. package/dist/utils/voxel/voxelize.js +1208 -1193
  93. package/dist/utils/webgpu.d.ts +8 -8
  94. package/dist/utils/webgpu.js +122 -122
  95. package/package.json +37 -39
  96. package/dist/native/cpp/bin/linux/binding.node +0 -0
  97. package/dist/native/cpp/bin/windows/binding.node +0 -0
@@ -1,175 +1,236 @@
1
- /**
2
- * Rotate spherical harmonics up to band 3 based on https://github.com/andrewwillmott/sh-lib
3
- * This implementation calculates the rotation factors during construction which can then
4
- * be used to rotate multiple spherical harmonics cheaply.
5
- */
6
- const kSqrt03_02 = Math.sqrt(3.0 / 2.0);
7
- const kSqrt01_03 = Math.sqrt(1.0 / 3.0);
8
- const kSqrt02_03 = Math.sqrt(2.0 / 3.0);
9
- const kSqrt04_03 = Math.sqrt(4.0 / 3.0);
10
- const kSqrt01_04 = Math.sqrt(1.0 / 4.0);
11
- const kSqrt03_04 = Math.sqrt(3.0 / 4.0);
12
- const kSqrt01_05 = Math.sqrt(1.0 / 5.0);
13
- const kSqrt03_05 = Math.sqrt(3.0 / 5.0);
14
- const kSqrt06_05 = Math.sqrt(6.0 / 5.0);
15
- const kSqrt08_05 = Math.sqrt(8.0 / 5.0);
16
- const kSqrt09_05 = Math.sqrt(9.0 / 5.0);
17
- const kSqrt01_06 = Math.sqrt(1.0 / 6.0);
18
- const kSqrt05_06 = Math.sqrt(5.0 / 6.0);
19
- const kSqrt03_08 = Math.sqrt(3.0 / 8.0);
20
- const kSqrt05_08 = Math.sqrt(5.0 / 8.0);
21
- const kSqrt09_08 = Math.sqrt(9.0 / 8.0);
22
- const kSqrt05_09 = Math.sqrt(5.0 / 9.0);
23
- const kSqrt08_09 = Math.sqrt(8.0 / 9.0);
24
- const kSqrt01_10 = Math.sqrt(1.0 / 10.0);
25
- const kSqrt03_10 = Math.sqrt(3.0 / 10.0);
26
- const kSqrt01_12 = Math.sqrt(1.0 / 12.0);
27
- const kSqrt04_15 = Math.sqrt(4.0 / 15.0);
28
- const kSqrt01_16 = Math.sqrt(1.0 / 16.0);
29
- const kSqrt15_16 = Math.sqrt(15.0 / 16.0);
30
- const kSqrt01_18 = Math.sqrt(1.0 / 18.0);
31
- const kSqrt01_60 = Math.sqrt(1.0 / 60.0);
32
- export function createSHRotateFn(mat) {
33
- const rot = mat.elements;
34
- const sh1 = [
35
- [rot[4], -rot[7], rot[1]],
36
- [-rot[5], rot[8], -rot[2]],
37
- [rot[3], -rot[6], rot[0]],
38
- ];
39
- const sh2 = [
40
- [
41
- kSqrt01_04 * ((sh1[2][2] * sh1[0][0] + sh1[2][0] * sh1[0][2]) + (sh1[0][2] * sh1[2][0] + sh1[0][0] * sh1[2][2])),
42
- (sh1[2][1] * sh1[0][0] + sh1[0][1] * sh1[2][0]),
43
- kSqrt03_04 * (sh1[2][1] * sh1[0][1] + sh1[0][1] * sh1[2][1]),
44
- (sh1[2][1] * sh1[0][2] + sh1[0][1] * sh1[2][2]),
45
- kSqrt01_04 * ((sh1[2][2] * sh1[0][2] - sh1[2][0] * sh1[0][0]) + (sh1[0][2] * sh1[2][2] - sh1[0][0] * sh1[2][0])),
46
- ],
47
- [
48
- kSqrt01_04 * ((sh1[1][2] * sh1[0][0] + sh1[1][0] * sh1[0][2]) + (sh1[0][2] * sh1[1][0] + sh1[0][0] * sh1[1][2])),
49
- sh1[1][1] * sh1[0][0] + sh1[0][1] * sh1[1][0],
50
- kSqrt03_04 * (sh1[1][1] * sh1[0][1] + sh1[0][1] * sh1[1][1]),
51
- sh1[1][1] * sh1[0][2] + sh1[0][1] * sh1[1][2],
52
- kSqrt01_04 * ((sh1[1][2] * sh1[0][2] - sh1[1][0] * sh1[0][0]) + (sh1[0][2] * sh1[1][2] - sh1[0][0] * sh1[1][0])),
53
- ],
54
- [
55
- kSqrt01_03 * (sh1[1][2] * sh1[1][0] + sh1[1][0] * sh1[1][2]) - kSqrt01_12 * ((sh1[2][2] * sh1[2][0] + sh1[2][0] * sh1[2][2]) + (sh1[0][2] * sh1[0][0] + sh1[0][0] * sh1[0][2])),
56
- kSqrt04_03 * sh1[1][1] * sh1[1][0] - kSqrt01_03 * (sh1[2][1] * sh1[2][0] + sh1[0][1] * sh1[0][0]),
57
- sh1[1][1] * sh1[1][1] - kSqrt01_04 * (sh1[2][1] * sh1[2][1] + sh1[0][1] * sh1[0][1]),
58
- kSqrt04_03 * sh1[1][1] * sh1[1][2] - kSqrt01_03 * (sh1[2][1] * sh1[2][2] + sh1[0][1] * sh1[0][2]),
59
- kSqrt01_03 * (sh1[1][2] * sh1[1][2] - sh1[1][0] * sh1[1][0]) - kSqrt01_12 * ((sh1[2][2] * sh1[2][2] - sh1[2][0] * sh1[2][0]) + (sh1[0][2] * sh1[0][2] - sh1[0][0] * sh1[0][0])),
60
- ], [
61
- kSqrt01_04 * ((sh1[1][2] * sh1[2][0] + sh1[1][0] * sh1[2][2]) + (sh1[2][2] * sh1[1][0] + sh1[2][0] * sh1[1][2])),
62
- sh1[1][1] * sh1[2][0] + sh1[2][1] * sh1[1][0],
63
- kSqrt03_04 * (sh1[1][1] * sh1[2][1] + sh1[2][1] * sh1[1][1]),
64
- sh1[1][1] * sh1[2][2] + sh1[2][1] * sh1[1][2],
65
- kSqrt01_04 * ((sh1[1][2] * sh1[2][2] - sh1[1][0] * sh1[2][0]) + (sh1[2][2] * sh1[1][2] - sh1[2][0] * sh1[1][0])),
66
- ],
67
- [
68
- kSqrt01_04 * ((sh1[2][2] * sh1[2][0] + sh1[2][0] * sh1[2][2]) - (sh1[0][2] * sh1[0][0] + sh1[0][0] * sh1[0][2])),
69
- (sh1[2][1] * sh1[2][0] - sh1[0][1] * sh1[0][0]),
70
- kSqrt03_04 * (sh1[2][1] * sh1[2][1] - sh1[0][1] * sh1[0][1]),
71
- (sh1[2][1] * sh1[2][2] - sh1[0][1] * sh1[0][2]),
72
- kSqrt01_04 * ((sh1[2][2] * sh1[2][2] - sh1[2][0] * sh1[2][0]) - (sh1[0][2] * sh1[0][2] - sh1[0][0] * sh1[0][0])),
73
- ],
74
- ];
75
- const sh3 = [
76
- [
77
- kSqrt01_04 * ((sh1[2][2] * sh2[0][0] + sh1[2][0] * sh2[0][4]) + (sh1[0][2] * sh2[4][0] + sh1[0][0] * sh2[4][4])),
78
- kSqrt03_02 * (sh1[2][1] * sh2[0][0] + sh1[0][1] * sh2[4][0]),
79
- kSqrt15_16 * (sh1[2][1] * sh2[0][1] + sh1[0][1] * sh2[4][1]),
80
- kSqrt05_06 * (sh1[2][1] * sh2[0][2] + sh1[0][1] * sh2[4][2]),
81
- kSqrt15_16 * (sh1[2][1] * sh2[0][3] + sh1[0][1] * sh2[4][3]),
82
- kSqrt03_02 * (sh1[2][1] * sh2[0][4] + sh1[0][1] * sh2[4][4]),
83
- kSqrt01_04 * ((sh1[2][2] * sh2[0][4] - sh1[2][0] * sh2[0][0]) + (sh1[0][2] * sh2[4][4] - sh1[0][0] * sh2[4][0])),
84
- ],
85
- [
86
- kSqrt01_06 * (sh1[1][2] * sh2[0][0] + sh1[1][0] * sh2[0][4]) + kSqrt01_06 * ((sh1[2][2] * sh2[1][0] + sh1[2][0] * sh2[1][4]) + (sh1[0][2] * sh2[3][0] + sh1[0][0] * sh2[3][4])),
87
- sh1[1][1] * sh2[0][0] + (sh1[2][1] * sh2[1][0] + sh1[0][1] * sh2[3][0]),
88
- kSqrt05_08 * sh1[1][1] * sh2[0][1] + kSqrt05_08 * (sh1[2][1] * sh2[1][1] + sh1[0][1] * sh2[3][1]),
89
- kSqrt05_09 * sh1[1][1] * sh2[0][2] + kSqrt05_09 * (sh1[2][1] * sh2[1][2] + sh1[0][1] * sh2[3][2]),
90
- kSqrt05_08 * sh1[1][1] * sh2[0][3] + kSqrt05_08 * (sh1[2][1] * sh2[1][3] + sh1[0][1] * sh2[3][3]),
91
- sh1[1][1] * sh2[0][4] + (sh1[2][1] * sh2[1][4] + sh1[0][1] * sh2[3][4]),
92
- kSqrt01_06 * (sh1[1][2] * sh2[0][4] - sh1[1][0] * sh2[0][0]) + kSqrt01_06 * ((sh1[2][2] * sh2[1][4] - sh1[2][0] * sh2[1][0]) + (sh1[0][2] * sh2[3][4] - sh1[0][0] * sh2[3][0])),
93
- ],
94
- [
95
- kSqrt04_15 * (sh1[1][2] * sh2[1][0] + sh1[1][0] * sh2[1][4]) + kSqrt01_05 * (sh1[0][2] * sh2[2][0] + sh1[0][0] * sh2[2][4]) - kSqrt01_60 * ((sh1[2][2] * sh2[0][0] + sh1[2][0] * sh2[0][4]) - (sh1[0][2] * sh2[4][0] + sh1[0][0] * sh2[4][4])),
96
- kSqrt08_05 * sh1[1][1] * sh2[1][0] + kSqrt06_05 * sh1[0][1] * sh2[2][0] - kSqrt01_10 * (sh1[2][1] * sh2[0][0] - sh1[0][1] * sh2[4][0]),
97
- sh1[1][1] * sh2[1][1] + kSqrt03_04 * sh1[0][1] * sh2[2][1] - kSqrt01_16 * (sh1[2][1] * sh2[0][1] - sh1[0][1] * sh2[4][1]),
98
- kSqrt08_09 * sh1[1][1] * sh2[1][2] + kSqrt02_03 * sh1[0][1] * sh2[2][2] - kSqrt01_18 * (sh1[2][1] * sh2[0][2] - sh1[0][1] * sh2[4][2]),
99
- sh1[1][1] * sh2[1][3] + kSqrt03_04 * sh1[0][1] * sh2[2][3] - kSqrt01_16 * (sh1[2][1] * sh2[0][3] - sh1[0][1] * sh2[4][3]),
100
- kSqrt08_05 * sh1[1][1] * sh2[1][4] + kSqrt06_05 * sh1[0][1] * sh2[2][4] - kSqrt01_10 * (sh1[2][1] * sh2[0][4] - sh1[0][1] * sh2[4][4]),
101
- kSqrt04_15 * (sh1[1][2] * sh2[1][4] - sh1[1][0] * sh2[1][0]) + kSqrt01_05 * (sh1[0][2] * sh2[2][4] - sh1[0][0] * sh2[2][0]) - kSqrt01_60 * ((sh1[2][2] * sh2[0][4] - sh1[2][0] * sh2[0][0]) - (sh1[0][2] * sh2[4][4] - sh1[0][0] * sh2[4][0])),
102
- ],
103
- [
104
- kSqrt03_10 * (sh1[1][2] * sh2[2][0] + sh1[1][0] * sh2[2][4]) - kSqrt01_10 * ((sh1[2][2] * sh2[3][0] + sh1[2][0] * sh2[3][4]) + (sh1[0][2] * sh2[1][0] + sh1[0][0] * sh2[1][4])),
105
- kSqrt09_05 * sh1[1][1] * sh2[2][0] - kSqrt03_05 * (sh1[2][1] * sh2[3][0] + sh1[0][1] * sh2[1][0]),
106
- kSqrt09_08 * sh1[1][1] * sh2[2][1] - kSqrt03_08 * (sh1[2][1] * sh2[3][1] + sh1[0][1] * sh2[1][1]),
107
- sh1[1][1] * sh2[2][2] - kSqrt01_03 * (sh1[2][1] * sh2[3][2] + sh1[0][1] * sh2[1][2]),
108
- kSqrt09_08 * sh1[1][1] * sh2[2][3] - kSqrt03_08 * (sh1[2][1] * sh2[3][3] + sh1[0][1] * sh2[1][3]),
109
- kSqrt09_05 * sh1[1][1] * sh2[2][4] - kSqrt03_05 * (sh1[2][1] * sh2[3][4] + sh1[0][1] * sh2[1][4]),
110
- kSqrt03_10 * (sh1[1][2] * sh2[2][4] - sh1[1][0] * sh2[2][0]) - kSqrt01_10 * ((sh1[2][2] * sh2[3][4] - sh1[2][0] * sh2[3][0]) + (sh1[0][2] * sh2[1][4] - sh1[0][0] * sh2[1][0])),
111
- ],
112
- [
113
- kSqrt04_15 * (sh1[1][2] * sh2[3][0] + sh1[1][0] * sh2[3][4]) + kSqrt01_05 * (sh1[2][2] * sh2[2][0] + sh1[2][0] * sh2[2][4]) - kSqrt01_60 * ((sh1[2][2] * sh2[4][0] + sh1[2][0] * sh2[4][4]) + (sh1[0][2] * sh2[0][0] + sh1[0][0] * sh2[0][4])),
114
- kSqrt08_05 * sh1[1][1] * sh2[3][0] + kSqrt06_05 * sh1[2][1] * sh2[2][0] - kSqrt01_10 * (sh1[2][1] * sh2[4][0] + sh1[0][1] * sh2[0][0]),
115
- sh1[1][1] * sh2[3][1] + kSqrt03_04 * sh1[2][1] * sh2[2][1] - kSqrt01_16 * (sh1[2][1] * sh2[4][1] + sh1[0][1] * sh2[0][1]),
116
- kSqrt08_09 * sh1[1][1] * sh2[3][2] + kSqrt02_03 * sh1[2][1] * sh2[2][2] - kSqrt01_18 * (sh1[2][1] * sh2[4][2] + sh1[0][1] * sh2[0][2]),
117
- sh1[1][1] * sh2[3][3] + kSqrt03_04 * sh1[2][1] * sh2[2][3] - kSqrt01_16 * (sh1[2][1] * sh2[4][3] + sh1[0][1] * sh2[0][3]),
118
- kSqrt08_05 * sh1[1][1] * sh2[3][4] + kSqrt06_05 * sh1[2][1] * sh2[2][4] - kSqrt01_10 * (sh1[2][1] * sh2[4][4] + sh1[0][1] * sh2[0][4]),
119
- kSqrt04_15 * (sh1[1][2] * sh2[3][4] - sh1[1][0] * sh2[3][0]) + kSqrt01_05 * (sh1[2][2] * sh2[2][4] - sh1[2][0] * sh2[2][0]) - kSqrt01_60 * ((sh1[2][2] * sh2[4][4] - sh1[2][0] * sh2[4][0]) + (sh1[0][2] * sh2[0][4] - sh1[0][0] * sh2[0][0])),
120
- ],
121
- [
122
- kSqrt01_06 * (sh1[1][2] * sh2[4][0] + sh1[1][0] * sh2[4][4]) + kSqrt01_06 * ((sh1[2][2] * sh2[3][0] + sh1[2][0] * sh2[3][4]) - (sh1[0][2] * sh2[1][0] + sh1[0][0] * sh2[1][4])),
123
- sh1[1][1] * sh2[4][0] + (sh1[2][1] * sh2[3][0] - sh1[0][1] * sh2[1][0]),
124
- kSqrt05_08 * sh1[1][1] * sh2[4][1] + kSqrt05_08 * (sh1[2][1] * sh2[3][1] - sh1[0][1] * sh2[1][1]),
125
- kSqrt05_09 * sh1[1][1] * sh2[4][2] + kSqrt05_09 * (sh1[2][1] * sh2[3][2] - sh1[0][1] * sh2[1][2]),
126
- kSqrt05_08 * sh1[1][1] * sh2[4][3] + kSqrt05_08 * (sh1[2][1] * sh2[3][3] - sh1[0][1] * sh2[1][3]),
127
- sh1[1][1] * sh2[4][4] + (sh1[2][1] * sh2[3][4] - sh1[0][1] * sh2[1][4]),
128
- kSqrt01_06 * (sh1[1][2] * sh2[4][4] - sh1[1][0] * sh2[4][0]) + kSqrt01_06 * ((sh1[2][2] * sh2[3][4] - sh1[2][0] * sh2[3][0]) - (sh1[0][2] * sh2[1][4] - sh1[0][0] * sh2[1][0])),
129
- ],
130
- [
131
- kSqrt01_04 * ((sh1[2][2] * sh2[4][0] + sh1[2][0] * sh2[4][4]) - (sh1[0][2] * sh2[0][0] + sh1[0][0] * sh2[0][4])),
132
- kSqrt03_02 * (sh1[2][1] * sh2[4][0] - sh1[0][1] * sh2[0][0]),
133
- kSqrt15_16 * (sh1[2][1] * sh2[4][1] - sh1[0][1] * sh2[0][1]),
134
- kSqrt05_06 * (sh1[2][1] * sh2[4][2] - sh1[0][1] * sh2[0][2]),
135
- kSqrt15_16 * (sh1[2][1] * sh2[4][3] - sh1[0][1] * sh2[0][3]),
136
- kSqrt03_02 * (sh1[2][1] * sh2[4][4] - sh1[0][1] * sh2[0][4]),
137
- kSqrt01_04 * ((sh1[2][2] * sh2[4][4] - sh1[2][0] * sh2[4][0]) - (sh1[0][2] * sh2[0][4] - sh1[0][0] * sh2[0][0])),
138
- ],
139
- ];
140
- const dp = (n, start, a, b) => {
141
- let sum = 0;
142
- for (let i = 0; i < n; i++) {
143
- sum += a[start + i] * b[i];
144
- }
145
- return sum;
146
- };
147
- const temp = new Float32Array(15);
148
- return (shN) => {
149
- temp.set(shN);
150
- if (shN.length < 3) {
151
- return;
152
- }
153
- shN[0] = dp(3, 0, temp, sh1[0]);
154
- shN[1] = dp(3, 0, temp, sh1[1]);
155
- shN[2] = dp(3, 0, temp, sh1[2]);
156
- if (shN.length < 8) {
157
- return;
158
- }
159
- shN[3] = dp(5, 3, temp, sh2[0]);
160
- shN[4] = dp(5, 3, temp, sh2[1]);
161
- shN[5] = dp(5, 3, temp, sh2[2]);
162
- shN[6] = dp(5, 3, temp, sh2[3]);
163
- shN[7] = dp(5, 3, temp, sh2[4]);
164
- if (shN.length < 15) {
165
- return;
166
- }
167
- shN[8] = dp(7, 8, temp, sh3[0]);
168
- shN[9] = dp(7, 8, temp, sh3[1]);
169
- shN[10] = dp(7, 8, temp, sh3[2]);
170
- shN[11] = dp(7, 8, temp, sh3[3]);
171
- shN[12] = dp(7, 8, temp, sh3[4]);
172
- shN[13] = dp(7, 8, temp, sh3[5]);
173
- shN[14] = dp(7, 8, temp, sh3[6]);
174
- };
175
- }
1
+ /**
2
+ * Rotate spherical harmonics up to band 3 based on https://github.com/andrewwillmott/sh-lib
3
+ * This implementation calculates the rotation factors during construction which can then
4
+ * be used to rotate multiple spherical harmonics cheaply.
5
+ */
6
+ const kSqrt03_02 = Math.sqrt(3.0 / 2.0);
7
+ const kSqrt01_03 = Math.sqrt(1.0 / 3.0);
8
+ const kSqrt02_03 = Math.sqrt(2.0 / 3.0);
9
+ const kSqrt04_03 = Math.sqrt(4.0 / 3.0);
10
+ const kSqrt01_04 = Math.sqrt(1.0 / 4.0);
11
+ const kSqrt03_04 = Math.sqrt(3.0 / 4.0);
12
+ const kSqrt01_05 = Math.sqrt(1.0 / 5.0);
13
+ const kSqrt03_05 = Math.sqrt(3.0 / 5.0);
14
+ const kSqrt06_05 = Math.sqrt(6.0 / 5.0);
15
+ const kSqrt08_05 = Math.sqrt(8.0 / 5.0);
16
+ const kSqrt09_05 = Math.sqrt(9.0 / 5.0);
17
+ const kSqrt01_06 = Math.sqrt(1.0 / 6.0);
18
+ const kSqrt05_06 = Math.sqrt(5.0 / 6.0);
19
+ const kSqrt03_08 = Math.sqrt(3.0 / 8.0);
20
+ const kSqrt05_08 = Math.sqrt(5.0 / 8.0);
21
+ const kSqrt09_08 = Math.sqrt(9.0 / 8.0);
22
+ const kSqrt05_09 = Math.sqrt(5.0 / 9.0);
23
+ const kSqrt08_09 = Math.sqrt(8.0 / 9.0);
24
+ const kSqrt01_10 = Math.sqrt(1.0 / 10.0);
25
+ const kSqrt03_10 = Math.sqrt(3.0 / 10.0);
26
+ const kSqrt01_12 = Math.sqrt(1.0 / 12.0);
27
+ const kSqrt04_15 = Math.sqrt(4.0 / 15.0);
28
+ const kSqrt01_16 = Math.sqrt(1.0 / 16.0);
29
+ const kSqrt15_16 = Math.sqrt(15.0 / 16.0);
30
+ const kSqrt01_18 = Math.sqrt(1.0 / 18.0);
31
+ const kSqrt01_60 = Math.sqrt(1.0 / 60.0);
32
+ export function createSHRotateFn(mat) {
33
+ const rot = mat.elements;
34
+ const sh1 = [
35
+ [rot[4], -rot[7], rot[1]],
36
+ [-rot[5], rot[8], -rot[2]],
37
+ [rot[3], -rot[6], rot[0]],
38
+ ];
39
+ const sh2 = [
40
+ [
41
+ kSqrt01_04 *
42
+ (sh1[2][2] * sh1[0][0] + sh1[2][0] * sh1[0][2] + (sh1[0][2] * sh1[2][0] + sh1[0][0] * sh1[2][2])),
43
+ sh1[2][1] * sh1[0][0] + sh1[0][1] * sh1[2][0],
44
+ kSqrt03_04 * (sh1[2][1] * sh1[0][1] + sh1[0][1] * sh1[2][1]),
45
+ sh1[2][1] * sh1[0][2] + sh1[0][1] * sh1[2][2],
46
+ kSqrt01_04 *
47
+ (sh1[2][2] * sh1[0][2] - sh1[2][0] * sh1[0][0] + (sh1[0][2] * sh1[2][2] - sh1[0][0] * sh1[2][0])),
48
+ ],
49
+ [
50
+ kSqrt01_04 *
51
+ (sh1[1][2] * sh1[0][0] + sh1[1][0] * sh1[0][2] + (sh1[0][2] * sh1[1][0] + sh1[0][0] * sh1[1][2])),
52
+ sh1[1][1] * sh1[0][0] + sh1[0][1] * sh1[1][0],
53
+ kSqrt03_04 * (sh1[1][1] * sh1[0][1] + sh1[0][1] * sh1[1][1]),
54
+ sh1[1][1] * sh1[0][2] + sh1[0][1] * sh1[1][2],
55
+ kSqrt01_04 *
56
+ (sh1[1][2] * sh1[0][2] - sh1[1][0] * sh1[0][0] + (sh1[0][2] * sh1[1][2] - sh1[0][0] * sh1[1][0])),
57
+ ],
58
+ [
59
+ kSqrt01_03 * (sh1[1][2] * sh1[1][0] + sh1[1][0] * sh1[1][2]) -
60
+ kSqrt01_12 *
61
+ (sh1[2][2] * sh1[2][0] + sh1[2][0] * sh1[2][2] + (sh1[0][2] * sh1[0][0] + sh1[0][0] * sh1[0][2])),
62
+ kSqrt04_03 * sh1[1][1] * sh1[1][0] - kSqrt01_03 * (sh1[2][1] * sh1[2][0] + sh1[0][1] * sh1[0][0]),
63
+ sh1[1][1] * sh1[1][1] - kSqrt01_04 * (sh1[2][1] * sh1[2][1] + sh1[0][1] * sh1[0][1]),
64
+ kSqrt04_03 * sh1[1][1] * sh1[1][2] - kSqrt01_03 * (sh1[2][1] * sh1[2][2] + sh1[0][1] * sh1[0][2]),
65
+ kSqrt01_03 * (sh1[1][2] * sh1[1][2] - sh1[1][0] * sh1[1][0]) -
66
+ kSqrt01_12 *
67
+ (sh1[2][2] * sh1[2][2] - sh1[2][0] * sh1[2][0] + (sh1[0][2] * sh1[0][2] - sh1[0][0] * sh1[0][0])),
68
+ ],
69
+ [
70
+ kSqrt01_04 *
71
+ (sh1[1][2] * sh1[2][0] + sh1[1][0] * sh1[2][2] + (sh1[2][2] * sh1[1][0] + sh1[2][0] * sh1[1][2])),
72
+ sh1[1][1] * sh1[2][0] + sh1[2][1] * sh1[1][0],
73
+ kSqrt03_04 * (sh1[1][1] * sh1[2][1] + sh1[2][1] * sh1[1][1]),
74
+ sh1[1][1] * sh1[2][2] + sh1[2][1] * sh1[1][2],
75
+ kSqrt01_04 *
76
+ (sh1[1][2] * sh1[2][2] - sh1[1][0] * sh1[2][0] + (sh1[2][2] * sh1[1][2] - sh1[2][0] * sh1[1][0])),
77
+ ],
78
+ [
79
+ kSqrt01_04 *
80
+ (sh1[2][2] * sh1[2][0] + sh1[2][0] * sh1[2][2] - (sh1[0][2] * sh1[0][0] + sh1[0][0] * sh1[0][2])),
81
+ sh1[2][1] * sh1[2][0] - sh1[0][1] * sh1[0][0],
82
+ kSqrt03_04 * (sh1[2][1] * sh1[2][1] - sh1[0][1] * sh1[0][1]),
83
+ sh1[2][1] * sh1[2][2] - sh1[0][1] * sh1[0][2],
84
+ kSqrt01_04 *
85
+ (sh1[2][2] * sh1[2][2] - sh1[2][0] * sh1[2][0] - (sh1[0][2] * sh1[0][2] - sh1[0][0] * sh1[0][0])),
86
+ ],
87
+ ];
88
+ const sh3 = [
89
+ [
90
+ kSqrt01_04 *
91
+ (sh1[2][2] * sh2[0][0] + sh1[2][0] * sh2[0][4] + (sh1[0][2] * sh2[4][0] + sh1[0][0] * sh2[4][4])),
92
+ kSqrt03_02 * (sh1[2][1] * sh2[0][0] + sh1[0][1] * sh2[4][0]),
93
+ kSqrt15_16 * (sh1[2][1] * sh2[0][1] + sh1[0][1] * sh2[4][1]),
94
+ kSqrt05_06 * (sh1[2][1] * sh2[0][2] + sh1[0][1] * sh2[4][2]),
95
+ kSqrt15_16 * (sh1[2][1] * sh2[0][3] + sh1[0][1] * sh2[4][3]),
96
+ kSqrt03_02 * (sh1[2][1] * sh2[0][4] + sh1[0][1] * sh2[4][4]),
97
+ kSqrt01_04 *
98
+ (sh1[2][2] * sh2[0][4] - sh1[2][0] * sh2[0][0] + (sh1[0][2] * sh2[4][4] - sh1[0][0] * sh2[4][0])),
99
+ ],
100
+ [
101
+ kSqrt01_06 * (sh1[1][2] * sh2[0][0] + sh1[1][0] * sh2[0][4]) +
102
+ kSqrt01_06 *
103
+ (sh1[2][2] * sh2[1][0] + sh1[2][0] * sh2[1][4] + (sh1[0][2] * sh2[3][0] + sh1[0][0] * sh2[3][4])),
104
+ sh1[1][1] * sh2[0][0] + (sh1[2][1] * sh2[1][0] + sh1[0][1] * sh2[3][0]),
105
+ kSqrt05_08 * sh1[1][1] * sh2[0][1] + kSqrt05_08 * (sh1[2][1] * sh2[1][1] + sh1[0][1] * sh2[3][1]),
106
+ kSqrt05_09 * sh1[1][1] * sh2[0][2] + kSqrt05_09 * (sh1[2][1] * sh2[1][2] + sh1[0][1] * sh2[3][2]),
107
+ kSqrt05_08 * sh1[1][1] * sh2[0][3] + kSqrt05_08 * (sh1[2][1] * sh2[1][3] + sh1[0][1] * sh2[3][3]),
108
+ sh1[1][1] * sh2[0][4] + (sh1[2][1] * sh2[1][4] + sh1[0][1] * sh2[3][4]),
109
+ kSqrt01_06 * (sh1[1][2] * sh2[0][4] - sh1[1][0] * sh2[0][0]) +
110
+ kSqrt01_06 *
111
+ (sh1[2][2] * sh2[1][4] - sh1[2][0] * sh2[1][0] + (sh1[0][2] * sh2[3][4] - sh1[0][0] * sh2[3][0])),
112
+ ],
113
+ [
114
+ kSqrt04_15 * (sh1[1][2] * sh2[1][0] + sh1[1][0] * sh2[1][4]) +
115
+ kSqrt01_05 * (sh1[0][2] * sh2[2][0] + sh1[0][0] * sh2[2][4]) -
116
+ kSqrt01_60 *
117
+ (sh1[2][2] * sh2[0][0] + sh1[2][0] * sh2[0][4] - (sh1[0][2] * sh2[4][0] + sh1[0][0] * sh2[4][4])),
118
+ kSqrt08_05 * sh1[1][1] * sh2[1][0] +
119
+ kSqrt06_05 * sh1[0][1] * sh2[2][0] -
120
+ kSqrt01_10 * (sh1[2][1] * sh2[0][0] - sh1[0][1] * sh2[4][0]),
121
+ sh1[1][1] * sh2[1][1] +
122
+ kSqrt03_04 * sh1[0][1] * sh2[2][1] -
123
+ kSqrt01_16 * (sh1[2][1] * sh2[0][1] - sh1[0][1] * sh2[4][1]),
124
+ kSqrt08_09 * sh1[1][1] * sh2[1][2] +
125
+ kSqrt02_03 * sh1[0][1] * sh2[2][2] -
126
+ kSqrt01_18 * (sh1[2][1] * sh2[0][2] - sh1[0][1] * sh2[4][2]),
127
+ sh1[1][1] * sh2[1][3] +
128
+ kSqrt03_04 * sh1[0][1] * sh2[2][3] -
129
+ kSqrt01_16 * (sh1[2][1] * sh2[0][3] - sh1[0][1] * sh2[4][3]),
130
+ kSqrt08_05 * sh1[1][1] * sh2[1][4] +
131
+ kSqrt06_05 * sh1[0][1] * sh2[2][4] -
132
+ kSqrt01_10 * (sh1[2][1] * sh2[0][4] - sh1[0][1] * sh2[4][4]),
133
+ kSqrt04_15 * (sh1[1][2] * sh2[1][4] - sh1[1][0] * sh2[1][0]) +
134
+ kSqrt01_05 * (sh1[0][2] * sh2[2][4] - sh1[0][0] * sh2[2][0]) -
135
+ kSqrt01_60 *
136
+ (sh1[2][2] * sh2[0][4] - sh1[2][0] * sh2[0][0] - (sh1[0][2] * sh2[4][4] - sh1[0][0] * sh2[4][0])),
137
+ ],
138
+ [
139
+ kSqrt03_10 * (sh1[1][2] * sh2[2][0] + sh1[1][0] * sh2[2][4]) -
140
+ kSqrt01_10 *
141
+ (sh1[2][2] * sh2[3][0] + sh1[2][0] * sh2[3][4] + (sh1[0][2] * sh2[1][0] + sh1[0][0] * sh2[1][4])),
142
+ kSqrt09_05 * sh1[1][1] * sh2[2][0] - kSqrt03_05 * (sh1[2][1] * sh2[3][0] + sh1[0][1] * sh2[1][0]),
143
+ kSqrt09_08 * sh1[1][1] * sh2[2][1] - kSqrt03_08 * (sh1[2][1] * sh2[3][1] + sh1[0][1] * sh2[1][1]),
144
+ sh1[1][1] * sh2[2][2] - kSqrt01_03 * (sh1[2][1] * sh2[3][2] + sh1[0][1] * sh2[1][2]),
145
+ kSqrt09_08 * sh1[1][1] * sh2[2][3] - kSqrt03_08 * (sh1[2][1] * sh2[3][3] + sh1[0][1] * sh2[1][3]),
146
+ kSqrt09_05 * sh1[1][1] * sh2[2][4] - kSqrt03_05 * (sh1[2][1] * sh2[3][4] + sh1[0][1] * sh2[1][4]),
147
+ kSqrt03_10 * (sh1[1][2] * sh2[2][4] - sh1[1][0] * sh2[2][0]) -
148
+ kSqrt01_10 *
149
+ (sh1[2][2] * sh2[3][4] - sh1[2][0] * sh2[3][0] + (sh1[0][2] * sh2[1][4] - sh1[0][0] * sh2[1][0])),
150
+ ],
151
+ [
152
+ kSqrt04_15 * (sh1[1][2] * sh2[3][0] + sh1[1][0] * sh2[3][4]) +
153
+ kSqrt01_05 * (sh1[2][2] * sh2[2][0] + sh1[2][0] * sh2[2][4]) -
154
+ kSqrt01_60 *
155
+ (sh1[2][2] * sh2[4][0] + sh1[2][0] * sh2[4][4] + (sh1[0][2] * sh2[0][0] + sh1[0][0] * sh2[0][4])),
156
+ kSqrt08_05 * sh1[1][1] * sh2[3][0] +
157
+ kSqrt06_05 * sh1[2][1] * sh2[2][0] -
158
+ kSqrt01_10 * (sh1[2][1] * sh2[4][0] + sh1[0][1] * sh2[0][0]),
159
+ sh1[1][1] * sh2[3][1] +
160
+ kSqrt03_04 * sh1[2][1] * sh2[2][1] -
161
+ kSqrt01_16 * (sh1[2][1] * sh2[4][1] + sh1[0][1] * sh2[0][1]),
162
+ kSqrt08_09 * sh1[1][1] * sh2[3][2] +
163
+ kSqrt02_03 * sh1[2][1] * sh2[2][2] -
164
+ kSqrt01_18 * (sh1[2][1] * sh2[4][2] + sh1[0][1] * sh2[0][2]),
165
+ sh1[1][1] * sh2[3][3] +
166
+ kSqrt03_04 * sh1[2][1] * sh2[2][3] -
167
+ kSqrt01_16 * (sh1[2][1] * sh2[4][3] + sh1[0][1] * sh2[0][3]),
168
+ kSqrt08_05 * sh1[1][1] * sh2[3][4] +
169
+ kSqrt06_05 * sh1[2][1] * sh2[2][4] -
170
+ kSqrt01_10 * (sh1[2][1] * sh2[4][4] + sh1[0][1] * sh2[0][4]),
171
+ kSqrt04_15 * (sh1[1][2] * sh2[3][4] - sh1[1][0] * sh2[3][0]) +
172
+ kSqrt01_05 * (sh1[2][2] * sh2[2][4] - sh1[2][0] * sh2[2][0]) -
173
+ kSqrt01_60 *
174
+ (sh1[2][2] * sh2[4][4] - sh1[2][0] * sh2[4][0] + (sh1[0][2] * sh2[0][4] - sh1[0][0] * sh2[0][0])),
175
+ ],
176
+ [
177
+ kSqrt01_06 * (sh1[1][2] * sh2[4][0] + sh1[1][0] * sh2[4][4]) +
178
+ kSqrt01_06 *
179
+ (sh1[2][2] * sh2[3][0] + sh1[2][0] * sh2[3][4] - (sh1[0][2] * sh2[1][0] + sh1[0][0] * sh2[1][4])),
180
+ sh1[1][1] * sh2[4][0] + (sh1[2][1] * sh2[3][0] - sh1[0][1] * sh2[1][0]),
181
+ kSqrt05_08 * sh1[1][1] * sh2[4][1] + kSqrt05_08 * (sh1[2][1] * sh2[3][1] - sh1[0][1] * sh2[1][1]),
182
+ kSqrt05_09 * sh1[1][1] * sh2[4][2] + kSqrt05_09 * (sh1[2][1] * sh2[3][2] - sh1[0][1] * sh2[1][2]),
183
+ kSqrt05_08 * sh1[1][1] * sh2[4][3] + kSqrt05_08 * (sh1[2][1] * sh2[3][3] - sh1[0][1] * sh2[1][3]),
184
+ sh1[1][1] * sh2[4][4] + (sh1[2][1] * sh2[3][4] - sh1[0][1] * sh2[1][4]),
185
+ kSqrt01_06 * (sh1[1][2] * sh2[4][4] - sh1[1][0] * sh2[4][0]) +
186
+ kSqrt01_06 *
187
+ (sh1[2][2] * sh2[3][4] - sh1[2][0] * sh2[3][0] - (sh1[0][2] * sh2[1][4] - sh1[0][0] * sh2[1][0])),
188
+ ],
189
+ [
190
+ kSqrt01_04 *
191
+ (sh1[2][2] * sh2[4][0] + sh1[2][0] * sh2[4][4] - (sh1[0][2] * sh2[0][0] + sh1[0][0] * sh2[0][4])),
192
+ kSqrt03_02 * (sh1[2][1] * sh2[4][0] - sh1[0][1] * sh2[0][0]),
193
+ kSqrt15_16 * (sh1[2][1] * sh2[4][1] - sh1[0][1] * sh2[0][1]),
194
+ kSqrt05_06 * (sh1[2][1] * sh2[4][2] - sh1[0][1] * sh2[0][2]),
195
+ kSqrt15_16 * (sh1[2][1] * sh2[4][3] - sh1[0][1] * sh2[0][3]),
196
+ kSqrt03_02 * (sh1[2][1] * sh2[4][4] - sh1[0][1] * sh2[0][4]),
197
+ kSqrt01_04 *
198
+ (sh1[2][2] * sh2[4][4] - sh1[2][0] * sh2[4][0] - (sh1[0][2] * sh2[0][4] - sh1[0][0] * sh2[0][0])),
199
+ ],
200
+ ];
201
+ const dp = (n, start, a, b) => {
202
+ let sum = 0;
203
+ for (let i = 0; i < n; i++) {
204
+ sum += a[start + i] * b[i];
205
+ }
206
+ return sum;
207
+ };
208
+ const temp = new Float32Array(15);
209
+ return (shN) => {
210
+ temp.set(shN);
211
+ if (shN.length < 3) {
212
+ return;
213
+ }
214
+ shN[0] = dp(3, 0, temp, sh1[0]);
215
+ shN[1] = dp(3, 0, temp, sh1[1]);
216
+ shN[2] = dp(3, 0, temp, sh1[2]);
217
+ if (shN.length < 8) {
218
+ return;
219
+ }
220
+ shN[3] = dp(5, 3, temp, sh2[0]);
221
+ shN[4] = dp(5, 3, temp, sh2[1]);
222
+ shN[5] = dp(5, 3, temp, sh2[2]);
223
+ shN[6] = dp(5, 3, temp, sh2[3]);
224
+ shN[7] = dp(5, 3, temp, sh2[4]);
225
+ if (shN.length < 15) {
226
+ return;
227
+ }
228
+ shN[8] = dp(7, 8, temp, sh3[0]);
229
+ shN[9] = dp(7, 8, temp, sh3[1]);
230
+ shN[10] = dp(7, 8, temp, sh3[2]);
231
+ shN[11] = dp(7, 8, temp, sh3[3]);
232
+ shN[12] = dp(7, 8, temp, sh3[4]);
233
+ shN[13] = dp(7, 8, temp, sh3[5]);
234
+ shN[14] = dp(7, 8, temp, sh3[6]);
235
+ };
236
+ }
@@ -1,21 +1,21 @@
1
- import { IFile } from '../file/index.js';
2
- import { SplatData } from '../SplatData.js';
3
- export declare enum SplatFileType {
4
- PLY = 0,
5
- SPZ = 1,
6
- USPZ = 2,// not gzip spz
7
- SPLAT = 3,
8
- KSPLAT = 4,
9
- SOG = 5,
10
- LCC = 6,
11
- ESZ = 7
12
- }
13
- export declare function detectSplatFileType(filename: string, buffer?: Uint8Array): SplatFileType | undefined;
14
- export declare function createSplatFile(path: string, buffer?: Uint8Array, compressLevel?: number, spzVersion?: number): IFile;
15
- export declare function combineSplatData(source: SplatData[]): SplatData;
16
- export declare function computeDenseBox(data: SplatData, ratio?: number): {
17
- min: number[];
18
- max: number[];
19
- };
20
- export declare function mortonSort(splat: SplatData): Uint32Array;
21
- export declare function fastDeleteSplat(splat: SplatData, indices: number[]): void;
1
+ import { type IFile } from '../file/index.js';
2
+ import { SplatData } from '../SplatData.js';
3
+ export declare enum SplatFileType {
4
+ PLY = 0,
5
+ SPZ = 1,
6
+ USPZ = 2,// not gzip spz
7
+ SPLAT = 3,
8
+ KSPLAT = 4,
9
+ SOG = 5,
10
+ LCC = 6,
11
+ ESZ = 7
12
+ }
13
+ export declare function detectSplatFileType(filename: string, buffer?: Uint8Array): SplatFileType | undefined;
14
+ export declare function createSplatFile(path: string, buffer?: Uint8Array, compressLevel?: number, spzVersion?: number): IFile;
15
+ export declare function combineSplatData(source: SplatData[]): SplatData;
16
+ export declare function computeDenseBox(data: SplatData, ratio?: number): {
17
+ min: number[];
18
+ max: number[];
19
+ };
20
+ export declare function mortonSort(splat: SplatData): Uint32Array;
21
+ export declare function fastDeleteSplat(splat: SplatData, indices: number[]): void;