@nebula-spatial/viewer 0.5.18 → 0.6.1
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 +83 -35
- package/README.md +5 -0
- package/dist/asset-ir-BXa1EdOy.js +637 -0
- package/dist/assets/source-types.d.ts +10 -0
- package/dist/assets/types.d.ts +61 -6
- package/dist/assets/{usd-worker-B6-1I5dT.js → usd-worker-r6Nuoxlk.js} +671 -584
- package/dist/index-CHf9y9eX.js +17406 -0
- package/dist/index.d.ts +21 -2
- package/dist/index.js +29 -18
- package/dist/{mjcf-visual-CtY2Wk3w.js → mjcf-visual-DxMXiBnu.js} +12 -13
- package/dist/mujoco-runtime-BA88JuDR.js +791 -0
- package/dist/physics-guide-size-CplAlsve.js +12 -0
- package/dist/scene/instances.d.ts +36 -0
- package/dist/scene/joints.d.ts +129 -0
- package/dist/scene/session.d.ts +26 -0
- package/dist/scene/types.d.ts +292 -0
- package/dist/session-DLi-MvLB.js +240 -0
- package/dist/{session-DxTeRKCd.js → session-DqEr1CxY.js} +581 -567
- package/dist/session-ZNb3ZYLq.js +562 -0
- package/dist/simulation/physics-runtime-state.d.ts +73 -0
- package/dist/simulation/types.d.ts +151 -0
- package/dist/simulation/usd-dependency-probe.d.ts +42 -0
- package/dist/simulation/usd-inspection.d.ts +66 -0
- package/dist/spark-renderer-BGF_AaI9.js +25 -0
- package/dist/spark.module-kM8pwA1o.js +9278 -0
- package/dist/types.d.ts +75 -1
- package/dist/ui/camera-axis-gizmo.d.ts +5 -0
- package/dist/urdf-session-CKlR-fOQ.js +1230 -0
- package/dist/usd-session-DyNMsD-v.js +11199 -0
- package/dist/version.d.ts +1 -1
- package/dist/visual/classification.d.ts +20 -0
- package/dist/{xacro-x2TeKQ7T.js → xacro-BCLnc3tY.js} +1 -1
- package/openusd/openusd-runtime-manifest.json +6 -6
- package/openusd/openusd_probe.js +1 -1
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +2 -1
- package/runtime-assets.d.mts +9 -9
- package/runtime-assets.mjs +11 -11
- package/vite.d.mts +7 -7
- package/vite.mjs +115 -115
- package/dist/collision-debug-BSJoz5J7.js +0 -2947
- package/dist/index-E8DHSeyT.js +0 -11499
- package/dist/mujoco-runtime-fDWdXNEc.js +0 -739
- package/dist/resources-CHhCm2f7.js +0 -27
- package/dist/session-DB-osaBL.js +0 -801
- package/dist/stage-BnRjc-Rp.js +0 -592
- package/dist/urdf-session-Q_c3Rd1M.js +0 -1264
- package/dist/usd-session-tW3LxVFs.js +0 -10647
|
@@ -0,0 +1,240 @@
|
|
|
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
|
+
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 { 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";
|
|
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, L, W;
|
|
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 j(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) ?? ((L = a.paged) == null ? void 0 : L.numSplats) ?? ((W = a.splats) == null ? void 0 : W.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 Q({
|
|
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
|
+
};
|