@nebula-spatial/viewer 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export { USD_RESOURCE_AUTH, USD_RESOURCE_EXTERNAL_DENIED, USD_RESOURCE_FETCH, US
22
22
  export type { Disposable, ToolbarItem, ViewerState, ViewerInteractionHooks, ViewerContributionPoint, ViewerPlugin, ViewerPluginContext, ViewerPluginRegistry, } from './plugins';
23
23
  export { configureViewerText } from './cad/text';
24
24
  export type { ViewerTextBuilderOptions } from './cad/text';
25
- export type { CadBlockModel, CadDocumentHandle, CadDocumentUnits, CadFontResolver, CadFontRequest, CadResolvedFont, CadResolvedTextFont, CadTextWarmupOptions, CadHudModel, CadHudSnapshot, CadInspectorModel, CadInspectorSnapshot, CadLayerModel, CadLayerRow, CadBlockUsageRow, CadSessionPhase, CadWorldBounds, CadScaleRulerState, CadInsertDetails, CadInsertSelection, CadInsertSelectionId, CadTextDetails, CadTextSelection, CadTextSelectionId, CadSelection, CadHit, CadViewerSnapshot, CadLoadProgress, CadViewerErrorCode, CadViewerErrorEvent, CadLoadSource, CadOpenOptions, CadSessionLoadTiming, RenderDebugBreakdownEntry, SplitBlockLayerDetail, CadViewerCapability, ResolveTextFont, CadViewerEventMap, CameraStateStore, Viewer, ViewerEventMap, ViewerEnvironment, ViewerEnvironmentState, ViewerEnvironmentTexture, ViewerFitViewOptions, ViewerHighlightOptions, ViewerOptions, ViewerPickOptions, ViewerPickResult, ViewerPointerEvent, ViewerObjectOptions, ViewerPreviewDragPreset, ViewerCameraSnapshot, ViewerOrthographicSnapshot, ViewerOrbitSnapshot, ViewerRenderStats, ViewerRenderEffect, ViewerRenderEffectContext, ViewerDocumentRect, ViewerCadUiKeyboardOptions, ViewerUiOptions, ViewerCadUiParts, ViewerCadUiOptions, ViewerUiPreset, ViewerCadUiStateStore, ViewerUiTheme, ViewerViewMode, CadInteractionMode, CameraChangeReason, ViewerUiTokens, } from './types';
25
+ export type { CadBlockModel, CadDocumentHandle, CadDocumentUnits, CadFontResolver, CadFontRequest, CadResolvedFont, CadResolvedTextFont, CadTextWarmupOptions, CadHudModel, CadHudSnapshot, CadInspectorModel, CadInspectorSnapshot, CadLayerModel, CadLayerRow, CadBlockUsageRow, CadSessionPhase, CadWorldBounds, CadScaleRulerState, CadInsertDetails, CadInsertSelection, CadInsertSelectionId, CadTextDetails, CadTextSelection, CadTextSelectionId, CadSelection, CadHit, CadViewerSnapshot, CadLoadProgress, CadViewerErrorCode, CadViewerErrorEvent, CadLoadSource, CadOpenOptions, CadSessionLoadTiming, RenderDebugBreakdownEntry, SplitBlockLayerDetail, CadViewerCapability, ResolveTextFont, CadViewerEventMap, CameraStateStore, Viewer, ViewerEventMap, ViewerEnvironment, ViewerEnvironmentState, ViewerEnvironmentTexture, ViewerFitViewOptions, ViewerHighlightOptions, ViewerModelBounds, ViewerModelDimensions, ViewerOptions, ViewerPickOptions, ViewerPickResult, ViewerPointerEvent, ViewerObjectOptions, ViewerPreviewDragPreset, ViewerCameraSnapshot, ViewerOrthographicSnapshot, ViewerOrbitSnapshot, ViewerRenderStats, ViewerRenderEffect, ViewerRenderEffectContext, ViewerDocumentRect, ViewerCadUiKeyboardOptions, ViewerUiOptions, ViewerCadUiParts, ViewerCadUiOptions, ViewerUiPreset, ViewerCadUiStateStore, ViewerUiTheme, ViewerViewMode, CadInteractionMode, CameraChangeReason, ViewerUiTokens, } from './types';
26
26
  export type { JointInspection, JointInspectionJoint, JointInspectionSnapshot, AssetInspection, UrdfEntityKind, UrdfInspection, UrdfInspectionEntity, UrdfInspectionIssue, UrdfInspectionJoint, UrdfInspectionLink, UrdfInspectionMode, UrdfInspectionNode, UrdfInspectionOverlays, UrdfInspectionRobot, UrdfInspectionSnapshot, UrdfSourceRange } from './inspection/types';
27
27
  /**
28
28
  * Multi-asset scene authoring. A scene owns one stage and several placed
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as s, I as o, V as r, J as n, U as t, H as i, W as c, X as U, Y as d, Z as S, _ as E, $ as _, a0 as D, a1 as l, a2 as R, L as m, a3 as p, a4 as u, m as C, a5 as O, a6 as I, a7 as V, a8 as G, a9 as T, aa as f, ab as N } from "./index-D4V1Rbos.js";
1
+ import { D as s, I as o, V as r, J as n, U as t, H as i, W as c, X as U, Y as d, Z as S, _ as E, $ as _, a0 as D, a1 as l, a2 as R, L as m, a3 as p, a4 as u, m as C, a5 as O, a6 as I, a7 as V, a8 as G, a9 as T, aa as f, ab as N } from "./index-8NPEYTG6.js";
2
2
  import { configureCadTextBuilder as x } from "@nebula-spatial/cad-loader";
3
3
  export {
4
4
  s as DEFAULT_GROUND_GRID_SCALE,
@@ -1,4 +1,4 @@
1
- import { O as v, T as E, d as z } from "./index-D4V1Rbos.js";
1
+ import { O as v, T as E, d as z } from "./index-8NPEYTG6.js";
2
2
  import { Group as q, Euler as G, BoxGeometry as N, SphereGeometry as P, CylinderGeometry as $, CapsuleGeometry as I, PlaneGeometry as X, Mesh as j } from "three";
3
3
  function D(f) {
4
4
  const y = f.extension.documents, l = new q();
@@ -3,7 +3,7 @@ var B = (p, t, e) => t in p ? P(p, t, { enumerable: !0, configurable: !0, writab
3
3
  var j = (p, t, e) => B(p, typeof t != "symbol" ? t + "" : t, e);
4
4
  import L from "@mujoco/mujoco";
5
5
  import { Quaternion as D, Vector3 as w } from "three";
6
- import { e as C, y as R } from "./index-D4V1Rbos.js";
6
+ import { e as C, y as R } from "./index-8NPEYTG6.js";
7
7
  let V = 0;
8
8
  function z(p, t) {
9
9
  const e = `/viewer-simulation-${++V}`;
@@ -1,6 +1,6 @@
1
- import { c as Fe, b as qe, S as Te, w as Je, d as Oe, p as ie, a as ke } from "./asset-ir-DrGD8GAH.js";
2
- import { D as Ne, B as ne, d as Le, E as Ce, S as Re } from "./index-D4V1Rbos.js";
3
- import { a as Ie, r as Ve } from "./spark-renderer-Bt6TPse5.js";
1
+ import { c as Fe, b as qe, S as Te, w as Je, d as Oe, p as ie, a as ke } from "./asset-ir-CTNCY5IT.js";
2
+ import { D as Ne, B as ne, d as Le, E as Ce, S as Re } from "./index-8NPEYTG6.js";
3
+ import { a as Ie, r as Ve } from "./spark-renderer-B_L1Xkr2.js";
4
4
  const Q = 0.7, ue = 0.2, Ue = 110 * Math.PI / 180;
5
5
  function $e(l, e = {}) {
6
6
  const b = l.getSnapshot();
@@ -257,7 +257,7 @@ function er(l, e) {
257
257
  const k = e.format;
258
258
  if (k === "usd" || k === "usda" || k === "usdc" || k === "usdz") {
259
259
  (s = e.reportProgress) == null || s.call(e, "usd-visual", "正在解析 USD 视觉场景...");
260
- const o = await (await import("./usd-session-CHCniTR3.js")).loadUsdSimulation(l, e, b);
260
+ const o = await (await import("./usd-session-DAQ4VHuu.js")).loadUsdSimulation(l, e, b);
261
261
  if (p || e.signal.aborted)
262
262
  throw o.dispose(), fe();
263
263
  D = o, n = { root: o.visual.root, sync() {
@@ -276,7 +276,7 @@ function er(l, e) {
276
276
  }
277
277
  if (k === "urdf" || k === "xacro") {
278
278
  (E = e.reportProgress) == null || E.call(e, "urdf", "正在解析 URDF 场景与运动学结构...");
279
- const o = await (await import("./urdf-session-Bts8dAcU.js")).loadUrdfSimulation(l, e, b);
279
+ const o = await (await import("./urdf-session-VIU_OO_x.js")).loadUrdfSimulation(l, e, b);
280
280
  if (p || e.signal.aborted)
281
281
  throw o.dispose(), fe();
282
282
  F = o.asset, r = o.stage, j = o.inspection, v = o.dispose, c = o.step, f = o.reset, d = o.play, A = o.pause, h = o.isPlaying, g = () => o.capabilities, O = () => o.physics, G = !1, u = !1, C = o.warning ?? null, H(), x();
@@ -300,7 +300,7 @@ function er(l, e) {
300
300
  (we = e.reportProgress) == null || we.call(e, "compile", "正在编译物理模型与参数...");
301
301
  const q = await We(F);
302
302
  $ = q, re(p, e.signal), (ge = e.reportProgress) == null || ge.call(e, "runtime", "正在初始化物理内核...");
303
- const { MujocoRuntime: o } = await import("./mujoco-runtime-D2vfQAaN.js");
303
+ const { MujocoRuntime: o } = await import("./mujoco-runtime-DiiANmuc.js");
304
304
  a = new o(), await a.initialize(q, {
305
305
  baseUrl: e.options.mujocoBaseUrl,
306
306
  wasmModule: e.options.mujocoWasmModule
@@ -308,7 +308,7 @@ function er(l, e) {
308
308
  } catch (q) {
309
309
  const o = ie(q, e.signal, "mjcf-physics");
310
310
  a == null || a.dispose(), a = null;
311
- const { compileMjcfPreview: V } = await import("./mjcf-visual-CgZcMQ20.js");
311
+ const { compileMjcfPreview: V } = await import("./mjcf-visual-U8gS-Yco.js");
312
312
  let U;
313
313
  try {
314
314
  U = V(F);
@@ -1,7 +1,7 @@
1
1
  import { DataTexture as ne, LinearMipmapLinearFilter as Xe, LinearFilter as _e, Loader as J, LoaderUtils as Ve, FileLoader as Ge, TextureLoader as Se, RepeatWrapping as pe, ClampToEdgeWrapping as fe, Texture as Y, MeshPhongMaterial as W, MeshLambertMaterial as Fe, ColorManagement as N, Color as k, SRGBColorSpace as X, EquirectangularReflectionMapping as Ne, Matrix4 as L, Group as ce, Bone as he, PropertyBinding as ee, Object3D as Z, PerspectiveCamera as $e, PointLight as de, MathUtils as B, SpotLight as ze, DirectionalLight as je, SkinnedMesh as He, Mesh as Ae, LineBasicMaterial as We, Line as Ye, Vector3 as V, Skeleton as qe, AmbientLight as Ke, BufferGeometry as re, Float32BufferAttribute as j, Uint16BufferAttribute as Ze, Matrix3 as Qe, Vector2 as Je, ShapeUtils as et, Vector4 as tt, Euler as z, AnimationClip as nt, Quaternion as G, VectorKeyframeTrack as rt, QuaternionKeyframeTrack as me, NumberKeyframeTrack as st, LoadingManager as at, LinearSRGBColorSpace as ge, RGBAFormat as Ie, UnsignedByteType as Re, NoColorSpace as ot, MeshPhysicalMaterial as De, Box3 as it } from "three";
2
2
  import { DRACOLoader as lt } from "three/examples/jsm/loaders/DRACOLoader.js";
3
3
  import { GLTFLoader as ct } from "three/examples/jsm/loaders/GLTFLoader.js";
4
- import { z as ye, A as we, B as ut, d as ve, D as pt } from "./index-D4V1Rbos.js";
4
+ import { z as ye, A as we, B as ut, d as ve, D as pt } from "./index-8NPEYTG6.js";
5
5
  import { TGALoader as ft } from "three/examples/jsm/loaders/TGALoader.js";
6
6
  import * as ht from "three/examples/jsm/libs/fflate.module.js";
7
7
  import { unzlibSync as dt } from "three/examples/jsm/libs/fflate.module.js";
@@ -1733,7 +1733,7 @@ async function Lt(o, e, t) {
1733
1733
  return m = new xt(u).parse(o, ""), await Promise.all(i), e.signal.throwIfAborted(), { root: m, textures: l, textureFailures: f };
1734
1734
  } catch (g) {
1735
1735
  if (n.abort(g), await Promise.allSettled(i), m) {
1736
- const { disposeModelResources: d } = await import("./index-D4V1Rbos.js").then((T) => T.ac);
1736
+ const { disposeModelResources: d } = await import("./index-8NPEYTG6.js").then((T) => T.ac);
1737
1737
  d(m, l);
1738
1738
  } else for (const d of l) d.dispose();
1739
1739
  throw g;
@@ -1,8 +1,8 @@
1
1
  import { Group as O, MeshStandardMaterial as Z, Mesh as z, PointsMaterial as H, Points as j, Color as J, Box3 as $, Vector3 as b, MeshBasicMaterial as Q, BoxGeometry as q } from "three";
2
2
  import { PLYLoader as X } from "three/examples/jsm/loaders/PLYLoader.js";
3
3
  import { S as ee, a as x } from "./spark.module-kM8pwA1o.js";
4
- import { L as te, A as _, B as ne, D as ie } from "./index-D4V1Rbos.js";
5
- import { a as re, r as ae } from "./spark-renderer-Bt6TPse5.js";
4
+ import { L as te, A as _, B as ne, D as ie } from "./index-8NPEYTG6.js";
5
+ import { a as re, r as ae } from "./spark-renderer-B_L1Xkr2.js";
6
6
  function xe(t, e) {
7
7
  let u = !1, s = null, c = null, i = null, o = null, w = null, d = null, h = null, r = null, v = "unsupported", B = null, F = null, k = null, S = "y", G;
8
8
  const V = P(), T = () => {
@@ -1,5 +1,5 @@
1
1
  import { b as d } from "./spark.module-kM8pwA1o.js";
2
- import { R as p } from "./index-D4V1Rbos.js";
2
+ import { R as p } from "./index-8NPEYTG6.js";
3
3
  const a = /* @__PURE__ */ new WeakMap();
4
4
  function o(r, e, s) {
5
5
  let n = a.get(e);
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Box3, ColorRepresentation, Object3D, Vector3 } from 'three';
2
2
  import type { CadViewerCapability, CameraStateStore, ViewerUiOptions, ViewerUiTheme } from './cad/types';
3
3
  import type { AssetChangeEvent, AssetControlChangeEvent, AssetErrorEvent, AssetPreview, AssetSource, OpenAssetOptions, ViewerAssetOptions } from './assets/types';
4
- import type { SceneControl, SceneEntry, SceneOptions } from './scene/types';
4
+ import type { SceneControl, SceneEntry, SceneOptions, Vec3Like } from './scene/types';
5
5
  export type { CadBlockModel, CadDocumentHandle, CadDocumentUnits, CadFontResolver, CadFontRequest, CadResolvedFont, CadResolvedTextFont, CadTextWarmupOptions, CadHudModel, CadHudSnapshot, CadInspectorModel, CadInspectorSnapshot, CadLayerModel, CadLayerRow, CadBlockUsageRow, CadSessionPhase, CadWorldBounds, CadScaleRulerState, CadInsertDetails, CadInsertSelection, CadInsertSelectionId, CadTextDetails, CadTextSelection, CadTextSelectionId, CadSelection, CadHit, CadViewerSnapshot, CadLoadProgress, CadViewerErrorCode, CadViewerErrorEvent, CadLoadSource, CadOpenOptions, CadSessionLoadTiming, RenderDebugBreakdownEntry, SplitBlockLayerDetail, CadViewerCapability, ResolveTextFont, CadViewerEventMap, CameraStateStore, ViewerCadUiKeyboardOptions, ViewerUiOptions, ViewerCadUiParts, ViewerCadUiOptions, ViewerUiPreset, ViewerCadUiStateStore, ViewerUiTheme, ViewerUiTokens, } from './cad/types';
6
6
  export type ViewerViewMode = '2d' | '3d';
7
7
  export type CadInteractionMode = 'managed' | 'manual' | 'disabled';
@@ -76,6 +76,22 @@ export interface ViewerCameraSnapshot {
76
76
  readonly orthographic?: ViewerOrthographicSnapshot;
77
77
  readonly orbit?: ViewerOrbitSnapshot;
78
78
  }
79
+ /** Axis-aligned world bounds at the active asset's current rendered pose. */
80
+ export interface ViewerModelBounds {
81
+ readonly min: Vec3Like;
82
+ readonly max: Vec3Like;
83
+ }
84
+ /**
85
+ * Current model dimensions in meters. Viewer normalizes model/simulation
86
+ * assets to world Z-up, so X is length, Y is width and Z is height.
87
+ */
88
+ export interface ViewerModelDimensions {
89
+ readonly unit: 'm';
90
+ readonly length: number;
91
+ readonly width: number;
92
+ readonly height: number;
93
+ readonly bounds: ViewerModelBounds;
94
+ }
79
95
  export interface ViewerOptions {
80
96
  viewport: HTMLElement;
81
97
  canvas: HTMLCanvasElement;
@@ -192,6 +208,11 @@ export interface ViewerPointerEvent {
192
208
  metaKey: boolean;
193
209
  }
194
210
  export interface ViewerEventMap {
211
+ /** Emitted after each animation-loop update, before the optional render. */
212
+ frame: {
213
+ frameTime: number;
214
+ deltaSeconds: number;
215
+ };
195
216
  'pointer-move': ViewerPointerEvent;
196
217
  'pointer-leave': ViewerPointerEvent;
197
218
  'pointer-click': ViewerPointerEvent;
@@ -295,6 +316,13 @@ export interface Viewer {
295
316
  }): void;
296
317
  /** Switches the UI and active preview stage theme at runtime. */
297
318
  setTheme(theme: ViewerUiTheme): boolean;
319
+ /**
320
+ * Reads exact dimensions at the current rendered pose. With `target`, measures
321
+ * that mounted subtree, which is the editor-selection path used by Studio.
322
+ * Without it, reads the active model/simulation asset. Returns `null` when
323
+ * no measurable content is available.
324
+ */
325
+ getModelDimensions(target?: Object3D): ViewerModelDimensions | null;
298
326
  fitView(target?: Object3D | Box3, options?: ViewerFitViewOptions): boolean;
299
327
  fitAll(options?: ViewerFitViewOptions): boolean;
300
328
  screenToWorldOnPlane(clientX: number, clientY: number, planeZ?: number): Vector3 | null;
@@ -12,6 +12,8 @@ export interface ViewerSceneUiParts {
12
12
  playback?: boolean;
13
13
  reset?: boolean;
14
14
  fit?: boolean;
15
+ /** Length/width/height annotations toggled from the scene toolbar. */
16
+ dimensions?: boolean;
15
17
  upAxis?: boolean;
16
18
  scaleRuler?: boolean;
17
19
  ground?: boolean;
@@ -1,8 +1,8 @@
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-DrGD8GAH.js";
5
- import { d as I, N as Pe, O as be, t as Be, u as Qe, v as we, M as Xe, P as Ke, i as Ze, B as Ye, Q as ve, S as Me } from "./index-D4V1Rbos.js";
4
+ import { c as Ge, b as Te, d as Ve, w as ye, e as ge, p as Je } from "./asset-ir-CTNCY5IT.js";
5
+ import { d as I, N as Pe, O as be, t as Be, u as Qe, v as we, M as Xe, P as Ke, i as Ze, B as Ye, Q as ve, S as Me } from "./index-8NPEYTG6.js";
6
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";
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";
@@ -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-BJGu3wdR.js");
1093
+ const { expandXacro: v } = await import("./xacro-BMaNGmce.js");
1094
1094
  n = await v(n, t, s, e.options.xacro, e.signal);
1095
1095
  }
1096
1096
  if (e.signal.aborted) throw Q();
@@ -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-D2vfQAaN.js");
1143
+ const Z = await import("./mujoco-runtime-DiiANmuc.js");
1144
1144
  if (v = new Z.MujocoRuntime(), await v.initialize(G, {
1145
1145
  baseUrl: e.options.mujocoBaseUrl,
1146
1146
  wasmModule: e.options.mujocoWasmModule