@nebula-spatial/viewer 0.4.4 → 0.4.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 +60 -0
- package/README.md +83 -4
- package/USD-VISUAL-MATERIAL-SUPPORT.md +51 -0
- package/dist/assets/types.d.ts +30 -11
- package/dist/{index-D-o1ODOX.js → index-BMpPLW5X.js} +2374 -1783
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/inspection/types.d.ts +13 -0
- package/dist/mjcf-visual-BKHVxVrs.js +73 -0
- package/dist/mujoco-runtime-7xiBQNJm.js +324 -0
- package/dist/session-BaKbYHiJ.js +809 -0
- package/dist/{session-c7xBLA4J.js → session-DN0DckL_.js} +152 -163
- package/dist/{stage-D113SHD8.js → stage-D1FYXbPa.js} +132 -71
- package/dist/types.d.ts +11 -0
- package/dist/urdf-session-Dp4X1_x8.js +3247 -0
- package/dist/usd-session-CxjXcMVI.js +1907 -0
- package/dist/xacro-BcGEW8o5.js +1537 -0
- package/package.json +4 -2
- package/dist/mjcf-visual-M1lmyjvw.js +0 -63
- package/dist/mujoco-runtime-C29PXDOl.js +0 -258
- package/dist/session-Cz6qHYMc.js +0 -676
- package/dist/urdf-session-AP-cMuwd.js +0 -3001
- package/dist/usd-session-CmSdkRw9.js +0 -1192
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { DataTexture as N, LinearMipmapLinearFilter as
|
|
2
|
-
import { DRACOLoader as
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
import { S as
|
|
5
|
-
import { TGALoader as
|
|
6
|
-
import { FBXLoader as
|
|
7
|
-
import { unzlibSync as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
if (!e || !t || e * t >
|
|
1
|
+
import { DataTexture as N, LinearMipmapLinearFilter as re, LinearFilter as se, LoadingManager as oe, Loader as ae, Texture as X, TextureLoader as ie, LinearSRGBColorSpace as G, SRGBColorSpace as le, RGBAFormat as K, UnsignedByteType as J, NoColorSpace as ce, Mesh as ue, MeshPhysicalMaterial as Z, MeshPhongMaterial as k, MeshLambertMaterial as fe, Color as C, Group as pe, Box3 as de, Vector3 as he } from "three";
|
|
2
|
+
import { DRACOLoader as me } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
3
|
+
import { GLTFLoader as ge } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
import { d as Y, a as q, S as ye, b as j } from "./stage-D1FYXbPa.js";
|
|
5
|
+
import { TGALoader as we } from "three/examples/jsm/loaders/TGALoader.js";
|
|
6
|
+
import { FBXLoader as be } from "three/examples/jsm/loaders/FBXLoader.js";
|
|
7
|
+
import { unzlibSync as xe } from "three/examples/jsm/libs/fflate.module.js";
|
|
8
|
+
const Ee = 16 * 1024 * 1024;
|
|
9
|
+
function Q(e, t) {
|
|
10
|
+
if (!e || !t || e * t > Ee) throw new Error("Invalid or oversized image dimensions (maximum 16M pixels).");
|
|
11
11
|
}
|
|
12
12
|
function B(e, t, n) {
|
|
13
13
|
if (t < 0 || n < 0 || t + n > e.length) throw new Error("Truncated image payload.");
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function Me(e) {
|
|
16
16
|
const t = new Uint8Array(e);
|
|
17
17
|
B(t, 0, 18);
|
|
18
18
|
const n = new DataView(e), s = t[2], r = t[16], c = n.getUint16(12, !0), i = n.getUint16(14, !0);
|
|
19
|
-
if (
|
|
19
|
+
if (Q(c, i), t[1] !== 0 || ![2, 3, 10, 11].includes(s) || !([3, 11].includes(s) ? [8, 16] : [24, 32]).includes(r) || t[17] & 192)
|
|
20
20
|
throw new Error("Unsupported TGA: require non-interleaved 24/32-bit true-color or 8/16-bit grayscale.");
|
|
21
21
|
let p = 18 + t[0];
|
|
22
22
|
B(t, 18, t[0]);
|
|
@@ -32,19 +32,19 @@ function ve(e) {
|
|
|
32
32
|
B(t, p, u), p += u, o += l;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
return { data: new
|
|
35
|
+
return { data: new we().parse(e).data, width: c, height: i };
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function z(e) {
|
|
38
38
|
const t = e >>> 11 & 31, n = e >>> 5 & 63, s = e & 31;
|
|
39
39
|
return [t << 3 | t >>> 2, n << 2 | n >>> 4, s << 3 | s >>> 2, 255];
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function ve(e) {
|
|
42
42
|
const t = new Uint8Array(e);
|
|
43
43
|
B(t, 0, 128);
|
|
44
44
|
const n = new DataView(e), s = (l) => n.getUint32(l, !0);
|
|
45
45
|
if (s(0) !== 542327876 || s(4) !== 124 || s(76) !== 32) throw new Error("Invalid DDS header.");
|
|
46
46
|
const r = s(16), c = s(12);
|
|
47
|
-
if (
|
|
47
|
+
if (Q(r, c), s(112) & 2162176 || s(24) > 1) throw new Error("DDS cubemap/volume textures are unsupported.");
|
|
48
48
|
const i = s(80), p = String.fromCharCode(...t.subarray(84, 88)), d = (i & 4) !== 0;
|
|
49
49
|
if (d && !["DXT1", "DXT3", "DXT5"].includes(p)) throw new Error(`Unsupported DDS FourCC: ${p}. Require DXT1/DXT3/DXT5.`);
|
|
50
50
|
const y = new Uint8Array(r * c * 4);
|
|
@@ -55,41 +55,41 @@ function Se(e) {
|
|
|
55
55
|
if (b < r * S) throw new Error("Invalid DDS row pitch.");
|
|
56
56
|
B(t, 128, b * c);
|
|
57
57
|
for (let v = 0; v < c; v++) for (let D = 0; D < r; D++) {
|
|
58
|
-
const
|
|
59
|
-
y[T] = t[
|
|
58
|
+
const U = 128 + v * b + D * S, T = (v * r + D) * 4;
|
|
59
|
+
y[T] = t[U + (u === 255 ? 0 : 2)], y[T + 1] = t[U + 1], y[T + 2] = t[U + (f === 255 ? 0 : 2)], y[T + 3] = M && i & 1 ? t[U + 3] : 255;
|
|
60
60
|
}
|
|
61
61
|
return { data: y, width: r, height: c };
|
|
62
62
|
}
|
|
63
63
|
const m = p === "DXT1" ? 8 : 16, o = Math.ceil(r / 4), a = Math.ceil(c / 4);
|
|
64
64
|
B(t, 128, o * a * m);
|
|
65
65
|
for (let l = 0; l < a; l++) for (let u = 0; u < o; u++) {
|
|
66
|
-
const w = 128 + (l * o + u) * m, f = w + (m === 8 ? 0 : 8), M = n.getUint16(f, !0), S = n.getUint16(f + 2, !0), b = [
|
|
66
|
+
const w = 128 + (l * o + u) * m, f = w + (m === 8 ? 0 : 8), M = n.getUint16(f, !0), S = n.getUint16(f + 2, !0), b = [z(M), z(S)], v = p !== "DXT1" || M > S;
|
|
67
67
|
b.push([0, 1, 2].map((T) => Math.floor(v ? (2 * b[0][T] + b[1][T]) / 3 : (b[0][T] + b[1][T]) / 2)).concat(255)), b.push(v ? [0, 1, 2].map((T) => Math.floor((b[0][T] + 2 * b[1][T]) / 3)).concat(255) : [0, 0, 0, 0]);
|
|
68
|
-
const D = s(f + 4),
|
|
68
|
+
const D = s(f + 4), U = [t[w], t[w + 1]];
|
|
69
69
|
if (p === "DXT5") {
|
|
70
|
-
const T =
|
|
71
|
-
for (let g = 1; g <= T; g++)
|
|
72
|
-
T === 4 &&
|
|
70
|
+
const T = U[0] > U[1] ? 6 : 4;
|
|
71
|
+
for (let g = 1; g <= T; g++) U.push(Math.floor(((T + 1 - g) * U[0] + g * U[1]) / (T + 1)));
|
|
72
|
+
T === 4 && U.push(0, 255);
|
|
73
73
|
}
|
|
74
74
|
for (let T = 0; T < 16; T++) {
|
|
75
75
|
const g = u * 4 + T % 4, x = l * 4 + Math.floor(T / 4);
|
|
76
76
|
if (g >= r || x >= c) continue;
|
|
77
77
|
const E = b[D >>> 2 * T & 3], A = (x * r + g) * 4;
|
|
78
78
|
if (y.set(E, A), p === "DXT3" && (y[A + 3] = (t[w + Math.floor(T / 2)] >>> T % 2 * 4 & 15) * 17), p === "DXT5") {
|
|
79
|
-
const I = T * 3, h = w + 2 + Math.floor(I / 8),
|
|
80
|
-
y[A + 3] = R
|
|
79
|
+
const I = T * 3, h = w + 2 + Math.floor(I / 8), R = t[h] | (h + 1 < w + 8 ? t[h + 1] : 0) << 8;
|
|
80
|
+
y[A + 3] = U[R >>> I % 8 & 7];
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
return { data: y, width: r, height: c };
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
const n = t === "tga" ?
|
|
86
|
+
function Se(e, t) {
|
|
87
|
+
const n = t === "tga" ? Me(e) : ve(e), s = new Uint8Array(n.data.length), r = n.width * 4;
|
|
88
88
|
for (let i = 0; i < n.height; i++) s.set(n.data.subarray(i * r, (i + 1) * r), (n.height - 1 - i) * r);
|
|
89
89
|
const c = new N(s, n.width, n.height);
|
|
90
|
-
return c.flipY = !1, c.generateMipmaps = !0, c.minFilter =
|
|
90
|
+
return c.flipY = !1, c.generateMipmaps = !0, c.minFilter = re, c.magFilter = se, c.needsUpdate = !0, c;
|
|
91
91
|
}
|
|
92
|
-
async function
|
|
92
|
+
async function Te(e, t, n) {
|
|
93
93
|
t.signal.throwIfAborted();
|
|
94
94
|
const s = new AbortController(), r = s.signal, c = () => s.abort(t.signal.reason);
|
|
95
95
|
t.signal.addEventListener("abort", c, { once: !0 });
|
|
@@ -103,21 +103,21 @@ async function Ae(e, t, n) {
|
|
|
103
103
|
}, (v) => {
|
|
104
104
|
r.removeEventListener("abort", b), S || (S = !0, M(v));
|
|
105
105
|
});
|
|
106
|
-
}), p = [], d = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), m = new
|
|
106
|
+
}), p = [], d = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), m = new oe(), o = async (u) => {
|
|
107
107
|
var D;
|
|
108
108
|
if (/^(blob:|data:)/i.test(u))
|
|
109
109
|
return u.startsWith("blob:") && y.add(u), u;
|
|
110
|
-
const w = [...new Set([...n.textures.values()].map((
|
|
111
|
-
let S = w.filter((
|
|
112
|
-
if (S.length || (S = w.filter((
|
|
110
|
+
const w = [...new Set([...n.textures.values()].map((U) => U.path).filter(Boolean))], f = (U) => U.replaceAll("\\", "/").replace(/^\.\//, ""), M = f(u);
|
|
111
|
+
let S = w.filter((U) => f(U) === M);
|
|
112
|
+
if (S.length || (S = w.filter((U) => f(U).split("/").pop() === M.split("/").pop())), S.length > 1) throw new Error(`FBX texture path is ambiguous: ${u}`);
|
|
113
113
|
const b = f(S[0] ?? u), v = t.original;
|
|
114
114
|
if (typeof v == "object" && v !== null && "kind" in v && v.kind === "files") {
|
|
115
|
-
const
|
|
115
|
+
const U = ((D = t.entryPath) == null ? void 0 : D.replace(/[^/]*$/, "")) ?? "", T = (E) => {
|
|
116
116
|
const A = [];
|
|
117
117
|
for (const I of f(E).split("/"))
|
|
118
118
|
I === ".." ? A.pop() : I && I !== "." && A.push(I);
|
|
119
119
|
return A.join("/");
|
|
120
|
-
}, g = v.files.filter((E) => T(E.path) === T(
|
|
120
|
+
}, g = v.files.filter((E) => T(E.path) === T(U + b));
|
|
121
121
|
if (g.length === 1) return t.resolve(g[0].path);
|
|
122
122
|
const x = v.files.filter((E) => T(E.path).split("/").pop() === b.split("/").pop());
|
|
123
123
|
if (x.length === 1) return t.resolve(x[0].path);
|
|
@@ -128,7 +128,7 @@ async function Ae(e, t, n) {
|
|
|
128
128
|
if (!t.baseUrl && !t.hasResourceResolver && !/^https?:/i.test(b)) throw new Error(`FBX external texture requires a file package or baseUrl: ${b}`);
|
|
129
129
|
return t.resolve(b);
|
|
130
130
|
};
|
|
131
|
-
class a extends
|
|
131
|
+
class a extends ae {
|
|
132
132
|
constructor(w) {
|
|
133
133
|
super(m), this.binaryFormat = w;
|
|
134
134
|
}
|
|
@@ -138,23 +138,23 @@ async function Ae(e, t, n) {
|
|
|
138
138
|
const v = (async () => {
|
|
139
139
|
const D = await i(o(w));
|
|
140
140
|
r.throwIfAborted();
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
141
|
+
const U = await fetch(D, { signal: r });
|
|
142
|
+
if (!U.ok) throw new Error(`FBX texture request failed (${U.status}): ${w}`);
|
|
143
143
|
if (this.binaryFormat) {
|
|
144
|
-
const g = await
|
|
144
|
+
const g = await U.arrayBuffer();
|
|
145
145
|
r.throwIfAborted();
|
|
146
146
|
let x;
|
|
147
147
|
try {
|
|
148
|
-
x =
|
|
148
|
+
x = Se(g, this.binaryFormat);
|
|
149
149
|
} catch (E) {
|
|
150
150
|
throw new Error(`FBX texture decode failed (${this.binaryFormat}): ${w}: ${String(E)}`, { cause: E });
|
|
151
151
|
}
|
|
152
152
|
b.image = x.image, b.flipY = x.flipY, b.generateMipmaps = x.generateMipmaps, b.minFilter = x.minFilter, b.magFilter = x.magFilter, b.format = x.format, b.type = x.type, x.dispose(), b.needsUpdate = !0, f == null || f(b);
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
-
const T = URL.createObjectURL(await
|
|
155
|
+
const T = URL.createObjectURL(await U.blob());
|
|
156
156
|
try {
|
|
157
|
-
const g = new
|
|
157
|
+
const g = new ie().loadAsync(T).catch((E) => {
|
|
158
158
|
const A = E instanceof Error ? `: ${E.message}` : "";
|
|
159
159
|
throw new Error(`FBX texture decode failed: ${w}${A}`, { cause: E });
|
|
160
160
|
}), x = await i(g, (E) => {
|
|
@@ -174,10 +174,10 @@ async function Ae(e, t, n) {
|
|
|
174
174
|
m.addHandler(/\.tga$/i, new a("tga")), m.addHandler(/\.dds$/i, new a("dds")), m.addHandler(/.*/, new a());
|
|
175
175
|
let l;
|
|
176
176
|
try {
|
|
177
|
-
return l = new
|
|
177
|
+
return l = new be(m).parse(e, ""), await Promise.all(p), t.signal.throwIfAborted(), { root: l, textures: d };
|
|
178
178
|
} catch (u) {
|
|
179
179
|
if (s.abort(u), await Promise.allSettled(p), l) {
|
|
180
|
-
const { disposeModelResources: w } = await import("./stage-
|
|
180
|
+
const { disposeModelResources: w } = await import("./stage-D1FYXbPa.js").then((f) => f.r);
|
|
181
181
|
w(l, d);
|
|
182
182
|
} else for (const w of d) w.dispose();
|
|
183
183
|
throw u;
|
|
@@ -186,59 +186,59 @@ async function Ae(e, t, n) {
|
|
|
186
186
|
for (const u of y) URL.revokeObjectURL(u);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
const P = "Kaydara FBX Binary \0",
|
|
190
|
-
function
|
|
189
|
+
const P = "Kaydara FBX Binary \0", Ae = /(?:^|[\r\n])\s*P:\s*"UpAxis"\s*,\s*"int"\s*,\s*"Integer"\s*,\s*""\s*,\s*(-?\d+)/i, Re = /(?:^|[\r\n])\s*P:\s*"UpAxisSign"\s*,\s*"int"\s*,\s*"Integer"\s*,\s*""\s*,\s*(-?\d+)/i;
|
|
190
|
+
function Fe(e) {
|
|
191
191
|
try {
|
|
192
|
-
const t = new Uint8Array(e), n =
|
|
192
|
+
const t = new Uint8Array(e), n = Ue(t) ? De(e) : Ie(new TextDecoder().decode(t));
|
|
193
193
|
return !n || n.sign !== 1 ? null : n.axis === 1 ? "y" : n.axis === 2 ? "z" : null;
|
|
194
194
|
} catch {
|
|
195
195
|
return null;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function Ue(e) {
|
|
199
199
|
if (e.byteLength < P.length) return !1;
|
|
200
200
|
for (let t = 0; t < P.length; t += 1)
|
|
201
201
|
if (e[t] !== P.charCodeAt(t)) return !1;
|
|
202
202
|
return !0;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function Ie(e) {
|
|
205
205
|
var r, c;
|
|
206
|
-
const t = Number.parseInt(((r =
|
|
206
|
+
const t = Number.parseInt(((r = Ae.exec(e)) == null ? void 0 : r[1]) ?? "", 10);
|
|
207
207
|
if (!Number.isInteger(t)) return null;
|
|
208
|
-
const n = (c =
|
|
208
|
+
const n = (c = Re.exec(e)) == null ? void 0 : c[1], s = n === void 0 ? 1 : Number.parseInt(n, 10);
|
|
209
209
|
return Number.isInteger(s) ? { axis: t, sign: s } : null;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function De(e) {
|
|
212
212
|
const t = new DataView(e);
|
|
213
213
|
if (t.byteLength < 27) return null;
|
|
214
214
|
const n = t.getUint32(23, !0) >= 7500;
|
|
215
215
|
let s = 27;
|
|
216
216
|
for (; s < t.byteLength; ) {
|
|
217
|
-
const r =
|
|
217
|
+
const r = _(t, s, n, !1);
|
|
218
218
|
if (!r) break;
|
|
219
|
-
if (r.name === "GlobalSettings") return
|
|
219
|
+
if (r.name === "GlobalSettings") return ee(t, r.childrenOffset, r.endOffset, n);
|
|
220
220
|
s = r.endOffset;
|
|
221
221
|
}
|
|
222
222
|
return null;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function ee(e, t, n, s) {
|
|
225
225
|
let r = t, c = null, i = 1;
|
|
226
226
|
for (; r < n; ) {
|
|
227
|
-
const p =
|
|
227
|
+
const p = _(e, r, s, !0);
|
|
228
228
|
if (!p) break;
|
|
229
229
|
if (p.name === "P") {
|
|
230
230
|
const [d, , , , y] = p.properties;
|
|
231
231
|
d === "UpAxis" && typeof y == "number" && (c = y), d === "UpAxisSign" && typeof y == "number" && (i = y);
|
|
232
232
|
}
|
|
233
233
|
if (p.childrenOffset < p.endOffset) {
|
|
234
|
-
const d =
|
|
234
|
+
const d = ee(e, p.childrenOffset, p.endOffset, s);
|
|
235
235
|
d && (c ?? (c = d.axis), i = d.sign);
|
|
236
236
|
}
|
|
237
237
|
r = p.endOffset;
|
|
238
238
|
}
|
|
239
239
|
return c === null ? null : { axis: c, sign: i };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function _(e, t, n, s) {
|
|
242
242
|
const r = n ? 25 : 13;
|
|
243
243
|
if (t + r > e.byteLength) return null;
|
|
244
244
|
const c = $(e, t, n), i = $(e, t + (n ? 8 : 4), n), p = $(e, t + (n ? 16 : 8), n), d = e.getUint8(t + (n ? 24 : 12));
|
|
@@ -249,7 +249,7 @@ function C(e, t, n, s) {
|
|
|
249
249
|
if (s) {
|
|
250
250
|
let u = m;
|
|
251
251
|
for (let w = 0; w < i; w += 1) {
|
|
252
|
-
const f =
|
|
252
|
+
const f = Oe(e, u);
|
|
253
253
|
if (l.push(f.value), u = f.nextOffset, u > o) return null;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
@@ -261,7 +261,7 @@ function $(e, t, n) {
|
|
|
261
261
|
if (s > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("FBX offset exceeds the safe integer range.");
|
|
262
262
|
return Number(s);
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function Oe(e, t) {
|
|
265
265
|
const n = String.fromCharCode(e.getUint8(t));
|
|
266
266
|
switch (n) {
|
|
267
267
|
case "Y":
|
|
@@ -294,10 +294,10 @@ function Be(e, t) {
|
|
|
294
294
|
throw new Error(`Unsupported FBX property type: ${n}`);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
const L = /* @__PURE__ */ new Set(["Definitions", "ObjectType", "PropertyTemplate", "Objects", "Material", "Properties70", "Connections", "Texture", "Video", "Geometry", "LayerElementUV", "LayeredTexture", "BlendModes", "Alphas"]),
|
|
298
|
-
function
|
|
299
|
-
var S, b, v, D,
|
|
300
|
-
const t = new Uint8Array(e), s = new TextDecoder().decode(t.subarray(0, 21)) === "Kaydara FBX Binary \0" ? Ce(e) :
|
|
297
|
+
const L = /* @__PURE__ */ new Set(["Definitions", "ObjectType", "PropertyTemplate", "Objects", "Material", "Properties70", "Connections", "Texture", "Video", "Geometry", "LayerElementUV", "LayeredTexture", "BlendModes", "Alphas"]), te = /* @__PURE__ */ new Set(["P", "C", "RelativeFilename", "FileName", "Filename", "ShadingModel", "UVSet", "Scaling", "Translation", "Rotation", "RotationPivot", "ScalingPivot", "Name", "UV", "a"]);
|
|
298
|
+
function Be(e) {
|
|
299
|
+
var S, b, v, D, U, T;
|
|
300
|
+
const t = new Uint8Array(e), s = new TextDecoder().decode(t.subarray(0, 21)) === "Kaydara FBX Binary \0" ? Ce(e) : _e(new TextDecoder().decode(t)), r = (g) => {
|
|
301
301
|
var x;
|
|
302
302
|
return new Map(
|
|
303
303
|
(((x = g == null ? void 0 : g.children.find((E) => E.name === "Properties70")) == null ? void 0 : x.children) ?? []).filter((E) => E.name === "P" && typeof E.values[0] == "string").map((E) => [E.values[0], E.values.slice(4)])
|
|
@@ -309,11 +309,11 @@ function _e(e) {
|
|
|
309
309
|
for (const g of y.filter((x) => x.name === "Texture")) {
|
|
310
310
|
const x = Number(g.values[0]), E = (v = d.find((F) => F.values[0] === "OO" && F.values[2] === x)) == null ? void 0 : v.values[1], A = y.find((F) => F.name === "Video" && F.values[0] === E), I = String(o(A, "RelativeFilename") || o(g, "RelativeFilename") || o(A, "Filename") || o(g, "FileName") || ""), h = r(g);
|
|
311
311
|
for (const F of ["Scaling", "Translation", "Rotation", "RotationPivot", "ScalingPivot"]) {
|
|
312
|
-
const O = (D = g.children.find((
|
|
312
|
+
const O = (D = g.children.find((ne) => ne.name === F)) == null ? void 0 : D.values;
|
|
313
313
|
O && h.set(F, O);
|
|
314
314
|
}
|
|
315
|
-
const
|
|
316
|
-
m.set(x, { id: x, path: I, values: h, uvSet: typeof
|
|
315
|
+
const R = o(g, "UVSet") ?? ((U = h.get("UVSet")) == null ? void 0 : U[0]);
|
|
316
|
+
m.set(x, { id: x, path: I, values: h, uvSet: typeof R == "string" ? R : null });
|
|
317
317
|
}
|
|
318
318
|
const a = /* @__PURE__ */ new Map(), l = (g, x) => {
|
|
319
319
|
var I;
|
|
@@ -337,14 +337,14 @@ function _e(e) {
|
|
|
337
337
|
if (g.name !== "Material") continue;
|
|
338
338
|
const x = g.values[0];
|
|
339
339
|
if (typeof x != "number" || !Number.isSafeInteger(x)) throw new Error("Invalid FBX material ID.");
|
|
340
|
-
const E = r(g), A = d.filter((F) => F.values[0] === "OP" && F.values[2] === x).map((F) => String(F.values[3])), I = d.filter((F) => F.values[0] === "OP" && F.values[2] === x).map((F) => ({ id: Number(F.values[1]), role: String(F.values[3]) })), h = String(o(g, "ShadingModel") ?? "phong").toLowerCase(),
|
|
340
|
+
const E = r(g), A = d.filter((F) => F.values[0] === "OP" && F.values[2] === x).map((F) => String(F.values[3])), I = d.filter((F) => F.values[0] === "OP" && F.values[2] === x).map((F) => ({ id: Number(F.values[1]), role: String(F.values[3]) })), h = String(o(g, "ShadingModel") ?? "phong").toLowerCase(), R = r(p.find((F) => String(F.values[0]).toLowerCase() === `fbxsurface${h}`));
|
|
341
341
|
u.set(x, {
|
|
342
342
|
textureConnections: I,
|
|
343
343
|
shadingModel: h,
|
|
344
344
|
id: x,
|
|
345
345
|
name: String(g.values[1] ?? ""),
|
|
346
346
|
ownValues: E,
|
|
347
|
-
values: new Map([...
|
|
347
|
+
values: new Map([...R, ...E]),
|
|
348
348
|
textureRoles: A
|
|
349
349
|
});
|
|
350
350
|
}
|
|
@@ -379,12 +379,12 @@ function Ce(e) {
|
|
|
379
379
|
const p = [];
|
|
380
380
|
let d = r;
|
|
381
381
|
for (; d < c; ) {
|
|
382
|
-
const y =
|
|
382
|
+
const y = _(t, d, n, !1);
|
|
383
383
|
if (!y) break;
|
|
384
384
|
if (y.endOffset > c) throw new Error("FBX child extends past its parent.");
|
|
385
|
-
if (L.has(y.name) ||
|
|
386
|
-
const m =
|
|
387
|
-
p.push({ name: m.name, values: ["BlendModes", "Alphas"].includes(m.name) ?
|
|
385
|
+
if (L.has(y.name) || te.has(y.name)) {
|
|
386
|
+
const m = _(t, d, n, y.name !== "UV");
|
|
387
|
+
p.push({ name: m.name, values: ["BlendModes", "Alphas"].includes(m.name) ? Xe(t, d, n, m.childrenOffset) : [...m.properties], children: L.has(m.name) ? s(m.childrenOffset, m.endOffset, i + 1) : [] });
|
|
388
388
|
}
|
|
389
389
|
d = y.endOffset;
|
|
390
390
|
}
|
|
@@ -392,7 +392,7 @@ function Ce(e) {
|
|
|
392
392
|
};
|
|
393
393
|
return s(27, t.byteLength, 0);
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function _e(e) {
|
|
396
396
|
const t = /"(?:\\.|[^"\\])*"|;[^\r\n]*|\r?\n|[^\S\r\n]+|[{}:,]|[^\s{}:,;]+/g;
|
|
397
397
|
let n = null;
|
|
398
398
|
const s = () => {
|
|
@@ -424,7 +424,7 @@ function Xe(e) {
|
|
|
424
424
|
` || d === `\r
|
|
425
425
|
`) continue;
|
|
426
426
|
if (s() !== ":") throw new Error("Malformed ASCII FBX metadata.");
|
|
427
|
-
const y = L.has(d) ||
|
|
427
|
+
const y = L.has(d) || te.has(d), m = [];
|
|
428
428
|
let o = [];
|
|
429
429
|
for (; ; ) {
|
|
430
430
|
const a = s();
|
|
@@ -454,24 +454,24 @@ function Xe(e) {
|
|
|
454
454
|
};
|
|
455
455
|
return c(0);
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function Xe(e, t, n, s) {
|
|
458
458
|
const r = n ? 25 : 13;
|
|
459
459
|
let c = t + r + e.getUint8(t + r - 1);
|
|
460
460
|
if (c === s) return [];
|
|
461
461
|
const i = String.fromCharCode(e.getUint8(c));
|
|
462
|
-
if (!["i", "d", "f"].includes(i)) return [...
|
|
462
|
+
if (!["i", "d", "f"].includes(i)) return [..._(e, t, n, !0).properties];
|
|
463
463
|
if (c + 13 > s) throw new Error("Truncated FBX layered array header.");
|
|
464
464
|
const p = e.getUint32(c + 1, !0), d = e.getUint32(c + 5, !0), y = e.getUint32(c + 9, !0), m = i === "d" ? 8 : 4;
|
|
465
465
|
if (p > 4096 || c + 13 + y !== s || ![0, 1].includes(d)) throw new Error("Invalid FBX layered array bounds.");
|
|
466
|
-
const o = new Uint8Array(e.buffer, e.byteOffset + c + 13, y), a = d === 1 ?
|
|
466
|
+
const o = new Uint8Array(e.buffer, e.byteOffset + c + 13, y), a = d === 1 ? xe(o, { out: new Uint8Array(p * m) }) : o;
|
|
467
467
|
if (a.length !== p * m) throw new Error("Invalid FBX layered array size.");
|
|
468
468
|
const l = new DataView(a.buffer, a.byteOffset, a.byteLength);
|
|
469
469
|
return Array.from({ length: p }, (u, w) => i === "i" ? l.getInt32(w * m, !0) : i === "d" ? l.getFloat64(w * m, !0) : l.getFloat32(w * m, !0));
|
|
470
470
|
}
|
|
471
|
-
const
|
|
472
|
-
function
|
|
471
|
+
const H = (e) => e <= 0.04045 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4, Le = (e) => e <= 31308e-7 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - 0.055, Ne = /* @__PURE__ */ new Set([0, 1, 2, 4, 5]), Pe = 4 * 1024 * 1024;
|
|
472
|
+
function W(e) {
|
|
473
473
|
const t = e.image, n = (t == null ? void 0 : t.naturalWidth) || (t == null ? void 0 : t.width), s = (t == null ? void 0 : t.naturalHeight) || (t == null ? void 0 : t.height);
|
|
474
|
-
if (!n || !s || n * s >
|
|
474
|
+
if (!n || !s || n * s > Pe) throw new Error("missing image or image exceeds 4M pixels");
|
|
475
475
|
let r;
|
|
476
476
|
if (t.data) {
|
|
477
477
|
if (e.format !== K || e.type !== J || !(t.data instanceof Uint8Array) || t.data.length !== n * s * 4) throw new Error("require RGBA8 source");
|
|
@@ -487,10 +487,10 @@ function z(e) {
|
|
|
487
487
|
for (let i = 0; i < s; i++) for (let p = 0; p < n * 4; p++) c[(e.flipY ? s - i - 1 : i) * n * 4 + p] = r[i * n * 4 + p];
|
|
488
488
|
return { data: c, width: n, height: s };
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function $e(e, t, n) {
|
|
491
491
|
if (e.issues.some((o) => o.code !== "LAYERED_TEXTURE_NOT_COMPOSITED")) throw new Error("incompatible layer graph or coordinates");
|
|
492
492
|
if (e.layers.length < 1 || e.layers.length > 8) throw new Error("require 1–8 layers");
|
|
493
|
-
if (!e.layers.every((o) => o.blendMode !== null &&
|
|
493
|
+
if (!e.layers.every((o) => o.blendMode !== null && Ne.has(o.blendMode))) throw new Error("unsupported blend mode");
|
|
494
494
|
const s = e.layers.map((o) => {
|
|
495
495
|
const a = [...n].find((l) => l.ID === o.textureId);
|
|
496
496
|
if (!a) throw new Error(`missing decoded texture ${o.textureId}`);
|
|
@@ -512,28 +512,28 @@ function Ve(e, t, n) {
|
|
|
512
512
|
]);
|
|
513
513
|
if (s.some((o) => c(o) !== c(r))) throw new Error("incompatible sampling state");
|
|
514
514
|
if (e.layers.some((o) => !t.textures.has(o.textureId))) throw new Error("missing source metadata");
|
|
515
|
-
const i =
|
|
515
|
+
const i = W(r), p = i.width * i.height;
|
|
516
516
|
if (e.layers[0].alpha !== 1 || i.data.some((o, a) => a % 4 === 3 && o !== 255)) throw new Error("base layer must be fully opaque with weight 1");
|
|
517
517
|
const d = new Float32Array(p * 3);
|
|
518
|
-
for (let o = 0; o < p; o++) for (let a = 0; a < 3; a++) d[o * 3 + a] = r.colorSpace === G ? i.data[o * 4 + a] / 255 :
|
|
518
|
+
for (let o = 0; o < p; o++) for (let a = 0; a < 3; a++) d[o * 3 + a] = r.colorSpace === G ? i.data[o * 4 + a] / 255 : H(i.data[o * 4 + a] / 255);
|
|
519
519
|
for (let o = 1; o < s.length; o++) {
|
|
520
|
-
const a = s[o], l =
|
|
520
|
+
const a = s[o], l = W(a), u = e.layers[o];
|
|
521
521
|
if (l.width !== i.width || l.height !== i.height) throw new Error("layer dimensions differ");
|
|
522
522
|
for (let w = 0; w < p; w++) {
|
|
523
523
|
const f = u.alpha * l.data[w * 4 + 3] / 255;
|
|
524
524
|
for (let M = 0; M < 3; M++) {
|
|
525
|
-
const S = d[w * 3 + M], b = l.data[w * 4 + M] / 255, v = a.colorSpace === G ? b :
|
|
525
|
+
const S = d[w * 3 + M], b = l.data[w * 4 + M] / 255, v = a.colorSpace === G ? b : H(b), D = u.blendMode === 1 ? Math.min(1, S + v) : u.blendMode === 2 ? S * v : v;
|
|
526
526
|
d[w * 3 + M] = S + (D - S) * f;
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
530
|
const y = new Uint8Array(p * 4);
|
|
531
531
|
for (let o = 0; o < p; o++) y[o * 4 + 3] = 255;
|
|
532
|
-
for (let o = 0; o < p; o++) for (let a = 0; a < 3; a++) y[o * 4 + a] = Math.round(255 * Math.min(1, Math.max(0,
|
|
532
|
+
for (let o = 0; o < p; o++) for (let a = 0; a < 3; a++) y[o * 4 + a] = Math.round(255 * Math.min(1, Math.max(0, Le(d[o * 3 + a]))));
|
|
533
533
|
const m = new N(y, i.width, i.height);
|
|
534
|
-
return m.colorSpace =
|
|
534
|
+
return m.colorSpace = le, m.generateMipmaps = r.generateMipmaps, m.wrapS = r.wrapS, m.wrapT = r.wrapT, m.minFilter = r.minFilter, m.magFilter = r.magFilter, m.anisotropy = r.anisotropy, m.offset.copy(r.offset), m.repeat.copy(r.repeat), m.center.copy(r.center), m.rotation = r.rotation, m.matrix.copy(r.matrix), m.matrixAutoUpdate = r.matrixAutoUpdate, m.channel = r.channel, m.mapping = r.mapping, m.userData.fbxLayerBaseId = e.layers[0].textureId, m.needsUpdate = !0, m;
|
|
535
535
|
}
|
|
536
|
-
function
|
|
536
|
+
function Ve(e, t) {
|
|
537
537
|
return e.textureConnections.flatMap((n) => {
|
|
538
538
|
var o;
|
|
539
539
|
const s = (o = t.layeredTextures) == null ? void 0 : o.get(n.id);
|
|
@@ -566,7 +566,7 @@ function Ge(e, t) {
|
|
|
566
566
|
})).size > 1 && c("LAYERED_TEXTURE_COORDINATES_DIFFER", "UV sets or transforms differ; direct pixel blending is unsafe"), [{ id: s.id, role: n.role, layers: s.textureIds.map((a, l) => ({ textureId: a, blendMode: s.blendModes[l] ?? null, alpha: s.alphas[l] ?? null })), issues: r }];
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
|
-
const
|
|
569
|
+
const Ge = {
|
|
570
570
|
DiffuseColor: "map",
|
|
571
571
|
"Maya|TEX_color_map": "map",
|
|
572
572
|
NormalMap: "normalMap",
|
|
@@ -583,11 +583,11 @@ const ke = {
|
|
|
583
583
|
TransparentColor: "alphaMap",
|
|
584
584
|
TransparencyFactor: "alphaMap"
|
|
585
585
|
};
|
|
586
|
-
function
|
|
586
|
+
function ke(e, t, n, s, r, c) {
|
|
587
587
|
var a;
|
|
588
588
|
const i = (a = s.modelUvSets) == null ? void 0 : a.get(e.ID ?? NaN), p = [], d = [], y = /* @__PURE__ */ new Set();
|
|
589
589
|
for (const l of n.textureConnections) {
|
|
590
|
-
const u =
|
|
590
|
+
const u = Ge[l.role], w = u ? t[u] : void 0, f = s.textures.get(l.id) ?? (w instanceof X ? s.textures.get(w.userData.fbxLayerBaseId) : void 0);
|
|
591
591
|
if (!u || !f || y.has(u)) continue;
|
|
592
592
|
y.add(u);
|
|
593
593
|
const M = t[u];
|
|
@@ -595,7 +595,7 @@ function Ye(e, t, n, s, r, c) {
|
|
|
595
595
|
const S = (I, h) => d.push({ status: "unsupported", code: I, source: `texture:${l.id}:${h}`, target: String(u) });
|
|
596
596
|
let b = 0;
|
|
597
597
|
if (f.uvSet) {
|
|
598
|
-
const I = (i == null ? void 0 : i.flatMap((h,
|
|
598
|
+
const I = (i == null ? void 0 : i.flatMap((h, R) => h === f.uvSet ? [R] : [])) ?? [];
|
|
599
599
|
if (I.length === 1) b = I[0];
|
|
600
600
|
else if (I.length > 1 || f.uvSet !== "default") {
|
|
601
601
|
S("UV_SET_UNRESOLVED", `UVSet:${f.uvSet}:${I.length > 1 ? "ambiguous" : "missing"}`);
|
|
@@ -607,12 +607,12 @@ function Ye(e, t, n, s, r, c) {
|
|
|
607
607
|
continue;
|
|
608
608
|
}
|
|
609
609
|
const v = (I, h) => {
|
|
610
|
-
const
|
|
611
|
-
return
|
|
612
|
-
}, D = v("Translation", [M.offset.x, M.offset.y, 0]),
|
|
613
|
-
E && S("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-rotation-or-pivot"), (D[2] ||
|
|
610
|
+
const R = f.values.get(I);
|
|
611
|
+
return R ? R.length < 2 || !R.every((F) => typeof F == "number" && Number.isFinite(F)) ? (S("TEXTURE_TRANSFORM_INVALID", I), h) : R : h;
|
|
612
|
+
}, D = v("Translation", [M.offset.x, M.offset.y, 0]), U = v("Scaling", [M.repeat.x, M.repeat.y, 1]), T = v("Rotation", [0, 0, 0]), g = v("RotationPivot", [0, 0, 0]), x = v("ScalingPivot", [0, 0, 0]), E = T[0] !== 0 || T[1] !== 0 || g.some((I) => I !== 0) || x.some((I) => I !== 0);
|
|
613
|
+
E && S("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-rotation-or-pivot"), (D[2] || U[2] !== void 0 && U[2] !== 1) && S("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-translation-or-scale");
|
|
614
614
|
const A = E ? 0 : -(T[2] ?? 0) * Math.PI / 180;
|
|
615
|
-
A && d.push({ status: "approximate", code: "TEXTURE_ROTATION_PROFILE", source: `texture:${l.id}:Rotation`, target: "T * Rccw * S; origin pivot" }), (b !== M.channel || D[0] !== M.offset.x || D[1] !== M.offset.y ||
|
|
615
|
+
A && d.push({ status: "approximate", code: "TEXTURE_ROTATION_PROFILE", source: `texture:${l.id}:Rotation`, target: "T * Rccw * S; origin pivot" }), (b !== M.channel || D[0] !== M.offset.x || D[1] !== M.offset.y || U[0] !== M.repeat.x || U[1] !== M.repeat.y || A !== M.rotation) && p.push({ slot: u, source: M, channel: b, offset: D, scale: U, rotation: A });
|
|
616
616
|
}
|
|
617
617
|
if (!p.length && !d.length) return t;
|
|
618
618
|
const m = t.clone();
|
|
@@ -637,20 +637,20 @@ function Ye(e, t, n, s, r, c) {
|
|
|
637
637
|
}
|
|
638
638
|
return m.needsUpdate = !0, m;
|
|
639
639
|
}
|
|
640
|
-
function
|
|
640
|
+
function Ye(e, t) {
|
|
641
641
|
return Math.min(1, Math.max(0, e));
|
|
642
642
|
}
|
|
643
|
-
function
|
|
643
|
+
function qe(e, t, n, s, r = "r", c = !1) {
|
|
644
644
|
if (!Number.isInteger(t) || !Number.isInteger(n) || t <= 0 || n <= 0 || e.length !== t * n * 4)
|
|
645
645
|
throw new Error("Invalid FBX scalar RGBA dimensions.");
|
|
646
646
|
const i = new Uint8Array(e.length), p = { r: 0, g: 1, b: 2, a: 3 }[r];
|
|
647
647
|
for (let d = 0; d < n; d++) for (let y = 0; y < t; y++) {
|
|
648
|
-
const m = (d * t + y) * 4, o = ((c ? n - d - 1 : d) * t + y) * 4, a = Math.round(255 *
|
|
648
|
+
const m = (d * t + y) * 4, o = ((c ? n - d - 1 : d) * t + y) * 4, a = Math.round(255 * Ye(e[m + p] / 255));
|
|
649
649
|
i.fill(a, o, o + 4);
|
|
650
650
|
}
|
|
651
651
|
return i;
|
|
652
652
|
}
|
|
653
|
-
function
|
|
653
|
+
function je(e, t) {
|
|
654
654
|
const n = e.image;
|
|
655
655
|
if (!n) throw new Error("FBX scalar texture has no decoded image.");
|
|
656
656
|
const s = n.naturalWidth || n.width, r = n.naturalHeight || n.height;
|
|
@@ -667,17 +667,17 @@ function ze(e, t) {
|
|
|
667
667
|
if (!d) throw new Error("FBX scalar texture conversion requires a 2D canvas.");
|
|
668
668
|
d.drawImage(n, 0, 0), c = d.getImageData(0, 0, s, r).data;
|
|
669
669
|
}
|
|
670
|
-
const i = new N(
|
|
671
|
-
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.magFilter = e.magFilter, i.minFilter = e.minFilter, i.generateMipmaps = e.generateMipmaps, i.anisotropy = e.anisotropy, i.colorSpace =
|
|
670
|
+
const i = new N(qe(c, s, r, t, "r", e.flipY), s, r);
|
|
671
|
+
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.magFilter = e.magFilter, i.minFilter = e.minFilter, i.generateMipmaps = e.generateMipmaps, i.anisotropy = e.anisotropy, i.colorSpace = ce, i.needsUpdate = !0, i;
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function ze(e, t, n) {
|
|
674
674
|
const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), d = [];
|
|
675
675
|
try {
|
|
676
676
|
e.traverse((a) => {
|
|
677
|
-
if (!(a instanceof
|
|
677
|
+
if (!(a instanceof ue)) return;
|
|
678
678
|
const l = t == null ? void 0 : t.modelMaterials.get(a.ID ?? NaN), u = (f) => l ? t == null ? void 0 : t.materials.get(l[f]) : void 0, w = (f, M) => {
|
|
679
|
-
const S = u(M), b =
|
|
680
|
-
return b instanceof
|
|
679
|
+
const S = u(M), b = He(f, s, S, n, t, r, c);
|
|
680
|
+
return b instanceof Z && S && t ? ke(a, b, S, t, (v) => i.add(v), (v) => p.add(v)) : b;
|
|
681
681
|
};
|
|
682
682
|
d.push({ mesh: a, material: Array.isArray(a.material) ? a.material.map(w) : w(a.material, 0) });
|
|
683
683
|
});
|
|
@@ -700,33 +700,33 @@ function He(e, t, n) {
|
|
|
700
700
|
const o = [...y].flatMap((a) => a.userData.fbxConversionReport ? [a.userData.fbxConversionReport] : []);
|
|
701
701
|
return e.userData.fbxConversionReports = o, o;
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function He(e, t, n, s, r, c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map()) {
|
|
704
704
|
var E, A, I;
|
|
705
705
|
const p = t.get(e);
|
|
706
706
|
if (p) return p;
|
|
707
|
-
if (!(e instanceof k) && !(e instanceof
|
|
707
|
+
if (!(e instanceof k) && !(e instanceof fe))
|
|
708
708
|
return t.set(e, e), e;
|
|
709
|
-
const d = e instanceof k ? e : null, y = (h,
|
|
709
|
+
const d = e instanceof k ? e : null, y = (h, R) => {
|
|
710
710
|
var O;
|
|
711
711
|
const F = (O = n == null ? void 0 : n.values.get(h)) == null ? void 0 : O[0];
|
|
712
|
-
return typeof F == "number" && Number.isFinite(F) ? F :
|
|
713
|
-
}, m = (h,
|
|
712
|
+
return typeof F == "number" && Number.isFinite(F) ? F : R;
|
|
713
|
+
}, m = (h, R) => {
|
|
714
714
|
const F = n == null ? void 0 : n.values.get(h);
|
|
715
|
-
return F && F.length >= 3 && F.slice(0, 3).every((O) => typeof O == "number" && Number.isFinite(O)) ? new
|
|
715
|
+
return F && F.length >= 3 && F.slice(0, 3).every((O) => typeof O == "number" && Number.isFinite(O)) ? new C().setRGB(F[0], F[1], F[2]) : R.clone();
|
|
716
716
|
}, o = (h) => Math.min(1, Math.max(0, h)), a = o(y("SpecularFactor", 0.25) * 2), l = Math.sqrt(0.08 * a), u = (1 + l) / (1 - l);
|
|
717
717
|
let w = e.opacity;
|
|
718
718
|
if (n && (w = 1 - y("TransparencyFactor", 0), w === 0 || w === 1)) {
|
|
719
719
|
const h = (E = n.ownValues.get("Opacity")) == null ? void 0 : E[0];
|
|
720
|
-
w = typeof h == "number" && Number.isFinite(h) ? h : 1 - m("TransparentColor", new
|
|
720
|
+
w = typeof h == "number" && Number.isFinite(h) ? h : 1 - m("TransparentColor", new C(0)).r;
|
|
721
721
|
}
|
|
722
|
-
const f = new
|
|
722
|
+
const f = new Z({
|
|
723
723
|
name: e.name,
|
|
724
724
|
// FBX diffuse textures supply the base color (as in Blender's importer),
|
|
725
725
|
// not an additional tint. Multiplying the atlas by DiffuseColor can turn
|
|
726
726
|
// blue atlas regions black when the material's constant color is red.
|
|
727
|
-
color: e.map ? new
|
|
727
|
+
color: e.map ? new C(16777215) : m("DiffuseColor", n ? new C(1, 1, 1) : e.color),
|
|
728
728
|
map: e.map,
|
|
729
|
-
emissive: e.emissiveMap ? new
|
|
729
|
+
emissive: e.emissiveMap ? new C(16777215) : m("EmissiveColor", n ? new C(0) : e.emissive),
|
|
730
730
|
emissiveMap: e.emissiveMap,
|
|
731
731
|
emissiveIntensity: y("EmissiveFactor", n ? 1 : e.emissiveIntensity),
|
|
732
732
|
normalMap: e.normalMap,
|
|
@@ -758,18 +758,18 @@ function We(e, t, n, s, r, c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ ne
|
|
|
758
758
|
});
|
|
759
759
|
t.set(e, f);
|
|
760
760
|
const M = (h) => {
|
|
761
|
-
let
|
|
762
|
-
return
|
|
763
|
-
}, S = n && r ?
|
|
761
|
+
let R = c.get(h);
|
|
762
|
+
return R || (R = je(h, "identity"), c.set(h, R)), R;
|
|
763
|
+
}, S = n && r ? Ve(n, r) : [], b = [];
|
|
764
764
|
for (const h of S)
|
|
765
|
-
if (!(!["DiffuseColor", "EmissiveColor"].includes(h.role) || !r || !s) && n.textureConnections.filter((
|
|
765
|
+
if (!(!["DiffuseColor", "EmissiveColor"].includes(h.role) || !r || !s) && n.textureConnections.filter((R) => R.role === h.role).length === 1)
|
|
766
766
|
try {
|
|
767
|
-
let
|
|
768
|
-
|
|
769
|
-
} catch (
|
|
770
|
-
h.issues.push({ status: "unsupported", code: "LAYERED_TEXTURE_BAKE_REJECTED", source: `layered:${h.id}:${
|
|
767
|
+
let R = i.get(h.id);
|
|
768
|
+
R || (R = $e(h, r, s), i.set(h.id, R)), h.role === "DiffuseColor" ? (f.map = R, f.color.setRGB(1, 1, 1)) : (f.emissiveMap = R, f.emissive.setRGB(1, 1, 1)), h.issues = [], b.push(h.id);
|
|
769
|
+
} catch (R) {
|
|
770
|
+
h.issues.push({ status: "unsupported", code: "LAYERED_TEXTURE_BAKE_REJECTED", source: `layered:${h.id}:${R instanceof Error ? R.message : String(R)}`, target: h.role });
|
|
771
771
|
}
|
|
772
|
-
const v = /* @__PURE__ */ new Set(), D = [],
|
|
772
|
+
const v = /* @__PURE__ */ new Set(), D = [], U = /* @__PURE__ */ new Set(), T = {
|
|
773
773
|
ReflectionFactor: "metalnessMap",
|
|
774
774
|
ReflectionColor: "metalnessMap",
|
|
775
775
|
ShininessExponent: "roughnessMap",
|
|
@@ -780,31 +780,31 @@ function We(e, t, n, s, r, c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ ne
|
|
|
780
780
|
};
|
|
781
781
|
for (const h of (n == null ? void 0 : n.textureConnections) ?? []) {
|
|
782
782
|
if ((A = r == null ? void 0 : r.layeredTextures) != null && A.has(h.id)) continue;
|
|
783
|
-
const
|
|
784
|
-
if (!
|
|
783
|
+
const R = [...s ?? []].find((O) => O.ID === h.id);
|
|
784
|
+
if (!R) {
|
|
785
785
|
D.push(`texture:${h.id}:unresolved:${h.role}`);
|
|
786
786
|
continue;
|
|
787
787
|
}
|
|
788
788
|
const F = T[h.role];
|
|
789
|
-
if (F &&
|
|
789
|
+
if (F && U.has(F)) {
|
|
790
790
|
D.push(`conflicting-input:${h.role}:${F}`);
|
|
791
791
|
continue;
|
|
792
792
|
}
|
|
793
|
-
switch (F &&
|
|
793
|
+
switch (F && U.add(F), h.role) {
|
|
794
794
|
case "ReflectionFactor":
|
|
795
795
|
case "ReflectionColor":
|
|
796
|
-
f.metalnessMap = M(
|
|
796
|
+
f.metalnessMap = M(R), f.metalness = 1, v.add(h.role);
|
|
797
797
|
break;
|
|
798
798
|
case "ShininessExponent":
|
|
799
|
-
f.roughnessMap = M(
|
|
799
|
+
f.roughnessMap = M(R), f.roughness = 1, v.add(h.role);
|
|
800
800
|
break;
|
|
801
801
|
case "SpecularFactor":
|
|
802
802
|
case "SpecularColor":
|
|
803
|
-
f.specularIntensityMap = M(
|
|
803
|
+
f.specularIntensityMap = M(R), f.ior = (1 + Math.sqrt(0.08)) / (1 - Math.sqrt(0.08)), f.specularIntensity = 1, v.add(h.role);
|
|
804
804
|
break;
|
|
805
805
|
case "TransparentColor":
|
|
806
806
|
case "TransparencyFactor":
|
|
807
|
-
f.alphaMap = M(
|
|
807
|
+
f.alphaMap = M(R), f.opacity = 1, f.transparent = !0, v.add(h.role);
|
|
808
808
|
break;
|
|
809
809
|
}
|
|
810
810
|
}
|
|
@@ -846,42 +846,31 @@ function We(e, t, n, s, r, c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ ne
|
|
|
846
846
|
};
|
|
847
847
|
return f.userData.fbxConversionReport = x, f.visible = e.visible, f.toneMapped = e.toneMapped, f.clippingPlanes = e.clippingPlanes, f.clipIntersection = e.clipIntersection, f.clipShadows = e.clipShadows, f.polygonOffset = e.polygonOffset, f.polygonOffsetFactor = e.polygonOffsetFactor, f.polygonOffsetUnits = e.polygonOffsetUnits, f.dithering = e.dithering, f.needsUpdate = !0, t.set(e, f), f;
|
|
848
848
|
}
|
|
849
|
-
|
|
850
|
-
function H(e) {
|
|
851
|
-
return e === "fbx" ? "y" : "z";
|
|
852
|
-
}
|
|
853
|
-
function Qe(e) {
|
|
854
|
-
return e === "y" ? Ke : Je;
|
|
855
|
-
}
|
|
856
|
-
function W(e, t) {
|
|
857
|
-
const n = Qe(t);
|
|
858
|
-
return n.equals(e.quaternion) ? !1 : (e.quaternion.copy(n), e.updateMatrixWorld(!0), !0);
|
|
859
|
-
}
|
|
860
|
-
function it(e, t) {
|
|
849
|
+
function rt(e, t) {
|
|
861
850
|
let n = !1, s = null, r = null, c = "z", i, p = null, d;
|
|
862
851
|
const y = () => {
|
|
863
852
|
n = !0;
|
|
864
853
|
}, m = (async () => {
|
|
865
|
-
c = t.options.upAxis ??
|
|
854
|
+
c = t.options.upAxis ?? Y(t.format);
|
|
866
855
|
let o = null;
|
|
867
856
|
try {
|
|
868
857
|
if (n || t.signal.aborted) throw V();
|
|
869
858
|
const a = e.url ?? await e.resolve(e.entryPath ?? "");
|
|
870
|
-
if (o = new
|
|
859
|
+
if (o = new pe(), o.name = "viewer-model-root", t.format === "fbx") {
|
|
871
860
|
const u = await fetch(a, { signal: t.signal });
|
|
872
861
|
if (!u.ok) throw new Error(`FBX request failed: ${u.status} ${u.statusText}`);
|
|
873
862
|
const w = await u.arrayBuffer();
|
|
874
|
-
c = t.options.upAxis ??
|
|
875
|
-
const f =
|
|
863
|
+
c = t.options.upAxis ?? Fe(w) ?? Y(t.format);
|
|
864
|
+
const f = Be(w), M = await Te(w, e, f);
|
|
876
865
|
d = M.textures, o.add(M.root);
|
|
877
|
-
const b =
|
|
866
|
+
const b = ze(o, f, d).flatMap((v) => v.issues.filter((D) => D.status === "unsupported" || D.code === "TEXTURE_ROTATION_PROFILE" || D.code === "LAYERED_TEXTURE_BAKED").map((D) => `${v.materialName || v.materialId || "material"}: ${D.source}`));
|
|
878
867
|
b.length && (p = {
|
|
879
868
|
code: "W_FBX_MATERIAL_APPROXIMATED",
|
|
880
869
|
stage: "material-conversion",
|
|
881
870
|
message: `FBX 材质存在未支持或按兼容规则近似处理的语义:${[...new Set(b)].join("、")}。当前为近似预览。`
|
|
882
871
|
});
|
|
883
872
|
} else {
|
|
884
|
-
const u = new
|
|
873
|
+
const u = new me(), w = new ge();
|
|
885
874
|
try {
|
|
886
875
|
t.options.dracoDecoderPath && u.setDecoderPath(t.options.dracoDecoderPath), w.setDRACOLoader(u);
|
|
887
876
|
const f = await w.loadAsync(a), M = f.scenes.filter((S) => S !== f.scene);
|
|
@@ -894,11 +883,11 @@ function it(e, t) {
|
|
|
894
883
|
}
|
|
895
884
|
}
|
|
896
885
|
if (n || t.signal.aborted) throw V();
|
|
897
|
-
|
|
898
|
-
const l = new
|
|
886
|
+
q(o, c), We(o);
|
|
887
|
+
const l = new ye(o, t.options.simulationTheme, void 0, "model");
|
|
899
888
|
s = o, r = l, o = null;
|
|
900
889
|
} finally {
|
|
901
|
-
o && (
|
|
890
|
+
o && (j(o, d), d = void 0);
|
|
902
891
|
}
|
|
903
892
|
})();
|
|
904
893
|
return m.catch(() => {
|
|
@@ -935,7 +924,7 @@ function it(e, t) {
|
|
|
935
924
|
return (r == null ? void 0 : r.getGroundVisible()) ?? !0;
|
|
936
925
|
},
|
|
937
926
|
setUpAxis(o) {
|
|
938
|
-
if (n || !s || !r || !
|
|
927
|
+
if (n || !s || !r || !q(s, o)) return;
|
|
939
928
|
c = o, r.reseatGround();
|
|
940
929
|
const a = r.getModelBounds();
|
|
941
930
|
t.requestRender(), t.fit(a, { padding: 1.15 });
|
|
@@ -944,21 +933,21 @@ function it(e, t) {
|
|
|
944
933
|
dispose() {
|
|
945
934
|
return y(), i ?? (i = m.catch(() => {
|
|
946
935
|
}).then(() => {
|
|
947
|
-
r == null || r.dispose(), r = null, s &&
|
|
936
|
+
r == null || r.dispose(), r = null, s && j(s, d), s = null, d = void 0;
|
|
948
937
|
})), i;
|
|
949
938
|
}
|
|
950
939
|
};
|
|
951
940
|
}
|
|
952
|
-
function
|
|
941
|
+
function We(e) {
|
|
953
942
|
e.updateMatrixWorld(!0);
|
|
954
|
-
const t = new
|
|
943
|
+
const t = new de().setFromObject(e);
|
|
955
944
|
if (t.isEmpty()) throw new Error("模型不包含可显示的几何内容。");
|
|
956
|
-
const n = t.getSize(new
|
|
945
|
+
const n = t.getSize(new he()), s = Math.max(n.x, n.y, n.z);
|
|
957
946
|
if (!Number.isFinite(s) || s <= 0) throw new Error("模型尺寸无效。");
|
|
958
947
|
}
|
|
959
948
|
function V() {
|
|
960
949
|
return Object.assign(new Error("Model load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
961
950
|
}
|
|
962
951
|
export {
|
|
963
|
-
|
|
952
|
+
rt as createModelSession
|
|
964
953
|
};
|