@nebula-spatial/viewer 0.5.12 → 0.5.14
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 +51 -0
- package/MATERIALX-LIBRARY-AUDIT.md +250 -0
- package/README.md +32 -34
- package/USD-VISUAL-MATERIAL-SUPPORT.md +57 -10
- package/dist/assets/types.d.ts +10 -1
- package/dist/{collision-debug-C-GfagYI.js → collision-debug-B2bN8P2g.js} +1 -1
- package/dist/{index-CPHfEIND.js → index-BSDalKkd.js} +846 -832
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{mjcf-visual-Coi35OaT.js → mjcf-visual-D6T3a1uQ.js} +1 -1
- package/dist/{mujoco-runtime-CciOWtJO.js → mujoco-runtime-CFQQsRmc.js} +1 -1
- package/dist/runtime-paths-Dj0itY6G.js +8 -0
- package/dist/{session-CoEU6ILc.js → session-BUarD9PA.js} +132 -129
- package/dist/{session-BwQqwtuW.js → session-Ciaw522_.js} +7 -7
- package/dist/simulation/usd-preload.d.ts +2 -0
- package/dist/simulation/usd-prewarm.d.ts +6 -0
- package/dist/{stage-C8MOE9K3.js → stage-CvP0yaff.js} +1 -1
- package/dist/{urdf-session-CCfMSB3h.js → urdf-session-DcGOHFg2.js} +5 -5
- package/dist/usd-session-DSFtJk4b.js +9634 -0
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-kijvGy5n.js → xacro-bURYAikr.js} +1 -1
- package/draco/draco_decoder.wasm +0 -0
- package/draco/draco_wasm_wrapper.js +117 -0
- package/package.json +30 -4
- package/runtime-assets.d.mts +9 -0
- package/runtime-assets.mjs +11 -0
- package/vite.d.mts +7 -0
- package/vite.mjs +115 -0
- package/dist/usd-session-CR2K_zdJ.js +0 -8478
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { DataTexture as ne, LinearMipmapLinearFilter as ke, LinearFilter as Xe, Loader as J, LoaderUtils as _e, FileLoader as Ve, TextureLoader as Me, RepeatWrapping as ue, ClampToEdgeWrapping as pe, Texture as Y, MeshPhongMaterial as W, MeshLambertMaterial as Se, ColorManagement as N, Color as k, SRGBColorSpace as X, EquirectangularReflectionMapping as Ge, Matrix4 as L, Group as ce, Bone as fe, PropertyBinding as ee, Object3D as Z, PerspectiveCamera as Ne, PointLight as he, MathUtils as B, SpotLight as $e, DirectionalLight as ze, SkinnedMesh as je, Mesh as Fe, LineBasicMaterial as He, Line as We, Vector3 as V, Skeleton as Ye, AmbientLight as qe, BufferGeometry as re, Float32BufferAttribute as j, Uint16BufferAttribute as Ke, Matrix3 as Ze, Vector2 as Qe, ShapeUtils as Je, Vector4 as et, Euler as z, AnimationClip as tt, Quaternion as G, VectorKeyframeTrack as nt, QuaternionKeyframeTrack as de, NumberKeyframeTrack as rt, LoadingManager as st, LinearSRGBColorSpace as me, RGBAFormat as Ie, UnsignedByteType as Ae, NoColorSpace as at, MeshPhysicalMaterial as
|
|
1
|
+
import { DataTexture as ne, LinearMipmapLinearFilter as ke, LinearFilter as Xe, Loader as J, LoaderUtils as _e, FileLoader as Ve, TextureLoader as Me, RepeatWrapping as ue, ClampToEdgeWrapping as pe, Texture as Y, MeshPhongMaterial as W, MeshLambertMaterial as Se, ColorManagement as N, Color as k, SRGBColorSpace as X, EquirectangularReflectionMapping as Ge, Matrix4 as L, Group as ce, Bone as fe, PropertyBinding as ee, Object3D as Z, PerspectiveCamera as Ne, PointLight as he, MathUtils as B, SpotLight as $e, DirectionalLight as ze, SkinnedMesh as je, Mesh as Fe, LineBasicMaterial as He, Line as We, Vector3 as V, Skeleton as Ye, AmbientLight as qe, BufferGeometry as re, Float32BufferAttribute as j, Uint16BufferAttribute as Ke, Matrix3 as Ze, Vector2 as Qe, ShapeUtils as Je, Vector4 as et, Euler as z, AnimationClip as tt, Quaternion as G, VectorKeyframeTrack as nt, QuaternionKeyframeTrack as de, NumberKeyframeTrack as rt, LoadingManager as st, LinearSRGBColorSpace as me, RGBAFormat as Ie, UnsignedByteType as Ae, NoColorSpace as at, MeshPhysicalMaterial as Re, Box3 as ot } from "three";
|
|
2
2
|
import { DRACOLoader as it } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
3
3
|
import { GLTFLoader as lt } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
-
import { D as ct } from "./index-
|
|
5
|
-
import { d as ge, a as ye, S as ut } from "./stage-
|
|
4
|
+
import { D as ct } from "./index-BSDalKkd.js";
|
|
5
|
+
import { d as ge, a as ye, S as ut } from "./stage-CvP0yaff.js";
|
|
6
6
|
import { TGALoader as pt } from "three/examples/jsm/loaders/TGALoader.js";
|
|
7
7
|
import * as ft from "three/examples/jsm/libs/fflate.module.js";
|
|
8
8
|
import { unzlibSync as ht } from "three/examples/jsm/libs/fflate.module.js";
|
|
9
9
|
import { NURBSCurve as dt } from "three/examples/jsm/curves/NURBSCurve.js";
|
|
10
10
|
import { disposeModelResources as we } from "./resources-CHhCm2f7.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { r as mt } from "./runtime-paths-Dj0itY6G.js";
|
|
12
|
+
const gt = 16 * 1024 * 1024;
|
|
13
|
+
function De(i, e) {
|
|
14
|
+
if (!i || !e || i * e > gt) throw new Error("Invalid or oversized image dimensions (maximum 16M pixels).");
|
|
14
15
|
}
|
|
15
16
|
function $(i, e, t) {
|
|
16
17
|
if (e < 0 || t < 0 || e + t > i.length) throw new Error("Truncated image payload.");
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function yt(i) {
|
|
19
20
|
const e = new Uint8Array(i);
|
|
20
21
|
$(e, 0, 18);
|
|
21
22
|
const t = new DataView(i), n = e[2], r = e[16], s = t.getUint16(12, !0), a = t.getUint16(14, !0);
|
|
22
|
-
if (
|
|
23
|
+
if (De(s, a), e[1] !== 0 || ![2, 3, 10, 11].includes(n) || !([3, 11].includes(n) ? [8, 16] : [24, 32]).includes(r) || e[17] & 192)
|
|
23
24
|
throw new Error("Unsupported TGA: require non-interleaved 24/32-bit true-color or 8/16-bit grayscale.");
|
|
24
25
|
let o = 18 + e[0];
|
|
25
26
|
$(e, 18, e[0]);
|
|
@@ -41,13 +42,13 @@ function ve(i) {
|
|
|
41
42
|
const e = i >>> 11 & 31, t = i >>> 5 & 63, n = i & 31;
|
|
42
43
|
return [e << 3 | e >>> 2, t << 2 | t >>> 4, n << 3 | n >>> 2, 255];
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function wt(i) {
|
|
45
46
|
const e = new Uint8Array(i);
|
|
46
47
|
$(e, 0, 128);
|
|
47
48
|
const t = new DataView(i), n = (h) => t.getUint32(h, !0);
|
|
48
49
|
if (n(0) !== 542327876 || n(4) !== 124 || n(76) !== 32) throw new Error("Invalid DDS header.");
|
|
49
50
|
const r = n(16), s = n(12);
|
|
50
|
-
if (
|
|
51
|
+
if (De(r, s), n(112) & 2162176 || n(24) > 1) throw new Error("DDS cubemap/volume textures are unsupported.");
|
|
51
52
|
const a = n(80), o = String.fromCharCode(...e.subarray(84, 88)), l = (a & 4) !== 0;
|
|
52
53
|
if (l && !["DXT1", "DXT3", "DXT5"].includes(o)) throw new Error(`Unsupported DDS FourCC: ${o}. Require DXT1/DXT3/DXT5.`);
|
|
53
54
|
const p = new Uint8Array(r * s * 4);
|
|
@@ -79,21 +80,21 @@ function yt(i) {
|
|
|
79
80
|
if (v >= r || S >= s) continue;
|
|
80
81
|
const E = y[I >>> 2 * M & 3], b = (S * r + v) * 4;
|
|
81
82
|
if (p.set(E, b), o === "DXT3" && (p[b + 3] = (e[g + Math.floor(M / 2)] >>> M % 2 * 4 & 15) * 17), o === "DXT5") {
|
|
82
|
-
const
|
|
83
|
-
p[b + 3] = A[
|
|
83
|
+
const R = M * 3, w = g + 2 + Math.floor(R / 8), D = e[w] | (w + 1 < g + 8 ? e[w + 1] : 0) << 8;
|
|
84
|
+
p[b + 3] = A[D >>> R % 8 & 7];
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
return { data: p, width: r, height: s };
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
const t = e === "tga" ?
|
|
90
|
+
function vt(i, e) {
|
|
91
|
+
const t = e === "tga" ? yt(i) : wt(i), n = new Uint8Array(t.data.length), r = t.width * 4;
|
|
91
92
|
for (let a = 0; a < t.height; a++) n.set(t.data.subarray(a * r, (a + 1) * r), (t.height - 1 - a) * r);
|
|
92
93
|
const s = new ne(n, t.width, t.height);
|
|
93
94
|
return s.flipY = !1, s.generateMipmaps = !0, s.minFilter = ke, s.magFilter = Xe, s.needsUpdate = !0, s;
|
|
94
95
|
}
|
|
95
96
|
let C, O, U;
|
|
96
|
-
class
|
|
97
|
+
class Tt extends J {
|
|
97
98
|
/**
|
|
98
99
|
* Constructs a new FBX loader.
|
|
99
100
|
*
|
|
@@ -129,27 +130,27 @@ class vt extends J {
|
|
|
129
130
|
* @return {Group} An object representing the parsed asset.
|
|
130
131
|
*/
|
|
131
132
|
parse(e, t) {
|
|
132
|
-
if (
|
|
133
|
-
C = new
|
|
133
|
+
if (Ft(e))
|
|
134
|
+
C = new St().parse(e);
|
|
134
135
|
else {
|
|
135
136
|
const r = Le(e);
|
|
136
|
-
if (!
|
|
137
|
+
if (!It(r))
|
|
137
138
|
throw new Error("THREE.FBXLoader: Unknown format.");
|
|
138
139
|
if (xe(r) < 7e3)
|
|
139
140
|
throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + xe(r));
|
|
140
|
-
C = new
|
|
141
|
+
C = new Mt().parse(r);
|
|
141
142
|
}
|
|
142
143
|
const n = new Me(this.manager).setPath(this.resourcePath || t).setCrossOrigin(this.crossOrigin);
|
|
143
|
-
return new
|
|
144
|
+
return new xt(n, this.manager).parse(C);
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
class
|
|
147
|
+
class xt {
|
|
147
148
|
constructor(e, t) {
|
|
148
149
|
this.textureLoader = e, this.manager = t;
|
|
149
150
|
}
|
|
150
151
|
parse() {
|
|
151
152
|
O = this.parseConnections();
|
|
152
|
-
const e = this.parseImages(), t = this.parseTextures(e), n = this.parseMaterials(t), r = this.parseDeformers(), s = new
|
|
153
|
+
const e = this.parseImages(), t = this.parseTextures(e), n = this.parseMaterials(t), r = this.parseDeformers(), s = new Et().parse(r);
|
|
153
154
|
return this.parseScene(r, s, n), U;
|
|
154
155
|
}
|
|
155
156
|
// Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry )
|
|
@@ -441,7 +442,7 @@ class Tt {
|
|
|
441
442
|
l.applyMatrix4(p), l.updateWorldMatrix();
|
|
442
443
|
}
|
|
443
444
|
});
|
|
444
|
-
const o = new
|
|
445
|
+
const o = new bt().parse();
|
|
445
446
|
U.children.length === 1 && U.children[0].isGroup && (U.children[0].animations = o, U = U.children[0]), U.animations = o;
|
|
446
447
|
}
|
|
447
448
|
// parse nodes in FBXTree.Objects.Model
|
|
@@ -658,7 +659,7 @@ class Tt {
|
|
|
658
659
|
}
|
|
659
660
|
}
|
|
660
661
|
}
|
|
661
|
-
class
|
|
662
|
+
class Et {
|
|
662
663
|
constructor() {
|
|
663
664
|
this.negativeMaterialIndices = !1;
|
|
664
665
|
}
|
|
@@ -772,8 +773,8 @@ class xt {
|
|
|
772
773
|
x.forEach(function(S, E, b) {
|
|
773
774
|
if (M > S) {
|
|
774
775
|
b[E] = M, M = S;
|
|
775
|
-
const
|
|
776
|
-
y[E] = v, v =
|
|
776
|
+
const R = y[E];
|
|
777
|
+
y[E] = v, v = R;
|
|
777
778
|
}
|
|
778
779
|
});
|
|
779
780
|
}), T = y, F = x;
|
|
@@ -949,7 +950,7 @@ class xt {
|
|
|
949
950
|
return new re().setFromPoints(f);
|
|
950
951
|
}
|
|
951
952
|
}
|
|
952
|
-
class
|
|
953
|
+
class bt {
|
|
953
954
|
// take raw animation clips and turn them into three.js animation clips
|
|
954
955
|
parse() {
|
|
955
956
|
const e = [], t = this.parseClips();
|
|
@@ -993,7 +994,7 @@ class Et {
|
|
|
993
994
|
for (const n in t) {
|
|
994
995
|
const r = {
|
|
995
996
|
id: t[n].id,
|
|
996
|
-
times: t[n].KeyTime.a.map(
|
|
997
|
+
times: t[n].KeyTime.a.map(At),
|
|
997
998
|
values: t[n].KeyValueFloat.a
|
|
998
999
|
}, s = O.get(r.id);
|
|
999
1000
|
if (s !== void 0) {
|
|
@@ -1202,7 +1203,7 @@ class Et {
|
|
|
1202
1203
|
return [s, a];
|
|
1203
1204
|
}
|
|
1204
1205
|
}
|
|
1205
|
-
class
|
|
1206
|
+
class Mt {
|
|
1206
1207
|
getPrevNode() {
|
|
1207
1208
|
return this.nodeStack[this.currentIndent - 2];
|
|
1208
1209
|
}
|
|
@@ -1297,7 +1298,7 @@ class bt {
|
|
|
1297
1298
|
}, this.setCurrentProp(this.getPrevNode(), s);
|
|
1298
1299
|
}
|
|
1299
1300
|
}
|
|
1300
|
-
class
|
|
1301
|
+
class St {
|
|
1301
1302
|
parse(e) {
|
|
1302
1303
|
const t = new Te(e);
|
|
1303
1304
|
t.skip(23);
|
|
@@ -1525,11 +1526,11 @@ class Pe {
|
|
|
1525
1526
|
this[e] = t;
|
|
1526
1527
|
}
|
|
1527
1528
|
}
|
|
1528
|
-
function
|
|
1529
|
+
function Ft(i) {
|
|
1529
1530
|
const e = "Kaydara FBX Binary \0";
|
|
1530
1531
|
return i.byteLength >= e.length && e === Le(i, 0, e.length);
|
|
1531
1532
|
}
|
|
1532
|
-
function
|
|
1533
|
+
function It(i) {
|
|
1533
1534
|
const e = ["K", "a", "y", "d", "a", "r", "a", "\\", "F", "B", "X", "\\", "B", "i", "n", "a", "r", "y", "\\", "\\"];
|
|
1534
1535
|
let t = 0;
|
|
1535
1536
|
function n(r) {
|
|
@@ -1547,10 +1548,10 @@ function xe(i) {
|
|
|
1547
1548
|
return parseInt(t[1]);
|
|
1548
1549
|
throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.");
|
|
1549
1550
|
}
|
|
1550
|
-
function
|
|
1551
|
+
function At(i) {
|
|
1551
1552
|
return i / 46186158e3;
|
|
1552
1553
|
}
|
|
1553
|
-
const
|
|
1554
|
+
const Rt = [];
|
|
1554
1555
|
function Q(i, e, t, n) {
|
|
1555
1556
|
let r;
|
|
1556
1557
|
switch (n.mappingType) {
|
|
@@ -1571,7 +1572,7 @@ function Q(i, e, t, n) {
|
|
|
1571
1572
|
}
|
|
1572
1573
|
n.referenceType === "IndexToDirect" && (r = n.indices[r]);
|
|
1573
1574
|
const s = r * n.dataSize, a = s + n.dataSize;
|
|
1574
|
-
return Rt
|
|
1575
|
+
return Pt(Rt, n.buffer, s, a);
|
|
1575
1576
|
}
|
|
1576
1577
|
const se = new z(), H = new V();
|
|
1577
1578
|
function Ce(i) {
|
|
@@ -1601,7 +1602,7 @@ function Ce(i) {
|
|
|
1601
1602
|
else if (h === 1)
|
|
1602
1603
|
I.copy(d).multiply(y).multiply(g).multiply(x);
|
|
1603
1604
|
else {
|
|
1604
|
-
const
|
|
1605
|
+
const R = new L().scale(new V().setFromMatrixScale(u)).clone().invert(), w = y.clone().multiply(R);
|
|
1605
1606
|
I.copy(d).multiply(g).multiply(w).multiply(x);
|
|
1606
1607
|
}
|
|
1607
1608
|
const A = p.clone().invert(), M = a.clone().invert();
|
|
@@ -1640,12 +1641,12 @@ function Dt(i, e) {
|
|
|
1640
1641
|
for (let t = 0, n = i.length, r = e.length; t < r; t++, n++)
|
|
1641
1642
|
i[n] = e[t];
|
|
1642
1643
|
}
|
|
1643
|
-
function
|
|
1644
|
+
function Pt(i, e, t, n) {
|
|
1644
1645
|
for (let r = t, s = 0; r < n; r++, s++)
|
|
1645
1646
|
i[s] = e[r];
|
|
1646
1647
|
return i;
|
|
1647
1648
|
}
|
|
1648
|
-
async function
|
|
1649
|
+
async function Ct(i, e, t) {
|
|
1649
1650
|
e.signal.throwIfAborted();
|
|
1650
1651
|
const n = new AbortController(), r = n.signal, s = () => n.abort(e.signal.reason);
|
|
1651
1652
|
e.signal.addEventListener("abort", s, { once: !0 });
|
|
@@ -1669,10 +1670,10 @@ async function Pt(i, e, t) {
|
|
|
1669
1670
|
const x = T(y[0] ?? g), I = e.original;
|
|
1670
1671
|
if (typeof I == "object" && I !== null && "kind" in I && I.kind === "files") {
|
|
1671
1672
|
const M = ((A = e.entryPath) == null ? void 0 : A.replace(/[^/]*$/, "")) ?? "", v = (b) => {
|
|
1672
|
-
const
|
|
1673
|
+
const R = [];
|
|
1673
1674
|
for (const w of T(b).split("/"))
|
|
1674
|
-
w === ".." ?
|
|
1675
|
-
return
|
|
1675
|
+
w === ".." ? R.pop() : w && w !== "." && R.push(w);
|
|
1676
|
+
return R.join("/");
|
|
1676
1677
|
}, S = I.files.filter((b) => v(b.path) === v(M + x));
|
|
1677
1678
|
if (S.length === 1) return e.resolve(S[0].path);
|
|
1678
1679
|
const E = I.files.filter((b) => v(b.path).split("/").pop() === x.split("/").pop());
|
|
@@ -1701,7 +1702,7 @@ async function Pt(i, e, t) {
|
|
|
1701
1702
|
r.throwIfAborted();
|
|
1702
1703
|
let E;
|
|
1703
1704
|
try {
|
|
1704
|
-
E =
|
|
1705
|
+
E = vt(S, this.binaryFormat);
|
|
1705
1706
|
} catch (b) {
|
|
1706
1707
|
throw new Error(`FBX texture decode failed (${this.binaryFormat}): ${d}: ${String(b)}`, { cause: b });
|
|
1707
1708
|
}
|
|
@@ -1711,8 +1712,8 @@ async function Pt(i, e, t) {
|
|
|
1711
1712
|
const v = URL.createObjectURL(await M.blob());
|
|
1712
1713
|
try {
|
|
1713
1714
|
const S = new Me().loadAsync(v).catch((b) => {
|
|
1714
|
-
const
|
|
1715
|
-
throw new Error(`FBX texture decode failed: ${d}${
|
|
1715
|
+
const R = b instanceof Error ? `: ${b.message}` : "";
|
|
1716
|
+
throw new Error(`FBX texture decode failed: ${d}${R}`, { cause: b });
|
|
1716
1717
|
}), E = await a(S, (b) => {
|
|
1717
1718
|
b.dispose();
|
|
1718
1719
|
});
|
|
@@ -1731,7 +1732,7 @@ async function Pt(i, e, t) {
|
|
|
1731
1732
|
u.addHandler(/\.tga$/i, new h("tga")), u.addHandler(/\.dds$/i, new h("dds")), u.addHandler(/.*/, new h());
|
|
1732
1733
|
let m;
|
|
1733
1734
|
try {
|
|
1734
|
-
return m = new
|
|
1735
|
+
return m = new Tt(u).parse(i, ""), await Promise.all(o), e.signal.throwIfAborted(), { root: m, textures: l, textureFailures: f };
|
|
1735
1736
|
} catch (g) {
|
|
1736
1737
|
if (n.abort(g), await Promise.allSettled(o), m) {
|
|
1737
1738
|
const { disposeModelResources: d } = await import("./resources-CHhCm2f7.js");
|
|
@@ -1743,29 +1744,29 @@ async function Pt(i, e, t) {
|
|
|
1743
1744
|
for (const g of p) URL.revokeObjectURL(g);
|
|
1744
1745
|
}
|
|
1745
1746
|
}
|
|
1746
|
-
const oe = "Kaydara FBX Binary \0",
|
|
1747
|
-
function
|
|
1747
|
+
const oe = "Kaydara FBX Binary \0", Lt = /(?:^|[\r\n])\s*P:\s*"UpAxis"\s*,\s*"int"\s*,\s*"Integer"\s*,\s*""\s*,\s*(-?\d+)/i, Ot = /(?:^|[\r\n])\s*P:\s*"UpAxisSign"\s*,\s*"int"\s*,\s*"Integer"\s*,\s*""\s*,\s*(-?\d+)/i;
|
|
1748
|
+
function Ut(i) {
|
|
1748
1749
|
try {
|
|
1749
|
-
const e = new Uint8Array(i), t =
|
|
1750
|
+
const e = new Uint8Array(i), t = Bt(e) ? Xt(i) : kt(new TextDecoder().decode(e));
|
|
1750
1751
|
return !t || t.sign !== 1 ? null : t.axis === 1 ? "y" : t.axis === 2 ? "z" : null;
|
|
1751
1752
|
} catch {
|
|
1752
1753
|
return null;
|
|
1753
1754
|
}
|
|
1754
1755
|
}
|
|
1755
|
-
function
|
|
1756
|
+
function Bt(i) {
|
|
1756
1757
|
if (i.byteLength < oe.length) return !1;
|
|
1757
1758
|
for (let e = 0; e < oe.length; e += 1)
|
|
1758
1759
|
if (i[e] !== oe.charCodeAt(e)) return !1;
|
|
1759
1760
|
return !0;
|
|
1760
1761
|
}
|
|
1761
|
-
function
|
|
1762
|
+
function kt(i) {
|
|
1762
1763
|
var r, s;
|
|
1763
|
-
const e = Number.parseInt(((r =
|
|
1764
|
+
const e = Number.parseInt(((r = Lt.exec(i)) == null ? void 0 : r[1]) ?? "", 10);
|
|
1764
1765
|
if (!Number.isInteger(e)) return null;
|
|
1765
|
-
const t = (s =
|
|
1766
|
+
const t = (s = Ot.exec(i)) == null ? void 0 : s[1], n = t === void 0 ? 1 : Number.parseInt(t, 10);
|
|
1766
1767
|
return Number.isInteger(n) ? { axis: e, sign: n } : null;
|
|
1767
1768
|
}
|
|
1768
|
-
function
|
|
1769
|
+
function Xt(i) {
|
|
1769
1770
|
const e = new DataView(i);
|
|
1770
1771
|
if (e.byteLength < 27) return null;
|
|
1771
1772
|
const t = e.getUint32(23, !0) >= 7500;
|
|
@@ -1806,7 +1807,7 @@ function K(i, e, t, n) {
|
|
|
1806
1807
|
if (n) {
|
|
1807
1808
|
let m = f;
|
|
1808
1809
|
for (let g = 0; g < a; g += 1) {
|
|
1809
|
-
const d =
|
|
1810
|
+
const d = _t(i, m);
|
|
1810
1811
|
if (h.push(d.value), m = d.nextOffset, m > u) return null;
|
|
1811
1812
|
}
|
|
1812
1813
|
}
|
|
@@ -1818,7 +1819,7 @@ function ie(i, e, t) {
|
|
|
1818
1819
|
if (n > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("FBX offset exceeds the safe integer range.");
|
|
1819
1820
|
return Number(n);
|
|
1820
1821
|
}
|
|
1821
|
-
function
|
|
1822
|
+
function _t(i, e) {
|
|
1822
1823
|
const t = String.fromCharCode(i.getUint8(e));
|
|
1823
1824
|
switch (t) {
|
|
1824
1825
|
case "Y":
|
|
@@ -1852,9 +1853,9 @@ function Xt(i, e) {
|
|
|
1852
1853
|
}
|
|
1853
1854
|
}
|
|
1854
1855
|
const te = /* @__PURE__ */ new Set(["Definitions", "ObjectType", "PropertyTemplate", "Objects", "Material", "Properties70", "Connections", "Texture", "Video", "Geometry", "LayerElementUV", "LayeredTexture", "BlendModes", "Alphas"]), Ue = /* @__PURE__ */ new Set(["P", "C", "RelativeFilename", "FileName", "Filename", "ShadingModel", "UVSet", "Scaling", "Translation", "Rotation", "RotationPivot", "ScalingPivot", "Name", "UV", "a"]);
|
|
1855
|
-
function
|
|
1856
|
+
function Vt(i) {
|
|
1856
1857
|
var F, y, x, I, A, M;
|
|
1857
|
-
const e = new Uint8Array(i), n = new TextDecoder().decode(e.subarray(0, 21)) === "Kaydara FBX Binary \0" ?
|
|
1858
|
+
const e = new Uint8Array(i), n = new TextDecoder().decode(e.subarray(0, 21)) === "Kaydara FBX Binary \0" ? Gt(i) : Nt(new TextDecoder().decode(e)), r = (v) => {
|
|
1858
1859
|
var S;
|
|
1859
1860
|
return new Map(
|
|
1860
1861
|
(((S = v == null ? void 0 : v.children.find((E) => E.name === "Properties70")) == null ? void 0 : S.children) ?? []).filter((E) => E.name === "P" && typeof E.values[0] == "string").map((E) => [E.values[0], E.values.slice(4)])
|
|
@@ -1864,17 +1865,17 @@ function _t(i) {
|
|
|
1864
1865
|
return (E = v == null ? void 0 : v.children.find((b) => b.name === S)) == null ? void 0 : E.values[0];
|
|
1865
1866
|
};
|
|
1866
1867
|
for (const v of p.filter((S) => S.name === "Texture")) {
|
|
1867
|
-
const S = Number(v.values[0]), E = (x = l.find((P) => P.values[0] === "OO" && P.values[2] === S)) == null ? void 0 : x.values[1], b = p.find((P) => P.name === "Video" && P.values[0] === E),
|
|
1868
|
+
const S = Number(v.values[0]), E = (x = l.find((P) => P.values[0] === "OO" && P.values[2] === S)) == null ? void 0 : x.values[1], b = p.find((P) => P.name === "Video" && P.values[0] === E), R = String(u(b, "RelativeFilename") || u(v, "RelativeFilename") || u(b, "Filename") || u(v, "FileName") || ""), w = r(v);
|
|
1868
1869
|
for (const P of ["Scaling", "Translation", "Rotation", "RotationPivot", "ScalingPivot"]) {
|
|
1869
1870
|
const _ = (I = v.children.find((Be) => Be.name === P)) == null ? void 0 : I.values;
|
|
1870
1871
|
_ && w.set(P, _);
|
|
1871
1872
|
}
|
|
1872
|
-
const
|
|
1873
|
-
f.set(S, { id: S, path:
|
|
1873
|
+
const D = u(v, "UVSet") ?? ((A = w.get("UVSet")) == null ? void 0 : A[0]);
|
|
1874
|
+
f.set(S, { id: S, path: R, values: w, uvSet: typeof D == "string" ? D : null });
|
|
1874
1875
|
}
|
|
1875
1876
|
const c = /* @__PURE__ */ new Map(), h = (v, S) => {
|
|
1876
|
-
var
|
|
1877
|
-
const E = v.children.find((w) => w.name === S), b = ((
|
|
1877
|
+
var R;
|
|
1878
|
+
const E = v.children.find((w) => w.name === S), b = ((R = E == null ? void 0 : E.children.find((w) => w.name === "a")) == null ? void 0 : R.values) ?? (E == null ? void 0 : E.values) ?? [];
|
|
1878
1879
|
if (b.some((w) => typeof w != "number" || !Number.isFinite(w))) throw new Error(`Invalid FBX layered ${S}.`);
|
|
1879
1880
|
return b;
|
|
1880
1881
|
};
|
|
@@ -1894,14 +1895,14 @@ function _t(i) {
|
|
|
1894
1895
|
if (v.name !== "Material") continue;
|
|
1895
1896
|
const S = v.values[0];
|
|
1896
1897
|
if (typeof S != "number" || !Number.isSafeInteger(S)) throw new Error("Invalid FBX material ID.");
|
|
1897
|
-
const E = r(v), b = l.filter((P) => P.values[0] === "OP" && P.values[2] === S).map((P) => String(P.values[3])),
|
|
1898
|
+
const E = r(v), b = l.filter((P) => P.values[0] === "OP" && P.values[2] === S).map((P) => String(P.values[3])), R = l.filter((P) => P.values[0] === "OP" && P.values[2] === S).map((P) => ({ id: Number(P.values[1]), role: String(P.values[3]) })), w = String(u(v, "ShadingModel") ?? "phong").toLowerCase(), D = r(o.find((P) => String(P.values[0]).toLowerCase() === `fbxsurface${w}`));
|
|
1898
1899
|
m.set(S, {
|
|
1899
|
-
textureConnections:
|
|
1900
|
+
textureConnections: R,
|
|
1900
1901
|
shadingModel: w,
|
|
1901
1902
|
id: S,
|
|
1902
1903
|
name: String(v.values[1] ?? ""),
|
|
1903
1904
|
ownValues: E,
|
|
1904
|
-
values: new Map([...
|
|
1905
|
+
values: new Map([...D, ...E]),
|
|
1905
1906
|
textureRoles: b
|
|
1906
1907
|
});
|
|
1907
1908
|
}
|
|
@@ -1909,15 +1910,15 @@ function _t(i) {
|
|
|
1909
1910
|
for (const v of l) {
|
|
1910
1911
|
const [S, E, b] = v.values;
|
|
1911
1912
|
if (S !== "OO" || typeof E != "number" || typeof b != "number" || !m.has(E)) continue;
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1913
|
+
const R = g.get(b) ?? [];
|
|
1914
|
+
R.push(E), g.set(b, R);
|
|
1914
1915
|
}
|
|
1915
1916
|
const d = /* @__PURE__ */ new Map();
|
|
1916
1917
|
for (const v of p.filter((S) => S.name === "Geometry")) {
|
|
1917
1918
|
const S = new Map(v.children.filter((b) => b.name === "LayerElementUV").map((b) => [Number(b.values[0]), b])), E = [];
|
|
1918
1919
|
for (let b = 0; S.has(b); b++) {
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1920
|
+
const R = S.get(b);
|
|
1921
|
+
R.children.some((w) => w.name === "UV") && E.push(String(u(R, "Name") ?? ""));
|
|
1921
1922
|
}
|
|
1922
1923
|
d.set(Number(v.values[0]), E);
|
|
1923
1924
|
}
|
|
@@ -1928,7 +1929,7 @@ function _t(i) {
|
|
|
1928
1929
|
}
|
|
1929
1930
|
return { materials: m, modelMaterials: g, textures: f, modelUvSets: T, layeredTextures: c };
|
|
1930
1931
|
}
|
|
1931
|
-
function
|
|
1932
|
+
function Gt(i) {
|
|
1932
1933
|
const e = new DataView(i);
|
|
1933
1934
|
if (e.byteLength < 27) throw new Error("Truncated FBX header.");
|
|
1934
1935
|
const t = e.getUint32(23, !0) >= 7500, n = (r, s, a) => {
|
|
@@ -1941,7 +1942,7 @@ function Vt(i) {
|
|
|
1941
1942
|
if (p.endOffset > s) throw new Error("FBX child extends past its parent.");
|
|
1942
1943
|
if (te.has(p.name) || Ue.has(p.name)) {
|
|
1943
1944
|
const f = K(e, l, t, p.name !== "UV");
|
|
1944
|
-
o.push({ name: f.name, values: ["BlendModes", "Alphas"].includes(f.name) ?
|
|
1945
|
+
o.push({ name: f.name, values: ["BlendModes", "Alphas"].includes(f.name) ? $t(e, l, t, f.childrenOffset) : [...f.properties], children: te.has(f.name) ? n(f.childrenOffset, f.endOffset, a + 1) : [] });
|
|
1945
1946
|
}
|
|
1946
1947
|
l = p.endOffset;
|
|
1947
1948
|
}
|
|
@@ -1949,7 +1950,7 @@ function Vt(i) {
|
|
|
1949
1950
|
};
|
|
1950
1951
|
return n(27, e.byteLength, 0);
|
|
1951
1952
|
}
|
|
1952
|
-
function
|
|
1953
|
+
function Nt(i) {
|
|
1953
1954
|
const e = /"(?:\\.|[^"\\])*"|;[^\r\n]*|\r?\n|[^\S\r\n]+|[{}:,]|[^\s{}:,;]+/g;
|
|
1954
1955
|
let t = null;
|
|
1955
1956
|
const n = () => {
|
|
@@ -2011,7 +2012,7 @@ function Gt(i) {
|
|
|
2011
2012
|
};
|
|
2012
2013
|
return s(0);
|
|
2013
2014
|
}
|
|
2014
|
-
function
|
|
2015
|
+
function $t(i, e, t, n) {
|
|
2015
2016
|
const r = t ? 25 : 13;
|
|
2016
2017
|
let s = e + r + i.getUint8(e + r - 1);
|
|
2017
2018
|
if (s === n) return [];
|
|
@@ -2025,10 +2026,10 @@ function Nt(i, e, t, n) {
|
|
|
2025
2026
|
const h = new DataView(c.buffer, c.byteOffset, c.byteLength);
|
|
2026
2027
|
return Array.from({ length: o }, (m, g) => a === "i" ? h.getInt32(g * f, !0) : a === "d" ? h.getFloat64(g * f, !0) : h.getFloat32(g * f, !0));
|
|
2027
2028
|
}
|
|
2028
|
-
const Ee = (i) => i <= 0.04045 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4,
|
|
2029
|
+
const Ee = (i) => i <= 0.04045 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4, zt = (i) => i <= 31308e-7 ? i * 12.92 : 1.055 * i ** (1 / 2.4) - 0.055, jt = /* @__PURE__ */ new Set([0, 1, 2, 4, 5]), Ht = 4 * 1024 * 1024;
|
|
2029
2030
|
function be(i) {
|
|
2030
2031
|
const e = i.image, t = (e == null ? void 0 : e.naturalWidth) || (e == null ? void 0 : e.width), n = (e == null ? void 0 : e.naturalHeight) || (e == null ? void 0 : e.height);
|
|
2031
|
-
if (!t || !n || t * n >
|
|
2032
|
+
if (!t || !n || t * n > Ht) throw new Error("missing image or image exceeds 4M pixels");
|
|
2032
2033
|
let r;
|
|
2033
2034
|
if (e.data) {
|
|
2034
2035
|
if (i.format !== Ie || i.type !== Ae || !(e.data instanceof Uint8Array) || e.data.length !== t * n * 4) throw new Error("require RGBA8 source");
|
|
@@ -2044,10 +2045,10 @@ function be(i) {
|
|
|
2044
2045
|
for (let a = 0; a < n; a++) for (let o = 0; o < t * 4; o++) s[(i.flipY ? n - a - 1 : a) * t * 4 + o] = r[a * t * 4 + o];
|
|
2045
2046
|
return { data: s, width: t, height: n };
|
|
2046
2047
|
}
|
|
2047
|
-
function
|
|
2048
|
+
function Wt(i, e, t) {
|
|
2048
2049
|
if (i.issues.some((u) => u.code !== "LAYERED_TEXTURE_NOT_COMPOSITED")) throw new Error("incompatible layer graph or coordinates");
|
|
2049
2050
|
if (i.layers.length < 1 || i.layers.length > 8) throw new Error("require 1–8 layers");
|
|
2050
|
-
if (!i.layers.every((u) => u.blendMode !== null &&
|
|
2051
|
+
if (!i.layers.every((u) => u.blendMode !== null && jt.has(u.blendMode))) throw new Error("unsupported blend mode");
|
|
2051
2052
|
const n = i.layers.map((u) => {
|
|
2052
2053
|
const c = [...t].find((h) => h.ID === u.textureId);
|
|
2053
2054
|
if (!c) throw new Error(`missing decoded texture ${u.textureId}`);
|
|
@@ -2086,11 +2087,11 @@ function Ht(i, e, t) {
|
|
|
2086
2087
|
}
|
|
2087
2088
|
const p = new Uint8Array(o * 4);
|
|
2088
2089
|
for (let u = 0; u < o; u++) p[u * 4 + 3] = 255;
|
|
2089
|
-
for (let u = 0; u < o; u++) for (let c = 0; c < 3; c++) p[u * 4 + c] = Math.round(255 * Math.min(1, Math.max(0,
|
|
2090
|
+
for (let u = 0; u < o; u++) for (let c = 0; c < 3; c++) p[u * 4 + c] = Math.round(255 * Math.min(1, Math.max(0, zt(l[u * 3 + c]))));
|
|
2090
2091
|
const f = new ne(p, a.width, a.height);
|
|
2091
2092
|
return f.colorSpace = X, f.generateMipmaps = r.generateMipmaps, f.wrapS = r.wrapS, f.wrapT = r.wrapT, f.minFilter = r.minFilter, f.magFilter = r.magFilter, f.anisotropy = r.anisotropy, f.offset.copy(r.offset), f.repeat.copy(r.repeat), f.center.copy(r.center), f.rotation = r.rotation, f.matrix.copy(r.matrix), f.matrixAutoUpdate = r.matrixAutoUpdate, f.channel = r.channel, f.mapping = r.mapping, f.userData.fbxLayerBaseId = i.layers[0].textureId, f.needsUpdate = !0, f;
|
|
2092
2093
|
}
|
|
2093
|
-
function
|
|
2094
|
+
function Yt(i, e) {
|
|
2094
2095
|
return i.textureConnections.flatMap((t) => {
|
|
2095
2096
|
var u;
|
|
2096
2097
|
const n = (u = e.layeredTextures) == null ? void 0 : u.get(t.id);
|
|
@@ -2123,7 +2124,7 @@ function Wt(i, e) {
|
|
|
2123
2124
|
})).size > 1 && s("LAYERED_TEXTURE_COORDINATES_DIFFER", "UV sets or transforms differ; direct pixel blending is unsafe"), [{ id: n.id, role: t.role, layers: n.textureIds.map((c, h) => ({ textureId: c, blendMode: n.blendModes[h] ?? null, alpha: n.alphas[h] ?? null })), issues: r }];
|
|
2124
2125
|
});
|
|
2125
2126
|
}
|
|
2126
|
-
const
|
|
2127
|
+
const qt = {
|
|
2127
2128
|
DiffuseColor: "map",
|
|
2128
2129
|
"Maya|TEX_color_map": "map",
|
|
2129
2130
|
NormalMap: "normalMap",
|
|
@@ -2140,22 +2141,22 @@ const Yt = {
|
|
|
2140
2141
|
TransparentColor: "alphaMap",
|
|
2141
2142
|
TransparencyFactor: "alphaMap"
|
|
2142
2143
|
};
|
|
2143
|
-
function
|
|
2144
|
+
function Kt(i, e, t, n, r, s) {
|
|
2144
2145
|
var c;
|
|
2145
2146
|
const a = (c = n.modelUvSets) == null ? void 0 : c.get(i.ID ?? NaN), o = [], l = [], p = /* @__PURE__ */ new Set();
|
|
2146
2147
|
for (const h of t.textureConnections) {
|
|
2147
|
-
const m =
|
|
2148
|
+
const m = qt[h.role], g = m ? e[m] : void 0, d = n.textures.get(h.id) ?? (g instanceof Y ? n.textures.get(g.userData.fbxLayerBaseId) : void 0);
|
|
2148
2149
|
if (!m || !d || p.has(m)) continue;
|
|
2149
2150
|
p.add(m);
|
|
2150
2151
|
const T = e[m];
|
|
2151
2152
|
if (!(T instanceof Y)) continue;
|
|
2152
|
-
const F = (
|
|
2153
|
+
const F = (R, w) => l.push({ status: "unsupported", code: R, source: `texture:${h.id}:${w}`, target: String(m) });
|
|
2153
2154
|
let y = 0;
|
|
2154
2155
|
if (d.uvSet) {
|
|
2155
|
-
const
|
|
2156
|
-
if (
|
|
2157
|
-
else if (
|
|
2158
|
-
F("UV_SET_UNRESOLVED", `UVSet:${d.uvSet}:${
|
|
2156
|
+
const R = (a == null ? void 0 : a.flatMap((w, D) => w === d.uvSet ? [D] : [])) ?? [];
|
|
2157
|
+
if (R.length === 1) y = R[0];
|
|
2158
|
+
else if (R.length > 1 || d.uvSet !== "default") {
|
|
2159
|
+
F("UV_SET_UNRESOLVED", `UVSet:${d.uvSet}:${R.length > 1 ? "ambiguous" : "missing"}`);
|
|
2159
2160
|
continue;
|
|
2160
2161
|
}
|
|
2161
2162
|
}
|
|
@@ -2163,10 +2164,10 @@ function qt(i, e, t, n, r, s) {
|
|
|
2163
2164
|
F("UV_CHANNEL_UNAVAILABLE", `channel:${y}`);
|
|
2164
2165
|
continue;
|
|
2165
2166
|
}
|
|
2166
|
-
const x = (
|
|
2167
|
-
const
|
|
2168
|
-
return
|
|
2169
|
-
}, I = x("Translation", [T.offset.x, T.offset.y, 0]), A = x("Scaling", [T.repeat.x, T.repeat.y, 1]), M = x("Rotation", [0, 0, 0]), v = x("RotationPivot", [0, 0, 0]), S = x("ScalingPivot", [0, 0, 0]), E = M[0] !== 0 || M[1] !== 0 || v.some((
|
|
2167
|
+
const x = (R, w) => {
|
|
2168
|
+
const D = d.values.get(R);
|
|
2169
|
+
return D ? D.length < 2 || !D.every((P) => typeof P == "number" && Number.isFinite(P)) ? (F("TEXTURE_TRANSFORM_INVALID", R), w) : D : w;
|
|
2170
|
+
}, I = x("Translation", [T.offset.x, T.offset.y, 0]), A = x("Scaling", [T.repeat.x, T.repeat.y, 1]), M = x("Rotation", [0, 0, 0]), v = x("RotationPivot", [0, 0, 0]), S = x("ScalingPivot", [0, 0, 0]), E = M[0] !== 0 || M[1] !== 0 || v.some((R) => R !== 0) || S.some((R) => R !== 0);
|
|
2170
2171
|
E && F("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-rotation-or-pivot"), (I[2] || A[2] !== void 0 && A[2] !== 1) && F("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-translation-or-scale");
|
|
2171
2172
|
const b = E ? 0 : -(M[2] ?? 0) * Math.PI / 180;
|
|
2172
2173
|
b && l.push({ status: "approximate", code: "TEXTURE_ROTATION_PROFILE", source: `texture:${h.id}:Rotation`, target: "T * Rccw * S; origin pivot" }), (y !== T.channel || I[0] !== T.offset.x || I[1] !== T.offset.y || A[0] !== T.repeat.x || A[1] !== T.repeat.y || b !== T.rotation) && o.push({ slot: m, source: T, channel: y, offset: I, scale: A, rotation: b });
|
|
@@ -2194,20 +2195,20 @@ function qt(i, e, t, n, r, s) {
|
|
|
2194
2195
|
}
|
|
2195
2196
|
return f.needsUpdate = !0, f;
|
|
2196
2197
|
}
|
|
2197
|
-
function
|
|
2198
|
+
function Zt(i, e) {
|
|
2198
2199
|
return Math.min(1, Math.max(0, i));
|
|
2199
2200
|
}
|
|
2200
|
-
function
|
|
2201
|
+
function Qt(i, e, t, n, r = "r", s = !1) {
|
|
2201
2202
|
if (!Number.isInteger(e) || !Number.isInteger(t) || e <= 0 || t <= 0 || i.length !== e * t * 4)
|
|
2202
2203
|
throw new Error("Invalid FBX scalar RGBA dimensions.");
|
|
2203
2204
|
const a = new Uint8Array(i.length), o = { r: 0, g: 1, b: 2, a: 3 }[r];
|
|
2204
2205
|
for (let l = 0; l < t; l++) for (let p = 0; p < e; p++) {
|
|
2205
|
-
const f = (l * e + p) * 4, u = ((s ? t - l - 1 : l) * e + p) * 4, c = Math.round(255 *
|
|
2206
|
+
const f = (l * e + p) * 4, u = ((s ? t - l - 1 : l) * e + p) * 4, c = Math.round(255 * Zt(i[f + o] / 255));
|
|
2206
2207
|
a.fill(c, u, u + 4);
|
|
2207
2208
|
}
|
|
2208
2209
|
return a;
|
|
2209
2210
|
}
|
|
2210
|
-
function
|
|
2211
|
+
function Jt(i, e) {
|
|
2211
2212
|
const t = i.image;
|
|
2212
2213
|
if (!t) throw new Error("FBX scalar texture has no decoded image.");
|
|
2213
2214
|
const n = t.naturalWidth || t.width, r = t.naturalHeight || t.height;
|
|
@@ -2224,17 +2225,17 @@ function Qt(i, e) {
|
|
|
2224
2225
|
if (!l) throw new Error("FBX scalar texture conversion requires a 2D canvas.");
|
|
2225
2226
|
l.drawImage(t, 0, 0), s = l.getImageData(0, 0, n, r).data;
|
|
2226
2227
|
}
|
|
2227
|
-
const a = new ne(
|
|
2228
|
+
const a = new ne(Qt(s, n, r, e, "r", i.flipY), n, r);
|
|
2228
2229
|
return a.wrapS = i.wrapS, a.wrapT = i.wrapT, a.offset.copy(i.offset), a.repeat.copy(i.repeat), a.center.copy(i.center), a.rotation = i.rotation, a.matrix.copy(i.matrix), a.matrixAutoUpdate = i.matrixAutoUpdate, a.channel = i.channel, a.magFilter = i.magFilter, a.minFilter = i.minFilter, a.generateMipmaps = i.generateMipmaps, a.anisotropy = i.anisotropy, a.colorSpace = at, a.needsUpdate = !0, a;
|
|
2229
2230
|
}
|
|
2230
|
-
function
|
|
2231
|
+
function en(i, e, t) {
|
|
2231
2232
|
const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), l = [];
|
|
2232
2233
|
try {
|
|
2233
2234
|
i.traverse((c) => {
|
|
2234
2235
|
if (!(c instanceof Fe)) return;
|
|
2235
2236
|
const h = e == null ? void 0 : e.modelMaterials.get(c.ID ?? NaN), m = (d) => h ? e == null ? void 0 : e.materials.get(h[d]) : void 0, g = (d, T) => {
|
|
2236
|
-
const F = m(T), y =
|
|
2237
|
-
return y instanceof
|
|
2237
|
+
const F = m(T), y = tn(d, n, F, t, e, r, s);
|
|
2238
|
+
return y instanceof Re && F && e ? Kt(c, y, F, e, (x) => a.add(x), (x) => o.add(x)) : y;
|
|
2238
2239
|
};
|
|
2239
2240
|
l.push({ mesh: c, material: Array.isArray(c.material) ? c.material.map(g) : g(c.material, 0) });
|
|
2240
2241
|
});
|
|
@@ -2257,26 +2258,26 @@ function Jt(i, e, t) {
|
|
|
2257
2258
|
const u = [...p].flatMap((c) => c.userData.fbxConversionReport ? [c.userData.fbxConversionReport] : []);
|
|
2258
2259
|
return i.userData.fbxConversionReports = u, u;
|
|
2259
2260
|
}
|
|
2260
|
-
function
|
|
2261
|
-
var E, b,
|
|
2261
|
+
function tn(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map()) {
|
|
2262
|
+
var E, b, R;
|
|
2262
2263
|
const o = e.get(i);
|
|
2263
2264
|
if (o) return o;
|
|
2264
2265
|
if (!(i instanceof W) && !(i instanceof Se))
|
|
2265
2266
|
return e.set(i, i), i;
|
|
2266
|
-
const l = i instanceof W ? i : null, p = (w,
|
|
2267
|
+
const l = i instanceof W ? i : null, p = (w, D) => {
|
|
2267
2268
|
var _;
|
|
2268
2269
|
const P = (_ = t == null ? void 0 : t.values.get(w)) == null ? void 0 : _[0];
|
|
2269
|
-
return typeof P == "number" && Number.isFinite(P) ? P :
|
|
2270
|
-
}, f = (w,
|
|
2270
|
+
return typeof P == "number" && Number.isFinite(P) ? P : D;
|
|
2271
|
+
}, f = (w, D) => {
|
|
2271
2272
|
const P = t == null ? void 0 : t.values.get(w);
|
|
2272
|
-
return P && P.length >= 3 && P.slice(0, 3).every((_) => typeof _ == "number" && Number.isFinite(_)) ? new k().setRGB(P[0], P[1], P[2]) :
|
|
2273
|
+
return P && P.length >= 3 && P.slice(0, 3).every((_) => typeof _ == "number" && Number.isFinite(_)) ? new k().setRGB(P[0], P[1], P[2]) : D.clone();
|
|
2273
2274
|
}, u = (w) => Math.min(1, Math.max(0, w)), c = u(p("SpecularFactor", 0.25) * 2), h = Math.sqrt(0.08 * c), m = (1 + h) / (1 - h);
|
|
2274
2275
|
let g = i.opacity;
|
|
2275
2276
|
if (t && (g = 1 - p("TransparencyFactor", 0), g === 0 || g === 1)) {
|
|
2276
2277
|
const w = (E = t.ownValues.get("Opacity")) == null ? void 0 : E[0];
|
|
2277
2278
|
g = typeof w == "number" && Number.isFinite(w) ? w : 1 - f("TransparentColor", new k(0)).r;
|
|
2278
2279
|
}
|
|
2279
|
-
const d = new
|
|
2280
|
+
const d = new Re({
|
|
2280
2281
|
name: i.name,
|
|
2281
2282
|
// FBX diffuse textures supply the base color (as in Blender's importer),
|
|
2282
2283
|
// not an additional tint. Multiplying the atlas by DiffuseColor can turn
|
|
@@ -2315,16 +2316,16 @@ function en(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2315
2316
|
});
|
|
2316
2317
|
e.set(i, d);
|
|
2317
2318
|
const T = (w) => {
|
|
2318
|
-
let
|
|
2319
|
-
return
|
|
2320
|
-
}, F = t && r ?
|
|
2319
|
+
let D = s.get(w);
|
|
2320
|
+
return D || (D = Jt(w, "identity"), s.set(w, D)), D;
|
|
2321
|
+
}, F = t && r ? Yt(t, r) : [], y = [];
|
|
2321
2322
|
for (const w of F)
|
|
2322
|
-
if (!(!["DiffuseColor", "EmissiveColor"].includes(w.role) || !r || !n) && t.textureConnections.filter((
|
|
2323
|
+
if (!(!["DiffuseColor", "EmissiveColor"].includes(w.role) || !r || !n) && t.textureConnections.filter((D) => D.role === w.role).length === 1)
|
|
2323
2324
|
try {
|
|
2324
|
-
let
|
|
2325
|
-
|
|
2326
|
-
} catch (
|
|
2327
|
-
w.issues.push({ status: "unsupported", code: "LAYERED_TEXTURE_BAKE_REJECTED", source: `layered:${w.id}:${
|
|
2325
|
+
let D = a.get(w.id);
|
|
2326
|
+
D || (D = Wt(w, r, n), a.set(w.id, D)), w.role === "DiffuseColor" ? (d.map = D, d.color.setRGB(1, 1, 1)) : (d.emissiveMap = D, d.emissive.setRGB(1, 1, 1)), w.issues = [], y.push(w.id);
|
|
2327
|
+
} catch (D) {
|
|
2328
|
+
w.issues.push({ status: "unsupported", code: "LAYERED_TEXTURE_BAKE_REJECTED", source: `layered:${w.id}:${D instanceof Error ? D.message : String(D)}`, target: w.role });
|
|
2328
2329
|
}
|
|
2329
2330
|
const x = /* @__PURE__ */ new Set(), I = [], A = /* @__PURE__ */ new Set(), M = {
|
|
2330
2331
|
ReflectionFactor: "metalnessMap",
|
|
@@ -2337,8 +2338,8 @@ function en(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2337
2338
|
};
|
|
2338
2339
|
for (const w of (t == null ? void 0 : t.textureConnections) ?? []) {
|
|
2339
2340
|
if ((b = r == null ? void 0 : r.layeredTextures) != null && b.has(w.id)) continue;
|
|
2340
|
-
const
|
|
2341
|
-
if (!
|
|
2341
|
+
const D = [...n ?? []].find((_) => _.ID === w.id);
|
|
2342
|
+
if (!D) {
|
|
2342
2343
|
I.push(`texture:${w.id}:unresolved:${w.role}`);
|
|
2343
2344
|
continue;
|
|
2344
2345
|
}
|
|
@@ -2350,18 +2351,18 @@ function en(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2350
2351
|
switch (P && A.add(P), w.role) {
|
|
2351
2352
|
case "ReflectionFactor":
|
|
2352
2353
|
case "ReflectionColor":
|
|
2353
|
-
d.metalnessMap = T(
|
|
2354
|
+
d.metalnessMap = T(D), d.metalness = 1, x.add(w.role);
|
|
2354
2355
|
break;
|
|
2355
2356
|
case "ShininessExponent":
|
|
2356
|
-
d.roughnessMap = T(
|
|
2357
|
+
d.roughnessMap = T(D), d.roughness = 1, x.add(w.role);
|
|
2357
2358
|
break;
|
|
2358
2359
|
case "SpecularFactor":
|
|
2359
2360
|
case "SpecularColor":
|
|
2360
|
-
d.specularIntensityMap = T(
|
|
2361
|
+
d.specularIntensityMap = T(D), d.ior = (1 + Math.sqrt(0.08)) / (1 - Math.sqrt(0.08)), d.specularIntensity = 1, x.add(w.role);
|
|
2361
2362
|
break;
|
|
2362
2363
|
case "TransparentColor":
|
|
2363
2364
|
case "TransparencyFactor":
|
|
2364
|
-
d.alphaMap = T(
|
|
2365
|
+
d.alphaMap = T(D), d.opacity = 1, d.transparent = !0, x.add(w.role);
|
|
2365
2366
|
break;
|
|
2366
2367
|
}
|
|
2367
2368
|
}
|
|
@@ -2380,7 +2381,7 @@ function en(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2380
2381
|
].includes(w) && !x.has(w))) ?? [];
|
|
2381
2382
|
v.push(...I);
|
|
2382
2383
|
for (const w of (t == null ? void 0 : t.textureConnections) ?? [])
|
|
2383
|
-
!(r == null ? void 0 : r.textures.get(w.id)) && !((
|
|
2384
|
+
!(r == null ? void 0 : r.textures.get(w.id)) && !((R = r == null ? void 0 : r.layeredTextures) != null && R.has(w.id)) && v.push(`texture:${w.id}:layered-or-unknown`);
|
|
2384
2385
|
t && !["phong", "lambert"].includes(t.shadingModel) && v.push(`shader:${t.shadingModel}`), v.length && (d.userData.fbxUnsupportedTextureRoles = v, console.warn(`[viewer] FBX material ${i.name}: unsupported texture semantics: ${v.join(", ")}`));
|
|
2385
2386
|
const S = {
|
|
2386
2387
|
layerStacks: F,
|
|
@@ -2403,7 +2404,7 @@ function en(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2403
2404
|
};
|
|
2404
2405
|
return d.userData.fbxConversionReport = S, d.visible = i.visible, d.toneMapped = i.toneMapped, d.clippingPlanes = i.clippingPlanes, d.clipIntersection = i.clipIntersection, d.clipShadows = i.clipShadows, d.polygonOffset = i.polygonOffset, d.polygonOffsetFactor = i.polygonOffsetFactor, d.polygonOffsetUnits = i.polygonOffsetUnits, d.dithering = i.dithering, d.needsUpdate = !0, e.set(i, d), d;
|
|
2405
2406
|
}
|
|
2406
|
-
function
|
|
2407
|
+
function dn(i, e) {
|
|
2407
2408
|
let t = !1, n = null, r = null, s = "z", a, o = null, l;
|
|
2408
2409
|
const p = () => {
|
|
2409
2410
|
t = !0;
|
|
@@ -2417,10 +2418,10 @@ function fn(i, e) {
|
|
|
2417
2418
|
const m = await fetch(c, { signal: e.signal });
|
|
2418
2419
|
if (!m.ok) throw new Error(`FBX request failed: ${m.status} ${m.statusText}`);
|
|
2419
2420
|
const g = await m.arrayBuffer();
|
|
2420
|
-
s = e.options.upAxis ??
|
|
2421
|
-
const d =
|
|
2421
|
+
s = e.options.upAxis ?? Ut(g) ?? ge(e.format);
|
|
2422
|
+
const d = Vt(g), T = await Ct(g, i, d);
|
|
2422
2423
|
l = T.textures, u.add(T.root);
|
|
2423
|
-
const y =
|
|
2424
|
+
const y = en(u, d, l).flatMap((I) => I.issues.filter((A) => A.status === "unsupported" || A.code === "TEXTURE_ROTATION_PROFILE" || A.code === "LAYERED_TEXTURE_BAKED").map((A) => `${I.materialName || I.materialId || "material"}: ${A.source}`));
|
|
2424
2425
|
y.length && (o = {
|
|
2425
2426
|
code: "W_FBX_MATERIAL_APPROXIMATED",
|
|
2426
2427
|
stage: "material-conversion",
|
|
@@ -2435,7 +2436,9 @@ function fn(i, e) {
|
|
|
2435
2436
|
} else {
|
|
2436
2437
|
const m = new it(), g = new lt();
|
|
2437
2438
|
try {
|
|
2438
|
-
|
|
2439
|
+
m.setDecoderPath(
|
|
2440
|
+
e.options.dracoDecoderPath ?? mt("draco")
|
|
2441
|
+
), g.setDRACOLoader(m);
|
|
2439
2442
|
const d = await g.loadAsync(c), T = d.scenes.filter((F) => F !== d.scene);
|
|
2440
2443
|
if (u.add(d.scene), t || e.signal.aborted) {
|
|
2441
2444
|
for (const F of T) u.add(F);
|
|
@@ -2446,7 +2449,7 @@ function fn(i, e) {
|
|
|
2446
2449
|
}
|
|
2447
2450
|
}
|
|
2448
2451
|
if (t || e.signal.aborted) throw le();
|
|
2449
|
-
ye(u, s),
|
|
2452
|
+
ye(u, s), nn(u);
|
|
2450
2453
|
const h = new ut(u, e.options.simulationTheme, void 0, "model");
|
|
2451
2454
|
h.setCacheInvalidationCallback(e.invalidateTransmissionCaches), n = u, r = h, u = null;
|
|
2452
2455
|
} finally {
|
|
@@ -2504,7 +2507,7 @@ function fn(i, e) {
|
|
|
2504
2507
|
}
|
|
2505
2508
|
};
|
|
2506
2509
|
}
|
|
2507
|
-
function
|
|
2510
|
+
function nn(i) {
|
|
2508
2511
|
i.updateMatrixWorld(!0);
|
|
2509
2512
|
const e = new ot().setFromObject(i);
|
|
2510
2513
|
if (e.isEmpty()) throw new Error("模型不包含可显示的几何内容。");
|
|
@@ -2515,5 +2518,5 @@ function le() {
|
|
|
2515
2518
|
return Object.assign(new Error("Model load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
2516
2519
|
}
|
|
2517
2520
|
export {
|
|
2518
|
-
|
|
2521
|
+
dn as createModelSession
|
|
2519
2522
|
};
|