@nebula-spatial/viewer 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as o } from "./index-D-o1ODOX.js";
1
+ import { c as o } from "./index-CxbZ--5C.js";
2
2
  import { configureCadTextBuilder as t } from "@nebula-spatial/cad-loader";
3
3
  export {
4
4
  t as configureViewerText,
@@ -20,6 +20,8 @@ export interface UrdfInspectionLink extends UrdfInspectionEntity {
20
20
  readonly kind: 'link';
21
21
  readonly mass?: number;
22
22
  readonly centerOfMass?: readonly number[];
23
+ /** Authored inertial frame RPY relative to the link frame, in radians. */
24
+ readonly inertialRotationRpy?: readonly number[];
23
25
  readonly inertiaTensor?: readonly number[];
24
26
  readonly inertiaMass?: number;
25
27
  readonly visualCount: number;
@@ -40,6 +42,15 @@ export interface UrdfInspectionJoint extends UrdfInspectionEntity {
40
42
  readonly effort?: number;
41
43
  readonly velocity?: number;
42
44
  readonly movable: boolean;
45
+ readonly controlLimits?: {
46
+ readonly lower: number;
47
+ readonly upper: number;
48
+ };
49
+ readonly mimic?: {
50
+ readonly joint: string;
51
+ readonly multiplier: number;
52
+ readonly offset: number;
53
+ };
43
54
  }
44
55
  export interface UrdfInspectionRobot extends UrdfInspectionEntity {
45
56
  readonly kind: 'robot';
@@ -93,6 +104,8 @@ export interface UrdfInspection {
93
104
  position: import('three').Vector3;
94
105
  axis: import('three').Vector3;
95
106
  } | null;
107
+ /** World-space label anchor at the own-link visual bounds center. */
108
+ linkWorldPosition?(linkId: string, target: import('three').Vector3): boolean;
96
109
  pickRoots?(): readonly import('three').Object3D[];
97
110
  }
98
111
  /** Tagged inspection surface. Future formats can extend this union without changing AssetPreview. */
@@ -0,0 +1,73 @@
1
+ import { e as v, s as E } from "./session-DNyPmQOW.js";
2
+ import { Group as q, Euler as z, BoxGeometry as G, SphereGeometry as N, CylinderGeometry as P, CapsuleGeometry as $, PlaneGeometry as I, Mesh as X } from "three";
3
+ import { d as j } from "./stage-BPiGudYP.js";
4
+ function U(f) {
5
+ const y = f.extension.documents, l = new q();
6
+ l.name = f.name;
7
+ try {
8
+ if (y.size !== 1) throw new Error("MJCF 独立预览暂不支持 include");
9
+ const u = [...y.values()][0];
10
+ if (u.querySelector("default, include, attach, replicate, composite, flexcomp, skin, hfield, plugin")) throw new Error("MJCF 独立预览包含尚不支持的继承、组合或扩展语义");
11
+ const a = u.querySelector("compiler");
12
+ if ((a == null ? void 0 : a.getAttribute("coordinate")) === "global" || a != null && a.hasAttribute("eulerseq")) throw new Error("MJCF 独立预览不支持此坐标设置");
13
+ const g = (a == null ? void 0 : a.getAttribute("angle")) === "radian" ? 1 : Math.PI / 180, b = (c, m) => {
14
+ const e = c ? c.trim().split(/\s+/).map(Number) : m;
15
+ if (e.some((s) => !Number.isFinite(s))) throw new Error("MJCF 视觉坐标无效");
16
+ return e;
17
+ }, h = (c, m, e) => {
18
+ const s = b(c, m);
19
+ if (s.length !== e) throw new Error(`MJCF 视觉变换需要 ${e} 个分量`);
20
+ return s;
21
+ }, M = (c, m) => {
22
+ for (const e of c.children) {
23
+ if (!["body", "geom"].includes(e.tagName)) continue;
24
+ if (["class", "childclass", "fromto", "axisangle", "xyaxes", "zaxis"].some((t) => e.hasAttribute(t))) throw new Error("MJCF 独立预览不支持此变换或默认类");
25
+ const s = new q();
26
+ if (s.name = e.getAttribute("name") ?? e.tagName, s.position.fromArray(h(e.getAttribute("pos"), [0, 0, 0], 3)), e.hasAttribute("quat")) {
27
+ const t = h(e.getAttribute("quat"), [1, 0, 0, 0], 4);
28
+ if (Math.hypot(...t) === 0) throw new Error("MJCF 视觉四元数不能为零");
29
+ s.quaternion.set(t[1], t[2], t[3], t[0]).normalize();
30
+ } else {
31
+ const t = h(e.getAttribute("euler"), [0, 0, 0], 3);
32
+ s.quaternion.setFromEuler(new z(t[0] * g, t[1] * g, t[2] * g, "XYZ"));
33
+ }
34
+ if (m.add(s), e.tagName === "body") {
35
+ M(e, s);
36
+ continue;
37
+ }
38
+ const n = e.getAttribute("type") ?? (e.hasAttribute("mesh") ? "mesh" : "sphere"), r = b(e.getAttribute("size"), []);
39
+ if (r.length === 0) throw new Error("MJCF 独立预览缺少可直接解析的几何或材质");
40
+ const F = { box: 3, sphere: 1, cylinder: 2, capsule: 2, plane: 3 }[n];
41
+ if (F && (r.length < F || r.some((t) => n === "plane" ? t < 0 : t <= 0)))
42
+ throw new Error(`MJCF geom ${n} 的尺寸缺失或无效`);
43
+ let i;
44
+ if (n === "box") i = new G(2 * r[0], 2 * r[1], 2 * r[2]);
45
+ else if (n === "sphere") i = new N(r[0]);
46
+ else if (n === "cylinder")
47
+ i = new P(r[0], r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
48
+ else if (n === "capsule")
49
+ i = new $(r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
50
+ else if (n === "plane") i = new I(2 * (r[0] || 5), 2 * (r[1] || 5));
51
+ else throw new Error(`MJCF 独立预览暂不支持 geom ${n}`);
52
+ const p = e.getAttribute("material"), o = [...u.querySelectorAll("asset > material")].find((t) => t.getAttribute("name") === p);
53
+ if (p && !o) throw new Error(`Undefined MJCF material: ${p}`);
54
+ if (o != null && o.hasAttribute("texture") || o != null && o.querySelector("layer")) throw new Error("MJCF textured preview requires the compiled material pipeline");
55
+ const x = h(e.getAttribute("rgba"), [0.5, 0.5, 0.5, 1], 4), J = o && x.every((t, d) => t === [0.5, 0.5, 0.5, 1][d]) ? h(o.getAttribute("rgba"), [1, 1, 1, 1], 4) : x, w = (t, d) => o != null && o.hasAttribute(t) ? b(o.getAttribute(t), [d])[0] : d, S = v({
56
+ color: J,
57
+ roughness: o ? E(w("roughness", -1), w("shininess", 0.5)) : E(),
58
+ metalness: Math.max(0, w("metallic", 0)),
59
+ specular: w("specular", 0.5),
60
+ emission: w("emission", 0)
61
+ }), C = new X(i, S);
62
+ n === "plane" && m === l && (C.userData.excludeFromSimulationFit = !0), s.add(C);
63
+ }
64
+ }, A = u.querySelector("worldbody");
65
+ if (!A) throw new Error("MJCF 缺少 worldbody");
66
+ return M(A, l), l.updateMatrixWorld(!0), l;
67
+ } catch (u) {
68
+ throw j(l), u;
69
+ }
70
+ }
71
+ export {
72
+ U as compileMjcfPreview
73
+ };
@@ -1,7 +1,7 @@
1
1
  import { DataTexture as N, LinearMipmapLinearFilter as oe, LinearFilter as ae, LoadingManager as ie, Loader as le, Texture as X, TextureLoader as ce, LinearSRGBColorSpace as G, SRGBColorSpace as ue, RGBAFormat as K, UnsignedByteType as J, NoColorSpace as fe, Mesh as pe, MeshPhysicalMaterial as Q, MeshPhongMaterial as k, MeshLambertMaterial as de, Color as _, Quaternion as Z, Vector3 as ee, Group as he, Box3 as me } from "three";
2
2
  import { DRACOLoader as ge } from "three/examples/jsm/loaders/DRACOLoader.js";
3
3
  import { GLTFLoader as ye } from "three/examples/jsm/loaders/GLTFLoader.js";
4
- import { S as we, d as Y } from "./stage-D113SHD8.js";
4
+ import { S as we, d as Y } from "./stage-BPiGudYP.js";
5
5
  import { TGALoader as be } from "three/examples/jsm/loaders/TGALoader.js";
6
6
  import { FBXLoader as xe } from "three/examples/jsm/loaders/FBXLoader.js";
7
7
  import { unzlibSync as Ee } from "three/examples/jsm/libs/fflate.module.js";
@@ -177,7 +177,7 @@ async function Ae(e, t, n) {
177
177
  return l = new xe(m).parse(e, ""), await Promise.all(p), t.signal.throwIfAborted(), { root: l, textures: d };
178
178
  } catch (u) {
179
179
  if (s.abort(u), await Promise.allSettled(p), l) {
180
- const { disposeModelResources: w } = await import("./stage-D113SHD8.js").then((f) => f.r);
180
+ const { disposeModelResources: w } = await import("./stage-BPiGudYP.js").then((f) => f.r);
181
181
  w(l, d);
182
182
  } else for (const w of d) w.dispose();
183
183
  throw u;