@nebula-spatial/viewer 0.6.5 → 0.6.7
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 +14 -0
- package/README.md +5 -0
- package/dist/assets/mujoco-physics-worker-MMv4Gmu_.js +5482 -0
- package/dist/assets/types.d.ts +1 -0
- package/dist/{asset-ir-CpAQLRUA.js → dynamic-raycast-DhiSzt3O.js} +135 -105
- package/dist/{index-B_0o0gFp.js → index-jlMvDvhU.js} +1051 -1007
- package/dist/index.js +7 -7
- package/dist/{mjcf-visual-DyxH6Xog.js → mjcf-visual-CApGRZP1.js} +7 -7
- package/dist/mujoco-runtime-BcD33xjr.js +1601 -0
- package/dist/{session-Bk1kzTKV.js → session-CD-me-3k.js} +2 -2
- package/dist/session-DJlYrv7o.js +240 -0
- package/dist/session-DjoV8nG4.js +719 -0
- package/dist/{spark-renderer-C3is1De3.js → spark-renderer-BUUhXzu_.js} +1 -1
- package/dist/{urdf-session-BqSsgeqp.js → urdf-session-CulvJBl2.js} +34 -34
- package/dist/{usd-session-CO-6k8lr.js → usd-session-CjZKAoph.js} +3192 -3177
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-itfAyoDj.js → xacro-BWEr4Pqt.js} +1 -1
- package/package.json +1 -1
- package/dist/assets/browser-module-shim-CxSGVgIL.js +0 -6
- package/dist/assets/mujoco-physics-worker-8NOXf5Pk.js +0 -5470
- package/dist/mujoco-runtime-BljZEVSG.js +0 -1290
- package/dist/session-BVP1ulLM.js +0 -240
- package/dist/session-EZx1acjF.js +0 -713
|
@@ -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-jlMvDvhU.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-jlMvDvhU.js").then((T) => T.ag);
|
|
1737
1737
|
d(m, l);
|
|
1738
1738
|
} else for (const d of l) d.dispose();
|
|
1739
1739
|
throw g;
|
|
@@ -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-jlMvDvhU.js";
|
|
5
|
+
import { a as se, r as oe } from "./spark-renderer-BUUhXzu_.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
|
+
};
|