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