@splnlss/3d-story-viewer 0.5.0 → 0.5.2

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.
@@ -0,0 +1,1514 @@
1
+ (function() {
2
+ "use strict";
3
+ class ChunkDecoder {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(ChunkDecoder.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ ChunkDecoderFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ ChunkDecoderFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_chunkdecoder_free(ptr, 0);
20
+ }
21
+ /**
22
+ * @returns {any}
23
+ */
24
+ finish() {
25
+ const ptr = this.__destroy_into_raw();
26
+ const ret = wasm.chunkdecoder_finish(ptr);
27
+ if (ret[2]) {
28
+ throw takeFromExternrefTable0(ret[1]);
29
+ }
30
+ return takeFromExternrefTable0(ret[0]);
31
+ }
32
+ /**
33
+ * @param {Uint8Array} bytes
34
+ */
35
+ push(bytes) {
36
+ const ret = wasm.chunkdecoder_push(this.__wbg_ptr, bytes);
37
+ if (ret[1]) {
38
+ throw takeFromExternrefTable0(ret[0]);
39
+ }
40
+ }
41
+ }
42
+ if (Symbol.dispose) ChunkDecoder.prototype[Symbol.dispose] = ChunkDecoder.prototype.free;
43
+ class CsplatArray {
44
+ static __wrap(ptr) {
45
+ ptr = ptr >>> 0;
46
+ const obj = Object.create(CsplatArray.prototype);
47
+ obj.__wbg_ptr = ptr;
48
+ CsplatArrayFinalization.register(obj, obj.__wbg_ptr, obj);
49
+ return obj;
50
+ }
51
+ __destroy_into_raw() {
52
+ const ptr = this.__wbg_ptr;
53
+ this.__wbg_ptr = 0;
54
+ CsplatArrayFinalization.unregister(this);
55
+ return ptr;
56
+ }
57
+ free() {
58
+ const ptr = this.__destroy_into_raw();
59
+ wasm.__wbg_csplatarray_free(ptr, 0);
60
+ }
61
+ /**
62
+ * @param {number} lod_base
63
+ */
64
+ bhatt_lod(lod_base) {
65
+ wasm.csplatarray_bhatt_lod(this.__wbg_ptr, lod_base);
66
+ }
67
+ /**
68
+ * @returns {boolean}
69
+ */
70
+ has_lod() {
71
+ const ret = wasm.csplatarray_has_lod(this.__wbg_ptr);
72
+ return ret !== 0;
73
+ }
74
+ /**
75
+ * @param {Uint8Array} rgba
76
+ */
77
+ inject_rgba8(rgba) {
78
+ wasm.csplatarray_inject_rgba8(this.__wbg_ptr, rgba);
79
+ }
80
+ /**
81
+ * @returns {number}
82
+ */
83
+ len() {
84
+ const ret = wasm.csplatarray_len(this.__wbg_ptr);
85
+ return ret >>> 0;
86
+ }
87
+ /**
88
+ * @param {number} lod_base
89
+ * @param {boolean} merge_filter
90
+ */
91
+ tiny_lod(lod_base, merge_filter) {
92
+ wasm.csplatarray_tiny_lod(this.__wbg_ptr, lod_base, merge_filter);
93
+ }
94
+ /**
95
+ * @returns {object}
96
+ */
97
+ to_extsplats() {
98
+ const ret = wasm.csplatarray_to_extsplats(this.__wbg_ptr);
99
+ if (ret[2]) {
100
+ throw takeFromExternrefTable0(ret[1]);
101
+ }
102
+ return takeFromExternrefTable0(ret[0]);
103
+ }
104
+ /**
105
+ * @returns {object}
106
+ */
107
+ to_extsplats_lod() {
108
+ const ret = wasm.csplatarray_to_extsplats_lod(this.__wbg_ptr);
109
+ if (ret[2]) {
110
+ throw takeFromExternrefTable0(ret[1]);
111
+ }
112
+ return takeFromExternrefTable0(ret[0]);
113
+ }
114
+ /**
115
+ * @returns {object}
116
+ */
117
+ to_packedsplats() {
118
+ const ret = wasm.csplatarray_to_packedsplats(this.__wbg_ptr);
119
+ if (ret[2]) {
120
+ throw takeFromExternrefTable0(ret[1]);
121
+ }
122
+ return takeFromExternrefTable0(ret[0]);
123
+ }
124
+ /**
125
+ * @returns {object}
126
+ */
127
+ to_packedsplats_lod() {
128
+ const ret = wasm.csplatarray_to_packedsplats_lod(this.__wbg_ptr);
129
+ if (ret[2]) {
130
+ throw takeFromExternrefTable0(ret[1]);
131
+ }
132
+ return takeFromExternrefTable0(ret[0]);
133
+ }
134
+ /**
135
+ * @returns {number}
136
+ */
137
+ get maxShDegree() {
138
+ const ret = wasm.__wbg_get_csplatarray_maxShDegree(this.__wbg_ptr);
139
+ return ret >>> 0;
140
+ }
141
+ /**
142
+ * @returns {number}
143
+ */
144
+ get numSplats() {
145
+ const ret = wasm.__wbg_get_csplatarray_numSplats(this.__wbg_ptr);
146
+ return ret >>> 0;
147
+ }
148
+ /**
149
+ * @param {number} arg0
150
+ */
151
+ set maxShDegree(arg0) {
152
+ wasm.__wbg_set_csplatarray_maxShDegree(this.__wbg_ptr, arg0);
153
+ }
154
+ /**
155
+ * @param {number} arg0
156
+ */
157
+ set numSplats(arg0) {
158
+ wasm.__wbg_set_csplatarray_numSplats(this.__wbg_ptr, arg0);
159
+ }
160
+ }
161
+ if (Symbol.dispose) CsplatArray.prototype[Symbol.dispose] = CsplatArray.prototype.free;
162
+ class GsplatArray {
163
+ static __wrap(ptr) {
164
+ ptr = ptr >>> 0;
165
+ const obj = Object.create(GsplatArray.prototype);
166
+ obj.__wbg_ptr = ptr;
167
+ GsplatArrayFinalization.register(obj, obj.__wbg_ptr, obj);
168
+ return obj;
169
+ }
170
+ __destroy_into_raw() {
171
+ const ptr = this.__wbg_ptr;
172
+ this.__wbg_ptr = 0;
173
+ GsplatArrayFinalization.unregister(this);
174
+ return ptr;
175
+ }
176
+ free() {
177
+ const ptr = this.__destroy_into_raw();
178
+ wasm.__wbg_gsplatarray_free(ptr, 0);
179
+ }
180
+ /**
181
+ * @returns {number}
182
+ */
183
+ get maxShDegree() {
184
+ const ret = wasm.__wbg_get_gsplatarray_maxShDegree(this.__wbg_ptr);
185
+ return ret >>> 0;
186
+ }
187
+ /**
188
+ * @returns {number}
189
+ */
190
+ get numSplats() {
191
+ const ret = wasm.__wbg_get_gsplatarray_numSplats(this.__wbg_ptr);
192
+ return ret >>> 0;
193
+ }
194
+ /**
195
+ * @param {number} lod_base
196
+ */
197
+ bhatt_lod(lod_base) {
198
+ wasm.gsplatarray_bhatt_lod(this.__wbg_ptr, lod_base);
199
+ }
200
+ /**
201
+ * @returns {boolean}
202
+ */
203
+ has_lod() {
204
+ const ret = wasm.gsplatarray_has_lod(this.__wbg_ptr);
205
+ return ret !== 0;
206
+ }
207
+ /**
208
+ * @param {Uint8Array} rgba
209
+ */
210
+ inject_rgba8(rgba) {
211
+ wasm.gsplatarray_inject_rgba8(this.__wbg_ptr, rgba);
212
+ }
213
+ /**
214
+ * @returns {number}
215
+ */
216
+ len() {
217
+ const ret = wasm.gsplatarray_len(this.__wbg_ptr);
218
+ return ret >>> 0;
219
+ }
220
+ /**
221
+ * @param {number} lod_base
222
+ * @param {boolean} merge_filter
223
+ */
224
+ tiny_lod(lod_base, merge_filter) {
225
+ wasm.gsplatarray_tiny_lod(this.__wbg_ptr, lod_base, merge_filter);
226
+ }
227
+ /**
228
+ * @returns {object}
229
+ */
230
+ to_extsplats() {
231
+ const ret = wasm.gsplatarray_to_extsplats(this.__wbg_ptr);
232
+ if (ret[2]) {
233
+ throw takeFromExternrefTable0(ret[1]);
234
+ }
235
+ return takeFromExternrefTable0(ret[0]);
236
+ }
237
+ /**
238
+ * @returns {object}
239
+ */
240
+ to_extsplats_lod() {
241
+ const ret = wasm.gsplatarray_to_extsplats_lod(this.__wbg_ptr);
242
+ if (ret[2]) {
243
+ throw takeFromExternrefTable0(ret[1]);
244
+ }
245
+ return takeFromExternrefTable0(ret[0]);
246
+ }
247
+ /**
248
+ * @param {any} encoding
249
+ * @returns {object}
250
+ */
251
+ to_packedsplats(encoding) {
252
+ const ret = wasm.gsplatarray_to_packedsplats(this.__wbg_ptr, encoding);
253
+ if (ret[2]) {
254
+ throw takeFromExternrefTable0(ret[1]);
255
+ }
256
+ return takeFromExternrefTable0(ret[0]);
257
+ }
258
+ /**
259
+ * @param {any} encoding
260
+ * @returns {object}
261
+ */
262
+ to_packedsplats_lod(encoding) {
263
+ const ret = wasm.gsplatarray_to_packedsplats_lod(this.__wbg_ptr, encoding);
264
+ if (ret[2]) {
265
+ throw takeFromExternrefTable0(ret[1]);
266
+ }
267
+ return takeFromExternrefTable0(ret[0]);
268
+ }
269
+ /**
270
+ * @param {number} arg0
271
+ */
272
+ set maxShDegree(arg0) {
273
+ wasm.__wbg_set_gsplatarray_maxShDegree(this.__wbg_ptr, arg0);
274
+ }
275
+ /**
276
+ * @param {number} arg0
277
+ */
278
+ set numSplats(arg0) {
279
+ wasm.__wbg_set_gsplatarray_numSplats(this.__wbg_ptr, arg0);
280
+ }
281
+ }
282
+ if (Symbol.dispose) GsplatArray.prototype[Symbol.dispose] = GsplatArray.prototype.free;
283
+ function bhatt_lod_extsplats(num_splats, ext1, ext2, extra, lod_base, rgba) {
284
+ const ret = wasm.bhatt_lod_extsplats(num_splats, ext1, ext2, isLikeNone(extra) ? 0 : addToExternrefTable0(extra), lod_base, isLikeNone(rgba) ? 0 : addToExternrefTable0(rgba));
285
+ if (ret[2]) {
286
+ throw takeFromExternrefTable0(ret[1]);
287
+ }
288
+ return takeFromExternrefTable0(ret[0]);
289
+ }
290
+ function bhatt_lod_packedsplats(num_splats, packed, extra, lod_base, rgba, encoding) {
291
+ const ret = wasm.bhatt_lod_packedsplats(num_splats, packed, isLikeNone(extra) ? 0 : addToExternrefTable0(extra), lod_base, isLikeNone(rgba) ? 0 : addToExternrefTable0(rgba), encoding);
292
+ if (ret[2]) {
293
+ throw takeFromExternrefTable0(ret[1]);
294
+ }
295
+ return takeFromExternrefTable0(ret[0]);
296
+ }
297
+ function decode_to_csplatarray(file_type, path_name, encoding) {
298
+ var ptr0 = isLikeNone(file_type) ? 0 : passStringToWasm0(file_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
299
+ var len0 = WASM_VECTOR_LEN;
300
+ var ptr1 = isLikeNone(path_name) ? 0 : passStringToWasm0(path_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
301
+ var len1 = WASM_VECTOR_LEN;
302
+ const ret = wasm.decode_to_csplatarray(ptr0, len0, ptr1, len1, encoding);
303
+ if (ret[2]) {
304
+ throw takeFromExternrefTable0(ret[1]);
305
+ }
306
+ return ChunkDecoder.__wrap(ret[0]);
307
+ }
308
+ function decode_to_extsplats(file_type, path_name, sh1_codes, sh2_codes, sh3_codes) {
309
+ var ptr0 = isLikeNone(file_type) ? 0 : passStringToWasm0(file_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
310
+ var len0 = WASM_VECTOR_LEN;
311
+ var ptr1 = isLikeNone(path_name) ? 0 : passStringToWasm0(path_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
312
+ var len1 = WASM_VECTOR_LEN;
313
+ const ret = wasm.decode_to_extsplats(ptr0, len0, ptr1, len1, isLikeNone(sh1_codes) ? 0 : addToExternrefTable0(sh1_codes), isLikeNone(sh2_codes) ? 0 : addToExternrefTable0(sh2_codes), isLikeNone(sh3_codes) ? 0 : addToExternrefTable0(sh3_codes));
314
+ if (ret[2]) {
315
+ throw takeFromExternrefTable0(ret[1]);
316
+ }
317
+ return ChunkDecoder.__wrap(ret[0]);
318
+ }
319
+ function decode_to_gsplatarray(file_type, path_name) {
320
+ var ptr0 = isLikeNone(file_type) ? 0 : passStringToWasm0(file_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ var len0 = WASM_VECTOR_LEN;
322
+ var ptr1 = isLikeNone(path_name) ? 0 : passStringToWasm0(path_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
323
+ var len1 = WASM_VECTOR_LEN;
324
+ const ret = wasm.decode_to_gsplatarray(ptr0, len0, ptr1, len1);
325
+ if (ret[2]) {
326
+ throw takeFromExternrefTable0(ret[1]);
327
+ }
328
+ return ChunkDecoder.__wrap(ret[0]);
329
+ }
330
+ function decode_to_packedsplats(file_type, path_name, encoding, sh1_codes, sh2_codes, sh3_codes) {
331
+ var ptr0 = isLikeNone(file_type) ? 0 : passStringToWasm0(file_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ var len0 = WASM_VECTOR_LEN;
333
+ var ptr1 = isLikeNone(path_name) ? 0 : passStringToWasm0(path_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ var len1 = WASM_VECTOR_LEN;
335
+ const ret = wasm.decode_to_packedsplats(ptr0, len0, ptr1, len1, encoding, isLikeNone(sh1_codes) ? 0 : addToExternrefTable0(sh1_codes), isLikeNone(sh2_codes) ? 0 : addToExternrefTable0(sh2_codes), isLikeNone(sh3_codes) ? 0 : addToExternrefTable0(sh3_codes));
336
+ if (ret[2]) {
337
+ throw takeFromExternrefTable0(ret[1]);
338
+ }
339
+ return ChunkDecoder.__wrap(ret[0]);
340
+ }
341
+ function dispose_lod_tree(lod_id) {
342
+ wasm.dispose_lod_tree(lod_id);
343
+ }
344
+ function get_lod_tree_level(lod_id, level) {
345
+ const ret = wasm.get_lod_tree_level(lod_id, level);
346
+ if (ret[2]) {
347
+ throw takeFromExternrefTable0(ret[1]);
348
+ }
349
+ return takeFromExternrefTable0(ret[0]);
350
+ }
351
+ function init_lod_tree(num_splats, lod_tree) {
352
+ const ret = wasm.init_lod_tree(num_splats, lod_tree);
353
+ if (ret[2]) {
354
+ throw takeFromExternrefTable0(ret[1]);
355
+ }
356
+ return takeFromExternrefTable0(ret[0]);
357
+ }
358
+ function new_lod_tree(capacity) {
359
+ const ret = wasm.new_lod_tree(capacity);
360
+ if (ret[2]) {
361
+ throw takeFromExternrefTable0(ret[1]);
362
+ }
363
+ return takeFromExternrefTable0(ret[0]);
364
+ }
365
+ function new_shared_lod_tree(orig_lod_id) {
366
+ const ret = wasm.new_shared_lod_tree(orig_lod_id);
367
+ if (ret[2]) {
368
+ throw takeFromExternrefTable0(ret[1]);
369
+ }
370
+ return takeFromExternrefTable0(ret[0]);
371
+ }
372
+ function sort32_splats(num_splats, readback, ordering) {
373
+ const ret = wasm.sort32_splats(num_splats, readback, ordering);
374
+ return ret >>> 0;
375
+ }
376
+ function sort_splats(num_splats, readback, ordering) {
377
+ const ret = wasm.sort_splats(num_splats, readback, ordering);
378
+ return ret >>> 0;
379
+ }
380
+ function tiny_lod_extsplats(num_splats, ext1, ext2, extra, lod_base, merge_filter, rgba) {
381
+ const ret = wasm.tiny_lod_extsplats(num_splats, ext1, ext2, isLikeNone(extra) ? 0 : addToExternrefTable0(extra), lod_base, merge_filter, isLikeNone(rgba) ? 0 : addToExternrefTable0(rgba));
382
+ if (ret[2]) {
383
+ throw takeFromExternrefTable0(ret[1]);
384
+ }
385
+ return takeFromExternrefTable0(ret[0]);
386
+ }
387
+ function tiny_lod_packedsplats(num_splats, packed, extra, lod_base, merge_filter, rgba, encoding) {
388
+ const ret = wasm.tiny_lod_packedsplats(num_splats, packed, isLikeNone(extra) ? 0 : addToExternrefTable0(extra), lod_base, merge_filter, isLikeNone(rgba) ? 0 : addToExternrefTable0(rgba), encoding);
389
+ if (ret[2]) {
390
+ throw takeFromExternrefTable0(ret[1]);
391
+ }
392
+ return takeFromExternrefTable0(ret[0]);
393
+ }
394
+ function traverse_lod_trees(max_splats, pixel_scale_limit, _last_pixel_limit, lod_ids, root_pages, view_to_objects, lod_scales, behind_foveates, cone_foveates, cone_fov0s, cone_fovs) {
395
+ const ptr0 = passArray32ToWasm0(lod_ids, wasm.__wbindgen_malloc);
396
+ const len0 = WASM_VECTOR_LEN;
397
+ const ptr1 = passArray32ToWasm0(root_pages, wasm.__wbindgen_malloc);
398
+ const len1 = WASM_VECTOR_LEN;
399
+ const ptr2 = passArrayF32ToWasm0(view_to_objects, wasm.__wbindgen_malloc);
400
+ const len2 = WASM_VECTOR_LEN;
401
+ const ptr3 = passArrayF32ToWasm0(lod_scales, wasm.__wbindgen_malloc);
402
+ const len3 = WASM_VECTOR_LEN;
403
+ const ptr4 = passArrayF32ToWasm0(behind_foveates, wasm.__wbindgen_malloc);
404
+ const len4 = WASM_VECTOR_LEN;
405
+ const ptr5 = passArrayF32ToWasm0(cone_foveates, wasm.__wbindgen_malloc);
406
+ const len5 = WASM_VECTOR_LEN;
407
+ const ptr6 = passArrayF32ToWasm0(cone_fov0s, wasm.__wbindgen_malloc);
408
+ const len6 = WASM_VECTOR_LEN;
409
+ const ptr7 = passArrayF32ToWasm0(cone_fovs, wasm.__wbindgen_malloc);
410
+ const len7 = WASM_VECTOR_LEN;
411
+ const ret = wasm.traverse_lod_trees(max_splats, pixel_scale_limit, isLikeNone(_last_pixel_limit) ? 4294967297 : Math.fround(_last_pixel_limit), ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
412
+ if (ret[2]) {
413
+ throw takeFromExternrefTable0(ret[1]);
414
+ }
415
+ return takeFromExternrefTable0(ret[0]);
416
+ }
417
+ function update_lod_trees(lod_ids, page_bases, chunk_bases, counts, lod_trees) {
418
+ const ptr0 = passArray32ToWasm0(lod_ids, wasm.__wbindgen_malloc);
419
+ const len0 = WASM_VECTOR_LEN;
420
+ const ptr1 = passArray32ToWasm0(page_bases, wasm.__wbindgen_malloc);
421
+ const len1 = WASM_VECTOR_LEN;
422
+ const ptr2 = passArray32ToWasm0(chunk_bases, wasm.__wbindgen_malloc);
423
+ const len2 = WASM_VECTOR_LEN;
424
+ const ptr3 = passArray32ToWasm0(counts, wasm.__wbindgen_malloc);
425
+ const len3 = WASM_VECTOR_LEN;
426
+ const ret = wasm.update_lod_trees(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, lod_trees);
427
+ if (ret[2]) {
428
+ throw takeFromExternrefTable0(ret[1]);
429
+ }
430
+ return takeFromExternrefTable0(ret[0]);
431
+ }
432
+ function __wbg_get_imports() {
433
+ const import0 = {
434
+ __proto__: null,
435
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
436
+ const ret = Error(getStringFromWasm0(arg0, arg1));
437
+ return ret;
438
+ },
439
+ __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
440
+ const v = arg0;
441
+ const ret = typeof v === "boolean" ? v : void 0;
442
+ return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
443
+ },
444
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
445
+ const ret = debugString(arg1);
446
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
447
+ const len1 = WASM_VECTOR_LEN;
448
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
449
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
450
+ },
451
+ __wbg___wbindgen_in_4bd7a57e54337366: function(arg0, arg1) {
452
+ const ret = arg0 in arg1;
453
+ return ret;
454
+ },
455
+ __wbg___wbindgen_is_falsy_c6ddfae1bb56d5ef: function(arg0) {
456
+ const ret = !arg0;
457
+ return ret;
458
+ },
459
+ __wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
460
+ const val = arg0;
461
+ const ret = typeof val === "object" && val !== null;
462
+ return ret;
463
+ },
464
+ __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
465
+ const ret = arg0 === void 0;
466
+ return ret;
467
+ },
468
+ __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
469
+ const ret = arg0 == arg1;
470
+ return ret;
471
+ },
472
+ __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
473
+ const obj = arg1;
474
+ const ret = typeof obj === "number" ? obj : void 0;
475
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
476
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
477
+ },
478
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
479
+ const obj = arg1;
480
+ const ret = typeof obj === "string" ? obj : void 0;
481
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
482
+ var len1 = WASM_VECTOR_LEN;
483
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
484
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
485
+ },
486
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
487
+ throw new Error(getStringFromWasm0(arg0, arg1));
488
+ },
489
+ __wbg_csplatarray_new: function(arg0) {
490
+ const ret = CsplatArray.__wrap(arg0);
491
+ return ret;
492
+ },
493
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
494
+ let deferred0_0;
495
+ let deferred0_1;
496
+ try {
497
+ deferred0_0 = arg0;
498
+ deferred0_1 = arg1;
499
+ console.error(getStringFromWasm0(arg0, arg1));
500
+ } finally {
501
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
502
+ }
503
+ },
504
+ __wbg_get_4848e350b40afc16: function(arg0, arg1) {
505
+ const ret = arg0[arg1 >>> 0];
506
+ return ret;
507
+ },
508
+ __wbg_get_f96702c6245e4ef9: function() {
509
+ return handleError(function(arg0, arg1) {
510
+ const ret = Reflect.get(arg0, arg1);
511
+ return ret;
512
+ }, arguments);
513
+ },
514
+ __wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
515
+ const ret = arg0[arg1 >>> 0];
516
+ return ret;
517
+ },
518
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
519
+ const ret = arg0[arg1];
520
+ return ret;
521
+ },
522
+ __wbg_gsplatarray_new: function(arg0) {
523
+ const ret = GsplatArray.__wrap(arg0);
524
+ return ret;
525
+ },
526
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
527
+ let result;
528
+ try {
529
+ result = arg0 instanceof ArrayBuffer;
530
+ } catch (_) {
531
+ result = false;
532
+ }
533
+ const ret = result;
534
+ return ret;
535
+ },
536
+ __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
537
+ let result;
538
+ try {
539
+ result = arg0 instanceof Uint8Array;
540
+ } catch (_) {
541
+ result = false;
542
+ }
543
+ const ret = result;
544
+ return ret;
545
+ },
546
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
547
+ const ret = arg0.length;
548
+ return ret;
549
+ },
550
+ __wbg_length_1e701798fdcaa3b4: function(arg0) {
551
+ const ret = arg0.length;
552
+ return ret;
553
+ },
554
+ __wbg_length_6e821edde497a532: function(arg0) {
555
+ const ret = arg0.length;
556
+ return ret;
557
+ },
558
+ __wbg_length_a4ca9e78359b5f1f: function(arg0) {
559
+ const ret = arg0.length;
560
+ return ret;
561
+ },
562
+ __wbg_new_227d7c05414eb861: function() {
563
+ const ret = new Error();
564
+ return ret;
565
+ },
566
+ __wbg_new_4f9fafbb3909af72: function() {
567
+ const ret = new Object();
568
+ return ret;
569
+ },
570
+ __wbg_new_a560378ea1240b14: function(arg0) {
571
+ const ret = new Uint8Array(arg0);
572
+ return ret;
573
+ },
574
+ __wbg_new_f3c9df4f38f3f798: function() {
575
+ const ret = new Array();
576
+ return ret;
577
+ },
578
+ __wbg_new_with_length_41a22191b9bdfd66: function(arg0) {
579
+ const ret = new Uint32Array(arg0 >>> 0);
580
+ return ret;
581
+ },
582
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
583
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
584
+ },
585
+ __wbg_prototypesetcall_64c287a27cc24d27: function(arg0, arg1, arg2) {
586
+ Uint16Array.prototype.set.call(getArrayU16FromWasm0(arg0, arg1), arg2);
587
+ },
588
+ __wbg_prototypesetcall_e42275e601e14eeb: function(arg0, arg1, arg2) {
589
+ Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), arg2);
590
+ },
591
+ __wbg_push_6bdbc990be5ac37b: function(arg0, arg1) {
592
+ const ret = arg0.push(arg1);
593
+ return ret;
594
+ },
595
+ __wbg_set_448126769bf7c181: function(arg0, arg1, arg2) {
596
+ arg0.set(getArrayU32FromWasm0(arg1, arg2));
597
+ },
598
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
599
+ arg0[arg1] = arg2;
600
+ },
601
+ __wbg_set_81b4174352e6a095: function(arg0, arg1, arg2) {
602
+ arg0.set(arg1, arg2 >>> 0);
603
+ },
604
+ __wbg_set_8ee2d34facb8466e: function() {
605
+ return handleError(function(arg0, arg1, arg2) {
606
+ const ret = Reflect.set(arg0, arg1, arg2);
607
+ return ret;
608
+ }, arguments);
609
+ },
610
+ __wbg_set_index_338a66e40fc45dee: function(arg0, arg1, arg2) {
611
+ arg0[arg1 >>> 0] = arg2 >>> 0;
612
+ },
613
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
614
+ const ret = arg1.stack;
615
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
616
+ const len1 = WASM_VECTOR_LEN;
617
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
618
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
619
+ },
620
+ __wbg_subarray_0f98d3fb634508ad: function(arg0, arg1, arg2) {
621
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
622
+ return ret;
623
+ },
624
+ __wbg_subarray_517cd0f1811ab872: function(arg0, arg1, arg2) {
625
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
626
+ return ret;
627
+ },
628
+ __wbg_subarray_d51e89458b3fdbf6: function(arg0, arg1, arg2) {
629
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
630
+ return ret;
631
+ },
632
+ __wbindgen_cast_0000000000000001: function(arg0) {
633
+ const ret = arg0;
634
+ return ret;
635
+ },
636
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
637
+ const ret = getStringFromWasm0(arg0, arg1);
638
+ return ret;
639
+ },
640
+ __wbindgen_init_externref_table: function() {
641
+ const table = wasm.__wbindgen_externrefs;
642
+ const offset = table.grow(4);
643
+ table.set(0, void 0);
644
+ table.set(offset + 0, void 0);
645
+ table.set(offset + 1, null);
646
+ table.set(offset + 2, true);
647
+ table.set(offset + 3, false);
648
+ }
649
+ };
650
+ return {
651
+ __proto__: null,
652
+ "./spark_worker_rs_bg.js": import0
653
+ };
654
+ }
655
+ const ChunkDecoderFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
656
+ }, unregister: () => {
657
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_chunkdecoder_free(ptr >>> 0, 1));
658
+ const CsplatArrayFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
659
+ }, unregister: () => {
660
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_csplatarray_free(ptr >>> 0, 1));
661
+ const GsplatArrayFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
662
+ }, unregister: () => {
663
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_gsplatarray_free(ptr >>> 0, 1));
664
+ function addToExternrefTable0(obj) {
665
+ const idx = wasm.__externref_table_alloc();
666
+ wasm.__wbindgen_externrefs.set(idx, obj);
667
+ return idx;
668
+ }
669
+ function debugString(val) {
670
+ const type = typeof val;
671
+ if (type == "number" || type == "boolean" || val == null) {
672
+ return `${val}`;
673
+ }
674
+ if (type == "string") {
675
+ return `"${val}"`;
676
+ }
677
+ if (type == "symbol") {
678
+ const description = val.description;
679
+ if (description == null) {
680
+ return "Symbol";
681
+ } else {
682
+ return `Symbol(${description})`;
683
+ }
684
+ }
685
+ if (type == "function") {
686
+ const name = val.name;
687
+ if (typeof name == "string" && name.length > 0) {
688
+ return `Function(${name})`;
689
+ } else {
690
+ return "Function";
691
+ }
692
+ }
693
+ if (Array.isArray(val)) {
694
+ const length = val.length;
695
+ let debug = "[";
696
+ if (length > 0) {
697
+ debug += debugString(val[0]);
698
+ }
699
+ for (let i = 1; i < length; i++) {
700
+ debug += ", " + debugString(val[i]);
701
+ }
702
+ debug += "]";
703
+ return debug;
704
+ }
705
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
706
+ let className;
707
+ if (builtInMatches && builtInMatches.length > 1) {
708
+ className = builtInMatches[1];
709
+ } else {
710
+ return toString.call(val);
711
+ }
712
+ if (className == "Object") {
713
+ try {
714
+ return "Object(" + JSON.stringify(val) + ")";
715
+ } catch (_) {
716
+ return "Object";
717
+ }
718
+ }
719
+ if (val instanceof Error) {
720
+ return `${val.name}: ${val.message}
721
+ ${val.stack}`;
722
+ }
723
+ return className;
724
+ }
725
+ function getArrayU16FromWasm0(ptr, len) {
726
+ ptr = ptr >>> 0;
727
+ return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
728
+ }
729
+ function getArrayU32FromWasm0(ptr, len) {
730
+ ptr = ptr >>> 0;
731
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
732
+ }
733
+ function getArrayU8FromWasm0(ptr, len) {
734
+ ptr = ptr >>> 0;
735
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
736
+ }
737
+ let cachedDataViewMemory0 = null;
738
+ function getDataViewMemory0() {
739
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
740
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
741
+ }
742
+ return cachedDataViewMemory0;
743
+ }
744
+ let cachedFloat32ArrayMemory0 = null;
745
+ function getFloat32ArrayMemory0() {
746
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
747
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
748
+ }
749
+ return cachedFloat32ArrayMemory0;
750
+ }
751
+ function getStringFromWasm0(ptr, len) {
752
+ ptr = ptr >>> 0;
753
+ return decodeText(ptr, len);
754
+ }
755
+ let cachedUint16ArrayMemory0 = null;
756
+ function getUint16ArrayMemory0() {
757
+ if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
758
+ cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
759
+ }
760
+ return cachedUint16ArrayMemory0;
761
+ }
762
+ let cachedUint32ArrayMemory0 = null;
763
+ function getUint32ArrayMemory0() {
764
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
765
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
766
+ }
767
+ return cachedUint32ArrayMemory0;
768
+ }
769
+ let cachedUint8ArrayMemory0 = null;
770
+ function getUint8ArrayMemory0() {
771
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
772
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
773
+ }
774
+ return cachedUint8ArrayMemory0;
775
+ }
776
+ function handleError(f, args) {
777
+ try {
778
+ return f.apply(this, args);
779
+ } catch (e) {
780
+ const idx = addToExternrefTable0(e);
781
+ wasm.__wbindgen_exn_store(idx);
782
+ }
783
+ }
784
+ function isLikeNone(x) {
785
+ return x === void 0 || x === null;
786
+ }
787
+ function passArray32ToWasm0(arg, malloc) {
788
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
789
+ getUint32ArrayMemory0().set(arg, ptr / 4);
790
+ WASM_VECTOR_LEN = arg.length;
791
+ return ptr;
792
+ }
793
+ function passArrayF32ToWasm0(arg, malloc) {
794
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
795
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
796
+ WASM_VECTOR_LEN = arg.length;
797
+ return ptr;
798
+ }
799
+ function passStringToWasm0(arg, malloc, realloc) {
800
+ if (realloc === void 0) {
801
+ const buf = cachedTextEncoder.encode(arg);
802
+ const ptr2 = malloc(buf.length, 1) >>> 0;
803
+ getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
804
+ WASM_VECTOR_LEN = buf.length;
805
+ return ptr2;
806
+ }
807
+ let len = arg.length;
808
+ let ptr = malloc(len, 1) >>> 0;
809
+ const mem = getUint8ArrayMemory0();
810
+ let offset = 0;
811
+ for (; offset < len; offset++) {
812
+ const code = arg.charCodeAt(offset);
813
+ if (code > 127) break;
814
+ mem[ptr + offset] = code;
815
+ }
816
+ if (offset !== len) {
817
+ if (offset !== 0) {
818
+ arg = arg.slice(offset);
819
+ }
820
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
821
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
822
+ const ret = cachedTextEncoder.encodeInto(arg, view);
823
+ offset += ret.written;
824
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
825
+ }
826
+ WASM_VECTOR_LEN = offset;
827
+ return ptr;
828
+ }
829
+ function takeFromExternrefTable0(idx) {
830
+ const value = wasm.__wbindgen_externrefs.get(idx);
831
+ wasm.__externref_table_dealloc(idx);
832
+ return value;
833
+ }
834
+ let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
835
+ cachedTextDecoder.decode();
836
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
837
+ let numBytesDecoded = 0;
838
+ function decodeText(ptr, len) {
839
+ numBytesDecoded += len;
840
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
841
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
842
+ cachedTextDecoder.decode();
843
+ numBytesDecoded = len;
844
+ }
845
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
846
+ }
847
+ const cachedTextEncoder = new TextEncoder();
848
+ if (!("encodeInto" in cachedTextEncoder)) {
849
+ cachedTextEncoder.encodeInto = function(arg, view) {
850
+ const buf = cachedTextEncoder.encode(arg);
851
+ view.set(buf);
852
+ return {
853
+ read: arg.length,
854
+ written: buf.length
855
+ };
856
+ };
857
+ }
858
+ let WASM_VECTOR_LEN = 0;
859
+ let wasm;
860
+ function __wbg_finalize_init(instance, module) {
861
+ wasm = instance.exports;
862
+ cachedDataViewMemory0 = null;
863
+ cachedFloat32ArrayMemory0 = null;
864
+ cachedUint16ArrayMemory0 = null;
865
+ cachedUint32ArrayMemory0 = null;
866
+ cachedUint8ArrayMemory0 = null;
867
+ wasm.__wbindgen_start();
868
+ return wasm;
869
+ }
870
+ async function __wbg_load(module, imports) {
871
+ if (typeof Response === "function" && module instanceof Response) {
872
+ if (typeof WebAssembly.instantiateStreaming === "function") {
873
+ try {
874
+ return await WebAssembly.instantiateStreaming(module, imports);
875
+ } catch (e) {
876
+ const validResponse = module.ok && expectedResponseType(module.type);
877
+ if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
878
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
879
+ } else {
880
+ throw e;
881
+ }
882
+ }
883
+ }
884
+ const bytes = await module.arrayBuffer();
885
+ return await WebAssembly.instantiate(bytes, imports);
886
+ } else {
887
+ const instance = await WebAssembly.instantiate(module, imports);
888
+ if (instance instanceof WebAssembly.Instance) {
889
+ return { instance, module };
890
+ } else {
891
+ return instance;
892
+ }
893
+ }
894
+ function expectedResponseType(type) {
895
+ switch (type) {
896
+ case "basic":
897
+ case "cors":
898
+ case "default":
899
+ return true;
900
+ }
901
+ return false;
902
+ }
903
+ }
904
+ async function __wbg_init(module_or_path) {
905
+ if (wasm !== void 0) return wasm;
906
+ if (module_or_path !== void 0) {
907
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
908
+ ({ module_or_path } = module_or_path);
909
+ } else {
910
+ console.warn("using deprecated parameters for the initialization function; pass a single object instead");
911
+ }
912
+ }
913
+ if (module_or_path === void 0) {
914
+ module_or_path = new URL(self.location.href).searchParams.get("wasm");
915
+ }
916
+ const imports = __wbg_get_imports();
917
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
918
+ module_or_path = fetch(module_or_path);
919
+ }
920
+ const { instance } = await __wbg_load(await module_or_path, imports);
921
+ return __wbg_finalize_init(instance);
922
+ }
923
+ const rpcHandlers = {
924
+ sortSplats16,
925
+ sortSplats32,
926
+ loadPackedSplats,
927
+ loadExtSplats,
928
+ tinyLodPackedSplats,
929
+ qualityLodPackedSplats,
930
+ tinyLodExtSplats,
931
+ qualityLodExtSplats,
932
+ newLodTree,
933
+ newSharedLodTree,
934
+ initLodTree,
935
+ disposeLodTree,
936
+ updateLodTrees,
937
+ traverseLodTrees,
938
+ getLodTreeLevel,
939
+ nextChunk
940
+ };
941
+ async function onMessage(event) {
942
+ const {
943
+ id,
944
+ name,
945
+ args
946
+ } = event.data;
947
+ try {
948
+ const handler = rpcHandlers[name];
949
+ if (!handler) {
950
+ throw new Error(`Unknown worker RPC: ${name}`);
951
+ }
952
+ const sendStatus = (data) => {
953
+ self.postMessage(
954
+ { id, status: data },
955
+ { transfer: getTransferable(data) }
956
+ );
957
+ };
958
+ const result = await handler(args, { sendStatus });
959
+ self.postMessage({ id, result }, { transfer: getTransferable(result) });
960
+ } catch (error) {
961
+ console.warn(`Worker error: ${error}`);
962
+ self.postMessage({ id, error }, { transfer: getTransferable(error) });
963
+ }
964
+ }
965
+ function sortSplats16({
966
+ numSplats,
967
+ readback,
968
+ ordering
969
+ }) {
970
+ const activeSplats = sort_splats(numSplats, readback, ordering);
971
+ return { activeSplats, readback, ordering };
972
+ }
973
+ function sortSplats32({
974
+ numSplats,
975
+ readback,
976
+ ordering
977
+ }) {
978
+ const activeSplats = sort32_splats(numSplats, readback, ordering);
979
+ return { activeSplats, readback, ordering };
980
+ }
981
+ async function decodeBytesUrl({
982
+ decoder,
983
+ fileBytes,
984
+ url,
985
+ requestHeader,
986
+ withCredentials,
987
+ chunked,
988
+ chunkedLength,
989
+ sendStatus
990
+ }) {
991
+ if (fileBytes) {
992
+ const CHUNK_SIZE = 1048576;
993
+ for (let i = 0; i < fileBytes.length; i += CHUNK_SIZE) {
994
+ decoder.push(
995
+ fileBytes.subarray(i, Math.min(i + CHUNK_SIZE, fileBytes.length))
996
+ );
997
+ }
998
+ } else if (url) {
999
+ const request = new Request(url, {
1000
+ headers: requestHeader ? new Headers(requestHeader) : void 0,
1001
+ credentials: withCredentials ? "include" : "same-origin"
1002
+ });
1003
+ const response = await fetch(request);
1004
+ if (!response.ok || !response.body) {
1005
+ throw new Error(
1006
+ `Failed to fetch "${url}": ${response.status} ${response.statusText}`
1007
+ );
1008
+ }
1009
+ const readStream = response.body.getReader();
1010
+ const contentLength = Number.parseInt(
1011
+ response.headers.get("Content-Length") || "0"
1012
+ );
1013
+ const total = Number.isNaN(contentLength) ? 0 : contentLength;
1014
+ let loaded = 0;
1015
+ while (true) {
1016
+ const { done, value } = await readStream.read();
1017
+ if (done) {
1018
+ readStream.releaseLock();
1019
+ break;
1020
+ }
1021
+ loaded += value.length;
1022
+ sendStatus({ loaded, total });
1023
+ decoder.push(value);
1024
+ }
1025
+ } else if (chunked) {
1026
+ let loaded = 0;
1027
+ const total = chunkedLength ?? 0;
1028
+ while (true) {
1029
+ const readNextChunk = new Promise((resolve) => {
1030
+ nextChunkWaiter = resolve;
1031
+ });
1032
+ sendStatus({ nextChunk: true });
1033
+ const nextChunk2 = await readNextChunk;
1034
+ if (nextChunk2.length === 0) {
1035
+ break;
1036
+ }
1037
+ decoder.push(nextChunk2);
1038
+ loaded += nextChunk2.length;
1039
+ sendStatus({ progress: { loaded, total } });
1040
+ }
1041
+ if (total === 0) {
1042
+ sendStatus({ progress: { loaded, total: loaded } });
1043
+ }
1044
+ } else {
1045
+ throw new Error("No url or fileBytes provided");
1046
+ }
1047
+ const decoded = decoder.finish();
1048
+ return decoded;
1049
+ }
1050
+ function toPackedResult(packed) {
1051
+ return {
1052
+ numSplats: packed.numSplats,
1053
+ packedArray: packed.packed,
1054
+ extra: {
1055
+ sh1: packed.sh1,
1056
+ sh2: packed.sh2,
1057
+ sh3: packed.sh3,
1058
+ sh1Codes: packed.sh1Codes,
1059
+ sh2Codes: packed.sh2Codes,
1060
+ sh3Codes: packed.sh3Codes,
1061
+ lodTree: packed.lodTree
1062
+ },
1063
+ splatEncoding: packed.splatEncoding
1064
+ };
1065
+ }
1066
+ async function loadPackedSplats({
1067
+ url,
1068
+ requestHeader,
1069
+ withCredentials,
1070
+ fileBytes,
1071
+ fileType,
1072
+ pathName,
1073
+ chunked,
1074
+ chunkedLength,
1075
+ encoding,
1076
+ lod,
1077
+ lodBase,
1078
+ lodAbove,
1079
+ nonLod,
1080
+ sh1Codes,
1081
+ sh2Codes,
1082
+ sh3Codes
1083
+ }, {
1084
+ sendStatus
1085
+ }) {
1086
+ if (!lod) {
1087
+ const decoder2 = decode_to_packedsplats(
1088
+ fileType,
1089
+ pathName ?? url,
1090
+ encoding,
1091
+ sh1Codes,
1092
+ sh2Codes,
1093
+ sh3Codes
1094
+ );
1095
+ const decoded2 = await decodeBytesUrl({
1096
+ decoder: decoder2,
1097
+ fileBytes,
1098
+ url,
1099
+ requestHeader,
1100
+ withCredentials,
1101
+ chunked,
1102
+ chunkedLength,
1103
+ sendStatus
1104
+ });
1105
+ const result2 = toPackedResult(decoded2);
1106
+ if (result2.splatEncoding.lodOpacity) {
1107
+ return { lodSplats: result2 };
1108
+ }
1109
+ return result2;
1110
+ }
1111
+ const decoder = decode_to_csplatarray(fileType, pathName ?? url, encoding);
1112
+ const decoded = await decodeBytesUrl({
1113
+ decoder,
1114
+ fileBytes,
1115
+ url,
1116
+ requestHeader,
1117
+ withCredentials,
1118
+ chunked,
1119
+ chunkedLength,
1120
+ sendStatus
1121
+ });
1122
+ if (decoded.has_lod()) {
1123
+ const result2 = toPackedResult(
1124
+ decoded.to_packedsplats_lod()
1125
+ );
1126
+ return { lodSplats: result2 };
1127
+ }
1128
+ if (lodAbove !== void 0) {
1129
+ if (decoded.len() < lodAbove) {
1130
+ return toPackedResult(decoded.to_packedsplats());
1131
+ }
1132
+ }
1133
+ let result = {};
1134
+ if (nonLod) {
1135
+ result = toPackedResult(decoded.to_packedsplats());
1136
+ }
1137
+ const initialSplats = decoded.len();
1138
+ const lodName = lod === "quality" ? "Bhatt" : "Tiny";
1139
+ console.log(
1140
+ `Loaded ${initialSplats} splats. Starting ${lodName} LoD build...`
1141
+ );
1142
+ const lodStart = performance.now();
1143
+ if (lod === "quality") {
1144
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.25));
1145
+ decoded.bhatt_lod(base);
1146
+ } else {
1147
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.5));
1148
+ decoded.tiny_lod(base, false);
1149
+ }
1150
+ const lodDuration = performance.now() - lodStart;
1151
+ console.log(
1152
+ `${lodName} LoD: ${initialSplats} -> ${decoded.len()} (${lodDuration} ms)`
1153
+ );
1154
+ const lodPacked = decoded.to_packedsplats_lod();
1155
+ result.lodSplats = toPackedResult(lodPacked);
1156
+ return result;
1157
+ }
1158
+ function toExtResult(packed) {
1159
+ return {
1160
+ numSplats: packed.numSplats,
1161
+ extArrays: [packed.ext0, packed.ext1],
1162
+ extra: {
1163
+ sh1: packed.sh1,
1164
+ sh2: packed.sh2,
1165
+ sh3a: packed.sh3a,
1166
+ sh3b: packed.sh3b,
1167
+ sh1Codes: packed.sh1Codes,
1168
+ sh2Codes: packed.sh2Codes,
1169
+ sh3Codes: packed.sh3Codes,
1170
+ lodTree: packed.lodTree
1171
+ }
1172
+ };
1173
+ }
1174
+ async function loadExtSplats({
1175
+ url,
1176
+ requestHeader,
1177
+ withCredentials,
1178
+ fileBytes,
1179
+ fileType,
1180
+ pathName,
1181
+ chunked,
1182
+ chunkedLength,
1183
+ lod,
1184
+ lodBase,
1185
+ lodAbove,
1186
+ nonLod,
1187
+ sh1Codes,
1188
+ sh2Codes,
1189
+ sh3Codes
1190
+ }, {
1191
+ sendStatus
1192
+ }) {
1193
+ if (!lod) {
1194
+ const decoder2 = decode_to_extsplats(
1195
+ fileType,
1196
+ pathName ?? url,
1197
+ sh1Codes,
1198
+ sh2Codes,
1199
+ sh3Codes
1200
+ );
1201
+ const decoded2 = await decodeBytesUrl({
1202
+ decoder: decoder2,
1203
+ fileBytes,
1204
+ url,
1205
+ requestHeader,
1206
+ withCredentials,
1207
+ chunked,
1208
+ chunkedLength,
1209
+ sendStatus
1210
+ });
1211
+ const result2 = toExtResult(decoded2);
1212
+ if (result2.extra.lodTree) {
1213
+ return { lodSplats: result2 };
1214
+ }
1215
+ return result2;
1216
+ }
1217
+ const decoder = decode_to_gsplatarray(fileType, pathName ?? url);
1218
+ const decoded = await decodeBytesUrl({
1219
+ decoder,
1220
+ fileBytes,
1221
+ url,
1222
+ requestHeader,
1223
+ withCredentials,
1224
+ chunked,
1225
+ chunkedLength,
1226
+ sendStatus
1227
+ });
1228
+ if (decoded.has_lod()) {
1229
+ return {
1230
+ lodSplats: toExtResult(decoded.to_extsplats_lod())
1231
+ };
1232
+ }
1233
+ if (lodAbove !== void 0) {
1234
+ if (decoded.len() < lodAbove) {
1235
+ return toExtResult(decoded.to_extsplats());
1236
+ }
1237
+ }
1238
+ let result = {};
1239
+ if (nonLod) {
1240
+ result = toExtResult(decoded.to_extsplats());
1241
+ }
1242
+ const initialSplats = decoded.len();
1243
+ const lodName = lod === "quality" ? "Bhatt" : "Tiny";
1244
+ console.log(
1245
+ `Loaded ${initialSplats} splats. Starting ${lodName} LoD build...`
1246
+ );
1247
+ const lodStart = performance.now();
1248
+ if (lod === "quality") {
1249
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.75));
1250
+ decoded.bhatt_lod(base);
1251
+ } else {
1252
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.5));
1253
+ decoded.tiny_lod(base, false);
1254
+ }
1255
+ const lodDuration = performance.now() - lodStart;
1256
+ console.log(
1257
+ `${lodName} LoD: ${initialSplats} -> ${decoded.len()} (${lodDuration} ms)`
1258
+ );
1259
+ const lodPacked = decoded.to_extsplats_lod();
1260
+ result.lodSplats = toExtResult(lodPacked);
1261
+ return result;
1262
+ }
1263
+ async function tinyLodPackedSplats({
1264
+ numSplats,
1265
+ packedArray,
1266
+ extra,
1267
+ lodBase,
1268
+ rgba,
1269
+ encoding
1270
+ }) {
1271
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.5));
1272
+ const lodStart = performance.now();
1273
+ const filter = false;
1274
+ const decoded = tiny_lod_packedsplats(
1275
+ numSplats,
1276
+ packedArray,
1277
+ extra,
1278
+ base,
1279
+ filter,
1280
+ rgba,
1281
+ encoding
1282
+ );
1283
+ const lodDuration = performance.now() - lodStart;
1284
+ const result = toPackedResult(decoded);
1285
+ console.log(
1286
+ `Tiny LoD: ${numSplats} -> ${result.numSplats} (${lodDuration} ms)`
1287
+ );
1288
+ return result;
1289
+ }
1290
+ async function qualityLodPackedSplats({
1291
+ numSplats,
1292
+ packedArray,
1293
+ extra,
1294
+ lodBase,
1295
+ rgba,
1296
+ encoding
1297
+ }) {
1298
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.75));
1299
+ const lodStart = performance.now();
1300
+ const decoded = bhatt_lod_packedsplats(
1301
+ numSplats,
1302
+ packedArray,
1303
+ extra,
1304
+ base,
1305
+ rgba,
1306
+ encoding
1307
+ );
1308
+ const lodDuration = performance.now() - lodStart;
1309
+ const result = toPackedResult(decoded);
1310
+ console.log(
1311
+ `Bhatt LoD: ${numSplats} -> ${result.numSplats} (${lodDuration} ms)`
1312
+ );
1313
+ return result;
1314
+ }
1315
+ async function tinyLodExtSplats({
1316
+ numSplats,
1317
+ extArrays,
1318
+ extra,
1319
+ lodBase,
1320
+ rgba,
1321
+ encoding
1322
+ }) {
1323
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.5));
1324
+ const lodStart = performance.now();
1325
+ const filter = false;
1326
+ const decoded = tiny_lod_extsplats(
1327
+ numSplats,
1328
+ extArrays[0],
1329
+ extArrays[1],
1330
+ extra,
1331
+ base,
1332
+ filter,
1333
+ rgba
1334
+ );
1335
+ const lodDuration = performance.now() - lodStart;
1336
+ const result = toExtResult(decoded);
1337
+ console.log(
1338
+ `Tiny LoD: ${numSplats} -> ${result.numSplats} (${lodDuration} ms)`
1339
+ );
1340
+ return result;
1341
+ }
1342
+ async function qualityLodExtSplats({
1343
+ numSplats,
1344
+ extArrays,
1345
+ extra,
1346
+ lodBase,
1347
+ rgba,
1348
+ encoding
1349
+ }) {
1350
+ const base = Math.max(1.1, Math.min(2, lodBase ?? 1.75));
1351
+ const lodStart = performance.now();
1352
+ const decoded = bhatt_lod_extsplats(
1353
+ numSplats,
1354
+ extArrays[0],
1355
+ extArrays[1],
1356
+ extra,
1357
+ base,
1358
+ rgba
1359
+ );
1360
+ const lodDuration = performance.now() - lodStart;
1361
+ const result = toExtResult(decoded);
1362
+ console.log(
1363
+ `Bhatt LoD: ${numSplats} -> ${result.numSplats} (${lodDuration} ms)`
1364
+ );
1365
+ return result;
1366
+ }
1367
+ function newLodTree({
1368
+ capacity
1369
+ }) {
1370
+ const { lodId } = new_lod_tree(capacity);
1371
+ return { lodId };
1372
+ }
1373
+ function newSharedLodTree({
1374
+ lodId
1375
+ }) {
1376
+ const { lodId: newLodId } = new_shared_lod_tree(lodId);
1377
+ return { lodId: newLodId };
1378
+ }
1379
+ function initLodTree({
1380
+ numSplats,
1381
+ lodTree
1382
+ }) {
1383
+ const { lodId, chunkToPage } = init_lod_tree(numSplats, lodTree);
1384
+ return { lodId, chunkToPage };
1385
+ }
1386
+ function disposeLodTree({ lodId }) {
1387
+ dispose_lod_tree(lodId);
1388
+ }
1389
+ function updateLodTrees({
1390
+ ranges
1391
+ }) {
1392
+ const lodIds = new Uint32Array(ranges.map(({ lodId }) => lodId));
1393
+ const pageBases = new Uint32Array(ranges.map(({ pageBase }) => pageBase));
1394
+ const chunkBases = new Uint32Array(ranges.map(({ chunkBase }) => chunkBase));
1395
+ const counts = new Uint32Array(ranges.map(({ count }) => count));
1396
+ const lodTreeData = ranges.map(({ lodTreeData: lodTreeData2 }) => lodTreeData2);
1397
+ update_lod_trees(
1398
+ lodIds,
1399
+ pageBases,
1400
+ chunkBases,
1401
+ counts,
1402
+ lodTreeData
1403
+ );
1404
+ }
1405
+ function traverseLodTrees({
1406
+ maxSplats,
1407
+ pixelScaleLimit,
1408
+ lastPixelLimit,
1409
+ instances
1410
+ }) {
1411
+ const keyInstances = Object.entries(instances);
1412
+ const lodIds = new Uint32Array(
1413
+ keyInstances.map(([_key, instance]) => instance.lodId)
1414
+ );
1415
+ const rootPages = new Uint32Array(
1416
+ keyInstances.map(([_key, instance]) => instance.rootPage ?? 4294967295)
1417
+ );
1418
+ const viewToObjects = new Float32Array(
1419
+ keyInstances.flatMap(([_key, instance]) => {
1420
+ if (instance.viewToObjectCols.length !== 16) {
1421
+ throw new Error("Incorrect array size for viewToObjectCols");
1422
+ }
1423
+ return instance.viewToObjectCols;
1424
+ })
1425
+ );
1426
+ const lodScales = new Float32Array(
1427
+ keyInstances.map(([_key, instance]) => instance.lodScale)
1428
+ );
1429
+ const behindFoveates = new Float32Array(
1430
+ keyInstances.map(([_key, instance]) => instance.behindFoveate)
1431
+ );
1432
+ const coneFov0s = new Float32Array(
1433
+ keyInstances.map(([_key, instance]) => instance.coneFov0)
1434
+ );
1435
+ const coneFovs = new Float32Array(
1436
+ keyInstances.map(([_key, instance]) => instance.coneFov)
1437
+ );
1438
+ const coneFoveates = new Float32Array(
1439
+ keyInstances.map(([_key, instance]) => instance.coneFoveate)
1440
+ );
1441
+ const result = traverse_lod_trees(
1442
+ maxSplats,
1443
+ pixelScaleLimit,
1444
+ lastPixelLimit,
1445
+ lodIds,
1446
+ rootPages,
1447
+ viewToObjects,
1448
+ lodScales,
1449
+ behindFoveates,
1450
+ coneFoveates,
1451
+ coneFov0s,
1452
+ coneFovs
1453
+ );
1454
+ const { instanceIndices, chunks, pixelLimit } = result;
1455
+ const indices = keyInstances.reduce(
1456
+ (indices2, [key, _instance], index) => {
1457
+ indices2[key] = instanceIndices[index];
1458
+ return indices2;
1459
+ },
1460
+ {}
1461
+ );
1462
+ return {
1463
+ keyIndices: indices,
1464
+ chunks,
1465
+ pixelLimit
1466
+ };
1467
+ }
1468
+ function getLodTreeLevel({
1469
+ lodId,
1470
+ level
1471
+ }) {
1472
+ return get_lod_tree_level(lodId, level);
1473
+ }
1474
+ let nextChunkWaiter = (_chunk) => {
1475
+ };
1476
+ async function nextChunk({ chunk }) {
1477
+ nextChunkWaiter(chunk);
1478
+ }
1479
+ function getTransferable(ctx) {
1480
+ const buffers = [];
1481
+ const seen = /* @__PURE__ */ new Set();
1482
+ function traverse(obj) {
1483
+ if (obj && typeof obj === "object" && !seen.has(obj)) {
1484
+ seen.add(obj);
1485
+ if (obj instanceof ArrayBuffer) {
1486
+ buffers.push(obj);
1487
+ } else if (ArrayBuffer.isView(obj)) {
1488
+ buffers.push(obj.buffer);
1489
+ } else if (Array.isArray(obj)) {
1490
+ obj.forEach(traverse);
1491
+ } else {
1492
+ Object.values(obj).forEach(traverse);
1493
+ }
1494
+ }
1495
+ }
1496
+ traverse(ctx);
1497
+ return buffers;
1498
+ }
1499
+ async function initialize() {
1500
+ const pending = [];
1501
+ const bufferMessage = (event) => {
1502
+ pending.push(event);
1503
+ };
1504
+ self.addEventListener("message", bufferMessage);
1505
+ await __wbg_init();
1506
+ self.removeEventListener("message", bufferMessage);
1507
+ self.addEventListener("message", onMessage);
1508
+ for (const event of pending) {
1509
+ onMessage(event);
1510
+ }
1511
+ pending.length = 0;
1512
+ }
1513
+ initialize().catch(console.error);
1514
+ })();