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