@miris-inc/core 0.0.8-3ee2ddb → 0.0.8-48a7adc
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 +201 -0
- package/README.md +82 -0
- package/banner.svg +34 -0
- package/dist/AquaApi.js +15 -0
- package/dist/AquaApi.wasm +0 -0
- package/dist/aqua-parser.js +14 -0
- package/dist/aqua-parser.wasm +0 -0
- package/dist/core.d.ts +624 -0
- package/dist/core.js +2137 -0
- package/dist/core.prod.js +1 -0
- package/dist/core.standalone.js +5782 -0
- package/dist/core.standalone.prod.js +1 -0
- package/package.json +50 -7
- package/core.js +0 -6318
- package/icon-black.svg +0 -10
- package/icon-white.svg +0 -11
- package/social-card.png +0 -3
package/dist/core.js
ADDED
|
@@ -0,0 +1,2137 @@
|
|
|
1
|
+
//#region packages/core/lod.ts
|
|
2
|
+
var LodStore = class {
|
|
3
|
+
#keyMap = /* @__PURE__ */ new Map();
|
|
4
|
+
#idMap = /* @__PURE__ */ new Map();
|
|
5
|
+
forKey(key) {
|
|
6
|
+
return this.#keyMap.get(key);
|
|
7
|
+
}
|
|
8
|
+
forId(id) {
|
|
9
|
+
return this.#idMap.get(id);
|
|
10
|
+
}
|
|
11
|
+
setKey(key, lod) {
|
|
12
|
+
this.#keyMap.set(key, lod);
|
|
13
|
+
}
|
|
14
|
+
setId(id, lod) {
|
|
15
|
+
return this.#idMap.set(id, lod);
|
|
16
|
+
}
|
|
17
|
+
delete(lod) {
|
|
18
|
+
this.#keyMap.delete(lod.key);
|
|
19
|
+
this.#idMap.delete(lod.id);
|
|
20
|
+
}
|
|
21
|
+
deleteKey(key) {
|
|
22
|
+
this.#keyMap.delete(key);
|
|
23
|
+
}
|
|
24
|
+
deleteId(id) {
|
|
25
|
+
this.#idMap.delete(id);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var Lod = class {
|
|
29
|
+
#key;
|
|
30
|
+
useExtSplats = false;
|
|
31
|
+
#splats = null;
|
|
32
|
+
splatsExtendedData = null;
|
|
33
|
+
#cachedWorldBounds = null;
|
|
34
|
+
#localBounds = null;
|
|
35
|
+
#transform = null;
|
|
36
|
+
#lodIndex = null;
|
|
37
|
+
#paddingCount = 0;
|
|
38
|
+
sh1Data = null;
|
|
39
|
+
sh1Max = 1;
|
|
40
|
+
sh2Data = null;
|
|
41
|
+
sh2Max = 1;
|
|
42
|
+
sh3Data = null;
|
|
43
|
+
sh3Max = 1;
|
|
44
|
+
sh3ExtendedData = null;
|
|
45
|
+
get key() {
|
|
46
|
+
return this.#key ?? null;
|
|
47
|
+
}
|
|
48
|
+
set key(key) {
|
|
49
|
+
this.store.deleteKey(this.key);
|
|
50
|
+
if (key || 0 === key) this.store.setKey(key, this);
|
|
51
|
+
this.#key = key;
|
|
52
|
+
}
|
|
53
|
+
set splats(splats) {
|
|
54
|
+
this.#splats = splats;
|
|
55
|
+
}
|
|
56
|
+
get splats() {
|
|
57
|
+
return this.#splats;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sets the cached world bounds of this object
|
|
61
|
+
*
|
|
62
|
+
* @deprecated set the local bounds and transform as needed
|
|
63
|
+
*/
|
|
64
|
+
set bounds(bounds) {
|
|
65
|
+
this.#cachedWorldBounds = bounds;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves the cached world bounds of this object
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Retrieve the local bounds and transform as needed
|
|
71
|
+
*/
|
|
72
|
+
get bounds() {
|
|
73
|
+
console.warn("`bounds` is deprecated, use `localBounds` instead");
|
|
74
|
+
return this.#cachedWorldBounds;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Sets the local bounds of this lod
|
|
78
|
+
*/
|
|
79
|
+
set localBounds(bounds) {
|
|
80
|
+
this.#localBounds = bounds;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the local bounds of this lod
|
|
84
|
+
*/
|
|
85
|
+
get localBounds() {
|
|
86
|
+
return this.#localBounds;
|
|
87
|
+
}
|
|
88
|
+
set lodIndex(index) {
|
|
89
|
+
this.#lodIndex = index;
|
|
90
|
+
}
|
|
91
|
+
get lodIndex() {
|
|
92
|
+
return this.#lodIndex;
|
|
93
|
+
}
|
|
94
|
+
set paddingCount(count) {
|
|
95
|
+
this.#paddingCount = count;
|
|
96
|
+
}
|
|
97
|
+
get paddingCount() {
|
|
98
|
+
return this.#paddingCount;
|
|
99
|
+
}
|
|
100
|
+
set transform(transform) {
|
|
101
|
+
this.#transform = transform;
|
|
102
|
+
}
|
|
103
|
+
get transform() {
|
|
104
|
+
return this.#transform;
|
|
105
|
+
}
|
|
106
|
+
setSh1(sh1Data, sh1Max) {
|
|
107
|
+
this.sh1Data = sh1Data;
|
|
108
|
+
this.sh1Max = sh1Max;
|
|
109
|
+
}
|
|
110
|
+
setSh2(sh2Data, sh2Max) {
|
|
111
|
+
this.sh2Data = sh2Data;
|
|
112
|
+
this.sh2Max = sh2Max;
|
|
113
|
+
}
|
|
114
|
+
setSh3(sh3Data, sh3Max) {
|
|
115
|
+
this.sh3Data = sh3Data;
|
|
116
|
+
this.sh3Max = sh3Max;
|
|
117
|
+
}
|
|
118
|
+
dispose() {
|
|
119
|
+
const key = this.#key;
|
|
120
|
+
key?.dispose?.();
|
|
121
|
+
this.store.delete(this);
|
|
122
|
+
this.#key = null;
|
|
123
|
+
key?.dispose?.();
|
|
124
|
+
this.#splats = null;
|
|
125
|
+
this.splatsExtendedData = null;
|
|
126
|
+
this.#cachedWorldBounds = null;
|
|
127
|
+
this.#transform = null;
|
|
128
|
+
this.sh1Data = null;
|
|
129
|
+
this.sh2Data = null;
|
|
130
|
+
this.sh3Data = null;
|
|
131
|
+
this.sh3ExtendedData = null;
|
|
132
|
+
this.modelRoot?.lods?.delete(this);
|
|
133
|
+
}
|
|
134
|
+
constructor({ id, modelRoot, lodStore }) {
|
|
135
|
+
Object.defineProperties(this, {
|
|
136
|
+
id: { value: id },
|
|
137
|
+
modelRoot: { value: modelRoot },
|
|
138
|
+
store: { value: lodStore }
|
|
139
|
+
});
|
|
140
|
+
lodStore.setId(id, this);
|
|
141
|
+
modelRoot.add(this);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region packages/core/change.ts
|
|
146
|
+
var Change = class {
|
|
147
|
+
constructor({ type, lod }) {
|
|
148
|
+
Object.defineProperties(this, {
|
|
149
|
+
type: { value: type },
|
|
150
|
+
lod: { value: lod }
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region packages/core/modelRoot.ts
|
|
156
|
+
var ModelRoot = class ModelRoot {
|
|
157
|
+
static #keyMap = /* @__PURE__ */ new Map();
|
|
158
|
+
static #idMap = /* @__PURE__ */ new Map();
|
|
159
|
+
static forKey(key) {
|
|
160
|
+
return this.#keyMap.get(key);
|
|
161
|
+
}
|
|
162
|
+
static forId(id) {
|
|
163
|
+
return this.#idMap.get(id);
|
|
164
|
+
}
|
|
165
|
+
#key;
|
|
166
|
+
get key() {
|
|
167
|
+
return this.#key ?? null;
|
|
168
|
+
}
|
|
169
|
+
set key(key) {
|
|
170
|
+
ModelRoot.#keyMap.delete(this.key);
|
|
171
|
+
if (key || 0 === key) ModelRoot.#keyMap.set(key, this);
|
|
172
|
+
this.#key = key;
|
|
173
|
+
}
|
|
174
|
+
#lods = /* @__PURE__ */ new Set();
|
|
175
|
+
get lods() {
|
|
176
|
+
return this.#lods;
|
|
177
|
+
}
|
|
178
|
+
#transform;
|
|
179
|
+
set transform(transform) {
|
|
180
|
+
this.#transform = transform;
|
|
181
|
+
}
|
|
182
|
+
get transform() {
|
|
183
|
+
return this.#transform;
|
|
184
|
+
}
|
|
185
|
+
constructor({ id, stream }) {
|
|
186
|
+
Object.defineProperties(this, {
|
|
187
|
+
id: { value: id },
|
|
188
|
+
stream: { value: stream }
|
|
189
|
+
});
|
|
190
|
+
ModelRoot.#idMap.set(id, this);
|
|
191
|
+
stream.add(this);
|
|
192
|
+
}
|
|
193
|
+
add(lod) {
|
|
194
|
+
this.#lods.add(lod);
|
|
195
|
+
}
|
|
196
|
+
dispose() {
|
|
197
|
+
const lods = [...this.#lods];
|
|
198
|
+
this.#lods.clear();
|
|
199
|
+
for (const lod of lods) lod.dispose();
|
|
200
|
+
ModelRoot.#keyMap.delete(this.key);
|
|
201
|
+
ModelRoot.#idMap.delete(this.id);
|
|
202
|
+
this.#key = null;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region packages/core/attributeCache.ts
|
|
207
|
+
var AttributeCache = class {
|
|
208
|
+
static #cache = /* @__PURE__ */ new Map();
|
|
209
|
+
static #nextId = 1;
|
|
210
|
+
static #checkSum = 0;
|
|
211
|
+
static #checkSumModulo = 2 ** 32;
|
|
212
|
+
static #lastReportedCheckSumDifference = 0;
|
|
213
|
+
static #addCheckSum(id) {
|
|
214
|
+
this.#checkSum = (this.#checkSum + id) % this.#checkSumModulo;
|
|
215
|
+
}
|
|
216
|
+
static #removeCheckSum(id) {
|
|
217
|
+
this.#checkSum = (this.#checkSum - id) % this.#checkSumModulo;
|
|
218
|
+
if (this.#checkSum < 0) this.#checkSum += this.#checkSumModulo;
|
|
219
|
+
}
|
|
220
|
+
static getCheckSum() {
|
|
221
|
+
return this.#checkSum;
|
|
222
|
+
}
|
|
223
|
+
static getConsecutiveIds(howMany) {
|
|
224
|
+
const result = this.#nextId;
|
|
225
|
+
this.#nextId += howMany;
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
static addWithId(data, id) {
|
|
229
|
+
this.#addCheckSum(id);
|
|
230
|
+
this.#cache.set(id, data);
|
|
231
|
+
}
|
|
232
|
+
static add(data) {
|
|
233
|
+
const id = this.#nextId++;
|
|
234
|
+
this.addWithId(data, id);
|
|
235
|
+
return id;
|
|
236
|
+
}
|
|
237
|
+
static get(id) {
|
|
238
|
+
const data = this.#cache.get(id);
|
|
239
|
+
if (data === void 0) throw new Error(`Attribute with id ${id} not found in cache`);
|
|
240
|
+
return data;
|
|
241
|
+
}
|
|
242
|
+
static remove(idOrIds) {
|
|
243
|
+
if (Array.isArray(idOrIds)) for (const id of idOrIds) {
|
|
244
|
+
this.#cache.delete(id);
|
|
245
|
+
this.#removeCheckSum(id);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
this.#cache.delete(idOrIds);
|
|
249
|
+
this.#removeCheckSum(idOrIds);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
static validateCheckSum(checkSumWasm) {
|
|
253
|
+
if (checkSumWasm != this.getCheckSum()) {
|
|
254
|
+
let difference = checkSumWasm - this.getCheckSum();
|
|
255
|
+
if (difference < 0) difference += this.#checkSumModulo;
|
|
256
|
+
if (difference != this.#lastReportedCheckSumDifference) {
|
|
257
|
+
console.error(`ID checksum mismatch between WASM and TypeScript sides! ${checkSumWasm} ${this.getCheckSum()}`);
|
|
258
|
+
this.#lastReportedCheckSumDifference = difference;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region packages/core/stream.ts
|
|
265
|
+
var Stream = class Stream extends EventTarget {
|
|
266
|
+
static _idMap = /* @__PURE__ */ new Map();
|
|
267
|
+
static _keyMap = /* @__PURE__ */ new Map();
|
|
268
|
+
static forId(id) {
|
|
269
|
+
if (!id) return;
|
|
270
|
+
return this._idMap.get(id);
|
|
271
|
+
}
|
|
272
|
+
static forKey(key) {
|
|
273
|
+
return this._keyMap.get(key);
|
|
274
|
+
}
|
|
275
|
+
#key;
|
|
276
|
+
#loadedRenderableData = false;
|
|
277
|
+
#variantHierarchies = {};
|
|
278
|
+
/**
|
|
279
|
+
* @internal
|
|
280
|
+
*/
|
|
281
|
+
_addVariantCollection(hierarchyId) {
|
|
282
|
+
if (!this.#variantHierarchies[hierarchyId]) this.#variantHierarchies[hierarchyId] = {
|
|
283
|
+
id: hierarchyId,
|
|
284
|
+
children: []
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
_findAndAddToVariantSet(parentId, variant) {
|
|
291
|
+
const addToNode = (node) => {
|
|
292
|
+
if (!node) return false;
|
|
293
|
+
if (node.id === parentId) {
|
|
294
|
+
if (node.children) node.children.push(variant);
|
|
295
|
+
else if (variant.type === "option") {
|
|
296
|
+
if (!node.options) node.options = [];
|
|
297
|
+
node.options.push(variant);
|
|
298
|
+
} else {
|
|
299
|
+
if (!node.nestedSets) node.nestedSets = [];
|
|
300
|
+
node.nestedSets.push(variant);
|
|
301
|
+
}
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(node.children)) {
|
|
305
|
+
for (const child of node.children) if (addToNode(child)) return true;
|
|
306
|
+
}
|
|
307
|
+
if (Array.isArray(node.nestedSets)) {
|
|
308
|
+
for (const nested of node.nestedSets) if (addToNode(nested)) return true;
|
|
309
|
+
}
|
|
310
|
+
if (Array.isArray(node.options)) {
|
|
311
|
+
for (const option of node.options) if (addToNode(option)) return true;
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
};
|
|
315
|
+
for (const hierarchy of Object.values(this.#variantHierarchies)) if (addToNode(hierarchy)) return;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @internal
|
|
319
|
+
*/
|
|
320
|
+
_addVariant(parentId, variant) {
|
|
321
|
+
this._findAndAddToVariantSet(parentId, variant);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* @internal
|
|
325
|
+
*/
|
|
326
|
+
_exportVariantHierarchies() {
|
|
327
|
+
return Object.entries(this.#variantHierarchies).map(([hierarchyId, hierarchy]) => ({
|
|
328
|
+
hierarchyId: Number(hierarchyId),
|
|
329
|
+
hierarchy
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @internal
|
|
334
|
+
*/
|
|
335
|
+
_setVariantSelection(variantId) {
|
|
336
|
+
this.client.setVariantSelection(variantId);
|
|
337
|
+
}
|
|
338
|
+
get key() {
|
|
339
|
+
return this.#key ?? null;
|
|
340
|
+
}
|
|
341
|
+
set key(key) {
|
|
342
|
+
Stream._keyMap.delete(this.key);
|
|
343
|
+
if (key || 0 === key) Stream._keyMap.set(key, this);
|
|
344
|
+
this.#key = key;
|
|
345
|
+
}
|
|
346
|
+
#matrix = [
|
|
347
|
+
1,
|
|
348
|
+
0,
|
|
349
|
+
0,
|
|
350
|
+
0,
|
|
351
|
+
0,
|
|
352
|
+
1,
|
|
353
|
+
0,
|
|
354
|
+
0,
|
|
355
|
+
0,
|
|
356
|
+
0,
|
|
357
|
+
1,
|
|
358
|
+
0,
|
|
359
|
+
0,
|
|
360
|
+
0,
|
|
361
|
+
0,
|
|
362
|
+
1
|
|
363
|
+
];
|
|
364
|
+
get matrix() {
|
|
365
|
+
return this.#matrix;
|
|
366
|
+
}
|
|
367
|
+
set matrix(matrix) {
|
|
368
|
+
this.#matrix = matrix;
|
|
369
|
+
const { engine, client } = this;
|
|
370
|
+
const matrixBuffer = engine.malloc(this.#matrix.length * 4);
|
|
371
|
+
engine.heapF32.set(Float32Array.from(this.#matrix), matrixBuffer / 4);
|
|
372
|
+
client.setSceneObjectTransform(this.id, matrixBuffer);
|
|
373
|
+
engine.free(matrixBuffer);
|
|
374
|
+
}
|
|
375
|
+
get boundingBox() {
|
|
376
|
+
const { engine, client } = this;
|
|
377
|
+
const boxBuffer = engine.malloc(24);
|
|
378
|
+
client.getWorldBoundingBox(this.id, boxBuffer);
|
|
379
|
+
const [cX, cY, cZ, dX, dY, dZ] = Float32Array.from(engine.heapF32.subarray(boxBuffer / 4, boxBuffer / 4 + 6));
|
|
380
|
+
if (cX === void 0 || cY === void 0 || cZ === void 0 || dX === void 0 || dY === void 0 || dZ === void 0) return;
|
|
381
|
+
const box = {
|
|
382
|
+
min: {
|
|
383
|
+
x: cX - dX / 2,
|
|
384
|
+
y: cY - dY / 2,
|
|
385
|
+
z: cZ - dZ / 2
|
|
386
|
+
},
|
|
387
|
+
max: {
|
|
388
|
+
x: cX + dX / 2,
|
|
389
|
+
y: cY + dY / 2,
|
|
390
|
+
z: cZ + dZ / 2
|
|
391
|
+
},
|
|
392
|
+
size: {
|
|
393
|
+
x: dX,
|
|
394
|
+
y: dY,
|
|
395
|
+
z: dZ
|
|
396
|
+
},
|
|
397
|
+
center: {
|
|
398
|
+
x: cX,
|
|
399
|
+
y: cY,
|
|
400
|
+
z: cZ
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
Object.freeze(box);
|
|
404
|
+
return box;
|
|
405
|
+
}
|
|
406
|
+
#modelRoots = /* @__PURE__ */ new Set();
|
|
407
|
+
get modelRoots() {
|
|
408
|
+
return new Set(this.#modelRoots);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* @deprecated Use `modelRoots` instead.
|
|
412
|
+
*/
|
|
413
|
+
get chunks() {
|
|
414
|
+
return this.modelRoots;
|
|
415
|
+
}
|
|
416
|
+
constructor(options) {
|
|
417
|
+
super();
|
|
418
|
+
const { scene, uuid } = options;
|
|
419
|
+
Object.defineProperties(this, {
|
|
420
|
+
uuid: {
|
|
421
|
+
value: uuid,
|
|
422
|
+
enumerable: true
|
|
423
|
+
},
|
|
424
|
+
scene: {
|
|
425
|
+
value: scene,
|
|
426
|
+
enumerable: true
|
|
427
|
+
},
|
|
428
|
+
client: {
|
|
429
|
+
value: scene.client,
|
|
430
|
+
enumerable: true
|
|
431
|
+
},
|
|
432
|
+
miris: {
|
|
433
|
+
value: scene.miris,
|
|
434
|
+
enumerable: true
|
|
435
|
+
},
|
|
436
|
+
engine: {
|
|
437
|
+
value: scene.miris.engine,
|
|
438
|
+
enumerable: true
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
this._initStream(options);
|
|
442
|
+
Stream._idMap.set(this.id, this);
|
|
443
|
+
scene.add(this);
|
|
444
|
+
}
|
|
445
|
+
_initStream({ uuid }) {
|
|
446
|
+
const id = this.client.addStreamById(uuid, uuid, false);
|
|
447
|
+
Object.defineProperty(this, "id", { value: id });
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* @internal
|
|
451
|
+
*/
|
|
452
|
+
async _onStreamLoaded() {
|
|
453
|
+
if (this.#loadedRenderableData) return;
|
|
454
|
+
this.dispatchEvent(new Event("streamloaded"));
|
|
455
|
+
this.scene._onSceneLoaded();
|
|
456
|
+
this.#loadedRenderableData = true;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* @internal
|
|
460
|
+
*/
|
|
461
|
+
_onRootLoaded() {
|
|
462
|
+
this.dispatchEvent(new Event("rootloaded"));
|
|
463
|
+
}
|
|
464
|
+
add(modelRoot) {
|
|
465
|
+
this.#modelRoots.add(modelRoot);
|
|
466
|
+
}
|
|
467
|
+
end() {
|
|
468
|
+
console.log("ending the stream");
|
|
469
|
+
this.client.removeStream(this.id);
|
|
470
|
+
for (const modelRoot of this.#modelRoots) modelRoot.dispose();
|
|
471
|
+
this.#modelRoots.clear();
|
|
472
|
+
Stream._idMap.delete(this.id);
|
|
473
|
+
Stream._keyMap.delete(this.key);
|
|
474
|
+
if (this.scene.streams.has(this)) this.scene.delete(this);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region \0emscripten-lazy:AquaApi
|
|
479
|
+
var _jsPromise;
|
|
480
|
+
var _wasmPromise;
|
|
481
|
+
var _wasmUrl = ((u) => u.includes("/.vite/") ? u.replace(/\.vite\/[^?#]*/, () => "node_modules/@miris-inc/core/dist/AquaApi.wasm") : u)(new URL("AquaApi.wasm", import.meta.url).href);
|
|
482
|
+
function _getExport(m) {
|
|
483
|
+
return m.default || m;
|
|
484
|
+
}
|
|
485
|
+
function _loadModule(url) {
|
|
486
|
+
return import(/* @vite-ignore */ /* webpackIgnore: true */ /* turbopackIgnore: true */ url).then((m) => {
|
|
487
|
+
const f = _getExport(m);
|
|
488
|
+
if (typeof f === "function") return f;
|
|
489
|
+
throw new Error("bad module");
|
|
490
|
+
}).catch(() => fetch(url).then((r) => {
|
|
491
|
+
if (!r.ok) throw new Error(r.status + " " + url);
|
|
492
|
+
return r.text();
|
|
493
|
+
}).then((text) => {
|
|
494
|
+
const blobUrl = URL.createObjectURL(new Blob([text], { type: "text/javascript" }));
|
|
495
|
+
return import(/* @vite-ignore */ /* webpackIgnore: true */ /* turbopackIgnore: true */ blobUrl).then((m) => {
|
|
496
|
+
URL.revokeObjectURL(blobUrl);
|
|
497
|
+
return _getExport(m);
|
|
498
|
+
});
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
function _emscripten_lazy_AquaApi_default(...args) {
|
|
502
|
+
if (!_jsPromise) {
|
|
503
|
+
_wasmPromise = fetch(_wasmUrl).then((r) => {
|
|
504
|
+
if (!r.ok || (r.headers.get("content-type") || "").includes("text/html")) return null;
|
|
505
|
+
return r.arrayBuffer();
|
|
506
|
+
}).catch(() => null);
|
|
507
|
+
_jsPromise = _loadModule(((u) => u.includes("/.vite/") ? new URL("/node_modules/@miris-inc/core/dist/AquaApi.js", u).href : u)(new URL("./AquaApi.js", "" + import.meta.url).href)).catch((e) => {
|
|
508
|
+
_jsPromise = _wasmPromise = void 0;
|
|
509
|
+
throw e;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
return Promise.all([_jsPromise, _wasmPromise]).then(([factory, wasmBinary]) => {
|
|
513
|
+
if (wasmBinary) {
|
|
514
|
+
const [opts = {}, ...rest] = args;
|
|
515
|
+
return factory({
|
|
516
|
+
...opts,
|
|
517
|
+
wasmBinary
|
|
518
|
+
}, ...rest);
|
|
519
|
+
}
|
|
520
|
+
return factory(...args);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region packages/core/engine/factory.ts
|
|
525
|
+
var factory_default = _emscripten_lazy_AquaApi_default;
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region packages/core/engine/threads/thread.ts
|
|
528
|
+
var Thread = class Thread {
|
|
529
|
+
static name = "thread";
|
|
530
|
+
static get Worker() {
|
|
531
|
+
throw new Error("Thread could not be initialized because no Worker was supplied. Do you forget to set `static Worker = Worker` on the child class?");
|
|
532
|
+
}
|
|
533
|
+
constructor({ engine }) {
|
|
534
|
+
Object.defineProperty(this, "engine", {
|
|
535
|
+
value: engine,
|
|
536
|
+
enumerable: true
|
|
537
|
+
});
|
|
538
|
+
Object.defineProperty(this, "ready", {
|
|
539
|
+
enumerable: true,
|
|
540
|
+
value: new Promise((resolve) => {
|
|
541
|
+
this.#resolvers.set(0, async () => {
|
|
542
|
+
this.#pending = false;
|
|
543
|
+
this.#resolvers.delete(0);
|
|
544
|
+
resolve(this);
|
|
545
|
+
});
|
|
546
|
+
})
|
|
547
|
+
});
|
|
548
|
+
this.#worker = new this.constructor.Worker({ name: `decoder-${Thread.#nextWorkerId()}` });
|
|
549
|
+
this.#worker.addEventListener("message", this.#message.bind(this));
|
|
550
|
+
}
|
|
551
|
+
static #latestWorkerId = 0;
|
|
552
|
+
static #nextWorkerId() {
|
|
553
|
+
return this.#latestWorkerId += 1;
|
|
554
|
+
}
|
|
555
|
+
#pending = true;
|
|
556
|
+
get pending() {
|
|
557
|
+
return this.#pending;
|
|
558
|
+
}
|
|
559
|
+
#worker;
|
|
560
|
+
#resolvers = /* @__PURE__ */ new Map();
|
|
561
|
+
get pendingRequests() {
|
|
562
|
+
return this.#resolvers.size;
|
|
563
|
+
}
|
|
564
|
+
get terminated() {
|
|
565
|
+
return !this.#worker;
|
|
566
|
+
}
|
|
567
|
+
#latestProcessId = 0;
|
|
568
|
+
#nextProcessId() {
|
|
569
|
+
return this.#latestProcessId += 1;
|
|
570
|
+
}
|
|
571
|
+
async _execute(action, ...args) {
|
|
572
|
+
if (this.pending) throw new Error(`Unable to execute ${action} because decoder has not yet been initialized`);
|
|
573
|
+
if (!this.#worker) throw new Error(`Unable to execute ${action} because decoder has already been terminated`);
|
|
574
|
+
return new Promise((resolve) => {
|
|
575
|
+
if (!this.#worker) throw new Error(`Unable to execute ${action} because decoder has already been terminated`);
|
|
576
|
+
const id = this.#nextProcessId();
|
|
577
|
+
this.#resolvers.set(id, async (result) => {
|
|
578
|
+
this.#resolvers.delete(id);
|
|
579
|
+
resolve(result);
|
|
580
|
+
});
|
|
581
|
+
const transfer = args.filter((arg) => arg instanceof ArrayBuffer);
|
|
582
|
+
this.#worker.postMessage({
|
|
583
|
+
id,
|
|
584
|
+
action,
|
|
585
|
+
args
|
|
586
|
+
}, transfer);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
#message({ data }) {
|
|
590
|
+
if ("ready" === data) data = {
|
|
591
|
+
id: 0,
|
|
592
|
+
result: void 0
|
|
593
|
+
};
|
|
594
|
+
const { id, result } = data;
|
|
595
|
+
this.#resolvers.get(id)?.(result);
|
|
596
|
+
}
|
|
597
|
+
_postToWorker(data, transfer) {
|
|
598
|
+
this.#worker?.postMessage(data, transfer ?? []);
|
|
599
|
+
}
|
|
600
|
+
terminate() {
|
|
601
|
+
if (!this.#worker) return;
|
|
602
|
+
this.#worker.terminate();
|
|
603
|
+
this.#worker.removeEventListener("message", this.#message);
|
|
604
|
+
this.#worker = null;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region packages/core/engine/threads/decoder/worker.ts?worker&inline
|
|
609
|
+
var jsContent = "//#region packages/core/engine/threads/utils.ts\nconst defineActions = (actions) => {\n self.postMessage(\"ready\");\n self.addEventListener(\"message\", async ({ data }) => {\n if (\"ready\" === data) return;\n const { id, action, args } = data;\n const [result, ...postMessageArgs] = await Reflect.apply(actions[action], void 0, [...args, id]);\n self.postMessage({\n id,\n result\n }, ...postMessageArgs);\n });\n return actions;\n};\n//#endregion\n//#region packages/core/attribute.ts\nconst sparkMinSplats = 2048;\nconst sparkAttributeList = {\n sparkPackedSplat: {\n elementsPerSplat: 4,\n discard: false\n },\n extendedPackedSplatLow: {\n elementsPerSplat: 4,\n discard: false\n },\n extendedPackedSplatHigh: {\n elementsPerSplat: 4,\n discard: false\n },\n packedSh1: {\n elementsPerSplat: 2,\n discard: false\n },\n packedSh2: {\n elementsPerSplat: 4,\n discard: false\n },\n packedSh3: {\n elementsPerSplat: 4,\n discard: false\n },\n sh1Extended: {\n elementsPerSplat: 4,\n discard: false\n },\n sh2Extended: {\n elementsPerSplat: 4,\n discard: false\n },\n sh3Extended_0: {\n elementsPerSplat: 4,\n discard: false\n },\n sh3Extended_1: {\n elementsPerSplat: 4,\n discard: false\n },\n splatterEllipsoids: {\n elementsPerSplat: 12,\n discard: false\n },\n splatterSphericalHarmonics: {\n elementsPerSplat: 16,\n discard: false\n }\n};\nfunction roundUpToMultipleOf(a, multiple) {\n return Math.ceil(a / multiple) * multiple;\n}\nfunction sparkAttributeFromRaw(name, id, wasmView) {\n const attrib = sparkAttributeList[name];\n if (attrib === void 0) throw new Error(\"attribute name\" + name + \" is unknown\");\n const originalSize = wasmView.length;\n const paddedSize = roundUpToMultipleOf(originalSize, attrib.elementsPerSplat * sparkMinSplats);\n const paddedData = new Uint32Array(paddedSize);\n paddedData.set(wasmView);\n return {\n paddedData,\n originalSize,\n id\n };\n}\n//#endregion\n//#region packages/core/aqua-parser.js\nasync function Li(Le = {}) {\n var $r, l = Le, ze = !1, Br = !0, Lr = \"./this.program\", zr = (e, r) => {\n throw r;\n }, Ne = import.meta.url, wr = \"\";\n function Ge(e) {\n return l.locateFile ? l.locateFile(e, wr) : wr + e;\n }\n var Yr, Tr;\n if (ze || Br) {\n try {\n wr = new URL(\".\", Ne).href;\n } catch {}\n Br && (Tr = (e) => {\n var r = new XMLHttpRequest();\n return r.open(\"GET\", e, !1), r.responseType = \"arraybuffer\", r.send(null), new Uint8Array(r.response);\n }), Yr = async (e) => {\n var r = await fetch(e, { credentials: \"same-origin\" });\n if (r.ok) return r.arrayBuffer();\n throw new Error(r.status + \" : \" + r.url);\n };\n }\n var Nr = console.log.bind(console), B = console.error.bind(console), G, Q = !1, rr, Gr, qr, er, k, A, U, L, T, w, tr, nr, V, Xr, Jr = !1;\n function Kr() {\n var e = er.buffer;\n l.HEAP8 = k = new Int8Array(e), U = new Int16Array(e), l.HEAPU8 = A = new Uint8Array(e), L = new Uint16Array(e), l.HEAP32 = T = new Int32Array(e), l.HEAPU32 = w = new Uint32Array(e), l.HEAPF32 = tr = new Float32Array(e), l.HEAPF64 = nr = new Float64Array(e), V = new BigInt64Array(e), Xr = new BigUint64Array(e);\n }\n function qe() {\n if (l.preRun) for (typeof l.preRun == \"function\" && (l.preRun = [l.preRun]); l.preRun.length;) at(l.preRun.shift());\n Qr(ee);\n }\n function Xe() {\n Jr = !0, H.__wasm_call_ctors();\n }\n function Je() {\n if (l.postRun) for (typeof l.postRun == \"function\" && (l.postRun = [l.postRun]); l.postRun.length;) it(l.postRun.shift());\n Qr(re);\n }\n function z(e) {\n l.onAbort?.(e), e = \"Aborted(\" + e + \")\", B(e), Q = !0, e += \". Build with -sASSERTIONS for more info.\";\n var r = new WebAssembly.RuntimeError(e);\n throw qr?.(r), r;\n }\n var Fr;\n function Ke() {\n return l.locateFile ? Ge(\"aqua-parser.wasm\") : \"\";\n }\n function Ze(e) {\n if (e == Fr && G) return new Uint8Array(G);\n if (Tr) return Tr(e);\n throw \"both async and sync fetching of the wasm failed\";\n }\n async function Qe(e) {\n if (!G) try {\n var r = await Yr(e);\n return new Uint8Array(r);\n } catch {}\n return Ze(e);\n }\n async function rt(e, r) {\n try {\n var t = await Qe(e);\n return await WebAssembly.instantiate(t, r);\n } catch (i) {\n B(`failed to asynchronously prepare wasm: ${i}`), z(i);\n }\n }\n async function et(e, r, t) {\n if (!e) try {\n var n = fetch(r, { credentials: \"same-origin\" });\n return await WebAssembly.instantiateStreaming(n, t);\n } catch (a) {\n B(`wasm streaming compile failed: ${a}`), B(\"falling back to ArrayBuffer instantiation\");\n }\n return rt(r, t);\n }\n function tt() {\n return {\n env: Ie,\n wasi_snapshot_preview1: Ie\n };\n }\n async function nt() {\n function e(a, s) {\n return H = a.exports, er = H.memory, Kr(), fe = H.__indirect_function_table, si(H), H;\n }\n function r(a) {\n return e(a.instance);\n }\n var t = tt();\n if (l.instantiateWasm) return new Promise((a, s) => {\n l.instantiateWasm(t, (o, u) => {\n a(e(o, u));\n });\n });\n Fr ??= Ke();\n return r(await et(G, Fr, t));\n }\n class Zr {\n name = \"ExitStatus\";\n constructor(r) {\n this.message = `Program terminated with exit(${r})`, this.status = r;\n }\n }\n var Qr = (e) => {\n for (; e.length > 0;) e.shift()(l);\n }, re = [], it = (e) => re.push(e), ee = [], at = (e) => ee.push(e);\n var Cr = !0;\n var y = (e) => De(e), m = () => xe(), ir = [], ar = 0, st = (e) => {\n var r = new Pr(e);\n return r.get_caught() || (r.set_caught(!0), ar--), r.set_rethrown(!1), ir.push(r), Ue(e), je(e);\n }, x = 0, ot = () => {\n g(0, 0);\n var e = ir.pop();\n Oe(e.excPtr), x = 0;\n };\n class Pr {\n constructor(r) {\n this.excPtr = r, this.ptr = r - 24;\n }\n set_type(r) {\n w[this.ptr + 4 >> 2] = r;\n }\n get_type() {\n return w[this.ptr + 4 >> 2];\n }\n set_destructor(r) {\n w[this.ptr + 8 >> 2] = r;\n }\n get_destructor() {\n return w[this.ptr + 8 >> 2];\n }\n set_caught(r) {\n r = r ? 1 : 0, k[this.ptr + 12] = r;\n }\n get_caught() {\n return k[this.ptr + 12] != 0;\n }\n set_rethrown(r) {\n r = r ? 1 : 0, k[this.ptr + 13] = r;\n }\n get_rethrown() {\n return k[this.ptr + 13] != 0;\n }\n init(r, t) {\n this.set_adjusted_ptr(0), this.set_type(r), this.set_destructor(t);\n }\n set_adjusted_ptr(r) {\n w[this.ptr + 16 >> 2] = r;\n }\n get_adjusted_ptr() {\n return w[this.ptr + 16 >> 2];\n }\n }\n var sr = (e) => Re(e), kr = (e) => {\n var r = x;\n if (!r) return sr(0), 0;\n var t = new Pr(r);\n t.set_adjusted_ptr(r);\n var n = t.get_type();\n if (!n) return sr(0), r;\n for (var i of e) {\n if (i === 0 || i === n) break;\n var a = t.ptr + 16;\n if (Ve(i, n, a)) return sr(i), r;\n }\n return sr(n), r;\n }, ut = () => kr([]), ct = (e) => kr([e]), ft = (e, r) => kr([e, r]), lt = () => {\n var e = ir.pop();\n e || z(\"no exception to throw\");\n var r = e.excPtr;\n throw e.get_rethrown() || (ir.push(e), e.set_rethrown(!0), e.set_caught(!1), ar++), x = r, x;\n }, vt = (e, r, t) => {\n throw new Pr(e).init(r, t), x = e, ar++, x;\n }, _t = () => ar, dt = (e) => {\n throw x || (x = e), x;\n }, pt = () => z(\"\"), C = (e) => {\n for (var r = \"\";;) {\n var t = A[e++];\n if (!t) return r;\n r += String.fromCharCode(t);\n }\n }, Y = {}, j = {}, or = {}, q = class extends Error {\n constructor(r) {\n super(r), this.name = \"BindingError\";\n }\n }, h = (e) => {\n throw new q(e);\n };\n function ht(e, r, t = {}) {\n var n = r.name;\n if (e || h(`type \"${n}\" must have a positive integer typeid pointer`), j.hasOwnProperty(e)) {\n if (t.ignoreDuplicateRegistrations) return;\n h(`Cannot register type '${n}' twice`);\n }\n if (j[e] = r, delete or[e], Y.hasOwnProperty(e)) {\n var i = Y[e];\n delete Y[e], i.forEach((a) => a());\n }\n }\n function E(e, r, t = {}) {\n return ht(e, r, t);\n }\n var te = (e, r, t) => {\n switch (r) {\n case 1: return t ? (n) => k[n] : (n) => A[n];\n case 2: return t ? (n) => U[n >> 1] : (n) => L[n >> 1];\n case 4: return t ? (n) => T[n >> 2] : (n) => w[n >> 2];\n case 8: return t ? (n) => V[n >> 3] : (n) => Xr[n >> 3];\n default: throw new TypeError(`invalid integer width (${r}): ${e}`);\n }\n }, gt = (e, r, t, n, i) => {\n r = C(r);\n const a = n === 0n;\n let s = (o) => o;\n if (a) {\n const o = t * 8;\n s = (u) => BigInt.asUintN(o, u), i = s(i);\n }\n E(e, {\n name: r,\n fromWireType: s,\n toWireType: (o, u) => (typeof u == \"number\" && (u = BigInt(u)), u),\n readValueFromPointer: te(r, t, !a),\n destructorFunction: null\n });\n }, yt = (e, r, t, n) => {\n r = C(r), E(e, {\n name: r,\n fromWireType: function(i) {\n return !!i;\n },\n toWireType: function(i, a) {\n return a ? t : n;\n },\n readValueFromPointer: function(i) {\n return this.fromWireType(A[i]);\n },\n destructorFunction: null\n });\n }, mt = (e) => ({\n count: e.count,\n deleteScheduled: e.deleteScheduled,\n preservePointerOnDelete: e.preservePointerOnDelete,\n ptr: e.ptr,\n ptrType: e.ptrType,\n smartPtr: e.smartPtr,\n smartPtrType: e.smartPtrType\n }), Sr = (e) => {\n function r(t) {\n return t.$$.ptrType.registeredClass.name;\n }\n h(r(e) + \" instance already deleted\");\n }, Ar = !1, ne = (e) => {}, bt = (e) => {\n e.smartPtr ? e.smartPtrType.rawDestructor(e.smartPtr) : e.ptrType.registeredClass.rawDestructor(e.ptr);\n }, ie = (e) => {\n e.count.value -= 1;\n e.count.value === 0 && bt(e);\n }, X = (e) => typeof FinalizationRegistry > \"u\" ? (X = (r) => r, e) : (Ar = new FinalizationRegistry((r) => {\n ie(r.$$);\n }), X = (r) => {\n var t = r.$$;\n if (!!t.smartPtr) {\n var i = { $$: t };\n Ar.register(r, i, r);\n }\n return r;\n }, ne = (r) => Ar.unregister(r), X(e)), ur = [], $t = () => {\n for (; ur.length;) {\n var e = ur.pop();\n e.$$.deleteScheduled = !1, e.delete();\n }\n }, ae, wt = () => {\n let e = cr.prototype;\n Object.assign(e, {\n isAliasOf(t) {\n if (!(this instanceof cr) || !(t instanceof cr)) return !1;\n var n = this.$$.ptrType.registeredClass, i = this.$$.ptr;\n t.$$ = t.$$;\n for (var a = t.$$.ptrType.registeredClass, s = t.$$.ptr; n.baseClass;) i = n.upcast(i), n = n.baseClass;\n for (; a.baseClass;) s = a.upcast(s), a = a.baseClass;\n return n === a && i === s;\n },\n clone() {\n if (this.$$.ptr || Sr(this), this.$$.preservePointerOnDelete) return this.$$.count.value += 1, this;\n var t = X(Object.create(Object.getPrototypeOf(this), { $$: { value: mt(this.$$) } }));\n return t.$$.count.value += 1, t.$$.deleteScheduled = !1, t;\n },\n delete() {\n this.$$.ptr || Sr(this), this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && h(\"Object already scheduled for deletion\"), ne(this), ie(this.$$), this.$$.preservePointerOnDelete || (this.$$.smartPtr = void 0, this.$$.ptr = void 0);\n },\n isDeleted() {\n return !this.$$.ptr;\n },\n deleteLater() {\n return this.$$.ptr || Sr(this), this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && h(\"Object already scheduled for deletion\"), ur.push(this), ur.length === 1 && ae && ae($t), this.$$.deleteScheduled = !0, this;\n }\n });\n const r = Symbol.dispose;\n r && (e[r] = e.delete);\n };\n function cr() {}\n var fr = (e, r) => Object.defineProperty(r, \"name\", { value: e }), se = {}, Er = (e, r, t) => {\n if (e[r].overloadTable === void 0) {\n var n = e[r];\n e[r] = function(...i) {\n return e[r].overloadTable.hasOwnProperty(i.length) || h(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`), e[r].overloadTable[i.length].apply(this, i);\n }, e[r].overloadTable = [], e[r].overloadTable[n.argCount] = n;\n }\n }, Rr = (e, r, t) => {\n l.hasOwnProperty(e) ? ((t === void 0 || l[e].overloadTable !== void 0 && l[e].overloadTable[t] !== void 0) && h(`Cannot register public name '${e}' twice`), Er(l, e, e), l[e].overloadTable.hasOwnProperty(t) && h(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`), l[e].overloadTable[t] = r) : (l[e] = r, l[e].argCount = t);\n }, Tt = 48, Ft = 57, Ct = (e) => {\n e = e.replace(/[^a-zA-Z0-9_]/g, \"$\");\n var r = e.charCodeAt(0);\n return r >= Tt && r <= Ft ? `_${e}` : e;\n };\n function Pt(e, r, t, n, i, a, s, o) {\n this.name = e, this.constructor = r, this.instancePrototype = t, this.rawDestructor = n, this.baseClass = i, this.getActualType = a, this.upcast = s, this.downcast = o, this.pureVirtualFunctions = [];\n }\n var lr = (e, r, t) => {\n for (; r !== t;) r.upcast || h(`Expected null or instance of ${t.name}, got an instance of ${r.name}`), e = r.upcast(e), r = r.baseClass;\n return e;\n }, Dr = (e) => {\n if (e === null) return \"null\";\n var r = typeof e;\n return r === \"object\" || r === \"array\" || r === \"function\" ? e.toString() : \"\" + e;\n };\n function kt(e, r) {\n if (r === null) return this.isReference && h(`null is not a valid ${this.name}`), 0;\n r.$$ || h(`Cannot pass \"${Dr(r)}\" as a ${this.name}`), r.$$.ptr || h(`Cannot pass deleted object as a pointer of type ${this.name}`);\n var t = r.$$.ptrType.registeredClass;\n return lr(r.$$.ptr, t, this.registeredClass);\n }\n function St(e, r) {\n var t;\n if (r === null) return this.isReference && h(`null is not a valid ${this.name}`), this.isSmartPointer ? (t = this.rawConstructor(), e !== null && e.push(this.rawDestructor, t), t) : 0;\n (!r || !r.$$) && h(`Cannot pass \"${Dr(r)}\" as a ${this.name}`), r.$$.ptr || h(`Cannot pass deleted object as a pointer of type ${this.name}`), !this.isConst && r.$$.ptrType.isConst && h(`Cannot convert argument of type ${r.$$.smartPtrType ? r.$$.smartPtrType.name : r.$$.ptrType.name} to parameter type ${this.name}`);\n var n = r.$$.ptrType.registeredClass;\n if (t = lr(r.$$.ptr, n, this.registeredClass), this.isSmartPointer) switch (r.$$.smartPtr === void 0 && h(\"Passing raw pointer to smart pointer is illegal\"), this.sharingPolicy) {\n case 0:\n r.$$.smartPtrType === this ? t = r.$$.smartPtr : h(`Cannot convert argument of type ${r.$$.smartPtrType ? r.$$.smartPtrType.name : r.$$.ptrType.name} to parameter type ${this.name}`);\n break;\n case 1:\n t = r.$$.smartPtr;\n break;\n case 2:\n if (r.$$.smartPtrType === this) t = r.$$.smartPtr;\n else {\n var i = r.clone();\n t = this.rawShare(t, W.toHandle(() => i.delete())), e !== null && e.push(this.rawDestructor, t);\n }\n break;\n default: h(\"Unsupporting sharing policy\");\n }\n return t;\n }\n function At(e, r) {\n if (r === null) return this.isReference && h(`null is not a valid ${this.name}`), 0;\n r.$$ || h(`Cannot pass \"${Dr(r)}\" as a ${this.name}`), r.$$.ptr || h(`Cannot pass deleted object as a pointer of type ${this.name}`), r.$$.ptrType.isConst && h(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);\n var t = r.$$.ptrType.registeredClass;\n return lr(r.$$.ptr, t, this.registeredClass);\n }\n function vr(e) {\n return this.fromWireType(w[e >> 2]);\n }\n var oe = (e, r, t) => {\n if (r === t) return e;\n if (t.baseClass === void 0) return null;\n var n = oe(e, r, t.baseClass);\n return n === null ? null : t.downcast(n);\n }, Et = {}, Rt = (e, r) => {\n for (r === void 0 && h(\"ptr should not be undefined\"); e.baseClass;) r = e.upcast(r), e = e.baseClass;\n return r;\n }, Dt = (e, r) => (r = Rt(e, r), Et[r]), Wt = class extends Error {\n constructor(r) {\n super(r), this.name = \"InternalError\";\n }\n }, _r = (e) => {\n throw new Wt(e);\n }, dr = (e, r) => {\n (!r.ptrType || !r.ptr) && _r(\"makeClassHandle requires ptr and ptrType\");\n return !!r.smartPtrType !== !!r.smartPtr && _r(\"Both smartPtrType and smartPtr must be specified\"), r.count = { value: 1 }, X(Object.create(e, { $$: {\n value: r,\n writable: !0\n } }));\n };\n function xt(e) {\n var r = this.getPointee(e);\n if (!r) return this.destructor(e), null;\n var t = Dt(this.registeredClass, r);\n if (t !== void 0) {\n if (t.$$.count.value === 0) return t.$$.ptr = r, t.$$.smartPtr = e, t.clone();\n var n = t.clone();\n return this.destructor(e), n;\n }\n function i() {\n return this.isSmartPointer ? dr(this.registeredClass.instancePrototype, {\n ptrType: this.pointeeType,\n ptr: r,\n smartPtrType: this,\n smartPtr: e\n }) : dr(this.registeredClass.instancePrototype, {\n ptrType: this,\n ptr: e\n });\n }\n var s = se[this.registeredClass.getActualType(r)];\n if (!s) return i.call(this);\n var o;\n this.isConst ? o = s.constPointerType : o = s.pointerType;\n var u = oe(r, this.registeredClass, o.registeredClass);\n return u === null ? i.call(this) : this.isSmartPointer ? dr(o.registeredClass.instancePrototype, {\n ptrType: o,\n ptr: u,\n smartPtrType: this,\n smartPtr: e\n }) : dr(o.registeredClass.instancePrototype, {\n ptrType: o,\n ptr: u\n });\n }\n var Ot = () => {\n Object.assign(pr.prototype, {\n getPointee(e) {\n return this.rawGetPointee && (e = this.rawGetPointee(e)), e;\n },\n destructor(e) {\n this.rawDestructor?.(e);\n },\n readValueFromPointer: vr,\n fromWireType: xt\n });\n };\n function pr(e, r, t, n, i, a, s, o, u, c, f) {\n this.name = e, this.registeredClass = r, this.isReference = t, this.isConst = n, this.isSmartPointer = i, this.pointeeType = a, this.sharingPolicy = s, this.rawGetPointee = o, this.rawConstructor = u, this.rawShare = c, this.rawDestructor = f, !i && r.baseClass === void 0 ? n ? (this.toWireType = kt, this.destructorFunction = null) : (this.toWireType = At, this.destructorFunction = null) : this.toWireType = St;\n }\n var ue = (e, r, t) => {\n l.hasOwnProperty(e) || _r(\"Replacing nonexistent public symbol\"), l[e].overloadTable !== void 0 && t !== void 0 ? l[e].overloadTable[t] = r : (l[e] = r, l[e].argCount = t);\n }, ce = [], fe, b = (e) => {\n var r = ce[e];\n return r || (ce[e] = r = fe.get(e)), r;\n }, R = (e, r, t = !1) => {\n e = C(e);\n function n() {\n return b(r);\n }\n var i = n();\n return typeof i != \"function\" && h(`unknown function pointer with signature ${e}: ${r}`), i;\n };\n class Ut extends Error {}\n var le = (e) => {\n var r = Ae(e), t = C(r);\n return O(r), t;\n }, I = (e, r) => {\n var t = [], n = {};\n function i(a) {\n if (!n[a] && !j[a]) {\n if (or[a]) {\n or[a].forEach(i);\n return;\n }\n t.push(a), n[a] = !0;\n }\n }\n throw r.forEach(i), new Ut(`${e}: ` + t.map(le).join([\", \"]));\n }, D = (e, r, t) => {\n e.forEach((o) => or[o] = r);\n function n(o) {\n var u = t(o);\n u.length !== e.length && _r(\"Mismatched type converter count\");\n for (var c = 0; c < e.length; ++c) E(e[c], u[c]);\n }\n var i = new Array(r.length), a = [], s = 0;\n r.forEach((o, u) => {\n j.hasOwnProperty(o) ? i[u] = j[o] : (a.push(o), Y.hasOwnProperty(o) || (Y[o] = []), Y[o].push(() => {\n i[u] = j[o], ++s, s === a.length && n(i);\n }));\n }), a.length === 0 && n(i);\n }, Vt = (e, r, t, n, i, a, s, o, u, c, f, _, d) => {\n f = C(f), a = R(i, a), o &&= R(s, o), c &&= R(u, c), d = R(_, d);\n var p = Ct(f);\n Rr(p, function() {\n I(`Cannot construct ${f} due to unbound types`, [n]);\n }), D([\n e,\n r,\n t\n ], n ? [n] : [], (v) => {\n v = v[0];\n var $, P;\n n ? ($ = v.registeredClass, P = $.instancePrototype) : P = cr.prototype;\n var F = fr(f, function(...Hr) {\n if (Object.getPrototypeOf(this) !== Z) throw new q(`Use 'new' to construct ${f}`);\n if (S.constructor_body === void 0) throw new q(`${f} has no accessible constructor`);\n var Be = S.constructor_body[Hr.length];\n if (Be === void 0) throw new q(`Tried to invoke ctor of ${f} with invalid number of parameters (${Hr.length}) - expected (${Object.keys(S.constructor_body).toString()}) parameters instead!`);\n return Be.apply(this, Hr);\n }), Z = Object.create(P, { constructor: { value: F } });\n F.prototype = Z;\n var S = new Pt(f, F, Z, d, $, a, o, c);\n S.baseClass && (S.baseClass.__derivedClasses ??= [], S.baseClass.__derivedClasses.push(S));\n var Bi = new pr(f, S, !0, !1, !1), Me = new pr(f + \"*\", S, !1, !1, !1), He = new pr(f + \" const*\", S, !1, !0, !1);\n return se[e] = {\n pointerType: Me,\n constPointerType: He\n }, ue(p, F), [\n Bi,\n Me,\n He\n ];\n });\n }, Wr = (e) => {\n for (; e.length;) {\n var r = e.pop();\n e.pop()(r);\n }\n };\n function ve(e) {\n for (var r = 1; r < e.length; ++r) if (e[r] !== null && e[r].destructorFunction === void 0) return !0;\n return !1;\n }\n function jt(e, r, t, n) {\n var i = ve(e), a = e.length - 2, s = [], o = [\"fn\"];\n r && o.push(\"thisWired\");\n for (var u = 0; u < a; ++u) s.push(`arg${u}`), o.push(`arg${u}Wired`);\n s = s.join(\",\"), o = o.join(\",\");\n var c = `return function (${s}) {\n`;\n i && (c += `var destructors = [];\n`);\n var f = i ? \"destructors\" : \"null\", _ = [\n \"humanName\",\n \"throwBindingError\",\n \"invoker\",\n \"fn\",\n \"runDestructors\",\n \"fromRetWire\",\n \"toClassParamWire\"\n ];\n r && (c += `var thisWired = toClassParamWire(${f}, this);\n`);\n for (var u = 0; u < a; ++u) {\n var d = `toArg${u}Wire`;\n c += `var arg${u}Wired = ${d}(${f}, arg${u});\n`, _.push(d);\n }\n c += (t || n ? \"var rv = \" : \"\") + `invoker(${o});\n`;\n if (i) c += `runDestructors(destructors);\n`;\n else for (var u = r ? 1 : 2; u < e.length; ++u) {\n var v = u === 1 ? \"thisWired\" : \"arg\" + (u - 2) + \"Wired\";\n e[u].destructorFunction !== null && (c += `${v}_dtor(${v});\n`, _.push(`${v}_dtor`));\n }\n return t && (c += `var ret = fromRetWire(rv);\nreturn ret;\n`), c += `}\n`, new Function(_, c);\n }\n function hr(e, r, t, n, i, a) {\n var s = r.length;\n s < 2 && h(\"argTypes array size mismatch! Must at least get return value and 'this' types!\");\n for (var o = r[1] !== null && t !== null, u = ve(r), c = !r[0].isVoid, f = s - 2, _ = r[0], d = r[1], p = [\n e,\n h,\n n,\n i,\n Wr,\n _.fromWireType.bind(_),\n d?.toWireType.bind(d)\n ], v = 2; v < s; ++v) {\n var $ = r[v];\n p.push($.toWireType.bind($));\n }\n if (!u) for (var v = o ? 1 : 2; v < r.length; ++v) r[v].destructorFunction !== null && p.push(r[v].destructorFunction);\n return fr(e, jt(r, o, c, a)(...p));\n }\n var gr = (e, r) => {\n for (var t = [], n = 0; n < e; n++) t.push(w[r + n * 4 >> 2]);\n return t;\n }, xr = (e) => {\n e = e.trim();\n const r = e.indexOf(\"(\");\n return r === -1 ? e : e.slice(0, r);\n }, It = (e, r, t, n, i, a, s, o, u) => {\n var c = gr(t, n);\n r = C(r), r = xr(r), a = R(i, a, o), D([], [e], (f) => {\n f = f[0];\n var _ = `${f.name}.${r}`;\n function d() {\n I(`Cannot call ${_} due to unbound types`, c);\n }\n r.startsWith(\"@@\") && (r = Symbol[r.substring(2)]);\n var p = f.registeredClass.constructor;\n return p[r] === void 0 ? (d.argCount = t - 1, p[r] = d) : (Er(p, r, _), p[r].overloadTable[t - 1] = d), D([], c, (v) => {\n var P = hr(_, [v[0], null].concat(v.slice(1)), null, a, s, o);\n if (p[r].overloadTable === void 0 ? (P.argCount = t - 1, p[r] = P) : p[r].overloadTable[t - 1] = P, f.registeredClass.__derivedClasses) for (const F of f.registeredClass.__derivedClasses) F.constructor.hasOwnProperty(r) || (F.constructor[r] = P);\n return [];\n }), [];\n });\n }, Mt = (e, r, t, n, i, a) => {\n var s = gr(r, t);\n i = R(n, i);\n D([], [e], (c) => {\n c = c[0];\n var f = `constructor ${c.name}`;\n if (c.registeredClass.constructor_body === void 0 && (c.registeredClass.constructor_body = []), c.registeredClass.constructor_body[r - 1] !== void 0) throw new q(`Cannot register multiple constructors with identical number of parameters (${r - 1}) for class '${c.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);\n return c.registeredClass.constructor_body[r - 1] = () => {\n I(`Cannot construct ${c.name} due to unbound types`, s);\n }, D([], s, (_) => (_.splice(1, 0, null), c.registeredClass.constructor_body[r - 1] = hr(f, _, null, i, a), [])), [];\n });\n }, Ht = (e, r, t, n, i, a, s, o, u, c) => {\n var f = gr(t, n);\n r = C(r), r = xr(r), a = R(i, a, u), D([], [e], (_) => {\n _ = _[0];\n var d = `${_.name}.${r}`;\n r.startsWith(\"@@\") && (r = Symbol[r.substring(2)]), o && _.registeredClass.pureVirtualFunctions.push(r);\n function p() {\n I(`Cannot call ${d} due to unbound types`, f);\n }\n var v = _.registeredClass.instancePrototype, $ = v[r];\n return $ === void 0 || $.overloadTable === void 0 && $.className !== _.name && $.argCount === t - 2 ? (p.argCount = t - 2, p.className = _.name, v[r] = p) : (Er(v, r, d), v[r].overloadTable[t - 2] = p), D([], f, (P) => {\n var F = hr(d, P, _, a, s, u);\n return v[r].overloadTable === void 0 ? (F.argCount = t - 2, v[r] = F) : v[r].overloadTable[t - 2] = F, [];\n }), [];\n });\n }, _e = (e, r, t) => (e instanceof Object || h(`${t} with invalid \"this\": ${e}`), e instanceof r.registeredClass.constructor || h(`${t} incompatible with \"this\" of type ${e.constructor.name}`), e.$$.ptr || h(`cannot call emscripten binding method ${t} on deleted object`), lr(e.$$.ptr, e.$$.ptrType.registeredClass, r.registeredClass)), Bt = (e, r, t, n, i, a, s, o, u, c) => {\n r = C(r), i = R(n, i), D([], [e], (f) => {\n f = f[0];\n var _ = `${f.name}.${r}`, d = {\n get() {\n I(`Cannot access ${_} due to unbound types`, [t, s]);\n },\n enumerable: !0,\n configurable: !0\n };\n return u ? d.set = () => I(`Cannot access ${_} due to unbound types`, [t, s]) : d.set = (p) => h(_ + \" is a read-only property\"), Object.defineProperty(f.registeredClass.instancePrototype, r, d), D([], u ? [t, s] : [t], (p) => {\n var v = p[0], $ = {\n get() {\n var F = _e(this, f, _ + \" getter\");\n return v.fromWireType(i(a, F));\n },\n enumerable: !0\n };\n if (u) {\n u = R(o, u);\n var P = p[1];\n $.set = function(F) {\n var Z = _e(this, f, _ + \" setter\"), S = [];\n u(c, Z, P.toWireType(S, F)), Wr(S);\n };\n }\n return Object.defineProperty(f.registeredClass.instancePrototype, r, $), [];\n }), [];\n });\n }, de = [], N = [\n 0,\n 1,\n ,\n 1,\n null,\n 1,\n !0,\n 1,\n !1,\n 1\n ], Or = (e) => {\n e > 9 && --N[e + 1] === 0 && (N[e] = void 0, de.push(e));\n }, W = {\n toValue: (e) => (e || h(`Cannot use deleted val. handle = ${e}`), N[e]),\n toHandle: (e) => {\n switch (e) {\n case void 0: return 2;\n case null: return 4;\n case !0: return 6;\n case !1: return 8;\n default: {\n const r = de.pop() || N.length;\n return N[r] = e, N[r + 1] = 1, r;\n }\n }\n }\n }, Lt = {\n name: \"emscripten::val\",\n fromWireType: (e) => {\n var r = W.toValue(e);\n return Or(e), r;\n },\n toWireType: (e, r) => W.toHandle(r),\n readValueFromPointer: vr,\n destructorFunction: null\n }, zt = (e) => E(e, Lt), Yt = (e, r, t) => {\n switch (r) {\n case 1: return t ? function(n) {\n return this.fromWireType(k[n]);\n } : function(n) {\n return this.fromWireType(A[n]);\n };\n case 2: return t ? function(n) {\n return this.fromWireType(U[n >> 1]);\n } : function(n) {\n return this.fromWireType(L[n >> 1]);\n };\n case 4: return t ? function(n) {\n return this.fromWireType(T[n >> 2]);\n } : function(n) {\n return this.fromWireType(w[n >> 2]);\n };\n default: throw new TypeError(`invalid integer width (${r}): ${e}`);\n }\n }, Nt = (e, r, t, n) => {\n r = C(r);\n function i() {}\n i.values = {}, E(e, {\n name: r,\n constructor: i,\n fromWireType: function(a) {\n return this.constructor.values[a];\n },\n toWireType: (a, s) => s.value,\n readValueFromPointer: Yt(r, t, n),\n destructorFunction: null\n }), Rr(r, i);\n }, pe = (e, r) => {\n var t = j[e];\n return t === void 0 && h(`${r} has unknown type ${le(e)}`), t;\n }, Gt = (e, r, t) => {\n var n = pe(e, \"enum\");\n r = C(r);\n var i = n.constructor, a = Object.create(n.constructor.prototype, {\n value: { value: t },\n constructor: { value: fr(`${n.name}_${r}`, function() {}) }\n });\n i.values[t] = a, i[r] = a;\n }, qt = (e, r) => {\n switch (r) {\n case 4: return function(t) {\n return this.fromWireType(tr[t >> 2]);\n };\n case 8: return function(t) {\n return this.fromWireType(nr[t >> 3]);\n };\n default: throw new TypeError(`invalid float width (${r}): ${e}`);\n }\n }, Xt = (e, r, t) => {\n r = C(r), E(e, {\n name: r,\n fromWireType: (n) => n,\n toWireType: (n, i) => i,\n readValueFromPointer: qt(r, t),\n destructorFunction: null\n });\n }, Jt = (e, r, t, n, i, a, s, o) => {\n var u = gr(r, t);\n e = C(e), e = xr(e), i = R(n, i, s), Rr(e, function() {\n I(`Cannot call ${e} due to unbound types`, u);\n }, r - 1), D([], u, (c) => {\n var f = [c[0], null].concat(c.slice(1));\n return ue(e, hr(e, f, null, i, a, s), r - 1), [];\n });\n }, Kt = (e, r, t, n, i) => {\n r = C(r);\n const a = n === 0;\n let s = (u) => u;\n if (a) {\n var o = 32 - 8 * t;\n s = (u) => u << o >>> o, i = s(i);\n }\n E(e, {\n name: r,\n fromWireType: s,\n toWireType: (u, c) => c,\n readValueFromPointer: te(r, t, n !== 0),\n destructorFunction: null\n });\n }, Zt = (e, r, t) => {\n var i = [\n Int8Array,\n Uint8Array,\n Int16Array,\n Uint16Array,\n Int32Array,\n Uint32Array,\n Float32Array,\n Float64Array,\n BigInt64Array,\n BigUint64Array\n ][r];\n function a(s) {\n var o = w[s >> 2], u = w[s + 4 >> 2];\n return new i(k.buffer, u, o);\n }\n t = C(t), E(e, {\n name: t,\n fromWireType: a,\n readValueFromPointer: a\n }, { ignoreDuplicateRegistrations: !0 });\n }, Qt = (e, r, t, n) => {\n if (!(n > 0)) return 0;\n for (var i = t, a = t + n - 1, s = 0; s < e.length; ++s) {\n var o = e.codePointAt(s);\n if (o <= 127) {\n if (t >= a) break;\n r[t++] = o;\n } else if (o <= 2047) {\n if (t + 1 >= a) break;\n r[t++] = 192 | o >> 6, r[t++] = 128 | o & 63;\n } else if (o <= 65535) {\n if (t + 2 >= a) break;\n r[t++] = 224 | o >> 12, r[t++] = 128 | o >> 6 & 63, r[t++] = 128 | o & 63;\n } else {\n if (t + 3 >= a) break;\n r[t++] = 240 | o >> 18, r[t++] = 128 | o >> 12 & 63, r[t++] = 128 | o >> 6 & 63, r[t++] = 128 | o & 63, s++;\n }\n }\n return r[t] = 0, t - i;\n }, M = (e, r, t) => Qt(e, A, r, t), Ur = (e) => {\n for (var r = 0, t = 0; t < e.length; ++t) {\n var n = e.charCodeAt(t);\n n <= 127 ? r++ : n <= 2047 ? r += 2 : n >= 55296 && n <= 57343 ? (r += 4, ++t) : r += 3;\n }\n return r;\n }, he = typeof TextDecoder < \"u\" ? new TextDecoder() : void 0, ge = (e, r, t, n) => {\n var i = r + t;\n if (n) return i;\n for (; e[r] && !(r >= i);) ++r;\n return r;\n }, ye = (e, r = 0, t, n) => {\n var i = ge(e, r, t, n);\n if (i - r > 16 && e.buffer && he) return he.decode(e.subarray(r, i));\n for (var a = \"\"; r < i;) {\n var s = e[r++];\n if (!(s & 128)) {\n a += String.fromCharCode(s);\n continue;\n }\n var o = e[r++] & 63;\n if ((s & 224) == 192) {\n a += String.fromCharCode((s & 31) << 6 | o);\n continue;\n }\n var u = e[r++] & 63;\n if ((s & 240) == 224 ? s = (s & 15) << 12 | o << 6 | u : s = (s & 7) << 18 | o << 12 | u << 6 | e[r++] & 63, s < 65536) a += String.fromCharCode(s);\n else {\n var c = s - 65536;\n a += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);\n }\n }\n return a;\n }, yr = (e, r, t) => e ? ye(A, e, r, t) : \"\", rn = (e, r) => {\n r = C(r);\n var t = !0;\n E(e, {\n name: r,\n fromWireType(n) {\n var i = w[n >> 2], a = n + 4, s;\n if (t) s = yr(a, i, !0);\n else {\n s = \"\";\n for (var o = 0; o < i; ++o) s += String.fromCharCode(A[a + o]);\n }\n return O(n), s;\n },\n toWireType(n, i) {\n i instanceof ArrayBuffer && (i = new Uint8Array(i));\n var a, s = typeof i == \"string\";\n s || ArrayBuffer.isView(i) && i.BYTES_PER_ELEMENT == 1 || h(\"Cannot pass non-string to std::string\"), t && s ? a = Ur(i) : a = i.length;\n var o = Mr(4 + a + 1), u = o + 4;\n if (w[o >> 2] = a, s) if (t) M(i, u, a + 1);\n else for (var c = 0; c < a; ++c) {\n var f = i.charCodeAt(c);\n f > 255 && (O(o), h(\"String has UTF-16 code units that do not fit in 8 bits\")), A[u + c] = f;\n }\n else A.set(i, u);\n return n !== null && n.push(O, o), o;\n },\n readValueFromPointer: vr,\n destructorFunction(n) {\n O(n);\n }\n });\n }, me = typeof TextDecoder < \"u\" ? new TextDecoder(\"utf-16le\") : void 0, en = (e, r, t) => {\n var n = e >> 1, i = ge(L, n, r / 2, t);\n if (i - n > 16 && me) return me.decode(L.subarray(n, i));\n for (var a = \"\", s = n; s < i; ++s) {\n var o = L[s];\n a += String.fromCharCode(o);\n }\n return a;\n }, tn = (e, r, t) => {\n if (t ??= 2147483647, t < 2) return 0;\n t -= 2;\n for (var n = r, i = t < e.length * 2 ? t / 2 : e.length, a = 0; a < i; ++a) {\n var s = e.charCodeAt(a);\n U[r >> 1] = s, r += 2;\n }\n return U[r >> 1] = 0, r - n;\n }, nn = (e) => e.length * 2, an = (e, r, t) => {\n for (var n = \"\", i = e >> 2, a = 0; !(a >= r / 4); a++) {\n var s = w[i + a];\n if (!s && !t) break;\n n += String.fromCodePoint(s);\n }\n return n;\n }, sn = (e, r, t) => {\n if (t ??= 2147483647, t < 4) return 0;\n for (var n = r, i = n + t - 4, a = 0; a < e.length; ++a) {\n var s = e.codePointAt(a);\n if (s > 65535 && a++, T[r >> 2] = s, r += 4, r + 4 > i) break;\n }\n return T[r >> 2] = 0, r - n;\n }, on = (e) => {\n for (var r = 0, t = 0; t < e.length; ++t) e.codePointAt(t) > 65535 && t++, r += 4;\n return r;\n }, un = (e, r, t) => {\n t = C(t);\n var n, i, a;\n r === 2 ? (n = en, i = tn, a = nn) : (n = an, i = sn, a = on), E(e, {\n name: t,\n fromWireType: (s) => {\n var o = w[s >> 2], u = n(s + 4, o * r, !0);\n return O(s), u;\n },\n toWireType: (s, o) => {\n typeof o != \"string\" && h(`Cannot pass non-string to C++ string type ${t}`);\n var u = a(o), c = Mr(4 + u + r);\n return w[c >> 2] = u / r, i(o, c + 4, u + r), s !== null && s.push(O, c), c;\n },\n readValueFromPointer: vr,\n destructorFunction(s) {\n O(s);\n }\n });\n }, cn = (e, r) => {\n r = C(r), E(e, {\n isVoid: !0,\n name: r,\n fromWireType: () => {},\n toWireType: (t, n) => {}\n });\n }, be = 0, fn = () => {\n Cr = !1, be = 0;\n }, Vr = [], ln = (e) => {\n var r = Vr.length;\n return Vr.push(e), r;\n }, vn = (e, r) => {\n for (var t = new Array(e), n = 0; n < e; ++n) t[n] = pe(w[r + n * 4 >> 2], `parameter ${n}`);\n return t;\n }, _n = (e, r, t) => {\n var n = [], i = e(n, t);\n return n.length && (w[r >> 2] = W.toHandle(n)), i;\n }, dn = {}, pn = (e) => {\n var r = dn[e];\n return r === void 0 ? C(e) : r;\n }, hn = (e, r, t) => {\n var n = 8, [i, ...a] = vn(e, r), s = i.toWireType.bind(i), o = a.map((p) => p.readValueFromPointer.bind(p));\n e--;\n var u = { toValue: W.toValue }, c = o.map((p, v) => {\n var $ = `argFromPtr${v}`;\n return u[$] = p, `${$}(args${v ? \"+\" + v * n : \"\"})`;\n }), f;\n switch (t) {\n case 0:\n f = \"toValue(handle)\";\n break;\n case 2:\n f = \"new (toValue(handle))\";\n break;\n case 3:\n f = \"\";\n break;\n case 1: u.getStringOrSymbol = pn, f = \"toValue(handle)[getStringOrSymbol(methodName)]\";\n }\n f += `(${c})`, i.isVoid || (u.toReturnWire = s, u.emval_returnValue = _n, f = `return emval_returnValue(toReturnWire, destructorsRef, ${f})`), f = `return function (handle, methodName, destructorsRef, args) {\n ${f}\n }`;\n var _ = new Function(Object.keys(u), f)(...Object.values(u));\n return ln(fr(`methodCaller<(${a.map((p) => p.name)}) => ${i.name}>`, _));\n }, gn = (e, r, t, n, i) => Vr[e](r, t, n, i), yn = () => W.toHandle({}), mn = (e) => {\n Wr(W.toValue(e)), Or(e);\n }, bn = (e, r, t) => {\n e = W.toValue(e), r = W.toValue(r), t = W.toValue(t), e[r] = t;\n }, $n = 9007199254740992, wn = -9007199254740992, mr = (e) => e < wn || e > $n ? NaN : Number(e);\n function Tn(e, r) {\n e = mr(e);\n var t = /* @__PURE__ */ new Date(e * 1e3);\n T[r >> 2] = t.getUTCSeconds(), T[r + 4 >> 2] = t.getUTCMinutes(), T[r + 8 >> 2] = t.getUTCHours(), T[r + 12 >> 2] = t.getUTCDate(), T[r + 16 >> 2] = t.getUTCMonth(), T[r + 20 >> 2] = t.getUTCFullYear() - 1900, T[r + 24 >> 2] = t.getUTCDay();\n var n = Date.UTC(t.getUTCFullYear(), 0, 1, 0, 0, 0, 0), i = (t.getTime() - n) / 864e5 | 0;\n T[r + 28 >> 2] = i;\n }\n var Fn = (e) => e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0), Cn = [\n 0,\n 31,\n 60,\n 91,\n 121,\n 152,\n 182,\n 213,\n 244,\n 274,\n 305,\n 335\n ], Pn = [\n 0,\n 31,\n 59,\n 90,\n 120,\n 151,\n 181,\n 212,\n 243,\n 273,\n 304,\n 334\n ], kn = (e) => {\n return (Fn(e.getFullYear()) ? Cn : Pn)[e.getMonth()] + e.getDate() - 1;\n };\n function Sn(e, r) {\n e = mr(e);\n var t = /* @__PURE__ */ new Date(e * 1e3);\n T[r >> 2] = t.getSeconds(), T[r + 4 >> 2] = t.getMinutes(), T[r + 8 >> 2] = t.getHours(), T[r + 12 >> 2] = t.getDate(), T[r + 16 >> 2] = t.getMonth(), T[r + 20 >> 2] = t.getFullYear() - 1900, T[r + 24 >> 2] = t.getDay();\n var n = kn(t) | 0;\n T[r + 28 >> 2] = n, T[r + 36 >> 2] = -(t.getTimezoneOffset() * 60);\n var i = new Date(t.getFullYear(), 0, 1), a = new Date(t.getFullYear(), 6, 1).getTimezoneOffset(), s = i.getTimezoneOffset(), o = (a != s && t.getTimezoneOffset() == Math.min(s, a)) | 0;\n T[r + 32 >> 2] = o;\n }\n var J = {}, $e = (e) => {\n if (e instanceof Zr || e == \"unwind\") return rr;\n zr(1, e);\n }, we = () => Cr || be > 0, Te = (e) => {\n rr = e, we() || (l.onExit?.(e), Q = !0), zr(e, new Zr(e));\n }, An = (e, r) => {\n rr = e, Te(e);\n }, En = An, Rn = () => {\n if (!we()) try {\n En(rr);\n } catch (e) {\n $e(e);\n }\n }, Dn = (e) => {\n if (!Q) try {\n e(), Rn();\n } catch (r) {\n $e(r);\n }\n }, Fe = () => performance.now(), Wn = (e, r) => {\n if (J[e] && (clearTimeout(J[e].id), delete J[e]), !r) return 0;\n return J[e] = {\n id: setTimeout(() => {\n delete J[e], Dn(() => Ee(e, Fe()));\n }, r),\n timeout_ms: r\n }, 0;\n }, xn = (e, r, t, n) => {\n var i = (/* @__PURE__ */ new Date()).getFullYear(), a = new Date(i, 0, 1), s = new Date(i, 6, 1), o = a.getTimezoneOffset(), u = s.getTimezoneOffset(), c = Math.max(o, u);\n w[e >> 2] = c * 60, T[r >> 2] = +(o != u);\n var f = (p) => {\n var v = p >= 0 ? \"-\" : \"+\", $ = Math.abs(p);\n return `UTC${v}${String(Math.floor($ / 60)).padStart(2, \"0\")}${String($ % 60).padStart(2, \"0\")}`;\n }, _ = f(o), d = f(u);\n u < o ? (M(_, t, 17), M(d, n, 17)) : (M(_, n, 17), M(d, t, 17));\n }, On = () => Date.now(), Un = 1, Vn = (e) => e >= 0 && e <= 3;\n function jn(e, r, t) {\n if (r = mr(r), !Vn(e)) return 28;\n var n;\n if (e === 0) n = On();\n else if (Un) n = Fe();\n else return 52;\n var i = Math.round(n * 1e3 * 1e3);\n return V[t >> 3] = BigInt(i), 0;\n }\n var Ce = () => 2147483648, In = () => Ce(), Mn = (e, r) => Math.ceil(e / r) * r, Hn = (e) => {\n var t = (e - er.buffer.byteLength + 65535) / 65536 | 0;\n try {\n return er.grow(t), Kr(), 1;\n } catch {}\n }, Bn = (e) => {\n var r = A.length;\n e >>>= 0;\n var t = Ce();\n if (e > t) return !1;\n for (var n = 1; n <= 4; n *= 2) {\n var i = r * (1 + .2 / n);\n i = Math.min(i, e + 100663296);\n if (Hn(Math.min(t, Mn(Math.max(e, i), 65536)))) return !0;\n }\n return !1;\n }, br = {}, Ln = () => Lr || \"./this.program\", K = () => {\n if (!K.strings) {\n var r = {\n USER: \"web_user\",\n LOGNAME: \"web_user\",\n PATH: \"/\",\n PWD: \"/\",\n HOME: \"/home/web_user\",\n LANG: (typeof navigator == \"object\" && navigator.language || \"C\").replace(\"-\", \"_\") + \".UTF-8\",\n _: Ln()\n };\n for (var t in br) br[t] === void 0 ? delete r[t] : r[t] = br[t];\n var n = [];\n for (var t in r) n.push(`${t}=${r[t]}`);\n K.strings = n;\n }\n return K.strings;\n }, zn = (e, r) => {\n var t = 0, n = 0;\n for (var i of K()) {\n var a = r + t;\n w[e + n >> 2] = a, t += M(i, a, 1 / 0) + 1, n += 4;\n }\n return 0;\n }, Yn = (e, r) => {\n var t = K();\n w[e >> 2] = t.length;\n var n = 0;\n for (var i of t) n += Ur(i) + 1;\n return w[r >> 2] = n, 0;\n }, Nn = (e) => 52, Gn = (e, r) => {\n var t = 0, n = 0, i = 0;\n var a = 2;\n e == 0 ? t = 2 : (e == 1 || e == 2) && (t = 64), i = 1;\n return k[r] = a, U[r + 2 >> 1] = i, V[r + 8 >> 3] = BigInt(t), V[r + 16 >> 3] = BigInt(n), 0;\n };\n function qn(e, r, t, n) {\n return r = mr(r), 70;\n }\n var jr = [\n null,\n [],\n []\n ], Ir = (e, r) => {\n var t = jr[e];\n r === 0 || r === 10 ? ((e === 1 ? Nr : B)(ye(t)), t.length = 0) : t.push(r);\n }, Xn = (e, r, t, n) => {\n for (var i = 0, a = 0; a < t; a++) {\n var s = w[r >> 2], o = w[r + 4 >> 2];\n r += 8;\n for (var u = 0; u < o; u++) Ir(e, A[s + u]);\n i += o;\n }\n return w[n >> 2] = i, 0;\n }, Jn = (e) => e, Pe = (e) => {\n return l[\"_\" + e];\n }, Kn = (e, r) => {\n k.set(e, r);\n }, ke = (e) => We(e), Zn = (e) => {\n var r = Ur(e) + 1, t = ke(r);\n return M(e, t, r), t;\n }, Se = (e, r, t, n, i) => {\n var a = {\n string: (v) => {\n var $ = 0;\n return v != null && v !== 0 && ($ = Zn(v)), $;\n },\n array: (v) => {\n var $ = ke(v.length);\n return Kn(v, $), $;\n }\n };\n function s(v) {\n return r === \"string\" ? yr(v) : r === \"boolean\" ? !!v : v;\n }\n var o = Pe(e), u = [], c = 0;\n if (n) for (var f = 0; f < n.length; f++) {\n var _ = a[t[f]];\n _ ? (c === 0 && (c = m()), u[f] = _(n[f])) : u[f] = n[f];\n }\n var d = o(...u);\n function p(v) {\n return c !== 0 && y(c), s(v);\n }\n return d = p(d), d;\n }, Qn = (e, r, t, n) => {\n var i = !t || t.every((s) => s === \"number\" || s === \"boolean\");\n return r !== \"string\" && i && !n ? Pe(e) : (...s) => Se(e, r, t, s, n);\n };\n if (wt(), Ot(), l.noExitRuntime && (Cr = l.noExitRuntime), l.print && (Nr = l.print), l.printErr && (B = l.printErr), l.wasmBinary && (G = l.wasmBinary), l.arguments && l.arguments, l.thisProgram && (Lr = l.thisProgram), l.preInit) for (typeof l.preInit == \"function\" && (l.preInit = [l.preInit]); l.preInit.length > 0;) l.preInit.shift()();\n l.ENV = br, l.ccall = Se, l.cwrap = Qn;\n var Ae, Mr, O, Ee, g, Re, De, We, xe, Oe, Ue, Ve, je;\n function si(e) {\n Ae = e.__getTypeName, l._malloc = Mr = e.malloc, l._parseDropFile = e.parseDropFile, l._getAttributeFromDropFile = e.getAttributeFromDropFile, l._takeAttributeFromDropFile = e.takeAttributeFromDropFile, l._flattenDropFile = e.flattenDropFile, l._destroyDropFileHandle = e.destroyDropFileHandle, e.__cxa_free_exception, l._free = O = e.free, Ee = e._emscripten_timeout, g = e.setThrew, Re = e._emscripten_tempret_set, De = e._emscripten_stack_restore, We = e._emscripten_stack_alloc, xe = e.emscripten_stack_get_current, Oe = e.__cxa_decrement_exception_refcount, Ue = e.__cxa_increment_exception_refcount, Ve = e.__cxa_can_catch, je = e.__cxa_get_exception_ptr;\n }\n var Ie = {\n __cxa_begin_catch: st,\n __cxa_end_catch: ot,\n __cxa_find_matching_catch_2: ut,\n __cxa_find_matching_catch_3: ct,\n __cxa_find_matching_catch_4: ft,\n __cxa_rethrow: lt,\n __cxa_throw: vt,\n __cxa_uncaught_exceptions: _t,\n __resumeException: dt,\n _abort_js: pt,\n _embind_register_bigint: gt,\n _embind_register_bool: yt,\n _embind_register_class: Vt,\n _embind_register_class_class_function: It,\n _embind_register_class_constructor: Mt,\n _embind_register_class_function: Ht,\n _embind_register_class_property: Bt,\n _embind_register_emval: zt,\n _embind_register_enum: Nt,\n _embind_register_enum_value: Gt,\n _embind_register_float: Xt,\n _embind_register_function: Jt,\n _embind_register_integer: Kt,\n _embind_register_memory_view: Zt,\n _embind_register_std_string: rn,\n _embind_register_std_wstring: un,\n _embind_register_void: cn,\n _emscripten_runtime_keepalive_clear: fn,\n _emval_create_invoker: hn,\n _emval_decref: Or,\n _emval_invoke: gn,\n _emval_new_object: yn,\n _emval_run_destructors: mn,\n _emval_set_property: bn,\n _gmtime_js: Tn,\n _localtime_js: Sn,\n _setitimer_js: Wn,\n _tzset_js: xn,\n clock_time_get: jn,\n emscripten_get_heap_max: In,\n emscripten_resize_heap: Bn,\n environ_get: zn,\n environ_sizes_get: Yn,\n fd_close: Nn,\n fd_fdstat_get: Gn,\n fd_seek: qn,\n fd_write: Xn,\n invoke_diii: Wi,\n invoke_fi: Ti,\n invoke_fiii: Di,\n invoke_i: Ci,\n invoke_ii: ui,\n invoke_iii: ci,\n invoke_iiii: mi,\n invoke_iiiid: Oi,\n invoke_iiiii: wi,\n invoke_iiiiid: Ai,\n invoke_iiiiii: hi,\n invoke_iiiiiii: Ui,\n invoke_iiiiiiii: Ei,\n invoke_iiiiiiiiii: yi,\n invoke_iiiiiiiiiii: _i,\n invoke_iiiiiiiiiiii: di,\n invoke_iiiiijj: Vi,\n invoke_iiiijj: ji,\n invoke_iiij: Pi,\n invoke_j: ki,\n invoke_jiiii: Ri,\n invoke_v: pi,\n invoke_vi: oi,\n invoke_vii: li,\n invoke_viii: fi,\n invoke_viiii: vi,\n invoke_viiiii: bi,\n invoke_viiiiii: gi,\n invoke_viiiiiii: xi,\n invoke_viiiiiiii: Fi,\n invoke_viiiiiiiiii: Ii,\n invoke_viiiiiiiiiiiiiii: Mi,\n invoke_viiji: Si,\n invoke_viijii: $i,\n llvm_eh_typeid_for: Jn,\n proc_exit: Te\n };\n function oi(e, r) {\n var t = m();\n try {\n b(e)(r);\n } catch (n) {\n if (y(t), n !== n + 0) throw n;\n g(1, 0);\n }\n }\n function ui(e, r) {\n var t = m();\n try {\n return b(e)(r);\n } catch (n) {\n if (y(t), n !== n + 0) throw n;\n g(1, 0);\n }\n }\n function ci(e, r, t) {\n var n = m();\n try {\n return b(e)(r, t);\n } catch (i) {\n if (y(n), i !== i + 0) throw i;\n g(1, 0);\n }\n }\n function fi(e, r, t, n) {\n var i = m();\n try {\n b(e)(r, t, n);\n } catch (a) {\n if (y(i), a !== a + 0) throw a;\n g(1, 0);\n }\n }\n function li(e, r, t) {\n var n = m();\n try {\n b(e)(r, t);\n } catch (i) {\n if (y(n), i !== i + 0) throw i;\n g(1, 0);\n }\n }\n function vi(e, r, t, n, i) {\n var a = m();\n try {\n b(e)(r, t, n, i);\n } catch (s) {\n if (y(a), s !== s + 0) throw s;\n g(1, 0);\n }\n }\n function _i(e, r, t, n, i, a, s, o, u, c, f) {\n var _ = m();\n try {\n return b(e)(r, t, n, i, a, s, o, u, c, f);\n } catch (d) {\n if (y(_), d !== d + 0) throw d;\n g(1, 0);\n }\n }\n function di(e, r, t, n, i, a, s, o, u, c, f, _) {\n var d = m();\n try {\n return b(e)(r, t, n, i, a, s, o, u, c, f, _);\n } catch (p) {\n if (y(d), p !== p + 0) throw p;\n g(1, 0);\n }\n }\n function pi(e) {\n var r = m();\n try {\n b(e)();\n } catch (t) {\n if (y(r), t !== t + 0) throw t;\n g(1, 0);\n }\n }\n function hi(e, r, t, n, i, a) {\n var s = m();\n try {\n return b(e)(r, t, n, i, a);\n } catch (o) {\n if (y(s), o !== o + 0) throw o;\n g(1, 0);\n }\n }\n function gi(e, r, t, n, i, a, s) {\n var o = m();\n try {\n b(e)(r, t, n, i, a, s);\n } catch (u) {\n if (y(o), u !== u + 0) throw u;\n g(1, 0);\n }\n }\n function yi(e, r, t, n, i, a, s, o, u, c) {\n var f = m();\n try {\n return b(e)(r, t, n, i, a, s, o, u, c);\n } catch (_) {\n if (y(f), _ !== _ + 0) throw _;\n g(1, 0);\n }\n }\n function mi(e, r, t, n) {\n var i = m();\n try {\n return b(e)(r, t, n);\n } catch (a) {\n if (y(i), a !== a + 0) throw a;\n g(1, 0);\n }\n }\n function bi(e, r, t, n, i, a) {\n var s = m();\n try {\n b(e)(r, t, n, i, a);\n } catch (o) {\n if (y(s), o !== o + 0) throw o;\n g(1, 0);\n }\n }\n function $i(e, r, t, n, i, a) {\n var s = m();\n try {\n b(e)(r, t, n, i, a);\n } catch (o) {\n if (y(s), o !== o + 0) throw o;\n g(1, 0);\n }\n }\n function wi(e, r, t, n, i) {\n var a = m();\n try {\n return b(e)(r, t, n, i);\n } catch (s) {\n if (y(a), s !== s + 0) throw s;\n g(1, 0);\n }\n }\n function Ti(e, r) {\n var t = m();\n try {\n return b(e)(r);\n } catch (n) {\n if (y(t), n !== n + 0) throw n;\n g(1, 0);\n }\n }\n function Fi(e, r, t, n, i, a, s, o, u) {\n var c = m();\n try {\n b(e)(r, t, n, i, a, s, o, u);\n } catch (f) {\n if (y(c), f !== f + 0) throw f;\n g(1, 0);\n }\n }\n function Ci(e) {\n var r = m();\n try {\n return b(e)();\n } catch (t) {\n if (y(r), t !== t + 0) throw t;\n g(1, 0);\n }\n }\n function Pi(e, r, t, n) {\n var i = m();\n try {\n return b(e)(r, t, n);\n } catch (a) {\n if (y(i), a !== a + 0) throw a;\n g(1, 0);\n }\n }\n function ki(e) {\n var r = m();\n try {\n return b(e)();\n } catch (t) {\n if (y(r), t !== t + 0) throw t;\n return g(1, 0), 0n;\n }\n }\n function Si(e, r, t, n, i) {\n var a = m();\n try {\n b(e)(r, t, n, i);\n } catch (s) {\n if (y(a), s !== s + 0) throw s;\n g(1, 0);\n }\n }\n function Ai(e, r, t, n, i, a) {\n var s = m();\n try {\n return b(e)(r, t, n, i, a);\n } catch (o) {\n if (y(s), o !== o + 0) throw o;\n g(1, 0);\n }\n }\n function Ei(e, r, t, n, i, a, s, o) {\n var u = m();\n try {\n return b(e)(r, t, n, i, a, s, o);\n } catch (c) {\n if (y(u), c !== c + 0) throw c;\n g(1, 0);\n }\n }\n function Ri(e, r, t, n, i) {\n var a = m();\n try {\n return b(e)(r, t, n, i);\n } catch (s) {\n if (y(a), s !== s + 0) throw s;\n return g(1, 0), 0n;\n }\n }\n function Di(e, r, t, n) {\n var i = m();\n try {\n return b(e)(r, t, n);\n } catch (a) {\n if (y(i), a !== a + 0) throw a;\n g(1, 0);\n }\n }\n function Wi(e, r, t, n) {\n var i = m();\n try {\n return b(e)(r, t, n);\n } catch (a) {\n if (y(i), a !== a + 0) throw a;\n g(1, 0);\n }\n }\n function xi(e, r, t, n, i, a, s, o) {\n var u = m();\n try {\n b(e)(r, t, n, i, a, s, o);\n } catch (c) {\n if (y(u), c !== c + 0) throw c;\n g(1, 0);\n }\n }\n function Oi(e, r, t, n, i) {\n var a = m();\n try {\n return b(e)(r, t, n, i);\n } catch (s) {\n if (y(a), s !== s + 0) throw s;\n g(1, 0);\n }\n }\n function Ui(e, r, t, n, i, a, s) {\n var o = m();\n try {\n return b(e)(r, t, n, i, a, s);\n } catch (u) {\n if (y(o), u !== u + 0) throw u;\n g(1, 0);\n }\n }\n function Vi(e, r, t, n, i, a, s) {\n var o = m();\n try {\n return b(e)(r, t, n, i, a, s);\n } catch (u) {\n if (y(o), u !== u + 0) throw u;\n g(1, 0);\n }\n }\n function ji(e, r, t, n, i, a) {\n var s = m();\n try {\n return b(e)(r, t, n, i, a);\n } catch (o) {\n if (y(s), o !== o + 0) throw o;\n g(1, 0);\n }\n }\n function Ii(e, r, t, n, i, a, s, o, u, c, f) {\n var _ = m();\n try {\n b(e)(r, t, n, i, a, s, o, u, c, f);\n } catch (d) {\n if (y(_), d !== d + 0) throw d;\n g(1, 0);\n }\n }\n function Mi(e, r, t, n, i, a, s, o, u, c, f, _, d, p, v, $) {\n var P = m();\n try {\n b(e)(r, t, n, i, a, s, o, u, c, f, _, d, p, v, $);\n } catch (F) {\n if (y(P), F !== F + 0) throw F;\n g(1, 0);\n }\n }\n function Hi() {\n qe();\n function e() {\n l.calledRun = !0, !Q && (Xe(), Gr?.(l), l.onRuntimeInitialized?.(), Je());\n }\n l.setStatus ? (l.setStatus(\"Running...\"), setTimeout(() => {\n setTimeout(() => l.setStatus(\"\"), 1), e();\n }, 1)) : e();\n }\n var H;\n return H = await nt(), Hi(), Jr ? $r = l : $r = new Promise((e, r) => {\n Gr = e, qr = r;\n }), $r;\n}\n//#endregion\n//#region packages/core/engine/threads/decoder/worker.ts\nconst { wasmBinary } = await new Promise((resolve) => {\n self.addEventListener(\"message\", function onInit(e) {\n if (e.data?.type === \"wasm-init\") {\n self.removeEventListener(\"message\", onInit);\n resolve(e.data);\n }\n });\n});\nif (!wasmBinary) throw new Error(\"Decoder worker did not receive WASM binary. The main thread failed to fetch aqua-parser.wasm.\");\nconst module = await Li({ wasmBinary });\nconst controllers = /* @__PURE__ */ new Map();\nconst decoder = {\n get AttributeInfo() {\n return module.AttributeInfo;\n },\n get AquaStatus() {\n return module.AquaStatus;\n },\n get heapU8() {\n return module.HEAPU8;\n },\n get heapU32() {\n return module.HEAPU32;\n },\n get SceneRequestDescriptor() {\n return module.SceneRequestDescriptor;\n },\n get WorkerDataType() {\n return module.WorkerDataType;\n },\n dataPtrView: (attributeInfo) => {\n return module.dataPtrView(attributeInfo);\n },\n free: (...args) => {\n return module.ccall(\"free\", \"number\", [\"number\"], args);\n },\n malloc: (...args) => {\n return module.ccall(\"malloc\", \"number\", [\"number\"], args);\n },\n parseDropFile: (bufferPtr, bufferSize) => {\n return module.parseDropFile(bufferPtr, bufferSize);\n },\n getAttributeFromDropFile: (handle, attributeName, attributeInfo) => {\n return module.getAttributeFromDropFile(handle, attributeName, attributeInfo);\n },\n takeAttributeFromDropFile: (handle, attributeName, clientSideId) => {\n return module.takeAttributeFromDropFile(handle, attributeName, clientSideId);\n },\n flattenDropFile: (handle, outPtr, outSize) => {\n return module.flattenDropFile(handle, outPtr, outSize);\n },\n destroyDropFileHandle: (handle) => {\n return module.destroyDropFileHandle(handle);\n }\n};\ndefineActions({\n async cancel(requestIdLow, requestIdHigh) {\n const key = `${requestIdHigh}-${requestIdLow}`;\n const controller = controllers.get(key);\n if (controller) {\n controller.abort();\n controllers.delete(key);\n }\n return [{ cancelled: !!controller }];\n },\n async heapSnapshot(topN) {\n if (typeof module.TakeHeapSnapshot !== \"function\") return [{ snapshotJson: null }];\n return [{ snapshotJson: module.TakeHeapSnapshot(topN) }];\n },\n async heapTrackingControl(enabled) {\n if (typeof module.SetHeapTrackingEnabled !== \"function\") return [{ success: false }];\n module.SetHeapTrackingEnabled(enabled);\n return [{ success: true }];\n },\n async heapTrackingReset() {\n if (typeof module.ResetHeapTracking !== \"function\") return [{ success: false }];\n module.ResetHeapTracking();\n return [{ success: true }];\n },\n async decode(requestIdLow, requestIdHigh, descriptorBuffer, contextPtr, consecutiveIdsStart, noJwt) {\n const key = `${requestIdHigh}-${requestIdLow}`;\n const controller = new AbortController();\n controllers.set(key, controller);\n try {\n const { free, malloc, parseDropFile, getAttributeFromDropFile, takeAttributeFromDropFile, flattenDropFile, destroyDropFileHandle } = decoder;\n const descriptorSize = descriptorBuffer.byteLength;\n const descriptorPointer = malloc(descriptorSize);\n decoder.heapU8.set(new Uint8Array(descriptorBuffer), descriptorPointer);\n const descriptor = module.SceneRequestDescriptor.deserializeFromBinary(descriptorPointer, descriptorSize);\n free(descriptorPointer);\n let url = descriptor.getUrl();\n if (noJwt) {\n const url_class = new URL(url);\n url_class.searchParams.delete(\"jwt\");\n url = url_class.toString();\n }\n const body = descriptor.getBody() || null;\n const method = body ? \"POST\" : \"GET\";\n const headers = descriptor.getHeaders();\n descriptor.delete();\n const startTime = performance.now();\n const response = await fetch(url, {\n method,\n headers,\n body,\n signal: controller.signal\n });\n const responseHeadersJson = JSON.stringify({ \"x-cache\": response.headers.get(\"x-cache\") ?? \"\" });\n if (!response.ok) {\n const duration = performance.now() - startTime;\n return [{\n requestIdLow,\n requestIdHigh,\n resultBuffer: /* @__PURE__ */ new ArrayBuffer(0),\n success: false,\n parsed: false,\n error: `HTTP error! status: ${response.status}`,\n dataType: module.WorkerDataType.Raw.value,\n contextPtr,\n attributes: [],\n duration,\n ttfb: duration,\n httpStatus: response.status,\n responseHeadersJson\n }, { transfer: [] }];\n }\n const rtt = performance.now() - startTime;\n const responseBuffer = await response.arrayBuffer();\n const duration = performance.now() - startTime;\n const attributes = [];\n if (!url.split(/[?#]/, 1)[0].endsWith(\".drop\")) return [{\n requestIdLow,\n requestIdHigh,\n resultBuffer: responseBuffer,\n success: true,\n parsed: false,\n error: void 0,\n dataType: module.WorkerDataType.Raw.value,\n contextPtr,\n attributes,\n duration,\n ttfb: rtt,\n httpStatus: response.status,\n responseHeadersJson\n }, { transfer: [responseBuffer] }];\n const responseSize = responseBuffer.byteLength;\n const responsePointer = malloc(responseSize);\n decoder.heapU8.set(new Uint8Array(responseBuffer), responsePointer);\n const outputPointerPointer = malloc(4);\n const outputSizePointer = malloc(4);\n decoder.heapU32[outputPointerPointer / 4] = 0;\n decoder.heapU32[outputSizePointer / 4] = 0;\n let handle = 0;\n let outputPointer = 0;\n const attributeInfo = new decoder.AttributeInfo();\n try {\n handle = parseDropFile(responsePointer, responseSize);\n if (handle === 0) throw new Error(\"parseDropFile failed\");\n let index = consecutiveIdsStart;\n for (const [name, info] of Object.entries(sparkAttributeList)) {\n if (info.discard) takeAttributeFromDropFile(handle, name, index);\n else if (getAttributeFromDropFile(handle, name, attributeInfo) === decoder.AquaStatus.Success) {\n const wasmView = decoder.dataPtrView(attributeInfo);\n const splatData = sparkAttributeFromRaw(name, index, wasmView);\n if (takeAttributeFromDropFile(handle, name, index) === decoder.AquaStatus.Success) attributes.push(splatData);\n }\n index++;\n }\n if (flattenDropFile(handle, outputPointerPointer, outputSizePointer) !== decoder.AquaStatus.Success) throw new Error(\"flattenDropFile failed\");\n outputPointer = decoder.heapU32[outputPointerPointer / 4];\n const outputSize = decoder.heapU32[outputSizePointer / 4];\n if (outputPointer === 0) throw new Error(\"flattenDropFile gave nullptr\");\n const resultBuffer = decoder.heapU8.buffer.slice(outputPointer, outputPointer + outputSize);\n const transferList = attributes.map((attr) => attr.paddedData.buffer);\n return [{\n requestIdLow,\n requestIdHigh,\n resultBuffer,\n success: true,\n parsed: true,\n error: void 0,\n dataType: module.WorkerDataType.Drop.value,\n contextPtr,\n attributes,\n duration,\n ttfb: rtt,\n httpStatus: response.status,\n responseHeadersJson\n }, { transfer: [resultBuffer, ...transferList] }];\n } catch (error) {\n console.error(\"Exception when parsing dropfile\", error);\n const errorMessage = error instanceof Error ? error.stack ?? error.message : String(error);\n const resultBuffer = (/* @__PURE__ */ new Uint8Array()).buffer;\n return [{\n requestIdLow,\n requestIdHigh,\n resultBuffer,\n success: false,\n parsed: false,\n error: errorMessage,\n dataType: module.WorkerDataType.Drop.value,\n contextPtr,\n attributes: void 0,\n duration,\n ttfb: rtt,\n httpStatus: response.status,\n responseHeadersJson\n }, { transfer: [resultBuffer] }];\n } finally {\n destroyDropFileHandle(handle);\n free(responsePointer);\n free(outputPointerPointer);\n free(outputSizePointer);\n if (outputPointer !== 0) free(outputPointer);\n attributeInfo.delete();\n }\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n const isCancelled = error instanceof Error && error.name === \"AbortError\";\n return [{\n requestIdLow,\n requestIdHigh,\n resultBuffer: /* @__PURE__ */ new ArrayBuffer(0),\n success: false,\n parsed: false,\n error: isCancelled ? \"Cancelled\" : errorMsg,\n dataType: module.WorkerDataType.Raw.value,\n contextPtr,\n attributes: [],\n duration: 0,\n ttfb: 0,\n httpStatus: 0,\n responseHeadersJson: \"{}\"\n }, { transfer: [] }];\n } finally {\n controllers.delete(key);\n }\n }\n});\n//#endregion\n";
|
|
610
|
+
var blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
611
|
+
function WorkerWrapper(options) {
|
|
612
|
+
let objURL;
|
|
613
|
+
try {
|
|
614
|
+
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
|
|
615
|
+
if (!objURL) throw "";
|
|
616
|
+
const worker = new Worker(objURL, {
|
|
617
|
+
type: "module",
|
|
618
|
+
name: options?.name
|
|
619
|
+
});
|
|
620
|
+
worker.addEventListener("error", () => {
|
|
621
|
+
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
622
|
+
});
|
|
623
|
+
return worker;
|
|
624
|
+
} catch (e) {
|
|
625
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent), {
|
|
626
|
+
type: "module",
|
|
627
|
+
name: options?.name
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region packages/core/engine/threads/decoder/wasmFetch.ts
|
|
633
|
+
var createSharedWasmFetch = (url) => {
|
|
634
|
+
let cached;
|
|
635
|
+
return async () => {
|
|
636
|
+
cached ??= fetch(url).then((response) => {
|
|
637
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} fetching ${url}`);
|
|
638
|
+
return response.arrayBuffer();
|
|
639
|
+
});
|
|
640
|
+
try {
|
|
641
|
+
return (await cached).slice(0);
|
|
642
|
+
} catch (error) {
|
|
643
|
+
cached = void 0;
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
var fetchParserWasm = createSharedWasmFetch(((u) => u.includes("/.vite/") ? u.replace(/\.vite\/[^?#]*/, () => "@miris-inc/core/dist/aqua-parser.wasm") : u)(new URL("aqua-parser.wasm", import.meta.url).href));
|
|
649
|
+
var Decoder = class extends Thread {
|
|
650
|
+
static name = "decoder";
|
|
651
|
+
static Worker = WorkerWrapper;
|
|
652
|
+
constructor(init) {
|
|
653
|
+
super(init);
|
|
654
|
+
this.#sendParserWasm();
|
|
655
|
+
}
|
|
656
|
+
async #sendParserWasm() {
|
|
657
|
+
try {
|
|
658
|
+
const wasmBinary = await fetchParserWasm();
|
|
659
|
+
this._postToWorker({
|
|
660
|
+
type: "wasm-init",
|
|
661
|
+
wasmBinary
|
|
662
|
+
}, [wasmBinary]);
|
|
663
|
+
} catch (e) {
|
|
664
|
+
console.error("Failed to load aqua-parser.wasm for decoder worker", e);
|
|
665
|
+
this._postToWorker({ type: "wasm-init" });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
get AttributeInfo() {
|
|
669
|
+
return this.module.AttributeInfo;
|
|
670
|
+
}
|
|
671
|
+
async heapSnapshot(topN) {
|
|
672
|
+
return this._execute("heapSnapshot", topN);
|
|
673
|
+
}
|
|
674
|
+
async heapTrackingControl(enabled) {
|
|
675
|
+
return this._execute("heapTrackingControl", enabled);
|
|
676
|
+
}
|
|
677
|
+
async heapTrackingReset() {
|
|
678
|
+
return this._execute("heapTrackingReset");
|
|
679
|
+
}
|
|
680
|
+
async cancel(requestIdLow, requestIdHigh) {
|
|
681
|
+
await this.ready;
|
|
682
|
+
this._execute("cancel", requestIdLow, requestIdHigh).catch(() => {});
|
|
683
|
+
}
|
|
684
|
+
async decode(...args) {
|
|
685
|
+
const { requestIdLow, requestIdHigh, resultBuffer, success, dataType, contextPtr, attributes, duration, ttfb, httpStatus, responseHeadersJson } = await this._execute("decode", ...args);
|
|
686
|
+
if (attributes !== void 0) for (const { paddedData, originalSize, id } of attributes) AttributeCache.addWithId({
|
|
687
|
+
paddedData,
|
|
688
|
+
originalSize
|
|
689
|
+
}, id);
|
|
690
|
+
const { engine } = this;
|
|
691
|
+
const bufferSize = resultBuffer.byteLength;
|
|
692
|
+
const bufferPointer = engine.malloc(bufferSize);
|
|
693
|
+
engine.heapU8.set(new Uint8Array(resultBuffer), bufferPointer);
|
|
694
|
+
engine.onWorkerResult(requestIdLow, requestIdHigh, bufferPointer, bufferSize, httpStatus, duration, ttfb, success, dataType, "", responseHeadersJson, contextPtr);
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region packages/core/attribute.ts
|
|
699
|
+
var sparkMinSplats = 2048;
|
|
700
|
+
var sparkAttributeList = {
|
|
701
|
+
sparkPackedSplat: {
|
|
702
|
+
elementsPerSplat: 4,
|
|
703
|
+
discard: false
|
|
704
|
+
},
|
|
705
|
+
extendedPackedSplatLow: {
|
|
706
|
+
elementsPerSplat: 4,
|
|
707
|
+
discard: false
|
|
708
|
+
},
|
|
709
|
+
extendedPackedSplatHigh: {
|
|
710
|
+
elementsPerSplat: 4,
|
|
711
|
+
discard: false
|
|
712
|
+
},
|
|
713
|
+
packedSh1: {
|
|
714
|
+
elementsPerSplat: 2,
|
|
715
|
+
discard: false
|
|
716
|
+
},
|
|
717
|
+
packedSh2: {
|
|
718
|
+
elementsPerSplat: 4,
|
|
719
|
+
discard: false
|
|
720
|
+
},
|
|
721
|
+
packedSh3: {
|
|
722
|
+
elementsPerSplat: 4,
|
|
723
|
+
discard: false
|
|
724
|
+
},
|
|
725
|
+
sh1Extended: {
|
|
726
|
+
elementsPerSplat: 4,
|
|
727
|
+
discard: false
|
|
728
|
+
},
|
|
729
|
+
sh2Extended: {
|
|
730
|
+
elementsPerSplat: 4,
|
|
731
|
+
discard: false
|
|
732
|
+
},
|
|
733
|
+
sh3Extended_0: {
|
|
734
|
+
elementsPerSplat: 4,
|
|
735
|
+
discard: false
|
|
736
|
+
},
|
|
737
|
+
sh3Extended_1: {
|
|
738
|
+
elementsPerSplat: 4,
|
|
739
|
+
discard: false
|
|
740
|
+
},
|
|
741
|
+
splatterEllipsoids: {
|
|
742
|
+
elementsPerSplat: 12,
|
|
743
|
+
discard: false
|
|
744
|
+
},
|
|
745
|
+
splatterSphericalHarmonics: {
|
|
746
|
+
elementsPerSplat: 16,
|
|
747
|
+
discard: false
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
function roundUpToMultipleOf(a, multiple) {
|
|
751
|
+
return Math.ceil(a / multiple) * multiple;
|
|
752
|
+
}
|
|
753
|
+
function sparkAttributeFromRaw(name, id, wasmView) {
|
|
754
|
+
const attrib = sparkAttributeList[name];
|
|
755
|
+
if (attrib === void 0) throw new Error("attribute name" + name + " is unknown");
|
|
756
|
+
const originalSize = wasmView.length;
|
|
757
|
+
const paddedSize = roundUpToMultipleOf(originalSize, attrib.elementsPerSplat * sparkMinSplats);
|
|
758
|
+
const paddedData = new Uint32Array(paddedSize);
|
|
759
|
+
paddedData.set(wasmView);
|
|
760
|
+
return {
|
|
761
|
+
paddedData,
|
|
762
|
+
originalSize,
|
|
763
|
+
id
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
var AttributeNames = class {
|
|
767
|
+
static SPARK_PACKED_SPLAT = "sparkPackedSplat";
|
|
768
|
+
static SPARK_EXTENDED_SPLAT_LOW = "extendedPackedSplatLow";
|
|
769
|
+
static SPARK_EXTENDED_SPLAT_HIGH = "extendedPackedSplatHigh";
|
|
770
|
+
static SPARK_PACKED_SH1 = "packedSh1";
|
|
771
|
+
static SPARK_PACKED_SH2 = "packedSh2";
|
|
772
|
+
static SPARK_PACKED_SH3 = "packedSh3";
|
|
773
|
+
static SPARK_EXTENDED_SH1 = "sh1Extended";
|
|
774
|
+
static SPARK_EXTENDED_SH2 = "sh2Extended";
|
|
775
|
+
static SPARK_EXTENDED_SH3_A = "sh3Extended_0";
|
|
776
|
+
static SPARK_EXTENDED_SH3_B = "sh3Extended_1";
|
|
777
|
+
static UNUSED = "unused";
|
|
778
|
+
static SPLATTER_ELLIPSOIDS = "splatterEllipsoids";
|
|
779
|
+
static SPLATTER_SPHERICAL_HARMONICS = "splatterSphericalHarmonics";
|
|
780
|
+
};
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region packages/core/engine/index.ts
|
|
783
|
+
/**
|
|
784
|
+
* The main Aqua wrapper.
|
|
785
|
+
*
|
|
786
|
+
* @remarks
|
|
787
|
+
* The engine is asynchronously initialized, meaning synchronous operations may
|
|
788
|
+
* fail if is not ready. To ensure the engine is ready, await `engine.ready`
|
|
789
|
+
* or check `engine.pending`.
|
|
790
|
+
*/
|
|
791
|
+
var Engine = class Engine {
|
|
792
|
+
static AquaStatus = {
|
|
793
|
+
Success: 0,
|
|
794
|
+
Failure: 1
|
|
795
|
+
};
|
|
796
|
+
static SceneObjectType = {
|
|
797
|
+
ModelRoot: 0,
|
|
798
|
+
SceneObject: 1,
|
|
799
|
+
StreamObject: 2,
|
|
800
|
+
GaussianSplats: 3,
|
|
801
|
+
PointsObject: 4,
|
|
802
|
+
Camera: 5,
|
|
803
|
+
LodOctree: 6,
|
|
804
|
+
VariantSetCollection: 7,
|
|
805
|
+
VariantSet: 8,
|
|
806
|
+
VariantSetOption: 9
|
|
807
|
+
};
|
|
808
|
+
static Feature = {
|
|
809
|
+
DrMap: 0,
|
|
810
|
+
ReflMesh: 1,
|
|
811
|
+
GlassMesh: 2
|
|
812
|
+
};
|
|
813
|
+
static FeatureState = {
|
|
814
|
+
NotLoaded: 0,
|
|
815
|
+
Pending: 1,
|
|
816
|
+
Loaded: 2,
|
|
817
|
+
Failed: 3
|
|
818
|
+
};
|
|
819
|
+
#module;
|
|
820
|
+
get module() {
|
|
821
|
+
if (!this.#module) throw new Error("Engine has not yet been initialized. Did you forget to `await engine.ready()?`");
|
|
822
|
+
return this.#module;
|
|
823
|
+
}
|
|
824
|
+
#decoders = /* @__PURE__ */ new Set();
|
|
825
|
+
#requestMap = /* @__PURE__ */ new Map();
|
|
826
|
+
#noJwt = new URL(location.href).searchParams.has("nojwt");
|
|
827
|
+
constructor(moduleOptions = {}) {
|
|
828
|
+
Object.defineProperty(this, "pending", {
|
|
829
|
+
value: true,
|
|
830
|
+
configurable: true,
|
|
831
|
+
enumerable: true
|
|
832
|
+
});
|
|
833
|
+
Object.defineProperty(this, "ready", {
|
|
834
|
+
enumerable: true,
|
|
835
|
+
value: this.#initialize(moduleOptions)
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
async #initialize(moduleOptions) {
|
|
839
|
+
this.#module = await factory_default({
|
|
840
|
+
createDeserializeWorker: this.createDeserializeWorker.bind(this),
|
|
841
|
+
submitToWorker: this.submitToWorker.bind(this),
|
|
842
|
+
cancelRequest: this.cancelRequest.bind(this),
|
|
843
|
+
terminateWorker: this.terminateWorker.bind(this),
|
|
844
|
+
workerUrl: "aqua-parser",
|
|
845
|
+
...moduleOptions,
|
|
846
|
+
preRun: [(mod) => Object.assign(mod.ENV, Engine.#env())]
|
|
847
|
+
});
|
|
848
|
+
Object.defineProperty(this, "pending", {
|
|
849
|
+
value: false,
|
|
850
|
+
configurable: false
|
|
851
|
+
});
|
|
852
|
+
return this;
|
|
853
|
+
}
|
|
854
|
+
get AttributeInfo() {
|
|
855
|
+
return this.module.AttributeInfo;
|
|
856
|
+
}
|
|
857
|
+
get Handedness() {
|
|
858
|
+
return this.module.Handedness;
|
|
859
|
+
}
|
|
860
|
+
get heapF32() {
|
|
861
|
+
return this.module.HEAPF32;
|
|
862
|
+
}
|
|
863
|
+
get heapU8() {
|
|
864
|
+
return this.module.HEAPU8;
|
|
865
|
+
}
|
|
866
|
+
get MatrixOrder() {
|
|
867
|
+
return this.module.MatrixOrder;
|
|
868
|
+
}
|
|
869
|
+
get SceneChangeIds() {
|
|
870
|
+
return this.module.SceneChangeIds;
|
|
871
|
+
}
|
|
872
|
+
get SceneMetadata() {
|
|
873
|
+
return this.module.SceneMetadata;
|
|
874
|
+
}
|
|
875
|
+
get RuntimeSettings() {
|
|
876
|
+
return this.module.RuntimeSettings;
|
|
877
|
+
}
|
|
878
|
+
get SpatialFormat() {
|
|
879
|
+
return this.module.SpatialFormat;
|
|
880
|
+
}
|
|
881
|
+
get StringVector() {
|
|
882
|
+
return this.module.StringVector;
|
|
883
|
+
}
|
|
884
|
+
get UpAxis() {
|
|
885
|
+
return this.module.UpAxis;
|
|
886
|
+
}
|
|
887
|
+
activatedObjectIdsView(...args) {
|
|
888
|
+
return this.module.activatedObjectIdsView(...args);
|
|
889
|
+
}
|
|
890
|
+
addStreamById(...args) {
|
|
891
|
+
return this.module.ccall("AddStreamById", "number", [
|
|
892
|
+
"number",
|
|
893
|
+
"string",
|
|
894
|
+
"string",
|
|
895
|
+
"number"
|
|
896
|
+
], args);
|
|
897
|
+
}
|
|
898
|
+
allocateSceneChangesArrays(...args) {
|
|
899
|
+
return this.module.AllocateSceneChangesArrays(...args);
|
|
900
|
+
}
|
|
901
|
+
createContext(...args) {
|
|
902
|
+
return this.module.ccall("CreateAquaContext", "number", [], args);
|
|
903
|
+
}
|
|
904
|
+
destroyContext(...args) {
|
|
905
|
+
return this.module.ccall("DestroyAquaContext", "number", ["number"], args);
|
|
906
|
+
}
|
|
907
|
+
createClient(context, ...args) {
|
|
908
|
+
if (context) return this.module.ccall("CreateClientForContext", "number", ["number"], [context, ...args]);
|
|
909
|
+
return this.module.ccall("CreateClient", "number", [], args);
|
|
910
|
+
}
|
|
911
|
+
createdObjectIdsView(...args) {
|
|
912
|
+
return this.module.createdObjectIdsView(...args);
|
|
913
|
+
}
|
|
914
|
+
deletedObjectIdsView(...args) {
|
|
915
|
+
return this.module.deletedObjectIdsView(...args);
|
|
916
|
+
}
|
|
917
|
+
dataPtrView(...args) {
|
|
918
|
+
return this.module.dataPtrView(...args);
|
|
919
|
+
}
|
|
920
|
+
deactivatedObjectIdsView(...args) {
|
|
921
|
+
return this.module.deactivatedObjectIdsView(...args);
|
|
922
|
+
}
|
|
923
|
+
destroyClient(...args) {
|
|
924
|
+
return this.module.ccall("DestroyClient", "number", ["number"], args);
|
|
925
|
+
}
|
|
926
|
+
free(...args) {
|
|
927
|
+
return this.module.ccall("free", "number", ["number"], args);
|
|
928
|
+
}
|
|
929
|
+
getAssetsAsync(...args) {
|
|
930
|
+
return this.module.GetAssetsAsync(...args);
|
|
931
|
+
}
|
|
932
|
+
getAttribute(...args) {
|
|
933
|
+
return this.module.ccall("GetAttribute", "number", [
|
|
934
|
+
"number",
|
|
935
|
+
"number",
|
|
936
|
+
"string",
|
|
937
|
+
"number"
|
|
938
|
+
], args);
|
|
939
|
+
}
|
|
940
|
+
getDefaultCameraId(...args) {
|
|
941
|
+
return this.module.ccall("GetDefaultCameraId", "number", ["number"], args);
|
|
942
|
+
}
|
|
943
|
+
getViewingVolumeId(...args) {
|
|
944
|
+
return this.module.ccall("GetViewingVolumeId", "number", ["number"], args);
|
|
945
|
+
}
|
|
946
|
+
getLocalBoundingBox(...args) {
|
|
947
|
+
return this.module.ccall("GetLocalBoundingBox", "number", [
|
|
948
|
+
"number",
|
|
949
|
+
"number",
|
|
950
|
+
"number"
|
|
951
|
+
], args);
|
|
952
|
+
}
|
|
953
|
+
getWorldBoundingBox(...args) {
|
|
954
|
+
return this.module.ccall("GetWorldBoundingBox", "number", [
|
|
955
|
+
"number",
|
|
956
|
+
"number",
|
|
957
|
+
"number"
|
|
958
|
+
], args);
|
|
959
|
+
}
|
|
960
|
+
getLodIndex(...args) {
|
|
961
|
+
return this.module.ccall("GetLodIndex", "number", ["number", "number"], args);
|
|
962
|
+
}
|
|
963
|
+
getSceneChanges(...args) {
|
|
964
|
+
return this.module.GetSceneChanges(...args);
|
|
965
|
+
}
|
|
966
|
+
getSceneChangesCounts(...args) {
|
|
967
|
+
return this.module.GetSceneChangesCounts(...args);
|
|
968
|
+
}
|
|
969
|
+
getSceneMetadata(...args) {
|
|
970
|
+
return this.module.GetSceneMetadata(...args).value;
|
|
971
|
+
}
|
|
972
|
+
getSceneObjectParent(...args) {
|
|
973
|
+
return this.module.ccall("GetSceneObjectParent", "number", ["number", "number"], args);
|
|
974
|
+
}
|
|
975
|
+
getSceneObjectType(...args) {
|
|
976
|
+
return this.module.ccall("GetSceneObjectType", "number", ["number", "number"], args);
|
|
977
|
+
}
|
|
978
|
+
getLocalTransform(...args) {
|
|
979
|
+
return this.module.ccall("MirisGetLocalTransform", "number", [
|
|
980
|
+
"number",
|
|
981
|
+
"number",
|
|
982
|
+
"number"
|
|
983
|
+
], args);
|
|
984
|
+
}
|
|
985
|
+
getWorldTransform(...args) {
|
|
986
|
+
return this.module.ccall("MirisGetWorldTransform", "number", [
|
|
987
|
+
"number",
|
|
988
|
+
"number",
|
|
989
|
+
"number"
|
|
990
|
+
], args);
|
|
991
|
+
}
|
|
992
|
+
hasAttribute(...args) {
|
|
993
|
+
return this.module.ccall("HasAttribute", "boolean", [
|
|
994
|
+
"number",
|
|
995
|
+
"number",
|
|
996
|
+
"string"
|
|
997
|
+
], args);
|
|
998
|
+
}
|
|
999
|
+
isSceneObjectAncestorOf(...args) {
|
|
1000
|
+
return this.module.ccall("IsSceneObjectAncestorOf", "boolean", [
|
|
1001
|
+
"number",
|
|
1002
|
+
"number",
|
|
1003
|
+
"number"
|
|
1004
|
+
], args);
|
|
1005
|
+
}
|
|
1006
|
+
lockScene(...args) {
|
|
1007
|
+
return this.module.ccall("LockScene", "number", ["number"], args);
|
|
1008
|
+
}
|
|
1009
|
+
malloc(...args) {
|
|
1010
|
+
return this.module.ccall("malloc", "number", ["number"], args);
|
|
1011
|
+
}
|
|
1012
|
+
modifiedObjectIdsView(...args) {
|
|
1013
|
+
return this.module.modifiedObjectIdsView(...args);
|
|
1014
|
+
}
|
|
1015
|
+
onWorkerResult(...args) {
|
|
1016
|
+
const requestKey = `${args[1]}-${args[0]}`;
|
|
1017
|
+
this.#requestMap.delete(requestKey);
|
|
1018
|
+
return this.module.ccall("onWorkerResult", null, [
|
|
1019
|
+
"number",
|
|
1020
|
+
"number",
|
|
1021
|
+
"number",
|
|
1022
|
+
"number",
|
|
1023
|
+
"number",
|
|
1024
|
+
"number",
|
|
1025
|
+
"number",
|
|
1026
|
+
"number",
|
|
1027
|
+
"number",
|
|
1028
|
+
"string",
|
|
1029
|
+
"string",
|
|
1030
|
+
"number"
|
|
1031
|
+
], args);
|
|
1032
|
+
}
|
|
1033
|
+
removeStream(...args) {
|
|
1034
|
+
return this.module.ccall("RemoveStream", "boolean", ["pointer", "number"], args);
|
|
1035
|
+
}
|
|
1036
|
+
setAssetViewerKey(...args) {
|
|
1037
|
+
return this.module.ccall("SetAssetViewerKey", "number", ["number", "string"], args);
|
|
1038
|
+
}
|
|
1039
|
+
setClientSpatialFormat(...args) {
|
|
1040
|
+
return this.module.SetClientSpatialFormat(...args).value;
|
|
1041
|
+
}
|
|
1042
|
+
setRuntimeSettings(...args) {
|
|
1043
|
+
return this.module.SetRuntimeSettings(...args).value;
|
|
1044
|
+
}
|
|
1045
|
+
setMainCameraTransform(...args) {
|
|
1046
|
+
return this.module.ccall("SetMainCameraTransform", "number", ["number", "number"], args);
|
|
1047
|
+
}
|
|
1048
|
+
setMainCameraViewFrustum(...args) {
|
|
1049
|
+
return this.module.ccall("SetMainCameraViewFrustum", "number", [
|
|
1050
|
+
"number",
|
|
1051
|
+
"number",
|
|
1052
|
+
"number",
|
|
1053
|
+
"number",
|
|
1054
|
+
"number"
|
|
1055
|
+
], args);
|
|
1056
|
+
}
|
|
1057
|
+
setMaxCacheSize(...args) {
|
|
1058
|
+
return this.module.setMaxCacheSize(...args);
|
|
1059
|
+
}
|
|
1060
|
+
setSceneObjectTransform(...args) {
|
|
1061
|
+
return this.module.ccall("SetSceneObjectTransform", "number", [
|
|
1062
|
+
"number",
|
|
1063
|
+
"number",
|
|
1064
|
+
"number"
|
|
1065
|
+
], args);
|
|
1066
|
+
}
|
|
1067
|
+
hasFeature(...args) {
|
|
1068
|
+
return this.module.HasFeature(...args);
|
|
1069
|
+
}
|
|
1070
|
+
getFeatureVersion(...args) {
|
|
1071
|
+
return this.module.GetFeatureVersion(...args);
|
|
1072
|
+
}
|
|
1073
|
+
getFeatureState(...args) {
|
|
1074
|
+
return this.module.GetFeatureState(...args);
|
|
1075
|
+
}
|
|
1076
|
+
getName(...args) {
|
|
1077
|
+
return this.module.GetName(...args);
|
|
1078
|
+
}
|
|
1079
|
+
setVariantSelection(...args) {
|
|
1080
|
+
return this.module.ccall("SetVariantSelection", "number", ["number", "number"], args);
|
|
1081
|
+
}
|
|
1082
|
+
takeAttribute(...args) {
|
|
1083
|
+
return this.module.ccall("TakeAttribute", "number", [
|
|
1084
|
+
"number",
|
|
1085
|
+
"number",
|
|
1086
|
+
"string",
|
|
1087
|
+
"bigint"
|
|
1088
|
+
], args);
|
|
1089
|
+
}
|
|
1090
|
+
takeEvictedClientSideAttributeIds(...args) {
|
|
1091
|
+
return this.module.TakeEvictedClientSideAttributeIds(...args);
|
|
1092
|
+
}
|
|
1093
|
+
getActiveClientSideIdsCheckSum() {
|
|
1094
|
+
return this.module.GetActiveClientSideIdsCheckSum();
|
|
1095
|
+
}
|
|
1096
|
+
unlockScene(...args) {
|
|
1097
|
+
return this.module.ccall("UnlockScene", "number", ["number"], args);
|
|
1098
|
+
}
|
|
1099
|
+
updateSceneExecution(...args) {
|
|
1100
|
+
return this.module.ccall("UpdateSceneExecution", "number", ["number"], args);
|
|
1101
|
+
}
|
|
1102
|
+
recordFrameTime(...args) {
|
|
1103
|
+
return this.module.ccall("RecordFrameTime", "number", ["number", "number"], args);
|
|
1104
|
+
}
|
|
1105
|
+
takeRenderRequired(...args) {
|
|
1106
|
+
return this.module.TakeRenderRequired(...args);
|
|
1107
|
+
}
|
|
1108
|
+
createDeserializeWorker(_url, _workerUrl, poolSize) {
|
|
1109
|
+
for (let index = 1; index < poolSize; index += 1) this.#decoders.add(new Decoder({ engine: this }));
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1112
|
+
cancelRequest(requestIdLow, requestIdHigh) {
|
|
1113
|
+
const requestKey = `${requestIdHigh}-${requestIdLow}`;
|
|
1114
|
+
const decoder = this.#requestMap.get(requestKey);
|
|
1115
|
+
if (decoder) {
|
|
1116
|
+
decoder.cancel(requestIdLow, requestIdHigh);
|
|
1117
|
+
this.#requestMap.delete(requestKey);
|
|
1118
|
+
}
|
|
1119
|
+
return true;
|
|
1120
|
+
}
|
|
1121
|
+
submitToWorker(requestIdLow, requestIdHigh, descriptorBuffer, contextPtr) {
|
|
1122
|
+
const decoder = [...this.#decoders.values()].reduce((previous, current) => {
|
|
1123
|
+
if (!previous) return current;
|
|
1124
|
+
return current.pendingRequests < previous.pendingRequests ? current : previous;
|
|
1125
|
+
});
|
|
1126
|
+
const requestKey = `${requestIdHigh}-${requestIdLow}`;
|
|
1127
|
+
this.#requestMap.set(requestKey, decoder);
|
|
1128
|
+
const firstId = AttributeCache.getConsecutiveIds(Object.keys(sparkAttributeList).length);
|
|
1129
|
+
decoder.ready.then(() => decoder.decode(requestIdLow, requestIdHigh, descriptorBuffer, contextPtr, firstId, this.#noJwt));
|
|
1130
|
+
return true;
|
|
1131
|
+
}
|
|
1132
|
+
terminateWorker() {
|
|
1133
|
+
for (const decoder of this.#decoders) decoder.terminate();
|
|
1134
|
+
this.#decoders.clear();
|
|
1135
|
+
}
|
|
1136
|
+
async requestWorkerHeapSnapshots(topN) {
|
|
1137
|
+
const decoders = [...this.#decoders];
|
|
1138
|
+
return (await Promise.allSettled(decoders.map((d) => d.ready.then(() => {
|
|
1139
|
+
let timer;
|
|
1140
|
+
const timeout = new Promise((resolve) => {
|
|
1141
|
+
timer = setTimeout(() => resolve(null), 5e3);
|
|
1142
|
+
});
|
|
1143
|
+
return Promise.race([d.heapSnapshot(topN).then((r) => r.snapshotJson), timeout]).finally(() => clearTimeout(timer));
|
|
1144
|
+
})))).map((r) => r.status === "fulfilled" ? r.value : null);
|
|
1145
|
+
}
|
|
1146
|
+
async setWorkerHeapTrackingEnabled(enabled) {
|
|
1147
|
+
await Promise.allSettled([...this.#decoders].map((d) => d.ready.then(() => d.heapTrackingControl(enabled))));
|
|
1148
|
+
}
|
|
1149
|
+
async resetWorkerHeapTracking() {
|
|
1150
|
+
await Promise.allSettled([...this.#decoders].map((d) => d.ready.then(() => d.heapTrackingReset())));
|
|
1151
|
+
}
|
|
1152
|
+
static #env() {
|
|
1153
|
+
return {
|
|
1154
|
+
AQUA_USE_SINGLETON_NETWORK_TRANSPORT: "true",
|
|
1155
|
+
AQUA_SERVER_BASE_URL: "https://app.miris.com/viewer/v1"
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region packages/core/rate.ts
|
|
1161
|
+
var RATES = [
|
|
1162
|
+
30,
|
|
1163
|
+
60,
|
|
1164
|
+
72,
|
|
1165
|
+
90,
|
|
1166
|
+
120,
|
|
1167
|
+
144,
|
|
1168
|
+
165,
|
|
1169
|
+
240
|
|
1170
|
+
];
|
|
1171
|
+
function createRefreshRateDetector() {
|
|
1172
|
+
let samples = [], last = null, hz = 0;
|
|
1173
|
+
screen.addEventListener?.("change", () => {
|
|
1174
|
+
samples = [];
|
|
1175
|
+
hz = 0;
|
|
1176
|
+
last = null;
|
|
1177
|
+
});
|
|
1178
|
+
return {
|
|
1179
|
+
update(ts) {
|
|
1180
|
+
if (hz) return;
|
|
1181
|
+
if (last !== null) {
|
|
1182
|
+
samples.push(ts - last);
|
|
1183
|
+
if (samples.length > 60) samples.shift();
|
|
1184
|
+
if (!hz && samples.length === 60) {
|
|
1185
|
+
const meanHz = 1e3 / (samples.reduce((a, b) => a + b, 0) / samples.length);
|
|
1186
|
+
hz = RATES.reduce((a, b) => Math.abs(b - meanHz) < Math.abs(a - meanHz) ? b : a);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
last = ts;
|
|
1190
|
+
},
|
|
1191
|
+
get nativeHz() {
|
|
1192
|
+
return hz;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region packages/core/miris.ts
|
|
1198
|
+
/**
|
|
1199
|
+
* The main Miris application.
|
|
1200
|
+
*
|
|
1201
|
+
* @remarks
|
|
1202
|
+
* This class is initialized asynchronously, so synchronous operations may
|
|
1203
|
+
* fail if Miris is not ready. To ensure Miris is ready, await `miris.ready`
|
|
1204
|
+
* or get `miris.pending`.
|
|
1205
|
+
*/
|
|
1206
|
+
var Miris = class {
|
|
1207
|
+
static _instance;
|
|
1208
|
+
static async instance() {
|
|
1209
|
+
const miris = this._instance ??= new this();
|
|
1210
|
+
await miris.ready;
|
|
1211
|
+
return miris;
|
|
1212
|
+
}
|
|
1213
|
+
#sharedContext;
|
|
1214
|
+
get sharedContext() {
|
|
1215
|
+
return this.#sharedContext;
|
|
1216
|
+
}
|
|
1217
|
+
#viewerKey;
|
|
1218
|
+
get viewerKey() {
|
|
1219
|
+
return this.#viewerKey;
|
|
1220
|
+
}
|
|
1221
|
+
set viewerKey(viewerKey) {
|
|
1222
|
+
this.#viewerKey = viewerKey;
|
|
1223
|
+
}
|
|
1224
|
+
#scenes = /* @__PURE__ */ new Set();
|
|
1225
|
+
get scenes() {
|
|
1226
|
+
return new Set(this.#scenes);
|
|
1227
|
+
}
|
|
1228
|
+
#changes = [];
|
|
1229
|
+
#changeIds = null;
|
|
1230
|
+
#pendingActivations = /* @__PURE__ */ new Set();
|
|
1231
|
+
#pendingDeactivations = /* @__PURE__ */ new Map();
|
|
1232
|
+
#useSphericalHarmonics = true;
|
|
1233
|
+
get useSphericalHarmonics() {
|
|
1234
|
+
return this.#useSphericalHarmonics;
|
|
1235
|
+
}
|
|
1236
|
+
set useSphericalHarmonics(value) {
|
|
1237
|
+
this.#useSphericalHarmonics = value;
|
|
1238
|
+
}
|
|
1239
|
+
constructor() {
|
|
1240
|
+
if (!this.constructor.prototype._instance) this.constructor.prototype._instance = this;
|
|
1241
|
+
Object.defineProperties(this, {
|
|
1242
|
+
pending: {
|
|
1243
|
+
value: true,
|
|
1244
|
+
configurable: true,
|
|
1245
|
+
enumerable: true
|
|
1246
|
+
},
|
|
1247
|
+
engine: {
|
|
1248
|
+
value: new Engine(),
|
|
1249
|
+
enumerable: true
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
Object.defineProperty(this, "ready", {
|
|
1253
|
+
enumerable: true,
|
|
1254
|
+
value: this.#initializeMiris()
|
|
1255
|
+
});
|
|
1256
|
+
console.assert?.(this._xrModeActive === false);
|
|
1257
|
+
this.#bindRequestAnimationFrame();
|
|
1258
|
+
}
|
|
1259
|
+
async #initializeMiris() {
|
|
1260
|
+
const { engine } = this;
|
|
1261
|
+
await engine.ready;
|
|
1262
|
+
this.#sharedContext = this.engine.createContext();
|
|
1263
|
+
const mb = 1048576;
|
|
1264
|
+
const maxCacheSizeParam = new URLSearchParams(window.location.search).get("aquaMaxCacheSize");
|
|
1265
|
+
let maxCacheSizeMB = 0;
|
|
1266
|
+
if (maxCacheSizeParam) {
|
|
1267
|
+
const parsedSize = parseInt(maxCacheSizeParam, 10);
|
|
1268
|
+
if (!isNaN(parsedSize) && parsedSize > 0) maxCacheSizeMB = parsedSize;
|
|
1269
|
+
}
|
|
1270
|
+
if (maxCacheSizeMB > 0) this.engine.setMaxCacheSize(maxCacheSizeMB * mb);
|
|
1271
|
+
else if (navigator.userAgent.includes("iPhone")) this.engine.setMaxCacheSize(128 * mb);
|
|
1272
|
+
else if (navigator.userAgent.includes("Android")) this.engine.setMaxCacheSize(256 * mb);
|
|
1273
|
+
this.#browserUpdate();
|
|
1274
|
+
Object.defineProperty(this, "pending", {
|
|
1275
|
+
value: false,
|
|
1276
|
+
configurable: false
|
|
1277
|
+
});
|
|
1278
|
+
return this;
|
|
1279
|
+
}
|
|
1280
|
+
dispose() {
|
|
1281
|
+
if (this.#sharedContext) {
|
|
1282
|
+
if (this.engine.destroyContext(this.#sharedContext) !== Engine.AquaStatus.Success) console.error(`Failed to destroy aqua context with handle '${this.#sharedContext}'`);
|
|
1283
|
+
this.#sharedContext = 0;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
updateParentedTransform(_modelTransform, _parentTransform) {}
|
|
1287
|
+
#detector = createRefreshRateDetector();
|
|
1288
|
+
#boundUpdate = this.#browserUpdate.bind(this);
|
|
1289
|
+
#hostDriven = false;
|
|
1290
|
+
#lastFrameTimestamp = null;
|
|
1291
|
+
#lastUpdateTs = -1;
|
|
1292
|
+
#targetFramesPerSecond = 72;
|
|
1293
|
+
#splatCountBudgetOverride = null;
|
|
1294
|
+
_xrModeActive = false;
|
|
1295
|
+
_xrSession = null;
|
|
1296
|
+
_requestAnimationFrame = null;
|
|
1297
|
+
signalResumeFromIdle() {}
|
|
1298
|
+
#applyDisplaySettings() {
|
|
1299
|
+
const settings = new this.engine.RuntimeSettings();
|
|
1300
|
+
settings.targetFramesPerSecond = this.#targetFramesPerSecond;
|
|
1301
|
+
settings.xrModeActive = this._xrModeActive;
|
|
1302
|
+
if (this.#splatCountBudgetOverride !== null) settings.splatCountBudget = this.#splatCountBudgetOverride;
|
|
1303
|
+
else if (this._xrModeActive) settings.splatCountBudget = 2e5;
|
|
1304
|
+
for (const scene of this.#scenes) scene.client.setRuntimeSettings(settings);
|
|
1305
|
+
settings.delete();
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Why 43? Because the AVP throttles down to 45Hz :(
|
|
1309
|
+
*/
|
|
1310
|
+
static _XR_TARGET_FRAME_RATE = 43;
|
|
1311
|
+
#bindRequestAnimationFrame() {
|
|
1312
|
+
this._requestAnimationFrame = this._xrModeActive ? this._xrSession.requestAnimationFrame.bind(this._xrSession) : window.requestAnimationFrame.bind(window);
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* @internal
|
|
1316
|
+
*/
|
|
1317
|
+
_setTargetFrameRate(frameRate) {
|
|
1318
|
+
this.#targetFramesPerSecond = frameRate;
|
|
1319
|
+
this.#detector = null;
|
|
1320
|
+
this.#applyDisplaySettings();
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* @internal
|
|
1324
|
+
*/
|
|
1325
|
+
_setXRModeActive(active, frameRate, xrSession) {
|
|
1326
|
+
this._xrModeActive = active;
|
|
1327
|
+
this._xrSession = xrSession ?? null;
|
|
1328
|
+
if (frameRate !== void 0) this.#targetFramesPerSecond = frameRate;
|
|
1329
|
+
this.#applyDisplaySettings();
|
|
1330
|
+
this.#bindRequestAnimationFrame();
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* @internal
|
|
1334
|
+
*/
|
|
1335
|
+
_setSplatCountBudgetOverride(budget) {
|
|
1336
|
+
this.#splatCountBudgetOverride = budget;
|
|
1337
|
+
this.#applyDisplaySettings();
|
|
1338
|
+
}
|
|
1339
|
+
#browserUpdate(ts = 0) {
|
|
1340
|
+
if (this.#hostDriven) return;
|
|
1341
|
+
this._update(ts);
|
|
1342
|
+
if (this._xrModeActive) return;
|
|
1343
|
+
requestAnimationFrame(this.#boundUpdate);
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* @internal
|
|
1347
|
+
*
|
|
1348
|
+
* Shared update function being driven by browser's update loop or an XR session
|
|
1349
|
+
*/
|
|
1350
|
+
_update(ts = 0) {
|
|
1351
|
+
if (ts !== 0 && ts === this.#lastUpdateTs) return;
|
|
1352
|
+
this.#lastUpdateTs = ts;
|
|
1353
|
+
if (this.#detector) {
|
|
1354
|
+
this.#detector.update(performance.now());
|
|
1355
|
+
if (this.#detector.nativeHz > 0) {
|
|
1356
|
+
const hz = this.#detector.nativeHz;
|
|
1357
|
+
this.#targetFramesPerSecond = hz <= 40 ? hz : 40;
|
|
1358
|
+
this.#applyDisplaySettings();
|
|
1359
|
+
this.#detector = null;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
const now = performance.now();
|
|
1363
|
+
const elapsed = this.#lastFrameTimestamp === null ? null : now - this.#lastFrameTimestamp;
|
|
1364
|
+
this.#lastFrameTimestamp = now;
|
|
1365
|
+
const frameTimeMs = elapsed !== null && elapsed <= 1e3 ? elapsed : null;
|
|
1366
|
+
for (const scene of this.#scenes) {
|
|
1367
|
+
const { client } = scene;
|
|
1368
|
+
if (frameTimeMs !== null) client.recordFrameTime(frameTimeMs);
|
|
1369
|
+
client.updateSceneExecution();
|
|
1370
|
+
const evicted = client.takeEvictedClientSideAttributeIds();
|
|
1371
|
+
try {
|
|
1372
|
+
const evictedSize = evicted.size();
|
|
1373
|
+
if (evictedSize > 0) {
|
|
1374
|
+
const evictedArray = [];
|
|
1375
|
+
for (let i = 0; i < evictedSize; i++) evictedArray.push(Number(evicted.get(i)));
|
|
1376
|
+
AttributeCache.remove(evictedArray);
|
|
1377
|
+
}
|
|
1378
|
+
} finally {
|
|
1379
|
+
evicted.delete();
|
|
1380
|
+
}
|
|
1381
|
+
const checkSumWasm = this.engine.getActiveClientSideIdsCheckSum();
|
|
1382
|
+
AttributeCache.validateCheckSum(checkSumWasm);
|
|
1383
|
+
if (!client.lockScene()) return;
|
|
1384
|
+
try {
|
|
1385
|
+
this.#updateScene(scene);
|
|
1386
|
+
} finally {
|
|
1387
|
+
client.unlockScene();
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
if (this.#changes.length) {
|
|
1391
|
+
this.applyChanges(this.#changes);
|
|
1392
|
+
this.#changes.length = 0;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
#retrieveFloatArray(objectId, arraySize, fn) {
|
|
1396
|
+
const arrayPtr = this.engine.malloc(arraySize * 4);
|
|
1397
|
+
fn(objectId, arrayPtr);
|
|
1398
|
+
const floatArray = this.engine.heapF32.subarray(arrayPtr >> 2, (arrayPtr >> 2) + arraySize).slice();
|
|
1399
|
+
this.engine.free(arrayPtr);
|
|
1400
|
+
return floatArray;
|
|
1401
|
+
}
|
|
1402
|
+
getLocalTransform(client, sceneObjectId) {
|
|
1403
|
+
if (Number.isInteger(sceneObjectId) && sceneObjectId >= 0) return this.#retrieveFloatArray(sceneObjectId, 16, client.getLocalTransform.bind(client));
|
|
1404
|
+
}
|
|
1405
|
+
getWorldTransform(client, sceneObjectId) {
|
|
1406
|
+
if (Number.isInteger(sceneObjectId) && sceneObjectId >= 0) return this.#retrieveFloatArray(sceneObjectId, 16, client.getWorldTransform.bind(client));
|
|
1407
|
+
}
|
|
1408
|
+
#shouldUpdateSceneChanges() {
|
|
1409
|
+
if (!this.#changeIds) return false;
|
|
1410
|
+
if (this.#changeIds.createdObjectsCount > 0) return true;
|
|
1411
|
+
if (this.#changeIds.activatedObjectsCount > 0) return true;
|
|
1412
|
+
if (this.#changeIds.deactivatedObjectsCount > 0) return true;
|
|
1413
|
+
if (this.#changeIds.modifiedObjectsCount > 0) return true;
|
|
1414
|
+
if (this.#changeIds.deletedObjectsCount > 0) return true;
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
#getDataFromAttribute(client, sceneObjectId, attributeName, outAttributeInfo) {
|
|
1418
|
+
const { engine } = this;
|
|
1419
|
+
if (!client.hasAttribute(sceneObjectId, attributeName)) return null;
|
|
1420
|
+
const { ptr } = outAttributeInfo.$$;
|
|
1421
|
+
const status = client.getAttribute(sceneObjectId, attributeName, ptr);
|
|
1422
|
+
if (status !== Engine.AquaStatus.Success) {
|
|
1423
|
+
console.warn(`GetAttribute failed for object id ${sceneObjectId} and attribute name ${attributeName}: status ${status}`);
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
let paddedData;
|
|
1427
|
+
let originalSize;
|
|
1428
|
+
if (outAttributeInfo.clientSideId != 0n) ({paddedData: paddedData, originalSize} = AttributeCache.get(Number(outAttributeInfo.clientSideId)));
|
|
1429
|
+
else {
|
|
1430
|
+
const result = sparkAttributeFromRaw(attributeName, 0, engine.dataPtrView(outAttributeInfo));
|
|
1431
|
+
paddedData = result.paddedData;
|
|
1432
|
+
originalSize = result.originalSize;
|
|
1433
|
+
const myCacheEntry = AttributeCache.add({
|
|
1434
|
+
paddedData: result.paddedData,
|
|
1435
|
+
originalSize: result.originalSize
|
|
1436
|
+
});
|
|
1437
|
+
const takeStatus = client.takeAttribute(sceneObjectId, attributeName, BigInt(myCacheEntry));
|
|
1438
|
+
if (takeStatus !== Engine.AquaStatus.Success) {
|
|
1439
|
+
AttributeCache.remove(myCacheEntry);
|
|
1440
|
+
console.warn(`Failed to take attribute ${attributeName} for scene object ${sceneObjectId}: status ${takeStatus}`);
|
|
1441
|
+
return null;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return {
|
|
1445
|
+
paddedData,
|
|
1446
|
+
originalSize
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
#updateScene(scene) {
|
|
1450
|
+
const { engine } = this;
|
|
1451
|
+
const { client, camera, lods } = scene;
|
|
1452
|
+
if (camera) camera.update();
|
|
1453
|
+
if (this.#changeIds === null) this.#changeIds = new engine.SceneChangeIds();
|
|
1454
|
+
client.getSceneChangesCounts(this.#changeIds);
|
|
1455
|
+
if (!this.#shouldUpdateSceneChanges()) return;
|
|
1456
|
+
engine.allocateSceneChangesArrays(this.#changeIds);
|
|
1457
|
+
client.getSceneChanges(this.#changeIds);
|
|
1458
|
+
const createdLodIds = /* @__PURE__ */ new Set();
|
|
1459
|
+
for (const sceneObjectId of engine.createdObjectIdsView(this.#changeIds)) {
|
|
1460
|
+
const sceneObjectType = client.getSceneObjectType(sceneObjectId);
|
|
1461
|
+
if (sceneObjectType === Engine.SceneObjectType.StreamObject) {
|
|
1462
|
+
Stream.forId(sceneObjectId);
|
|
1463
|
+
continue;
|
|
1464
|
+
} else if (sceneObjectType === Engine.SceneObjectType.ModelRoot) {
|
|
1465
|
+
const stream = scene.getStreamForDescendentId(sceneObjectId);
|
|
1466
|
+
if (!stream) continue;
|
|
1467
|
+
const modelRoot = new ModelRoot({
|
|
1468
|
+
id: sceneObjectId,
|
|
1469
|
+
stream
|
|
1470
|
+
});
|
|
1471
|
+
const modelRootTransform = this.getLocalTransform(client, sceneObjectId);
|
|
1472
|
+
if (!modelRootTransform) continue;
|
|
1473
|
+
const parentId = client.getSceneObjectParent(sceneObjectId);
|
|
1474
|
+
const parentTransform = this.getLocalTransform(client, parentId);
|
|
1475
|
+
if (!parentTransform) continue;
|
|
1476
|
+
const updatedTransform = this.updateParentedTransform(modelRootTransform, parentTransform);
|
|
1477
|
+
if (!updatedTransform) continue;
|
|
1478
|
+
modelRoot.transform = updatedTransform;
|
|
1479
|
+
} else if (sceneObjectType == Engine.SceneObjectType.GaussianSplats) {
|
|
1480
|
+
const modelRoot = scene.getModelRootForDescendentId(sceneObjectId);
|
|
1481
|
+
if (!modelRoot) continue;
|
|
1482
|
+
const lod = new Lod({
|
|
1483
|
+
id: sceneObjectId,
|
|
1484
|
+
modelRoot,
|
|
1485
|
+
lodStore: lods
|
|
1486
|
+
});
|
|
1487
|
+
lod.transform = this.getLocalTransform(client, sceneObjectId);
|
|
1488
|
+
createdLodIds.add(sceneObjectId);
|
|
1489
|
+
const entry = new Change({
|
|
1490
|
+
type: "created",
|
|
1491
|
+
lod
|
|
1492
|
+
});
|
|
1493
|
+
this.#changes.push(entry);
|
|
1494
|
+
} else if (sceneObjectType == Engine.SceneObjectType.VariantSetCollection) scene.getStreamForDescendentId(sceneObjectId)?._addVariantCollection(sceneObjectId);
|
|
1495
|
+
else if (sceneObjectType == Engine.SceneObjectType.VariantSet) {
|
|
1496
|
+
const stream = scene.getStreamForDescendentId(sceneObjectId);
|
|
1497
|
+
const name = client.getName(sceneObjectId);
|
|
1498
|
+
const parentId = client.getSceneObjectParent(sceneObjectId);
|
|
1499
|
+
stream?._addVariant(parentId, {
|
|
1500
|
+
id: sceneObjectId,
|
|
1501
|
+
name,
|
|
1502
|
+
options: [],
|
|
1503
|
+
nestedSets: []
|
|
1504
|
+
});
|
|
1505
|
+
} else if (sceneObjectType == Engine.SceneObjectType.VariantSetOption) {
|
|
1506
|
+
const stream = scene.getStreamForDescendentId(sceneObjectId);
|
|
1507
|
+
const name = client.getName(sceneObjectId);
|
|
1508
|
+
const parentId = client.getSceneObjectParent(sceneObjectId);
|
|
1509
|
+
stream?._addVariant(parentId, {
|
|
1510
|
+
id: sceneObjectId,
|
|
1511
|
+
name,
|
|
1512
|
+
type: "option"
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
for (const sceneObjectId of engine.deletedObjectIdsView(this.#changeIds)) {
|
|
1517
|
+
const lod = lods.forId(sceneObjectId);
|
|
1518
|
+
if (!lod) continue;
|
|
1519
|
+
const entry = new Change({
|
|
1520
|
+
type: "deleted",
|
|
1521
|
+
lod
|
|
1522
|
+
});
|
|
1523
|
+
this.#changes.push(entry);
|
|
1524
|
+
}
|
|
1525
|
+
for (const sceneObjectId of engine.modifiedObjectIdsView(this.#changeIds)) {
|
|
1526
|
+
const sceneObjectType = client.getSceneObjectType(sceneObjectId);
|
|
1527
|
+
if (sceneObjectType === Engine.SceneObjectType.LodOctree) scene._onFeatureData(sceneObjectId);
|
|
1528
|
+
else if (sceneObjectType === Engine.SceneObjectType.GaussianSplats) {
|
|
1529
|
+
const lodIndex = client.getLodIndex(sceneObjectId);
|
|
1530
|
+
const attributeInfo = new engine.AttributeInfo();
|
|
1531
|
+
const attributeInfoHigh = new engine.AttributeInfo();
|
|
1532
|
+
try {
|
|
1533
|
+
let attribute = this.#getDataFromAttribute(client, sceneObjectId, AttributeNames.SPARK_EXTENDED_SPLAT_LOW, attributeInfo);
|
|
1534
|
+
let attributeHigh = null;
|
|
1535
|
+
let useExtSplats = true;
|
|
1536
|
+
if (attribute === null) {
|
|
1537
|
+
attribute = this.#getDataFromAttribute(client, sceneObjectId, AttributeNames.SPARK_PACKED_SPLAT, attributeInfo);
|
|
1538
|
+
useExtSplats = false;
|
|
1539
|
+
} else attributeHigh = this.#getDataFromAttribute(client, sceneObjectId, AttributeNames.SPARK_EXTENDED_SPLAT_HIGH, attributeInfoHigh);
|
|
1540
|
+
if (attribute === null) {
|
|
1541
|
+
console.error(`Could not retrieve primary splats attribute for scene object ${sceneObjectId}! skipping scene object`);
|
|
1542
|
+
continue;
|
|
1543
|
+
}
|
|
1544
|
+
const lod = lods.forId(sceneObjectId);
|
|
1545
|
+
if (!lod) {
|
|
1546
|
+
console.warn(`Received modified event for LOD ${sceneObjectId} which does not exist.`);
|
|
1547
|
+
continue;
|
|
1548
|
+
}
|
|
1549
|
+
const worldBounds = this.#retrieveFloatArray(lod.id, 6, client.getWorldBoundingBox.bind(client));
|
|
1550
|
+
const localBounds = this.#retrieveFloatArray(lod.id, 6, client.getLocalBoundingBox.bind(client));
|
|
1551
|
+
lod.splats = attribute?.paddedData;
|
|
1552
|
+
lod.splatsExtendedData = attributeHigh?.paddedData ?? null;
|
|
1553
|
+
lod.useExtSplats = useExtSplats;
|
|
1554
|
+
lod.bounds = worldBounds;
|
|
1555
|
+
lod.localBounds = localBounds;
|
|
1556
|
+
lod.lodIndex = lodIndex;
|
|
1557
|
+
lod.paddingCount = (attribute?.paddedData.length - attribute.originalSize) / 4;
|
|
1558
|
+
if (this.useSphericalHarmonics) this.#addSphericalHarmonicsToLod(scene, sceneObjectId, lod);
|
|
1559
|
+
const entry = new Change({
|
|
1560
|
+
type: "modified",
|
|
1561
|
+
lod
|
|
1562
|
+
});
|
|
1563
|
+
this.#changes.push(entry);
|
|
1564
|
+
if (this.#pendingActivations.delete(sceneObjectId)) {
|
|
1565
|
+
this.#changes.push(new Change({
|
|
1566
|
+
type: "activated",
|
|
1567
|
+
lod
|
|
1568
|
+
}));
|
|
1569
|
+
for (const [, deactLod] of this.#pendingDeactivations) this.#changes.push(new Change({
|
|
1570
|
+
type: "deactivated",
|
|
1571
|
+
lod: deactLod
|
|
1572
|
+
}));
|
|
1573
|
+
this.#pendingDeactivations.clear();
|
|
1574
|
+
}
|
|
1575
|
+
} finally {
|
|
1576
|
+
attributeInfo.delete();
|
|
1577
|
+
attributeInfoHigh.delete();
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
if (this.#changes.some((c) => c.type === "created")) try {
|
|
1582
|
+
const metadata = new engine.SceneMetadata();
|
|
1583
|
+
client.getSceneMetadata(metadata);
|
|
1584
|
+
this.onColorSpaceDetected(metadata.inputColorSpace === "linear");
|
|
1585
|
+
metadata.delete();
|
|
1586
|
+
} catch (e) {
|
|
1587
|
+
console.warn("Failed to read scene metadata:", e);
|
|
1588
|
+
}
|
|
1589
|
+
let deferredActivationsThisFrame = false;
|
|
1590
|
+
for (const sceneObjectId of engine.activatedObjectIdsView(this.#changeIds)) if (client.getSceneObjectType(sceneObjectId) == Engine.SceneObjectType.GaussianSplats) {
|
|
1591
|
+
const lod = lods.forId(sceneObjectId);
|
|
1592
|
+
if (lod && lod.splats) {
|
|
1593
|
+
const entry = new Change({
|
|
1594
|
+
type: "activated",
|
|
1595
|
+
lod
|
|
1596
|
+
});
|
|
1597
|
+
this.#changes.push(entry);
|
|
1598
|
+
} else if (lod) {
|
|
1599
|
+
this.#pendingActivations.add(sceneObjectId);
|
|
1600
|
+
deferredActivationsThisFrame = true;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
for (const sceneObjectId of engine.deactivatedObjectIdsView(this.#changeIds)) if (client.getSceneObjectType(sceneObjectId) == Engine.SceneObjectType.GaussianSplats) {
|
|
1604
|
+
this.#pendingActivations.delete(sceneObjectId);
|
|
1605
|
+
if (!createdLodIds.has(sceneObjectId)) {
|
|
1606
|
+
const lod = lods.forId(sceneObjectId);
|
|
1607
|
+
if (lod && lod.splats) {
|
|
1608
|
+
if (deferredActivationsThisFrame) this.#pendingDeactivations.set(sceneObjectId, lod);
|
|
1609
|
+
else {
|
|
1610
|
+
const entry = new Change({
|
|
1611
|
+
type: "deactivated",
|
|
1612
|
+
lod
|
|
1613
|
+
});
|
|
1614
|
+
this.#changes.push(entry);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
#addSphericalHarmonicsToLod(scene, sceneObjectId, outLod) {
|
|
1621
|
+
const { engine } = this;
|
|
1622
|
+
const { client } = scene;
|
|
1623
|
+
const getAndAssignSh = (packedName, extName, setter) => {
|
|
1624
|
+
const attributeName = outLod.useExtSplats ? extName : packedName;
|
|
1625
|
+
if (client.hasAttribute(sceneObjectId, attributeName)) {
|
|
1626
|
+
const attributeInfo = new engine.AttributeInfo();
|
|
1627
|
+
try {
|
|
1628
|
+
const attribute = this.#getDataFromAttribute(client, sceneObjectId, attributeName, attributeInfo);
|
|
1629
|
+
if (attribute !== null) setter(attribute.paddedData, attributeInfo.maxValue.x);
|
|
1630
|
+
} finally {
|
|
1631
|
+
attributeInfo.delete();
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
getAndAssignSh(AttributeNames.SPARK_PACKED_SH1, AttributeNames.SPARK_EXTENDED_SH1, (data, max) => outLod.setSh1(data, max));
|
|
1636
|
+
getAndAssignSh(AttributeNames.SPARK_PACKED_SH2, AttributeNames.SPARK_EXTENDED_SH2, (data, max) => outLod.setSh2(data, max));
|
|
1637
|
+
getAndAssignSh(AttributeNames.SPARK_PACKED_SH3, AttributeNames.SPARK_EXTENDED_SH3_A, (data, max) => outLod.setSh3(data, max));
|
|
1638
|
+
getAndAssignSh(AttributeNames.UNUSED, AttributeNames.SPARK_EXTENDED_SH3_B, (data, _max) => outLod.sh3ExtendedData = data);
|
|
1639
|
+
}
|
|
1640
|
+
update() {
|
|
1641
|
+
this.#hostDriven = true;
|
|
1642
|
+
this._update();
|
|
1643
|
+
let needsRender = false;
|
|
1644
|
+
for (const scene of this.#scenes) if (scene.client.takeRenderRequired()) needsRender = true;
|
|
1645
|
+
return needsRender || this._computeAdditionalRenderNeeded();
|
|
1646
|
+
}
|
|
1647
|
+
applyChanges(_entries) {}
|
|
1648
|
+
_computeAdditionalRenderNeeded() {
|
|
1649
|
+
return false;
|
|
1650
|
+
}
|
|
1651
|
+
onColorSpaceDetected(_isLinear) {}
|
|
1652
|
+
add(scene) {
|
|
1653
|
+
this.#scenes.add(scene);
|
|
1654
|
+
}
|
|
1655
|
+
delete(scene) {
|
|
1656
|
+
this.#scenes.delete(scene);
|
|
1657
|
+
if (scene.miris) scene.close();
|
|
1658
|
+
if (this.#scenes.size === 0 && this.#changeIds !== null) {
|
|
1659
|
+
this.#changeIds.delete();
|
|
1660
|
+
this.#changeIds = null;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region packages/core/camera.ts
|
|
1666
|
+
var Camera = class {
|
|
1667
|
+
update() {
|
|
1668
|
+
const { engine } = this;
|
|
1669
|
+
const { client } = this.scene;
|
|
1670
|
+
const matrixBuffer = engine.malloc(this.#matrix.length * 4);
|
|
1671
|
+
engine.heapF32.set(Float32Array.from(this.#matrix), matrixBuffer / 4);
|
|
1672
|
+
client.setMainCameraTransform(matrixBuffer);
|
|
1673
|
+
engine.free(matrixBuffer);
|
|
1674
|
+
client.setMainCameraViewFrustum(this.#aspect, this.#fov, this.#near, this.#far);
|
|
1675
|
+
}
|
|
1676
|
+
#aspect;
|
|
1677
|
+
get aspect() {
|
|
1678
|
+
return this.#aspect;
|
|
1679
|
+
}
|
|
1680
|
+
set aspect(aspect) {
|
|
1681
|
+
this.#aspect = aspect;
|
|
1682
|
+
}
|
|
1683
|
+
#fov;
|
|
1684
|
+
get fov() {
|
|
1685
|
+
return this.#fov;
|
|
1686
|
+
}
|
|
1687
|
+
set fov(fov) {
|
|
1688
|
+
this.#fov = fov;
|
|
1689
|
+
}
|
|
1690
|
+
#near;
|
|
1691
|
+
get near() {
|
|
1692
|
+
return this.#near;
|
|
1693
|
+
}
|
|
1694
|
+
set near(near) {
|
|
1695
|
+
this.#near = near;
|
|
1696
|
+
}
|
|
1697
|
+
#far;
|
|
1698
|
+
get far() {
|
|
1699
|
+
return this.#far;
|
|
1700
|
+
}
|
|
1701
|
+
set far(far) {
|
|
1702
|
+
this.#far = far;
|
|
1703
|
+
}
|
|
1704
|
+
#matrix;
|
|
1705
|
+
get matrix() {
|
|
1706
|
+
return this.#matrix;
|
|
1707
|
+
}
|
|
1708
|
+
set matrix(matrix) {
|
|
1709
|
+
this.#matrix = matrix;
|
|
1710
|
+
}
|
|
1711
|
+
constructor({ aspect, fov, near, far, matrix, scene }) {
|
|
1712
|
+
this.#aspect = aspect;
|
|
1713
|
+
this.#fov = fov;
|
|
1714
|
+
this.#near = near;
|
|
1715
|
+
this.#far = far;
|
|
1716
|
+
this.#matrix = matrix;
|
|
1717
|
+
Object.defineProperties(this, {
|
|
1718
|
+
scene: { value: scene },
|
|
1719
|
+
miris: { value: scene.miris },
|
|
1720
|
+
engine: { value: scene.miris.engine }
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
//#endregion
|
|
1725
|
+
//#region packages/core/engine/client.ts
|
|
1726
|
+
var Client = class {
|
|
1727
|
+
#viewerKey = null;
|
|
1728
|
+
get viewerKey() {
|
|
1729
|
+
return this.#viewerKey;
|
|
1730
|
+
}
|
|
1731
|
+
set viewerKey(key) {
|
|
1732
|
+
if (key) this.setAssetViewerKey(key);
|
|
1733
|
+
this.#viewerKey = key;
|
|
1734
|
+
}
|
|
1735
|
+
constructor({ engine, context }) {
|
|
1736
|
+
Object.defineProperties(this, {
|
|
1737
|
+
engine: {
|
|
1738
|
+
value: engine,
|
|
1739
|
+
enumerable: true
|
|
1740
|
+
},
|
|
1741
|
+
handle: {
|
|
1742
|
+
value: engine.createClient(context),
|
|
1743
|
+
enumerable: true
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
dispose() {
|
|
1748
|
+
if (this.engine.destroyClient(this.handle) !== Engine.AquaStatus.Success) console.error(`Failed to destroy client with handle '${this.handle}'`);
|
|
1749
|
+
}
|
|
1750
|
+
addStreamById(...args) {
|
|
1751
|
+
return this.engine.addStreamById(this.handle, ...args);
|
|
1752
|
+
}
|
|
1753
|
+
destroyClient(...args) {
|
|
1754
|
+
return this.engine.destroyClient(this.handle, ...args);
|
|
1755
|
+
}
|
|
1756
|
+
getAssetsAsync(...args) {
|
|
1757
|
+
return this.engine.getAssetsAsync(this.handle, ...args);
|
|
1758
|
+
}
|
|
1759
|
+
getAttribute(...args) {
|
|
1760
|
+
return this.engine.getAttribute(this.handle, ...args);
|
|
1761
|
+
}
|
|
1762
|
+
getDefaultCameraId(...args) {
|
|
1763
|
+
return this.engine.getDefaultCameraId(this.handle, ...args);
|
|
1764
|
+
}
|
|
1765
|
+
getViewingVolumeId(...args) {
|
|
1766
|
+
return this.engine.getViewingVolumeId(this.handle, ...args);
|
|
1767
|
+
}
|
|
1768
|
+
getLocalBoundingBox(...args) {
|
|
1769
|
+
return this.engine.getLocalBoundingBox(this.handle, ...args);
|
|
1770
|
+
}
|
|
1771
|
+
getWorldBoundingBox(...args) {
|
|
1772
|
+
return this.engine.getWorldBoundingBox(this.handle, ...args);
|
|
1773
|
+
}
|
|
1774
|
+
getLodIndex(...args) {
|
|
1775
|
+
return this.engine.getLodIndex(this.handle, ...args);
|
|
1776
|
+
}
|
|
1777
|
+
getSceneChanges(...args) {
|
|
1778
|
+
return this.engine.getSceneChanges(this.handle, ...args);
|
|
1779
|
+
}
|
|
1780
|
+
getSceneChangesCounts(...args) {
|
|
1781
|
+
return this.engine.getSceneChangesCounts(this.handle, ...args);
|
|
1782
|
+
}
|
|
1783
|
+
getSceneMetadata(...args) {
|
|
1784
|
+
return this.engine.getSceneMetadata(this.handle, ...args);
|
|
1785
|
+
}
|
|
1786
|
+
getSceneObjectParent(...args) {
|
|
1787
|
+
return this.engine.getSceneObjectParent(this.handle, ...args);
|
|
1788
|
+
}
|
|
1789
|
+
getSceneObjectType(...args) {
|
|
1790
|
+
return this.engine.getSceneObjectType(this.handle, ...args);
|
|
1791
|
+
}
|
|
1792
|
+
getLocalTransform(...args) {
|
|
1793
|
+
return this.engine.getLocalTransform(this.handle, ...args);
|
|
1794
|
+
}
|
|
1795
|
+
getWorldTransform(...args) {
|
|
1796
|
+
return this.engine.getWorldTransform(this.handle, ...args);
|
|
1797
|
+
}
|
|
1798
|
+
hasAttribute(...args) {
|
|
1799
|
+
return this.engine.hasAttribute(this.handle, ...args);
|
|
1800
|
+
}
|
|
1801
|
+
isSceneObjectAncestorOf(...args) {
|
|
1802
|
+
return this.engine.isSceneObjectAncestorOf(this.handle, ...args);
|
|
1803
|
+
}
|
|
1804
|
+
lockScene(...args) {
|
|
1805
|
+
return this.engine.lockScene(this.handle, ...args);
|
|
1806
|
+
}
|
|
1807
|
+
removeStream(...args) {
|
|
1808
|
+
return this.engine.removeStream(this.handle, ...args);
|
|
1809
|
+
}
|
|
1810
|
+
setAssetViewerKey(...args) {
|
|
1811
|
+
return this.engine.setAssetViewerKey(this.handle, ...args);
|
|
1812
|
+
}
|
|
1813
|
+
setClientSpatialFormat(...args) {
|
|
1814
|
+
return this.engine.setClientSpatialFormat(this.handle, ...args);
|
|
1815
|
+
}
|
|
1816
|
+
setRuntimeSettings(...args) {
|
|
1817
|
+
return this.engine.setRuntimeSettings(this.handle, ...args);
|
|
1818
|
+
}
|
|
1819
|
+
setMainCameraTransform(...args) {
|
|
1820
|
+
return this.engine.setMainCameraTransform(this.handle, ...args);
|
|
1821
|
+
}
|
|
1822
|
+
setMainCameraViewFrustum(...args) {
|
|
1823
|
+
return this.engine.setMainCameraViewFrustum(this.handle, ...args);
|
|
1824
|
+
}
|
|
1825
|
+
setSceneObjectTransform(...args) {
|
|
1826
|
+
return this.engine.setSceneObjectTransform(this.handle, ...args);
|
|
1827
|
+
}
|
|
1828
|
+
hasFeature(...args) {
|
|
1829
|
+
return this.engine.hasFeature(this.handle, ...args);
|
|
1830
|
+
}
|
|
1831
|
+
getFeatureVersion(...args) {
|
|
1832
|
+
return this.engine.getFeatureVersion(this.handle, ...args);
|
|
1833
|
+
}
|
|
1834
|
+
getFeatureState(...args) {
|
|
1835
|
+
return this.engine.getFeatureState(this.handle, ...args);
|
|
1836
|
+
}
|
|
1837
|
+
getName(...args) {
|
|
1838
|
+
return this.engine.getName(this.handle, ...args);
|
|
1839
|
+
}
|
|
1840
|
+
setVariantSelection(...args) {
|
|
1841
|
+
return this.engine.setVariantSelection(this.handle, ...args);
|
|
1842
|
+
}
|
|
1843
|
+
takeAttribute(...args) {
|
|
1844
|
+
return this.engine.takeAttribute(this.handle, ...args);
|
|
1845
|
+
}
|
|
1846
|
+
takeEvictedClientSideAttributeIds(...args) {
|
|
1847
|
+
return this.engine.takeEvictedClientSideAttributeIds(this.handle, ...args);
|
|
1848
|
+
}
|
|
1849
|
+
takeRenderRequired(...args) {
|
|
1850
|
+
return this.engine.takeRenderRequired(this.handle, ...args);
|
|
1851
|
+
}
|
|
1852
|
+
unlockScene(...args) {
|
|
1853
|
+
return this.engine.unlockScene(this.handle, ...args);
|
|
1854
|
+
}
|
|
1855
|
+
updateSceneExecution(...args) {
|
|
1856
|
+
return this.engine.updateSceneExecution(this.handle, ...args);
|
|
1857
|
+
}
|
|
1858
|
+
recordFrameTime(...args) {
|
|
1859
|
+
return this.engine.recordFrameTime(this.handle, ...args);
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
//#endregion
|
|
1863
|
+
//#region packages/core/scene.ts
|
|
1864
|
+
var Scene = class Scene extends EventTarget {
|
|
1865
|
+
static #idMap = /* @__PURE__ */ new Map();
|
|
1866
|
+
static #keyMap = /* @__PURE__ */ new Map();
|
|
1867
|
+
#camera = null;
|
|
1868
|
+
get camera() {
|
|
1869
|
+
return this.#camera;
|
|
1870
|
+
}
|
|
1871
|
+
set camera(camera) {
|
|
1872
|
+
this.#camera = camera;
|
|
1873
|
+
}
|
|
1874
|
+
#defaultCameraId = null;
|
|
1875
|
+
static forId(id) {
|
|
1876
|
+
return Scene.#idMap.get(id);
|
|
1877
|
+
}
|
|
1878
|
+
static forKey(key) {
|
|
1879
|
+
return Scene.#keyMap.get(key);
|
|
1880
|
+
}
|
|
1881
|
+
#key;
|
|
1882
|
+
get key() {
|
|
1883
|
+
return this.#key ?? null;
|
|
1884
|
+
}
|
|
1885
|
+
set key(key) {
|
|
1886
|
+
Scene.#keyMap.delete(this.key);
|
|
1887
|
+
if (key || 0 === key) Scene.#keyMap.set(key, this);
|
|
1888
|
+
this.#key = key;
|
|
1889
|
+
}
|
|
1890
|
+
#streams = /* @__PURE__ */ new Set();
|
|
1891
|
+
#streamObjectIdToStream = /* @__PURE__ */ new Map();
|
|
1892
|
+
get viewerKey() {
|
|
1893
|
+
return this.client.viewerKey;
|
|
1894
|
+
}
|
|
1895
|
+
set viewerKey(viewerKey) {
|
|
1896
|
+
if (viewerKey) this.client.viewerKey = viewerKey;
|
|
1897
|
+
}
|
|
1898
|
+
get streams() {
|
|
1899
|
+
return new Set(this.#streams);
|
|
1900
|
+
}
|
|
1901
|
+
#lods = new LodStore();
|
|
1902
|
+
get lods() {
|
|
1903
|
+
return this.#lods;
|
|
1904
|
+
}
|
|
1905
|
+
constructor({ miris, viewerKey }) {
|
|
1906
|
+
super();
|
|
1907
|
+
Object.defineProperties(this, {
|
|
1908
|
+
miris: {
|
|
1909
|
+
value: miris,
|
|
1910
|
+
enumerable: true
|
|
1911
|
+
},
|
|
1912
|
+
engine: {
|
|
1913
|
+
value: miris.engine,
|
|
1914
|
+
enumerable: true
|
|
1915
|
+
},
|
|
1916
|
+
client: { value: new Client({
|
|
1917
|
+
engine: miris.engine,
|
|
1918
|
+
context: miris.sharedContext
|
|
1919
|
+
}) }
|
|
1920
|
+
});
|
|
1921
|
+
if (viewerKey) this.viewerKey = viewerKey;
|
|
1922
|
+
const spatialFormat = new this.engine.SpatialFormat();
|
|
1923
|
+
spatialFormat.metersPerUnit = 1;
|
|
1924
|
+
spatialFormat.upAxis = this.engine.UpAxis.Y;
|
|
1925
|
+
spatialFormat.matrixOrder = this.engine.MatrixOrder.ColumnMajor;
|
|
1926
|
+
spatialFormat.handedness = this.engine.Handedness.Right;
|
|
1927
|
+
this.client.setClientSpatialFormat(spatialFormat);
|
|
1928
|
+
spatialFormat.delete();
|
|
1929
|
+
Scene.#idMap.set(this.id, this);
|
|
1930
|
+
miris.add(this);
|
|
1931
|
+
}
|
|
1932
|
+
dispose() {
|
|
1933
|
+
this.close();
|
|
1934
|
+
this.client.dispose();
|
|
1935
|
+
}
|
|
1936
|
+
#updateSceneCameraData() {
|
|
1937
|
+
const defaultCameraId = this.client.getDefaultCameraId();
|
|
1938
|
+
this.#defaultCameraId = defaultCameraId >= 0 ? defaultCameraId : null;
|
|
1939
|
+
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Returns the world-space AABB of the authored /Miris/ViewingVolume prim,
|
|
1942
|
+
* or null if no viewing volume is present in the loaded structure.
|
|
1943
|
+
* @internal
|
|
1944
|
+
*/
|
|
1945
|
+
_getViewingVolumeBounds() {
|
|
1946
|
+
const viewingVolumeId = this.client.getViewingVolumeId();
|
|
1947
|
+
if (viewingVolumeId < 0) return null;
|
|
1948
|
+
const { engine, client } = this;
|
|
1949
|
+
const boxBuffer = engine.malloc(24);
|
|
1950
|
+
try {
|
|
1951
|
+
client.getWorldBoundingBox(viewingVolumeId, boxBuffer);
|
|
1952
|
+
const [cX, cY, cZ, dX, dY, dZ] = Float32Array.from(engine.heapF32.subarray(boxBuffer / 4, boxBuffer / 4 + 6));
|
|
1953
|
+
if (cX === void 0 || cY === void 0 || cZ === void 0 || dX === void 0 || dY === void 0 || dZ === void 0) return null;
|
|
1954
|
+
return {
|
|
1955
|
+
min: [
|
|
1956
|
+
cX - dX / 2,
|
|
1957
|
+
cY - dY / 2,
|
|
1958
|
+
cZ - dZ / 2
|
|
1959
|
+
],
|
|
1960
|
+
max: [
|
|
1961
|
+
cX + dX / 2,
|
|
1962
|
+
cY + dY / 2,
|
|
1963
|
+
cZ + dZ / 2
|
|
1964
|
+
]
|
|
1965
|
+
};
|
|
1966
|
+
} finally {
|
|
1967
|
+
engine.free(boxBuffer);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
async fetchAssets(tags) {
|
|
1971
|
+
if (!this.viewerKey) throw new Error("Could not fetch assets because there is no viewer key");
|
|
1972
|
+
const vector = new this.engine.StringVector();
|
|
1973
|
+
let _tags = [];
|
|
1974
|
+
if (typeof tags === "string") _tags = tags.split(",");
|
|
1975
|
+
else if (tags?.[Symbol.iterator]) _tags = [...tags];
|
|
1976
|
+
for (const tag of _tags) vector.push_back(tag);
|
|
1977
|
+
const _assets = await this.client.getAssetsAsync(vector);
|
|
1978
|
+
const assets = [];
|
|
1979
|
+
const decoder = new TextDecoder();
|
|
1980
|
+
for (const { name, tags, thumbnailUrl, uuid } of _assets) {
|
|
1981
|
+
const asset = {
|
|
1982
|
+
name,
|
|
1983
|
+
thumbnailUrl,
|
|
1984
|
+
uuid,
|
|
1985
|
+
tags: []
|
|
1986
|
+
};
|
|
1987
|
+
const size = tags.size();
|
|
1988
|
+
for (let index = 0; index < size; index += 1) {
|
|
1989
|
+
let tag = tags.get(index);
|
|
1990
|
+
if (tag) {
|
|
1991
|
+
if (typeof tag !== "string") tag = decoder.decode(tag);
|
|
1992
|
+
asset.tags.push(tag);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
assets.push(asset);
|
|
1996
|
+
}
|
|
1997
|
+
vector.delete();
|
|
1998
|
+
return assets;
|
|
1999
|
+
}
|
|
2000
|
+
getDefaultCameraTransform() {
|
|
2001
|
+
if (this.#defaultCameraId === null) return null;
|
|
2002
|
+
return this.miris.getWorldTransform(this.client, this.#defaultCameraId);
|
|
2003
|
+
}
|
|
2004
|
+
add(stream) {
|
|
2005
|
+
this.#streams.add(stream);
|
|
2006
|
+
this.#streamObjectIdToStream.set(stream.id, stream);
|
|
2007
|
+
}
|
|
2008
|
+
getStreamForId(streamObjectId) {
|
|
2009
|
+
return this.#streamObjectIdToStream.get(streamObjectId);
|
|
2010
|
+
}
|
|
2011
|
+
getStreamForDescendentId(descendentObjectId) {
|
|
2012
|
+
for (const [streamObjectId, stream] of this.#streamObjectIdToStream) if (this.client.isSceneObjectAncestorOf(streamObjectId, descendentObjectId)) return stream;
|
|
2013
|
+
return null;
|
|
2014
|
+
}
|
|
2015
|
+
getModelRootForDescendentId(descendentObjectId) {
|
|
2016
|
+
for (const [, stream] of this.#streamObjectIdToStream) for (const modelRoot of stream.modelRoots) if (this.client.isSceneObjectAncestorOf(modelRoot.id, descendentObjectId)) return modelRoot;
|
|
2017
|
+
return null;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* @internal
|
|
2021
|
+
*/
|
|
2022
|
+
async _getFeatureMesh(sceneObjectId, feature, attrBase) {
|
|
2023
|
+
if (!this.client.hasFeature(sceneObjectId, feature)) return null;
|
|
2024
|
+
if (this.client.getFeatureState(sceneObjectId, feature) !== Engine.FeatureState.Loaded) return null;
|
|
2025
|
+
const version = this.client.getFeatureVersion(sceneObjectId, feature);
|
|
2026
|
+
if (version === 1) {
|
|
2027
|
+
const attrName = `${attrBase}_v${version}`;
|
|
2028
|
+
const attrInfo = new this.engine.AttributeInfo();
|
|
2029
|
+
try {
|
|
2030
|
+
if (this.client.getAttribute(sceneObjectId, attrName, attrInfo.$$.ptr) !== Engine.AquaStatus.Success) return null;
|
|
2031
|
+
if (attrInfo.clientSideId !== 0n) return AttributeCache.get(Number(attrInfo.clientSideId));
|
|
2032
|
+
const wasmView = this.engine.dataPtrView(attrInfo);
|
|
2033
|
+
const buffer = new Uint8Array(wasmView.buffer).subarray(wasmView.byteOffset, wasmView.byteOffset + wasmView.byteLength).slice().buffer;
|
|
2034
|
+
const cacheId = AttributeCache.add(buffer);
|
|
2035
|
+
const takeStatus = this.client.takeAttribute(sceneObjectId, attrName, BigInt(cacheId));
|
|
2036
|
+
if (takeStatus !== Engine.AquaStatus.Success) {
|
|
2037
|
+
AttributeCache.remove(cacheId);
|
|
2038
|
+
console.warn(`Failed to take attribute ${attrName} for scene object ${sceneObjectId}: status ${takeStatus}`);
|
|
2039
|
+
return null;
|
|
2040
|
+
}
|
|
2041
|
+
return buffer;
|
|
2042
|
+
} finally {
|
|
2043
|
+
attrInfo.delete();
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
console.warn(`getFeatureMesh: unsupported version ${version} for feature ${feature}`);
|
|
2047
|
+
return null;
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* @internal
|
|
2051
|
+
*/
|
|
2052
|
+
async _getDrMap(sceneObjectId) {
|
|
2053
|
+
if (!this.client.hasFeature(sceneObjectId, Engine.Feature.DrMap)) return null;
|
|
2054
|
+
if (this.client.getFeatureState(sceneObjectId, Engine.Feature.DrMap) !== Engine.FeatureState.Loaded) return null;
|
|
2055
|
+
const version = this.client.getFeatureVersion(sceneObjectId, Engine.Feature.DrMap);
|
|
2056
|
+
if (version === 1 || version === 2) {
|
|
2057
|
+
const attrName = `drMap_v${version}`;
|
|
2058
|
+
const attrInfo = new this.engine.AttributeInfo();
|
|
2059
|
+
try {
|
|
2060
|
+
if (this.client.getAttribute(sceneObjectId, attrName, attrInfo.$$.ptr) !== Engine.AquaStatus.Success) return null;
|
|
2061
|
+
if (attrInfo.clientSideId !== 0n) {
|
|
2062
|
+
const cached = AttributeCache.get(Number(attrInfo.clientSideId));
|
|
2063
|
+
return cached !== void 0 ? {
|
|
2064
|
+
bytes: cached,
|
|
2065
|
+
version
|
|
2066
|
+
} : null;
|
|
2067
|
+
}
|
|
2068
|
+
const wasmView = this.engine.dataPtrView(attrInfo);
|
|
2069
|
+
const bytes = new Uint8Array(wasmView.buffer).subarray(wasmView.byteOffset, wasmView.byteOffset + wasmView.byteLength).slice();
|
|
2070
|
+
const cacheId = AttributeCache.add(bytes);
|
|
2071
|
+
console.log(`_getDrMap is calling takeAttribute for ${attrName} with id ${cacheId}`);
|
|
2072
|
+
const takeStatus = this.client.takeAttribute(sceneObjectId, attrName, BigInt(cacheId));
|
|
2073
|
+
if (takeStatus !== Engine.AquaStatus.Success) {
|
|
2074
|
+
AttributeCache.remove(cacheId);
|
|
2075
|
+
if (this.client.getAttribute(sceneObjectId, attrName, attrInfo.$$.ptr) === Engine.AquaStatus.Success && attrInfo.clientSideId !== 0n) {
|
|
2076
|
+
const cached = AttributeCache.get(Number(attrInfo.clientSideId));
|
|
2077
|
+
return cached !== void 0 ? {
|
|
2078
|
+
bytes: cached,
|
|
2079
|
+
version
|
|
2080
|
+
} : null;
|
|
2081
|
+
}
|
|
2082
|
+
console.warn(`getDrMap: failed to take attribute ${attrName} for scene object ${sceneObjectId}: status ${takeStatus}`);
|
|
2083
|
+
return null;
|
|
2084
|
+
}
|
|
2085
|
+
return {
|
|
2086
|
+
bytes,
|
|
2087
|
+
version
|
|
2088
|
+
};
|
|
2089
|
+
} finally {
|
|
2090
|
+
attrInfo.delete();
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
console.warn(`getDrMap: unsupported DR map version ${version}`);
|
|
2094
|
+
return null;
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* @internal
|
|
2098
|
+
*/
|
|
2099
|
+
async _onFeatureData(sceneObjectId) {
|
|
2100
|
+
const drMapData = await this._getDrMap(sceneObjectId);
|
|
2101
|
+
if (drMapData !== null) this.dispatchEvent(new CustomEvent("drmaploaded", { detail: {
|
|
2102
|
+
bytes: drMapData.bytes,
|
|
2103
|
+
version: drMapData.version,
|
|
2104
|
+
sceneObjectId
|
|
2105
|
+
} }));
|
|
2106
|
+
const reflBuffer = await this._getFeatureMesh(sceneObjectId, Engine.Feature.ReflMesh, "reflMesh");
|
|
2107
|
+
if (reflBuffer !== null) this.dispatchEvent(new CustomEvent("reflmeshloaded", { detail: {
|
|
2108
|
+
buffer: reflBuffer,
|
|
2109
|
+
sceneObjectId
|
|
2110
|
+
} }));
|
|
2111
|
+
const glassBuffer = await this._getFeatureMesh(sceneObjectId, Engine.Feature.GlassMesh, "glassMesh");
|
|
2112
|
+
if (glassBuffer !== null) this.dispatchEvent(new CustomEvent("glassmeshloaded", { detail: {
|
|
2113
|
+
buffer: glassBuffer,
|
|
2114
|
+
sceneObjectId
|
|
2115
|
+
} }));
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* @internal
|
|
2119
|
+
*/
|
|
2120
|
+
_onSceneLoaded() {
|
|
2121
|
+
this.#updateSceneCameraData();
|
|
2122
|
+
this.dispatchEvent(new Event("sceneloaded"));
|
|
2123
|
+
}
|
|
2124
|
+
delete(stream) {
|
|
2125
|
+
this.#streams.delete(stream);
|
|
2126
|
+
this.#streamObjectIdToStream.delete(stream.id);
|
|
2127
|
+
if (Stream.forId(stream.id)) stream.end();
|
|
2128
|
+
}
|
|
2129
|
+
close() {
|
|
2130
|
+
for (const stream of this.streams) stream.end();
|
|
2131
|
+
Scene.#idMap.delete(this.id);
|
|
2132
|
+
Scene.#keyMap.delete(this.key);
|
|
2133
|
+
if (this.miris.scenes.has(this)) this.miris.delete(this);
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
//#endregion
|
|
2137
|
+
export { Camera, Lod, LodStore, Miris, ModelRoot, Scene, Stream };
|