@nebula-spatial/viewer 0.5.14 → 0.5.16
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 +116 -72
- package/README.md +15 -0
- package/dist/assets/types.d.ts +22 -0
- package/dist/assets/usd-worker-drur-7bI.js +1673 -0
- package/dist/{collision-debug-B2bN8P2g.js → collision-debug-fwawwhH3.js} +87 -75
- package/dist/{index-BSDalKkd.js → index-D9-UMnkK.js} +1062 -1018
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{mjcf-visual-D6T3a1uQ.js → mjcf-visual-8DniLezh.js} +1 -1
- package/dist/{mujoco-runtime-CFQQsRmc.js → mujoco-runtime-D3JnsOCZ.js} +1 -1
- package/dist/session-CEipzQYJ.js +801 -0
- package/dist/{session-BUarD9PA.js → session-Dn5fAl3z.js} +2 -2
- package/dist/{stage-CvP0yaff.js → stage-CrDYgXLe.js} +1 -1
- package/dist/{urdf-session-DcGOHFg2.js → urdf-session-BABUz6Qt.js} +5 -5
- package/dist/{usd-session-DSFtJk4b.js → usd-session-CNYn-3LD.js} +3680 -3494
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-bURYAikr.js → xacro-Q-egO2RI.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 +1 -1
- package/dist/assets/usd-worker-CPCXyXkl.js +0 -1508
- package/dist/session-Ciaw522_.js +0 -786
|
@@ -1,1508 +0,0 @@
|
|
|
1
|
-
function Ae(e, t) {
|
|
2
|
-
return /^https?:$/.test(t.protocol) && e.origin === t.origin && !e.username && !e.password && me(e.pathname).startsWith(me(new URL(".", t).pathname));
|
|
3
|
-
}
|
|
4
|
-
function me(e) {
|
|
5
|
-
return e.endsWith("/") ? e : e.slice(0, e.lastIndexOf("/") + 1);
|
|
6
|
-
}
|
|
7
|
-
function Ce(e, t) {
|
|
8
|
-
for (const n of e) for (const a of n.shaders) for (const i of Object.values(a.inputs)) {
|
|
9
|
-
if (!i || typeof i != "object" || Array.isArray(i)) continue;
|
|
10
|
-
const r = i, s = [r.path, r.url, r.resolvedPath].find((c) => typeof c == "string" && c);
|
|
11
|
-
!s || /^(?:data|blob):/i.test(s) || /\.mdl(?:[?#].*)?$/i.test(s) || t(r, s);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function je(e, t, n) {
|
|
15
|
-
const a = [];
|
|
16
|
-
try {
|
|
17
|
-
return Ce(e, (i, r) => {
|
|
18
|
-
if (t(r)) return;
|
|
19
|
-
const s = {};
|
|
20
|
-
for (const c of ["path", "resolvedPath", "url"])
|
|
21
|
-
c in i && (s[c] = i[c], delete i[c]);
|
|
22
|
-
a.push({ asset: i, values: s });
|
|
23
|
-
}), n();
|
|
24
|
-
} finally {
|
|
25
|
-
for (const { asset: i, values: r } of a) Object.assign(i, r);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const Ve = "E_ASSET_RESOURCE_NOT_FOUND", Me = "E_ASSET_RESOURCE_INVALID", Ge = "E_ASSET_FETCH", Be = "E_ASSET_EXTERNAL_DENIED", Fe = "E_ASSET_AUTH", ze = /* @__PURE__ */ new Set([
|
|
29
|
-
"png",
|
|
30
|
-
"jpg",
|
|
31
|
-
"jpeg",
|
|
32
|
-
"webp",
|
|
33
|
-
"avif",
|
|
34
|
-
"gif",
|
|
35
|
-
"bmp",
|
|
36
|
-
"tga",
|
|
37
|
-
"dds",
|
|
38
|
-
"hdr",
|
|
39
|
-
"exr",
|
|
40
|
-
"ktx2"
|
|
41
|
-
]), He = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
|
|
42
|
-
function We(e) {
|
|
43
|
-
var n;
|
|
44
|
-
return ((n = (e.split(/[?#]/, 1)[0] ?? e).split(".").pop()) == null ? void 0 : n.toLowerCase()) ?? "";
|
|
45
|
-
}
|
|
46
|
-
function Xe(e) {
|
|
47
|
-
const t = We(e);
|
|
48
|
-
return ze.has(t) && !He.has(t);
|
|
49
|
-
}
|
|
50
|
-
function Je(e, t) {
|
|
51
|
-
return Object.assign(new Error(e), { code: t });
|
|
52
|
-
}
|
|
53
|
-
function Ze(e) {
|
|
54
|
-
var a;
|
|
55
|
-
if (e instanceof Error && e.name === "AbortError") return "aborted";
|
|
56
|
-
const t = e == null ? void 0 : e.code;
|
|
57
|
-
if (t === Ve) return "missing";
|
|
58
|
-
if (t === Me) return "invalid";
|
|
59
|
-
if (t === Ge) return "unavailable";
|
|
60
|
-
if (t === Fe || t === Be) return "denied";
|
|
61
|
-
const n = (a = /\((\d{3})\)/.exec(e instanceof Error ? e.message : "")) == null ? void 0 : a[1];
|
|
62
|
-
return n === "404" || n === "410" ? "missing" : n === "401" || n === "403" ? "denied" : n != null && n.startsWith("5") ? "unavailable" : "unknown";
|
|
63
|
-
}
|
|
64
|
-
function Ye(e) {
|
|
65
|
-
const t = Ze(e);
|
|
66
|
-
return t === "missing" || t === "invalid" || t === "unavailable";
|
|
67
|
-
}
|
|
68
|
-
function qe(e, t) {
|
|
69
|
-
return e && /\bhtml\b/i.test(e) ? `返回 HTML 页面(${e})` : e && !/^text\//i.test(e) ? null : /^\uFEFF?\s*(?:<!doctype\s+html|<html|<\?xml[^>]*\bhtml)/i.test(t) ? "返回 HTML 兜底页" : null;
|
|
70
|
-
}
|
|
71
|
-
function Ke(e, t) {
|
|
72
|
-
return t.byteLength ? qe(e, new TextDecoder().decode(t.subarray(0, 512))) : "响应内容为空";
|
|
73
|
-
}
|
|
74
|
-
const Qe = /<UDIM>/i;
|
|
75
|
-
function et(e, t) {
|
|
76
|
-
const n = we(e).replaceAll("\\", "/");
|
|
77
|
-
if (!Qe.test(n)) return null;
|
|
78
|
-
const a = ye(n), i = a.split("/").at(-1);
|
|
79
|
-
if (!i) return { paths: [], tiles: [] };
|
|
80
|
-
const r = tt(i);
|
|
81
|
-
if (!r) return { paths: [], tiles: [] };
|
|
82
|
-
const s = [];
|
|
83
|
-
for (const u of new Set(t)) {
|
|
84
|
-
const h = we(u).replaceAll("\\", "/"), g = ye(h), l = g.split("/").at(-1);
|
|
85
|
-
if (!l) continue;
|
|
86
|
-
const f = r.exec(l);
|
|
87
|
-
if (!f) continue;
|
|
88
|
-
const p = Number(f[1]);
|
|
89
|
-
!Number.isInteger(p) || p < 1001 || p > 9999 || s.push({
|
|
90
|
-
path: u,
|
|
91
|
-
tile: p,
|
|
92
|
-
score: nt(a, g)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
if (!s.length) return { paths: [], tiles: [] };
|
|
96
|
-
const c = Math.max(...s.map((u) => u.score)), o = s.filter((u) => u.score === c).sort((u, h) => u.tile - h.tile || u.path.localeCompare(h.path));
|
|
97
|
-
return {
|
|
98
|
-
paths: o.map((u) => u.path),
|
|
99
|
-
tiles: o.map((u) => u.tile)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function tt(e) {
|
|
103
|
-
const t = e.split(/<UDIM>/i);
|
|
104
|
-
return t.length !== 2 ? null : new RegExp(`^${_e(t[0])}(\\d{4})${_e(t[1])}$`, "i");
|
|
105
|
-
}
|
|
106
|
-
function nt(e, t) {
|
|
107
|
-
const n = e.split("/").slice(0, -1).filter(Boolean), a = t.split("/").slice(0, -1).filter(Boolean);
|
|
108
|
-
let i = 0;
|
|
109
|
-
for (; i < n.length && i < a.length; ) {
|
|
110
|
-
const r = n.at(-1 - i), s = a.at(-1 - i);
|
|
111
|
-
if ((r == null ? void 0 : r.toLowerCase()) !== (s == null ? void 0 : s.toLowerCase())) break;
|
|
112
|
-
i += 1;
|
|
113
|
-
}
|
|
114
|
-
return i;
|
|
115
|
-
}
|
|
116
|
-
function we(e) {
|
|
117
|
-
const t = e.replace(/%3CUDIM%3E/gi, "<UDIM>");
|
|
118
|
-
try {
|
|
119
|
-
return decodeURIComponent(t);
|
|
120
|
-
} catch {
|
|
121
|
-
return t;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function ye(e) {
|
|
125
|
-
const t = e.search(/[?#]/);
|
|
126
|
-
return t < 0 ? e : e.slice(0, t);
|
|
127
|
-
}
|
|
128
|
-
function _e(e) {
|
|
129
|
-
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
130
|
-
}
|
|
131
|
-
const rt = 67324752, st = 33639248, ot = 101010256, ie = 4294967295, at = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "webp"]);
|
|
132
|
-
function it(e) {
|
|
133
|
-
return e.length > 3 && e[0] === 80 && e[1] === 75;
|
|
134
|
-
}
|
|
135
|
-
async function ct(e, t = {}) {
|
|
136
|
-
const n = new DataView(e.buffer, e.byteOffset, e.byteLength), a = pt(n);
|
|
137
|
-
if (a < 0) throw new Error("Not a zip package: end of central directory not found.");
|
|
138
|
-
const i = n.getUint16(a + 10, !0);
|
|
139
|
-
let r = n.getUint32(a + 16, !0);
|
|
140
|
-
if (i === 65535 || r === ie) throw new Error("ZIP64 usdz packages are not supported.");
|
|
141
|
-
const s = /* @__PURE__ */ new Map(), c = [];
|
|
142
|
-
for (let o = 0; o < i; o += 1) {
|
|
143
|
-
if (r + 46 > n.byteLength || n.getUint32(r, !0) !== st)
|
|
144
|
-
throw new Error(`Corrupt zip central directory at entry ${o}.`);
|
|
145
|
-
const u = n.getUint16(r + 10, !0), h = n.getUint32(r + 20, !0), g = n.getUint16(r + 28, !0), l = n.getUint16(r + 30, !0), f = n.getUint16(r + 32, !0), p = n.getUint32(r + 42, !0);
|
|
146
|
-
if (h === ie || p === ie)
|
|
147
|
-
throw new Error("ZIP64 usdz packages are not supported.");
|
|
148
|
-
const y = new TextDecoder().decode(e.subarray(r + 46, r + 46 + g));
|
|
149
|
-
r += 46 + g + l + f, !y.endsWith("/") && (t.include && !t.include(y) || c.push(lt(e, n, p, h, u).then((w) => ({ name: y, data: w }))));
|
|
150
|
-
}
|
|
151
|
-
for (const { name: o, data: u } of await Promise.all(c)) s.set(o, u);
|
|
152
|
-
return s;
|
|
153
|
-
}
|
|
154
|
-
function ut(e) {
|
|
155
|
-
if (typeof URL > "u" || typeof URL.createObjectURL != "function") return null;
|
|
156
|
-
const t = new Map([...e].filter(([s]) => ke(s)));
|
|
157
|
-
if (t.size === 0) return null;
|
|
158
|
-
const n = /* @__PURE__ */ new Map();
|
|
159
|
-
for (const s of t.keys()) {
|
|
160
|
-
const c = s.split("/").pop() ?? s;
|
|
161
|
-
n.set(c, n.has(c) ? null : s);
|
|
162
|
-
}
|
|
163
|
-
const a = /* @__PURE__ */ new Map(), i = (s) => {
|
|
164
|
-
let c = a.get(s);
|
|
165
|
-
if (!c) {
|
|
166
|
-
const o = t.get(s);
|
|
167
|
-
c = URL.createObjectURL(new Blob([new Uint8Array(o)], { type: ht(s) })), a.set(s, c);
|
|
168
|
-
}
|
|
169
|
-
return c;
|
|
170
|
-
}, r = (s) => {
|
|
171
|
-
if (!s) return null;
|
|
172
|
-
const c = ft(dt(s));
|
|
173
|
-
if (!c) return null;
|
|
174
|
-
if (t.has(c)) return i(c);
|
|
175
|
-
const o = [...t.keys()].filter((g) => g.endsWith(`/${c}`));
|
|
176
|
-
if (o.length === 1) return i(o[0]);
|
|
177
|
-
const u = [...t.keys()].filter((g) => c.endsWith(`/${g}`));
|
|
178
|
-
if (u.length === 1) return i(u[0]);
|
|
179
|
-
const h = n.get(c.split("/").pop() ?? "");
|
|
180
|
-
return h ? i(h) : null;
|
|
181
|
-
};
|
|
182
|
-
for (const s of t.keys()) i(s);
|
|
183
|
-
return {
|
|
184
|
-
urls: a,
|
|
185
|
-
resolve: (s) => r(s.resolvedPath) ?? r(s.path) ?? r(s.url) ?? null,
|
|
186
|
-
dispose: () => {
|
|
187
|
-
for (const s of a.values()) URL.revokeObjectURL(s);
|
|
188
|
-
a.clear();
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function ke(e) {
|
|
193
|
-
return at.has(xe(e));
|
|
194
|
-
}
|
|
195
|
-
async function lt(e, t, n, a, i) {
|
|
196
|
-
if (t.getUint32(n, !0) !== rt) throw new Error("Corrupt zip local file header.");
|
|
197
|
-
const r = t.getUint16(n + 26, !0), s = t.getUint16(n + 28, !0), c = n + 30 + r + s, o = e.subarray(c, c + a);
|
|
198
|
-
if (i === 0) return o.slice();
|
|
199
|
-
if (i !== 8) throw new Error(`Unsupported zip compression method ${i}.`);
|
|
200
|
-
const u = new Blob([new Uint8Array(o)]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
|
201
|
-
return new Uint8Array(await new Response(u).arrayBuffer());
|
|
202
|
-
}
|
|
203
|
-
function dt(e) {
|
|
204
|
-
const t = e.indexOf("[");
|
|
205
|
-
return t >= 0 && e.endsWith("]") ? e.slice(t + 1, -1) : e;
|
|
206
|
-
}
|
|
207
|
-
function ft(e) {
|
|
208
|
-
const t = [];
|
|
209
|
-
for (const n of e.replaceAll("\\", "/").split("/"))
|
|
210
|
-
!n || n === "." || (n === ".." ? t.pop() : t.push(n));
|
|
211
|
-
return t.join("/");
|
|
212
|
-
}
|
|
213
|
-
function xe(e) {
|
|
214
|
-
const t = e.split(/[?#]/)[0] ?? e, n = t.lastIndexOf(".");
|
|
215
|
-
return n < 0 ? "" : t.slice(n + 1).toLowerCase();
|
|
216
|
-
}
|
|
217
|
-
function ht(e) {
|
|
218
|
-
switch (xe(e)) {
|
|
219
|
-
case "png":
|
|
220
|
-
return "image/png";
|
|
221
|
-
case "jpg":
|
|
222
|
-
case "jpeg":
|
|
223
|
-
return "image/jpeg";
|
|
224
|
-
case "webp":
|
|
225
|
-
return "image/webp";
|
|
226
|
-
default:
|
|
227
|
-
return "application/octet-stream";
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function pt(e) {
|
|
231
|
-
const t = Math.max(0, e.byteLength - 65535 - 22);
|
|
232
|
-
for (let n = e.byteLength - 22; n >= t; n -= 1)
|
|
233
|
-
if (e.getUint32(n, !0) === ot) return n;
|
|
234
|
-
return -1;
|
|
235
|
-
}
|
|
236
|
-
const gt = 1, mt = 3, wt = "6ad6617c3ba6d2037c62", yt = {
|
|
237
|
-
file: "openusd_probe.js",
|
|
238
|
-
sha256: "83a14d264f2348a0899de8f1bc0c021fdcd8cae554ef545fb9e5b88da6f30b4e",
|
|
239
|
-
bytes: 95918
|
|
240
|
-
}, _t = {
|
|
241
|
-
file: "openusd_probe.wasm",
|
|
242
|
-
sha256: "a68fdbc8902ccb59e5cc84d24ad79572860806c01eaec5ad130218d0bbc835a9",
|
|
243
|
-
bytes: 10672319
|
|
244
|
-
};
|
|
245
|
-
var bt = {
|
|
246
|
-
schemaVersion: gt,
|
|
247
|
-
apiVersion: mt,
|
|
248
|
-
runtimeId: wt,
|
|
249
|
-
js: yt,
|
|
250
|
-
wasm: _t
|
|
251
|
-
};
|
|
252
|
-
const St = Ut(bt);
|
|
253
|
-
function Ut(e) {
|
|
254
|
-
if (!e || typeof e != "object") throw new Error("OpenUSD runtime manifest is missing.");
|
|
255
|
-
const t = e;
|
|
256
|
-
if (t.schemaVersion !== 1 || !Number.isInteger(t.apiVersion) || Number(t.apiVersion) < 1 || typeof t.runtimeId != "string" || !/^[0-9a-f]{20}$/.test(t.runtimeId))
|
|
257
|
-
throw new Error("OpenUSD runtime manifest metadata is invalid.");
|
|
258
|
-
return Object.freeze({
|
|
259
|
-
schemaVersion: t.schemaVersion,
|
|
260
|
-
apiVersion: Number(t.apiVersion),
|
|
261
|
-
runtimeId: t.runtimeId,
|
|
262
|
-
js: be(t.js, "openusd_probe.js"),
|
|
263
|
-
wasm: be(t.wasm, "openusd_probe.wasm")
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
function be(e, t) {
|
|
267
|
-
if (!e || typeof e != "object") throw new Error(`OpenUSD runtime manifest omits ${t}.`);
|
|
268
|
-
const n = e;
|
|
269
|
-
if (n.file !== t || typeof n.sha256 != "string" || !/^[0-9a-f]{64}$/.test(n.sha256) || !Number.isInteger(n.bytes) || Number(n.bytes) < 1)
|
|
270
|
-
throw new Error(`OpenUSD runtime manifest is invalid for ${t}.`);
|
|
271
|
-
return Object.freeze({
|
|
272
|
-
file: t,
|
|
273
|
-
sha256: n.sha256,
|
|
274
|
-
bytes: Number(n.bytes)
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
function Et(e, t, n) {
|
|
278
|
-
return WebAssembly.instantiate(e, t).then(
|
|
279
|
-
(a) => n(a, e),
|
|
280
|
-
(a) => {
|
|
281
|
-
setTimeout(() => {
|
|
282
|
-
throw a;
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
), {};
|
|
286
|
-
}
|
|
287
|
-
function Re(e, t) {
|
|
288
|
-
const n = async (r, s) => {
|
|
289
|
-
var o;
|
|
290
|
-
const c = e.GetPrimAtPath(r);
|
|
291
|
-
try {
|
|
292
|
-
return s(c);
|
|
293
|
-
} finally {
|
|
294
|
-
(o = c == null ? void 0 : c.delete) == null || o.call(c);
|
|
295
|
-
}
|
|
296
|
-
}, a = (r, s) => {
|
|
297
|
-
var o, u, h, g;
|
|
298
|
-
const c = (o = r == null ? void 0 : r.GetAttribute) == null ? void 0 : o.call(r, s);
|
|
299
|
-
if (!c) return [];
|
|
300
|
-
try {
|
|
301
|
-
return ((u = c.IsValid) == null ? void 0 : u.call(c)) !== !0 ? [] : (((h = c.GetConnections) == null ? void 0 : h.call(c)) ?? []).map((l) => {
|
|
302
|
-
var p, y;
|
|
303
|
-
if (typeof l == "string") return l;
|
|
304
|
-
const f = String(((p = l.GetString) == null ? void 0 : p.call(l)) ?? l.path ?? "");
|
|
305
|
-
return (y = l.delete) == null || y.call(l), f;
|
|
306
|
-
}).filter(Boolean);
|
|
307
|
-
} finally {
|
|
308
|
-
(g = c.delete) == null || g.call(c);
|
|
309
|
-
}
|
|
310
|
-
}, i = (r) => {
|
|
311
|
-
var c;
|
|
312
|
-
const s = r && ((c = t.UsdShade) != null && c.ComputeBoundMaterialPath) ? t.UsdShade.ComputeBoundMaterialPath(r) : null;
|
|
313
|
-
return s ? {
|
|
314
|
-
found: !0,
|
|
315
|
-
materialPath: String(s.materialPath ?? ""),
|
|
316
|
-
resolvedTargetPath: String(s.resolvedTargetPath ?? ""),
|
|
317
|
-
bindingRelationshipPath: String(s.bindingRelationshipPath ?? "")
|
|
318
|
-
} : { found: !1, materialPath: "", resolvedTargetPath: "", bindingRelationshipPath: "" };
|
|
319
|
-
};
|
|
320
|
-
return {
|
|
321
|
-
async stageMetadata(r) {
|
|
322
|
-
var c;
|
|
323
|
-
const s = e.GetPseudoRoot();
|
|
324
|
-
try {
|
|
325
|
-
const o = s.GetMetadata(r);
|
|
326
|
-
return { valid: !0, found: o != null, value: o };
|
|
327
|
-
} finally {
|
|
328
|
-
(c = s.delete) == null || c.call(s);
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
async primInfo(r) {
|
|
332
|
-
return n(r, (s) => {
|
|
333
|
-
var c, o, u, h;
|
|
334
|
-
return {
|
|
335
|
-
valid: !!s && ((c = s.IsValid) == null ? void 0 : c.call(s)) !== !1,
|
|
336
|
-
name: String(((o = s.GetName) == null ? void 0 : o.call(s)) ?? r.split("/").pop() ?? ""),
|
|
337
|
-
path: r,
|
|
338
|
-
typeName: String(((u = s.GetTypeName) == null ? void 0 : u.call(s)) ?? ""),
|
|
339
|
-
instance: ((h = s.IsInstance) == null ? void 0 : h.call(s)) === !0
|
|
340
|
-
};
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
async primChildren(r) {
|
|
344
|
-
return n(r, (s) => {
|
|
345
|
-
var c;
|
|
346
|
-
return (((c = s.GetChildren) == null ? void 0 : c.call(s)) ?? []).map((o) => {
|
|
347
|
-
var h, g;
|
|
348
|
-
const u = String(o.__path ?? ((h = o.GetPath) == null ? void 0 : h.call(o)) ?? "");
|
|
349
|
-
return (g = o.delete) == null || g.call(o), u;
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
},
|
|
353
|
-
async primDescendants(r, s = "") {
|
|
354
|
-
var c;
|
|
355
|
-
return (((c = e.GetDescendants) == null ? void 0 : c.call(e, r, s)) ?? []).map(String);
|
|
356
|
-
},
|
|
357
|
-
async primAttributes(r) {
|
|
358
|
-
return n(r, (s) => {
|
|
359
|
-
var c;
|
|
360
|
-
return (((c = s.GetAttributes) == null ? void 0 : c.call(s)) ?? []).map((o) => {
|
|
361
|
-
var h, g;
|
|
362
|
-
const u = String(((h = o.GetName) == null ? void 0 : h.call(o)) ?? "");
|
|
363
|
-
return (g = o.delete) == null || g.call(o), u;
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
},
|
|
367
|
-
async primMetadata(r, s) {
|
|
368
|
-
return n(r, (c) => {
|
|
369
|
-
var h;
|
|
370
|
-
const o = (h = c == null ? void 0 : c.GetMetadata) == null ? void 0 : h.call(c, s), u = typeof o == "string" ? o : o && typeof o == "object" && typeof o.string == "string" ? String(o.string) : void 0;
|
|
371
|
-
return {
|
|
372
|
-
valid: !0,
|
|
373
|
-
found: o != null,
|
|
374
|
-
...o != null ? { value: o } : {},
|
|
375
|
-
...u !== void 0 ? { text: u } : {}
|
|
376
|
-
};
|
|
377
|
-
});
|
|
378
|
-
},
|
|
379
|
-
async relationshipTargets(r, s) {
|
|
380
|
-
return n(r, (c) => {
|
|
381
|
-
var u, h, g;
|
|
382
|
-
const o = (u = c == null ? void 0 : c.GetRelationship) == null ? void 0 : u.call(c, s);
|
|
383
|
-
if (!o) return [];
|
|
384
|
-
try {
|
|
385
|
-
return (((h = o.GetTargets) == null ? void 0 : h.call(o)) ?? []).map((l) => {
|
|
386
|
-
var f;
|
|
387
|
-
return typeof l == "string" ? l : String(((f = l.GetString) == null ? void 0 : f.call(l)) ?? l.path ?? "");
|
|
388
|
-
}).filter(Boolean);
|
|
389
|
-
} finally {
|
|
390
|
-
(g = o.delete) == null || g.call(o);
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
},
|
|
394
|
-
async attributeValue(r, s) {
|
|
395
|
-
return n(r, (c) => {
|
|
396
|
-
var u, h, g, l;
|
|
397
|
-
const o = (u = c == null ? void 0 : c.GetAttribute) == null ? void 0 : u.call(c, s);
|
|
398
|
-
if (!o) return { valid: !1, authored: !1, value: null };
|
|
399
|
-
try {
|
|
400
|
-
const f = ((h = o.IsValid) == null ? void 0 : h.call(o)) === !0;
|
|
401
|
-
return {
|
|
402
|
-
valid: f,
|
|
403
|
-
authored: f && ((g = o.HasAuthoredValue) == null ? void 0 : g.call(o)) === !0,
|
|
404
|
-
value: f ? o.Get() : null
|
|
405
|
-
};
|
|
406
|
-
} finally {
|
|
407
|
-
(l = o.delete) == null || l.call(o);
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
},
|
|
411
|
-
async attributeValues(r) {
|
|
412
|
-
const s = {};
|
|
413
|
-
for (const c of r)
|
|
414
|
-
s[c.path] = await n(c.path, (o) => Object.fromEntries(
|
|
415
|
-
c.names.map((u) => {
|
|
416
|
-
var g, l, f, p;
|
|
417
|
-
const h = (g = o == null ? void 0 : o.GetAttribute) == null ? void 0 : g.call(o, u);
|
|
418
|
-
if (!h) return [u, { valid: !1, authored: !1, value: null }];
|
|
419
|
-
try {
|
|
420
|
-
const y = ((l = h.IsValid) == null ? void 0 : l.call(h)) === !0;
|
|
421
|
-
return [u, {
|
|
422
|
-
valid: y,
|
|
423
|
-
authored: y && ((f = h.HasAuthoredValue) == null ? void 0 : f.call(h)) === !0,
|
|
424
|
-
value: y ? h.Get() : null
|
|
425
|
-
}];
|
|
426
|
-
} finally {
|
|
427
|
-
(p = h.delete) == null || p.call(h);
|
|
428
|
-
}
|
|
429
|
-
})
|
|
430
|
-
));
|
|
431
|
-
return s;
|
|
432
|
-
},
|
|
433
|
-
async attributeMetadata(r, s, c) {
|
|
434
|
-
return n(r, (o) => {
|
|
435
|
-
var h, g, l;
|
|
436
|
-
const u = (h = o == null ? void 0 : o.GetAttribute) == null ? void 0 : h.call(o, s);
|
|
437
|
-
if (!u) return { valid: !1, found: !1 };
|
|
438
|
-
try {
|
|
439
|
-
if (((g = u.IsValid) == null ? void 0 : g.call(u)) !== !0) return { valid: !1, found: !1 };
|
|
440
|
-
const f = u.GetMetadata(c);
|
|
441
|
-
return {
|
|
442
|
-
valid: !0,
|
|
443
|
-
found: f != null,
|
|
444
|
-
...f != null ? { value: f } : {}
|
|
445
|
-
};
|
|
446
|
-
} finally {
|
|
447
|
-
(l = u.delete) == null || l.call(u);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
},
|
|
451
|
-
async attributeConnections(r, s) {
|
|
452
|
-
return n(r, (c) => a(c, s));
|
|
453
|
-
},
|
|
454
|
-
async boundMaterial(r) {
|
|
455
|
-
return n(r, i);
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
const vt = /^physics$/i, Pt = /^(newton|mjc|mujoco)(?:[_-]|$)/i, It = /^(physx|newton|mjc|mujoco)(?:[_-]|)/i;
|
|
460
|
-
function At(e, t = []) {
|
|
461
|
-
const n = new Set(t.map(Se)), a = [];
|
|
462
|
-
for (const i of e) {
|
|
463
|
-
if (!vt.test(i.setName) || n.has(Se(i))) continue;
|
|
464
|
-
const r = i.variantNames.map((o, u) => ({ selection: o, index: u, rank: Mt(o) })).filter((o) => o.rank !== null);
|
|
465
|
-
if (r.length === 0 || i.selection && Pt.test(i.selection)) continue;
|
|
466
|
-
const s = ce(i.selection), c = [...r].sort((o, u) => {
|
|
467
|
-
const h = s !== null && ce(o.selection) === s, g = s !== null && ce(u.selection) === s;
|
|
468
|
-
return Number(g) - Number(h) || o.rank - u.rank || o.index - u.index;
|
|
469
|
-
})[0];
|
|
470
|
-
a.push({
|
|
471
|
-
primPath: i.primPath,
|
|
472
|
-
setName: i.setName,
|
|
473
|
-
selection: c.selection
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return a;
|
|
477
|
-
}
|
|
478
|
-
function Mt(e) {
|
|
479
|
-
return /^newton(?:[_-]|$)/i.test(e) ? 0 : /^mjc(?:[_-]|$)/i.test(e) ? 1 : /^mujoco(?:[_-]|$)/i.test(e) ? 2 : null;
|
|
480
|
-
}
|
|
481
|
-
function ce(e) {
|
|
482
|
-
return e && e.replace(It, "").toLowerCase() || null;
|
|
483
|
-
}
|
|
484
|
-
function Se(e) {
|
|
485
|
-
return `${e.primPath}\0${e.setName}`;
|
|
486
|
-
}
|
|
487
|
-
function kt(e) {
|
|
488
|
-
let t = 0;
|
|
489
|
-
const n = () => {
|
|
490
|
-
for (; t < e.length; ) {
|
|
491
|
-
const o = e[t];
|
|
492
|
-
if (/\s/.test(o)) {
|
|
493
|
-
t++;
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
|
-
if (o === "#") {
|
|
497
|
-
for (; t < e.length && e[t] !== `
|
|
498
|
-
`; ) t++;
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
if (o === '"' || o === "@" || o === "<") {
|
|
502
|
-
const h = o === "<" ? ">" : o, g = o === '"' && e.slice(t, t + 3) === '"""';
|
|
503
|
-
t += g ? 3 : 1;
|
|
504
|
-
const l = t;
|
|
505
|
-
for (; t < e.length; ) {
|
|
506
|
-
if (e[t] === "\\") {
|
|
507
|
-
t += 2;
|
|
508
|
-
continue;
|
|
509
|
-
}
|
|
510
|
-
if (g ? e.slice(t, t + 3) === '"""' : e[t] === h) {
|
|
511
|
-
const f = e.slice(l, t);
|
|
512
|
-
return t += g ? 3 : 1, { kind: o === "<" ? "path" : "string", value: f };
|
|
513
|
-
}
|
|
514
|
-
t++;
|
|
515
|
-
}
|
|
516
|
-
throw new Error("Unterminated USDA string or path");
|
|
517
|
-
}
|
|
518
|
-
if ("{}()[]=,".includes(o))
|
|
519
|
-
return t++, { kind: "symbol", value: o };
|
|
520
|
-
const u = t;
|
|
521
|
-
for (; t < e.length && !/[\s{}()\[\]=,<>"@#]/.test(e[t]); ) t++;
|
|
522
|
-
if (u === t) {
|
|
523
|
-
t++;
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
return { kind: "word", value: e.slice(u, t) };
|
|
527
|
-
}
|
|
528
|
-
}, a = () => {
|
|
529
|
-
let o = 1, u;
|
|
530
|
-
for (; o && (u = n()); )
|
|
531
|
-
u.value === "[" && u.kind === "symbol" ? o++ : u.value === "]" && u.kind === "symbol" && o--;
|
|
532
|
-
if (o) throw new Error("Unterminated USDA list");
|
|
533
|
-
}, i = () => {
|
|
534
|
-
let o = 1, u;
|
|
535
|
-
for (; o && (u = n()); )
|
|
536
|
-
u.value === "{" && u.kind === "symbol" ? o++ : u.value === "}" && u.kind === "symbol" && o--;
|
|
537
|
-
if (o) throw new Error("Unterminated USDA dictionary");
|
|
538
|
-
}, r = /* @__PURE__ */ new Map(), s = [];
|
|
539
|
-
let c;
|
|
540
|
-
for (; c = n(); ) {
|
|
541
|
-
if (c.kind !== "word") {
|
|
542
|
-
c.kind === "symbol" && c.value === "[" ? a() : c.kind === "symbol" && c.value === "{" ? i() : c.kind === "symbol" && c.value === "}" && s.pop();
|
|
543
|
-
continue;
|
|
544
|
-
}
|
|
545
|
-
if (["def", "over", "class"].includes(c.value)) {
|
|
546
|
-
const l = n(), f = (l == null ? void 0 : l.kind) === "string" ? l : n();
|
|
547
|
-
if (!f || f.kind !== "string") throw new Error("Invalid USDA prim header");
|
|
548
|
-
const p = [...s].reverse().find(Boolean), y = `${(p == null ? void 0 : p.path) ?? ""}/${f.value}`, w = { schemas: [], relationships: /* @__PURE__ */ new Map() };
|
|
549
|
-
let d, m = 0;
|
|
550
|
-
for (; (d = n()) && !(d.kind === "symbol" && d.value === "{" && m === 0); ) {
|
|
551
|
-
if (d.kind === "symbol" && d.value === "(") m++;
|
|
552
|
-
else if (d.kind === "symbol" && d.value === ")") m--;
|
|
553
|
-
else if (d.kind === "symbol" && d.value === "{") {
|
|
554
|
-
i();
|
|
555
|
-
continue;
|
|
556
|
-
}
|
|
557
|
-
if (d.kind === "word" && d.value === "apiSchemas") {
|
|
558
|
-
const S = n(), b = n();
|
|
559
|
-
if ((S == null ? void 0 : S.value) !== "=") throw new Error("Invalid USDA apiSchemas");
|
|
560
|
-
if ((b == null ? void 0 : b.kind) === "word" && b.value === "None") continue;
|
|
561
|
-
if ((b == null ? void 0 : b.value) !== "[") throw new Error(`Invalid USDA apiSchemas at ${y}: ${b == null ? void 0 : b.value}`);
|
|
562
|
-
for (; (d = n()) && d.value !== "]"; )
|
|
563
|
-
d.kind === "string" && d.value.startsWith("PhysxMimicJointAPI:") && w.schemas.push(d.value);
|
|
564
|
-
if (!d) throw new Error("Unterminated USDA apiSchemas");
|
|
565
|
-
} else d.value === "[" && d.kind === "symbol" && a();
|
|
566
|
-
}
|
|
567
|
-
if (!d) throw new Error("Unterminated USDA prim header");
|
|
568
|
-
r.set(y, w), s.push({ path: y, prim: w });
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
if (c.value !== "rel" || !s.at(-1)) continue;
|
|
572
|
-
const o = n();
|
|
573
|
-
if (!o || o.kind !== "word" || !/^physxMimicJoint:[^:]+:referenceJoint$/.test(o.value)) continue;
|
|
574
|
-
const u = n(), h = n();
|
|
575
|
-
if ((u == null ? void 0 : u.value) !== "=" || !h) continue;
|
|
576
|
-
const g = [];
|
|
577
|
-
if (h.kind === "path") g.push(h.value);
|
|
578
|
-
else if (h.value === "[") {
|
|
579
|
-
let l;
|
|
580
|
-
for (; (l = n()) && l.value !== "]"; ) l.kind === "path" && g.push(l.value);
|
|
581
|
-
if (!l) throw new Error("Unterminated USDA relationship");
|
|
582
|
-
}
|
|
583
|
-
s.at(-1).prim.relationships.set(o.value, g);
|
|
584
|
-
}
|
|
585
|
-
return new Map([...r].filter(([, o]) => o.schemas.length || o.relationships.size));
|
|
586
|
-
}
|
|
587
|
-
const xt = [
|
|
588
|
-
1,
|
|
589
|
-
0,
|
|
590
|
-
0,
|
|
591
|
-
0,
|
|
592
|
-
0,
|
|
593
|
-
1,
|
|
594
|
-
0,
|
|
595
|
-
0,
|
|
596
|
-
0,
|
|
597
|
-
0,
|
|
598
|
-
1,
|
|
599
|
-
0,
|
|
600
|
-
0,
|
|
601
|
-
0,
|
|
602
|
-
0,
|
|
603
|
-
1
|
|
604
|
-
];
|
|
605
|
-
function Rt(e) {
|
|
606
|
-
const t = new Map(e.map((r) => [r.path, r])), n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), i = (r) => {
|
|
607
|
-
const s = n.get(r.path);
|
|
608
|
-
if (s) return s;
|
|
609
|
-
if (a.has(r.path)) return Ue(r.localMatrix);
|
|
610
|
-
a.add(r.path);
|
|
611
|
-
const c = Ue(r.localMatrix), o = r.parentPath ? t.get(r.parentPath) : void 0, u = !o || r.resetsXformStack ? c : Ee(c, i(o));
|
|
612
|
-
return a.delete(r.path), n.set(r.path, u), u;
|
|
613
|
-
};
|
|
614
|
-
return e.map((r) => {
|
|
615
|
-
if (!r.resetsXformStack || !r.parentPath) return r;
|
|
616
|
-
const s = t.get(r.parentPath);
|
|
617
|
-
if (!s) return r;
|
|
618
|
-
const c = i(s), o = Nt(c);
|
|
619
|
-
return o ? {
|
|
620
|
-
...r,
|
|
621
|
-
localMatrix: Ee(i(r), o)
|
|
622
|
-
} : r;
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
function Ue(e) {
|
|
626
|
-
return Dt(e) ? e : xt;
|
|
627
|
-
}
|
|
628
|
-
function Dt(e) {
|
|
629
|
-
return (e == null ? void 0 : e.length) === 16 && e.every(Number.isFinite);
|
|
630
|
-
}
|
|
631
|
-
function Ee(e, t) {
|
|
632
|
-
const n = new Array(16);
|
|
633
|
-
for (let a = 0; a < 4; a++)
|
|
634
|
-
for (let i = 0; i < 4; i++) {
|
|
635
|
-
let r = 0;
|
|
636
|
-
for (let s = 0; s < 4; s++)
|
|
637
|
-
r += e[a * 4 + s] * t[s * 4 + i];
|
|
638
|
-
n[a * 4 + i] = r;
|
|
639
|
-
}
|
|
640
|
-
return n;
|
|
641
|
-
}
|
|
642
|
-
function Nt(e) {
|
|
643
|
-
const [
|
|
644
|
-
t,
|
|
645
|
-
n,
|
|
646
|
-
a,
|
|
647
|
-
,
|
|
648
|
-
i,
|
|
649
|
-
r,
|
|
650
|
-
s,
|
|
651
|
-
,
|
|
652
|
-
c,
|
|
653
|
-
o,
|
|
654
|
-
u,
|
|
655
|
-
,
|
|
656
|
-
h,
|
|
657
|
-
g,
|
|
658
|
-
l
|
|
659
|
-
] = e, f = r * u - s * o, p = a * o - n * u, y = n * s - a * r, w = t * f + i * p + c * y, d = Math.max(
|
|
660
|
-
Math.abs(t * r * u),
|
|
661
|
-
Math.abs(t * s * o),
|
|
662
|
-
Math.abs(n * i * u),
|
|
663
|
-
Math.abs(n * s * c),
|
|
664
|
-
Math.abs(a * i * o),
|
|
665
|
-
Math.abs(a * r * c),
|
|
666
|
-
1
|
|
667
|
-
);
|
|
668
|
-
if (!Number.isFinite(w) || Math.abs(w) <= Number.EPSILON * d * 16)
|
|
669
|
-
return null;
|
|
670
|
-
const m = 1 / w, S = f * m, b = p * m, k = y * m, j = (s * c - i * u) * m, V = (t * u - a * c) * m, G = (a * i - t * s) * m, U = (i * o - r * c) * m, A = (n * c - t * o) * m, E = (t * r - n * i) * m;
|
|
671
|
-
return [
|
|
672
|
-
S,
|
|
673
|
-
b,
|
|
674
|
-
k,
|
|
675
|
-
0,
|
|
676
|
-
j,
|
|
677
|
-
V,
|
|
678
|
-
G,
|
|
679
|
-
0,
|
|
680
|
-
U,
|
|
681
|
-
A,
|
|
682
|
-
E,
|
|
683
|
-
0,
|
|
684
|
-
-(h * S + g * j + l * U),
|
|
685
|
-
-(h * b + g * V + l * A),
|
|
686
|
-
-(h * k + g * G + l * E),
|
|
687
|
-
1
|
|
688
|
-
];
|
|
689
|
-
}
|
|
690
|
-
function Tt(e, t = []) {
|
|
691
|
-
return {
|
|
692
|
-
stage: e.stage,
|
|
693
|
-
view: {
|
|
694
|
-
...e.view,
|
|
695
|
-
prims: Rt(e.view.prims)
|
|
696
|
-
},
|
|
697
|
-
elements: e.elements,
|
|
698
|
-
materials: e.materials,
|
|
699
|
-
materialAliases: e.materialAliases,
|
|
700
|
-
physics: Ot(),
|
|
701
|
-
joints: [],
|
|
702
|
-
cameras: [],
|
|
703
|
-
lights: [],
|
|
704
|
-
skels: e.skels,
|
|
705
|
-
animations: e.animations,
|
|
706
|
-
variants: t
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
function $t(e, t) {
|
|
710
|
-
e.physics = t.physics, e.joints = t.joints;
|
|
711
|
-
}
|
|
712
|
-
function Ot() {
|
|
713
|
-
return {
|
|
714
|
-
scenes: [],
|
|
715
|
-
rigidBodies: [],
|
|
716
|
-
colliders: [],
|
|
717
|
-
materials: [],
|
|
718
|
-
articulationRoots: []
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
const Lt = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
|
|
722
|
-
async function Ct(e) {
|
|
723
|
-
const t = await import(
|
|
724
|
-
/* @vite-ignore */
|
|
725
|
-
e.moduleUrl
|
|
726
|
-
), n = t.default ?? t.createOpenUsdProbe, a = e.wasmModule ? {
|
|
727
|
-
instantiateWasm(w, d) {
|
|
728
|
-
return Et(e.wasmModule, w, d);
|
|
729
|
-
}
|
|
730
|
-
} : {
|
|
731
|
-
wasmBinary: await (typeof e.wasmBinary == "function" ? e.wasmBinary() : e.wasmBinary ?? Xt(e.wasmUrl))
|
|
732
|
-
}, i = await n(a), r = e.apiVersion ?? St.apiVersion, s = Number(i.ccall("usd_probe_api_version", "number", [], []));
|
|
733
|
-
if (s !== r)
|
|
734
|
-
throw Object.assign(
|
|
735
|
-
new Error(`OpenUSD runtime API mismatch: expected ${r}, received ${s}.`),
|
|
736
|
-
{ code: "E_USD_RUNTIME_VERSION" }
|
|
737
|
-
);
|
|
738
|
-
const c = e.memfsRoot ?? "/asset", o = e.fetchBytes ?? (async (w) => {
|
|
739
|
-
const d = await fetch(w);
|
|
740
|
-
if (!d.ok) throw Object.assign(new Error(`USD resource request failed (${d.status}): ${w}`), {
|
|
741
|
-
code: d.status === 401 || d.status === 403 ? "E_ASSET_AUTH" : "E_ASSET_FETCH"
|
|
742
|
-
});
|
|
743
|
-
const m = new Uint8Array(await d.arrayBuffer()), S = Ke(d.headers.get("content-type"), m);
|
|
744
|
-
if (S) throw Je(`USD resource is not usable (${S}): ${w}`, Me);
|
|
745
|
-
return m;
|
|
746
|
-
}), u = (w, d, m) => JSON.parse(i.ccall(w, "string", d, m)), h = /* @__PURE__ */ new Set(), g = ve(i);
|
|
747
|
-
let l = 0, f = null;
|
|
748
|
-
async function p() {
|
|
749
|
-
return f || (f = (async () => {
|
|
750
|
-
const w = `${c}/__viewer_warmup__`, d = `${w}/empty.usda`;
|
|
751
|
-
i.FS.mkdirTree(w), i.FS.writeFile(d, new TextEncoder().encode(`#usda 1.0
|
|
752
|
-
`));
|
|
753
|
-
let m;
|
|
754
|
-
try {
|
|
755
|
-
const S = u("usd_probe_stage_open", ["string"], [d]);
|
|
756
|
-
if (S.ok !== !0 || S.stageId === void 0)
|
|
757
|
-
throw new Error(S.error ?? "Failed to initialize the USD Stage runtime.");
|
|
758
|
-
m = S.stageId;
|
|
759
|
-
} finally {
|
|
760
|
-
m !== void 0 && u("usd_probe_stage_release", ["number"], [m]), i.FS.analyzePath(d, !0).exists && i.FS.unlink(d);
|
|
761
|
-
}
|
|
762
|
-
})(), f);
|
|
763
|
-
}
|
|
764
|
-
async function y(w, d) {
|
|
765
|
-
const m = new URL(d.sourcePath, "file:///"), S = `${c}/load-${++l}`, b = J(m.href, S), k = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map(), G = d.readTextureBytes ?? !0, U = d.collectTextureUrls ?? !G, A = U || G ? De : Ht, E = /* @__PURE__ */ new Map();
|
|
766
|
-
let z, x = null, P = null;
|
|
767
|
-
const M = () => {
|
|
768
|
-
z !== void 0 && h.delete(z) && u("usd_probe_stage_release", ["number"], [z]), x == null || x.dispose(), $e(i.FS, S);
|
|
769
|
-
};
|
|
770
|
-
try {
|
|
771
|
-
const T = await Ie(w);
|
|
772
|
-
de(i, b, T, k), j.set(b, A(T));
|
|
773
|
-
for (const [_, I] of Object.entries(d.files ?? {})) {
|
|
774
|
-
const v = J(new URL(_, m).href, S), F = await Ie(I);
|
|
775
|
-
k.has(v) || j.set(v, A(F)), de(i, v, F, k);
|
|
776
|
-
}
|
|
777
|
-
const H = new Set(k);
|
|
778
|
-
for (const _ of d.packagePaths ?? [])
|
|
779
|
-
H.add(J(new URL(_, m).href, S));
|
|
780
|
-
const O = d.externalReferenceMode ?? "complete", L = it(T) ? await ct(T, { include: ke }) : null;
|
|
781
|
-
let B = {};
|
|
782
|
-
if (!L && d.autoResolveAssets !== !1) {
|
|
783
|
-
const _ = d.resolveBytes ?? ((I) => o(I));
|
|
784
|
-
B = await Bt(
|
|
785
|
-
i,
|
|
786
|
-
m,
|
|
787
|
-
S,
|
|
788
|
-
_,
|
|
789
|
-
u,
|
|
790
|
-
k,
|
|
791
|
-
E,
|
|
792
|
-
U ? V : null,
|
|
793
|
-
j,
|
|
794
|
-
d.maxFiles ?? 1024,
|
|
795
|
-
d.maxDepth ?? 8,
|
|
796
|
-
d.maxConcurrency ?? 1,
|
|
797
|
-
O,
|
|
798
|
-
H,
|
|
799
|
-
G,
|
|
800
|
-
d.onReferenceSkipped,
|
|
801
|
-
d.onResourceFailed
|
|
802
|
-
);
|
|
803
|
-
}
|
|
804
|
-
x = L ? ut(L) : null;
|
|
805
|
-
const Z = d.textureResolver || x ? (_) => {
|
|
806
|
-
var I;
|
|
807
|
-
return ((I = d.textureResolver) == null ? void 0 : I.call(d, _)) ?? (x == null ? void 0 : x.resolve(_)) ?? null;
|
|
808
|
-
} : void 0, R = Object.keys(B).length > 0;
|
|
809
|
-
if (R && typeof i._usd_probe_stage_open_mapped != "function")
|
|
810
|
-
throw Object.assign(new Error("USD dependency mapping requires the matching packaged openusd_probe.js and .wasm runtime."), { code: "E_USD_RUNTIME_VERSION" });
|
|
811
|
-
const D = R ? u("usd_probe_stage_open_mapped", ["string", "string"], [b, JSON.stringify(B)]) : u("usd_probe_stage_open", ["string"], [b]);
|
|
812
|
-
if (!D.ok) throw new Error(D.error ?? `Failed to open ${b}`);
|
|
813
|
-
z = D.stageId, h.add(D.stageId);
|
|
814
|
-
const $ = d.variantSelections ?? [];
|
|
815
|
-
let ne = [], W = $;
|
|
816
|
-
if (d.selectMuJoCoPhysicsVariant !== !1) {
|
|
817
|
-
if (typeof i._usd_probe_stage_variants != "function")
|
|
818
|
-
throw Object.assign(
|
|
819
|
-
new Error("USD variant discovery requires the matching packaged openusd_probe runtime."),
|
|
820
|
-
{ code: "E_USD_RUNTIME_VERSION" }
|
|
821
|
-
);
|
|
822
|
-
const _ = u("usd_probe_stage_variants", ["number"], [D.stageId]);
|
|
823
|
-
if (_.ok !== !0)
|
|
824
|
-
throw new Error(String(_.error ?? "Failed to enumerate USD variants."));
|
|
825
|
-
ne = _.variants ?? [], W = [
|
|
826
|
-
...$,
|
|
827
|
-
...At(ne, $)
|
|
828
|
-
];
|
|
829
|
-
}
|
|
830
|
-
for (const _ of W) {
|
|
831
|
-
const I = u(
|
|
832
|
-
"usd_probe_stage_set_variant",
|
|
833
|
-
["number", "string", "string", "string"],
|
|
834
|
-
[D.stageId, _.primPath, _.setName, _.selection]
|
|
835
|
-
);
|
|
836
|
-
if (I.ok !== !0)
|
|
837
|
-
throw new Error(String(I.error ?? `Failed to select USD variant ${_.primPath}:${_.setName}=${_.selection}`));
|
|
838
|
-
}
|
|
839
|
-
const re = ve(i, E, b), se = re.openStage(D.stageId);
|
|
840
|
-
if (d.selectMuJoCoPhysicsVariant !== !1) {
|
|
841
|
-
const _ = new Set($.map(ue)), I = /* @__PURE__ */ new Set();
|
|
842
|
-
for (const v of W) {
|
|
843
|
-
const F = ue(v);
|
|
844
|
-
if (_.has(F)) continue;
|
|
845
|
-
const C = ne.find((ge) => ge.primPath === v.primPath && ge.setName === v.setName);
|
|
846
|
-
if (!(C != null && C.selection) || C.selection === v.selection || se.GetDescendants(v.primPath, "MjcActuator").length === 0) continue;
|
|
847
|
-
const pe = u(
|
|
848
|
-
"usd_probe_stage_set_variant",
|
|
849
|
-
["number", "string", "string", "string"],
|
|
850
|
-
[D.stageId, v.primPath, v.setName, C.selection]
|
|
851
|
-
);
|
|
852
|
-
if (pe.ok !== !0)
|
|
853
|
-
throw new Error(String(pe.error ?? `Failed to restore authored USD variant ${v.primPath}:${v.setName}=${C.selection}`));
|
|
854
|
-
I.add(F);
|
|
855
|
-
}
|
|
856
|
-
I.size > 0 && (W = W.filter((v) => !I.has(ue(v))));
|
|
857
|
-
}
|
|
858
|
-
const fe = await jt(i, D.stageId, b, {
|
|
859
|
-
batchSize: d.geometryBatchSize,
|
|
860
|
-
onProgress: d.onGeometryProgress
|
|
861
|
-
});
|
|
862
|
-
Te(fe.materials, E);
|
|
863
|
-
const Oe = new Map(W.map((_) => [
|
|
864
|
-
`${_.primPath}\0${_.setName}`,
|
|
865
|
-
_.selection
|
|
866
|
-
])), Le = ne.map((_) => ({
|
|
867
|
-
..._,
|
|
868
|
-
selection: Oe.get(`${_.primPath}\0${_.setName}`) ?? _.selection
|
|
869
|
-
})), ae = Tt(fe, Le), he = L ? void 0 : d.isTextureAllowed ?? (O === "package" ? (_) => {
|
|
870
|
-
const I = new URL(_, m);
|
|
871
|
-
return H.has(J(I.href, S)) || Ae(I, m);
|
|
872
|
-
} : void 0);
|
|
873
|
-
return {
|
|
874
|
-
data: ae,
|
|
875
|
-
pxr: re,
|
|
876
|
-
stage: se,
|
|
877
|
-
entryPath: b,
|
|
878
|
-
textureURLs: V,
|
|
879
|
-
buildModel: async () => {
|
|
880
|
-
const { createUSDLoadedModel: _ } = await import("@openusd-wasm/three-loader"), I = () => _(
|
|
881
|
-
ae,
|
|
882
|
-
re,
|
|
883
|
-
b,
|
|
884
|
-
{
|
|
885
|
-
sourcePath: d.sourcePath,
|
|
886
|
-
// The Viewer normalises USD to world Z-up and draws its own studio
|
|
887
|
-
// lighting. Textures remain enabled unless the host explicitly
|
|
888
|
-
// injects its own loader/cache.
|
|
889
|
-
convertZUp: d.convertZUp ?? !1,
|
|
890
|
-
loadLights: d.loadLights ?? !1,
|
|
891
|
-
loadTextures: d.loadTextures ?? !0,
|
|
892
|
-
...d.textureLoader ? { textureLoader: d.textureLoader } : {},
|
|
893
|
-
...d.textureCache ? { textureCache: d.textureCache } : {},
|
|
894
|
-
...Z ? { textureResolver: Z } : {}
|
|
895
|
-
},
|
|
896
|
-
se,
|
|
897
|
-
{
|
|
898
|
-
// Keep package texture identities on the model so the visual adapter
|
|
899
|
-
// can resolve textures referenced by unsupported-but-known MDL nodes.
|
|
900
|
-
usdzTextureURLs: (x == null ? void 0 : x.urls) ?? /* @__PURE__ */ new Map(),
|
|
901
|
-
autoTextureURLs: /* @__PURE__ */ new Map()
|
|
902
|
-
}
|
|
903
|
-
), v = he ? je(ae.materials, he, I) : I();
|
|
904
|
-
v.usdQuery = Re(se, re);
|
|
905
|
-
const F = v.dispose.bind(v);
|
|
906
|
-
let C = !1;
|
|
907
|
-
return v.dispose = () => {
|
|
908
|
-
C || (C = !0, F(), M());
|
|
909
|
-
}, v;
|
|
910
|
-
},
|
|
911
|
-
readPhysics() {
|
|
912
|
-
return P || (P = (async () => {
|
|
913
|
-
if (typeof i._usd_probe_scene_physics != "function")
|
|
914
|
-
throw Object.assign(
|
|
915
|
-
new Error("USD physics phase requires the matching packaged openusd_probe runtime."),
|
|
916
|
-
{ code: "E_USD_RUNTIME_VERSION" }
|
|
917
|
-
);
|
|
918
|
-
const _ = u("usd_probe_scene_physics", ["number"], [D.stageId]);
|
|
919
|
-
if (_.ok !== !0) throw new Error(String(_.error ?? "Failed to extract USD physics."));
|
|
920
|
-
return _;
|
|
921
|
-
})(), P);
|
|
922
|
-
},
|
|
923
|
-
release: M
|
|
924
|
-
};
|
|
925
|
-
} catch (T) {
|
|
926
|
-
throw M(), T;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
return {
|
|
930
|
-
runtime: i,
|
|
931
|
-
pxr: g,
|
|
932
|
-
warmup: p,
|
|
933
|
-
async parseAsync(w, d) {
|
|
934
|
-
const m = await y(w, d);
|
|
935
|
-
try {
|
|
936
|
-
return $t(m.data, await m.readPhysics()), await m.buildModel();
|
|
937
|
-
} catch (S) {
|
|
938
|
-
throw m.release(), S;
|
|
939
|
-
}
|
|
940
|
-
},
|
|
941
|
-
async parseVisualSceneAsync(w, d) {
|
|
942
|
-
return await y(w, d);
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
}
|
|
946
|
-
function ve(e, t = /* @__PURE__ */ new Map(), n) {
|
|
947
|
-
const a = (l, f, p) => JSON.parse(e.ccall(l, "string", f, p));
|
|
948
|
-
class i {
|
|
949
|
-
constructor(f) {
|
|
950
|
-
this.path = f;
|
|
951
|
-
}
|
|
952
|
-
GetString() {
|
|
953
|
-
return this.path;
|
|
954
|
-
}
|
|
955
|
-
delete() {
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
let r;
|
|
959
|
-
const s = /* @__PURE__ */ new Map(), c = (l, f) => {
|
|
960
|
-
if (!r) {
|
|
961
|
-
const S = e._usd_probe_flatten_stage;
|
|
962
|
-
if (n && typeof S == "function") {
|
|
963
|
-
const b = e.ccall("usd_probe_flatten_stage", "string", ["string"], [n]);
|
|
964
|
-
if (typeof b != "string" || !b.startsWith("#usda")) throw new Error("Unable to read flattened USD joint metadata");
|
|
965
|
-
r = kt(b);
|
|
966
|
-
} else
|
|
967
|
-
r = /* @__PURE__ */ new Map();
|
|
968
|
-
}
|
|
969
|
-
const p = r.get(f);
|
|
970
|
-
if (p || s.has(f)) return p ?? s.get(f);
|
|
971
|
-
const y = ["rotX", "rotY", "rotZ", "transX", "transY", "transZ", "X", "Y", "Z"], w = [], d = /* @__PURE__ */ new Map();
|
|
972
|
-
for (const S of y) {
|
|
973
|
-
const b = `physxMimicJoint:${S}:referenceJoint`, k = a("usd_probe_relationship_targets", ["number", "string", "string"], [l, f, b]).paths ?? [];
|
|
974
|
-
k.length && (w.push(`PhysxMimicJointAPI:${S}`), d.set(b, k));
|
|
975
|
-
}
|
|
976
|
-
const m = w.length ? { schemas: w, relationships: d } : void 0;
|
|
977
|
-
return m && s.set(f, m), m;
|
|
978
|
-
}, o = (l, f, p) => {
|
|
979
|
-
let y = null;
|
|
980
|
-
const w = () => y ?? (y = a(
|
|
981
|
-
"usd_probe_attribute_value",
|
|
982
|
-
["number", "string", "string"],
|
|
983
|
-
[l, f, p]
|
|
984
|
-
));
|
|
985
|
-
return {
|
|
986
|
-
IsValid: () => w().valid === !0,
|
|
987
|
-
Get: () => {
|
|
988
|
-
const d = w();
|
|
989
|
-
return d.valid === !0 ? typeof d.value == "string" ? t.get(d.value) ?? d.value : d.value : null;
|
|
990
|
-
},
|
|
991
|
-
HasAuthoredValue: () => w().authored === !0,
|
|
992
|
-
GetName: () => p,
|
|
993
|
-
GetMetadata: (d) => {
|
|
994
|
-
const m = a("usd_probe_attribute_metadata", ["number", "string", "string", "string"], [l, f, p, d]);
|
|
995
|
-
return m.valid === !0 && m.found === !0 ? m.value ?? null : null;
|
|
996
|
-
},
|
|
997
|
-
// The viewer accepts either plain strings or objects with GetString().
|
|
998
|
-
GetConnections: () => a("usd_probe_attribute_connections", ["number", "string", "string"], [l, f, p]).paths ?? [],
|
|
999
|
-
delete: () => {
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
}, u = (l, f) => ({
|
|
1003
|
-
__path: f,
|
|
1004
|
-
__stageId: l,
|
|
1005
|
-
IsValid: () => a("usd_probe_prim_info", ["number", "string"], [l, f]).valid === !0,
|
|
1006
|
-
GetName: () => String(f.split("/").pop() ?? ""),
|
|
1007
|
-
GetPath: () => new i(f),
|
|
1008
|
-
GetTypeName: () => String(a("usd_probe_prim_info", ["number", "string"], [l, f]).typeName ?? ""),
|
|
1009
|
-
IsInstance: () => a("usd_probe_prim_info", ["number", "string"], [l, f]).instance === !0,
|
|
1010
|
-
GetAppliedSchemas: () => {
|
|
1011
|
-
var p;
|
|
1012
|
-
return ((p = c(l, f)) == null ? void 0 : p.schemas) ?? [];
|
|
1013
|
-
},
|
|
1014
|
-
GetRelationships: () => {
|
|
1015
|
-
var p;
|
|
1016
|
-
return [...((p = c(l, f)) == null ? void 0 : p.relationships) ?? []].map(([y, w]) => ({
|
|
1017
|
-
GetName: () => y,
|
|
1018
|
-
GetTargets: () => w.map((d) => new i(d)),
|
|
1019
|
-
delete: () => {
|
|
1020
|
-
}
|
|
1021
|
-
}));
|
|
1022
|
-
},
|
|
1023
|
-
GetAttribute: (p) => o(l, f, p),
|
|
1024
|
-
GetAttributes: () => (a("usd_probe_prim_attributes", ["number", "string"], [l, f]).names ?? []).map((p) => o(l, f, p)),
|
|
1025
|
-
GetChildren: () => (a("usd_probe_prim_children", ["number", "string"], [l, f]).paths ?? []).map((p) => u(l, p)),
|
|
1026
|
-
GetRelationship: (p) => {
|
|
1027
|
-
const y = a(
|
|
1028
|
-
"usd_probe_relationship_targets",
|
|
1029
|
-
["number", "string", "string"],
|
|
1030
|
-
[l, f, p]
|
|
1031
|
-
).paths ?? [];
|
|
1032
|
-
return {
|
|
1033
|
-
GetName: () => p,
|
|
1034
|
-
GetTargets: () => y.map((w) => new i(w)),
|
|
1035
|
-
delete: () => {
|
|
1036
|
-
}
|
|
1037
|
-
};
|
|
1038
|
-
},
|
|
1039
|
-
GetMetadata: (p) => {
|
|
1040
|
-
const y = a("usd_probe_prim_metadata", ["number", "string", "string"], [l, f, p]);
|
|
1041
|
-
return y.valid !== !0 ? null : typeof y.text == "string" ? y.text : y.found === !0 ? y.value : null;
|
|
1042
|
-
},
|
|
1043
|
-
delete: () => {
|
|
1044
|
-
}
|
|
1045
|
-
}), h = (l) => ({
|
|
1046
|
-
GetPrimAtPath: (f) => u(l, typeof f == "string" ? f : f.path),
|
|
1047
|
-
GetPseudoRoot: () => Object.assign(u(l, "/"), {
|
|
1048
|
-
// Stage-level metadata (metersPerUnit, upAxis, defaultPrim) is authored on
|
|
1049
|
-
// the layer, not composed onto the pseudo-root prim.
|
|
1050
|
-
GetMetadata: (f) => {
|
|
1051
|
-
const p = a("usd_probe_stage_metadata", ["number", "string"], [l, f]);
|
|
1052
|
-
return p.found === !0 ? p.value : null;
|
|
1053
|
-
},
|
|
1054
|
-
GetName: () => "",
|
|
1055
|
-
IsValid: () => !0
|
|
1056
|
-
}),
|
|
1057
|
-
GetDescendants: (f, p = "") => a(
|
|
1058
|
-
"usd_probe_prim_descendants",
|
|
1059
|
-
["number", "string", "string"],
|
|
1060
|
-
[l, f, p]
|
|
1061
|
-
).paths ?? [],
|
|
1062
|
-
delete: () => {
|
|
1063
|
-
}
|
|
1064
|
-
}), { FS: g } = e;
|
|
1065
|
-
return {
|
|
1066
|
-
FS: {
|
|
1067
|
-
createDir: (l) => g.mkdirTree(l),
|
|
1068
|
-
writeFile: (l, f) => g.writeFile(l, f),
|
|
1069
|
-
exists: (l) => g.analyzePath(l, !0).exists,
|
|
1070
|
-
listDir: (l) => g.readdir(l).filter((f) => f !== "." && f !== "..").map((f) => {
|
|
1071
|
-
const p = `${l.replace(/\/+$/, "")}/${f}`;
|
|
1072
|
-
return { path: p, name: f, isDir: g.isDir(g.stat(p).mode) };
|
|
1073
|
-
}),
|
|
1074
|
-
deleteFile: (l) => g.unlink(l),
|
|
1075
|
-
deleteDir: (l) => g.rmdir(l)
|
|
1076
|
-
},
|
|
1077
|
-
Sdf: { Path: i },
|
|
1078
|
-
Usd: { TimeCode: { Default: () => ({ delete: () => {
|
|
1079
|
-
} }) } },
|
|
1080
|
-
UsdShade: {
|
|
1081
|
-
ComputeBoundMaterialPath: (l) => {
|
|
1082
|
-
const f = a("usd_probe_bound_material", ["number", "string"], [l.__stageId, l.__path]);
|
|
1083
|
-
return f.found !== !0 ? null : {
|
|
1084
|
-
materialPath: String(f.materialPath ?? ""),
|
|
1085
|
-
resolvedTargetPath: String(f.resolvedTargetPath ?? ""),
|
|
1086
|
-
bindingRelationshipPath: String(f.bindingRelationshipPath ?? "")
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
},
|
|
1090
|
-
UsdUtils: {
|
|
1091
|
-
ExtractSanitizedExternalReferences: (l) => a("usd_probe_external_references", ["string"], [l]).paths ?? []
|
|
1092
|
-
},
|
|
1093
|
-
openStage: h
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
async function jt(e, t, n, a = {}) {
|
|
1097
|
-
var c;
|
|
1098
|
-
if (typeof e._usd_probe_scene_visual != "function" || typeof e._usd_probe_scene_geometry != "function" || typeof e._usd_probe_scene_geometry_end != "function")
|
|
1099
|
-
throw Object.assign(
|
|
1100
|
-
new Error("USD visual phases require the matching packaged openusd_probe runtime."),
|
|
1101
|
-
{ code: "E_USD_RUNTIME_VERSION" }
|
|
1102
|
-
);
|
|
1103
|
-
const i = JSON.parse(e.ccall(
|
|
1104
|
-
"usd_probe_scene_visual",
|
|
1105
|
-
"string",
|
|
1106
|
-
["number", "string"],
|
|
1107
|
-
[t, n]
|
|
1108
|
-
));
|
|
1109
|
-
if (i.error) throw new Error(i.error);
|
|
1110
|
-
const r = i, s = Math.max(1, Math.floor(a.batchSize ?? 8));
|
|
1111
|
-
try {
|
|
1112
|
-
for (const [o, u] of r.elements.entries()) {
|
|
1113
|
-
const g = u.geometry.streamIndex;
|
|
1114
|
-
if (!Number.isInteger(g))
|
|
1115
|
-
throw new Error(`USD scene geometry is missing a stream index for ${u.path}`);
|
|
1116
|
-
const l = JSON.parse(e.ccall(
|
|
1117
|
-
"usd_probe_scene_geometry",
|
|
1118
|
-
"string",
|
|
1119
|
-
["number", "number"],
|
|
1120
|
-
[t, g]
|
|
1121
|
-
));
|
|
1122
|
-
if (!l.ok) throw new Error(l.error ?? `Failed to stream USD geometry for ${u.path}`);
|
|
1123
|
-
u.geometry = Object.fromEntries(
|
|
1124
|
-
Object.entries(l.geometry ?? {}).map(([f, p]) => [f, Gt(e, p)])
|
|
1125
|
-
), (c = a.onProgress) == null || c.call(a, o + 1, r.elements.length, u.path), (o + 1) % s === 0 && await Vt();
|
|
1126
|
-
}
|
|
1127
|
-
} finally {
|
|
1128
|
-
e.ccall("usd_probe_scene_geometry_end", "string", ["number"], [t]);
|
|
1129
|
-
}
|
|
1130
|
-
return r;
|
|
1131
|
-
}
|
|
1132
|
-
function Vt() {
|
|
1133
|
-
return new Promise((e) => setTimeout(e, 0));
|
|
1134
|
-
}
|
|
1135
|
-
function Gt(e, t) {
|
|
1136
|
-
if (!t || typeof t != "object") return t ?? null;
|
|
1137
|
-
const { ptr: n, length: a, kind: i } = t;
|
|
1138
|
-
return typeof n != "number" ? t : a ? (i === "i32" ? new Int32Array(e.HEAP32.buffer, n, a) : new Float32Array(e.HEAPF32.buffer, n, a)).slice() : i === "i32" ? new Int32Array() : new Float32Array();
|
|
1139
|
-
}
|
|
1140
|
-
async function Bt(e, t, n, a, i, r, s, c, o, u, h, g, l, f, p, y, w) {
|
|
1141
|
-
const d = {}, m = [...f];
|
|
1142
|
-
let S = [
|
|
1143
|
-
{ url: t, depth: 0, recurse: !0, absolute: !1 }
|
|
1144
|
-
];
|
|
1145
|
-
const b = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Set();
|
|
1146
|
-
for (; S.length; ) {
|
|
1147
|
-
const j = S;
|
|
1148
|
-
S = [];
|
|
1149
|
-
const V = [];
|
|
1150
|
-
for (const U of j) {
|
|
1151
|
-
const A = U.absolute ? U.url.href : Pe(U.url.href, t);
|
|
1152
|
-
if (!b.has(A)) {
|
|
1153
|
-
if (U.depth > h) throw new Error(`USD dependency depth limit exceeded (${h}): ${A}`);
|
|
1154
|
-
if (b.size >= u) throw new Error(`USD dependency limit exceeded (${u}).`);
|
|
1155
|
-
b.add(A), V.push({ item: U, identifier: A });
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
S = (await Ft(
|
|
1159
|
-
V,
|
|
1160
|
-
Math.max(1, g),
|
|
1161
|
-
async ({ item: U, identifier: A }) => {
|
|
1162
|
-
const E = J(U.url.href, n);
|
|
1163
|
-
if (!r.has(E) || U.absolute && !f.has(E)) {
|
|
1164
|
-
let P;
|
|
1165
|
-
try {
|
|
1166
|
-
P = await a(U.url, A);
|
|
1167
|
-
} catch (M) {
|
|
1168
|
-
if (!U.owner || !Xe(A) || !Ye(M)) throw M;
|
|
1169
|
-
const T = `${n}/__unavailable__/${encodeURIComponent(A)}`;
|
|
1170
|
-
return d[U.owner.path][U.owner.reference] = T, s.set(T, A), w == null || w(A, M), [];
|
|
1171
|
-
}
|
|
1172
|
-
o.set(E, De(P)), de(e, E, P, r);
|
|
1173
|
-
}
|
|
1174
|
-
if (s.set(E, A), !U.recurse) return [];
|
|
1175
|
-
if (d[E] ?? (d[E] = {}), o.get(E) === !1) return [];
|
|
1176
|
-
const z = i("usd_probe_external_references", ["string"], [E]).paths ?? [], x = [];
|
|
1177
|
-
for (const P of z) {
|
|
1178
|
-
if (!P || /^(?:data|blob):/i.test(P) || /\.mdl(?:[?#].*)?$/i.test(P)) continue;
|
|
1179
|
-
let M;
|
|
1180
|
-
try {
|
|
1181
|
-
M = new URL(P, U.url);
|
|
1182
|
-
} catch {
|
|
1183
|
-
continue;
|
|
1184
|
-
}
|
|
1185
|
-
const T = /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(P), H = J(M.href, n), O = et(H, m), L = (O == null ? void 0 : O.paths.length) === 1 ? O.paths[0] : null, B = L ?? H, Z = U.absolute || T, R = Z ? M.href : Pe(M.href, t), D = zt(M.pathname);
|
|
1186
|
-
if (L && s.set(L, R), l === "package" && O && O.paths.length > 1) {
|
|
1187
|
-
const $ = `${n}/__deferred_udim__/${encodeURIComponent(R)}`;
|
|
1188
|
-
d[E][P] = $, s.set($, R);
|
|
1189
|
-
continue;
|
|
1190
|
-
}
|
|
1191
|
-
if (l === "package" && !f.has(B) && !Ae(M, t)) {
|
|
1192
|
-
const $ = `${n}/__skipped__/${encodeURIComponent(R)}`;
|
|
1193
|
-
d[E][P] = $, s.set($, R), k.has(R) || (k.add(R), y == null || y(R));
|
|
1194
|
-
continue;
|
|
1195
|
-
}
|
|
1196
|
-
if (!D && c && (c.set(R, M.href), c.set(P, M.href)), d[E][P] = B, !D && !p) {
|
|
1197
|
-
s.set(B, R);
|
|
1198
|
-
continue;
|
|
1199
|
-
}
|
|
1200
|
-
!L && !b.has(R) && x.push({
|
|
1201
|
-
url: M,
|
|
1202
|
-
depth: U.depth + 1,
|
|
1203
|
-
recurse: D,
|
|
1204
|
-
absolute: Z,
|
|
1205
|
-
owner: { path: E, reference: P }
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
|
-
return x;
|
|
1209
|
-
}
|
|
1210
|
-
)).flat();
|
|
1211
|
-
}
|
|
1212
|
-
return d;
|
|
1213
|
-
}
|
|
1214
|
-
async function Ft(e, t, n) {
|
|
1215
|
-
const a = new Array(e.length);
|
|
1216
|
-
let i = 0;
|
|
1217
|
-
const r = Array.from({ length: Math.min(t, e.length) }, async () => {
|
|
1218
|
-
for (; i < e.length; ) {
|
|
1219
|
-
const s = i++;
|
|
1220
|
-
a[s] = await n(e[s]);
|
|
1221
|
-
}
|
|
1222
|
-
});
|
|
1223
|
-
return await Promise.all(r), a;
|
|
1224
|
-
}
|
|
1225
|
-
function zt(e) {
|
|
1226
|
-
var n, a;
|
|
1227
|
-
const t = (a = (n = e.split(/[?#]/, 1)[0]) == null ? void 0 : n.split(".").pop()) == null ? void 0 : a.toLowerCase();
|
|
1228
|
-
return t != null && Lt.has(t);
|
|
1229
|
-
}
|
|
1230
|
-
function De(e) {
|
|
1231
|
-
return Ne(e) ? e.includes(64) : !0;
|
|
1232
|
-
}
|
|
1233
|
-
function Ht(e) {
|
|
1234
|
-
return Ne(e) ? Wt(e, [
|
|
1235
|
-
"subLayers",
|
|
1236
|
-
"references",
|
|
1237
|
-
"payload",
|
|
1238
|
-
"payloads",
|
|
1239
|
-
"clipAssetPaths"
|
|
1240
|
-
]) : !0;
|
|
1241
|
-
}
|
|
1242
|
-
function Ne(e) {
|
|
1243
|
-
let t = e[0] === 239 && e[1] === 187 && e[2] === 191 ? 3 : 0;
|
|
1244
|
-
for (; t < e.length && t < 64 && /\s/.test(String.fromCharCode(e[t])); ) t += 1;
|
|
1245
|
-
return e[t] === 35 && e[t + 1] === 117 && e[t + 2] === 115 && e[t + 3] === 100 && e[t + 4] === 97;
|
|
1246
|
-
}
|
|
1247
|
-
function Wt(e, t) {
|
|
1248
|
-
const n = /* @__PURE__ */ new Map();
|
|
1249
|
-
let a = 1;
|
|
1250
|
-
for (const r of t) {
|
|
1251
|
-
const s = r.charCodeAt(0);
|
|
1252
|
-
n.set(s, [...n.get(s) ?? [], r]), a = Math.max(a, r.length);
|
|
1253
|
-
}
|
|
1254
|
-
const i = e.length - a;
|
|
1255
|
-
for (let r = 0; r <= i; ++r) {
|
|
1256
|
-
const s = n.get(e[r]);
|
|
1257
|
-
if (s)
|
|
1258
|
-
for (const c of s) {
|
|
1259
|
-
let o = !0;
|
|
1260
|
-
for (let u = 1; u < c.length; ++u)
|
|
1261
|
-
if (e[r + u] !== c.charCodeAt(u)) {
|
|
1262
|
-
o = !1;
|
|
1263
|
-
break;
|
|
1264
|
-
}
|
|
1265
|
-
if (o) return !0;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
return !1;
|
|
1269
|
-
}
|
|
1270
|
-
function Pe(e, t) {
|
|
1271
|
-
const n = new URL(e);
|
|
1272
|
-
if (n.protocol !== t.protocol || n.host !== t.host) return n.href;
|
|
1273
|
-
const a = new URL(".", t).pathname.split("/").filter(Boolean), i = n.pathname.split("/").filter(Boolean);
|
|
1274
|
-
let r = 0;
|
|
1275
|
-
for (; r < a.length && a[r] === i[r]; ) r++;
|
|
1276
|
-
const s = [...a.slice(r).map(() => ".."), ...i.slice(r)].join("/");
|
|
1277
|
-
return decodeURIComponent(s) + n.search + n.hash;
|
|
1278
|
-
}
|
|
1279
|
-
function J(e, t) {
|
|
1280
|
-
const n = new URL(e), a = encodeURIComponent(`${n.protocol}//${n.host}`);
|
|
1281
|
-
let i = n.pathname.split("/").map((r) => decodeURIComponent(r).replaceAll("/", "%2F").replaceAll("\\", "%5C")).join("/");
|
|
1282
|
-
if (n.search || n.hash) {
|
|
1283
|
-
const r = i.lastIndexOf("."), s = r > i.lastIndexOf("/") ? r : i.length;
|
|
1284
|
-
i = `${i.slice(0, s)}.__url_${encodeURIComponent(n.search + n.hash)}${i.slice(s)}`;
|
|
1285
|
-
}
|
|
1286
|
-
return `${t}/${a}${i}`;
|
|
1287
|
-
}
|
|
1288
|
-
function Te(e, t) {
|
|
1289
|
-
if (!e || typeof e != "object" || ArrayBuffer.isView(e)) return;
|
|
1290
|
-
const n = e;
|
|
1291
|
-
if (typeof n.path == "string" && typeof n.resolvedPath == "string") {
|
|
1292
|
-
for (const a of ["path", "resolvedPath"]) {
|
|
1293
|
-
const i = n[a];
|
|
1294
|
-
n[a] = t.get(i) ?? i;
|
|
1295
|
-
}
|
|
1296
|
-
return;
|
|
1297
|
-
}
|
|
1298
|
-
for (const a of Object.values(e)) Te(a, t);
|
|
1299
|
-
}
|
|
1300
|
-
function $e(e, t) {
|
|
1301
|
-
if (e.analyzePath(t).exists) {
|
|
1302
|
-
for (const n of e.readdir(t)) {
|
|
1303
|
-
if (n === "." || n === "..") continue;
|
|
1304
|
-
const a = `${t}/${n}`;
|
|
1305
|
-
e.isDir(e.stat(a).mode) ? $e(e, a) : e.unlink(a);
|
|
1306
|
-
}
|
|
1307
|
-
e.rmdir(t);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
function de(e, t, n, a) {
|
|
1311
|
-
a.has(t) || (e.FS.mkdirTree(t.split("/").slice(0, -1).join("/") || "/"), e.FS.writeFile(t, n), a.add(t));
|
|
1312
|
-
}
|
|
1313
|
-
function ue(e) {
|
|
1314
|
-
return `${e.primPath}\0${e.setName}`;
|
|
1315
|
-
}
|
|
1316
|
-
async function Ie(e) {
|
|
1317
|
-
return typeof e == "string" ? new TextEncoder().encode(e) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(await e.arrayBuffer());
|
|
1318
|
-
}
|
|
1319
|
-
async function Xt(e) {
|
|
1320
|
-
if (!e) throw new Error("createSingleThreadUsd needs wasmUrl or wasmBinary.");
|
|
1321
|
-
return (await fetch(e)).arrayBuffer();
|
|
1322
|
-
}
|
|
1323
|
-
function Jt(e) {
|
|
1324
|
-
if (e.length < 30) return null;
|
|
1325
|
-
const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (a, i) => {
|
|
1326
|
-
for (let r = 0; r < i.length; r += 1)
|
|
1327
|
-
if (e[a + r] !== i.charCodeAt(r)) return !1;
|
|
1328
|
-
return !0;
|
|
1329
|
-
};
|
|
1330
|
-
if (e[0] === 137 && n(1, "PNG") && n(12, "IHDR"))
|
|
1331
|
-
return Y(t.getUint32(16), t.getUint32(20));
|
|
1332
|
-
if (e[0] === 255 && e[1] === 216) {
|
|
1333
|
-
let a = 2;
|
|
1334
|
-
for (; a + 9 < e.length; ) {
|
|
1335
|
-
if (e[a] !== 255) return null;
|
|
1336
|
-
const i = e[a + 1], r = e[a + 2] << 8 | e[a + 3];
|
|
1337
|
-
if (i >= 192 && i <= 207 && i !== 196 && i !== 200 && i !== 204)
|
|
1338
|
-
return Y(
|
|
1339
|
-
e[a + 7] << 8 | e[a + 8],
|
|
1340
|
-
e[a + 5] << 8 | e[a + 6]
|
|
1341
|
-
);
|
|
1342
|
-
if (r < 2) return null;
|
|
1343
|
-
a += 2 + r;
|
|
1344
|
-
}
|
|
1345
|
-
return null;
|
|
1346
|
-
}
|
|
1347
|
-
if (n(0, "RIFF") && n(8, "WEBP")) {
|
|
1348
|
-
if (n(12, "VP8 "))
|
|
1349
|
-
return Y(
|
|
1350
|
-
t.getUint16(26, !0) & 16383,
|
|
1351
|
-
t.getUint16(28, !0) & 16383
|
|
1352
|
-
);
|
|
1353
|
-
if (n(12, "VP8L")) {
|
|
1354
|
-
const a = t.getUint32(21, !0);
|
|
1355
|
-
return Y((a & 16383) + 1, (a >>> 14 & 16383) + 1);
|
|
1356
|
-
}
|
|
1357
|
-
if (n(12, "VP8X")) {
|
|
1358
|
-
const a = (i) => e[i] | e[i + 1] << 8 | e[i + 2] << 16;
|
|
1359
|
-
return Y(a(24) + 1, a(27) + 1);
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
return null;
|
|
1363
|
-
}
|
|
1364
|
-
function Zt(e, t) {
|
|
1365
|
-
const n = Math.max(e.width, e.height);
|
|
1366
|
-
if (t <= 0 || n <= t) return e;
|
|
1367
|
-
const a = t / n;
|
|
1368
|
-
return {
|
|
1369
|
-
width: Math.max(1, Math.round(e.width * a)),
|
|
1370
|
-
height: Math.max(1, Math.round(e.height * a))
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
function Y(e, t) {
|
|
1374
|
-
return e > 0 && t > 0 ? { width: e, height: t } : null;
|
|
1375
|
-
}
|
|
1376
|
-
function X(e) {
|
|
1377
|
-
return e instanceof Error ? {
|
|
1378
|
-
name: e.name,
|
|
1379
|
-
message: e.message,
|
|
1380
|
-
...typeof e.code == "string" ? { code: e.code } : {},
|
|
1381
|
-
...e.stack ? { stack: e.stack } : {}
|
|
1382
|
-
} : { name: "Error", message: String(e) };
|
|
1383
|
-
}
|
|
1384
|
-
const K = globalThis;
|
|
1385
|
-
let ee = null, q = null, te = null, oe = null, le = !1, Yt = 1;
|
|
1386
|
-
const Q = /* @__PURE__ */ new Map();
|
|
1387
|
-
function N(e, t) {
|
|
1388
|
-
K.postMessage(e, t);
|
|
1389
|
-
}
|
|
1390
|
-
function qt(e, t) {
|
|
1391
|
-
const n = Yt++;
|
|
1392
|
-
return new Promise((a, i) => {
|
|
1393
|
-
Q.set(n, { resolve: a, reject: i }), N({ type: "resource-request", id: n, url: e.href, identifier: t });
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
function Kt(e) {
|
|
1397
|
-
return ee ?? (ee = Ct(e)), ee;
|
|
1398
|
-
}
|
|
1399
|
-
function Qt(e) {
|
|
1400
|
-
const t = /* @__PURE__ */ new Set();
|
|
1401
|
-
for (const n of e.elements)
|
|
1402
|
-
for (const a of Object.values(n.geometry ?? {}))
|
|
1403
|
-
ArrayBuffer.isView(a) && t.add(a.buffer);
|
|
1404
|
-
return [...t];
|
|
1405
|
-
}
|
|
1406
|
-
async function en(e) {
|
|
1407
|
-
if (!te) throw new Error("USD worker has no live stage");
|
|
1408
|
-
const t = te[e.method];
|
|
1409
|
-
return { type: "query-result", id: e.id, value: await t.apply(te, e.args) };
|
|
1410
|
-
}
|
|
1411
|
-
async function tn(e, t) {
|
|
1412
|
-
if (typeof createImageBitmap != "function")
|
|
1413
|
-
throw new Error("This browser cannot decode USD textures in a worker.");
|
|
1414
|
-
const n = await fetch(e);
|
|
1415
|
-
if (!n.ok) throw new Error(`HTTP ${n.status} for ${e}`);
|
|
1416
|
-
const a = new Uint8Array(await n.arrayBuffer()), i = Jt(a), r = {
|
|
1417
|
-
imageOrientation: "flipY",
|
|
1418
|
-
premultiplyAlpha: "none",
|
|
1419
|
-
colorSpaceConversion: "none"
|
|
1420
|
-
};
|
|
1421
|
-
if (i) {
|
|
1422
|
-
const s = t > 0 ? Zt(i, t) : i;
|
|
1423
|
-
(s.width !== i.width || s.height !== i.height) && (r.resizeWidth = s.width, r.resizeHeight = s.height, r.resizeQuality = "high");
|
|
1424
|
-
}
|
|
1425
|
-
return createImageBitmap(new Blob([a]), r);
|
|
1426
|
-
}
|
|
1427
|
-
K.onmessage = async (e) => {
|
|
1428
|
-
const t = e.data;
|
|
1429
|
-
if (t.type === "resource-result") {
|
|
1430
|
-
const n = Q.get(t.id);
|
|
1431
|
-
if (!n) return;
|
|
1432
|
-
Q.delete(t.id), t.error ? n.reject(Object.assign(new Error(t.error.message), {
|
|
1433
|
-
name: t.error.name,
|
|
1434
|
-
...t.error.code ? { code: t.error.code } : {}
|
|
1435
|
-
})) : n.resolve(t.bytes ?? new Uint8Array());
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
if (t.type === "query") {
|
|
1439
|
-
try {
|
|
1440
|
-
N(await en(t));
|
|
1441
|
-
} catch (n) {
|
|
1442
|
-
N({ type: "error", id: t.id, error: X(n) });
|
|
1443
|
-
}
|
|
1444
|
-
return;
|
|
1445
|
-
}
|
|
1446
|
-
if (t.type === "decode-texture") {
|
|
1447
|
-
try {
|
|
1448
|
-
const n = await tn(t.url, t.maxDimension);
|
|
1449
|
-
N({
|
|
1450
|
-
type: "texture-decoded",
|
|
1451
|
-
id: t.id,
|
|
1452
|
-
bitmap: n,
|
|
1453
|
-
width: n.width,
|
|
1454
|
-
height: n.height
|
|
1455
|
-
}, [n]);
|
|
1456
|
-
} catch (n) {
|
|
1457
|
-
N({ type: "error", id: t.id, error: X(n) });
|
|
1458
|
-
}
|
|
1459
|
-
return;
|
|
1460
|
-
}
|
|
1461
|
-
if (t.type === "dispose") {
|
|
1462
|
-
for (const n of Q.values()) n.reject(new Error("USD worker disposed"));
|
|
1463
|
-
Q.clear(), q == null || q(), te = null, oe = null, le = !1, ee = null, q = null, K.close();
|
|
1464
|
-
return;
|
|
1465
|
-
}
|
|
1466
|
-
if (t.type === "extract-physics") {
|
|
1467
|
-
if (le || !oe) return;
|
|
1468
|
-
le = !0;
|
|
1469
|
-
try {
|
|
1470
|
-
N({ type: "physics-ready", phase: await oe() });
|
|
1471
|
-
} catch (n) {
|
|
1472
|
-
N({ type: "physics-failed", error: X(n) });
|
|
1473
|
-
}
|
|
1474
|
-
return;
|
|
1475
|
-
}
|
|
1476
|
-
if (t.type === "prepare") {
|
|
1477
|
-
try {
|
|
1478
|
-
const n = await Kt(t.runtime);
|
|
1479
|
-
t.warmup && await n.warmup(), N({ type: "worker-ready" });
|
|
1480
|
-
} catch (n) {
|
|
1481
|
-
N({ type: "error", error: X(n) }), K.close();
|
|
1482
|
-
}
|
|
1483
|
-
return;
|
|
1484
|
-
}
|
|
1485
|
-
try {
|
|
1486
|
-
if (!ee) throw new Error("USD worker was not prepared before load");
|
|
1487
|
-
const a = await (await ee).parseVisualSceneAsync(t.input, {
|
|
1488
|
-
...t.options,
|
|
1489
|
-
packagePaths: t.options.packagePaths,
|
|
1490
|
-
readTextureBytes: t.options.readTextureBytes ?? !1,
|
|
1491
|
-
loadTextures: !1,
|
|
1492
|
-
convertZUp: !1,
|
|
1493
|
-
loadLights: !1,
|
|
1494
|
-
resolveBytes: qt,
|
|
1495
|
-
onReferenceSkipped: (s) => N({ type: "event", event: "reference-skipped", identifier: s }),
|
|
1496
|
-
onResourceFailed: (s, c) => N({ type: "event", event: "resource-failed", identifier: s, error: X(c) })
|
|
1497
|
-
});
|
|
1498
|
-
q = a.release, te = Re(a.stage, a.pxr), oe = a.readPhysics;
|
|
1499
|
-
const i = a.data, r = Qt(i);
|
|
1500
|
-
N({
|
|
1501
|
-
type: "visual-ready",
|
|
1502
|
-
data: i,
|
|
1503
|
-
textureURLs: [...a.textureURLs ?? []]
|
|
1504
|
-
}, r);
|
|
1505
|
-
} catch (n) {
|
|
1506
|
-
N({ type: "error", error: X(n) }), K.close();
|
|
1507
|
-
}
|
|
1508
|
-
};
|