@nebula-spatial/studio 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/assets/openusd_three_loader-DLiqJWUM.js +13769 -0
- package/dist/assets/usd-export-worker-BRxTLqer.js +182 -0
- package/dist/assets/usd-worker-DekqMsQv.js +1392 -0
- package/dist/{builders-BAXRR5o5.js → builders-lydx4-Rh.js} +1 -1
- package/dist/core/session-persistence-controller.d.ts +55 -0
- package/dist/doc/placement-policy.d.ts +4 -0
- package/dist/editor/editor.d.ts +3 -1
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/session-persistence.d.ts +54 -0
- package/dist/editor.js +727 -490
- package/dist/export-evidence-z2Ne7Trf.js +2387 -0
- package/dist/generalization.js +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +314 -306
- package/dist/mjcf-visual-IOy-ucto.js +72 -0
- package/dist/mujoco-runtime-BYZnrvbR.js +467 -0
- package/dist/persist/indexeddb-store.d.ts +22 -2
- package/dist/persist/session.d.ts +22 -0
- package/dist/persist/snapshot.d.ts +24 -0
- package/dist/{physics-facts-tfQYyNTD.js → physics-facts-D-URIBrt.js} +8 -7
- package/dist/{placement-policy-DY_FNRDu.js → placement-policy-C6dV6Tf-.js} +161 -141
- package/dist/ports/persistence.d.ts +45 -1
- package/dist/project/contracts.d.ts +3 -0
- package/dist/remote-asset-resolver-D-UeyDMD.js +311 -0
- package/dist/{scene-graph-DBLKAhxa.js → scene-graph-DVOXjMmp.js} +2 -2
- package/dist/scene-session-PhoFXFCY.js +22006 -0
- package/dist/scene.js +2 -2
- package/dist/session-2bp8YOA4.js +963 -0
- package/dist/session-B3WbC7Y2.js +296 -0
- package/dist/session-B9kEf4xN.js +915 -0
- package/dist/session-DYThdzLZ.js +825 -0
- package/dist/studio/index.d.ts +5 -0
- package/dist/studio/indexeddb-persistence.d.ts +2 -0
- package/dist/studio/indexeddb-session-persistence.d.ts +11 -0
- package/dist/studio/scene-package-asset-sources.d.ts +14 -0
- package/dist/studio.js +1423 -1220
- package/dist/urdf-session-CRXL4bHf.js +1230 -0
- package/dist/usd-session-CTzInpNy.js +7385 -0
- package/dist/version.d.ts +1 -1
- package/dist/view/scene-session.d.ts +5 -1
- package/dist/wasm-module-DZn2AM1W.js +13 -0
- package/dist/xacro-IpPHTMYs.js +76 -0
- package/package.json +1 -1
- package/dist/asset-source-BExlEcRt.js +0 -444
- package/dist/assets/usd-export-worker-BsGubtAE.js +0 -1
- package/dist/editorial-BkAFWfbg.js +0 -83
- package/dist/export-evidence-B_0zRmb8.js +0 -5027
- package/dist/remote-asset-resolver-Cb8cfNmw.js +0 -136
- package/dist/scene-session-BV1HnxNh.js +0 -3506
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Group as D, MeshStandardMaterial as j, Mesh as Y, PointsMaterial as H, Points as J, Color as Q, Box3 as V, Vector3 as A, MeshBasicMaterial as X, BoxGeometry as O } from "three";
|
|
2
|
+
import { PLYLoader as ee } from "three/examples/jsm/loaders/PLYLoader.js";
|
|
3
|
+
import { SplatMesh as ne, SplatFileType as B, SparkRenderer as te } from "@sparkjsdev/spark";
|
|
4
|
+
import { a as $, D as re } from "./scene-session-PhoFXFCY.js";
|
|
5
|
+
const ie = /^(?:f_dc_\d+|f_rest_\d+|opacity|scale_\d+|rot_\d+|packed_(?:position|rotation|scale|color))$/i, se = /^(?:x|y|z|red|green|blue|r|g|b)$/i;
|
|
6
|
+
function ae(n) {
|
|
7
|
+
var P;
|
|
8
|
+
const e = n instanceof Uint8Array ? n : new Uint8Array(n), o = e.subarray(0, Math.min(e.byteLength, 1024 * 1024)), t = new TextDecoder("latin1").decode(o), i = t.search(/\r?\nend_header\s*(?:\r?\n|$)/i);
|
|
9
|
+
if (i < 0)
|
|
10
|
+
return { kind: "unsupported", reason: "PLY header is missing end_header." };
|
|
11
|
+
const l = t.slice(0, i + 1).split(/\r?\n/).map((d) => d.trim()).filter(Boolean);
|
|
12
|
+
if (((P = l[0]) == null ? void 0 : P.toLowerCase()) !== "ply")
|
|
13
|
+
return { kind: "unsupported", reason: "PLY magic is missing." };
|
|
14
|
+
let w = null, u = 0, g = 0, f = null;
|
|
15
|
+
const r = [], k = [];
|
|
16
|
+
for (const d of l.slice(1)) {
|
|
17
|
+
const m = d.split(/\s+/);
|
|
18
|
+
if (m[0] === "format" && (w = m[1] ?? null), m[0] === "element" && m[1] && (f = m[1].toLowerCase(), r.push(f), f === "vertex" && (u = I(m[2])), f === "face" && (g = I(m[2]))), m[0] === "property" && f === "vertex") {
|
|
19
|
+
const E = m.at(-1);
|
|
20
|
+
E && k.push(E);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const h = {
|
|
24
|
+
format: w,
|
|
25
|
+
vertexCount: u,
|
|
26
|
+
faceCount: g,
|
|
27
|
+
properties: k,
|
|
28
|
+
elements: r
|
|
29
|
+
};
|
|
30
|
+
if (u <= 0)
|
|
31
|
+
return { kind: "unsupported", reason: "PLY has no vertex data.", ply: h };
|
|
32
|
+
if (g > 0 || r.includes("face"))
|
|
33
|
+
return { kind: "ply-mesh", reason: "PLY declares a face element.", ply: h };
|
|
34
|
+
if (k.some((d) => ie.test(d)))
|
|
35
|
+
return { kind: "gaussian-ply", reason: "PLY declares Gaussian splat properties.", ply: h };
|
|
36
|
+
const L = new Set(k.map((d) => d.toLowerCase()));
|
|
37
|
+
if (!["x", "y", "z"].every((d) => L.has(d)))
|
|
38
|
+
return { kind: "unsupported", reason: "PLY point cloud is missing x/y/z fields.", ply: h };
|
|
39
|
+
const z = ["red", "green", "blue"].filter((d) => L.has(d));
|
|
40
|
+
return z.length !== 0 && z.length !== 3 ? { kind: "unsupported", reason: "PLY point cloud has an incomplete RGB field set.", ply: h } : k.some((d) => !se.test(d)) ? {
|
|
41
|
+
kind: "unsupported",
|
|
42
|
+
reason: "PLY has no faces and contains non-standard fields, but is not a recognised Gaussian layout.",
|
|
43
|
+
ply: h
|
|
44
|
+
} : { kind: "ply-point-cloud", reason: "PLY has xyz vertices, no faces and no Gaussian fields.", ply: h };
|
|
45
|
+
}
|
|
46
|
+
function oe(n, e, o) {
|
|
47
|
+
const t = (e ?? "").toLowerCase(), i = (o ?? "").toLowerCase();
|
|
48
|
+
return t.endsWith(".ply") || i === "ply" ? ae(n) : t.endsWith(".glb") || i === "glb" ? { kind: "glb", reason: "GLB extension." } : t.endsWith(".gltf") || i === "gltf" ? { kind: "gltf", reason: "glTF extension." } : t.endsWith(".spz") || i === "spz" || le(n) ? { kind: "gaussian-spz", reason: "SPZ extension or magic." } : t.endsWith(".splat") || i === "splat" ? { kind: "gaussian-splat", reason: "SPLAT extension." } : t.endsWith(".ksplat") || i === "ksplat" ? { kind: "gaussian-ksplat", reason: "KSPLAT extension." } : t.endsWith(".rad") || i === "rad" ? { kind: "gaussian-rad", reason: "RAD extension." } : t.endsWith(".sog") || t.endsWith(".sog.zip") || i === "sog" || i === "pcsogs" || i === "pcsogszip" ? { kind: "gaussian-sog", reason: "SOG extension." } : (t.endsWith(".zip") || i === "zip") && ue(n, [80, 75]) ? {
|
|
49
|
+
kind: "unsupported",
|
|
50
|
+
reason: "ZIP is not a .sog.zip package; generic ZIPs are handled by asset intake."
|
|
51
|
+
} : { kind: "unsupported", reason: "No supported visual format was detected." };
|
|
52
|
+
}
|
|
53
|
+
function le(n) {
|
|
54
|
+
if (n.length < 4) return !1;
|
|
55
|
+
const e = de(n, 0);
|
|
56
|
+
return e === 1347639818 || e === 1347635022 ? !0 : n[0] === 31 && n[1] === 139;
|
|
57
|
+
}
|
|
58
|
+
function ue(n, e) {
|
|
59
|
+
return e.every((o, t) => n[t] === o);
|
|
60
|
+
}
|
|
61
|
+
function de(n, e) {
|
|
62
|
+
return (n[e] | n[e + 1] << 8 | n[e + 2] << 16 | n[e + 3] << 24) >>> 0;
|
|
63
|
+
}
|
|
64
|
+
function I(n) {
|
|
65
|
+
const e = Number(n);
|
|
66
|
+
return Number.isInteger(e) && e >= 0 ? e : 0;
|
|
67
|
+
}
|
|
68
|
+
const M = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
function Pe(n, e) {
|
|
70
|
+
let o = !1, t = null, i = null, l = null, w = null, u = null, g = null, f = null, r = null, k = "unsupported", h = null, L = null, z = null, P = "y", d;
|
|
71
|
+
const m = W(), E = () => {
|
|
72
|
+
o = !0;
|
|
73
|
+
}, F = () => {
|
|
74
|
+
!f || !g || (f.references -= 1, f.references <= 0 && (g.remove(f.renderer), f.renderer.dispose(), M.get(g) === f && M.delete(g)), f = null, g = null);
|
|
75
|
+
}, q = (s, y) => {
|
|
76
|
+
if (f && g === y) return;
|
|
77
|
+
F();
|
|
78
|
+
let p = M.get(y);
|
|
79
|
+
if (!p) {
|
|
80
|
+
const S = new te({
|
|
81
|
+
renderer: s,
|
|
82
|
+
onDirty: e.requestRender,
|
|
83
|
+
transparent: !0,
|
|
84
|
+
depthTest: !0,
|
|
85
|
+
depthWrite: !1
|
|
86
|
+
});
|
|
87
|
+
S.name = "viewer-spark-renderer", y.add(S), p = { renderer: S, references: 0 }, M.set(y, p);
|
|
88
|
+
}
|
|
89
|
+
p.references += 1, f = p, g = y;
|
|
90
|
+
}, T = (async () => {
|
|
91
|
+
var G, C, N, R, U, _;
|
|
92
|
+
const s = await pe(n);
|
|
93
|
+
if (o || e.signal.aborted) throw Z();
|
|
94
|
+
const y = n.entryPath ?? n.filename, p = oe(s, y, e.format);
|
|
95
|
+
if (p.kind === "unsupported")
|
|
96
|
+
throw new Error(`Unsupported visual asset: ${p.reason}`);
|
|
97
|
+
k = p.kind;
|
|
98
|
+
const S = new D();
|
|
99
|
+
S.name = "viewer-visual-root";
|
|
100
|
+
const x = new D();
|
|
101
|
+
if (x.name = "viewer-visual-content", p.kind === "glb" || p.kind === "gltf")
|
|
102
|
+
throw new Error("GLB/glTF is handled by the model loader.");
|
|
103
|
+
if (p.kind === "ply-mesh" || p.kind === "ply-point-cloud") {
|
|
104
|
+
const c = new ee().parse(he(s));
|
|
105
|
+
if (c.computeBoundingBox(), !c.boundingBox || c.boundingBox.isEmpty())
|
|
106
|
+
throw c.dispose(), new Error("PLY does not contain displayable vertex data.");
|
|
107
|
+
if (p.kind === "ply-mesh") {
|
|
108
|
+
const a = c.hasAttribute("color"), b = new j({
|
|
109
|
+
color: a ? 16777215 : 10135733,
|
|
110
|
+
vertexColors: a,
|
|
111
|
+
roughness: 0.82,
|
|
112
|
+
metalness: 0.04
|
|
113
|
+
}), v = new Y(c, b);
|
|
114
|
+
v.name = "viewer-visual-ply-mesh", x.add(v);
|
|
115
|
+
} else {
|
|
116
|
+
const a = c.hasAttribute("color"), b = new H({
|
|
117
|
+
color: a ? 16777215 : 10934783,
|
|
118
|
+
vertexColors: a,
|
|
119
|
+
size: Math.max(4e-3, fe(c.boundingBox) * 3e-3),
|
|
120
|
+
sizeAttenuation: !0
|
|
121
|
+
}), v = new J(c, b);
|
|
122
|
+
v.name = "viewer-visual-ply-points", x.add(v);
|
|
123
|
+
}
|
|
124
|
+
h = null;
|
|
125
|
+
} else {
|
|
126
|
+
const c = ce(p.kind), a = new ne({
|
|
127
|
+
fileBytes: s,
|
|
128
|
+
fileType: c,
|
|
129
|
+
fileName: y ?? `visual.${c}`,
|
|
130
|
+
raycastable: e.options.visualSelectionMode === "exact"
|
|
131
|
+
});
|
|
132
|
+
if (await a.initialized, o || e.signal.aborted)
|
|
133
|
+
throw a.dispose(), Z();
|
|
134
|
+
if (a.name = "viewer-visual-splat", a.position.set(0, 0, 0), (G = e.options.visualAppearance) != null && G.color && (a.recolor = new Q(...e.options.visualAppearance.color)), ((C = e.options.visualAppearance) == null ? void 0 : C.opacity) !== void 0 && (a.opacity = e.options.visualAppearance.opacity), x.add(a), l = a, h = ((N = a.packedSplats) == null ? void 0 : N.numSplats) ?? ((R = a.extSplats) == null ? void 0 : R.numSplats) ?? ((U = a.paged) == null ? void 0 : U.numSplats) ?? ((_ = a.splats) == null ? void 0 : _.getNumSplats()) ?? null, w = me(a), w.isEmpty()) throw new Error("Gaussian asset has empty bounds.");
|
|
135
|
+
}
|
|
136
|
+
if (P = e.options.upAxis ?? (p.kind.startsWith("gaussian-") ? "y-down" : "y"), $(x, P), S.add(x), x.updateMatrixWorld(!0), r = new V().setFromObject(x), l && w && (l.updateWorldMatrix(!0, !1), r.union(w.clone().applyMatrix4(l.matrixWorld))), r.isEmpty()) throw new Error("Visual asset has no displayable bounds.");
|
|
137
|
+
if (l && e.options.visualSelectionMode !== "exact") {
|
|
138
|
+
const c = r.getSize(new A()), a = new X({
|
|
139
|
+
transparent: !0,
|
|
140
|
+
// The scene picker filters fully transparent materials, while colorWrite
|
|
141
|
+
// keeps this raycastable proxy invisible in the rendered frame.
|
|
142
|
+
opacity: 1,
|
|
143
|
+
colorWrite: !1,
|
|
144
|
+
depthTest: !1,
|
|
145
|
+
depthWrite: !1
|
|
146
|
+
}), b = new Y(new O(c.x, c.y, c.z), a), v = r.getCenter(new A());
|
|
147
|
+
b.position.copy(v), b.name = "viewer-visual-bounds-proxy", b.userData.viewerVisualBoundsProxy = !0, S.add(b), u = b;
|
|
148
|
+
}
|
|
149
|
+
t = S, i = x, z = W() - m;
|
|
150
|
+
})();
|
|
151
|
+
return T.catch((s) => {
|
|
152
|
+
L = s instanceof Error ? s.message : String(s), z = W() - m;
|
|
153
|
+
}), {
|
|
154
|
+
id: `visual-${Math.random().toString(36).slice(2)}`,
|
|
155
|
+
opened: T,
|
|
156
|
+
get root() {
|
|
157
|
+
return t;
|
|
158
|
+
},
|
|
159
|
+
get fitTarget() {
|
|
160
|
+
return r;
|
|
161
|
+
},
|
|
162
|
+
getFitBounds() {
|
|
163
|
+
return r;
|
|
164
|
+
},
|
|
165
|
+
capabilities: {
|
|
166
|
+
canPlay: !1,
|
|
167
|
+
canPause: !1,
|
|
168
|
+
canReset: !1,
|
|
169
|
+
hasPhysics: !1,
|
|
170
|
+
canReorientUpAxis: !0,
|
|
171
|
+
canToggleGround: !0
|
|
172
|
+
},
|
|
173
|
+
presentation: {
|
|
174
|
+
preferredViewMode: "3d",
|
|
175
|
+
interactionMode: "object",
|
|
176
|
+
uiProfile: "model",
|
|
177
|
+
fitPolicy: "fit-on-ready"
|
|
178
|
+
},
|
|
179
|
+
getUpAxis() {
|
|
180
|
+
return i ? P : null;
|
|
181
|
+
},
|
|
182
|
+
setUpAxis(s) {
|
|
183
|
+
o || !i || $(i, s) && (P = s, i.updateMatrixWorld(!0), r = new V().setFromObject(i), K(), e.requestRender());
|
|
184
|
+
},
|
|
185
|
+
setGroundVisible() {
|
|
186
|
+
},
|
|
187
|
+
getGroundVisible() {
|
|
188
|
+
return !1;
|
|
189
|
+
},
|
|
190
|
+
getGroundGridScale() {
|
|
191
|
+
return re;
|
|
192
|
+
},
|
|
193
|
+
beforeRender(s, y) {
|
|
194
|
+
!o && l && q(s, y);
|
|
195
|
+
},
|
|
196
|
+
getVisualDiagnostics() {
|
|
197
|
+
const s = (r == null ? void 0 : r.getSize(new A())) ?? new A();
|
|
198
|
+
return {
|
|
199
|
+
schemaVersion: 1,
|
|
200
|
+
backend: l ? "spark-2.4.0" : k === "ply-point-cloud" ? "three-points" : "three-mesh",
|
|
201
|
+
kind: k,
|
|
202
|
+
splatCount: h,
|
|
203
|
+
bounds: r ? {
|
|
204
|
+
min: [r.min.x, r.min.y, r.min.z],
|
|
205
|
+
max: [r.max.x, r.max.y, r.max.z],
|
|
206
|
+
size: [s.x, s.y, s.z]
|
|
207
|
+
} : null,
|
|
208
|
+
upAxis: P,
|
|
209
|
+
loadMilliseconds: z,
|
|
210
|
+
error: L
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
beginDispose() {
|
|
214
|
+
E();
|
|
215
|
+
},
|
|
216
|
+
dispose() {
|
|
217
|
+
return E(), d ?? (d = T.catch(() => {
|
|
218
|
+
}).then(() => {
|
|
219
|
+
if (u == null || u.geometry.dispose(), u)
|
|
220
|
+
for (const s of Array.isArray(u.material) ? u.material : [u.material]) s.dispose();
|
|
221
|
+
u = null, l == null || l.dispose(), l = null, w = null, t && ge(t), t = null, i = null, F();
|
|
222
|
+
})), d;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
function K() {
|
|
226
|
+
if (!u || !r) return;
|
|
227
|
+
const s = r.getSize(new A()), y = r.getCenter(new A());
|
|
228
|
+
u.geometry.dispose(), u.geometry = new O(s.x, s.y, s.z), u.position.copy(y);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function pe(n) {
|
|
232
|
+
const e = n.original;
|
|
233
|
+
if (typeof Blob < "u" && e instanceof Blob)
|
|
234
|
+
return new Uint8Array(await e.arrayBuffer());
|
|
235
|
+
if (e instanceof ArrayBuffer) return new Uint8Array(e);
|
|
236
|
+
if (typeof e == "object" && e !== null && "kind" in e) {
|
|
237
|
+
if (e.kind === "buffer") return new Uint8Array(e.buffer);
|
|
238
|
+
if (e.kind === "files") {
|
|
239
|
+
const i = n.entryPath ?? e.entry, l = e.files.find((w) => w.path === i) ?? (e.files.length === 1 ? e.files[0] : null);
|
|
240
|
+
if (l) return new Uint8Array(await l.file.arrayBuffer());
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const o = n.url ?? await n.resolve(n.entryPath ?? ""), t = await fetch(o, { signal: n.signal });
|
|
244
|
+
if (!t.ok) throw new Error(`Visual asset request failed: ${t.status} ${t.statusText}`);
|
|
245
|
+
return new Uint8Array(await t.arrayBuffer());
|
|
246
|
+
}
|
|
247
|
+
function ce(n) {
|
|
248
|
+
switch (n) {
|
|
249
|
+
case "gaussian-ply":
|
|
250
|
+
return B.PLY;
|
|
251
|
+
case "gaussian-spz":
|
|
252
|
+
return B.SPZ;
|
|
253
|
+
case "gaussian-splat":
|
|
254
|
+
return B.SPLAT;
|
|
255
|
+
case "gaussian-ksplat":
|
|
256
|
+
return B.KSPLAT;
|
|
257
|
+
case "gaussian-sog":
|
|
258
|
+
return B.PCSOGSZIP;
|
|
259
|
+
case "gaussian-rad":
|
|
260
|
+
return B.RAD;
|
|
261
|
+
default:
|
|
262
|
+
throw new Error(`Not a Gaussian format: ${n}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function fe(n) {
|
|
266
|
+
return n.getSize(new A()).length();
|
|
267
|
+
}
|
|
268
|
+
function me(n) {
|
|
269
|
+
const e = n.getBoundingBox(!0);
|
|
270
|
+
return ye(e) || (e.makeEmpty(), n.forEachSplat((o, t) => {
|
|
271
|
+
Number.isFinite(t.x) && Number.isFinite(t.y) && Number.isFinite(t.z) && e.expandByPoint(t);
|
|
272
|
+
})), e;
|
|
273
|
+
}
|
|
274
|
+
function ye(n) {
|
|
275
|
+
return !n.isEmpty() && Number.isFinite(n.min.x) && Number.isFinite(n.min.y) && Number.isFinite(n.min.z) && Number.isFinite(n.max.x) && Number.isFinite(n.max.y) && Number.isFinite(n.max.z);
|
|
276
|
+
}
|
|
277
|
+
function ge(n) {
|
|
278
|
+
n.traverse((e) => {
|
|
279
|
+
"geometry" in e && e.geometry && typeof e.geometry.dispose == "function" && e.geometry.dispose();
|
|
280
|
+
const o = "material" in e ? e.material : null;
|
|
281
|
+
for (const t of Array.isArray(o) ? o : o ? [o] : []) t.dispose();
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
function he(n) {
|
|
285
|
+
const e = new Uint8Array(n.byteLength);
|
|
286
|
+
return e.set(n), e.buffer;
|
|
287
|
+
}
|
|
288
|
+
function Z() {
|
|
289
|
+
return Object.assign(new Error("Visual asset load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
290
|
+
}
|
|
291
|
+
function W() {
|
|
292
|
+
return typeof performance > "u" ? Date.now() : performance.now();
|
|
293
|
+
}
|
|
294
|
+
export {
|
|
295
|
+
Pe as createVisualSession
|
|
296
|
+
};
|