mbt-3d 0.4.2 → 0.4.3
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/dist/mbt-3d.cjs +2 -2
- package/dist/mbt-3d.cjs.map +1 -1
- package/dist/mbt-3d.js +243 -239
- package/dist/mbt-3d.js.map +1 -1
- package/package.json +1 -1
package/dist/mbt-3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState as BA, useRef as N, useCallback as
|
|
1
|
+
import { useState as BA, useRef as N, useCallback as K, useEffect as L, Suspense as $, useMemo as V, createContext as UA, useContext as sA, forwardRef as wA, useImperativeHandle as iA } from "react";
|
|
2
2
|
import { ContactShadows as RA, Environment as aA, OrbitControls as MA, useProgress as eA, useTexture as SA, useGLTF as Z, useAnimations as cA } from "@react-three/drei";
|
|
3
3
|
import * as t from "three";
|
|
4
4
|
import * as FA from "three/examples/jsm/utils/SkeletonUtils.js";
|
|
@@ -54,9 +54,9 @@ function YA({ config: g }) {
|
|
|
54
54
|
function NA({ config: g }) {
|
|
55
55
|
const { scene: Q } = _();
|
|
56
56
|
return L(() => {
|
|
57
|
-
const B = g.intensity ?? 1, D = g.blur ?? 0, i = "environmentIntensity" in Q, G = "backgroundBlurriness" in Q,
|
|
58
|
-
return i && (Q.environmentIntensity = B), G && (Q.backgroundBlurriness = D), g.background &&
|
|
59
|
-
i && (Q.environmentIntensity = S ?? 1), G && (Q.backgroundBlurriness = o ?? 0),
|
|
57
|
+
const B = g.intensity ?? 1, D = g.blur ?? 0, i = "environmentIntensity" in Q, G = "backgroundBlurriness" in Q, U = "backgroundIntensity" in Q, S = i ? Q.environmentIntensity : void 0, o = G ? Q.backgroundBlurriness : void 0, w = U ? Q.backgroundIntensity : void 0;
|
|
58
|
+
return i && (Q.environmentIntensity = B), G && (Q.backgroundBlurriness = D), g.background && U && (Q.backgroundIntensity = B), () => {
|
|
59
|
+
i && (Q.environmentIntensity = S ?? 1), G && (Q.backgroundBlurriness = o ?? 0), U && (Q.backgroundIntensity = w ?? 1);
|
|
60
60
|
};
|
|
61
61
|
}, [Q, g]), null;
|
|
62
62
|
}
|
|
@@ -83,7 +83,7 @@ function fA({ config: g }) {
|
|
|
83
83
|
castShadow: D = !0,
|
|
84
84
|
shadowMapSize: i = 2048,
|
|
85
85
|
angle: G = Math.PI / 6,
|
|
86
|
-
penumbra:
|
|
86
|
+
penumbra: U = 0.5,
|
|
87
87
|
decay: S = 2,
|
|
88
88
|
distance: o = 0,
|
|
89
89
|
color: w = "#ffffff"
|
|
@@ -95,7 +95,7 @@ function fA({ config: g }) {
|
|
|
95
95
|
intensity: B,
|
|
96
96
|
castShadow: D,
|
|
97
97
|
angle: G,
|
|
98
|
-
penumbra:
|
|
98
|
+
penumbra: U,
|
|
99
99
|
decay: S,
|
|
100
100
|
distance: o,
|
|
101
101
|
color: w,
|
|
@@ -111,7 +111,7 @@ function fA({ config: g }) {
|
|
|
111
111
|
color: D = "#ffffff",
|
|
112
112
|
distance: i = 0,
|
|
113
113
|
decay: G = 2,
|
|
114
|
-
castShadow:
|
|
114
|
+
castShadow: U = !1,
|
|
115
115
|
shadowMapSize: S = 2048
|
|
116
116
|
} = g;
|
|
117
117
|
return /* @__PURE__ */ y(
|
|
@@ -122,7 +122,7 @@ function fA({ config: g }) {
|
|
|
122
122
|
color: D,
|
|
123
123
|
distance: i,
|
|
124
124
|
decay: G,
|
|
125
|
-
castShadow:
|
|
125
|
+
castShadow: U,
|
|
126
126
|
"shadow-mapSize-width": S,
|
|
127
127
|
"shadow-mapSize-height": S
|
|
128
128
|
}
|
|
@@ -154,11 +154,11 @@ function fA({ config: g }) {
|
|
|
154
154
|
groundColor: B = "#444444",
|
|
155
155
|
intensity: D = 0.5,
|
|
156
156
|
position: i = [0, 10, 0]
|
|
157
|
-
} = g, G = V(() => new t.Color(Q), [Q]),
|
|
157
|
+
} = g, G = V(() => new t.Color(Q), [Q]), U = V(() => new t.Color(B), [B]);
|
|
158
158
|
return /* @__PURE__ */ y(
|
|
159
159
|
"hemisphereLight",
|
|
160
160
|
{
|
|
161
|
-
args: [G,
|
|
161
|
+
args: [G, U, D],
|
|
162
162
|
position: i
|
|
163
163
|
}
|
|
164
164
|
);
|
|
@@ -198,7 +198,7 @@ function ZA({
|
|
|
198
198
|
{ type: "ambient", intensity: 0.5 },
|
|
199
199
|
{ type: "spot", position: [5, 10, 5], intensity: 50, castShadow: !0 }
|
|
200
200
|
],
|
|
201
|
-
environment:
|
|
201
|
+
environment: U,
|
|
202
202
|
renderer: S = {
|
|
203
203
|
physicallyCorrectLights: !0,
|
|
204
204
|
outputColorSpace: "srgb",
|
|
@@ -210,13 +210,13 @@ function ZA({
|
|
|
210
210
|
style: C,
|
|
211
211
|
className: A
|
|
212
212
|
}) {
|
|
213
|
-
const [F,
|
|
214
|
-
if (
|
|
215
|
-
c.current !== null && (window.clearTimeout(c.current), c.current = null),
|
|
213
|
+
const [F, s] = BA(!1), [J, h] = BA(0), c = N(null), f = K((M, a) => {
|
|
214
|
+
if (M) {
|
|
215
|
+
c.current !== null && (window.clearTimeout(c.current), c.current = null), s(!0), h(Math.max(0, Math.min(100, Math.round(a))));
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
h(100), c.current = window.setTimeout(() => {
|
|
219
|
+
s(!1), h(0), c.current = null;
|
|
220
220
|
}, 200);
|
|
221
221
|
}, []);
|
|
222
222
|
L(() => () => {
|
|
@@ -225,7 +225,7 @@ function ZA({
|
|
|
225
225
|
const I = {
|
|
226
226
|
position: Q.position || [0, 2, 5],
|
|
227
227
|
fov: Q.fov || 45
|
|
228
|
-
},
|
|
228
|
+
}, e = {
|
|
229
229
|
target: B.target || [0, 0, 0],
|
|
230
230
|
enabled: B.enabled ?? !0,
|
|
231
231
|
enablePan: B.enablePan ?? !0,
|
|
@@ -254,19 +254,19 @@ function ZA({
|
|
|
254
254
|
style: { width: "100%", height: "100%" },
|
|
255
255
|
children: [
|
|
256
256
|
/* @__PURE__ */ y($, { fallback: null, children: /* @__PURE__ */ y(tA, { background: D }) }),
|
|
257
|
-
|
|
258
|
-
/* @__PURE__ */ y(YA, { config:
|
|
259
|
-
/* @__PURE__ */ y(NA, { config:
|
|
257
|
+
U && /* @__PURE__ */ b($, { fallback: null, children: [
|
|
258
|
+
/* @__PURE__ */ y(YA, { config: U }),
|
|
259
|
+
/* @__PURE__ */ y(NA, { config: U })
|
|
260
260
|
] }),
|
|
261
261
|
/* @__PURE__ */ y(LA, { config: S }),
|
|
262
|
-
G.map((
|
|
262
|
+
G.map((M, a) => /* @__PURE__ */ y(fA, { config: M }, `${M.type}-${a}`)),
|
|
263
263
|
/* @__PURE__ */ y($, { fallback: null, children: g }),
|
|
264
264
|
/* @__PURE__ */ y(
|
|
265
265
|
kA,
|
|
266
266
|
{
|
|
267
267
|
position: I.position,
|
|
268
|
-
target:
|
|
269
|
-
controlsConfig:
|
|
268
|
+
target: e.target,
|
|
269
|
+
controlsConfig: e
|
|
270
270
|
}
|
|
271
271
|
),
|
|
272
272
|
E && /* @__PURE__ */ y(
|
|
@@ -277,7 +277,7 @@ function ZA({
|
|
|
277
277
|
blur: E.blur
|
|
278
278
|
}
|
|
279
279
|
),
|
|
280
|
-
/* @__PURE__ */ y(nA, { onChange:
|
|
280
|
+
/* @__PURE__ */ y(nA, { onChange: f })
|
|
281
281
|
]
|
|
282
282
|
}
|
|
283
283
|
),
|
|
@@ -336,7 +336,7 @@ function ZA({
|
|
|
336
336
|
)
|
|
337
337
|
] }) }),
|
|
338
338
|
/* @__PURE__ */ b("div", { style: { fontSize: 12, opacity: 0.82, marginTop: 4 }, children: [
|
|
339
|
-
|
|
339
|
+
J,
|
|
340
340
|
"%"
|
|
341
341
|
] })
|
|
342
342
|
]
|
|
@@ -368,11 +368,11 @@ function gA(g, Q) {
|
|
|
368
368
|
F && F.visible !== A && (F.visible = A);
|
|
369
369
|
}
|
|
370
370
|
});
|
|
371
|
-
const G =
|
|
371
|
+
const G = K((o, w) => {
|
|
372
372
|
i.current[o] = w;
|
|
373
373
|
const C = B.current.get(o);
|
|
374
374
|
C && (C.visible = w);
|
|
375
|
-
}, []),
|
|
375
|
+
}, []), U = K(() => Array.from(B.current.keys()).sort(), []), S = K(() => {
|
|
376
376
|
const o = {};
|
|
377
377
|
return B.current.forEach((w, C) => {
|
|
378
378
|
o[C] = w.visible;
|
|
@@ -380,7 +380,7 @@ function gA(g, Q) {
|
|
|
380
380
|
}, []);
|
|
381
381
|
return {
|
|
382
382
|
setMeshVisibility: G,
|
|
383
|
-
getMeshNames:
|
|
383
|
+
getMeshNames: U,
|
|
384
384
|
getMeshVisibility: S
|
|
385
385
|
};
|
|
386
386
|
}
|
|
@@ -392,15 +392,15 @@ function IA(g, Q) {
|
|
|
392
392
|
g.traverse((C) => {
|
|
393
393
|
if (C.isMesh) {
|
|
394
394
|
const A = C;
|
|
395
|
-
(Array.isArray(A.material) ? A.material : [A.material]).forEach((
|
|
396
|
-
|
|
395
|
+
(Array.isArray(A.material) ? A.material : [A.material]).forEach((s) => {
|
|
396
|
+
s.name && !w.has(s.name) && w.set(s.name, s);
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
}), B.current = w, Q && Object.entries(Q).forEach(([C, A]) => {
|
|
400
400
|
const F = w.get(C);
|
|
401
401
|
if (F && !Array.isArray(F)) {
|
|
402
|
-
const
|
|
403
|
-
F.color && F.color.copy(
|
|
402
|
+
const s = i(A);
|
|
403
|
+
F.color && F.color.copy(s), D.current.set(C, s);
|
|
404
404
|
}
|
|
405
405
|
});
|
|
406
406
|
}, [g, Q]), QA(() => {
|
|
@@ -412,15 +412,15 @@ function IA(g, Q) {
|
|
|
412
412
|
}
|
|
413
413
|
});
|
|
414
414
|
});
|
|
415
|
-
const i = (w) => typeof w == "string" ? new t.Color(w) : new t.Color(w[0], w[1], w[2]), G =
|
|
415
|
+
const i = (w) => typeof w == "string" ? new t.Color(w) : new t.Color(w[0], w[1], w[2]), G = K((w, C) => {
|
|
416
416
|
const A = i(C);
|
|
417
417
|
D.current.set(w, A);
|
|
418
418
|
const F = B.current.get(w);
|
|
419
419
|
if (F && !Array.isArray(F)) {
|
|
420
|
-
const
|
|
421
|
-
|
|
420
|
+
const s = F;
|
|
421
|
+
s.color && (s.color.copy(A), s.needsUpdate = !0);
|
|
422
422
|
}
|
|
423
|
-
}, []),
|
|
423
|
+
}, []), U = K(() => Array.from(B.current.keys()).sort(), []), S = K((w) => {
|
|
424
424
|
const C = B.current.get(w);
|
|
425
425
|
if (C && !Array.isArray(C)) {
|
|
426
426
|
const A = C;
|
|
@@ -428,7 +428,7 @@ function IA(g, Q) {
|
|
|
428
428
|
return "#" + A.color.getHexString();
|
|
429
429
|
}
|
|
430
430
|
return null;
|
|
431
|
-
}, []), o =
|
|
431
|
+
}, []), o = K(() => {
|
|
432
432
|
const w = {};
|
|
433
433
|
return B.current.forEach((C, A) => {
|
|
434
434
|
if (!Array.isArray(C)) {
|
|
@@ -439,7 +439,7 @@ function IA(g, Q) {
|
|
|
439
439
|
}, []);
|
|
440
440
|
return {
|
|
441
441
|
setMaterialColor: G,
|
|
442
|
-
getMaterialNames:
|
|
442
|
+
getMaterialNames: U,
|
|
443
443
|
getMaterialColor: S,
|
|
444
444
|
getAllMaterialColors: o
|
|
445
445
|
};
|
|
@@ -456,30 +456,30 @@ function v(g) {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
function EA(g, Q, B) {
|
|
459
|
-
const { gl: D } = _(), i = N(/* @__PURE__ */ new Map()), G = N(new t.TextureLoader()),
|
|
459
|
+
const { gl: D } = _(), i = N(/* @__PURE__ */ new Map()), G = N(new t.TextureLoader()), U = N(null), S = N(/* @__PURE__ */ new Map()), o = N(/* @__PURE__ */ new Set()), w = N(""), C = N((B == null ? void 0 : B.enableLogging) ?? !1);
|
|
460
460
|
L(() => {
|
|
461
461
|
C.current = (B == null ? void 0 : B.enableLogging) ?? !1;
|
|
462
462
|
}, [B == null ? void 0 : B.enableLogging]);
|
|
463
|
-
const A =
|
|
463
|
+
const A = K((...I) => {
|
|
464
464
|
C.current && console.log(...I);
|
|
465
|
-
}, []), F =
|
|
465
|
+
}, []), F = K((...I) => {
|
|
466
466
|
C.current && console.warn(...I);
|
|
467
467
|
}, []);
|
|
468
468
|
L(() => {
|
|
469
|
-
if (!
|
|
469
|
+
if (!U.current)
|
|
470
470
|
try {
|
|
471
471
|
const I = typeof WebAssembly == "object" && typeof WebAssembly.validate == "function";
|
|
472
472
|
A("[useMaterialTexture] Browser features:"), A(` WebAssembly supported: ${I}`), A(` WebGL2: ${D.capabilities.isWebGL2}`);
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
const E =
|
|
473
|
+
const e = new u();
|
|
474
|
+
e.detectSupport(D);
|
|
475
|
+
const E = e;
|
|
476
476
|
E.init = function() {
|
|
477
|
-
return E.transcoderPending || (E.transcoderPending = fetch(AA).then((
|
|
478
|
-
if (!
|
|
479
|
-
throw new Error(`basis_transcoder.wasm returned ${
|
|
480
|
-
return
|
|
481
|
-
}).then((
|
|
482
|
-
const
|
|
477
|
+
return E.transcoderPending || (E.transcoderPending = fetch(AA).then((a) => {
|
|
478
|
+
if (!a.ok)
|
|
479
|
+
throw new Error(`basis_transcoder.wasm returned ${a.status}`);
|
|
480
|
+
return a.arrayBuffer();
|
|
481
|
+
}).then((a) => {
|
|
482
|
+
const P = u.BasisWorker.toString(), n = [
|
|
483
483
|
"/* constants */",
|
|
484
484
|
"let _EngineFormat = " + JSON.stringify(u.EngineFormat),
|
|
485
485
|
"let _EngineType = " + JSON.stringify(u.EngineType),
|
|
@@ -488,127 +488,127 @@ function EA(g, Q, B) {
|
|
|
488
488
|
"/* basis_transcoder.js */",
|
|
489
489
|
dA,
|
|
490
490
|
"/* worker */",
|
|
491
|
-
|
|
491
|
+
P.substring(P.indexOf("{") + 1, P.lastIndexOf("}"))
|
|
492
492
|
].join(`
|
|
493
493
|
`);
|
|
494
|
-
E.workerSourceURL = URL.createObjectURL(new Blob([
|
|
495
|
-
const
|
|
496
|
-
return
|
|
494
|
+
E.workerSourceURL = URL.createObjectURL(new Blob([n])), E.transcoderBinary = a, E.workerPool.setWorkerCreator(() => {
|
|
495
|
+
const H = new Worker(E.workerSourceURL), r = E.transcoderBinary.slice(0);
|
|
496
|
+
return H.postMessage(
|
|
497
497
|
{ type: "init", config: E.workerConfig, transcoderBinary: r },
|
|
498
498
|
[r]
|
|
499
|
-
),
|
|
499
|
+
), H;
|
|
500
500
|
});
|
|
501
501
|
})), E.transcoderPending;
|
|
502
|
-
},
|
|
503
|
-
|
|
504
|
-
}).catch((
|
|
505
|
-
console.error("[useMaterialTexture] ❌ Failed to check basis_transcoder.wasm:",
|
|
502
|
+
}, U.current = e, A("[useMaterialTexture] ✅ KTX2Loader initialized"), A("[useMaterialTexture] Bundled transcoder wasm URL:", AA), fetch(AA).then((M) => {
|
|
503
|
+
M.ok ? A("[useMaterialTexture] ✅ basis_transcoder.wasm is accessible") : console.error("[useMaterialTexture] ❌ basis_transcoder.wasm returned", M.status);
|
|
504
|
+
}).catch((M) => {
|
|
505
|
+
console.error("[useMaterialTexture] ❌ Failed to check basis_transcoder.wasm:", M);
|
|
506
506
|
}), I || (F("[useMaterialTexture] ⚠️ WebAssembly not supported! KTX2 will fallback to CPU decoding (slow)"), F("[useMaterialTexture] ⚠️ Recommend using WebP instead of KTX2 for this browser"));
|
|
507
507
|
} catch (I) {
|
|
508
508
|
console.error("[useMaterialTexture] ❌ Failed to initialize KTX2Loader:", I);
|
|
509
509
|
}
|
|
510
510
|
return () => {
|
|
511
|
-
|
|
511
|
+
U.current && (U.current.dispose(), U.current = null);
|
|
512
512
|
};
|
|
513
513
|
}, [D, A, F]), L(() => {
|
|
514
514
|
if (!g) return;
|
|
515
515
|
const I = /* @__PURE__ */ new Map();
|
|
516
|
-
g.traverse((
|
|
517
|
-
if (
|
|
518
|
-
const E =
|
|
519
|
-
(Array.isArray(E.material) ? E.material : [E.material]).forEach((
|
|
520
|
-
|
|
516
|
+
g.traverse((e) => {
|
|
517
|
+
if (e.isMesh) {
|
|
518
|
+
const E = e;
|
|
519
|
+
(Array.isArray(E.material) ? E.material : [E.material]).forEach((a) => {
|
|
520
|
+
a.name && !I.has(a.name) && I.set(a.name, a);
|
|
521
521
|
});
|
|
522
522
|
}
|
|
523
523
|
}), i.current = I;
|
|
524
524
|
}, [g]);
|
|
525
|
-
const
|
|
525
|
+
const s = K((I) => v(I) ? U.current ? U.current : (F("[useMaterialTexture] KTX2Loader not initialized, falling back to TextureLoader"), G.current) : G.current, [F]);
|
|
526
526
|
L(() => {
|
|
527
527
|
if (!Q || !g) return;
|
|
528
528
|
const I = i.current;
|
|
529
529
|
if (I.size === 0) return;
|
|
530
|
-
const
|
|
531
|
-
if (w.current ===
|
|
530
|
+
const e = JSON.stringify(Q);
|
|
531
|
+
if (w.current === e) {
|
|
532
532
|
A("[useMaterialTexture] Textures unchanged, skipping reload");
|
|
533
533
|
return;
|
|
534
534
|
}
|
|
535
|
-
w.current =
|
|
535
|
+
w.current = e;
|
|
536
536
|
let E = !1;
|
|
537
|
-
const
|
|
538
|
-
Object.entries(Q).forEach(([
|
|
539
|
-
|
|
540
|
-
}), A("[useMaterialTexture] Starting texture load for",
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
var
|
|
537
|
+
const M = /* @__PURE__ */ new Map();
|
|
538
|
+
Object.entries(Q).forEach(([H, r]) => {
|
|
539
|
+
M.set(H, typeof r == "string" ? { map: r } : r);
|
|
540
|
+
}), A("[useMaterialTexture] Starting texture load for", M.size, "materials");
|
|
541
|
+
const a = [];
|
|
542
|
+
M.forEach((H, r) => {
|
|
543
|
+
var k, p;
|
|
544
544
|
const T = I.get(r);
|
|
545
545
|
if (!T || !T.isMeshStandardMaterial) {
|
|
546
546
|
F(`[useMaterialTexture] Material "${r}" not found or not MeshStandardMaterial`);
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
549
|
const R = T;
|
|
550
|
-
A(`[useMaterialTexture] 📋 Material "${r}" BEFORE reset:`), A(` - map: ${R.map ? "EXISTS" : "null"} ${R.map ? `(uuid: ${R.map.uuid})` : ""}`), A(` - normalMap: ${R.normalMap ? "EXISTS" : "null"}`), A(` - roughnessMap: ${R.roughnessMap ? "EXISTS" : "null"}`), A(` - metalnessMap: ${R.metalnessMap ? "EXISTS" : "null"}`), A(` - emissiveMap: ${R.emissiveMap ? "EXISTS" : "null"}`), A(` - aoMap: ${R.aoMap ? "EXISTS" : "null"}`), A(` - color: ${(
|
|
550
|
+
A(`[useMaterialTexture] 📋 Material "${r}" BEFORE reset:`), A(` - map: ${R.map ? "EXISTS" : "null"} ${R.map ? `(uuid: ${R.map.uuid})` : ""}`), A(` - normalMap: ${R.normalMap ? "EXISTS" : "null"}`), A(` - roughnessMap: ${R.roughnessMap ? "EXISTS" : "null"}`), A(` - metalnessMap: ${R.metalnessMap ? "EXISTS" : "null"}`), A(` - emissiveMap: ${R.emissiveMap ? "EXISTS" : "null"}`), A(` - aoMap: ${R.aoMap ? "EXISTS" : "null"}`), A(` - color: ${(k = R.color) == null ? void 0 : k.getHexString()}`), A(` - emissive: ${(p = R.emissive) == null ? void 0 : p.getHexString()}`), A(` - material uuid: ${R.uuid}`), Object.entries(H).forEach(([Y, l]) => {
|
|
551
551
|
if (!l) return;
|
|
552
|
-
const x = Y,
|
|
553
|
-
|
|
554
|
-
}),
|
|
552
|
+
const x = Y, d = R[x];
|
|
553
|
+
d && (A(`[useMaterialTexture] 🗑️ Disposing old ${x} (uuid: ${d.uuid})`), d.dispose(), R[x] = null);
|
|
554
|
+
}), H.emissiveMap && (R.emissive = new t.Color(0), R.emissiveIntensity = 0), R.needsUpdate = !0, R.color = new t.Color(16777215), A(`[useMaterialTexture] ✅ Material "${r}" AFTER reset: only specified maps cleared`), Object.entries(H).forEach(([Y, l]) => {
|
|
555
555
|
if (!l) return;
|
|
556
|
-
const x = `${r}_${Y}_${l}`,
|
|
557
|
-
if (
|
|
558
|
-
A(`[useMaterialTexture] Using cached texture: ${r}.${Y}`), E ||
|
|
556
|
+
const x = `${r}_${Y}_${l}`, d = S.current.get(x);
|
|
557
|
+
if (d) {
|
|
558
|
+
A(`[useMaterialTexture] Using cached texture: ${r}.${Y}`), E || J(R, Y, d);
|
|
559
559
|
return;
|
|
560
560
|
}
|
|
561
561
|
if (o.current.has(x)) {
|
|
562
562
|
A(`[useMaterialTexture] Skipping already loading: ${r}.${Y}`);
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
|
|
565
|
+
a.push({ materialName: r, textureType: Y, url: l, material: R });
|
|
566
566
|
});
|
|
567
|
-
}), A(`[useMaterialTexture] Queued ${
|
|
568
|
-
let
|
|
569
|
-
const
|
|
570
|
-
if (E ||
|
|
571
|
-
A("[useMaterialTexture] ✅ All textures loaded"), A("[useMaterialTexture] 📊 FINAL material states:"), I.forEach((
|
|
567
|
+
}), A(`[useMaterialTexture] Queued ${a.length} textures to load`);
|
|
568
|
+
let P = 0;
|
|
569
|
+
const n = () => {
|
|
570
|
+
if (E || P >= a.length) {
|
|
571
|
+
A("[useMaterialTexture] ✅ All textures loaded"), A("[useMaterialTexture] 📊 FINAL material states:"), I.forEach((k, p) => {
|
|
572
572
|
var l, x;
|
|
573
|
-
const Y =
|
|
573
|
+
const Y = k;
|
|
574
574
|
A(` Material "${p}":`), A(` - map: ${Y.map ? "EXISTS" : "null"} ${Y.map ? `(colorSpace: ${Y.map.colorSpace})` : ""}`), A(` - normalMap: ${Y.normalMap ? "EXISTS" : "null"}`), A(` - roughnessMap: ${Y.roughnessMap ? "EXISTS" : "null"}`), A(` - metalnessMap: ${Y.metalnessMap ? "EXISTS" : "null"}`), A(` - emissiveMap: ${Y.emissiveMap ? "EXISTS" : "null"}`), A(` - color: ${(l = Y.color) == null ? void 0 : l.getHexString()}`), A(` - emissive: ${(x = Y.emissive) == null ? void 0 : x.getHexString()}`), A(` - emissiveIntensity: ${Y.emissiveIntensity}`), A(` - roughness: ${Y.roughness}`), A(` - metalness: ${Y.metalness}`);
|
|
575
575
|
});
|
|
576
576
|
return;
|
|
577
577
|
}
|
|
578
|
-
const
|
|
579
|
-
A(`[useMaterialTexture] Loading (${
|
|
580
|
-
const T =
|
|
581
|
-
A(`[useMaterialTexture] Using ${R} for ${
|
|
582
|
-
|
|
583
|
-
(
|
|
584
|
-
var x,
|
|
578
|
+
const H = a[P++], r = `${H.materialName}_${H.textureType}_${H.url}`;
|
|
579
|
+
A(`[useMaterialTexture] Loading (${P}/${a.length}): ${H.materialName}.${H.textureType} from ${H.url}`), o.current.add(r);
|
|
580
|
+
const T = s(H.url), R = v(H.url) ? "KTX2Loader" : "TextureLoader";
|
|
581
|
+
A(`[useMaterialTexture] Using ${R} for ${H.url}`), T.load(
|
|
582
|
+
H.url,
|
|
583
|
+
(k) => {
|
|
584
|
+
var x, d, m, q, X, z;
|
|
585
585
|
if (o.current.delete(r), E) {
|
|
586
|
-
A(`[useMaterialTexture] Disposed, cleaning up texture: ${
|
|
586
|
+
A(`[useMaterialTexture] Disposed, cleaning up texture: ${H.materialName}.${H.textureType}`), k.dispose();
|
|
587
587
|
return;
|
|
588
588
|
}
|
|
589
|
-
const p = ((x =
|
|
590
|
-
A(`[useMaterialTexture] ✅ Loaded: ${
|
|
591
|
-
const l = v(
|
|
592
|
-
A(`[useMaterialTexture] Waiting111111 ${l}ms before next texture...`), setTimeout(
|
|
589
|
+
const p = ((x = k.image) == null ? void 0 : x.width) || ((m = (d = k.source) == null ? void 0 : d.data) == null ? void 0 : m.width) || "unknown", Y = ((q = k.image) == null ? void 0 : q.height) || ((z = (X = k.source) == null ? void 0 : X.data) == null ? void 0 : z.height) || "unknown";
|
|
590
|
+
A(`[useMaterialTexture] ✅ Loaded: ${H.materialName}.${H.textureType} (${p}x${Y})`), k.colorSpace = H.textureType === "map" || H.textureType === "emissiveMap" ? t.SRGBColorSpace : t.NoColorSpace, k.wrapS = t.RepeatWrapping, k.wrapT = t.RepeatWrapping, k.flipY = !1, S.current.set(r, k), J(H.material, H.textureType, k);
|
|
591
|
+
const l = v(H.url) ? 500 : 150;
|
|
592
|
+
A(`[useMaterialTexture] Waiting111111 ${l}ms before next texture...`), setTimeout(n, 0);
|
|
593
593
|
},
|
|
594
|
-
(
|
|
595
|
-
if (
|
|
596
|
-
const p = Math.round(
|
|
597
|
-
p % 25 === 0 && A(`[useMaterialTexture] Progress ${
|
|
594
|
+
(k) => {
|
|
595
|
+
if (k.lengthComputable) {
|
|
596
|
+
const p = Math.round(k.loaded / k.total * 100);
|
|
597
|
+
p % 25 === 0 && A(`[useMaterialTexture] Progress ${H.materialName}.${H.textureType}: ${p}%`);
|
|
598
598
|
}
|
|
599
599
|
},
|
|
600
|
-
(
|
|
601
|
-
o.current.delete(r), E || (console.error(`[useMaterialTexture] ❌ Failed to load ${
|
|
600
|
+
(k) => {
|
|
601
|
+
o.current.delete(r), E || (console.error(`[useMaterialTexture] ❌ Failed to load ${H.materialName}.${H.textureType} from ${H.url}`), console.error("[useMaterialTexture] Error details:", k), console.error("[useMaterialTexture] Loader type:", R), v(H.url) && (console.error("[useMaterialTexture] KTX2 error - file may not be in Basis Universal format!"), console.error("[useMaterialTexture] Make sure files are created with: gltf-transform etc1s input.png output.ktx2"))), setTimeout(n, 100);
|
|
602
602
|
}
|
|
603
603
|
);
|
|
604
604
|
};
|
|
605
|
-
return
|
|
605
|
+
return n(), () => {
|
|
606
606
|
A("[useMaterialTexture] Cleanup: disposed"), E = !0;
|
|
607
607
|
};
|
|
608
|
-
}, [g, Q,
|
|
609
|
-
const
|
|
610
|
-
var
|
|
611
|
-
switch (A(`[useMaterialTexture] 🎨 Applying texture: ${I.name}.${
|
|
608
|
+
}, [g, Q, s, A, F]);
|
|
609
|
+
const J = (I, e, E) => {
|
|
610
|
+
var M, a;
|
|
611
|
+
switch (A(`[useMaterialTexture] 🎨 Applying texture: ${I.name}.${e} (texture uuid: ${E.uuid})`), e) {
|
|
612
612
|
case "map":
|
|
613
613
|
I.map = E;
|
|
614
614
|
break;
|
|
@@ -631,42 +631,42 @@ function EA(g, Q, B) {
|
|
|
631
631
|
I.aoMap = E;
|
|
632
632
|
break;
|
|
633
633
|
}
|
|
634
|
-
I.needsUpdate = !0, A(`[useMaterialTexture] ✅ Applied ${
|
|
635
|
-
},
|
|
636
|
-
const E = typeof
|
|
637
|
-
if (!
|
|
634
|
+
I.needsUpdate = !0, A(`[useMaterialTexture] ✅ Applied ${e} to ${I.name}, needsUpdate=true`), A(`[useMaterialTexture] 📊 Material "${I.name}" FINAL state:`), A(` - map: ${I.map ? "EXISTS" : "null"} ${I.map ? `(uuid: ${I.map.uuid}, colorSpace: ${I.map.colorSpace})` : ""}`), A(` - normalMap: ${I.normalMap ? "EXISTS" : "null"}`), A(` - roughnessMap: ${I.roughnessMap ? "EXISTS" : "null"}`), A(` - metalnessMap: ${I.metalnessMap ? "EXISTS" : "null"}`), A(` - emissiveMap: ${I.emissiveMap ? "EXISTS" : "null"}`), A(` - aoMap: ${I.aoMap ? "EXISTS" : "null"}`), A(` - alphaMap: ${I.alphaMap ? "EXISTS" : "null"}`), A(` - transparent: ${I.transparent}`), A(` - alphaTest: ${I.alphaTest}`), A(` - depthWrite: ${I.depthWrite}`), A(` - color: ${(M = I.color) == null ? void 0 : M.getHexString()}`), A(` - emissive: ${(a = I.emissive) == null ? void 0 : a.getHexString()}`), A(` - emissiveIntensity: ${I.emissiveIntensity}`), A(` - roughness: ${I.roughness}`), A(` - metalness: ${I.metalness}`);
|
|
635
|
+
}, h = K((I, e) => {
|
|
636
|
+
const E = typeof e == "string" ? { map: e } : e, M = i.current.get(I);
|
|
637
|
+
if (!M || !M.isMeshStandardMaterial) {
|
|
638
638
|
F(`Material "${I}" not found or not MeshStandardMaterial`);
|
|
639
639
|
return;
|
|
640
640
|
}
|
|
641
|
-
const
|
|
642
|
-
Object.entries(E).forEach(([
|
|
643
|
-
if (!
|
|
644
|
-
const
|
|
641
|
+
const a = M;
|
|
642
|
+
Object.entries(E).forEach(([P, n]) => {
|
|
643
|
+
if (!n) return;
|
|
644
|
+
const H = `${I}_${P}_${n}`, r = S.current.get(H);
|
|
645
645
|
if (r) {
|
|
646
|
-
|
|
646
|
+
J(a, P, r);
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
|
-
|
|
650
|
-
|
|
649
|
+
s(n).load(
|
|
650
|
+
n,
|
|
651
651
|
(R) => {
|
|
652
|
-
R.colorSpace =
|
|
652
|
+
R.colorSpace = P === "map" || P === "emissiveMap" ? t.SRGBColorSpace : t.NoColorSpace, R.wrapS = t.RepeatWrapping, R.wrapT = t.RepeatWrapping, S.current.set(H, R), J(a, P, R);
|
|
653
653
|
},
|
|
654
654
|
void 0,
|
|
655
655
|
(R) => {
|
|
656
|
-
console.error(`Failed to load texture ${
|
|
656
|
+
console.error(`Failed to load texture ${n}:`, R);
|
|
657
657
|
}
|
|
658
658
|
);
|
|
659
659
|
});
|
|
660
|
-
}, [
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
663
|
-
const E =
|
|
660
|
+
}, [s, F]), c = K(() => Array.from(i.current.keys()).sort(), []), f = K((I) => {
|
|
661
|
+
const e = i.current.get(I);
|
|
662
|
+
if (!e || !e.isMeshStandardMaterial) return;
|
|
663
|
+
const E = e;
|
|
664
664
|
E.map = null, E.normalMap = null, E.roughnessMap = null, E.metalnessMap = null, E.emissiveMap = null, E.alphaMap = null, E.aoMap = null, E.transparent = !1, E.alphaTest = 0, E.depthWrite = !0, E.needsUpdate = !0;
|
|
665
665
|
}, []);
|
|
666
666
|
return {
|
|
667
|
-
setMaterialTextures:
|
|
667
|
+
setMaterialTextures: h,
|
|
668
668
|
getMaterialNames: c,
|
|
669
|
-
clearMaterialTextures:
|
|
669
|
+
clearMaterialTextures: f
|
|
670
670
|
};
|
|
671
671
|
}
|
|
672
672
|
function KA({
|
|
@@ -676,95 +676,99 @@ function KA({
|
|
|
676
676
|
scale: D = 1,
|
|
677
677
|
meshVisibility: i,
|
|
678
678
|
materialColors: G,
|
|
679
|
-
materialTextures:
|
|
679
|
+
materialTextures: U,
|
|
680
680
|
materialTextureLogging: S = !1,
|
|
681
681
|
onLoad: o,
|
|
682
682
|
onError: w
|
|
683
683
|
}) {
|
|
684
684
|
const { scene: C } = Z(g), A = N(o);
|
|
685
685
|
A.current = o;
|
|
686
|
-
const F =
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
686
|
+
const F = N(S);
|
|
687
|
+
F.current = S;
|
|
688
|
+
const s = (...c) => {
|
|
689
|
+
F.current && console.log(...c);
|
|
690
|
+
}, J = V(() => {
|
|
691
|
+
const c = C.clone(), f = [], I = /* @__PURE__ */ new Set(), e = [];
|
|
692
|
+
let E = 0;
|
|
693
|
+
return c.traverse((M) => {
|
|
694
|
+
if (E++, M.type === "Bone" && e.push(M.name), M.isMesh) {
|
|
695
|
+
const a = M;
|
|
696
|
+
f.push(a.name), a.castShadow = !0, a.receiveShadow = !0, (Array.isArray(a.material) ? a.material : [a.material]).forEach((n) => {
|
|
697
|
+
I.add(n.name), s(`[Model] 📦 Material found: "${n.name}" (uuid: ${n.uuid})`);
|
|
698
|
+
const H = n;
|
|
699
|
+
s(` - Has map: ${H.map ? "YES" : "NO"}`), s(` - Has normalMap: ${H.normalMap ? "YES" : "NO"}`), s(` - Has roughnessMap: ${H.roughnessMap ? "YES" : "NO"}`), s(` - Has metalnessMap: ${H.metalnessMap ? "YES" : "NO"}`);
|
|
696
700
|
});
|
|
697
701
|
}
|
|
698
|
-
}),
|
|
699
|
-
var
|
|
700
|
-
(
|
|
701
|
-
meshes:
|
|
702
|
-
materials: Array.from(
|
|
703
|
-
bones:
|
|
704
|
-
nodeCount:
|
|
702
|
+
}), s(`[Model] 📊 Clone summary: ${f.length} meshes, ${I.size} materials`), setTimeout(() => {
|
|
703
|
+
var M;
|
|
704
|
+
(M = A.current) == null || M.call(A, {
|
|
705
|
+
meshes: f.sort(),
|
|
706
|
+
materials: Array.from(I).sort(),
|
|
707
|
+
bones: e.sort(),
|
|
708
|
+
nodeCount: E
|
|
705
709
|
});
|
|
706
|
-
}, 0),
|
|
710
|
+
}, 0), c;
|
|
707
711
|
}, [C]);
|
|
708
|
-
return gA(
|
|
712
|
+
return gA(J, i), IA(J, G), EA(J, U, {
|
|
709
713
|
enableLogging: S
|
|
710
|
-
}), /* @__PURE__ */ y("group", { position: Q, rotation: B, scale: typeof D == "number" ? [D, D, D] : D, children: /* @__PURE__ */ y("primitive", { object:
|
|
714
|
+
}), /* @__PURE__ */ y("group", { position: Q, rotation: B, scale: typeof D == "number" ? [D, D, D] : D, children: /* @__PURE__ */ y("primitive", { object: J }) });
|
|
711
715
|
}
|
|
712
716
|
KA.preload = (g) => {
|
|
713
717
|
Z.preload(g);
|
|
714
718
|
};
|
|
715
719
|
function xA(g, Q, B) {
|
|
716
|
-
const { actions: D, names: i } = cA(g, Q), G = N(null),
|
|
720
|
+
const { actions: D, names: i } = cA(g, Q), G = N(null), U = N(B == null ? void 0 : B.defaultAnimation);
|
|
717
721
|
L(() => {
|
|
718
|
-
|
|
722
|
+
U.current = B == null ? void 0 : B.defaultAnimation;
|
|
719
723
|
}, [B == null ? void 0 : B.defaultAnimation]), L(() => {
|
|
720
724
|
if (i.length === 0) return;
|
|
721
|
-
const C =
|
|
725
|
+
const C = U.current;
|
|
722
726
|
let A = i[0];
|
|
723
727
|
if (C) {
|
|
724
|
-
const
|
|
725
|
-
|
|
728
|
+
const s = i.find((J) => J === C || J.includes(C));
|
|
729
|
+
s && (A = s);
|
|
726
730
|
}
|
|
727
731
|
const F = D[A];
|
|
728
732
|
F && (F.reset().fadeIn(0.5).play(), G.current = F);
|
|
729
733
|
}, [D, i]);
|
|
730
|
-
const S =
|
|
734
|
+
const S = K(
|
|
731
735
|
(C, A) => {
|
|
732
736
|
const {
|
|
733
737
|
loop: F = !1,
|
|
734
|
-
crossFadeDuration:
|
|
735
|
-
restoreDefault:
|
|
738
|
+
crossFadeDuration: s = 0.2,
|
|
739
|
+
restoreDefault: J = !0
|
|
736
740
|
} = A || {};
|
|
737
|
-
let
|
|
738
|
-
if (!
|
|
739
|
-
const
|
|
741
|
+
let h = D[C];
|
|
742
|
+
if (!h) {
|
|
743
|
+
const f = Object.keys(D).find(
|
|
740
744
|
(I) => I.toLowerCase().includes(C.toLowerCase()) || C.toLowerCase().includes(I.toLowerCase())
|
|
741
745
|
);
|
|
742
|
-
|
|
746
|
+
f && (h = D[f]);
|
|
743
747
|
}
|
|
744
|
-
if (!
|
|
748
|
+
if (!h) {
|
|
745
749
|
console.warn(`Animation "${C}" not found. Available: ${i.join(", ")}`);
|
|
746
750
|
return;
|
|
747
751
|
}
|
|
748
752
|
const c = G.current;
|
|
749
|
-
if (!(c ===
|
|
753
|
+
if (!(c === h && h.isRunning()) && (c && c !== h && c.fadeOut(s), h.reset(), h.fadeIn(s), h.setLoop(
|
|
750
754
|
F ? t.LoopRepeat : t.LoopOnce,
|
|
751
755
|
F ? 1 / 0 : 1
|
|
752
|
-
),
|
|
753
|
-
const
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
const E = D[
|
|
757
|
-
E && (
|
|
756
|
+
), h.clampWhenFinished = !F, h.play(), F || h.getMixer().update(0), G.current = h, J && !F && U.current)) {
|
|
757
|
+
const f = h.getMixer(), I = (e) => {
|
|
758
|
+
if (e.action === h) {
|
|
759
|
+
f.removeEventListener("finished", I);
|
|
760
|
+
const E = D[U.current];
|
|
761
|
+
E && (h.fadeOut(s), E.reset().fadeIn(s).play(), G.current = E);
|
|
758
762
|
}
|
|
759
763
|
};
|
|
760
|
-
|
|
764
|
+
f.addEventListener("finished", I);
|
|
761
765
|
}
|
|
762
766
|
},
|
|
763
767
|
[D, i]
|
|
764
|
-
), o =
|
|
768
|
+
), o = K(() => {
|
|
765
769
|
var C;
|
|
766
770
|
(C = G.current) == null || C.fadeOut(0.2), G.current = null;
|
|
767
|
-
}, []), w =
|
|
771
|
+
}, []), w = K(() => i, [i]);
|
|
768
772
|
return {
|
|
769
773
|
playAnimation: S,
|
|
770
774
|
stopAnimation: o,
|
|
@@ -792,12 +796,12 @@ function oA(g, Q) {
|
|
|
792
796
|
}), L(() => {
|
|
793
797
|
Q && (B.current = { ...Q });
|
|
794
798
|
}, [Q]);
|
|
795
|
-
const G =
|
|
799
|
+
const G = K((o, w) => {
|
|
796
800
|
B.current[o] = Math.max(0, Math.min(1, w));
|
|
797
|
-
}, []),
|
|
801
|
+
}, []), U = K(() => D.current, []), S = K(() => ({ ...B.current }), []);
|
|
798
802
|
return {
|
|
799
803
|
setMorphTarget: G,
|
|
800
|
-
getMorphTargetNames:
|
|
804
|
+
getMorphTargetNames: U,
|
|
801
805
|
getMorphTargetValues: S
|
|
802
806
|
};
|
|
803
807
|
}
|
|
@@ -816,32 +820,32 @@ const HA = wA(
|
|
|
816
820
|
scale: D = 1,
|
|
817
821
|
defaultAnimation: i,
|
|
818
822
|
animation: G,
|
|
819
|
-
morphTargets:
|
|
823
|
+
morphTargets: U,
|
|
820
824
|
meshVisibility: S,
|
|
821
825
|
materialColors: o,
|
|
822
826
|
materialTextures: w,
|
|
823
827
|
materialTextureLogging: C = !1,
|
|
824
828
|
onLoad: A,
|
|
825
829
|
onError: F,
|
|
826
|
-
children:
|
|
827
|
-
},
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
const { scene: I, animations:
|
|
831
|
-
|
|
830
|
+
children: s
|
|
831
|
+
}, J) => {
|
|
832
|
+
const h = N(null), c = N([]), f = N(A);
|
|
833
|
+
f.current = A;
|
|
834
|
+
const { scene: I, animations: e } = Z(g), E = V(() => FA.clone(I), [I]), { playAnimation: M, stopAnimation: a, getAnimationNames: P } = xA(
|
|
835
|
+
e,
|
|
832
836
|
E,
|
|
833
837
|
{ defaultAnimation: i }
|
|
834
838
|
);
|
|
835
839
|
L(() => {
|
|
836
|
-
G &&
|
|
837
|
-
}, [G,
|
|
838
|
-
const { setMorphTarget:
|
|
840
|
+
G && M(G, { loop: !0, restoreDefault: !1 });
|
|
841
|
+
}, [G, M]);
|
|
842
|
+
const { setMorphTarget: n } = oA(
|
|
839
843
|
E,
|
|
840
|
-
|
|
841
|
-
), { setMeshVisibility:
|
|
844
|
+
U
|
|
845
|
+
), { setMeshVisibility: H, getMeshNames: r } = gA(
|
|
842
846
|
E,
|
|
843
847
|
S
|
|
844
|
-
), { setMaterialColor: T, getMaterialNames: R, getMaterialColor:
|
|
848
|
+
), { setMaterialColor: T, getMaterialNames: R, getMaterialColor: k } = IA(
|
|
845
849
|
E,
|
|
846
850
|
o
|
|
847
851
|
), { setMaterialTextures: p, clearMaterialTextures: Y } = EA(
|
|
@@ -851,7 +855,7 @@ const HA = wA(
|
|
|
851
855
|
);
|
|
852
856
|
L(() => {
|
|
853
857
|
if (!E) return;
|
|
854
|
-
const
|
|
858
|
+
const d = setTimeout(() => {
|
|
855
859
|
var DA;
|
|
856
860
|
const m = [], q = [], X = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ new Set();
|
|
857
861
|
let CA = 0;
|
|
@@ -864,48 +868,48 @@ const HA = wA(
|
|
|
864
868
|
z.add(j);
|
|
865
869
|
});
|
|
866
870
|
}
|
|
867
|
-
}), c.current = Array.from(z).sort(), (DA =
|
|
871
|
+
}), c.current = Array.from(z).sort(), (DA = f.current) == null || DA.call(f, {
|
|
868
872
|
meshes: q.sort(),
|
|
869
873
|
materials: Array.from(X).sort(),
|
|
870
874
|
bones: m.sort(),
|
|
871
875
|
nodeCount: CA,
|
|
872
|
-
animations:
|
|
876
|
+
animations: e.map((W) => W.name),
|
|
873
877
|
morphTargetNames: c.current
|
|
874
878
|
});
|
|
875
879
|
}, 0);
|
|
876
|
-
return () => clearTimeout(
|
|
877
|
-
}, [E,
|
|
878
|
-
playAnimation:
|
|
879
|
-
stopAnimation:
|
|
880
|
-
getAnimationNames:
|
|
881
|
-
getGroup: () =>
|
|
882
|
-
setMorphTarget:
|
|
880
|
+
return () => clearTimeout(d);
|
|
881
|
+
}, [E, e]), iA(J, () => ({
|
|
882
|
+
playAnimation: M,
|
|
883
|
+
stopAnimation: a,
|
|
884
|
+
getAnimationNames: P,
|
|
885
|
+
getGroup: () => h.current,
|
|
886
|
+
setMorphTarget: n,
|
|
883
887
|
getMorphTargetNames: () => c.current,
|
|
884
|
-
setMeshVisibility:
|
|
888
|
+
setMeshVisibility: H,
|
|
885
889
|
getMeshNames: r,
|
|
886
890
|
setMaterialColor: T,
|
|
887
891
|
getMaterialNames: R,
|
|
888
|
-
getMaterialColor:
|
|
892
|
+
getMaterialColor: k,
|
|
889
893
|
setMaterialTextures: p,
|
|
890
894
|
clearMaterialTextures: Y
|
|
891
895
|
}));
|
|
892
896
|
const l = V(
|
|
893
897
|
() => ({
|
|
894
898
|
scene: E,
|
|
895
|
-
getBone: (
|
|
899
|
+
getBone: (d) => E.getObjectByName(d) || null
|
|
896
900
|
}),
|
|
897
901
|
[E]
|
|
898
902
|
), x = typeof D == "number" ? [D, D, D] : D;
|
|
899
903
|
return /* @__PURE__ */ y(GA.Provider, { value: l, children: /* @__PURE__ */ b(
|
|
900
904
|
"group",
|
|
901
905
|
{
|
|
902
|
-
ref:
|
|
906
|
+
ref: h,
|
|
903
907
|
position: Q,
|
|
904
908
|
rotation: B,
|
|
905
909
|
scale: x,
|
|
906
910
|
children: [
|
|
907
911
|
/* @__PURE__ */ y("primitive", { object: E }),
|
|
908
|
-
|
|
912
|
+
s
|
|
909
913
|
]
|
|
910
914
|
}
|
|
911
915
|
) });
|
|
@@ -923,61 +927,61 @@ const lA = wA(
|
|
|
923
927
|
scale: D = 1,
|
|
924
928
|
morphTargets: i,
|
|
925
929
|
meshVisibility: G,
|
|
926
|
-
materialColors:
|
|
930
|
+
materialColors: U,
|
|
927
931
|
materialTextures: S,
|
|
928
932
|
materialTextureLogging: o = !1,
|
|
929
933
|
onMorphTargetsFound: w,
|
|
930
934
|
onLoad: C,
|
|
931
935
|
onError: A
|
|
932
936
|
}, F) => {
|
|
933
|
-
const { scene:
|
|
934
|
-
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
const c = V(() =>
|
|
937
|
+
const { scene: s } = Z(g), J = N(C);
|
|
938
|
+
J.current = C;
|
|
939
|
+
const h = N(w);
|
|
940
|
+
h.current = w;
|
|
941
|
+
const c = V(() => s.clone(), [s]), { setMorphTarget: f, getMorphTargetNames: I, getMorphTargetValues: e } = oA(
|
|
938
942
|
c,
|
|
939
943
|
i
|
|
940
|
-
), { setMeshVisibility: E, getMeshNames:
|
|
944
|
+
), { setMeshVisibility: E, getMeshNames: M } = gA(
|
|
941
945
|
c,
|
|
942
946
|
G
|
|
943
|
-
), { setMaterialColor:
|
|
947
|
+
), { setMaterialColor: a, getMaterialNames: P, getMaterialColor: n } = IA(
|
|
944
948
|
c,
|
|
945
|
-
|
|
946
|
-
), { setMaterialTextures:
|
|
949
|
+
U
|
|
950
|
+
), { setMaterialTextures: H, clearMaterialTextures: r } = EA(
|
|
947
951
|
c,
|
|
948
952
|
S,
|
|
949
953
|
{ enableLogging: o }
|
|
950
954
|
);
|
|
951
955
|
return L(() => {
|
|
952
|
-
var
|
|
956
|
+
var k;
|
|
953
957
|
const R = I();
|
|
954
|
-
R.length > 0 && ((
|
|
958
|
+
R.length > 0 && ((k = h.current) == null || k.call(h, R));
|
|
955
959
|
}, [c, I]), L(() => {
|
|
956
960
|
var l;
|
|
957
961
|
if (!c) return;
|
|
958
|
-
const R = [],
|
|
962
|
+
const R = [], k = /* @__PURE__ */ new Set(), p = [];
|
|
959
963
|
let Y = 0;
|
|
960
964
|
c.traverse((x) => {
|
|
961
965
|
if (Y++, x.type === "Bone" && p.push(x.name), x.isMesh) {
|
|
962
|
-
const
|
|
963
|
-
R.push(
|
|
966
|
+
const d = x;
|
|
967
|
+
R.push(d.name), d.castShadow = !0, d.receiveShadow = !0, (Array.isArray(d.material) ? d.material : [d.material]).forEach((q) => k.add(q.name));
|
|
964
968
|
}
|
|
965
|
-
}), (l =
|
|
969
|
+
}), (l = J.current) == null || l.call(J, {
|
|
966
970
|
meshes: R.sort(),
|
|
967
|
-
materials: Array.from(
|
|
971
|
+
materials: Array.from(k).sort(),
|
|
968
972
|
bones: p.sort(),
|
|
969
973
|
nodeCount: Y
|
|
970
974
|
});
|
|
971
975
|
}, [c]), iA(F, () => ({
|
|
972
|
-
setMorphTarget:
|
|
976
|
+
setMorphTarget: f,
|
|
973
977
|
getMorphTargetNames: I,
|
|
974
|
-
getMorphTargetValues:
|
|
978
|
+
getMorphTargetValues: e,
|
|
975
979
|
setMeshVisibility: E,
|
|
976
|
-
getMeshNames:
|
|
977
|
-
setMaterialColor:
|
|
978
|
-
getMaterialNames:
|
|
979
|
-
getMaterialColor:
|
|
980
|
-
setMaterialTextures:
|
|
980
|
+
getMeshNames: M,
|
|
981
|
+
setMaterialColor: a,
|
|
982
|
+
getMaterialNames: P,
|
|
983
|
+
getMaterialColor: n,
|
|
984
|
+
setMaterialTextures: H,
|
|
981
985
|
clearMaterialTextures: r
|
|
982
986
|
})), /* @__PURE__ */ y("group", { position: Q, rotation: B, scale: typeof D == "number" ? [D, D, D] : D, children: /* @__PURE__ */ y("primitive", { object: c }) });
|
|
983
987
|
}
|
|
@@ -990,11 +994,11 @@ function mA({
|
|
|
990
994
|
rotation: D = [0, 0, 0],
|
|
991
995
|
scale: i = 1
|
|
992
996
|
}) {
|
|
993
|
-
const { getBone: G } = PA(), [
|
|
997
|
+
const { getBone: G } = PA(), [U, S] = BA(null);
|
|
994
998
|
return L(() => {
|
|
995
999
|
const w = G(Q);
|
|
996
1000
|
w ? S(w) : console.warn(`Bone "${Q}" not found in model`);
|
|
997
|
-
}, [Q, G]),
|
|
1001
|
+
}, [Q, G]), U ? hA(
|
|
998
1002
|
/* @__PURE__ */ y(
|
|
999
1003
|
"group",
|
|
1000
1004
|
{
|
|
@@ -1004,7 +1008,7 @@ function mA({
|
|
|
1004
1008
|
children: g
|
|
1005
1009
|
}
|
|
1006
1010
|
),
|
|
1007
|
-
|
|
1011
|
+
U
|
|
1008
1012
|
) : null;
|
|
1009
1013
|
}
|
|
1010
1014
|
function WA(g, Q) {
|
|
@@ -1012,17 +1016,17 @@ function WA(g, Q) {
|
|
|
1012
1016
|
return L(() => {
|
|
1013
1017
|
var w;
|
|
1014
1018
|
if (!i) return;
|
|
1015
|
-
const G = [],
|
|
1019
|
+
const G = [], U = [], S = /* @__PURE__ */ new Set();
|
|
1016
1020
|
let o = 0;
|
|
1017
1021
|
i.traverse((C) => {
|
|
1018
1022
|
if (o++, C.type === "Bone" && G.push(C.name), C.isMesh) {
|
|
1019
1023
|
const A = C;
|
|
1020
|
-
|
|
1021
|
-
S.add(
|
|
1024
|
+
U.push(A.name), A.castShadow = !0, A.receiveShadow = !0, (Array.isArray(A.material) ? A.material : [A.material]).forEach((s) => {
|
|
1025
|
+
S.add(s.name), s.shadowSide = t.DoubleSide;
|
|
1022
1026
|
});
|
|
1023
1027
|
}
|
|
1024
1028
|
}), (w = Q == null ? void 0 : Q.onLoad) == null || w.call(Q, {
|
|
1025
|
-
meshes:
|
|
1029
|
+
meshes: U.sort(),
|
|
1026
1030
|
materials: Array.from(S).sort(),
|
|
1027
1031
|
bones: G.sort(),
|
|
1028
1032
|
nodeCount: o
|