@nebula-spatial/viewer 0.5.18 → 0.6.1
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 +83 -35
- package/README.md +5 -0
- package/dist/asset-ir-BXa1EdOy.js +637 -0
- package/dist/assets/source-types.d.ts +10 -0
- package/dist/assets/types.d.ts +61 -6
- package/dist/assets/{usd-worker-B6-1I5dT.js → usd-worker-r6Nuoxlk.js} +671 -584
- package/dist/index-CHf9y9eX.js +17406 -0
- package/dist/index.d.ts +21 -2
- package/dist/index.js +29 -18
- package/dist/{mjcf-visual-CtY2Wk3w.js → mjcf-visual-DxMXiBnu.js} +12 -13
- package/dist/mujoco-runtime-BA88JuDR.js +791 -0
- package/dist/physics-guide-size-CplAlsve.js +12 -0
- package/dist/scene/instances.d.ts +36 -0
- package/dist/scene/joints.d.ts +129 -0
- package/dist/scene/session.d.ts +26 -0
- package/dist/scene/types.d.ts +292 -0
- package/dist/session-DLi-MvLB.js +240 -0
- package/dist/{session-DxTeRKCd.js → session-DqEr1CxY.js} +581 -567
- package/dist/session-ZNb3ZYLq.js +562 -0
- package/dist/simulation/physics-runtime-state.d.ts +73 -0
- package/dist/simulation/types.d.ts +151 -0
- package/dist/simulation/usd-dependency-probe.d.ts +42 -0
- package/dist/simulation/usd-inspection.d.ts +66 -0
- package/dist/spark-renderer-BGF_AaI9.js +25 -0
- package/dist/spark.module-kM8pwA1o.js +9278 -0
- package/dist/types.d.ts +75 -1
- package/dist/ui/camera-axis-gizmo.d.ts +5 -0
- package/dist/urdf-session-CKlR-fOQ.js +1230 -0
- package/dist/usd-session-DyNMsD-v.js +11199 -0
- package/dist/version.d.ts +1 -1
- package/dist/visual/classification.d.ts +20 -0
- package/dist/{xacro-x2TeKQ7T.js → xacro-BCLnc3tY.js} +1 -1
- package/openusd/openusd-runtime-manifest.json +6 -6
- package/openusd/openusd_probe.js +1 -1
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +2 -1
- package/runtime-assets.d.mts +9 -9
- package/runtime-assets.mjs +11 -11
- package/vite.d.mts +7 -7
- package/vite.mjs +115 -115
- package/dist/collision-debug-BSJoz5J7.js +0 -2947
- package/dist/index-E8DHSeyT.js +0 -11499
- package/dist/mujoco-runtime-fDWdXNEc.js +0 -739
- package/dist/resources-CHhCm2f7.js +0 -27
- package/dist/session-DB-osaBL.js +0 -801
- package/dist/stage-BnRjc-Rp.js +0 -592
- package/dist/urdf-session-Q_c3Rd1M.js +0 -1264
- package/dist/usd-session-tW3LxVFs.js +0 -10647
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
import { DataTexture as ne, LinearMipmapLinearFilter as
|
|
2
|
-
import { DRACOLoader as
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
import { D as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function De(i, e) {
|
|
14
|
-
if (!i || !e || i * e > gt) throw new Error("Invalid or oversized image dimensions (maximum 16M pixels).");
|
|
1
|
+
import { DataTexture as ne, LinearMipmapLinearFilter as Xe, LinearFilter as _e, Loader as J, LoaderUtils as Ve, FileLoader as Ge, TextureLoader as Se, RepeatWrapping as pe, ClampToEdgeWrapping as fe, Texture as Y, MeshPhongMaterial as W, MeshLambertMaterial as Fe, ColorManagement as N, Color as k, SRGBColorSpace as X, EquirectangularReflectionMapping as Ne, Matrix4 as L, Group as ce, Bone as he, PropertyBinding as ee, Object3D as Z, PerspectiveCamera as $e, PointLight as de, MathUtils as B, SpotLight as ze, DirectionalLight as je, SkinnedMesh as He, Mesh as Ae, LineBasicMaterial as We, Line as Ye, Vector3 as V, Skeleton as qe, AmbientLight as Ke, BufferGeometry as re, Float32BufferAttribute as j, Uint16BufferAttribute as Ze, Matrix3 as Qe, Vector2 as Je, ShapeUtils as et, Vector4 as tt, Euler as z, AnimationClip as nt, Quaternion as G, VectorKeyframeTrack as rt, QuaternionKeyframeTrack as me, NumberKeyframeTrack as st, LoadingManager as at, LinearSRGBColorSpace as ge, RGBAFormat as Ie, UnsignedByteType as Re, NoColorSpace as ot, MeshPhysicalMaterial as De, Box3 as it } from "three";
|
|
2
|
+
import { DRACOLoader as lt } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
3
|
+
import { GLTFLoader as ct } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
import { z as ye, A as we, B as ut, d as ve, D as pt } from "./index-CHf9y9eX.js";
|
|
5
|
+
import { TGALoader as ft } from "three/examples/jsm/loaders/TGALoader.js";
|
|
6
|
+
import * as ht from "three/examples/jsm/libs/fflate.module.js";
|
|
7
|
+
import { unzlibSync as dt } from "three/examples/jsm/libs/fflate.module.js";
|
|
8
|
+
import { NURBSCurve as mt } from "three/examples/jsm/curves/NURBSCurve.js";
|
|
9
|
+
import { r as gt } from "./runtime-paths-Dj0itY6G.js";
|
|
10
|
+
const yt = 16 * 1024 * 1024;
|
|
11
|
+
function Pe(o, e) {
|
|
12
|
+
if (!o || !e || o * e > yt) throw new Error("Invalid or oversized image dimensions (maximum 16M pixels).");
|
|
15
13
|
}
|
|
16
|
-
function $(
|
|
17
|
-
if (e < 0 || t < 0 || e + t >
|
|
14
|
+
function $(o, e, t) {
|
|
15
|
+
if (e < 0 || t < 0 || e + t > o.length) throw new Error("Truncated image payload.");
|
|
18
16
|
}
|
|
19
|
-
function
|
|
20
|
-
const e = new Uint8Array(
|
|
17
|
+
function wt(o) {
|
|
18
|
+
const e = new Uint8Array(o);
|
|
21
19
|
$(e, 0, 18);
|
|
22
|
-
const t = new DataView(
|
|
23
|
-
if (
|
|
20
|
+
const t = new DataView(o), n = e[2], r = e[16], s = t.getUint16(12, !0), a = t.getUint16(14, !0);
|
|
21
|
+
if (Pe(s, a), e[1] !== 0 || ![2, 3, 10, 11].includes(n) || !([3, 11].includes(n) ? [8, 16] : [24, 32]).includes(r) || e[17] & 192)
|
|
24
22
|
throw new Error("Unsupported TGA: require non-interleaved 24/32-bit true-color or 8/16-bit grayscale.");
|
|
25
|
-
let
|
|
23
|
+
let i = 18 + e[0];
|
|
26
24
|
$(e, 18, e[0]);
|
|
27
25
|
const l = r / 8, p = s * a;
|
|
28
|
-
if (n === 2 || n === 3) $(e,
|
|
26
|
+
if (n === 2 || n === 3) $(e, i, p * l);
|
|
29
27
|
else {
|
|
30
28
|
let u = 0;
|
|
31
29
|
for (; u < p; ) {
|
|
32
|
-
$(e,
|
|
33
|
-
const c = e[
|
|
30
|
+
$(e, i, 1);
|
|
31
|
+
const c = e[i++], h = (c & 127) + 1;
|
|
34
32
|
if (u + h > p) throw new Error("Invalid TGA RLE packet length.");
|
|
35
33
|
const m = (c & 128 ? 1 : h) * l;
|
|
36
|
-
$(e,
|
|
34
|
+
$(e, i, m), i += m, u += h;
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
return { data: new
|
|
37
|
+
return { data: new ft().parse(o).data, width: s, height: a };
|
|
40
38
|
}
|
|
41
|
-
function
|
|
42
|
-
const e =
|
|
39
|
+
function Te(o) {
|
|
40
|
+
const e = o >>> 11 & 31, t = o >>> 5 & 63, n = o & 31;
|
|
43
41
|
return [e << 3 | e >>> 2, t << 2 | t >>> 4, n << 3 | n >>> 2, 255];
|
|
44
42
|
}
|
|
45
|
-
function
|
|
46
|
-
const e = new Uint8Array(
|
|
43
|
+
function vt(o) {
|
|
44
|
+
const e = new Uint8Array(o);
|
|
47
45
|
$(e, 0, 128);
|
|
48
|
-
const t = new DataView(
|
|
46
|
+
const t = new DataView(o), n = (h) => t.getUint32(h, !0);
|
|
49
47
|
if (n(0) !== 542327876 || n(4) !== 124 || n(76) !== 32) throw new Error("Invalid DDS header.");
|
|
50
48
|
const r = n(16), s = n(12);
|
|
51
|
-
if (
|
|
52
|
-
const a = n(80),
|
|
53
|
-
if (l && !["DXT1", "DXT3", "DXT5"].includes(
|
|
49
|
+
if (Pe(r, s), n(112) & 2162176 || n(24) > 1) throw new Error("DDS cubemap/volume textures are unsupported.");
|
|
50
|
+
const a = n(80), i = String.fromCharCode(...e.subarray(84, 88)), l = (a & 4) !== 0;
|
|
51
|
+
if (l && !["DXT1", "DXT3", "DXT5"].includes(i)) throw new Error(`Unsupported DDS FourCC: ${i}. Require DXT1/DXT3/DXT5.`);
|
|
54
52
|
const p = new Uint8Array(r * s * 4);
|
|
55
53
|
if (!l) {
|
|
56
54
|
const h = n(88), m = n(92), g = n(96), d = n(100), T = n(104);
|
|
@@ -58,43 +56,43 @@ function wt(i) {
|
|
|
58
56
|
const F = h / 8, y = n(8) & 8 ? n(20) : r * F;
|
|
59
57
|
if (y < r * F) throw new Error("Invalid DDS row pitch.");
|
|
60
58
|
$(e, 128, y * s);
|
|
61
|
-
for (let x = 0; x < s; x++) for (let
|
|
62
|
-
const
|
|
63
|
-
p[
|
|
59
|
+
for (let x = 0; x < s; x++) for (let A = 0; A < r; A++) {
|
|
60
|
+
const I = 128 + x * y + A * F, b = (x * r + A) * 4;
|
|
61
|
+
p[b] = e[I + (m === 255 ? 0 : 2)], p[b + 1] = e[I + 1], p[b + 2] = e[I + (d === 255 ? 0 : 2)], p[b + 3] = T && a & 1 ? e[I + 3] : 255;
|
|
64
62
|
}
|
|
65
63
|
return { data: p, width: r, height: s };
|
|
66
64
|
}
|
|
67
|
-
const f =
|
|
65
|
+
const f = i === "DXT1" ? 8 : 16, u = Math.ceil(r / 4), c = Math.ceil(s / 4);
|
|
68
66
|
$(e, 128, u * c * f);
|
|
69
67
|
for (let h = 0; h < c; h++) for (let m = 0; m < u; m++) {
|
|
70
|
-
const g = 128 + (h * u + m) * f, d = g + (f === 8 ? 0 : 8), T = t.getUint16(d, !0), F = t.getUint16(d + 2, !0), y = [
|
|
71
|
-
y.push([0, 1, 2].map((
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
for (let v = 1; v <=
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
for (let
|
|
79
|
-
const v = m * 4 +
|
|
68
|
+
const g = 128 + (h * u + m) * f, d = g + (f === 8 ? 0 : 8), T = t.getUint16(d, !0), F = t.getUint16(d + 2, !0), y = [Te(T), Te(F)], x = i !== "DXT1" || T > F;
|
|
69
|
+
y.push([0, 1, 2].map((b) => Math.floor(x ? (2 * y[0][b] + y[1][b]) / 3 : (y[0][b] + y[1][b]) / 2)).concat(255)), y.push(x ? [0, 1, 2].map((b) => Math.floor((y[0][b] + 2 * y[1][b]) / 3)).concat(255) : [0, 0, 0, 0]);
|
|
70
|
+
const A = n(d + 4), I = [e[g], e[g + 1]];
|
|
71
|
+
if (i === "DXT5") {
|
|
72
|
+
const b = I[0] > I[1] ? 6 : 4;
|
|
73
|
+
for (let v = 1; v <= b; v++) I.push(Math.floor(((b + 1 - v) * I[0] + v * I[1]) / (b + 1)));
|
|
74
|
+
b === 4 && I.push(0, 255);
|
|
75
|
+
}
|
|
76
|
+
for (let b = 0; b < 16; b++) {
|
|
77
|
+
const v = m * 4 + b % 4, S = h * 4 + Math.floor(b / 4);
|
|
80
78
|
if (v >= r || S >= s) continue;
|
|
81
|
-
const E = y[
|
|
82
|
-
if (p.set(E,
|
|
83
|
-
const R =
|
|
84
|
-
p[
|
|
79
|
+
const E = y[A >>> 2 * b & 3], M = (S * r + v) * 4;
|
|
80
|
+
if (p.set(E, M), i === "DXT3" && (p[M + 3] = (e[g + Math.floor(b / 2)] >>> b % 2 * 4 & 15) * 17), i === "DXT5") {
|
|
81
|
+
const R = b * 3, w = g + 2 + Math.floor(R / 8), D = e[w] | (w + 1 < g + 8 ? e[w + 1] : 0) << 8;
|
|
82
|
+
p[M + 3] = I[D >>> R % 8 & 7];
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
return { data: p, width: r, height: s };
|
|
89
87
|
}
|
|
90
|
-
function
|
|
91
|
-
const t = e === "tga" ?
|
|
88
|
+
function Tt(o, e) {
|
|
89
|
+
const t = e === "tga" ? wt(o) : vt(o), n = new Uint8Array(t.data.length), r = t.width * 4;
|
|
92
90
|
for (let a = 0; a < t.height; a++) n.set(t.data.subarray(a * r, (a + 1) * r), (t.height - 1 - a) * r);
|
|
93
91
|
const s = new ne(n, t.width, t.height);
|
|
94
|
-
return s.flipY = !1, s.generateMipmaps = !0, s.minFilter =
|
|
92
|
+
return s.flipY = !1, s.generateMipmaps = !0, s.minFilter = Xe, s.magFilter = _e, s.needsUpdate = !0, s;
|
|
95
93
|
}
|
|
96
|
-
let C,
|
|
97
|
-
class
|
|
94
|
+
let C, U, O;
|
|
95
|
+
class xt extends J {
|
|
98
96
|
/**
|
|
99
97
|
* Constructs a new FBX loader.
|
|
100
98
|
*
|
|
@@ -113,8 +111,8 @@ class Tt extends J {
|
|
|
113
111
|
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
114
112
|
*/
|
|
115
113
|
load(e, t, n, r) {
|
|
116
|
-
const s = this, a = s.path === "" ?
|
|
117
|
-
|
|
114
|
+
const s = this, a = s.path === "" ? Ve.extractUrlBase(e) : s.path, i = new Ge(this.manager);
|
|
115
|
+
i.setPath(s.path), i.setResponseType("arraybuffer"), i.setRequestHeader(s.requestHeader), i.setWithCredentials(s.withCredentials), i.load(e, function(l) {
|
|
118
116
|
try {
|
|
119
117
|
t(s.parse(l, a));
|
|
120
118
|
} catch (p) {
|
|
@@ -130,28 +128,28 @@ class Tt extends J {
|
|
|
130
128
|
* @return {Group} An object representing the parsed asset.
|
|
131
129
|
*/
|
|
132
130
|
parse(e, t) {
|
|
133
|
-
if (
|
|
134
|
-
C = new
|
|
131
|
+
if (At(e))
|
|
132
|
+
C = new Ft().parse(e);
|
|
135
133
|
else {
|
|
136
|
-
const r =
|
|
134
|
+
const r = Ue(e);
|
|
137
135
|
if (!It(r))
|
|
138
136
|
throw new Error("THREE.FBXLoader: Unknown format.");
|
|
139
|
-
if (
|
|
140
|
-
throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " +
|
|
141
|
-
C = new
|
|
137
|
+
if (Ee(r) < 7e3)
|
|
138
|
+
throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + Ee(r));
|
|
139
|
+
C = new St().parse(r);
|
|
142
140
|
}
|
|
143
|
-
const n = new
|
|
144
|
-
return new
|
|
141
|
+
const n = new Se(this.manager).setPath(this.resourcePath || t).setCrossOrigin(this.crossOrigin);
|
|
142
|
+
return new Et(n, this.manager).parse(C);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
|
-
class
|
|
145
|
+
class Et {
|
|
148
146
|
constructor(e, t) {
|
|
149
147
|
this.textureLoader = e, this.manager = t;
|
|
150
148
|
}
|
|
151
149
|
parse() {
|
|
152
|
-
|
|
153
|
-
const e = this.parseImages(), t = this.parseTextures(e), n = this.parseMaterials(t), r = this.parseDeformers(), s = new
|
|
154
|
-
return this.parseScene(r, s, n),
|
|
150
|
+
U = this.parseConnections();
|
|
151
|
+
const e = this.parseImages(), t = this.parseTextures(e), n = this.parseMaterials(t), r = this.parseDeformers(), s = new bt().parse(r);
|
|
152
|
+
return this.parseScene(r, s, n), O;
|
|
155
153
|
}
|
|
156
154
|
// Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry )
|
|
157
155
|
// and details the connection type
|
|
@@ -163,8 +161,8 @@ class xt {
|
|
|
163
161
|
parents: [],
|
|
164
162
|
children: []
|
|
165
163
|
});
|
|
166
|
-
const
|
|
167
|
-
e.get(r).parents.push(
|
|
164
|
+
const i = { ID: s, relationship: a };
|
|
165
|
+
e.get(r).parents.push(i), e.has(s) || e.set(s, {
|
|
168
166
|
parents: [],
|
|
169
167
|
children: []
|
|
170
168
|
});
|
|
@@ -182,8 +180,8 @@ class xt {
|
|
|
182
180
|
for (const r in n) {
|
|
183
181
|
const s = n[r], a = parseInt(r);
|
|
184
182
|
if (e[a] = s.RelativeFilename || s.Filename, "Content" in s) {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
183
|
+
const i = s.Content instanceof ArrayBuffer && s.Content.byteLength > 0, l = typeof s.Content == "string" && s.Content !== "";
|
|
184
|
+
if (i || l) {
|
|
187
185
|
const p = this.parseImage(n[r]);
|
|
188
186
|
t[s.RelativeFilename || s.Filename] = p;
|
|
189
187
|
}
|
|
@@ -249,8 +247,8 @@ class xt {
|
|
|
249
247
|
parseTexture(e, t) {
|
|
250
248
|
const n = this.loadTexture(e, t);
|
|
251
249
|
n.ID = e.id, n.name = e.attrName;
|
|
252
|
-
const r = e.WrapModeU, s = e.WrapModeV, a = r !== void 0 ? r.value : 0,
|
|
253
|
-
if (n.wrapS = a === 0 ?
|
|
250
|
+
const r = e.WrapModeU, s = e.WrapModeV, a = r !== void 0 ? r.value : 0, i = s !== void 0 ? s.value : 0;
|
|
251
|
+
if (n.wrapS = a === 0 ? pe : fe, n.wrapT = i === 0 ? pe : fe, "Scaling" in e) {
|
|
254
252
|
const l = e.Scaling.value;
|
|
255
253
|
n.repeat.x = l[0], n.repeat.y = l[1];
|
|
256
254
|
}
|
|
@@ -267,11 +265,11 @@ class xt {
|
|
|
267
265
|
r === null && (r = this.textureLoader);
|
|
268
266
|
const s = r.path;
|
|
269
267
|
s || r.setPath(this.textureLoader.path);
|
|
270
|
-
const a =
|
|
271
|
-
let
|
|
272
|
-
if (a !== void 0 && a.length > 0 && t[a[0].ID] !== void 0 && (
|
|
268
|
+
const a = U.get(e.id).children;
|
|
269
|
+
let i;
|
|
270
|
+
if (a !== void 0 && a.length > 0 && t[a[0].ID] !== void 0 && (i = t[a[0].ID], (i.indexOf("blob:") === 0 || i.indexOf("data:") === 0) && r.setPath(void 0)), i === void 0)
|
|
273
271
|
return console.warn("FBXLoader: Undefined filename, creating placeholder texture."), new Y();
|
|
274
|
-
const l = r.load(
|
|
272
|
+
const l = r.load(i);
|
|
275
273
|
return r.setPath(s), l;
|
|
276
274
|
}
|
|
277
275
|
// Parse nodes in FBXTree.Objects.Material
|
|
@@ -292,21 +290,21 @@ class xt {
|
|
|
292
290
|
parseMaterial(e, t) {
|
|
293
291
|
const n = e.id, r = e.attrName;
|
|
294
292
|
let s = e.ShadingModel;
|
|
295
|
-
if (typeof s == "object" && (s = s.value), !
|
|
293
|
+
if (typeof s == "object" && (s = s.value), !U.has(n)) return null;
|
|
296
294
|
const a = this.parseParameters(e, t, n);
|
|
297
|
-
let
|
|
295
|
+
let i;
|
|
298
296
|
switch (s.toLowerCase()) {
|
|
299
297
|
case "phong":
|
|
300
|
-
|
|
298
|
+
i = new W();
|
|
301
299
|
break;
|
|
302
300
|
case "lambert":
|
|
303
|
-
|
|
301
|
+
i = new Fe();
|
|
304
302
|
break;
|
|
305
303
|
default:
|
|
306
|
-
console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', s),
|
|
304
|
+
console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', s), i = new W();
|
|
307
305
|
break;
|
|
308
306
|
}
|
|
309
|
-
return
|
|
307
|
+
return i.setValues(a), i.name = r, i;
|
|
310
308
|
}
|
|
311
309
|
// Parse FBX material and return parameters suitable for a three.js material
|
|
312
310
|
// Also parse the texture map and return any textures associated with the material
|
|
@@ -314,9 +312,9 @@ class xt {
|
|
|
314
312
|
const r = {};
|
|
315
313
|
e.BumpFactor && (r.bumpScale = e.BumpFactor.value), e.Diffuse ? r.color = N.colorSpaceToWorking(new k().fromArray(e.Diffuse.value), X) : e.DiffuseColor && (e.DiffuseColor.type === "Color" || e.DiffuseColor.type === "ColorRGB") && (r.color = N.colorSpaceToWorking(new k().fromArray(e.DiffuseColor.value), X)), e.DisplacementFactor && (r.displacementScale = e.DisplacementFactor.value), e.Emissive ? r.emissive = N.colorSpaceToWorking(new k().fromArray(e.Emissive.value), X) : e.EmissiveColor && (e.EmissiveColor.type === "Color" || e.EmissiveColor.type === "ColorRGB") && (r.emissive = N.colorSpaceToWorking(new k().fromArray(e.EmissiveColor.value), X)), e.EmissiveFactor && (r.emissiveIntensity = parseFloat(e.EmissiveFactor.value)), r.opacity = 1 - (e.TransparencyFactor ? parseFloat(e.TransparencyFactor.value) : 0), (r.opacity === 1 || r.opacity === 0) && (r.opacity = e.Opacity ? parseFloat(e.Opacity.value) : null, r.opacity === null && (r.opacity = 1 - (e.TransparentColor ? parseFloat(e.TransparentColor.value[0]) : 0))), r.opacity < 1 && (r.transparent = !0), e.ReflectionFactor && (r.reflectivity = e.ReflectionFactor.value), e.Shininess && (r.shininess = e.Shininess.value), e.Specular ? r.specular = N.colorSpaceToWorking(new k().fromArray(e.Specular.value), X) : e.SpecularColor && e.SpecularColor.type === "Color" && (r.specular = N.colorSpaceToWorking(new k().fromArray(e.SpecularColor.value), X));
|
|
316
314
|
const s = this;
|
|
317
|
-
return
|
|
318
|
-
const
|
|
319
|
-
switch (
|
|
315
|
+
return U.get(n).children.forEach(function(a) {
|
|
316
|
+
const i = a.relationship;
|
|
317
|
+
switch (i) {
|
|
320
318
|
case "Bump":
|
|
321
319
|
r.bumpMap = s.getTexture(t, a.ID);
|
|
322
320
|
break;
|
|
@@ -338,7 +336,7 @@ class xt {
|
|
|
338
336
|
r.normalMap = s.getTexture(t, a.ID);
|
|
339
337
|
break;
|
|
340
338
|
case "ReflectionColor":
|
|
341
|
-
r.envMap = s.getTexture(t, a.ID), r.envMap !== void 0 && (r.envMap.mapping =
|
|
339
|
+
r.envMap = s.getTexture(t, a.ID), r.envMap !== void 0 && (r.envMap.mapping = Ne, r.envMap.colorSpace = X);
|
|
342
340
|
break;
|
|
343
341
|
case "SpecularColor":
|
|
344
342
|
r.specularMap = s.getTexture(t, a.ID), r.specularMap !== void 0 && (r.specularMap.colorSpace = X);
|
|
@@ -352,14 +350,14 @@ class xt {
|
|
|
352
350
|
case "SpecularFactor":
|
|
353
351
|
case "VectorDisplacementColor":
|
|
354
352
|
default:
|
|
355
|
-
console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",
|
|
353
|
+
console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.", i);
|
|
356
354
|
break;
|
|
357
355
|
}
|
|
358
356
|
}), r;
|
|
359
357
|
}
|
|
360
358
|
// get a texture from the textureMap for use by a material.
|
|
361
359
|
getTexture(e, t) {
|
|
362
|
-
return "LayeredTexture" in C.Objects && t in C.Objects.LayeredTexture && (console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."), t =
|
|
360
|
+
return "LayeredTexture" in C.Objects && t in C.Objects.LayeredTexture && (console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."), t = U.get(t).children[0].ID), e.get(t);
|
|
363
361
|
}
|
|
364
362
|
// Parse nodes in FBXTree.Objects.Deformer
|
|
365
363
|
// Deformer node can contain skinning or Vertex Cache animation data, however only skinning is supported here
|
|
@@ -369,15 +367,15 @@ class xt {
|
|
|
369
367
|
if ("Deformer" in C.Objects) {
|
|
370
368
|
const n = C.Objects.Deformer;
|
|
371
369
|
for (const r in n) {
|
|
372
|
-
const s = n[r], a =
|
|
370
|
+
const s = n[r], a = U.get(parseInt(r));
|
|
373
371
|
if (s.attrType === "Skin") {
|
|
374
|
-
const
|
|
375
|
-
|
|
372
|
+
const i = this.parseSkeleton(a, n);
|
|
373
|
+
i.ID = r, a.parents.length > 1 && console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."), i.geometryID = a.parents[0].ID, e[r] = i;
|
|
376
374
|
} else if (s.attrType === "BlendShape") {
|
|
377
|
-
const
|
|
375
|
+
const i = {
|
|
378
376
|
id: r
|
|
379
377
|
};
|
|
380
|
-
|
|
378
|
+
i.rawTargets = this.parseMorphTargets(a, n), i.id = r, a.parents.length > 1 && console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."), t[r] = i;
|
|
381
379
|
}
|
|
382
380
|
}
|
|
383
381
|
}
|
|
@@ -412,46 +410,46 @@ class xt {
|
|
|
412
410
|
parseMorphTargets(e, t) {
|
|
413
411
|
const n = [];
|
|
414
412
|
for (let r = 0; r < e.children.length; r++) {
|
|
415
|
-
const s = e.children[r], a = t[s.ID],
|
|
413
|
+
const s = e.children[r], a = t[s.ID], i = {
|
|
416
414
|
name: a.attrName,
|
|
417
415
|
initialWeight: a.DeformPercent,
|
|
418
416
|
id: a.id,
|
|
419
417
|
fullWeights: a.FullWeights.a
|
|
420
418
|
};
|
|
421
419
|
if (a.attrType !== "BlendShapeChannel") return;
|
|
422
|
-
|
|
420
|
+
i.geoID = U.get(parseInt(s.ID)).children.filter(function(l) {
|
|
423
421
|
return l.relationship === void 0;
|
|
424
|
-
})[0].ID, n.push(
|
|
422
|
+
})[0].ID, n.push(i);
|
|
425
423
|
}
|
|
426
424
|
return n;
|
|
427
425
|
}
|
|
428
426
|
// create the main Group() to be returned by the loader
|
|
429
427
|
parseScene(e, t, n) {
|
|
430
|
-
|
|
428
|
+
O = new ce();
|
|
431
429
|
const r = this.parseModels(e.skeletons, t, n), s = C.Objects.Model, a = this;
|
|
432
430
|
r.forEach(function(l) {
|
|
433
431
|
const p = s[l.ID];
|
|
434
|
-
a.setLookAtProperties(l, p),
|
|
432
|
+
a.setLookAtProperties(l, p), U.get(l.ID).parents.forEach(function(u) {
|
|
435
433
|
const c = r.get(u.ID);
|
|
436
434
|
c !== void 0 && c.add(l);
|
|
437
|
-
}), l.parent === null &&
|
|
438
|
-
}), this.bindSkeleton(e.skeletons, t, r), this.addGlobalSceneSettings(),
|
|
435
|
+
}), l.parent === null && O.add(l);
|
|
436
|
+
}), this.bindSkeleton(e.skeletons, t, r), this.addGlobalSceneSettings(), O.traverse(function(l) {
|
|
439
437
|
if (l.userData.transformData) {
|
|
440
438
|
l.parent && (l.userData.transformData.parentMatrix = l.parent.matrix, l.userData.transformData.parentMatrixWorld = l.parent.matrixWorld);
|
|
441
|
-
const p =
|
|
439
|
+
const p = Le(l.userData.transformData);
|
|
442
440
|
l.applyMatrix4(p), l.updateWorldMatrix();
|
|
443
441
|
}
|
|
444
442
|
});
|
|
445
|
-
const
|
|
446
|
-
|
|
443
|
+
const i = new Mt().parse();
|
|
444
|
+
O.children.length === 1 && O.children[0].isGroup && (O.children[0].animations = i, O = O.children[0]), O.animations = i;
|
|
447
445
|
}
|
|
448
446
|
// parse nodes in FBXTree.Objects.Model
|
|
449
447
|
parseModels(e, t, n) {
|
|
450
448
|
const r = /* @__PURE__ */ new Map(), s = C.Objects.Model;
|
|
451
449
|
for (const a in s) {
|
|
452
|
-
const
|
|
450
|
+
const i = parseInt(a), l = s[a], p = U.get(i);
|
|
453
451
|
if (p === void 0) continue;
|
|
454
|
-
let f = this.buildSkeleton(p, e,
|
|
452
|
+
let f = this.buildSkeleton(p, e, i, l.attrName);
|
|
455
453
|
if (!f) {
|
|
456
454
|
switch (l.attrType) {
|
|
457
455
|
case "Camera":
|
|
@@ -468,28 +466,28 @@ class xt {
|
|
|
468
466
|
break;
|
|
469
467
|
case "LimbNode":
|
|
470
468
|
case "Root":
|
|
471
|
-
f = new
|
|
469
|
+
f = new he();
|
|
472
470
|
break;
|
|
473
471
|
case "Null":
|
|
474
472
|
default:
|
|
475
473
|
f = new ce();
|
|
476
474
|
break;
|
|
477
475
|
}
|
|
478
|
-
f.name = l.attrName ? ee.sanitizeNodeName(l.attrName) : "", f.userData.originalName = l.attrName, f.ID =
|
|
476
|
+
f.name = l.attrName ? ee.sanitizeNodeName(l.attrName) : "", f.userData.originalName = l.attrName, f.ID = i;
|
|
479
477
|
}
|
|
480
|
-
this.getTransformData(f, l), r.set(
|
|
478
|
+
this.getTransformData(f, l), r.set(i, f);
|
|
481
479
|
}
|
|
482
480
|
return r;
|
|
483
481
|
}
|
|
484
482
|
buildSkeleton(e, t, n, r) {
|
|
485
483
|
let s = null;
|
|
486
484
|
return e.parents.forEach(function(a) {
|
|
487
|
-
for (const
|
|
488
|
-
const l = t[
|
|
485
|
+
for (const i in t) {
|
|
486
|
+
const l = t[i];
|
|
489
487
|
l.rawBones.forEach(function(p, f) {
|
|
490
488
|
if (p.ID === a.ID) {
|
|
491
489
|
const u = s;
|
|
492
|
-
s = new
|
|
490
|
+
s = new he(), s.matrixWorld.copy(p.transformLink), s.name = r ? ee.sanitizeNodeName(r) : "", s.userData.originalName = r, s.ID = n, l.bones[f] = s, u !== null && s.add(u);
|
|
493
491
|
}
|
|
494
492
|
});
|
|
495
493
|
}
|
|
@@ -510,15 +508,15 @@ class xt {
|
|
|
510
508
|
n.NearPlane !== void 0 && (s = n.NearPlane.value / 1e3);
|
|
511
509
|
let a = 1e3;
|
|
512
510
|
n.FarPlane !== void 0 && (a = n.FarPlane.value / 1e3);
|
|
513
|
-
let
|
|
514
|
-
n.AspectWidth !== void 0 && n.AspectHeight !== void 0 && (
|
|
515
|
-
const p =
|
|
511
|
+
let i = window.innerWidth, l = window.innerHeight;
|
|
512
|
+
n.AspectWidth !== void 0 && n.AspectHeight !== void 0 && (i = n.AspectWidth.value, l = n.AspectHeight.value);
|
|
513
|
+
const p = i / l;
|
|
516
514
|
let f = 45;
|
|
517
515
|
n.FieldOfView !== void 0 && (f = n.FieldOfView.value);
|
|
518
516
|
const u = n.FocalLength ? n.FocalLength.value : null;
|
|
519
517
|
switch (r) {
|
|
520
518
|
case 0:
|
|
521
|
-
t = new
|
|
519
|
+
t = new $e(f, p, s, a), u !== null && t.setFocalLength(u);
|
|
522
520
|
break;
|
|
523
521
|
case 1:
|
|
524
522
|
console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."), t = new Z();
|
|
@@ -545,24 +543,24 @@ class xt {
|
|
|
545
543
|
n.Color !== void 0 && (s = N.colorSpaceToWorking(new k().fromArray(n.Color.value), X));
|
|
546
544
|
let a = n.Intensity === void 0 ? 1 : n.Intensity.value / 100;
|
|
547
545
|
n.CastLightOnObject !== void 0 && n.CastLightOnObject.value === 0 && (a = 0);
|
|
548
|
-
let
|
|
549
|
-
n.FarAttenuationEnd !== void 0 && (n.EnableFarAttenuation !== void 0 && n.EnableFarAttenuation.value === 0 ?
|
|
546
|
+
let i = 0;
|
|
547
|
+
n.FarAttenuationEnd !== void 0 && (n.EnableFarAttenuation !== void 0 && n.EnableFarAttenuation.value === 0 ? i = 0 : i = n.FarAttenuationEnd.value);
|
|
550
548
|
const l = 1;
|
|
551
549
|
switch (r) {
|
|
552
550
|
case 0:
|
|
553
|
-
t = new
|
|
551
|
+
t = new de(s, a, i, l);
|
|
554
552
|
break;
|
|
555
553
|
case 1:
|
|
556
|
-
t = new
|
|
554
|
+
t = new je(s, a);
|
|
557
555
|
break;
|
|
558
556
|
case 2:
|
|
559
557
|
let p = Math.PI / 3;
|
|
560
558
|
n.InnerAngle !== void 0 && (p = B.degToRad(n.InnerAngle.value));
|
|
561
559
|
let f = 0;
|
|
562
|
-
n.OuterAngle !== void 0 && (f = B.degToRad(n.OuterAngle.value), f = Math.max(f, 1)), t = new
|
|
560
|
+
n.OuterAngle !== void 0 && (f = B.degToRad(n.OuterAngle.value), f = Math.max(f, 1)), t = new ze(s, a, i, p, f, l);
|
|
563
561
|
break;
|
|
564
562
|
default:
|
|
565
|
-
console.warn("THREE.FBXLoader: Unknown light type " + n.LightType.value + ", defaulting to a PointLight."), t = new
|
|
563
|
+
console.warn("THREE.FBXLoader: Unknown light type " + n.LightType.value + ", defaulting to a PointLight."), t = new de(s, a);
|
|
566
564
|
break;
|
|
567
565
|
}
|
|
568
566
|
n.CastShadows !== void 0 && n.CastShadows.value === 1 && (t.castShadow = !0);
|
|
@@ -571,36 +569,36 @@ class xt {
|
|
|
571
569
|
}
|
|
572
570
|
createMesh(e, t, n) {
|
|
573
571
|
let r, s = null, a = null;
|
|
574
|
-
const
|
|
572
|
+
const i = [];
|
|
575
573
|
if (e.children.forEach(function(l) {
|
|
576
|
-
t.has(l.ID) && (s = t.get(l.ID)), n.has(l.ID) &&
|
|
577
|
-
}),
|
|
574
|
+
t.has(l.ID) && (s = t.get(l.ID)), n.has(l.ID) && i.push(n.get(l.ID));
|
|
575
|
+
}), i.length > 1 ? a = i : i.length > 0 ? a = i[0] : (a = new W({
|
|
578
576
|
name: J.DEFAULT_MATERIAL_NAME,
|
|
579
577
|
color: 13421772
|
|
580
|
-
}),
|
|
578
|
+
}), i.push(a)), "color" in s.attributes && i.forEach(function(l) {
|
|
581
579
|
l.vertexColors = !0;
|
|
582
580
|
}), s.groups.length > 0) {
|
|
583
581
|
let l = !1;
|
|
584
582
|
for (let p = 0, f = s.groups.length; p < f; p++) {
|
|
585
583
|
const u = s.groups[p];
|
|
586
|
-
(u.materialIndex < 0 || u.materialIndex >=
|
|
584
|
+
(u.materialIndex < 0 || u.materialIndex >= i.length) && (u.materialIndex = i.length, l = !0);
|
|
587
585
|
}
|
|
588
586
|
if (l) {
|
|
589
587
|
const p = new W();
|
|
590
|
-
|
|
588
|
+
i.push(p);
|
|
591
589
|
}
|
|
592
590
|
}
|
|
593
|
-
return s.FBX_Deformer ? (r = new
|
|
591
|
+
return s.FBX_Deformer ? (r = new He(s, a), r.normalizeSkinWeights()) : r = new Ae(s, a), r;
|
|
594
592
|
}
|
|
595
593
|
createCurve(e, t) {
|
|
596
594
|
const n = e.children.reduce(function(s, a) {
|
|
597
595
|
return t.has(a.ID) && (s = t.get(a.ID)), s;
|
|
598
|
-
}, null), r = new
|
|
596
|
+
}, null), r = new We({
|
|
599
597
|
name: J.DEFAULT_MATERIAL_NAME,
|
|
600
598
|
color: 3342591,
|
|
601
599
|
linewidth: 1
|
|
602
600
|
});
|
|
603
|
-
return new
|
|
601
|
+
return new Ye(n, r);
|
|
604
602
|
}
|
|
605
603
|
// parse the model node for transform data
|
|
606
604
|
getTransformData(e, t) {
|
|
@@ -608,12 +606,12 @@ class xt {
|
|
|
608
606
|
"InheritType" in t && (n.inheritType = parseInt(t.InheritType.value)), "RotationOrder" in t ? n.eulerOrder = q(t.RotationOrder.value) : n.eulerOrder = q(0), "Lcl_Translation" in t && (n.translation = t.Lcl_Translation.value), "PreRotation" in t && (n.preRotation = t.PreRotation.value), "Lcl_Rotation" in t && (n.rotation = t.Lcl_Rotation.value), "PostRotation" in t && (n.postRotation = t.PostRotation.value), "Lcl_Scaling" in t && (n.scale = t.Lcl_Scaling.value), "ScalingOffset" in t && (n.scalingOffset = t.ScalingOffset.value), "ScalingPivot" in t && (n.scalingPivot = t.ScalingPivot.value), "RotationOffset" in t && (n.rotationOffset = t.RotationOffset.value), "RotationPivot" in t && (n.rotationPivot = t.RotationPivot.value), e.userData.transformData = n;
|
|
609
607
|
}
|
|
610
608
|
setLookAtProperties(e, t) {
|
|
611
|
-
"LookAtProperty" in t &&
|
|
609
|
+
"LookAtProperty" in t && U.get(e.ID).children.forEach(function(r) {
|
|
612
610
|
if (r.relationship === "LookAtProperty") {
|
|
613
611
|
const s = C.Objects.Model[r.ID];
|
|
614
612
|
if ("Lcl_Translation" in s) {
|
|
615
613
|
const a = s.Lcl_Translation.value;
|
|
616
|
-
e.target !== void 0 ? (e.target.position.fromArray(a),
|
|
614
|
+
e.target !== void 0 ? (e.target.position.fromArray(a), O.add(e.target)) : e.lookAt(new V().fromArray(a));
|
|
617
615
|
}
|
|
618
616
|
}
|
|
619
617
|
});
|
|
@@ -622,11 +620,11 @@ class xt {
|
|
|
622
620
|
const r = this.parsePoseNodes();
|
|
623
621
|
for (const s in e) {
|
|
624
622
|
const a = e[s];
|
|
625
|
-
|
|
623
|
+
U.get(parseInt(a.ID)).parents.forEach(function(l) {
|
|
626
624
|
if (t.has(l.ID)) {
|
|
627
625
|
const p = l.ID;
|
|
628
|
-
|
|
629
|
-
n.has(u.ID) && n.get(u.ID).bind(new
|
|
626
|
+
U.get(p).parents.forEach(function(u) {
|
|
627
|
+
n.has(u.ID) && n.get(u.ID).bind(new qe(a.bones), r[u.ID]);
|
|
630
628
|
});
|
|
631
629
|
}
|
|
632
630
|
});
|
|
@@ -652,14 +650,14 @@ class xt {
|
|
|
652
650
|
const e = C.GlobalSettings.AmbientColor.value, t = e[0], n = e[1], r = e[2];
|
|
653
651
|
if (t !== 0 || n !== 0 || r !== 0) {
|
|
654
652
|
const s = new k().setRGB(t, n, r, X);
|
|
655
|
-
|
|
653
|
+
O.add(new Ke(s, 1));
|
|
656
654
|
}
|
|
657
655
|
}
|
|
658
|
-
"UnitScaleFactor" in C.GlobalSettings && (
|
|
656
|
+
"UnitScaleFactor" in C.GlobalSettings && (O.userData.unitScaleFactor = C.GlobalSettings.UnitScaleFactor.value);
|
|
659
657
|
}
|
|
660
658
|
}
|
|
661
659
|
}
|
|
662
|
-
class
|
|
660
|
+
class bt {
|
|
663
661
|
constructor() {
|
|
664
662
|
this.negativeMaterialIndices = !1;
|
|
665
663
|
}
|
|
@@ -669,7 +667,7 @@ class Et {
|
|
|
669
667
|
if ("Geometry" in C.Objects) {
|
|
670
668
|
const n = C.Objects.Geometry;
|
|
671
669
|
for (const r in n) {
|
|
672
|
-
const s =
|
|
670
|
+
const s = U.get(parseInt(r)), a = this.parseGeometry(s, n[r], e);
|
|
673
671
|
t.set(parseInt(r), a);
|
|
674
672
|
}
|
|
675
673
|
}
|
|
@@ -690,7 +688,7 @@ class Et {
|
|
|
690
688
|
return C.Objects.Model[u.ID];
|
|
691
689
|
});
|
|
692
690
|
if (a.length === 0) return;
|
|
693
|
-
const
|
|
691
|
+
const i = e.children.reduce(function(u, c) {
|
|
694
692
|
return r[c.ID] !== void 0 && (u = r[c.ID]), u;
|
|
695
693
|
}, null);
|
|
696
694
|
e.children.forEach(function(u) {
|
|
@@ -698,30 +696,30 @@ class Et {
|
|
|
698
696
|
});
|
|
699
697
|
const l = a[0], p = {};
|
|
700
698
|
"RotationOrder" in l && (p.eulerOrder = q(l.RotationOrder.value)), "InheritType" in l && (p.inheritType = parseInt(l.InheritType.value)), "GeometricTranslation" in l && (p.translation = l.GeometricTranslation.value), "GeometricRotation" in l && (p.rotation = l.GeometricRotation.value), "GeometricScaling" in l && (p.scale = l.GeometricScaling.value);
|
|
701
|
-
const f =
|
|
702
|
-
return this.genGeometry(t,
|
|
699
|
+
const f = Le(p);
|
|
700
|
+
return this.genGeometry(t, i, s, f);
|
|
703
701
|
}
|
|
704
702
|
// Generate a BufferGeometry from a node in FBXTree.Objects.Geometry
|
|
705
703
|
genGeometry(e, t, n, r) {
|
|
706
704
|
const s = new re();
|
|
707
705
|
e.attrName && (s.name = e.attrName);
|
|
708
|
-
const a = this.parseGeoNode(e, t),
|
|
709
|
-
if (l.applyMatrix4(r), s.setAttribute("position", l),
|
|
710
|
-
const p = new
|
|
706
|
+
const a = this.parseGeoNode(e, t), i = this.genBuffers(a), l = new j(i.vertex, 3);
|
|
707
|
+
if (l.applyMatrix4(r), s.setAttribute("position", l), i.colors.length > 0 && s.setAttribute("color", new j(i.colors, 3)), t && (s.setAttribute("skinIndex", new Ze(i.weightsIndices, 4)), s.setAttribute("skinWeight", new j(i.vertexWeights, 4)), s.FBX_Deformer = t), i.normal.length > 0) {
|
|
708
|
+
const p = new Qe().getNormalMatrix(r), f = new j(i.normal, 3);
|
|
711
709
|
f.applyNormalMatrix(p), s.setAttribute("normal", f);
|
|
712
710
|
}
|
|
713
|
-
if (
|
|
711
|
+
if (i.uvs.forEach(function(p, f) {
|
|
714
712
|
const u = f === 0 ? "uv" : `uv${f}`;
|
|
715
|
-
s.setAttribute(u, new j(
|
|
713
|
+
s.setAttribute(u, new j(i.uvs[f], 2));
|
|
716
714
|
}), a.material && a.material.mappingType !== "AllSame") {
|
|
717
|
-
let p =
|
|
718
|
-
if (
|
|
715
|
+
let p = i.materialIndex[0], f = 0;
|
|
716
|
+
if (i.materialIndex.forEach(function(u, c) {
|
|
719
717
|
u !== p && (s.addGroup(f, c - f, p), p = u, f = c);
|
|
720
718
|
}), s.groups.length > 0) {
|
|
721
719
|
const u = s.groups[s.groups.length - 1], c = u.start + u.count;
|
|
722
|
-
c !==
|
|
720
|
+
c !== i.materialIndex.length && s.addGroup(c, i.materialIndex.length - c, p);
|
|
723
721
|
}
|
|
724
|
-
s.groups.length === 0 && s.addGroup(0,
|
|
722
|
+
s.groups.length === 0 && s.addGroup(0, i.materialIndex.length, i.materialIndex[0]);
|
|
725
723
|
}
|
|
726
724
|
return this.addMorphTargets(s, e, n, r), s;
|
|
727
725
|
}
|
|
@@ -734,10 +732,10 @@ class Et {
|
|
|
734
732
|
e.LayerElementUV[r].UV && n.uv.push(this.parseUVs(e.LayerElementUV[r])), r++;
|
|
735
733
|
}
|
|
736
734
|
return n.weightTable = {}, t !== null && (n.skeleton = t, t.rawBones.forEach(function(r, s) {
|
|
737
|
-
r.indices.forEach(function(a,
|
|
735
|
+
r.indices.forEach(function(a, i) {
|
|
738
736
|
n.weightTable[a] === void 0 && (n.weightTable[a] = []), n.weightTable[a].push({
|
|
739
737
|
id: s,
|
|
740
|
-
weight: r.weights[
|
|
738
|
+
weight: r.weights[i]
|
|
741
739
|
});
|
|
742
740
|
});
|
|
743
741
|
})), n;
|
|
@@ -752,7 +750,7 @@ class Et {
|
|
|
752
750
|
vertexWeights: [],
|
|
753
751
|
weightsIndices: []
|
|
754
752
|
};
|
|
755
|
-
let n = 0, r = 0, s = !1, a = [],
|
|
753
|
+
let n = 0, r = 0, s = !1, a = [], i = [], l = [], p = [], f = [], u = [];
|
|
756
754
|
const c = this;
|
|
757
755
|
return e.vertexIndices.forEach(function(h, m) {
|
|
758
756
|
let g, d = !1;
|
|
@@ -768,11 +766,11 @@ class Et {
|
|
|
768
766
|
}), F.length > 4) {
|
|
769
767
|
s || (console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."), s = !0);
|
|
770
768
|
const y = [0, 0, 0, 0], x = [0, 0, 0, 0];
|
|
771
|
-
F.forEach(function(
|
|
772
|
-
let
|
|
773
|
-
x.forEach(function(S, E,
|
|
774
|
-
if (
|
|
775
|
-
|
|
769
|
+
F.forEach(function(A, I) {
|
|
770
|
+
let b = A, v = T[I];
|
|
771
|
+
x.forEach(function(S, E, M) {
|
|
772
|
+
if (b > S) {
|
|
773
|
+
M[E] = b, b = S;
|
|
776
774
|
const R = y[E];
|
|
777
775
|
y[E] = v, v = R;
|
|
778
776
|
}
|
|
@@ -786,12 +784,12 @@ class Et {
|
|
|
786
784
|
}
|
|
787
785
|
if (e.normal) {
|
|
788
786
|
const y = Q(m, n, h, e.normal);
|
|
789
|
-
|
|
787
|
+
i.push(y[0], y[1], y[2]);
|
|
790
788
|
}
|
|
791
789
|
e.material && e.material.mappingType !== "AllSame" && (g = Q(m, n, h, e.material)[0], g < 0 && (c.negativeMaterialIndices = !0, g = 0)), e.uv && e.uv.forEach(function(y, x) {
|
|
792
|
-
const
|
|
793
|
-
p[x] === void 0 && (p[x] = []), p[x].push(
|
|
794
|
-
}), r++, d && (c.genFace(t, e, a, g,
|
|
790
|
+
const A = Q(m, n, h, y);
|
|
791
|
+
p[x] === void 0 && (p[x] = []), p[x].push(A[0]), p[x].push(A[1]);
|
|
792
|
+
}), r++, d && (c.genFace(t, e, a, g, i, l, p, f, u, r), n++, r = 0, a = [], i = [], l = [], p = [], f = [], u = []);
|
|
795
793
|
}), t;
|
|
796
794
|
}
|
|
797
795
|
// See https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal
|
|
@@ -812,13 +810,13 @@ class Et {
|
|
|
812
810
|
};
|
|
813
811
|
}
|
|
814
812
|
flattenVertex(e, t, n) {
|
|
815
|
-
return new
|
|
813
|
+
return new Je(
|
|
816
814
|
e.dot(t),
|
|
817
815
|
e.dot(n)
|
|
818
816
|
);
|
|
819
817
|
}
|
|
820
818
|
// Generate data for a single face in a geometry. If the face is a quad then split it into 2 tris
|
|
821
|
-
genFace(e, t, n, r, s, a,
|
|
819
|
+
genFace(e, t, n, r, s, a, i, l, p, f) {
|
|
822
820
|
let u;
|
|
823
821
|
if (f > 3) {
|
|
824
822
|
const c = [], h = t.baseVertexPositions || t.vertexPositions;
|
|
@@ -833,12 +831,12 @@ class Et {
|
|
|
833
831
|
const { tangent: m, bitangent: g } = this.getNormalTangentAndBitangent(c), d = [];
|
|
834
832
|
for (const T of c)
|
|
835
833
|
d.push(this.flattenVertex(T, m, g));
|
|
836
|
-
u =
|
|
834
|
+
u = et.triangulateShape(d, []);
|
|
837
835
|
} else
|
|
838
836
|
u = [[0, 1, 2]];
|
|
839
837
|
for (const [c, h, m] of u)
|
|
840
838
|
e.vertex.push(t.vertexPositions[n[c * 3]]), e.vertex.push(t.vertexPositions[n[c * 3 + 1]]), e.vertex.push(t.vertexPositions[n[c * 3 + 2]]), e.vertex.push(t.vertexPositions[n[h * 3]]), e.vertex.push(t.vertexPositions[n[h * 3 + 1]]), e.vertex.push(t.vertexPositions[n[h * 3 + 2]]), e.vertex.push(t.vertexPositions[n[m * 3]]), e.vertex.push(t.vertexPositions[n[m * 3 + 1]]), e.vertex.push(t.vertexPositions[n[m * 3 + 2]]), t.skeleton && (e.vertexWeights.push(l[c * 4]), e.vertexWeights.push(l[c * 4 + 1]), e.vertexWeights.push(l[c * 4 + 2]), e.vertexWeights.push(l[c * 4 + 3]), e.vertexWeights.push(l[h * 4]), e.vertexWeights.push(l[h * 4 + 1]), e.vertexWeights.push(l[h * 4 + 2]), e.vertexWeights.push(l[h * 4 + 3]), e.vertexWeights.push(l[m * 4]), e.vertexWeights.push(l[m * 4 + 1]), e.vertexWeights.push(l[m * 4 + 2]), e.vertexWeights.push(l[m * 4 + 3]), e.weightsIndices.push(p[c * 4]), e.weightsIndices.push(p[c * 4 + 1]), e.weightsIndices.push(p[c * 4 + 2]), e.weightsIndices.push(p[c * 4 + 3]), e.weightsIndices.push(p[h * 4]), e.weightsIndices.push(p[h * 4 + 1]), e.weightsIndices.push(p[h * 4 + 2]), e.weightsIndices.push(p[h * 4 + 3]), e.weightsIndices.push(p[m * 4]), e.weightsIndices.push(p[m * 4 + 1]), e.weightsIndices.push(p[m * 4 + 2]), e.weightsIndices.push(p[m * 4 + 3])), t.color && (e.colors.push(a[c * 3]), e.colors.push(a[c * 3 + 1]), e.colors.push(a[c * 3 + 2]), e.colors.push(a[h * 3]), e.colors.push(a[h * 3 + 1]), e.colors.push(a[h * 3 + 2]), e.colors.push(a[m * 3]), e.colors.push(a[m * 3 + 1]), e.colors.push(a[m * 3 + 2])), t.material && t.material.mappingType !== "AllSame" && (e.materialIndex.push(r), e.materialIndex.push(r), e.materialIndex.push(r)), t.normal && (e.normal.push(s[c * 3]), e.normal.push(s[c * 3 + 1]), e.normal.push(s[c * 3 + 2]), e.normal.push(s[h * 3]), e.normal.push(s[h * 3 + 1]), e.normal.push(s[h * 3 + 2]), e.normal.push(s[m * 3]), e.normal.push(s[m * 3 + 1]), e.normal.push(s[m * 3 + 2])), t.uv && t.uv.forEach(function(g, d) {
|
|
841
|
-
e.uvs[d] === void 0 && (e.uvs[d] = []), e.uvs[d].push(
|
|
839
|
+
e.uvs[d] === void 0 && (e.uvs[d] = []), e.uvs[d].push(i[d][c * 2]), e.uvs[d].push(i[d][c * 2 + 1]), e.uvs[d].push(i[d][h * 2]), e.uvs[d].push(i[d][h * 2 + 1]), e.uvs[d].push(i[d][m * 2]), e.uvs[d].push(i[d][m * 2 + 1]);
|
|
842
840
|
});
|
|
843
841
|
}
|
|
844
842
|
addMorphTargets(e, t, n, r) {
|
|
@@ -846,9 +844,9 @@ class Et {
|
|
|
846
844
|
e.morphTargetsRelative = !0, e.morphAttributes.position = [];
|
|
847
845
|
const s = this;
|
|
848
846
|
n.forEach(function(a) {
|
|
849
|
-
a.rawTargets.forEach(function(
|
|
850
|
-
const l = C.Objects.Geometry[
|
|
851
|
-
l !== void 0 && s.genMorphGeometry(e, t, l, r,
|
|
847
|
+
a.rawTargets.forEach(function(i) {
|
|
848
|
+
const l = C.Objects.Geometry[i.geoID];
|
|
849
|
+
l !== void 0 && s.genMorphGeometry(e, t, l, r, i.name);
|
|
852
850
|
});
|
|
853
851
|
});
|
|
854
852
|
}
|
|
@@ -857,13 +855,13 @@ class Et {
|
|
|
857
855
|
// and a special attribute Index defining which vertices of the original geometry are affected
|
|
858
856
|
// Normal and position attributes only have data for the vertices that are affected by the morph
|
|
859
857
|
genMorphGeometry(e, t, n, r, s) {
|
|
860
|
-
const a = t.Vertices !== void 0 ? t.Vertices.a : [],
|
|
858
|
+
const a = t.Vertices !== void 0 ? t.Vertices.a : [], i = t.PolygonVertexIndex !== void 0 ? t.PolygonVertexIndex.a : [], l = n.Vertices !== void 0 ? n.Vertices.a : [], p = n.Indexes !== void 0 ? n.Indexes.a : [], f = e.attributes.position.count * 3, u = new Float32Array(f);
|
|
861
859
|
for (let g = 0; g < p.length; g++) {
|
|
862
860
|
const d = p[g] * 3;
|
|
863
861
|
u[d] = l[g * 3], u[d + 1] = l[g * 3 + 1], u[d + 2] = l[g * 3 + 2];
|
|
864
862
|
}
|
|
865
863
|
const c = {
|
|
866
|
-
vertexIndices:
|
|
864
|
+
vertexIndices: i,
|
|
867
865
|
vertexPositions: u,
|
|
868
866
|
baseVertexPositions: a
|
|
869
867
|
}, h = this.genBuffers(c), m = new j(h.vertex, 3);
|
|
@@ -898,8 +896,8 @@ class Et {
|
|
|
898
896
|
const t = e.MappingInformationType, n = e.ReferenceInformationType, r = e.Colors.a;
|
|
899
897
|
let s = [];
|
|
900
898
|
n === "IndexToDirect" && (s = e.ColorIndex.a);
|
|
901
|
-
for (let a = 0,
|
|
902
|
-
|
|
899
|
+
for (let a = 0, i = new k(); a < r.length; a += 4)
|
|
900
|
+
i.fromArray(r, a), N.colorSpaceToWorking(i, X), i.toArray(r, a);
|
|
903
901
|
return {
|
|
904
902
|
dataSize: 4,
|
|
905
903
|
buffer: r,
|
|
@@ -937,20 +935,20 @@ class Et {
|
|
|
937
935
|
return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s", e.Order, e.id), new re();
|
|
938
936
|
const n = t - 1, r = e.KnotVector.a, s = [], a = e.Points.a;
|
|
939
937
|
for (let u = 0, c = a.length; u < c; u += 4)
|
|
940
|
-
s.push(new
|
|
941
|
-
let
|
|
938
|
+
s.push(new tt().fromArray(a, u));
|
|
939
|
+
let i, l;
|
|
942
940
|
if (e.Form === "Closed")
|
|
943
941
|
s.push(s[0]);
|
|
944
942
|
else if (e.Form === "Periodic") {
|
|
945
|
-
|
|
943
|
+
i = n, l = r.length - 1 - i;
|
|
946
944
|
for (let u = 0; u < n; ++u)
|
|
947
945
|
s.push(s[u]);
|
|
948
946
|
}
|
|
949
|
-
const f = new
|
|
947
|
+
const f = new mt(n, r, s, i, l).getPoints(s.length * 12);
|
|
950
948
|
return new re().setFromPoints(f);
|
|
951
949
|
}
|
|
952
950
|
}
|
|
953
|
-
class
|
|
951
|
+
class Mt {
|
|
954
952
|
// take raw animation clips and turn them into three.js animation clips
|
|
955
953
|
parse() {
|
|
956
954
|
const e = [], t = this.parseClips();
|
|
@@ -994,12 +992,12 @@ class bt {
|
|
|
994
992
|
for (const n in t) {
|
|
995
993
|
const r = {
|
|
996
994
|
id: t[n].id,
|
|
997
|
-
times: t[n].KeyTime.a.map(
|
|
995
|
+
times: t[n].KeyTime.a.map(Rt),
|
|
998
996
|
values: t[n].KeyValueFloat.a
|
|
999
|
-
}, s =
|
|
997
|
+
}, s = U.get(r.id);
|
|
1000
998
|
if (s !== void 0) {
|
|
1001
|
-
const a = s.parents[0].ID,
|
|
1002
|
-
|
|
999
|
+
const a = s.parents[0].ID, i = s.parents[0].relationship;
|
|
1000
|
+
i.match(/X/) ? e.get(a).curves.x = r : i.match(/Y/) ? e.get(a).curves.y = r : i.match(/Z/) ? e.get(a).curves.z = r : i.match(/DeformPercent/) && e.has(a) && (e.get(a).curves.morph = r);
|
|
1003
1001
|
}
|
|
1004
1002
|
}
|
|
1005
1003
|
}
|
|
@@ -1009,13 +1007,13 @@ class bt {
|
|
|
1009
1007
|
parseAnimationLayers(e) {
|
|
1010
1008
|
const t = C.Objects.AnimationLayer, n = /* @__PURE__ */ new Map();
|
|
1011
1009
|
for (const r in t) {
|
|
1012
|
-
const s = [], a =
|
|
1010
|
+
const s = [], a = U.get(parseInt(r));
|
|
1013
1011
|
a !== void 0 && (a.children.forEach(function(l, p) {
|
|
1014
1012
|
if (e.has(l.ID)) {
|
|
1015
1013
|
const f = e.get(l.ID);
|
|
1016
1014
|
if (f.curves.x !== void 0 || f.curves.y !== void 0 || f.curves.z !== void 0) {
|
|
1017
1015
|
if (s[p] === void 0) {
|
|
1018
|
-
const u =
|
|
1016
|
+
const u = U.get(l.ID).parents.filter(function(c) {
|
|
1019
1017
|
return c.relationship !== void 0;
|
|
1020
1018
|
})[0].ID;
|
|
1021
1019
|
if (u !== void 0) {
|
|
@@ -1031,7 +1029,7 @@ class bt {
|
|
|
1031
1029
|
initialRotation: [0, 0, 0],
|
|
1032
1030
|
initialScale: [1, 1, 1]
|
|
1033
1031
|
};
|
|
1034
|
-
|
|
1032
|
+
O.traverse(function(m) {
|
|
1035
1033
|
m.ID === c.id && (h.transform = m.matrix, m.userData.transformData && (h.eulerOrder = m.userData.transformData.eulerOrder));
|
|
1036
1034
|
}), h.transform || (h.transform = new L()), "PreRotation" in c && (h.preRotation = c.PreRotation.value), "PostRotation" in c && (h.postRotation = c.PostRotation.value), s[p] = h;
|
|
1037
1035
|
}
|
|
@@ -1039,9 +1037,9 @@ class bt {
|
|
|
1039
1037
|
s[p] && (s[p][f.attr] = f);
|
|
1040
1038
|
} else if (f.curves.morph !== void 0) {
|
|
1041
1039
|
if (s[p] === void 0) {
|
|
1042
|
-
const u =
|
|
1040
|
+
const u = U.get(l.ID).parents.filter(function(T) {
|
|
1043
1041
|
return T.relationship !== void 0;
|
|
1044
|
-
})[0].ID, c =
|
|
1042
|
+
})[0].ID, c = U.get(u).parents[0].ID, h = U.get(c).parents[0].ID, m = U.get(h).parents[0].ID, g = C.Objects.Model[m], d = {
|
|
1045
1043
|
modelName: g.attrName ? ee.sanitizeNodeName(g.attrName) : "",
|
|
1046
1044
|
morphName: C.Objects.Deformer[u].attrName
|
|
1047
1045
|
};
|
|
@@ -1059,7 +1057,7 @@ class bt {
|
|
|
1059
1057
|
parseAnimStacks(e) {
|
|
1060
1058
|
const t = C.Objects.AnimationStack, n = {};
|
|
1061
1059
|
for (const r in t) {
|
|
1062
|
-
const s =
|
|
1060
|
+
const s = U.get(parseInt(r)).children;
|
|
1063
1061
|
s.length > 1 && console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");
|
|
1064
1062
|
const a = e.get(s[0].ID);
|
|
1065
1063
|
n[r] = {
|
|
@@ -1074,7 +1072,7 @@ class bt {
|
|
|
1074
1072
|
const n = this;
|
|
1075
1073
|
return e.layer.forEach(function(r) {
|
|
1076
1074
|
t = t.concat(n.generateTracks(r));
|
|
1077
|
-
}), new
|
|
1075
|
+
}), new nt(e.name, -1, t);
|
|
1078
1076
|
}
|
|
1079
1077
|
generateTracks(e) {
|
|
1080
1078
|
const t = [];
|
|
@@ -1099,30 +1097,30 @@ class bt {
|
|
|
1099
1097
|
}
|
|
1100
1098
|
generateVectorTrack(e, t, n, r) {
|
|
1101
1099
|
const s = this.getTimesForAllAxes(t), a = this.getKeyframeTrackValues(s, t, n);
|
|
1102
|
-
return new
|
|
1100
|
+
return new rt(e + "." + r, s, a);
|
|
1103
1101
|
}
|
|
1104
1102
|
generateRotationTrack(e, t, n, r, s) {
|
|
1105
|
-
let a,
|
|
1103
|
+
let a, i;
|
|
1106
1104
|
if (t.x !== void 0 && t.y !== void 0 && t.z !== void 0) {
|
|
1107
1105
|
const c = this.interpolateRotations(t.x, t.y, t.z, s);
|
|
1108
|
-
a = c[0],
|
|
1106
|
+
a = c[0], i = c[1];
|
|
1109
1107
|
}
|
|
1110
1108
|
const l = q(0);
|
|
1111
1109
|
n !== void 0 && (n = n.map(B.degToRad), n.push(l), n = new z().fromArray(n), n = new G().setFromEuler(n)), r !== void 0 && (r = r.map(B.degToRad), r.push(l), r = new z().fromArray(r), r = new G().setFromEuler(r).invert());
|
|
1112
1110
|
const p = new G(), f = new z(), u = [];
|
|
1113
|
-
if (!
|
|
1114
|
-
for (let c = 0; c <
|
|
1115
|
-
f.set(
|
|
1111
|
+
if (!i || !a) return new me(e + ".quaternion", [0], [0]);
|
|
1112
|
+
for (let c = 0; c < i.length; c += 3)
|
|
1113
|
+
f.set(i[c], i[c + 1], i[c + 2], s), p.setFromEuler(f), n !== void 0 && p.premultiply(n), r !== void 0 && p.multiply(r), c > 2 && new G().fromArray(
|
|
1116
1114
|
u,
|
|
1117
1115
|
(c - 3) / 3 * 4
|
|
1118
1116
|
).dot(p) < 0 && p.set(-p.x, -p.y, -p.z, -p.w), p.toArray(u, c / 3 * 4);
|
|
1119
|
-
return new
|
|
1117
|
+
return new me(e + ".quaternion", a, u);
|
|
1120
1118
|
}
|
|
1121
1119
|
generateMorphTrack(e) {
|
|
1122
1120
|
const t = e.DeformPercent.curves.morph, n = t.values.map(function(s) {
|
|
1123
1121
|
return s / 100;
|
|
1124
|
-
}), r =
|
|
1125
|
-
return new
|
|
1122
|
+
}), r = O.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];
|
|
1123
|
+
return new st(e.modelName + ".morphTargetInfluences[" + r + "]", t.times, n);
|
|
1126
1124
|
}
|
|
1127
1125
|
// For all animated objects, times are defined separately for each axis
|
|
1128
1126
|
// Here we'll combine the times into one sorted array without duplicates
|
|
@@ -1142,15 +1140,15 @@ class bt {
|
|
|
1142
1140
|
}
|
|
1143
1141
|
getKeyframeTrackValues(e, t, n) {
|
|
1144
1142
|
const r = n, s = [];
|
|
1145
|
-
let a = -1,
|
|
1143
|
+
let a = -1, i = -1, l = -1;
|
|
1146
1144
|
return e.forEach(function(p) {
|
|
1147
|
-
if (t.x && (a = t.x.times.indexOf(p)), t.y && (
|
|
1145
|
+
if (t.x && (a = t.x.times.indexOf(p)), t.y && (i = t.y.times.indexOf(p)), t.z && (l = t.z.times.indexOf(p)), a !== -1) {
|
|
1148
1146
|
const f = t.x.values[a];
|
|
1149
1147
|
s.push(f), r[0] = f;
|
|
1150
1148
|
} else
|
|
1151
1149
|
s.push(r[0]);
|
|
1152
|
-
if (
|
|
1153
|
-
const f = t.y.values[
|
|
1150
|
+
if (i !== -1) {
|
|
1151
|
+
const f = t.y.values[i];
|
|
1154
1152
|
s.push(f), r[1] = f;
|
|
1155
1153
|
} else
|
|
1156
1154
|
s.push(r[1]);
|
|
@@ -1167,18 +1165,18 @@ class bt {
|
|
|
1167
1165
|
interpolateRotations(e, t, n, r) {
|
|
1168
1166
|
const s = [], a = [];
|
|
1169
1167
|
s.push(e.times[0]), a.push(B.degToRad(e.values[0])), a.push(B.degToRad(t.values[0])), a.push(B.degToRad(n.values[0]));
|
|
1170
|
-
for (let
|
|
1168
|
+
for (let i = 1; i < e.values.length; i++) {
|
|
1171
1169
|
const l = [
|
|
1172
|
-
e.values[
|
|
1173
|
-
t.values[
|
|
1174
|
-
n.values[
|
|
1170
|
+
e.values[i - 1],
|
|
1171
|
+
t.values[i - 1],
|
|
1172
|
+
n.values[i - 1]
|
|
1175
1173
|
];
|
|
1176
1174
|
if (isNaN(l[0]) || isNaN(l[1]) || isNaN(l[2]))
|
|
1177
1175
|
continue;
|
|
1178
1176
|
const p = l.map(B.degToRad), f = [
|
|
1179
|
-
e.values[
|
|
1180
|
-
t.values[
|
|
1181
|
-
n.values[
|
|
1177
|
+
e.values[i],
|
|
1178
|
+
t.values[i],
|
|
1179
|
+
n.values[i]
|
|
1182
1180
|
];
|
|
1183
1181
|
if (isNaN(f[0]) || isNaN(f[1]) || isNaN(f[2]))
|
|
1184
1182
|
continue;
|
|
@@ -1194,16 +1192,16 @@ class bt {
|
|
|
1194
1192
|
if (h[0] >= 180 || h[1] >= 180 || h[2] >= 180) {
|
|
1195
1193
|
const g = Math.max(...h) / 180, d = new z(...p, r), T = new z(...u, r), F = new G().setFromEuler(d), y = new G().setFromEuler(T);
|
|
1196
1194
|
F.dot(y) && y.set(-y.x, -y.y, -y.z, -y.w);
|
|
1197
|
-
const x = e.times[
|
|
1195
|
+
const x = e.times[i - 1], A = e.times[i] - x, I = new G(), b = new z();
|
|
1198
1196
|
for (let v = 0; v < 1; v += 1 / g)
|
|
1199
|
-
|
|
1197
|
+
I.copy(F.clone().slerp(y.clone(), v)), s.push(x + v * A), b.setFromQuaternion(I, r), a.push(b.x), a.push(b.y), a.push(b.z);
|
|
1200
1198
|
} else
|
|
1201
|
-
s.push(e.times[
|
|
1199
|
+
s.push(e.times[i]), a.push(B.degToRad(e.values[i])), a.push(B.degToRad(t.values[i])), a.push(B.degToRad(n.values[i]));
|
|
1202
1200
|
}
|
|
1203
1201
|
return [s, a];
|
|
1204
1202
|
}
|
|
1205
1203
|
}
|
|
1206
|
-
class
|
|
1204
|
+
class St {
|
|
1207
1205
|
getPrevNode() {
|
|
1208
1206
|
return this.nodeStack[this.currentIndent - 2];
|
|
1209
1207
|
}
|
|
@@ -1223,11 +1221,11 @@ class Mt {
|
|
|
1223
1221
|
this.currentProp = e, this.currentPropName = t;
|
|
1224
1222
|
}
|
|
1225
1223
|
parse(e) {
|
|
1226
|
-
this.currentIndent = 0, this.allNodes = new
|
|
1224
|
+
this.currentIndent = 0, this.allNodes = new Ce(), this.nodeStack = [], this.currentProp = [], this.currentPropName = "";
|
|
1227
1225
|
const t = this, n = e.split(/[\r\n]+/);
|
|
1228
1226
|
return n.forEach(function(r, s) {
|
|
1229
|
-
const a = r.match(/^[\s\t]*;/),
|
|
1230
|
-
if (a ||
|
|
1227
|
+
const a = r.match(/^[\s\t]*;/), i = r.match(/^[\s\t]*$/);
|
|
1228
|
+
if (a || i) return;
|
|
1231
1229
|
const l = r.match("^\\t{" + t.currentIndent + "}(\\w+):(.*){", ""), p = r.match("^\\t{" + t.currentIndent + "}(\\w+):[\\s\\t\\r\\n](.*)"), f = r.match("^\\t{" + (t.currentIndent - 1) + "}}");
|
|
1232
1230
|
l ? t.parseNodeBegin(r, l) : p ? t.parseNodeProperty(r, p, n[++s]) : f ? t.popStack() : r.match(/^[^\s\t}]/) && t.parseNodePropertyContinued(r);
|
|
1233
1231
|
}), this.allNodes;
|
|
@@ -1235,8 +1233,8 @@ class Mt {
|
|
|
1235
1233
|
parseNodeBegin(e, t) {
|
|
1236
1234
|
const n = t[1].trim().replace(/^"/, "").replace(/"$/, ""), r = t[2].split(",").map(function(l) {
|
|
1237
1235
|
return l.trim().replace(/^"/, "").replace(/"$/, "");
|
|
1238
|
-
}), s = { name: n }, a = this.parseNodeAttr(r),
|
|
1239
|
-
this.currentIndent === 0 ? this.allNodes.add(n, s) : n in
|
|
1236
|
+
}), s = { name: n }, a = this.parseNodeAttr(r), i = this.getCurrentNode();
|
|
1237
|
+
this.currentIndent === 0 ? this.allNodes.add(n, s) : n in i ? (n === "PoseNode" ? i.PoseNode.push(s) : i[n].id !== void 0 && (i[n] = {}, i[n][i[n].id] = i[n]), a.id !== "" && (i[n][a.id] = s)) : typeof a.id == "number" ? (i[n] = {}, i[n][a.id] = s) : n !== "Properties70" && (n === "PoseNode" ? i[n] = [s] : i[n] = s), typeof a.id == "number" && (s.id = a.id), a.name !== "" && (s.attrName = a.name), a.type !== "" && (s.attrType = a.type), this.pushStack(s);
|
|
1240
1238
|
}
|
|
1241
1239
|
parseNodeAttr(e) {
|
|
1242
1240
|
let t = e[0];
|
|
@@ -1257,7 +1255,7 @@ class Mt {
|
|
|
1257
1255
|
let u = s.split(",").slice(3);
|
|
1258
1256
|
u = u.map(function(c) {
|
|
1259
1257
|
return c.trim().replace(/^"/, "");
|
|
1260
|
-
}), r = "connections", s = [p, f],
|
|
1258
|
+
}), r = "connections", s = [p, f], Pt(s, u), a[r] === void 0 && (a[r] = []);
|
|
1261
1259
|
}
|
|
1262
1260
|
r === "Node" && (a.id = s), r in a && Array.isArray(a[r]) ? a[r].push(s) : r !== "a" ? a[r] = s : a.a = s, this.setCurrentProp(a, r), r === "a" && s.slice(-1) !== "," && (a.a = ae(s));
|
|
1263
1261
|
}
|
|
@@ -1269,7 +1267,7 @@ class Mt {
|
|
|
1269
1267
|
parseNodeSpecialProperty(e, t, n) {
|
|
1270
1268
|
const r = n.split('",').map(function(f) {
|
|
1271
1269
|
return f.trim().replace(/^\"/, "").replace(/\s/, "_");
|
|
1272
|
-
}), s = r[0], a = r[1],
|
|
1270
|
+
}), s = r[0], a = r[1], i = r[2], l = r[3];
|
|
1273
1271
|
let p = r[4];
|
|
1274
1272
|
switch (a) {
|
|
1275
1273
|
case "int":
|
|
@@ -1292,20 +1290,20 @@ class Mt {
|
|
|
1292
1290
|
}
|
|
1293
1291
|
this.getPrevNode()[s] = {
|
|
1294
1292
|
type: a,
|
|
1295
|
-
type2:
|
|
1293
|
+
type2: i,
|
|
1296
1294
|
flag: l,
|
|
1297
1295
|
value: p
|
|
1298
1296
|
}, this.setCurrentProp(this.getPrevNode(), s);
|
|
1299
1297
|
}
|
|
1300
1298
|
}
|
|
1301
|
-
class
|
|
1299
|
+
class Ft {
|
|
1302
1300
|
parse(e) {
|
|
1303
|
-
const t = new
|
|
1301
|
+
const t = new xe(e);
|
|
1304
1302
|
t.skip(23);
|
|
1305
1303
|
const n = t.getUint32();
|
|
1306
1304
|
if (n < 6400)
|
|
1307
1305
|
throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + n);
|
|
1308
|
-
const r = new
|
|
1306
|
+
const r = new Ce();
|
|
1309
1307
|
for (; !this.endOfContent(t); ) {
|
|
1310
1308
|
const s = this.parseNode(t, n);
|
|
1311
1309
|
s !== null && r.add(s.name, s);
|
|
@@ -1320,7 +1318,7 @@ class St {
|
|
|
1320
1318
|
parseNode(e, t) {
|
|
1321
1319
|
const n = {}, r = t >= 7500 ? e.getUint64() : e.getUint32(), s = t >= 7500 ? e.getUint64() : e.getUint32();
|
|
1322
1320
|
t >= 7500 ? e.getUint64() : e.getUint32();
|
|
1323
|
-
const a = e.getUint8(),
|
|
1321
|
+
const a = e.getUint8(), i = e.getString(a);
|
|
1324
1322
|
if (r === 0) return null;
|
|
1325
1323
|
const l = [];
|
|
1326
1324
|
for (let c = 0; c < s; c++)
|
|
@@ -1328,9 +1326,9 @@ class St {
|
|
|
1328
1326
|
const p = l.length > 0 ? l[0] : "", f = l.length > 1 ? l[1] : "", u = l.length > 2 ? l[2] : "";
|
|
1329
1327
|
for (n.singleProperty = s === 1 && e.getOffset() === r; r > e.getOffset(); ) {
|
|
1330
1328
|
const c = this.parseNode(e, t);
|
|
1331
|
-
c !== null && this.parseSubNode(
|
|
1329
|
+
c !== null && this.parseSubNode(i, n, c);
|
|
1332
1330
|
}
|
|
1333
|
-
return n.propertyList = l, typeof p == "number" && (n.id = p), f !== "" && (n.attrName = f), u !== "" && (n.attrType = u),
|
|
1331
|
+
return n.propertyList = l, typeof p == "number" && (n.id = p), f !== "" && (n.attrName = f), u !== "" && (n.attrType = u), i !== "" && (n.name = i), n;
|
|
1334
1332
|
}
|
|
1335
1333
|
parseSubNode(e, t, n) {
|
|
1336
1334
|
if (n.singleProperty === !0) {
|
|
@@ -1347,7 +1345,7 @@ class St {
|
|
|
1347
1345
|
});
|
|
1348
1346
|
else if (e === "Properties70" && n.name === "P") {
|
|
1349
1347
|
let r = n.propertyList[0], s = n.propertyList[1];
|
|
1350
|
-
const a = n.propertyList[2],
|
|
1348
|
+
const a = n.propertyList[2], i = n.propertyList[3];
|
|
1351
1349
|
let l;
|
|
1352
1350
|
r.indexOf("Lcl ") === 0 && (r = r.replace("Lcl ", "Lcl_")), s.indexOf("Lcl ") === 0 && (s = s.replace("Lcl ", "Lcl_")), s === "Color" || s === "ColorRGB" || s === "Vector" || s === "Vector3D" || s.indexOf("Lcl_") === 0 ? l = [
|
|
1353
1351
|
n.propertyList[4],
|
|
@@ -1356,7 +1354,7 @@ class St {
|
|
|
1356
1354
|
] : l = n.propertyList[4], t[r] = {
|
|
1357
1355
|
type: s,
|
|
1358
1356
|
type2: a,
|
|
1359
|
-
flag:
|
|
1357
|
+
flag: i,
|
|
1360
1358
|
value: l
|
|
1361
1359
|
};
|
|
1362
1360
|
} else t[n.name] === void 0 ? typeof n.id == "number" ? (t[n.name] = {}, t[n.name][n.id] = n) : t[n.name] = n : n.name === "PoseNode" ? (Array.isArray(t[n.name]) || (t[n.name] = [t[n.name]]), t[n.name].push(n)) : t[n.name][n.id] === void 0 && (t[n.name][n.id] = n);
|
|
@@ -1402,7 +1400,7 @@ class St {
|
|
|
1402
1400
|
case "l":
|
|
1403
1401
|
return e.getInt64Array(r);
|
|
1404
1402
|
}
|
|
1405
|
-
const
|
|
1403
|
+
const i = ht.unzlibSync(new Uint8Array(e.getArrayBuffer(a))), l = new xe(i.buffer);
|
|
1406
1404
|
switch (t) {
|
|
1407
1405
|
case "b":
|
|
1408
1406
|
case "c":
|
|
@@ -1422,7 +1420,7 @@ class St {
|
|
|
1422
1420
|
}
|
|
1423
1421
|
}
|
|
1424
1422
|
}
|
|
1425
|
-
class
|
|
1423
|
+
class xe {
|
|
1426
1424
|
constructor(e, t) {
|
|
1427
1425
|
this.dv = new DataView(e), this.offset = 0, this.littleEndian = t !== void 0 ? t : !0, this._textDecoder = new TextDecoder();
|
|
1428
1426
|
}
|
|
@@ -1521,42 +1519,42 @@ class Te {
|
|
|
1521
1519
|
return r >= 0 && (n = new Uint8Array(this.dv.buffer, t, r)), this._textDecoder.decode(n);
|
|
1522
1520
|
}
|
|
1523
1521
|
}
|
|
1524
|
-
class
|
|
1522
|
+
class Ce {
|
|
1525
1523
|
add(e, t) {
|
|
1526
1524
|
this[e] = t;
|
|
1527
1525
|
}
|
|
1528
1526
|
}
|
|
1529
|
-
function
|
|
1527
|
+
function At(o) {
|
|
1530
1528
|
const e = "Kaydara FBX Binary \0";
|
|
1531
|
-
return
|
|
1529
|
+
return o.byteLength >= e.length && e === Ue(o, 0, e.length);
|
|
1532
1530
|
}
|
|
1533
|
-
function It(
|
|
1531
|
+
function It(o) {
|
|
1534
1532
|
const e = ["K", "a", "y", "d", "a", "r", "a", "\\", "F", "B", "X", "\\", "B", "i", "n", "a", "r", "y", "\\", "\\"];
|
|
1535
1533
|
let t = 0;
|
|
1536
1534
|
function n(r) {
|
|
1537
|
-
const s =
|
|
1538
|
-
return
|
|
1535
|
+
const s = o[r - 1];
|
|
1536
|
+
return o = o.slice(t + r), t++, s;
|
|
1539
1537
|
}
|
|
1540
1538
|
for (let r = 0; r < e.length; ++r)
|
|
1541
1539
|
if (n(1) === e[r])
|
|
1542
1540
|
return !1;
|
|
1543
1541
|
return !0;
|
|
1544
1542
|
}
|
|
1545
|
-
function
|
|
1546
|
-
const e = /FBXVersion: (\d+)/, t =
|
|
1543
|
+
function Ee(o) {
|
|
1544
|
+
const e = /FBXVersion: (\d+)/, t = o.match(e);
|
|
1547
1545
|
if (t)
|
|
1548
1546
|
return parseInt(t[1]);
|
|
1549
1547
|
throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.");
|
|
1550
1548
|
}
|
|
1551
|
-
function
|
|
1552
|
-
return
|
|
1549
|
+
function Rt(o) {
|
|
1550
|
+
return o / 46186158e3;
|
|
1553
1551
|
}
|
|
1554
|
-
const
|
|
1555
|
-
function Q(
|
|
1552
|
+
const Dt = [];
|
|
1553
|
+
function Q(o, e, t, n) {
|
|
1556
1554
|
let r;
|
|
1557
1555
|
switch (n.mappingType) {
|
|
1558
1556
|
case "ByPolygonVertex":
|
|
1559
|
-
r =
|
|
1557
|
+
r = o;
|
|
1560
1558
|
break;
|
|
1561
1559
|
case "ByPolygon":
|
|
1562
1560
|
r = e;
|
|
@@ -1572,46 +1570,46 @@ function Q(i, e, t, n) {
|
|
|
1572
1570
|
}
|
|
1573
1571
|
n.referenceType === "IndexToDirect" && (r = n.indices[r]);
|
|
1574
1572
|
const s = r * n.dataSize, a = s + n.dataSize;
|
|
1575
|
-
return
|
|
1573
|
+
return Ct(Dt, n.buffer, s, a);
|
|
1576
1574
|
}
|
|
1577
1575
|
const se = new z(), H = new V();
|
|
1578
|
-
function
|
|
1579
|
-
const e = new L(), t = new L(), n = new L(), r = new L(), s = new L(), a = new L(),
|
|
1580
|
-
|
|
1576
|
+
function Le(o) {
|
|
1577
|
+
const e = new L(), t = new L(), n = new L(), r = new L(), s = new L(), a = new L(), i = new L(), l = new L(), p = new L(), f = new L(), u = new L(), c = new L(), h = o.inheritType ? o.inheritType : 0;
|
|
1578
|
+
o.translation && e.setPosition(H.fromArray(o.translation));
|
|
1581
1579
|
const m = q(0);
|
|
1582
|
-
if (
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1580
|
+
if (o.preRotation) {
|
|
1581
|
+
const M = o.preRotation.map(B.degToRad);
|
|
1582
|
+
M.push(m), t.makeRotationFromEuler(se.fromArray(M));
|
|
1585
1583
|
}
|
|
1586
|
-
if (
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1584
|
+
if (o.rotation) {
|
|
1585
|
+
const M = o.rotation.map(B.degToRad);
|
|
1586
|
+
M.push(o.eulerOrder || m), n.makeRotationFromEuler(se.fromArray(M));
|
|
1589
1587
|
}
|
|
1590
|
-
if (
|
|
1591
|
-
const
|
|
1592
|
-
|
|
1588
|
+
if (o.postRotation) {
|
|
1589
|
+
const M = o.postRotation.map(B.degToRad);
|
|
1590
|
+
M.push(m), r.makeRotationFromEuler(se.fromArray(M)), r.invert();
|
|
1593
1591
|
}
|
|
1594
|
-
|
|
1592
|
+
o.scale && s.scale(H.fromArray(o.scale)), o.scalingOffset && i.setPosition(H.fromArray(o.scalingOffset)), o.scalingPivot && a.setPosition(H.fromArray(o.scalingPivot)), o.rotationOffset && l.setPosition(H.fromArray(o.rotationOffset)), o.rotationPivot && p.setPosition(H.fromArray(o.rotationPivot)), o.parentMatrixWorld && (u.copy(o.parentMatrix), f.copy(o.parentMatrixWorld));
|
|
1595
1593
|
const g = t.clone().multiply(n).multiply(r), d = new L();
|
|
1596
1594
|
d.extractRotation(f);
|
|
1597
1595
|
const T = new L();
|
|
1598
1596
|
T.copyPosition(f);
|
|
1599
|
-
const F = T.clone().invert().multiply(f), y = d.clone().invert().multiply(F), x = s,
|
|
1597
|
+
const F = T.clone().invert().multiply(f), y = d.clone().invert().multiply(F), x = s, A = new L();
|
|
1600
1598
|
if (h === 0)
|
|
1601
|
-
|
|
1599
|
+
A.copy(d).multiply(g).multiply(y).multiply(x);
|
|
1602
1600
|
else if (h === 1)
|
|
1603
|
-
|
|
1601
|
+
A.copy(d).multiply(y).multiply(g).multiply(x);
|
|
1604
1602
|
else {
|
|
1605
1603
|
const R = new L().scale(new V().setFromMatrixScale(u)).clone().invert(), w = y.clone().multiply(R);
|
|
1606
|
-
|
|
1604
|
+
A.copy(d).multiply(g).multiply(w).multiply(x);
|
|
1607
1605
|
}
|
|
1608
|
-
const
|
|
1609
|
-
let v = e.clone().multiply(l).multiply(p).multiply(t).multiply(n).multiply(r).multiply(
|
|
1606
|
+
const I = p.clone().invert(), b = a.clone().invert();
|
|
1607
|
+
let v = e.clone().multiply(l).multiply(p).multiply(t).multiply(n).multiply(r).multiply(I).multiply(i).multiply(a).multiply(s).multiply(b);
|
|
1610
1608
|
const S = new L().copyPosition(v), E = f.clone().multiply(S);
|
|
1611
|
-
return c.copyPosition(E), v = c.clone().multiply(
|
|
1609
|
+
return c.copyPosition(E), v = c.clone().multiply(A), v.premultiply(f.invert()), v;
|
|
1612
1610
|
}
|
|
1613
|
-
function q(
|
|
1614
|
-
|
|
1611
|
+
function q(o) {
|
|
1612
|
+
o = o || 0;
|
|
1615
1613
|
const e = [
|
|
1616
1614
|
"ZYX",
|
|
1617
1615
|
// -> XYZ extrinsic
|
|
@@ -1627,26 +1625,26 @@ function q(i) {
|
|
|
1627
1625
|
// -> ZYX extrinsic
|
|
1628
1626
|
//'SphericXYZ', // not possible to support
|
|
1629
1627
|
];
|
|
1630
|
-
return
|
|
1628
|
+
return o === 6 ? (console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."), e[0]) : e[o];
|
|
1631
1629
|
}
|
|
1632
|
-
function ae(
|
|
1633
|
-
return
|
|
1630
|
+
function ae(o) {
|
|
1631
|
+
return o.split(",").map(function(t) {
|
|
1634
1632
|
return parseFloat(t);
|
|
1635
1633
|
});
|
|
1636
1634
|
}
|
|
1637
|
-
function
|
|
1638
|
-
return e === void 0 && (e = 0), t === void 0 && (t =
|
|
1635
|
+
function Ue(o, e, t) {
|
|
1636
|
+
return e === void 0 && (e = 0), t === void 0 && (t = o.byteLength), new TextDecoder().decode(new Uint8Array(o, e, t));
|
|
1639
1637
|
}
|
|
1640
|
-
function
|
|
1641
|
-
for (let t = 0, n =
|
|
1642
|
-
|
|
1638
|
+
function Pt(o, e) {
|
|
1639
|
+
for (let t = 0, n = o.length, r = e.length; t < r; t++, n++)
|
|
1640
|
+
o[n] = e[t];
|
|
1643
1641
|
}
|
|
1644
|
-
function
|
|
1642
|
+
function Ct(o, e, t, n) {
|
|
1645
1643
|
for (let r = t, s = 0; r < n; r++, s++)
|
|
1646
|
-
|
|
1647
|
-
return
|
|
1644
|
+
o[s] = e[r];
|
|
1645
|
+
return o;
|
|
1648
1646
|
}
|
|
1649
|
-
async function
|
|
1647
|
+
async function Lt(o, e, t) {
|
|
1650
1648
|
e.signal.throwIfAborted();
|
|
1651
1649
|
const n = new AbortController(), r = n.signal, s = () => n.abort(e.signal.reason);
|
|
1652
1650
|
e.signal.addEventListener("abort", s, { once: !0 });
|
|
@@ -1655,28 +1653,28 @@ async function Ct(i, e, t) {
|
|
|
1655
1653
|
const x = () => {
|
|
1656
1654
|
y || (y = !0, F(r.reason));
|
|
1657
1655
|
};
|
|
1658
|
-
r.aborted ? x() : r.addEventListener("abort", x, { once: !0 }), g.then((
|
|
1659
|
-
r.removeEventListener("abort", x), y ? d == null || d(
|
|
1660
|
-
}, (
|
|
1661
|
-
r.removeEventListener("abort", x), y || (y = !0, F(
|
|
1656
|
+
r.aborted ? x() : r.addEventListener("abort", x, { once: !0 }), g.then((A) => {
|
|
1657
|
+
r.removeEventListener("abort", x), y ? d == null || d(A) : (y = !0, T(A));
|
|
1658
|
+
}, (A) => {
|
|
1659
|
+
r.removeEventListener("abort", x), y || (y = !0, F(A));
|
|
1662
1660
|
});
|
|
1663
|
-
}),
|
|
1664
|
-
var
|
|
1661
|
+
}), i = [], l = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), f = [], u = new at(), c = async (g) => {
|
|
1662
|
+
var I;
|
|
1665
1663
|
if (/^(blob:|data:)/i.test(g))
|
|
1666
1664
|
return g.startsWith("blob:") && p.add(g), g;
|
|
1667
|
-
const d = [...new Set([...t.textures.values()].map((
|
|
1668
|
-
let y = d.filter((
|
|
1669
|
-
if (y.length || (y = d.filter((
|
|
1670
|
-
const x = T(y[0] ?? g),
|
|
1671
|
-
if (typeof
|
|
1672
|
-
const
|
|
1665
|
+
const d = [...new Set([...t.textures.values()].map((b) => b.path).filter(Boolean))], T = (b) => b.replaceAll("\\", "/").replace(/^\.\//, ""), F = T(g);
|
|
1666
|
+
let y = d.filter((b) => T(b) === F);
|
|
1667
|
+
if (y.length || (y = d.filter((b) => T(b).split("/").pop() === F.split("/").pop())), y.length > 1) throw new Error(`FBX texture path is ambiguous: ${g}`);
|
|
1668
|
+
const x = T(y[0] ?? g), A = e.original;
|
|
1669
|
+
if (typeof A == "object" && A !== null && "kind" in A && A.kind === "files") {
|
|
1670
|
+
const b = ((I = e.entryPath) == null ? void 0 : I.replace(/[^/]*$/, "")) ?? "", v = (M) => {
|
|
1673
1671
|
const R = [];
|
|
1674
|
-
for (const w of T(
|
|
1672
|
+
for (const w of T(M).split("/"))
|
|
1675
1673
|
w === ".." ? R.pop() : w && w !== "." && R.push(w);
|
|
1676
1674
|
return R.join("/");
|
|
1677
|
-
}, S =
|
|
1675
|
+
}, S = A.files.filter((M) => v(M.path) === v(b + x));
|
|
1678
1676
|
if (S.length === 1) return e.resolve(S[0].path);
|
|
1679
|
-
const E =
|
|
1677
|
+
const E = A.files.filter((M) => v(M.path).split("/").pop() === x.split("/").pop());
|
|
1680
1678
|
if (E.length === 1) return e.resolve(E[0].path);
|
|
1681
1679
|
if (E.length > 1) throw new Error(`FBX texture path is ambiguous: ${x}`);
|
|
1682
1680
|
if (!e.hasResourceResolver) throw new Error(`FBX texture is missing from the selected files: ${x}`);
|
|
@@ -1692,50 +1690,50 @@ async function Ct(i, e, t) {
|
|
|
1692
1690
|
load(d, T, F, y) {
|
|
1693
1691
|
const x = this.binaryFormat ? new ne() : new Y();
|
|
1694
1692
|
l.add(x);
|
|
1695
|
-
const
|
|
1696
|
-
const
|
|
1693
|
+
const A = (async () => {
|
|
1694
|
+
const I = await a(c(d));
|
|
1697
1695
|
r.throwIfAborted();
|
|
1698
|
-
const
|
|
1699
|
-
if (!
|
|
1696
|
+
const b = await fetch(I, { signal: r });
|
|
1697
|
+
if (!b.ok) throw new Error(`FBX texture request failed (${b.status}): ${d}`);
|
|
1700
1698
|
if (this.binaryFormat) {
|
|
1701
|
-
const S = await
|
|
1699
|
+
const S = await b.arrayBuffer();
|
|
1702
1700
|
r.throwIfAborted();
|
|
1703
1701
|
let E;
|
|
1704
1702
|
try {
|
|
1705
|
-
E =
|
|
1706
|
-
} catch (
|
|
1707
|
-
throw new Error(`FBX texture decode failed (${this.binaryFormat}): ${d}: ${String(
|
|
1703
|
+
E = Tt(S, this.binaryFormat);
|
|
1704
|
+
} catch (M) {
|
|
1705
|
+
throw new Error(`FBX texture decode failed (${this.binaryFormat}): ${d}: ${String(M)}`, { cause: M });
|
|
1708
1706
|
}
|
|
1709
1707
|
x.image = E.image, x.flipY = E.flipY, x.generateMipmaps = E.generateMipmaps, x.minFilter = E.minFilter, x.magFilter = E.magFilter, x.format = E.format, x.type = E.type, E.dispose(), x.needsUpdate = !0, T == null || T(x);
|
|
1710
1708
|
return;
|
|
1711
1709
|
}
|
|
1712
|
-
const v = URL.createObjectURL(await
|
|
1710
|
+
const v = URL.createObjectURL(await b.blob());
|
|
1713
1711
|
try {
|
|
1714
|
-
const S = new
|
|
1715
|
-
const R =
|
|
1716
|
-
throw new Error(`FBX texture decode failed: ${d}${R}`, { cause:
|
|
1717
|
-
}), E = await a(S, (
|
|
1718
|
-
|
|
1712
|
+
const S = new Se().loadAsync(v).catch((M) => {
|
|
1713
|
+
const R = M instanceof Error ? `: ${M.message}` : "";
|
|
1714
|
+
throw new Error(`FBX texture decode failed: ${d}${R}`, { cause: M });
|
|
1715
|
+
}), E = await a(S, (M) => {
|
|
1716
|
+
M.dispose();
|
|
1719
1717
|
});
|
|
1720
1718
|
x.image = E.image, E.dispose(), r.throwIfAborted(), x.needsUpdate = !0, T == null || T(x);
|
|
1721
1719
|
} finally {
|
|
1722
1720
|
URL.revokeObjectURL(v);
|
|
1723
1721
|
}
|
|
1724
|
-
})().catch((
|
|
1725
|
-
if (r.aborted) throw
|
|
1726
|
-
f.push(
|
|
1722
|
+
})().catch((I) => {
|
|
1723
|
+
if (r.aborted) throw I;
|
|
1724
|
+
f.push(I instanceof Error ? I.message : String(I)), console.warn(`[viewer] FBX texture skipped: ${d}`, I), y == null || y(I);
|
|
1727
1725
|
});
|
|
1728
|
-
return
|
|
1729
|
-
}),
|
|
1726
|
+
return A.catch(() => {
|
|
1727
|
+
}), i.push(A), x;
|
|
1730
1728
|
}
|
|
1731
1729
|
}
|
|
1732
1730
|
u.addHandler(/\.tga$/i, new h("tga")), u.addHandler(/\.dds$/i, new h("dds")), u.addHandler(/.*/, new h());
|
|
1733
1731
|
let m;
|
|
1734
1732
|
try {
|
|
1735
|
-
return m = new
|
|
1733
|
+
return m = new xt(u).parse(o, ""), await Promise.all(i), e.signal.throwIfAborted(), { root: m, textures: l, textureFailures: f };
|
|
1736
1734
|
} catch (g) {
|
|
1737
|
-
if (n.abort(g), await Promise.allSettled(
|
|
1738
|
-
const { disposeModelResources: d } = await import("./
|
|
1735
|
+
if (n.abort(g), await Promise.allSettled(i), m) {
|
|
1736
|
+
const { disposeModelResources: d } = await import("./index-CHf9y9eX.js").then((T) => T.ac);
|
|
1739
1737
|
d(m, l);
|
|
1740
1738
|
} else for (const d of l) d.dispose();
|
|
1741
1739
|
throw g;
|
|
@@ -1744,30 +1742,30 @@ async function Ct(i, e, t) {
|
|
|
1744
1742
|
for (const g of p) URL.revokeObjectURL(g);
|
|
1745
1743
|
}
|
|
1746
1744
|
}
|
|
1747
|
-
const oe = "Kaydara FBX Binary \0",
|
|
1748
|
-
function
|
|
1745
|
+
const oe = "Kaydara FBX Binary \0", Ut = /(?:^|[\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;
|
|
1746
|
+
function Bt(o) {
|
|
1749
1747
|
try {
|
|
1750
|
-
const e = new Uint8Array(
|
|
1748
|
+
const e = new Uint8Array(o), t = kt(e) ? _t(o) : Xt(new TextDecoder().decode(e));
|
|
1751
1749
|
return !t || t.sign !== 1 ? null : t.axis === 1 ? "y" : t.axis === 2 ? "z" : null;
|
|
1752
1750
|
} catch {
|
|
1753
1751
|
return null;
|
|
1754
1752
|
}
|
|
1755
1753
|
}
|
|
1756
|
-
function
|
|
1757
|
-
if (
|
|
1754
|
+
function kt(o) {
|
|
1755
|
+
if (o.byteLength < oe.length) return !1;
|
|
1758
1756
|
for (let e = 0; e < oe.length; e += 1)
|
|
1759
|
-
if (
|
|
1757
|
+
if (o[e] !== oe.charCodeAt(e)) return !1;
|
|
1760
1758
|
return !0;
|
|
1761
1759
|
}
|
|
1762
|
-
function
|
|
1760
|
+
function Xt(o) {
|
|
1763
1761
|
var r, s;
|
|
1764
|
-
const e = Number.parseInt(((r =
|
|
1762
|
+
const e = Number.parseInt(((r = Ut.exec(o)) == null ? void 0 : r[1]) ?? "", 10);
|
|
1765
1763
|
if (!Number.isInteger(e)) return null;
|
|
1766
|
-
const t = (s = Ot.exec(
|
|
1764
|
+
const t = (s = Ot.exec(o)) == null ? void 0 : s[1], n = t === void 0 ? 1 : Number.parseInt(t, 10);
|
|
1767
1765
|
return Number.isInteger(n) ? { axis: e, sign: n } : null;
|
|
1768
1766
|
}
|
|
1769
|
-
function
|
|
1770
|
-
const e = new DataView(
|
|
1767
|
+
function _t(o) {
|
|
1768
|
+
const e = new DataView(o);
|
|
1771
1769
|
if (e.byteLength < 27) return null;
|
|
1772
1770
|
const t = e.getUint32(23, !0) >= 7500;
|
|
1773
1771
|
let n = 27;
|
|
@@ -1779,64 +1777,64 @@ function Xt(i) {
|
|
|
1779
1777
|
}
|
|
1780
1778
|
return null;
|
|
1781
1779
|
}
|
|
1782
|
-
function Oe(
|
|
1780
|
+
function Oe(o, e, t, n) {
|
|
1783
1781
|
let r = e, s = null, a = 1;
|
|
1784
1782
|
for (; r < t; ) {
|
|
1785
|
-
const
|
|
1786
|
-
if (!
|
|
1787
|
-
if (
|
|
1788
|
-
const [l, , , , p] =
|
|
1783
|
+
const i = K(o, r, n, !0);
|
|
1784
|
+
if (!i) break;
|
|
1785
|
+
if (i.name === "P") {
|
|
1786
|
+
const [l, , , , p] = i.properties;
|
|
1789
1787
|
l === "UpAxis" && typeof p == "number" && (s = p), l === "UpAxisSign" && typeof p == "number" && (a = p);
|
|
1790
1788
|
}
|
|
1791
|
-
if (
|
|
1792
|
-
const l = Oe(
|
|
1789
|
+
if (i.childrenOffset < i.endOffset) {
|
|
1790
|
+
const l = Oe(o, i.childrenOffset, i.endOffset, n);
|
|
1793
1791
|
l && (s ?? (s = l.axis), a = l.sign);
|
|
1794
1792
|
}
|
|
1795
|
-
r =
|
|
1793
|
+
r = i.endOffset;
|
|
1796
1794
|
}
|
|
1797
1795
|
return s === null ? null : { axis: s, sign: a };
|
|
1798
1796
|
}
|
|
1799
|
-
function K(
|
|
1797
|
+
function K(o, e, t, n) {
|
|
1800
1798
|
const r = t ? 25 : 13;
|
|
1801
|
-
if (e + r >
|
|
1802
|
-
const s = ie(
|
|
1799
|
+
if (e + r > o.byteLength) return null;
|
|
1800
|
+
const s = ie(o, e, t), a = ie(o, e + (t ? 8 : 4), t), i = ie(o, e + (t ? 16 : 8), t), l = o.getUint8(e + (t ? 24 : 12));
|
|
1803
1801
|
if (s === 0) return null;
|
|
1804
|
-
const p = e + r, f = p + l, u = f +
|
|
1805
|
-
if (s <= e || s >
|
|
1806
|
-
const c = new TextDecoder().decode(new Uint8Array(
|
|
1802
|
+
const p = e + r, f = p + l, u = f + i;
|
|
1803
|
+
if (s <= e || s > o.byteLength || u > s) throw new Error("Invalid FBX node bounds.");
|
|
1804
|
+
const c = new TextDecoder().decode(new Uint8Array(o.buffer, o.byteOffset + p, l)), h = [];
|
|
1807
1805
|
if (n) {
|
|
1808
1806
|
let m = f;
|
|
1809
1807
|
for (let g = 0; g < a; g += 1) {
|
|
1810
|
-
const d =
|
|
1808
|
+
const d = Vt(o, m);
|
|
1811
1809
|
if (h.push(d.value), m = d.nextOffset, m > u) return null;
|
|
1812
1810
|
}
|
|
1813
1811
|
}
|
|
1814
1812
|
return { name: c, endOffset: s, childrenOffset: u, properties: h };
|
|
1815
1813
|
}
|
|
1816
|
-
function ie(
|
|
1817
|
-
if (!t) return
|
|
1818
|
-
const n =
|
|
1814
|
+
function ie(o, e, t) {
|
|
1815
|
+
if (!t) return o.getUint32(e, !0);
|
|
1816
|
+
const n = o.getBigUint64(e, !0);
|
|
1819
1817
|
if (n > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("FBX offset exceeds the safe integer range.");
|
|
1820
1818
|
return Number(n);
|
|
1821
1819
|
}
|
|
1822
|
-
function
|
|
1823
|
-
const t = String.fromCharCode(
|
|
1820
|
+
function Vt(o, e) {
|
|
1821
|
+
const t = String.fromCharCode(o.getUint8(e));
|
|
1824
1822
|
switch (t) {
|
|
1825
1823
|
case "Y":
|
|
1826
|
-
return { value:
|
|
1824
|
+
return { value: o.getInt16(e + 1, !0), nextOffset: e + 3 };
|
|
1827
1825
|
case "C":
|
|
1828
|
-
return { value:
|
|
1826
|
+
return { value: o.getUint8(e + 1) !== 0, nextOffset: e + 2 };
|
|
1829
1827
|
case "I":
|
|
1830
|
-
return { value:
|
|
1828
|
+
return { value: o.getInt32(e + 1, !0), nextOffset: e + 5 };
|
|
1831
1829
|
case "F":
|
|
1832
|
-
return { value:
|
|
1830
|
+
return { value: o.getFloat32(e + 1, !0), nextOffset: e + 5 };
|
|
1833
1831
|
case "D":
|
|
1834
|
-
return { value:
|
|
1832
|
+
return { value: o.getFloat64(e + 1, !0), nextOffset: e + 9 };
|
|
1835
1833
|
case "L":
|
|
1836
|
-
return { value: Number(
|
|
1834
|
+
return { value: Number(o.getBigInt64(e + 1, !0)), nextOffset: e + 9 };
|
|
1837
1835
|
case "S":
|
|
1838
1836
|
case "R": {
|
|
1839
|
-
const n =
|
|
1837
|
+
const n = o.getUint32(e + 1, !0), r = e + 5, s = new Uint8Array(o.buffer, o.byteOffset + r, n);
|
|
1840
1838
|
return { value: t === "S" ? new TextDecoder().decode(s) : s, nextOffset: r + n };
|
|
1841
1839
|
}
|
|
1842
1840
|
case "f":
|
|
@@ -1845,39 +1843,39 @@ function _t(i, e) {
|
|
|
1845
1843
|
case "i":
|
|
1846
1844
|
case "b":
|
|
1847
1845
|
case "c": {
|
|
1848
|
-
const n =
|
|
1846
|
+
const n = o.getUint32(e + 9, !0);
|
|
1849
1847
|
return { value: null, nextOffset: e + 13 + n };
|
|
1850
1848
|
}
|
|
1851
1849
|
default:
|
|
1852
1850
|
throw new Error(`Unsupported FBX property type: ${t}`);
|
|
1853
1851
|
}
|
|
1854
1852
|
}
|
|
1855
|
-
const te = /* @__PURE__ */ new Set(["Definitions", "ObjectType", "PropertyTemplate", "Objects", "Material", "Properties70", "Connections", "Texture", "Video", "Geometry", "LayerElementUV", "LayeredTexture", "BlendModes", "Alphas"]),
|
|
1856
|
-
function
|
|
1857
|
-
var F, y, x,
|
|
1858
|
-
const e = new Uint8Array(
|
|
1853
|
+
const te = /* @__PURE__ */ new Set(["Definitions", "ObjectType", "PropertyTemplate", "Objects", "Material", "Properties70", "Connections", "Texture", "Video", "Geometry", "LayerElementUV", "LayeredTexture", "BlendModes", "Alphas"]), Be = /* @__PURE__ */ new Set(["P", "C", "RelativeFilename", "FileName", "Filename", "ShadingModel", "UVSet", "Scaling", "Translation", "Rotation", "RotationPivot", "ScalingPivot", "Name", "UV", "a"]);
|
|
1854
|
+
function Gt(o) {
|
|
1855
|
+
var F, y, x, A, I, b;
|
|
1856
|
+
const e = new Uint8Array(o), n = new TextDecoder().decode(e.subarray(0, 21)) === "Kaydara FBX Binary \0" ? Nt(o) : $t(new TextDecoder().decode(e)), r = (v) => {
|
|
1859
1857
|
var S;
|
|
1860
1858
|
return new Map(
|
|
1861
1859
|
(((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)])
|
|
1862
1860
|
);
|
|
1863
|
-
}, s = n.find((v) => v.name === "Definitions"), a = s == null ? void 0 : s.children.find((v) => v.name === "ObjectType" && v.values[0] === "Material"),
|
|
1861
|
+
}, s = n.find((v) => v.name === "Definitions"), a = s == null ? void 0 : s.children.find((v) => v.name === "ObjectType" && v.values[0] === "Material"), i = (a == null ? void 0 : a.children.filter((v) => v.name === "PropertyTemplate")) ?? [], l = ((F = n.find((v) => v.name === "Connections")) == null ? void 0 : F.children.filter((v) => v.name === "C")) ?? [], p = ((y = n.find((v) => v.name === "Objects")) == null ? void 0 : y.children) ?? [], f = /* @__PURE__ */ new Map(), u = (v, S) => {
|
|
1864
1862
|
var E;
|
|
1865
|
-
return (E = v == null ? void 0 : v.children.find((
|
|
1863
|
+
return (E = v == null ? void 0 : v.children.find((M) => M.name === S)) == null ? void 0 : E.values[0];
|
|
1866
1864
|
};
|
|
1867
1865
|
for (const v of p.filter((S) => S.name === "Texture")) {
|
|
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],
|
|
1866
|
+
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], M = p.find((P) => P.name === "Video" && P.values[0] === E), R = String(u(M, "RelativeFilename") || u(v, "RelativeFilename") || u(M, "Filename") || u(v, "FileName") || ""), w = r(v);
|
|
1869
1867
|
for (const P of ["Scaling", "Translation", "Rotation", "RotationPivot", "ScalingPivot"]) {
|
|
1870
|
-
const _ = (
|
|
1868
|
+
const _ = (A = v.children.find((ke) => ke.name === P)) == null ? void 0 : A.values;
|
|
1871
1869
|
_ && w.set(P, _);
|
|
1872
1870
|
}
|
|
1873
|
-
const D = u(v, "UVSet") ?? ((
|
|
1871
|
+
const D = u(v, "UVSet") ?? ((I = w.get("UVSet")) == null ? void 0 : I[0]);
|
|
1874
1872
|
f.set(S, { id: S, path: R, values: w, uvSet: typeof D == "string" ? D : null });
|
|
1875
1873
|
}
|
|
1876
1874
|
const c = /* @__PURE__ */ new Map(), h = (v, S) => {
|
|
1877
1875
|
var R;
|
|
1878
|
-
const E = v.children.find((w) => w.name === S),
|
|
1879
|
-
if (
|
|
1880
|
-
return
|
|
1876
|
+
const E = v.children.find((w) => w.name === S), M = ((R = E == null ? void 0 : E.children.find((w) => w.name === "a")) == null ? void 0 : R.values) ?? (E == null ? void 0 : E.values) ?? [];
|
|
1877
|
+
if (M.some((w) => typeof w != "number" || !Number.isFinite(w))) throw new Error(`Invalid FBX layered ${S}.`);
|
|
1878
|
+
return M;
|
|
1881
1879
|
};
|
|
1882
1880
|
for (const v of p.filter((S) => S.name === "LayeredTexture")) {
|
|
1883
1881
|
const S = Number(v.values[0]);
|
|
@@ -1891,11 +1889,11 @@ function Vt(i) {
|
|
|
1891
1889
|
});
|
|
1892
1890
|
}
|
|
1893
1891
|
const m = /* @__PURE__ */ new Map();
|
|
1894
|
-
for (const v of ((
|
|
1892
|
+
for (const v of ((b = n.find((S) => S.name === "Objects")) == null ? void 0 : b.children) ?? []) {
|
|
1895
1893
|
if (v.name !== "Material") continue;
|
|
1896
1894
|
const S = v.values[0];
|
|
1897
1895
|
if (typeof S != "number" || !Number.isSafeInteger(S)) throw new Error("Invalid FBX material ID.");
|
|
1898
|
-
const E = r(v),
|
|
1896
|
+
const E = r(v), M = 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(i.find((P) => String(P.values[0]).toLowerCase() === `fbxsurface${w}`));
|
|
1899
1897
|
m.set(S, {
|
|
1900
1898
|
textureConnections: R,
|
|
1901
1899
|
shadingModel: w,
|
|
@@ -1903,86 +1901,86 @@ function Vt(i) {
|
|
|
1903
1901
|
name: String(v.values[1] ?? ""),
|
|
1904
1902
|
ownValues: E,
|
|
1905
1903
|
values: new Map([...D, ...E]),
|
|
1906
|
-
textureRoles:
|
|
1904
|
+
textureRoles: M
|
|
1907
1905
|
});
|
|
1908
1906
|
}
|
|
1909
1907
|
const g = /* @__PURE__ */ new Map();
|
|
1910
1908
|
for (const v of l) {
|
|
1911
|
-
const [S, E,
|
|
1912
|
-
if (S !== "OO" || typeof E != "number" || typeof
|
|
1913
|
-
const R = g.get(
|
|
1914
|
-
R.push(E), g.set(
|
|
1909
|
+
const [S, E, M] = v.values;
|
|
1910
|
+
if (S !== "OO" || typeof E != "number" || typeof M != "number" || !m.has(E)) continue;
|
|
1911
|
+
const R = g.get(M) ?? [];
|
|
1912
|
+
R.push(E), g.set(M, R);
|
|
1915
1913
|
}
|
|
1916
1914
|
const d = /* @__PURE__ */ new Map();
|
|
1917
1915
|
for (const v of p.filter((S) => S.name === "Geometry")) {
|
|
1918
|
-
const S = new Map(v.children.filter((
|
|
1919
|
-
for (let
|
|
1920
|
-
const R = S.get(
|
|
1916
|
+
const S = new Map(v.children.filter((M) => M.name === "LayerElementUV").map((M) => [Number(M.values[0]), M])), E = [];
|
|
1917
|
+
for (let M = 0; S.has(M); M++) {
|
|
1918
|
+
const R = S.get(M);
|
|
1921
1919
|
R.children.some((w) => w.name === "UV") && E.push(String(u(R, "Name") ?? ""));
|
|
1922
1920
|
}
|
|
1923
1921
|
d.set(Number(v.values[0]), E);
|
|
1924
1922
|
}
|
|
1925
1923
|
const T = /* @__PURE__ */ new Map();
|
|
1926
1924
|
for (const v of l) {
|
|
1927
|
-
const [S, E,
|
|
1928
|
-
S === "OO" && typeof E == "number" && typeof
|
|
1925
|
+
const [S, E, M] = v.values;
|
|
1926
|
+
S === "OO" && typeof E == "number" && typeof M == "number" && d.has(E) && T.set(M, d.get(E));
|
|
1929
1927
|
}
|
|
1930
1928
|
return { materials: m, modelMaterials: g, textures: f, modelUvSets: T, layeredTextures: c };
|
|
1931
1929
|
}
|
|
1932
|
-
function
|
|
1933
|
-
const e = new DataView(
|
|
1930
|
+
function Nt(o) {
|
|
1931
|
+
const e = new DataView(o);
|
|
1934
1932
|
if (e.byteLength < 27) throw new Error("Truncated FBX header.");
|
|
1935
1933
|
const t = e.getUint32(23, !0) >= 7500, n = (r, s, a) => {
|
|
1936
1934
|
if (a > 16) throw new Error("Excessive FBX metadata nesting.");
|
|
1937
|
-
const
|
|
1935
|
+
const i = [];
|
|
1938
1936
|
let l = r;
|
|
1939
1937
|
for (; l < s; ) {
|
|
1940
1938
|
const p = K(e, l, t, !1);
|
|
1941
1939
|
if (!p) break;
|
|
1942
1940
|
if (p.endOffset > s) throw new Error("FBX child extends past its parent.");
|
|
1943
|
-
if (te.has(p.name) ||
|
|
1941
|
+
if (te.has(p.name) || Be.has(p.name)) {
|
|
1944
1942
|
const f = K(e, l, t, p.name !== "UV");
|
|
1945
|
-
|
|
1943
|
+
i.push({ name: f.name, values: ["BlendModes", "Alphas"].includes(f.name) ? zt(e, l, t, f.childrenOffset) : [...f.properties], children: te.has(f.name) ? n(f.childrenOffset, f.endOffset, a + 1) : [] });
|
|
1946
1944
|
}
|
|
1947
1945
|
l = p.endOffset;
|
|
1948
1946
|
}
|
|
1949
|
-
return
|
|
1947
|
+
return i;
|
|
1950
1948
|
};
|
|
1951
1949
|
return n(27, e.byteLength, 0);
|
|
1952
1950
|
}
|
|
1953
|
-
function
|
|
1951
|
+
function $t(o) {
|
|
1954
1952
|
const e = /"(?:\\.|[^"\\])*"|;[^\r\n]*|\r?\n|[^\S\r\n]+|[{}:,]|[^\s{}:,;]+/g;
|
|
1955
1953
|
let t = null;
|
|
1956
1954
|
const n = () => {
|
|
1957
1955
|
var a;
|
|
1958
1956
|
if (t !== null) {
|
|
1959
|
-
const
|
|
1960
|
-
return t = null,
|
|
1957
|
+
const i = t;
|
|
1958
|
+
return t = null, i;
|
|
1961
1959
|
}
|
|
1962
1960
|
for (; ; ) {
|
|
1963
|
-
const
|
|
1964
|
-
if (
|
|
1965
|
-
if (!(
|
|
1966
|
-
return
|
|
1961
|
+
const i = ((a = e.exec(o)) == null ? void 0 : a[0]) ?? null;
|
|
1962
|
+
if (i === null) return null;
|
|
1963
|
+
if (!(i.startsWith(";") || /^[^\S\r\n]+$/.test(i)))
|
|
1964
|
+
return i;
|
|
1967
1965
|
}
|
|
1968
1966
|
}, r = (a) => a.startsWith('"') ? a.slice(1, -1).replace(/\\(["\\])/g, "$1") : Number.isFinite(Number(a)) ? Number(a) : a, s = (a) => {
|
|
1969
1967
|
if (a > 16) throw new Error("Excessive FBX metadata nesting.");
|
|
1970
|
-
const
|
|
1968
|
+
const i = [];
|
|
1971
1969
|
for (; ; ) {
|
|
1972
1970
|
const l = n();
|
|
1973
1971
|
if (l === null) {
|
|
1974
1972
|
if (a) throw new Error("Unclosed FBX block.");
|
|
1975
|
-
return
|
|
1973
|
+
return i;
|
|
1976
1974
|
}
|
|
1977
1975
|
if (l === "}") {
|
|
1978
1976
|
if (!a) throw new Error("Unexpected FBX closing brace.");
|
|
1979
|
-
return
|
|
1977
|
+
return i;
|
|
1980
1978
|
}
|
|
1981
1979
|
if (l === `
|
|
1982
1980
|
` || l === `\r
|
|
1983
1981
|
`) continue;
|
|
1984
1982
|
if (n() !== ":") throw new Error("Malformed ASCII FBX metadata.");
|
|
1985
|
-
const p = te.has(l) ||
|
|
1983
|
+
const p = te.has(l) || Be.has(l), f = [];
|
|
1986
1984
|
let u = [];
|
|
1987
1985
|
for (; ; ) {
|
|
1988
1986
|
const c = n();
|
|
@@ -2007,49 +2005,49 @@ function Nt(i) {
|
|
|
2007
2005
|
}
|
|
2008
2006
|
p && c !== "," && f.push(r(c));
|
|
2009
2007
|
}
|
|
2010
|
-
p &&
|
|
2008
|
+
p && i.push({ name: l, values: f, children: u });
|
|
2011
2009
|
}
|
|
2012
2010
|
};
|
|
2013
2011
|
return s(0);
|
|
2014
2012
|
}
|
|
2015
|
-
function
|
|
2013
|
+
function zt(o, e, t, n) {
|
|
2016
2014
|
const r = t ? 25 : 13;
|
|
2017
|
-
let s = e + r +
|
|
2015
|
+
let s = e + r + o.getUint8(e + r - 1);
|
|
2018
2016
|
if (s === n) return [];
|
|
2019
|
-
const a = String.fromCharCode(
|
|
2020
|
-
if (!["i", "d", "f"].includes(a)) return [...K(
|
|
2017
|
+
const a = String.fromCharCode(o.getUint8(s));
|
|
2018
|
+
if (!["i", "d", "f"].includes(a)) return [...K(o, e, t, !0).properties];
|
|
2021
2019
|
if (s + 13 > n) throw new Error("Truncated FBX layered array header.");
|
|
2022
|
-
const
|
|
2023
|
-
if (
|
|
2024
|
-
const u = new Uint8Array(
|
|
2025
|
-
if (c.length !==
|
|
2020
|
+
const i = o.getUint32(s + 1, !0), l = o.getUint32(s + 5, !0), p = o.getUint32(s + 9, !0), f = a === "d" ? 8 : 4;
|
|
2021
|
+
if (i > 4096 || s + 13 + p !== n || ![0, 1].includes(l)) throw new Error("Invalid FBX layered array bounds.");
|
|
2022
|
+
const u = new Uint8Array(o.buffer, o.byteOffset + s + 13, p), c = l === 1 ? dt(u, { out: new Uint8Array(i * f) }) : u;
|
|
2023
|
+
if (c.length !== i * f) throw new Error("Invalid FBX layered array size.");
|
|
2026
2024
|
const h = new DataView(c.buffer, c.byteOffset, c.byteLength);
|
|
2027
|
-
return Array.from({ length:
|
|
2025
|
+
return Array.from({ length: i }, (m, g) => a === "i" ? h.getInt32(g * f, !0) : a === "d" ? h.getFloat64(g * f, !0) : h.getFloat32(g * f, !0));
|
|
2028
2026
|
}
|
|
2029
|
-
const
|
|
2030
|
-
function
|
|
2031
|
-
const e =
|
|
2032
|
-
if (!t || !n || t * n >
|
|
2027
|
+
const be = (o) => o <= 0.04045 ? o / 12.92 : ((o + 0.055) / 1.055) ** 2.4, jt = (o) => o <= 31308e-7 ? o * 12.92 : 1.055 * o ** (1 / 2.4) - 0.055, Ht = /* @__PURE__ */ new Set([0, 1, 2, 4, 5]), Wt = 4 * 1024 * 1024;
|
|
2028
|
+
function Me(o) {
|
|
2029
|
+
const e = o.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);
|
|
2030
|
+
if (!t || !n || t * n > Wt) throw new Error("missing image or image exceeds 4M pixels");
|
|
2033
2031
|
let r;
|
|
2034
2032
|
if (e.data) {
|
|
2035
|
-
if (
|
|
2033
|
+
if (o.format !== Ie || o.type !== Re || !(e.data instanceof Uint8Array) || e.data.length !== t * n * 4) throw new Error("require RGBA8 source");
|
|
2036
2034
|
r = e.data;
|
|
2037
2035
|
} else {
|
|
2038
2036
|
const a = document.createElement("canvas");
|
|
2039
2037
|
a.width = t, a.height = n;
|
|
2040
|
-
const
|
|
2041
|
-
if (!
|
|
2042
|
-
|
|
2038
|
+
const i = a.getContext("2d", { willReadFrequently: !0 });
|
|
2039
|
+
if (!i) throw new Error("canvas readback unavailable");
|
|
2040
|
+
i.drawImage(o.image, 0, 0), r = i.getImageData(0, 0, t, n).data;
|
|
2043
2041
|
}
|
|
2044
2042
|
const s = new Uint8Array(t * n * 4);
|
|
2045
|
-
for (let a = 0; a < n; a++) for (let
|
|
2043
|
+
for (let a = 0; a < n; a++) for (let i = 0; i < t * 4; i++) s[(o.flipY ? n - a - 1 : a) * t * 4 + i] = r[a * t * 4 + i];
|
|
2046
2044
|
return { data: s, width: t, height: n };
|
|
2047
2045
|
}
|
|
2048
|
-
function
|
|
2049
|
-
if (
|
|
2050
|
-
if (
|
|
2051
|
-
if (!
|
|
2052
|
-
const n =
|
|
2046
|
+
function Yt(o, e, t) {
|
|
2047
|
+
if (o.issues.some((u) => u.code !== "LAYERED_TEXTURE_NOT_COMPOSITED")) throw new Error("incompatible layer graph or coordinates");
|
|
2048
|
+
if (o.layers.length < 1 || o.layers.length > 8) throw new Error("require 1–8 layers");
|
|
2049
|
+
if (!o.layers.every((u) => u.blendMode !== null && Ht.has(u.blendMode))) throw new Error("unsupported blend mode");
|
|
2050
|
+
const n = o.layers.map((u) => {
|
|
2053
2051
|
const c = [...t].find((h) => h.ID === u.textureId);
|
|
2054
2052
|
if (!c) throw new Error(`missing decoded texture ${u.textureId}`);
|
|
2055
2053
|
return c;
|
|
@@ -2069,54 +2067,54 @@ function Wt(i, e, t) {
|
|
|
2069
2067
|
u.matrix.elements
|
|
2070
2068
|
]);
|
|
2071
2069
|
if (n.some((u) => s(u) !== s(r))) throw new Error("incompatible sampling state");
|
|
2072
|
-
if (
|
|
2073
|
-
const a =
|
|
2074
|
-
if (
|
|
2075
|
-
const l = new Float32Array(
|
|
2076
|
-
for (let u = 0; u <
|
|
2070
|
+
if (o.layers.some((u) => !e.textures.has(u.textureId))) throw new Error("missing source metadata");
|
|
2071
|
+
const a = Me(r), i = a.width * a.height;
|
|
2072
|
+
if (o.layers[0].alpha !== 1 || a.data.some((u, c) => c % 4 === 3 && u !== 255)) throw new Error("base layer must be fully opaque with weight 1");
|
|
2073
|
+
const l = new Float32Array(i * 3);
|
|
2074
|
+
for (let u = 0; u < i; u++) for (let c = 0; c < 3; c++) l[u * 3 + c] = r.colorSpace === ge ? a.data[u * 4 + c] / 255 : be(a.data[u * 4 + c] / 255);
|
|
2077
2075
|
for (let u = 1; u < n.length; u++) {
|
|
2078
|
-
const c = n[u], h =
|
|
2076
|
+
const c = n[u], h = Me(c), m = o.layers[u];
|
|
2079
2077
|
if (h.width !== a.width || h.height !== a.height) throw new Error("layer dimensions differ");
|
|
2080
|
-
for (let g = 0; g <
|
|
2078
|
+
for (let g = 0; g < i; g++) {
|
|
2081
2079
|
const d = m.alpha * h.data[g * 4 + 3] / 255;
|
|
2082
2080
|
for (let T = 0; T < 3; T++) {
|
|
2083
|
-
const F = l[g * 3 + T], y = h.data[g * 4 + T] / 255, x = c.colorSpace ===
|
|
2084
|
-
l[g * 3 + T] = F + (
|
|
2081
|
+
const F = l[g * 3 + T], y = h.data[g * 4 + T] / 255, x = c.colorSpace === ge ? y : be(y), A = m.blendMode === 1 ? Math.min(1, F + x) : m.blendMode === 2 ? F * x : x;
|
|
2082
|
+
l[g * 3 + T] = F + (A - F) * d;
|
|
2085
2083
|
}
|
|
2086
2084
|
}
|
|
2087
2085
|
}
|
|
2088
|
-
const p = new Uint8Array(
|
|
2089
|
-
for (let u = 0; u <
|
|
2090
|
-
for (let u = 0; u <
|
|
2086
|
+
const p = new Uint8Array(i * 4);
|
|
2087
|
+
for (let u = 0; u < i; u++) p[u * 4 + 3] = 255;
|
|
2088
|
+
for (let u = 0; u < i; u++) for (let c = 0; c < 3; c++) p[u * 4 + c] = Math.round(255 * Math.min(1, Math.max(0, jt(l[u * 3 + c]))));
|
|
2091
2089
|
const f = new ne(p, a.width, a.height);
|
|
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 =
|
|
2090
|
+
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 = o.layers[0].textureId, f.needsUpdate = !0, f;
|
|
2093
2091
|
}
|
|
2094
|
-
function
|
|
2095
|
-
return
|
|
2092
|
+
function qt(o, e) {
|
|
2093
|
+
return o.textureConnections.flatMap((t) => {
|
|
2096
2094
|
var u;
|
|
2097
2095
|
const n = (u = e.layeredTextures) == null ? void 0 : u.get(t.id);
|
|
2098
2096
|
if (!n) return [];
|
|
2099
2097
|
const r = [], s = (c, h) => r.push({ status: "unsupported", code: c, source: `layered:${n.id}:${h}`, target: t.role });
|
|
2100
2098
|
s("LAYERED_TEXTURE_NOT_COMPOSITED", "preview uses loader fallback; layers have not been composited");
|
|
2101
|
-
const a = /* @__PURE__ */ new Set(),
|
|
2099
|
+
const a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = [], p = (c, h) => {
|
|
2102
2100
|
var g;
|
|
2103
2101
|
if (a.has(c)) {
|
|
2104
2102
|
s("LAYERED_TEXTURE_CYCLE", String(c));
|
|
2105
2103
|
return;
|
|
2106
2104
|
}
|
|
2107
|
-
if (h > 32 ||
|
|
2105
|
+
if (h > 32 || i.size >= 4096) {
|
|
2108
2106
|
s("LAYERED_TEXTURE_GRAPH_LIMIT", String(c));
|
|
2109
2107
|
return;
|
|
2110
2108
|
}
|
|
2111
|
-
if (
|
|
2109
|
+
if (i.has(c)) return;
|
|
2112
2110
|
const m = (g = e.layeredTextures) == null ? void 0 : g.get(c);
|
|
2113
2111
|
if (!m) {
|
|
2114
|
-
e.textures.has(c) ? l.push(c) : s("LAYERED_TEXTURE_MISSING_SOURCE", String(c)),
|
|
2112
|
+
e.textures.has(c) ? l.push(c) : s("LAYERED_TEXTURE_MISSING_SOURCE", String(c)), i.add(c);
|
|
2115
2113
|
return;
|
|
2116
2114
|
}
|
|
2117
2115
|
h && s("LAYERED_TEXTURE_NESTED", String(c)), m.textureIds.length || s("LAYERED_TEXTURE_EMPTY", String(c)), (m.blendModes.length !== m.textureIds.length || m.alphas.length !== m.textureIds.length) && s("LAYERED_TEXTURE_METADATA_MISMATCH", `${c}:sources=${m.textureIds.length},modes=${m.blendModes.length},alphas=${m.alphas.length}`), m.blendModes.some((d) => !Number.isInteger(d) || d < 0) && s("LAYERED_TEXTURE_INVALID_MODE", String(c)), m.alphas.some((d) => !Number.isFinite(d) || d < 0 || d > 1) && s("LAYERED_TEXTURE_INVALID_ALPHA", String(c)), a.add(c);
|
|
2118
2116
|
for (const d of m.textureIds) p(d, h + 1);
|
|
2119
|
-
a.delete(c),
|
|
2117
|
+
a.delete(c), i.add(c);
|
|
2120
2118
|
};
|
|
2121
2119
|
return p(n.id, 0), new Set(l.map((c) => {
|
|
2122
2120
|
const h = e.textures.get(c);
|
|
@@ -2124,7 +2122,7 @@ function Yt(i, e) {
|
|
|
2124
2122
|
})).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 }];
|
|
2125
2123
|
});
|
|
2126
2124
|
}
|
|
2127
|
-
const
|
|
2125
|
+
const Kt = {
|
|
2128
2126
|
DiffuseColor: "map",
|
|
2129
2127
|
"Maya|TEX_color_map": "map",
|
|
2130
2128
|
NormalMap: "normalMap",
|
|
@@ -2141,11 +2139,11 @@ const qt = {
|
|
|
2141
2139
|
TransparentColor: "alphaMap",
|
|
2142
2140
|
TransparencyFactor: "alphaMap"
|
|
2143
2141
|
};
|
|
2144
|
-
function
|
|
2142
|
+
function Zt(o, e, t, n, r, s) {
|
|
2145
2143
|
var c;
|
|
2146
|
-
const a = (c = n.modelUvSets) == null ? void 0 : c.get(
|
|
2144
|
+
const a = (c = n.modelUvSets) == null ? void 0 : c.get(o.ID ?? NaN), i = [], l = [], p = /* @__PURE__ */ new Set();
|
|
2147
2145
|
for (const h of t.textureConnections) {
|
|
2148
|
-
const m =
|
|
2146
|
+
const m = Kt[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);
|
|
2149
2147
|
if (!m || !d || p.has(m)) continue;
|
|
2150
2148
|
p.add(m);
|
|
2151
2149
|
const T = e[m];
|
|
@@ -2160,24 +2158,24 @@ function Kt(i, e, t, n, r, s) {
|
|
|
2160
2158
|
continue;
|
|
2161
2159
|
}
|
|
2162
2160
|
}
|
|
2163
|
-
if (y > 3 || !
|
|
2161
|
+
if (y > 3 || !o.geometry.hasAttribute(y === 0 ? "uv" : `uv${y}`)) {
|
|
2164
2162
|
F("UV_CHANNEL_UNAVAILABLE", `channel:${y}`);
|
|
2165
2163
|
continue;
|
|
2166
2164
|
}
|
|
2167
2165
|
const x = (R, w) => {
|
|
2168
2166
|
const D = d.values.get(R);
|
|
2169
2167
|
return D ? D.length < 2 || !D.every((P) => typeof P == "number" && Number.isFinite(P)) ? (F("TEXTURE_TRANSFORM_INVALID", R), w) : D : w;
|
|
2170
|
-
},
|
|
2171
|
-
E && F("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-rotation-or-pivot"), (
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2168
|
+
}, A = x("Translation", [T.offset.x, T.offset.y, 0]), I = x("Scaling", [T.repeat.x, T.repeat.y, 1]), b = x("Rotation", [0, 0, 0]), v = x("RotationPivot", [0, 0, 0]), S = x("ScalingPivot", [0, 0, 0]), E = b[0] !== 0 || b[1] !== 0 || v.some((R) => R !== 0) || S.some((R) => R !== 0);
|
|
2169
|
+
E && F("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-rotation-or-pivot"), (A[2] || I[2] !== void 0 && I[2] !== 1) && F("TEXTURE_TRANSFORM_UNSUPPORTED", "3D-translation-or-scale");
|
|
2170
|
+
const M = E ? 0 : -(b[2] ?? 0) * Math.PI / 180;
|
|
2171
|
+
M && l.push({ status: "approximate", code: "TEXTURE_ROTATION_PROFILE", source: `texture:${h.id}:Rotation`, target: "T * Rccw * S; origin pivot" }), (y !== T.channel || A[0] !== T.offset.x || A[1] !== T.offset.y || I[0] !== T.repeat.x || I[1] !== T.repeat.y || M !== T.rotation) && i.push({ slot: m, source: T, channel: y, offset: A, scale: I, rotation: M });
|
|
2174
2172
|
}
|
|
2175
|
-
if (!
|
|
2173
|
+
if (!i.length && !l.length) return e;
|
|
2176
2174
|
const f = e.clone();
|
|
2177
2175
|
r(f);
|
|
2178
2176
|
const u = f.userData.fbxConversionReport;
|
|
2179
2177
|
u.issues.push(...l);
|
|
2180
|
-
for (const h of
|
|
2178
|
+
for (const h of i) {
|
|
2181
2179
|
const m = h.source.clone();
|
|
2182
2180
|
s(m), m.channel = h.channel, m.offset.set(h.offset[0], h.offset[1]), m.repeat.set(h.scale[0], h.scale[1]), m.center.set(0, 0), m.rotation = h.rotation;
|
|
2183
2181
|
const g = -h.rotation, d = Math.cos(g), T = Math.sin(g);
|
|
@@ -2195,47 +2193,47 @@ function Kt(i, e, t, n, r, s) {
|
|
|
2195
2193
|
}
|
|
2196
2194
|
return f.needsUpdate = !0, f;
|
|
2197
2195
|
}
|
|
2198
|
-
function
|
|
2199
|
-
return Math.min(1, Math.max(0,
|
|
2196
|
+
function Qt(o, e) {
|
|
2197
|
+
return Math.min(1, Math.max(0, o));
|
|
2200
2198
|
}
|
|
2201
|
-
function
|
|
2202
|
-
if (!Number.isInteger(e) || !Number.isInteger(t) || e <= 0 || t <= 0 ||
|
|
2199
|
+
function Jt(o, e, t, n, r = "r", s = !1) {
|
|
2200
|
+
if (!Number.isInteger(e) || !Number.isInteger(t) || e <= 0 || t <= 0 || o.length !== e * t * 4)
|
|
2203
2201
|
throw new Error("Invalid FBX scalar RGBA dimensions.");
|
|
2204
|
-
const a = new Uint8Array(
|
|
2202
|
+
const a = new Uint8Array(o.length), i = { r: 0, g: 1, b: 2, a: 3 }[r];
|
|
2205
2203
|
for (let l = 0; l < t; l++) for (let p = 0; p < e; p++) {
|
|
2206
|
-
const f = (l * e + p) * 4, u = ((s ? t - l - 1 : l) * e + p) * 4, c = Math.round(255 *
|
|
2204
|
+
const f = (l * e + p) * 4, u = ((s ? t - l - 1 : l) * e + p) * 4, c = Math.round(255 * Qt(o[f + i] / 255));
|
|
2207
2205
|
a.fill(c, u, u + 4);
|
|
2208
2206
|
}
|
|
2209
2207
|
return a;
|
|
2210
2208
|
}
|
|
2211
|
-
function
|
|
2212
|
-
const t =
|
|
2209
|
+
function en(o, e) {
|
|
2210
|
+
const t = o.image;
|
|
2213
2211
|
if (!t) throw new Error("FBX scalar texture has no decoded image.");
|
|
2214
2212
|
const n = t.naturalWidth || t.width, r = t.naturalHeight || t.height;
|
|
2215
2213
|
if (!n || !r) throw new Error("FBX scalar texture has no decoded image.");
|
|
2216
2214
|
let s;
|
|
2217
2215
|
if (t.data) {
|
|
2218
|
-
if (!(t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray) ||
|
|
2216
|
+
if (!(t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray) || o.format !== Ie || o.type !== Re)
|
|
2219
2217
|
throw new Error("FBX scalar conversion requires 8-bit RGBA pixels.");
|
|
2220
2218
|
s = t.data;
|
|
2221
2219
|
} else {
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2224
|
-
const l =
|
|
2220
|
+
const i = document.createElement("canvas");
|
|
2221
|
+
i.width = n, i.height = r;
|
|
2222
|
+
const l = i.getContext("2d", { willReadFrequently: !0 });
|
|
2225
2223
|
if (!l) throw new Error("FBX scalar texture conversion requires a 2D canvas.");
|
|
2226
2224
|
l.drawImage(t, 0, 0), s = l.getImageData(0, 0, n, r).data;
|
|
2227
2225
|
}
|
|
2228
|
-
const a = new ne(
|
|
2229
|
-
return a.wrapS =
|
|
2226
|
+
const a = new ne(Jt(s, n, r, e, "r", o.flipY), n, r);
|
|
2227
|
+
return a.wrapS = o.wrapS, a.wrapT = o.wrapT, a.offset.copy(o.offset), a.repeat.copy(o.repeat), a.center.copy(o.center), a.rotation = o.rotation, a.matrix.copy(o.matrix), a.matrixAutoUpdate = o.matrixAutoUpdate, a.channel = o.channel, a.magFilter = o.magFilter, a.minFilter = o.minFilter, a.generateMipmaps = o.generateMipmaps, a.anisotropy = o.anisotropy, a.colorSpace = ot, a.needsUpdate = !0, a;
|
|
2230
2228
|
}
|
|
2231
|
-
function
|
|
2232
|
-
const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(),
|
|
2229
|
+
function tn(o, e, t) {
|
|
2230
|
+
const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = [];
|
|
2233
2231
|
try {
|
|
2234
|
-
|
|
2235
|
-
if (!(c instanceof
|
|
2232
|
+
o.traverse((c) => {
|
|
2233
|
+
if (!(c instanceof Ae)) return;
|
|
2236
2234
|
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) => {
|
|
2237
|
-
const F = m(T), y =
|
|
2238
|
-
return y instanceof
|
|
2235
|
+
const F = m(T), y = nn(d, n, F, t, e, r, s);
|
|
2236
|
+
return y instanceof De && F && e ? Zt(c, y, F, e, (x) => a.add(x), (x) => i.add(x)) : y;
|
|
2239
2237
|
};
|
|
2240
2238
|
l.push({ mesh: c, material: Array.isArray(c.material) ? c.material.map(g) : g(c.material, 0) });
|
|
2241
2239
|
});
|
|
@@ -2243,7 +2241,7 @@ function en(i, e, t) {
|
|
|
2243
2241
|
for (const [h, m] of n) h !== m && m.dispose();
|
|
2244
2242
|
for (const h of r.values()) h.dispose();
|
|
2245
2243
|
for (const h of a) h.dispose();
|
|
2246
|
-
for (const h of
|
|
2244
|
+
for (const h of i) h.dispose();
|
|
2247
2245
|
for (const h of s.values()) h.dispose();
|
|
2248
2246
|
throw c;
|
|
2249
2247
|
}
|
|
@@ -2256,15 +2254,15 @@ function en(i, e, t) {
|
|
|
2256
2254
|
for (const c of r.values()) f.has(c) || c.dispose();
|
|
2257
2255
|
for (const c of s.values()) f.has(c) || c.dispose();
|
|
2258
2256
|
const u = [...p].flatMap((c) => c.userData.fbxConversionReport ? [c.userData.fbxConversionReport] : []);
|
|
2259
|
-
return
|
|
2257
|
+
return o.userData.fbxConversionReports = u, u;
|
|
2260
2258
|
}
|
|
2261
|
-
function
|
|
2262
|
-
var E,
|
|
2263
|
-
const
|
|
2264
|
-
if (
|
|
2265
|
-
if (!(
|
|
2266
|
-
return e.set(
|
|
2267
|
-
const l =
|
|
2259
|
+
function nn(o, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map()) {
|
|
2260
|
+
var E, M, R;
|
|
2261
|
+
const i = e.get(o);
|
|
2262
|
+
if (i) return i;
|
|
2263
|
+
if (!(o instanceof W) && !(o instanceof Fe))
|
|
2264
|
+
return e.set(o, o), o;
|
|
2265
|
+
const l = o instanceof W ? o : null, p = (w, D) => {
|
|
2268
2266
|
var _;
|
|
2269
2267
|
const P = (_ = t == null ? void 0 : t.values.get(w)) == null ? void 0 : _[0];
|
|
2270
2268
|
return typeof P == "number" && Number.isFinite(P) ? P : D;
|
|
@@ -2272,41 +2270,41 @@ function tn(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2272
2270
|
const P = t == null ? void 0 : t.values.get(w);
|
|
2273
2271
|
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();
|
|
2274
2272
|
}, 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);
|
|
2275
|
-
let g =
|
|
2273
|
+
let g = o.opacity;
|
|
2276
2274
|
if (t && (g = 1 - p("TransparencyFactor", 0), g === 0 || g === 1)) {
|
|
2277
2275
|
const w = (E = t.ownValues.get("Opacity")) == null ? void 0 : E[0];
|
|
2278
2276
|
g = typeof w == "number" && Number.isFinite(w) ? w : 1 - f("TransparentColor", new k(0)).r;
|
|
2279
2277
|
}
|
|
2280
|
-
const d = new
|
|
2281
|
-
name:
|
|
2278
|
+
const d = new De({
|
|
2279
|
+
name: o.name,
|
|
2282
2280
|
// FBX diffuse textures supply the base color (as in Blender's importer),
|
|
2283
2281
|
// not an additional tint. Multiplying the atlas by DiffuseColor can turn
|
|
2284
2282
|
// blue atlas regions black when the material's constant color is red.
|
|
2285
|
-
color:
|
|
2286
|
-
map:
|
|
2287
|
-
emissive:
|
|
2288
|
-
emissiveMap:
|
|
2289
|
-
emissiveIntensity: p("EmissiveFactor", t ? 1 :
|
|
2290
|
-
normalMap:
|
|
2291
|
-
normalMapType:
|
|
2292
|
-
normalScale:
|
|
2293
|
-
bumpMap:
|
|
2294
|
-
bumpScale:
|
|
2295
|
-
displacementMap:
|
|
2296
|
-
displacementScale:
|
|
2297
|
-
displacementBias:
|
|
2298
|
-
aoMap:
|
|
2299
|
-
aoMapIntensity:
|
|
2300
|
-
alphaMap:
|
|
2283
|
+
color: o.map ? new k(16777215) : f("DiffuseColor", t ? new k(1, 1, 1) : o.color),
|
|
2284
|
+
map: o.map,
|
|
2285
|
+
emissive: o.emissiveMap ? new k(16777215) : f("EmissiveColor", t ? new k(0) : o.emissive),
|
|
2286
|
+
emissiveMap: o.emissiveMap,
|
|
2287
|
+
emissiveIntensity: p("EmissiveFactor", t ? 1 : o.emissiveIntensity),
|
|
2288
|
+
normalMap: o.normalMap,
|
|
2289
|
+
normalMapType: o.normalMapType,
|
|
2290
|
+
normalScale: o.normalScale.clone().setScalar(p("BumpFactor", 1)),
|
|
2291
|
+
bumpMap: o.bumpMap,
|
|
2292
|
+
bumpScale: o.bumpScale,
|
|
2293
|
+
displacementMap: o.displacementMap,
|
|
2294
|
+
displacementScale: o.displacementScale,
|
|
2295
|
+
displacementBias: o.displacementBias,
|
|
2296
|
+
aoMap: o.aoMap,
|
|
2297
|
+
aoMapIntensity: o.aoMapIntensity,
|
|
2298
|
+
alphaMap: o.alphaMap,
|
|
2301
2299
|
opacity: u(g),
|
|
2302
|
-
transparent:
|
|
2303
|
-
alphaTest:
|
|
2304
|
-
side:
|
|
2305
|
-
depthTest:
|
|
2306
|
-
depthWrite:
|
|
2307
|
-
vertexColors:
|
|
2308
|
-
wireframe:
|
|
2309
|
-
flatShading:
|
|
2300
|
+
transparent: o.transparent || g < 1,
|
|
2301
|
+
alphaTest: o.alphaTest,
|
|
2302
|
+
side: o.side,
|
|
2303
|
+
depthTest: o.depthTest,
|
|
2304
|
+
depthWrite: o.depthWrite,
|
|
2305
|
+
vertexColors: o.vertexColors,
|
|
2306
|
+
wireframe: o.wireframe,
|
|
2307
|
+
flatShading: o.flatShading,
|
|
2310
2308
|
metalness: u(p("ReflectionFactor", 0)),
|
|
2311
2309
|
ior: m,
|
|
2312
2310
|
specularIntensity: 1,
|
|
@@ -2314,20 +2312,20 @@ function tn(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2314
2312
|
// This is an importer convention, not an exact BRDF conversion.
|
|
2315
2313
|
roughness: t || l ? u(1 - Math.sqrt(Math.max(0, p("Shininess", t ? 20 : l.shininess))) / 10) : 1
|
|
2316
2314
|
});
|
|
2317
|
-
e.set(
|
|
2315
|
+
e.set(o, d);
|
|
2318
2316
|
const T = (w) => {
|
|
2319
2317
|
let D = s.get(w);
|
|
2320
|
-
return D || (D =
|
|
2321
|
-
}, F = t && r ?
|
|
2318
|
+
return D || (D = en(w, "identity"), s.set(w, D)), D;
|
|
2319
|
+
}, F = t && r ? qt(t, r) : [], y = [];
|
|
2322
2320
|
for (const w of F)
|
|
2323
2321
|
if (!(!["DiffuseColor", "EmissiveColor"].includes(w.role) || !r || !n) && t.textureConnections.filter((D) => D.role === w.role).length === 1)
|
|
2324
2322
|
try {
|
|
2325
2323
|
let D = a.get(w.id);
|
|
2326
|
-
D || (D =
|
|
2324
|
+
D || (D = Yt(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
2325
|
} catch (D) {
|
|
2328
2326
|
w.issues.push({ status: "unsupported", code: "LAYERED_TEXTURE_BAKE_REJECTED", source: `layered:${w.id}:${D instanceof Error ? D.message : String(D)}`, target: w.role });
|
|
2329
2327
|
}
|
|
2330
|
-
const x = /* @__PURE__ */ new Set(),
|
|
2328
|
+
const x = /* @__PURE__ */ new Set(), A = [], I = /* @__PURE__ */ new Set(), b = {
|
|
2331
2329
|
ReflectionFactor: "metalnessMap",
|
|
2332
2330
|
ReflectionColor: "metalnessMap",
|
|
2333
2331
|
ShininessExponent: "roughnessMap",
|
|
@@ -2337,18 +2335,18 @@ function tn(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2337
2335
|
TransparencyFactor: "alphaMap"
|
|
2338
2336
|
};
|
|
2339
2337
|
for (const w of (t == null ? void 0 : t.textureConnections) ?? []) {
|
|
2340
|
-
if ((
|
|
2338
|
+
if ((M = r == null ? void 0 : r.layeredTextures) != null && M.has(w.id)) continue;
|
|
2341
2339
|
const D = [...n ?? []].find((_) => _.ID === w.id);
|
|
2342
2340
|
if (!D) {
|
|
2343
|
-
|
|
2341
|
+
A.push(`texture:${w.id}:unresolved:${w.role}`);
|
|
2344
2342
|
continue;
|
|
2345
2343
|
}
|
|
2346
|
-
const P =
|
|
2347
|
-
if (P &&
|
|
2348
|
-
|
|
2344
|
+
const P = b[w.role];
|
|
2345
|
+
if (P && I.has(P)) {
|
|
2346
|
+
A.push(`conflicting-input:${w.role}:${P}`);
|
|
2349
2347
|
continue;
|
|
2350
2348
|
}
|
|
2351
|
-
switch (P &&
|
|
2349
|
+
switch (P && I.add(P), w.role) {
|
|
2352
2350
|
case "ReflectionFactor":
|
|
2353
2351
|
case "ReflectionColor":
|
|
2354
2352
|
d.metalnessMap = T(D), d.metalness = 1, x.add(w.role);
|
|
@@ -2366,7 +2364,7 @@ function tn(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2366
2364
|
break;
|
|
2367
2365
|
}
|
|
2368
2366
|
}
|
|
2369
|
-
d.userData = { ...
|
|
2367
|
+
d.userData = { ...o.userData, fbxMaterialId: t == null ? void 0 : t.id };
|
|
2370
2368
|
const v = (t == null ? void 0 : t.textureRoles.filter((w) => ![
|
|
2371
2369
|
"DiffuseColor",
|
|
2372
2370
|
"Maya|TEX_color_map",
|
|
@@ -2379,81 +2377,97 @@ function tn(i, e, t, n, r, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ ne
|
|
|
2379
2377
|
"TransparencyFactor",
|
|
2380
2378
|
"Maya|TEX_ao_map"
|
|
2381
2379
|
].includes(w) && !x.has(w))) ?? [];
|
|
2382
|
-
v.push(...
|
|
2380
|
+
v.push(...A);
|
|
2383
2381
|
for (const w of (t == null ? void 0 : t.textureConnections) ?? [])
|
|
2384
2382
|
!(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`);
|
|
2385
|
-
t && !["phong", "lambert"].includes(t.shadingModel) && v.push(`shader:${t.shadingModel}`), v.length && (d.userData.fbxUnsupportedTextureRoles = v, console.warn(`[viewer] FBX material ${
|
|
2383
|
+
t && !["phong", "lambert"].includes(t.shadingModel) && v.push(`shader:${t.shadingModel}`), v.length && (d.userData.fbxUnsupportedTextureRoles = v, console.warn(`[viewer] FBX material ${o.name}: unsupported texture semantics: ${v.join(", ")}`));
|
|
2386
2384
|
const S = {
|
|
2387
2385
|
layerStacks: F,
|
|
2388
2386
|
strategy: "blender-compatible-v1",
|
|
2389
2387
|
materialId: t == null ? void 0 : t.id,
|
|
2390
|
-
materialName:
|
|
2388
|
+
materialName: o.name,
|
|
2391
2389
|
mappings: [
|
|
2392
2390
|
{ source: "DiffuseColor", target: "color/map", rule: "texture replaces constant; raw constant RGB otherwise" },
|
|
2393
2391
|
{ source: "Shininess", target: "roughness", rule: "clamp(1-sqrt(max(0,s))/10); empirical approximation" },
|
|
2394
2392
|
{ source: "ReflectionFactor", target: "metalness", rule: "clamp(value); importer convention" },
|
|
2395
2393
|
{ source: "SpecularFactor", target: "ior", rule: "match normal-incidence F0 only" },
|
|
2396
|
-
...[...x].map((w) => ({ source: w, target:
|
|
2394
|
+
...[...x].map((w) => ({ source: w, target: b[w], rule: "raw R; identity; replaces scalar constant" }))
|
|
2397
2395
|
],
|
|
2398
2396
|
issues: [
|
|
2399
2397
|
...F.flatMap((w) => w.issues),
|
|
2400
2398
|
...y.map((w) => ({ status: "approximate", code: "LAYERED_TEXTURE_BAKED", source: `layered:${w}:linear-color-v1; opaque base; first connection bottom`, target: "RGBA8 color texture" })),
|
|
2401
|
-
{ status: "approximate", code: "PHONG_TO_PBR", source: (t == null ? void 0 : t.shadingModel) ??
|
|
2399
|
+
{ status: "approximate", code: "PHONG_TO_PBR", source: (t == null ? void 0 : t.shadingModel) ?? o.type, target: "MeshPhysicalMaterial" },
|
|
2402
2400
|
...v.map((w) => ({ status: "unsupported", code: "UNSUPPORTED_SEMANTICS", source: w }))
|
|
2403
2401
|
]
|
|
2404
2402
|
};
|
|
2405
|
-
return d.userData.fbxConversionReport = S, d.visible =
|
|
2403
|
+
return d.userData.fbxConversionReport = S, d.visible = o.visible, d.toneMapped = o.toneMapped, d.clippingPlanes = o.clippingPlanes, d.clipIntersection = o.clipIntersection, d.clipShadows = o.clipShadows, d.polygonOffset = o.polygonOffset, d.polygonOffsetFactor = o.polygonOffsetFactor, d.polygonOffsetUnits = o.polygonOffsetUnits, d.dithering = o.dithering, d.needsUpdate = !0, e.set(o, d), d;
|
|
2404
|
+
}
|
|
2405
|
+
const ue = "viewer-package:///";
|
|
2406
|
+
function rn(o) {
|
|
2407
|
+
const e = o.replaceAll("\\", "/").split("/").filter(Boolean).map((t) => encodeURIComponent(t)).join("/");
|
|
2408
|
+
return `${ue}${e}`;
|
|
2409
|
+
}
|
|
2410
|
+
function sn(o, e) {
|
|
2411
|
+
if (!o.resolveSync || !e.startsWith(ue)) return e;
|
|
2412
|
+
const t = e.slice(ue.length).split(/[?#]/, 1)[0] ?? "";
|
|
2413
|
+
let n = t;
|
|
2414
|
+
try {
|
|
2415
|
+
n = decodeURIComponent(t);
|
|
2416
|
+
} catch {
|
|
2417
|
+
return e;
|
|
2418
|
+
}
|
|
2419
|
+
return o.resolveSync(n) ?? e;
|
|
2406
2420
|
}
|
|
2407
|
-
function
|
|
2408
|
-
let t = !1, n = null, r = null, s = "z", a,
|
|
2421
|
+
function mn(o, e) {
|
|
2422
|
+
let t = !1, n = null, r = null, s = "z", a, i = null, l;
|
|
2409
2423
|
const p = () => {
|
|
2410
2424
|
t = !0;
|
|
2411
2425
|
}, f = (async () => {
|
|
2412
|
-
s = e.options.upAxis ??
|
|
2426
|
+
s = e.options.upAxis ?? ye(e.format);
|
|
2413
2427
|
let u = null;
|
|
2414
2428
|
try {
|
|
2415
2429
|
if (t || e.signal.aborted) throw le();
|
|
2416
|
-
const c =
|
|
2430
|
+
const c = e.format !== "fbx" && typeof o.original == "object" && o.original !== null && "kind" in o.original && o.original.kind === "files" && o.entryPath && o.resolveSync ? rn(o.entryPath) : null, h = o.url ?? c ?? await o.resolve(o.entryPath ?? "");
|
|
2417
2431
|
if (u = new ce(), u.name = "viewer-model-root", e.format === "fbx") {
|
|
2418
|
-
const
|
|
2419
|
-
if (!
|
|
2420
|
-
const
|
|
2421
|
-
s = e.options.upAxis ??
|
|
2422
|
-
const
|
|
2423
|
-
l =
|
|
2424
|
-
const
|
|
2425
|
-
|
|
2432
|
+
const g = await fetch(h, { signal: e.signal });
|
|
2433
|
+
if (!g.ok) throw new Error(`FBX request failed: ${g.status} ${g.statusText}`);
|
|
2434
|
+
const d = await g.arrayBuffer();
|
|
2435
|
+
s = e.options.upAxis ?? Bt(d) ?? ye(e.format);
|
|
2436
|
+
const T = Gt(d), F = await Lt(d, o, T);
|
|
2437
|
+
l = F.textures, u.add(F.root);
|
|
2438
|
+
const x = tn(u, T, l).flatMap((I) => I.issues.filter((b) => b.status === "unsupported" || b.code === "TEXTURE_ROTATION_PROFILE" || b.code === "LAYERED_TEXTURE_BAKED").map((b) => `${I.materialName || I.materialId || "material"}: ${b.source}`));
|
|
2439
|
+
x.length && (i = {
|
|
2426
2440
|
code: "W_FBX_MATERIAL_APPROXIMATED",
|
|
2427
2441
|
stage: "material-conversion",
|
|
2428
|
-
message: `FBX 材质存在未支持或按兼容规则近似处理的语义:${[...new Set(
|
|
2442
|
+
message: `FBX 材质存在未支持或按兼容规则近似处理的语义:${[...new Set(x)].join("、")}。当前为近似预览。`
|
|
2429
2443
|
});
|
|
2430
|
-
const
|
|
2431
|
-
|
|
2444
|
+
const A = [...new Set(F.textureFailures)];
|
|
2445
|
+
A.length && (i = {
|
|
2432
2446
|
code: "W_FBX_TEXTURE_UNAVAILABLE",
|
|
2433
2447
|
stage: "material-conversion",
|
|
2434
|
-
message: `FBX 贴图缺失或加载失败,已按无贴图降级显示:${
|
|
2448
|
+
message: `FBX 贴图缺失或加载失败,已按无贴图降级显示:${A.join("、")}。${i ? `另有材质近似处理:${i.message}` : ""}`
|
|
2435
2449
|
});
|
|
2436
2450
|
} else {
|
|
2437
|
-
const
|
|
2451
|
+
const g = new lt(), d = new ct();
|
|
2438
2452
|
try {
|
|
2439
|
-
|
|
2440
|
-
e.options.dracoDecoderPath ??
|
|
2441
|
-
),
|
|
2442
|
-
const
|
|
2443
|
-
if (u.add(
|
|
2444
|
-
for (const
|
|
2453
|
+
c && d.manager.setURLModifier((y) => sn(o, y)), g.setDecoderPath(
|
|
2454
|
+
e.options.dracoDecoderPath ?? gt("draco")
|
|
2455
|
+
), d.setDRACOLoader(g);
|
|
2456
|
+
const T = await d.loadAsync(h), F = T.scenes.filter((y) => y !== T.scene);
|
|
2457
|
+
if (u.add(T.scene), t || e.signal.aborted) {
|
|
2458
|
+
for (const y of F) u.add(y);
|
|
2445
2459
|
throw le();
|
|
2446
2460
|
}
|
|
2447
2461
|
} finally {
|
|
2448
|
-
|
|
2462
|
+
g.dispose();
|
|
2449
2463
|
}
|
|
2450
2464
|
}
|
|
2451
2465
|
if (t || e.signal.aborted) throw le();
|
|
2452
|
-
|
|
2453
|
-
const
|
|
2454
|
-
|
|
2466
|
+
we(u, s), an(u);
|
|
2467
|
+
const m = new ut(u, e.options.simulationTheme, void 0, "model");
|
|
2468
|
+
m.setCacheInvalidationCallback(e.invalidateTransmissionCaches), n = u, r = m, u = null;
|
|
2455
2469
|
} finally {
|
|
2456
|
-
u && (
|
|
2470
|
+
u && (ve(u, l), l = void 0);
|
|
2457
2471
|
}
|
|
2458
2472
|
})();
|
|
2459
2473
|
return f.catch(() => {
|
|
@@ -2461,7 +2475,7 @@ function dn(i, e) {
|
|
|
2461
2475
|
id: `model-${Math.random().toString(36).slice(2)}`,
|
|
2462
2476
|
opened: f,
|
|
2463
2477
|
get warning() {
|
|
2464
|
-
return
|
|
2478
|
+
return i;
|
|
2465
2479
|
},
|
|
2466
2480
|
get root() {
|
|
2467
2481
|
return (r == null ? void 0 : r.root) ?? null;
|
|
@@ -2490,10 +2504,10 @@ function dn(i, e) {
|
|
|
2490
2504
|
return (r == null ? void 0 : r.getGroundVisible()) ?? !0;
|
|
2491
2505
|
},
|
|
2492
2506
|
getGroundGridScale() {
|
|
2493
|
-
return (r == null ? void 0 : r.getGroundGridScale()) ??
|
|
2507
|
+
return (r == null ? void 0 : r.getGroundGridScale()) ?? pt;
|
|
2494
2508
|
},
|
|
2495
2509
|
setUpAxis(u) {
|
|
2496
|
-
if (t || !n || !r || !
|
|
2510
|
+
if (t || !n || !r || !we(n, u)) return;
|
|
2497
2511
|
s = u, r.reseatGround();
|
|
2498
2512
|
const c = r.getModelBounds();
|
|
2499
2513
|
e.requestRender(), e.fit(c, { padding: 1.15 });
|
|
@@ -2502,14 +2516,14 @@ function dn(i, e) {
|
|
|
2502
2516
|
dispose() {
|
|
2503
2517
|
return p(), a ?? (a = f.catch(() => {
|
|
2504
2518
|
}).then(() => {
|
|
2505
|
-
r == null || r.dispose(), r = null, n &&
|
|
2519
|
+
r == null || r.dispose(), r = null, n && ve(n, l), n = null, l = void 0;
|
|
2506
2520
|
})), a;
|
|
2507
2521
|
}
|
|
2508
2522
|
};
|
|
2509
2523
|
}
|
|
2510
|
-
function
|
|
2511
|
-
|
|
2512
|
-
const e = new
|
|
2524
|
+
function an(o) {
|
|
2525
|
+
o.updateMatrixWorld(!0);
|
|
2526
|
+
const e = new it().setFromObject(o);
|
|
2513
2527
|
if (e.isEmpty()) throw new Error("模型不包含可显示的几何内容。");
|
|
2514
2528
|
const t = e.getSize(new V()), n = Math.max(t.x, t.y, t.z);
|
|
2515
2529
|
if (!Number.isFinite(n) || n <= 0) throw new Error("模型尺寸无效。");
|
|
@@ -2518,5 +2532,5 @@ function le() {
|
|
|
2518
2532
|
return Object.assign(new Error("Model load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
2519
2533
|
}
|
|
2520
2534
|
export {
|
|
2521
|
-
|
|
2535
|
+
mn as createModelSession
|
|
2522
2536
|
};
|