@nebula-spatial/viewer 0.6.1 → 0.6.2

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 { 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-CHf9y9eX.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-D4V1Rbos.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-CHf9y9eX.js";
1
+ import { O as v, T as E, d as z } from "./index-D4V1Rbos.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-CHf9y9eX.js";
6
+ import { e as C, y as R } from "./index-D4V1Rbos.js";
7
7
  let V = 0;
8
8
  function z(p, t) {
9
9
  const e = `/viewer-simulation-${++V}`;
@@ -14,6 +14,7 @@ import type { AssetPhysicsState, AssetPreviewCapabilities, AssetWarningSnapshot
14
14
  import type { CadLoadSource } from '../cad/types';
15
15
  import type { PhysicsBodyMotionType, PhysicsRuntimeSnapshot } from '../simulation/physics-runtime-state';
16
16
  import type { SceneInstanceJoints } from './joints';
17
+ import type { ViewerRenderEffectContext } from '../types';
17
18
  /** Plain readonly tuple, kept local so this module imports no document types. */
18
19
  export type Vec3Like = readonly [number, number, number];
19
20
  /** Placement of one asset inside the scene, relative to the scene root. */
@@ -60,6 +61,18 @@ export interface SceneEntry {
60
61
  export interface SceneOptions {
61
62
  readonly signal?: AbortSignal;
62
63
  readonly simulationTheme?: 'dark' | 'light';
64
+ /**
65
+ * Ground-grid sizing. `scene` follows mounted scene bounds (default).
66
+ * `editor` fixes the grid to world z=0 and adapts its density to the camera.
67
+ */
68
+ readonly groundGridMode?: 'scene' | 'editor';
69
+ /**
70
+ * Render the ground's planar mirror pass. Defaults to `true`.
71
+ *
72
+ * Disabling it keeps the grid and editor axes while skipping the extra scene
73
+ * render used to populate the reflection texture.
74
+ */
75
+ readonly groundReflection?: boolean;
63
76
  readonly dracoDecoderPath?: string;
64
77
  readonly ktx2TranscoderPath?: string;
65
78
  readonly mujocoBaseUrl?: string;
@@ -224,7 +237,7 @@ export interface SceneControl {
224
237
  /** Advances all playing scene sessions and returns whether any pose changed. */
225
238
  update(deltaSeconds: number): boolean;
226
239
  /** Installs the one shared scene stage transaction for reflection and fog. */
227
- beforeRender(renderer: import('three').WebGLRenderer, scene: import('three').Scene, camera: import('three').Camera): (() => void) | void;
240
+ beforeRender(renderer: import('three').WebGLRenderer, scene: import('three').Scene, camera: import('three').Camera, context?: ViewerRenderEffectContext): (() => void) | void;
228
241
  /** Routes the Viewer's elastic-force grab to the hit scene instance. */
229
242
  beginGrab(event: PointerEvent, camera: import('three').Camera, canvas: HTMLElement): boolean;
230
243
  moveGrab(event: PointerEvent, camera: import('three').Camera, canvas: HTMLElement): void;
@@ -255,6 +268,8 @@ export interface SceneControl {
255
268
  setInstanceCollisionVisible(id: string, visible: boolean | null): boolean;
256
269
  setCollisionVisible(visible: boolean): void;
257
270
  setGroundVisible(visible: boolean): void;
271
+ /** Enables or disables the ground reflection pass without recreating the scene. */
272
+ setGroundReflectionEnabled(enabled: boolean): void;
258
273
  setTheme(theme: 'dark' | 'light'): void;
259
274
  close(): Promise<void>;
260
275
  }
@@ -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-CHf9y9eX.js";
4
+ import { z as ye, A as we, B as ut, d as ve, D as pt } from "./index-D4V1Rbos.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-CHf9y9eX.js").then((T) => T.ac);
1736
+ const { disposeModelResources: d } = await import("./index-D4V1Rbos.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,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-BXa1EdOy.js";
2
- import { D as Ne, B as ne, d as Le, E as Ce, S as Re } from "./index-CHf9y9eX.js";
3
- import { a as Ie, r as Ve } from "./spark-renderer-BGF_AaI9.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-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";
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-DyNMsD-v.js")).loadUsdSimulation(l, e, b);
260
+ const o = await (await import("./usd-session-CHCniTR3.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-CKlR-fOQ.js")).loadUrdfSimulation(l, e, b);
279
+ const o = await (await import("./urdf-session-Bts8dAcU.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-BA88JuDR.js");
303
+ const { MujocoRuntime: o } = await import("./mujoco-runtime-D2vfQAaN.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-DxMXiBnu.js");
311
+ const { compileMjcfPreview: V } = await import("./mjcf-visual-CgZcMQ20.js");
312
312
  let U;
313
313
  try {
314
314
  U = V(F);
@@ -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-CHf9y9eX.js";
5
- import { a as re, r as ae } from "./spark-renderer-BGF_AaI9.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";
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-CHf9y9eX.js";
2
+ import { R as p } from "./index-D4V1Rbos.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
@@ -143,12 +143,18 @@ export interface ViewerOptions {
143
143
  export interface ViewerFitViewOptions {
144
144
  padding?: number;
145
145
  viewMode?: ViewerViewMode;
146
- /** Keep the document/asset-owned preview camera range and clipping profile. */
146
+ /**
147
+ * Keep the scene-owned maximum distance and far plane. The minimum distance
148
+ * and near plane may shrink so a focused object remains reachable and
149
+ * visible for detail inspection.
150
+ */
147
151
  preservePreviewCameraRange?: boolean;
148
152
  /** Rebuild the preview camera profile without moving the camera. */
149
153
  preserveCameraPose?: boolean;
150
154
  /** Maximum preview orbit distance as a multiple of the fitted radius. */
151
155
  previewMaxDistanceFactor?: number;
156
+ /** Lower bound for the preview maximum orbit distance, in world units. */
157
+ minimumMaxDistance?: number;
152
158
  }
153
159
  export interface ViewerPickOptions {
154
160
  /** Stop at the nearest intersection when accelerated picking is available. */
@@ -329,6 +335,7 @@ export interface Viewer {
329
335
  export interface ViewerRenderEffectContext {
330
336
  readonly purpose: 'viewport' | 'capture';
331
337
  readonly target: import('three').WebGLRenderTarget | null;
338
+ readonly navigationTarget?: import('three').Vector3;
332
339
  }
333
340
  export interface ViewerRenderEffect {
334
341
  isActive?(): 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-BXa1EdOy.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-CHf9y9eX.js";
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";
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-BCLnc3tY.js");
1093
+ const { expandXacro: v } = await import("./xacro-BJGu3wdR.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-BA88JuDR.js");
1143
+ const Z = await import("./mujoco-runtime-D2vfQAaN.js");
1144
1144
  if (v = new Z.MujocoRuntime(), await v.initialize(G, {
1145
1145
  baseUrl: e.options.mujocoBaseUrl,
1146
1146
  wasmModule: e.options.mujocoWasmModule