@nebula-spatial/viewer 0.5.4 → 0.5.6
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 +67 -0
- package/README.md +97 -54
- package/USD-VISUAL-MATERIAL-SUPPORT.md +5 -3
- package/basis/basis_transcoder.js +19 -0
- package/basis/basis_transcoder.wasm +0 -0
- package/dist/assets/ground-grid.d.ts +6 -0
- package/dist/assets/types.d.ts +37 -0
- package/dist/assets/usd-worker-CnpILBYh.js +1352 -0
- package/dist/collision-debug-CqRm6cC8.js +479 -0
- package/dist/{index-8TD-Puyo.js → index-D6-ClMfm.js} +2512 -1768
- package/dist/index.d.ts +5 -1
- package/dist/index.js +15 -12
- package/dist/{mjcf-visual-qlID4stF.js → mjcf-visual-B8RE9CqV.js} +7 -7
- package/dist/mujoco-runtime-ZuEJSHnD.js +396 -0
- package/dist/resources-CHhCm2f7.js +27 -0
- package/dist/{session-CCDMlwej.js → session-CDrNB1J2.js} +6 -5
- package/dist/session-DgvOdcLe.js +632 -0
- package/dist/simulation/usd-query.d.ts +50 -0
- package/dist/simulation/usd-resource-policy.d.ts +28 -0
- package/dist/{stage-DAhe0IZz.js → stage-CSRMl8kx.js} +158 -170
- package/dist/{urdf-session-DceYWCib.js → urdf-session-DD3HOAib.js} +552 -542
- package/dist/usd-session-BCCp_YDr.js +6217 -0
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-DPEhwEml.js → xacro-BpICdIYd.js} +1 -1
- package/openusd/openusd-runtime-manifest.json +15 -0
- package/openusd/openusd_probe.js +1 -1
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +4 -2
- package/dist/mujoco-runtime-DTxVmIzc.js +0 -349
- package/dist/session-um40A-5F.js +0 -878
- package/dist/usd-session-BBtKxubs.js +0 -4174
|
@@ -1,4174 +0,0 @@
|
|
|
1
|
-
import { Mesh as me, FrontSide as Tn, DoubleSide as En, MeshPhysicalMaterial as W, DataTexture as Ct, UnsignedByteType as Dt, RGBAFormat as Tt, NoColorSpace as re, Color as tt, Float32BufferAttribute as $n, SRGBColorSpace as pt, RepeatWrapping as te, Texture as bt, MeshStandardMaterial as St, TextureLoader as nn, MirroredRepeatWrapping as sn, ClampToEdgeWrapping as rn, Group as ze, Vector3 as j, Quaternion as fe, Matrix4 as Pe, Box3 as et, Sphere as Nn, SphereGeometry as Bn, BoxGeometry as Ln, SkinnedMesh as qe, Skeleton as kn, AnimationMixer as Fn, LoopRepeat as Gn } from "three";
|
|
2
|
-
import { n as Ze, c as Et, a as $t, b as Fe, d as Vn, p as zn, S as Nt, C as Bt, e as jn } from "./session-um40A-5F.js";
|
|
3
|
-
import { ConvexGeometry as Wn } from "three/examples/jsm/geometries/ConvexGeometry.js";
|
|
4
|
-
import { createUSDLoadedModel as Xn, buildUSDScene as Kn } from "@openusd-wasm/three-loader";
|
|
5
|
-
import { f as Hn, g as qn, c as Yn, h as Jn, j as Zn, d as Qn } from "./index-8TD-Puyo.js";
|
|
6
|
-
import { b as on } from "./stage-DAhe0IZz.js";
|
|
7
|
-
function es(e) {
|
|
8
|
-
var r, o;
|
|
9
|
-
const t = e.stage;
|
|
10
|
-
if (!t || !((o = (r = e.pxr) == null ? void 0 : r.Sdf) != null && o.Path)) return;
|
|
11
|
-
const n = /* @__PURE__ */ new Map(), s = (a) => {
|
|
12
|
-
if (!a || a === "/") return "default";
|
|
13
|
-
const c = n.get(a);
|
|
14
|
-
if (c !== void 0) return c;
|
|
15
|
-
const u = new e.pxr.Sdf.Path(a), l = t.GetPrimAtPath(u), p = l.GetAttribute("purpose"), i = e.pxr.Usd.TimeCode.Default();
|
|
16
|
-
let f;
|
|
17
|
-
try {
|
|
18
|
-
p.IsValid() && p.HasAuthoredValue() && (f = String(p.Get(i)));
|
|
19
|
-
} finally {
|
|
20
|
-
i.delete(), p.delete(), l.delete(), u.delete();
|
|
21
|
-
}
|
|
22
|
-
const h = f ?? s(a.slice(0, a.lastIndexOf("/")));
|
|
23
|
-
return n.set(a, h), h;
|
|
24
|
-
};
|
|
25
|
-
e.scene.traverse((a) => {
|
|
26
|
-
var p, i;
|
|
27
|
-
if (!(a instanceof me)) return;
|
|
28
|
-
let c = a, u;
|
|
29
|
-
for (; c && !u; )
|
|
30
|
-
u = (p = c.userData.usd) == null ? void 0 : p.path, c = c.parent;
|
|
31
|
-
if (!u) return;
|
|
32
|
-
const l = s(u) === "guide";
|
|
33
|
-
a.userData.usdPurposeExcluded = l, l ? ((i = a.userData).usdPurposeLayerMask ?? (i.usdPurposeLayerMask = a.layers.mask), a.layers.disableAll()) : a.userData.usdPurposeLayerMask !== void 0 && (a.layers.mask = a.userData.usdPurposeLayerMask, delete a.userData.usdPurposeLayerMask);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function vt(e, t) {
|
|
37
|
-
return /^https?:$/.test(t.protocol) && e.origin === t.origin && !e.username && !e.password && e.pathname.startsWith(new URL(".", t).pathname);
|
|
38
|
-
}
|
|
39
|
-
function an(e, t, n) {
|
|
40
|
-
const s = [];
|
|
41
|
-
try {
|
|
42
|
-
for (const r of e) for (const o of r.shaders) for (const a of Object.values(o.inputs)) {
|
|
43
|
-
if (!a || typeof a != "object" || Array.isArray(a)) continue;
|
|
44
|
-
const c = a, u = [c.path, c.url, c.resolvedPath].find((p) => typeof p == "string" && p);
|
|
45
|
-
if (!u || /^(?:data|blob):/i.test(u) || /\.mdl(?:[?#].*)?$/i.test(u) || t(u)) continue;
|
|
46
|
-
const l = {};
|
|
47
|
-
for (const p of ["path", "resolvedPath", "url"])
|
|
48
|
-
p in c && (l[p] = c[p], delete c[p]);
|
|
49
|
-
s.push({ asset: c, values: l });
|
|
50
|
-
}
|
|
51
|
-
return n();
|
|
52
|
-
} finally {
|
|
53
|
-
for (const { asset: r, values: o } of s) Object.assign(r, o);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const ts = 67324752, ns = 33639248, ss = 101010256, at = 4294967295, rs = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "webp"]);
|
|
57
|
-
function os(e) {
|
|
58
|
-
return e.length > 3 && e[0] === 80 && e[1] === 75;
|
|
59
|
-
}
|
|
60
|
-
async function as(e, t = {}) {
|
|
61
|
-
const n = new DataView(e.buffer, e.byteOffset, e.byteLength), s = fs(n);
|
|
62
|
-
if (s < 0) throw new Error("Not a zip package: end of central directory not found.");
|
|
63
|
-
const r = n.getUint16(s + 10, !0);
|
|
64
|
-
let o = n.getUint32(s + 16, !0);
|
|
65
|
-
if (r === 65535 || o === at) throw new Error("ZIP64 usdz packages are not supported.");
|
|
66
|
-
const a = /* @__PURE__ */ new Map(), c = [];
|
|
67
|
-
for (let u = 0; u < r; u += 1) {
|
|
68
|
-
if (o + 46 > n.byteLength || n.getUint32(o, !0) !== ns)
|
|
69
|
-
throw new Error(`Corrupt zip central directory at entry ${u}.`);
|
|
70
|
-
const l = n.getUint16(o + 10, !0), p = n.getUint32(o + 20, !0), i = n.getUint16(o + 28, !0), f = n.getUint16(o + 30, !0), h = n.getUint16(o + 32, !0), d = n.getUint32(o + 42, !0);
|
|
71
|
-
if (p === at || d === at)
|
|
72
|
-
throw new Error("ZIP64 usdz packages are not supported.");
|
|
73
|
-
const g = new TextDecoder().decode(e.subarray(o + 46, o + 46 + i));
|
|
74
|
-
o += 46 + i + f + h, !g.endsWith("/") && (t.include && !t.include(g) || c.push(us(e, n, d, p, l).then((_) => ({ name: g, data: _ }))));
|
|
75
|
-
}
|
|
76
|
-
for (const { name: u, data: l } of await Promise.all(c)) a.set(u, l);
|
|
77
|
-
return a;
|
|
78
|
-
}
|
|
79
|
-
function is(e) {
|
|
80
|
-
if (typeof URL > "u" || typeof URL.createObjectURL != "function") return null;
|
|
81
|
-
const t = new Map([...e].filter(([a]) => rs.has(un(a))));
|
|
82
|
-
if (t.size === 0) return null;
|
|
83
|
-
const n = /* @__PURE__ */ new Map();
|
|
84
|
-
for (const a of t.keys()) {
|
|
85
|
-
const c = a.split("/").pop() ?? a;
|
|
86
|
-
n.set(c, n.has(c) ? null : a);
|
|
87
|
-
}
|
|
88
|
-
const s = /* @__PURE__ */ new Map(), r = (a) => {
|
|
89
|
-
let c = s.get(a);
|
|
90
|
-
if (!c) {
|
|
91
|
-
const u = t.get(a);
|
|
92
|
-
c = URL.createObjectURL(new Blob([new Uint8Array(u)], { type: ps(a) })), s.set(a, c);
|
|
93
|
-
}
|
|
94
|
-
return c;
|
|
95
|
-
}, o = (a) => {
|
|
96
|
-
if (!a) return null;
|
|
97
|
-
const c = ls(cs(a));
|
|
98
|
-
if (!c) return null;
|
|
99
|
-
if (t.has(c)) return r(c);
|
|
100
|
-
const u = [...t.keys()].filter((i) => i.endsWith(`/${c}`));
|
|
101
|
-
if (u.length === 1) return r(u[0]);
|
|
102
|
-
const l = [...t.keys()].filter((i) => c.endsWith(`/${i}`));
|
|
103
|
-
if (l.length === 1) return r(l[0]);
|
|
104
|
-
const p = n.get(c.split("/").pop() ?? "");
|
|
105
|
-
return p ? r(p) : null;
|
|
106
|
-
};
|
|
107
|
-
for (const a of t.keys()) r(a);
|
|
108
|
-
return {
|
|
109
|
-
urls: s,
|
|
110
|
-
resolve: (a) => o(a.resolvedPath) ?? o(a.path) ?? o(a.url) ?? null,
|
|
111
|
-
dispose: () => {
|
|
112
|
-
for (const a of s.values()) URL.revokeObjectURL(a);
|
|
113
|
-
s.clear();
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
async function us(e, t, n, s, r) {
|
|
118
|
-
if (t.getUint32(n, !0) !== ts) throw new Error("Corrupt zip local file header.");
|
|
119
|
-
const o = t.getUint16(n + 26, !0), a = t.getUint16(n + 28, !0), c = n + 30 + o + a, u = e.subarray(c, c + s);
|
|
120
|
-
if (r === 0) return u.slice();
|
|
121
|
-
if (r !== 8) throw new Error(`Unsupported zip compression method ${r}.`);
|
|
122
|
-
const l = new Blob([new Uint8Array(u)]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
|
123
|
-
return new Uint8Array(await new Response(l).arrayBuffer());
|
|
124
|
-
}
|
|
125
|
-
function cs(e) {
|
|
126
|
-
const t = e.indexOf("[");
|
|
127
|
-
return t >= 0 && e.endsWith("]") ? e.slice(t + 1, -1) : e;
|
|
128
|
-
}
|
|
129
|
-
function ls(e) {
|
|
130
|
-
const t = [];
|
|
131
|
-
for (const n of e.replaceAll("\\", "/").split("/"))
|
|
132
|
-
!n || n === "." || (n === ".." ? t.pop() : t.push(n));
|
|
133
|
-
return t.join("/");
|
|
134
|
-
}
|
|
135
|
-
function un(e) {
|
|
136
|
-
const t = e.split(/[?#]/)[0] ?? e, n = t.lastIndexOf(".");
|
|
137
|
-
return n < 0 ? "" : t.slice(n + 1).toLowerCase();
|
|
138
|
-
}
|
|
139
|
-
function ps(e) {
|
|
140
|
-
switch (un(e)) {
|
|
141
|
-
case "png":
|
|
142
|
-
return "image/png";
|
|
143
|
-
case "jpg":
|
|
144
|
-
case "jpeg":
|
|
145
|
-
return "image/jpeg";
|
|
146
|
-
case "webp":
|
|
147
|
-
return "image/webp";
|
|
148
|
-
default:
|
|
149
|
-
return "application/octet-stream";
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function fs(e) {
|
|
153
|
-
const t = Math.max(0, e.byteLength - 65535 - 22);
|
|
154
|
-
for (let n = e.byteLength - 22; n >= t; n -= 1)
|
|
155
|
-
if (e.getUint32(n, !0) === ss) return n;
|
|
156
|
-
return -1;
|
|
157
|
-
}
|
|
158
|
-
const ds = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
|
|
159
|
-
async function ms(e) {
|
|
160
|
-
const t = await import(
|
|
161
|
-
/* @vite-ignore */
|
|
162
|
-
e.moduleUrl
|
|
163
|
-
), n = t.default ?? t.createOpenUsdProbe, s = await (typeof e.wasmBinary == "function" ? e.wasmBinary() : e.wasmBinary ?? bs(e.wasmUrl)), r = await n({ wasmBinary: s }), o = e.memfsRoot ?? "/asset", a = e.fetchBytes ?? (async (f) => {
|
|
164
|
-
const h = await fetch(f);
|
|
165
|
-
if (!h.ok) throw Object.assign(new Error(`USD resource request failed (${h.status}): ${f}`), {
|
|
166
|
-
code: h.status === 401 || h.status === 403 ? "E_ASSET_AUTH" : "E_ASSET_FETCH"
|
|
167
|
-
});
|
|
168
|
-
const d = new Uint8Array(await h.arrayBuffer()), g = Hn(h.headers.get("content-type"), d);
|
|
169
|
-
if (g) throw qn(`USD resource is not usable (${g}): ${f}`, Yn);
|
|
170
|
-
return d;
|
|
171
|
-
}), c = (f, h, d) => JSON.parse(r.ccall(f, "string", h, d)), u = /* @__PURE__ */ new Set(), l = Lt(r);
|
|
172
|
-
let p = 0;
|
|
173
|
-
async function i(f, h) {
|
|
174
|
-
const d = new URL(h.sourcePath, "file:///"), g = `${o}/load-${++p}`, _ = je(d.href, g), y = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Map();
|
|
175
|
-
let m, U = null;
|
|
176
|
-
const b = () => {
|
|
177
|
-
m !== void 0 && u.delete(m) && c("usd_probe_stage_release", ["number"], [m]), U == null || U.dispose(), cn(r.FS, g);
|
|
178
|
-
};
|
|
179
|
-
try {
|
|
180
|
-
const S = await Ft(f);
|
|
181
|
-
dt(r, _, S, y);
|
|
182
|
-
for (const [F, D] of Object.entries(h.files ?? {}))
|
|
183
|
-
dt(r, je(new URL(F, d).href, g), await Ft(D), y);
|
|
184
|
-
const x = new Set(y), O = h.externalReferenceMode ?? "complete", C = os(S) ? await as(S, { include: hs }) : null;
|
|
185
|
-
let v = {};
|
|
186
|
-
if (!C && h.autoResolveAssets !== !1) {
|
|
187
|
-
const F = h.resolveBytes ?? ((D) => a(D));
|
|
188
|
-
v = await ys(
|
|
189
|
-
r,
|
|
190
|
-
d,
|
|
191
|
-
g,
|
|
192
|
-
F,
|
|
193
|
-
c,
|
|
194
|
-
y,
|
|
195
|
-
w,
|
|
196
|
-
h.maxFiles ?? 1024,
|
|
197
|
-
h.maxDepth ?? 8,
|
|
198
|
-
O,
|
|
199
|
-
x,
|
|
200
|
-
h.onReferenceSkipped,
|
|
201
|
-
h.onResourceFailed
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
U = C ? is(C) : null;
|
|
205
|
-
const B = h.textureResolver || U ? (F) => {
|
|
206
|
-
var D;
|
|
207
|
-
return ((D = h.textureResolver) == null ? void 0 : D.call(h, F)) ?? (U == null ? void 0 : U.resolve(F)) ?? null;
|
|
208
|
-
} : void 0, E = Object.keys(v).length > 0;
|
|
209
|
-
if (E && typeof r._usd_probe_stage_open_mapped != "function")
|
|
210
|
-
throw Object.assign(new Error("USD dependency mapping requires the matching packaged openusd_probe.js and .wasm runtime."), { code: "E_USD_RUNTIME_VERSION" });
|
|
211
|
-
const R = E ? c("usd_probe_stage_open_mapped", ["string", "string"], [_, JSON.stringify(v)]) : c("usd_probe_stage_open", ["string"], [_]);
|
|
212
|
-
if (!R.ok) throw new Error(R.error ?? `Failed to open ${_}`);
|
|
213
|
-
m = R.stageId, u.add(R.stageId);
|
|
214
|
-
const I = Lt(r, w), H = I.openStage(R.stageId), P = _s(r, R.stageId, _);
|
|
215
|
-
ft(P.materials, w), ft(P.lights, w);
|
|
216
|
-
const $ = C ? void 0 : h.isTextureAllowed ?? (O === "package" ? (F) => {
|
|
217
|
-
const D = new URL(F, d);
|
|
218
|
-
return x.has(je(D.href, g)) || vt(D, d);
|
|
219
|
-
} : void 0), J = () => Xn(
|
|
220
|
-
P,
|
|
221
|
-
I,
|
|
222
|
-
_,
|
|
223
|
-
{
|
|
224
|
-
sourcePath: h.sourcePath,
|
|
225
|
-
// `convertZUp` and `loadLights` are opt-in here: the viewer normalises USD
|
|
226
|
-
// to world Z-up itself and draws its own studio lighting. `loadTextures`
|
|
227
|
-
// keeps the reference builder's opt-out default, so omitting it loads
|
|
228
|
-
// textures instead of silently rendering untextured materials.
|
|
229
|
-
convertZUp: h.convertZUp ?? !1,
|
|
230
|
-
loadLights: h.loadLights ?? !1,
|
|
231
|
-
loadTextures: h.loadTextures ?? !0,
|
|
232
|
-
...h.textureLoader ? { textureLoader: h.textureLoader } : {},
|
|
233
|
-
...B ? { textureResolver: B } : {}
|
|
234
|
-
},
|
|
235
|
-
H,
|
|
236
|
-
{
|
|
237
|
-
// Keep package texture identities on the model so the visual adapter
|
|
238
|
-
// can resolve textures referenced by unsupported-but-known MDL nodes.
|
|
239
|
-
usdzTextureURLs: (U == null ? void 0 : U.urls) ?? /* @__PURE__ */ new Map(),
|
|
240
|
-
autoTextureURLs: /* @__PURE__ */ new Map()
|
|
241
|
-
}
|
|
242
|
-
), T = $ ? an(P.materials, $, J) : J(), se = T.dispose.bind(T);
|
|
243
|
-
let A = !1;
|
|
244
|
-
return T.dispose = () => {
|
|
245
|
-
A || (A = !0, se(), b());
|
|
246
|
-
}, T;
|
|
247
|
-
} catch (S) {
|
|
248
|
-
throw b(), S;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return { runtime: r, pxr: l, parseAsync: i };
|
|
252
|
-
}
|
|
253
|
-
function hs(e) {
|
|
254
|
-
return /\.(?:png|jpe?g|webp)$/i.test(e.split(/[?#]/, 1)[0] ?? e);
|
|
255
|
-
}
|
|
256
|
-
function Lt(e, t = /* @__PURE__ */ new Map()) {
|
|
257
|
-
const n = (u, l, p) => JSON.parse(e.ccall(u, "string", l, p));
|
|
258
|
-
class s {
|
|
259
|
-
constructor(l) {
|
|
260
|
-
this.path = l;
|
|
261
|
-
}
|
|
262
|
-
delete() {
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const r = (u, l, p) => {
|
|
266
|
-
const i = n("usd_probe_attribute_value", ["number", "string", "string"], [u, l, p]), f = i.valid === !0;
|
|
267
|
-
return {
|
|
268
|
-
IsValid: () => f,
|
|
269
|
-
Get: () => f ? typeof i.value == "string" ? t.get(i.value) ?? i.value : i.value : null,
|
|
270
|
-
HasAuthoredValue: () => i.authored === !0,
|
|
271
|
-
GetName: () => p,
|
|
272
|
-
GetMetadata: (h) => {
|
|
273
|
-
const d = n("usd_probe_attribute_metadata", ["number", "string", "string", "string"], [u, l, p, h]);
|
|
274
|
-
return d.valid === !0 && d.found === !0 ? d.value ?? null : null;
|
|
275
|
-
},
|
|
276
|
-
// The viewer accepts either plain strings or objects with GetString().
|
|
277
|
-
GetConnections: () => n("usd_probe_attribute_connections", ["number", "string", "string"], [u, l, p]).paths ?? [],
|
|
278
|
-
delete: () => {
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
}, o = (u, l) => ({
|
|
282
|
-
__path: l,
|
|
283
|
-
__stageId: u,
|
|
284
|
-
IsValid: () => n("usd_probe_prim_info", ["number", "string"], [u, l]).valid === !0,
|
|
285
|
-
GetName: () => String(l.split("/").pop() ?? ""),
|
|
286
|
-
GetPath: () => new s(l),
|
|
287
|
-
GetTypeName: () => String(n("usd_probe_prim_info", ["number", "string"], [u, l]).typeName ?? ""),
|
|
288
|
-
IsInstance: () => n("usd_probe_prim_info", ["number", "string"], [u, l]).instance === !0,
|
|
289
|
-
GetAttribute: (p) => r(u, l, p),
|
|
290
|
-
GetAttributes: () => (n("usd_probe_prim_attributes", ["number", "string"], [u, l]).names ?? []).map((p) => r(u, l, p)),
|
|
291
|
-
GetChildren: () => (n("usd_probe_prim_children", ["number", "string"], [u, l]).paths ?? []).map((p) => o(u, p)),
|
|
292
|
-
GetMetadata: (p) => {
|
|
293
|
-
const i = n("usd_probe_prim_metadata", ["number", "string", "string"], [u, l, p]);
|
|
294
|
-
return i.valid !== !0 ? null : typeof i.text == "string" ? i.text : i.found === !0 ? i.value : null;
|
|
295
|
-
},
|
|
296
|
-
delete: () => {
|
|
297
|
-
}
|
|
298
|
-
}), a = (u) => ({
|
|
299
|
-
GetPrimAtPath: (l) => o(u, typeof l == "string" ? l : l.path),
|
|
300
|
-
GetPseudoRoot: () => Object.assign(o(u, "/"), {
|
|
301
|
-
// Stage-level metadata (metersPerUnit, upAxis, defaultPrim) is authored on
|
|
302
|
-
// the layer, not composed onto the pseudo-root prim.
|
|
303
|
-
GetMetadata: (l) => {
|
|
304
|
-
const p = n("usd_probe_stage_metadata", ["number", "string"], [u, l]);
|
|
305
|
-
return p.found === !0 ? p.value : null;
|
|
306
|
-
},
|
|
307
|
-
GetName: () => "",
|
|
308
|
-
IsValid: () => !0
|
|
309
|
-
}),
|
|
310
|
-
delete: () => {
|
|
311
|
-
}
|
|
312
|
-
}), { FS: c } = e;
|
|
313
|
-
return {
|
|
314
|
-
FS: {
|
|
315
|
-
createDir: (u) => c.mkdirTree(u),
|
|
316
|
-
writeFile: (u, l) => c.writeFile(u, l),
|
|
317
|
-
exists: (u) => c.analyzePath(u, !0).exists,
|
|
318
|
-
listDir: (u) => c.readdir(u).filter((l) => l !== "." && l !== "..").map((l) => {
|
|
319
|
-
const p = `${u.replace(/\/+$/, "")}/${l}`;
|
|
320
|
-
return { path: p, name: l, isDir: c.isDir(c.stat(p).mode) };
|
|
321
|
-
}),
|
|
322
|
-
deleteFile: (u) => c.unlink(u),
|
|
323
|
-
deleteDir: (u) => c.rmdir(u)
|
|
324
|
-
},
|
|
325
|
-
Sdf: { Path: s },
|
|
326
|
-
Usd: { TimeCode: { Default: () => ({ delete: () => {
|
|
327
|
-
} }) } },
|
|
328
|
-
UsdShade: {
|
|
329
|
-
ComputeBoundMaterialPath: (u) => {
|
|
330
|
-
const l = n("usd_probe_bound_material", ["number", "string"], [u.__stageId, u.__path]);
|
|
331
|
-
return l.found !== !0 ? null : {
|
|
332
|
-
materialPath: String(l.materialPath ?? ""),
|
|
333
|
-
resolvedTargetPath: String(l.resolvedTargetPath ?? ""),
|
|
334
|
-
bindingRelationshipPath: String(l.bindingRelationshipPath ?? "")
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
UsdUtils: {
|
|
339
|
-
ExtractSanitizedExternalReferences: (u) => n("usd_probe_external_references", ["string"], [u]).paths ?? []
|
|
340
|
-
},
|
|
341
|
-
openStage: a
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function _s(e, t, n) {
|
|
345
|
-
const s = JSON.parse(e.ccall("usd_probe_scene_data", "string", ["number", "string"], [t, n]));
|
|
346
|
-
if (s.error) throw new Error(s.error);
|
|
347
|
-
const r = s;
|
|
348
|
-
for (const o of r.elements)
|
|
349
|
-
o.geometry = Object.fromEntries(
|
|
350
|
-
Object.entries(o.geometry).map(([a, c]) => [a, gs(e, c)])
|
|
351
|
-
);
|
|
352
|
-
return r;
|
|
353
|
-
}
|
|
354
|
-
function gs(e, t) {
|
|
355
|
-
if (!t || typeof t != "object") return t ?? null;
|
|
356
|
-
const { ptr: n, length: s, kind: r } = t;
|
|
357
|
-
return typeof n != "number" ? t : s ? (r === "i32" ? new Int32Array(e.HEAP32.buffer, n, s) : new Float32Array(e.HEAPF32.buffer, n, s)).slice() : r === "i32" ? new Int32Array() : new Float32Array();
|
|
358
|
-
}
|
|
359
|
-
async function ys(e, t, n, s, r, o, a, c, u, l, p, i, f) {
|
|
360
|
-
const h = {}, d = [
|
|
361
|
-
{ url: t, depth: 0, recurse: !0, absolute: !1 }
|
|
362
|
-
], g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set();
|
|
363
|
-
for (; d.length; ) {
|
|
364
|
-
const y = d.shift(), w = y.absolute ? y.url.href : kt(y.url.href, t);
|
|
365
|
-
if (g.has(w)) continue;
|
|
366
|
-
if (y.depth > u) throw new Error(`USD dependency depth limit exceeded (${u}): ${w}`);
|
|
367
|
-
if (g.size >= c) throw new Error(`USD dependency limit exceeded (${c}).`);
|
|
368
|
-
g.add(w);
|
|
369
|
-
const m = je(y.url.href, n);
|
|
370
|
-
if (!o.has(m) || y.absolute && !p.has(m)) {
|
|
371
|
-
let b;
|
|
372
|
-
try {
|
|
373
|
-
b = await s(y.url, w);
|
|
374
|
-
} catch (S) {
|
|
375
|
-
if (!y.owner || !Jn(w) || !Zn(S)) throw S;
|
|
376
|
-
const x = `${n}/__unavailable__/${encodeURIComponent(w)}`;
|
|
377
|
-
h[y.owner.path][y.owner.reference] = x, a.set(x, w), f == null || f(w, S);
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
dt(e, m, b, o);
|
|
381
|
-
}
|
|
382
|
-
if (a.set(m, w), !y.recurse) continue;
|
|
383
|
-
h[m] ?? (h[m] = {});
|
|
384
|
-
const U = r("usd_probe_external_references", ["string"], [m]).paths ?? [];
|
|
385
|
-
for (const b of U) {
|
|
386
|
-
if (!b || /^(?:data|blob):/i.test(b) || /\.mdl(?:[?#].*)?$/i.test(b)) continue;
|
|
387
|
-
let S;
|
|
388
|
-
try {
|
|
389
|
-
S = new URL(b, y.url);
|
|
390
|
-
} catch {
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
const x = /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(b), O = je(S.href, n), C = y.absolute || x;
|
|
394
|
-
if (l === "package" && !p.has(O) && !vt(S, t)) {
|
|
395
|
-
const v = C ? S.href : kt(S.href, t), B = `${n}/__skipped__/${encodeURIComponent(v)}`;
|
|
396
|
-
h[m][b] = B, a.set(B, v), _.has(v) || (_.add(v), i == null || i(v));
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
h[m][b] = O, d.push({
|
|
400
|
-
url: S,
|
|
401
|
-
depth: y.depth + 1,
|
|
402
|
-
recurse: ws(S.pathname),
|
|
403
|
-
absolute: C,
|
|
404
|
-
owner: { path: m, reference: b }
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return h;
|
|
409
|
-
}
|
|
410
|
-
function ws(e) {
|
|
411
|
-
var n, s;
|
|
412
|
-
const t = (s = (n = e.split(/[?#]/, 1)[0]) == null ? void 0 : n.split(".").pop()) == null ? void 0 : s.toLowerCase();
|
|
413
|
-
return t != null && ds.has(t);
|
|
414
|
-
}
|
|
415
|
-
function kt(e, t) {
|
|
416
|
-
const n = new URL(e);
|
|
417
|
-
if (n.protocol !== t.protocol || n.host !== t.host) return n.href;
|
|
418
|
-
const s = new URL(".", t).pathname.split("/").filter(Boolean), r = n.pathname.split("/").filter(Boolean);
|
|
419
|
-
let o = 0;
|
|
420
|
-
for (; o < s.length && s[o] === r[o]; ) o++;
|
|
421
|
-
const a = [...s.slice(o).map(() => ".."), ...r.slice(o)].join("/");
|
|
422
|
-
return decodeURIComponent(a) + n.search + n.hash;
|
|
423
|
-
}
|
|
424
|
-
function je(e, t) {
|
|
425
|
-
const n = new URL(e), s = encodeURIComponent(`${n.protocol}//${n.host}`);
|
|
426
|
-
let r = n.pathname.split("/").map((o) => decodeURIComponent(o).replaceAll("/", "%2F").replaceAll("\\", "%5C")).join("/");
|
|
427
|
-
if (n.search || n.hash) {
|
|
428
|
-
const o = r.lastIndexOf("."), a = o > r.lastIndexOf("/") ? o : r.length;
|
|
429
|
-
r = `${r.slice(0, a)}.__url_${encodeURIComponent(n.search + n.hash)}${r.slice(a)}`;
|
|
430
|
-
}
|
|
431
|
-
return `${t}/${s}${r}`;
|
|
432
|
-
}
|
|
433
|
-
function ft(e, t) {
|
|
434
|
-
if (!e || typeof e != "object" || ArrayBuffer.isView(e)) return;
|
|
435
|
-
const n = e;
|
|
436
|
-
if (typeof n.path == "string" && typeof n.resolvedPath == "string") {
|
|
437
|
-
for (const s of ["path", "resolvedPath"]) {
|
|
438
|
-
const r = n[s];
|
|
439
|
-
n[s] = t.get(r) ?? r;
|
|
440
|
-
}
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
for (const s of Object.values(e)) ft(s, t);
|
|
444
|
-
}
|
|
445
|
-
function cn(e, t) {
|
|
446
|
-
if (e.analyzePath(t).exists) {
|
|
447
|
-
for (const n of e.readdir(t)) {
|
|
448
|
-
if (n === "." || n === "..") continue;
|
|
449
|
-
const s = `${t}/${n}`;
|
|
450
|
-
e.isDir(e.stat(s).mode) ? cn(e, s) : e.unlink(s);
|
|
451
|
-
}
|
|
452
|
-
e.rmdir(t);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
function dt(e, t, n, s) {
|
|
456
|
-
s.has(t) || (e.FS.mkdirTree(t.split("/").slice(0, -1).join("/") || "/"), e.FS.writeFile(t, n), s.add(t));
|
|
457
|
-
}
|
|
458
|
-
async function Ft(e) {
|
|
459
|
-
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());
|
|
460
|
-
}
|
|
461
|
-
async function bs(e) {
|
|
462
|
-
if (!e) throw new Error("createSingleThreadUsd needs wasmUrl or wasmBinary.");
|
|
463
|
-
return (await fetch(e)).arrayBuffer();
|
|
464
|
-
}
|
|
465
|
-
const Ss = "/openusd/";
|
|
466
|
-
function vs(e) {
|
|
467
|
-
const t = (e ?? Ss).replace(/\/*$/, "/"), n = typeof document > "u" ? new URL(t, "file:///").href : new URL(t, document.baseURI).href;
|
|
468
|
-
return {
|
|
469
|
-
moduleUrl: new URL("openusd_probe.js", n).href,
|
|
470
|
-
wasmUrl: new URL("openusd_probe.wasm", n).href
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
function Us(e) {
|
|
474
|
-
var c, u;
|
|
475
|
-
const t = e.stage, n = e.pxr;
|
|
476
|
-
if (!t || !((c = n == null ? void 0 : n.Sdf) != null && c.Path) || !((u = n == null ? void 0 : n.Usd) != null && u.TimeCode)) return;
|
|
477
|
-
const s = n.Usd.TimeCode.Default(), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), a = (l) => {
|
|
478
|
-
let p, i, f;
|
|
479
|
-
try {
|
|
480
|
-
if (p = new n.Sdf.Path(l), i = t.GetPrimAtPath(p), !i.IsValid() || (f = i.GetAttribute("doubleSided"), !f.IsValid() || typeof f.HasAuthoredValue != "function")) return "unknown";
|
|
481
|
-
if (!f.HasAuthoredValue()) return;
|
|
482
|
-
const h = f.Get(s);
|
|
483
|
-
return typeof h == "boolean" ? h : "unknown";
|
|
484
|
-
} catch {
|
|
485
|
-
return "unknown";
|
|
486
|
-
} finally {
|
|
487
|
-
f == null || f.delete(), i == null || i.delete(), p == null || p.delete();
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
try {
|
|
491
|
-
e.scene.traverse((l) => {
|
|
492
|
-
var d;
|
|
493
|
-
if (!(l instanceof me)) return;
|
|
494
|
-
const p = (d = l.userData.usd) == null ? void 0 : d.path;
|
|
495
|
-
if (typeof p != "string") return;
|
|
496
|
-
const i = a(p);
|
|
497
|
-
if (i === "unknown") return;
|
|
498
|
-
const f = i === !1 ? Tn : En, h = (g) => {
|
|
499
|
-
if (!(g instanceof W) || g.transmission <= 0 || g.metalness !== 0 || g.side === f) return g;
|
|
500
|
-
let _ = r.get(g);
|
|
501
|
-
_ || (_ = /* @__PURE__ */ new Map(), r.set(g, _));
|
|
502
|
-
let y = _.get(f);
|
|
503
|
-
return y || (y = g.clone(), y.side = f, y.needsUpdate = !0, y.userData.usdGlassSidePolicy = i === !1 ? "authored-false" : i === !0 ? "authored-true" : "viewer-default-double", _.set(f, y)), o.add(g), y;
|
|
504
|
-
};
|
|
505
|
-
if (Array.isArray(l.material)) {
|
|
506
|
-
const g = l.material, _ = g.map(h);
|
|
507
|
-
_.some((y, w) => y !== g[w]) && (l.material = _);
|
|
508
|
-
} else {
|
|
509
|
-
const g = h(l.material);
|
|
510
|
-
g !== l.material && (l.material = g);
|
|
511
|
-
}
|
|
512
|
-
}), e.scene.traverse((l) => {
|
|
513
|
-
if (l instanceof me) for (const p of Array.isArray(l.material) ? l.material : [l.material]) o.delete(p);
|
|
514
|
-
});
|
|
515
|
-
for (const l of o) l.dispose();
|
|
516
|
-
} finally {
|
|
517
|
-
s.delete();
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
function Os(e, t) {
|
|
521
|
-
if (!e.stage || t.shaders.length) return null;
|
|
522
|
-
const n = e.stage, s = e.pxr, r = s.Usd.TimeCode.Default(), o = (u, l) => {
|
|
523
|
-
const p = new s.Sdf.Path(u), i = n.GetPrimAtPath(p);
|
|
524
|
-
try {
|
|
525
|
-
if (!i.IsValid()) throw new Error("Missing prim");
|
|
526
|
-
return l(i);
|
|
527
|
-
} finally {
|
|
528
|
-
i.delete(), p.delete();
|
|
529
|
-
}
|
|
530
|
-
}, a = (u) => {
|
|
531
|
-
const l = u.GetConnections();
|
|
532
|
-
try {
|
|
533
|
-
return l.map((p) => typeof p == "string" ? p : p.GetString());
|
|
534
|
-
} finally {
|
|
535
|
-
for (const p of l) typeof p != "string" && p.delete();
|
|
536
|
-
}
|
|
537
|
-
}, c = (u, l = /* @__PURE__ */ new Set()) => {
|
|
538
|
-
if (l.has(u) || l.size >= 32) throw new Error("Cyclic material input");
|
|
539
|
-
l.add(u);
|
|
540
|
-
const p = u.lastIndexOf(".");
|
|
541
|
-
if (p < 0 || !u.slice(p + 1).startsWith("inputs:")) throw new Error("Not a constant input");
|
|
542
|
-
return o(u.slice(0, p), (i) => {
|
|
543
|
-
const f = i.GetAttribute(u.slice(p + 1));
|
|
544
|
-
try {
|
|
545
|
-
if (!f.IsValid()) throw new Error("Missing material input");
|
|
546
|
-
const h = a(f);
|
|
547
|
-
if (h.length > 1) throw new Error("Ambiguous material input");
|
|
548
|
-
const d = h.length ? c(h[0], l) : f.Get(r);
|
|
549
|
-
if (d == null) throw new Error("Unauthored material input");
|
|
550
|
-
return d;
|
|
551
|
-
} finally {
|
|
552
|
-
f.delete();
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
};
|
|
556
|
-
try {
|
|
557
|
-
return o(t.path, (u) => {
|
|
558
|
-
if (!u.IsInstance()) return null;
|
|
559
|
-
const l = u.GetAttribute("outputs:surface");
|
|
560
|
-
let p;
|
|
561
|
-
try {
|
|
562
|
-
if (!l.IsValid()) return null;
|
|
563
|
-
p = a(l);
|
|
564
|
-
} finally {
|
|
565
|
-
l.delete();
|
|
566
|
-
}
|
|
567
|
-
if (p.length !== 1 || !p[0].endsWith(".outputs:surface")) return null;
|
|
568
|
-
const i = p[0].slice(0, -16);
|
|
569
|
-
return o(i, (f) => {
|
|
570
|
-
const h = f.GetAttribute("info:id");
|
|
571
|
-
try {
|
|
572
|
-
if (h.Get(r) !== "UsdPreviewSurface") return null;
|
|
573
|
-
} finally {
|
|
574
|
-
h.delete();
|
|
575
|
-
}
|
|
576
|
-
const d = {}, g = f.GetAttributes();
|
|
577
|
-
try {
|
|
578
|
-
for (const y of g) {
|
|
579
|
-
const w = String(y.GetName());
|
|
580
|
-
w.startsWith("inputs:") && (d[w] = c(`${i}.${w}`));
|
|
581
|
-
}
|
|
582
|
-
} finally {
|
|
583
|
-
for (const y of g) y.delete();
|
|
584
|
-
}
|
|
585
|
-
return { ...t, shaders: [{ path: i, id: "UsdPreviewSurface", inputs: d }] };
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
} catch {
|
|
589
|
-
return null;
|
|
590
|
-
} finally {
|
|
591
|
-
r.delete();
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
function Ae(e, t, n = 1, s = 0, r = "rgb") {
|
|
595
|
-
var f;
|
|
596
|
-
const o = e.image, a = (o == null ? void 0 : o.naturalWidth) || (o == null ? void 0 : o.width), c = (o == null ? void 0 : o.naturalHeight) || (o == null ? void 0 : o.height);
|
|
597
|
-
if (!Number.isInteger(a) || !Number.isInteger(c) || a <= 0 || c <= 0) throw new Error("Texture has no decoded pixels");
|
|
598
|
-
let u;
|
|
599
|
-
if (e instanceof Ct) {
|
|
600
|
-
if (e.type !== Dt || e.format !== Tt || ((f = o.data) == null ? void 0 : f.length) !== a * c * 4) throw new Error("Unsupported scalar pixel format");
|
|
601
|
-
u = o.data;
|
|
602
|
-
} else {
|
|
603
|
-
const h = document.createElement("canvas");
|
|
604
|
-
h.width = a, h.height = c;
|
|
605
|
-
const d = h.getContext("2d", { willReadFrequently: !0 });
|
|
606
|
-
if (!d) throw new Error("Scalar conversion requires a 2D canvas");
|
|
607
|
-
d.drawImage(o, 0, 0), u = d.getImageData(0, 0, a, c).data;
|
|
608
|
-
}
|
|
609
|
-
const l = new Uint8Array(a * c * 4), p = "rgba".indexOf(t);
|
|
610
|
-
for (let h = 0; h < l.length; h += 4) {
|
|
611
|
-
const d = u[h], g = u[h + 1], _ = u[h + 2];
|
|
612
|
-
if (t === "grayscale" && (d !== g || g !== _)) throw new Error("Non-grayscale scalar image needs an explicit mono convention");
|
|
613
|
-
const y = t === "average" ? (d + g + _) / 3 : t === "luminance" ? 0.2126 * d + 0.7152 * g + 0.0722 * _ : t === "maximum" ? Math.max(d, g, _) : t === "grayscale" ? d : u[h + p], w = Math.round(255 * Math.min(1, Math.max(0, y / 255 * n + s)));
|
|
614
|
-
l[h] = l[h + 1] = l[h + 2] = w, l[h + 3] = r === "a" ? w : 255;
|
|
615
|
-
}
|
|
616
|
-
const i = new Ct(l, a, c, Tt, Dt);
|
|
617
|
-
return i.wrapS = e.wrapS, i.wrapT = e.wrapT, i.offset.copy(e.offset), i.repeat.copy(e.repeat), i.center.copy(e.center), i.rotation = e.rotation, i.matrix.copy(e.matrix), i.matrixAutoUpdate = e.matrixAutoUpdate, i.channel = e.channel, i.flipY = e.flipY, i.minFilter = e.minFilter, i.magFilter = e.magFilter, i.anisotropy = e.anisotropy, i.generateMipmaps = e.generateMipmaps, i.colorSpace = re, i.needsUpdate = !0, i;
|
|
618
|
-
}
|
|
619
|
-
const Ps = [1, 1, 1, 1], Rs = [0, 0, 0, 0];
|
|
620
|
-
function Gt(e, t) {
|
|
621
|
-
const n = [], s = e.shaders.map((o) => ({
|
|
622
|
-
path: o.path,
|
|
623
|
-
id: o.id,
|
|
624
|
-
inputs: Object.freeze({ ...o.inputs }),
|
|
625
|
-
connections: ln(o)
|
|
626
|
-
})), r = t ? Is(e, t, n) : [];
|
|
627
|
-
return Object.freeze({
|
|
628
|
-
schemaVersion: 1,
|
|
629
|
-
materialPath: e.path,
|
|
630
|
-
surfacePath: (t == null ? void 0 : t.path) ?? null,
|
|
631
|
-
surfaceShaderId: (t == null ? void 0 : t.id) ?? null,
|
|
632
|
-
dialect: As(t),
|
|
633
|
-
workflow: Ms(e, t),
|
|
634
|
-
materialInputs: Object.freeze({ ...e.inputs }),
|
|
635
|
-
alpha: xs(e, t),
|
|
636
|
-
nodes: Object.freeze(s),
|
|
637
|
-
textures: Object.freeze(r),
|
|
638
|
-
issues: Object.freeze(n),
|
|
639
|
-
program: null
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
function we(e) {
|
|
643
|
-
const t = Array.isArray(e) ? e[0] : e;
|
|
644
|
-
if (typeof t != "string" || t.length === 0) return null;
|
|
645
|
-
const n = /^(.*?)(?:\.outputs:([^/]+))?$/.exec(t);
|
|
646
|
-
return n != null && n[1] ? { path: n[1], outputName: n[2] ?? null } : null;
|
|
647
|
-
}
|
|
648
|
-
function ln(e) {
|
|
649
|
-
const t = /* @__PURE__ */ new Map(), n = (s, r) => {
|
|
650
|
-
const o = r ? ".resolvedConnect" : ".connect";
|
|
651
|
-
if (!s.endsWith(o)) return;
|
|
652
|
-
const a = s.slice(0, -o.length);
|
|
653
|
-
if (r)
|
|
654
|
-
t.delete(a);
|
|
655
|
-
else if (t.has(a))
|
|
656
|
-
return;
|
|
657
|
-
const c = we(e.inputs[s]);
|
|
658
|
-
c && t.set(a, {
|
|
659
|
-
inputName: a.replace(/^inputs:/, ""),
|
|
660
|
-
sourcePath: c.path,
|
|
661
|
-
outputName: c.outputName
|
|
662
|
-
});
|
|
663
|
-
};
|
|
664
|
-
for (const s of Object.keys(e.inputs)) n(s, !0);
|
|
665
|
-
for (const s of Object.keys(e.inputs)) n(s, !1);
|
|
666
|
-
return Object.freeze([...t.values()]);
|
|
667
|
-
}
|
|
668
|
-
function Is(e, t, n) {
|
|
669
|
-
const s = [];
|
|
670
|
-
for (const r of ln(t)) {
|
|
671
|
-
let o = r.sourcePath, a = r.outputName;
|
|
672
|
-
const c = pn(e, o);
|
|
673
|
-
if (c) {
|
|
674
|
-
const d = e.inputs[`inputs:${c}.resolvedConnect`] ?? e.inputs[`inputs:${c}.connect`], g = we(d);
|
|
675
|
-
if (g)
|
|
676
|
-
o = g.path, a = g.outputName;
|
|
677
|
-
else if (e.inputs[`inputs:${c}`] !== void 0)
|
|
678
|
-
continue;
|
|
679
|
-
}
|
|
680
|
-
const u = e.shaders.find((d) => d.path === o);
|
|
681
|
-
if (!u) {
|
|
682
|
-
n.push({
|
|
683
|
-
code: "DANGLING_CONNECTION",
|
|
684
|
-
sourcePath: o,
|
|
685
|
-
message: `材质 ${e.path} 的输入 ${r.inputName} 指向不存在的 shader ${o}。`
|
|
686
|
-
});
|
|
687
|
-
continue;
|
|
688
|
-
}
|
|
689
|
-
const l = Bs(r.inputName), p = Ts(u) ?? (l === "normal" ? be(ve(u, ["texture"])) : null);
|
|
690
|
-
if (!p) {
|
|
691
|
-
mn(u) ? n.push({
|
|
692
|
-
code: "MISSING_TEXTURE_ASSET",
|
|
693
|
-
sourcePath: u.path,
|
|
694
|
-
message: `材质 ${e.path} 的纹理 ${u.path} 没有可解析的资源路径。`
|
|
695
|
-
}) : n.push({
|
|
696
|
-
code: "UNSUPPORTED_SURFACE_NODE",
|
|
697
|
-
sourcePath: u.path,
|
|
698
|
-
message: `材质 ${e.path} 的输入 ${r.inputName} 连接到尚未求值的节点 ${u.id ?? u.path}。`
|
|
699
|
-
});
|
|
700
|
-
continue;
|
|
701
|
-
}
|
|
702
|
-
const i = Ns(a);
|
|
703
|
-
if (!i) {
|
|
704
|
-
n.push({
|
|
705
|
-
code: "UNKNOWN_TEXTURE_OUTPUT",
|
|
706
|
-
sourcePath: u.path,
|
|
707
|
-
message: `材质 ${e.path} 的纹理 ${u.path} 使用未知输出 ${a ?? "<null>"}。`
|
|
708
|
-
});
|
|
709
|
-
continue;
|
|
710
|
-
}
|
|
711
|
-
const f = Vt(u, "scale", Ps), h = Vt(u, "bias", Rs);
|
|
712
|
-
s.push(Object.freeze({
|
|
713
|
-
surfaceInput: r.inputName,
|
|
714
|
-
shaderPath: u.path,
|
|
715
|
-
path: p,
|
|
716
|
-
sourceChannel: i,
|
|
717
|
-
semantic: l,
|
|
718
|
-
sourceColorSpace: Gs(u, l),
|
|
719
|
-
scale: f,
|
|
720
|
-
bias: h,
|
|
721
|
-
uvSet: Es(e, u),
|
|
722
|
-
uvTransform: $s(e, u, n),
|
|
723
|
-
wrapS: zt(u, "wrapS", "wrap_s"),
|
|
724
|
-
wrapT: zt(u, "wrapT", "wrap_t"),
|
|
725
|
-
fallback: ks(u, ["fallback", "value"]),
|
|
726
|
-
...Vs(u)
|
|
727
|
-
}));
|
|
728
|
-
}
|
|
729
|
-
return s;
|
|
730
|
-
}
|
|
731
|
-
function pn(e, t) {
|
|
732
|
-
const n = /^(.*)\.inputs:([^/.]+)$/.exec(t);
|
|
733
|
-
return (n == null ? void 0 : n[1]) === e.path && n[2] ? n[2] : null;
|
|
734
|
-
}
|
|
735
|
-
function As(e) {
|
|
736
|
-
var o;
|
|
737
|
-
if (!e) return "unknown";
|
|
738
|
-
const t = e.id ?? "";
|
|
739
|
-
if (/^(?:UsdPreviewSurface|ND_UsdPreviewSurface_surfaceshader)$/i.test(t)) return "usd-preview";
|
|
740
|
-
if (/open.?pbr/i.test(t)) return "openpbr";
|
|
741
|
-
if (/standard.?surface/i.test(t) && /mtlx|ND_/i.test(t) || /standard.?surface/i.test(t)) return "materialx-standard-surface";
|
|
742
|
-
if (/PxrSurface/i.test(t)) return "pxr-surface";
|
|
743
|
-
const n = be(e.inputs["info:mdl:sourceAsset"]), s = (o = n == null ? void 0 : n.split(/[\\/]/).at(-1)) == null ? void 0 : o.toLowerCase(), r = ke(e, "info:mdl:sourceAsset:subIdentifier");
|
|
744
|
-
return s === "omnipbr.mdl" ? "omnipbr" : hn(e) ? "omni-pbr-base" : s === "omniglass.mdl" ? "omniglass" : s === "omnisurfacebase.mdl" || (r == null ? void 0 : r.toLowerCase()) === "omnisurfacebase" ? "omni-surface-base" : Ot(e) ? "gltf-material" : "unknown";
|
|
745
|
-
}
|
|
746
|
-
function Ms(e, t) {
|
|
747
|
-
return t ? Ot(t) ? "metallic" : Fs(t) ? "specular" : hn(t) ? "metallic" : /UsdPreviewSurface/i.test(t.id ?? "") ? Ie(e, t, ["useSpecularWorkflow"]).value === !0 ? "specular" : "metallic" : "unknown" : "unknown";
|
|
748
|
-
}
|
|
749
|
-
function xs(e, t) {
|
|
750
|
-
if (!t) return Object.freeze({ mode: "opaque", cutoff: 0, opacityMode: null });
|
|
751
|
-
if (Ot(t)) return Cs(e, t);
|
|
752
|
-
if (Ds(t) && !dn(t, "enable_opacity", !1))
|
|
753
|
-
return Object.freeze({ mode: "opaque", cutoff: 0, opacityMode: null });
|
|
754
|
-
const n = mt(Ie(
|
|
755
|
-
e,
|
|
756
|
-
t,
|
|
757
|
-
["opacityThreshold", "opacity_threshold", "geometry_opacity_threshold", "alphaCutoff"]
|
|
758
|
-
).value) ?? 0, s = Ie(e, t, ["opacityMode"]).value, r = s === "presence" ? "presence" : s === "transparent" ? "transparent" : null;
|
|
759
|
-
if (n > 0)
|
|
760
|
-
return Object.freeze({ mode: "mask", cutoff: ht(n), opacityMode: r });
|
|
761
|
-
const a = Ls(Ie(
|
|
762
|
-
e,
|
|
763
|
-
t,
|
|
764
|
-
["opacity", "presence", "geometry_opacity", "opacity_constant"]
|
|
765
|
-
).value).some((u) => u < 1), c = ["opacity", "presence", "geometry_opacity", "opacity_constant"].some((u) => Ie(e, t, [u]).connection !== null);
|
|
766
|
-
return Object.freeze({
|
|
767
|
-
mode: a || c ? "blend" : "opaque",
|
|
768
|
-
cutoff: 0,
|
|
769
|
-
opacityMode: r
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
function Cs(e, t) {
|
|
773
|
-
const n = Ie(e, t, ["alpha_mode"]).value, s = n === 1 || n === "mask" ? "mask" : n === 2 || n === "blend" ? "blend" : "opaque";
|
|
774
|
-
if (s === "mask") {
|
|
775
|
-
const r = mt(Ie(
|
|
776
|
-
e,
|
|
777
|
-
t,
|
|
778
|
-
["alpha_cutoff"]
|
|
779
|
-
).value) ?? 0.5;
|
|
780
|
-
return Object.freeze({ mode: s, cutoff: ht(r), opacityMode: null, opacity: null });
|
|
781
|
-
}
|
|
782
|
-
if (s === "blend") {
|
|
783
|
-
const r = mt(Ie(
|
|
784
|
-
e,
|
|
785
|
-
t,
|
|
786
|
-
["base_alpha"]
|
|
787
|
-
).value) ?? 1;
|
|
788
|
-
return Object.freeze({
|
|
789
|
-
mode: s,
|
|
790
|
-
cutoff: 0,
|
|
791
|
-
opacityMode: "transparent",
|
|
792
|
-
opacity: ht(r)
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
return Object.freeze({ mode: s, cutoff: 0, opacityMode: null, opacity: null });
|
|
796
|
-
}
|
|
797
|
-
function Ds(e) {
|
|
798
|
-
var n, s;
|
|
799
|
-
const t = (s = (n = be(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : n.split(/[\\/]/).at(-1)) == null ? void 0 : s.toLowerCase();
|
|
800
|
-
return t === "omnipbr.mdl" || t === "omnipbrbase.mdl" || t === "omniglass.mdl";
|
|
801
|
-
}
|
|
802
|
-
function Ts(e) {
|
|
803
|
-
return mn(e) ? be(ve(e, ["file", "filename", "texture"])) : null;
|
|
804
|
-
}
|
|
805
|
-
function Es(e, t) {
|
|
806
|
-
if (nt(t)) {
|
|
807
|
-
const r = Be(t, ["tex_coord_index"]);
|
|
808
|
-
return r !== null && Number.isInteger(r) && r >= 0 ? `texcoord${r}` : null;
|
|
809
|
-
}
|
|
810
|
-
const n = we(t.inputs["inputs:st.resolvedConnect"] ?? t.inputs["inputs:st.connect"]);
|
|
811
|
-
if (!n) return null;
|
|
812
|
-
let s = e.shaders.find((r) => r.path === n.path);
|
|
813
|
-
if (s && /^(?:UsdTransform2d|ND_transform2d_vector2)$/i.test(s.id ?? "")) {
|
|
814
|
-
const r = we(
|
|
815
|
-
s.inputs["inputs:in.resolvedConnect"] ?? s.inputs["inputs:in.connect"]
|
|
816
|
-
);
|
|
817
|
-
s = r ? e.shaders.find((o) => o.path === r.path) : void 0;
|
|
818
|
-
}
|
|
819
|
-
return s ? fn(s, ["varname"]) : null;
|
|
820
|
-
}
|
|
821
|
-
function $s(e, t, n) {
|
|
822
|
-
if (nt(t)) {
|
|
823
|
-
const o = Ye(t, "scale", [1, 1]), a = Be(t, ["rotation"]) ?? 0, c = Ye(t, "offset", [0, 0]);
|
|
824
|
-
return o[0] === 1 && o[1] === 1 && a === 0 && c[0] === 0 && c[1] === 0 ? null : Object.freeze({
|
|
825
|
-
sourcePath: t.path,
|
|
826
|
-
scale: o,
|
|
827
|
-
rotation: a * 180 / Math.PI,
|
|
828
|
-
translation: c
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
const s = we(t.inputs["inputs:st.resolvedConnect"] ?? t.inputs["inputs:st.connect"]);
|
|
832
|
-
if (!s) return null;
|
|
833
|
-
const r = e.shaders.find((o) => o.path === s.path);
|
|
834
|
-
return !r || /^UsdPrimvarReader_float2$/i.test(r.id ?? "") ? null : /^(?:UsdTransform2d|ND_transform2d_vector2)$/i.test(r.id ?? "") ? Object.freeze({
|
|
835
|
-
sourcePath: r.path,
|
|
836
|
-
scale: Ye(r, "scale", [1, 1]),
|
|
837
|
-
rotation: Be(r, ["rotation"]) ?? 0,
|
|
838
|
-
translation: Ye(r, "translation", [0, 0])
|
|
839
|
-
}) : (n.push({
|
|
840
|
-
code: "TEXTURE_UV_UNSUPPORTED",
|
|
841
|
-
sourcePath: r.path,
|
|
842
|
-
message: `材质纹理 ${t.path} 的 UV 上游 ${r.id ?? r.path} 尚未映射。`
|
|
843
|
-
}), null);
|
|
844
|
-
}
|
|
845
|
-
function Ns(e) {
|
|
846
|
-
return !e || /^(?:out|result)$/i.test(e) ? "rgb" : /^(?:mono|resultMono)$/i.test(e) ? "mono" : /^(?:tint|resultTint)$/i.test(e) ? "rgb" : /^(?:r|resultR)$/i.test(e) ? "r" : /^(?:g|resultG)$/i.test(e) ? "g" : /^(?:b|resultB)$/i.test(e) ? "b" : /^(?:a|resultA|alpha)$/i.test(e) ? "a" : /^(?:rgb|resultRGB)$/i.test(e) ? "rgb" : null;
|
|
847
|
-
}
|
|
848
|
-
function Bs(e) {
|
|
849
|
-
return /(?:roughness|metalness|metallic|occlusion|opacity|transmission|thickness)$/i.test(e) ? "scalar" : /(?:^|\.)(?:normal|normal_texture|normalmap_texture|normalCamera|geometry_normal)$/i.test(e) ? "normal" : /(?:diffuse|base.?color|emission|emissive|sheen|fuzz|specular.?color|coat.?color)/i.test(e) ? "color" : "scalar";
|
|
850
|
-
}
|
|
851
|
-
function ve(e, t) {
|
|
852
|
-
for (const n of t) {
|
|
853
|
-
const s = e.inputs[`inputs:${n}`];
|
|
854
|
-
if (s !== void 0) return s;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
function Ie(e, t, n) {
|
|
858
|
-
for (const s of n) {
|
|
859
|
-
const r = we(
|
|
860
|
-
t.inputs[`inputs:${s}.resolvedConnect`] ?? t.inputs[`inputs:${s}.connect`]
|
|
861
|
-
);
|
|
862
|
-
if (r) {
|
|
863
|
-
const a = pn(e, r.path);
|
|
864
|
-
if (!a) return { value: void 0, connection: r };
|
|
865
|
-
const c = we(
|
|
866
|
-
e.inputs[`inputs:${a}.resolvedConnect`] ?? e.inputs[`inputs:${a}.connect`]
|
|
867
|
-
);
|
|
868
|
-
return c ? { value: void 0, connection: c } : {
|
|
869
|
-
value: e.inputs[`inputs:${a}`],
|
|
870
|
-
connection: null
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
const o = t.inputs[`inputs:${s}`];
|
|
874
|
-
if (o !== void 0) return { value: o, connection: null };
|
|
875
|
-
}
|
|
876
|
-
return { value: void 0, connection: null };
|
|
877
|
-
}
|
|
878
|
-
function mt(e) {
|
|
879
|
-
return typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
880
|
-
}
|
|
881
|
-
function Ls(e) {
|
|
882
|
-
return typeof e == "number" && Number.isFinite(e) ? [e] : Array.isArray(e) ? e.every((t) => typeof t == "number" && Number.isFinite(t)) ? e : [] : [];
|
|
883
|
-
}
|
|
884
|
-
function fn(e, t) {
|
|
885
|
-
const n = ve(e, t);
|
|
886
|
-
return typeof n == "string" && n.length > 0 ? n : null;
|
|
887
|
-
}
|
|
888
|
-
function dn(e, t, n) {
|
|
889
|
-
const s = ve(e, [t]);
|
|
890
|
-
return typeof s == "boolean" ? s : n;
|
|
891
|
-
}
|
|
892
|
-
function Vt(e, t, n) {
|
|
893
|
-
const s = ve(e, [t]);
|
|
894
|
-
return !Array.isArray(s) || s.length !== 4 ? n : s.every((r) => typeof r == "number" && Number.isFinite(r)) ? Object.freeze([...s]) : n;
|
|
895
|
-
}
|
|
896
|
-
function Ye(e, t, n) {
|
|
897
|
-
const s = ve(e, [t]);
|
|
898
|
-
return Array.isArray(s) && s.length >= 2 && typeof s[0] == "number" && Number.isFinite(s[0]) && typeof s[1] == "number" && Number.isFinite(s[1]) ? Object.freeze([s[0], s[1]]) : n;
|
|
899
|
-
}
|
|
900
|
-
function ks(e, t) {
|
|
901
|
-
const n = ve(e, t);
|
|
902
|
-
return Array.isArray(n) && n.every((s) => typeof s == "number" && Number.isFinite(s)) ? Object.freeze([...n]) : null;
|
|
903
|
-
}
|
|
904
|
-
function Be(e, t) {
|
|
905
|
-
const n = ve(e, t);
|
|
906
|
-
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
907
|
-
}
|
|
908
|
-
function ht(e) {
|
|
909
|
-
return Math.min(1, Math.max(0, e));
|
|
910
|
-
}
|
|
911
|
-
function mn(e) {
|
|
912
|
-
return /^(?:UsdUVTexture|PxrTexture|normalmap_texture)$/i.test(_n(e)) || nt(e) || Ut(e);
|
|
913
|
-
}
|
|
914
|
-
function Ut(e) {
|
|
915
|
-
var s, r, o;
|
|
916
|
-
const t = (s = be(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/"), n = (r = ke(e, "info:mdl:sourceAsset:subIdentifier")) == null ? void 0 : r.toLowerCase();
|
|
917
|
-
return ((o = t == null ? void 0 : t.split("/").at(-1)) == null ? void 0 : o.toLowerCase()) === "core_definitions.mdl" && (n === "file_texture" || ve(e, ["texture"]) !== void 0);
|
|
918
|
-
}
|
|
919
|
-
function nt(e) {
|
|
920
|
-
var s;
|
|
921
|
-
const t = _n(e);
|
|
922
|
-
if (/^(?:gltf_texture_lookup|gltf_normal_texture_lookup)$/i.test(t)) return !0;
|
|
923
|
-
const n = (s = be(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/");
|
|
924
|
-
return /(?:^|\/)gltf\/pbr\.mdl$/i.test(n ?? "") ? be(e.inputs["inputs:texture"]) !== null && (e.inputs["inputs:tex_coord_index"] !== void 0 || e.inputs["inputs:wrap_s"] !== void 0 || e.inputs["inputs:wrap_t"] !== void 0) : !1;
|
|
925
|
-
}
|
|
926
|
-
function Ot(e) {
|
|
927
|
-
var s, r;
|
|
928
|
-
const t = (s = be(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/");
|
|
929
|
-
if (!/(?:^|\/)gltf\/pbr\.mdl$/i.test(t ?? "")) return !1;
|
|
930
|
-
const n = (r = ke(e, "info:mdl:sourceAsset:subIdentifier")) == null ? void 0 : r.toLowerCase();
|
|
931
|
-
return n ? n === "gltf_material" : [
|
|
932
|
-
"inputs:base_color_factor",
|
|
933
|
-
"inputs:metallic_factor",
|
|
934
|
-
"inputs:roughness_factor",
|
|
935
|
-
"inputs:alpha_mode",
|
|
936
|
-
"inputs:base_alpha",
|
|
937
|
-
"inputs:base_color_texture.connect",
|
|
938
|
-
"inputs:normal_texture.connect"
|
|
939
|
-
].some((o) => e.inputs[o] !== void 0);
|
|
940
|
-
}
|
|
941
|
-
function Fs(e) {
|
|
942
|
-
var n;
|
|
943
|
-
const t = (n = be(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : n.replaceAll("\\", "/");
|
|
944
|
-
return /(?:^|\/)OmniSurface\/OmniSurfaceBase\.mdl$/i.test(t ?? "") || (ke(e, "info:mdl:sourceAsset:subIdentifier") ?? "").toLowerCase() === "omnisurfacebase";
|
|
945
|
-
}
|
|
946
|
-
function hn(e) {
|
|
947
|
-
var s, r, o;
|
|
948
|
-
const t = (s = be(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/"), n = (r = ke(e, "info:mdl:sourceAsset:subIdentifier")) == null ? void 0 : r.toLowerCase();
|
|
949
|
-
return ((o = t == null ? void 0 : t.split("/").at(-1)) == null ? void 0 : o.toLowerCase()) !== "omnipbrbase.mdl" ? !1 : n ? n === "omnipbrbase" : [
|
|
950
|
-
"inputs:diffuse_reflection_color",
|
|
951
|
-
"inputs:geometry_opacity",
|
|
952
|
-
"inputs:specular_level",
|
|
953
|
-
"inputs:enable_coat",
|
|
954
|
-
"inputs:specular_reflection_roughness"
|
|
955
|
-
].some((a) => e.inputs[a] !== void 0 || e.inputs[`${a}.connect`] !== void 0 || e.inputs[`${a}.resolvedConnect`] !== void 0);
|
|
956
|
-
}
|
|
957
|
-
function _n(e) {
|
|
958
|
-
return ke(e, "info:mdl:sourceAsset:subIdentifier") ?? e.id ?? "";
|
|
959
|
-
}
|
|
960
|
-
function Gs(e, t) {
|
|
961
|
-
const n = fn(e, ["sourceColorSpace", "fileColorSpace"]);
|
|
962
|
-
return n && n.toLowerCase() !== "auto" ? n : t === "normal" ? "raw" : Ut(e) || nt(e) || (n == null ? void 0 : n.toLowerCase()) === "auto" ? t === "color" ? "sRGB" : "raw" : null;
|
|
963
|
-
}
|
|
964
|
-
function Vs(e) {
|
|
965
|
-
return Ut(e) ? {
|
|
966
|
-
monoSource: Be(e, ["mono_source"]),
|
|
967
|
-
brightness: Be(e, ["brightness"]) ?? 1,
|
|
968
|
-
contrast: Be(e, ["contrast"]) ?? 1,
|
|
969
|
-
invert: dn(e, "invert", !1)
|
|
970
|
-
} : {};
|
|
971
|
-
}
|
|
972
|
-
function zt(e, t, n) {
|
|
973
|
-
const s = ve(e, [t, n]);
|
|
974
|
-
return typeof s == "string" && s.length > 0 ? s : s === 10497 ? "repeat" : s === 33648 ? "mirror" : s === 33071 ? "clamp" : null;
|
|
975
|
-
}
|
|
976
|
-
function ke(e, t) {
|
|
977
|
-
const n = e.inputs[t];
|
|
978
|
-
return typeof n == "string" && n.length > 0 ? n : null;
|
|
979
|
-
}
|
|
980
|
-
function be(e) {
|
|
981
|
-
if (typeof e == "string") return e;
|
|
982
|
-
if (!e || typeof e != "object") return null;
|
|
983
|
-
for (const t of ["path", "resolvedPath", "url"]) {
|
|
984
|
-
const n = e[t];
|
|
985
|
-
if (typeof n == "string" && n.length > 0) return n;
|
|
986
|
-
}
|
|
987
|
-
return null;
|
|
988
|
-
}
|
|
989
|
-
function zs(e, t, n) {
|
|
990
|
-
const s = [], r = [], o = [];
|
|
991
|
-
let a = !1;
|
|
992
|
-
const c = [], u = {}, l = (k) => k.some((M) => xe(e, n, M) !== null || Me(e, n, M) !== void 0), p = (k) => {
|
|
993
|
-
for (const M of k) {
|
|
994
|
-
if (xe(e, t, M)) return;
|
|
995
|
-
const V = Me(e, t, M);
|
|
996
|
-
if (V !== void 0) return V;
|
|
997
|
-
}
|
|
998
|
-
}, i = (k) => jt(p(k)), f = (k) => Wt(p(k)), h = (k, M) => {
|
|
999
|
-
c.push({ code: k, message: M });
|
|
1000
|
-
}, d = (k) => Wt(Me(e, n, k)), g = (k) => jt(Me(e, n, k)), _ = i(["base_weight"]), y = f(["base_color", "baseColor"]), w = d(["diffuseColor", "baseColor", "base_color"]);
|
|
1001
|
-
l(["diffuseColor", "baseColor", "base_color"]) && o.push("openpbr:base_color", "openpbr:baseColor", "openpbr:diffuseColor"), n && w ? (u.color = w, s.push("PreviewSurface.base_color.dual-basic")) : l(["diffuseColor", "baseColor", "base_color"]) || (y ? _ !== null && _ !== 1 ? _ < 0 ? r.push("OpenPBR.base_weight.range") : (u.color = y.multiplyScalar(_), s.push("OpenPBR.base_color.base_weight"), h(
|
|
1002
|
-
"USD_VISUAL_OPENPBR_BASE_WEIGHT_APPROXIMATION",
|
|
1003
|
-
"OpenPBR base_weight 已乘入基础颜色;未表达独立基础漫反射层与底层混合。"
|
|
1004
|
-
)) : (u.color = y, s.push("OpenPBR.base_color")) : _ !== null && _ < 1 && r.push("OpenPBR.base_weight.without-base-color"));
|
|
1005
|
-
const m = i(["base_metalness", "metalness"]), U = g(["metallic", "metalness"]);
|
|
1006
|
-
l(["metallic", "metalness"]) && o.push("openpbr:base_metalness", "openpbr:metalness", "openpbr:metallic"), n && U !== null && l(["metallic", "metalness"]) ? U >= 0 && U <= 1 ? (u.metalness = U, s.push("PreviewSurface.metalness.dual-basic")) : r.push("PreviewSurface.metallic.range") : m !== null && !l(["metallic", "metalness"]) && (m < 0 || m > 1 ? r.push("OpenPBR.base_metalness.range") : (u.metalness = m, s.push("OpenPBR.base_metalness")));
|
|
1007
|
-
const b = i(["specular_roughness", "roughness"]), S = g(["roughness"]);
|
|
1008
|
-
l(["roughness"]) && o.push("openpbr:specular_roughness", "openpbr:roughness"), n && S !== null && l(["roughness"]) ? S >= 0 && S <= 1 ? (u.roughness = S, s.push("PreviewSurface.roughness.dual-basic")) : r.push("PreviewSurface.roughness.range") : b !== null && !l(["roughness"]) && (b < 0 || b > 1 ? r.push("OpenPBR.specular_roughness.range") : (u.roughness = b, s.push("OpenPBR.specular_roughness"))), i(["base_diffuse_roughness"]) !== null && r.push("OpenPBR.base_diffuse_roughness");
|
|
1009
|
-
const O = i(["specular_ior"]);
|
|
1010
|
-
O !== null && (O < 1 || O > 2.333333 ? r.push("OpenPBR.specular_ior.range") : (m ?? 0) >= 1 ? r.push("OpenPBR.specular_ior.pure-metal") : (u.ior = O, s.push("OpenPBR.specular_ior")));
|
|
1011
|
-
const C = f(["emission_color", "emissiveColor"]);
|
|
1012
|
-
C && (u.emissive = C, s.push("OpenPBR.emission_color"));
|
|
1013
|
-
const v = i(["emission_luminance"]);
|
|
1014
|
-
v !== null && (v < 0 ? r.push("OpenPBR.emission_luminance.range") : (u.emissiveIntensity = v, s.push("OpenPBR.emission_luminance"), h(
|
|
1015
|
-
"USD_VISUAL_OPENPBR_EMISSION_APPROXIMATION",
|
|
1016
|
-
"OpenPBR emission_luminance 已映射为 emissiveIntensity;未声明 nit 到实时曝光单位的严格换算。"
|
|
1017
|
-
)));
|
|
1018
|
-
const B = i(["specular_weight"]);
|
|
1019
|
-
B !== null && (B < 0 || B > 1 ? r.push("OpenPBR.specular_weight.range") : (u.specularIntensity = B, s.push("OpenPBR.specular_weight"), h(
|
|
1020
|
-
"USD_VISUAL_OPENPBR_SPECULAR_APPROXIMATION",
|
|
1021
|
-
"OpenPBR specular_weight 已映射为 specularIntensity;不等于 OpenPBR 完整电介质反射模型。"
|
|
1022
|
-
)));
|
|
1023
|
-
const E = f(["specular_color"]);
|
|
1024
|
-
E && (u.specularColor = E, s.push("OpenPBR.specular_color"), h(
|
|
1025
|
-
"USD_VISUAL_OPENPBR_SPECULAR_APPROXIMATION",
|
|
1026
|
-
"OpenPBR specular_color 已映射为 Three.js specularColor;不表达彩色金属边缘和完整分层反射。"
|
|
1027
|
-
));
|
|
1028
|
-
const R = i(["geometry_opacity"]), I = i(["transmission_weight", "transmission"]);
|
|
1029
|
-
R !== null && (R < 0 || R > 1) && r.push("OpenPBR.geometry_opacity.range"), I !== null && (I < 0 || I > 1) && r.push("OpenPBR.transmission_weight.range");
|
|
1030
|
-
const H = l(["opacity", "presence"]), P = R !== null && R > 0 && R < 1 && I !== null && I > 0, $ = I !== null || ["transmission_weight", "transmission", "transmissionWeight"].some((k) => xe(e, t, k) !== null);
|
|
1031
|
-
R !== null && R >= 0 && R <= 1 && !H && (u.opacity = R, s.push("OpenPBR.geometry_opacity"), P && (u.transmission = 0, a = !0, o.push("openpbr:transmission_weight", "openpbr:transmission", "openpbr:transmissionWeight"), r.push("OpenPBR.fractional-opacity-with-transmission"))), I !== null && I >= 0 && I <= 1 && !H && !P ? (u.transmission = I, I > 0 && (u.opacity = 1), s.push("OpenPBR.transmission_weight"), h(
|
|
1032
|
-
"USD_VISUAL_OPENPBR_TRANSMISSION_APPROXIMATION",
|
|
1033
|
-
"OpenPBR transmission_weight 已映射为实时透射;不表达彩色体积吸收、散射或完整薄壁/实体介质分层。"
|
|
1034
|
-
)) : H && $ && (u.transmission = 0, a = !0, o.push("openpbr:transmission_weight", "openpbr:transmission", "openpbr:transmissionWeight"), r.push("OpenPBR.transmission-suppressed-by-preview-coverage"));
|
|
1035
|
-
const J = Ws(p(["geometry_thin_walled"]));
|
|
1036
|
-
J === !0 ? (u.thickness = 0, s.push("OpenPBR.geometry_thin_walled")) : J === !1 && (I ?? 0) > 0 && r.push("OpenPBR.solid-transmission-without-thickness");
|
|
1037
|
-
const T = i(["coat_weight", "clearcoat"]);
|
|
1038
|
-
T !== null && (T < 0 || T > 1 ? r.push("OpenPBR.coat_weight.range") : (u.clearcoat = T, s.push("OpenPBR.coat_weight"), T === 0 && (u.clearcoatRoughness = 0)));
|
|
1039
|
-
const se = i(["coat_roughness"]);
|
|
1040
|
-
se !== null && (se < 0 || se > 1 ? r.push("OpenPBR.coat_roughness.range") : (T ?? 1) > 0 && (u.clearcoatRoughness = se, s.push("OpenPBR.coat_roughness")));
|
|
1041
|
-
for (const k of ["coat_color", "coat_ior", "coat_darkening", "coat_roughness_anisotropy"])
|
|
1042
|
-
Me(e, t, k) !== void 0 && r.push(`OpenPBR.${k}`);
|
|
1043
|
-
const A = i(["fuzz_weight"]), F = f(["fuzz_color", "sheenColor", "sheen_color"]), D = i(["fuzz_roughness", "sheenRoughness", "sheen_roughness"]);
|
|
1044
|
-
A !== null && (A < 0 || A > 1) && r.push("OpenPBR.fuzz_weight.range"), F ? (u.sheenColor = F, u.sheen = A ?? 1, s.push("OpenPBR.fuzz_color")) : (A ?? 0) > 0 && r.push("OpenPBR.fuzz-weight-without-color"), D !== null && (D < 0 || D > 1 ? r.push("OpenPBR.fuzz_roughness.range") : (u.sheenRoughness = D, s.push("OpenPBR.fuzz_roughness"))), (A !== null || F || D !== null) && h(
|
|
1045
|
-
"USD_VISUAL_OPENPBR_FUZZ_APPROXIMATION",
|
|
1046
|
-
"OpenPBR fuzz 已映射为 Three.js sheen;两者微表面模型不等价。"
|
|
1047
|
-
);
|
|
1048
|
-
const L = i(["specular_roughness_anisotropy", "anisotropy"]);
|
|
1049
|
-
L !== null && (L < 0 || L > 1 ? r.push("OpenPBR.specular_roughness_anisotropy.range") : (u.anisotropy = L, s.push("OpenPBR.specular_roughness_anisotropy"), h(
|
|
1050
|
-
"USD_VISUAL_OPENPBR_ANISOTROPY_APPROXIMATION",
|
|
1051
|
-
"OpenPBR 各向异性已映射到 Three.js anisotropy;依赖切线方向且不保证 BRDF 等价。"
|
|
1052
|
-
)));
|
|
1053
|
-
const K = i(["anisotropy_rotation"]);
|
|
1054
|
-
K !== null && (u.anisotropyRotation = K, s.push("OpenPBR.anisotropy_rotation"));
|
|
1055
|
-
for (const k of [
|
|
1056
|
-
"transmission_color",
|
|
1057
|
-
"transmission_depth",
|
|
1058
|
-
"transmission_scatter",
|
|
1059
|
-
"transmission_scatter_anisotropy",
|
|
1060
|
-
"subsurface_weight",
|
|
1061
|
-
"subsurface_color",
|
|
1062
|
-
"subsurface_radius",
|
|
1063
|
-
"subsurface_radius_scale",
|
|
1064
|
-
"subsurface_scatter_anisotropy",
|
|
1065
|
-
"thin_film_weight",
|
|
1066
|
-
"thin_film_thickness",
|
|
1067
|
-
"thin_film_ior"
|
|
1068
|
-
])
|
|
1069
|
-
(xe(e, t, k) || Me(e, t, k) !== void 0) && r.push(`OpenPBR.${k}`);
|
|
1070
|
-
for (const k of ["geometry_normal", "geometry_coat_normal", "geometry_tangent", "geometry_coat_tangent"])
|
|
1071
|
-
(xe(e, t, k) || Me(e, t, k) !== void 0) && r.push(`OpenPBR.${k}`);
|
|
1072
|
-
for (const k of [
|
|
1073
|
-
"geometry_opacity",
|
|
1074
|
-
"specular_ior",
|
|
1075
|
-
"emission_luminance",
|
|
1076
|
-
"fuzz_weight",
|
|
1077
|
-
"anisotropy_rotation",
|
|
1078
|
-
"geometry_thin_walled",
|
|
1079
|
-
"base_weight"
|
|
1080
|
-
])
|
|
1081
|
-
xe(e, t, k) && r.push(`OpenPBR.${k}.connection`);
|
|
1082
|
-
return {
|
|
1083
|
-
fields: u,
|
|
1084
|
-
applied: Object.freeze([...new Set(s)]),
|
|
1085
|
-
unsupported: Object.freeze([...new Set(r)]),
|
|
1086
|
-
suppressedInputs: Object.freeze([...new Set(o)]),
|
|
1087
|
-
clearTransmissionMap: a,
|
|
1088
|
-
approximations: Object.freeze(c),
|
|
1089
|
-
needsPhysical: Object.keys(u).some((k) => [
|
|
1090
|
-
"ior",
|
|
1091
|
-
"clearcoat",
|
|
1092
|
-
"clearcoatRoughness",
|
|
1093
|
-
"transmission",
|
|
1094
|
-
"thickness",
|
|
1095
|
-
"sheen",
|
|
1096
|
-
"sheenColor",
|
|
1097
|
-
"sheenRoughness",
|
|
1098
|
-
"anisotropy",
|
|
1099
|
-
"anisotropyRotation",
|
|
1100
|
-
"specularIntensity",
|
|
1101
|
-
"specularColor"
|
|
1102
|
-
].includes(k))
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
function js(e, t) {
|
|
1106
|
-
for (const n of e) {
|
|
1107
|
-
const s = t.fields;
|
|
1108
|
-
s.color && n.color.copy(s.color), s.roughness !== void 0 && (n.roughness = s.roughness), s.metalness !== void 0 && (n.metalness = s.metalness), s.emissive && n.emissive.copy(s.emissive), s.emissiveIntensity !== void 0 && (n.emissiveIntensity = s.emissiveIntensity), s.opacity !== void 0 && (n.opacity = s.opacity, n.transparent = s.opacity < 1, n.depthWrite = s.opacity >= 1), n instanceof W && (s.ior !== void 0 && (n.ior = s.ior), s.clearcoat !== void 0 && (n.clearcoat = s.clearcoat), s.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = s.clearcoatRoughness), s.transmission !== void 0 && (n.transmission = s.transmission, s.transmission > 0 && (n.opacity = 1, n.transparent = !1, n.depthWrite = !0)), t.clearTransmissionMap && (n.transmissionMap = null), s.thickness !== void 0 && (n.thickness = s.thickness), s.sheen !== void 0 && (n.sheen = s.sheen), s.sheenColor && n.sheenColor.copy(s.sheenColor), s.sheenRoughness !== void 0 && (n.sheenRoughness = s.sheenRoughness), s.anisotropy !== void 0 && (n.anisotropy = s.anisotropy), s.anisotropyRotation !== void 0 && (n.anisotropyRotation = s.anisotropyRotation), s.specularIntensity !== void 0 && (n.specularIntensity = s.specularIntensity), s.specularColor && n.specularColor.copy(s.specularColor)), n.needsUpdate = !0;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
function xe(e, t, n) {
|
|
1112
|
-
if (!t) return null;
|
|
1113
|
-
const s = t.inputs[`inputs:${n}.resolvedConnect`] ?? t.inputs[`inputs:${n}.connect`], r = we(s);
|
|
1114
|
-
if (!r) return null;
|
|
1115
|
-
const o = gn(e, r.path);
|
|
1116
|
-
return o ? we(
|
|
1117
|
-
e.inputs[`inputs:${o}.resolvedConnect`] ?? e.inputs[`inputs:${o}.connect`]
|
|
1118
|
-
) : r;
|
|
1119
|
-
}
|
|
1120
|
-
function Me(e, t, n) {
|
|
1121
|
-
if (t)
|
|
1122
|
-
for (const s of typeof n == "string" ? [n] : n) {
|
|
1123
|
-
const r = t.inputs[`inputs:${s}.resolvedConnect`] ?? t.inputs[`inputs:${s}.connect`], o = we(r);
|
|
1124
|
-
if (o) {
|
|
1125
|
-
const c = gn(e, o.path);
|
|
1126
|
-
return !c || xe(e, t, s) ? void 0 : e.inputs[`inputs:${c}`];
|
|
1127
|
-
}
|
|
1128
|
-
const a = t.inputs[`inputs:${s}`];
|
|
1129
|
-
if (a !== void 0) return a;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
function gn(e, t) {
|
|
1133
|
-
const n = /^(.*)\.inputs:([^/.]+)$/.exec(t);
|
|
1134
|
-
return (n == null ? void 0 : n[1]) === e.path && n[2] ? n[2] : null;
|
|
1135
|
-
}
|
|
1136
|
-
function jt(e) {
|
|
1137
|
-
return typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
1138
|
-
}
|
|
1139
|
-
function Wt(e) {
|
|
1140
|
-
return !Array.isArray(e) || e.length < 3 ? null : e.slice(0, 3).every((t) => typeof t == "number" && Number.isFinite(t)) ? new tt(e[0], e[1], e[2]) : null;
|
|
1141
|
-
}
|
|
1142
|
-
function Ws(e) {
|
|
1143
|
-
return typeof e == "boolean" ? e : null;
|
|
1144
|
-
}
|
|
1145
|
-
function Xs(e, t, n, s = [], r = !1) {
|
|
1146
|
-
if (e.some((l) => !Number.isInteger(l) || l < 0) || e.reduce((l, p) => l + p, 0) !== t.length || s.some((l) => !Number.isInteger(l) || l < 0 || l >= e.length))
|
|
1147
|
-
throw new Error("Invalid authored face topology");
|
|
1148
|
-
const o = [], a = [], c = new Set(s);
|
|
1149
|
-
let u = 0;
|
|
1150
|
-
if (e.forEach((l, p) => {
|
|
1151
|
-
if (!c.has(p)) for (let i = 1; i < l - 1; i++)
|
|
1152
|
-
o.push(u, u + (r ? i + 1 : i), u + (r ? i : i + 1)), a.push(p);
|
|
1153
|
-
u += l;
|
|
1154
|
-
}), o.length !== n.length || o.some((l, p) => t[l] !== n[p]))
|
|
1155
|
-
throw new Error("Authored polygon/loader corner correspondence unavailable");
|
|
1156
|
-
return { corners: o, faces: a };
|
|
1157
|
-
}
|
|
1158
|
-
function Ks(e, t, n) {
|
|
1159
|
-
if (t.length !== n || t.some((r) => !Number.isInteger(r) || r < 0 || r >= e.length))
|
|
1160
|
-
throw new Error("Invalid faceVarying UV indices");
|
|
1161
|
-
const s = t.flatMap((r) => e[r]);
|
|
1162
|
-
if (s.length !== n * 2 || !s.every(Number.isFinite)) throw new Error("Invalid UV values");
|
|
1163
|
-
return s;
|
|
1164
|
-
}
|
|
1165
|
-
function Hs(e, t) {
|
|
1166
|
-
const n = Array(e).fill(0);
|
|
1167
|
-
for (const s of t) for (const r of s.faces) {
|
|
1168
|
-
if (!Number.isInteger(r) || r < 0 || r >= e || n[r] !== 0)
|
|
1169
|
-
throw new Error("Invalid or overlapping material subset faces");
|
|
1170
|
-
n[r] = s.slot;
|
|
1171
|
-
}
|
|
1172
|
-
return n;
|
|
1173
|
-
}
|
|
1174
|
-
function qs(e, t, n, s) {
|
|
1175
|
-
if (!e.stage) return;
|
|
1176
|
-
const r = e.stage, o = e.pxr, a = o.Usd.TimeCode.Default(), c = (l, p) => t.warnings.push({
|
|
1177
|
-
code: "USD_VISUAL_TOPOLOGY_UNSUPPORTED",
|
|
1178
|
-
source: "usd-visual",
|
|
1179
|
-
message: `USD ${l} 的部分视觉拓扑未能安全补齐,未确认部分保留 Loader 输出:${String(p)}`
|
|
1180
|
-
}), u = (l, p) => {
|
|
1181
|
-
const i = l.GetAttribute(p);
|
|
1182
|
-
try {
|
|
1183
|
-
return i.IsValid() ? i.Get(a) : null;
|
|
1184
|
-
} finally {
|
|
1185
|
-
i.delete();
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
try {
|
|
1189
|
-
for (const l of e.data.elements) {
|
|
1190
|
-
const p = e.index.objectsByPath.get(l.path);
|
|
1191
|
-
if (!(p instanceof me)) continue;
|
|
1192
|
-
const i = new o.Sdf.Path(l.path), f = r.GetPrimAtPath(i);
|
|
1193
|
-
let h = [];
|
|
1194
|
-
try {
|
|
1195
|
-
if (f.GetTypeName() !== "Mesh") continue;
|
|
1196
|
-
h = f.GetChildren();
|
|
1197
|
-
const d = h.filter((E) => E.GetTypeName() === "GeomSubset" && u(E, "familyName") === "materialBind"), g = f.GetAttribute("primvars:st");
|
|
1198
|
-
let _ = null, y = null;
|
|
1199
|
-
try {
|
|
1200
|
-
n(l.material) && g.IsValid() && g.GetMetadata("interpolation") === "faceVarying" && (y = u(f, "primvars:st:indices"), y && (_ = g.Get(a)));
|
|
1201
|
-
} finally {
|
|
1202
|
-
g.delete();
|
|
1203
|
-
}
|
|
1204
|
-
const w = d.length > 0 && !Array.isArray(p.material) && p.geometry.groups.length === 0;
|
|
1205
|
-
if (!_ && !w) continue;
|
|
1206
|
-
const m = u(f, "faceVertexCounts"), U = u(f, "faceVertexIndices");
|
|
1207
|
-
if (!m || !U || p.geometry.index) throw new Error("Authored face topology unavailable");
|
|
1208
|
-
const b = Xs(
|
|
1209
|
-
m,
|
|
1210
|
-
U,
|
|
1211
|
-
l.geometry.pointIndices ?? [],
|
|
1212
|
-
u(f, "holeIndices") ?? [],
|
|
1213
|
-
u(f, "orientation") === "leftHanded"
|
|
1214
|
-
);
|
|
1215
|
-
if (p.geometry.getAttribute("position").count !== b.corners.length)
|
|
1216
|
-
throw new Error("Loader geometry corner count mismatch");
|
|
1217
|
-
if (_ && y) {
|
|
1218
|
-
const E = Ks(_, y, U.length), R = b.corners.flatMap((H) => [E[H * 2], E[H * 2 + 1]]), I = p.geometry.getAttribute("uv");
|
|
1219
|
-
(!I || I.array.length !== R.length || R.some((H, P) => Math.abs(H - I.array[P]) > 1e-6)) && (p.geometry.setAttribute("uv", new $n(R, 2)), l.geometry.uvs = R);
|
|
1220
|
-
}
|
|
1221
|
-
if (!w) continue;
|
|
1222
|
-
const S = d.map((E) => {
|
|
1223
|
-
if (u(E, "elementType") !== "face") throw new Error("Non-face material subset");
|
|
1224
|
-
const R = o.UsdShade.ComputeBoundMaterialPath(E), I = (R == null ? void 0 : R.resolvedTargetPath) || (R == null ? void 0 : R.materialPath);
|
|
1225
|
-
if (!I || !e.index.materialsByPath.has(I)) throw new Error("Unresolved subset material");
|
|
1226
|
-
const H = u(E, "indices");
|
|
1227
|
-
if (!Array.isArray(H)) throw new Error("Missing subset face indices");
|
|
1228
|
-
return { materialPath: I, faces: H };
|
|
1229
|
-
}), x = [...new Set(S.map((E) => E.materialPath))], O = Hs(m.length, S.map((E) => ({ faces: E.faces, slot: x.indexOf(E.materialPath) + 1 })));
|
|
1230
|
-
let C = b.faces.map((E) => O[E]);
|
|
1231
|
-
const v = [p.material];
|
|
1232
|
-
try {
|
|
1233
|
-
for (const E of x) v.push(s(l, E));
|
|
1234
|
-
} catch (E) {
|
|
1235
|
-
for (const R of v.slice(1)) R.dispose();
|
|
1236
|
-
throw E;
|
|
1237
|
-
}
|
|
1238
|
-
const B = [...new Set(C)].sort((E, R) => E - R);
|
|
1239
|
-
if (B.includes(0))
|
|
1240
|
-
p.material = v;
|
|
1241
|
-
else {
|
|
1242
|
-
const E = new Map(B.map((R, I) => [R, I]));
|
|
1243
|
-
p.material = B.map((R) => v[R]), C = C.map((R) => E.get(R));
|
|
1244
|
-
}
|
|
1245
|
-
for (let E = 0; E < C.length; ) {
|
|
1246
|
-
let R = E + 1;
|
|
1247
|
-
for (; R < C.length && C[R] === C[E]; ) R++;
|
|
1248
|
-
p.geometry.addGroup(E * 3, (R - E) * 3, C[E]), E = R;
|
|
1249
|
-
}
|
|
1250
|
-
} catch (d) {
|
|
1251
|
-
c(l.path, d);
|
|
1252
|
-
} finally {
|
|
1253
|
-
for (const d of h) d.delete();
|
|
1254
|
-
f.delete(), i.delete();
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
} finally {
|
|
1258
|
-
a.delete();
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
const Ys = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "webp", "avif", "gif", "bmp"]), De = /^(?:UsdPreviewSurface|ND_UsdPreviewSurface_surfaceshader)$/i, yn = /(?:standard.?surface|principled|open.?pbr|adobe.?standard.?material)/i;
|
|
1262
|
-
async function Js(e, t) {
|
|
1263
|
-
var p;
|
|
1264
|
-
Xt(e.scene);
|
|
1265
|
-
const n = vr(e), s = /* @__PURE__ */ new Set();
|
|
1266
|
-
for (const i of e.data.materials) {
|
|
1267
|
-
const f = Os(e, i);
|
|
1268
|
-
f && (i.shaders = f.shaders, e.index.materialsByPath.set(i.path, i), s.add(i.path));
|
|
1269
|
-
}
|
|
1270
|
-
const r = (i, f) => {
|
|
1271
|
-
const h = e.data.view.prims.find((m) => m.path === i.path);
|
|
1272
|
-
if (!h) throw new Error(`Missing view prim: ${i.path}`);
|
|
1273
|
-
const d = e.index.materialsByPath.get(f), g = _t(d, n.get(f)), _ = () => Kn({
|
|
1274
|
-
...e.data,
|
|
1275
|
-
elements: [{ ...i, material: f }],
|
|
1276
|
-
view: { ...e.data.view, prims: [{ ...h, parentPath: null }] },
|
|
1277
|
-
animations: [],
|
|
1278
|
-
lights: [],
|
|
1279
|
-
skels: { ...e.data.skels, bindings: [], skeletons: [], animations: [] }
|
|
1280
|
-
}, {
|
|
1281
|
-
convertZUp: !1,
|
|
1282
|
-
loadLights: !1,
|
|
1283
|
-
loadTextures: !g,
|
|
1284
|
-
sourcePath: t.sourcePath,
|
|
1285
|
-
textureResolver: (m) => {
|
|
1286
|
-
for (const U of [m.resolvedPath, m.path, m.url]) {
|
|
1287
|
-
if (!U) continue;
|
|
1288
|
-
const b = t.files.objectUrlIfPresent(U, t.entryDirectory ?? "");
|
|
1289
|
-
if (b) return b;
|
|
1290
|
-
}
|
|
1291
|
-
return null;
|
|
1292
|
-
}
|
|
1293
|
-
}), y = t.isTextureAllowed ? an(e.data.materials, (m) => t.isTextureAllowed(m) && !!t.files.objectUrlIfPresent(m, t.entryDirectory ?? ""), _) : _();
|
|
1294
|
-
Xt(y.scene);
|
|
1295
|
-
const w = y.index.objectsByPath.get(i.path);
|
|
1296
|
-
if (w.geometry.dispose(), Array.isArray(w.material)) throw new Error("Unexpected scratch material array");
|
|
1297
|
-
return w.material;
|
|
1298
|
-
}, o = /* @__PURE__ */ new Set();
|
|
1299
|
-
for (const i of e.data.elements) {
|
|
1300
|
-
const f = e.index.objectsByPath.get(i.path);
|
|
1301
|
-
if (!(f instanceof me)) continue;
|
|
1302
|
-
const h = (d) => {
|
|
1303
|
-
const g = le(d.userData.usdMaterialPath);
|
|
1304
|
-
if (!g || !s.has(g) || d.userData.usdSurfaceShaderId) return d;
|
|
1305
|
-
const _ = r(i, g), y = `Material ${g} has no supported surface shader.`;
|
|
1306
|
-
return _.userData.usdInstanceResolvedDiagnostics = [y], _.userData.usdMaterialDiagnostics = oe([
|
|
1307
|
-
...Je(d.userData.usdMaterialDiagnostics),
|
|
1308
|
-
...Je(_.userData.usdMaterialDiagnostics)
|
|
1309
|
-
]), o.add(d), _;
|
|
1310
|
-
};
|
|
1311
|
-
if (Array.isArray(f.material)) {
|
|
1312
|
-
const d = f.material.map(h);
|
|
1313
|
-
d.some((g, _) => g !== f.material[_]) && (f.material = d);
|
|
1314
|
-
} else f.material = h(f.material);
|
|
1315
|
-
}
|
|
1316
|
-
e.scene.traverse((i) => {
|
|
1317
|
-
if (i instanceof me) for (const f of Array.isArray(i.material) ? i.material : [i.material]) o.delete(f);
|
|
1318
|
-
});
|
|
1319
|
-
for (const i of o) i.dispose();
|
|
1320
|
-
qs(e, t.diagnostics, (i) => {
|
|
1321
|
-
if (!i) return !0;
|
|
1322
|
-
const f = e.index.materialsByPath.get(i), h = f && _t(f, n.get(i));
|
|
1323
|
-
return !!h && We(h) && Ue(h, /* @__PURE__ */ new Set());
|
|
1324
|
-
}, r);
|
|
1325
|
-
const a = yr(e), c = [], u = /* @__PURE__ */ new Set();
|
|
1326
|
-
for (const [i, f] of a) {
|
|
1327
|
-
const h = e.index.materialsByPath.get(i);
|
|
1328
|
-
if (!h) continue;
|
|
1329
|
-
const d = f[0], g = n.get(i), _ = Gt(h, Kt(h, d, g));
|
|
1330
|
-
for (const P of f) P.userData.usdMaterialIR = _;
|
|
1331
|
-
const y = _.issues.map((P) => `${P.code}:${P.sourcePath}`), w = oe(f.flatMap((P) => Je(P.userData.usdMaterialDiagnostics))), m = le(d.userData.usdSurfaceShaderId), U = m ?? _.surfaceShaderId;
|
|
1332
|
-
if (U && (De.test(U) || yn.test(U))) {
|
|
1333
|
-
const P = Ht(h, f, wr), $ = Ht(h, f, br), J = !!(P && $) && Sr(h, f[0], m, P, $), T = P && (J || !$ || De.test(U)) ? P : null, se = $ && (J || !P || bn(U)) ? $ : null, A = se ? zs(h, se, T) : null, F = se ? Gt(h, se) : null, D = F && F.surfacePath !== _.surfacePath ? [_, F] : [_];
|
|
1334
|
-
if ((A != null && A.needsPhysical || hr(F)) && Le(e, f), A) {
|
|
1335
|
-
js(
|
|
1336
|
-
f.filter(X),
|
|
1337
|
-
A
|
|
1338
|
-
);
|
|
1339
|
-
for (const ne of A.approximations)
|
|
1340
|
-
t.diagnostics.approximations.push({
|
|
1341
|
-
code: ne.code,
|
|
1342
|
-
source: "usd-visual",
|
|
1343
|
-
message: `${i}: ${ne.message}`
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
const L = T ? sr(e, h, T, f) : { applied: [], unsupported: [] }, K = await st(
|
|
1347
|
-
D,
|
|
1348
|
-
f,
|
|
1349
|
-
new Set((A == null ? void 0 : A.suppressedInputs) ?? []),
|
|
1350
|
-
t,
|
|
1351
|
-
u
|
|
1352
|
-
), k = await nr(
|
|
1353
|
-
_,
|
|
1354
|
-
f,
|
|
1355
|
-
t,
|
|
1356
|
-
u
|
|
1357
|
-
), M = await fr(
|
|
1358
|
-
D,
|
|
1359
|
-
f,
|
|
1360
|
-
w,
|
|
1361
|
-
new Set((A == null ? void 0 : A.suppressedInputs) ?? []),
|
|
1362
|
-
t,
|
|
1363
|
-
u
|
|
1364
|
-
), V = await pr(h, f, t);
|
|
1365
|
-
M.applied.push(...V.applied), M.resources.push(...V.resources);
|
|
1366
|
-
const Z = V.applied.length ? { applied: [], unsupported: [], bounded: !0 } : T ? cr(e, h, f, t) : se ? { applied: [], unsupported: [], bounded: !!(A != null && A.unsupported.length) } : lr(h, f, t);
|
|
1367
|
-
M.applied.push(...Z.applied), M.applied.push(...K.applied), M.resolved.push(...K.resolved);
|
|
1368
|
-
const q = /* @__PURE__ */ new Set([...K.resolvedInputs, ...M.resolvedInputs]);
|
|
1369
|
-
for (const ne of k.resolvedInputs) q.add(ne);
|
|
1370
|
-
V.resolvedInputs.length && q.add("opacity"), M.unsupported.push(...K.unsupported), M.resources.push(...K.resources), M.applied.push(...k.applied), M.unsupported.push(...k.unsupported), M.resources.push(...k.resources);
|
|
1371
|
-
const z = oe(f.flatMap((ne) => Je(ne.userData.usdInstanceResolvedDiagnostics)));
|
|
1372
|
-
M.resolved.push(...z), z.length && M.applied.push("instance.surface.constants"), M.applied.push(...(A == null ? void 0 : A.applied) ?? []), M.unsupported.push(...(A == null ? void 0 : A.unsupported) ?? []), M.applied.push(...L.applied), M.unsupported.push(...L.unsupported), T && M.resolved.push(...rr(
|
|
1373
|
-
h,
|
|
1374
|
-
T,
|
|
1375
|
-
q
|
|
1376
|
-
));
|
|
1377
|
-
const ie = oe([...M.unsupported, ...Z.unsupported]);
|
|
1378
|
-
On(t.diagnostics, i, M.resources), ur(
|
|
1379
|
-
t.diagnostics,
|
|
1380
|
-
i,
|
|
1381
|
-
[..._.issues, ...(F == null ? void 0 : F.issues) ?? []],
|
|
1382
|
-
ie
|
|
1383
|
-
), c.push({
|
|
1384
|
-
materialPath: i,
|
|
1385
|
-
sourceShaderId: U,
|
|
1386
|
-
dialect: _.dialect,
|
|
1387
|
-
irIssues: y,
|
|
1388
|
-
action: M.applied.length ? "augmented" : "preserved",
|
|
1389
|
-
fidelity: Z.bounded || A != null && A.unsupported.length || ie.length > 0 || _.issues.length > 0 || w.some((ne) => !M.resolved.includes(ne)) ? "bounded-approximation" : "native",
|
|
1390
|
-
appliedInputs: M.applied,
|
|
1391
|
-
unsupportedNodes: ie,
|
|
1392
|
-
resources: M.resources,
|
|
1393
|
-
loaderDiagnostics: w,
|
|
1394
|
-
resolvedLoaderDiagnostics: M.resolved
|
|
1395
|
-
});
|
|
1396
|
-
continue;
|
|
1397
|
-
}
|
|
1398
|
-
const b = Kt(h, d, g);
|
|
1399
|
-
if (!b) {
|
|
1400
|
-
const P = gt(e, i), $ = h.shaders.map((J) => ae(J.inputs["info:mdl:sourceAsset"])).filter(yt);
|
|
1401
|
-
for (const J of $) t.diagnostics.droppedFeatures.push({ code: "USD_VISUAL_SHADER_NODE_UNSUPPORTED", source: "usd-visual", message: `USD 材质 ${i} 使用尚未支持的 MDL 材质 ${J};保留现有结果,未生成替代内容。` });
|
|
1402
|
-
c.push({
|
|
1403
|
-
materialPath: i,
|
|
1404
|
-
sourceShaderId: $[0] ?? null,
|
|
1405
|
-
dialect: _.dialect,
|
|
1406
|
-
irIssues: y,
|
|
1407
|
-
action: "fallback",
|
|
1408
|
-
fidelity: P ? "authored-fallback" : "default-fallback",
|
|
1409
|
-
appliedInputs: [],
|
|
1410
|
-
unsupportedNodes: oe(h.shaders.map((J) => J.id).filter(yt)),
|
|
1411
|
-
resources: [],
|
|
1412
|
-
loaderDiagnostics: w
|
|
1413
|
-
});
|
|
1414
|
-
continue;
|
|
1415
|
-
}
|
|
1416
|
-
if (At(b)) {
|
|
1417
|
-
const P = await Rr(
|
|
1418
|
-
b,
|
|
1419
|
-
_,
|
|
1420
|
-
f,
|
|
1421
|
-
t,
|
|
1422
|
-
u
|
|
1423
|
-
);
|
|
1424
|
-
Ge(
|
|
1425
|
-
t.diagnostics,
|
|
1426
|
-
i,
|
|
1427
|
-
b,
|
|
1428
|
-
P.applied,
|
|
1429
|
-
new Set(P.unsupported),
|
|
1430
|
-
P.resources,
|
|
1431
|
-
P.applied.length ? "augmented" : "fallback"
|
|
1432
|
-
), c.push({
|
|
1433
|
-
materialPath: i,
|
|
1434
|
-
sourceShaderId: "gltf_material",
|
|
1435
|
-
dialect: _.dialect,
|
|
1436
|
-
irIssues: y,
|
|
1437
|
-
action: P.applied.length ? "augmented" : "fallback",
|
|
1438
|
-
fidelity: P.applied.length ? "bounded-approximation" : ut(e, i),
|
|
1439
|
-
appliedInputs: oe(P.applied),
|
|
1440
|
-
unsupportedNodes: oe(P.unsupported),
|
|
1441
|
-
resources: P.resources,
|
|
1442
|
-
loaderDiagnostics: w
|
|
1443
|
-
});
|
|
1444
|
-
continue;
|
|
1445
|
-
}
|
|
1446
|
-
if (It(b)) {
|
|
1447
|
-
const P = await Ar(
|
|
1448
|
-
e,
|
|
1449
|
-
b,
|
|
1450
|
-
_,
|
|
1451
|
-
f,
|
|
1452
|
-
t,
|
|
1453
|
-
u
|
|
1454
|
-
);
|
|
1455
|
-
Ge(
|
|
1456
|
-
t.diagnostics,
|
|
1457
|
-
i,
|
|
1458
|
-
b,
|
|
1459
|
-
P.applied,
|
|
1460
|
-
new Set(P.unsupported),
|
|
1461
|
-
P.resources,
|
|
1462
|
-
P.applied.length ? "augmented" : "fallback"
|
|
1463
|
-
), c.push({
|
|
1464
|
-
materialPath: i,
|
|
1465
|
-
sourceShaderId: "OmniPBRBase",
|
|
1466
|
-
dialect: _.dialect,
|
|
1467
|
-
irIssues: y,
|
|
1468
|
-
action: P.applied.length ? "augmented" : "fallback",
|
|
1469
|
-
fidelity: P.applied.length ? "bounded-approximation" : ut(e, i),
|
|
1470
|
-
appliedInputs: oe(P.applied),
|
|
1471
|
-
unsupportedNodes: oe(P.unsupported),
|
|
1472
|
-
resources: P.resources,
|
|
1473
|
-
loaderDiagnostics: w
|
|
1474
|
-
});
|
|
1475
|
-
continue;
|
|
1476
|
-
}
|
|
1477
|
-
if (Mt(b)) {
|
|
1478
|
-
const P = await Cr(
|
|
1479
|
-
e,
|
|
1480
|
-
b,
|
|
1481
|
-
_,
|
|
1482
|
-
f,
|
|
1483
|
-
t,
|
|
1484
|
-
u
|
|
1485
|
-
);
|
|
1486
|
-
Ge(
|
|
1487
|
-
t.diagnostics,
|
|
1488
|
-
i,
|
|
1489
|
-
b,
|
|
1490
|
-
P.applied,
|
|
1491
|
-
new Set(P.unsupported),
|
|
1492
|
-
P.resources,
|
|
1493
|
-
P.applied.length ? "augmented" : "fallback"
|
|
1494
|
-
), c.push({
|
|
1495
|
-
materialPath: i,
|
|
1496
|
-
sourceShaderId: "OmniSurfaceBase",
|
|
1497
|
-
dialect: _.dialect,
|
|
1498
|
-
irIssues: y,
|
|
1499
|
-
action: P.applied.length ? "augmented" : "fallback",
|
|
1500
|
-
fidelity: P.applied.length ? "bounded-approximation" : ut(e, i),
|
|
1501
|
-
appliedInputs: oe(P.applied),
|
|
1502
|
-
unsupportedNodes: oe(P.unsupported),
|
|
1503
|
-
resources: P.resources,
|
|
1504
|
-
loaderDiagnostics: w
|
|
1505
|
-
});
|
|
1506
|
-
continue;
|
|
1507
|
-
}
|
|
1508
|
-
if (Rt(b)) {
|
|
1509
|
-
const P = Ur(e, f, b), $ = P.applied.length ? await Pr(f, b, P, t) : [];
|
|
1510
|
-
P.applied.length && $.push(...await Or(f, b, P, t)), Ge(t.diagnostics, i, b, P.applied, P.unsupported, $, P.applied.length ? "augmented" : "fallback"), c.push({
|
|
1511
|
-
materialPath: i,
|
|
1512
|
-
sourceShaderId: "OmniGlass",
|
|
1513
|
-
action: P.applied.length ? "augmented" : "fallback",
|
|
1514
|
-
dialect: _.dialect,
|
|
1515
|
-
irIssues: y,
|
|
1516
|
-
fidelity: "bounded-approximation",
|
|
1517
|
-
appliedInputs: P.applied,
|
|
1518
|
-
unsupportedNodes: [...P.unsupported],
|
|
1519
|
-
resources: $,
|
|
1520
|
-
loaderDiagnostics: w
|
|
1521
|
-
});
|
|
1522
|
-
continue;
|
|
1523
|
-
}
|
|
1524
|
-
const S = [], x = [], O = /* @__PURE__ */ new Set(), C = Er(f, b, S);
|
|
1525
|
-
let v = !1;
|
|
1526
|
-
if (We(b)) {
|
|
1527
|
-
const P = ae(G(b, ["diffuse_texture"]));
|
|
1528
|
-
if (P) {
|
|
1529
|
-
const D = await ue(P, t);
|
|
1530
|
-
if (x.push(D.report), D.url && Ue(b, O) && f.every((L) => X(L) && !L.map)) {
|
|
1531
|
-
let L = null;
|
|
1532
|
-
try {
|
|
1533
|
-
L = await (t.createTexture ?? ce)(D.url, pt);
|
|
1534
|
-
} catch (K) {
|
|
1535
|
-
if (K instanceof Error && K.name === "AbortError") throw K;
|
|
1536
|
-
x[x.length - 1] = { path: P, status: "decode-failed" };
|
|
1537
|
-
}
|
|
1538
|
-
if (L) {
|
|
1539
|
-
for (const K of f)
|
|
1540
|
-
X(K) && (K.map = L, K.color.set(16777215), K.needsUpdate = !0, v = !0);
|
|
1541
|
-
v ? S.push("diffuse_texture") : L.dispose();
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
const $ = ge(b, ["enable_ORM_texture"], !1);
|
|
1546
|
-
if ($) {
|
|
1547
|
-
const D = ae(G(b, ["ORM_texture"])), L = N(b, ["reflection_roughness_texture_influence"]) ?? 0, K = N(b, ["metallic_texture_influence"]) ?? 0;
|
|
1548
|
-
N(b, ["ao_to_diffuse"]);
|
|
1549
|
-
const k = G(b, ["ORM_texture_colorspace"]);
|
|
1550
|
-
if (k !== void 0 && k !== "raw") O.add("OmniPBR.ORM_texture_colorspace");
|
|
1551
|
-
else if (L || K)
|
|
1552
|
-
if (!D) O.add("OmniPBR.ORM_texture_missing");
|
|
1553
|
-
else {
|
|
1554
|
-
const M = await ue(D, t);
|
|
1555
|
-
if (x.push(M.report), M.url && Ue(b, O)) {
|
|
1556
|
-
let V = null, Z = !1;
|
|
1557
|
-
try {
|
|
1558
|
-
V = await (t.createTexture ?? ce)(M.url, re), V.colorSpace = re, V.wrapS = te, V.wrapT = te;
|
|
1559
|
-
const q = [
|
|
1560
|
-
{
|
|
1561
|
-
slot: "roughnessMap",
|
|
1562
|
-
scalar: "roughness",
|
|
1563
|
-
channel: "g",
|
|
1564
|
-
influence: L,
|
|
1565
|
-
constant: N(b, ["reflection_roughness_constant"]) ?? 0.5
|
|
1566
|
-
},
|
|
1567
|
-
{
|
|
1568
|
-
slot: "metalnessMap",
|
|
1569
|
-
scalar: "metalness",
|
|
1570
|
-
channel: "b",
|
|
1571
|
-
influence: K,
|
|
1572
|
-
constant: N(b, ["metallic_constant"]) ?? 0
|
|
1573
|
-
}
|
|
1574
|
-
];
|
|
1575
|
-
for (const z of q) {
|
|
1576
|
-
if (!Number.isFinite(z.influence) || z.influence < 0 || z.influence > 1 || z.constant < 0 || z.constant > 1) {
|
|
1577
|
-
O.add(`OmniPBR.${z.scalar}_ORM_range`);
|
|
1578
|
-
continue;
|
|
1579
|
-
}
|
|
1580
|
-
const ie = f.filter(X).filter((ne) => !ne[z.slot]);
|
|
1581
|
-
if (ie.length) {
|
|
1582
|
-
if (z.influence === 0) {
|
|
1583
|
-
for (const ne of ie) ne[z.scalar] = z.constant;
|
|
1584
|
-
continue;
|
|
1585
|
-
}
|
|
1586
|
-
try {
|
|
1587
|
-
const ne = z.influence === 1 ? V : Ae(
|
|
1588
|
-
V,
|
|
1589
|
-
z.channel,
|
|
1590
|
-
z.influence,
|
|
1591
|
-
z.constant * (1 - z.influence)
|
|
1592
|
-
);
|
|
1593
|
-
for (const he of ie)
|
|
1594
|
-
he[z.slot] = ne, he[z.scalar] = 1, he.needsUpdate = !0;
|
|
1595
|
-
ne === V && (Z = !0), S.push(`${z.scalar}.ORM.${z.channel}`, `ORM.${z.scalar}.influence=${z.influence}`), v = !0;
|
|
1596
|
-
} catch {
|
|
1597
|
-
O.add(`OmniPBR.${z.scalar}_ORM_conversion`);
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
v && S.push("ORM_texture");
|
|
1602
|
-
} catch (q) {
|
|
1603
|
-
if (q instanceof Error && q.name === "AbortError") throw q;
|
|
1604
|
-
x[x.length - 1] = { path: D, status: "decode-failed" };
|
|
1605
|
-
} finally {
|
|
1606
|
-
Z || V == null || V.dispose();
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
if (!$ && Ue(b, O))
|
|
1612
|
-
for (const D of [
|
|
1613
|
-
{ file: "reflectionroughness_texture", weight: "reflection_roughness_texture_influence", constant: "reflection_roughness_constant", fallback: 0.5, map: "roughnessMap", scalar: "roughness" },
|
|
1614
|
-
{ file: "metallic_texture", weight: "metallic_texture_influence", constant: "metallic_constant", fallback: 0, map: "metalnessMap", scalar: "metalness" }
|
|
1615
|
-
]) {
|
|
1616
|
-
const L = N(b, [D.weight]) ?? 0;
|
|
1617
|
-
if (L === 0) continue;
|
|
1618
|
-
if (L < 0 || L > 1) {
|
|
1619
|
-
O.add(`OmniPBR.${D.weight}`);
|
|
1620
|
-
continue;
|
|
1621
|
-
}
|
|
1622
|
-
const K = ae(G(b, [D.file]));
|
|
1623
|
-
if (!K) continue;
|
|
1624
|
-
const k = G(b, [`${D.file}_colorspace`]);
|
|
1625
|
-
if (k !== void 0 && k !== "raw") {
|
|
1626
|
-
O.add(`OmniPBR.${D.file}_colorspace`);
|
|
1627
|
-
continue;
|
|
1628
|
-
}
|
|
1629
|
-
const M = await ue(K, t);
|
|
1630
|
-
x.push(M.report);
|
|
1631
|
-
const V = f.filter(X).filter((q) => !q[D.map]);
|
|
1632
|
-
if (!M.url || !V.length) continue;
|
|
1633
|
-
let Z = null;
|
|
1634
|
-
try {
|
|
1635
|
-
Z = await (t.createTexture ?? ce)(M.url, re);
|
|
1636
|
-
const q = N(b, [D.constant]) ?? D.fallback, z = Ae(Z, "grayscale", L, q * (1 - L));
|
|
1637
|
-
z.wrapS = te, z.wrapT = te;
|
|
1638
|
-
for (const ie of V)
|
|
1639
|
-
ie[D.map] = z, ie[D.scalar] = 1, ie.needsUpdate = !0;
|
|
1640
|
-
S.push(D.file), v = !0;
|
|
1641
|
-
} catch (q) {
|
|
1642
|
-
if (q instanceof Error && q.name === "AbortError") throw q;
|
|
1643
|
-
O.add(`OmniPBR.${D.file}_conversion`);
|
|
1644
|
-
} finally {
|
|
1645
|
-
Z == null || Z.dispose();
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
const J = ge(b, ["enable_opacity"], !1), T = N(b, ["opacity_threshold"]) ?? 0;
|
|
1649
|
-
if (J && T >= 0 && ge(b, ["enable_opacity_texture"], !1) && Ue(b, O)) {
|
|
1650
|
-
const D = ae(G(b, ["opacity_texture"])), L = G(b, ["opacity_mode"]) ?? 1, K = L === 0 || L === "mono_alpha" ? "a" : L === 1 || L === "mono_average" ? "average" : L === 3 || L === "mono_maximum" ? "maximum" : null, k = G(b, ["opacity_texture_colorspace"]);
|
|
1651
|
-
if (k !== void 0 && k !== "raw") O.add("OmniPBR.opacity_texture_colorspace");
|
|
1652
|
-
else if (!K) O.add("OmniPBR.opacity_mode");
|
|
1653
|
-
else if (!D) O.add("OmniPBR.opacity_texture_missing");
|
|
1654
|
-
else {
|
|
1655
|
-
const M = await ue(D, t);
|
|
1656
|
-
x.push(M.report);
|
|
1657
|
-
const V = f.filter(X).filter((q) => !q.alphaMap);
|
|
1658
|
-
let Z = null;
|
|
1659
|
-
if (M.url && V.length) try {
|
|
1660
|
-
Z = await (t.createTexture ?? ce)(M.url, re);
|
|
1661
|
-
const q = Ae(Z, K);
|
|
1662
|
-
q.wrapS = te, q.wrapT = te;
|
|
1663
|
-
for (const z of V)
|
|
1664
|
-
z.alphaMap = q, z.opacity = 1, z.alphaTest = Math.max(0, T), z.transparent = T === 0, z.depthWrite = T > 0, z.needsUpdate = !0;
|
|
1665
|
-
S.push("opacity_texture"), v = !0;
|
|
1666
|
-
} catch (q) {
|
|
1667
|
-
if (q instanceof Error && q.name === "AbortError") throw q;
|
|
1668
|
-
x[x.length - 1] = { path: D, status: "decode-failed" };
|
|
1669
|
-
} finally {
|
|
1670
|
-
Z == null || Z.dispose();
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
const A = de(b, ["diffuse_tint"]);
|
|
1675
|
-
if (A) {
|
|
1676
|
-
for (const D of f)
|
|
1677
|
-
X(D) && (D.map ? D.color.copy(A) : D.color.copy(de(b, ["diffuse_color_constant"]) ?? new tt(0.2, 0.2, 0.2)).multiply(A), D.needsUpdate = !0);
|
|
1678
|
-
S.push("diffuse_tint"), v = !0;
|
|
1679
|
-
}
|
|
1680
|
-
const F = ae(G(b, ["normalmap_texture"]));
|
|
1681
|
-
if (F) {
|
|
1682
|
-
const D = await ue(F, t);
|
|
1683
|
-
x.push(D.report);
|
|
1684
|
-
const L = G(b, ["normalmap_texture_colorspace"]), K = N(b, ["bump_factor"]) ?? 1;
|
|
1685
|
-
if (L !== void 0 && L !== "raw") O.add("OmniPBR.normalmap_texture_colorspace");
|
|
1686
|
-
else if (!Number.isFinite(K) || K < 0) O.add("OmniPBR.bump_factor");
|
|
1687
|
-
else if (D.url && Ue(b, O)) {
|
|
1688
|
-
const k = f.filter(X).filter((M) => !M.normalMap);
|
|
1689
|
-
if (k.length)
|
|
1690
|
-
try {
|
|
1691
|
-
const M = await (t.createTexture ?? ce)(D.url, re);
|
|
1692
|
-
M.colorSpace = re, M.wrapS = te, M.wrapT = te;
|
|
1693
|
-
for (const V of k)
|
|
1694
|
-
V.normalMap = M, V.normalScale.set(
|
|
1695
|
-
K * (ge(b, ["flip_tangent_u"], !1) ? -1 : 1),
|
|
1696
|
-
K * (ge(b, ["flip_tangent_v"], !0) ? -1 : 1)
|
|
1697
|
-
), V.needsUpdate = !0;
|
|
1698
|
-
S.push("normalmap_texture", "normal.tangent_convention"), v = !0;
|
|
1699
|
-
} catch (M) {
|
|
1700
|
-
if (M instanceof Error && M.name === "AbortError") throw M;
|
|
1701
|
-
x[x.length - 1] = { path: F, status: "decode-failed" };
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
Tr(b, O), v = await Dr(f, b, S, O, x, t) || v;
|
|
1706
|
-
}
|
|
1707
|
-
const B = ee(b, "diffuseColor") ?? ee(b, "baseColor");
|
|
1708
|
-
let E = !1;
|
|
1709
|
-
if (B) {
|
|
1710
|
-
const P = Xe(h, B);
|
|
1711
|
-
if (P && Rn(P)) {
|
|
1712
|
-
const $ = Br(P);
|
|
1713
|
-
if ($) {
|
|
1714
|
-
const J = await ue($.path, t);
|
|
1715
|
-
x.push(J.report);
|
|
1716
|
-
const T = ee(P, "manifold");
|
|
1717
|
-
T && O.add(((p = Xe(h, T)) == null ? void 0 : p.id) ?? T.path);
|
|
1718
|
-
const se = Object.keys(P.inputs).filter((D) => !["inputs:filename", "inputs:resultRGB", "inputs:linearize"].includes(D)), A = P.inputs["inputs:linearize"], F = A === 0 || A === 1;
|
|
1719
|
-
if (F || O.add("PxrTexture.colorSpace"), se.length > 0 && !T && O.add("PxrTexture.controls"), J.url && !T && se.length === 0 && F && B.outputName === "resultRGB" && f.every((D) => X(D) && !D.map)) {
|
|
1720
|
-
let D = null;
|
|
1721
|
-
try {
|
|
1722
|
-
D = await (t.createTexture ?? ce)(J.url, A === 1 ? pt : re);
|
|
1723
|
-
} catch (L) {
|
|
1724
|
-
if (L instanceof Error && L.name === "AbortError") throw L;
|
|
1725
|
-
x[x.length - 1] = { path: $.path, status: "decode-failed" };
|
|
1726
|
-
}
|
|
1727
|
-
if (D) {
|
|
1728
|
-
for (const L of f)
|
|
1729
|
-
X(L) && (L.map = D, L.color.set(16777215), L.needsUpdate = !0, E = !0);
|
|
1730
|
-
E ? S.push("diffuseColor.texture") : D.dispose();
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
} else
|
|
1734
|
-
O.add(P.id ?? P.path);
|
|
1735
|
-
} else P ? O.add(P.id ?? P.path) : O.add(B.path);
|
|
1736
|
-
}
|
|
1737
|
-
$r(h, b, O);
|
|
1738
|
-
const R = C || E || v ? "augmented" : "fallback", I = gt(e, i), H = R === "augmented" ? "bounded-approximation" : I ? "authored-fallback" : "default-fallback";
|
|
1739
|
-
Ge(t.diagnostics, i, b, S, O, x, R), c.push({
|
|
1740
|
-
materialPath: i,
|
|
1741
|
-
sourceShaderId: Un(b),
|
|
1742
|
-
dialect: _.dialect,
|
|
1743
|
-
irIssues: y,
|
|
1744
|
-
action: R,
|
|
1745
|
-
fidelity: H,
|
|
1746
|
-
appliedInputs: oe(S),
|
|
1747
|
-
unsupportedNodes: [...O],
|
|
1748
|
-
resources: x,
|
|
1749
|
-
loaderDiagnostics: w
|
|
1750
|
-
});
|
|
1751
|
-
}
|
|
1752
|
-
Us(e), mr(e.scene, u);
|
|
1753
|
-
const l = c.filter((i) => i.loaderDiagnostics.some(
|
|
1754
|
-
(f) => {
|
|
1755
|
-
var h;
|
|
1756
|
-
return !((h = i.resolvedLoaderDiagnostics) != null && h.includes(f)) && !(i.action === "augmented" && f === `Material ${i.materialPath} has no supported surface shader.`);
|
|
1757
|
-
}
|
|
1758
|
-
));
|
|
1759
|
-
return l.length > 0 && t.diagnostics.droppedFeatures.push({
|
|
1760
|
-
code: "USD_VISUAL_LOADER_DIAGNOSTIC",
|
|
1761
|
-
message: `${l.length} 个 USD 材质仍有尚未被视觉适配层消解的 Loader 限制;具体材质和原始诊断见 visualAdaptation 报告。`,
|
|
1762
|
-
source: "usd-visual"
|
|
1763
|
-
}), Object.freeze({
|
|
1764
|
-
schemaVersion: 1,
|
|
1765
|
-
materials: c,
|
|
1766
|
-
summary: Object.freeze({
|
|
1767
|
-
preserved: c.filter((i) => i.action === "preserved").length,
|
|
1768
|
-
augmented: c.filter((i) => i.action === "augmented").length,
|
|
1769
|
-
fallback: c.filter((i) => i.action === "fallback").length,
|
|
1770
|
-
missingResources: c.flatMap((i) => i.resources).filter((i) => i.status === "missing").length,
|
|
1771
|
-
unsupportedResources: c.flatMap((i) => i.resources).filter((i) => i.status === "unsupported-format").length
|
|
1772
|
-
})
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
function Xt(e) {
|
|
1776
|
-
e == null || e.traverse((t) => {
|
|
1777
|
-
if (!(t instanceof me)) return;
|
|
1778
|
-
const n = Array.isArray(t.material) ? t.material : [t.material];
|
|
1779
|
-
for (const s of n)
|
|
1780
|
-
for (const r of ["map", "normalMap", "roughnessMap", "metalnessMap", "aoMap", "emissiveMap", "alphaMap", "bumpMap", "displacementMap", "clearcoatMap", "clearcoatNormalMap", "clearcoatRoughnessMap", "iridescenceMap", "iridescenceThicknessMap", "specularColorMap", "specularIntensityMap", "transmissionMap", "thicknessMap", "sheenColorMap", "sheenRoughnessMap"]) {
|
|
1781
|
-
const o = s[r];
|
|
1782
|
-
o instanceof bt && (o.userData.usdScalarConversionKey || o.userData.usdCoverageConversionKey || o.userData.usdColorConversionKey || o.userData.usdNormalConversionKey || (o.matrix.identity(), o.matrixAutoUpdate = !1, o.needsUpdate = !0));
|
|
1783
|
-
}
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
const Zs = [
|
|
1787
|
-
{
|
|
1788
|
-
reportName: "baseColor",
|
|
1789
|
-
sources: [
|
|
1790
|
-
{ dialect: "usd-preview", inputNames: ["diffuseColor", "baseColor", "base_color"] },
|
|
1791
|
-
{ dialect: "openpbr", inputNames: ["base_color", "baseColor"] },
|
|
1792
|
-
{ dialect: "materialx-standard-surface", inputNames: ["base_color", "baseColor", "diffuseColor"] },
|
|
1793
|
-
{ dialect: "omni-pbr-base", inputNames: ["diffuse_reflection_color"] },
|
|
1794
|
-
{ dialect: "omni-surface-base", inputNames: ["diffuse_reflection_color"] },
|
|
1795
|
-
{ dialect: "gltf-material", inputNames: ["base_color_texture"] }
|
|
1796
|
-
],
|
|
1797
|
-
targetMap: "map"
|
|
1798
|
-
},
|
|
1799
|
-
{
|
|
1800
|
-
reportName: "emissiveColor",
|
|
1801
|
-
sources: [
|
|
1802
|
-
{ dialect: "usd-preview", inputNames: ["emissiveColor", "emission_color"] },
|
|
1803
|
-
{ dialect: "openpbr", inputNames: ["emission_color", "emissiveColor"] },
|
|
1804
|
-
{ dialect: "materialx-standard-surface", inputNames: ["emission_color", "emissiveColor"] }
|
|
1805
|
-
],
|
|
1806
|
-
targetMap: "emissiveMap"
|
|
1807
|
-
}
|
|
1808
|
-
];
|
|
1809
|
-
async function st(e, t, n, s, r) {
|
|
1810
|
-
const o = {
|
|
1811
|
-
applied: [],
|
|
1812
|
-
resolved: [],
|
|
1813
|
-
resolvedInputs: [],
|
|
1814
|
-
unsupported: [],
|
|
1815
|
-
resources: []
|
|
1816
|
-
};
|
|
1817
|
-
for (const a of Zs)
|
|
1818
|
-
for (const c of e) {
|
|
1819
|
-
const u = a.sources.find((i) => i.dialect === c.dialect), l = u && c.textures.find((i) => i.semantic === "color" && u.inputNames.includes(i.surfaceInput) && !n.has(`${c.dialect}:${i.surfaceInput}`));
|
|
1820
|
-
if (!l) continue;
|
|
1821
|
-
const p = await Qs(c, a, l, t, s, r);
|
|
1822
|
-
o.applied.push(...p.applied), o.resolved.push(...p.resolved), o.resolvedInputs.push(...p.resolvedInputs), o.unsupported.push(...p.unsupported), o.resources.push(...p.resources);
|
|
1823
|
-
break;
|
|
1824
|
-
}
|
|
1825
|
-
return o;
|
|
1826
|
-
}
|
|
1827
|
-
async function Qs(e, t, n, s, r, o) {
|
|
1828
|
-
var w;
|
|
1829
|
-
const a = {
|
|
1830
|
-
applied: [],
|
|
1831
|
-
resolved: [],
|
|
1832
|
-
resolvedInputs: [],
|
|
1833
|
-
unsupported: [],
|
|
1834
|
-
resources: []
|
|
1835
|
-
}, c = (m) => (a.unsupported.push(`${e.dialect}.${n.surfaceInput}.${m}`), a), u = s.filter(X);
|
|
1836
|
-
if (!u.length) return c("standard-material-required");
|
|
1837
|
-
const l = u.map((m) => er(m, t));
|
|
1838
|
-
if (l.some((m) => (m == null ? void 0 : m.userData.usdTextureOwner) === "foreign"))
|
|
1839
|
-
return c("existing-foreign-map");
|
|
1840
|
-
if (e.dialect === "gltf-material" && n.surfaceInput === "base_color_texture" && !["texcoord0", "st"].includes((n.uvSet ?? "texcoord0").toLowerCase()))
|
|
1841
|
-
return c(`uv=${n.uvSet ?? "unknown"}`);
|
|
1842
|
-
const p = JSON.stringify([
|
|
1843
|
-
"usd-color-v1",
|
|
1844
|
-
e.materialPath,
|
|
1845
|
-
t.reportName,
|
|
1846
|
-
n.shaderPath,
|
|
1847
|
-
n.path,
|
|
1848
|
-
n.sourceColorSpace,
|
|
1849
|
-
n.sourceChannel,
|
|
1850
|
-
n.wrapS,
|
|
1851
|
-
n.wrapT,
|
|
1852
|
-
n.uvSet ?? "st",
|
|
1853
|
-
n.uvTransform
|
|
1854
|
-
]);
|
|
1855
|
-
if (l.every((m) => (m == null ? void 0 : m.userData.usdColorConversionKey) === p))
|
|
1856
|
-
return a.applied.push(`${t.reportName}.texture.rgb`), a.resolvedInputs.push(n.surfaceInput), a;
|
|
1857
|
-
if (l.every((m) => m !== null) && l.every((m) => !m.userData.usdColorConversionKey))
|
|
1858
|
-
return a.resolvedInputs.push(n.surfaceInput), a;
|
|
1859
|
-
if (Pt([e])) return c("multiple-uv-sets");
|
|
1860
|
-
let i = !1;
|
|
1861
|
-
const f = (m) => {
|
|
1862
|
-
a.unsupported.push(`${e.dialect}.${n.surfaceInput}.${m}`), i = !0;
|
|
1863
|
-
};
|
|
1864
|
-
n.sourceChannel !== "rgb" && f("color-channel-not-rgb"), ((w = n.sourceColorSpace) == null ? void 0 : w.toLowerCase()) !== "srgb" && f(`color-space=${n.sourceColorSpace ?? "auto"}`), (n.scale.slice(0, 3).some((m) => m !== 1) || n.bias.slice(0, 3).some((m) => m !== 0)) && f("color-affine-scale-bias");
|
|
1865
|
-
const h = n.wrapS === null ? te : Se(n.wrapS), d = n.wrapT === null ? te : Se(n.wrapT);
|
|
1866
|
-
if ((h === null || d === null) && f("unsupported-wrap"), i || h === null || d === null) return a;
|
|
1867
|
-
const g = u.filter((m, U) => {
|
|
1868
|
-
const b = l[U];
|
|
1869
|
-
return !b || b.userData.usdColorConversionKey;
|
|
1870
|
-
});
|
|
1871
|
-
if (!g.length) return a;
|
|
1872
|
-
const _ = await ue(n.path, r);
|
|
1873
|
-
if (a.resources.push(_.report), !_.url) return a;
|
|
1874
|
-
let y = null;
|
|
1875
|
-
try {
|
|
1876
|
-
y = await (r.createTexture ?? ce)(_.url, pt), y.wrapS = h, y.wrapT = d, y.channel = 0, rt(y, n.uvTransform), y.userData.usdColorConversionKey = p, y.userData.usdTextureOwner = "adapter-derived";
|
|
1877
|
-
for (const m of l)
|
|
1878
|
-
m != null && m.userData.usdColorConversionKey && o.add(m);
|
|
1879
|
-
for (const m of g) tr(m, t, y);
|
|
1880
|
-
a.applied.push(`${t.reportName}.texture.rgb`), a.resolvedInputs.push(n.surfaceInput);
|
|
1881
|
-
} catch (m) {
|
|
1882
|
-
if (m instanceof Error && m.name === "AbortError") throw m;
|
|
1883
|
-
a.resources[a.resources.length - 1] = {
|
|
1884
|
-
path: n.path,
|
|
1885
|
-
status: "decode-failed"
|
|
1886
|
-
};
|
|
1887
|
-
}
|
|
1888
|
-
return a;
|
|
1889
|
-
}
|
|
1890
|
-
function er(e, t) {
|
|
1891
|
-
return t.targetMap === "map" ? e.map : e.emissiveMap;
|
|
1892
|
-
}
|
|
1893
|
-
function tr(e, t, n) {
|
|
1894
|
-
t.targetMap === "map" ? (e.map = n, e.color.set(16777215)) : (e.emissiveMap = n, e.emissive.set(16777215)), e.needsUpdate = !0;
|
|
1895
|
-
}
|
|
1896
|
-
async function nr(e, t, n, s) {
|
|
1897
|
-
var g;
|
|
1898
|
-
const r = { applied: [], resolvedInputs: [], unsupported: [], resources: [] };
|
|
1899
|
-
if (e.dialect !== "usd-preview") return r;
|
|
1900
|
-
const o = e.textures.find((_) => _.surfaceInput === "normal" && _.semantic === "normal");
|
|
1901
|
-
if (!o) return r;
|
|
1902
|
-
const a = (_) => (r.unsupported.push(`usd-preview.normal.${_}`), r);
|
|
1903
|
-
if (o.sourceChannel !== "rgb") return a("color-channel-not-rgb");
|
|
1904
|
-
if (((g = o.sourceColorSpace) == null ? void 0 : g.toLowerCase()) !== "raw")
|
|
1905
|
-
return a(`color-space=${o.sourceColorSpace ?? "auto"}`);
|
|
1906
|
-
if (![2, 2, 2].every((_, y) => o.scale[y] === _ && o.bias[y] === -1)) return a("non-canonical-normal-scale-bias");
|
|
1907
|
-
if (Pt([e])) return a("multiple-uv-sets");
|
|
1908
|
-
const u = o.wrapS === null ? te : Se(o.wrapS), l = o.wrapT === null ? te : Se(o.wrapT);
|
|
1909
|
-
if (u === null || l === null) return a("unsupported-wrap");
|
|
1910
|
-
const p = t.filter(X);
|
|
1911
|
-
if (!p.length) return a("standard-material-required");
|
|
1912
|
-
const i = p.map((_) => _.normalMap);
|
|
1913
|
-
if (i.some((_) => _ && _.userData.usdTextureOwner === "foreign"))
|
|
1914
|
-
return a("existing-foreign-map");
|
|
1915
|
-
const f = JSON.stringify([
|
|
1916
|
-
"usd-preview-normal-v1",
|
|
1917
|
-
e.materialPath,
|
|
1918
|
-
o.shaderPath,
|
|
1919
|
-
o.path,
|
|
1920
|
-
u,
|
|
1921
|
-
l,
|
|
1922
|
-
o.uvSet ?? "st",
|
|
1923
|
-
o.uvTransform
|
|
1924
|
-
]);
|
|
1925
|
-
if (i.every((_) => (_ == null ? void 0 : _.userData.usdNormalConversionKey) === f))
|
|
1926
|
-
return r.applied.push("PreviewSurface.normal.texture"), r.resolvedInputs.push("normal"), r.resources.push({ path: o.path, status: "available" }), r;
|
|
1927
|
-
if (i.every((_) => _ !== null) && i.every((_) => !_.userData.usdNormalConversionKey))
|
|
1928
|
-
return r.resolvedInputs.push("normal"), r;
|
|
1929
|
-
if (i.some((_) => _ && !_.userData.usdNormalConversionKey))
|
|
1930
|
-
return a("existing-map-owner-unknown");
|
|
1931
|
-
const h = await ue(o.path, n);
|
|
1932
|
-
if (r.resources.push(h.report), !h.url) return r;
|
|
1933
|
-
let d = null;
|
|
1934
|
-
try {
|
|
1935
|
-
d = await (n.createTexture ?? ce)(h.url, re), d.colorSpace = re, d.wrapS = u, d.wrapT = l, d.channel = 0, rt(d, o.uvTransform), d.userData.usdNormalConversionKey = f, d.userData.usdTextureOwner = "adapter-derived";
|
|
1936
|
-
for (const _ of i)
|
|
1937
|
-
_ != null && _.userData.usdNormalConversionKey && s.add(_);
|
|
1938
|
-
for (const _ of p)
|
|
1939
|
-
_.normalMap = d, _.normalScale.set(1, 1), _.needsUpdate = !0;
|
|
1940
|
-
r.applied.push("PreviewSurface.normal.texture"), r.resolvedInputs.push("normal"), d = null;
|
|
1941
|
-
} catch (_) {
|
|
1942
|
-
if (_ instanceof Error && _.name === "AbortError") throw _;
|
|
1943
|
-
r.resources[r.resources.length - 1] = {
|
|
1944
|
-
path: o.path,
|
|
1945
|
-
status: "decode-failed"
|
|
1946
|
-
};
|
|
1947
|
-
} finally {
|
|
1948
|
-
d == null || d.dispose();
|
|
1949
|
-
}
|
|
1950
|
-
return r;
|
|
1951
|
-
}
|
|
1952
|
-
function rt(e, t) {
|
|
1953
|
-
if (!t) return;
|
|
1954
|
-
const n = t.rotation * Math.PI / 180, s = Math.cos(n), r = Math.sin(n);
|
|
1955
|
-
e.matrix.set(
|
|
1956
|
-
s * t.scale[0],
|
|
1957
|
-
-r * t.scale[1],
|
|
1958
|
-
t.translation[0],
|
|
1959
|
-
r * t.scale[0],
|
|
1960
|
-
s * t.scale[1],
|
|
1961
|
-
t.translation[1],
|
|
1962
|
-
0,
|
|
1963
|
-
0,
|
|
1964
|
-
1
|
|
1965
|
-
), e.matrixAutoUpdate = !1, e.needsUpdate = !0;
|
|
1966
|
-
}
|
|
1967
|
-
function sr(e, t, n, s) {
|
|
1968
|
-
const r = [], o = [], a = Yt(t, n, ["diffuseColor", "baseColor", "base_color"]), c = Ve(t, n, ["roughness", "specular_roughness"]), u = Ve(t, n, ["metallic", "metalness", "base_metalness"]), l = Ve(t, n, ["ior", "specular_ior"]), p = Ve(t, n, ["clearcoat", "coat_weight"]), i = Ve(t, n, ["clearcoatRoughness", "coat_roughness"]), f = Yt(t, n, ["emissiveColor", "emission_color"]);
|
|
1969
|
-
Lr(t, n, ["useSpecularWorkflow"]) === !0 && o.push("PreviewSurface.specularWorkflow"), (l !== null || p !== null || i !== null) && Le(e, s);
|
|
1970
|
-
for (const d of s)
|
|
1971
|
-
X(d) && (a && d.color.copy(a), c !== null && (d.roughness = Q(c)), u !== null && (d.metalness = Q(u)), f && d.emissive.copy(f), d instanceof W && (l !== null && l > 0 && (d.ior = l), p !== null && (d.clearcoat = Q(p)), i !== null && (d.clearcoatRoughness = Q(i))), d.needsUpdate = !0);
|
|
1972
|
-
return a && r.push("PreviewSurface.diffuseColor.constant"), c !== null && r.push("PreviewSurface.roughness.constant"), u !== null && r.push("PreviewSurface.metallic.constant"), l !== null && r.push("PreviewSurface.ior.constant"), p !== null && r.push("PreviewSurface.clearcoat.constant"), i !== null && r.push("PreviewSurface.clearcoatRoughness.constant"), f && r.push("PreviewSurface.emissiveColor.constant"), { applied: r, unsupported: o };
|
|
1973
|
-
}
|
|
1974
|
-
function rr(e, t, n) {
|
|
1975
|
-
const s = /* @__PURE__ */ new Set();
|
|
1976
|
-
for (const r of Object.keys(t.inputs)) {
|
|
1977
|
-
if (!r.endsWith(".connect") || r.endsWith(".resolvedConnect")) continue;
|
|
1978
|
-
const o = Re(t.inputs[r]);
|
|
1979
|
-
if (!o) continue;
|
|
1980
|
-
const a = Pn(e, o.path);
|
|
1981
|
-
!a || !or(
|
|
1982
|
-
e,
|
|
1983
|
-
a,
|
|
1984
|
-
n
|
|
1985
|
-
) || s.add(`Connection references missing shader ${o.path}.`);
|
|
1986
|
-
}
|
|
1987
|
-
return [...s];
|
|
1988
|
-
}
|
|
1989
|
-
function or(e, t, n) {
|
|
1990
|
-
const s = ar(t);
|
|
1991
|
-
if (!s.some((o) => e.inputs[`inputs:${o}.resolvedConnect`] !== void 0 || e.inputs[`inputs:${o}.connect`] !== void 0)) {
|
|
1992
|
-
const o = s.map((a) => e.inputs[`inputs:${a}`]).find((a) => a !== void 0);
|
|
1993
|
-
if (o !== void 0) return ir(t, o);
|
|
1994
|
-
}
|
|
1995
|
-
return s.some((o) => n.has(o));
|
|
1996
|
-
}
|
|
1997
|
-
function ar(e) {
|
|
1998
|
-
return e === "baseColor" || e === "base_color" ? [e, "diffuseColor"] : e === "specular_roughness" ? [e, "roughness"] : e === "base_metalness" || e === "metalness" ? [e, "metallic"] : e === "coat_weight" ? [e, "clearcoat"] : e === "coat_roughness" ? [e, "clearcoatRoughness"] : e === "emission_color" ? [e, "emissiveColor"] : e === "ambientOcclusion" ? [e, "occlusion"] : [e];
|
|
1999
|
-
}
|
|
2000
|
-
function ir(e, t) {
|
|
2001
|
-
return e === "useSpecularWorkflow" ? typeof t == "boolean" : e === "opacityMode" ? t === "transparent" || t === "presence" : /^(?:diffuseColor|baseColor|base_color|emissiveColor|emission_color)$/.test(e) ? Array.isArray(t) && t.length >= 3 && t.slice(0, 3).every((s) => typeof s == "number" && Number.isFinite(s)) : (/* @__PURE__ */ new Set([
|
|
2002
|
-
"roughness",
|
|
2003
|
-
"specular_roughness",
|
|
2004
|
-
"metallic",
|
|
2005
|
-
"metalness",
|
|
2006
|
-
"base_metalness",
|
|
2007
|
-
"ior",
|
|
2008
|
-
"clearcoat",
|
|
2009
|
-
"coat_weight",
|
|
2010
|
-
"clearcoatRoughness",
|
|
2011
|
-
"coat_roughness",
|
|
2012
|
-
"opacity",
|
|
2013
|
-
"opacityThreshold"
|
|
2014
|
-
])).has(e) && typeof t == "number" && Number.isFinite(t);
|
|
2015
|
-
}
|
|
2016
|
-
function ur(e, t, n, s) {
|
|
2017
|
-
for (const r of n) {
|
|
2018
|
-
const o = `USD 材质 ${t} 的 ${r.code}:${r.message}`;
|
|
2019
|
-
e.droppedFeatures.some((a) => a.code === "USD_VISUAL_MATERIAL_IR_ISSUE" && a.message === o) || e.droppedFeatures.push({
|
|
2020
|
-
code: "USD_VISUAL_MATERIAL_IR_ISSUE",
|
|
2021
|
-
message: o,
|
|
2022
|
-
source: "usd-visual"
|
|
2023
|
-
});
|
|
2024
|
-
}
|
|
2025
|
-
for (const r of oe(s)) {
|
|
2026
|
-
const o = `USD 材质 ${t} 的 ${r} 尚未完成浏览器适配;保留来源与 gap,不生成猜测内容。`;
|
|
2027
|
-
e.droppedFeatures.some((a) => a.code === "USD_VISUAL_SHADER_NODE_UNSUPPORTED" && a.message === o) || e.droppedFeatures.push({
|
|
2028
|
-
code: "USD_VISUAL_SHADER_NODE_UNSUPPORTED",
|
|
2029
|
-
message: o,
|
|
2030
|
-
source: "usd-visual"
|
|
2031
|
-
});
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
function cr(e, t, n, s) {
|
|
2035
|
-
var w;
|
|
2036
|
-
const r = { applied: [], unsupported: [], bounded: !1 }, o = le((w = n[0]) == null ? void 0 : w.userData.usdSurfaceShaderPath), a = t.shaders.filter((m) => De.test(m.id ?? "")), c = o ? a.find((m) => m.path === o) : a.length === 1 ? a[0] : void 0;
|
|
2037
|
-
if (!c) return r;
|
|
2038
|
-
const u = Oe(t, c, ["opacity"]), l = Oe(t, c, ["opacityMode"]), p = Oe(t, c, ["opacityThreshold"]), i = typeof u.value == "number" && Number.isFinite(u.value) ? u.value : null, f = typeof l.value == "string" ? l.value : "transparent", h = typeof p.value == "number" && Number.isFinite(p.value) ? p.value : 0, d = (m) => (r.bounded = !0, r.unsupported.push(m), r);
|
|
2039
|
-
if (u.connection || p.connection || l.connection) return d("connected opacity/threshold/mode");
|
|
2040
|
-
if (h > 0 || f === "presence") {
|
|
2041
|
-
if (n.some((U) => !X(U) || U.alphaMap || U.map)) return d("textured coverage/cutout");
|
|
2042
|
-
const m = Q(i ?? 1);
|
|
2043
|
-
for (const U of n)
|
|
2044
|
-
U.opacity = h > 0 ? m >= h ? 1 : 0 : m, U.alphaTest = h > 0 ? 0.5 : 0, U.transparent = h === 0 && m < 1, U.depthWrite = !U.transparent, U instanceof W && (U.transmission = 0), U.needsUpdate = !0;
|
|
2045
|
-
return r.applied.push(h > 0 ? "PreviewSurface.cutout.constant" : "PreviewSurface.presence.constant"), r;
|
|
2046
|
-
}
|
|
2047
|
-
if (f !== "transparent") return d(`opacityMode=${String(f)}`);
|
|
2048
|
-
if (i === null || i >= 1) return r;
|
|
2049
|
-
const g = Oe(t, c, ["metallic"]), _ = Oe(t, c, ["useSpecularWorkflow"]);
|
|
2050
|
-
if (!g.connection && g.value === 1 && !_.connection && [void 0, !1, 0].includes(_.value)) {
|
|
2051
|
-
if (n.some((m) => !X(m) || m.alphaMap || m.map || m.metalnessMap || m.alphaTest > 0)) return d("textured metal transparency");
|
|
2052
|
-
for (const m of n)
|
|
2053
|
-
X(m) && (m.opacity = 1, m.transparent = !1, m.depthWrite = !0, m.metalness = 1, m instanceof W && (m.transmission = 0), m.needsUpdate = !0);
|
|
2054
|
-
return r.applied.push("PreviewSurface.transparent.pure-metal"), r;
|
|
2055
|
-
}
|
|
2056
|
-
const y = Oe(t, c, ["ior"]);
|
|
2057
|
-
if (g.connection || _.connection || y.connection || (typeof g.value == "number" ? g.value : 0) !== 0 || ![void 0, !1, 0].includes(_.value)) return d("non-dielectric or connected transparency");
|
|
2058
|
-
if (n.some((m) => !X(m) || m.alphaMap || m.map || m.metalnessMap || m.alphaTest > 0)) return d("textured or non-standard transparency");
|
|
2059
|
-
Le(e, n);
|
|
2060
|
-
for (const m of n)
|
|
2061
|
-
m instanceof W && (m.opacity = 1, m.transparent = !1, m.transmission = 1 - Q(i), m.ior = typeof y.value == "number" && Number.isFinite(y.value) ? y.value : 1.5, m.depthWrite = !0, m.needsUpdate = !0);
|
|
2062
|
-
return r.applied.push("PreviewSurface.transparent.constant-dielectric"), r.bounded = !0, s.diagnostics.approximations.push({
|
|
2063
|
-
code: "USD_VISUAL_PREVIEW_TRANSMISSION_APPROXIMATION",
|
|
2064
|
-
source: "usd-visual",
|
|
2065
|
-
message: `USD 材质 ${t.path} 的常量介质透明已映射为实时透射;保留表面反射;Three.js 透射与反射共用粗糙度,不等同于 PreviewSurface 的零粗糙度透射。不推断壁厚或体积吸收,不保证多层折射与路径追踪等价。`
|
|
2066
|
-
}), r;
|
|
2067
|
-
}
|
|
2068
|
-
function lr(e, t, n) {
|
|
2069
|
-
var p;
|
|
2070
|
-
const s = { applied: [], unsupported: [], bounded: !1 }, r = le((p = t[0]) == null ? void 0 : p.userData.usdSurfaceShaderPath), o = e.shaders.filter((i) => i.id === "ND_standard_surface_surfaceshader"), a = r ? o.find((i) => i.path === r) : o.length === 1 ? o[0] : void 0;
|
|
2071
|
-
if (!a) return s;
|
|
2072
|
-
const c = (i) => {
|
|
2073
|
-
s.bounded = !0, s.unsupported.push(i);
|
|
2074
|
-
}, u = G(a, ["opacity"]);
|
|
2075
|
-
if (ee(a, "opacity")) c("connected opacity");
|
|
2076
|
-
else if (Array.isArray(u) && u.length === 3 && u.every((i) => typeof i == "number" && Number.isFinite(i)))
|
|
2077
|
-
if (u[0] !== u[1] || u[1] !== u[2]) c("colored opacity");
|
|
2078
|
-
else if (t.some((i) => !X(i) || i.alphaMap || i.map)) c("textured coverage");
|
|
2079
|
-
else {
|
|
2080
|
-
const i = Q(u[0]);
|
|
2081
|
-
for (const f of t)
|
|
2082
|
-
f.opacity = i, f.transparent = i < 1, f.depthWrite = i === 1, f.needsUpdate = !0;
|
|
2083
|
-
s.applied.push("MaterialX.opacity.achromatic-constant");
|
|
2084
|
-
}
|
|
2085
|
-
const l = N(a, ["transmission"]) ?? 0;
|
|
2086
|
-
return ee(a, "transmission") && c("connected transmission"), l > 0 && (s.bounded = !0, Array.isArray(u) && u.some((i) => typeof i == "number" && i > 0 && i < 1) && c("fractional coverage + transmission compositing"), ge(a, ["thin_walled"], !1) ? n.diagnostics.approximations.push({
|
|
2087
|
-
code: "USD_VISUAL_MATERIALX_TRANSMISSION_APPROXIMATION",
|
|
2088
|
-
source: "usd-visual",
|
|
2089
|
-
message: `USD 材质 ${e.path} 的 MaterialX 薄壁透射使用 Loader 的实时近似;并非完整 MaterialX 着色器执行。`
|
|
2090
|
-
}) : c("solid transmission / absorption path length")), s;
|
|
2091
|
-
}
|
|
2092
|
-
async function pr(e, t, n) {
|
|
2093
|
-
var O;
|
|
2094
|
-
const s = {
|
|
2095
|
-
applied: [],
|
|
2096
|
-
resolvedInputs: [],
|
|
2097
|
-
resources: []
|
|
2098
|
-
}, r = le((O = t[0]) == null ? void 0 : O.userData.usdSurfaceShaderPath), o = e.shaders.filter((C) => De.test(C.id ?? "")), a = r ? o.find((C) => C.path === r) : o.length === 1 ? o[0] : void 0;
|
|
2099
|
-
if (!a || ee(a, "opacityThreshold") || ee(a, "opacityMode")) return s;
|
|
2100
|
-
const c = N(a, ["opacityThreshold"]) ?? 0, u = G(a, ["opacityMode"]);
|
|
2101
|
-
if (u !== void 0 && u !== "transparent" && u !== "presence") return s;
|
|
2102
|
-
const l = ee(a, "opacity");
|
|
2103
|
-
if (!(l != null && l.outputName) || !["r", "g", "b", "a"].includes(l.outputName)) return s;
|
|
2104
|
-
const p = Xe(e, l);
|
|
2105
|
-
if (!p || p.id !== "UsdUVTexture" || G(p, ["sourceColorSpace"]) !== "raw") return s;
|
|
2106
|
-
const i = ee(p, "st"), f = i && Xe(e, i);
|
|
2107
|
-
if (!f || f.id !== "UsdPrimvarReader_float2" || G(f, ["varname"]) !== "st" || t.some((C) => !X(C) || C.map)) return s;
|
|
2108
|
-
const h = "rgba".indexOf(l.outputName), d = (C, v) => {
|
|
2109
|
-
if (ee(p, C)) return null;
|
|
2110
|
-
const B = p.inputs[`inputs:${C}`];
|
|
2111
|
-
return B === void 0 ? v : Array.isArray(B) && B.length === 4 && B.every(Number.isFinite) ? B[h] : null;
|
|
2112
|
-
}, g = d("scale", 1), _ = d("bias", 0);
|
|
2113
|
-
if (g === null || _ === null) return s;
|
|
2114
|
-
const y = (C) => {
|
|
2115
|
-
const v = G(p, [C]);
|
|
2116
|
-
return v === "repeat" ? te : v === "mirror" ? sn : v === "clamp" ? rn : null;
|
|
2117
|
-
}, w = y("wrapS"), m = y("wrapT"), U = ae(G(p, ["file"]));
|
|
2118
|
-
if (!U || w === null || m === null) return s;
|
|
2119
|
-
const b = JSON.stringify([p.path, l.outputName, g, _, w, m, c]);
|
|
2120
|
-
if (t.every((C) => {
|
|
2121
|
-
var v;
|
|
2122
|
-
return X(C) && ((v = C.alphaMap) == null ? void 0 : v.userData.usdCoverageConversionKey) === b;
|
|
2123
|
-
}))
|
|
2124
|
-
return s.applied.push(`PreviewSurface.opacity.texture.${l.outputName}->g`), s.resolvedInputs.push("opacity"), s.resources.push({ path: U, status: "available" }), s;
|
|
2125
|
-
const S = await ue(U, n);
|
|
2126
|
-
s.resources.push(S.report);
|
|
2127
|
-
let x = null;
|
|
2128
|
-
try {
|
|
2129
|
-
if (!S.url) return s;
|
|
2130
|
-
x = await (n.createTexture ?? ce)(S.url, re);
|
|
2131
|
-
const C = Ae(x, l.outputName, g, _);
|
|
2132
|
-
C.wrapS = w, C.wrapT = m, C.userData.usdCoverageConversionKey = b;
|
|
2133
|
-
for (const v of t)
|
|
2134
|
-
X(v) && (v.alphaMap = C, v.opacity = 1, v.alphaTest = c > 0 ? c : 0, v.transparent = c <= 0, v.depthWrite = c > 0, v instanceof W && (v.transmission = 0), v.needsUpdate = !0);
|
|
2135
|
-
s.applied.push(`PreviewSurface.opacity.texture.${l.outputName}->g`), n.diagnostics.approximations.push({
|
|
2136
|
-
code: "USD_VISUAL_COVERAGE_TEXTURE_APPROXIMATION",
|
|
2137
|
-
source: "usd-visual",
|
|
2138
|
-
message: `USD 材质 ${e.path} 的透明遮罩已按源通道转换;采用 8 位纹理重排,阈值边缘与过滤结果不保证跨渲染器逐像素一致。`
|
|
2139
|
-
});
|
|
2140
|
-
} catch (C) {
|
|
2141
|
-
if (C instanceof Error && C.name === "AbortError") throw C;
|
|
2142
|
-
s.resources[0] = { path: U, status: "decode-failed" };
|
|
2143
|
-
} finally {
|
|
2144
|
-
x == null || x.dispose();
|
|
2145
|
-
}
|
|
2146
|
-
return s;
|
|
2147
|
-
}
|
|
2148
|
-
const wn = [
|
|
2149
|
-
{
|
|
2150
|
-
reportName: "roughness",
|
|
2151
|
-
sources: [
|
|
2152
|
-
{ dialect: "usd-preview", inputNames: ["roughness"] },
|
|
2153
|
-
{ dialect: "openpbr", inputNames: ["specular_roughness"] },
|
|
2154
|
-
{ dialect: "materialx-standard-surface", inputNames: ["specular_roughness", "roughness"] }
|
|
2155
|
-
],
|
|
2156
|
-
targetMap: "roughnessMap",
|
|
2157
|
-
targetValue: "roughness",
|
|
2158
|
-
targetChannel: "g",
|
|
2159
|
-
physicalOnly: !1
|
|
2160
|
-
},
|
|
2161
|
-
{
|
|
2162
|
-
reportName: "metalness",
|
|
2163
|
-
sources: [
|
|
2164
|
-
{ dialect: "usd-preview", inputNames: ["metallic"] },
|
|
2165
|
-
{ dialect: "openpbr", inputNames: ["base_metalness", "metalness"] },
|
|
2166
|
-
{ dialect: "materialx-standard-surface", inputNames: ["base_metalness", "metalness"] }
|
|
2167
|
-
],
|
|
2168
|
-
targetMap: "metalnessMap",
|
|
2169
|
-
targetValue: "metalness",
|
|
2170
|
-
targetChannel: "b",
|
|
2171
|
-
physicalOnly: !1
|
|
2172
|
-
},
|
|
2173
|
-
{
|
|
2174
|
-
reportName: "occlusion",
|
|
2175
|
-
sources: [
|
|
2176
|
-
{ dialect: "usd-preview", inputNames: ["occlusion", "ambientOcclusion"] },
|
|
2177
|
-
{ dialect: "openpbr", inputNames: ["occlusion", "ambientOcclusion"] },
|
|
2178
|
-
{ dialect: "materialx-standard-surface", inputNames: ["occlusion", "ambientOcclusion"] }
|
|
2179
|
-
],
|
|
2180
|
-
targetMap: "aoMap",
|
|
2181
|
-
targetValue: "aoMapIntensity",
|
|
2182
|
-
targetChannel: "r",
|
|
2183
|
-
physicalOnly: !1,
|
|
2184
|
-
aoApproximation: !0
|
|
2185
|
-
},
|
|
2186
|
-
{
|
|
2187
|
-
reportName: "clearcoat",
|
|
2188
|
-
sources: [
|
|
2189
|
-
{ dialect: "openpbr", inputNames: ["coat_weight", "clearcoat", "coat"] },
|
|
2190
|
-
{ dialect: "materialx-standard-surface", inputNames: ["coat", "coat_weight", "clearcoat"] }
|
|
2191
|
-
],
|
|
2192
|
-
targetMap: "clearcoatMap",
|
|
2193
|
-
targetValue: "clearcoat",
|
|
2194
|
-
targetChannel: "r",
|
|
2195
|
-
physicalOnly: !0
|
|
2196
|
-
},
|
|
2197
|
-
{
|
|
2198
|
-
reportName: "clearcoatRoughness",
|
|
2199
|
-
sources: [
|
|
2200
|
-
{ dialect: "openpbr", inputNames: ["coat_roughness", "clearcoatRoughness", "coatRoughness"] },
|
|
2201
|
-
{ dialect: "materialx-standard-surface", inputNames: ["coat_roughness", "clearcoatRoughness", "coatRoughness"] }
|
|
2202
|
-
],
|
|
2203
|
-
targetMap: "clearcoatRoughnessMap",
|
|
2204
|
-
targetValue: "clearcoatRoughness",
|
|
2205
|
-
targetChannel: "g",
|
|
2206
|
-
physicalOnly: !0
|
|
2207
|
-
},
|
|
2208
|
-
{
|
|
2209
|
-
reportName: "transmission",
|
|
2210
|
-
sources: [
|
|
2211
|
-
{ dialect: "openpbr", inputNames: ["transmission_weight", "transmission", "transmissionWeight"] },
|
|
2212
|
-
{ dialect: "materialx-standard-surface", inputNames: ["transmission", "transmission_weight", "transmissionWeight"] }
|
|
2213
|
-
],
|
|
2214
|
-
targetMap: "transmissionMap",
|
|
2215
|
-
targetValue: "transmission",
|
|
2216
|
-
targetChannel: "r",
|
|
2217
|
-
physicalOnly: !0
|
|
2218
|
-
},
|
|
2219
|
-
{
|
|
2220
|
-
reportName: "thickness",
|
|
2221
|
-
sources: [
|
|
2222
|
-
{ dialect: "openpbr", inputNames: ["thickness"] },
|
|
2223
|
-
{ dialect: "materialx-standard-surface", inputNames: ["thickness"] }
|
|
2224
|
-
],
|
|
2225
|
-
targetMap: "thicknessMap",
|
|
2226
|
-
targetValue: "thickness",
|
|
2227
|
-
targetChannel: "g",
|
|
2228
|
-
physicalOnly: !0
|
|
2229
|
-
},
|
|
2230
|
-
{
|
|
2231
|
-
reportName: "sheenRoughness",
|
|
2232
|
-
sources: [
|
|
2233
|
-
{ dialect: "openpbr", inputNames: ["fuzz_roughness", "sheen_roughness", "sheenRoughness"] },
|
|
2234
|
-
{ dialect: "materialx-standard-surface", inputNames: ["sheen_roughness", "sheenRoughness"] }
|
|
2235
|
-
],
|
|
2236
|
-
targetMap: "sheenRoughnessMap",
|
|
2237
|
-
targetValue: "sheenRoughness",
|
|
2238
|
-
targetChannel: "a",
|
|
2239
|
-
physicalOnly: !0
|
|
2240
|
-
}
|
|
2241
|
-
];
|
|
2242
|
-
async function fr(e, t, n, s, r, o) {
|
|
2243
|
-
const a = {
|
|
2244
|
-
applied: [],
|
|
2245
|
-
resolved: [],
|
|
2246
|
-
resolvedInputs: [],
|
|
2247
|
-
unsupported: [],
|
|
2248
|
-
resources: []
|
|
2249
|
-
}, c = Pt(e);
|
|
2250
|
-
for (const u of e)
|
|
2251
|
-
for (const l of wn) {
|
|
2252
|
-
const p = l.sources.find((h) => h.dialect === u.dialect);
|
|
2253
|
-
if (!p) continue;
|
|
2254
|
-
let i;
|
|
2255
|
-
for (const h of p.inputNames)
|
|
2256
|
-
if (!s.has(`${u.dialect}:${h}`) && (i = u.textures.find((d) => d.surfaceInput === h), i))
|
|
2257
|
-
break;
|
|
2258
|
-
if (!i) continue;
|
|
2259
|
-
const f = await dr(
|
|
2260
|
-
u,
|
|
2261
|
-
l,
|
|
2262
|
-
i,
|
|
2263
|
-
t,
|
|
2264
|
-
n,
|
|
2265
|
-
c,
|
|
2266
|
-
r,
|
|
2267
|
-
o
|
|
2268
|
-
);
|
|
2269
|
-
a.applied.push(...f.applied), a.resolved.push(...f.resolved), a.resolvedInputs.push(...f.resolvedInputs), a.unsupported.push(...f.unsupported), a.resources.push(...f.resources);
|
|
2270
|
-
}
|
|
2271
|
-
return a;
|
|
2272
|
-
}
|
|
2273
|
-
async function dr(e, t, n, s, r, o, a, c) {
|
|
2274
|
-
var b;
|
|
2275
|
-
const u = {
|
|
2276
|
-
applied: [],
|
|
2277
|
-
resolved: [],
|
|
2278
|
-
resolvedInputs: [],
|
|
2279
|
-
unsupported: [],
|
|
2280
|
-
resources: []
|
|
2281
|
-
}, l = (S) => (u.unsupported.push(`${e.dialect}.${t.reportName}.${S}`), u);
|
|
2282
|
-
if (o) return l("multiple-uv-sets");
|
|
2283
|
-
if (((b = n.sourceColorSpace) == null ? void 0 : b.toLowerCase()) !== "raw") return l("non-raw-color-space");
|
|
2284
|
-
if (n.sourceChannel === "rgb" || n.sourceChannel === "mono")
|
|
2285
|
-
return l("missing-source-channel");
|
|
2286
|
-
const p = Se(n.wrapS), i = Se(n.wrapT);
|
|
2287
|
-
if (p === null || i === null) return l("unsupported-wrap");
|
|
2288
|
-
const f = "rgba".indexOf(n.sourceChannel), h = n.scale[f], d = n.bias[f], g = h === 1 && d === 0, _ = s.filter(X).filter((S) => !t.physicalOnly || S instanceof W);
|
|
2289
|
-
if (!_.length) return l("physical-material-required");
|
|
2290
|
-
const y = _.map((S) => _r(S, t));
|
|
2291
|
-
if (y.some((S) => (S == null ? void 0 : S.userData.usdTextureOwner) === "foreign"))
|
|
2292
|
-
return l("existing-foreign-map");
|
|
2293
|
-
const w = JSON.stringify([
|
|
2294
|
-
"usd-scalar-v2",
|
|
2295
|
-
e.materialPath,
|
|
2296
|
-
t.reportName,
|
|
2297
|
-
n.shaderPath,
|
|
2298
|
-
n.path,
|
|
2299
|
-
n.sourceColorSpace,
|
|
2300
|
-
n.sourceChannel,
|
|
2301
|
-
t.targetChannel,
|
|
2302
|
-
h,
|
|
2303
|
-
d,
|
|
2304
|
-
p,
|
|
2305
|
-
i,
|
|
2306
|
-
n.uvSet ?? "st",
|
|
2307
|
-
n.uvTransform
|
|
2308
|
-
]);
|
|
2309
|
-
if (y.every((S) => (S == null ? void 0 : S.userData.usdScalarConversionKey) === w)) {
|
|
2310
|
-
u.applied.push(`${t.reportName}.texture.${n.sourceChannel}->${t.targetChannel}`), u.resolvedInputs.push(n.surfaceInput);
|
|
2311
|
-
const S = it(r, n, t.reportName);
|
|
2312
|
-
return S && u.resolved.push(S), u;
|
|
2313
|
-
}
|
|
2314
|
-
if (!g || n.sourceChannel !== t.targetChannel) {
|
|
2315
|
-
const S = it(r, n, t.reportName) !== null;
|
|
2316
|
-
if (y.some((O) => O !== null && !O.userData.usdScalarConversionKey && !S)) return l("existing-map-owner-unknown");
|
|
2317
|
-
} else if (y.some((S) => S !== null) && y.every((S) => S !== null))
|
|
2318
|
-
return u.resolvedInputs.push(n.surfaceInput), u;
|
|
2319
|
-
const m = await ue(n.path, a);
|
|
2320
|
-
if (u.resources.push(m.report), !m.url) return u;
|
|
2321
|
-
let U = null;
|
|
2322
|
-
try {
|
|
2323
|
-
U = await (a.createTexture ?? ce)(m.url, re);
|
|
2324
|
-
const S = Ae(
|
|
2325
|
-
U,
|
|
2326
|
-
n.sourceChannel,
|
|
2327
|
-
h,
|
|
2328
|
-
d,
|
|
2329
|
-
t.targetChannel === "a" ? "a" : "rgb"
|
|
2330
|
-
);
|
|
2331
|
-
S.wrapS = p, S.wrapT = i, rt(S, n.uvTransform), S.channel = 0, S.userData.usdScalarConversionKey = w, S.userData.usdTextureOwner = "adapter-derived";
|
|
2332
|
-
for (const O of y)
|
|
2333
|
-
O != null && O.userData.usdScalarConversionKey && c.add(O);
|
|
2334
|
-
for (const O of _) gr(O, t, S);
|
|
2335
|
-
u.applied.push(`${t.reportName}.texture.${n.sourceChannel}->${t.targetChannel}`), u.resolvedInputs.push(n.surfaceInput), t.aoApproximation && a.diagnostics.approximations.push({
|
|
2336
|
-
code: "USD_VISUAL_AO_LIGHTING_APPROXIMATION",
|
|
2337
|
-
source: "usd-visual",
|
|
2338
|
-
message: `USD 材质 ${e.materialPath} 的 AO 已映射为 Three.js 间接光遮蔽;并非源材质对漫反射或直接光的等价调制。`
|
|
2339
|
-
});
|
|
2340
|
-
const x = it(r, n, t.reportName);
|
|
2341
|
-
x && u.resolved.push(x);
|
|
2342
|
-
} catch (S) {
|
|
2343
|
-
if (S instanceof Error && S.name === "AbortError") throw S;
|
|
2344
|
-
u.resources[u.resources.length - 1] = { path: n.path, status: "decode-failed" };
|
|
2345
|
-
} finally {
|
|
2346
|
-
U == null || U.dispose();
|
|
2347
|
-
}
|
|
2348
|
-
return u;
|
|
2349
|
-
}
|
|
2350
|
-
function mr(e, t) {
|
|
2351
|
-
if (!t.size) return;
|
|
2352
|
-
const n = /* @__PURE__ */ new Set();
|
|
2353
|
-
e.traverse((s) => {
|
|
2354
|
-
if (!s || !("material" in s)) return;
|
|
2355
|
-
const r = s.material;
|
|
2356
|
-
for (const o of Array.isArray(r) ? r : [r])
|
|
2357
|
-
if (o)
|
|
2358
|
-
for (const a of Object.values(o))
|
|
2359
|
-
a instanceof bt && n.add(a);
|
|
2360
|
-
});
|
|
2361
|
-
for (const s of t)
|
|
2362
|
-
s.userData.usdTextureOwner !== "adapter-derived" || n.has(s) || s.dispose();
|
|
2363
|
-
}
|
|
2364
|
-
function Pt(e) {
|
|
2365
|
-
return new Set(e.flatMap((t) => t.textures.map((n) => (n.uvSet ?? "st").toLowerCase()))).size > 1;
|
|
2366
|
-
}
|
|
2367
|
-
function hr(e) {
|
|
2368
|
-
if (!e || e.dialect !== "openpbr") return !1;
|
|
2369
|
-
const t = new Set(wn.filter((n) => n.physicalOnly).flatMap((n) => n.sources.filter((s) => s.dialect === "openpbr").flatMap((s) => s.inputNames)));
|
|
2370
|
-
return e.textures.some((n) => t.has(n.surfaceInput));
|
|
2371
|
-
}
|
|
2372
|
-
function Se(e) {
|
|
2373
|
-
const t = e == null ? void 0 : e.toLowerCase();
|
|
2374
|
-
return t ? t === "repeat" || t === "periodic" ? te : t === "mirror" || t === "mirroredrepeat" ? sn : t === "clamp" ? rn : null : null;
|
|
2375
|
-
}
|
|
2376
|
-
function _r(e, t) {
|
|
2377
|
-
switch (t.targetMap) {
|
|
2378
|
-
case "roughnessMap":
|
|
2379
|
-
return e.roughnessMap;
|
|
2380
|
-
case "metalnessMap":
|
|
2381
|
-
return e.metalnessMap;
|
|
2382
|
-
case "aoMap":
|
|
2383
|
-
return e.aoMap;
|
|
2384
|
-
case "clearcoatMap":
|
|
2385
|
-
return e instanceof W ? e.clearcoatMap : null;
|
|
2386
|
-
case "clearcoatRoughnessMap":
|
|
2387
|
-
return e instanceof W ? e.clearcoatRoughnessMap : null;
|
|
2388
|
-
case "transmissionMap":
|
|
2389
|
-
return e instanceof W ? e.transmissionMap : null;
|
|
2390
|
-
case "thicknessMap":
|
|
2391
|
-
return e instanceof W ? e.thicknessMap : null;
|
|
2392
|
-
case "sheenRoughnessMap":
|
|
2393
|
-
return e instanceof W ? e.sheenRoughnessMap : null;
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
function gr(e, t, n) {
|
|
2397
|
-
switch (t.targetMap) {
|
|
2398
|
-
case "roughnessMap":
|
|
2399
|
-
e.roughnessMap = n;
|
|
2400
|
-
break;
|
|
2401
|
-
case "metalnessMap":
|
|
2402
|
-
e.metalnessMap = n;
|
|
2403
|
-
break;
|
|
2404
|
-
case "aoMap":
|
|
2405
|
-
e.aoMap = n;
|
|
2406
|
-
break;
|
|
2407
|
-
case "clearcoatMap":
|
|
2408
|
-
if (e instanceof W) e.clearcoatMap = n;
|
|
2409
|
-
else return;
|
|
2410
|
-
break;
|
|
2411
|
-
case "clearcoatRoughnessMap":
|
|
2412
|
-
if (e instanceof W) e.clearcoatRoughnessMap = n;
|
|
2413
|
-
else return;
|
|
2414
|
-
break;
|
|
2415
|
-
case "transmissionMap":
|
|
2416
|
-
if (e instanceof W) e.transmissionMap = n;
|
|
2417
|
-
else return;
|
|
2418
|
-
break;
|
|
2419
|
-
case "thicknessMap":
|
|
2420
|
-
if (e instanceof W) e.thicknessMap = n;
|
|
2421
|
-
else return;
|
|
2422
|
-
break;
|
|
2423
|
-
case "sheenRoughnessMap":
|
|
2424
|
-
if (e instanceof W) e.sheenRoughnessMap = n;
|
|
2425
|
-
else return;
|
|
2426
|
-
break;
|
|
2427
|
-
}
|
|
2428
|
-
switch (t.targetValue) {
|
|
2429
|
-
case "roughness":
|
|
2430
|
-
e.roughness = 1;
|
|
2431
|
-
break;
|
|
2432
|
-
case "metalness":
|
|
2433
|
-
e.metalness = 1;
|
|
2434
|
-
break;
|
|
2435
|
-
case "aoMapIntensity":
|
|
2436
|
-
e.aoMapIntensity = 1;
|
|
2437
|
-
break;
|
|
2438
|
-
case "clearcoat":
|
|
2439
|
-
e instanceof W && (e.clearcoat = 1);
|
|
2440
|
-
break;
|
|
2441
|
-
case "clearcoatRoughness":
|
|
2442
|
-
e instanceof W && (e.clearcoatRoughness = 1);
|
|
2443
|
-
break;
|
|
2444
|
-
case "transmission":
|
|
2445
|
-
e instanceof W && (e.transmission = 1);
|
|
2446
|
-
break;
|
|
2447
|
-
case "thickness":
|
|
2448
|
-
e instanceof W && (e.thickness = 1);
|
|
2449
|
-
break;
|
|
2450
|
-
case "sheenRoughness":
|
|
2451
|
-
e instanceof W && (e.sheenRoughness = 1);
|
|
2452
|
-
break;
|
|
2453
|
-
}
|
|
2454
|
-
e.needsUpdate = !0;
|
|
2455
|
-
}
|
|
2456
|
-
function it(e, t, n) {
|
|
2457
|
-
return e.find((s) => s.includes(`from ${t.shaderPath}`) && s.includes(`Three.js ${n}`)) ?? e.find((s) => s.startsWith(`Texture scale/bias on ${t.shaderPath}`)) ?? null;
|
|
2458
|
-
}
|
|
2459
|
-
function yr(e) {
|
|
2460
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
2461
|
-
return e.scene.traverse((s) => {
|
|
2462
|
-
if (s instanceof me)
|
|
2463
|
-
for (const r of Array.isArray(s.material) ? s.material : [s.material]) {
|
|
2464
|
-
if (n.has(r)) continue;
|
|
2465
|
-
n.add(r);
|
|
2466
|
-
const o = le(r.userData.usdMaterialPath);
|
|
2467
|
-
if (!o) continue;
|
|
2468
|
-
const a = t.get(o);
|
|
2469
|
-
a ? a.push(r) : t.set(o, [r]);
|
|
2470
|
-
}
|
|
2471
|
-
}), t;
|
|
2472
|
-
}
|
|
2473
|
-
function _t(e, t) {
|
|
2474
|
-
const n = t ? e.shaders.find((r) => r.path === t) : void 0;
|
|
2475
|
-
if (n) return n;
|
|
2476
|
-
const s = e.shaders.filter((r) => /^PxrSurface$/i.test(r.id ?? "") || We(r) || It(r) || Rt(r) || At(r) || Mt(r));
|
|
2477
|
-
return s.length === 1 ? s[0] : null;
|
|
2478
|
-
}
|
|
2479
|
-
function Kt(e, t, n) {
|
|
2480
|
-
if (n) {
|
|
2481
|
-
const a = e.shaders.find((c) => c.path === n);
|
|
2482
|
-
if (a) return a;
|
|
2483
|
-
}
|
|
2484
|
-
const s = le(t.userData.usdSurfaceShaderPath);
|
|
2485
|
-
if (s) {
|
|
2486
|
-
const a = e.shaders.find((c) => c.path === s);
|
|
2487
|
-
if (a) return a;
|
|
2488
|
-
}
|
|
2489
|
-
const r = _t(e);
|
|
2490
|
-
if (r) return r;
|
|
2491
|
-
const o = e.shaders.filter((a) => De.test(a.id ?? "") || yn.test(a.id ?? ""));
|
|
2492
|
-
return o.length === 1 ? o[0] : null;
|
|
2493
|
-
}
|
|
2494
|
-
function wr(e) {
|
|
2495
|
-
return De.test(e.id ?? "");
|
|
2496
|
-
}
|
|
2497
|
-
function br(e) {
|
|
2498
|
-
return /open.?pbr/i.test(e.id ?? "");
|
|
2499
|
-
}
|
|
2500
|
-
function bn(e) {
|
|
2501
|
-
return /open.?pbr/i.test(e);
|
|
2502
|
-
}
|
|
2503
|
-
function Ht(e, t, n) {
|
|
2504
|
-
var o;
|
|
2505
|
-
const s = le((o = t[0]) == null ? void 0 : o.userData.usdSurfaceShaderPath);
|
|
2506
|
-
if (s) {
|
|
2507
|
-
const a = e.shaders.find((c) => c.path === s);
|
|
2508
|
-
if (a && n(a)) return a;
|
|
2509
|
-
}
|
|
2510
|
-
const r = e.shaders.filter(n);
|
|
2511
|
-
return r.length === 1 ? r[0] : null;
|
|
2512
|
-
}
|
|
2513
|
-
function Sr(e, t, n, s, r) {
|
|
2514
|
-
const o = Sn(e), a = le(t.userData.usdSurfaceShaderPath), c = (u, l) => o.has(u.path) || a === u.path || l;
|
|
2515
|
-
return c(s, De.test(n ?? "")) && c(r, bn(n ?? ""));
|
|
2516
|
-
}
|
|
2517
|
-
function Sn(e) {
|
|
2518
|
-
const t = /* @__PURE__ */ new Set(), n = (s) => {
|
|
2519
|
-
for (const [r, o] of Object.entries(s)) {
|
|
2520
|
-
if (!/surface/i.test(r) || !/(?:connect|outputs)/i.test(r)) continue;
|
|
2521
|
-
const a = Re(o);
|
|
2522
|
-
a && t.add(a.path);
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
n(e.inputs);
|
|
2526
|
-
for (const s of e.shaders) n(s.inputs);
|
|
2527
|
-
return t;
|
|
2528
|
-
}
|
|
2529
|
-
function vr(e) {
|
|
2530
|
-
var s, r, o, a, c;
|
|
2531
|
-
const t = /* @__PURE__ */ new Map(), n = e.stage;
|
|
2532
|
-
for (const u of e.data.materials) {
|
|
2533
|
-
const l = Sn(u);
|
|
2534
|
-
if (l.size === 1) {
|
|
2535
|
-
t.set(u.path, [...l][0]);
|
|
2536
|
-
continue;
|
|
2537
|
-
}
|
|
2538
|
-
if (!(n != null && n.GetPrimAtPath)) continue;
|
|
2539
|
-
const p = n.GetPrimAtPath(u.path);
|
|
2540
|
-
if (p != null && p.GetAttribute) {
|
|
2541
|
-
for (const i of ["outputs:mdl:surface", "outputs:surface", "surface"]) {
|
|
2542
|
-
const f = p.GetAttribute(i);
|
|
2543
|
-
if (!((s = f == null ? void 0 : f.IsValid) != null && s.call(f))) {
|
|
2544
|
-
(r = f == null ? void 0 : f.delete) == null || r.call(f);
|
|
2545
|
-
continue;
|
|
2546
|
-
}
|
|
2547
|
-
try {
|
|
2548
|
-
for (const h of ((o = f.GetConnections) == null ? void 0 : o.call(f)) ?? []) {
|
|
2549
|
-
const d = typeof h == "string" ? h : h.path, g = Re(d);
|
|
2550
|
-
if (g) {
|
|
2551
|
-
t.set(u.path, g.path);
|
|
2552
|
-
break;
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
} finally {
|
|
2556
|
-
(a = f.delete) == null || a.call(f);
|
|
2557
|
-
}
|
|
2558
|
-
if (t.has(u.path)) break;
|
|
2559
|
-
}
|
|
2560
|
-
(c = p.delete) == null || c.call(p);
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
return t;
|
|
2564
|
-
}
|
|
2565
|
-
function Le(e, t) {
|
|
2566
|
-
const n = /* @__PURE__ */ new Map();
|
|
2567
|
-
for (const s of t) {
|
|
2568
|
-
if (!X(s) || s instanceof W) continue;
|
|
2569
|
-
const r = new W();
|
|
2570
|
-
St.prototype.copy.call(r, s), r.defines = { STANDARD: "", PHYSICAL: "" }, n.set(s, r);
|
|
2571
|
-
}
|
|
2572
|
-
if (!n.size) return t.filter((s) => s instanceof W);
|
|
2573
|
-
e.scene.traverse((s) => {
|
|
2574
|
-
s instanceof me && (s.material = Array.isArray(s.material) ? s.material.map((r) => n.get(r) ?? r) : n.get(s.material) ?? s.material);
|
|
2575
|
-
}), t.forEach((s, r) => {
|
|
2576
|
-
t[r] = n.get(s) ?? s;
|
|
2577
|
-
});
|
|
2578
|
-
for (const s of n.keys()) s.dispose();
|
|
2579
|
-
return t.filter((s) => s instanceof W);
|
|
2580
|
-
}
|
|
2581
|
-
function Rt(e) {
|
|
2582
|
-
var s;
|
|
2583
|
-
const t = ae(e.inputs["info:mdl:sourceAsset"]), n = e.inputs["info:mdl:sourceAsset:subIdentifier"];
|
|
2584
|
-
return ((s = t == null ? void 0 : t.replaceAll("\\", "/").split("/").at(-1)) == null ? void 0 : s.toLowerCase()) === "omniglass.mdl" && (n === void 0 || n === "OmniGlass");
|
|
2585
|
-
}
|
|
2586
|
-
function Ur(e, t, n) {
|
|
2587
|
-
const s = { applied: [], unsupported: /* @__PURE__ */ new Set() }, r = /* @__PURE__ */ new Set(["glass_color", "glass_ior", "frosting_roughness", "thin_walled", "reflection_color", "enable_opacity", "cutout_opacity", "opacity_constant", "opacity_threshold"]);
|
|
2588
|
-
for (const [w, m] of Object.entries(n.inputs)) {
|
|
2589
|
-
if (!w.startsWith("inputs:")) continue;
|
|
2590
|
-
const U = w.slice(7);
|
|
2591
|
-
r.has(U) || ["glass_color_texture", "roughness_texture", "normalmap_texture"].includes(U) && !ae(m) || s.unsupported.add(`OmniGlass.${U}`);
|
|
2592
|
-
}
|
|
2593
|
-
const o = (w) => (s.unsupported.add(`OmniGlass.${w}`), s);
|
|
2594
|
-
for (const w of r) if (ee(n, w)) return o(`${w}.connection`);
|
|
2595
|
-
const a = N(n, ["glass_ior"]) ?? 1.491, c = N(n, ["frosting_roughness"]) ?? 0, u = G(n, ["thin_walled"]) ?? !1, l = G(n, ["glass_color"]) ?? [1, 1, 1], p = G(n, ["reflection_color"]) ?? [1, 1, 1];
|
|
2596
|
-
if (!Array.isArray(p) || p.length !== 3 || !p.every((w) => typeof w == "number" && Number.isFinite(w) && w >= 0 && w <= 1)) return o("reflection_color.range");
|
|
2597
|
-
if (G(n, ["glass_ior"]) !== void 0 && N(n, ["glass_ior"]) === null || a < 1 || a > 2.333) return o("glass_ior.range");
|
|
2598
|
-
if (G(n, ["frosting_roughness"]) !== void 0 && N(n, ["frosting_roughness"]) === null || c < 0 || c > 1) return o("frosting_roughness.range");
|
|
2599
|
-
if (typeof u != "boolean") return o("thin_walled.type");
|
|
2600
|
-
if (!Array.isArray(l) || l.length !== 3 || !l.every((w) => typeof w == "number" && Number.isFinite(w) && w >= 0 && w <= 1)) return o("glass_color.range");
|
|
2601
|
-
if (t.some((w) => !X(w))) return o("non-standard-loader-material");
|
|
2602
|
-
if (t.some((w) => X(w) && (w.map || w.alphaMap || w.roughnessMap || w.metalnessMap))) return o("existing-loader-texture-semantics");
|
|
2603
|
-
u || s.unsupported.add("OmniGlass.solid_volume_absorption"), u && l.some((w) => w !== 1) && s.unsupported.add("OmniGlass.tint_reflection_coupling"), !u && l.some((w) => w !== 1) && s.unsupported.add("OmniGlass.glass_color.volume");
|
|
2604
|
-
const i = G(n, ["enable_opacity"]) ?? !1;
|
|
2605
|
-
if (typeof i != "boolean") return o("enable_opacity.type");
|
|
2606
|
-
const f = N(n, ["cutout_opacity"]), h = N(n, ["opacity_constant"]);
|
|
2607
|
-
if (i && f !== null && h !== null && Math.abs(f - h) > 1e-6) return o("opacity.alias-conflict");
|
|
2608
|
-
for (const w of ["cutout_opacity", "opacity_constant", "opacity_threshold"]) if (i && G(n, [w]) !== void 0 && N(n, [w]) === null) return o(`${w}.type`);
|
|
2609
|
-
const d = i ? f ?? h ?? 1 : 1, g = i ? N(n, ["opacity_threshold"]) ?? 0 : 0;
|
|
2610
|
-
if (d < 0 || d > 1 || g < 0 || g > 1) return o("opacity.range");
|
|
2611
|
-
if (i && (ae(G(n, ["opacity_texture"])) || ee(n, "opacity_texture"))) return o("opacity_texture");
|
|
2612
|
-
const _ = g > 0 ? d >= g ? 1 : 0 : d, y = /* @__PURE__ */ new Map();
|
|
2613
|
-
for (const w of t) {
|
|
2614
|
-
const m = w instanceof W ? w : new W();
|
|
2615
|
-
m !== w && (St.prototype.copy.call(m, w), m.defines = { STANDARD: "", PHYSICAL: "" }, y.set(w, m)), m.color.setRGB(...u ? l : [1, 1, 1]), m.specularColor.setRGB(...p), m.metalness = 0, m.roughness = c, m.ior = a, m.opacity = _, m.transparent = g === 0 && _ < 1, m.alphaTest = g > 0 ? 0.5 : 0, m.transmission = 1, m.thickness = 0, m.depthWrite = !m.transparent, m.attenuationColor.setRGB(1, 1, 1), m.attenuationDistance = 1 / 0, m.needsUpdate = !0;
|
|
2616
|
-
}
|
|
2617
|
-
e.scene.traverse((w) => {
|
|
2618
|
-
w instanceof me && (w.material = Array.isArray(w.material) ? w.material.map((m) => y.get(m) ?? m) : y.get(w.material) ?? w.material);
|
|
2619
|
-
}), t.forEach((w, m) => {
|
|
2620
|
-
t[m] = y.get(w) ?? w;
|
|
2621
|
-
});
|
|
2622
|
-
for (const w of y.keys()) w.dispose();
|
|
2623
|
-
return s.applied.push("OmniGlass.reflection_color.specular-approximation", "OmniGlass.glass_ior", "OmniGlass.frosting_roughness", "OmniGlass.surface_transmission"), i && s.applied.push("OmniGlass.opacity.constant-coverage"), _ > 0 && _ < 1 && s.unsupported.add("OmniGlass.fractional_coverage_transmission_compositing"), u && s.applied.push("OmniGlass.thin_walled", "OmniGlass.glass_color.surface-approximation"), s;
|
|
2624
|
-
}
|
|
2625
|
-
async function Or(e, t, n, s) {
|
|
2626
|
-
const r = [], o = ["normalmap_texture", "normalmap_texture_colorspace", "bump_factor", "flip_tangent_u", "flip_tangent_v"], a = () => o.forEach((g) => n.unsupported.delete(`OmniGlass.${g}`));
|
|
2627
|
-
if (o.some((g) => ee(t, g))) return r;
|
|
2628
|
-
const c = ae(G(t, ["normalmap_texture"]));
|
|
2629
|
-
if (!c)
|
|
2630
|
-
return a(), r;
|
|
2631
|
-
const u = N(t, ["bump_factor"]) ?? 1;
|
|
2632
|
-
if (G(t, ["bump_factor"]) !== void 0 && N(t, ["bump_factor"]) === null || u < 0) return r;
|
|
2633
|
-
if (u === 0)
|
|
2634
|
-
return a(), r;
|
|
2635
|
-
const l = G(t, ["flip_tangent_u"]) ?? !1, p = G(t, ["flip_tangent_v"]) ?? !0;
|
|
2636
|
-
if (typeof l != "boolean" || typeof p != "boolean" || G(t, ["normalmap_texture_colorspace"]) !== "raw" || ["project_uvw", "world_or_object", "uv_space_index", "texture_scale", "texture_translate", "texture_rotate"].some((g) => ee(t, g)) || !Ue(t, /* @__PURE__ */ new Set())) return r;
|
|
2637
|
-
const f = e.filter((g) => g instanceof W);
|
|
2638
|
-
if (!f.length || f.some((g) => g.normalMap))
|
|
2639
|
-
return n.unsupported.add("OmniGlass.existing_normalMap"), r;
|
|
2640
|
-
const h = await ue(c, s);
|
|
2641
|
-
if (r.push(h.report), !h.url) return r;
|
|
2642
|
-
let d = null;
|
|
2643
|
-
try {
|
|
2644
|
-
d = await (s.createTexture ?? ce)(h.url, re), d.colorSpace = re, d.wrapS = te, d.wrapT = te, d.channel = 0;
|
|
2645
|
-
for (const g of f)
|
|
2646
|
-
g.normalMap = d, g.normalScale.set(u * (l ? -1 : 1), u * (p ? -1 : 1)), g.needsUpdate = !0;
|
|
2647
|
-
a(), n.applied.push("OmniGlass.normalmap_texture", "OmniGlass.normal.tangent_convention"), d = null;
|
|
2648
|
-
} catch (g) {
|
|
2649
|
-
if (g instanceof Error && g.name === "AbortError") throw g;
|
|
2650
|
-
r[0] = { path: c, status: "decode-failed" };
|
|
2651
|
-
} finally {
|
|
2652
|
-
d == null || d.dispose();
|
|
2653
|
-
}
|
|
2654
|
-
return r;
|
|
2655
|
-
}
|
|
2656
|
-
async function Pr(e, t, n, s) {
|
|
2657
|
-
const r = [], o = ae(G(t, ["roughness_texture"]));
|
|
2658
|
-
if (!o) return r;
|
|
2659
|
-
const a = N(t, ["roughness_texture_influence"]) ?? 1;
|
|
2660
|
-
if (ee(t, "roughness_texture_influence") || a < 0 || a > 1 || G(t, ["roughness_texture_influence"]) !== void 0 && N(t, ["roughness_texture_influence"]) === null) return r;
|
|
2661
|
-
if (a === 0)
|
|
2662
|
-
return n.unsupported.delete("OmniGlass.roughness_texture"), n.unsupported.delete("OmniGlass.roughness_texture_influence"), r;
|
|
2663
|
-
if (G(t, ["roughness_texture_colorspace"]) !== "raw" || ["project_uvw", "uv_space_index", "texture_scale", "texture_translate", "texture_rotate"].some((i) => ee(t, i)) || !Ue(t, /* @__PURE__ */ new Set())) return r;
|
|
2664
|
-
const l = await ue(o, s);
|
|
2665
|
-
if (r.push(l.report), !l.url) return r;
|
|
2666
|
-
let p = null;
|
|
2667
|
-
try {
|
|
2668
|
-
p = await (s.createTexture ?? ce)(l.url, re);
|
|
2669
|
-
const i = N(t, ["frosting_roughness"]) ?? 0, f = Ae(p, "grayscale", a, i * (1 - a));
|
|
2670
|
-
f.wrapS = te, f.wrapT = te;
|
|
2671
|
-
for (const h of e) h instanceof W && (h.roughnessMap = f, h.roughness = 1, h.needsUpdate = !0);
|
|
2672
|
-
n.applied.push("OmniGlass.roughness_texture.grayscale-linear-blend");
|
|
2673
|
-
for (const h of ["roughness_texture", "roughness_texture_influence", "roughness_texture_colorspace"]) n.unsupported.delete(`OmniGlass.${h}`);
|
|
2674
|
-
} catch (i) {
|
|
2675
|
-
if (i instanceof Error && i.name === "AbortError") throw i;
|
|
2676
|
-
n.unsupported.add("OmniGlass.roughness_texture.pixel-conversion");
|
|
2677
|
-
} finally {
|
|
2678
|
-
p == null || p.dispose();
|
|
2679
|
-
}
|
|
2680
|
-
return r;
|
|
2681
|
-
}
|
|
2682
|
-
function We(e) {
|
|
2683
|
-
var n;
|
|
2684
|
-
const t = ae(e.inputs["info:mdl:sourceAsset"]);
|
|
2685
|
-
return ((n = t == null ? void 0 : t.replaceAll("\\", "/").split("/").at(-1)) == null ? void 0 : n.toLowerCase()) === "omnipbr.mdl";
|
|
2686
|
-
}
|
|
2687
|
-
function It(e) {
|
|
2688
|
-
var s, r;
|
|
2689
|
-
const t = (s = ae(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/"), n = le(e.inputs["info:mdl:sourceAsset:subIdentifier"]);
|
|
2690
|
-
return ((r = t == null ? void 0 : t.split("/").at(-1)) == null ? void 0 : r.toLowerCase()) !== "omnipbrbase.mdl" ? !1 : n ? n.toLowerCase() === "omnipbrbase" : [
|
|
2691
|
-
"inputs:diffuse_reflection_color",
|
|
2692
|
-
"inputs:geometry_opacity",
|
|
2693
|
-
"inputs:specular_level",
|
|
2694
|
-
"inputs:enable_coat",
|
|
2695
|
-
"inputs:specular_reflection_roughness"
|
|
2696
|
-
].some((o) => e.inputs[o] !== void 0 || e.inputs[`${o}.connect`] !== void 0 || e.inputs[`${o}.resolvedConnect`] !== void 0);
|
|
2697
|
-
}
|
|
2698
|
-
function At(e) {
|
|
2699
|
-
var s;
|
|
2700
|
-
const t = (s = ae(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/"), n = le(e.inputs["info:mdl:sourceAsset:subIdentifier"]);
|
|
2701
|
-
return /(?:^|\/)gltf\/pbr\.mdl$/i.test(t ?? "") ? n !== null ? n.toLowerCase() === "gltf_material" : [
|
|
2702
|
-
"inputs:base_color_factor",
|
|
2703
|
-
"inputs:metallic_factor",
|
|
2704
|
-
"inputs:roughness_factor",
|
|
2705
|
-
"inputs:alpha_mode",
|
|
2706
|
-
"inputs:base_alpha",
|
|
2707
|
-
"inputs:base_color_texture.connect",
|
|
2708
|
-
"inputs:normal_texture.connect"
|
|
2709
|
-
].some((r) => e.inputs[r] !== void 0) : !1;
|
|
2710
|
-
}
|
|
2711
|
-
function Mt(e) {
|
|
2712
|
-
var s, r;
|
|
2713
|
-
const t = (s = ae(e.inputs["info:mdl:sourceAsset"])) == null ? void 0 : s.replaceAll("\\", "/"), n = le(e.inputs["info:mdl:sourceAsset:subIdentifier"]);
|
|
2714
|
-
return ((r = t == null ? void 0 : t.split("/").at(-1)) == null ? void 0 : r.toLowerCase()) === "omnisurfacebase.mdl" || (n == null ? void 0 : n.toLowerCase()) === "omnisurfacebase";
|
|
2715
|
-
}
|
|
2716
|
-
async function Rr(e, t, n, s, r) {
|
|
2717
|
-
const o = [], a = [], c = [], u = de(e, ["base_color_factor"]), l = N(e, ["metallic_factor"]), p = N(e, ["roughness_factor"]), i = kr(G(e, ["alpha_mode"])), f = Q(N(e, ["base_alpha"]) ?? 1), h = Q(N(e, ["alpha_cutoff"]) ?? 0.5);
|
|
2718
|
-
u && o.push("gltf_material.base_color_factor"), l !== null && o.push("gltf_material.metallic_factor"), p !== null && o.push("gltf_material.roughness_factor"), o.push(`gltf_material.alpha_mode.${i}`), i === "blend" && o.push("gltf_material.base_alpha"), i === "mask" && o.push("gltf_material.alpha_cutoff");
|
|
2719
|
-
for (const m of n.filter(X))
|
|
2720
|
-
u && m.color.copy(u), l !== null && (m.metalness = Q(l)), p !== null && (m.roughness = Q(p)), m.alphaTest = i === "mask" ? h : 0, m.opacity = i === "blend" ? f : 1, m.transparent = i === "blend", m.depthWrite = i !== "blend", m.needsUpdate = !0;
|
|
2721
|
-
if (ee(e, "base_color_texture")) {
|
|
2722
|
-
const m = await st(
|
|
2723
|
-
[t],
|
|
2724
|
-
n,
|
|
2725
|
-
/* @__PURE__ */ new Set(),
|
|
2726
|
-
s,
|
|
2727
|
-
r
|
|
2728
|
-
);
|
|
2729
|
-
if (o.push(...m.applied), a.push(...m.unsupported), c.push(...m.resources), u) for (const U of n.filter(X)) U.color.copy(u);
|
|
2730
|
-
}
|
|
2731
|
-
if (ee(e, "normal_texture")) {
|
|
2732
|
-
const m = await Ir(
|
|
2733
|
-
t,
|
|
2734
|
-
e,
|
|
2735
|
-
n,
|
|
2736
|
-
s,
|
|
2737
|
-
r
|
|
2738
|
-
);
|
|
2739
|
-
o.push(...m.applied), a.push(...m.unsupported), c.push(...m.resources);
|
|
2740
|
-
}
|
|
2741
|
-
const _ = /* @__PURE__ */ new Set(["base_color_texture", "normal_texture"]);
|
|
2742
|
-
for (const [m, U] of Object.entries(e.inputs)) {
|
|
2743
|
-
if (!m.endsWith(".resolvedConnect") && !m.endsWith(".connect")) continue;
|
|
2744
|
-
const b = m.replace(/^inputs:/, "").replace(/\.(?:resolvedConnect|connect)$/, "");
|
|
2745
|
-
if (_.has(b)) continue;
|
|
2746
|
-
const S = Re(U);
|
|
2747
|
-
a.push(`gltf_material.${b}${S ? `:${S.path}` : ""}`);
|
|
2748
|
-
}
|
|
2749
|
-
const y = de(e, ["emissive_factor"]);
|
|
2750
|
-
y && y.getHex() !== 0 && a.push("gltf_material.emissive_factor");
|
|
2751
|
-
const w = /* @__PURE__ */ new Set([
|
|
2752
|
-
"base_color_factor",
|
|
2753
|
-
"base_alpha",
|
|
2754
|
-
"alpha_mode",
|
|
2755
|
-
"alpha_cutoff",
|
|
2756
|
-
"metallic_factor",
|
|
2757
|
-
"roughness_factor",
|
|
2758
|
-
"emissive_strength",
|
|
2759
|
-
"base_color_texture",
|
|
2760
|
-
"normal_texture"
|
|
2761
|
-
]);
|
|
2762
|
-
for (const m of Object.keys(e.inputs)) {
|
|
2763
|
-
if (!m.startsWith("inputs:")) continue;
|
|
2764
|
-
const U = m.slice(7).replace(/\.(?:resolvedConnect|connect)$/, "");
|
|
2765
|
-
w.has(U) || a.push(`gltf_material.${U}`);
|
|
2766
|
-
}
|
|
2767
|
-
return { applied: oe(o), unsupported: oe(a), resources: c };
|
|
2768
|
-
}
|
|
2769
|
-
async function Ir(e, t, n, s, r) {
|
|
2770
|
-
var _;
|
|
2771
|
-
const o = { applied: [], unsupported: [], resources: [] }, a = e.textures.find((y) => y.surfaceInput === "normal_texture" && y.semantic === "normal");
|
|
2772
|
-
if (!a)
|
|
2773
|
-
return o.unsupported.push("gltf_material.normal_texture.unresolved-texture"), o;
|
|
2774
|
-
const c = (a.uvSet ?? "texcoord0").toLowerCase();
|
|
2775
|
-
if (c !== "texcoord0" && c !== "st")
|
|
2776
|
-
return o.unsupported.push(`gltf_material.normal_texture.uv=${c}`), o;
|
|
2777
|
-
if (((_ = a.sourceColorSpace) == null ? void 0 : _.toLowerCase()) !== "raw")
|
|
2778
|
-
return o.unsupported.push(`gltf_material.normal_texture.color-space=${a.sourceColorSpace ?? "auto"}`), o;
|
|
2779
|
-
const u = a.wrapS === null ? te : Se(a.wrapS), l = a.wrapT === null ? te : Se(a.wrapT);
|
|
2780
|
-
if (u === null || l === null)
|
|
2781
|
-
return o.unsupported.push("gltf_material.normal_texture.unsupported-wrap"), o;
|
|
2782
|
-
const p = N(t, ["normal_scale", "normalScale"]) ?? 1;
|
|
2783
|
-
if (!Number.isFinite(p) || p < 0)
|
|
2784
|
-
return o.unsupported.push("gltf_material.normal_scale"), o;
|
|
2785
|
-
const i = n.filter(X);
|
|
2786
|
-
if (!i.length)
|
|
2787
|
-
return o.unsupported.push("gltf_material.normal_texture.standard-material-required"), o;
|
|
2788
|
-
const f = i.map((y) => y.normalMap);
|
|
2789
|
-
if (f.some((y) => y && y.userData.usdTextureOwner === "foreign"))
|
|
2790
|
-
return o.unsupported.push("gltf_material.normal_texture.existing-foreign-map"), o;
|
|
2791
|
-
const h = JSON.stringify([
|
|
2792
|
-
"gltf-normal-v1",
|
|
2793
|
-
e.materialPath,
|
|
2794
|
-
a.shaderPath,
|
|
2795
|
-
a.path,
|
|
2796
|
-
a.wrapS,
|
|
2797
|
-
a.wrapT,
|
|
2798
|
-
a.uvSet,
|
|
2799
|
-
a.uvTransform,
|
|
2800
|
-
p
|
|
2801
|
-
]);
|
|
2802
|
-
if (f.every((y) => (y == null ? void 0 : y.userData.usdNormalConversionKey) === h))
|
|
2803
|
-
return o.applied.push("gltf_material.normal_texture"), o.resources.push({ path: a.path, status: "available" }), o;
|
|
2804
|
-
if (f.some((y) => y && !y.userData.usdNormalConversionKey))
|
|
2805
|
-
return o.unsupported.push("gltf_material.normal_texture.existing-map-owner-unknown"), o;
|
|
2806
|
-
const d = await ue(a.path, s);
|
|
2807
|
-
if (o.resources.push(d.report), !d.url) return o;
|
|
2808
|
-
let g = null;
|
|
2809
|
-
try {
|
|
2810
|
-
g = await (s.createTexture ?? ce)(d.url, re), g.colorSpace = re, g.wrapS = u, g.wrapT = l, g.channel = 0, g.userData.usdNormalConversionKey = h, g.userData.usdTextureOwner = "adapter-derived", rt(g, a.uvTransform);
|
|
2811
|
-
for (const y of f)
|
|
2812
|
-
y != null && y.userData.usdNormalConversionKey && r.add(y);
|
|
2813
|
-
for (const y of i)
|
|
2814
|
-
y.normalMap = g, y.normalScale.set(p, p), y.needsUpdate = !0;
|
|
2815
|
-
o.applied.push("gltf_material.normal_texture"), g = null;
|
|
2816
|
-
} catch (y) {
|
|
2817
|
-
if (y instanceof Error && y.name === "AbortError") throw y;
|
|
2818
|
-
o.resources[o.resources.length - 1] = {
|
|
2819
|
-
path: a.path,
|
|
2820
|
-
status: "decode-failed"
|
|
2821
|
-
};
|
|
2822
|
-
} finally {
|
|
2823
|
-
g == null || g.dispose();
|
|
2824
|
-
}
|
|
2825
|
-
return o;
|
|
2826
|
-
}
|
|
2827
|
-
async function Ar(e, t, n, s, r, o) {
|
|
2828
|
-
const a = [], c = [], u = [], l = n.textures.find((I) => I.surfaceInput === "diffuse_reflection_color" && I.semantic === "color" && I.sourceChannel === "rgb"), p = n.textures.find((I) => I.surfaceInput === "geometry_opacity" && I.sourceChannel === "mono"), i = de(t, ["diffuse_reflection_color"]), f = de(t, ["diffuse_tint"]), h = N(t, ["diffuse_reflection_weight"]), d = N(t, ["specular_reflection_roughness"]), g = N(t, ["metalness"]), _ = N(t, ["specular_level"]), y = de(t, ["specular_reflection_color"]), w = Ce(t, "enable_opacity", !1), m = N(t, ["geometry_opacity_threshold", "opacity_threshold"]) ?? 0, U = N(t, ["coat_weight"]) ?? 0, b = N(t, ["coat_roughness"]), S = N(t, ["coat_ior"]), O = Ce(t, "enable_emission", !1) ? de(t, ["emission_color", "emissive_color"]) : null, C = N(t, ["emission_intensity", "emissive_intensity"]), v = ee(t, "geometry_opacity");
|
|
2829
|
-
ee(t, "diffuse_reflection_color") && !l && c.push("OmniPBRBase.diffuse_reflection_color.unresolved-texture"), ee(t, "geometry_opacity_threshold") ? c.push("OmniPBRBase.geometry_opacity_threshold.connection") : (!Number.isFinite(m) || m < 0 || m > 1) && c.push("OmniPBRBase.geometry_opacity_threshold.range"), w && v && !p && c.push("OmniPBRBase.geometry_opacity.unresolved-texture"), _ !== null && _ !== 0.5 && (Le(e, s), a.push("OmniPBRBase.specular_level.approximation"), r.diagnostics.approximations.push({
|
|
2830
|
-
code: "USD_VISUAL_OMNIPBRBASE_SPECULAR_APPROXIMATION",
|
|
2831
|
-
source: "usd-visual",
|
|
2832
|
-
message: `USD 材质 ${t.path} 的 OmniPBRBase specular_level 已按 Three.js specularIntensity 有界近似,不等同于原 MDL 介电反射瓣。`
|
|
2833
|
-
})), U > 0 && (Le(e, s), S !== null && c.push("OmniPBRBase.coat_ior"));
|
|
2834
|
-
for (const I of s.filter(X))
|
|
2835
|
-
d !== null && (I.roughness = Q(d)), g !== null && (I.metalness = Q(g)), y && I instanceof W && I.specularColor.copy(y), _ !== null && I instanceof W && (I.specularIntensity = Q(_)), I instanceof W && (I.clearcoat = Q(U), b !== null && (I.clearcoatRoughness = Q(b))), i && !l && I.color.copy(i), h !== null && (!l && i && I.color.multiplyScalar(Q(h)), h !== 1 && a.push("OmniPBRBase.diffuse_reflection_weight")), O ? (I.emissive.copy(O), I.emissiveIntensity = Math.max(0, C ?? 1)) : (I.emissive.setRGB(0, 0, 0), I.emissiveIntensity = 0), I.needsUpdate = !0;
|
|
2836
|
-
if (d !== null && a.push("OmniPBRBase.specular_reflection_roughness"), g !== null && a.push("OmniPBRBase.metalness"), y && a.push("OmniPBRBase.specular_reflection_color"), U > 0 && a.push("OmniPBRBase.coat_weight"), b !== null && U > 0 && a.push("OmniPBRBase.coat_roughness"), O && a.push("OmniPBRBase.emission_color"), l) {
|
|
2837
|
-
const I = await st(
|
|
2838
|
-
[n],
|
|
2839
|
-
s,
|
|
2840
|
-
/* @__PURE__ */ new Set(),
|
|
2841
|
-
r,
|
|
2842
|
-
o
|
|
2843
|
-
);
|
|
2844
|
-
if (a.push(...I.applied), c.push(...I.unsupported), u.push(...I.resources), f) {
|
|
2845
|
-
for (const H of s.filter(X)) H.color.multiply(f);
|
|
2846
|
-
a.push("OmniPBRBase.diffuse_tint");
|
|
2847
|
-
}
|
|
2848
|
-
if (h !== null)
|
|
2849
|
-
for (const H of s.filter(X))
|
|
2850
|
-
H.color.multiplyScalar(Q(h));
|
|
2851
|
-
} else if (i && (a.push("OmniPBRBase.diffuse_reflection_color.constant"), f)) {
|
|
2852
|
-
for (const I of s.filter(X)) I.color.multiply(f);
|
|
2853
|
-
a.push("OmniPBRBase.diffuse_tint");
|
|
2854
|
-
}
|
|
2855
|
-
if (w) {
|
|
2856
|
-
if (p) {
|
|
2857
|
-
const I = await Mr(
|
|
2858
|
-
n,
|
|
2859
|
-
p,
|
|
2860
|
-
s,
|
|
2861
|
-
m,
|
|
2862
|
-
r,
|
|
2863
|
-
o
|
|
2864
|
-
);
|
|
2865
|
-
a.push(...I.applied), c.push(...I.unsupported), u.push(...I.resources);
|
|
2866
|
-
} else if (!v) {
|
|
2867
|
-
const I = Q(N(t, ["geometry_opacity"]) ?? 1), H = m > 0 ? I >= m ? 1 : 0 : I;
|
|
2868
|
-
for (const P of s.filter(X))
|
|
2869
|
-
P.opacity = H, P.alphaTest = m, P.transparent = m === 0 && H < 1, P.depthWrite = !P.transparent, P instanceof W && (P.transmission = 0), P.needsUpdate = !0;
|
|
2870
|
-
a.push("OmniPBRBase.geometry_opacity.constant");
|
|
2871
|
-
}
|
|
2872
|
-
} else if (!Ce(t, "enable_opacity", !1))
|
|
2873
|
-
for (const I of s.filter(X))
|
|
2874
|
-
I.opacity = 1, I.transparent = !1, I.alphaTest = 0, I.depthWrite = !0, I.needsUpdate = !0;
|
|
2875
|
-
const B = ee(t, "geometry_normal");
|
|
2876
|
-
if (B) {
|
|
2877
|
-
const I = await vn(
|
|
2878
|
-
e,
|
|
2879
|
-
t,
|
|
2880
|
-
B,
|
|
2881
|
-
s,
|
|
2882
|
-
r,
|
|
2883
|
-
o,
|
|
2884
|
-
"OmniPBRBase"
|
|
2885
|
-
);
|
|
2886
|
-
a.push(...I.applied), c.push(...I.unsupported), u.push(...I.resources);
|
|
2887
|
-
}
|
|
2888
|
-
const E = /* @__PURE__ */ new Set([
|
|
2889
|
-
"diffuse_reflection_color",
|
|
2890
|
-
"diffuse_tint",
|
|
2891
|
-
"diffuse_reflection_weight",
|
|
2892
|
-
"specular_reflection_roughness",
|
|
2893
|
-
"specular_reflection_color",
|
|
2894
|
-
"specular_level",
|
|
2895
|
-
"metalness",
|
|
2896
|
-
"enable_opacity",
|
|
2897
|
-
"geometry_opacity",
|
|
2898
|
-
"geometry_opacity_threshold",
|
|
2899
|
-
"opacity_threshold",
|
|
2900
|
-
"geometry_normal",
|
|
2901
|
-
"coat_weight",
|
|
2902
|
-
"coat_roughness",
|
|
2903
|
-
"coat_ior",
|
|
2904
|
-
"enable_coat",
|
|
2905
|
-
"enable_emission",
|
|
2906
|
-
"emission_color",
|
|
2907
|
-
"emissive_color",
|
|
2908
|
-
"emission_intensity",
|
|
2909
|
-
"emissive_intensity",
|
|
2910
|
-
"texture_scale",
|
|
2911
|
-
"texture_translate",
|
|
2912
|
-
"texture_rotate",
|
|
2913
|
-
"project_uvw",
|
|
2914
|
-
"uv_space_index"
|
|
2915
|
-
]), R = {
|
|
2916
|
-
enable_coat: !1,
|
|
2917
|
-
enable_emission: !1,
|
|
2918
|
-
emission_intensity: 0,
|
|
2919
|
-
emissive_intensity: 0
|
|
2920
|
-
};
|
|
2921
|
-
for (const I of Object.keys(t.inputs)) {
|
|
2922
|
-
if (!I.startsWith("inputs:")) continue;
|
|
2923
|
-
const H = I.slice(7).replace(/\.(?:resolvedConnect|connect)$/, "");
|
|
2924
|
-
E.has(H) || H in R && t.inputs[I] === R[H] || c.push(`OmniPBRBase.${H}`);
|
|
2925
|
-
}
|
|
2926
|
-
return Ce(t, "enable_coat", !1) && c.push("OmniPBRBase.enable_coat"), { applied: oe(a), unsupported: oe(c), resources: u };
|
|
2927
|
-
}
|
|
2928
|
-
async function Mr(e, t, n, s, r, o) {
|
|
2929
|
-
var U;
|
|
2930
|
-
const a = { applied: [], unsupported: [], resources: [] }, c = xr(t.monoSource);
|
|
2931
|
-
if (!c)
|
|
2932
|
-
return a.unsupported.push(`OmniPBRBase.geometry_opacity.mono_source=${t.monoSource ?? "unknown"}`), a;
|
|
2933
|
-
if (((U = t.sourceColorSpace) == null ? void 0 : U.toLowerCase()) !== "raw")
|
|
2934
|
-
return a.unsupported.push(`OmniPBRBase.geometry_opacity.color-space=${t.sourceColorSpace ?? "auto"}`), a;
|
|
2935
|
-
const u = n.filter(X);
|
|
2936
|
-
if (!u.length)
|
|
2937
|
-
return a.unsupported.push("OmniPBRBase.geometry_opacity.standard-material-required"), a;
|
|
2938
|
-
const l = u.map((b) => b.alphaMap);
|
|
2939
|
-
if (l.some((b) => (b == null ? void 0 : b.userData.usdTextureOwner) === "foreign" || b && !b.userData.usdCoverageConversionKey))
|
|
2940
|
-
return a.unsupported.push("OmniPBRBase.geometry_opacity.existing-map-owner-unknown"), a;
|
|
2941
|
-
const p = qt(t.brightness, 1), i = qt(t.contrast, 1), f = t.invert === !0, h = (f ? -1 : 1) * p * i, d = f ? 1 - 0.5 * p * (1 - i) : 0.5 * p * (1 - i), g = t.wrapS === null ? te : Se(t.wrapS), _ = t.wrapT === null ? te : Se(t.wrapT);
|
|
2942
|
-
if (g === null || _ === null)
|
|
2943
|
-
return a.unsupported.push("OmniPBRBase.geometry_opacity.unsupported-wrap"), a;
|
|
2944
|
-
const y = JSON.stringify([
|
|
2945
|
-
"usd-file-texture-mono-v1",
|
|
2946
|
-
e.materialPath,
|
|
2947
|
-
t.shaderPath,
|
|
2948
|
-
t.path,
|
|
2949
|
-
c,
|
|
2950
|
-
h,
|
|
2951
|
-
d,
|
|
2952
|
-
g,
|
|
2953
|
-
_,
|
|
2954
|
-
s
|
|
2955
|
-
]);
|
|
2956
|
-
if (l.every((b) => (b == null ? void 0 : b.userData.usdCoverageConversionKey) === y))
|
|
2957
|
-
return a.applied.push(`OmniPBRBase.geometry_opacity.mono.${c}`), a.resources.push({ path: t.path, status: "available" }), a;
|
|
2958
|
-
const w = await ue(t.path, r);
|
|
2959
|
-
if (a.resources.push(w.report), !w.url) return a;
|
|
2960
|
-
let m = null;
|
|
2961
|
-
try {
|
|
2962
|
-
m = await (r.createTexture ?? ce)(w.url, re);
|
|
2963
|
-
const b = Ae(m, c, h, d);
|
|
2964
|
-
b.wrapS = g, b.wrapT = _, b.channel = 0, b.userData.usdCoverageConversionKey = y, b.userData.usdTextureOwner = "adapter-derived";
|
|
2965
|
-
for (const S of l)
|
|
2966
|
-
S != null && S.userData.usdCoverageConversionKey && o.add(S);
|
|
2967
|
-
for (const S of u)
|
|
2968
|
-
S.alphaMap = b, S.opacity = 1, S.alphaTest = s, S.transparent = s === 0, S.depthWrite = s > 0, S instanceof W && (S.transmission = 0), S.needsUpdate = !0;
|
|
2969
|
-
a.applied.push(`OmniPBRBase.geometry_opacity.mono.${c}`), r.diagnostics.approximations.push({
|
|
2970
|
-
code: "USD_VISUAL_OMNIPBRBASE_FILE_TEXTURE_APPROXIMATION",
|
|
2971
|
-
source: "usd-visual",
|
|
2972
|
-
message: `USD 材质 ${e.materialPath} 的 core_definitions::file_texture.mono 已按 mono_source、brightness、contrast、invert 做 8 位通道重排;过滤边缘和阈值结果不保证与 MDL 渲染逐像素一致。`
|
|
2973
|
-
});
|
|
2974
|
-
} catch (b) {
|
|
2975
|
-
if (b instanceof Error && b.name === "AbortError") throw b;
|
|
2976
|
-
a.resources[a.resources.length - 1] = { path: t.path, status: "decode-failed" };
|
|
2977
|
-
} finally {
|
|
2978
|
-
m == null || m.dispose();
|
|
2979
|
-
}
|
|
2980
|
-
return a;
|
|
2981
|
-
}
|
|
2982
|
-
function xr(e) {
|
|
2983
|
-
return e === 0 ? "a" : e === 1 || e === null || e === void 0 ? "average" : e === 2 ? "luminance" : e === 3 ? "maximum" : null;
|
|
2984
|
-
}
|
|
2985
|
-
function qt(e, t) {
|
|
2986
|
-
return typeof e == "number" && Number.isFinite(e) ? e : t;
|
|
2987
|
-
}
|
|
2988
|
-
async function Cr(e, t, n, s, r, o) {
|
|
2989
|
-
const a = [], c = [], u = [], l = Ce(t, "enable_specular_transmission", !1), p = Q(N(t, ["specular_transmission_weight"]) ?? 0), i = de(t, ["specular_transmission_color"]), f = de(t, ["diffuse_reflection_color"]), h = Q(N(t, ["diffuse_reflection_weight"]) ?? 1), d = N(t, ["specular_reflection_ior"]), g = N(t, ["specular_reflection_roughness"]), _ = N(t, ["specular_reflection_weight"]), y = de(t, ["specular_reflection_color"]), w = N(t, ["metalness"]), m = Q(N(t, ["coat_weight"]) ?? 0), U = N(t, ["coat_roughness"]), b = N(t, ["coat_ior"]), S = N(t, ["diffuse_reflection_roughness"]), x = Ce(t, "enable_thin_film", !1), O = Ce(t, "enable_diffuse_transmission", !1), C = N(t, ["subsurface_weight"]) ?? 0;
|
|
2990
|
-
Le(e, s);
|
|
2991
|
-
for (const R of s.filter(
|
|
2992
|
-
(I) => I instanceof W
|
|
2993
|
-
))
|
|
2994
|
-
R.metalness = 0, g !== null && (R.roughness = Q(g)), w !== null && (R.metalness = Q(w)), d !== null && d > 0 && (R.ior = d), _ !== null && (R.specularIntensity = Q(_)), y && R.specularColor.copy(y), m > 0 && (R.clearcoat = m, U !== null && (R.clearcoatRoughness = Q(U))), l && p > 0 ? (R.transmission = p, R.thickness = 0, R.opacity = 1, R.transparent = !1, R.depthWrite = !0, i && (R.color.copy(i), R.attenuationColor.copy(i), R.attenuationDistance = 1 / 0)) : (R.transmission = 0, f && R.color.copy(f).multiplyScalar(h)), R.needsUpdate = !0;
|
|
2995
|
-
l && a.push("OmniSurfaceBase.enable_specular_transmission"), p > 0 && a.push("OmniSurfaceBase.specular_transmission_weight"), i && l && (a.push(
|
|
2996
|
-
"OmniSurfaceBase.specular_transmission_color.surface-tint",
|
|
2997
|
-
"OmniSurfaceBase.specular_transmission_color.attenuation"
|
|
2998
|
-
), r.diagnostics.approximations.push({
|
|
2999
|
-
code: "USD_VISUAL_OMNISURFACE_TRANSMISSION_APPROXIMATION",
|
|
3000
|
-
source: "usd-visual",
|
|
3001
|
-
message: `USD 材质 ${t.path} 的 OmniSurfaceBase 透射颜色已映射为 Three.js 表面颜色与 attenuationColor;不推断壁厚、内部光程或体积吸收,不保证与 MDL 透射瓣等价。`
|
|
3002
|
-
})), h === 0 ? a.push("OmniSurfaceBase.diffuse_reflection_weight") : h !== 1 && (a.push("OmniSurfaceBase.diffuse_reflection_weight"), c.push("OmniSurfaceBase.diffuse_reflection_weight.partial")), d !== null && a.push("OmniSurfaceBase.specular_reflection_ior"), g !== null && a.push("OmniSurfaceBase.specular_reflection_roughness"), _ !== null && a.push("OmniSurfaceBase.specular_reflection_weight"), y && a.push("OmniSurfaceBase.specular_reflection_color"), w !== null && a.push("OmniSurfaceBase.metalness"), m > 0 && a.push("OmniSurfaceBase.coat_weight"), m > 0 && U !== null && a.push("OmniSurfaceBase.coat_roughness"), m > 0 && b !== null && c.push("OmniSurfaceBase.coat_ior"), S !== null && S !== 0 && c.push("OmniSurfaceBase.diffuse_reflection_roughness"), x && c.push("OmniSurfaceBase.enable_thin_film"), O && c.push("OmniSurfaceBase.enable_diffuse_transmission"), C > 0 && c.push("OmniSurfaceBase.subsurface_weight");
|
|
3003
|
-
const v = await st(
|
|
3004
|
-
[n],
|
|
3005
|
-
s,
|
|
3006
|
-
/* @__PURE__ */ new Set(),
|
|
3007
|
-
r,
|
|
3008
|
-
o
|
|
3009
|
-
);
|
|
3010
|
-
a.push(...v.applied), c.push(...v.unsupported), u.push(...v.resources);
|
|
3011
|
-
const B = ee(t, "geometry_normal");
|
|
3012
|
-
if (B) {
|
|
3013
|
-
const R = await vn(
|
|
3014
|
-
e,
|
|
3015
|
-
t,
|
|
3016
|
-
B,
|
|
3017
|
-
s,
|
|
3018
|
-
r,
|
|
3019
|
-
o
|
|
3020
|
-
);
|
|
3021
|
-
a.push(...R.applied), c.push(...R.unsupported), u.push(...R.resources);
|
|
3022
|
-
}
|
|
3023
|
-
const E = /* @__PURE__ */ new Set([
|
|
3024
|
-
"diffuse_reflection_weight",
|
|
3025
|
-
"diffuse_reflection_color",
|
|
3026
|
-
"diffuse_reflection_roughness",
|
|
3027
|
-
"metalness",
|
|
3028
|
-
"enable_specular_transmission",
|
|
3029
|
-
"specular_transmission_weight",
|
|
3030
|
-
"specular_transmission_color",
|
|
3031
|
-
"specular_transmission_dispersion_abbe",
|
|
3032
|
-
"specular_transmission_scatter_anisotropy",
|
|
3033
|
-
"specular_transmission_scattering_color",
|
|
3034
|
-
"specular_reflection_ior",
|
|
3035
|
-
"specular_reflection_roughness",
|
|
3036
|
-
"specular_reflection_weight",
|
|
3037
|
-
"specular_reflection_color",
|
|
3038
|
-
"coat_weight",
|
|
3039
|
-
"coat_roughness",
|
|
3040
|
-
"coat_ior",
|
|
3041
|
-
"enable_thin_film",
|
|
3042
|
-
"enable_diffuse_transmission",
|
|
3043
|
-
"subsurface_weight",
|
|
3044
|
-
"subsurface_scale",
|
|
3045
|
-
"subsurface_anisotropy",
|
|
3046
|
-
"subsurface_scattering_color",
|
|
3047
|
-
"subsurface_scattering_colors_preset",
|
|
3048
|
-
"subsurface_transmission_color",
|
|
3049
|
-
"geometry_normal"
|
|
3050
|
-
]);
|
|
3051
|
-
for (const R of Object.keys(t.inputs)) {
|
|
3052
|
-
if (!R.startsWith("inputs:")) continue;
|
|
3053
|
-
const I = R.slice(7).replace(/\.(?:resolvedConnect|connect)$/, "");
|
|
3054
|
-
E.has(I) || c.push(`OmniSurfaceBase.${I}`);
|
|
3055
|
-
}
|
|
3056
|
-
return { applied: oe(a), unsupported: oe(c), resources: u };
|
|
3057
|
-
}
|
|
3058
|
-
async function vn(e, t, n, s, r, o, a = "OmniSurfaceBase") {
|
|
3059
|
-
var w, m, U, b;
|
|
3060
|
-
const c = { applied: [], unsupported: [], resources: [] }, u = (m = e.index.materialsByPath.get(
|
|
3061
|
-
le((w = s[0]) == null ? void 0 : w.userData.usdMaterialPath) ?? ""
|
|
3062
|
-
)) == null ? void 0 : m.shaders.find((S) => S.path === n.path);
|
|
3063
|
-
if (!u)
|
|
3064
|
-
return c.unsupported.push(`${a}.geometry_normal.unresolved:${n.path}`), c;
|
|
3065
|
-
const l = le(u.inputs["info:mdl:sourceAsset:subIdentifier"]) ?? u.id, p = (U = ae(u.inputs["info:mdl:sourceAsset"])) == null ? void 0 : U.replaceAll("\\", "/");
|
|
3066
|
-
if (!(/^(?:normalmap_texture|gltf_normal_texture_lookup)$/i.test(l ?? "") || l === null && ((b = p == null ? void 0 : p.split("/").at(-1)) == null ? void 0 : b.toLowerCase()) === "core_definitions.mdl"))
|
|
3067
|
-
return c.unsupported.push(`${a}.geometry_normal.${l ?? u.path}`), c;
|
|
3068
|
-
const f = ae(G(u, ["texture", "file"]));
|
|
3069
|
-
if (!f)
|
|
3070
|
-
return c.unsupported.push(`${a}.geometry_normal.missing-texture:${u.path}`), c;
|
|
3071
|
-
const h = s.filter(X);
|
|
3072
|
-
if (!h.length)
|
|
3073
|
-
return c.unsupported.push(`${a}.geometry_normal.standard-material-required`), c;
|
|
3074
|
-
const d = h.map((S) => S.normalMap);
|
|
3075
|
-
if (d.some((S) => S && S.userData.usdTextureOwner === "foreign"))
|
|
3076
|
-
return c.unsupported.push(`${a}.geometry_normal.existing-foreign-map`), c;
|
|
3077
|
-
const g = JSON.stringify([
|
|
3078
|
-
"omnisurface-normal-v1",
|
|
3079
|
-
t.path,
|
|
3080
|
-
u.path,
|
|
3081
|
-
f
|
|
3082
|
-
]);
|
|
3083
|
-
if (d.every((S) => (S == null ? void 0 : S.userData.usdNormalConversionKey) === g))
|
|
3084
|
-
return c.applied.push(`${a}.geometry_normal`), c.resources.push({ path: f, status: "available" }), c;
|
|
3085
|
-
if (d.some((S) => S && !S.userData.usdNormalConversionKey))
|
|
3086
|
-
return c.unsupported.push(`${a}.geometry_normal.existing-map-owner-unknown`), c;
|
|
3087
|
-
const _ = await ue(f, r);
|
|
3088
|
-
if (c.resources.push(_.report), !_.url) return c;
|
|
3089
|
-
let y = null;
|
|
3090
|
-
try {
|
|
3091
|
-
y = await (r.createTexture ?? ce)(_.url, re), y.colorSpace = re, y.wrapS = te, y.wrapT = te, y.channel = 0, y.userData.usdNormalConversionKey = g, y.userData.usdTextureOwner = "adapter-derived";
|
|
3092
|
-
for (const S of d)
|
|
3093
|
-
S != null && S.userData.usdNormalConversionKey && o.add(S);
|
|
3094
|
-
for (const S of h)
|
|
3095
|
-
S.normalMap = y, S.normalScale.set(1, 1), S.needsUpdate = !0;
|
|
3096
|
-
c.applied.push(`${a}.geometry_normal`), y = null;
|
|
3097
|
-
} catch (S) {
|
|
3098
|
-
if (S instanceof Error && S.name === "AbortError") throw S;
|
|
3099
|
-
c.resources[c.resources.length - 1] = { path: f, status: "decode-failed" };
|
|
3100
|
-
} finally {
|
|
3101
|
-
y == null || y.dispose();
|
|
3102
|
-
}
|
|
3103
|
-
return c;
|
|
3104
|
-
}
|
|
3105
|
-
function Un(e) {
|
|
3106
|
-
return We(e) ? "OmniPBR" : It(e) ? "OmniPBRBase" : Rt(e) ? "OmniGlass" : At(e) ? "gltf_material" : Mt(e) ? "OmniSurfaceBase" : e.id;
|
|
3107
|
-
}
|
|
3108
|
-
function Ue(e, t) {
|
|
3109
|
-
const n = Jt(e, "texture_scale", [1, 1]), s = Jt(e, "texture_translate", [0, 0]), r = N(e, ["texture_rotate"]) ?? 0, o = ge(e, ["project_uvw"], !1), a = N(e, ["uv_space_index"]) ?? 0, c = !o && a === 0 && n[0] === 1 && n[1] === 1 && s[0] === 0 && s[1] === 0 && r === 0;
|
|
3110
|
-
return c || t.add("OmniPBR.uvTransform"), c;
|
|
3111
|
-
}
|
|
3112
|
-
async function Dr(e, t, n, s, r, o) {
|
|
3113
|
-
const a = () => {
|
|
3114
|
-
for (const h of ["ao_texture", "ao_texture_colorspace", "ao_to_diffuse"]) s.delete(`OmniPBR.${h}`);
|
|
3115
|
-
};
|
|
3116
|
-
if (ee(t, "ao_to_diffuse"))
|
|
3117
|
-
return s.add("OmniPBR.ao_to_diffuse.connection"), !1;
|
|
3118
|
-
const c = N(t, ["ao_to_diffuse"]) ?? 0;
|
|
3119
|
-
if (G(t, ["ao_to_diffuse"]) !== void 0 && N(t, ["ao_to_diffuse"]) === null || c < 0 || c > 1)
|
|
3120
|
-
return s.add("OmniPBR.ao_to_diffuse.range"), !1;
|
|
3121
|
-
if (c === 0)
|
|
3122
|
-
return a(), !1;
|
|
3123
|
-
if (ee(t, "enable_ORM_texture"))
|
|
3124
|
-
return s.add("OmniPBR.enable_ORM_texture.connection"), !1;
|
|
3125
|
-
const u = ge(t, ["enable_ORM_texture"], !1), l = u ? "ORM_texture" : "ao_texture";
|
|
3126
|
-
if (ee(t, l))
|
|
3127
|
-
return s.add(`OmniPBR.${l}.connection`), !1;
|
|
3128
|
-
const p = ae(G(t, [l]));
|
|
3129
|
-
if (!p)
|
|
3130
|
-
return a(), !1;
|
|
3131
|
-
if (G(t, [`${l}_colorspace`]) !== "raw")
|
|
3132
|
-
return s.add(`OmniPBR.${l}_colorspace`), !1;
|
|
3133
|
-
if (!Ue(t, s)) return !1;
|
|
3134
|
-
const i = await ue(p, o);
|
|
3135
|
-
if (r.push(i.report), !i.url) return !1;
|
|
3136
|
-
let f = null;
|
|
3137
|
-
try {
|
|
3138
|
-
f = await (o.createTexture ?? ce)(i.url, re);
|
|
3139
|
-
const h = Ae(f, u ? "r" : "grayscale");
|
|
3140
|
-
h.wrapS = te, h.wrapT = te, h.channel = 0;
|
|
3141
|
-
const d = e.filter(X).filter((g) => !g.aoMap);
|
|
3142
|
-
if (!d.length)
|
|
3143
|
-
return h.dispose(), s.add("OmniPBR.existing_aoMap"), !1;
|
|
3144
|
-
for (const g of d)
|
|
3145
|
-
g.aoMap = h, g.aoMapIntensity = c, g.needsUpdate = !0;
|
|
3146
|
-
return a(), n.push(u ? "OmniPBR.ORM.r.aoMap" : "OmniPBR.ao_texture.aoMap"), o.diagnostics.approximations.push({ code: "USD_VISUAL_AO_LIGHTING_APPROXIMATION", source: "usd-visual", message: `USD 材质 AO 已映射为 Three.js 间接光遮蔽(${t.path});并非 OmniPBR 对漫反射贴图的等价调制。` }), !0;
|
|
3147
|
-
} catch (h) {
|
|
3148
|
-
if (h instanceof Error && h.name === "AbortError") throw h;
|
|
3149
|
-
return s.add(`OmniPBR.${l}.pixel-conversion`), !1;
|
|
3150
|
-
} finally {
|
|
3151
|
-
f == null || f.dispose();
|
|
3152
|
-
}
|
|
3153
|
-
}
|
|
3154
|
-
function Tr(e, t) {
|
|
3155
|
-
const n = /* @__PURE__ */ new Set([
|
|
3156
|
-
"inputs:diffuse_color_constant",
|
|
3157
|
-
"inputs:diffuse_texture",
|
|
3158
|
-
"inputs:reflection_roughness_constant",
|
|
3159
|
-
"inputs:metallic_constant",
|
|
3160
|
-
"inputs:opacity_constant",
|
|
3161
|
-
"inputs:enable_opacity",
|
|
3162
|
-
"inputs:enable_emission",
|
|
3163
|
-
"inputs:emissive_color",
|
|
3164
|
-
"inputs:emissive_intensity",
|
|
3165
|
-
"inputs:texture_scale",
|
|
3166
|
-
"inputs:texture_translate",
|
|
3167
|
-
"inputs:texture_rotate",
|
|
3168
|
-
"inputs:project_uvw",
|
|
3169
|
-
"inputs:uv_space_index",
|
|
3170
|
-
"info:mdl:sourceAsset",
|
|
3171
|
-
"inputs:enable_ORM_texture",
|
|
3172
|
-
"inputs:ORM_texture",
|
|
3173
|
-
"inputs:metallic_texture_influence",
|
|
3174
|
-
"inputs:reflection_roughness_texture_influence",
|
|
3175
|
-
"inputs:ao_to_diffuse",
|
|
3176
|
-
"inputs:diffuse_tint",
|
|
3177
|
-
"inputs:normalmap_texture",
|
|
3178
|
-
"inputs:bump_factor",
|
|
3179
|
-
"inputs:flip_tangent_u",
|
|
3180
|
-
"inputs:flip_tangent_v",
|
|
3181
|
-
"inputs:reflectionroughness_texture",
|
|
3182
|
-
"inputs:metallic_texture",
|
|
3183
|
-
"inputs:opacity_texture"
|
|
3184
|
-
]);
|
|
3185
|
-
(N(e, ["specular_level"]) ?? 0.5) !== 0.5 && t.add("OmniPBR.specular_level"), n.add("inputs:specular_level");
|
|
3186
|
-
const s = /* @__PURE__ */ new Set(["inputs:opacity_mode", "inputs:opacity_threshold", "inputs:enable_opacity_texture"]);
|
|
3187
|
-
ge(e, ["enable_emission"], !1) && t.add("OmniPBR.emission_radiometric_equivalence");
|
|
3188
|
-
const r = {
|
|
3189
|
-
"inputs:albedo_desaturation": 0,
|
|
3190
|
-
"inputs:albedo_add": 0,
|
|
3191
|
-
"inputs:albedo_brightness": 1,
|
|
3192
|
-
"inputs:world_or_object": !1
|
|
3193
|
-
};
|
|
3194
|
-
for (const o of Object.keys(e.inputs))
|
|
3195
|
-
o in r && e.inputs[o] === r[o] || !n.has(o) && !s.has(o) && t.add(`OmniPBR.${o.replace(/^inputs:/, "")}`);
|
|
3196
|
-
}
|
|
3197
|
-
function Er(e, t, n) {
|
|
3198
|
-
let s = !1;
|
|
3199
|
-
const r = We(t), o = de(t, ["diffuseColor", "baseColor", "base_color", "diffuse_color_constant"]), a = N(t, ["roughness", "specularRoughness", "specular_roughness", "reflection_roughness_constant"]) ?? (r ? 0.5 : null), c = N(t, ["metallic", "metalness", "metallicFactor", "metallic_constant"]) ?? (r ? 0 : null), u = N(t, ["opacity_threshold"]) ?? 0, l = ge(t, ["enable_opacity"], !1) && u >= 0, p = N(t, ["opacity", "presence", "opacity_constant"]) ?? (r ? 1 : null), i = r ? l ? u > 0 ? p >= u ? 1 : 0 : p : 1 : p, f = ge(t, ["enable_emission"], !r), h = f ? de(t, ["emissiveColor", "emissionColor", "emission_color", "emissive_color"]) : null;
|
|
3200
|
-
for (const d of e)
|
|
3201
|
-
X(d) && (o && (d.color.copy(o), s = !0), a !== null && (d.roughness = Q(a), s = !0), c !== null && (d.metalness = Q(c), s = !0), i !== null && (d.opacity = Q(i), d.transparent = d.opacity < 1, d.depthWrite = d.opacity >= 1, s = !0), r && !f && (d.emissive.setRGB(0, 0, 0), d.emissiveIntensity = 0), h && (d.emissive.copy(h), r && (d.emissiveIntensity = Math.max(0, N(t, ["emissive_intensity"]) ?? 40)), s = !0), s && (d.needsUpdate = !0));
|
|
3202
|
-
return o && n.push("diffuseColor.constant"), a !== null && n.push("roughness.constant"), c !== null && n.push("metalness.constant"), i !== null && n.push("opacity.constant"), h && n.push("emissiveColor.constant"), s;
|
|
3203
|
-
}
|
|
3204
|
-
function $r(e, t, n) {
|
|
3205
|
-
const s = /* @__PURE__ */ new Set(), r = (o) => {
|
|
3206
|
-
if (s.has(o.path)) return;
|
|
3207
|
-
s.add(o.path);
|
|
3208
|
-
const a = Xe(e, o);
|
|
3209
|
-
if (!a) {
|
|
3210
|
-
n.add(o.path);
|
|
3211
|
-
return;
|
|
3212
|
-
}
|
|
3213
|
-
if (!Rn(a)) {
|
|
3214
|
-
n.add(a.id ?? a.path);
|
|
3215
|
-
for (const [c, u] of Object.entries(a.inputs)) {
|
|
3216
|
-
if (!c.endsWith(".resolvedConnect") && !c.endsWith(".connect")) continue;
|
|
3217
|
-
const l = Re(u);
|
|
3218
|
-
l && r(l);
|
|
3219
|
-
}
|
|
3220
|
-
}
|
|
3221
|
-
};
|
|
3222
|
-
for (const [o, a] of Object.entries(t.inputs)) {
|
|
3223
|
-
if (!o.endsWith(".resolvedConnect") && !o.endsWith(".connect") || /(?:diffuseColor|baseColor)/i.test(o)) continue;
|
|
3224
|
-
const c = Re(a);
|
|
3225
|
-
c && r(c);
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3228
|
-
async function ue(e, t) {
|
|
3229
|
-
const n = Nr(e, t.packageTextureURLs);
|
|
3230
|
-
if (n) return { report: { path: e, status: "available" }, url: n };
|
|
3231
|
-
if (t.isTextureAllowed && !t.isTextureAllowed(e)) return { report: { path: e, status: "unresolved" }, url: null };
|
|
3232
|
-
const s = Ze(t.entryDirectory ? `${t.entryDirectory}/${e}` : e);
|
|
3233
|
-
let r = t.files.find(e, t.entryDirectory ?? "") ?? t.files.find(s);
|
|
3234
|
-
if (!r)
|
|
3235
|
-
try {
|
|
3236
|
-
await t.files.ensure(s), r = t.files.find(s) ?? t.files.find(e, t.entryDirectory ?? "");
|
|
3237
|
-
} catch (o) {
|
|
3238
|
-
const a = o == null ? void 0 : o.code;
|
|
3239
|
-
if (o instanceof Error && o.name === "AbortError" || a === "E_ASSET_AUTH") throw o;
|
|
3240
|
-
const c = a === "E_ASSET_RESOURCE_NOT_FOUND" || /\((404|410)\)/.test(String(o));
|
|
3241
|
-
return { report: { path: e, status: c ? "missing" : "unresolved" }, url: null };
|
|
3242
|
-
}
|
|
3243
|
-
return r ? Ys.has(Fr(e)) ? { report: { path: e, status: "available" }, url: t.files.objectUrl(r) } : { report: { path: e, status: "unsupported-format" }, url: null } : { report: { path: e, status: "unresolved" }, url: null };
|
|
3244
|
-
}
|
|
3245
|
-
function Nr(e, t) {
|
|
3246
|
-
if (!(t != null && t.size)) return null;
|
|
3247
|
-
const n = /\[([^\]]+)\]/.exec(e), s = Ze((n == null ? void 0 : n[1]) ?? e), r = t.get(s);
|
|
3248
|
-
if (r) return r;
|
|
3249
|
-
const o = [...t].find(([l]) => l.toLowerCase() === s.toLowerCase());
|
|
3250
|
-
if (o) return o[1];
|
|
3251
|
-
const a = [...t].filter(([l]) => {
|
|
3252
|
-
const p = Ze(l);
|
|
3253
|
-
return p.endsWith(`/${s}`) || s.endsWith(`/${p}`);
|
|
3254
|
-
});
|
|
3255
|
-
if (a.length === 1) return a[0][1];
|
|
3256
|
-
const c = s.split("/").pop();
|
|
3257
|
-
if (!c) return null;
|
|
3258
|
-
const u = [...t].filter(([l]) => Ze(l).split("/").pop() === c);
|
|
3259
|
-
return u.length === 1 ? u[0][1] : null;
|
|
3260
|
-
}
|
|
3261
|
-
function Ge(e, t, n, s, r, o, a) {
|
|
3262
|
-
a === "augmented" && e.approximations.push({
|
|
3263
|
-
code: "USD_VISUAL_MATERIAL_AUGMENTED",
|
|
3264
|
-
message: `USD 材质 ${t}(${Un(n) ?? "renderer-specific shader"})已通过视觉适配层映射资产明确提供的输入:${oe(s).join(", ")}。这是有限范围的材质映射,不保证与原渲染器完全等价;原始 Loader 诊断保留在 visualAdaptation 报告中。`,
|
|
3265
|
-
source: "usd-visual"
|
|
3266
|
-
}), On(e, t, o);
|
|
3267
|
-
const c = {
|
|
3268
|
-
"OmniGlass.solid_volume_absorption": "实体玻璃目前仅渲染表面透射:缺少可靠的内部光程,未实现体积吸收。未推断或生成壁厚",
|
|
3269
|
-
"OmniGlass.glass_color.volume": "源玻璃颜色用于体积吸收,当前未还原该体积颜色;未用表面染色替代",
|
|
3270
|
-
"OmniGlass.depth": "源 depth 是体积吸收缩放,不能直接当作 Three.js 壁厚或衰减距离;此输入尚未映射",
|
|
3271
|
-
"OmniGlass.fractional_coverage_transmission_compositing": "覆盖率与透射参数已映射,但其组合使用实时合成近似,不保证与 MDL 渲染等价",
|
|
3272
|
-
"OmniGlass.tint_reflection_coupling": "薄壁玻璃颜色已作表面近似,其反射与透射颜色响应不保证与 MDL 等价"
|
|
3273
|
-
};
|
|
3274
|
-
for (const u of r) e.droppedFeatures.push({
|
|
3275
|
-
code: "USD_VISUAL_SHADER_NODE_UNSUPPORTED",
|
|
3276
|
-
message: c[u] ? `USD 材质 ${t}:${c[u]}。` : `USD 材质功能或节点 ${u} 尚未完成浏览器适配(${t})。未生成替代内容。`,
|
|
3277
|
-
source: "usd-visual"
|
|
3278
|
-
});
|
|
3279
|
-
}
|
|
3280
|
-
function On(e, t, n) {
|
|
3281
|
-
for (const s of n) {
|
|
3282
|
-
const r = (o, a, c) => {
|
|
3283
|
-
o.some((u) => u.code === a && u.message === c) || o.push({ code: a, message: c, source: "usd-visual" });
|
|
3284
|
-
};
|
|
3285
|
-
s.status === "missing" && r(
|
|
3286
|
-
e.warnings,
|
|
3287
|
-
"USD_VISUAL_RESOURCE_MISSING",
|
|
3288
|
-
`USD 材质资源缺失:${s.path}(${t})。未生成替代内容。`
|
|
3289
|
-
), s.status === "unsupported-format" && r(
|
|
3290
|
-
e.droppedFeatures,
|
|
3291
|
-
"USD_VISUAL_TEXTURE_FORMAT_UNSUPPORTED",
|
|
3292
|
-
`USD 材质纹理格式无法由浏览器直接消费:${s.path}(${t})。需要离线确定性转码。`
|
|
3293
|
-
), s.status === "decode-failed" && r(
|
|
3294
|
-
e.warnings,
|
|
3295
|
-
"USD_VISUAL_TEXTURE_DECODE_FAILED",
|
|
3296
|
-
`USD 纹理解码失败:${s.path}(${t})。保留原材质。`
|
|
3297
|
-
), s.status === "unresolved" && r(
|
|
3298
|
-
e.warnings,
|
|
3299
|
-
"USD_VISUAL_RESOURCE_UNRESOLVED",
|
|
3300
|
-
`无法确认 USD 材质资源是否可用:${s.path}(${t})。未生成替代内容。`
|
|
3301
|
-
);
|
|
3302
|
-
}
|
|
3303
|
-
}
|
|
3304
|
-
function Br(e) {
|
|
3305
|
-
const t = G(e, ["filename", "file"]), n = ae(t);
|
|
3306
|
-
return n ? { shader: e, path: n } : null;
|
|
3307
|
-
}
|
|
3308
|
-
function ee(e, t) {
|
|
3309
|
-
return Re(e.inputs[`inputs:${t}.resolvedConnect`] ?? e.inputs[`inputs:${t}.connect`]);
|
|
3310
|
-
}
|
|
3311
|
-
function Oe(e, t, n) {
|
|
3312
|
-
for (const s of n) {
|
|
3313
|
-
const r = t.inputs[`inputs:${s}.resolvedConnect`] ?? t.inputs[`inputs:${s}.connect`], o = Re(r);
|
|
3314
|
-
if (o) {
|
|
3315
|
-
const c = Pn(e, o.path);
|
|
3316
|
-
if (!c) return { value: void 0, connection: o, materialInput: null };
|
|
3317
|
-
const u = e.inputs[`inputs:${c}.resolvedConnect`] ?? e.inputs[`inputs:${c}.connect`], l = Re(u);
|
|
3318
|
-
return l ? { value: void 0, connection: l, materialInput: c } : {
|
|
3319
|
-
value: e.inputs[`inputs:${c}`],
|
|
3320
|
-
connection: null,
|
|
3321
|
-
materialInput: c
|
|
3322
|
-
};
|
|
3323
|
-
}
|
|
3324
|
-
const a = t.inputs[`inputs:${s}`];
|
|
3325
|
-
if (a !== void 0) return { value: a, connection: null, materialInput: null };
|
|
3326
|
-
}
|
|
3327
|
-
return { value: void 0, connection: null, materialInput: null };
|
|
3328
|
-
}
|
|
3329
|
-
function Pn(e, t) {
|
|
3330
|
-
const n = /^(.*)\.inputs:([^/.]+)$/.exec(t);
|
|
3331
|
-
return (n == null ? void 0 : n[1]) === e.path && n[2] ? n[2] : null;
|
|
3332
|
-
}
|
|
3333
|
-
function Ve(e, t, n) {
|
|
3334
|
-
const s = Oe(e, t, n).value;
|
|
3335
|
-
return typeof s == "number" && Number.isFinite(s) ? s : null;
|
|
3336
|
-
}
|
|
3337
|
-
function Lr(e, t, n) {
|
|
3338
|
-
const s = Oe(e, t, n).value;
|
|
3339
|
-
return typeof s == "boolean" ? s : null;
|
|
3340
|
-
}
|
|
3341
|
-
function Yt(e, t, n) {
|
|
3342
|
-
const s = Oe(e, t, n).value;
|
|
3343
|
-
if (!Array.isArray(s) || s.length < 3) return null;
|
|
3344
|
-
const r = s.slice(0, 3);
|
|
3345
|
-
return r.every((o) => typeof o == "number" && Number.isFinite(o)) ? new tt(r[0], r[1], r[2]) : null;
|
|
3346
|
-
}
|
|
3347
|
-
function Re(e) {
|
|
3348
|
-
const t = Array.isArray(e) ? e[0] : e;
|
|
3349
|
-
if (typeof t != "string") return null;
|
|
3350
|
-
const n = /^(.*?)(?:\.outputs:([^/]+))?$/.exec(t);
|
|
3351
|
-
return n ? { path: n[1], outputName: n[2] ?? null } : null;
|
|
3352
|
-
}
|
|
3353
|
-
function Xe(e, t) {
|
|
3354
|
-
return e.shaders.find((n) => n.path === t.path) ?? null;
|
|
3355
|
-
}
|
|
3356
|
-
function Rn(e) {
|
|
3357
|
-
return e.id === "PxrTexture";
|
|
3358
|
-
}
|
|
3359
|
-
function X(e) {
|
|
3360
|
-
return e instanceof St || e instanceof W;
|
|
3361
|
-
}
|
|
3362
|
-
async function ce(e, t) {
|
|
3363
|
-
const n = await new nn().loadAsync(e);
|
|
3364
|
-
return n.colorSpace = t, n.flipY = !0, n;
|
|
3365
|
-
}
|
|
3366
|
-
function de(e, t) {
|
|
3367
|
-
const n = G(e, t);
|
|
3368
|
-
if (!Array.isArray(n) || n.length < 3) return null;
|
|
3369
|
-
const s = n.slice(0, 3);
|
|
3370
|
-
return s.every((r) => typeof r == "number" && Number.isFinite(r)) ? new tt(s[0], s[1], s[2]) : null;
|
|
3371
|
-
}
|
|
3372
|
-
function ge(e, t, n) {
|
|
3373
|
-
const s = G(e, t);
|
|
3374
|
-
return typeof s == "boolean" ? s : n;
|
|
3375
|
-
}
|
|
3376
|
-
function Ce(e, t, n) {
|
|
3377
|
-
const s = G(e, [t]);
|
|
3378
|
-
if (typeof s == "boolean") return s;
|
|
3379
|
-
if (typeof s == "number" && Number.isFinite(s)) return s !== 0;
|
|
3380
|
-
if (typeof s == "string") {
|
|
3381
|
-
if (s.toLowerCase() === "true") return !0;
|
|
3382
|
-
if (s.toLowerCase() === "false") return !1;
|
|
3383
|
-
}
|
|
3384
|
-
return n;
|
|
3385
|
-
}
|
|
3386
|
-
function kr(e) {
|
|
3387
|
-
return e === 1 || e === "mask" ? "mask" : e === 2 || e === "blend" ? "blend" : "opaque";
|
|
3388
|
-
}
|
|
3389
|
-
function Jt(e, t, n) {
|
|
3390
|
-
const s = G(e, [t]);
|
|
3391
|
-
return Array.isArray(s) && s.length >= 2 && s.slice(0, 2).every((r) => typeof r == "number" && Number.isFinite(r)) ? [s[0], s[1]] : n;
|
|
3392
|
-
}
|
|
3393
|
-
function N(e, t) {
|
|
3394
|
-
const n = G(e, t), s = typeof n == "number" ? n : Number.NaN;
|
|
3395
|
-
return Number.isFinite(s) ? s : null;
|
|
3396
|
-
}
|
|
3397
|
-
function G(e, t) {
|
|
3398
|
-
for (const n of t) {
|
|
3399
|
-
if (ee(e, n)) return;
|
|
3400
|
-
const s = e.inputs[`inputs:${n}`];
|
|
3401
|
-
if (s !== void 0) return s;
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
function ae(e) {
|
|
3405
|
-
if (typeof e == "string") return e;
|
|
3406
|
-
if (!e || typeof e != "object") return null;
|
|
3407
|
-
for (const t of ["path", "resolvedPath", "url"]) {
|
|
3408
|
-
const n = e[t];
|
|
3409
|
-
if (typeof n == "string" && n) return n;
|
|
3410
|
-
}
|
|
3411
|
-
return null;
|
|
3412
|
-
}
|
|
3413
|
-
function gt(e, t) {
|
|
3414
|
-
return e.data.elements.some((n) => n.material === t && n.geometry.displayColor !== null);
|
|
3415
|
-
}
|
|
3416
|
-
function ut(e, t) {
|
|
3417
|
-
return gt(e, t) ? "authored-fallback" : "default-fallback";
|
|
3418
|
-
}
|
|
3419
|
-
function Fr(e) {
|
|
3420
|
-
var t, n;
|
|
3421
|
-
return ((n = (t = e.split(/[?#]/, 1)[0]) == null ? void 0 : t.split(".").pop()) == null ? void 0 : n.toLowerCase()) ?? "";
|
|
3422
|
-
}
|
|
3423
|
-
function Q(e) {
|
|
3424
|
-
return Math.min(1, Math.max(0, e));
|
|
3425
|
-
}
|
|
3426
|
-
function Je(e) {
|
|
3427
|
-
return Array.isArray(e) ? e.filter(yt) : [];
|
|
3428
|
-
}
|
|
3429
|
-
function le(e) {
|
|
3430
|
-
return typeof e == "string" && e ? e : null;
|
|
3431
|
-
}
|
|
3432
|
-
function yt(e) {
|
|
3433
|
-
return typeof e == "string" && e.length > 0;
|
|
3434
|
-
}
|
|
3435
|
-
function oe(e) {
|
|
3436
|
-
return [...new Set(e)];
|
|
3437
|
-
}
|
|
3438
|
-
const Zt = /* @__PURE__ */ new Map();
|
|
3439
|
-
function Gr(e) {
|
|
3440
|
-
const t = e ?? "";
|
|
3441
|
-
let n = Zt.get(t);
|
|
3442
|
-
return n || (n = ms(vs(e)), Zt.set(t, n)), n;
|
|
3443
|
-
}
|
|
3444
|
-
async function uo(e, t, n) {
|
|
3445
|
-
var x;
|
|
3446
|
-
const s = n.hasLocalFiles(), r = e.entryPath ?? e.filename ?? "asset.usd", o = s ? r : await eo(e, r), a = s ? n.getBlob(r) : await to(e), c = r.split("/").pop() || "asset.usd", u = r.split("/").slice(0, -1).join("/"), l = t.options.usdExternalReferenceMode ?? "package", p = new URL(o, "file:///"), i = jn(), f = /* @__PURE__ */ new Set(), h = (O) => {
|
|
3447
|
-
f.has(O) || (f.add(O), i.warnings.push({ code: "USD_EXTERNAL_REFERENCE_SKIPPED", message: `资产包模式已跳过包外 USD 资源:${O}。包内内容继续加载;完整模式可尝试加载该资源。`, source: "usd-resources" }));
|
|
3448
|
-
}, d = (O) => {
|
|
3449
|
-
if (n.find(O, r) || l === "complete") return !0;
|
|
3450
|
-
const C = !s && vt(new URL(O, p), p);
|
|
3451
|
-
return C || h(O), C;
|
|
3452
|
-
}, g = /* @__PURE__ */ new Set(), _ = (O, C) => {
|
|
3453
|
-
if (g.has(O)) return;
|
|
3454
|
-
g.add(O);
|
|
3455
|
-
const v = Qn(C);
|
|
3456
|
-
i.warnings.push({
|
|
3457
|
-
code: v === "invalid" ? "USD_VISUAL_RESOURCE_INVALID" : v === "unavailable" ? "USD_VISUAL_RESOURCE_UNAVAILABLE" : "USD_VISUAL_RESOURCE_MISSING",
|
|
3458
|
-
message: `USD 视觉资源不可用:${O}`,
|
|
3459
|
-
source: "usd-resources"
|
|
3460
|
-
});
|
|
3461
|
-
}, { parseAsync: y } = await Gr(t.options.openUsdBaseUrl), w = Vr(t.requestRender);
|
|
3462
|
-
let m = null, U = null, b = null, S = null;
|
|
3463
|
-
try {
|
|
3464
|
-
if (m = await y(a, {
|
|
3465
|
-
sourcePath: o,
|
|
3466
|
-
fileName: c,
|
|
3467
|
-
files: s ? n.asSourceRecord(u, !0) : void 0,
|
|
3468
|
-
// The viewer default is the package boundary, not the source kind:
|
|
3469
|
-
// package-local layers/textures are discovered for both File and URL
|
|
3470
|
-
// inputs, while package-external references are filtered before reading.
|
|
3471
|
-
// Complete mode discovers all references. If the host supplied a
|
|
3472
|
-
// resolver, files.ensure() remains the only path to external bytes and
|
|
3473
|
-
// therefore the resolver remains authoritative; without one it falls
|
|
3474
|
-
// through to the source base URL and direct browser fetch.
|
|
3475
|
-
autoResolveAssets: !0,
|
|
3476
|
-
externalReferenceMode: l,
|
|
3477
|
-
onReferenceSkipped: h,
|
|
3478
|
-
onResourceFailed: _,
|
|
3479
|
-
isTextureAllowed: (A) => d(A) && !!n.find(A, r),
|
|
3480
|
-
resolveBytes: async (A, F) => {
|
|
3481
|
-
const D = n.find(F, r);
|
|
3482
|
-
return D ? n.bytes(D) : (await n.ensure(F), n.bytes(F));
|
|
3483
|
-
},
|
|
3484
|
-
textureResolver: (A) => {
|
|
3485
|
-
for (const F of [A.resolvedPath, A.path, A.url]) {
|
|
3486
|
-
if (!F) continue;
|
|
3487
|
-
const D = n.objectUrlIfPresent(F, u);
|
|
3488
|
-
if (D) return D;
|
|
3489
|
-
}
|
|
3490
|
-
return null;
|
|
3491
|
-
},
|
|
3492
|
-
textureLoader: w
|
|
3493
|
-
}), t.signal.aborted) throw lt();
|
|
3494
|
-
const O = Qr(m);
|
|
3495
|
-
m.scene.scale.multiplyScalar(O.metersPerUnit), m.data.stage.upAxis.toUpperCase() === "Y" && m.scene.quaternion.setFromAxisAngle(new j(1, 0, 0), Math.PI / 2), m.scene.updateMatrixWorld(!0);
|
|
3496
|
-
const C = m.data.physics.rigidBodies.filter((A) => A.enabled), v = Mn(m, C.map((A) => A.path)), B = await Js(m, {
|
|
3497
|
-
files: n,
|
|
3498
|
-
entryDirectory: u,
|
|
3499
|
-
sourcePath: o,
|
|
3500
|
-
isLocalPackage: s,
|
|
3501
|
-
diagnostics: i,
|
|
3502
|
-
isTextureAllowed: t.format === "usdz" ? void 0 : d,
|
|
3503
|
-
packageTextureURLs: m.resources.usdzTextureURLs
|
|
3504
|
-
});
|
|
3505
|
-
if (t.signal.aborted) throw lt();
|
|
3506
|
-
es(m);
|
|
3507
|
-
const E = jr(i);
|
|
3508
|
-
C.some((A) => A.startsAsleep === !0) && i.droppedFeatures.push({ code: "E_USD_STARTS_ASLEEP", message: "USD startsAsleep 无法在 MuJoCo 初始化阶段保证完全等价,已按正常初始状态加载。", source: "usd-physics" });
|
|
3509
|
-
const R = Vn({
|
|
3510
|
-
id: o,
|
|
3511
|
-
name: o.split("/").pop() ?? o,
|
|
3512
|
-
source: { format: "usd", uri: o },
|
|
3513
|
-
links: C.map((A) => ({ id: A.path, name: A.name, visuals: [], collisions: [] })),
|
|
3514
|
-
joints: v.flatMap((A) => A.body0 && A.body1 ? [{
|
|
3515
|
-
id: A.path,
|
|
3516
|
-
type: A.jointType,
|
|
3517
|
-
parent: A.body0,
|
|
3518
|
-
child: A.body1,
|
|
3519
|
-
origin: { position: A.localPos1.map((F) => F * O.metersPerUnit), rotationRpy: [0, 0, 0] },
|
|
3520
|
-
axis: xn(A.axis).applyQuaternion($e(A.localRot1 ?? [1, 0, 0, 0])).toArray(),
|
|
3521
|
-
...Number.isFinite(A.lowerLimit) && Number.isFinite(A.upperLimit) ? { limits: {
|
|
3522
|
-
lower: A.lowerLimit * (A.jointType === "revolute" ? Math.PI / 180 : O.metersPerUnit),
|
|
3523
|
-
upper: A.upperLimit * (A.jointType === "revolute" ? Math.PI / 180 : O.metersPerUnit)
|
|
3524
|
-
} } : {}
|
|
3525
|
-
}] : []),
|
|
3526
|
-
diagnostics: i,
|
|
3527
|
-
extension: { rigidBodyCount: C.length, jointCount: v.length, visualAdaptation: B }
|
|
3528
|
-
});
|
|
3529
|
-
if (C.length === 0) {
|
|
3530
|
-
Qt(m);
|
|
3531
|
-
const A = en(m, i), F = m.scene, D = m, L = zr(F, t.requestRender);
|
|
3532
|
-
return b = { root: F, sync() {
|
|
3533
|
-
}, dispose() {
|
|
3534
|
-
L == null || L.dispose(), D.dispose();
|
|
3535
|
-
} }, m = null, ct(R, b, !1, () => {
|
|
3536
|
-
}, void 0, void 0, A, E, L);
|
|
3537
|
-
}
|
|
3538
|
-
let I;
|
|
3539
|
-
try {
|
|
3540
|
-
I = Yr(m, C.map((F) => F.path), O, v), (x = I.massOverrides) != null && x.length && i.approximations.push({ code: "USD_INFERRED_INERTIA", message: "保留显式总质量;惯量按碰撞几何的密度分布推导并同比缩放,重叠体积会重复计入。", source: "usd-physics" });
|
|
3541
|
-
const { MujocoRuntime: A } = await import("./mujoco-runtime-DTxVmIzc.js");
|
|
3542
|
-
U = new A(), await U.initialize(I, t.options.mujocoBaseUrl), t.signal.throwIfAborted();
|
|
3543
|
-
} catch (A) {
|
|
3544
|
-
const F = zn(A, t.signal, "usd-physics");
|
|
3545
|
-
U == null || U.dispose(), U = null, i.droppedFeatures.push(F), Qt(m);
|
|
3546
|
-
const D = en(m, i), L = m.scene, K = m;
|
|
3547
|
-
return b = { root: L, sync() {
|
|
3548
|
-
}, dispose() {
|
|
3549
|
-
K.dispose();
|
|
3550
|
-
} }, m = null, ct(R, b, !1, () => {
|
|
3551
|
-
}, void 0, F, D, E);
|
|
3552
|
-
}
|
|
3553
|
-
const H = S = Kr(m, C.map((A) => A.path), i);
|
|
3554
|
-
if (t.signal.aborted) throw lt();
|
|
3555
|
-
b = new Nt(U, H);
|
|
3556
|
-
const P = An(m, C.map((A) => A.path), i), $ = P ? new Nt(U, P) : void 0;
|
|
3557
|
-
S = null;
|
|
3558
|
-
const J = m, T = U, se = b;
|
|
3559
|
-
return m = null, U = null, b = null, ct(R, se, !0, () => {
|
|
3560
|
-
T.dispose(), J.dispose();
|
|
3561
|
-
}, T, void 0, $, E);
|
|
3562
|
-
} catch (O) {
|
|
3563
|
-
throw S && on(S.root), b == null || b.dispose(), U == null || U.dispose(), m == null || m.dispose(), O;
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
function Qt(e) {
|
|
3567
|
-
for (const t of e.index.boneHostsBySkeletonPath.values())
|
|
3568
|
-
t.matrix.copy(e.scene.matrixWorld).invert();
|
|
3569
|
-
e.scene.updateMatrixWorld(!0);
|
|
3570
|
-
}
|
|
3571
|
-
function Vr(e) {
|
|
3572
|
-
const n = [];
|
|
3573
|
-
let s = !1;
|
|
3574
|
-
const r = () => {
|
|
3575
|
-
if (s || n.length === 0) return;
|
|
3576
|
-
s = !0;
|
|
3577
|
-
const a = () => {
|
|
3578
|
-
var u;
|
|
3579
|
-
s = !1;
|
|
3580
|
-
let c = 0;
|
|
3581
|
-
for (; n.length; ) {
|
|
3582
|
-
const l = n[0];
|
|
3583
|
-
if (c > 0 && c + l.pixels > 4194304 || ((u = n.shift()) == null || u.apply(), c += l.pixels, c >= 4194304)) break;
|
|
3584
|
-
}
|
|
3585
|
-
n.length && r();
|
|
3586
|
-
};
|
|
3587
|
-
typeof requestAnimationFrame == "function" ? requestAnimationFrame(a) : setTimeout(a, 16);
|
|
3588
|
-
};
|
|
3589
|
-
class o extends nn {
|
|
3590
|
-
load(c, u, l, p) {
|
|
3591
|
-
const i = new bt();
|
|
3592
|
-
return setTimeout(() => {
|
|
3593
|
-
super.load(c, (f) => {
|
|
3594
|
-
var g, _;
|
|
3595
|
-
const h = ((g = f.image) == null ? void 0 : g.width) || 0, d = ((_ = f.image) == null ? void 0 : _.height) || 0;
|
|
3596
|
-
n.push({ pixels: Math.max(1, h * d), apply: () => {
|
|
3597
|
-
i.image = f.image, i.source.needsUpdate = !0, i.needsUpdate = !0, f.dispose(), u == null || u(i), e();
|
|
3598
|
-
} }), r();
|
|
3599
|
-
}, l, p);
|
|
3600
|
-
}, 0), i;
|
|
3601
|
-
}
|
|
3602
|
-
}
|
|
3603
|
-
return new o();
|
|
3604
|
-
}
|
|
3605
|
-
function zr(e, t) {
|
|
3606
|
-
const n = e.animations ?? [];
|
|
3607
|
-
if (n.length === 0) return;
|
|
3608
|
-
const s = new Fn(e), r = n.map((o) => s.clipAction(o));
|
|
3609
|
-
for (const o of r) o.reset().setLoop(Gn, 1 / 0).play();
|
|
3610
|
-
return s.setTime(0), {
|
|
3611
|
-
step(o) {
|
|
3612
|
-
return o > 0 ? (s.update(o), t(), !0) : !1;
|
|
3613
|
-
},
|
|
3614
|
-
reset() {
|
|
3615
|
-
s.setTime(0), t();
|
|
3616
|
-
},
|
|
3617
|
-
dispose() {
|
|
3618
|
-
for (const o of r) o.stop();
|
|
3619
|
-
s.stopAllAction(), s.uncacheRoot(e);
|
|
3620
|
-
}
|
|
3621
|
-
};
|
|
3622
|
-
}
|
|
3623
|
-
function jr(e) {
|
|
3624
|
-
const t = [
|
|
3625
|
-
"USD_VISUAL_RESOURCE_MISSING",
|
|
3626
|
-
"USD_VISUAL_RESOURCE_INVALID",
|
|
3627
|
-
"USD_VISUAL_RESOURCE_UNAVAILABLE",
|
|
3628
|
-
"USD_VISUAL_TEXTURE_FORMAT_UNSUPPORTED",
|
|
3629
|
-
"USD_VISUAL_RESOURCE_UNRESOLVED",
|
|
3630
|
-
"USD_VISUAL_TEXTURE_DECODE_FAILED",
|
|
3631
|
-
"USD_VISUAL_MATERIAL_IR_ISSUE",
|
|
3632
|
-
"USD_VISUAL_SHADER_NODE_UNSUPPORTED",
|
|
3633
|
-
"USD_VISUAL_LOADER_DIAGNOSTIC",
|
|
3634
|
-
"USD_VISUAL_TOPOLOGY_UNSUPPORTED",
|
|
3635
|
-
"USD_EXTERNAL_REFERENCE_SKIPPED"
|
|
3636
|
-
], n = [...e.warnings, ...e.droppedFeatures, ...e.approximations];
|
|
3637
|
-
for (const s of t) {
|
|
3638
|
-
const r = n.find((o) => o.code === s);
|
|
3639
|
-
if (r) return r;
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
function ct(e, t, n, s, r, o, a, c, u) {
|
|
3643
|
-
let l = !1;
|
|
3644
|
-
return {
|
|
3645
|
-
asset: e,
|
|
3646
|
-
binding: t,
|
|
3647
|
-
hasPhysics: n,
|
|
3648
|
-
hasAnimation: !!u,
|
|
3649
|
-
runtime: r,
|
|
3650
|
-
fallback: o,
|
|
3651
|
-
visualWarning: c,
|
|
3652
|
-
collision: a,
|
|
3653
|
-
step(p) {
|
|
3654
|
-
if (u) return u.step(p);
|
|
3655
|
-
if (!r) return !1;
|
|
3656
|
-
const i = r.step(p);
|
|
3657
|
-
return i && t.sync(), i;
|
|
3658
|
-
},
|
|
3659
|
-
reset() {
|
|
3660
|
-
if (u) {
|
|
3661
|
-
u.reset();
|
|
3662
|
-
return;
|
|
3663
|
-
}
|
|
3664
|
-
r == null || r.reset(), t.sync();
|
|
3665
|
-
},
|
|
3666
|
-
dispose() {
|
|
3667
|
-
l || (l = !0, a == null || a.dispose(), t.dispose(), s());
|
|
3668
|
-
}
|
|
3669
|
-
};
|
|
3670
|
-
}
|
|
3671
|
-
const Wr = /* @__PURE__ */ new Set([
|
|
3672
|
-
"E_USD_PHYSICS_UNSUPPORTED",
|
|
3673
|
-
"E_USD_UNBAKED_BODY_SCALE",
|
|
3674
|
-
"E_USD_INVALID_JOINT_REFERENCE",
|
|
3675
|
-
"E_USD_UNSUPPORTED_JOINT",
|
|
3676
|
-
"E_USD_MULTIPLE_PARENTS",
|
|
3677
|
-
"E_USD_JOINT_CYCLE",
|
|
3678
|
-
"E_USD_UNSUPPORTED_DRIVE",
|
|
3679
|
-
"E_USD_INVALID_MASS",
|
|
3680
|
-
"E_USD_PARTIAL_INERTIA",
|
|
3681
|
-
"E_USD_MISSING_COLLISION_GEOMETRY",
|
|
3682
|
-
"E_USD_UNREACHABLE_BODIES",
|
|
3683
|
-
"E_USD_MULTIPLE_PHYSICS_SCENES",
|
|
3684
|
-
"E_USD_NONUNIFORM_RADIAL_SCALE",
|
|
3685
|
-
"E_USD_UNSUPPORTED_GEOMETRY",
|
|
3686
|
-
"E_USD_CONSTRAINED_INITIAL_VELOCITY",
|
|
3687
|
-
"E_USD_UNSUPPORTED_APPROXIMATION"
|
|
3688
|
-
]);
|
|
3689
|
-
function co(e) {
|
|
3690
|
-
const t = Xr(e);
|
|
3691
|
-
return t !== null && Wr.has(t);
|
|
3692
|
-
}
|
|
3693
|
-
function Xr(e) {
|
|
3694
|
-
if (!e || typeof e != "object" || !("code" in e)) return null;
|
|
3695
|
-
const t = e.code;
|
|
3696
|
-
return typeof t == "string" ? t : null;
|
|
3697
|
-
}
|
|
3698
|
-
function Kr(e, t, n) {
|
|
3699
|
-
e.scene.updateMatrixWorld(!0);
|
|
3700
|
-
const s = new ze();
|
|
3701
|
-
s.name = "USD simulation";
|
|
3702
|
-
const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
3703
|
-
for (const d of t) {
|
|
3704
|
-
const g = e.index.objectsByPath.get(d);
|
|
3705
|
-
if (!g) throw Y(`USD rigid body node is missing: ${d}`, "E_USD_PHYSICS_UNSUPPORTED");
|
|
3706
|
-
const _ = new ze();
|
|
3707
|
-
_.name = d, s.add(_), r.set(d, _);
|
|
3708
|
-
const y = new j(), w = new fe();
|
|
3709
|
-
g.matrixWorld.decompose(y, w, new j()), o.set(d, new Pe().compose(y, w, new j(1, 1, 1)));
|
|
3710
|
-
}
|
|
3711
|
-
const a = Hr(e, t, n), c = [], u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), i = (d, g) => {
|
|
3712
|
-
var U;
|
|
3713
|
-
const _ = d.skeleton, y = _.bones.map((b) => b.uuid).join("|");
|
|
3714
|
-
let w = p.get(y), m;
|
|
3715
|
-
if (w)
|
|
3716
|
-
m = _.bones.map((b) => l.get(b.uuid));
|
|
3717
|
-
else {
|
|
3718
|
-
w = new ze(), w.name = `${d.name || "USD"}_BoneHost`, w.matrixAutoUpdate = !1;
|
|
3719
|
-
const b = (U = _.bones[0]) == null ? void 0 : U.parent;
|
|
3720
|
-
w.matrix.copy(g).multiply((b == null ? void 0 : b.matrixWorld) ?? new Pe()), s.add(w), p.set(y, w), m = _.bones.map((S) => {
|
|
3721
|
-
const x = S.clone(!1);
|
|
3722
|
-
return x.matrix.copy(S.matrix), x.matrixAutoUpdate = !1, l.set(S.uuid, x), x;
|
|
3723
|
-
});
|
|
3724
|
-
for (let S = 0; S < m.length; S++) {
|
|
3725
|
-
const x = _.bones[S].parent, O = _.bones.indexOf(x);
|
|
3726
|
-
(O >= 0 ? m[O] : w).add(m[S]);
|
|
3727
|
-
}
|
|
3728
|
-
}
|
|
3729
|
-
return new kn(m, _.boneInverses.map((b) => b.clone()));
|
|
3730
|
-
};
|
|
3731
|
-
e.scene.traverse((d) => {
|
|
3732
|
-
var m;
|
|
3733
|
-
if (!(d instanceof me) || d.userData.usdPurposeExcluded) return;
|
|
3734
|
-
let g = d, _, y, w = !0;
|
|
3735
|
-
for (; g; ) {
|
|
3736
|
-
w && (w = g.visible);
|
|
3737
|
-
const U = (m = g.userData.usd) == null ? void 0 : m.path;
|
|
3738
|
-
!y && U && (y = U), !_ && U && r.has(U) && (_ = U), g = g.parent;
|
|
3739
|
-
}
|
|
3740
|
-
!_ && y && (_ = a.get(In(y))), w && c.push([d, _]);
|
|
3741
|
-
});
|
|
3742
|
-
for (const [d, g] of c) {
|
|
3743
|
-
const _ = g ? o.get(g).clone().invert() : new Pe(), y = d instanceof qe ? new qe(d.geometry.clone(), Array.isArray(d.material) ? d.material.map((w) => w.clone()) : d.material.clone()) : d.clone(!1);
|
|
3744
|
-
y.geometry = d.geometry.clone(), y.material = Array.isArray(d.material) ? d.material.map((w) => w.clone()) : d.material.clone(), y instanceof qe && d instanceof qe && (y.bindMode = d.bindMode, y.bindMatrix.copy(d.bindMatrix), y.bindMatrixInverse.copy(d.bindMatrixInverse), y.bind(i(d, _), y.bindMatrix), y.frustumCulled = !1), y.matrix.copy(_).multiply(d.matrixWorld), y.matrix.decompose(y.position, y.quaternion, y.scale), (g ? r.get(g) : s).add(y), u.set(d.uuid, y);
|
|
3745
|
-
}
|
|
3746
|
-
const h = (e.scene.animations ?? []).map((d) => {
|
|
3747
|
-
const g = d.clone();
|
|
3748
|
-
return g.tracks = g.tracks.map((_) => {
|
|
3749
|
-
const y = _.name.split(".", 1)[0], w = u.get(y) ?? l.get(y);
|
|
3750
|
-
return w && (_.name = `${w.uuid}${_.name.slice(y.length)}`), _;
|
|
3751
|
-
}), g;
|
|
3752
|
-
});
|
|
3753
|
-
return { root: s, bindings: r, expectedLinkCount: r.size, animations: h };
|
|
3754
|
-
}
|
|
3755
|
-
function Hr(e, t, n) {
|
|
3756
|
-
var u, l;
|
|
3757
|
-
const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = e.stage, a = e.pxr;
|
|
3758
|
-
if (!o || !((u = a == null ? void 0 : a.Sdf) != null && u.Path) || !((l = e.data.view) != null && l.prims)) return s;
|
|
3759
|
-
const c = new Set(e.data.view.prims.map((p) => p.path));
|
|
3760
|
-
for (const p of t) {
|
|
3761
|
-
const i = `${p}/Visual/`;
|
|
3762
|
-
for (const f of c) {
|
|
3763
|
-
if (!f.startsWith(i)) continue;
|
|
3764
|
-
const h = o.GetPrimAtPath(new a.Sdf.Path(f));
|
|
3765
|
-
try {
|
|
3766
|
-
const d = h.GetMetadata("references"), g = typeof d == "string" ? d : d == null ? void 0 : d.string;
|
|
3767
|
-
if (g == null) {
|
|
3768
|
-
n == null || n.warnings.push({ code: "USD_VISUAL_REFERENCE_MISSING", message: `刚体视觉节点缺少 reference:${f}`, source: "usd-visual-binding" });
|
|
3769
|
-
continue;
|
|
3770
|
-
}
|
|
3771
|
-
const _ = qr(g);
|
|
3772
|
-
if (!_) {
|
|
3773
|
-
n == null || n.warnings.push({ code: "USD_VISUAL_REFERENCE_UNRESOLVED", message: `无法解析视觉引用元数据:${f}`, source: "usd-visual-binding" });
|
|
3774
|
-
continue;
|
|
3775
|
-
}
|
|
3776
|
-
if (!_.primPath) continue;
|
|
3777
|
-
const y = In(_.primPath), w = r.get(y);
|
|
3778
|
-
if (w && w.owner !== p)
|
|
3779
|
-
throw Y(`USD visual reference maps to multiple rigid bodies: ${_.primPath} -> ${w.owner}, ${p}`, "E_USD_VISUAL_REFERENCE_AMBIGUOUS");
|
|
3780
|
-
r.set(y, { owner: p, target: _.primPath }), s.set(y, p);
|
|
3781
|
-
} finally {
|
|
3782
|
-
h.delete();
|
|
3783
|
-
}
|
|
3784
|
-
}
|
|
3785
|
-
}
|
|
3786
|
-
return s;
|
|
3787
|
-
}
|
|
3788
|
-
function qr(e) {
|
|
3789
|
-
var n, s;
|
|
3790
|
-
const t = e.match(/SdfReference\(([^,]*),\s*(?:(\/[^,\)]+),\s*)?SdfLayerOffset/);
|
|
3791
|
-
return t ? { identifier: ((n = t[1]) == null ? void 0 : n.trim()) ?? "", primPath: ((s = t[2]) == null ? void 0 : s.trim()) ?? null } : null;
|
|
3792
|
-
}
|
|
3793
|
-
function In(e) {
|
|
3794
|
-
const t = e.replaceAll("\\", "/");
|
|
3795
|
-
for (const n of ["/Geometry/", "/Visual/"]) {
|
|
3796
|
-
const s = t.indexOf(n);
|
|
3797
|
-
if (s >= 0) return t.slice(s + n.length);
|
|
3798
|
-
}
|
|
3799
|
-
return t;
|
|
3800
|
-
}
|
|
3801
|
-
function An(e, t, n) {
|
|
3802
|
-
e.scene.updateMatrixWorld(!0);
|
|
3803
|
-
const s = new ze();
|
|
3804
|
-
s.name = "USD authored collisions";
|
|
3805
|
-
const r = Et(), o = $t(), a = Et(Bt), c = $t(Bt), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
3806
|
-
for (const i of t) {
|
|
3807
|
-
const f = e.index.objectsByPath.get(i);
|
|
3808
|
-
if (!f) continue;
|
|
3809
|
-
const h = new j(), d = new fe();
|
|
3810
|
-
f.matrixWorld.decompose(h, d, new j()), l.set(i, new Pe().compose(h, d, new j(1, 1, 1)));
|
|
3811
|
-
const g = new ze();
|
|
3812
|
-
g.name = i, g.position.copy(h), g.quaternion.copy(d), u.set(i, g), s.add(g);
|
|
3813
|
-
}
|
|
3814
|
-
let p = 0;
|
|
3815
|
-
for (const i of e.data.physics.colliders) {
|
|
3816
|
-
if (!i.enabled) continue;
|
|
3817
|
-
const f = e.index.objectsByPath.get(i.path);
|
|
3818
|
-
if (!f) continue;
|
|
3819
|
-
const h = i.bodyPath && u.has(i.bodyPath) ? i.bodyPath : null, d = h ? u.get(h) : s, g = h ? l.get(h) : new Pe(), _ = [];
|
|
3820
|
-
if (f.traverse((b) => {
|
|
3821
|
-
b instanceof me && _.push(b);
|
|
3822
|
-
}), _.length === 0) continue;
|
|
3823
|
-
const y = String(i.typeName ?? f.type).toLowerCase(), w = y.includes("mesh") ? i.approximation ?? "none" : null;
|
|
3824
|
-
if (w && !["none", "convexHull", "boundingSphere", "boundingCube"].includes(w)) {
|
|
3825
|
-
n == null || n.droppedFeatures.push({
|
|
3826
|
-
code: "E_USD_COLLISION_DEBUG_APPROXIMATION_UNAVAILABLE",
|
|
3827
|
-
message: `USD collider ${i.path} 使用 ${w},最终求解器代理无法从 OpenUSD 唯一还原;已用橙黄色显示作者提供的 collision source mesh 近似预览。`,
|
|
3828
|
-
source: "usd-collision-debug"
|
|
3829
|
-
});
|
|
3830
|
-
const b = g.clone().invert();
|
|
3831
|
-
for (const S of _) {
|
|
3832
|
-
const x = Fe(
|
|
3833
|
-
S.geometry,
|
|
3834
|
-
a,
|
|
3835
|
-
"feature",
|
|
3836
|
-
c
|
|
3837
|
-
);
|
|
3838
|
-
x.name = `Collision approximation:${i.path}`, x.matrixAutoUpdate = !1, x.matrix.copy(b).multiply(S.matrixWorld), x.userData.usdColliderPath = i.path, x.userData.usdColliderApproximation = w, x.userData.usdCollisionDebugSource = "authored-collision-mesh", d.add(x), p += 1;
|
|
3839
|
-
}
|
|
3840
|
-
continue;
|
|
3841
|
-
}
|
|
3842
|
-
if (y.includes("mesh") && w !== "none") {
|
|
3843
|
-
const b = [], S = g.clone().invert();
|
|
3844
|
-
for (const x of _) {
|
|
3845
|
-
const O = S.clone().multiply(x.matrixWorld), C = x.geometry.getAttribute("position");
|
|
3846
|
-
for (let v = 0; v < C.count; v += 1) b.push(new j().fromBufferAttribute(C, v).applyMatrix4(O));
|
|
3847
|
-
}
|
|
3848
|
-
if (b.length >= 4 && w === "convexHull") {
|
|
3849
|
-
const x = new Wn(b), O = Fe(x, r, "mesh", o);
|
|
3850
|
-
x.dispose(), O.name = `Collision:${i.path}`, O.userData.usdColliderPath = i.path, O.userData.usdColliderApproximation = w, d.add(O), p += 1;
|
|
3851
|
-
} else if (b.length > 0 && w === "boundingSphere") {
|
|
3852
|
-
const O = new et().setFromPoints(b).getBoundingSphere(new Nn()), C = new Bn(O.radius, 24, 16);
|
|
3853
|
-
C.translate(O.center.x, O.center.y, O.center.z);
|
|
3854
|
-
const v = Fe(C, r, "feature", o);
|
|
3855
|
-
C.dispose(), v.name = `Collision:${i.path}`, v.userData.usdColliderPath = i.path, v.userData.usdColliderApproximation = w, d.add(v), p += 1;
|
|
3856
|
-
} else if (b.length > 0 && w === "boundingCube") {
|
|
3857
|
-
const x = new et().setFromPoints(b), O = x.getSize(new j()), C = x.getCenter(new j()), v = new Ln(O.x, O.y, O.z);
|
|
3858
|
-
v.translate(C.x, C.y, C.z);
|
|
3859
|
-
const B = Fe(v, r, "feature", o);
|
|
3860
|
-
v.dispose(), B.name = `Collision:${i.path}`, B.userData.usdColliderPath = i.path, B.userData.usdColliderApproximation = w, d.add(B), p += 1;
|
|
3861
|
-
}
|
|
3862
|
-
continue;
|
|
3863
|
-
}
|
|
3864
|
-
const U = y.includes("mesh") ? "mesh" : "feature";
|
|
3865
|
-
for (const b of _) {
|
|
3866
|
-
const S = Fe(b.geometry, r, U, o);
|
|
3867
|
-
S.name = `Collision:${i.path}`, S.matrixAutoUpdate = !1, S.matrix.copy(g).invert().multiply(b.matrixWorld), S.userData.usdColliderPath = i.path, w && (S.userData.usdColliderApproximation = w), d.add(S), p += 1;
|
|
3868
|
-
}
|
|
3869
|
-
}
|
|
3870
|
-
if (p === 0) {
|
|
3871
|
-
r.dispose(), o.dispose(), a.dispose(), c.dispose();
|
|
3872
|
-
return;
|
|
3873
|
-
}
|
|
3874
|
-
return { root: s, bindings: u, expectedLinkCount: u.size };
|
|
3875
|
-
}
|
|
3876
|
-
function en(e, t) {
|
|
3877
|
-
const n = An(e, [], t);
|
|
3878
|
-
if (n)
|
|
3879
|
-
return n.root.visible = !1, { root: n.root, sync() {
|
|
3880
|
-
}, dispose() {
|
|
3881
|
-
n.root.removeFromParent(), on(n.root);
|
|
3882
|
-
} };
|
|
3883
|
-
}
|
|
3884
|
-
function Mn(e, t) {
|
|
3885
|
-
e.scene.updateMatrixWorld(!0);
|
|
3886
|
-
const n = new Set(t);
|
|
3887
|
-
return e.data.joints.filter((s) => s.enabled).map((s) => {
|
|
3888
|
-
const r = { ...s };
|
|
3889
|
-
for (const o of [0, 1]) {
|
|
3890
|
-
const a = o === 0 ? "body0" : "body1", c = o === 0 ? "localPos0" : "localPos1", u = o === 0 ? "localRot0" : "localRot1", l = s[a];
|
|
3891
|
-
if (!l) continue;
|
|
3892
|
-
let p = l;
|
|
3893
|
-
for (; p && !e.index.rigidBodiesByPath.has(p); )
|
|
3894
|
-
p = p.slice(0, p.lastIndexOf("/"));
|
|
3895
|
-
if (p && !n.has(p))
|
|
3896
|
-
throw Y(`USD joint references an unknown or disabled rigid body: ${s.path} (${l})`, "E_USD_INVALID_JOINT_REFERENCE");
|
|
3897
|
-
const i = e.index.objectsByPath.get(l), f = p ? e.index.objectsByPath.get(p) : e.scene;
|
|
3898
|
-
if (!i || !f)
|
|
3899
|
-
throw Y(`USD joint target node is missing: ${s.path} (${l})`, "E_USD_INVALID_JOINT_REFERENCE");
|
|
3900
|
-
if (p === l) continue;
|
|
3901
|
-
const h = f.matrixWorld.clone().invert().multiply(i.matrixWorld), d = new j(), g = new fe(), _ = new j();
|
|
3902
|
-
h.decompose(d, g, _);
|
|
3903
|
-
const y = new Pe().compose(d, g, new j(1, 1, 1));
|
|
3904
|
-
if (h.elements.some((m, U) => Math.abs(m - y.elements[U]) > 1e-5))
|
|
3905
|
-
throw Y(`USD joint target has unsupported scale or shear: ${s.path} (${l})`, "E_USD_PHYSICS_UNSUPPORTED");
|
|
3906
|
-
r[a] = p || null, r[c] = new j(...s[c]).applyMatrix4(h).toArray();
|
|
3907
|
-
const w = g.multiply($e(s[u] ?? [1, 0, 0, 0])).normalize();
|
|
3908
|
-
r[u] = [w.w, w.x, w.y, w.z];
|
|
3909
|
-
}
|
|
3910
|
-
return r;
|
|
3911
|
-
});
|
|
3912
|
-
}
|
|
3913
|
-
function Yr(e, t, n, s = Mn(e, t)) {
|
|
3914
|
-
e.scene.updateMatrixWorld(!0);
|
|
3915
|
-
const r = [], o = [], a = [], c = [], u = [], l = [], p = [], { metersPerUnit: i, kilogramsPerUnit: f } = n, h = new Map(t.map((v) => {
|
|
3916
|
-
const B = e.index.rigidBodiesByPath.get(v);
|
|
3917
|
-
if (!B) throw Y(`USD rigid body metadata is missing: ${v}`, "E_USD_PHYSICS_UNSUPPORTED");
|
|
3918
|
-
return [v, B];
|
|
3919
|
-
})), d = /* @__PURE__ */ new Map();
|
|
3920
|
-
for (const v of h.keys()) {
|
|
3921
|
-
const B = e.index.objectsByPath.get(v);
|
|
3922
|
-
if (!B) throw Y(`USD rigid body node is missing: ${v}`, "E_USD_PHYSICS_UNSUPPORTED");
|
|
3923
|
-
const E = new j(), R = new fe(), I = new j();
|
|
3924
|
-
if (B.matrixWorld.decompose(E, R, I), I.clone().divideScalar(i).toArray().some((P) => Math.abs(Math.abs(P) - 1) > 1e-5))
|
|
3925
|
-
throw Y(`USD rigid body has unbaked scale: ${v}`, "E_USD_UNBAKED_BODY_SCALE");
|
|
3926
|
-
d.set(v, new Pe().compose(E, R, new j(1, 1, 1)));
|
|
3927
|
-
}
|
|
3928
|
-
const g = /* @__PURE__ */ new Map();
|
|
3929
|
-
for (const v of s) {
|
|
3930
|
-
if (!v.body1 || !h.has(v.body1) || v.body0 && !h.has(v.body0))
|
|
3931
|
-
throw Y(`USD joint references an unknown rigid body: ${v.path}`, "E_USD_INVALID_JOINT_REFERENCE");
|
|
3932
|
-
if (!["fixed", "revolute", "prismatic"].includes(v.jointType))
|
|
3933
|
-
throw Y(`Unsupported USD joint type ${v.jointType}: ${v.path}`, "E_USD_UNSUPPORTED_JOINT");
|
|
3934
|
-
if (g.has(v.body1)) throw Y(`USD rigid body has multiple parent joints: ${v.body1}`, "E_USD_MULTIPLE_PARENTS");
|
|
3935
|
-
g.set(v.body1, v), v.body0 && v.collisionEnabled !== !0 && a.push(`<exclude body1="${Ee(v.body0)}" body2="${Ee(v.body1)}"/>`);
|
|
3936
|
-
}
|
|
3937
|
-
let _ = 0;
|
|
3938
|
-
const y = /* @__PURE__ */ new Set(), w = (v, B = new Pe()) => {
|
|
3939
|
-
var F, D, L, K, k;
|
|
3940
|
-
if (y.has(v)) throw Y(`USD joint graph contains a cycle at ${v}`, "E_USD_JOINT_CYCLE");
|
|
3941
|
-
y.add(v);
|
|
3942
|
-
const E = h.get(v), R = d.get(v), I = B.clone().invert().multiply(R), H = new j(), P = new fe();
|
|
3943
|
-
I.decompose(H, P, new j());
|
|
3944
|
-
const $ = g.get(v), J = [`<body name="${Ee(v)}" pos="${pe(H.toArray())}" quat="${Ne(P)}">`];
|
|
3945
|
-
if (!$ && !E.kinematicEnabled && J.push("<freejoint/>"), $ && [...E.velocity ?? [], ...E.angularVelocity ?? []].some((M) => M !== 0))
|
|
3946
|
-
throw Y(`Constrained USD initial velocity cannot be projected reliably: ${v}`, "E_USD_CONSTRAINED_INITIAL_VELOCITY");
|
|
3947
|
-
if (!$ && !E.kinematicEnabled) {
|
|
3948
|
-
const M = new j(...E.velocity ?? [0, 0, 0]).multiplyScalar(i).applyQuaternion(e.scene.quaternion), V = new j(...E.angularVelocity ?? [0, 0, 0]).multiplyScalar(Math.PI / 180).applyQuaternion(e.scene.quaternion).applyQuaternion(new fe().setFromRotationMatrix(R).invert());
|
|
3949
|
-
p.push({ body: v, velocity: [...M.toArray(), ...V.toArray()] });
|
|
3950
|
-
}
|
|
3951
|
-
if ($ && $.jointType !== "fixed") {
|
|
3952
|
-
const M = $.jointType === "revolute" ? "hinge" : "slide", V = xn($.axis).applyQuaternion($e($.localRot1 ?? [1, 0, 0, 0])), Z = M === "hinge" ? Math.PI / 180 : i, q = $.body0 ? B : e.scene.matrixWorld.clone();
|
|
3953
|
-
if (!$.body0) {
|
|
3954
|
-
const _e = new j(), Te = new fe();
|
|
3955
|
-
q.decompose(_e, Te, new j()), q.compose(_e, Te, new j(1, 1, 1));
|
|
3956
|
-
}
|
|
3957
|
-
const z = new fe().setFromRotationMatrix(q), ie = new fe().setFromRotationMatrix(R), ne = z.clone().multiply($e($.localRot0 ?? [1, 0, 0, 0])).invert().multiply(ie).multiply($e($.localRot1 ?? [1, 0, 0, 0]));
|
|
3958
|
-
let he = 0;
|
|
3959
|
-
if (M === "hinge") {
|
|
3960
|
-
const _e = $.axis === "Y" ? ne.y : $.axis === "Z" ? ne.z : ne.x;
|
|
3961
|
-
he = 2 * Math.atan2(_e, ne.w), he = Math.atan2(Math.sin(he), Math.cos(he));
|
|
3962
|
-
} else {
|
|
3963
|
-
const _e = new j(...$.localPos0).multiplyScalar(i).applyMatrix4(q);
|
|
3964
|
-
he = new j(...$.localPos1).multiplyScalar(i).applyMatrix4(R).sub(_e).dot(V.clone().applyQuaternion(ie));
|
|
3965
|
-
}
|
|
3966
|
-
const xt = Number.isFinite($.lowerLimit) && Number.isFinite($.upperLimit) && Math.abs($.lowerLimit) < 1e20 && Math.abs($.upperLimit) < 1e20, Cn = xt && $.lowerLimit < $.upperLimit, Ke = f * (M === "slide" ? i : i * i), ot = Qe(e, $.path, `physxJointAxis:${M === "slide" ? "linear" : "angular"}:dynamicFrictionEffort`), Dn = typeof ot == "number" && Number.isFinite(ot) ? ot * Ke : 0;
|
|
3967
|
-
J.push(`<joint name="${Ee($.path)}" type="${M}" pos="${pe($.localPos1.map((_e) => _e * i))}" axis="${pe(V.toArray())}" ref="${he}" ${Cn ? `range="${$.lowerLimit * Z} ${$.upperLimit * Z}"` : 'limited="false"'} frictionloss="${Dn}" armature="0.00001"/>`), xt && $.lowerLimit === $.upperLimit && o.push(`<joint joint1="${Ee($.path)}" polycoef="${$.lowerLimit * Z - he} 0 0 0 0"/>`);
|
|
3968
|
-
const ye = $.drive;
|
|
3969
|
-
if (ye && ((ye.stiffness ?? 0) !== 0 || (ye.damping ?? 0) !== 0)) {
|
|
3970
|
-
if (ye.type === "acceleration") throw Y(`Unsupported USD acceleration drive: ${$.path}`, "E_USD_UNSUPPORTED_DRIVE");
|
|
3971
|
-
const _e = (ye.stiffness ?? 0) * Ke / Z, Te = (ye.damping ?? 0) * Ke / Z, He = ye.maxForce == null ? null : ye.maxForce * Ke;
|
|
3972
|
-
u.push(`<general joint="${Ee($.path)}" gainprm="1" biastype="affine" biasprm="0 ${-_e} ${-Te}" ${He != null && Number.isFinite(He) ? `forcelimited="true" forcerange="${-He} ${He}"` : ""}/>`), l.push(_e * (ye.targetPosition ?? 0) * Z + Te * (ye.targetVelocity ?? 0) * Z);
|
|
3973
|
-
}
|
|
3974
|
-
}
|
|
3975
|
-
const T = E.mass;
|
|
3976
|
-
if ((T == null ? void 0 : T.mass) != null && (!Number.isFinite(T.mass) || T.mass < 0)) throw Y(`USD rigid body mass must be finite and non-negative: ${v}`, "E_USD_INVALID_MASS");
|
|
3977
|
-
let se = !1;
|
|
3978
|
-
if ((T == null ? void 0 : T.mass) != null && T.mass > 0 && ((F = T.centerOfMass) == null ? void 0 : F.length) === 3 && T.centerOfMass.every(Number.isFinite) && ((D = T.diagonalInertia) == null ? void 0 : D.length) === 3 && T.diagonalInertia.every((M) => Number.isFinite(M) && M > 0) && ((L = T.principalAxes) == null ? void 0 : L.length) === 4 && T.principalAxes.every(Number.isFinite))
|
|
3979
|
-
se = !0, J.push(`<inertial mass="${T.mass * f}" pos="${pe(T.centerOfMass.map((M) => M * i))}" quat="${Ne($e(T.principalAxes))}" diaginertia="${pe(T.diagonalInertia.map((M) => M * f * i * i))}"/>`);
|
|
3980
|
-
else {
|
|
3981
|
-
if ((K = T == null ? void 0 : T.diagonalInertia) != null && K.some((M) => M > 0))
|
|
3982
|
-
throw Y(`USD rigid body has incomplete explicit inertia: ${v}`, "E_USD_PARTIAL_INERTIA");
|
|
3983
|
-
if ((T == null ? void 0 : T.mass) != null && T.mass > 0) {
|
|
3984
|
-
if ((k = T.centerOfMass) != null && k.every(Number.isFinite) && T.centerOfMass.some((M) => M !== 0)) throw Y(`Custom center of mass requires explicit inertia: ${v}`, "E_USD_PARTIAL_INERTIA");
|
|
3985
|
-
c.push({ body: v, mass: T.mass * f });
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
const A = e.data.physics.colliders.filter((M) => M.enabled && M.bodyPath === v);
|
|
3989
|
-
if (!A.length && !se) throw Y(`USD rigid body has no authored collision geometry: ${v}`, "E_USD_MISSING_COLLISION_GEOMETRY");
|
|
3990
|
-
for (const M of A) {
|
|
3991
|
-
const V = e.data.physics.materials.find((ne) => ne.path === M.material), Z = (T == null ? void 0 : T.density) != null && T.density > 0 ? T.density : V == null ? void 0 : V.density, q = Z != null && Z > 0 ? Z * f / i ** 3 : 1e3, z = (V == null ? void 0 : V.dynamicFriction) ?? 0.4, ie = `density="${q}" group="3" contype="1" conaffinity="1" friction="${z} 0.01 0.0002"`;
|
|
3992
|
-
J.push(tn(e, M, v, R, _++, r, ie));
|
|
3993
|
-
}
|
|
3994
|
-
for (const [M, V] of g) V.body0 === v && J.push(w(M, R));
|
|
3995
|
-
return J.push("</body>"), J.join("");
|
|
3996
|
-
}, m = e.data.physics.colliders.filter((v) => v.enabled && !v.bodyPath), U = m.map((v) => {
|
|
3997
|
-
const B = e.data.physics.materials.find((H) => H.path === v.material), E = (B == null ? void 0 : B.density) != null && B.density > 0 ? B.density * f / i ** 3 : 1e3, R = (B == null ? void 0 : B.dynamicFriction) ?? 0.4, I = `density="${E}" group="3" contype="1" conaffinity="1" friction="${R} 0.01 0.0002"`;
|
|
3998
|
-
return tn(e, v, "", new Pe(), _++, r, I);
|
|
3999
|
-
}).join(""), b = Jr(e, t, m) ? `<geom name="__viewer_default_ground__" type="plane" pos="0 0 ${Zr(e, t)}" size="1 1 0.1" group="3" contype="1" conaffinity="1" friction="0.8 0.01 0.0002"/>` : "", x = [...h.keys()].filter((v) => {
|
|
4000
|
-
var B;
|
|
4001
|
-
return !((B = g.get(v)) != null && B.body0);
|
|
4002
|
-
}).map((v) => w(v)).join("");
|
|
4003
|
-
if (y.size !== h.size) throw Y("USD joint graph contains unreachable bodies or a cycle.", "E_USD_UNREACHABLE_BODIES");
|
|
4004
|
-
if (e.data.physics.scenes.length > 1) throw Y("Multiple USD PhysicsScene prims are not supported.", "E_USD_MULTIPLE_PHYSICS_SCENES");
|
|
4005
|
-
const O = e.data.physics.scenes[0], C = O != null && O.gravityDirection && O.gravityMagnitude != null && O.gravityMagnitude >= 0 ? new j(...O.gravityDirection).normalize().multiplyScalar(O.gravityMagnitude * i).applyQuaternion(e.scene.quaternion) : new j(0, 0, -9.81);
|
|
4006
|
-
return {
|
|
4007
|
-
// Do not inflate contact surfaces across authored clearances. PhysX contactOffset
|
|
4008
|
-
// is not a MuJoCo force-generating margin and must not be copied as one.
|
|
4009
|
-
format: "mjcf",
|
|
4010
|
-
files: /* @__PURE__ */ new Map(),
|
|
4011
|
-
initialControls: l,
|
|
4012
|
-
initialVelocities: p,
|
|
4013
|
-
massOverrides: c,
|
|
4014
|
-
xml: `<mujoco><compiler angle="radian" autolimits="true"/><option integrator="implicitfast" gravity="${pe(C.toArray())}"><flag filterparent="disable"/></option><default><geom margin="0" solref="0.004 1"/></default>${r.length ? `<asset>${r.join("")}</asset>` : ""}<worldbody>${b}${U}${x}</worldbody>${a.length ? `<contact>${a.join("")}</contact>` : ""}${o.length ? `<equality>${o.join("")}</equality>` : ""}${u.length ? `<actuator>${u.join("")}</actuator>` : ""}</mujoco>`
|
|
4015
|
-
};
|
|
4016
|
-
}
|
|
4017
|
-
function Jr(e, t, n = e.data.physics.colliders.filter((s) => s.enabled && !s.bodyPath)) {
|
|
4018
|
-
if (!t.length || n.some((c) => c.typeName.toLowerCase().includes("plane"))) return !1;
|
|
4019
|
-
const s = wt(e, e.data.physics.colliders.filter(
|
|
4020
|
-
(c) => c.enabled && c.bodyPath && t.includes(c.bodyPath)
|
|
4021
|
-
));
|
|
4022
|
-
if (s.isEmpty()) return n.length === 0;
|
|
4023
|
-
const r = Math.max(s.max.x - s.min.x, 1e-6), o = Math.max(s.max.y - s.min.y, 1e-6), a = Math.max(r, o, s.max.z - s.min.z) * 0.05;
|
|
4024
|
-
return !n.some((c) => {
|
|
4025
|
-
const u = wt(e, [c]);
|
|
4026
|
-
if (u.isEmpty()) return !1;
|
|
4027
|
-
const l = u.max.x >= s.min.x && u.min.x <= s.max.x, p = u.max.y >= s.min.y && u.min.y <= s.max.y;
|
|
4028
|
-
return l && p && u.max.z <= s.min.z + a;
|
|
4029
|
-
});
|
|
4030
|
-
}
|
|
4031
|
-
function Zr(e, t) {
|
|
4032
|
-
const n = wt(e, e.data.physics.colliders.filter(
|
|
4033
|
-
(r) => r.enabled && r.bodyPath && t.includes(r.bodyPath)
|
|
4034
|
-
)), s = n.isEmpty() ? 0 : n.min.z;
|
|
4035
|
-
return Number.isFinite(s) ? String(s) : "0";
|
|
4036
|
-
}
|
|
4037
|
-
function wt(e, t) {
|
|
4038
|
-
const n = new et();
|
|
4039
|
-
for (const s of t) {
|
|
4040
|
-
const r = e.index.objectsByPath.get(s.path);
|
|
4041
|
-
r && n.union(new et().setFromObject(r));
|
|
4042
|
-
}
|
|
4043
|
-
return n;
|
|
4044
|
-
}
|
|
4045
|
-
function xn(e) {
|
|
4046
|
-
return e === "Y" ? new j(0, 1, 0) : e === "Z" ? new j(0, 0, 1) : new j(1, 0, 0);
|
|
4047
|
-
}
|
|
4048
|
-
function tn(e, t, n, s, r, o, a) {
|
|
4049
|
-
const c = e.index.objectsByPath.get(t.path);
|
|
4050
|
-
if (!c) throw Y(`USD collider node is missing: ${t.path}`, "E_USD_MISSING_COLLISION_GEOMETRY");
|
|
4051
|
-
const u = s.clone().invert().multiply(c.matrixWorld), l = new j(), p = new fe(), i = new j();
|
|
4052
|
-
u.decompose(l, p, i);
|
|
4053
|
-
const f = t.typeName.replace(/^UsdGeom/, "").toLowerCase(), h = (d, g) => {
|
|
4054
|
-
const _ = Qe(e, t.path, d);
|
|
4055
|
-
return typeof _ == "number" ? _ : g;
|
|
4056
|
-
};
|
|
4057
|
-
if (f.includes("cube")) {
|
|
4058
|
-
const d = Math.abs(h("size", 2)) / 2;
|
|
4059
|
-
return `<geom type="box" pos="${pe(l.toArray())}" quat="${Ne(p)}" size="${pe([Math.abs(i.x) * d, Math.abs(i.y) * d, Math.abs(i.z) * d])}" ${a}/>`;
|
|
4060
|
-
}
|
|
4061
|
-
if (f.includes("plane")) {
|
|
4062
|
-
if (n) throw Y(`USD plane collider requires a static world owner: ${t.path}`, "E_USD_UNSUPPORTED_GEOMETRY");
|
|
4063
|
-
const d = String(Qe(e, t.path, "axis") ?? "Z").toUpperCase(), _ = { X: new j(1, 0, 0), Y: new j(0, 1, 0), Z: new j(0, 0, 1) }[d];
|
|
4064
|
-
if (!_) throw Y(`Unsupported USD plane axis: ${d}`, "E_USD_UNSUPPORTED_GEOMETRY");
|
|
4065
|
-
const y = p.clone().multiply(new fe().setFromUnitVectors(new j(0, 0, 1), _));
|
|
4066
|
-
return `<geom type="plane" pos="${pe(l.toArray())}" quat="${Ne(y)}" size="1 1 0.1" ${a}/>`;
|
|
4067
|
-
}
|
|
4068
|
-
if (f.includes("cone"))
|
|
4069
|
-
throw Y(`MuJoCo has no analytic cone geom; a validated mesh conversion is required: ${t.path}`, "E_USD_UNSUPPORTED_GEOMETRY");
|
|
4070
|
-
if (f.includes("sphere")) {
|
|
4071
|
-
const d = [Math.abs(i.x), Math.abs(i.y), Math.abs(i.z)];
|
|
4072
|
-
if (Math.max(...d) - Math.min(...d) > 1e-6) throw Y(`USD sphere collider does not support non-uniform scale: ${t.path}`, "E_USD_NONUNIFORM_RADIAL_SCALE");
|
|
4073
|
-
return `<geom type="sphere" pos="${pe(l.toArray())}" quat="${Ne(p)}" size="${d[0] * h("radius", 1)}" ${a}/>`;
|
|
4074
|
-
}
|
|
4075
|
-
if (f.includes("cylinder") || f.includes("capsule")) {
|
|
4076
|
-
const d = String(Qe(e, t.path, "axis") ?? "Z").toUpperCase(), g = { X: 0, Y: 1, Z: 2 }[d];
|
|
4077
|
-
if (g === void 0) throw Y(`Unsupported USD collider axis: ${d}`, "E_USD_UNSUPPORTED_GEOMETRY");
|
|
4078
|
-
const _ = [Math.abs(i.x), Math.abs(i.y), Math.abs(i.z)], y = _.filter((S, x) => x !== g);
|
|
4079
|
-
if (Math.abs(y[0] - y[1]) > 1e-6) throw Y(`USD ${t.typeName} collider does not support non-uniform radial scale: ${t.path}`, "E_USD_NONUNIFORM_RADIAL_SCALE");
|
|
4080
|
-
const w = new j(...{ X: [1, 0, 0], Y: [0, 1, 0], Z: [0, 0, 1] }[d]), m = p.clone().multiply(new fe().setFromUnitVectors(new j(0, 0, 1), w)), U = h("radius", 1) * y[0], b = h("height", 2) * _[g] / 2;
|
|
4081
|
-
return `<geom type="${f.includes("capsule") ? "capsule" : "cylinder"}" pos="${pe(l.toArray())}" quat="${Ne(m)}" size="${U} ${b}" ${a}/>`;
|
|
4082
|
-
}
|
|
4083
|
-
if (f.includes("mesh")) {
|
|
4084
|
-
if (t.approximation && !["none", "convexHull"].includes(t.approximation)) throw Y(`USD mesh approximation cannot be mapped exactly: ${t.path}`, "E_USD_UNSUPPORTED_APPROXIMATION");
|
|
4085
|
-
const d = [];
|
|
4086
|
-
if (c.traverse((m) => {
|
|
4087
|
-
m instanceof me && d.push(m);
|
|
4088
|
-
}), !d.length) throw Y(`USD collider has no mesh geometry: ${t.path}`, "E_USD_MISSING_COLLISION_GEOMETRY");
|
|
4089
|
-
const g = [], _ = [];
|
|
4090
|
-
let y = 0;
|
|
4091
|
-
for (const m of d) {
|
|
4092
|
-
const U = m.geometry.getAttribute("position");
|
|
4093
|
-
for (let S = 0; S < U.count; S++) {
|
|
4094
|
-
const x = new j().fromBufferAttribute(U, S).applyMatrix4(s.clone().invert().multiply(m.matrixWorld));
|
|
4095
|
-
g.push(x.x, x.y, x.z);
|
|
4096
|
-
}
|
|
4097
|
-
const b = m.geometry.index;
|
|
4098
|
-
for (let S = 0; S < (b ? b.count : U.count); S += 3) _.push(y + (b ? b.getX(S) : S), y + (b ? b.getX(S + 1) : S + 1), y + (b ? b.getX(S + 2) : S + 2));
|
|
4099
|
-
y += U.count;
|
|
4100
|
-
}
|
|
4101
|
-
const w = `collision_${r}`;
|
|
4102
|
-
return o.push(`<mesh name="${w}" vertex="${pe(g)}" face="${pe(_)}"/>`), `<geom type="mesh" mesh="${w}" ${a}/>`;
|
|
4103
|
-
}
|
|
4104
|
-
throw Y(`Unsupported USD collider geometry: ${t.typeName}`, "E_USD_UNSUPPORTED_GEOMETRY");
|
|
4105
|
-
}
|
|
4106
|
-
function Qr(e) {
|
|
4107
|
-
const t = e.stage.GetPseudoRoot();
|
|
4108
|
-
try {
|
|
4109
|
-
const n = Number(t.GetMetadata("metersPerUnit") ?? 0.01), s = Number(t.GetMetadata("kilogramsPerUnit") ?? 1);
|
|
4110
|
-
if (!Number.isFinite(n) || n <= 0) throw Y("USD metersPerUnit must be finite and positive.", "E_USD_INVALID_UNITS");
|
|
4111
|
-
if (!Number.isFinite(s) || s <= 0) throw Y("USD kilogramsPerUnit must be finite and positive.", "E_USD_INVALID_UNITS");
|
|
4112
|
-
return { metersPerUnit: n, kilogramsPerUnit: s };
|
|
4113
|
-
} finally {
|
|
4114
|
-
t.delete();
|
|
4115
|
-
}
|
|
4116
|
-
}
|
|
4117
|
-
function $e(e) {
|
|
4118
|
-
const [t = 1, n = 0, s = 0, r = 0] = e;
|
|
4119
|
-
return new fe(n, s, r, t).normalize();
|
|
4120
|
-
}
|
|
4121
|
-
function pe(e) {
|
|
4122
|
-
return e.join(" ");
|
|
4123
|
-
}
|
|
4124
|
-
function Ne(e) {
|
|
4125
|
-
return `${e.w} ${e.x} ${e.y} ${e.z}`;
|
|
4126
|
-
}
|
|
4127
|
-
function Qe(e, t, n) {
|
|
4128
|
-
var u, l;
|
|
4129
|
-
const s = e.stage;
|
|
4130
|
-
if (!s || !((l = (u = e.pxr) == null ? void 0 : u.Sdf) != null && l.Path)) return null;
|
|
4131
|
-
const r = new e.pxr.Sdf.Path(t), o = s.GetPrimAtPath(r), a = o.GetAttribute(n), c = e.pxr.Usd.TimeCode.Default();
|
|
4132
|
-
try {
|
|
4133
|
-
return a.IsValid() ? a.Get(c) : null;
|
|
4134
|
-
} finally {
|
|
4135
|
-
c.delete(), a.delete(), o.delete(), r.delete();
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
async function eo(e, t) {
|
|
4139
|
-
var n;
|
|
4140
|
-
if (e.url)
|
|
4141
|
-
try {
|
|
4142
|
-
return new URL(e.url, ((n = globalThis.location) == null ? void 0 : n.href) ?? e.baseUrl ?? void 0).href;
|
|
4143
|
-
} catch {
|
|
4144
|
-
return e.url;
|
|
4145
|
-
}
|
|
4146
|
-
return e.resolve(t);
|
|
4147
|
-
}
|
|
4148
|
-
async function to(e) {
|
|
4149
|
-
const t = e.url ?? await e.resolve(e.entryPath ?? ""), n = await fetch(t, { signal: e.signal });
|
|
4150
|
-
if (!n.ok) throw Y(`USD request failed (${n.status}): ${t}`, n.status === 401 || n.status === 403 ? "E_ASSET_AUTH" : "E_ASSET_FETCH");
|
|
4151
|
-
return n.blob();
|
|
4152
|
-
}
|
|
4153
|
-
function Ee(e) {
|
|
4154
|
-
return e.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">");
|
|
4155
|
-
}
|
|
4156
|
-
function Y(e, t) {
|
|
4157
|
-
return Object.assign(new Error(e), { code: t });
|
|
4158
|
-
}
|
|
4159
|
-
function lt() {
|
|
4160
|
-
return Object.assign(new Error("USD load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
4161
|
-
}
|
|
4162
|
-
export {
|
|
4163
|
-
Hr as buildUsdVisualReferenceOwners,
|
|
4164
|
-
en as compileUsdCollisionOverlay,
|
|
4165
|
-
An as compileUsdCollisionVisual,
|
|
4166
|
-
Yr as compileUsdPhysics,
|
|
4167
|
-
Kr as compileUsdVisual,
|
|
4168
|
-
jr as firstUsdVisualWarning,
|
|
4169
|
-
co as isUsdPhysicsFallbackEligible,
|
|
4170
|
-
uo as loadUsdSimulation,
|
|
4171
|
-
qr as parseUsdReferenceMetadata,
|
|
4172
|
-
Mn as resolveUsdJoints,
|
|
4173
|
-
Jr as shouldInjectUsdDefaultGround
|
|
4174
|
-
};
|