@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 +12 -0
- package/dist/assets/types.d.ts +1 -0
- package/dist/{dynamic-raycast-Ctu2X5u5.js → dynamic-raycast-BW_YlAtV.js} +2 -2
- package/dist/{index-DyBfusq5.js → index-DEmX80cg.js} +32 -31
- package/dist/index.js +7 -7
- package/dist/{mjcf-visual-5WZebsIs.js → mjcf-visual-BkiYD5Ks.js} +7 -7
- package/dist/{mujoco-runtime-CZSNQ7An.js → mujoco-runtime-Dn2yyGuI.js} +1 -1
- package/dist/{session-DXUACJAS.js → session-CxPD2fPU.js} +7 -7
- package/dist/session-D20eDowE.js +240 -0
- package/dist/{session-CzJBN0Us.js → session-D98gYyL3.js} +2 -2
- package/dist/{spark-renderer-dvFIUjr0.js → spark-renderer-D-bKFKf6.js} +1 -1
- package/dist/{urdf-session-DRHt0jW4.js → urdf-session-D_LD1j5U.js} +4 -4
- package/dist/{usd-session-CLU3UR4C.js → usd-session-DRnVjKEv.js} +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-BV6bRVpX.js → xacro-BZmqTcxa.js} +1 -1
- package/package.json +1 -1
- package/dist/session-BerXscrf.js +0 -240
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
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -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-
|
|
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, {
|
|
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.
|
|
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-
|
|
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-
|
|
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-
|
|
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() ?
|
|
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-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
18457
|
+
Ei as T,
|
|
18458
18458
|
wg as U,
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
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
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
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,
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 {
|
|
2
|
-
import { Group as q, Euler as G, BoxGeometry as N, SphereGeometry as P, CylinderGeometry as
|
|
3
|
-
function
|
|
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
|
|
46
|
+
i = new $(r[0], r[0], 2 * r[1]), i.rotateX(Math.PI / 2);
|
|
47
47
|
else if (n === "capsule")
|
|
48
|
-
i = new
|
|
49
|
-
else if (n === "plane") i = new
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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,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-
|
|
5
|
-
import { d as I,
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
package/package.json
CHANGED
package/dist/session-BerXscrf.js
DELETED
|
@@ -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
|
-
};
|