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