@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
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,9 +1,9 @@
|
|
|
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
|
-
var
|
|
4
|
-
import { I as ut, J as
|
|
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-jlMvDvhU.js";
|
|
5
5
|
import { Vector3 as Z } from "three";
|
|
6
|
-
const
|
|
6
|
+
const Et = /* @__PURE__ */ new Set([
|
|
7
7
|
"E_MJCF_INCLUDE_CYCLE",
|
|
8
8
|
"E_MJCF_PARSE",
|
|
9
9
|
"E_URDF_COMPILE",
|
|
@@ -19,12 +19,12 @@ const bt = /* @__PURE__ */ new Set([
|
|
|
19
19
|
"E_USD_MULTIPLE_PHYSICS_SCENES",
|
|
20
20
|
"E_USD_PARTIAL_INERTIA",
|
|
21
21
|
"E_USD_UNREACHABLE_BODIES"
|
|
22
|
-
]),
|
|
22
|
+
]), yt = /* @__PURE__ */ new Set(["step", "reset", "grab", "up-axis"]), St = Object.freeze({
|
|
23
23
|
kind: "visual-adaptation",
|
|
24
24
|
title: "视觉适配信息",
|
|
25
25
|
summary: "部分材质细节采用近似表示,不影响资产结构与模型查看。",
|
|
26
26
|
tone: "info"
|
|
27
|
-
}),
|
|
27
|
+
}), gt = Object.freeze({
|
|
28
28
|
kind: "unsupported-by-viewer",
|
|
29
29
|
title: "视觉预览模式",
|
|
30
30
|
summary: "当前仿真链路未能建立物理模型,资产视觉内容仍可正常查看。",
|
|
@@ -43,17 +43,17 @@ function M(e, t) {
|
|
|
43
43
|
tone: "warning"
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function It(e) {
|
|
47
47
|
return e === "visual-material" ? {
|
|
48
48
|
kind: "visual-adaptation",
|
|
49
49
|
title: "视觉材质近似",
|
|
50
50
|
summary: "部分材质信息未完整转换,当前显示使用近似材质。",
|
|
51
51
|
tone: "info"
|
|
52
|
-
} :
|
|
52
|
+
} : St;
|
|
53
53
|
}
|
|
54
54
|
function rt(e, t) {
|
|
55
55
|
const n = t.split(":").at(-1);
|
|
56
|
-
if (n &&
|
|
56
|
+
if (n && yt.has(n))
|
|
57
57
|
return {
|
|
58
58
|
kind: "runtime-failure",
|
|
59
59
|
title: "仿真运行异常",
|
|
@@ -83,25 +83,25 @@ function rt(e, t) {
|
|
|
83
83
|
tone: "warning"
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
return
|
|
86
|
+
return Et.has(e) ? M(e, t) : t === "usd-physics" || e.startsWith("E_USD_") ? {
|
|
87
87
|
kind: "unsupported-by-viewer",
|
|
88
88
|
title: "视觉预览模式",
|
|
89
89
|
summary: "当前 Viewer 未覆盖该 USD 资产使用的部分物理语义,视觉与结构信息可正常查看,物理仿真未启动。",
|
|
90
90
|
tone: "info"
|
|
91
|
-
} : e.startsWith("E_MJCF_") || e.startsWith("E_URDF_") ? M(e, t) :
|
|
91
|
+
} : e.startsWith("E_MJCF_") || e.startsWith("E_URDF_") ? M(e, t) : gt;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const n = e.notice ?? (t === "physics-validation" ? M(e.code, e.source) : t === "visual-adaptation" || t === "visual-material" ?
|
|
93
|
+
function Ct(e, t) {
|
|
94
|
+
const n = e.notice ?? (t === "physics-validation" ? M(e.code, e.source) : t === "visual-adaptation" || t === "visual-material" ? It(t) : rt(e.code, e.source ?? t));
|
|
95
95
|
return { ...e, stage: t, notice: n };
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function Ft(e, t, n) {
|
|
98
98
|
if (t.throwIfAborted(), e instanceof Error && (e.name === "AbortError" || ["E_ABORTED", "E_SUPERSEDED"].includes(String(e.code)))) throw e;
|
|
99
99
|
const s = e && typeof e == "object" && "code" in e && typeof e.code == "string" ? e.code : "E_PHYSICS_INITIALIZE", i = e instanceof Error ? e.message : String(e);
|
|
100
100
|
return { code: s, source: n, message: i, notice: rt(s, n) };
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Jt(e, t, n, s, i, r) {
|
|
103
103
|
try {
|
|
104
|
-
return
|
|
104
|
+
return wt(e, t, n, s, r);
|
|
105
105
|
} catch (o) {
|
|
106
106
|
try {
|
|
107
107
|
i == null || i(o);
|
|
@@ -110,19 +110,19 @@ function Pt(e, t, n, s, i, r) {
|
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function wt(e, t, n, s, i) {
|
|
114
114
|
var V, z, W, G;
|
|
115
115
|
const r = e.model, o = e.mujoco, f = e.data;
|
|
116
116
|
if (!r || !o || !f) return;
|
|
117
117
|
const c = [], l = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
|
|
118
118
|
for (let a = 0; a < r.nflexvert; a++) S.add(Number(r.flex_vertbodyid[a]));
|
|
119
119
|
for (let a = 0; a < r.nflexnode; a++) S.add(Number(r.flex_nodebodyid[a]));
|
|
120
|
-
const
|
|
120
|
+
const I = /* @__PURE__ */ new Set();
|
|
121
121
|
for (let a = 0; a < r.nflex; a++) {
|
|
122
122
|
const u = o.mj_id2name(r, o.mjtObj.mjOBJ_FLEX.value, a);
|
|
123
|
-
u &&
|
|
123
|
+
u && I.add(u);
|
|
124
124
|
}
|
|
125
|
-
const
|
|
125
|
+
const g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), st = (a) => {
|
|
126
126
|
try {
|
|
127
127
|
const u = Number(r.nu ?? 0);
|
|
128
128
|
if (!Number.isFinite(u) || u <= 0) return {};
|
|
@@ -132,18 +132,18 @@ function It(e, t, n, s, i) {
|
|
|
132
132
|
if (d[_] !== o.mjtTrn.mjTRN_JOINT.value || h[_ * 2] !== a) continue;
|
|
133
133
|
const j = Number(r.actuator_gear[_ * 6]);
|
|
134
134
|
if (!Number.isFinite(j)) continue;
|
|
135
|
-
const
|
|
136
|
-
type: A &&
|
|
135
|
+
const N = r.actuator_biastype[_] === o.mjtBias.mjBIAS_AFFINE.value, A = r.actuator_gaintype[_] === o.mjtGain.mjGAIN_FIXED.value, w = N ? -Number(p == null ? void 0 : p[_ * 10 + 1]) + 0 : void 0, b = N ? -Number(p == null ? void 0 : p[_ * 10 + 2]) + 0 : void 0, T = Number(r.actuator_gainprm[_ * 10]), at = {
|
|
136
|
+
type: A && N && w != null && w > 0 && T === w ? "position" : A && N && w === 0 && b != null && b > 0 && T === b ? "velocity" : A && r.actuator_biastype[_] === o.mjtBias.mjBIAS_NONE.value ? "motor" : "general",
|
|
137
137
|
...Number.isFinite(w) ? { stiffness: w * j * j } : {},
|
|
138
138
|
...Number.isFinite(b) ? { damping: b * j * j } : {}
|
|
139
|
-
},
|
|
140
|
-
let
|
|
139
|
+
}, Y = r.actuator(_);
|
|
140
|
+
let q;
|
|
141
141
|
try {
|
|
142
|
-
|
|
142
|
+
q = !!Y.forcelimited;
|
|
143
143
|
} finally {
|
|
144
|
-
|
|
144
|
+
Y.delete();
|
|
145
145
|
}
|
|
146
|
-
const H = Number(m == null ? void 0 : m[_ * 2]), K = Number(m == null ? void 0 : m[_ * 2 + 1]), Q =
|
|
146
|
+
const H = Number(m == null ? void 0 : m[_ * 2]), K = Number(m == null ? void 0 : m[_ * 2 + 1]), Q = q && Number.isFinite(H) && Number.isFinite(K) ? Math.max(Math.abs(H), Math.abs(K)) * Math.abs(j) : void 0;
|
|
147
147
|
return { drive: at, ...Q != null ? { maxEffort: Q } : {} };
|
|
148
148
|
}
|
|
149
149
|
} catch {
|
|
@@ -154,12 +154,12 @@ function It(e, t, n, s, i) {
|
|
|
154
154
|
const u = r.jnt_type[a], d = u === o.mjtJoint.mjJNT_HINGE.value;
|
|
155
155
|
if (!d && u !== o.mjtJoint.mjJNT_SLIDE.value || S.has(r.jnt_bodyid[a])) continue;
|
|
156
156
|
const h = o.mj_id2name(r, o.mjtObj.mjOBJ_BODY.value, r.jnt_bodyid[a]);
|
|
157
|
-
if (h && [...
|
|
157
|
+
if (h && [...I].some((N) => h.startsWith(`${N}_`))) continue;
|
|
158
158
|
const m = o.mj_id2name(r, o.mjtObj.mjOBJ_JOINT.value, a);
|
|
159
159
|
if (!m || o.mj_name2id(r, o.mjtObj.mjOBJ_JOINT.value, m) !== a) continue;
|
|
160
160
|
const p = r.jnt_bodyid[a], _ = r.body_parentid[p], j = r.jnt(a);
|
|
161
161
|
try {
|
|
162
|
-
const
|
|
162
|
+
const N = (V = i == null ? void 0 : i.mimics) == null ? void 0 : V.get(m), A = st(a), w = Number((z = r.body_mass) == null ? void 0 : z[p]), b = (W = i == null ? void 0 : i.metadata) == null ? void 0 : W.get(m), T = ((G = i == null ? void 0 : i.limits) == null ? void 0 : G.get(m)) ?? (j.limited ? { lower: r.jnt_range[a * 2], upper: r.jnt_range[a * 2 + 1] } : void 0);
|
|
163
163
|
c.push({
|
|
164
164
|
id: m,
|
|
165
165
|
name: m.split("/").pop() || m,
|
|
@@ -169,27 +169,27 @@ function It(e, t, n, s, i) {
|
|
|
169
169
|
axis: Array.from(r.jnt_axis.slice(a * 3, a * 3 + 3)),
|
|
170
170
|
unit: d ? "rad" : "m",
|
|
171
171
|
defaultValue: f.qpos[r.jnt_qposadr[a]],
|
|
172
|
-
...
|
|
172
|
+
...T ? { limits: T } : {},
|
|
173
173
|
...(b == null ? void 0 : b.movingMass) != null ? { movingMass: b.movingMass } : Number.isFinite(w) && w > 0 ? { movingMass: w } : {},
|
|
174
174
|
...b != null && b.drive ? { drive: b.drive } : A.drive ? { drive: A.drive } : {},
|
|
175
175
|
...(b == null ? void 0 : b.maxEffort) != null ? { maxEffort: b.maxEffort } : A.maxEffort != null ? { maxEffort: A.maxEffort } : {},
|
|
176
|
-
...
|
|
177
|
-
}), l.set(m, a), y.set(m, p),
|
|
176
|
+
...N ? { mimic: { ...N } } : {}
|
|
177
|
+
}), l.set(m, a), y.set(m, p), g.has(p) || g.set(p, m), v.set(p, m);
|
|
178
178
|
} finally {
|
|
179
179
|
j.delete();
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
if (!c.length) return;
|
|
183
|
-
const
|
|
183
|
+
const P = /* @__PURE__ */ new Map(), ot = c.map((a) => {
|
|
184
184
|
const u = y.get(a.id);
|
|
185
|
-
let d =
|
|
185
|
+
let d = P.get(u);
|
|
186
186
|
if (!d) {
|
|
187
187
|
let h = r.body_parentid[u];
|
|
188
|
-
for (; h > 0 && !
|
|
188
|
+
for (; h > 0 && !g.has(h); ) h = r.body_parentid[h];
|
|
189
189
|
d = v.get(h);
|
|
190
190
|
}
|
|
191
|
-
return
|
|
192
|
-
}),
|
|
191
|
+
return P.set(u, a.id), { ...a, parentJointId: d ?? null };
|
|
192
|
+
}), k = ut(ot, t, {
|
|
193
193
|
controlMode: t === "usd" ? "kinematic" : "physics",
|
|
194
194
|
apply(a, u) {
|
|
195
195
|
if (t === "usd")
|
|
@@ -202,18 +202,18 @@ function It(e, t, n, s, i) {
|
|
|
202
202
|
},
|
|
203
203
|
...t === "mjcf" ? { isDriveActive: () => e.isJointDriveActive } : {},
|
|
204
204
|
requestRender: s
|
|
205
|
-
}),
|
|
205
|
+
}), C = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map();
|
|
206
206
|
for (let a = 1; a < r.nbody; a++) {
|
|
207
207
|
const u = o.mj_id2name(r, o.mjtObj.mjOBJ_BODY.value, a);
|
|
208
208
|
if (!u) continue;
|
|
209
|
-
|
|
209
|
+
C.set(u, a), F.set(a, u);
|
|
210
210
|
let d = a;
|
|
211
|
-
for (; d > 0 && !
|
|
212
|
-
J.set(u,
|
|
211
|
+
for (; d > 0 && !g.has(d); ) d = r.body_parentid[d];
|
|
212
|
+
J.set(u, g.get(d) ?? null);
|
|
213
213
|
}
|
|
214
214
|
for (const [a, u] of y) {
|
|
215
215
|
const d = [];
|
|
216
|
-
for (const [h, m] of
|
|
216
|
+
for (const [h, m] of F) {
|
|
217
217
|
let p = h;
|
|
218
218
|
for (; p > 0 && p !== u; ) p = r.body_parentid[p];
|
|
219
219
|
p === u && d.push(m);
|
|
@@ -223,13 +223,13 @@ function It(e, t, n, s, i) {
|
|
|
223
223
|
let L = !1;
|
|
224
224
|
const D = () => !L && e.model === r && e.data === f;
|
|
225
225
|
return {
|
|
226
|
-
...
|
|
226
|
+
...k,
|
|
227
227
|
pickRoots() {
|
|
228
228
|
return D() && (i != null && i.root) ? [i.root] : [];
|
|
229
229
|
},
|
|
230
230
|
objectForBody(a) {
|
|
231
231
|
var u;
|
|
232
|
-
return D() &&
|
|
232
|
+
return D() && C.has(a) ? ((u = i == null ? void 0 : i.objectForBody) == null ? void 0 : u.call(i, a)) ?? null : null;
|
|
233
233
|
},
|
|
234
234
|
jointForBody(a) {
|
|
235
235
|
return D() ? J.get(a) ?? null : null;
|
|
@@ -244,29 +244,29 @@ function It(e, t, n, s, i) {
|
|
|
244
244
|
return !d.toArray().every(Number.isFinite) || !h.toArray().every(Number.isFinite) || h.lengthSq() < 1e-12 ? null : (i != null && i.root ? (i.root.updateWorldMatrix(!0, !1), d.applyMatrix4(i.root.matrixWorld), h.transformDirection(i.root.matrixWorld)) : h.normalize(), { position: d, axis: h });
|
|
245
245
|
},
|
|
246
246
|
dispose() {
|
|
247
|
-
L || (L = !0,
|
|
247
|
+
L || (L = !0, k.dispose());
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
function
|
|
251
|
+
const vt = /<UDIM>/i;
|
|
252
|
+
function jt(e, t) {
|
|
253
253
|
const n = tt(e).replaceAll("\\", "/");
|
|
254
|
-
if (!
|
|
254
|
+
if (!vt.test(n)) return null;
|
|
255
255
|
const s = et(n), i = s.split("/").at(-1);
|
|
256
256
|
if (!i) return { paths: [], tiles: [] };
|
|
257
|
-
const r =
|
|
257
|
+
const r = Ut(i);
|
|
258
258
|
if (!r) return { paths: [], tiles: [] };
|
|
259
259
|
const o = [];
|
|
260
260
|
for (const l of new Set(t)) {
|
|
261
|
-
const y = tt(l).replaceAll("\\", "/"), S = et(y),
|
|
262
|
-
if (!g) continue;
|
|
263
|
-
const I = r.exec(g);
|
|
261
|
+
const y = tt(l).replaceAll("\\", "/"), S = et(y), I = S.split("/").at(-1);
|
|
264
262
|
if (!I) continue;
|
|
265
|
-
const
|
|
263
|
+
const g = r.exec(I);
|
|
264
|
+
if (!g) continue;
|
|
265
|
+
const v = Number(g[1]);
|
|
266
266
|
!Number.isInteger(v) || v < 1001 || v > 9999 || o.push({
|
|
267
267
|
path: l,
|
|
268
268
|
tile: v,
|
|
269
|
-
score:
|
|
269
|
+
score: Ot(s, S)
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
if (!o.length) return { paths: [], tiles: [] };
|
|
@@ -276,9 +276,9 @@ function wt(e, t) {
|
|
|
276
276
|
tiles: c.map((l) => l.tile)
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function $t(e) {
|
|
280
280
|
if (!e.tiles.length) return null;
|
|
281
|
-
const t = e.tiles.map(
|
|
281
|
+
const t = e.tiles.map(Nt), n = Math.min(...t.map(({ column: o }) => o)), s = Math.max(...t.map(({ column: o }) => o)), i = Math.min(...t.map(({ row: o }) => o)), r = Math.max(...t.map(({ row: o }) => o));
|
|
282
282
|
return {
|
|
283
283
|
minColumn: n,
|
|
284
284
|
maxColumn: s,
|
|
@@ -288,18 +288,18 @@ function Ft(e) {
|
|
|
288
288
|
rows: r - i + 1
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function Nt(e) {
|
|
292
292
|
const t = e - 1001;
|
|
293
293
|
return {
|
|
294
294
|
column: (t % 10 + 10) % 10,
|
|
295
295
|
row: Math.floor(t / 10)
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function Ut(e) {
|
|
299
299
|
const t = e.split(/<UDIM>/i);
|
|
300
300
|
return t.length !== 2 ? null : new RegExp(`^${nt(t[0])}(\\d{4})${nt(t[1])}$`, "i");
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function Ot(e, t) {
|
|
303
303
|
const n = e.split("/").slice(0, -1).filter(Boolean), s = t.split("/").slice(0, -1).filter(Boolean);
|
|
304
304
|
let i = 0;
|
|
305
305
|
for (; i < n.length && i < s.length; ) {
|
|
@@ -324,20 +324,20 @@ function et(e) {
|
|
|
324
324
|
function nt(e) {
|
|
325
325
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
326
326
|
}
|
|
327
|
-
class
|
|
327
|
+
class Vt {
|
|
328
328
|
constructor(t) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
U(this, "entries", /* @__PURE__ */ new Map());
|
|
330
|
+
U(this, "manifestPaths", /* @__PURE__ */ new Set());
|
|
331
|
+
U(this, "objectUrls", /* @__PURE__ */ new Map());
|
|
332
|
+
U(this, "objectUrlPaths", /* @__PURE__ */ new Map());
|
|
333
333
|
/**
|
|
334
334
|
* Reads that already failed, so a missing resource is not requested again by
|
|
335
335
|
* the visual adapter after the reference prefetch has recorded it.
|
|
336
336
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
337
|
+
U(this, "failures", /* @__PURE__ */ new Map());
|
|
338
|
+
U(this, "pending", /* @__PURE__ */ new Map());
|
|
339
|
+
U(this, "localPackage");
|
|
340
|
+
U(this, "disposed", !1);
|
|
341
341
|
this.source = t;
|
|
342
342
|
for (const s of t.resourcePaths ?? []) {
|
|
343
343
|
const i = E(s);
|
|
@@ -346,7 +346,7 @@ class Ct {
|
|
|
346
346
|
const n = t.original;
|
|
347
347
|
if (this.localPackage = it(n) || typeof Blob < "u" && n instanceof Blob || n instanceof ArrayBuffer || typeof n == "object" && n !== null && "kind" in n && n.kind === "buffer", it(n))
|
|
348
348
|
for (const s of n.files) this.entries.set(E(s.path), s.file);
|
|
349
|
-
else t.entryBlob &&
|
|
349
|
+
else t.entryBlob && Tt(n) ? this.entries.set(t.entryPath ?? n.entryPath, t.entryBlob) : typeof Blob < "u" && n instanceof Blob ? this.entries.set(t.entryPath ?? t.filename ?? "asset", n) : n instanceof ArrayBuffer ? this.entries.set(t.entryPath ?? t.filename ?? "asset", new Blob([n])) : typeof n == "object" && n !== null && "kind" in n && n.kind === "buffer" && this.entries.set(t.entryPath ?? t.filename ?? "asset", new Blob([n.buffer]));
|
|
350
350
|
}
|
|
351
351
|
paths() {
|
|
352
352
|
return [.../* @__PURE__ */ new Set([...this.entries.keys(), ...this.manifestPaths])];
|
|
@@ -421,7 +421,7 @@ class Ct {
|
|
|
421
421
|
if (this.entries.has(i)) return;
|
|
422
422
|
const r = (s == null ? void 0 : s.signal) ?? this.source.signal;
|
|
423
423
|
if (!r) throw O(`No abort signal is available to read ${t}`, "E_ASSET_SIGNAL_REQUIRED");
|
|
424
|
-
|
|
424
|
+
x(r);
|
|
425
425
|
const o = this.failures.get(i);
|
|
426
426
|
if (o) throw o;
|
|
427
427
|
let f = this.pending.get(i);
|
|
@@ -434,32 +434,32 @@ class Ct {
|
|
|
434
434
|
promise: Promise.resolve().then(() => this.readResource(i, t, l.signal, s ?? {}))
|
|
435
435
|
};
|
|
436
436
|
this.pending.set(i, S);
|
|
437
|
-
const
|
|
437
|
+
const I = () => {
|
|
438
438
|
this.source.signal.removeEventListener("abort", y), this.pending.get(i) === S && this.pending.delete(i);
|
|
439
439
|
};
|
|
440
|
-
S.promise.then(
|
|
440
|
+
S.promise.then(I, I), f = S;
|
|
441
441
|
}
|
|
442
442
|
const c = f;
|
|
443
443
|
return c.waiters++, new Promise((l, y) => {
|
|
444
444
|
let S = !1;
|
|
445
|
-
const
|
|
446
|
-
|
|
445
|
+
const I = () => S ? !1 : (S = !0, r.removeEventListener("abort", g), c.controller.signal.removeEventListener("abort", g), c.waiters--, !0), g = () => {
|
|
446
|
+
I() && (c.waiters === 0 && this.pending.get(i) === c && (this.pending.delete(i), c.controller.abort()), y(new DOMException("The operation was aborted.", "AbortError")));
|
|
447
447
|
};
|
|
448
|
-
r.addEventListener("abort",
|
|
448
|
+
r.addEventListener("abort", g, { once: !0 }), c.controller.signal.addEventListener("abort", g, { once: !0 }), (r.aborted || c.controller.signal.aborted) && g(), c.promise.then(
|
|
449
449
|
() => {
|
|
450
|
-
|
|
450
|
+
I() && l();
|
|
451
451
|
},
|
|
452
452
|
(v) => {
|
|
453
|
-
|
|
453
|
+
I() && y(v);
|
|
454
454
|
}
|
|
455
455
|
);
|
|
456
456
|
});
|
|
457
457
|
}
|
|
458
458
|
async readResource(t, n, s, i) {
|
|
459
459
|
try {
|
|
460
|
-
|
|
460
|
+
x(s);
|
|
461
461
|
const r = await this.source.resolve(t, { ...i, signal: s });
|
|
462
|
-
if (
|
|
462
|
+
if (x(s), !/^https?:\/\//i.test(r) && !/^blob:/i.test(r))
|
|
463
463
|
throw O(`Simulation resource not found: ${n}. Upload the complete asset folder or provide a resourceResolver/baseUrl.`, X);
|
|
464
464
|
const o = await fetch(r, { signal: s });
|
|
465
465
|
if (!o.ok) {
|
|
@@ -467,9 +467,9 @@ class Ct {
|
|
|
467
467
|
throw O(`Simulation resource request failed (${o.status}): ${r}`, l);
|
|
468
468
|
}
|
|
469
469
|
const f = await o.blob();
|
|
470
|
-
|
|
470
|
+
x(s);
|
|
471
471
|
const c = await ht(f);
|
|
472
|
-
if (
|
|
472
|
+
if (x(s), c) throw O(`Simulation resource is not usable (${c}): ${r}`, mt);
|
|
473
473
|
this.entries.set(t, f);
|
|
474
474
|
} catch (r) {
|
|
475
475
|
throw s.aborted ? new DOMException("The operation was aborted.", "AbortError") : (pt(r) === "aborted" || this.failures.set(t, r instanceof Error ? r : new Error(String(r))), r);
|
|
@@ -499,7 +499,7 @@ class Ct {
|
|
|
499
499
|
}
|
|
500
500
|
udimTextureSet(t, n = "") {
|
|
501
501
|
const s = this.bindPackageReference(t, n), i = this.texturesUnderEntryDirectory(n);
|
|
502
|
-
return
|
|
502
|
+
return jt(s, i.length ? i : this.paths());
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* Package files below the entry directory named like UDIM tiles. A set the
|
|
@@ -537,14 +537,14 @@ class Ct {
|
|
|
537
537
|
* References that are not URLs, or that bind to nothing, are returned as-is.
|
|
538
538
|
*/
|
|
539
539
|
bindPackageReference(t, n = "") {
|
|
540
|
-
const s = E(n), i = s ? `${s}/` : "", r =
|
|
540
|
+
const s = E(n), i = s ? `${s}/` : "", r = Dt(t).flatMap((f) => f.split("/")).filter(Boolean);
|
|
541
541
|
if (!r.length) return t;
|
|
542
542
|
let o = null;
|
|
543
543
|
for (const f of this.paths()) {
|
|
544
544
|
if (R(f) || i && !f.startsWith(i)) continue;
|
|
545
545
|
const c = f.split("/");
|
|
546
546
|
let l = 0;
|
|
547
|
-
for (; l < r.length && l < c.length &&
|
|
547
|
+
for (; l < r.length && l < c.length && At(r.at(-1 - l), c.at(-1 - l)); ) l += 1;
|
|
548
548
|
l < 2 || (!o || l > o.depth) && (o = { path: f, depth: l });
|
|
549
549
|
}
|
|
550
550
|
return o ? i && o.path.startsWith(i) ? o.path.slice(i.length) : o.path : t;
|
|
@@ -557,14 +557,14 @@ class Ct {
|
|
|
557
557
|
this.objectUrls.clear(), this.objectUrlPaths.clear(), this.entries.clear(), this.manifestPaths.clear(), this.failures.clear();
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
async function
|
|
560
|
+
async function zt(e, t) {
|
|
561
561
|
if (t.hasLocalFiles()) return t.text(e.entryPath ?? e.filename ?? t.paths()[0]);
|
|
562
562
|
if (e.entryBlob) return e.entryBlob.text();
|
|
563
563
|
const n = await fetch(e.url ?? await e.resolve(e.entryPath ?? ""), { signal: e.signal });
|
|
564
564
|
if (!n.ok) throw O(`Simulation asset request failed: ${n.status}`, "E_ASSET_FETCH");
|
|
565
565
|
return n.text();
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function Wt(e) {
|
|
568
568
|
return E(e);
|
|
569
569
|
}
|
|
570
570
|
function E(e) {
|
|
@@ -577,18 +577,18 @@ function E(e) {
|
|
|
577
577
|
function R(e) {
|
|
578
578
|
return /^[a-z][a-z\d+.-]*:/i.test(e) && !/^package:\/\//i.test(e);
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function At(e, t) {
|
|
581
581
|
const n = e.search(/[?#]/);
|
|
582
582
|
return t === (n < 0 ? e : e.slice(0, n));
|
|
583
583
|
}
|
|
584
|
-
function
|
|
584
|
+
function Rt(e) {
|
|
585
585
|
try {
|
|
586
586
|
return decodeURIComponent(e);
|
|
587
587
|
} catch {
|
|
588
588
|
return e;
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function Dt(e) {
|
|
592
592
|
if (!R(e) || /^(?:data|blob):/i.test(e)) return [];
|
|
593
593
|
let t;
|
|
594
594
|
try {
|
|
@@ -596,25 +596,25 @@ function At(e) {
|
|
|
596
596
|
} catch {
|
|
597
597
|
t = e.replace(/^[a-z][a-z\d+.-]*:\/\/[^/]*/i, "").replace(/[?#].*$/, "");
|
|
598
598
|
}
|
|
599
|
-
return t.split("/").filter(Boolean).map(
|
|
599
|
+
return t.split("/").filter(Boolean).map(Rt);
|
|
600
600
|
}
|
|
601
601
|
function it(e) {
|
|
602
602
|
return typeof e == "object" && e !== null && "kind" in e && e.kind === "files";
|
|
603
603
|
}
|
|
604
|
-
function
|
|
604
|
+
function Tt(e) {
|
|
605
605
|
return typeof e == "object" && e !== null && "kind" in e && e.kind === "remote-entry";
|
|
606
606
|
}
|
|
607
607
|
function O(e, t) {
|
|
608
608
|
return Object.assign(new Error(e), { code: t });
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function Gt() {
|
|
611
611
|
return { errors: [], warnings: [], approximations: [], droppedFeatures: [] };
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function Yt(e, t = {}) {
|
|
614
614
|
const n = Object.freeze({ schemaVersion: 1, ...e });
|
|
615
|
-
return
|
|
615
|
+
return xt(n, t), n;
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function xt(e, t = {}) {
|
|
618
618
|
if (!e.id.trim() || !e.name.trim()) throw B("Asset IR id and name are required.", "E_ASSET_IR_INVALID");
|
|
619
619
|
if (e.source.format !== "usd" && e.links.length === 0) throw B("Asset IR requires at least one link.", "E_ASSET_IR_INVALID");
|
|
620
620
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -632,16 +632,46 @@ function Dt(e, t = {}) {
|
|
|
632
632
|
function B(e, t) {
|
|
633
633
|
return Object.assign(new Error(e), { code: t });
|
|
634
634
|
}
|
|
635
|
+
const Bt = {
|
|
636
|
+
refit() {
|
|
637
|
+
},
|
|
638
|
+
dispose() {
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
function qt(e, t = e.geometry) {
|
|
642
|
+
const n = t;
|
|
643
|
+
let s = n.boundsTree, i = !1;
|
|
644
|
+
if (!s) {
|
|
645
|
+
try {
|
|
646
|
+
s = new bt(t, { targetLeafSize: 20, indirect: !0, verbose: !1 });
|
|
647
|
+
} catch {
|
|
648
|
+
return Bt;
|
|
649
|
+
}
|
|
650
|
+
n.boundsTree = s, i = !0;
|
|
651
|
+
}
|
|
652
|
+
const r = e.raycast;
|
|
653
|
+
e.raycast = _t;
|
|
654
|
+
let o = !1;
|
|
655
|
+
return {
|
|
656
|
+
refit() {
|
|
657
|
+
o || s.refit();
|
|
658
|
+
},
|
|
659
|
+
dispose() {
|
|
660
|
+
o || (o = !0, e.raycast = r, i && n.boundsTree === s && delete n.boundsTree);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
}
|
|
635
664
|
export {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
665
|
+
Vt as S,
|
|
666
|
+
Ft as a,
|
|
667
|
+
Jt as b,
|
|
668
|
+
Yt as c,
|
|
669
|
+
Gt as d,
|
|
670
|
+
zt as e,
|
|
671
|
+
M as f,
|
|
672
|
+
Wt as n,
|
|
673
|
+
qt as p,
|
|
674
|
+
jt as r,
|
|
675
|
+
$t as u,
|
|
676
|
+
Ct as w
|
|
647
677
|
};
|