@nebula-spatial/viewer 0.6.6 → 0.6.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this package are documented in this file.
4
4
 
5
+ ## 0.6.8
6
+
7
+ ### Fixed
8
+
9
+ - 修复动态 Raycast 的 BVH 构建参数与 `three-mesh-bvh` 0.9 系列部分版本不匹配的问题:这些版本不支持 `targetLeafSize`,导致软体/Flex 动态网格回退到默认叶节点大小;改用兼容的 `maxLeafSize` 后按预期构建加速结构。
10
+
11
+ ## 0.6.7
12
+
13
+ ### Fixed
14
+
15
+ - 修复场景运行时对模型世界包围盒重复应用实例变换,导致移动、旋转、缩放或设置原点后包围盒与实际几何不一致的问题;`getFitBounds()` 统一返回当前世界坐标包围盒,点云与 Gaussian 资产同步按当前挂载变换测量。
16
+
5
17
  ## 0.6.6
6
18
 
7
19
  ### Fixed
@@ -362,6 +362,7 @@ export interface AssetSession {
362
362
  setGroundVisible?(visible: boolean): void;
363
363
  getGroundVisible?(): boolean;
364
364
  getGroundGridScale?(): GroundGridScale;
365
+ /** Current world-space visual bounds, including mounted ancestors; callers must not transform them again. */
365
366
  getFitBounds?(): Box3 | null;
366
367
  readonly fitTarget?: Object3D | Box3 | null;
367
368
  readonly id: string;
@@ -1,7 +1,7 @@
1
1
  var lt = Object.defineProperty;
2
2
  var ct = (e, t, n) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var U = (e, t, n) => ct(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { I as ut, J as x, K as X, L as ft, N as dt, O as ht, U as mt, s as pt, M as bt, P as _t } from "./index-DyBfusq5.js";
4
+ import { I as ut, J as x, K as X, L as ft, N as dt, O as ht, U as mt, s as pt, M as bt, P as _t } from "./index-DEmX80cg.js";
5
5
  import { Vector3 as Z } from "three";
6
6
  const Et = /* @__PURE__ */ new Set([
7
7
  "E_MJCF_INCLUDE_CYCLE",
@@ -643,7 +643,7 @@ function qt(e, t = e.geometry) {
643
643
  let s = n.boundsTree, i = !1;
644
644
  if (!s) {
645
645
  try {
646
- s = new bt(t, { targetLeafSize: 20, indirect: !0, verbose: !1 });
646
+ s = new bt(t, { maxLeafSize: 20, indirect: !0, verbose: !1 });
647
647
  } catch {
648
648
  return Bt;
649
649
  }
@@ -12,7 +12,7 @@ import { createCadDocumentSession as $l, getCadDocumentRenderResource as Gl, for
12
12
  import { CSS2DObject as Hl, CSS2DRenderer as ql } from "three/addons/renderers/CSS2DRenderer.js";
13
13
  import { viewerRuntimeAssetUrls as ys } from "@nebula-spatial/viewer/runtime-assets";
14
14
  import Wl from "@mujoco/mujoco/mujoco.wasm?url";
15
- const Yl = "0.6.6", Xl = "@nebula-spatial/viewer", xs = "__NEBULA_SPATIAL_VIEWER_BANNER_PRINTED__";
15
+ const Yl = "0.6.8", Xl = "@nebula-spatial/viewer", xs = "__NEBULA_SPATIAL_VIEWER_BANNER_PRINTED__";
16
16
  function ws() {
17
17
  const n = `%c ${Xl} %c v${Yl} `;
18
18
  console.log(n, "background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;", "background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;");
@@ -10272,7 +10272,7 @@ const Wh = {
10272
10272
  clearColor: ut.dark
10273
10273
  },
10274
10274
  async createSession(e, t) {
10275
- const { createModelSession: i } = await import("./session-CzJBN0Us.js");
10275
+ const { createModelSession: i } = await import("./session-D98gYyL3.js");
10276
10276
  return i(e, t);
10277
10277
  }
10278
10278
  });
@@ -10356,7 +10356,7 @@ const Zh = {
10356
10356
  clearColor: ut.dark
10357
10357
  },
10358
10358
  async createSession(e, t) {
10359
- const { createSimulationSession: i } = await import("./session-DXUACJAS.js");
10359
+ const { createSimulationSession: i } = await import("./session-CxPD2fPU.js");
10360
10360
  return i(e, t);
10361
10361
  }
10362
10362
  });
@@ -11472,7 +11472,7 @@ const Rp = {
11472
11472
  return t === "ply" ? { format: "ply" } : t === "spz" ? { format: "gaussian-spz" } : t === "splat" ? { format: "splat" } : t === "ksplat" ? { format: "ksplat" } : t === "sog" || (s = e.entryPath) != null && s.toLowerCase().endsWith(".sog.zip") ? { format: "sog" } : t === "rad" ? { format: "rad" } : null;
11473
11473
  },
11474
11474
  async createSession(e, t) {
11475
- const { createVisualSession: i } = await import("./session-BerXscrf.js");
11475
+ const { createVisualSession: i } = await import("./session-D20eDowE.js");
11476
11476
  return i(e, t);
11477
11477
  }
11478
11478
  });
@@ -15685,7 +15685,7 @@ function Am(n, e, t) {
15685
15685
  }, te = (A) => {
15686
15686
  var O, j;
15687
15687
  const T = (j = (O = A.session).getFitBounds) == null ? void 0 : j.call(O);
15688
- return T && !T.isEmpty() ? (A.content.updateWorldMatrix(!0, !1), T.clone().applyMatrix4(A.content.matrixWorld)) : new re().setFromObject(A.group, !0);
15688
+ return T && !T.isEmpty() ? T.clone() : new re().setFromObject(A.group, !0);
15689
15689
  }, He = () => {
15690
15690
  const A = new re();
15691
15691
  for (const T of h) {
@@ -15762,7 +15762,7 @@ function Am(n, e, t) {
15762
15762
  }
15763
15763
  let O = null, j = null;
15764
15764
  try {
15765
- const H = dm(T, a.environment), { MujocoRuntime: ee } = await import("./mujoco-runtime-CZSNQ7An.js");
15765
+ const H = dm(T, a.environment), { MujocoRuntime: ee } = await import("./mujoco-runtime-Dn2yyGuI.js");
15766
15766
  if (O = new ee(), await O.initialize(H.physics, {
15767
15767
  baseUrl: e.mujocoBaseUrl,
15768
15768
  wasmModule: e.mujocoWasmModule
@@ -17750,7 +17750,7 @@ function Jg(n = {}) {
17750
17750
  }
17751
17751
  let xa = null;
17752
17752
  function Zg() {
17753
- return xa ?? (xa = import("./usd-session-CLU3UR4C.js").then(() => {
17753
+ return xa ?? (xa = import("./usd-session-DRnVjKEv.js").then(() => {
17754
17754
  })), xa;
17755
17755
  }
17756
17756
  function Zm(n) {
@@ -18434,7 +18434,7 @@ async function pv(n) {
18434
18434
  return n.size ? vl(n.type, await n.slice(0, 512).text()) : "响应内容为空";
18435
18435
  }
18436
18436
  export {
18437
- aa as $,
18437
+ Ui as $,
18438
18438
  Vg as A,
18439
18439
  Ug as B,
18440
18440
  $g as C,
@@ -18454,31 +18454,32 @@ export {
18454
18454
  lv as Q,
18455
18455
  nl as R,
18456
18456
  _f as S,
18457
- bm as T,
18457
+ Ei as T,
18458
18458
  wg as U,
18459
- Hf as V,
18460
- rl as W,
18461
- na as X,
18462
- Sg as Y,
18463
- Wg as Z,
18464
- Ui as _,
18459
+ bm as V,
18460
+ Hf as W,
18461
+ rl as X,
18462
+ na as Y,
18463
+ Sg as Z,
18464
+ Wg as _,
18465
18465
  hv as a,
18466
- Jg as a0,
18467
- Kg as a1,
18468
- Mm as a2,
18469
- Am as a3,
18470
- qg as a4,
18471
- gg as a5,
18472
- Hg as a6,
18473
- Tu as a7,
18474
- Cm as a8,
18475
- Yt as a9,
18476
- Zg as aa,
18477
- ov as ab,
18478
- av as ac,
18479
- Sm as ad,
18480
- Yl as ae,
18481
- zg as af,
18466
+ aa as a0,
18467
+ Jg as a1,
18468
+ Kg as a2,
18469
+ Mm as a3,
18470
+ Am as a4,
18471
+ qg as a5,
18472
+ gg as a6,
18473
+ Hg as a7,
18474
+ Tu as a8,
18475
+ Cm as a9,
18476
+ Yt as aa,
18477
+ Zg as ab,
18478
+ ov as ac,
18479
+ av as ad,
18480
+ Sm as ae,
18481
+ Yl as af,
18482
+ zg as ag,
18482
18483
  ng as b,
18483
18484
  dv as c,
18484
18485
  Oi as d,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E as s, L as o, Y as r, N as n, U as t, K as c, Z as i, _ as d, $ as U, a0 as S, a1 as E, a2 as _, a3 as l, a4 as D, a5 as R, Q as m, a6 as p, a7 as u, m as C, a8 as O, a9 as G, aa as I, ab as N, ac as T, ad as V, ae as f } from "./index-DyBfusq5.js";
1
+ import { E as s, L as o, Z as r, N as n, U as t, K as c, _ as i, $ as d, a0 as U, a1 as S, a2 as E, a3 as _, a4 as l, a5 as D, a6 as R, Q as m, a7 as p, a8 as u, m as C, a9 as O, aa as f, ab as G, ac as I, ad as N, ae as T, af as V } from "./index-DEmX80cg.js";
2
2
  import { configureCadTextBuilder as x } from "@nebula-spatial/cad-loader";
3
3
  export {
4
4
  s as DEFAULT_GROUND_GRID_SCALE,
@@ -22,10 +22,10 @@ export {
22
22
  u as formatGroundGridScale,
23
23
  C as getUsdQuery,
24
24
  O as isSceneScalarJoint,
25
- G as jointBlockReason,
26
- I as preloadUsdViewer,
27
- N as prewarmUsdWorker,
28
- T as probeUsdDependencies,
29
- V as toSceneJointDescriptor,
30
- f as viewerVersion
25
+ f as jointBlockReason,
26
+ G as preloadUsdViewer,
27
+ I as prewarmUsdWorker,
28
+ N as probeUsdDependencies,
29
+ T as toSceneJointDescriptor,
30
+ V as viewerVersion
31
31
  };
@@ -1,6 +1,6 @@
1
- import { V as v, X as E, d as z } from "./index-DyBfusq5.js";
2
- import { Group as q, Euler as G, BoxGeometry as N, SphereGeometry as P, CylinderGeometry as X, CapsuleGeometry as $, PlaneGeometry as I, Mesh as j } from "three";
3
- function B(f) {
1
+ import { W as v, Y as E, d as z } from "./index-DEmX80cg.js";
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
+ function Y(f) {
4
4
  const y = f.extension.documents, l = new q();
5
5
  l.name = f.name;
6
6
  try {
@@ -43,10 +43,10 @@ function B(f) {
43
43
  if (n === "box") i = new N(2 * r[0], 2 * r[1], 2 * r[2]);
44
44
  else if (n === "sphere") i = new P(r[0]);
45
45
  else if (n === "cylinder")
46
- i = new X(r[0], r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
46
+ i = new $(r[0], r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
47
47
  else if (n === "capsule")
48
- i = new $(r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
49
- else if (n === "plane") i = new I(2 * (r[0] || 5), 2 * (r[1] || 5));
48
+ i = new I(r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
49
+ else if (n === "plane") i = new X(2 * (r[0] || 5), 2 * (r[1] || 5));
50
50
  else throw new Error(`MJCF 独立预览暂不支持 geom ${n}`);
51
51
  const p = e.getAttribute("material"), o = [...u.querySelectorAll("asset > material")].find((t) => t.getAttribute("name") === p);
52
52
  if (p && !o) throw new Error(`Undefined MJCF material: ${p}`);
@@ -68,5 +68,5 @@ function B(f) {
68
68
  }
69
69
  }
70
70
  export {
71
- B as compileMjcfPreview
71
+ Y as compileMjcfPreview
72
72
  };
@@ -3,7 +3,7 @@ var et = (v, t, e) => t in v ? tt(v, t, { enumerable: !0, configurable: !0, writ
3
3
  var x = (v, t, e) => et(v, typeof t != "symbol" ? t + "" : t, e);
4
4
  import it from "@mujoco/mujoco";
5
5
  import { Quaternion as B, Vector3 as D } from "three";
6
- import { e as st, y as U, z as ot } from "./index-DyBfusq5.js";
6
+ import { e as st, y as U, z as ot } from "./index-DEmX80cg.js";
7
7
  let rt = 0;
8
8
  function nt(v, t) {
9
9
  const e = `/viewer-simulation-${++rt}`;
@@ -1,7 +1,7 @@
1
- import { c as Ie, d as Ue, p as Ve, S as Le, w as ke, e as Je, a as oe, b as $e } from "./dynamic-raycast-Ctu2X5u5.js";
2
- import { F as xe, G as ze, E as Xe, D as ue, d as We, H as Fe, S as Re } from "./index-DyBfusq5.js";
1
+ import { c as Ie, d as Ue, p as Ve, S as Le, w as ke, e as Je, a as oe, b as $e } from "./dynamic-raycast-BW_YlAtV.js";
2
+ import { F as xe, G as ze, E as Xe, D as ue, d as We, H as Fe, S as Re } from "./index-DEmX80cg.js";
3
3
  import { CylinderGeometry as Ye, MeshStandardMaterial as _e, InstancedMesh as Be, DynamicDrawUsage as He, BufferGeometry as Ke, BufferAttribute as Ge, DoubleSide as Qe, Mesh as Ze, DataTexture as et, RGBAFormat as tt, UnsignedByteType as rt, SRGBColorSpace as st, NoColorSpace as at, RepeatWrapping as nt, LinearFilter as it, LinearMipmapLinearFilter as lt, Vector3 as Y, Quaternion as ot, Matrix4 as ut } from "three";
4
- import { a as ft, r as ct } from "./spark-renderer-dvFIUjr0.js";
4
+ import { a as ft, r as ct } from "./spark-renderer-D-bKFKf6.js";
5
5
  const Z = 0.7, fe = 0.2, dt = 110 * Math.PI / 180;
6
6
  function mt(l, e = {}) {
7
7
  const g = l.getSnapshot();
@@ -404,7 +404,7 @@ function Rt(l, e) {
404
404
  const k = e.format;
405
405
  if (k === "usd" || k === "usda" || k === "usdc" || k === "usdz") {
406
406
  (r = e.reportProgress) == null || r.call(e, "usd-visual", "正在解析 USD 视觉场景...");
407
- const S = await (await import("./usd-session-CLU3UR4C.js")).loadUsdSimulation(l, e, g);
407
+ const S = await (await import("./usd-session-DRnVjKEv.js")).loadUsdSimulation(l, e, g);
408
408
  if (u || e.signal.aborted)
409
409
  throw S.dispose(), de();
410
410
  N = S, a = { root: S.visual.root, sync() {
@@ -424,7 +424,7 @@ function Rt(l, e) {
424
424
  }
425
425
  if (k === "urdf" || k === "xacro") {
426
426
  (T = e.reportProgress) == null || T.call(e, "urdf", "正在解析 URDF 场景与运动学结构...");
427
- const S = await (await import("./urdf-session-DRHt0jW4.js")).loadUrdfSimulation(l, e, g);
427
+ const S = await (await import("./urdf-session-D_LD1j5U.js")).loadUrdfSimulation(l, e, g);
428
428
  if (u || e.signal.aborted)
429
429
  throw S.dispose(), de();
430
430
  D = S.asset, t = S.stage, y = S.inspection, d = S.dispose, n = S.step, i = S.reset, w = S.play, M = S.pause, o = S.isPlaying, c = () => S.capabilities, F = () => S.physics, P = !1, m = !1, R = S.warning ?? null, K(), re();
@@ -448,7 +448,7 @@ function Rt(l, e) {
448
448
  (ve = e.reportProgress) == null || ve.call(e, "compile", "正在编译物理模型与参数...");
449
449
  const I = await yt(D);
450
450
  V = I, ae(u, e.signal), (Ae = e.reportProgress) == null || Ae.call(e, "runtime", "正在初始化物理内核...");
451
- const { MujocoRuntime: S } = await import("./mujoco-runtime-CZSNQ7An.js");
451
+ const { MujocoRuntime: S } = await import("./mujoco-runtime-Dn2yyGuI.js");
452
452
  s = new S(), await s.initialize(I, {
453
453
  baseUrl: e.options.mujocoBaseUrl,
454
454
  wasmModule: e.options.mujocoWasmModule
@@ -456,7 +456,7 @@ function Rt(l, e) {
456
456
  } catch (I) {
457
457
  const S = oe(I, e.signal, "mjcf-physics");
458
458
  s == null || s.dispose(), s = null;
459
- const { compileMjcfPreview: z } = await import("./mjcf-visual-5WZebsIs.js");
459
+ const { compileMjcfPreview: z } = await import("./mjcf-visual-BkiYD5Ks.js");
460
460
  let X;
461
461
  try {
462
462
  X = z(D);
@@ -0,0 +1,240 @@
1
+ import { Group as $, MeshStandardMaterial as H, Mesh as z, PointsMaterial as Q, Points as j, Color as J, Box3 as q, Vector3 as x, MeshBasicMaterial as X, BoxGeometry as _ } from "three";
2
+ import { PLYLoader as ee } from "three/examples/jsm/loaders/PLYLoader.js";
3
+ import { S as te, a as b } from "./spark.module-kM8pwA1o.js";
4
+ import { Q as ne, B as I, D as re, E as ie, T as ae } from "./index-DEmX80cg.js";
5
+ import { a as se, r as oe } from "./spark-renderer-D-bKFKf6.js";
6
+ function Ae(t, e) {
7
+ let u = !1, o = null, f = null, r = null, s = null, m = null, d = null, h = null, a = null, B = "unsupported", v = null, F = null, k = null, S = "y", G;
8
+ const T = P(), V = () => {
9
+ u = !0;
10
+ }, U = () => {
11
+ h && (oe(h), h = null);
12
+ }, K = (n, c) => {
13
+ (h == null ? void 0 : h.scene) !== c && (U(), h = se(n, c, e.requestRender));
14
+ }, C = () => f ? s && m ? (s.updateWorldMatrix(!0, !1), m.clone().applyMatrix4(s.matrixWorld)) : ae(f) : null, M = (async () => {
15
+ var N, R, D, W, L, O;
16
+ const n = await de(t);
17
+ if (u || e.signal.aborted) throw Y();
18
+ const c = t.entryPath ?? t.filename, p = ne(n, c, e.format);
19
+ if (p.kind === "unsupported")
20
+ throw new Error(`Unsupported visual asset: ${p.reason}`);
21
+ B = p.kind;
22
+ const A = new $();
23
+ A.name = "viewer-visual-root";
24
+ const y = new $();
25
+ if (y.name = "viewer-visual-content", p.kind === "glb" || p.kind === "gltf")
26
+ throw new Error("GLB/glTF is handled by the model loader.");
27
+ if (p.kind === "ply-mesh" || p.kind === "ply-point-cloud") {
28
+ const l = new ee().parse(we(n));
29
+ if (l.computeBoundingBox(), !l.boundingBox || l.boundingBox.isEmpty())
30
+ throw l.dispose(), new Error("PLY does not contain displayable vertex data.");
31
+ if (p.kind === "ply-mesh") {
32
+ const i = l.hasAttribute("color"), w = new H({
33
+ color: i ? 16777215 : 10135733,
34
+ vertexColors: i,
35
+ roughness: 0.82,
36
+ metalness: 0.04
37
+ }), g = new z(l, w);
38
+ g.name = "viewer-visual-ply-mesh", y.add(g);
39
+ } else {
40
+ const i = l.hasAttribute("color"), w = new Q({
41
+ color: i ? 16777215 : 10934783,
42
+ vertexColors: i,
43
+ size: Math.max(4e-3, fe(l.boundingBox) * 3e-3),
44
+ sizeAttenuation: !0
45
+ }), g = new j(l, w);
46
+ g.name = "viewer-visual-ply-points", y.add(g);
47
+ }
48
+ v = null;
49
+ } else {
50
+ const l = pe(p.kind), i = new te({
51
+ fileBytes: n,
52
+ fileType: l,
53
+ fileName: c ?? `visual.${l}`,
54
+ raycastable: e.options.visualSelectionMode === "exact"
55
+ });
56
+ if (await i.initialized, u || e.signal.aborted)
57
+ throw i.dispose(), Y();
58
+ if (i.name = "viewer-visual-splat", i.position.set(0, 0, 0), (N = e.options.visualAppearance) != null && N.color && (i.recolor = new J(...e.options.visualAppearance.color)), ((R = e.options.visualAppearance) == null ? void 0 : R.opacity) !== void 0 && (i.opacity = e.options.visualAppearance.opacity), y.add(i), s = i, v = ((D = i.packedSplats) == null ? void 0 : D.numSplats) ?? ((W = i.extSplats) == null ? void 0 : W.numSplats) ?? ((L = i.paged) == null ? void 0 : L.numSplats) ?? ((O = i.splats) == null ? void 0 : O.getNumSplats()) ?? null, m = ce(i), m.isEmpty()) throw new Error("Gaussian asset has empty bounds.");
59
+ }
60
+ if (S = e.options.upAxis ?? ue(p.kind), I(y, S), A.add(y), y.updateMatrixWorld(!0), a = new q().setFromObject(y), s && m && (s.updateWorldMatrix(!0, !1), a.union(m.clone().applyMatrix4(s.matrixWorld))), a.isEmpty()) throw new Error("Visual asset has no displayable bounds.");
61
+ if (s && e.options.visualSelectionMode !== "exact") {
62
+ const l = a.getSize(new x()), i = new X({
63
+ transparent: !0,
64
+ // The scene picker filters fully transparent materials, while colorWrite
65
+ // keeps this raycastable proxy invisible in the rendered frame.
66
+ opacity: 1,
67
+ colorWrite: !1,
68
+ depthTest: !1,
69
+ depthWrite: !1
70
+ }), w = new z(new _(l.x, l.y, l.z), i), g = a.getCenter(new x());
71
+ w.position.copy(g), w.name = "viewer-visual-bounds-proxy", w.userData.viewerVisualBoundsProxy = !0, A.add(w), d = w;
72
+ }
73
+ le(A);
74
+ const E = new re(
75
+ A,
76
+ e.options.simulationTheme,
77
+ void 0,
78
+ "model"
79
+ );
80
+ E.setCacheInvalidationCallback(e.invalidateTransmissionCaches), r = E, o = E.root, f = y, k = P() - T;
81
+ })();
82
+ return M.catch((n) => {
83
+ F = n instanceof Error ? n.message : String(n), k = P() - T;
84
+ }), {
85
+ id: `visual-${Math.random().toString(36).slice(2)}`,
86
+ opened: M,
87
+ get root() {
88
+ return o;
89
+ },
90
+ get fitTarget() {
91
+ return C();
92
+ },
93
+ getFitBounds() {
94
+ return C();
95
+ },
96
+ capabilities: {
97
+ canPlay: !1,
98
+ canPause: !1,
99
+ canReset: !1,
100
+ hasPhysics: !1,
101
+ canReorientUpAxis: !0,
102
+ canToggleGround: !0
103
+ },
104
+ presentation: {
105
+ preferredViewMode: "3d",
106
+ interactionMode: "object",
107
+ uiProfile: "model",
108
+ fitPolicy: "fit-on-ready"
109
+ },
110
+ getUpAxis() {
111
+ return f ? S : null;
112
+ },
113
+ setUpAxis(n) {
114
+ u || !f || I(f, n) && (S = n, f.updateMatrixWorld(!0), a = new q().setFromObject(f), s && m && (s.updateWorldMatrix(!0, !1), a.union(m.clone().applyMatrix4(s.matrixWorld))), Z(), r == null || r.reseatGround(), e.requestRender());
115
+ },
116
+ setGroundVisible(n) {
117
+ r == null || r.setGroundVisible(n);
118
+ },
119
+ getGroundVisible() {
120
+ return (r == null ? void 0 : r.getGroundVisible()) ?? !1;
121
+ },
122
+ getGroundGridScale() {
123
+ return (r == null ? void 0 : r.getGroundGridScale()) ?? ie;
124
+ },
125
+ beforeRender(n, c, p) {
126
+ return !u && s && K(n, c), r == null ? void 0 : r.beforeRender(n, c, p);
127
+ },
128
+ getVisualDiagnostics() {
129
+ const n = (a == null ? void 0 : a.getSize(new x())) ?? new x();
130
+ return {
131
+ schemaVersion: 1,
132
+ backend: s ? "spark-2.4.0" : B === "ply-point-cloud" ? "three-points" : "three-mesh",
133
+ kind: B,
134
+ splatCount: v,
135
+ bounds: a ? {
136
+ min: [a.min.x, a.min.y, a.min.z],
137
+ max: [a.max.x, a.max.y, a.max.z],
138
+ size: [n.x, n.y, n.z]
139
+ } : null,
140
+ upAxis: S,
141
+ loadMilliseconds: k,
142
+ error: F
143
+ };
144
+ },
145
+ beginDispose() {
146
+ V();
147
+ },
148
+ dispose() {
149
+ return V(), G ?? (G = M.catch(() => {
150
+ }).then(() => {
151
+ if (d == null || d.geometry.dispose(), d)
152
+ for (const n of Array.isArray(d.material) ? d.material : [d.material]) n.dispose();
153
+ d = null, s == null || s.dispose(), s = null, m = null, r ? r.dispose() : o && ye(o), r = null, o = null, f = null, U();
154
+ })), G;
155
+ }
156
+ };
157
+ function Z() {
158
+ if (!d || !a) return;
159
+ const n = a.getSize(new x()), c = a.getCenter(new x());
160
+ d.geometry.dispose(), d.geometry = new _(n.x, n.y, n.z), d.position.copy(c);
161
+ }
162
+ }
163
+ function le(t) {
164
+ t.traverse((e) => {
165
+ e instanceof z && (e.userData.hdrTransparentBackdrop = !1);
166
+ });
167
+ }
168
+ function ue(t) {
169
+ return t.startsWith("gaussian-") ? "y-down" : "y";
170
+ }
171
+ async function de(t) {
172
+ if (t.entryBlob)
173
+ return new Uint8Array(await t.entryBlob.arrayBuffer());
174
+ const e = t.original;
175
+ if (typeof Blob < "u" && e instanceof Blob)
176
+ return new Uint8Array(await e.arrayBuffer());
177
+ if (e instanceof ArrayBuffer) return new Uint8Array(e);
178
+ if (typeof e == "object" && e !== null && "kind" in e) {
179
+ if (e.kind === "buffer") return new Uint8Array(e.buffer);
180
+ if (e.kind === "files") {
181
+ const f = t.entryPath ?? e.entry, r = e.files.find((s) => s.path === f) ?? (e.files.length === 1 ? e.files[0] : null);
182
+ if (r) return new Uint8Array(await r.file.arrayBuffer());
183
+ }
184
+ }
185
+ const u = t.url ?? await t.resolve(t.entryPath ?? ""), o = await fetch(u, { signal: t.signal });
186
+ if (!o.ok) throw new Error(`Visual asset request failed: ${o.status} ${o.statusText}`);
187
+ return new Uint8Array(await o.arrayBuffer());
188
+ }
189
+ function pe(t) {
190
+ switch (t) {
191
+ case "gaussian-ply":
192
+ return b.PLY;
193
+ case "gaussian-spz":
194
+ return b.SPZ;
195
+ case "gaussian-splat":
196
+ return b.SPLAT;
197
+ case "gaussian-ksplat":
198
+ return b.KSPLAT;
199
+ case "gaussian-sog":
200
+ return b.PCSOGSZIP;
201
+ case "gaussian-rad":
202
+ return b.RAD;
203
+ default:
204
+ throw new Error(`Not a Gaussian format: ${t}`);
205
+ }
206
+ }
207
+ function fe(t) {
208
+ return t.getSize(new x()).length();
209
+ }
210
+ function ce(t) {
211
+ const e = t.getBoundingBox(!0);
212
+ return me(e) || (e.makeEmpty(), t.forEachSplat((u, o) => {
213
+ Number.isFinite(o.x) && Number.isFinite(o.y) && Number.isFinite(o.z) && e.expandByPoint(o);
214
+ })), e;
215
+ }
216
+ function me(t) {
217
+ return !t.isEmpty() && Number.isFinite(t.min.x) && Number.isFinite(t.min.y) && Number.isFinite(t.min.z) && Number.isFinite(t.max.x) && Number.isFinite(t.max.y) && Number.isFinite(t.max.z);
218
+ }
219
+ function ye(t) {
220
+ t.traverse((e) => {
221
+ "geometry" in e && e.geometry && typeof e.geometry.dispose == "function" && e.geometry.dispose();
222
+ const u = "material" in e ? e.material : null;
223
+ for (const o of Array.isArray(u) ? u : u ? [u] : []) o.dispose();
224
+ });
225
+ }
226
+ function we(t) {
227
+ const e = new Uint8Array(t.byteLength);
228
+ return e.set(t), e.buffer;
229
+ }
230
+ function Y() {
231
+ return Object.assign(new Error("Visual asset load aborted."), { name: "AbortError", code: "E_ABORTED" });
232
+ }
233
+ function P() {
234
+ return typeof performance > "u" ? Date.now() : performance.now();
235
+ }
236
+ export {
237
+ Ae as createVisualSession,
238
+ ue as defaultVisualAssetUpAxis,
239
+ le as excludeVisualSessionFromHdrBackdrop
240
+ };
@@ -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 je, DirectionalLight as ze, 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 z, Uint16BufferAttribute as Ze, Matrix3 as Qe, Vector2 as Je, ShapeUtils as et, Vector4 as tt, Euler as j, 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 { A as ye, B as we, D as ut, d as ve, E as pt } from "./index-DyBfusq5.js";
4
+ import { A as ye, B as we, D as ut, d as ve, E as pt } from "./index-DEmX80cg.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-DyBfusq5.js").then((T) => T.af);
1736
+ const { disposeModelResources: d } = await import("./index-DEmX80cg.js").then((T) => T.ag);
1737
1737
  d(m, l);
1738
1738
  } else for (const d of l) d.dispose();
1739
1739
  throw g;
@@ -1,5 +1,5 @@
1
1
  import { b as d } from "./spark.module-kM8pwA1o.js";
2
- import { R as p } from "./index-DyBfusq5.js";
2
+ import { R as p } from "./index-DEmX80cg.js";
3
3
  const a = /* @__PURE__ */ new WeakMap();
4
4
  function o(r, e, s) {
5
5
  let n = a.get(e);
@@ -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, d as Te, e as Ve, w as ye, f as ge, a as Je } from "./dynamic-raycast-Ctu2X5u5.js";
5
- import { d as I, T as Oe, V as be, t as Be, u as Qe, v as we, M as Xe, P as Ke, i as Ze, D as Ye, W as ve, S as Me } from "./index-DyBfusq5.js";
4
+ import { c as Ge, d as Te, e as Ve, w as ye, f as ge, a as Je } from "./dynamic-raycast-BW_YlAtV.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-DEmX80cg.js";
6
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";
@@ -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-BV6bRVpX.js");
1093
+ const { expandXacro: v } = await import("./xacro-BZmqTcxa.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-CZSNQ7An.js");
1143
+ const Z = await import("./mujoco-runtime-Dn2yyGuI.js");
1144
1144
  if (v = new Z.MujocoRuntime(), await v.initialize(G, {
1145
1145
  baseUrl: e.options.mujocoBaseUrl,
1146
1146
  wasmModule: e.options.mujocoWasmModule
@@ -2,9 +2,9 @@ var Lc = Object.defineProperty;
2
2
  var Bc = (e, t, n) => t in e ? Lc(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var _n = (e, t, n) => Bc(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { Box3 as lt, Vector3 as F, SphereGeometry as Fc, Float32BufferAttribute as zt, Mesh as De, MeshBasicMaterial as So, Group as _t, BoxGeometry as Qa, LineSegments as Vc, EdgesGeometry as zc, LineBasicMaterial as xr, AxesHelper as jc, ArrowHelper as Wc, Line as Gc, BufferGeometry as Qo, Quaternion as He, Points as ei, MeshPhysicalMaterial as se, FrontSide as zn, DoubleSide as $t, DataTexture as Ss, UnsignedByteType as vs, RGBAFormat as Ms, NoColorSpace as ze, SRGBColorSpace as Pn, Material as Yc, ShaderChunk as ti, Color as Te, TextureLoader as Fs, Texture as mn, Ray as er, BufferAttribute as Vs, Matrix4 as Ke, Matrix3 as ni, RepeatWrapping as $e, MeshStandardMaterial as Dn, ClampToEdgeWrapping as jn, MirroredRepeatWrapping as Hc, CanvasTexture as Xc, PointsMaterial as Jc, LinearSRGBColorSpace as Kc, CylinderGeometry as qc, InstancedMesh as Zc, DynamicDrawUsage as Qc, SkinnedMesh as ns, Skeleton as eu, AnimationMixer as tu, LoopRepeat as nu, Sphere as su } from "three";
5
- import { i as ou, d as tr, r as ru, o as au, a as iu, c as cu, b as si, e as uu, f as lu, g as fu, U as pu, h as du, j as oi, k as ri, l as nr, m as Dt, n as hu, p as mu, q as gu, M as sr, s as ai, R as yu, t as Ir, u as Ar, C as Tr, v as ii, w as ci, x as _u, S as Dr } from "./index-DyBfusq5.js";
5
+ import { i as ou, d as tr, r as ru, o as au, a as iu, c as cu, b as si, e as uu, f as lu, g as fu, U as pu, h as du, j as oi, k as ri, l as nr, m as Dt, n as hu, p as mu, q as gu, M as sr, s as ai, R as yu, t as Ir, u as Ar, C as Tr, v as ii, w as ci, x as _u, S as Dr } from "./index-DEmX80cg.js";
6
6
  import { k as bu } from "./physics-guide-size-CplAlsve.js";
7
- import { r as ui, n as Rt, u as wu, p as Pr, c as Su, a as Cr, b as vu, d as Mu } from "./dynamic-raycast-Ctu2X5u5.js";
7
+ import { r as ui, n as Rt, u as wu, p as Pr, c as Su, a as Cr, b as vu, d as Mu } from "./dynamic-raycast-BW_YlAtV.js";
8
8
  import { ConvexGeometry as li } from "three/examples/jsm/geometries/ConvexGeometry.js";
9
9
  import { buildUSDScene as Uu, createUSDLoadedModel as xu } from "@openusd-wasm/three-loader";
10
10
  import { KTX2Loader as Iu } from "three/addons/loaders/KTX2Loader.js";
@@ -11358,7 +11358,7 @@ async function Xm(e, t, n) {
11358
11358
  Oe
11359
11359
  );
11360
11360
  if (!((wr = Ae.flexes) != null && wr.length)) throw we("USD soft-body contracts did not produce a flexcomp.", "E_USD_SOFTBODY_UNSUPPORTED");
11361
- const { MujocoRuntime: Xe } = await import("./mujoco-runtime-CZSNQ7An.js");
11361
+ const { MujocoRuntime: Xe } = await import("./mujoco-runtime-Dn2yyGuI.js");
11362
11362
  H = new Xe(), await H.initialize(Ae, {
11363
11363
  baseUrl: t.options.mujocoBaseUrl,
11364
11364
  wasmModule: t.options.mujocoWasmModule
@@ -11425,7 +11425,7 @@ async function Xm(e, t, n) {
11425
11425
  message: `${Ye.accelerationDrives.length} 个 acceleration drive 已按 MuJoCo 初始化姿态的关节广义惯量 M(jj) 转换为等效力/力矩;多关节耦合或大幅运动后的有效惯量变化不会逐帧重算。`,
11426
11426
  source: "usd-physics"
11427
11427
  }), (vr = Ye.massOverrides) != null && vr.length && d.approximations.push({ code: "USD_INFERRED_INERTIA", message: "保留显式总质量;惯量按碰撞几何的密度分布推导并同比缩放,重叠体积会重复计入。", source: "usd-physics" });
11428
- const { MujocoRuntime: H } = await import("./mujoco-runtime-CZSNQ7An.js");
11428
+ const { MujocoRuntime: H } = await import("./mujoco-runtime-Dn2yyGuI.js");
11429
11429
  k = new H(), await k.initialize(Ye, {
11430
11430
  baseUrl: t.options.mujocoBaseUrl,
11431
11431
  wasmModule: t.options.mujocoWasmModule
package/dist/version.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * Viewer 版本号。必须与 package.json 的 version 保持一致,
3
3
  * check-boundary 脚本会在构建前校验两者是否漂移。
4
4
  */
5
- export declare const viewerVersion = "0.6.6";
5
+ export declare const viewerVersion = "0.6.8";
@@ -1,4 +1,4 @@
1
- import { n as bt } from "./dynamic-raycast-Ctu2X5u5.js";
1
+ import { n as bt } from "./dynamic-raycast-BW_YlAtV.js";
2
2
  function _t(t) {
3
3
  const e = t.split(/[\\/]/g);
4
4
  return e.pop(), e.length === 0 ? "./" : e.join("/") + "/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula-spatial/viewer",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "Read-only Three.js viewer facade",
5
5
  "license": "ISC",
6
6
  "engines": {
@@ -1,240 +0,0 @@
1
- import { Group as O, MeshStandardMaterial as Z, Mesh as z, PointsMaterial as H, Points as Q, Color as j, Box3 as $, Vector3 as b, MeshBasicMaterial as J, BoxGeometry as q } from "three";
2
- import { PLYLoader as X } from "three/examples/jsm/loaders/PLYLoader.js";
3
- import { S as ee, a as x } from "./spark.module-kM8pwA1o.js";
4
- import { Q as te, B as _, D as ne, E as ie } from "./index-DyBfusq5.js";
5
- import { a as re, r as ae } from "./spark-renderer-dvFIUjr0.js";
6
- function xe(t, e) {
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
- const V = P(), T = () => {
9
- u = !0;
10
- }, U = () => {
11
- h && (ae(h), h = null);
12
- }, Y = (n, f) => {
13
- (h == null ? void 0 : h.scene) !== f && (U(), h = re(n, f, e.requestRender));
14
- }, E = (async () => {
15
- var C, N, R, D, W, L;
16
- const n = await le(t);
17
- if (u || e.signal.aborted) throw I();
18
- const f = t.entryPath ?? t.filename, p = te(n, f, e.format);
19
- if (p.kind === "unsupported")
20
- throw new Error(`Unsupported visual asset: ${p.reason}`);
21
- v = p.kind;
22
- const A = new O();
23
- A.name = "viewer-visual-root";
24
- const m = new O();
25
- if (m.name = "viewer-visual-content", p.kind === "glb" || p.kind === "gltf")
26
- throw new Error("GLB/glTF is handled by the model loader.");
27
- if (p.kind === "ply-mesh" || p.kind === "ply-point-cloud") {
28
- const l = new X().parse(me(n));
29
- if (l.computeBoundingBox(), !l.boundingBox || l.boundingBox.isEmpty())
30
- throw l.dispose(), new Error("PLY does not contain displayable vertex data.");
31
- if (p.kind === "ply-mesh") {
32
- const a = l.hasAttribute("color"), y = new Z({
33
- color: a ? 16777215 : 10135733,
34
- vertexColors: a,
35
- roughness: 0.82,
36
- metalness: 0.04
37
- }), g = new z(l, y);
38
- g.name = "viewer-visual-ply-mesh", m.add(g);
39
- } else {
40
- const a = l.hasAttribute("color"), y = new H({
41
- color: a ? 16777215 : 10934783,
42
- vertexColors: a,
43
- size: Math.max(4e-3, de(l.boundingBox) * 3e-3),
44
- sizeAttenuation: !0
45
- }), g = new Q(l, y);
46
- g.name = "viewer-visual-ply-points", m.add(g);
47
- }
48
- B = null;
49
- } else {
50
- const l = ue(p.kind), a = new ee({
51
- fileBytes: n,
52
- fileType: l,
53
- fileName: f ?? `visual.${l}`,
54
- raycastable: e.options.visualSelectionMode === "exact"
55
- });
56
- if (await a.initialized, u || e.signal.aborted)
57
- throw a.dispose(), I();
58
- if (a.name = "viewer-visual-splat", a.position.set(0, 0, 0), (C = e.options.visualAppearance) != null && C.color && (a.recolor = new j(...e.options.visualAppearance.color)), ((N = e.options.visualAppearance) == null ? void 0 : N.opacity) !== void 0 && (a.opacity = e.options.visualAppearance.opacity), m.add(a), o = a, B = ((R = a.packedSplats) == null ? void 0 : R.numSplats) ?? ((D = a.extSplats) == null ? void 0 : D.numSplats) ?? ((W = a.paged) == null ? void 0 : W.numSplats) ?? ((L = a.splats) == null ? void 0 : L.getNumSplats()) ?? null, w = pe(a), w.isEmpty()) throw new Error("Gaussian asset has empty bounds.");
59
- }
60
- if (S = e.options.upAxis ?? oe(p.kind), _(m, S), A.add(m), m.updateMatrixWorld(!0), r = new $().setFromObject(m), o && w && (o.updateWorldMatrix(!0, !1), r.union(w.clone().applyMatrix4(o.matrixWorld))), r.isEmpty()) throw new Error("Visual asset has no displayable bounds.");
61
- if (o && e.options.visualSelectionMode !== "exact") {
62
- const l = r.getSize(new b()), a = new J({
63
- transparent: !0,
64
- // The scene picker filters fully transparent materials, while colorWrite
65
- // keeps this raycastable proxy invisible in the rendered frame.
66
- opacity: 1,
67
- colorWrite: !1,
68
- depthTest: !1,
69
- depthWrite: !1
70
- }), y = new z(new q(l.x, l.y, l.z), a), g = r.getCenter(new b());
71
- y.position.copy(g), y.name = "viewer-visual-bounds-proxy", y.userData.viewerVisualBoundsProxy = !0, A.add(y), d = y;
72
- }
73
- se(A);
74
- const M = new ne(
75
- A,
76
- e.options.simulationTheme,
77
- void 0,
78
- "model"
79
- );
80
- M.setCacheInvalidationCallback(e.invalidateTransmissionCaches), i = M, s = M.root, c = m, k = P() - V;
81
- })();
82
- return E.catch((n) => {
83
- F = n instanceof Error ? n.message : String(n), k = P() - V;
84
- }), {
85
- id: `visual-${Math.random().toString(36).slice(2)}`,
86
- opened: E,
87
- get root() {
88
- return s;
89
- },
90
- get fitTarget() {
91
- return r;
92
- },
93
- getFitBounds() {
94
- return r;
95
- },
96
- capabilities: {
97
- canPlay: !1,
98
- canPause: !1,
99
- canReset: !1,
100
- hasPhysics: !1,
101
- canReorientUpAxis: !0,
102
- canToggleGround: !0
103
- },
104
- presentation: {
105
- preferredViewMode: "3d",
106
- interactionMode: "object",
107
- uiProfile: "model",
108
- fitPolicy: "fit-on-ready"
109
- },
110
- getUpAxis() {
111
- return c ? S : null;
112
- },
113
- setUpAxis(n) {
114
- u || !c || _(c, n) && (S = n, c.updateMatrixWorld(!0), r = new $().setFromObject(c), o && w && (o.updateWorldMatrix(!0, !1), r.union(w.clone().applyMatrix4(o.matrixWorld))), K(), i == null || i.reseatGround(), e.requestRender());
115
- },
116
- setGroundVisible(n) {
117
- i == null || i.setGroundVisible(n);
118
- },
119
- getGroundVisible() {
120
- return (i == null ? void 0 : i.getGroundVisible()) ?? !1;
121
- },
122
- getGroundGridScale() {
123
- return (i == null ? void 0 : i.getGroundGridScale()) ?? ie;
124
- },
125
- beforeRender(n, f, p) {
126
- return !u && o && Y(n, f), i == null ? void 0 : i.beforeRender(n, f, p);
127
- },
128
- getVisualDiagnostics() {
129
- const n = (r == null ? void 0 : r.getSize(new b())) ?? new b();
130
- return {
131
- schemaVersion: 1,
132
- backend: o ? "spark-2.4.0" : v === "ply-point-cloud" ? "three-points" : "three-mesh",
133
- kind: v,
134
- splatCount: B,
135
- bounds: r ? {
136
- min: [r.min.x, r.min.y, r.min.z],
137
- max: [r.max.x, r.max.y, r.max.z],
138
- size: [n.x, n.y, n.z]
139
- } : null,
140
- upAxis: S,
141
- loadMilliseconds: k,
142
- error: F
143
- };
144
- },
145
- beginDispose() {
146
- T();
147
- },
148
- dispose() {
149
- return T(), G ?? (G = E.catch(() => {
150
- }).then(() => {
151
- if (d == null || d.geometry.dispose(), d)
152
- for (const n of Array.isArray(d.material) ? d.material : [d.material]) n.dispose();
153
- d = null, o == null || o.dispose(), o = null, w = null, i ? i.dispose() : s && ce(s), i = null, s = null, c = null, U();
154
- })), G;
155
- }
156
- };
157
- function K() {
158
- if (!d || !r) return;
159
- const n = r.getSize(new b()), f = r.getCenter(new b());
160
- d.geometry.dispose(), d.geometry = new q(n.x, n.y, n.z), d.position.copy(f);
161
- }
162
- }
163
- function se(t) {
164
- t.traverse((e) => {
165
- e instanceof z && (e.userData.hdrTransparentBackdrop = !1);
166
- });
167
- }
168
- function oe(t) {
169
- return t.startsWith("gaussian-") ? "y-down" : "y";
170
- }
171
- async function le(t) {
172
- if (t.entryBlob)
173
- return new Uint8Array(await t.entryBlob.arrayBuffer());
174
- const e = t.original;
175
- if (typeof Blob < "u" && e instanceof Blob)
176
- return new Uint8Array(await e.arrayBuffer());
177
- if (e instanceof ArrayBuffer) return new Uint8Array(e);
178
- if (typeof e == "object" && e !== null && "kind" in e) {
179
- if (e.kind === "buffer") return new Uint8Array(e.buffer);
180
- if (e.kind === "files") {
181
- const c = t.entryPath ?? e.entry, i = e.files.find((o) => o.path === c) ?? (e.files.length === 1 ? e.files[0] : null);
182
- if (i) return new Uint8Array(await i.file.arrayBuffer());
183
- }
184
- }
185
- const u = t.url ?? await t.resolve(t.entryPath ?? ""), s = await fetch(u, { signal: t.signal });
186
- if (!s.ok) throw new Error(`Visual asset request failed: ${s.status} ${s.statusText}`);
187
- return new Uint8Array(await s.arrayBuffer());
188
- }
189
- function ue(t) {
190
- switch (t) {
191
- case "gaussian-ply":
192
- return x.PLY;
193
- case "gaussian-spz":
194
- return x.SPZ;
195
- case "gaussian-splat":
196
- return x.SPLAT;
197
- case "gaussian-ksplat":
198
- return x.KSPLAT;
199
- case "gaussian-sog":
200
- return x.PCSOGSZIP;
201
- case "gaussian-rad":
202
- return x.RAD;
203
- default:
204
- throw new Error(`Not a Gaussian format: ${t}`);
205
- }
206
- }
207
- function de(t) {
208
- return t.getSize(new b()).length();
209
- }
210
- function pe(t) {
211
- const e = t.getBoundingBox(!0);
212
- return fe(e) || (e.makeEmpty(), t.forEachSplat((u, s) => {
213
- Number.isFinite(s.x) && Number.isFinite(s.y) && Number.isFinite(s.z) && e.expandByPoint(s);
214
- })), e;
215
- }
216
- function fe(t) {
217
- return !t.isEmpty() && Number.isFinite(t.min.x) && Number.isFinite(t.min.y) && Number.isFinite(t.min.z) && Number.isFinite(t.max.x) && Number.isFinite(t.max.y) && Number.isFinite(t.max.z);
218
- }
219
- function ce(t) {
220
- t.traverse((e) => {
221
- "geometry" in e && e.geometry && typeof e.geometry.dispose == "function" && e.geometry.dispose();
222
- const u = "material" in e ? e.material : null;
223
- for (const s of Array.isArray(u) ? u : u ? [u] : []) s.dispose();
224
- });
225
- }
226
- function me(t) {
227
- const e = new Uint8Array(t.byteLength);
228
- return e.set(t), e.buffer;
229
- }
230
- function I() {
231
- return Object.assign(new Error("Visual asset load aborted."), { name: "AbortError", code: "E_ABORTED" });
232
- }
233
- function P() {
234
- return typeof performance > "u" ? Date.now() : performance.now();
235
- }
236
- export {
237
- xe as createVisualSession,
238
- oe as defaultVisualAssetUpAxis,
239
- se as excludeVisualSessionFromHdrBackdrop
240
- };