@driftengine/splats 3.61.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 +202 -0
- package/NOTICE +9 -0
- package/README.md +56 -0
- package/dist/half.d.ts +32 -0
- package/dist/half.js +88 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +38 -0
- package/dist/shaders/generated/splat.wgsl.d.ts +89 -0
- package/dist/shaders/generated/splat.wgsl.js +95 -0
- package/dist/shaders/splat.d.ts +25 -0
- package/dist/shaders/splat.js +337 -0
- package/dist/splat.d.ts +26 -0
- package/dist/splat.js +63 -0
- package/dist/splatBudget.d.ts +40 -0
- package/dist/splatBudget.js +45 -0
- package/dist/splatCapture.d.ts +76 -0
- package/dist/splatCapture.js +108 -0
- package/dist/splatCull.d.ts +25 -0
- package/dist/splatCull.js +80 -0
- package/dist/splatData.d.ts +177 -0
- package/dist/splatData.js +223 -0
- package/dist/splatGl.d.ts +49 -0
- package/dist/splatGl.js +176 -0
- package/dist/splatGpu.d.ts +50 -0
- package/dist/splatGpu.js +180 -0
- package/dist/splatLayout.d.ts +52 -0
- package/dist/splatLayout.js +75 -0
- package/dist/splatMatrix.d.ts +29 -0
- package/dist/splatMatrix.js +68 -0
- package/dist/splatPass.d.ts +83 -0
- package/dist/splatPass.js +206 -0
- package/dist/splatPly.d.ts +14 -0
- package/dist/splatPly.js +242 -0
- package/dist/splatSog.d.ts +110 -0
- package/dist/splatSog.js +285 -0
- package/dist/splatSogDecoder.d.ts +26 -0
- package/dist/splatSogDecoder.js +29 -0
- package/dist/splatSort.d.ts +137 -0
- package/dist/splatSort.js +199 -0
- package/dist/splatSortWorker.d.ts +14 -0
- package/dist/splatSortWorker.js +137 -0
- package/dist/splatSorter.d.ts +112 -0
- package/dist/splatSorter.js +231 -0
- package/dist/splatView.d.ts +52 -0
- package/dist/splatView.js +115 -0
- package/package.json +56 -0
- package/src/fixtures/README.md +36 -0
- package/src/fixtures/cloud.sog +0 -0
- package/src/fixtures/cloud.texels.json +27 -0
- package/src/fixtures/cloud.truth.json +582 -0
- package/src/half.ts +92 -0
- package/src/index.ts +55 -0
- package/src/shaders/generated/splat.wgsl.ts +98 -0
- package/src/shaders/splat.ts +344 -0
- package/src/splat.ts +75 -0
- package/src/splatBudget.ts +48 -0
- package/src/splatCapture.ts +154 -0
- package/src/splatCull.ts +91 -0
- package/src/splatData.ts +398 -0
- package/src/splatGl.ts +262 -0
- package/src/splatGpu.ts +259 -0
- package/src/splatLayout.ts +86 -0
- package/src/splatMatrix.ts +81 -0
- package/src/splatPass.ts +324 -0
- package/src/splatPly.ts +283 -0
- package/src/splatSog.ts +375 -0
- package/src/splatSogDecoder.ts +33 -0
- package/src/splatSort.ts +296 -0
- package/src/splatSortWorker.ts +155 -0
- package/src/splatSorter.ts +285 -0
- package/src/splatView.ts +147 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"x": -2,
|
|
4
|
+
"y": 0,
|
|
5
|
+
"z": 2,
|
|
6
|
+
"scale": [0.02, 0.03, 0.04],
|
|
7
|
+
"opacity": 0.15,
|
|
8
|
+
"rotWxyz": [1, 0, 0, 0],
|
|
9
|
+
"colour": [0.2, 0.7, 0.45]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"x": -1.9365079365079365,
|
|
13
|
+
"y": 0.14264128137713222,
|
|
14
|
+
"z": 1.9959701119343136,
|
|
15
|
+
"scale": [0.021269841269841272, 0.030793650793650793, 0.04031746031746032],
|
|
16
|
+
"opacity": 0.1626984126984127,
|
|
17
|
+
"rotWxyz": [
|
|
18
|
+
0.9997165666780686, 0.014284364577724177, 0.01142749166217934, 0.015236655549572455
|
|
19
|
+
],
|
|
20
|
+
"colour": [0.20952380952380953, 0.692063492063492, 0.45]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"x": -1.873015873015873,
|
|
24
|
+
"y": 0.283989741915895,
|
|
25
|
+
"z": 1.9838966877350768,
|
|
26
|
+
"scale": [0.02253968253968254, 0.03158730158730159, 0.040634920634920635],
|
|
27
|
+
"opacity": 0.17539682539682538,
|
|
28
|
+
"rotWxyz": [
|
|
29
|
+
0.9988664273811704, 0.028560631825640465, 0.022848505460512373, 0.03046467394734983
|
|
30
|
+
],
|
|
31
|
+
"colour": [0.21904761904761905, 0.6841269841269841, 0.45]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"x": -1.8095238095238095,
|
|
35
|
+
"y": 0.4227642781833149,
|
|
36
|
+
"z": 1.963828381950382,
|
|
37
|
+
"scale": [0.023809523809523808, 0.03238095238095238, 0.040952380952380955],
|
|
38
|
+
"opacity": 0.1880952380952381,
|
|
39
|
+
"rotWxyz": [0.9974500640249153, 0.04282070900404716, 0.03425656720323773, 0.045675422937650305],
|
|
40
|
+
"colour": [0.2285714285714286, 0.6761904761904761, 0.45]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"x": -1.746031746031746,
|
|
44
|
+
"y": 0.5577071153571985,
|
|
45
|
+
"z": 1.935846067606209,
|
|
46
|
+
"scale": [0.02507936507936508, 0.033174603174603176, 0.04126984126984127],
|
|
47
|
+
"opacity": 0.2007936507936508,
|
|
48
|
+
"rotWxyz": [0.9954682794984456, 0.05705651255085288, 0.04564521004068231, 0.06086028005424308],
|
|
49
|
+
"colour": [0.2380952380952381, 0.6682539682539682, 0.45]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"x": -1.6825396825396826,
|
|
53
|
+
"y": 0.6875952069940283,
|
|
54
|
+
"z": 1.9000625102971842,
|
|
55
|
+
"scale": [0.02634920634920635, 0.03396825396825397, 0.04158730158730159],
|
|
56
|
+
"opacity": 0.21349206349206348,
|
|
57
|
+
"rotWxyz": [0.9929221972093049, 0.0712599726638784, 0.05700797813110272, 0.07601063750813697],
|
|
58
|
+
"colour": [0.24761904761904763, 0.6603174603174603, 0.45]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"x": -1.619047619047619,
|
|
62
|
+
"y": 0.8112513200382473,
|
|
63
|
+
"z": 1.8566219137538549,
|
|
64
|
+
"scale": [0.02761904761904762, 0.03476190476190476, 0.0419047619047619],
|
|
65
|
+
"opacity": 0.2261904761904762,
|
|
66
|
+
"rotWxyz": [0.9898132604466151, 0.08542303787535818, 0.06833843030028655, 0.09111790706704874],
|
|
67
|
+
"colour": [0.2571428571428571, 0.6523809523809523, 0.45]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"x": -1.5555555555555556,
|
|
71
|
+
"y": 0.9275547046046055,
|
|
72
|
+
"z": 1.8056993387177973,
|
|
73
|
+
"scale": [0.028888888888888888, 0.035555555555555556, 0.042222222222222223],
|
|
74
|
+
"opacity": 0.23888888888888887,
|
|
75
|
+
"rotWxyz": [0.986143231562925, 0.09953767961604901, 0.0796301436928392, 0.10617352492378562],
|
|
76
|
+
"colour": [0.26666666666666666, 0.6444444444444444, 0.45]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"x": -1.492063492063492,
|
|
80
|
+
"y": 1.0354512518286239,
|
|
81
|
+
"z": 1.7474999974664231,
|
|
82
|
+
"scale": [0.03015873015873016, 0.036349206349206346, 0.042539682539682544],
|
|
83
|
+
"opacity": 0.2515873015873016,
|
|
84
|
+
"rotWxyz": [0.9819141909751907, 0.11359589676635795, 0.09087671741308637, 0.12116895655078183],
|
|
85
|
+
"colour": [0.2761904761904762, 0.6365079365079365, 0.45]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"x": -1.4285714285714286,
|
|
89
|
+
"y": 1.1339630477200986,
|
|
90
|
+
"z": 1.6822584268304723,
|
|
91
|
+
"scale": [0.03142857142857143, 0.037142857142857144, 0.04285714285714286],
|
|
92
|
+
"opacity": 0.2642857142857143,
|
|
93
|
+
"rotWxyz": [0.9771285359854575, 0.12758972019191042, 0.10207177615352835, 0.1360957015380378],
|
|
94
|
+
"colour": [0.2857142857142857, 0.6285714285714286, 0.45]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"x": -1.3650793650793651,
|
|
98
|
+
"y": 1.2221972364288565,
|
|
99
|
+
"z": 1.6102375430368372,
|
|
100
|
+
"scale": [0.0326984126984127, 0.037936507936507935, 0.04317460317460318],
|
|
101
|
+
"opacity": 0.276984126984127,
|
|
102
|
+
"rotWxyz": [0.9717889794219073, 0.1415112172609863, 0.11320897380878904, 0.15094529841171875],
|
|
103
|
+
"colour": [0.29523809523809524, 0.6206349206349207, 0.45]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"x": -1.3015873015873016,
|
|
107
|
+
"y": 1.2993541125910792,
|
|
108
|
+
"z": 1.531727582185598,
|
|
109
|
+
"scale": [0.03396825396825397, 0.038730158730158726, 0.04349206349206349],
|
|
110
|
+
"opacity": 0.28968253968253965,
|
|
111
|
+
"rotWxyz": [0.9658985481010495, 0.15535249634126447, 0.12428199707301157, 0.16570932943068212],
|
|
112
|
+
"colour": [0.3047619047619048, 0.6126984126984126, 0.45]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"x": -1.2380952380952381,
|
|
116
|
+
"y": 1.364734369411686,
|
|
117
|
+
"z": 1.4470449306310265,
|
|
118
|
+
"scale": [0.035238095238095235, 0.039523809523809524, 0.04380952380952381],
|
|
119
|
+
"opacity": 0.3023809523809524,
|
|
120
|
+
"rotWxyz": [0.9594605811119173, 0.16910571127332596, 0.13528456901866076, 0.18037942535821436],
|
|
121
|
+
"colour": [0.3142857142857143, 0.6047619047619047, 0.45]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"x": -1.1746031746031746,
|
|
125
|
+
"y": 1.417745436790215,
|
|
126
|
+
"z": 1.3565308499799933,
|
|
127
|
+
"scale": [0.0365079365079365, 0.040317460317460314, 0.044126984126984126],
|
|
128
|
+
"opacity": 0.31507936507936507,
|
|
129
|
+
"rotWxyz": [0.9524787279232518, 0.18276306581837995, 0.14621045265470395, 0.19494727020627195],
|
|
130
|
+
"colour": [0.3238095238095238, 0.5968253968253968, 0.45]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"x": -1.1111111111111112,
|
|
134
|
+
"y": 1.4579068520449692,
|
|
135
|
+
"z": 1.2605501018458902,
|
|
136
|
+
"scale": [0.03777777777777778, 0.04111111111111111, 0.044444444444444446],
|
|
137
|
+
"opacity": 0.3277777777777778,
|
|
138
|
+
"rotWxyz": [0.9449569463147375, 0.19631681807769127, 0.15705345446215302, 0.20940460594953736],
|
|
139
|
+
"colour": [0.33333333333333337, 0.5888888888888888, 0.45]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"x": -1.0476190476190477,
|
|
143
|
+
"y": 1.4848546145581858,
|
|
144
|
+
"z": 1.159489477900159,
|
|
145
|
+
"scale": [0.039047619047619046, 0.0419047619047619, 0.04476190476190476],
|
|
146
|
+
"opacity": 0.3404761904761905,
|
|
147
|
+
"rotWxyz": [0.9368995001334712, 0.20975928488120518, 0.16780742790496414, 0.22374323720661887],
|
|
148
|
+
"colour": [0.34285714285714286, 0.5809523809523809, 0.45]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"x": -0.9841269841269842,
|
|
152
|
+
"y": 1.4983444848741607,
|
|
153
|
+
"z": 1.053756241145149,
|
|
154
|
+
"scale": [0.04031746031746032, 0.042698412698412694, 0.04507936507936508],
|
|
155
|
+
"opacity": 0.35317460317460314,
|
|
156
|
+
"rotWxyz": [0.9283109568769274, 0.2230828461428794, 0.17846627691430353, 0.23795503588573805],
|
|
157
|
+
"colour": [0.35238095238095235, 0.573015873015873, 0.45]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"x": -0.9206349206349207,
|
|
161
|
+
"y": 1.4982541983491453,
|
|
162
|
+
"z": 0.9437764846898058,
|
|
163
|
+
"scale": [0.04158730158730159, 0.04349206349206349, 0.045396825396825394],
|
|
164
|
+
"opacity": 0.3658730158730159,
|
|
165
|
+
"rotWxyz": [0.9191961851037977, 0.23627994918025727, 0.18902395934420582, 0.25203194579227445],
|
|
166
|
+
"colour": [0.3619047619047619, 0.5650793650793651, 0.45]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"x": -0.8571428571428572,
|
|
170
|
+
"y": 1.484584573289732,
|
|
171
|
+
"z": 0.8299934146421357,
|
|
172
|
+
"scale": [0.04285714285714286, 0.04428571428571428, 0.045714285714285714],
|
|
173
|
+
"opacity": 0.37857142857142856,
|
|
174
|
+
"rotWxyz": [0.9095603516741667, 0.24934311299583117, 0.19947449039666496, 0.26596598719555326],
|
|
175
|
+
"colour": [0.37142857142857144, 0.5571428571428572, 0.45]
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"x": -0.7936507936507937,
|
|
179
|
+
"y": 1.4574595035361824,
|
|
180
|
+
"z": 0.7128655640382011,
|
|
181
|
+
"scale": [0.044126984126984126, 0.04507936507936508, 0.046031746031746035],
|
|
182
|
+
"opacity": 0.39126984126984127,
|
|
183
|
+
"rotWxyz": [0.8994089188205915, 0.26226493251777083, 0.20981194601421668, 0.2797492613522889],
|
|
184
|
+
"colour": [0.38095238095238093, 0.5492063492063491, 0.45]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"x": -0.7301587301587302,
|
|
188
|
+
"y": 1.4171248355579122,
|
|
189
|
+
"z": 0.5928649450053103,
|
|
190
|
+
"scale": [0.045396825396825394, 0.04587301587301587, 0.04634920634920635],
|
|
191
|
+
"opacity": 0.403968253968254,
|
|
192
|
+
"rotWxyz": [0.8887476410517441, 0.27503808279761127, 0.22003046623808903, 0.2933739549841187],
|
|
193
|
+
"colour": [0.3904761904761905, 0.5412698412698412, 0.45]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"x": -0.6666666666666667,
|
|
197
|
+
"y": 1.3639461402385225,
|
|
198
|
+
"z": 0.47047514660597883,
|
|
199
|
+
"scale": [0.04666666666666666, 0.04666666666666666, 0.04666666666666667],
|
|
200
|
+
"opacity": 0.41666666666666663,
|
|
201
|
+
"rotWxyz": [0.8775825618903728, 0.2876553231625218, 0.23012425853001744, 0.3068323447066899],
|
|
202
|
+
"colour": [0.4, 0.5333333333333333, 0.45]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"x": -0.6031746031746033,
|
|
206
|
+
"y": 1.2984053995456635,
|
|
207
|
+
"z": 0.3461893860281379,
|
|
208
|
+
"scale": [0.04793650793650794, 0.04746031746031746, 0.04698412698412698],
|
|
209
|
+
"opacity": 0.4293650793650794,
|
|
210
|
+
"rotWxyz": [0.86592001044743, 0.30010950131980185, 0.24008760105584148, 0.32011680140778864],
|
|
211
|
+
"colour": [0.4095238095238095, 0.5253968253968253, 0.45]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"x": -0.5396825396825398,
|
|
215
|
+
"y": 1.2210966381159043,
|
|
216
|
+
"z": 0.22050852097507492,
|
|
217
|
+
"scale": [0.049206349206349205, 0.04825396825396826, 0.0473015873015873],
|
|
218
|
+
"opacity": 0.44206349206349205,
|
|
219
|
+
"rotWxyz": [0.8537665978343114, 0.3123935574112774, 0.2499148459290219, 0.3332197945720292],
|
|
220
|
+
"colour": [0.419047619047619, 0.5174603174603174, 0.45]
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"x": -0.4761904761904763,
|
|
224
|
+
"y": 1.132720539347487,
|
|
225
|
+
"z": 0.09393903126495234,
|
|
226
|
+
"scale": [0.05047619047619048, 0.04904761904761905, 0.047619047619047616],
|
|
227
|
+
"opacity": 0.4547619047619048,
|
|
228
|
+
"rotWxyz": [0.8411292134152362, 0.3245005280152989, 0.25960042241223913, 0.3461338965496522],
|
|
229
|
+
"colour": [0.42857142857142855, 0.5095238095238095, 0.45]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"x": -0.4126984126984128,
|
|
233
|
+
"y": 1.0340780947976844,
|
|
234
|
+
"z": -0.03300902222616699,
|
|
235
|
+
"scale": [0.05174603174603175, 0.04984126984126984, 0.04793650793650794],
|
|
236
|
+
"opacity": 0.46746031746031746,
|
|
237
|
+
"rotWxyz": [0.8280150209018973, 0.3364235500940726, 0.2691388400752581, 0.3588517867670108],
|
|
238
|
+
"colour": [0.4380952380952381, 0.5015873015873016, 0.45]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"x": -0.3492063492063493,
|
|
242
|
+
"y": 0.9260633444430757,
|
|
243
|
+
"z": -0.15982405305255712,
|
|
244
|
+
"scale": [0.053015873015873016, 0.05063492063492063, 0.04825396825396826],
|
|
245
|
+
"opacity": 0.4801587301587301,
|
|
246
|
+
"rotWxyz": [0.8144314542925918, 0.3481558648840881, 0.2785246919072705, 0.3713662558763607],
|
|
247
|
+
"colour": [0.4476190476190476, 0.4936507936507936, 0.45]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"x": -0.2857142857142858,
|
|
251
|
+
"y": 0.8096552736009661,
|
|
252
|
+
"z": -0.2859950108349411,
|
|
253
|
+
"scale": [0.054285714285714284, 0.05142857142857143, 0.04857142857142857],
|
|
254
|
+
"opacity": 0.4928571428571429,
|
|
255
|
+
"rotWxyz": [0.8003862136581352, 0.35969082172743555, 0.28775265738194844, 0.383670209842598],
|
|
256
|
+
"colour": [0.45714285714285713, 0.48571428571428565, 0.45]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"x": -0.22222222222222232,
|
|
260
|
+
"y": 0.6859089399537179,
|
|
261
|
+
"z": -0.4110134407363156,
|
|
262
|
+
"scale": [0.05555555555555555, 0.052222222222222225, 0.04888888888888889],
|
|
263
|
+
"opacity": 0.5055555555555555,
|
|
264
|
+
"rotWxyz": [0.785887260776948, 0.3710218818418422, 0.29681750547347374, 0.39575667396463166],
|
|
265
|
+
"colour": [0.4666666666666667, 0.47777777777777775, 0.45]
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"x": -0.15873015873015883,
|
|
269
|
+
"y": 0.5559459110956944,
|
|
270
|
+
"z": -0.5343755324780302,
|
|
271
|
+
"scale": [0.05682539682539682, 0.053015873015873016, 0.049206349206349205],
|
|
272
|
+
"opacity": 0.5182539682539683,
|
|
273
|
+
"rotWxyz": [0.7709428146217897, 0.38214262202728944, 0.30571409762183155, 0.40761879682910873],
|
|
274
|
+
"colour": [0.47619047619047616, 0.46984126984126984, 0.45]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"x": -0.09523809523809534,
|
|
278
|
+
"y": 0.4209440992715359,
|
|
279
|
+
"z": -0.6555841506388167,
|
|
280
|
+
"scale": [0.05809523809523809, 0.05380952380952381, 0.049523809523809526],
|
|
281
|
+
"opacity": 0.530952380952381,
|
|
282
|
+
"rotWxyz": [0.7555613467006966, 0.39304673830711107, 0.3144373906456889, 0.41924985419425187],
|
|
283
|
+
"colour": [0.4857142857142857, 0.4619047619047619, 0.45]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"x": -0.031746031746031855,
|
|
287
|
+
"y": 0.28212708543802256,
|
|
288
|
+
"z": -0.7741508380548908,
|
|
289
|
+
"scale": [0.05936507936507937, 0.0546031746031746, 0.04984126984126984],
|
|
290
|
+
"opacity": 0.5436507936507936,
|
|
291
|
+
"rotWxyz": [0.7397515762547668, 0.4037280495015074, 0.32298243960120593, 0.430643252801608],
|
|
292
|
+
"colour": [0.4952380952380952, 0.4539682539682539, 0.45]
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"x": 0.03174603174603163,
|
|
296
|
+
"y": 0.1407530294102627,
|
|
297
|
+
"z": -0.8895977842476466,
|
|
298
|
+
"scale": [0.06063492063492064, 0.055396825396825396, 0.05015873015873016],
|
|
299
|
+
"opacity": 0.5563492063492064,
|
|
300
|
+
"rotWxyz": [0.7235224653155132, 0.4141805007314496, 0.3313444005851597, 0.44179253411354624],
|
|
301
|
+
"colour": [0.5047619047619047, 0.446031746031746, 0.45]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"x": 0.09523809523809534,
|
|
305
|
+
"y": -0.001896733395566601,
|
|
306
|
+
"z": -1.001459750946402,
|
|
307
|
+
"scale": [0.06190476190476191, 0.05619047619047619, 0.05047619047619048],
|
|
308
|
+
"opacity": 0.5690476190476191,
|
|
309
|
+
"rotWxyz": [0.7068832136245868, 0.4243981668509887, 0.339518533480791, 0.45269137797438797],
|
|
310
|
+
"colour": [0.5142857142857142, 0.43809523809523804, 0.45]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"x": 0.1587301587301586,
|
|
314
|
+
"y": -0.14452930527016522,
|
|
315
|
+
"z": -1.1092859469465528,
|
|
316
|
+
"scale": [0.06317460317460317, 0.056984126984126984, 0.050793650793650794],
|
|
317
|
+
"opacity": 0.5817460317460318,
|
|
318
|
+
"rotWxyz": [0.6898432534187502, 0.4343752558060233, 0.3475002046448186, 0.46333360619309155],
|
|
319
|
+
"colour": [0.5238095238095237, 0.43015873015873013, 0.45]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"x": 0.22222222222222232,
|
|
323
|
+
"y": -0.2858519443132281,
|
|
324
|
+
"z": -1.2126418447476708,
|
|
325
|
+
"scale": [0.06444444444444444, 0.057777777777777775, 0.051111111111111114],
|
|
326
|
+
"opacity": 0.5944444444444444,
|
|
327
|
+
"rotWxyz": [0.6724122440830567, 0.4441061119176222, 0.3552848895340978, 0.47371318604546375],
|
|
328
|
+
"colour": [0.5333333333333333, 0.42222222222222217, 0.45]
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"x": 0.2857142857142856,
|
|
332
|
+
"y": -0.42458378112338335,
|
|
333
|
+
"z": -1.3111109316506877,
|
|
334
|
+
"scale": [0.06571428571428571, 0.058571428571428566, 0.05142857142857143],
|
|
335
|
+
"opacity": 0.6071428571428571,
|
|
336
|
+
"rotWxyz": [0.6546000666752675, 0.4535852190880393, 0.36286817527043147, 0.4838242336939086],
|
|
337
|
+
"colour": [0.5428571428571428, 0.41428571428571426, 0.45]
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"x": 0.3492063492063493,
|
|
341
|
+
"y": -0.5594674278824507,
|
|
342
|
+
"z": -1.4042963882574553,
|
|
343
|
+
"scale": [0.066984126984127, 0.05936507936507937, 0.05174603174603175],
|
|
344
|
+
"opacity": 0.6198412698412699,
|
|
345
|
+
"rotWxyz": [0.6364168183246098, 0.4628072039276064, 0.3702457631420851, 0.4936610175227802],
|
|
346
|
+
"colour": [0.5523809523809524, 0.4063492063492063, 0.45]
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"x": 0.41269841269841256,
|
|
350
|
+
"y": -0.6892803746157439,
|
|
351
|
+
"z": -1.4918226876084972,
|
|
352
|
+
"scale": [0.06825396825396825, 0.06015873015873016, 0.05206349206349206],
|
|
353
|
+
"opacity": 0.6325396825396825,
|
|
354
|
+
"rotWxyz": [0.6178728065080505, 0.4717668388007273, 0.3774134710405818, 0.5032179613874425],
|
|
355
|
+
"colour": [0.5619047619047619, 0.3984126984126984, 0.45]
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"x": 0.4761904761904763,
|
|
359
|
+
"y": -0.8128460693391077,
|
|
360
|
+
"z": -1.5733371085146264,
|
|
361
|
+
"scale": [0.06952380952380953, 0.06095238095238095, 0.05238095238095238],
|
|
362
|
+
"opacity": 0.6452380952380953,
|
|
363
|
+
"rotWxyz": [0.5989785432073319, 0.48045904478925167, 0.3843672358314013, 0.5124896477752018],
|
|
364
|
+
"colour": [0.5714285714285714, 0.3904761904761904, 0.45]
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"x": 0.5396825396825395,
|
|
368
|
+
"y": -0.9290445816684068,
|
|
369
|
+
"z": -1.6485111569838504,
|
|
370
|
+
"scale": [0.0707936507936508, 0.06174603174603174, 0.0526984126984127],
|
|
371
|
+
"opacity": 0.6579365079365079,
|
|
372
|
+
"rotWxyz": [0.5797447389500795, 0.4888788945715426, 0.39110311565723405, 0.5214708208763121],
|
|
373
|
+
"colour": [0.5809523809523809, 0.3825396825396825, 0.45]
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"x": 0.6031746031746033,
|
|
377
|
+
"y": -1.036822753242497,
|
|
378
|
+
"z": -1.717041890015395,
|
|
379
|
+
"scale": [0.07206349206349207, 0.06253968253968253, 0.053015873015873016],
|
|
380
|
+
"opacity": 0.6706349206349207,
|
|
381
|
+
"rotWxyz": [0.5601822967383612, 0.4970216152156126, 0.3976172921724901, 0.5301563895633201],
|
|
382
|
+
"colour": [0.5904761904761905, 0.37460317460317455, 0.45]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"x": 0.6666666666666665,
|
|
386
|
+
"y": -1.1352037429618922,
|
|
387
|
+
"z": -1.7786531364260827,
|
|
388
|
+
"scale": [0.07333333333333333, 0.06333333333333332, 0.05333333333333333],
|
|
389
|
+
"opacity": 0.6833333333333333,
|
|
390
|
+
"rotWxyz": [0.5403023058681398, 0.5048825908847379, 0.40390607270779033, 0.5385414302770538],
|
|
391
|
+
"colour": [0.6, 0.36666666666666664, 0.45]
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"x": 0.7301587301587302,
|
|
395
|
+
"y": -1.2232958805304444,
|
|
396
|
+
"z": -1.833096609789292,
|
|
397
|
+
"scale": [0.0746031746031746, 0.06412698412698413, 0.05365079365079365],
|
|
398
|
+
"opacity": 0.6960317460317461,
|
|
399
|
+
"rotWxyz": [0.5201160356431195, 0.5124573654540237, 0.4099658923632189, 0.5466211898176253],
|
|
400
|
+
"colour": [0.6095238095238096, 0.3587301587301587, 0.45]
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"x": 0.7936507936507935,
|
|
404
|
+
"y": -1.300300748056463,
|
|
405
|
+
"z": -1.8801529090014608,
|
|
406
|
+
"scale": [0.07587301587301587, 0.06492063492063492, 0.05396825396825397],
|
|
407
|
+
"opacity": 0.7087301587301588,
|
|
408
|
+
"rotWxyz": [0.49963492898655487, 0.5197416450364317, 0.4157933160291454, 0.5543910880388605],
|
|
409
|
+
"colour": [0.6190476190476191, 0.35079365079365077, 0.45]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"x": 0.8571428571428572,
|
|
413
|
+
"y": -1.365520416466174,
|
|
414
|
+
"z": -1.91963240244398,
|
|
415
|
+
"scale": [0.07714285714285715, 0.06571428571428573, 0.054285714285714284],
|
|
416
|
+
"opacity": 0.7214285714285715,
|
|
417
|
+
"rotWxyz": [0.4788705959546387, 0.5267313004168421, 0.4213850403334736, 0.5618467204446316],
|
|
418
|
+
"colour": [0.6285714285714286, 0.3428571428571428, 0.45]
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"x": 0.9206349206349205,
|
|
422
|
+
"y": -1.418363771142703,
|
|
423
|
+
"z": -1.951375992177385,
|
|
424
|
+
"scale": [0.0784126984126984, 0.06650793650793652, 0.054603174603174605],
|
|
425
|
+
"opacity": 0.7341269841269842,
|
|
426
|
+
"rotWxyz": [0.45783480715514957, 0.5334223693927679, 0.42673789551421426, 0.568983860685619],
|
|
427
|
+
"colour": [0.638095238095238, 0.3349206349206349, 0.45]
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"x": 0.9841269841269842,
|
|
431
|
+
"y": -1.4583518694585338,
|
|
432
|
+
"z": -1.975255755088248,
|
|
433
|
+
"scale": [0.07968253968253969, 0.0673015873015873, 0.054920634920634925],
|
|
434
|
+
"opacity": 0.7468253968253968,
|
|
435
|
+
"rotWxyz": [0.4365394870750846, 0.5398110590203947, 0.4318488472163157, 0.5757984629550877],
|
|
436
|
+
"colour": [0.6476190476190476, 0.32698412698412693, 0.45]
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"x": 1.0476190476190474,
|
|
440
|
+
"y": -1.4851222816437533,
|
|
441
|
+
"z": -1.9911754584050023,
|
|
442
|
+
"scale": [0.08095238095238096, 0.0680952380952381, 0.05523809523809524],
|
|
443
|
+
"opacity": 0.7595238095238096,
|
|
444
|
+
"rotWxyz": [0.41499670732106775, 0.5458937477646743, 0.43671499821173937, 0.5822866642823192],
|
|
445
|
+
"colour": [0.657142857142857, 0.319047619047619, 0.45]
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"x": 1.1111111111111112,
|
|
449
|
+
"y": -1.4984323756468925,
|
|
450
|
+
"z": -1.999070947505243,
|
|
451
|
+
"scale": [0.08222222222222222, 0.06888888888888889, 0.05555555555555556],
|
|
452
|
+
"opacity": 0.7722222222222223,
|
|
453
|
+
"rotWxyz": [0.3932186797763578, 0.5516669875522532, 0.4413335900418025, 0.5884447867224034],
|
|
454
|
+
"colour": [0.6666666666666667, 0.31111111111111106, 0.45]
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"x": 1.1746031746031744,
|
|
458
|
+
"y": -1.498161516216208,
|
|
459
|
+
"z": -1.9989104044516723,
|
|
460
|
+
"scale": [0.08349206349206349, 0.06968253968253968, 0.05587301587301587],
|
|
461
|
+
"opacity": 0.7849206349206349,
|
|
462
|
+
"rotWxyz": [0.3712177496783389, 0.5571275057260682, 0.4457020045808545, 0.5942693394411395],
|
|
463
|
+
"colour": [0.6761904761904762, 0.30317460317460315, 0.45]
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"x": 1.2380952380952381,
|
|
467
|
+
"y": -1.48431215827017,
|
|
468
|
+
"z": -1.9906944762148258,
|
|
469
|
+
"scale": [0.08476190476190477, 0.07047619047619047, 0.05619047619047619],
|
|
470
|
+
"opacity": 0.7976190476190477,
|
|
471
|
+
"rotWxyz": [0.3490063886204174, 0.5622722069005086, 0.44981776552040686, 0.5997570206938759],
|
|
472
|
+
"colour": [0.6857142857142857, 0.2952380952380952, 0.45]
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
"x": 1.3015873015873014,
|
|
476
|
+
"y": -1.4570098246474532,
|
|
477
|
+
"z": -1.9744562720658534,
|
|
478
|
+
"scale": [0.08603174603174603, 0.07126984126984126, 0.05650793650793651],
|
|
479
|
+
"opacity": 0.8103174603174603,
|
|
480
|
+
"rotWxyz": [0.32659718748229205, 0.5670981747160859, 0.45367853977286876, 0.6049047196971583],
|
|
481
|
+
"colour": [0.6952380952380952, 0.2873015873015873, 0.45]
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
"x": 1.3650793650793651,
|
|
485
|
+
"y": -1.4165019684380946,
|
|
486
|
+
"z": -1.9502612301498634,
|
|
487
|
+
"scale": [0.08730158730158731, 0.07206349206349207, 0.05682539682539683],
|
|
488
|
+
"opacity": 0.8230158730158731,
|
|
489
|
+
"rotWxyz": [0.3040028492926036, 0.5716026734926213, 0.45728213879409707, 0.6097095183921295],
|
|
490
|
+
"colour": [0.7047619047619047, 0.2793650793650793, 0.45]
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"x": 1.4285714285714284,
|
|
494
|
+
"y": -1.3631557302070099,
|
|
495
|
+
"z": -1.9182068537775219,
|
|
496
|
+
"scale": [0.08857142857142858, 0.07285714285714286, 0.05714285714285715],
|
|
497
|
+
"opacity": 0.8357142857142857,
|
|
498
|
+
"rotWxyz": [0.281236182028012, 0.5757831497800109, 0.46062651982400876, 0.6141686930986784],
|
|
499
|
+
"colour": [0.7142857142857142, 0.2714285714285714, 0.45]
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"x": 1.492063492063492,
|
|
503
|
+
"y": -1.2974546104371438,
|
|
504
|
+
"z": -1.8784223184976245,
|
|
505
|
+
"scale": [0.08984126984126985, 0.07365079365079366, 0.05746031746031746],
|
|
506
|
+
"opacity": 0.8484126984126985,
|
|
507
|
+
"rotWxyz": [0.2583100913527811, 0.579637233805692, 0.46370978704455357, 0.6182797160594048],
|
|
508
|
+
"colour": [0.7238095238095239, 0.26349206349206344, 0.45]
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"x": 1.5555555555555554,
|
|
512
|
+
"y": -1.21999408735137,
|
|
513
|
+
"z": -1.831067951534095,
|
|
514
|
+
"scale": [0.09111111111111111, 0.07444444444444445, 0.057777777777777775],
|
|
515
|
+
"opacity": 0.8611111111111112,
|
|
516
|
+
"rotWxyz": [0.23523757330298942, 0.5831627408179876, 0.4665301926543901, 0.6220402568725202],
|
|
517
|
+
"colour": [0.7333333333333334, 0.25555555555555554, 0.45]
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"x": 1.619047619047619,
|
|
521
|
+
"y": -1.1314762198307446,
|
|
522
|
+
"z": -1.7763345856852175,
|
|
523
|
+
"scale": [0.09238095238095238, 0.07523809523809524, 0.058095238095238096],
|
|
524
|
+
"opacity": 0.8738095238095239,
|
|
525
|
+
"rotWxyz": [0.2120317069195088, 0.58635767232457, 0.469086137859656, 0.6254481838128747],
|
|
526
|
+
"colour": [0.7428571428571429, 0.24761904761904757, 0.45]
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"x": 1.6825396825396823,
|
|
530
|
+
"y": -1.0327032843452637,
|
|
531
|
+
"z": -1.7144427902888217,
|
|
532
|
+
"scale": [0.09365079365079365, 0.07603174603174603, 0.058412698412698416],
|
|
533
|
+
"opacity": 0.8865079365079366,
|
|
534
|
+
"rotWxyz": [0.18870564683393445, 0.5892202172253386, 0.47137617378027086, 0.6285015650403611],
|
|
535
|
+
"colour": [0.7523809523809524, 0.23968253968253966, 0.45]
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"x": 1.746031746031746,
|
|
539
|
+
"y": -0.9245705035684031,
|
|
540
|
+
"z": -1.6456419823525388,
|
|
541
|
+
"scale": [0.09492063492063493, 0.07682539682539682, 0.05873015873015873],
|
|
542
|
+
"opacity": 0.8992063492063492,
|
|
543
|
+
"rotWxyz": [0.16527261581166136, 0.5917487528390724, 0.47339900227125786, 0.6311986696950106],
|
|
544
|
+
"colour": [0.7619047619047619, 0.2317460317460317, 0.45]
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
"x": 1.8095238095238093,
|
|
548
|
+
"y": -0.8080579325792356,
|
|
549
|
+
"z": -1.5702094214311813,
|
|
550
|
+
"scale": [0.09619047619047619, 0.07761904761904762, 0.05904761904761904],
|
|
551
|
+
"opacity": 0.9119047619047619,
|
|
552
|
+
"rotWxyz": [0.14174589725634068, 0.5939418458232743, 0.4751534766586194, 0.6335379688781593],
|
|
553
|
+
"colour": [0.7714285714285714, 0.2238095238095238, 0.45]
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
"x": 1.873015873015873,
|
|
557
|
+
"y": -0.684221576191041,
|
|
558
|
+
"z": -1.4884490923017697,
|
|
559
|
+
"scale": [0.09746031746031747, 0.0784126984126984, 0.05936507936507937],
|
|
560
|
+
"opacity": 0.9246031746031746,
|
|
561
|
+
"rotWxyz": [0.11813882767996077, 0.5957982529866848, 0.4766386023893478, 0.6355181365191305],
|
|
562
|
+
"colour": [0.7809523809523808, 0.21587301587301583, 0.45]
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"x": 1.9365079365079363,
|
|
566
|
+
"y": -0.554183817913986,
|
|
567
|
+
"z": -1.4006904799389102,
|
|
568
|
+
"scale": [0.09873015873015874, 0.0792063492063492, 0.059682539682539684],
|
|
569
|
+
"opacity": 0.9373015873015873,
|
|
570
|
+
"rotWxyz": [0.09446478914282425, 0.5973169219940053, 0.47785353759520427, 0.637138050126939],
|
|
571
|
+
"colour": [0.7904761904761903, 0.20793650793650792, 0.45]
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"x": 2,
|
|
575
|
+
"y": -0.4191232472983888,
|
|
576
|
+
"z": -1.3072872417272239,
|
|
577
|
+
"scale": [0.1, 0.08, 0.06],
|
|
578
|
+
"opacity": 0.9500000000000001,
|
|
579
|
+
"rotWxyz": [0.0707372016677029, 0.5984969919624327, 0.4787975935699461, 0.6383967914265949],
|
|
580
|
+
"colour": [0.8, 0.19999999999999996, 0.45]
|
|
581
|
+
}
|
|
582
|
+
]
|
package/src/half.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/** IEEE 754 binary16 encoding, because a covariance term is stored as a half and JavaScript has no half. */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* One scratch pair at module scope, reinterpreting a float's bits without allocating. `packSplats`
|
|
5
|
+
* calls this six times per splat, so a capture of a million splats calls it six million times in
|
|
6
|
+
* one loop — an `ArrayBuffer` per call would be six million of them.
|
|
7
|
+
*
|
|
8
|
+
* Not a hot path in the per-frame sense: packing happens once, on load. It is a hot *loop* all the
|
|
9
|
+
* same, and the house rule's reason applies to both.
|
|
10
|
+
*/
|
|
11
|
+
const scratch = new ArrayBuffer(4);
|
|
12
|
+
const asFloat = new Float32Array(scratch);
|
|
13
|
+
const asBits = new Uint32Array(scratch);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The 16-bit pattern of the nearest half to `value`, ties to even.
|
|
17
|
+
*
|
|
18
|
+
* **Round to nearest even rather than truncate**, which costs a handful of operations per call and
|
|
19
|
+
* buys a bounded error instead of a biased one: truncation always moves toward zero, so a sum of
|
|
20
|
+
* truncated covariance terms shrinks a splat systematically rather than jittering it. What would
|
|
21
|
+
* make it wrong is nothing about correctness — a truncating version is simpler and is what several
|
|
22
|
+
* published viewers ship; it is half an ulp worse per term and the bias accumulates over six.
|
|
23
|
+
*
|
|
24
|
+
* Overflow saturates to infinity and underflow to a signed zero, which is what the format says.
|
|
25
|
+
* **A covariance term small enough to underflow is a splat smaller than 8 micrometres** at a
|
|
26
|
+
* capture's usual scale, and the low-pass in the vertex stage would swallow it whole.
|
|
27
|
+
*/
|
|
28
|
+
export function floatToHalf(value: number): number {
|
|
29
|
+
asFloat[0] = value;
|
|
30
|
+
const bits = asBits[0] ?? 0;
|
|
31
|
+
const sign = (bits >>> 16) & 0x8000;
|
|
32
|
+
const exponent = (bits >>> 23) & 0xff;
|
|
33
|
+
const mantissa = bits & 0x007fffff;
|
|
34
|
+
|
|
35
|
+
/* NaN keeps a non-zero mantissa so it stays NaN; infinity keeps an empty one. */
|
|
36
|
+
if (exponent === 0xff) return sign | 0x7c00 | (mantissa === 0 ? 0 : 0x0200);
|
|
37
|
+
|
|
38
|
+
/* Rebias: float32 excess-127 to float16 excess-15. */
|
|
39
|
+
const rebiased = exponent - 127 + 15;
|
|
40
|
+
|
|
41
|
+
if (rebiased >= 0x1f) return sign | 0x7c00;
|
|
42
|
+
|
|
43
|
+
if (rebiased <= 0) {
|
|
44
|
+
/* Past the subnormal range entirely — 24 bits of shift would leave nothing. */
|
|
45
|
+
if (rebiased < -10) return sign;
|
|
46
|
+
/* Subnormal: restore the implicit leading one, then shift it down into place. */
|
|
47
|
+
const full = mantissa | 0x00800000;
|
|
48
|
+
const shift = 14 - rebiased;
|
|
49
|
+
const truncated = full >>> shift;
|
|
50
|
+
const half = truncated & 0xffff;
|
|
51
|
+
const roundBit = (full >>> (shift - 1)) & 1;
|
|
52
|
+
const sticky = (full & ((1 << (shift - 1)) - 1)) === 0 ? 0 : 1;
|
|
53
|
+
const round = roundBit === 1 && (sticky === 1 || (half & 1) === 1) ? 1 : 0;
|
|
54
|
+
return sign | (half + round);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const truncated = (rebiased << 10) | (mantissa >>> 13);
|
|
58
|
+
const roundBit = (mantissa >>> 12) & 1;
|
|
59
|
+
const sticky = (mantissa & 0x0fff) === 0 ? 0 : 1;
|
|
60
|
+
const round = roundBit === 1 && (sticky === 1 || (truncated & 1) === 1) ? 1 : 0;
|
|
61
|
+
/* Carrying out of the mantissa lands in the exponent, which is exactly right: 65520 rounds up
|
|
62
|
+
to infinity and 2047.5 rounds up to 2048, both by the same addition. */
|
|
63
|
+
return (sign | (truncated + round)) & 0xffff;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The number a 16-bit pattern stands for. **Tests and tools only** — nothing in a frame decodes a
|
|
68
|
+
* half, because the GPU does it.
|
|
69
|
+
*
|
|
70
|
+
* It exists so a round-trip can be asserted against the value that went in rather than against a
|
|
71
|
+
* second implementation of the encoder, which would only prove the two agree.
|
|
72
|
+
*/
|
|
73
|
+
export function halfToFloat(bits: number): number {
|
|
74
|
+
const sign = (bits & 0x8000) === 0 ? 1 : -1;
|
|
75
|
+
const exponent = (bits >>> 10) & 0x1f;
|
|
76
|
+
const mantissa = bits & 0x03ff;
|
|
77
|
+
if (exponent === 0) return sign * mantissa * 2 ** -24;
|
|
78
|
+
if (exponent === 0x1f) return mantissa === 0 ? sign * Infinity : NaN;
|
|
79
|
+
return sign * (1 + mantissa / 1024) * 2 ** (exponent - 15);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Two halves in one `uint32`, laid out as GLSL's `packHalf2x16`.
|
|
84
|
+
*
|
|
85
|
+
* **`a` occupies the sixteen least significant bits**, which is the specification's wording and is
|
|
86
|
+
* the one detail here that a shader cannot report going wrong: swapping them produces a covariance
|
|
87
|
+
* whose terms are transposed into each other's places, which is a valid matrix and draws a
|
|
88
|
+
* plausible, wrong ellipse.
|
|
89
|
+
*/
|
|
90
|
+
export function packHalf2x16(a: number, b: number): number {
|
|
91
|
+
return ((floatToHalf(b) << 16) | floatToHalf(a)) >>> 0;
|
|
92
|
+
}
|