@nebula-spatial/viewer 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,878 +0,0 @@
1
- var Ce = Object.defineProperty;
2
- var Re = (s, e, o) => e in s ? Ce(s, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : s[e] = o;
3
- var $ = (s, e, o) => Re(s, typeof e != "symbol" ? e + "" : e, o);
4
- import { b as X, S as Z } from "./stage-DAhe0IZz.js";
5
- import { U as me, a as Ue, b as Le, i as Pe, c as De, d as Te, D as Fe } from "./index-8TD-Puyo.js";
6
- import { LineBasicMaterial as Ie, MeshBasicMaterial as Ne, DoubleSide as $e, WireframeGeometry as Be, LineSegments as ze, Mesh as ee, EdgesGeometry as Q, Vector3 as de, Color as ke, LinearSRGBColorSpace as xe, SRGBColorSpace as we, MeshPhysicalMaterial as qe, Float32BufferAttribute as H, DataTexture as Ve, RGBAFormat as Je, UnsignedByteType as He, NoColorSpace as We, RepeatWrapping as Xe, LinearFilter as Ye, LinearMipmapLinearFilter as Ke, BufferGeometry as ne, Group as pe, PlaneGeometry as je, BoxGeometry as Se, SphereGeometry as te, Matrix4 as Ze, CylinderGeometry as Me, CapsuleGeometry as Oe, BufferAttribute as se } from "three";
7
- function he(s, e, o) {
8
- if (e.throwIfAborted(), s instanceof Error && (s.name === "AbortError" || ["E_ABORTED", "E_SUPERSEDED"].includes(String(s.code)))) throw s;
9
- const t = s && typeof s == "object" && "code" in s && typeof s.code == "string" ? s.code : "E_PHYSICS_INITIALIZE", r = s instanceof Error ? s.message : String(s);
10
- return { code: t, source: o, message: `无法启用物理仿真(${o}):${r}` };
11
- }
12
- class _e {
13
- constructor(e, o) {
14
- $(this, "root");
15
- $(this, "bodies", /* @__PURE__ */ new Map());
16
- $(this, "links", /* @__PURE__ */ new Map());
17
- $(this, "disposed", !1);
18
- this.runtime = e, this.root = o.root;
19
- const t = e.mujoco, r = e.model;
20
- for (const [l, n] of o.bindings) {
21
- const c = t.mj_name2id(r, t.mjtObj.mjOBJ_BODY.value, l);
22
- if (c < 0) throw ge(`Physics body missing for visual link: ${l}`, "E_SIMULATION_BIND");
23
- this.links.set(l, n), n.userData.bodyId = c, this.bodies.set(c, n);
24
- }
25
- if (this.bodies.size !== o.expectedLinkCount) throw ge("Visual body binding count mismatch.", "E_SIMULATION_BIND");
26
- this.sync();
27
- }
28
- objectForLink(e) {
29
- return this.links.get(e) ?? null;
30
- }
31
- bodyPoses() {
32
- return new Map([...this.bodies.values()].map((e) => [e.name, { position: e.position.clone(), quaternion: e.quaternion.clone() }]));
33
- }
34
- sync() {
35
- if (this.disposed || !this.runtime.data) return;
36
- const { xpos: e, xquat: o } = this.runtime.data;
37
- for (const [t, r] of this.bodies) {
38
- const l = t * 3, n = t * 4;
39
- r.position.set(e[l], e[l + 1], e[l + 2]), r.quaternion.set(o[n + 1], o[n + 2], o[n + 3], o[n]);
40
- }
41
- this.root.updateMatrixWorld(!0);
42
- }
43
- dispose() {
44
- this.disposed || (this.disposed = !0, this.bodies.clear(), this.links.clear(), X(this.root));
45
- }
46
- }
47
- function ge(s, e) {
48
- return Object.assign(new Error(s), { code: e });
49
- }
50
- class Qe {
51
- constructor(e) {
52
- $(this, "entries", /* @__PURE__ */ new Map());
53
- $(this, "objectUrls", /* @__PURE__ */ new Map());
54
- /**
55
- * Reads that already failed, so a missing resource is not requested again by
56
- * the visual adapter after the reference prefetch has recorded it.
57
- */
58
- $(this, "failures", /* @__PURE__ */ new Map());
59
- this.source = e;
60
- const o = e.original;
61
- if (tt(o))
62
- for (const t of o.files) this.entries.set(P(t.path), t.file);
63
- else typeof Blob < "u" && o instanceof Blob ? this.entries.set(e.entryPath ?? e.filename ?? "asset", o) : o instanceof ArrayBuffer ? this.entries.set(e.entryPath ?? e.filename ?? "asset", new Blob([o])) : typeof o == "object" && o !== null && "kind" in o && o.kind === "buffer" && this.entries.set(e.entryPath ?? e.filename ?? "asset", new Blob([o.buffer]));
64
- }
65
- paths() {
66
- return [...this.entries.keys()];
67
- }
68
- hasLocalFiles() {
69
- return this.entries.size > 0;
70
- }
71
- put(e, o) {
72
- this.entries.set(P(e), o);
73
- }
74
- asSourceRecord(e = "", o = !1) {
75
- const t = P(e), r = t ? `${t}/` : "", l = {};
76
- for (const [n, c] of this.entries)
77
- if (!r || n.startsWith(r)) l[r ? n.slice(r.length) : n] = c;
78
- else if (o) {
79
- const i = t.split("/"), a = n.split("/");
80
- let d = 0;
81
- for (; d < i.length && i[d] === a[d]; ) d++;
82
- l[[...i.slice(d).map(() => ".."), ...a.slice(d)].join("/")] = c;
83
- }
84
- return l;
85
- }
86
- resolve(e, o = "") {
87
- const t = this.find(e, o);
88
- if (t) return t;
89
- const r = P(o).split("/").slice(0, -1).join("/");
90
- if (this.source.url) return P(`${r}/${e.replace(/^package:\/\//, "")}`);
91
- throw B(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
92
- }
93
- find(e, o = "") {
94
- const t = P(e.replace(/^package:\/\//, ""));
95
- if (W(t)) return this.entries.has(t) ? t : null;
96
- const r = P(o).split("/").slice(0, -1).join("/");
97
- for (const n of [P(`${r}/${e.replace(/^package:\/\//, "")}`), t])
98
- if (this.entries.has(n)) return n;
99
- const l = this.paths().filter(
100
- (n) => !W(n) && (n === t || n.endsWith(`/${t}`) || t.endsWith(`/${n}`))
101
- );
102
- return l.length === 1 ? l[0] : null;
103
- }
104
- async text(e) {
105
- await this.ensure(e);
106
- const o = this.entries.get(this.resolve(e));
107
- if (!o) throw B(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
108
- return o.text();
109
- }
110
- async bytes(e) {
111
- await this.ensure(e);
112
- const o = this.entries.get(this.resolve(e));
113
- if (!o) throw B(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
114
- return new Uint8Array(await o.arrayBuffer());
115
- }
116
- getBlob(e) {
117
- const o = this.resolve(e), t = this.entries.get(o);
118
- if (!t) throw B(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
119
- return t;
120
- }
121
- async ensure(e) {
122
- const o = P(e);
123
- if (this.entries.has(o)) return;
124
- const t = this.failures.get(o);
125
- if (t) throw t;
126
- try {
127
- const r = await this.source.resolve(o);
128
- if (!/^https?:\/\//i.test(r) && !/^blob:/i.test(r))
129
- throw B(`Simulation resource not found: ${e}. Upload the complete asset folder or provide a resourceResolver/baseUrl.`, me);
130
- const l = await fetch(r, { signal: this.source.signal });
131
- if (!l.ok) {
132
- const i = l.status === 401 || l.status === 403 ? Ue : l.status === 404 || l.status === 410 ? me : Le;
133
- throw B(`Simulation resource request failed (${l.status}): ${r}`, i);
134
- }
135
- const n = await l.blob();
136
- this.source.signal.throwIfAborted();
137
- const c = await Pe(n);
138
- if (c) throw B(`Simulation resource is not usable (${c}): ${r}`, De);
139
- this.entries.set(o, n);
140
- } catch (r) {
141
- throw Te(r) === "aborted" || this.failures.set(o, r instanceof Error ? r : new Error(String(r))), r;
142
- }
143
- }
144
- /** The recorded failure for a resource, if a previous read already failed. */
145
- failureOf(e) {
146
- return this.failures.get(P(e));
147
- }
148
- objectUrl(e) {
149
- const o = this.resolve(e);
150
- let t = this.objectUrls.get(o);
151
- return t || (t = URL.createObjectURL(this.getBlob(o)), this.objectUrls.set(o, t)), t;
152
- }
153
- objectUrlIfPresent(e, o = "") {
154
- if (W(e)) return this.entries.has(e) ? this.objectUrl(e) : null;
155
- const t = P(o), r = t ? `${t}/` : "", l = P(e), n = r ? this.paths().filter((i) => {
156
- if (!i.startsWith(r)) return !1;
157
- const a = i.slice(r.length);
158
- return a === l || l.endsWith(`/${a}`);
159
- }) : [], c = n.length === 1 ? n[0] : this.find(e);
160
- return c ? this.objectUrl(c) : null;
161
- }
162
- dispose() {
163
- for (const e of this.objectUrls.values()) URL.revokeObjectURL(e);
164
- this.objectUrls.clear(), this.entries.clear(), this.failures.clear();
165
- }
166
- }
167
- async function et(s, e) {
168
- if (e.hasLocalFiles()) return e.text(s.entryPath ?? s.filename ?? e.paths()[0]);
169
- const o = await fetch(s.url ?? await s.resolve(s.entryPath ?? ""), { signal: s.signal });
170
- if (!o.ok) throw B(`Simulation asset request failed: ${o.status}`, "E_ASSET_FETCH");
171
- return o.text();
172
- }
173
- function Nt(s) {
174
- return P(s);
175
- }
176
- function P(s) {
177
- if (W(s)) return s;
178
- const e = [];
179
- for (const o of s.replaceAll("\\", "/").split("/"))
180
- !o || o === "." || (o === ".." && e.length && e.at(-1) !== ".." ? e.pop() : e.push(o));
181
- return e.join("/");
182
- }
183
- function W(s) {
184
- return /^[a-z][a-z\d+.-]*:/i.test(s) && !/^package:\/\//i.test(s);
185
- }
186
- function tt(s) {
187
- return typeof s == "object" && s !== null && "kind" in s && s.kind === "files";
188
- }
189
- function B(s, e) {
190
- return Object.assign(new Error(s), { code: e });
191
- }
192
- function st() {
193
- return { errors: [], warnings: [], approximations: [], droppedFeatures: [] };
194
- }
195
- function ot(s, e = {}) {
196
- const o = Object.freeze({ schemaVersion: 1, ...s });
197
- return rt(o, e), o;
198
- }
199
- function rt(s, e = {}) {
200
- if (!s.id.trim() || !s.name.trim()) throw V("Asset IR id and name are required.", "E_ASSET_IR_INVALID");
201
- if (s.source.format !== "usd" && s.links.length === 0) throw V("Asset IR requires at least one link.", "E_ASSET_IR_INVALID");
202
- const o = /* @__PURE__ */ new Set();
203
- for (const r of s.links) {
204
- if (!r.id || o.has(r.id)) throw V(`Invalid or duplicate link: ${r.id}`, "E_ASSET_IR_INVALID");
205
- o.add(r.id);
206
- }
207
- const t = /* @__PURE__ */ new Set();
208
- for (const r of s.joints) {
209
- if (!r.id || t.has(r.id) || !e.allowInvalidGraph && (!o.has(r.parent) || !o.has(r.child)))
210
- throw V(`Invalid joint: ${r.id}`, "E_ASSET_IR_INVALID");
211
- t.add(r.id);
212
- }
213
- }
214
- function V(s, e) {
215
- return Object.assign(new Error(s), { code: e });
216
- }
217
- async function nt(s, e, o) {
218
- var i;
219
- const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), n = async (a, d) => {
220
- if (l.has(a)) throw oe(`MJCF include cycle: ${a}`, "E_MJCF_INCLUDE_CYCLE");
221
- l.add(a);
222
- const p = ct(d, a);
223
- t.set(a, p);
224
- for (const S of p.querySelectorAll("worldbody body[name]")) r.add(S.getAttribute("name"));
225
- for (const S of p.querySelectorAll("include[file]")) {
226
- const E = o.resolve(S.getAttribute("file"), a);
227
- await n(E, await o.text(E));
228
- }
229
- l.delete(a);
230
- };
231
- await n(e, s);
232
- const c = (i = t.get(e)) == null ? void 0 : i.querySelector("mujoco");
233
- if (!c || r.size === 0) throw oe("MJCF requires a mujoco root and at least one named body.", "E_MJCF_PARSE");
234
- return ot({
235
- id: c.getAttribute("model") || e,
236
- name: c.getAttribute("model") || e,
237
- source: { format: "mjcf", uri: e },
238
- links: [...r].map((a) => ({ id: a, name: a, visuals: [], collisions: [] })),
239
- joints: [],
240
- diagnostics: st(),
241
- extension: { files: o, xml: s, documents: t }
242
- });
243
- }
244
- async function it(s) {
245
- const e = s.extension.files, o = s.source.uri, t = o.split("/").slice(0, -1).join("/"), r = /* @__PURE__ */ new Map(), l = s.extension.documents;
246
- for (const [i, a] of l) {
247
- const d = a.querySelector("compiler");
248
- for (const p of a.querySelectorAll("asset [file]")) {
249
- const S = (d == null ? void 0 : d.getAttribute(p.tagName === "texture" ? "texturedir" : "meshdir")) ?? (d == null ? void 0 : d.getAttribute("assetdir")) ?? "", E = e.resolve(`${S}/${p.getAttribute("file")}`, i);
250
- await e.bytes(E);
251
- }
252
- }
253
- for (const i of ut(e.paths(), l)) {
254
- if (i === o) continue;
255
- const a = t && i.startsWith(`${t}/`) ? i.slice(t.length + 1) : i;
256
- r.set(a, await e.bytes(i));
257
- }
258
- const n = s.extension.xml;
259
- return { format: "mjcf", xml: at(l) ? lt(n) : n, files: r };
260
- }
261
- function at(s) {
262
- return s.size === 0 || ![...s.values()].some((o) => o.querySelector("freejoint, actuator") ? !0 : [...o.querySelectorAll("joint")].some(
263
- (t) => (t.getAttribute("type") ?? "hinge").toLowerCase() !== "fixed"
264
- )) ? !1 : ![...s.values()].some(
265
- (o) => [...o.querySelectorAll("worldbody geom")].some((t) => {
266
- var r;
267
- return ((r = t.getAttribute("type")) == null ? void 0 : r.toLowerCase()) === "plane";
268
- })
269
- );
270
- }
271
- function lt(s) {
272
- const e = '<geom name="__viewer_default_ground__" type="plane" size="5 5 0.1" contype="1" conaffinity="1" friction="0.8 0.01 0.0002"/>';
273
- return /<worldbody\b[^>]*>/i.test(s) ? s.replace(/(<worldbody\b[^>]*>)/i, `$1${e}`) : s.replace(/<\/mujoco\s*>/i, `<worldbody>${e}</worldbody></mujoco>`);
274
- }
275
- function ut(s, e) {
276
- const o = (c) => c.replaceAll("\\", "/").split("/").pop() ?? "", t = /* @__PURE__ */ new Map();
277
- for (const c of s) {
278
- const i = o(c), a = t.get(i) ?? [];
279
- a.push(c), t.set(i, a);
280
- }
281
- const r = new Set(e.keys()), l = /* @__PURE__ */ new Set(["include", "mesh", "texture", "hfield", "skin"]), n = /* @__PURE__ */ new Set(["fileleft", "fileright", "fileup", "filedown", "filefront", "fileback"]);
282
- for (const c of e.values()) {
283
- if (c.querySelector("plugin, extension, model, attach")) return s;
284
- for (const i of c.querySelectorAll("*"))
285
- for (const a of i.attributes) {
286
- if (!a.name.startsWith("file")) continue;
287
- if (a.name === "file") {
288
- if (!l.has(i.tagName)) return s;
289
- } else if (!(i.tagName === "texture" && n.has(a.name)))
290
- return s;
291
- if (!a.value) continue;
292
- const d = t.get(o(a.value));
293
- if (!d) return s;
294
- for (const p of d) r.add(p);
295
- }
296
- }
297
- return s.filter((c) => r.has(c));
298
- }
299
- function ct(s, e) {
300
- const o = new DOMParser().parseFromString(s, "application/xml"), t = o.querySelector("parsererror");
301
- if (t) throw oe(`MJCF XML parse failed (${e}): ${t.textContent ?? ""}`, "E_MJCF_PARSE");
302
- return o;
303
- }
304
- function oe(s, e) {
305
- return Object.assign(new Error(s), { code: e });
306
- }
307
- const ve = 3073715, $t = 16758861, ft = 0.96, mt = 0.1, dt = 20, pt = 1;
308
- function ht(s = ve) {
309
- return new Ie({
310
- color: s,
311
- transparent: !0,
312
- opacity: ft,
313
- depthTest: !1,
314
- depthWrite: !1,
315
- linewidth: 2,
316
- toneMapped: !1,
317
- fog: !1
318
- });
319
- }
320
- function _t(s = ve) {
321
- return new Ne({
322
- color: s,
323
- transparent: !0,
324
- opacity: mt,
325
- depthTest: !0,
326
- depthWrite: !1,
327
- side: $e,
328
- polygonOffset: !0,
329
- polygonOffsetFactor: -1,
330
- polygonOffsetUnits: -1,
331
- toneMapped: !1,
332
- fog: !1
333
- });
334
- }
335
- function gt(s, e, o = "feature", t) {
336
- const r = o === "mesh" ? new Be(s) : yt(s), l = new ze(r, e);
337
- if (l.renderOrder = 9, t) {
338
- const n = new ee(s.clone(), t);
339
- n.name = "collision-volume", n.renderOrder = 8, n.userData.collisionDebugRole = "volume", l.add(n), l.userData.collisionDebugRole = "outline";
340
- }
341
- return l;
342
- }
343
- function yt(s) {
344
- let e = new Q(s, dt);
345
- return ye(s, e) || (e.dispose(), e = new Q(s, pt)), ye(s, e) || (e.dispose(), e = new Q(s, 0)), e;
346
- }
347
- const bt = 256, Et = 0.5;
348
- function ye(s, e) {
349
- var c, i;
350
- const o = e.getAttribute("position");
351
- if (!o || o.count === 0) return !1;
352
- const t = s.getAttribute("position");
353
- if (!t || t.count < bt) return !0;
354
- s.computeBoundingBox(), e.computeBoundingBox();
355
- const r = (c = s.boundingBox) == null ? void 0 : c.getSize(new de()), l = (i = e.boundingBox) == null ? void 0 : i.getSize(new de());
356
- if (!r || !l) return !1;
357
- const n = r.length();
358
- return !Number.isFinite(n) || n <= 0 ? !0 : l.length() / n >= Et;
359
- }
360
- const Y = 0.5, k = (s, e) => Number.isFinite(s) ? Math.min(1, Math.max(0, s)) : e;
361
- function be(s, e) {
362
- return s !== void 0 && Number.isFinite(s) && s >= 0 ? k(s, Y) : e !== void 0 && Number.isFinite(e) && e >= 0 ? 1 - k(e, 0.5) : Y;
363
- }
364
- function wt(s = {}) {
365
- const e = s.color ?? [0.68, 0.72, 0.7, 1], o = new ke().setRGB(e[0], e[1], e[2], s.colorSpace === "linear" ? xe : we), t = k(e[3] ?? 1, 1), r = k(s.specular ?? 0.5, 0.5), l = Math.sqrt(0.08 * r);
366
- return new qe({
367
- color: o,
368
- opacity: t,
369
- transparent: t < 1,
370
- depthWrite: t === 1,
371
- roughness: k(s.roughness ?? Y, Y),
372
- metalness: k(s.metalness ?? 0, 0),
373
- // Legacy specular 0.5 corresponds to the standard dielectric response.
374
- specularIntensity: r <= 0.5 ? r * 2 : 1,
375
- ior: r <= 0.5 ? 1.5 : (1 + l) / (1 - l),
376
- emissive: o.clone().multiplyScalar(Math.max(0, s.emission ?? 0)),
377
- map: s.map ?? null
378
- });
379
- }
380
- function jt(s, e) {
381
- var S, E;
382
- const o = [], t = [], r = [], l = s.mesh_vertadr[e], n = s.mesh_faceadr[e], c = s.mesh_normaladr[e], i = s.mesh_texcoordadr[e];
383
- let a = c >= 0, d = i >= 0;
384
- for (let _ = 0; _ < s.mesh_facenum[e]; _++) for (let w = 0; w < 3; w++) {
385
- const m = (n + _) * 3 + w, b = (l + s.mesh_face[m]) * 3;
386
- o.push(...s.mesh_vert.slice(b, b + 3));
387
- const g = ((S = s.mesh_facenormal) == null ? void 0 : S[m]) ?? -1;
388
- c >= 0 && g >= 0 ? t.push(...s.mesh_normal.slice((c + g) * 3, (c + g) * 3 + 3)) : a = !1;
389
- const j = ((E = s.mesh_facetexcoord) == null ? void 0 : E[m]) ?? -1;
390
- i >= 0 && j >= 0 ? r.push(...s.mesh_texcoord.slice((i + j) * 2, (i + j) * 2 + 2)) : d = !1;
391
- }
392
- const p = new ne();
393
- return p.setAttribute("position", new H(o, 3)), a && t.length === o.length ? p.setAttribute("normal", new H(t, 3)) : p.computeVertexNormals(), d && r.length === o.length / 3 * 2 && p.setAttribute("uv", new H(r, 2)), p;
394
- }
395
- function St(s) {
396
- const e = /* @__PURE__ */ new Map();
397
- if (!s.model.ntex) return e;
398
- const o = s.mujoco, t = s.model, r = new o.MjvScene(t, Math.max(1e3, t.ngeom * 2)), l = new o.MjvOption(), n = new o.MjvPerturb(), c = new o.MjvCamera();
399
- try {
400
- l.geomgroup.fill(1), o.mjv_updateScene(t, s.data, l, n, c, o.mjtCatBit.mjCAT_ALL.value, r);
401
- for (let i = 0; i < r.ngeom; i++) {
402
- const a = r.geoms.get(i);
403
- try {
404
- a.objtype === o.mjtObj.mjOBJ_GEOM.value && e.set(a.objid, a.texuniform !== 0);
405
- } finally {
406
- a.delete();
407
- }
408
- }
409
- return e;
410
- } finally {
411
- r.delete(), l.delete(), n.delete(), c.delete();
412
- }
413
- }
414
- function Mt(s, e, o, t, r, l = /* @__PURE__ */ new Map()) {
415
- var w;
416
- const n = s.model, c = s.mujoco, i = n.geom_matid[e];
417
- if (i < 0) return;
418
- const a = (m, b) => {
419
- r != null && r.droppedFeatures.some((g) => g.code === m && g.source === `material:${i}`) || r == null || r.droppedFeatures.push({ code: m, message: b, source: `material:${i}` });
420
- };
421
- n.mat_reflectance[i] > 0 && a("MJCF_REFLECTANCE_UNSUPPORTED", "Legacy planar reflection is not reproduced by the PBR material.");
422
- const d = c.mjtTextureRole.mjNTEXROLE.value;
423
- if (!Array.from(n.mat_texid.slice(i * d, (i + 1) * d)).some((m) => Number(m) >= 0)) return;
424
- const E = !(n.geom_type[e] === c.mjtGeom.mjGEOM_MESH.value) || !o.getAttribute("uv"), _ = l.get(e);
425
- if (_ === void 0) throw new Error(`Missing compiled texture projection for geom ${e}`);
426
- if (E) {
427
- const m = o.getAttribute("position"), b = [], g = n.geom_size[e * 3] || 1, j = n.geom_size[e * 3 + 1] || g;
428
- for (let v = 0; v < m.count; v++) b.push(m.getX(v) / (2 * (_ ? 1 : g)), -m.getY(v) / (2 * (_ ? 1 : j)));
429
- o.setAttribute("uv", new H(b, 2));
430
- }
431
- for (let m = 0; m < d; m++) {
432
- const b = n.mat_texid[i * d + m];
433
- if (b < 0) continue;
434
- if (n.tex_type[b] !== c.mjtTexture.mjTEXTURE_2D.value) {
435
- a("MJCF_TEXTURE_PROJECTION_UNSUPPORTED", "Cube/skybox surface textures require a dedicated projection and are not substituted with a 2D map.");
436
- continue;
437
- }
438
- if (m === 0) {
439
- a("MJCF_USER_TEXTURE_UNSUPPORTED", "User texture role has no defined PBR material slot.");
440
- continue;
441
- }
442
- const g = n.tex_width[b], j = n.tex_height[b], v = n.tex_nchannel[b];
443
- if (![1, 2, 3, 4].includes(v)) {
444
- a("MJCF_TEXTURE_CHANNELS_UNSUPPORTED", "Unsupported texture channel count.");
445
- continue;
446
- }
447
- const O = Number(n.tex_adr[b]), u = new Uint8Array(g * j * 4);
448
- for (let G = 0; G < g * j; G++) {
449
- const U = O + G * v, L = G * 4, T = n.tex_data[U];
450
- u[L] = T, u[L + 1] = v >= 3 ? n.tex_data[U + 1] : T, u[L + 2] = v >= 3 ? n.tex_data[U + 2] : T, u[L + 3] = v === 4 ? n.tex_data[U + 3] : v === 2 ? n.tex_data[U + 1] : 255, [2, 3, 4, 6].includes(m) && (u[L] = u[L + 1] = u[L + 2] = T);
451
- }
452
- const f = new Ve(u, g, j, Je, He);
453
- f.colorSpace = [1, 7, 8].includes(m) && n.tex_colorspace[b] === c.mjtColorSpace.mjCOLORSPACE_SRGB.value ? we : We, f.wrapS = f.wrapT = Xe, f.magFilter = Ye, f.minFilter = Ke, f.generateMipmaps = !0;
454
- const A = n.mat_texrepeat[i * 2], C = n.mat_texrepeat[i * 2 + 1];
455
- if (f.repeat.set(A, C), E ? f.offset.set(-0.5, -0.5) : _ && f.repeat.set(A * (n.geom_size[e * 3] || 1), C * (n.geom_size[e * 3 + 1] || 1)), f.needsUpdate = !0, m === 1 || m === 8)
456
- (w = t.map) == null || w.dispose(), t.map = f, m === 8 && (t.transparent = !0, t.depthWrite = !1);
457
- else if (m === 2) t.aoMap = f;
458
- else if (m === 3)
459
- t.roughnessMap = f, t.roughness = n.mat_roughness[i] >= 0 ? t.roughness : 1;
460
- else if (m === 4)
461
- t.metalnessMap = f, t.metalness = n.mat_metallic[i] >= 0 ? t.metalness : 1;
462
- else if (m === 5) t.normalMap = f;
463
- else if (m === 6)
464
- t.alphaMap = f, t.transparent = !0, t.depthWrite = !1;
465
- else if (m === 7)
466
- t.emissiveMap = f, t.emissive.setRGB(1, 1, 1), v === 4 && a("MJCF_EMISSIVE_EXPOSURE_UNSUPPORTED", "Emissive RGB is preserved; per-pixel exposure weight is not supported.");
467
- else if (m === 9) {
468
- for (const G of /* @__PURE__ */ new Set([t.aoMap, t.roughnessMap, t.metalnessMap])) G == null || G.dispose();
469
- t.aoMap = t.roughnessMap = t.metalnessMap = f, t.roughness = n.mat_roughness[i] >= 0 ? t.roughness : 1, t.metalness = n.mat_metallic[i] >= 0 ? t.metalness : 1;
470
- }
471
- }
472
- }
473
- function Ot(s, e) {
474
- return e < 0 ? be() : be(s.mat_roughness[e], s.mat_shininess[e]);
475
- }
476
- function vt(s, e) {
477
- if (e < 0) return 0;
478
- const o = s.mat_metallic[e];
479
- return Number.isFinite(o) && o >= 0 ? o : 0;
480
- }
481
- function Ee(s, e = !1, o) {
482
- const t = s.model, r = s.mujoco, l = new pe();
483
- l.name = "MuJoCo scene";
484
- const n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
485
- for (let i = 1; i < t.nbody; i += 1) {
486
- const a = r.mj_id2name(t, r.mjtObj.mjOBJ_BODY.value, i);
487
- if (!a) continue;
488
- const d = new pe();
489
- d.name = a, d.userData.bodyId = i, n.set(i, d), c.set(a, d), l.add(d);
490
- }
491
- try {
492
- if (n.set(0, l), e) {
493
- const i = ht(), a = _t();
494
- let d = 0;
495
- for (let p = 0; p < t.ngeom; p += 1) {
496
- const S = r.mj_id2name(t, r.mjtObj.mjOBJ_GEOM.value, p);
497
- if (S === "__viewer_default_ground__" || !Ct(t, p)) continue;
498
- const E = n.get(t.geom_bodyid[p]), _ = At(s, p);
499
- if (!E) continue;
500
- if (!_) {
501
- o == null || o.droppedFeatures.push({
502
- code: "E_MJCF_COLLISION_DEBUG_GEOMETRY_UNAVAILABLE",
503
- message: `MJCF geom ${S ?? `#${p}`} 的 compiled type=${t.geom_type[p]} 无法准确还原为碰撞线框。`,
504
- source: "mjcf-collision-debug"
505
- });
506
- continue;
507
- }
508
- const w = Gt(s, p) ? "mesh" : "feature", m = gt(_, i, w, a);
509
- _.dispose(), m.userData.geomId = p, d += 1;
510
- const b = p * 3, g = p * 4;
511
- m.position.fromArray(t.geom_pos, b), m.quaternion.set(t.geom_quat[g + 1], t.geom_quat[g + 2], t.geom_quat[g + 3], t.geom_quat[g]), E.add(m);
512
- }
513
- d === 0 && (i.dispose(), a.dispose());
514
- } else {
515
- const i = St(s);
516
- for (let a = 0; a < t.ngeom; a += 1) {
517
- if (t.geom_group[a] > 2 || r.mj_id2name(t, r.mjtObj.mjOBJ_GEOM.value, a) === "__viewer_default_ground__") continue;
518
- const d = n.get(t.geom_bodyid[a]), p = Lt(s, a);
519
- if (!d || !p) continue;
520
- const S = a * 4, E = t.geom_matid[a], _ = Array.from(t.geom_rgba.slice(S, S + 4));
521
- E >= 0 && [0.5, 0.5, 0.5, 1].every((j, v) => _[v] === j) && _.splice(0, 4, ...Array.from(t.mat_rgba.slice(E * 4, E * 4 + 4)));
522
- const w = wt({
523
- color: _,
524
- roughness: Ot(t, E),
525
- metalness: vt(t, E),
526
- specular: E >= 0 ? t.mat_specular[E] : void 0,
527
- emission: E >= 0 ? t.mat_emission[E] : void 0
528
- });
529
- try {
530
- Mt(s, a, p, w, o, i);
531
- } catch (j) {
532
- throw X(new ee(p, w)), j;
533
- }
534
- const m = new ee(p, w), b = a * 3, g = a * 4;
535
- t.geom_bodyid[a] === 0 && t.geom_type[a] === r.mjtGeom.mjGEOM_PLANE.value && (m.userData.excludeFromSimulationFit = !0), m.position.fromArray(t.geom_pos, b), m.quaternion.set(t.geom_quat[g + 1], t.geom_quat[g + 2], t.geom_quat[g + 3], t.geom_quat[g]), d.add(m);
536
- }
537
- }
538
- return { root: l, bindings: c, expectedLinkCount: c.size };
539
- } catch (i) {
540
- throw X(l), i;
541
- }
542
- }
543
- function At(s, e) {
544
- const o = s.model, t = s.mujoco, r = e * 3, l = o.geom_size[r], n = o.geom_size[r + 1], c = o.geom_size[r + 2], i = o.geom_type[e];
545
- if (i === t.mjtGeom.mjGEOM_PLANE.value) return new je(Math.max(l * 2, 2), Math.max(n * 2, 2), 10, 10);
546
- if (i === t.mjtGeom.mjGEOM_BOX.value) return new Se(l * 2, n * 2, c * 2);
547
- if (i === t.mjtGeom.mjGEOM_SPHERE.value) return new te(l, 20, 12);
548
- if (i === t.mjtGeom.mjGEOM_ELLIPSOID.value) {
549
- const a = new te(1, 24, 16);
550
- return a.applyMatrix4(new Ze().makeScale(l, n, c)), a;
551
- }
552
- if (i === t.mjtGeom.mjGEOM_CYLINDER.value) {
553
- const a = new Me(l, l, n * 2, 24);
554
- return a.rotateX(Math.PI / 2), a;
555
- }
556
- if (i === t.mjtGeom.mjGEOM_CAPSULE.value) {
557
- const a = new Oe(l, n * 2, 6, 16);
558
- return a.rotateX(Math.PI / 2), a;
559
- }
560
- return i === t.mjtGeom.mjGEOM_MESH.value ? Rt(s, o.geom_dataid[e]) : i === t.mjtGeom.mjGEOM_HFIELD.value ? Ut(s, o.geom_dataid[e]) : null;
561
- }
562
- function Gt(s, e) {
563
- const o = s.model.geom_type[e];
564
- return o === s.mujoco.mjtGeom.mjGEOM_MESH.value || o === s.mujoco.mjtGeom.mjGEOM_HFIELD.value;
565
- }
566
- function Ct(s, e) {
567
- if (s.geom_contype[e] !== 0 || s.geom_conaffinity[e] !== 0) return !0;
568
- for (let o = 0; o < s.npair; o += 1) if (s.pair_geom1[o] === e || s.pair_geom2[o] === e) return !0;
569
- return !1;
570
- }
571
- function Rt(s, e) {
572
- const o = s.model, t = o.mesh_graphadr[e];
573
- if (t < 0) return null;
574
- const r = o.mesh_vertadr[e], l = o.mesh_vertnum[e], n = o.mesh_graph[t], c = o.mesh_graph[t + 1];
575
- if (n < 4 || c < 4) return null;
576
- const i = t + 2 + 3 * n + 3 * c, a = new ne();
577
- return a.setAttribute("position", new se(Float32Array.from(o.mesh_vert.subarray(r * 3, (r + l) * 3)), 3)), a.setIndex(new se(Uint32Array.from(o.mesh_graph.subarray(i, i + c * 3)), 1)), a.computeVertexNormals(), a;
578
- }
579
- function Ut(s, e) {
580
- const o = s.model, t = o.hfield_nrow[e], r = o.hfield_ncol[e];
581
- if (t < 2 || r < 2) return null;
582
- const l = o.hfield_adr[e], n = e * 4, c = o.hfield_size[n], i = o.hfield_size[n + 1], a = o.hfield_size[n + 2], d = o.hfield_size[n + 3], p = t * r, S = [];
583
- for (let A = 0; A < t; A += 1) for (let C = 0; C < r; C += 1)
584
- S.push(
585
- -c + 2 * c * C / (r - 1),
586
- -i + 2 * i * A / (t - 1),
587
- o.hfield_data[l + A * r + C] * a
588
- );
589
- const E = [
590
- [-c, -i, -d],
591
- [c, -i, -d],
592
- [-c, i, -d],
593
- [c, i, -d]
594
- ];
595
- for (const A of E) S.push(...A);
596
- const _ = [];
597
- for (let A = 0; A < t - 1; A += 1) for (let C = 0; C < r - 1; C += 1) {
598
- const G = A * r + C, U = G + 1, L = G + r, T = L + 1;
599
- _.push(G, L, U, U, L, T);
600
- }
601
- const w = p, m = p + 1, b = p + 2, g = p + 3;
602
- _.push(w, m, b, m, g, b);
603
- const j = 0, v = r - 1, O = (t - 1) * r, u = t * r - 1;
604
- _.push(w, j, m, m, j, v), _.push(b, g, O, g, u, O), _.push(w, b, j, b, O, j), _.push(m, v, g, g, v, u);
605
- const f = new ne();
606
- return f.setAttribute("position", new se(Float32Array.from(S), 3)), f.setIndex(_), f.computeVertexNormals(), f;
607
- }
608
- function Lt(s, e) {
609
- const o = s.model, t = s.mujoco, r = e * 3, l = o.geom_size[r], n = o.geom_size[r + 1], c = o.geom_size[r + 2], i = o.geom_type[e];
610
- if (i === t.mjtGeom.mjGEOM_PLANE.value) return new je((l || 5) * 2, (n || 5) * 2);
611
- if (i === t.mjtGeom.mjGEOM_BOX.value) return new Se(l * 2, n * 2, c * 2);
612
- if (i === t.mjtGeom.mjGEOM_SPHERE.value) return new te(l, 24, 16);
613
- if (i === t.mjtGeom.mjGEOM_CYLINDER.value) {
614
- const a = new Me(l, l, n * 2, 24);
615
- return a.rotateX(Math.PI / 2), a;
616
- }
617
- if (i === t.mjtGeom.mjGEOM_CAPSULE.value) {
618
- const a = new Oe(l, n * 2, 6, 16);
619
- return a.rotateX(Math.PI / 2), a;
620
- }
621
- return i !== t.mjtGeom.mjGEOM_MESH.value ? null : jt(o, o.geom_dataid[e]);
622
- }
623
- function Pt(s, e) {
624
- const o = new Qe(s);
625
- let t = null, r = null, l = null, n = null, c = null, i = null, a = null, d = null, p = null, S = null, E = null, _ = !1, w = !0, m = !1, b = !1, g = null, j = null, v, O = null, u = null, f = null, A = "z", C = !1;
626
- const G = () => {
627
- u && (A = e.options.upAxis ?? "z", C = !0, u.setUpAxis(A) && (r == null || r.sync(), f == null || f.sync()));
628
- }, U = (y, M) => {
629
- var D;
630
- const R = he(y, e.signal, `${e.format}:${M}`);
631
- w = !1, m = !1, j = { ...R, stage: M };
632
- try {
633
- u == null || u.endGrab();
634
- } catch {
635
- }
636
- (D = e.reportSessionState) == null || D.call(e), e.reportError(y, { fatal: !1, stage: M, code: R.code });
637
- }, L = () => {
638
- _ = !0, w = !1;
639
- }, T = (async () => {
640
- var y, M, R, D, N, ie, ae, le, ue;
641
- try {
642
- const F = e.format;
643
- if (F === "usd" || F === "usda" || F === "usdc" || F === "usdz") {
644
- (y = e.reportProgress) == null || y.call(e, "usd", "正在解析 USD 场景与物理刚体...");
645
- const h = await (await import("./usd-session-BBtKxubs.js")).loadUsdSimulation(s, e, o);
646
- if (_ || e.signal.aborted)
647
- throw h.dispose(), re();
648
- O = h.asset, r = h.binding, l = h.dispose, b = h.hasAnimation === !0, n = h.hasPhysics || b ? h.step : null, c = h.reset, w = h.hasPhysics || b, m = h.hasPhysics, g = h.fallback ? { ...h.fallback, stage: "physics-fallback" } : h.visualWarning ? { ...h.visualWarning, stage: "visual-adaptation" } : null, (M = e.reportProgress) == null || M.call(e, "stage", "正在构建三维场景与环境光影..."), u = new Z(
649
- r.root,
650
- e.options.simulationTheme,
651
- h.runtime,
652
- "simulation",
653
- h.hasPhysics ? "physics" : "visual"
654
- ), h.runtime && (t = h.runtime), f = h.collision ?? null, f && (f.root.visible = !1, u.attachAuxiliary(f.root)), G();
655
- return;
656
- }
657
- if (F === "urdf" || F === "xacro") {
658
- (R = e.reportProgress) == null || R.call(e, "urdf", "正在解析 URDF 场景与运动学结构...");
659
- const h = await (await import("./urdf-session-DceYWCib.js")).loadUrdfSimulation(s, e, o);
660
- if (_ || e.signal.aborted)
661
- throw h.dispose(), re();
662
- O = h.asset, u = h.stage, p = h.inspection, l = h.dispose, n = h.step, c = h.reset, i = h.play, a = h.pause, d = h.isPlaying, S = () => h.capabilities, E = () => h.physics, w = !1, m = !1, g = h.warning ?? null, G();
663
- return;
664
- }
665
- let x = s.entryPath ?? s.filename;
666
- if (!x && F === "mjcf") {
667
- const I = o.paths().filter((h) => h.toLowerCase().endsWith(".xml"));
668
- for (const h of ["scene.xml", "model.xml", "main.xml"]) {
669
- const q = I.find((z) => z.toLowerCase().endsWith(`/${h}`) || z.toLowerCase() === h);
670
- if (q) {
671
- x = q;
672
- break;
673
- }
674
- }
675
- }
676
- x ?? (x = "asset.xml"), (D = e.reportProgress) == null || D.call(e, "fetch", "正在读取模型描述与依赖资源...");
677
- const Ae = await et(s, o);
678
- J(_, e.signal), (N = e.reportProgress) == null || N.call(e, "parse", "正在解析 MJCF 场景与连杆..."), O = await nt(Ae, x, o);
679
- try {
680
- (ie = e.reportProgress) == null || ie.call(e, "compile", "正在编译物理模型与参数...");
681
- const I = await it(O);
682
- J(_, e.signal), (ae = e.reportProgress) == null || ae.call(e, "runtime", "正在初始化物理内核...");
683
- const { MujocoRuntime: h } = await import("./mujoco-runtime-DTxVmIzc.js");
684
- t = new h(), await t.initialize(I, e.options.mujocoBaseUrl);
685
- } catch (I) {
686
- const h = he(I, e.signal, "mjcf-physics");
687
- t == null || t.dispose(), t = null;
688
- const { compileMjcfPreview: q } = await import("./mjcf-visual-qlID4stF.js");
689
- let z;
690
- try {
691
- z = q(O);
692
- } catch (K) {
693
- throw new Error(`${h.message};独立视觉预览也不可用:${K instanceof Error ? K.message : String(K)}`);
694
- }
695
- r = { root: z, sync() {
696
- }, dispose() {
697
- X(z);
698
- } }, g = { ...h, stage: "physics-fallback" }, u = new Z(z, e.options.simulationTheme, void 0, "simulation", "visual"), w = !1, G();
699
- return;
700
- }
701
- m = !0, J(_, e.signal), (le = e.reportProgress) == null || le.call(e, "visual", "正在构建视觉渲染网格...");
702
- const Ge = Ee(t, !1, O.diagnostics), ce = O.diagnostics.droppedFeatures.find((I) => I.code.startsWith("MJCF_"));
703
- ce && (g = { ...ce, stage: "visual-material" }), J(_, e.signal), (ue = e.reportProgress) == null || ue.call(e, "stage", "正在构建三维场景与环境光影..."), r = new _e(t, Ge), u = new Z(r.root, e.options.simulationTheme, t);
704
- const fe = Ee(t, !0, O.diagnostics);
705
- fe.root.children.length > 0 ? (f = new _e(t, fe), f.root.visible = !1) : f = null, f && u.attachAuxiliary(f.root), G();
706
- } catch (F) {
707
- throw u == null || u.dispose(), u = null, l ? (l(), l = null) : (f == null || f.dispose(), r == null || r.dispose(), t == null || t.dispose()), f = null, r = null, t = null, o.dispose(), F;
708
- }
709
- })();
710
- return T.catch(() => {
711
- }), {
712
- id: `simulation-${Math.random().toString(36).slice(2)}`,
713
- get autoPlay() {
714
- return e.format === "urdf" || e.format === "xacro" ? !1 : void 0;
715
- },
716
- get inspection() {
717
- return p;
718
- },
719
- isPlaying() {
720
- return (d == null ? void 0 : d()) ?? w;
721
- },
722
- opened: T,
723
- get root() {
724
- return (u == null ? void 0 : u.root) ?? null;
725
- },
726
- getFitBounds() {
727
- return (u == null ? void 0 : u.getModelBounds()) ?? null;
728
- },
729
- beforeRender(y, M, R) {
730
- return u == null ? void 0 : u.beforeRender(y, M, R);
731
- },
732
- get capabilities() {
733
- return j ? { canPlay: !1, canPause: !1, canReset: !1, hasPhysics: !1, hasAnimation: !1, canToggleGround: !0, canToggleCollision: f !== null, canReorientUpAxis: !0 } : (S == null ? void 0 : S()) ?? { canPlay: m || b, canPause: m || b, canReset: m || b, hasPhysics: m, hasAnimation: b, canToggleGround: !0, canToggleCollision: f !== null, canReorientUpAxis: !0 };
734
- },
735
- get warning() {
736
- return g;
737
- },
738
- get physics() {
739
- return j ? { status: "unavailable", issue: j } : E ? E() : m ? { status: "ready" } : (g == null ? void 0 : g.stage) === "physics-fallback" ? { status: "unavailable", issue: g } : { status: "not-authored" };
740
- },
741
- setTheme(y) {
742
- u == null || u.setTheme(y);
743
- },
744
- setGroundVisible(y) {
745
- u == null || u.setGroundVisible(y);
746
- },
747
- getGroundVisible() {
748
- return (u == null ? void 0 : u.getGroundVisible()) ?? !0;
749
- },
750
- getGroundGridScale() {
751
- return (u == null ? void 0 : u.getGroundGridScale()) ?? Fe;
752
- },
753
- getUpAxis() {
754
- return u && C ? A : null;
755
- },
756
- setUpAxis(y) {
757
- if (!(_ || !u))
758
- try {
759
- if (!u.setUpAxis(y)) return;
760
- A = y, r == null || r.sync(), f == null || f.sync(), e.requestRender();
761
- } catch (M) {
762
- U(M, "up-axis");
763
- }
764
- },
765
- presentation: { preferredViewMode: "3d", interactionMode: "simulation", uiProfile: "simulation", fitPolicy: "fit-on-ready" },
766
- beginDispose: L,
767
- setCollisionVisible(y) {
768
- if (!_) {
769
- if (S) {
770
- const M = p;
771
- M == null || M.setOverlay("collision", y);
772
- return;
773
- }
774
- if (!f) throw new Error("This asset has no collision display.");
775
- f.root.visible = y;
776
- }
777
- },
778
- getVisualDiagnostics() {
779
- return _ || !O || O.source.format !== "usd" ? null : structuredClone({ report: O.extension.visualAdaptation, diagnostics: O.diagnostics });
780
- },
781
- getPhysicsProperties() {
782
- if (_ || !m || !(t != null && t.model) || !t.mujoco) return null;
783
- const y = t.model, M = t.mujoco;
784
- return structuredClone({
785
- units: { length: "m", mass: "kg", time: "s" },
786
- timestep: y.opt.timestep,
787
- gravity: Array.from(y.opt.gravity),
788
- bodyCount: y.nbody - 1,
789
- jointCount: y.njnt,
790
- geomCount: y.ngeom,
791
- bodies: Array.from({ length: y.nbody - 1 }, (R, D) => {
792
- const N = D + 1;
793
- return { id: N, name: M.mj_id2name(y, M.mjtObj.mjOBJ_BODY.value, N), mass: y.body_mass[N], inertia: Array.from(y.body_inertia.slice(N * 3, N * 3 + 3)) };
794
- }),
795
- diagnostics: O == null ? void 0 : O.diagnostics
796
- });
797
- },
798
- get update() {
799
- return t != null && t.model || n ? (y) => {
800
- if (j || _ || !((d == null ? void 0 : d()) ?? w) || !r && !n) return !1;
801
- try {
802
- if (n) {
803
- const R = n(y);
804
- return R && (f == null || f.sync()), R;
805
- }
806
- const M = t.step(y);
807
- return M && (r.sync(), f == null || f.sync(), u == null || u.updateForceLine()), M;
808
- } catch (M) {
809
- return U(M, "step"), !1;
810
- }
811
- } : void 0;
812
- },
813
- play() {
814
- _ || j || (i ? (i(), w = (d == null ? void 0 : d()) ?? !1) : (m || b) && (w = !0));
815
- },
816
- pause() {
817
- j || (a && a(), w = !1);
818
- },
819
- reset() {
820
- if (!(j || _ || !r && !c))
821
- try {
822
- u == null || u.endGrab(), c ? c() : (t == null || t.reset(), r.sync()), f == null || f.sync(), u == null || u.resetGround(), u == null || u.updateForceLine();
823
- } catch (y) {
824
- U(y, "reset");
825
- }
826
- },
827
- beginGrab(y, M, R) {
828
- if (_ || !m && !E) return !1;
829
- try {
830
- return (u == null ? void 0 : u.beginGrab(y, M, R)) ?? !1;
831
- } catch (D) {
832
- return U(D, "grab"), !1;
833
- }
834
- },
835
- moveGrab(y, M, R) {
836
- if (!(_ || !m && !E))
837
- try {
838
- u == null || u.moveGrab(y, M, R);
839
- } catch (D) {
840
- U(D, "grab");
841
- }
842
- },
843
- endGrab() {
844
- u == null || u.endGrab();
845
- },
846
- dispose() {
847
- return L(), v ?? (v = T.catch(() => {
848
- }).then(() => {
849
- l ? (l(), l = null, u = null, r = null, f = null) : (u == null || u.dispose(), u = null, f == null || f.root.removeFromParent(), f == null || f.dispose(), f = null, r == null || r.dispose(), r = null, t == null || t.dispose()), o.dispose(), O = null, p = null, n = null, c = null, i = null, a = null, d = null, S = null, E = null, m = !1, b = !1, g = null, C = !1;
850
- })), v;
851
- }
852
- };
853
- }
854
- function J(s, e) {
855
- if (s || e.aborted) throw re();
856
- }
857
- function re() {
858
- return Object.assign(new Error("Simulation load aborted."), { name: "AbortError", code: "E_ABORTED" });
859
- }
860
- const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
861
- __proto__: null,
862
- createSimulationSession: Pt
863
- }, Symbol.toStringTag, { value: "Module" }));
864
- export {
865
- $t as C,
866
- _e as S,
867
- _t as a,
868
- gt as b,
869
- ht as c,
870
- ot as d,
871
- st as e,
872
- wt as f,
873
- Bt as g,
874
- Nt as n,
875
- he as p,
876
- et as r,
877
- be as s
878
- };