@nebula-spatial/viewer 0.5.2 → 0.5.3

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