@nebula-spatial/viewer 0.5.6 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,396 +0,0 @@
1
- var A = Object.defineProperty;
2
- var J = (l, t, e) => t in l ? A(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
3
- var p = (l, t, e) => J(l, typeof t != "symbol" ? t + "" : t, e);
4
- import L from "@mujoco/mujoco";
5
- import R from "@mujoco/mujoco/mujoco.wasm?url";
6
- import { Quaternion as I, Vector3 as b } from "three";
7
- let B = 0;
8
- function D(l, t) {
9
- const e = `/viewer-simulation-${++B}`;
10
- l.mkdir(e);
11
- const s = /* @__PURE__ */ new Set([e]), o = /* @__PURE__ */ new Set(), n = (i, a) => {
12
- const m = i.replaceAll("\\", "/").split("/");
13
- if (m[0] === "" || m.some((_) => _ === ".." || _.includes(":"))) throw F(`Invalid package path: ${i}`, "E_SIMULATION_PATH");
14
- const h = m.filter((_) => _ && _ !== ".");
15
- if (!h.length) throw F("Package path is empty.", "E_SIMULATION_PATH");
16
- let c = e;
17
- for (const _ of h.slice(0, -1))
18
- c += `/${_}`, s.has(c) || (l.mkdir(c), s.add(c));
19
- const u = `${e}/${h.join("/")}`;
20
- return l.writeFile(u, a), o.add(u), u;
21
- }, r = () => {
22
- for (const i of o) l.unlink(i);
23
- o.clear();
24
- for (const i of [...s].reverse()) l.rmdir(i);
25
- s.clear();
26
- };
27
- try {
28
- for (const [i, a] of t) n(i, a);
29
- return { writeEntry: (i) => n("__viewer_entry.xml", i), dispose: r };
30
- } catch (i) {
31
- throw r(), i;
32
- }
33
- }
34
- function F(l, t) {
35
- return Object.assign(new Error(l), { code: t });
36
- }
37
- function C({
38
- target: l,
39
- point: t,
40
- velocity: e,
41
- stiffness: s,
42
- damping: o,
43
- maxForce: n,
44
- strength: r
45
- }) {
46
- const i = [
47
- s * (l[0] - t[0]) - o * e[0],
48
- s * (l[1] - t[1]) - o * e[1],
49
- s * (l[2] - t[2]) - o * e[2]
50
- ], a = Math.hypot(i[0], i[1], i[2]), m = n * r;
51
- if (a > m && a > 0) {
52
- const h = m / a;
53
- i[0] *= h, i[1] *= h, i[2] *= h;
54
- }
55
- return i;
56
- }
57
- const g = 1 / 240, z = 1 / 960, V = 0.25, U = 0.05, P = 80, $ = 0.7, Y = 60, H = 1e-4, w = 10, N = 3.5, S = 14;
58
- class W {
59
- constructor() {
60
- p(this, "mujoco", null);
61
- p(this, "model", null);
62
- p(this, "data", null);
63
- p(this, "grab", null);
64
- p(this, "lastGrabForce", [0, 0, 0]);
65
- p(this, "initialControls", []);
66
- p(this, "accumulator", 0);
67
- p(this, "timestep", g);
68
- /** Timestep compiled from the physics asset; grabs may temporarily refine it. */
69
- p(this, "baseTimestep", g);
70
- /** Authored ground pose, captured before any seating. Re-seats start here. */
71
- p(this, "initialGround", null);
72
- /** Ground pose currently in the model; restored verbatim by reset(). */
73
- p(this, "seatedGround", null);
74
- p(this, "worldRotation", new I());
75
- p(this, "topLevelBodies", []);
76
- p(this, "initialVelocities", []);
77
- }
78
- async initialize(t, e) {
79
- var m;
80
- this.mujoco ?? (this.mujoco = await L({ locateFile: (h) => h.endsWith(".wasm") ? e ? new URL(h, e).href : R : h }));
81
- const s = D(this.mujoco.FS, t.files);
82
- let o = null, n = null, r = null, i = null, a = g;
83
- try {
84
- if (o = this.mujoco.MjModel.from_xml_path(s.writeEntry(t.xml)), a = o.opt.timestep, !Number.isFinite(a) || a <= 0)
85
- throw new Error(`Invalid MuJoCo timestep: ${a}`);
86
- for (const c of t.massOverrides ?? []) {
87
- const u = this.mujoco.mj_name2id(o, this.mujoco.mjtObj.mjOBJ_BODY.value, c.body);
88
- if (u <= 0 || !Number.isFinite(c.mass) || c.mass <= 0 || !(o.body_mass[u] > 0)) throw new Error(`Invalid mass override: ${c.body}`);
89
- const _ = c.mass / o.body_mass[u];
90
- o.body_mass[u] = c.mass;
91
- for (let d = 0; d < 3; d++) o.body_inertia[u * 3 + d] *= _;
92
- }
93
- n = new this.mujoco.MjData(o), (m = t.massOverrides) != null && m.length && this.mujoco.mj_setConst(o, n), this.worldRotation.identity(), this.applyInitialControls(n, t.initialControls), this.applyInitialVelocities(o, n, t.initialVelocities), this.mujoco.mj_forward(o, n);
94
- const h = this.mujoco.mj_name2id(o, this.mujoco.mjtObj.mjOBJ_GEOM.value, "__viewer_default_ground__");
95
- r = h < 0 ? null : { id: h, height: o.geom_pos[h * 3 + 2], sameFrame: o.geom_sameframe[h] }, i = this.seatDefaultGround(o, n);
96
- } catch (h) {
97
- throw n == null || n.delete(), o == null || o.delete(), O(h, "E_MUJOCO_INITIALIZE");
98
- } finally {
99
- s.dispose();
100
- }
101
- this.disposeModel(), this.model = o, this.data = n, this.initialControls = t.initialControls ?? [], this.initialVelocities = t.initialVelocities ?? [], this.accumulator = 0, this.baseTimestep = a, this.timestep = a, this.initialGround = r, this.seatedGround = i, this.topLevelBodies = this.captureTopLevelBodies(o);
102
- }
103
- get defaultGroundHeight() {
104
- if (!this.mujoco || !this.model) return;
105
- const t = this.mujoco.mj_name2id(this.model, this.mujoco.mjtObj.mjOBJ_GEOM.value, "__viewer_default_ground__");
106
- return t < 0 ? void 0 : this.model.geom_pos[t * 3 + 2];
107
- }
108
- /**
109
- * Re-orients the compiled physics to the given authored up axis by rotating
110
- * every top-level body about the world origin. Gravity stays -Z and the
111
- * viewer ground stays the authored horizontal plane, so a cup that was
112
- * standing now genuinely topples and settles on its side — the alternative,
113
- * rotating only the rendered scene graph, would leave the visuals and the
114
- * simulation in different frames.
115
- *
116
- * The full current state (free-joint positions, orientations and velocities)
117
- * is rotated by the same delta, so a paused or running simulation is carried
118
- * over instead of being re-seeded.
119
- */
120
- setWorldRotation(t) {
121
- var n;
122
- if (!this.mujoco || !this.model || !this.data) return;
123
- const e = this.model, s = this.data;
124
- if (t.equals(this.worldRotation)) return;
125
- const o = t.clone().multiply(this.worldRotation.clone().invert());
126
- this.rotateReferenceFrames(this.topLevelBodies, t), this.rotateState(this.topLevelBodies, e, s, o), this.worldRotation.copy(t), this.mujoco.mj_forward(e, s), this.seatedGround = this.seatDefaultGround(e, s, (n = this.initialGround) == null ? void 0 : n.height), this.accumulator = 0;
127
- }
128
- captureTopLevelBodies(t) {
129
- const e = this.mujoco, s = [];
130
- for (let o = 1; o < t.nbody; o++) {
131
- if (t.body_parentid[o] !== 0) continue;
132
- const n = t.body_jntadr[o], r = t.body_jntnum[o] === 1 && n >= 0 && t.jnt_type[n] === e.mjtJoint.mjJNT_FREE.value ? n : -1, i = o * 3, a = o * 4;
133
- s.push({
134
- id: o,
135
- position: new b(t.body_pos[i], t.body_pos[i + 1], t.body_pos[i + 2]),
136
- quaternion: new I(t.body_quat[a + 1], t.body_quat[a + 2], t.body_quat[a + 3], t.body_quat[a]),
137
- freeJoint: r
138
- });
139
- }
140
- return s;
141
- }
142
- /** Writes the rotated reference pose, which reset() and fixed bases follow. */
143
- rotateReferenceFrames(t, e) {
144
- const s = this.model;
145
- for (const o of t) {
146
- const n = o.position.clone().applyQuaternion(e), r = e.clone().multiply(o.quaternion), i = o.id * 3, a = o.id * 4;
147
- if (s.body_pos[i] = n.x, s.body_pos[i + 1] = n.y, s.body_pos[i + 2] = n.z, s.body_quat[a] = r.w, s.body_quat[a + 1] = r.x, s.body_quat[a + 2] = r.y, s.body_quat[a + 3] = r.z, s.body_sameframe[o.id] && (s.body_sameframe[o.id] = 0), o.freeJoint < 0) continue;
148
- const m = s.jnt_qposadr[o.freeJoint];
149
- s.qpos0[m] = n.x, s.qpos0[m + 1] = n.y, s.qpos0[m + 2] = n.z, s.qpos0[m + 3] = r.w, s.qpos0[m + 4] = r.x, s.qpos0[m + 5] = r.y, s.qpos0[m + 6] = r.z;
150
- }
151
- }
152
- /** Rotates the live free-joint state so the simulation keeps its progress. */
153
- rotateState(t, e, s, o) {
154
- for (const n of t) {
155
- if (n.freeJoint < 0) continue;
156
- const r = e.jnt_qposadr[n.freeJoint], i = e.jnt_dofadr[n.freeJoint], a = new b(s.qpos[r], s.qpos[r + 1], s.qpos[r + 2]).applyQuaternion(o);
157
- s.qpos[r] = a.x, s.qpos[r + 1] = a.y, s.qpos[r + 2] = a.z;
158
- const m = new I(s.qpos[r + 4], s.qpos[r + 5], s.qpos[r + 6], s.qpos[r + 3]).premultiply(o);
159
- s.qpos[r + 3] = m.w, s.qpos[r + 4] = m.x, s.qpos[r + 5] = m.y, s.qpos[r + 6] = m.z;
160
- const h = new b(s.qvel[i], s.qvel[i + 1], s.qvel[i + 2]).applyQuaternion(o);
161
- s.qvel[i] = h.x, s.qvel[i + 1] = h.y, s.qvel[i + 2] = h.z;
162
- const c = new b(s.qvel[i + 3], s.qvel[i + 4], s.qvel[i + 5]).applyQuaternion(o);
163
- s.qvel[i + 3] = c.x, s.qvel[i + 4] = c.y, s.qvel[i + 5] = c.z;
164
- }
165
- }
166
- /** Lower only the viewer-owned plane, never authored bodies or authored floors.
167
- * Run after forward kinematics, not during stepping (the floor must not follow falling bodies).
168
- * `baseHeight` re-seats from a stable reference; omitting it lowers from the current pose.
169
- */
170
- seatDefaultGround(t, e, s) {
171
- const o = this.mujoco, n = o.mj_name2id(t, o.mjtObj.mjOBJ_GEOM.value, "__viewer_default_ground__");
172
- if (n < 0 || t.geom_bodyid[n] !== 0 || t.geom_type[n] !== o.mjtGeom.mjGEOM_PLANE.value) return null;
173
- let r = s ?? t.geom_pos[n * 3 + 2];
174
- for (let i = 0; i < t.ngeom; i++) {
175
- if (i === n || t.geom_type[i] === o.mjtGeom.mjGEOM_PLANE.value || !(t.geom_contype[i] & t.geom_conaffinity[n]) && !(t.geom_conaffinity[i] & t.geom_contype[n])) continue;
176
- const a = this.geomBottom(t, e, i), m = Math.max(1e-3, t.geom_margin[i] + t.geom_margin[n]);
177
- Number.isFinite(a) && a < r && (r = Math.min(r, a - m));
178
- }
179
- return r !== t.geom_pos[n * 3 + 2] && (t.geom_pos[n * 3 + 2] = r, t.geom_sameframe[n] = 0, o.mj_forward(t, e)), { id: n, height: r, sameFrame: t.geom_sameframe[n] };
180
- }
181
- /**
182
- * Resolve the lowest world-space point directly from MuJoCo's primitive
183
- * parameters. Rotating a mesh's local AABB into world space is conservative:
184
- * for a long, rotated shape it can sit far below the actual geometry. Use the
185
- * compiled vertices for mesh-backed geoms so the ground reflects the real
186
- * lowest point rather than the corners of its local bounding box.
187
- */
188
- geomBottom(t, e, s) {
189
- const o = this.mujoco, n = e.geom_xpos[s * 3 + 2], r = s * 3, i = s * 9, a = t.geom_type[s], m = Math.abs(t.geom_size[r]), h = Math.abs(t.geom_size[r + 1]), c = Math.abs(t.geom_size[r + 2]);
190
- if (a === o.mjtGeom.mjGEOM_SPHERE.value)
191
- return n - m;
192
- if (a === o.mjtGeom.mjGEOM_CAPSULE.value)
193
- return n - m - Math.abs(e.geom_xmat[i + 8]) * h;
194
- if (a === o.mjtGeom.mjGEOM_CYLINDER.value) {
195
- const j = e.geom_xmat[i + 8];
196
- return n - Math.abs(j) * h - Math.sqrt(Math.max(0, 1 - j * j)) * m;
197
- }
198
- if (a === o.mjtGeom.mjGEOM_ELLIPSOID.value)
199
- return n - Math.hypot(
200
- e.geom_xmat[i + 2] * m,
201
- e.geom_xmat[i + 5] * h,
202
- e.geom_xmat[i + 8] * c
203
- );
204
- if (a === o.mjtGeom.mjGEOM_BOX.value)
205
- return n - Math.abs(e.geom_xmat[i + 2]) * m - Math.abs(e.geom_xmat[i + 5]) * h - Math.abs(e.geom_xmat[i + 8]) * c;
206
- if (a === o.mjtGeom.mjGEOM_MESH.value || a === o.mjtGeom.mjGEOM_SDF.value) {
207
- const j = t.geom_dataid[s];
208
- if (j < 0 || j >= t.nmesh) return Number.POSITIVE_INFINITY;
209
- const M = t.mesh_vertadr[j], v = t.mesh_vertnum[j];
210
- if (!Number.isInteger(M) || !Number.isInteger(v) || M < 0 || v <= 0 || M + v > t.nmeshvert)
211
- return Number.POSITIVE_INFINITY;
212
- let x = Number.POSITIVE_INFINITY;
213
- for (let q = M; q < M + v; q++) {
214
- const T = q * 3, G = n + e.geom_xmat[i + 6] * t.mesh_vert[T] + e.geom_xmat[i + 7] * t.mesh_vert[T + 1] + e.geom_xmat[i + 8] * t.mesh_vert[T + 2];
215
- Number.isFinite(G) && G < x && (x = G);
216
- }
217
- return x;
218
- }
219
- const u = s * 6, _ = t.geom_aabb[u + 3], d = t.geom_aabb[u + 4], f = t.geom_aabb[u + 5];
220
- if (![_, d, f].every((j) => Number.isFinite(j) && j >= 0))
221
- return Number.POSITIVE_INFINITY;
222
- const y = n + e.geom_xmat[i + 6] * t.geom_aabb[u] + e.geom_xmat[i + 7] * t.geom_aabb[u + 1] + e.geom_xmat[i + 8] * t.geom_aabb[u + 2], E = Math.abs(e.geom_xmat[i + 6]) * _ + Math.abs(e.geom_xmat[i + 7]) * d + Math.abs(e.geom_xmat[i + 8]) * f;
223
- return y - E;
224
- }
225
- beginGrab({
226
- bodyId: t,
227
- localPoint: e,
228
- target: s,
229
- stiffness: o,
230
- damping: n,
231
- maxForce: r,
232
- dampingRatio: i = $,
233
- maxTargetSpeed: a = N,
234
- targetResponse: m = S
235
- }) {
236
- var f;
237
- const h = Math.max(((f = this.model) == null ? void 0 : f.body_mass[t]) ?? 1, 1e-6), c = o ?? P, u = n ?? 2 * Math.sqrt(c * h) * i, _ = r ?? Math.max(H, h * Y);
238
- this.setTimestep(this.grabTimestep(t, e, h, c));
239
- const d = [s[0], s[1], s[2]];
240
- this.grab = {
241
- bodyId: t,
242
- localPoint: [e[0], e[1], e[2]],
243
- target: [...d],
244
- requestedTarget: d,
245
- stiffness: c,
246
- damping: u,
247
- maxForce: _,
248
- strength: 1,
249
- maxTargetSpeed: a,
250
- targetResponse: m
251
- };
252
- }
253
- updateGrabTarget(t) {
254
- this.grab && (this.grab.requestedTarget = [t[0], t[1], t[2]]);
255
- }
256
- updateGrabStrength(t) {
257
- this.grab && (this.grab.strength = t);
258
- }
259
- applyGrabForce() {
260
- if (!this.grab || !this.model || !this.data || !this.mujoco) return;
261
- const { bodyId: t, localPoint: e, target: s, stiffness: o, damping: n, maxForce: r, strength: i } = this.grab, a = this.data.xmat.subarray(t * 9, t * 9 + 9), m = this.data.xpos.subarray(t * 3, t * 3 + 3), h = [
262
- m[0] + a[0] * e[0] + a[1] * e[1] + a[2] * e[2],
263
- m[1] + a[3] * e[0] + a[4] * e[1] + a[5] * e[2],
264
- m[2] + a[6] * e[0] + a[7] * e[1] + a[8] * e[2]
265
- ], c = this.data.cvel.subarray(t * 6, t * 6 + 6), u = this.data.xipos.subarray(t * 3, t * 3 + 3), _ = [
266
- h[0] - u[0],
267
- h[1] - u[1],
268
- h[2] - u[2]
269
- ], d = [
270
- c[3] + c[1] * _[2] - c[2] * _[1],
271
- c[4] + c[2] * _[0] - c[0] * _[2],
272
- c[5] + c[0] * _[1] - c[1] * _[0]
273
- ], f = C({ target: s, point: h, velocity: d, stiffness: o, damping: n, maxForce: r, strength: i });
274
- this.lastGrabForce = [...f], this.data.qfrc_applied.fill(0);
275
- const y = Math.min(
276
- Math.max(this.model.body_inertia[t * 3], 1e-9),
277
- Math.max(this.model.body_inertia[t * 3 + 1], 1e-9),
278
- Math.max(this.model.body_inertia[t * 3 + 2], 1e-9)
279
- ), E = [
280
- -y * w * c[0],
281
- -y * w * c[1],
282
- -y * w * c[2]
283
- ];
284
- this.mujoco.mj_applyFT(
285
- this.model,
286
- this.data,
287
- f,
288
- E,
289
- h,
290
- t,
291
- this.data.qfrc_applied
292
- );
293
- }
294
- endGrab() {
295
- this.data && this.data.qfrc_applied.fill(0), this.lastGrabForce = [0, 0, 0], this.grab = null, this.setTimestep(this.baseTimestep);
296
- }
297
- step(t) {
298
- if (!this.mujoco || !this.model || !this.data || t <= 0) return !1;
299
- this.accumulator += Math.min(t, U);
300
- let e = !1;
301
- for (; this.accumulator >= this.timestep; )
302
- this.updateGrabTargetForStep(), this.applyGrabForce(), this.mujoco.mj_step(this.model, this.data), this.accumulator -= this.timestep, e = !0;
303
- return e;
304
- }
305
- updateGrabTargetForStep() {
306
- const t = this.grab;
307
- if (!t) return;
308
- const e = t.requestedTarget ?? t.target, s = (t.maxTargetSpeed ?? N) * Math.max(1, Math.sqrt(t.strength)), o = t.targetResponse ?? S, n = 1 - Math.exp(-o * this.timestep), r = s * this.timestep;
309
- for (let i = 0; i < 3; i++) {
310
- const a = e[i] - t.target[i], m = Math.sign(a) * Math.min(Math.abs(a) * n, r);
311
- t.target[i] += m;
312
- }
313
- }
314
- setJointValues(t) {
315
- if (!(!this.mujoco || !this.model || !this.data)) {
316
- for (const [e, s] of Object.entries(t)) {
317
- const o = this.mujoco.mj_name2id(this.model, this.mujoco.mjtObj.mjOBJ_JOINT.value, e);
318
- if (o < 0 || !Number.isFinite(s)) continue;
319
- const n = this.model.jnt_type[o], r = this.mujoco.mjtJoint.mjJNT_HINGE.value, i = this.mujoco.mjtJoint.mjJNT_SLIDE.value;
320
- n !== r && n !== i || (this.data.qpos[this.model.jnt_qposadr[o]] = s);
321
- }
322
- this.mujoco.mj_forward(this.model, this.data), this.seatDefaultGround(this.model, this.data), this.accumulator = 0;
323
- }
324
- }
325
- getJointValues(t) {
326
- const e = {};
327
- if (!this.mujoco || !this.model || !this.data) return e;
328
- for (const s of t) {
329
- const o = this.mujoco.mj_name2id(this.model, this.mujoco.mjtObj.mjOBJ_JOINT.value, s);
330
- if (o < 0) continue;
331
- const n = this.model.jnt_type[o], r = this.mujoco.mjtJoint.mjJNT_HINGE.value, i = this.mujoco.mjtJoint.mjJNT_SLIDE.value;
332
- (n === r || n === i) && (e[s] = this.data.qpos[this.model.jnt_qposadr[o]]);
333
- }
334
- return e;
335
- }
336
- reset() {
337
- if (!(!this.mujoco || !this.model || !this.data)) {
338
- if (this.endGrab(), this.seatedGround) {
339
- const { id: t, height: e, sameFrame: s } = this.seatedGround;
340
- this.model.geom_pos[t * 3 + 2] = e, this.model.geom_sameframe[t] = s;
341
- }
342
- this.mujoco.mj_resetData(this.model, this.data), this.applyInitialControls(this.data, this.initialControls), this.applyInitialVelocities(this.model, this.data, this.initialVelocities), this.mujoco.mj_forward(this.model, this.data), this.accumulator = 0;
343
- }
344
- }
345
- dispose() {
346
- this.disposeModel(), this.mujoco = null;
347
- }
348
- applyInitialControls(t, e) {
349
- if (e != null && e.length) {
350
- if (e.length !== t.ctrl.length) throw O(new Error(`Initial control count ${e.length} does not match MuJoCo actuator count ${t.ctrl.length}.`), "E_MUJOCO_INITIALIZE");
351
- t.ctrl.set(e);
352
- }
353
- }
354
- /**
355
- * A point force on a light body can excite a much higher rotational
356
- * frequency than its translational mass suggests. Refine physics only while
357
- * that body is grabbed instead of adding global damping to hide the error.
358
- */
359
- grabTimestep(t, e, s, o) {
360
- if (!this.model || !this.data) return g;
361
- const n = Math.min(
362
- Math.max(this.model.body_inertia[t * 3], 1e-9),
363
- Math.max(this.model.body_inertia[t * 3 + 1], 1e-9),
364
- Math.max(this.model.body_inertia[t * 3 + 2], 1e-9)
365
- ), r = this.data.xpos.subarray(t * 3, t * 3 + 3), i = this.data.xipos.subarray(t * 3, t * 3 + 3), a = this.data.xmat.subarray(t * 9, t * 9 + 9), m = [
366
- r[0] + a[0] * e[0] + a[1] * e[1] + a[2] * e[2],
367
- r[1] + a[3] * e[0] + a[4] * e[1] + a[5] * e[2],
368
- r[2] + a[6] * e[0] + a[7] * e[1] + a[8] * e[2]
369
- ], h = (m[0] - i[0]) ** 2 + (m[1] - i[1]) ** 2 + (m[2] - i[2]) ** 2, c = Math.sqrt(o * (1 / s + h / n)), u = V / Math.max(c, 1e-9);
370
- return Math.min(this.baseTimestep, Math.max(z, u));
371
- }
372
- setTimestep(t) {
373
- var e;
374
- this.timestep = t, (e = this.model) != null && e.opt && (this.model.opt.timestep = t);
375
- }
376
- applyInitialVelocities(t, e, s) {
377
- for (const o of s ?? []) {
378
- const n = this.mujoco.mj_name2id(t, this.mujoco.mjtObj.mjOBJ_BODY.value, o.body), r = n >= 0 ? t.body_jntadr[n] : -1;
379
- if (r < 0 || t.jnt_type[r] !== this.mujoco.mjtJoint.mjJNT_FREE.value || o.velocity.length !== 6 || !o.velocity.every(Number.isFinite))
380
- throw O(new Error(`Invalid free-body initial velocity: ${o.body}`), "E_MUJOCO_INITIALIZE");
381
- const { worldRotation: i } = this, a = new b(o.velocity[0], o.velocity[1], o.velocity[2]).applyQuaternion(i), m = new b(o.velocity[3], o.velocity[4], o.velocity[5]).applyQuaternion(i);
382
- e.qvel.set([a.x, a.y, a.z, m.x, m.y, m.z], t.jnt_dofadr[r]);
383
- }
384
- }
385
- disposeModel() {
386
- var t, e;
387
- this.endGrab(), (t = this.data) == null || t.delete(), (e = this.model) == null || e.delete(), this.data = null, this.model = null, this.initialGround = null, this.seatedGround = null, this.topLevelBodies = [], this.initialControls = [], this.initialVelocities = [], this.accumulator = 0, this.baseTimestep = g, this.timestep = g;
388
- }
389
- }
390
- function O(l, t) {
391
- const e = l instanceof Error ? l : new Error(String(l));
392
- return Object.assign(e, { code: t });
393
- }
394
- export {
395
- W as MujocoRuntime
396
- };