@nebula-spatial/viewer 0.5.8 → 0.5.9

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,46 +1,46 @@
1
- import { d as Je, f as ze, c as Ve, a as $e, b as Be, g as ke, w as Xe, h as Ie, p as se, S as je, e as He } from "./collision-debug-B9HJ34H8.js";
1
+ import { d as Je, f as ze, c as Ve, a as ke, b as $e, g as Be, w as Xe, h as Ie, p as se, S as je, e as He } from "./collision-debug-FutuxXPm.js";
2
2
  import { disposeModelResources as ae } from "./resources-CHhCm2f7.js";
3
- import { D as We } from "./index-CIMsZtyY.js";
4
- import { S as oe } from "./stage-C2FchK6h.js";
5
- import { Color as Ye, LinearSRGBColorSpace as Ke, SRGBColorSpace as Ce, MeshPhysicalMaterial as Qe, Float32BufferAttribute as Z, DataTexture as Ze, RGBAFormat as xe, UnsignedByteType as et, NoColorSpace as tt, RepeatWrapping as rt, LinearFilter as st, LinearMipmapLinearFilter as ot, BufferGeometry as ce, Group as Ee, Mesh as Ae, PlaneGeometry as Oe, BoxGeometry as Re, SphereGeometry as ie, Matrix4 as nt, CylinderGeometry as Fe, CapsuleGeometry as Ne, BufferAttribute as le } from "three";
3
+ import { D as We } from "./index-BQn4yVNd.js";
4
+ import { S as oe } from "./stage-Ck2xORK4.js";
5
+ import { Color as Ye, LinearSRGBColorSpace as Ke, SRGBColorSpace as Ce, MeshPhysicalMaterial as Qe, Float32BufferAttribute as Z, DataTexture as Ze, RGBAFormat as xe, UnsignedByteType as et, NoColorSpace as tt, RepeatWrapping as rt, LinearFilter as st, LinearMipmapLinearFilter as ot, BufferGeometry as fe, Group as Ee, Mesh as Ae, PlaneGeometry as Oe, BoxGeometry as Re, SphereGeometry as ie, Matrix4 as nt, CylinderGeometry as Fe, CapsuleGeometry as Te, BufferAttribute as le } from "three";
6
6
  const X = 0.7, ne = 0.2, at = 110 * Math.PI / 180;
7
7
  function it(t, e = {}) {
8
8
  const a = t.getSnapshot();
9
9
  if (a.controlMode !== "kinematic" || a.playing) return;
10
10
  const r = [], s = {};
11
11
  let u = X;
12
- for (const b of a.joints) {
13
- if (b.mimic || !["revolute", "prismatic"].includes(b.type) || !Number.isFinite(b.defaultValue)) continue;
14
- const _ = b.controlLimits ?? b.limits;
12
+ for (const v of a.joints) {
13
+ if (v.mimic || !["revolute", "prismatic"].includes(v.type) || !Number.isFinite(v.defaultValue)) continue;
14
+ const _ = v.controlLimits ?? v.limits;
15
15
  if (!_ || !Number.isFinite(_.lower) || !Number.isFinite(_.upper) || _.lower >= _.upper) continue;
16
- const g = b.defaultValue;
16
+ const g = v.defaultValue;
17
17
  if (g < _.lower || g > _.upper) continue;
18
- const G = Math.abs(_.upper - g) >= Math.abs(_.lower - g) ? _.upper : _.lower, R = Math.abs(G - g), E = b.type === "revolute" ? Math.max(0.6, R / at) : Math.max(0.6, 0.8 * R / (_.upper - _.lower));
18
+ const G = Math.abs(_.upper - g) >= Math.abs(_.lower - g) ? _.upper : _.lower, R = Math.abs(G - g), E = v.type === "revolute" ? Math.max(0.6, R / at) : Math.max(0.6, 0.8 * R / (_.upper - _.lower));
19
19
  if (!Number.isFinite(E) || E <= 0) continue;
20
20
  const o = u;
21
- u = o + 2 * E + ne, s[b.id] = g, r.push({ id: b.id, home: g, far: G, duration: E, start: o, end: u });
21
+ u = o + 2 * E + ne, s[v.id] = g, r.push({ id: v.id, home: g, far: G, duration: E, start: o, end: u });
22
22
  }
23
23
  if (!r.length) return;
24
- const f = e.autoPlay !== !1;
25
- let c = f ? 0 : X, n = f, i = !1, v = !1, p = !1, P = !f, M = !1, S = !0, w = f ? !0 : null;
26
- const m = (b) => {
24
+ const c = e.autoPlay !== !1;
25
+ let f = c ? 0 : X, n = c, i = !1, b = !1, p = !1, P = !c, M = !1, S = !0, w = c ? !0 : null;
26
+ const m = (v) => {
27
27
  var _;
28
28
  if (S) {
29
- w = b;
29
+ w = v;
30
30
  return;
31
31
  }
32
- w = null, (_ = e.onPlayingChange) == null || _.call(e, b);
33
- }, h = (b) => {
34
- if (n !== b) {
35
- if (n = b, b) {
32
+ w = null, (_ = e.onPlayingChange) == null || _.call(e, v);
33
+ }, h = (v) => {
34
+ if (n !== v) {
35
+ if (n = v, v) {
36
36
  if (t.setPreviewing(!0), !n || M) return;
37
37
  t.setPlaying(!0);
38
38
  } else
39
39
  t.setPlaying(!1), t.setPreviewing(!1);
40
- n === b && m(b);
40
+ n === v && m(v);
41
41
  }
42
42
  }, y = () => {
43
- M || (f && !v && (p = !0), P = !0, i = !1, h(!1));
43
+ M || (c && !b && (p = !0), P = !0, i = !1, h(!1));
44
44
  }, O = t.onManualInput(y), C = {
45
45
  get playing() {
46
46
  return n;
@@ -53,31 +53,31 @@ function it(t, e = {}) {
53
53
  if (!(M || n)) {
54
54
  if (P || i) {
55
55
  if (t.resetPreviewPose(), M) return;
56
- c = X, i = !1, P = !1;
56
+ f = X, i = !1, P = !1;
57
57
  }
58
58
  h(!0);
59
59
  }
60
60
  },
61
61
  pause() {
62
- M || (f && !v && (p = !0), h(!1));
62
+ M || (c && !b && (p = !0), h(!1));
63
63
  },
64
64
  reset() {
65
- M || (f && !v && (p = !0), h(!1), !M && (c = X, i = !1, P = !1, t.resetPreviewPose()));
65
+ M || (c && !b && (p = !0), h(!1), !M && (f = X, i = !1, P = !1, t.resetPreviewPose()));
66
66
  },
67
67
  dispose() {
68
68
  M || (M = !0, O(), h(!1), w = null);
69
69
  },
70
- update(b) {
70
+ update(v) {
71
71
  var R, E;
72
72
  if (M) return !1;
73
73
  if (w !== null) {
74
74
  const o = w;
75
75
  w = null, (R = e.onPlayingChange) == null || R.call(e, o);
76
76
  }
77
- if (!n || M || !Number.isFinite(b) || b <= 0 || (c += b, c < X)) return !1;
78
- if (c >= u)
79
- return i = !0, P = !0, h(!1), M ? !1 : (t.resetPreviewPose(), f && !p && !v && (v = !0, (E = e.onFinished) == null || E.call(e)), !0);
80
- const _ = r.find((o) => c < o.end), g = c - _.start;
77
+ if (!n || M || !Number.isFinite(v) || v <= 0 || (f += v, f < X)) return !1;
78
+ if (f >= u)
79
+ return i = !0, P = !0, h(!1), M ? !1 : (t.resetPreviewPose(), c && !p && !b && (b = !0, (E = e.onFinished) == null || E.call(e)), !0);
80
+ const _ = r.find((o) => f < o.end), g = f - _.start;
81
81
  let G;
82
82
  if (g < _.duration)
83
83
  G = _.home + (_.far - _.home) * Se(g / _.duration);
@@ -90,31 +90,31 @@ function it(t, e = {}) {
90
90
  return t.setPreviewPose({ ...s, [_.id]: G }), !0;
91
91
  }
92
92
  };
93
- return f && (t.setPreviewing(!0), n && !M && t.setPlaying(!0)), S = !1, C;
93
+ return c && (t.setPreviewing(!0), n && !M && t.setPlaying(!0)), S = !1, C;
94
94
  }
95
95
  function Se(t) {
96
96
  return t * t * t * (t * (6 * t - 15) + 10);
97
97
  }
98
98
  async function lt(t, e, a) {
99
99
  var n;
100
- const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), f = async (i, v) => {
100
+ const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), c = async (i, b) => {
101
101
  if (u.has(i)) throw ue(`MJCF include cycle: ${i}`, "E_MJCF_INCLUDE_CYCLE");
102
102
  u.add(i);
103
- const p = dt(v, i);
103
+ const p = dt(b, i);
104
104
  r.set(i, p);
105
105
  for (const P of p.querySelectorAll("worldbody body[name]")) s.add(P.getAttribute("name"));
106
106
  for (const P of p.querySelectorAll("include[file]")) {
107
107
  const M = a.resolve(P.getAttribute("file"), i);
108
- await f(M, await a.text(M));
108
+ await c(M, await a.text(M));
109
109
  }
110
110
  u.delete(i);
111
111
  };
112
- await f(e, t);
113
- const c = (n = r.get(e)) == null ? void 0 : n.querySelector("mujoco");
114
- if (!c || s.size === 0) throw ue("MJCF requires a mujoco root and at least one named body.", "E_MJCF_PARSE");
112
+ await c(e, t);
113
+ const f = (n = r.get(e)) == null ? void 0 : n.querySelector("mujoco");
114
+ if (!f || s.size === 0) throw ue("MJCF requires a mujoco root and at least one named body.", "E_MJCF_PARSE");
115
115
  return Je({
116
- id: c.getAttribute("model") || e,
117
- name: c.getAttribute("model") || e,
116
+ id: f.getAttribute("model") || e,
117
+ name: f.getAttribute("model") || e,
118
118
  source: { format: "mjcf", uri: e },
119
119
  links: [...s].map((i) => ({ id: i, name: i, visuals: [], collisions: [] })),
120
120
  joints: [],
@@ -125,9 +125,9 @@ async function lt(t, e, a) {
125
125
  async function ut(t) {
126
126
  const e = t.extension.files, a = t.source.uri, r = a.split("/").slice(0, -1).join("/"), s = /* @__PURE__ */ new Map(), u = t.extension.documents;
127
127
  for (const [n, i] of u) {
128
- const v = i.querySelector("compiler");
128
+ const b = i.querySelector("compiler");
129
129
  for (const p of i.querySelectorAll("asset [file]")) {
130
- const P = (v == null ? void 0 : v.getAttribute(p.tagName === "texture" ? "texturedir" : "meshdir")) ?? (v == null ? void 0 : v.getAttribute("assetdir")) ?? "", M = e.resolve(`${P}/${p.getAttribute("file")}`, n);
130
+ const P = (b == null ? void 0 : b.getAttribute(p.tagName === "texture" ? "texturedir" : "meshdir")) ?? (b == null ? void 0 : b.getAttribute("assetdir")) ?? "", M = e.resolve(`${P}/${p.getAttribute("file")}`, n);
131
131
  await e.bytes(M);
132
132
  }
133
133
  }
@@ -136,10 +136,10 @@ async function ut(t) {
136
136
  const i = r && n.startsWith(`${r}/`) ? n.slice(r.length + 1) : n;
137
137
  s.set(i, await e.bytes(n));
138
138
  }
139
- const f = t.extension.xml;
140
- return { format: "mjcf", xml: ft(u) ? ct(f) : f, files: s };
139
+ const c = t.extension.xml;
140
+ return { format: "mjcf", xml: ct(u) ? ft(c) : c, files: s };
141
141
  }
142
- function ft(t) {
142
+ function ct(t) {
143
143
  return t.size === 0 || ![...t.values()].some((a) => a.querySelector("freejoint, actuator") ? !0 : [...a.querySelectorAll("joint")].some(
144
144
  (r) => (r.getAttribute("type") ?? "hinge").toLowerCase() !== "fixed"
145
145
  )) ? !1 : ![...t.values()].some(
@@ -149,33 +149,33 @@ function ft(t) {
149
149
  })
150
150
  );
151
151
  }
152
- function ct(t) {
152
+ function ft(t) {
153
153
  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"/>';
154
154
  return /<worldbody\b[^>]*>/i.test(t) ? t.replace(/(<worldbody\b[^>]*>)/i, `$1${e}`) : t.replace(/<\/mujoco\s*>/i, `<worldbody>${e}</worldbody></mujoco>`);
155
155
  }
156
156
  function mt(t, e) {
157
- const a = (c) => c.replaceAll("\\", "/").split("/").pop() ?? "", r = /* @__PURE__ */ new Map();
158
- for (const c of t) {
159
- const n = a(c), i = r.get(n) ?? [];
160
- i.push(c), r.set(n, i);
157
+ const a = (f) => f.replaceAll("\\", "/").split("/").pop() ?? "", r = /* @__PURE__ */ new Map();
158
+ for (const f of t) {
159
+ const n = a(f), i = r.get(n) ?? [];
160
+ i.push(f), r.set(n, i);
161
161
  }
162
- const s = new Set(e.keys()), u = /* @__PURE__ */ new Set(["include", "mesh", "texture", "hfield", "skin"]), f = /* @__PURE__ */ new Set(["fileleft", "fileright", "fileup", "filedown", "filefront", "fileback"]);
163
- for (const c of e.values()) {
164
- if (c.querySelector("plugin, extension, model, attach")) return t;
165
- for (const n of c.querySelectorAll("*"))
162
+ const s = new Set(e.keys()), u = /* @__PURE__ */ new Set(["include", "mesh", "texture", "hfield", "skin"]), c = /* @__PURE__ */ new Set(["fileleft", "fileright", "fileup", "filedown", "filefront", "fileback"]);
163
+ for (const f of e.values()) {
164
+ if (f.querySelector("plugin, extension, model, attach")) return t;
165
+ for (const n of f.querySelectorAll("*"))
166
166
  for (const i of n.attributes) {
167
167
  if (!i.name.startsWith("file")) continue;
168
168
  if (i.name === "file") {
169
169
  if (!u.has(n.tagName)) return t;
170
- } else if (!(n.tagName === "texture" && f.has(i.name)))
170
+ } else if (!(n.tagName === "texture" && c.has(i.name)))
171
171
  return t;
172
172
  if (!i.value) continue;
173
- const v = r.get(a(i.value));
174
- if (!v) return t;
175
- for (const p of v) s.add(p);
173
+ const b = r.get(a(i.value));
174
+ if (!b) return t;
175
+ for (const p of b) s.add(p);
176
176
  }
177
177
  }
178
- return t.filter((c) => s.has(c));
178
+ return t.filter((f) => s.has(f));
179
179
  }
180
180
  function dt(t, e) {
181
181
  const a = new DOMParser().parseFromString(t, "application/xml"), r = a.querySelector("parsererror");
@@ -207,25 +207,25 @@ function pt(t = {}) {
207
207
  }
208
208
  function ht(t, e) {
209
209
  var P, M;
210
- const a = [], r = [], s = [], u = t.mesh_vertadr[e], f = t.mesh_faceadr[e], c = t.mesh_normaladr[e], n = t.mesh_texcoordadr[e];
211
- let i = c >= 0, v = n >= 0;
210
+ const a = [], r = [], s = [], u = t.mesh_vertadr[e], c = t.mesh_faceadr[e], f = t.mesh_normaladr[e], n = t.mesh_texcoordadr[e];
211
+ let i = f >= 0, b = n >= 0;
212
212
  for (let S = 0; S < t.mesh_facenum[e]; S++) for (let w = 0; w < 3; w++) {
213
- const m = (f + S) * 3 + w, h = (u + t.mesh_face[m]) * 3;
213
+ const m = (c + S) * 3 + w, h = (u + t.mesh_face[m]) * 3;
214
214
  a.push(...t.mesh_vert.slice(h, h + 3));
215
215
  const y = ((P = t.mesh_facenormal) == null ? void 0 : P[m]) ?? -1;
216
- c >= 0 && y >= 0 ? r.push(...t.mesh_normal.slice((c + y) * 3, (c + y) * 3 + 3)) : i = !1;
216
+ f >= 0 && y >= 0 ? r.push(...t.mesh_normal.slice((f + y) * 3, (f + y) * 3 + 3)) : i = !1;
217
217
  const O = ((M = t.mesh_facetexcoord) == null ? void 0 : M[m]) ?? -1;
218
- n >= 0 && O >= 0 ? s.push(...t.mesh_texcoord.slice((n + O) * 2, (n + O) * 2 + 2)) : v = !1;
218
+ n >= 0 && O >= 0 ? s.push(...t.mesh_texcoord.slice((n + O) * 2, (n + O) * 2 + 2)) : b = !1;
219
219
  }
220
- const p = new ce();
221
- return p.setAttribute("position", new Z(a, 3)), i && r.length === a.length ? p.setAttribute("normal", new Z(r, 3)) : p.computeVertexNormals(), v && s.length === a.length / 3 * 2 && p.setAttribute("uv", new Z(s, 2)), p;
220
+ const p = new fe();
221
+ return p.setAttribute("position", new Z(a, 3)), i && r.length === a.length ? p.setAttribute("normal", new Z(r, 3)) : p.computeVertexNormals(), b && s.length === a.length / 3 * 2 && p.setAttribute("uv", new Z(s, 2)), p;
222
222
  }
223
223
  function yt(t) {
224
224
  const e = /* @__PURE__ */ new Map();
225
225
  if (!t.model.ntex) return e;
226
- const a = t.mujoco, r = t.model, s = new a.MjvScene(r, Math.max(1e3, r.ngeom * 2)), u = new a.MjvOption(), f = new a.MjvPerturb(), c = new a.MjvCamera();
226
+ const a = t.mujoco, r = t.model, s = new a.MjvScene(r, Math.max(1e3, r.ngeom * 2)), u = new a.MjvOption(), c = new a.MjvPerturb(), f = new a.MjvCamera();
227
227
  try {
228
- u.geomgroup.fill(1), a.mjv_updateScene(r, t.data, u, f, c, a.mjtCatBit.mjCAT_ALL.value, s);
228
+ u.geomgroup.fill(1), a.mjv_updateScene(r, t.data, u, c, f, a.mjtCatBit.mjCAT_ALL.value, s);
229
229
  for (let n = 0; n < s.ngeom; n++) {
230
230
  const i = s.geoms.get(n);
231
231
  try {
@@ -236,30 +236,30 @@ function yt(t) {
236
236
  }
237
237
  return e;
238
238
  } finally {
239
- s.delete(), u.delete(), f.delete(), c.delete();
239
+ s.delete(), u.delete(), c.delete(), f.delete();
240
240
  }
241
241
  }
242
242
  function _t(t, e, a, r, s, u = /* @__PURE__ */ new Map()) {
243
243
  var w;
244
- const f = t.model, c = t.mujoco, n = f.geom_matid[e];
244
+ const c = t.model, f = t.mujoco, n = c.geom_matid[e];
245
245
  if (n < 0) return;
246
246
  const i = (m, h) => {
247
247
  s != null && s.droppedFeatures.some((y) => y.code === m && y.source === `material:${n}`) || s == null || s.droppedFeatures.push({ code: m, message: h, source: `material:${n}` });
248
248
  };
249
- f.mat_reflectance[n] > 0 && i("MJCF_REFLECTANCE_UNSUPPORTED", "Legacy planar reflection is not reproduced by the PBR material.");
250
- const v = c.mjtTextureRole.mjNTEXROLE.value;
251
- if (!Array.from(f.mat_texid.slice(n * v, (n + 1) * v)).some((m) => Number(m) >= 0)) return;
252
- const M = !(f.geom_type[e] === c.mjtGeom.mjGEOM_MESH.value) || !a.getAttribute("uv"), S = u.get(e);
249
+ c.mat_reflectance[n] > 0 && i("MJCF_REFLECTANCE_UNSUPPORTED", "Legacy planar reflection is not reproduced by the PBR material.");
250
+ const b = f.mjtTextureRole.mjNTEXROLE.value;
251
+ if (!Array.from(c.mat_texid.slice(n * b, (n + 1) * b)).some((m) => Number(m) >= 0)) return;
252
+ const M = !(c.geom_type[e] === f.mjtGeom.mjGEOM_MESH.value) || !a.getAttribute("uv"), S = u.get(e);
253
253
  if (S === void 0) throw new Error(`Missing compiled texture projection for geom ${e}`);
254
254
  if (M) {
255
- const m = a.getAttribute("position"), h = [], y = f.geom_size[e * 3] || 1, O = f.geom_size[e * 3 + 1] || y;
255
+ const m = a.getAttribute("position"), h = [], y = c.geom_size[e * 3] || 1, O = c.geom_size[e * 3 + 1] || y;
256
256
  for (let C = 0; C < m.count; C++) h.push(m.getX(C) / (2 * (S ? 1 : y)), -m.getY(C) / (2 * (S ? 1 : O)));
257
257
  a.setAttribute("uv", new Z(h, 2));
258
258
  }
259
- for (let m = 0; m < v; m++) {
260
- const h = f.mat_texid[n * v + m];
259
+ for (let m = 0; m < b; m++) {
260
+ const h = c.mat_texid[n * b + m];
261
261
  if (h < 0) continue;
262
- if (f.tex_type[h] !== c.mjtTexture.mjTEXTURE_2D.value) {
262
+ if (c.tex_type[h] !== f.mjtTexture.mjTEXTURE_2D.value) {
263
263
  i("MJCF_TEXTURE_PROJECTION_UNSUPPORTED", "Cube/skybox surface textures require a dedicated projection and are not substituted with a 2D map.");
264
264
  continue;
265
265
  }
@@ -267,26 +267,26 @@ function _t(t, e, a, r, s, u = /* @__PURE__ */ new Map()) {
267
267
  i("MJCF_USER_TEXTURE_UNSUPPORTED", "User texture role has no defined PBR material slot.");
268
268
  continue;
269
269
  }
270
- const y = f.tex_width[h], O = f.tex_height[h], C = f.tex_nchannel[h];
270
+ const y = c.tex_width[h], O = c.tex_height[h], C = c.tex_nchannel[h];
271
271
  if (![1, 2, 3, 4].includes(C)) {
272
272
  i("MJCF_TEXTURE_CHANNELS_UNSUPPORTED", "Unsupported texture channel count.");
273
273
  continue;
274
274
  }
275
- const b = Number(f.tex_adr[h]), _ = new Uint8Array(y * O * 4);
275
+ const v = Number(c.tex_adr[h]), _ = new Uint8Array(y * O * 4);
276
276
  for (let E = 0; E < y * O; E++) {
277
- const o = b + E * C, d = E * 4, D = f.tex_data[o];
278
- _[d] = D, _[d + 1] = C >= 3 ? f.tex_data[o + 1] : D, _[d + 2] = C >= 3 ? f.tex_data[o + 2] : D, _[d + 3] = C === 4 ? f.tex_data[o + 3] : C === 2 ? f.tex_data[o + 1] : 255, [2, 3, 4, 6].includes(m) && (_[d] = _[d + 1] = _[d + 2] = D);
277
+ const o = v + E * C, d = E * 4, D = c.tex_data[o];
278
+ _[d] = D, _[d + 1] = C >= 3 ? c.tex_data[o + 1] : D, _[d + 2] = C >= 3 ? c.tex_data[o + 2] : D, _[d + 3] = C === 4 ? c.tex_data[o + 3] : C === 2 ? c.tex_data[o + 1] : 255, [2, 3, 4, 6].includes(m) && (_[d] = _[d + 1] = _[d + 2] = D);
279
279
  }
280
280
  const g = new Ze(_, y, O, xe, et);
281
- g.colorSpace = [1, 7, 8].includes(m) && f.tex_colorspace[h] === c.mjtColorSpace.mjCOLORSPACE_SRGB.value ? Ce : tt, g.wrapS = g.wrapT = rt, g.magFilter = st, g.minFilter = ot, g.generateMipmaps = !0;
282
- const G = f.mat_texrepeat[n * 2], R = f.mat_texrepeat[n * 2 + 1];
283
- if (g.repeat.set(G, R), M ? g.offset.set(-0.5, -0.5) : S && g.repeat.set(G * (f.geom_size[e * 3] || 1), R * (f.geom_size[e * 3 + 1] || 1)), g.needsUpdate = !0, m === 1 || m === 8)
281
+ g.colorSpace = [1, 7, 8].includes(m) && c.tex_colorspace[h] === f.mjtColorSpace.mjCOLORSPACE_SRGB.value ? Ce : tt, g.wrapS = g.wrapT = rt, g.magFilter = st, g.minFilter = ot, g.generateMipmaps = !0;
282
+ const G = c.mat_texrepeat[n * 2], R = c.mat_texrepeat[n * 2 + 1];
283
+ if (g.repeat.set(G, R), M ? g.offset.set(-0.5, -0.5) : S && g.repeat.set(G * (c.geom_size[e * 3] || 1), R * (c.geom_size[e * 3 + 1] || 1)), g.needsUpdate = !0, m === 1 || m === 8)
284
284
  (w = r.map) == null || w.dispose(), r.map = g, m === 8 && (r.transparent = !0, r.depthWrite = !1);
285
285
  else if (m === 2) r.aoMap = g;
286
286
  else if (m === 3)
287
- r.roughnessMap = g, r.roughness = f.mat_roughness[n] >= 0 ? r.roughness : 1;
287
+ r.roughnessMap = g, r.roughness = c.mat_roughness[n] >= 0 ? r.roughness : 1;
288
288
  else if (m === 4)
289
- r.metalnessMap = g, r.metalness = f.mat_metallic[n] >= 0 ? r.metalness : 1;
289
+ r.metalnessMap = g, r.metalness = c.mat_metallic[n] >= 0 ? r.metalness : 1;
290
290
  else if (m === 5) r.normalMap = g;
291
291
  else if (m === 6)
292
292
  r.alphaMap = g, r.transparent = !0, r.depthWrite = !1;
@@ -294,14 +294,14 @@ function _t(t, e, a, r, s, u = /* @__PURE__ */ new Map()) {
294
294
  r.emissiveMap = g, r.emissive.setRGB(1, 1, 1), C === 4 && i("MJCF_EMISSIVE_EXPOSURE_UNSUPPORTED", "Emissive RGB is preserved; per-pixel exposure weight is not supported.");
295
295
  else if (m === 9) {
296
296
  for (const E of /* @__PURE__ */ new Set([r.aoMap, r.roughnessMap, r.metalnessMap])) E == null || E.dispose();
297
- r.aoMap = r.roughnessMap = r.metalnessMap = g, r.roughness = f.mat_roughness[n] >= 0 ? r.roughness : 1, r.metalness = f.mat_metallic[n] >= 0 ? r.metalness : 1;
297
+ r.aoMap = r.roughnessMap = r.metalnessMap = g, r.roughness = c.mat_roughness[n] >= 0 ? r.roughness : 1, r.metalness = c.mat_metallic[n] >= 0 ? r.metalness : 1;
298
298
  }
299
299
  }
300
300
  }
301
301
  function gt(t, e) {
302
302
  return e < 0 ? Pe() : Pe(t.mat_roughness[e], t.mat_shininess[e]);
303
303
  }
304
- function bt(t, e) {
304
+ function vt(t, e) {
305
305
  if (e < 0) return 0;
306
306
  const a = t.mat_metallic[e];
307
307
  return Number.isFinite(a) && a >= 0 ? a : 0;
@@ -309,21 +309,21 @@ function bt(t, e) {
309
309
  function Ge(t, e = !1, a) {
310
310
  const r = t.model, s = t.mujoco, u = new Ee();
311
311
  u.name = "MuJoCo scene";
312
- const f = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
312
+ const c = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
313
313
  for (let n = 1; n < r.nbody; n += 1) {
314
314
  const i = s.mj_id2name(r, s.mjtObj.mjOBJ_BODY.value, n);
315
315
  if (!i) continue;
316
- const v = new Ee();
317
- v.name = i, v.userData.bodyId = n, f.set(n, v), c.set(i, v), u.add(v);
316
+ const b = new Ee();
317
+ b.name = i, b.userData.bodyId = n, c.set(n, b), f.set(i, b), u.add(b);
318
318
  }
319
319
  try {
320
- if (f.set(0, u), e) {
321
- const n = Ve(), i = $e();
322
- let v = 0;
320
+ if (c.set(0, u), e) {
321
+ const n = Ve(), i = ke();
322
+ let b = 0;
323
323
  for (let p = 0; p < r.ngeom; p += 1) {
324
324
  const P = s.mj_id2name(r, s.mjtObj.mjOBJ_GEOM.value, p);
325
325
  if (P === "__viewer_default_ground__" || !Mt(r, p)) continue;
326
- const M = f.get(r.geom_bodyid[p]), S = vt(t, p);
326
+ const M = c.get(r.geom_bodyid[p]), S = bt(t, p);
327
327
  if (!M) continue;
328
328
  if (!S) {
329
329
  a == null || a.droppedFeatures.push({
@@ -333,24 +333,24 @@ function Ge(t, e = !1, a) {
333
333
  });
334
334
  continue;
335
335
  }
336
- const w = wt(t, p) ? "mesh" : "feature", m = Be(S, n, w, i);
337
- S.dispose(), m.userData.geomId = p, v += 1;
336
+ const w = wt(t, p) ? "mesh" : "feature", m = $e(S, n, w, i);
337
+ S.dispose(), m.userData.geomId = p, b += 1;
338
338
  const h = p * 3, y = p * 4;
339
339
  m.position.fromArray(r.geom_pos, h), m.quaternion.set(r.geom_quat[y + 1], r.geom_quat[y + 2], r.geom_quat[y + 3], r.geom_quat[y]), M.add(m);
340
340
  }
341
- v === 0 && (n.dispose(), i.dispose());
341
+ b === 0 && (n.dispose(), i.dispose());
342
342
  } else {
343
343
  const n = yt(t);
344
344
  for (let i = 0; i < r.ngeom; i += 1) {
345
345
  if (r.geom_group[i] > 2 || s.mj_id2name(r, s.mjtObj.mjOBJ_GEOM.value, i) === "__viewer_default_ground__") continue;
346
- const v = f.get(r.geom_bodyid[i]), p = At(t, i);
347
- if (!v || !p) continue;
346
+ const b = c.get(r.geom_bodyid[i]), p = At(t, i);
347
+ if (!b || !p) continue;
348
348
  const P = i * 4, M = r.geom_matid[i], S = Array.from(r.geom_rgba.slice(P, P + 4));
349
349
  M >= 0 && [0.5, 0.5, 0.5, 1].every((O, C) => S[C] === O) && S.splice(0, 4, ...Array.from(r.mat_rgba.slice(M * 4, M * 4 + 4)));
350
350
  const w = pt({
351
351
  color: S,
352
352
  roughness: gt(r, M),
353
- metalness: bt(r, M),
353
+ metalness: vt(r, M),
354
354
  specular: M >= 0 ? r.mat_specular[M] : void 0,
355
355
  emission: M >= 0 ? r.mat_emission[M] : void 0
356
356
  });
@@ -360,29 +360,29 @@ function Ge(t, e = !1, a) {
360
360
  throw ae(new Ae(p, w)), O;
361
361
  }
362
362
  const m = new Ae(p, w), h = i * 3, y = i * 4;
363
- r.geom_bodyid[i] === 0 && r.geom_type[i] === s.mjtGeom.mjGEOM_PLANE.value && (m.userData.excludeFromSimulationFit = !0), m.position.fromArray(r.geom_pos, h), m.quaternion.set(r.geom_quat[y + 1], r.geom_quat[y + 2], r.geom_quat[y + 3], r.geom_quat[y]), v.add(m);
363
+ r.geom_bodyid[i] === 0 && r.geom_type[i] === s.mjtGeom.mjGEOM_PLANE.value && (m.userData.excludeFromSimulationFit = !0), m.position.fromArray(r.geom_pos, h), m.quaternion.set(r.geom_quat[y + 1], r.geom_quat[y + 2], r.geom_quat[y + 3], r.geom_quat[y]), b.add(m);
364
364
  }
365
365
  }
366
- return { root: u, bindings: c, expectedLinkCount: c.size };
366
+ return { root: u, bindings: f, expectedLinkCount: f.size };
367
367
  } catch (n) {
368
368
  throw ae(u), n;
369
369
  }
370
370
  }
371
- function vt(t, e) {
372
- const a = t.model, r = t.mujoco, s = e * 3, u = a.geom_size[s], f = a.geom_size[s + 1], c = a.geom_size[s + 2], n = a.geom_type[e];
373
- if (n === r.mjtGeom.mjGEOM_PLANE.value) return new Oe(Math.max(u * 2, 2), Math.max(f * 2, 2), 10, 10);
374
- if (n === r.mjtGeom.mjGEOM_BOX.value) return new Re(u * 2, f * 2, c * 2);
371
+ function bt(t, e) {
372
+ const a = t.model, r = t.mujoco, s = e * 3, u = a.geom_size[s], c = a.geom_size[s + 1], f = a.geom_size[s + 2], n = a.geom_type[e];
373
+ if (n === r.mjtGeom.mjGEOM_PLANE.value) return new Oe(Math.max(u * 2, 2), Math.max(c * 2, 2), 10, 10);
374
+ if (n === r.mjtGeom.mjGEOM_BOX.value) return new Re(u * 2, c * 2, f * 2);
375
375
  if (n === r.mjtGeom.mjGEOM_SPHERE.value) return new ie(u, 20, 12);
376
376
  if (n === r.mjtGeom.mjGEOM_ELLIPSOID.value) {
377
377
  const i = new ie(1, 24, 16);
378
- return i.applyMatrix4(new nt().makeScale(u, f, c)), i;
378
+ return i.applyMatrix4(new nt().makeScale(u, c, f)), i;
379
379
  }
380
380
  if (n === r.mjtGeom.mjGEOM_CYLINDER.value) {
381
- const i = new Fe(u, u, f * 2, 24);
381
+ const i = new Fe(u, u, c * 2, 24);
382
382
  return i.rotateX(Math.PI / 2), i;
383
383
  }
384
384
  if (n === r.mjtGeom.mjGEOM_CAPSULE.value) {
385
- const i = new Ne(u, f * 2, 6, 16);
385
+ const i = new Te(u, c * 2, 6, 16);
386
386
  return i.rotateX(Math.PI / 2), i;
387
387
  }
388
388
  return n === r.mjtGeom.mjGEOM_MESH.value ? jt(t, a.geom_dataid[e]) : n === r.mjtGeom.mjGEOM_HFIELD.value ? Et(t, a.geom_dataid[e]) : null;
@@ -399,26 +399,26 @@ function Mt(t, e) {
399
399
  function jt(t, e) {
400
400
  const a = t.model, r = a.mesh_graphadr[e];
401
401
  if (r < 0) return null;
402
- const s = a.mesh_vertadr[e], u = a.mesh_vertnum[e], f = a.mesh_graph[r], c = a.mesh_graph[r + 1];
403
- if (f < 4 || c < 4) return null;
404
- const n = r + 2 + 3 * f + 3 * c, i = new ce();
405
- return i.setAttribute("position", new le(Float32Array.from(a.mesh_vert.subarray(s * 3, (s + u) * 3)), 3)), i.setIndex(new le(Uint32Array.from(a.mesh_graph.subarray(n, n + c * 3)), 1)), i.computeVertexNormals(), i;
402
+ const s = a.mesh_vertadr[e], u = a.mesh_vertnum[e], c = a.mesh_graph[r], f = a.mesh_graph[r + 1];
403
+ if (c < 4 || f < 4) return null;
404
+ const n = r + 2 + 3 * c + 3 * f, i = new fe();
405
+ return i.setAttribute("position", new le(Float32Array.from(a.mesh_vert.subarray(s * 3, (s + u) * 3)), 3)), i.setIndex(new le(Uint32Array.from(a.mesh_graph.subarray(n, n + f * 3)), 1)), i.computeVertexNormals(), i;
406
406
  }
407
407
  function Et(t, e) {
408
408
  const a = t.model, r = a.hfield_nrow[e], s = a.hfield_ncol[e];
409
409
  if (r < 2 || s < 2) return null;
410
- const u = a.hfield_adr[e], f = e * 4, c = a.hfield_size[f], n = a.hfield_size[f + 1], i = a.hfield_size[f + 2], v = a.hfield_size[f + 3], p = r * s, P = [];
410
+ const u = a.hfield_adr[e], c = e * 4, f = a.hfield_size[c], n = a.hfield_size[c + 1], i = a.hfield_size[c + 2], b = a.hfield_size[c + 3], p = r * s, P = [];
411
411
  for (let G = 0; G < r; G += 1) for (let R = 0; R < s; R += 1)
412
412
  P.push(
413
- -c + 2 * c * R / (s - 1),
413
+ -f + 2 * f * R / (s - 1),
414
414
  -n + 2 * n * G / (r - 1),
415
415
  a.hfield_data[u + G * s + R] * i
416
416
  );
417
417
  const M = [
418
- [-c, -n, -v],
419
- [c, -n, -v],
420
- [-c, n, -v],
421
- [c, n, -v]
418
+ [-f, -n, -b],
419
+ [f, -n, -b],
420
+ [-f, n, -b],
421
+ [f, n, -b]
422
422
  ];
423
423
  for (const G of M) P.push(...G);
424
424
  const S = [];
@@ -428,72 +428,72 @@ function Et(t, e) {
428
428
  }
429
429
  const w = p, m = p + 1, h = p + 2, y = p + 3;
430
430
  S.push(w, m, h, m, y, h);
431
- const O = 0, C = s - 1, b = (r - 1) * s, _ = r * s - 1;
432
- S.push(w, O, m, m, O, C), S.push(h, y, b, y, _, b), S.push(w, h, O, h, b, O), S.push(m, C, y, y, C, _);
433
- const g = new ce();
431
+ const O = 0, C = s - 1, v = (r - 1) * s, _ = r * s - 1;
432
+ S.push(w, O, m, m, O, C), S.push(h, y, v, y, _, v), S.push(w, h, O, h, v, O), S.push(m, C, y, y, C, _);
433
+ const g = new fe();
434
434
  return g.setAttribute("position", new le(Float32Array.from(P), 3)), g.setIndex(S), g.computeVertexNormals(), g;
435
435
  }
436
436
  function At(t, e) {
437
- const a = t.model, r = t.mujoco, s = e * 3, u = a.geom_size[s], f = a.geom_size[s + 1], c = a.geom_size[s + 2], n = a.geom_type[e];
438
- if (n === r.mjtGeom.mjGEOM_PLANE.value) return new Oe((u || 5) * 2, (f || 5) * 2);
439
- if (n === r.mjtGeom.mjGEOM_BOX.value) return new Re(u * 2, f * 2, c * 2);
437
+ const a = t.model, r = t.mujoco, s = e * 3, u = a.geom_size[s], c = a.geom_size[s + 1], f = a.geom_size[s + 2], n = a.geom_type[e];
438
+ if (n === r.mjtGeom.mjGEOM_PLANE.value) return new Oe((u || 5) * 2, (c || 5) * 2);
439
+ if (n === r.mjtGeom.mjGEOM_BOX.value) return new Re(u * 2, c * 2, f * 2);
440
440
  if (n === r.mjtGeom.mjGEOM_SPHERE.value) return new ie(u, 24, 16);
441
441
  if (n === r.mjtGeom.mjGEOM_CYLINDER.value) {
442
- const i = new Fe(u, u, f * 2, 24);
442
+ const i = new Fe(u, u, c * 2, 24);
443
443
  return i.rotateX(Math.PI / 2), i;
444
444
  }
445
445
  if (n === r.mjtGeom.mjGEOM_CAPSULE.value) {
446
- const i = new Ne(u, f * 2, 6, 16);
446
+ const i = new Te(u, c * 2, 6, 16);
447
447
  return i.rotateX(Math.PI / 2), i;
448
448
  }
449
449
  return n !== r.mjtGeom.mjGEOM_MESH.value ? null : ht(a, a.geom_dataid[e]);
450
450
  }
451
451
  function St(t, e) {
452
- const a = new ke(t), r = e.format === "usd" || e.format === "usda" || e.format === "usdc" || e.format === "usdz";
453
- let s = null, u = null, f = null, c = null, n = null, i = null, v = null, p = null, P = null, M = null, S = null, w = !1, m = !1, h, y;
452
+ const a = new Be(t), r = e.format === "usd" || e.format === "usda" || e.format === "usdc" || e.format === "usdz";
453
+ let s = null, u = null, c = null, f = null, n = null, i = null, b = null, p = null, P = null, M = null, S = null, w = !1, m = !1, h, y;
454
454
  const O = () => {
455
455
  y == null || y.cancel();
456
456
  }, C = () => {
457
457
  const l = y;
458
458
  y = void 0, l == null || l.dispose();
459
459
  };
460
- let b = !1, _ = !1, g = null, G = null, R, E = null, o = null, d = null, D = null, N = null, I = null, $ = !1, H = "z", ee = !1;
461
- const B = () => {
460
+ let v = !1, _ = !1, g = null, G = null, R, E = null, o = null, d = null, D = null, T = null, I = null, k = !1, H = "z", ee = !1;
461
+ const $ = () => {
462
462
  o && (H = e.options.upAxis ?? "z", ee = !0, o.setUpAxis(H) && (u == null || u.sync(), d == null || d.sync()));
463
- }, k = (l = !1) => {
463
+ }, B = (l = !1) => {
464
464
  if (!s || !h || typeof s.getJointValues != "function") return;
465
465
  const j = h.getSnapshot().joints.map((F) => F.id);
466
466
  h.syncValues(s.getJointValues(j), l);
467
467
  }, q = (l, j) => {
468
- var T;
468
+ var N;
469
469
  const F = se(l, e.signal, `${e.format}:${j}`);
470
- m = !1, C(), h == null || h.dispose(), h = void 0, P = null, b = !1, G = { ...F, stage: j };
470
+ m = !1, C(), h == null || h.dispose(), h = void 0, P = null, v = !1, G = { ...F, stage: j };
471
471
  try {
472
472
  o == null || o.endGrab();
473
473
  } catch {
474
474
  }
475
- (T = e.reportSessionState) == null || T.call(e), e.reportError(l, { fatal: !1, stage: j, code: F.code });
476
- }, Te = (l) => {
475
+ (N = e.reportSessionState) == null || N.call(e), e.reportError(l, { fatal: !1, stage: j, code: F.code });
476
+ }, Ne = (l) => {
477
477
  var j;
478
478
  if (w) {
479
479
  l.dispose();
480
480
  return;
481
481
  }
482
- N = null, $ = !1, E = l.asset, f = l.dispose, _ = l.hasAnimation === !0, c = l.hasPhysics || _ ? l.step : null, n = l.reset, m = !l.hasPhysics && l.hasAnimation === !0, b = l.hasPhysics, g = l.fallback ? { ...l.fallback, stage: "physics-fallback" } : l.visualWarning ? { ...l.visualWarning, stage: "visual-adaptation" } : null, u = l.binding, s = l.runtime ?? null, h = l.inspection, P = h ?? null, d = l.collision ?? null, D = l.createCollision ?? null, o == null || o.setRuntime(l.runtime), o == null || o.replaceModel(l.binding.root), d && (d.root.visible = !1, o == null || o.attachAuxiliary(d.root), d.sync()), h && (y = it(h, {
482
+ T = null, k = !1, E = l.asset, c = l.dispose, _ = l.hasAnimation === !0, f = l.hasPhysics || _ ? l.step : null, n = l.reset, m = !l.hasPhysics && l.hasAnimation === !0, v = l.hasPhysics, g = l.fallback ? { ...l.fallback, stage: "physics-fallback" } : l.visualWarning ? { ...l.visualWarning, stage: "visual-adaptation" } : null, u = l.binding, s = l.runtime ?? null, h = l.inspection, P = h ?? null, d = l.collision ?? null, D = l.createCollision ?? null, o == null || o.setRuntime(l.runtime), o == null || o.replaceModel(l.binding.root), d && (d.root.visible = !1, o == null || o.attachAuxiliary(d.root), d.sync()), h && (y = it(h, {
483
483
  autoPlay: e.options.jointIntro !== !1 && !(typeof globalThis.matchMedia == "function" && globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches),
484
484
  onPlayingChange(F) {
485
- var T;
486
- m = F, w || ((T = e.reportSessionState) == null || T.call(e), e.requestRender());
485
+ var N;
486
+ m = F, w || ((N = e.reportSessionState) == null || N.call(e), e.requestRender());
487
487
  },
488
488
  onFinished() {
489
489
  w || h == null || h.notifyIntroFinished();
490
490
  }
491
- }), y && (m = y.playing)), B(), (j = e.reportSessionState) == null || j.call(e), e.requestRender();
491
+ }), y && (m = y.playing)), $(), (j = e.reportSessionState) == null || j.call(e), e.requestRender();
492
492
  }, De = (l) => {
493
493
  var F;
494
494
  if (w) return;
495
495
  const j = se(l, e.signal, "usd-physics");
496
- $ = !1, G = { ...j, stage: "usd-physics" }, b = !1, _ = (N == null ? void 0 : N.visual.hasAnimation) ?? _, c = N != null && N.visual.hasAnimation ? N.visual.step : null, n = N != null && N.visual.hasAnimation ? N.visual.reset : null, m = !!(N != null && N.visual.hasAnimation), (F = e.reportSessionState) == null || F.call(e), e.reportError(l, { fatal: !1, stage: "usd-physics", code: j.code });
496
+ k = !1, G = { ...j, stage: "usd-physics" }, v = !1, _ = (T == null ? void 0 : T.visual.hasAnimation) ?? _, f = T != null && T.visual.hasAnimation ? T.visual.step : null, n = T != null && T.visual.hasAnimation ? T.visual.reset : null, m = !!(T != null && T.visual.hasAnimation), (F = e.reportSessionState) == null || F.call(e), e.reportError(l, { fatal: !1, stage: "usd-physics", code: j.code });
497
497
  }, me = () => {
498
498
  var l;
499
499
  w || (w = !0, m = !1, C(), (l = e.reportSessionState) == null || l.call(e));
@@ -511,31 +511,31 @@ function St(t, e) {
511
511
  he || (he = !0, de());
512
512
  };
513
513
  return (async () => {
514
- var l, j, F, T, J, ye, _e, ge, be, ve;
514
+ var l, j, F, N, J, ye, _e, ge, ve, be;
515
515
  try {
516
516
  const U = e.format;
517
517
  if (U === "usd" || U === "usda" || U === "usdc" || U === "usdz") {
518
518
  (l = e.reportProgress) == null || l.call(e, "usd-visual", "正在解析 USD 视觉场景...");
519
- const A = await (await import("./usd-session-Cb1e-Bx8.js")).loadUsdSimulation(t, e, a);
519
+ const A = await (await import("./usd-session-BEjswMmU.js")).loadUsdSimulation(t, e, a);
520
520
  if (w || e.signal.aborted)
521
- throw A.dispose(), fe();
522
- N = A, u = { root: A.visual.root, sync() {
521
+ throw A.dispose(), ce();
522
+ T = A, u = { root: A.visual.root, sync() {
523
523
  }, dispose() {
524
- } }, f = A.dispose, _ = A.visual.hasAnimation, c = _ ? A.visual.step : null, n = A.visual.reset, m = !1, $ = !0, g = A.visual.warning ? { ...A.visual.warning, stage: "visual-adaptation" } : null, (j = e.reportProgress) == null || j.call(e, "stage", "正在构建三维场景与环境光影..."), o = new oe(
524
+ } }, c = A.dispose, _ = A.visual.hasAnimation, f = _ ? A.visual.step : null, n = A.visual.reset, m = !1, k = !0, g = A.visual.warning ? { ...A.visual.warning, stage: "visual-adaptation" } : null, (j = e.reportProgress) == null || j.call(e, "stage", "正在构建三维场景与环境光影..."), o = new oe(
525
525
  A.visual.root,
526
526
  e.options.simulationTheme,
527
527
  void 0,
528
528
  "simulation",
529
529
  "visual"
530
- ), B(), W(), (F = e.reportProgress) == null || F.call(e, "usd-physics", "视觉场景已就绪,正在准备物理..."), I = A.completePhysics().then(Te).catch(De);
530
+ ), o.setCacheInvalidationCallback(e.invalidateTransmissionCaches), $(), W(), (F = e.reportProgress) == null || F.call(e, "usd-physics", "视觉场景已就绪,正在准备物理..."), I = A.completePhysics().then(Ne).catch(De);
531
531
  return;
532
532
  }
533
533
  if (U === "urdf" || U === "xacro") {
534
- (T = e.reportProgress) == null || T.call(e, "urdf", "正在解析 URDF 场景与运动学结构...");
535
- const A = await (await import("./urdf-session-CjGG32Zy.js")).loadUrdfSimulation(t, e, a);
534
+ (N = e.reportProgress) == null || N.call(e, "urdf", "正在解析 URDF 场景与运动学结构...");
535
+ const A = await (await import("./urdf-session-DJs9oT_G.js")).loadUrdfSimulation(t, e, a);
536
536
  if (w || e.signal.aborted)
537
- throw A.dispose(), fe();
538
- E = A.asset, o = A.stage, P = A.inspection, f = A.dispose, c = A.step, n = A.reset, i = A.play, v = A.pause, p = A.isPlaying, M = () => A.capabilities, S = () => A.physics, m = !1, b = !1, g = A.warning ?? null, B(), W();
537
+ throw A.dispose(), ce();
538
+ E = A.asset, o = A.stage, P = A.inspection, c = A.dispose, f = A.step, n = A.reset, i = A.play, b = A.pause, p = A.isPlaying, M = () => A.capabilities, S = () => A.physics, m = !1, v = !1, g = A.warning ?? null, $(), W();
539
539
  return;
540
540
  }
541
541
  let Y = t.entryPath ?? t.filename;
@@ -556,7 +556,7 @@ function St(t, e) {
556
556
  (_e = e.reportProgress) == null || _e.call(e, "compile", "正在编译物理模型与参数...");
557
557
  const L = await ut(E);
558
558
  Q(w, e.signal), (ge = e.reportProgress) == null || ge.call(e, "runtime", "正在初始化物理内核...");
559
- const { MujocoRuntime: A } = await import("./mujoco-runtime-B9AZiFiG.js");
559
+ const { MujocoRuntime: A } = await import("./mujoco-runtime-DNqHIXvQ.js");
560
560
  s = new A(), await s.initialize(L, {
561
561
  baseUrl: e.options.mujocoBaseUrl,
562
562
  wasmModule: e.options.mujocoWasmModule
@@ -564,7 +564,7 @@ function St(t, e) {
564
564
  } catch (L) {
565
565
  const A = se(L, e.signal, "mjcf-physics");
566
566
  s == null || s.dispose(), s = null;
567
- const { compileMjcfPreview: K } = await import("./mjcf-visual-DCfPUwyh.js");
567
+ const { compileMjcfPreview: K } = await import("./mjcf-visual-BxcQ3hIg.js");
568
568
  let z;
569
569
  try {
570
570
  z = K(E);
@@ -574,14 +574,14 @@ function St(t, e) {
574
574
  u = { root: z, sync() {
575
575
  }, dispose() {
576
576
  ae(z);
577
- } }, g = { ...A, stage: "physics-fallback" }, o = new oe(z, e.options.simulationTheme, void 0, "simulation", "visual"), m = !1, B(), W();
577
+ } }, g = { ...A, stage: "physics-fallback" }, o = new oe(z, e.options.simulationTheme, void 0, "simulation", "visual"), o.setCacheInvalidationCallback(e.invalidateTransmissionCaches), m = !1, $(), W();
578
578
  return;
579
579
  }
580
- b = !0, Q(w, e.signal), (be = e.reportProgress) == null || be.call(e, "visual", "正在构建视觉渲染网格...");
580
+ v = !0, Q(w, e.signal), (ve = e.reportProgress) == null || ve.call(e, "visual", "正在构建视觉渲染网格...");
581
581
  const qe = Ge(s, !1, E.diagnostics), we = E.diagnostics.droppedFeatures.find((L) => L.code.startsWith("MJCF_"));
582
- we && (g = { ...we, stage: "visual-material" }), Q(w, e.signal), (ve = e.reportProgress) == null || ve.call(e, "stage", "正在构建三维场景与环境光影..."), u = new je(s, qe), o = new oe(u.root, e.options.simulationTheme, s);
582
+ we && (g = { ...we, stage: "visual-material" }), Q(w, e.signal), (be = e.reportProgress) == null || be.call(e, "stage", "正在构建三维场景与环境光影..."), u = new je(s, qe), o = new oe(u.root, e.options.simulationTheme, s), o.setCacheInvalidationCallback(e.invalidateTransmissionCaches);
583
583
  const Me = Ge(s, !0, E.diagnostics);
584
- Me.root.children.length > 0 ? (d = new je(s, Me, { accelerateRaycast: !1 }), d.root.visible = !1) : d = null, d && o.attachAuxiliary(d.root), B(), h = He(
584
+ Me.root.children.length > 0 ? (d = new je(s, Me, { accelerateRaycast: !1 }), d.root.visible = !1) : d = null, d && o.attachAuxiliary(d.root), $(), h = He(
585
585
  s,
586
586
  "mjcf",
587
587
  () => {
@@ -591,13 +591,13 @@ function St(t, e) {
591
591
  (L) => e.reportError(L, { fatal: !1, stage: "joint-inspection", code: "E_MUJOCO_JOINT_INSPECTION" })
592
592
  ), P = h ?? null, W();
593
593
  } catch (U) {
594
- throw o == null || o.dispose(), o = null, f ? (f(), f = null) : (d == null || d.dispose(), u == null || u.dispose(), s == null || s.dispose()), d = null, u = null, s = null, a.dispose(), N = null, U;
594
+ throw o == null || o.dispose(), o = null, c ? (c(), c = null) : (d == null || d.dispose(), u == null || u.dispose(), s == null || s.dispose()), d = null, u = null, s = null, a.dispose(), T = null, U;
595
595
  }
596
596
  })().catch(pe), te.catch(() => {
597
597
  }), {
598
598
  id: `simulation-${Math.random().toString(36).slice(2)}`,
599
599
  get autoPlay() {
600
- return y ? y.playing : !$ && !b && _ ? !0 : e.format === "urdf" || e.format === "xacro" || b ? !1 : void 0;
600
+ return y ? y.playing : !k && !v && _ ? !0 : e.format === "urdf" || e.format === "xacro" || v ? !1 : void 0;
601
601
  },
602
602
  get inspection() {
603
603
  return P;
@@ -617,13 +617,13 @@ function St(t, e) {
617
617
  },
618
618
  get capabilities() {
619
619
  const l = d !== null || D !== null;
620
- return G ? { canPlay: !1, canPause: !1, canReset: !1, hasPhysics: !1, hasAnimation: !1, canToggleGround: !0, canToggleCollision: l, canReorientUpAxis: !0 } : (M == null ? void 0 : M()) ?? { canPlay: b || _ || !!y, canPause: b || _ || !!y, canReset: b || _ || !!h, hasPhysics: b, hasAnimation: _ || !!y, canToggleGround: !0, canToggleCollision: l, canReorientUpAxis: !0 };
620
+ return G ? { canPlay: !1, canPause: !1, canReset: !1, hasPhysics: !1, hasAnimation: !1, canToggleGround: !0, canToggleCollision: l, canReorientUpAxis: !0 } : (M == null ? void 0 : M()) ?? { canPlay: v || _ || !!y, canPause: v || _ || !!y, canReset: v || _ || !!h, hasPhysics: v, hasAnimation: _ || !!y, canToggleGround: !0, canToggleCollision: l, canReorientUpAxis: !0 };
621
621
  },
622
622
  get warning() {
623
623
  return g && !g.notice ? Xe(g, g.stage) : g;
624
624
  },
625
625
  get physics() {
626
- return G ? { status: "unavailable", issue: G } : S ? S() : $ ? { status: "initializing" } : b ? { status: "ready" } : (g == null ? void 0 : g.stage) === "physics-fallback" ? { status: "unavailable", issue: g } : { status: "not-authored" };
626
+ return G ? { status: "unavailable", issue: G } : S ? S() : k ? { status: "initializing" } : v ? { status: "ready" } : (g == null ? void 0 : g.stage) === "physics-fallback" ? { status: "unavailable", issue: g } : { status: "not-authored" };
627
627
  },
628
628
  setTheme(l) {
629
629
  o == null || o.setTheme(l);
@@ -666,7 +666,7 @@ function St(t, e) {
666
666
  return w || !E || E.source.format !== "usd" ? null : structuredClone({ report: E.extension.visualAdaptation, diagnostics: E.diagnostics });
667
667
  },
668
668
  getPhysicsProperties() {
669
- if (w || !b || !(s != null && s.model) || !s.mujoco) return null;
669
+ if (w || !v || !(s != null && s.model) || !s.mujoco) return null;
670
670
  const l = s.model, j = s.mujoco;
671
671
  return structuredClone({
672
672
  units: { length: "m", mass: "kg", time: "s" },
@@ -675,20 +675,20 @@ function St(t, e) {
675
675
  bodyCount: l.nbody - 1,
676
676
  jointCount: l.njnt,
677
677
  geomCount: l.ngeom,
678
- bodies: Array.from({ length: l.nbody - 1 }, (F, T) => {
679
- const J = T + 1;
678
+ bodies: Array.from({ length: l.nbody - 1 }, (F, N) => {
679
+ const J = N + 1;
680
680
  return { id: J, name: j.mj_id2name(l, j.mjtObj.mjOBJ_BODY.value, J), mass: l.body_mass[J], inertia: Array.from(l.body_inertia.slice(J * 3, J * 3 + 3)) };
681
681
  }),
682
682
  diagnostics: E == null ? void 0 : E.diagnostics
683
683
  });
684
684
  },
685
685
  get update() {
686
- return y || s != null && s.model || c || r ? (l) => {
687
- if (G || w || !((p == null ? void 0 : p()) ?? m) || !u && !c || !c && !(s != null && s.model)) return !1;
686
+ return y || s != null && s.model || f || r ? (l) => {
687
+ if (G || w || !((p == null ? void 0 : p()) ?? m) || !u && !f || !f && !(s != null && s.model)) return !1;
688
688
  try {
689
689
  if (y) return y.update(l);
690
- const j = c ? c(l) : s.step(l);
691
- return j && (c || u.sync(), d == null || d.sync(), o == null || o.updateForceLine(), k()), j;
690
+ const j = f ? f(l) : s.step(l);
691
+ return j && (f || u.sync(), d == null || d.sync(), o == null || o.updateForceLine(), B()), j;
692
692
  } catch (j) {
693
693
  return q(j, "step"), !1;
694
694
  }
@@ -697,9 +697,9 @@ function St(t, e) {
697
697
  updatePaused(l) {
698
698
  if (G || w || ((p == null ? void 0 : p()) ?? m)) return !1;
699
699
  try {
700
- if (y || !b || !(s != null && s.isJointDriveActive) || !u) return !1;
700
+ if (y || !v || !(s != null && s.isJointDriveActive) || !u) return !1;
701
701
  const j = s.stepJointDrive(l);
702
- return j && (u.sync(), d == null || d.sync(), o == null || o.updateForceLine()), k(!s.isJointDriveActive), j;
702
+ return j && (u.sync(), d == null || d.sync(), o == null || o.updateForceLine()), B(!s.isJointDriveActive), j;
703
703
  } catch (j) {
704
704
  return q(j, "joint-drive"), !1;
705
705
  }
@@ -711,7 +711,7 @@ function St(t, e) {
711
711
  o == null || o.endGrab(), y.play(), e.requestRender();
712
712
  return;
713
713
  }
714
- i ? (i(), m = (p == null ? void 0 : p()) ?? !1) : b ? (o == null || o.endGrab(), n ? n() : (s == null || s.reset(), u == null || u.sync()), d == null || d.sync(), o == null || o.resetGround(), o == null || o.updateForceLine(), k(!0), m = !0, h == null || h.setPlaying(!0), e.requestRender()) : _ && (m = !0, e.requestRender());
714
+ i ? (i(), m = (p == null ? void 0 : p()) ?? !1) : v ? (o == null || o.endGrab(), n ? n() : (s == null || s.reset(), u == null || u.sync()), d == null || d.sync(), o == null || o.resetGround(), o == null || o.updateForceLine(), B(!0), m = !0, h == null || h.setPlaying(!0), e.requestRender()) : _ && (m = !0, e.requestRender());
715
715
  } catch (l) {
716
716
  q(l, "play");
717
717
  }
@@ -723,7 +723,7 @@ function St(t, e) {
723
723
  y.pause();
724
724
  return;
725
725
  }
726
- v && v(), m = !1, o == null || o.endGrab(), b && (s == null || s.clearJointTargets({ freeze: !0 })), h == null || h.setPlaying(!1), k(!0);
726
+ b && b(), m = !1, o == null || o.endGrab(), v && (s == null || s.clearJointTargets({ freeze: !0 })), h == null || h.setPlaying(!1), B(!0);
727
727
  } catch (l) {
728
728
  q(l, "pause");
729
729
  }
@@ -735,26 +735,26 @@ function St(t, e) {
735
735
  y.reset(), o == null || o.resetGround(), e.requestRender();
736
736
  return;
737
737
  }
738
- o == null || o.endGrab(), n ? n() : (s == null || s.reset(), u.sync()), d == null || d.sync(), o == null || o.resetGround(), o == null || o.updateForceLine(), k(!0);
738
+ o == null || o.endGrab(), n ? n() : (s == null || s.reset(), u.sync()), d == null || d.sync(), o == null || o.resetGround(), o == null || o.updateForceLine(), B(!0);
739
739
  } catch (l) {
740
740
  q(l, "reset");
741
741
  }
742
742
  },
743
743
  beginGrab(l, j, F) {
744
- if (w || y || !b && !S) return !1;
744
+ if (w || y || !v && !S) return !1;
745
745
  try {
746
- const T = (o == null ? void 0 : o.beginGrab(l, j, F)) ?? !1;
747
- return T && O(), T;
748
- } catch (T) {
749
- return q(T, "grab"), !1;
746
+ const N = (o == null ? void 0 : o.beginGrab(l, j, F)) ?? !1;
747
+ return N && O(), N;
748
+ } catch (N) {
749
+ return q(N, "grab"), !1;
750
750
  }
751
751
  },
752
752
  moveGrab(l, j, F) {
753
- if (!(w || !b && !S))
753
+ if (!(w || !v && !S))
754
754
  try {
755
755
  o == null || o.moveGrab(l, j, F);
756
- } catch (T) {
757
- q(T, "grab");
756
+ } catch (N) {
757
+ q(N, "grab");
758
758
  }
759
759
  },
760
760
  endGrab() {
@@ -763,24 +763,24 @@ function St(t, e) {
763
763
  dispose() {
764
764
  return me(), R ?? (R = te.catch(() => {
765
765
  }).then(async () => {
766
- o == null || o.dispose(), o = null, f ? (f(), f = null, o = null, u = null, d = null, D = null) : (d == null || d.root.removeFromParent(), d == null || d.dispose(), d = null, D = null, u == null || u.dispose(), u = null, s == null || s.dispose()), await (I == null ? void 0 : I.catch(() => {
767
- })), N = null, h == null || h.dispose(), h = void 0, C(), a.dispose(), E = null, P = null, c = null, n = null, i = null, v = null, p = null, M = null, S = null, b = !1, _ = !1, g = null, ee = !1;
766
+ o == null || o.dispose(), o = null, c ? (c(), c = null, o = null, u = null, d = null, D = null) : (d == null || d.root.removeFromParent(), d == null || d.dispose(), d = null, D = null, u == null || u.dispose(), u = null, s == null || s.dispose()), await (I == null ? void 0 : I.catch(() => {
767
+ })), T = null, h == null || h.dispose(), h = void 0, C(), a.dispose(), E = null, P = null, f = null, n = null, i = null, b = null, p = null, M = null, S = null, v = !1, _ = !1, g = null, ee = !1;
768
768
  })), R;
769
769
  }
770
770
  };
771
771
  }
772
772
  function Q(t, e) {
773
- if (t || e.aborted) throw fe();
773
+ if (t || e.aborted) throw ce();
774
774
  }
775
- function fe() {
775
+ function ce() {
776
776
  return Object.assign(new Error("Simulation load aborted."), { name: "AbortError", code: "E_ABORTED" });
777
777
  }
778
- const Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
778
+ const Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
779
779
  __proto__: null,
780
780
  createSimulationSession: St
781
781
  }, Symbol.toStringTag, { value: "Module" }));
782
782
  export {
783
- Nt as a,
783
+ Tt as a,
784
784
  pt as c,
785
785
  Pe as s
786
786
  };