@nebula-spatial/viewer 0.6.5 → 0.6.7

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,5 +1,5 @@
1
1
  import { b as d } from "./spark.module-kM8pwA1o.js";
2
- import { R as p } from "./index-B_0o0gFp.js";
2
+ import { R as p } from "./index-jlMvDvhU.js";
3
3
  const a = /* @__PURE__ */ new WeakMap();
4
4
  function o(r, e, s) {
5
5
  let n = a.get(e);
@@ -1,9 +1,9 @@
1
1
  var We = Object.defineProperty;
2
2
  var Ce = (i, e, s) => e in i ? We(i, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[e] = s;
3
3
  var R = (i, e, s) => Ce(i, typeof e != "symbol" ? e + "" : e, s);
4
- import { c as Ge, b as Te, d as Ve, w as ye, e as ge, p as Je } from "./asset-ir-CpAQLRUA.js";
5
- import { d as I, Q as Pe, T as be, t as Be, u as Qe, v as we, M as Xe, V as Ke, i as Ze, D as Ye, W as ve, S as Me } from "./index-B_0o0gFp.js";
6
- import { Quaternion as P, Euler as X, LoadingManager as _e, Group as L, Mesh as z, MeshLambertMaterial as He, MeshPhongMaterial as Re, MeshStandardMaterial as oe, TextureLoader as et, SRGBColorSpace as tt, RepeatWrapping as it, BoxGeometry as re, SphereGeometry as ae, CylinderGeometry as De, CapsuleGeometry as qe, Matrix4 as W, Vector3 as O, MathUtils as st, Matrix3 as Ae, Box3 as $e, AxesHelper as nt, ArrowHelper as Ee, Line as ot, BufferGeometry as rt, LineBasicMaterial as je, Float32BufferAttribute as at, MeshBasicMaterial as Se, LineSegments as lt, EdgesGeometry as ct } from "three";
4
+ import { c as Ge, d as Te, e as Ve, w as ye, f as ge, a as Je } from "./dynamic-raycast-DhiSzt3O.js";
5
+ import { d as I, V as Oe, W as be, t as Be, u as Qe, v as we, M as Xe, P as Ke, i as Ze, D as Ye, X as ve, S as Me } from "./index-jlMvDvhU.js";
6
+ import { Quaternion as O, Euler as X, LoadingManager as _e, Group as L, Mesh as z, MeshLambertMaterial as He, MeshPhongMaterial as Re, MeshStandardMaterial as oe, TextureLoader as et, SRGBColorSpace as tt, RepeatWrapping as it, BoxGeometry as re, SphereGeometry as ae, CylinderGeometry as De, CapsuleGeometry as qe, Matrix4 as W, Vector3 as P, MathUtils as st, Matrix3 as Ae, Box3 as $e, AxesHelper as nt, ArrowHelper as Ee, Line as ot, BufferGeometry as rt, LineBasicMaterial as je, Float32BufferAttribute as at, MeshBasicMaterial as Se, LineSegments as lt, EdgesGeometry as ct } from "three";
7
7
  import { GLTFLoader as ut } from "three/examples/jsm/loaders/GLTFLoader.js";
8
8
  import { ColladaLoader as dt } from "three/examples/jsm/loaders/ColladaLoader.js";
9
9
  import { OBJLoader as pt } from "three/examples/jsm/loaders/OBJLoader.js";
@@ -54,7 +54,7 @@ function le(i, e = {}) {
54
54
  }));
55
55
  }
56
56
  function K(i) {
57
- return i.rotationQuaternion ? new P().fromArray(i.rotationQuaternion).normalize() : new P().setFromEuler(new X(i.rotationRpy[0], i.rotationRpy[1], i.rotationRpy[2], "ZYX"));
57
+ return i.rotationQuaternion ? new O().fromArray(i.rotationQuaternion).normalize() : new O().setFromEuler(new X(i.rotationRpy[0], i.rotationRpy[1], i.rotationRpy[2], "ZYX"));
58
58
  }
59
59
  function ht(i) {
60
60
  const e = /* @__PURE__ */ new Map(), s = (t) => {
@@ -178,7 +178,7 @@ function gt(i, e, s) {
178
178
  name: D(c, "name"),
179
179
  inertial: (() => {
180
180
  const d = jt(c);
181
- return d && (!(d.mass > 0) || !Number.isFinite(d.mass) || !Pe(d.tensor)) && a.errors.push({ code: "E_URDF_INERTIA", message: `连杆 ${c.getAttribute("name")} 的质量或惯性张量无效。`, source: c.getAttribute("name") ?? void 0 }), d;
181
+ return d && (!(d.mass > 0) || !Number.isFinite(d.mass) || !Oe(d.tensor)) && a.errors.push({ code: "E_URDF_INERTIA", message: `连杆 ${c.getAttribute("name")} 的质量或惯性张量无效。`, source: c.getAttribute("name") ?? void 0 }), d;
182
182
  })(),
183
183
  visuals: [...c.querySelectorAll("visual")].map((d) => {
184
184
  const b = ke(d, e, s), l = d.querySelector("material"), r = l == null ? void 0 : l.getAttribute("name"), p = r ? o.get(r) : void 0, f = (l == null ? void 0 : l.querySelector("color")) ?? (p == null ? void 0 : p.querySelector("color")), h = (l == null ? void 0 : l.querySelector("texture")) ?? (p == null ? void 0 : p.querySelector("texture"));
@@ -221,7 +221,7 @@ function xe(i) {
221
221
  }
222
222
  function ie(i) {
223
223
  const e = new W(), s = K(i);
224
- return e.compose(new O().fromArray(i.position), s, new O(1, 1, 1));
224
+ return e.compose(new P().fromArray(i.position), s, new P(1, 1, 1));
225
225
  }
226
226
  function bt(i) {
227
227
  if (i.type === "continuous" || !i.limits) return 0;
@@ -242,7 +242,7 @@ function wt(i) {
242
242
  for (const t of [-e[0], e[0]])
243
243
  for (const n of [-e[1], e[1]])
244
244
  for (const a of [-e[2], e[2]])
245
- s.push(new O(t, n, a));
245
+ s.push(new P(t, n, a));
246
246
  return s;
247
247
  }
248
248
  function Ie(i, e, s) {
@@ -264,7 +264,7 @@ function Ie(i, e, s) {
264
264
  }
265
265
  for (const h of s.get(r) ?? []) {
266
266
  const g = p.clone().multiply(ie(h.origin)), w = d ? a[h.id] : 0;
267
- w && h.type === "revolute" ? g.multiply(new W().makeRotationAxis(new O().fromArray(h.axis).normalize(), w)) : w && h.type === "prismatic" && g.multiply(new W().makeTranslation(h.axis[0] * w, h.axis[1] * w, h.axis[2] * w)), l(h.child, g);
267
+ w && h.type === "revolute" ? g.multiply(new W().makeRotationAxis(new P().fromArray(h.axis).normalize(), w)) : w && h.type === "prismatic" && g.multiply(new W().makeTranslation(h.axis[0] * w, h.axis[1] * w, h.axis[2] * w)), l(h.child, g);
268
268
  }
269
269
  }
270
270
  };
@@ -468,11 +468,11 @@ async function se(i, e, s) {
468
468
  if (i.type === "sphere") return new z(new ae(i.radius, 24, 16), s);
469
469
  if (i.type === "cylinder") {
470
470
  const o = new z(new De(i.radius, i.radius, i.length, 24), s);
471
- return o.quaternion.copy(new P().setFromEuler(new X(Math.PI / 2, 0, 0))), o;
471
+ return o.quaternion.copy(new O().setFromEuler(new X(Math.PI / 2, 0, 0))), o;
472
472
  }
473
473
  if (i.type === "capsule") {
474
474
  const o = new z(new qe(i.radius, i.length, 8, 24), s);
475
- return o.quaternion.copy(new P().setFromEuler(new X(Math.PI / 2, 0, 0))), o;
475
+ return o.quaternion.copy(new O().setFromEuler(new X(Math.PI / 2, 0, 0))), o;
476
476
  }
477
477
  const t = (a = i.resourcePath.split(".").pop()) == null ? void 0 : a.toLowerCase();
478
478
  await e.ensure(i.resourcePath);
@@ -584,9 +584,9 @@ class St {
584
584
  const g = {
585
585
  joint: f,
586
586
  child: h,
587
- originPosition: new O().fromArray(f.origin.position),
587
+ originPosition: new P().fromArray(f.origin.position),
588
588
  originQuaternion: K(f.origin),
589
- axis: new O().fromArray(f.axis).normalize()
589
+ axis: new P().fromArray(f.axis).normalize()
590
590
  };
591
591
  this.joints.set(f.id, g), this.specs.set(f.id, f), this.values.set(f.id, te(f)), this.apply(g, this.values.get(f.id)), b(f.child);
592
592
  }
@@ -663,7 +663,7 @@ class St {
663
663
  const t = s.child.parent;
664
664
  if (!t) return null;
665
665
  t.updateMatrixWorld(!0);
666
- const n = s.originPosition.clone().applyMatrix4(t.matrixWorld), a = t.getWorldQuaternion(new P()).multiply(s.originQuaternion);
666
+ const n = s.originPosition.clone().applyMatrix4(t.matrixWorld), a = t.getWorldQuaternion(new O()).multiply(s.originQuaternion);
667
667
  return { position: n, quaternion: a, axis: s.axis.clone().applyQuaternion(a).normalize() };
668
668
  }
669
669
  dispose() {
@@ -690,7 +690,7 @@ class St {
690
690
  });
691
691
  }
692
692
  apply(e, s) {
693
- e.child.position.copy(e.originPosition), e.child.quaternion.copy(e.originQuaternion), e.joint.type === "revolute" || e.joint.type === "continuous" ? e.child.quaternion.multiply(new P().setFromAxisAngle(e.axis, s)) : e.joint.type === "prismatic" && e.child.position.addScaledVector(e.axis, s);
693
+ e.child.position.copy(e.originPosition), e.child.quaternion.copy(e.originQuaternion), e.joint.type === "revolute" || e.joint.type === "continuous" ? e.child.quaternion.multiply(new O().setFromAxisAngle(e.axis, s)) : e.joint.type === "prismatic" && e.child.position.addScaledVector(e.axis, s);
694
694
  }
695
695
  }
696
696
  function B(i, e) {
@@ -814,7 +814,7 @@ function Ut(i, e) {
814
814
  for (const [l, r] of b) r.length > 1 && t("link.multiple-parents", "连杆存在多个父关节", `${l} 同时被 ${r.join("、")} 作为 child。`, `link:${l}`, e.links.get(l), { joints: r });
815
815
  for (const l of i.links) {
816
816
  const r = l.inertial;
817
- r && ((!(r.mass > 0) || !Number.isFinite(r.mass)) && t("inertial.mass.invalid", "质量无效", `${l.id} 的质量必须是大于零的有限数。`, `link:${l.id}`, e.links.get(l.id), { mass: r.mass }), Pe(r.tensor) || t("inertial.tensor.invalid", "惯性张量无效", `${l.id} 的惯性张量不是正定的物理惯性张量。`, `link:${l.id}`, e.links.get(l.id), { tensor: r.tensor }));
817
+ r && ((!(r.mass > 0) || !Number.isFinite(r.mass)) && t("inertial.mass.invalid", "质量无效", `${l.id} 的质量必须是大于零的有限数。`, `link:${l.id}`, e.links.get(l.id), { mass: r.mass }), Oe(r.tensor) || t("inertial.tensor.invalid", "惯性张量无效", `${l.id} 的惯性张量不是正定的物理惯性张量。`, `link:${l.id}`, e.links.get(l.id), { tensor: r.tensor }));
818
818
  }
819
819
  return s;
820
820
  }
@@ -835,14 +835,14 @@ function ze(i, e, s, t, n) {
835
835
  if (a < 0) return;
836
836
  const o = i.indexOf(">", a);
837
837
  if (o < 0) return;
838
- const u = i.slice(a, o + 1).trimEnd().endsWith("/>") ? o + 1 : i.indexOf(`</${e}>`, o + 1), c = u < 0 ? o + 1 : u + e.length + 3, d = Oe(i, a), b = Oe(i, c);
838
+ const u = i.slice(a, o + 1).trimEnd().endsWith("/>") ? o + 1 : i.indexOf(`</${e}>`, o + 1), c = u < 0 ? o + 1 : u + e.length + 3, d = Pe(i, a), b = Pe(i, c);
839
839
  return Object.freeze({ file: t, startOffset: a, endOffset: c, startLine: d.line, startColumn: d.column, endLine: b.line, endColumn: b.column });
840
840
  }
841
- function Oe(i, e) {
841
+ function Pe(i, e) {
842
842
  const t = i.slice(0, e).split(/\r?\n/);
843
843
  return { line: t.length, column: t.at(-1).length + 1 };
844
844
  }
845
- class Ot {
845
+ class Pt {
846
846
  constructor(e, s, t, n, a) {
847
847
  R(this, "kind", "urdf");
848
848
  R(this, "overlayRoot", new L());
@@ -888,7 +888,7 @@ class Ot {
888
888
  }
889
889
  select(e) {
890
890
  if (!(this.mode === "dynamics-running" || this.mode === "dynamics-initializing")) {
891
- if (e !== null && !this.document.nodes.some((s) => s.id === e)) throw Pt(`Unknown URDF entity: ${e}`, "E_URDF_ENTITY_UNKNOWN");
891
+ if (e !== null && !this.document.nodes.some((s) => s.id === e)) throw Ot(`Unknown URDF entity: ${e}`, "E_URDF_ENTITY_UNKNOWN");
892
892
  this.selectedEntityId !== e && (this.selectedEntityId = e, this.rebuildOverlay(), this.publish());
893
893
  }
894
894
  }
@@ -979,16 +979,16 @@ class Ot {
979
979
  }
980
980
  };
981
981
  if (o(n), a.isEmpty()) continue;
982
- this.labelAnchors.set(t.name, a.getCenter(new O()).applyMatrix4(n.matrixWorld.clone().invert()));
983
- const m = a.getSize(new O()).length();
982
+ this.labelAnchors.set(t.name, a.getCenter(new P()).applyMatrix4(n.matrixWorld.clone().invert()));
983
+ const m = a.getSize(new P()).length();
984
984
  Number.isFinite(m) && m > 0 && (this.guideSizes.set(t.name, m), e.union(a));
985
985
  }
986
- const s = e.getSize(new O()).length();
986
+ const s = e.getSize(new P()).length();
987
987
  Number.isFinite(s) && s > 0 && (this.modelSize = s);
988
988
  }
989
989
  linkWorldPosition(e, s) {
990
990
  const t = this.linkObject(e);
991
- return !t || this.disposed || this.mode === "dynamics-initializing" ? !1 : (t.updateWorldMatrix(!0, !1), s.copy(this.labelAnchors.get(e) ?? new O()).applyMatrix4(t.matrixWorld), !0);
991
+ return !t || this.disposed || this.mode === "dynamics-initializing" ? !1 : (t.updateWorldMatrix(!0, !1), s.copy(this.labelAnchors.get(e) ?? new P()).applyMatrix4(t.matrixWorld), !0);
992
992
  }
993
993
  guideSize(e) {
994
994
  const s = this.guideSizes.get(e) ?? this.modelSize * 0.1;
@@ -1000,8 +1000,8 @@ class Ot {
1000
1000
  if (t.kind !== "joint" || !this.overlays.jointAxis && t.id !== (s == null ? void 0 : s.id)) continue;
1001
1001
  const n = this.linkObject(t.parentLink), a = n ? (() => {
1002
1002
  n.updateWorldMatrix(!0, !1);
1003
- const c = n.getWorldQuaternion(new P()).multiply(new P().setFromEuler(new X(...t.originRotationRpy, "ZYX")));
1004
- return { position: new O().fromArray(t.originPosition).applyMatrix4(n.matrixWorld), quaternion: c, axis: new O().fromArray(t.axis).applyQuaternion(c).normalize() };
1003
+ const c = n.getWorldQuaternion(new O()).multiply(new O().setFromEuler(new X(...t.originRotationRpy, "ZYX")));
1004
+ return { position: new P().fromArray(t.originPosition).applyMatrix4(n.matrixWorld), quaternion: c, axis: new P().fromArray(t.axis).applyQuaternion(c).normalize() };
1005
1005
  })() : this.binding.jointWorldFrame(t.name);
1006
1006
  if (!a) continue;
1007
1007
  const o = new L();
@@ -1010,7 +1010,7 @@ class Ot {
1010
1010
  if (u.name = `Joint frame:${t.name}`, u.position.copy(a.position), u.quaternion.copy(a.quaternion), o.add(u), ["revolute", "continuous", "prismatic"].includes(t.jointType)) {
1011
1011
  const c = a.axis.clone().normalize(), d = new Ee(c, a.position, 0.28 * m, 5625523, 0.045 * m, 0.022 * m);
1012
1012
  if (d.name = `Joint axis:${t.name}`, o.add(d), t.jointType !== "prismatic") {
1013
- const l = (Math.abs(c.z) < 0.9 ? new O(0, 0, 1) : new O(0, 1, 0)).cross(c).normalize(), r = c.clone().cross(l).normalize(), p = 0.09 * m, f = Math.PI * 1.65, h = a.position.clone().addScaledVector(c, 0.085 * m), g = Array.from({ length: 33 }, (E, $) => {
1013
+ const l = (Math.abs(c.z) < 0.9 ? new P(0, 0, 1) : new P(0, 1, 0)).cross(c).normalize(), r = c.clone().cross(l).normalize(), p = 0.09 * m, f = Math.PI * 1.65, h = a.position.clone().addScaledVector(c, 0.085 * m), g = Array.from({ length: 33 }, (E, $) => {
1014
1014
  const S = f * $ / 32;
1015
1015
  return h.clone().addScaledVector(l, p * Math.cos(S)).addScaledVector(r, p * Math.sin(S));
1016
1016
  }), w = new ot(new rt().setFromPoints(g), new je({ color: 16761963 }));
@@ -1034,7 +1034,7 @@ class Ot {
1034
1034
  const n = t.inertial, a = this.linkObject(t.id);
1035
1035
  if (!n || !a) continue;
1036
1036
  a.updateWorldMatrix(!0, !1);
1037
- const o = new O().fromArray(n.origin.position).applyMatrix4(a.matrixWorld), m = t.id === s;
1037
+ const o = new P().fromArray(n.origin.position).applyMatrix4(a.matrixWorld), m = t.id === s;
1038
1038
  if (this.overlays.centerOfMass) {
1039
1039
  const r = 0.025 * this.guideSize(t.id), p = new ae(r, 32, 16), f = p.toNonIndexed();
1040
1040
  p.dispose();
@@ -1048,14 +1048,14 @@ class Ot {
1048
1048
  }
1049
1049
  f.setAttribute("color", new at(g, 3));
1050
1050
  const w = new z(f, new Se({ color: m ? 16739210 : 16777215, vertexColors: !0, depthTest: !1, depthWrite: !1 }));
1051
- mt(w, r), w.frustumCulled = !1, w.quaternion.copy(a.getWorldQuaternion(new P())), w.position.copy(o), w.renderOrder = 1002, w.name = `Center of mass:${t.id}`, this.overlayRoot.add(w), this.trackGuide(w, a);
1051
+ mt(w, r), w.frustumCulled = !1, w.quaternion.copy(a.getWorldQuaternion(new O())), w.position.copy(o), w.renderOrder = 1002, w.name = `Center of mass:${t.id}`, this.overlayRoot.add(w), this.trackGuide(w, a);
1052
1052
  }
1053
1053
  const u = this.overlays.inertia ? Ze(n.tensor, n.mass) : null;
1054
1054
  if (!u) continue;
1055
1055
  const c = new re(1, 1, 1), d = new lt(new ct(c), new je({ color: m ? 16736135 : 2211300, transparent: !0, opacity: m ? 0.98 : 0.82, depthTest: !0, depthWrite: !1 })), b = new z(c, new Se({ color: m ? 16739210 : 3262699, transparent: !0, opacity: m ? 0.28 : 0.16, depthTest: !0, depthWrite: !1 }));
1056
1056
  b.name = `Inertia fill:${t.id}`;
1057
- const l = n.origin.rotationQuaternion ? new P().fromArray(n.origin.rotationQuaternion) : new P().setFromEuler(new X(...n.origin.rotationRpy, "ZYX"));
1058
- d.position.copy(o), d.scale.fromArray(u.size), d.quaternion.copy(a.getWorldQuaternion(new P())).multiply(l).multiply(u.rotation), d.renderOrder = 1001, d.name = `Inertia:${t.id}`, b.position.copy(d.position), b.quaternion.copy(d.quaternion), b.scale.copy(d.scale), b.renderOrder = 1e3, this.overlayRoot.add(b, d), this.trackGuide(b, a), this.trackGuide(d, a);
1057
+ const l = n.origin.rotationQuaternion ? new O().fromArray(n.origin.rotationQuaternion) : new O().setFromEuler(new X(...n.origin.rotationRpy, "ZYX"));
1058
+ d.position.copy(o), d.scale.fromArray(u.size), d.quaternion.copy(a.getWorldQuaternion(new O())).multiply(l).multiply(u.rotation), d.renderOrder = 1001, d.name = `Inertia:${t.id}`, b.position.copy(d.position), b.quaternion.copy(d.quaternion), b.scale.copy(d.scale), b.renderOrder = 1e3, this.overlayRoot.add(b, d), this.trackGuide(b, a), this.trackGuide(d, a);
1059
1059
  }
1060
1060
  }
1061
1061
  applySelectionMaterials(e) {
@@ -1079,7 +1079,7 @@ class Ot {
1079
1079
  this.highlightedMaterials.clear();
1080
1080
  }
1081
1081
  }
1082
- function Pt(i, e) {
1082
+ function Ot(i, e) {
1083
1083
  return Object.assign(new Error(i), { code: e });
1084
1084
  }
1085
1085
  async function Vt(i, e, s) {
@@ -1090,7 +1090,7 @@ async function Vt(i, e, s) {
1090
1090
  const a = e.format === "xacro";
1091
1091
  if (a) {
1092
1092
  (q = e.reportProgress) == null || q.call(e, "xacro", "正在展开 Xacro 宏与依赖文件...");
1093
- const { expandXacro: v } = await import("./xacro-itfAyoDj.js");
1093
+ const { expandXacro: v } = await import("./xacro-BWEr4Pqt.js");
1094
1094
  n = await v(n, t, s, e.options.xacro, e.signal);
1095
1095
  }
1096
1096
  if (e.signal.aborted) throw Q();
@@ -1117,7 +1117,7 @@ async function Vt(i, e, s) {
1117
1117
  var j;
1118
1118
  const v = E || !u.root.visible;
1119
1119
  E = !1, r.setRuntime(void 0), f && (f.root.visible = !1), r.replaceModel(u.root, !1), u.root.visible = !0, c && c.sync(), c != null && c.root && (c.root.visible = A.getSnapshot().overlays.collision), h && (h.root.visible = !1), v && ((j = e.reportSessionState) == null || j.call(e)), e.requestRender();
1120
- }, A = new Ot(o, kt(o, n, a ? `${t} (expanded URDF)` : t), u, {
1120
+ }, A = new Pt(o, kt(o, n, a ? `${t} (expanded URDF)` : t), u, {
1121
1121
  requestRender() {
1122
1122
  u.root.visible && (c == null || c.sync()), e.requestRender();
1123
1123
  },
@@ -1140,7 +1140,7 @@ async function Vt(i, e, s) {
1140
1140
  try {
1141
1141
  const G = await vt(o);
1142
1142
  if (e.signal.aborted || S) throw Q();
1143
- const Z = await import("./mujoco-runtime-BljZEVSG.js");
1143
+ const Z = await import("./mujoco-runtime-BcD33xjr.js");
1144
1144
  if (v = new Z.MujocoRuntime(), await v.initialize(G, {
1145
1145
  baseUrl: e.options.mujocoBaseUrl,
1146
1146
  wasmModule: e.options.mujocoWasmModule