mbt-3d 0.3.8 → 0.4.0
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/README.md +48 -11
- package/dist/index.d.ts +51 -9
- package/dist/mbt-3d.cjs +1 -1
- package/dist/mbt-3d.cjs.map +1 -1
- package/dist/mbt-3d.js +710 -657
- package/dist/mbt-3d.js.map +1 -1
- package/package.json +1 -1
package/dist/mbt-3d.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { ContactShadows as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import { Canvas as
|
|
6
|
-
import { KTX2Loader as
|
|
7
|
-
import { jsxs as
|
|
8
|
-
function
|
|
9
|
-
position:
|
|
1
|
+
import { useState as Z, useRef as k, useCallback as R, useEffect as C, Suspense as Y, useMemo as P, createContext as pe, useContext as de, forwardRef as ae, useImperativeHandle as se } from "react";
|
|
2
|
+
import { ContactShadows as me, Environment as fe, OrbitControls as ge, useProgress as he, useTexture as Me, useGLTF as F, useAnimations as ye } from "@react-three/drei";
|
|
3
|
+
import * as A from "three";
|
|
4
|
+
import * as ie from "three/examples/jsm/utils/SkeletonUtils.js";
|
|
5
|
+
import { Canvas as Te, useThree as V, useFrame as q, createPortal as be } from "@react-three/fiber";
|
|
6
|
+
import { KTX2Loader as Se } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
7
|
+
import { jsxs as z, jsx as x } from "react/jsx-runtime";
|
|
8
|
+
function xe({
|
|
9
|
+
position: r,
|
|
10
|
+
target: t,
|
|
10
11
|
controlsConfig: e
|
|
11
12
|
}) {
|
|
12
|
-
const { camera:
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
}, [t,
|
|
16
|
-
|
|
13
|
+
const { camera: s } = V(), c = k(null);
|
|
14
|
+
return C(() => {
|
|
15
|
+
s && (s.position.set(r[0], r[1], r[2]), s.updateProjectionMatrix(), c.current && (c.current.target.set(t[0], t[1], t[2]), c.current.update()));
|
|
16
|
+
}, [r, t, s]), /* @__PURE__ */ x(
|
|
17
|
+
ge,
|
|
17
18
|
{
|
|
18
|
-
ref:
|
|
19
|
+
ref: c,
|
|
19
20
|
makeDefault: !0,
|
|
20
21
|
enabled: e.enabled,
|
|
21
22
|
enablePan: e.enablePan,
|
|
@@ -30,117 +31,148 @@ function Se({
|
|
|
30
31
|
}
|
|
31
32
|
);
|
|
32
33
|
}
|
|
33
|
-
function $e({ background:
|
|
34
|
-
const
|
|
35
|
-
return
|
|
34
|
+
function $e({ background: r }) {
|
|
35
|
+
const t = r == null ? void 0 : r.startsWith("#");
|
|
36
|
+
return r ? t ? /* @__PURE__ */ x("color", { attach: "background", args: [r] }) : /* @__PURE__ */ x(we, { url: r }) : null;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
}, [
|
|
38
|
+
function we({ url: r }) {
|
|
39
|
+
const t = Me(r);
|
|
40
|
+
return P(() => {
|
|
41
|
+
t.colorSpace = A.SRGBColorSpace;
|
|
42
|
+
}, [t]), /* @__PURE__ */ x("primitive", { attach: "background", object: t });
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
|
|
44
|
+
function Ae({ config: r }) {
|
|
45
|
+
return /* @__PURE__ */ x(
|
|
46
|
+
fe,
|
|
46
47
|
{
|
|
47
|
-
files:
|
|
48
|
-
background:
|
|
49
|
-
blur:
|
|
50
|
-
children: /* @__PURE__ */ b("group", { scale: t.intensity ?? 1, children: /* @__PURE__ */ b("ambientLight", { intensity: 0 }) })
|
|
48
|
+
files: r.files,
|
|
49
|
+
background: r.background ?? !1,
|
|
50
|
+
blur: r.blur ?? 0
|
|
51
51
|
}
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
54
|
+
function ve({ config: r }) {
|
|
55
|
+
const { scene: t } = V();
|
|
56
|
+
return C(() => {
|
|
57
|
+
const e = r.intensity ?? 1, s = r.blur ?? 0, c = "environmentIntensity" in t, u = "backgroundBlurriness" in t, g = "backgroundIntensity" in t, b = c ? t.environmentIntensity : void 0, m = u ? t.backgroundBlurriness : void 0, a = g ? t.backgroundIntensity : void 0;
|
|
58
|
+
return c && (t.environmentIntensity = e), u && (t.backgroundBlurriness = s), r.background && g && (t.backgroundIntensity = e), () => {
|
|
59
|
+
c && (t.environmentIntensity = b ?? 1), u && (t.backgroundBlurriness = m ?? 0), g && (t.backgroundIntensity = a ?? 1);
|
|
60
|
+
};
|
|
61
|
+
}, [t, r]), null;
|
|
62
|
+
}
|
|
63
|
+
const Ee = {
|
|
64
|
+
NoToneMapping: A.NoToneMapping,
|
|
65
|
+
LinearToneMapping: A.LinearToneMapping,
|
|
66
|
+
ReinhardToneMapping: A.ReinhardToneMapping,
|
|
67
|
+
CineonToneMapping: A.CineonToneMapping,
|
|
68
|
+
ACESFilmicToneMapping: A.ACESFilmicToneMapping
|
|
69
|
+
};
|
|
70
|
+
function ke({ config: r }) {
|
|
71
|
+
const { gl: t } = V();
|
|
72
|
+
return C(() => {
|
|
73
|
+
const e = r.outputColorSpace === "linear" ? A.LinearSRGBColorSpace : A.SRGBColorSpace, s = Ee[r.toneMapping ?? "ACESFilmicToneMapping"];
|
|
74
|
+
t.physicallyCorrectLights = r.physicallyCorrectLights ?? !0, t.outputColorSpace = e, t.toneMapping = s, t.toneMappingExposure = r.toneMappingExposure ?? 1;
|
|
75
|
+
}, [t, r]), null;
|
|
76
|
+
}
|
|
77
|
+
function Ce({ config: r }) {
|
|
78
|
+
switch (r.type) {
|
|
56
79
|
case "spot": {
|
|
57
80
|
const {
|
|
58
|
-
position:
|
|
59
|
-
intensity:
|
|
60
|
-
castShadow:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
position: t = [5, 10, 5],
|
|
82
|
+
intensity: e = 50,
|
|
83
|
+
castShadow: s = !0,
|
|
84
|
+
shadowMapSize: c = 2048,
|
|
85
|
+
angle: u = Math.PI / 6,
|
|
86
|
+
penumbra: g = 0.5,
|
|
87
|
+
decay: b = 2,
|
|
88
|
+
distance: m = 0,
|
|
89
|
+
color: a = "#ffffff"
|
|
90
|
+
} = r;
|
|
91
|
+
return /* @__PURE__ */ x(
|
|
68
92
|
"spotLight",
|
|
69
93
|
{
|
|
70
|
-
position:
|
|
71
|
-
intensity:
|
|
72
|
-
castShadow:
|
|
73
|
-
angle:
|
|
74
|
-
penumbra:
|
|
75
|
-
decay:
|
|
76
|
-
distance:
|
|
77
|
-
color:
|
|
94
|
+
position: t,
|
|
95
|
+
intensity: e,
|
|
96
|
+
castShadow: s,
|
|
97
|
+
angle: u,
|
|
98
|
+
penumbra: g,
|
|
99
|
+
decay: b,
|
|
100
|
+
distance: m,
|
|
101
|
+
color: a,
|
|
102
|
+
"shadow-mapSize-width": c,
|
|
103
|
+
"shadow-mapSize-height": c
|
|
78
104
|
}
|
|
79
105
|
);
|
|
80
106
|
}
|
|
81
107
|
case "point": {
|
|
82
108
|
const {
|
|
83
|
-
position:
|
|
84
|
-
intensity:
|
|
85
|
-
color:
|
|
86
|
-
distance:
|
|
87
|
-
decay:
|
|
88
|
-
castShadow:
|
|
89
|
-
|
|
90
|
-
|
|
109
|
+
position: t = [0, 5, 0],
|
|
110
|
+
intensity: e = 20,
|
|
111
|
+
color: s = "#ffffff",
|
|
112
|
+
distance: c = 0,
|
|
113
|
+
decay: u = 2,
|
|
114
|
+
castShadow: g = !1,
|
|
115
|
+
shadowMapSize: b = 2048
|
|
116
|
+
} = r;
|
|
117
|
+
return /* @__PURE__ */ x(
|
|
91
118
|
"pointLight",
|
|
92
119
|
{
|
|
93
|
-
position:
|
|
94
|
-
intensity:
|
|
95
|
-
color:
|
|
96
|
-
distance:
|
|
97
|
-
decay:
|
|
98
|
-
castShadow:
|
|
120
|
+
position: t,
|
|
121
|
+
intensity: e,
|
|
122
|
+
color: s,
|
|
123
|
+
distance: c,
|
|
124
|
+
decay: u,
|
|
125
|
+
castShadow: g,
|
|
126
|
+
"shadow-mapSize-width": b,
|
|
127
|
+
"shadow-mapSize-height": b
|
|
99
128
|
}
|
|
100
129
|
);
|
|
101
130
|
}
|
|
102
131
|
case "directional": {
|
|
103
132
|
const {
|
|
104
|
-
position:
|
|
105
|
-
intensity:
|
|
106
|
-
color:
|
|
107
|
-
castShadow:
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
position: t = [10, 20, 10],
|
|
134
|
+
intensity: e = 40,
|
|
135
|
+
color: s = "#ffffff",
|
|
136
|
+
castShadow: c = !0,
|
|
137
|
+
shadowMapSize: u = 2048
|
|
138
|
+
} = r;
|
|
139
|
+
return /* @__PURE__ */ x(
|
|
110
140
|
"directionalLight",
|
|
111
141
|
{
|
|
112
|
-
position:
|
|
113
|
-
intensity:
|
|
114
|
-
color:
|
|
115
|
-
castShadow:
|
|
142
|
+
position: t,
|
|
143
|
+
intensity: e,
|
|
144
|
+
color: s,
|
|
145
|
+
castShadow: c,
|
|
146
|
+
"shadow-mapSize-width": u,
|
|
147
|
+
"shadow-mapSize-height": u
|
|
116
148
|
}
|
|
117
149
|
);
|
|
118
150
|
}
|
|
119
151
|
case "hemisphere": {
|
|
120
152
|
const {
|
|
121
|
-
skyColor:
|
|
122
|
-
groundColor:
|
|
123
|
-
intensity:
|
|
124
|
-
position:
|
|
125
|
-
} =
|
|
126
|
-
return /* @__PURE__ */
|
|
153
|
+
skyColor: t = "#ffffff",
|
|
154
|
+
groundColor: e = "#444444",
|
|
155
|
+
intensity: s = 0.5,
|
|
156
|
+
position: c = [0, 10, 0]
|
|
157
|
+
} = r, u = P(() => new A.Color(t), [t]), g = P(() => new A.Color(e), [e]);
|
|
158
|
+
return /* @__PURE__ */ x(
|
|
127
159
|
"hemisphereLight",
|
|
128
160
|
{
|
|
129
|
-
args: [
|
|
130
|
-
position:
|
|
161
|
+
args: [u, g, s],
|
|
162
|
+
position: c
|
|
131
163
|
}
|
|
132
164
|
);
|
|
133
165
|
}
|
|
134
166
|
case "ambient": {
|
|
135
167
|
const {
|
|
136
|
-
intensity:
|
|
137
|
-
color:
|
|
138
|
-
} =
|
|
139
|
-
return /* @__PURE__ */
|
|
168
|
+
intensity: t = 0.5,
|
|
169
|
+
color: e = "#ffffff"
|
|
170
|
+
} = r;
|
|
171
|
+
return /* @__PURE__ */ x(
|
|
140
172
|
"ambientLight",
|
|
141
173
|
{
|
|
142
|
-
intensity:
|
|
143
|
-
color:
|
|
174
|
+
intensity: t,
|
|
175
|
+
color: e
|
|
144
176
|
}
|
|
145
177
|
);
|
|
146
178
|
}
|
|
@@ -148,109 +180,123 @@ function Ae({ config: t }) {
|
|
|
148
180
|
return null;
|
|
149
181
|
}
|
|
150
182
|
}
|
|
151
|
-
function
|
|
152
|
-
onChange:
|
|
183
|
+
function Ie({
|
|
184
|
+
onChange: r
|
|
153
185
|
}) {
|
|
154
|
-
const { active:
|
|
155
|
-
return
|
|
156
|
-
t
|
|
157
|
-
}, [e, r
|
|
186
|
+
const { active: t, progress: e } = he();
|
|
187
|
+
return C(() => {
|
|
188
|
+
r(t, e);
|
|
189
|
+
}, [t, e, r]), null;
|
|
158
190
|
}
|
|
159
|
-
function
|
|
160
|
-
children:
|
|
161
|
-
camera:
|
|
162
|
-
controls:
|
|
163
|
-
background:
|
|
164
|
-
shadows:
|
|
165
|
-
lights:
|
|
191
|
+
function ze({
|
|
192
|
+
children: r,
|
|
193
|
+
camera: t = {},
|
|
194
|
+
controls: e = {},
|
|
195
|
+
background: s,
|
|
196
|
+
shadows: c = !0,
|
|
197
|
+
lights: u = [
|
|
166
198
|
{ type: "ambient", intensity: 0.5 },
|
|
167
199
|
{ type: "spot", position: [5, 10, 5], intensity: 50, castShadow: !0 }
|
|
168
200
|
],
|
|
169
|
-
environment:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
201
|
+
environment: g,
|
|
202
|
+
renderer: b = {
|
|
203
|
+
physicallyCorrectLights: !0,
|
|
204
|
+
outputColorSpace: "srgb",
|
|
205
|
+
toneMapping: "ACESFilmicToneMapping",
|
|
206
|
+
toneMappingExposure: 1
|
|
207
|
+
},
|
|
208
|
+
contactShadows: m = !0,
|
|
209
|
+
showLoadingOverlay: a = !0,
|
|
210
|
+
style: o,
|
|
211
|
+
className: p
|
|
174
212
|
}) {
|
|
175
|
-
const [
|
|
176
|
-
if (
|
|
177
|
-
|
|
213
|
+
const [f, M] = Z(!1), [n, i] = Z(0), l = k(null), w = R((d, S) => {
|
|
214
|
+
if (d) {
|
|
215
|
+
l.current !== null && (window.clearTimeout(l.current), l.current = null), M(!0), i(Math.max(0, Math.min(100, Math.round(S))));
|
|
178
216
|
return;
|
|
179
217
|
}
|
|
180
|
-
|
|
181
|
-
|
|
218
|
+
i(100), l.current = window.setTimeout(() => {
|
|
219
|
+
M(!1), i(0), l.current = null;
|
|
182
220
|
}, 200);
|
|
183
221
|
}, []);
|
|
184
|
-
|
|
185
|
-
|
|
222
|
+
C(() => () => {
|
|
223
|
+
l.current !== null && window.clearTimeout(l.current);
|
|
186
224
|
}, []);
|
|
187
|
-
const
|
|
188
|
-
position:
|
|
189
|
-
fov:
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
225
|
+
const h = {
|
|
226
|
+
position: t.position || [0, 2, 5],
|
|
227
|
+
fov: t.fov || 45
|
|
228
|
+
}, y = {
|
|
229
|
+
target: e.target || [0, 0, 0],
|
|
230
|
+
enabled: e.enabled ?? !0,
|
|
231
|
+
enablePan: e.enablePan ?? !0,
|
|
232
|
+
enableZoom: e.enableZoom ?? !0,
|
|
233
|
+
enableRotate: e.enableRotate ?? !0,
|
|
234
|
+
minDistance: e.minDistance,
|
|
235
|
+
maxDistance: e.maxDistance,
|
|
236
|
+
minPolarAngle: e.minPolarAngle,
|
|
237
|
+
maxPolarAngle: e.maxPolarAngle,
|
|
238
|
+
autoRotate: e.autoRotate ?? !1,
|
|
239
|
+
autoRotateSpeed: e.autoRotateSpeed ?? 2
|
|
240
|
+
}, E = typeof m == "object" ? {
|
|
241
|
+
position: m.position || [0, -1, 0],
|
|
242
|
+
opacity: m.opacity ?? 0.5,
|
|
243
|
+
blur: m.blur ?? 2
|
|
244
|
+
} : m ? { position: [0, -1, 0], opacity: 0.5, blur: 2 } : null;
|
|
245
|
+
return /* @__PURE__ */ z("div", { style: { ...o || {}, position: (o == null ? void 0 : o.position) ?? "relative" }, className: p, children: [
|
|
246
|
+
/* @__PURE__ */ z(
|
|
247
|
+
Te,
|
|
209
248
|
{
|
|
210
|
-
shadows:
|
|
249
|
+
shadows: c,
|
|
211
250
|
camera: {
|
|
212
|
-
position:
|
|
213
|
-
fov:
|
|
251
|
+
position: h.position,
|
|
252
|
+
fov: h.fov
|
|
214
253
|
},
|
|
215
254
|
style: { width: "100%", height: "100%" },
|
|
216
255
|
children: [
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
256
|
+
/* @__PURE__ */ x(Y, { fallback: null, children: /* @__PURE__ */ x($e, { background: s }) }),
|
|
257
|
+
g && /* @__PURE__ */ z(Y, { fallback: null, children: [
|
|
258
|
+
/* @__PURE__ */ x(Ae, { config: g }),
|
|
259
|
+
/* @__PURE__ */ x(ve, { config: g })
|
|
260
|
+
] }),
|
|
261
|
+
/* @__PURE__ */ x(ke, { config: b }),
|
|
262
|
+
u.map((d, S) => /* @__PURE__ */ x(Ce, { config: d }, `${d.type}-${S}`)),
|
|
263
|
+
/* @__PURE__ */ x(Y, { fallback: null, children: r }),
|
|
264
|
+
/* @__PURE__ */ x(
|
|
265
|
+
xe,
|
|
223
266
|
{
|
|
224
|
-
position:
|
|
225
|
-
|
|
267
|
+
position: h.position,
|
|
268
|
+
target: y.target,
|
|
269
|
+
controlsConfig: y
|
|
226
270
|
}
|
|
227
271
|
),
|
|
228
|
-
|
|
229
|
-
|
|
272
|
+
E && /* @__PURE__ */ x(
|
|
273
|
+
me,
|
|
230
274
|
{
|
|
231
|
-
position:
|
|
232
|
-
opacity:
|
|
233
|
-
blur:
|
|
275
|
+
position: E.position,
|
|
276
|
+
opacity: E.opacity,
|
|
277
|
+
blur: E.blur
|
|
234
278
|
}
|
|
235
279
|
),
|
|
236
|
-
/* @__PURE__ */
|
|
280
|
+
/* @__PURE__ */ x(Ie, { onChange: w })
|
|
237
281
|
]
|
|
238
282
|
}
|
|
239
283
|
),
|
|
240
|
-
|
|
284
|
+
a && f && /* @__PURE__ */ x(
|
|
241
285
|
"div",
|
|
242
286
|
{
|
|
243
287
|
style: {
|
|
244
288
|
position: "absolute",
|
|
245
289
|
inset: 0,
|
|
246
|
-
background: "rgba(8, 10, 16, 0.
|
|
290
|
+
background: "rgba(8, 10, 16, 0.56)",
|
|
291
|
+
backdropFilter: "blur(18px)",
|
|
292
|
+
WebkitBackdropFilter: "blur(18px)",
|
|
247
293
|
display: "flex",
|
|
248
294
|
alignItems: "center",
|
|
249
295
|
justifyContent: "center",
|
|
250
296
|
pointerEvents: "none",
|
|
251
297
|
zIndex: 10
|
|
252
298
|
},
|
|
253
|
-
children: /* @__PURE__ */
|
|
299
|
+
children: /* @__PURE__ */ z(
|
|
254
300
|
"div",
|
|
255
301
|
{
|
|
256
302
|
style: {
|
|
@@ -265,9 +311,9 @@ function Xe({
|
|
|
265
311
|
textAlign: "center"
|
|
266
312
|
},
|
|
267
313
|
children: [
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
-
/* @__PURE__ */
|
|
314
|
+
/* @__PURE__ */ x("div", { style: { display: "flex", justifyContent: "center", marginBottom: 10 }, children: /* @__PURE__ */ z("svg", { width: "34", height: "34", viewBox: "0 0 34 34", "aria-hidden": "true", children: [
|
|
315
|
+
/* @__PURE__ */ x("circle", { cx: "17", cy: "17", r: "14", fill: "none", stroke: "rgba(255,255,255,0.2)", strokeWidth: "4" }),
|
|
316
|
+
/* @__PURE__ */ x(
|
|
271
317
|
"path",
|
|
272
318
|
{
|
|
273
319
|
d: "M31 17a14 14 0 0 1-14 14",
|
|
@@ -275,7 +321,7 @@ function Xe({
|
|
|
275
321
|
stroke: "#67b4ff",
|
|
276
322
|
strokeWidth: "4",
|
|
277
323
|
strokeLinecap: "round",
|
|
278
|
-
children: /* @__PURE__ */
|
|
324
|
+
children: /* @__PURE__ */ x(
|
|
279
325
|
"animateTransform",
|
|
280
326
|
{
|
|
281
327
|
attributeName: "transform",
|
|
@@ -289,8 +335,8 @@ function Xe({
|
|
|
289
335
|
}
|
|
290
336
|
)
|
|
291
337
|
] }) }),
|
|
292
|
-
/* @__PURE__ */
|
|
293
|
-
|
|
338
|
+
/* @__PURE__ */ z("div", { style: { fontSize: 12, opacity: 0.82, marginTop: 4 }, children: [
|
|
339
|
+
n,
|
|
294
340
|
"%"
|
|
295
341
|
] })
|
|
296
342
|
]
|
|
@@ -300,655 +346,662 @@ function Xe({
|
|
|
300
346
|
)
|
|
301
347
|
] });
|
|
302
348
|
}
|
|
303
|
-
function
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}, [
|
|
308
|
-
if (!
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
const
|
|
313
|
-
|
|
349
|
+
function J(r, t) {
|
|
350
|
+
const e = k(/* @__PURE__ */ new Map()), s = k({}), c = k({});
|
|
351
|
+
C(() => {
|
|
352
|
+
t && (s.current = { ...t });
|
|
353
|
+
}, [t]), C(() => {
|
|
354
|
+
if (!r) return;
|
|
355
|
+
const m = /* @__PURE__ */ new Map();
|
|
356
|
+
r.traverse((a) => {
|
|
357
|
+
if (a.isMesh) {
|
|
358
|
+
const o = a;
|
|
359
|
+
o.name && m.set(o.name, o);
|
|
314
360
|
}
|
|
315
|
-
}),
|
|
316
|
-
}, [
|
|
317
|
-
const
|
|
318
|
-
if (
|
|
319
|
-
const
|
|
320
|
-
for (const [
|
|
321
|
-
const
|
|
322
|
-
|
|
361
|
+
}), e.current = m;
|
|
362
|
+
}, [r]), q(() => {
|
|
363
|
+
const m = e.current;
|
|
364
|
+
if (m.size === 0) return;
|
|
365
|
+
const a = { ...s.current, ...c.current };
|
|
366
|
+
for (const [o, p] of Object.entries(a)) {
|
|
367
|
+
const f = m.get(o);
|
|
368
|
+
f && f.visible !== p && (f.visible = p);
|
|
323
369
|
}
|
|
324
370
|
});
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
}, []),
|
|
330
|
-
const
|
|
331
|
-
return
|
|
332
|
-
|
|
333
|
-
}),
|
|
371
|
+
const u = R((m, a) => {
|
|
372
|
+
c.current[m] = a;
|
|
373
|
+
const o = e.current.get(m);
|
|
374
|
+
o && (o.visible = a);
|
|
375
|
+
}, []), g = R(() => Array.from(e.current.keys()).sort(), []), b = R(() => {
|
|
376
|
+
const m = {};
|
|
377
|
+
return e.current.forEach((a, o) => {
|
|
378
|
+
m[o] = a.visible;
|
|
379
|
+
}), m;
|
|
334
380
|
}, []);
|
|
335
381
|
return {
|
|
336
|
-
setMeshVisibility:
|
|
337
|
-
getMeshNames:
|
|
338
|
-
getMeshVisibility:
|
|
382
|
+
setMeshVisibility: u,
|
|
383
|
+
getMeshNames: g,
|
|
384
|
+
getMeshVisibility: b
|
|
339
385
|
};
|
|
340
386
|
}
|
|
341
|
-
function
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
if (!
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
(Array.isArray(
|
|
350
|
-
|
|
387
|
+
function Q(r, t) {
|
|
388
|
+
const e = k(/* @__PURE__ */ new Map()), s = k(/* @__PURE__ */ new Map());
|
|
389
|
+
C(() => {
|
|
390
|
+
if (!r) return;
|
|
391
|
+
const a = /* @__PURE__ */ new Map();
|
|
392
|
+
r.traverse((o) => {
|
|
393
|
+
if (o.isMesh) {
|
|
394
|
+
const p = o;
|
|
395
|
+
(Array.isArray(p.material) ? p.material : [p.material]).forEach((M) => {
|
|
396
|
+
M.name && !a.has(M.name) && a.set(M.name, M);
|
|
351
397
|
});
|
|
352
398
|
}
|
|
353
|
-
}),
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
|
|
399
|
+
}), e.current = a, t && Object.entries(t).forEach(([o, p]) => {
|
|
400
|
+
const f = a.get(o);
|
|
401
|
+
if (f && !Array.isArray(f)) {
|
|
402
|
+
const M = c(p);
|
|
403
|
+
f.color && f.color.copy(M), s.current.set(o, M);
|
|
358
404
|
}
|
|
359
405
|
});
|
|
360
|
-
}, [
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
|
|
406
|
+
}, [r, t]), q(() => {
|
|
407
|
+
s.current.forEach((a, o) => {
|
|
408
|
+
const p = e.current.get(o);
|
|
409
|
+
if (p && !Array.isArray(p)) {
|
|
410
|
+
const f = p;
|
|
411
|
+
f.color && !f.color.equals(a) && (f.color.copy(a), f.needsUpdate = !0);
|
|
366
412
|
}
|
|
367
413
|
});
|
|
368
414
|
});
|
|
369
|
-
const
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
if (
|
|
374
|
-
const
|
|
375
|
-
|
|
415
|
+
const c = (a) => typeof a == "string" ? new A.Color(a) : new A.Color(a[0], a[1], a[2]), u = R((a, o) => {
|
|
416
|
+
const p = c(o);
|
|
417
|
+
s.current.set(a, p);
|
|
418
|
+
const f = e.current.get(a);
|
|
419
|
+
if (f && !Array.isArray(f)) {
|
|
420
|
+
const M = f;
|
|
421
|
+
M.color && (M.color.copy(p), M.needsUpdate = !0);
|
|
376
422
|
}
|
|
377
|
-
}, []),
|
|
378
|
-
const
|
|
379
|
-
if (
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
382
|
-
return "#" +
|
|
423
|
+
}, []), g = R(() => Array.from(e.current.keys()).sort(), []), b = R((a) => {
|
|
424
|
+
const o = e.current.get(a);
|
|
425
|
+
if (o && !Array.isArray(o)) {
|
|
426
|
+
const p = o;
|
|
427
|
+
if (p.color)
|
|
428
|
+
return "#" + p.color.getHexString();
|
|
383
429
|
}
|
|
384
430
|
return null;
|
|
385
|
-
}, []),
|
|
386
|
-
const
|
|
387
|
-
return
|
|
388
|
-
if (!Array.isArray(
|
|
389
|
-
const
|
|
390
|
-
|
|
431
|
+
}, []), m = R(() => {
|
|
432
|
+
const a = {};
|
|
433
|
+
return e.current.forEach((o, p) => {
|
|
434
|
+
if (!Array.isArray(o)) {
|
|
435
|
+
const f = o;
|
|
436
|
+
f.color && (a[p] = "#" + f.color.getHexString());
|
|
391
437
|
}
|
|
392
|
-
}),
|
|
438
|
+
}), a;
|
|
393
439
|
}, []);
|
|
394
440
|
return {
|
|
395
|
-
setMaterialColor:
|
|
396
|
-
getMaterialNames:
|
|
397
|
-
getMaterialColor:
|
|
398
|
-
getAllMaterialColors:
|
|
441
|
+
setMaterialColor: u,
|
|
442
|
+
getMaterialNames: g,
|
|
443
|
+
getMaterialColor: b,
|
|
444
|
+
getAllMaterialColors: m
|
|
399
445
|
};
|
|
400
446
|
}
|
|
401
|
-
function G(
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
447
|
+
function G(r) {
|
|
448
|
+
const t = r.toLowerCase();
|
|
449
|
+
if (t.endsWith(".ktx2")) return !0;
|
|
404
450
|
try {
|
|
405
|
-
const
|
|
406
|
-
return
|
|
451
|
+
const e = new URL(r, window.location.origin), s = decodeURIComponent(e.hash.replace(/^#/, "")).toLowerCase(), c = decodeURIComponent(e.search).toLowerCase(), u = decodeURIComponent(e.pathname).toLowerCase();
|
|
452
|
+
return s.endsWith(".ktx2") || c.includes(".ktx2") || u.endsWith(".ktx2");
|
|
407
453
|
} catch {
|
|
408
|
-
return
|
|
454
|
+
return t.includes(".ktx2");
|
|
409
455
|
}
|
|
410
456
|
}
|
|
411
|
-
function
|
|
412
|
-
const { gl:
|
|
413
|
-
|
|
414
|
-
if (!
|
|
457
|
+
function ee(r, t) {
|
|
458
|
+
const { gl: e } = V(), s = k(/* @__PURE__ */ new Map()), c = k(new A.TextureLoader()), u = k(null), g = k(/* @__PURE__ */ new Map()), b = k(/* @__PURE__ */ new Set()), m = k("");
|
|
459
|
+
C(() => {
|
|
460
|
+
if (!u.current)
|
|
415
461
|
try {
|
|
416
|
-
const
|
|
417
|
-
console.log("[useMaterialTexture] Browser features:"), console.log(` WebAssembly supported: ${
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}).catch((
|
|
422
|
-
console.error("[useMaterialTexture] ❌ Failed to check basis_transcoder.wasm:",
|
|
423
|
-
}),
|
|
424
|
-
} catch (
|
|
425
|
-
console.error("[useMaterialTexture] ❌ Failed to initialize KTX2Loader:",
|
|
462
|
+
const n = typeof WebAssembly == "object" && typeof WebAssembly.validate == "function";
|
|
463
|
+
console.log("[useMaterialTexture] Browser features:"), console.log(` WebAssembly supported: ${n}`), console.log(` WebGL2: ${e.capabilities.isWebGL2}`);
|
|
464
|
+
const i = new Se();
|
|
465
|
+
i.setTranscoderPath("/basis/"), i.detectSupport(e), u.current = i, console.log("[useMaterialTexture] ✅ KTX2Loader initialized"), console.log("[useMaterialTexture] Transcoder path: /basis/"), fetch("/basis/basis_transcoder.wasm").then((l) => {
|
|
466
|
+
l.ok ? console.log("[useMaterialTexture] ✅ basis_transcoder.wasm is accessible") : console.error("[useMaterialTexture] ❌ basis_transcoder.wasm returned", l.status);
|
|
467
|
+
}).catch((l) => {
|
|
468
|
+
console.error("[useMaterialTexture] ❌ Failed to check basis_transcoder.wasm:", l);
|
|
469
|
+
}), n || (console.warn("[useMaterialTexture] ⚠️ WebAssembly not supported! KTX2 will fallback to CPU decoding (slow)"), console.warn("[useMaterialTexture] ⚠️ Recommend using WebP instead of KTX2 for this browser"));
|
|
470
|
+
} catch (n) {
|
|
471
|
+
console.error("[useMaterialTexture] ❌ Failed to initialize KTX2Loader:", n);
|
|
426
472
|
}
|
|
427
473
|
return () => {
|
|
428
|
-
|
|
474
|
+
u.current && (u.current.dispose(), u.current = null);
|
|
429
475
|
};
|
|
430
|
-
}, [
|
|
431
|
-
if (!
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
(Array.isArray(
|
|
437
|
-
|
|
476
|
+
}, [e]), C(() => {
|
|
477
|
+
if (!r) return;
|
|
478
|
+
const n = /* @__PURE__ */ new Map();
|
|
479
|
+
r.traverse((i) => {
|
|
480
|
+
if (i.isMesh) {
|
|
481
|
+
const l = i;
|
|
482
|
+
(Array.isArray(l.material) ? l.material : [l.material]).forEach((h) => {
|
|
483
|
+
h.name && !n.has(h.name) && n.set(h.name, h);
|
|
438
484
|
});
|
|
439
485
|
}
|
|
440
|
-
}),
|
|
441
|
-
}, [
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
if (!
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
const
|
|
448
|
-
if (
|
|
486
|
+
}), s.current = n;
|
|
487
|
+
}, [r]);
|
|
488
|
+
const a = R((n) => G(n) ? u.current ? u.current : (console.warn("[useMaterialTexture] KTX2Loader not initialized, falling back to TextureLoader"), c.current) : c.current, []);
|
|
489
|
+
C(() => {
|
|
490
|
+
if (!t || !r) return;
|
|
491
|
+
const n = s.current;
|
|
492
|
+
if (n.size === 0) return;
|
|
493
|
+
const i = JSON.stringify(t);
|
|
494
|
+
if (m.current === i) {
|
|
449
495
|
console.log("[useMaterialTexture] Textures unchanged, skipping reload");
|
|
450
496
|
return;
|
|
451
497
|
}
|
|
452
|
-
|
|
453
|
-
let
|
|
454
|
-
const
|
|
455
|
-
Object.entries(
|
|
456
|
-
|
|
457
|
-
}), console.log("[useMaterialTexture] Starting texture load for",
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
var
|
|
461
|
-
const
|
|
462
|
-
if (!
|
|
463
|
-
console.warn(`[useMaterialTexture] Material "${
|
|
498
|
+
m.current = i;
|
|
499
|
+
let l = !1;
|
|
500
|
+
const w = /* @__PURE__ */ new Map();
|
|
501
|
+
Object.entries(t).forEach(([d, S]) => {
|
|
502
|
+
w.set(d, typeof S == "string" ? { map: S } : S);
|
|
503
|
+
}), console.log("[useMaterialTexture] Starting texture load for", w.size, "materials");
|
|
504
|
+
const h = [];
|
|
505
|
+
w.forEach((d, S) => {
|
|
506
|
+
var v, N;
|
|
507
|
+
const W = n.get(S);
|
|
508
|
+
if (!W || !W.isMeshStandardMaterial) {
|
|
509
|
+
console.warn(`[useMaterialTexture] Material "${S}" not found or not MeshStandardMaterial`);
|
|
464
510
|
return;
|
|
465
511
|
}
|
|
466
|
-
const
|
|
467
|
-
console.log(`[useMaterialTexture] 📋 Material "${
|
|
468
|
-
if (!
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
}),
|
|
472
|
-
if (!
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
console.log(`[useMaterialTexture] Using cached texture: ${
|
|
512
|
+
const T = W;
|
|
513
|
+
console.log(`[useMaterialTexture] 📋 Material "${S}" BEFORE reset:`), console.log(` - map: ${T.map ? "EXISTS" : "null"} ${T.map ? `(uuid: ${T.map.uuid})` : ""}`), console.log(` - normalMap: ${T.normalMap ? "EXISTS" : "null"}`), console.log(` - roughnessMap: ${T.roughnessMap ? "EXISTS" : "null"}`), console.log(` - metalnessMap: ${T.metalnessMap ? "EXISTS" : "null"}`), console.log(` - emissiveMap: ${T.emissiveMap ? "EXISTS" : "null"}`), console.log(` - aoMap: ${T.aoMap ? "EXISTS" : "null"}`), console.log(` - color: ${(v = T.color) == null ? void 0 : v.getHexString()}`), console.log(` - emissive: ${(N = T.emissive) == null ? void 0 : N.getHexString()}`), console.log(` - material uuid: ${T.uuid}`), Object.entries(d).forEach(([$, I]) => {
|
|
514
|
+
if (!I) return;
|
|
515
|
+
const L = $, B = T[L];
|
|
516
|
+
B && (console.log(`[useMaterialTexture] 🗑️ Disposing old ${L} (uuid: ${B.uuid})`), B.dispose(), T[L] = null);
|
|
517
|
+
}), d.emissiveMap && (T.emissive = new A.Color(0), T.emissiveIntensity = 0), T.needsUpdate = !0, T.color = new A.Color(16777215), console.log(`[useMaterialTexture] ✅ Material "${S}" AFTER reset: only specified maps cleared`), Object.entries(d).forEach(([$, I]) => {
|
|
518
|
+
if (!I) return;
|
|
519
|
+
const L = `${S}_${$}_${I}`, B = g.current.get(L);
|
|
520
|
+
if (B) {
|
|
521
|
+
console.log(`[useMaterialTexture] Using cached texture: ${S}.${$}`), l || o(T, $, B);
|
|
476
522
|
return;
|
|
477
523
|
}
|
|
478
|
-
if (
|
|
479
|
-
console.log(`[useMaterialTexture] Skipping already loading: ${
|
|
524
|
+
if (b.current.has(L)) {
|
|
525
|
+
console.log(`[useMaterialTexture] Skipping already loading: ${S}.${$}`);
|
|
480
526
|
return;
|
|
481
527
|
}
|
|
482
|
-
|
|
528
|
+
h.push({ materialName: S, textureType: $, url: I, material: T });
|
|
483
529
|
});
|
|
484
|
-
}), console.log(`[useMaterialTexture] Queued ${
|
|
485
|
-
let
|
|
530
|
+
}), console.log(`[useMaterialTexture] Queued ${h.length} textures to load`);
|
|
531
|
+
let y = 0;
|
|
486
532
|
const E = () => {
|
|
487
|
-
if (
|
|
488
|
-
console.log("[useMaterialTexture] ✅ All textures loaded"), console.log("[useMaterialTexture] 📊 FINAL material states:"),
|
|
489
|
-
var
|
|
490
|
-
const $ =
|
|
491
|
-
console.log(` Material "${
|
|
533
|
+
if (l || y >= h.length) {
|
|
534
|
+
console.log("[useMaterialTexture] ✅ All textures loaded"), console.log("[useMaterialTexture] 📊 FINAL material states:"), n.forEach((v, N) => {
|
|
535
|
+
var I, L;
|
|
536
|
+
const $ = v;
|
|
537
|
+
console.log(` Material "${N}":`), console.log(` - map: ${$.map ? "EXISTS" : "null"} ${$.map ? `(colorSpace: ${$.map.colorSpace})` : ""}`), console.log(` - normalMap: ${$.normalMap ? "EXISTS" : "null"}`), console.log(` - roughnessMap: ${$.roughnessMap ? "EXISTS" : "null"}`), console.log(` - metalnessMap: ${$.metalnessMap ? "EXISTS" : "null"}`), console.log(` - emissiveMap: ${$.emissiveMap ? "EXISTS" : "null"}`), console.log(` - color: ${(I = $.color) == null ? void 0 : I.getHexString()}`), console.log(` - emissive: ${(L = $.emissive) == null ? void 0 : L.getHexString()}`), console.log(` - emissiveIntensity: ${$.emissiveIntensity}`), console.log(` - roughness: ${$.roughness}`), console.log(` - metalness: ${$.metalness}`);
|
|
492
538
|
});
|
|
493
539
|
return;
|
|
494
540
|
}
|
|
495
|
-
const
|
|
496
|
-
console.log(`[useMaterialTexture] Loading (${
|
|
497
|
-
const
|
|
498
|
-
console.log(`[useMaterialTexture] Using ${
|
|
499
|
-
|
|
500
|
-
(
|
|
501
|
-
var
|
|
502
|
-
if (
|
|
503
|
-
console.log(`[useMaterialTexture] Disposed, cleaning up texture: ${
|
|
541
|
+
const d = h[y++], S = `${d.materialName}_${d.textureType}_${d.url}`;
|
|
542
|
+
console.log(`[useMaterialTexture] Loading (${y}/${h.length}): ${d.materialName}.${d.textureType} from ${d.url}`), b.current.add(S);
|
|
543
|
+
const W = a(d.url), T = G(d.url) ? "KTX2Loader" : "TextureLoader";
|
|
544
|
+
console.log(`[useMaterialTexture] Using ${T} for ${d.url}`), W.load(
|
|
545
|
+
d.url,
|
|
546
|
+
(v) => {
|
|
547
|
+
var L, B, D, O, j, U;
|
|
548
|
+
if (b.current.delete(S), l) {
|
|
549
|
+
console.log(`[useMaterialTexture] Disposed, cleaning up texture: ${d.materialName}.${d.textureType}`), v.dispose();
|
|
504
550
|
return;
|
|
505
551
|
}
|
|
506
|
-
const
|
|
507
|
-
console.log(`[useMaterialTexture] ✅ Loaded: ${
|
|
508
|
-
const
|
|
509
|
-
console.log(`[useMaterialTexture] Waiting111111 ${
|
|
552
|
+
const N = ((L = v.image) == null ? void 0 : L.width) || ((D = (B = v.source) == null ? void 0 : B.data) == null ? void 0 : D.width) || "unknown", $ = ((O = v.image) == null ? void 0 : O.height) || ((U = (j = v.source) == null ? void 0 : j.data) == null ? void 0 : U.height) || "unknown";
|
|
553
|
+
console.log(`[useMaterialTexture] ✅ Loaded: ${d.materialName}.${d.textureType} (${N}x${$})`), v.colorSpace = d.textureType === "map" || d.textureType === "emissiveMap" ? A.SRGBColorSpace : A.NoColorSpace, v.wrapS = A.RepeatWrapping, v.wrapT = A.RepeatWrapping, v.flipY = !1, g.current.set(S, v), o(d.material, d.textureType, v);
|
|
554
|
+
const I = G(d.url) ? 500 : 150;
|
|
555
|
+
console.log(`[useMaterialTexture] Waiting111111 ${I}ms before next texture...`), setTimeout(E, 0);
|
|
510
556
|
},
|
|
511
|
-
(
|
|
512
|
-
if (
|
|
513
|
-
const
|
|
514
|
-
|
|
557
|
+
(v) => {
|
|
558
|
+
if (v.lengthComputable) {
|
|
559
|
+
const N = Math.round(v.loaded / v.total * 100);
|
|
560
|
+
N % 25 === 0 && console.log(`[useMaterialTexture] Progress ${d.materialName}.${d.textureType}: ${N}%`);
|
|
515
561
|
}
|
|
516
562
|
},
|
|
517
|
-
(
|
|
518
|
-
|
|
563
|
+
(v) => {
|
|
564
|
+
b.current.delete(S), l || (console.error(`[useMaterialTexture] ❌ Failed to load ${d.materialName}.${d.textureType} from ${d.url}`), console.error("[useMaterialTexture] Error details:", v), console.error("[useMaterialTexture] Loader type:", T), G(d.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(E, 100);
|
|
519
565
|
}
|
|
520
566
|
);
|
|
521
567
|
};
|
|
522
568
|
return E(), () => {
|
|
523
|
-
console.log("[useMaterialTexture] Cleanup: disposed"),
|
|
569
|
+
console.log("[useMaterialTexture] Cleanup: disposed"), l = !0;
|
|
524
570
|
};
|
|
525
|
-
}, [
|
|
526
|
-
const
|
|
527
|
-
var
|
|
528
|
-
switch (console.log(`[useMaterialTexture] 🎨 Applying texture: ${
|
|
571
|
+
}, [r, t, a]);
|
|
572
|
+
const o = (n, i, l) => {
|
|
573
|
+
var w, h;
|
|
574
|
+
switch (console.log(`[useMaterialTexture] 🎨 Applying texture: ${n.name}.${i} (texture uuid: ${l.uuid})`), i) {
|
|
529
575
|
case "map":
|
|
530
|
-
|
|
576
|
+
n.map = l;
|
|
531
577
|
break;
|
|
532
578
|
case "normalMap":
|
|
533
|
-
|
|
579
|
+
n.normalMap = l;
|
|
534
580
|
break;
|
|
535
581
|
case "roughnessMap":
|
|
536
|
-
|
|
582
|
+
n.roughnessMap = l;
|
|
537
583
|
break;
|
|
538
584
|
case "metalnessMap":
|
|
539
|
-
|
|
585
|
+
n.metalnessMap = l;
|
|
540
586
|
break;
|
|
541
587
|
case "emissiveMap":
|
|
542
|
-
|
|
588
|
+
n.emissiveMap = l, n.emissive = new A.Color(16777215), n.emissiveIntensity = 1;
|
|
543
589
|
break;
|
|
544
590
|
case "alphaMap":
|
|
545
|
-
|
|
591
|
+
n.alphaMap = l, n.transparent = !0, n.alphaTest = Math.max(n.alphaTest ?? 0, 1e-3), n.depthWrite = !1;
|
|
546
592
|
break;
|
|
547
593
|
case "aoMap":
|
|
548
|
-
|
|
594
|
+
n.aoMap = l;
|
|
549
595
|
break;
|
|
550
596
|
}
|
|
551
|
-
|
|
552
|
-
},
|
|
553
|
-
const
|
|
554
|
-
if (!
|
|
555
|
-
console.warn(`Material "${
|
|
597
|
+
n.needsUpdate = !0, console.log(`[useMaterialTexture] ✅ Applied ${i} to ${n.name}, needsUpdate=true`), console.log(`[useMaterialTexture] 📊 Material "${n.name}" FINAL state:`), console.log(` - map: ${n.map ? "EXISTS" : "null"} ${n.map ? `(uuid: ${n.map.uuid}, colorSpace: ${n.map.colorSpace})` : ""}`), console.log(` - normalMap: ${n.normalMap ? "EXISTS" : "null"}`), console.log(` - roughnessMap: ${n.roughnessMap ? "EXISTS" : "null"}`), console.log(` - metalnessMap: ${n.metalnessMap ? "EXISTS" : "null"}`), console.log(` - emissiveMap: ${n.emissiveMap ? "EXISTS" : "null"}`), console.log(` - aoMap: ${n.aoMap ? "EXISTS" : "null"}`), console.log(` - alphaMap: ${n.alphaMap ? "EXISTS" : "null"}`), console.log(` - transparent: ${n.transparent}`), console.log(` - alphaTest: ${n.alphaTest}`), console.log(` - depthWrite: ${n.depthWrite}`), console.log(` - color: ${(w = n.color) == null ? void 0 : w.getHexString()}`), console.log(` - emissive: ${(h = n.emissive) == null ? void 0 : h.getHexString()}`), console.log(` - emissiveIntensity: ${n.emissiveIntensity}`), console.log(` - roughness: ${n.roughness}`), console.log(` - metalness: ${n.metalness}`);
|
|
598
|
+
}, p = R((n, i) => {
|
|
599
|
+
const l = typeof i == "string" ? { map: i } : i, w = s.current.get(n);
|
|
600
|
+
if (!w || !w.isMeshStandardMaterial) {
|
|
601
|
+
console.warn(`Material "${n}" not found or not MeshStandardMaterial`);
|
|
556
602
|
return;
|
|
557
603
|
}
|
|
558
|
-
const
|
|
559
|
-
Object.entries(
|
|
604
|
+
const h = w;
|
|
605
|
+
Object.entries(l).forEach(([y, E]) => {
|
|
560
606
|
if (!E) return;
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
563
|
-
|
|
607
|
+
const d = `${n}_${y}_${E}`, S = g.current.get(d);
|
|
608
|
+
if (S) {
|
|
609
|
+
o(h, y, S);
|
|
564
610
|
return;
|
|
565
611
|
}
|
|
566
|
-
|
|
612
|
+
a(E).load(
|
|
567
613
|
E,
|
|
568
|
-
(
|
|
569
|
-
|
|
614
|
+
(T) => {
|
|
615
|
+
T.colorSpace = y === "map" || y === "emissiveMap" ? A.SRGBColorSpace : A.NoColorSpace, T.wrapS = A.RepeatWrapping, T.wrapT = A.RepeatWrapping, g.current.set(d, T), o(h, y, T);
|
|
570
616
|
},
|
|
571
617
|
void 0,
|
|
572
|
-
(
|
|
573
|
-
console.error(`Failed to load texture ${E}:`,
|
|
618
|
+
(T) => {
|
|
619
|
+
console.error(`Failed to load texture ${E}:`, T);
|
|
574
620
|
}
|
|
575
621
|
);
|
|
576
622
|
});
|
|
577
|
-
}, [
|
|
578
|
-
const
|
|
579
|
-
if (!
|
|
580
|
-
const
|
|
581
|
-
|
|
623
|
+
}, [a]), f = R(() => Array.from(s.current.keys()).sort(), []), M = R((n) => {
|
|
624
|
+
const i = s.current.get(n);
|
|
625
|
+
if (!i || !i.isMeshStandardMaterial) return;
|
|
626
|
+
const l = i;
|
|
627
|
+
l.map = null, l.normalMap = null, l.roughnessMap = null, l.metalnessMap = null, l.emissiveMap = null, l.alphaMap = null, l.aoMap = null, l.transparent = !1, l.alphaTest = 0, l.depthWrite = !0, l.needsUpdate = !0;
|
|
582
628
|
}, []);
|
|
583
629
|
return {
|
|
584
|
-
setMaterialTextures:
|
|
585
|
-
getMaterialNames:
|
|
586
|
-
clearMaterialTextures:
|
|
630
|
+
setMaterialTextures: p,
|
|
631
|
+
getMaterialNames: f,
|
|
632
|
+
clearMaterialTextures: M
|
|
587
633
|
};
|
|
588
634
|
}
|
|
589
|
-
function
|
|
590
|
-
url:
|
|
591
|
-
position:
|
|
592
|
-
rotation:
|
|
593
|
-
scale:
|
|
594
|
-
meshVisibility:
|
|
595
|
-
materialColors:
|
|
596
|
-
materialTextures:
|
|
597
|
-
onLoad:
|
|
598
|
-
onError:
|
|
635
|
+
function Re({
|
|
636
|
+
url: r,
|
|
637
|
+
position: t = [0, 0, 0],
|
|
638
|
+
rotation: e = [0, 0, 0],
|
|
639
|
+
scale: s = 1,
|
|
640
|
+
meshVisibility: c,
|
|
641
|
+
materialColors: u,
|
|
642
|
+
materialTextures: g,
|
|
643
|
+
onLoad: b,
|
|
644
|
+
onError: m
|
|
599
645
|
}) {
|
|
600
|
-
const { scene:
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
-
const
|
|
646
|
+
const { scene: a } = F(r), o = k(b);
|
|
647
|
+
o.current = b;
|
|
648
|
+
const p = P(() => {
|
|
649
|
+
const M = a.clone();
|
|
604
650
|
console.log("[Model] 🔍 Scene clone created, checking materials...");
|
|
605
|
-
const
|
|
606
|
-
let
|
|
607
|
-
return
|
|
608
|
-
if (
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
const
|
|
613
|
-
console.log(` - Has map: ${
|
|
651
|
+
const n = [], i = /* @__PURE__ */ new Set(), l = [];
|
|
652
|
+
let w = 0;
|
|
653
|
+
return M.traverse((h) => {
|
|
654
|
+
if (w++, h.type === "Bone" && l.push(h.name), h.isMesh) {
|
|
655
|
+
const y = h;
|
|
656
|
+
n.push(y.name), y.castShadow = !0, y.receiveShadow = !0, (Array.isArray(y.material) ? y.material : [y.material]).forEach((d) => {
|
|
657
|
+
i.add(d.name), console.log(`[Model] 📦 Material found: "${d.name}" (uuid: ${d.uuid})`);
|
|
658
|
+
const S = d;
|
|
659
|
+
console.log(` - Has map: ${S.map ? "YES" : "NO"}`), console.log(` - Has normalMap: ${S.normalMap ? "YES" : "NO"}`), console.log(` - Has roughnessMap: ${S.roughnessMap ? "YES" : "NO"}`), console.log(` - Has metalnessMap: ${S.metalnessMap ? "YES" : "NO"}`);
|
|
614
660
|
});
|
|
615
661
|
}
|
|
616
|
-
}), console.log(`[Model] 📊 Clone summary: ${
|
|
617
|
-
var
|
|
618
|
-
(
|
|
619
|
-
meshes:
|
|
620
|
-
materials: Array.from(
|
|
621
|
-
bones:
|
|
622
|
-
nodeCount:
|
|
662
|
+
}), console.log(`[Model] 📊 Clone summary: ${n.length} meshes, ${i.size} materials`), setTimeout(() => {
|
|
663
|
+
var h;
|
|
664
|
+
(h = o.current) == null || h.call(o, {
|
|
665
|
+
meshes: n.sort(),
|
|
666
|
+
materials: Array.from(i).sort(),
|
|
667
|
+
bones: l.sort(),
|
|
668
|
+
nodeCount: w
|
|
623
669
|
});
|
|
624
|
-
}, 0),
|
|
625
|
-
}, [
|
|
626
|
-
return
|
|
670
|
+
}, 0), M;
|
|
671
|
+
}, [a]);
|
|
672
|
+
return J(p, c), Q(p, u), ee(p, g), /* @__PURE__ */ x("group", { position: t, rotation: e, scale: typeof s == "number" ? [s, s, s] : s, children: /* @__PURE__ */ x("primitive", { object: p }) });
|
|
627
673
|
}
|
|
628
|
-
|
|
629
|
-
|
|
674
|
+
Re.preload = (r) => {
|
|
675
|
+
F.preload(r);
|
|
630
676
|
};
|
|
631
|
-
function
|
|
632
|
-
const { actions:
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
677
|
+
function Le(r, t, e) {
|
|
678
|
+
const { actions: s, names: c } = ye(r, t), u = k(null), g = k(e == null ? void 0 : e.defaultAnimation);
|
|
679
|
+
C(() => {
|
|
680
|
+
g.current = e == null ? void 0 : e.defaultAnimation;
|
|
681
|
+
}, [e == null ? void 0 : e.defaultAnimation]), C(() => {
|
|
682
|
+
if (c.length === 0) return;
|
|
683
|
+
const o = g.current;
|
|
684
|
+
let p = c[0];
|
|
685
|
+
if (o) {
|
|
686
|
+
const M = c.find((n) => n === o || n.includes(o));
|
|
687
|
+
M && (p = M);
|
|
640
688
|
}
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
}, [
|
|
644
|
-
const
|
|
645
|
-
(
|
|
689
|
+
const f = s[p];
|
|
690
|
+
f && (f.reset().fadeIn(0.5).play(), u.current = f);
|
|
691
|
+
}, [s, c]);
|
|
692
|
+
const b = R(
|
|
693
|
+
(o, p) => {
|
|
646
694
|
const {
|
|
647
|
-
loop:
|
|
648
|
-
crossFadeDuration:
|
|
649
|
-
restoreDefault:
|
|
650
|
-
} =
|
|
651
|
-
let
|
|
652
|
-
if (!
|
|
653
|
-
const
|
|
654
|
-
(
|
|
695
|
+
loop: f = !1,
|
|
696
|
+
crossFadeDuration: M = 0.2,
|
|
697
|
+
restoreDefault: n = !0
|
|
698
|
+
} = p || {};
|
|
699
|
+
let i = s[o];
|
|
700
|
+
if (!i) {
|
|
701
|
+
const w = Object.keys(s).find(
|
|
702
|
+
(h) => h.toLowerCase().includes(o.toLowerCase()) || o.toLowerCase().includes(h.toLowerCase())
|
|
655
703
|
);
|
|
656
|
-
|
|
704
|
+
w && (i = s[w]);
|
|
657
705
|
}
|
|
658
|
-
if (!
|
|
659
|
-
console.warn(`Animation "${
|
|
706
|
+
if (!i) {
|
|
707
|
+
console.warn(`Animation "${o}" not found. Available: ${c.join(", ")}`);
|
|
660
708
|
return;
|
|
661
709
|
}
|
|
662
|
-
const
|
|
663
|
-
if (!(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
),
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
669
|
-
|
|
670
|
-
const E =
|
|
671
|
-
E && (
|
|
710
|
+
const l = u.current;
|
|
711
|
+
if (!(l === i && i.isRunning()) && (l && l !== i && l.fadeOut(M), i.reset(), i.fadeIn(M), i.setLoop(
|
|
712
|
+
f ? A.LoopRepeat : A.LoopOnce,
|
|
713
|
+
f ? 1 / 0 : 1
|
|
714
|
+
), i.clampWhenFinished = !f, i.play(), f || i.getMixer().update(0), u.current = i, n && !f && g.current)) {
|
|
715
|
+
const w = i.getMixer(), h = (y) => {
|
|
716
|
+
if (y.action === i) {
|
|
717
|
+
w.removeEventListener("finished", h);
|
|
718
|
+
const E = s[g.current];
|
|
719
|
+
E && (i.fadeOut(M), E.reset().fadeIn(M).play(), u.current = E);
|
|
672
720
|
}
|
|
673
721
|
};
|
|
674
|
-
|
|
722
|
+
w.addEventListener("finished", h);
|
|
675
723
|
}
|
|
676
724
|
},
|
|
677
|
-
[
|
|
678
|
-
),
|
|
679
|
-
var
|
|
680
|
-
(
|
|
681
|
-
}, []),
|
|
725
|
+
[s, c]
|
|
726
|
+
), m = R(() => {
|
|
727
|
+
var o;
|
|
728
|
+
(o = u.current) == null || o.fadeOut(0.2), u.current = null;
|
|
729
|
+
}, []), a = R(() => c, [c]);
|
|
682
730
|
return {
|
|
683
|
-
playAnimation:
|
|
684
|
-
stopAnimation:
|
|
685
|
-
getAnimationNames:
|
|
686
|
-
actions:
|
|
731
|
+
playAnimation: b,
|
|
732
|
+
stopAnimation: m,
|
|
733
|
+
getAnimationNames: a,
|
|
734
|
+
actions: s
|
|
687
735
|
};
|
|
688
736
|
}
|
|
689
|
-
function
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
737
|
+
function le(r, t) {
|
|
738
|
+
const e = k(t || {}), s = k([]), c = k([]);
|
|
739
|
+
C(() => {
|
|
740
|
+
const m = /* @__PURE__ */ new Set(), a = [];
|
|
741
|
+
r.traverse((o) => {
|
|
742
|
+
o instanceof A.Mesh && o.morphTargetDictionary && o.morphTargetInfluences && (a.push(o), Object.keys(o.morphTargetDictionary).forEach((p) => {
|
|
743
|
+
m.add(p);
|
|
696
744
|
}));
|
|
697
|
-
}),
|
|
698
|
-
}, [
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
!
|
|
702
|
-
const
|
|
703
|
-
|
|
745
|
+
}), s.current = Array.from(m).sort(), c.current = a;
|
|
746
|
+
}, [r]), q(() => {
|
|
747
|
+
const m = e.current;
|
|
748
|
+
c.current.forEach((a) => {
|
|
749
|
+
!a.morphTargetDictionary || !a.morphTargetInfluences || Object.entries(m).forEach(([o, p]) => {
|
|
750
|
+
const f = a.morphTargetDictionary[o];
|
|
751
|
+
f !== void 0 && (a.morphTargetInfluences[f] = p);
|
|
704
752
|
});
|
|
705
753
|
});
|
|
706
|
-
}),
|
|
707
|
-
|
|
708
|
-
}, [
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
}, []),
|
|
754
|
+
}), C(() => {
|
|
755
|
+
t && (e.current = { ...t });
|
|
756
|
+
}, [t]);
|
|
757
|
+
const u = R((m, a) => {
|
|
758
|
+
e.current[m] = Math.max(0, Math.min(1, a));
|
|
759
|
+
}, []), g = R(() => s.current, []), b = R(() => ({ ...e.current }), []);
|
|
712
760
|
return {
|
|
713
|
-
setMorphTarget:
|
|
714
|
-
getMorphTargetNames:
|
|
715
|
-
getMorphTargetValues:
|
|
761
|
+
setMorphTarget: u,
|
|
762
|
+
getMorphTargetNames: g,
|
|
763
|
+
getMorphTargetValues: b
|
|
716
764
|
};
|
|
717
765
|
}
|
|
718
|
-
const
|
|
719
|
-
function
|
|
720
|
-
const
|
|
721
|
-
if (!
|
|
766
|
+
const ce = pe(null);
|
|
767
|
+
function Be() {
|
|
768
|
+
const r = de(ce);
|
|
769
|
+
if (!r)
|
|
722
770
|
throw new Error("BoneAttachment must be used within an AnimatedModel");
|
|
723
|
-
return
|
|
771
|
+
return r;
|
|
724
772
|
}
|
|
725
|
-
const
|
|
773
|
+
const ue = ae(
|
|
726
774
|
({
|
|
727
|
-
url:
|
|
728
|
-
position:
|
|
729
|
-
rotation:
|
|
730
|
-
scale:
|
|
731
|
-
defaultAnimation:
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
m,
|
|
754
|
-
T
|
|
755
|
-
), { setMaterialTextures: k, clearMaterialTextures: I } = Q(
|
|
756
|
-
m,
|
|
775
|
+
url: r,
|
|
776
|
+
position: t = [0, 0, 0],
|
|
777
|
+
rotation: e = [0, 0, 0],
|
|
778
|
+
scale: s = 1,
|
|
779
|
+
defaultAnimation: c,
|
|
780
|
+
animation: u,
|
|
781
|
+
morphTargets: g,
|
|
782
|
+
meshVisibility: b,
|
|
783
|
+
materialColors: m,
|
|
784
|
+
materialTextures: a,
|
|
785
|
+
onLoad: o,
|
|
786
|
+
onError: p,
|
|
787
|
+
children: f
|
|
788
|
+
}, M) => {
|
|
789
|
+
const n = k(null), i = k([]), l = k(o);
|
|
790
|
+
l.current = o;
|
|
791
|
+
const { scene: w, animations: h } = F(r), y = P(() => ie.clone(w), [w]), { playAnimation: E, stopAnimation: d, getAnimationNames: S } = Le(
|
|
792
|
+
h,
|
|
793
|
+
y,
|
|
794
|
+
{ defaultAnimation: c }
|
|
795
|
+
);
|
|
796
|
+
C(() => {
|
|
797
|
+
u && E(u, { loop: !0, restoreDefault: !1 });
|
|
798
|
+
}, [u, E]);
|
|
799
|
+
const { setMorphTarget: W } = le(
|
|
800
|
+
y,
|
|
757
801
|
g
|
|
802
|
+
), { setMeshVisibility: T, getMeshNames: v } = J(
|
|
803
|
+
y,
|
|
804
|
+
b
|
|
805
|
+
), { setMaterialColor: N, getMaterialNames: $, getMaterialColor: I } = Q(
|
|
806
|
+
y,
|
|
807
|
+
m
|
|
808
|
+
), { setMaterialTextures: L, clearMaterialTextures: B } = ee(
|
|
809
|
+
y,
|
|
810
|
+
a
|
|
758
811
|
);
|
|
759
|
-
|
|
760
|
-
if (!
|
|
761
|
-
const
|
|
762
|
-
var
|
|
763
|
-
const
|
|
764
|
-
let
|
|
765
|
-
|
|
766
|
-
if (
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}),
|
|
771
|
-
|
|
812
|
+
C(() => {
|
|
813
|
+
if (!y) return;
|
|
814
|
+
const j = setTimeout(() => {
|
|
815
|
+
var oe;
|
|
816
|
+
const U = [], K = [], te = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Set();
|
|
817
|
+
let ne = 0;
|
|
818
|
+
y.traverse((H) => {
|
|
819
|
+
if (ne++, H.type === "Bone" && U.push(H.name), H.isMesh) {
|
|
820
|
+
const X = H;
|
|
821
|
+
K.push(X.name), X.castShadow = !0, X.receiveShadow = !0, (Array.isArray(X.material) ? X.material : [X.material]).forEach((_) => {
|
|
822
|
+
te.add(_.name), _.shadowSide = A.DoubleSide;
|
|
823
|
+
}), X.morphTargetDictionary && Object.keys(X.morphTargetDictionary).forEach((_) => {
|
|
824
|
+
re.add(_);
|
|
772
825
|
});
|
|
773
826
|
}
|
|
774
|
-
}),
|
|
775
|
-
meshes:
|
|
776
|
-
materials: Array.from(
|
|
777
|
-
bones:
|
|
778
|
-
nodeCount:
|
|
779
|
-
animations:
|
|
780
|
-
morphTargetNames:
|
|
827
|
+
}), i.current = Array.from(re).sort(), (oe = l.current) == null || oe.call(l, {
|
|
828
|
+
meshes: K.sort(),
|
|
829
|
+
materials: Array.from(te).sort(),
|
|
830
|
+
bones: U.sort(),
|
|
831
|
+
nodeCount: ne,
|
|
832
|
+
animations: h.map((H) => H.name),
|
|
833
|
+
morphTargetNames: i.current
|
|
781
834
|
});
|
|
782
835
|
}, 0);
|
|
783
|
-
return () => clearTimeout(
|
|
784
|
-
}, [
|
|
785
|
-
playAnimation:
|
|
786
|
-
stopAnimation:
|
|
787
|
-
getAnimationNames:
|
|
788
|
-
getGroup: () =>
|
|
789
|
-
setMorphTarget:
|
|
790
|
-
getMorphTargetNames: () =>
|
|
791
|
-
setMeshVisibility:
|
|
792
|
-
getMeshNames:
|
|
793
|
-
setMaterialColor:
|
|
794
|
-
getMaterialNames:
|
|
795
|
-
getMaterialColor:
|
|
796
|
-
setMaterialTextures:
|
|
797
|
-
clearMaterialTextures:
|
|
836
|
+
return () => clearTimeout(j);
|
|
837
|
+
}, [y, h]), se(M, () => ({
|
|
838
|
+
playAnimation: E,
|
|
839
|
+
stopAnimation: d,
|
|
840
|
+
getAnimationNames: S,
|
|
841
|
+
getGroup: () => n.current,
|
|
842
|
+
setMorphTarget: W,
|
|
843
|
+
getMorphTargetNames: () => i.current,
|
|
844
|
+
setMeshVisibility: T,
|
|
845
|
+
getMeshNames: v,
|
|
846
|
+
setMaterialColor: N,
|
|
847
|
+
getMaterialNames: $,
|
|
848
|
+
getMaterialColor: I,
|
|
849
|
+
setMaterialTextures: L,
|
|
850
|
+
clearMaterialTextures: B
|
|
798
851
|
}));
|
|
799
|
-
const
|
|
852
|
+
const D = P(
|
|
800
853
|
() => ({
|
|
801
|
-
scene:
|
|
802
|
-
getBone: (
|
|
854
|
+
scene: y,
|
|
855
|
+
getBone: (j) => y.getObjectByName(j) || null
|
|
803
856
|
}),
|
|
804
|
-
[
|
|
805
|
-
),
|
|
806
|
-
return /* @__PURE__ */
|
|
857
|
+
[y]
|
|
858
|
+
), O = typeof s == "number" ? [s, s, s] : s;
|
|
859
|
+
return /* @__PURE__ */ x(ce.Provider, { value: D, children: /* @__PURE__ */ z(
|
|
807
860
|
"group",
|
|
808
861
|
{
|
|
809
|
-
ref:
|
|
810
|
-
position:
|
|
811
|
-
rotation:
|
|
812
|
-
scale:
|
|
862
|
+
ref: n,
|
|
863
|
+
position: t,
|
|
864
|
+
rotation: e,
|
|
865
|
+
scale: O,
|
|
813
866
|
children: [
|
|
814
|
-
/* @__PURE__ */
|
|
815
|
-
|
|
867
|
+
/* @__PURE__ */ x("primitive", { object: y }),
|
|
868
|
+
f
|
|
816
869
|
]
|
|
817
870
|
}
|
|
818
871
|
) });
|
|
819
872
|
}
|
|
820
873
|
);
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
874
|
+
ue.displayName = "AnimatedModel";
|
|
875
|
+
ue.preload = (r) => {
|
|
876
|
+
F.preload(r);
|
|
824
877
|
};
|
|
825
|
-
const
|
|
878
|
+
const je = ae(
|
|
826
879
|
({
|
|
827
|
-
url:
|
|
828
|
-
position:
|
|
829
|
-
rotation:
|
|
830
|
-
scale:
|
|
831
|
-
morphTargets:
|
|
832
|
-
meshVisibility:
|
|
833
|
-
materialColors:
|
|
834
|
-
materialTextures:
|
|
835
|
-
onMorphTargetsFound:
|
|
836
|
-
onLoad:
|
|
837
|
-
onError:
|
|
838
|
-
},
|
|
839
|
-
const { scene:
|
|
840
|
-
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
), { setMeshVisibility:
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
), { setMaterialColor:
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
), { setMaterialTextures:
|
|
853
|
-
|
|
854
|
-
|
|
880
|
+
url: r,
|
|
881
|
+
position: t = [0, 0, 0],
|
|
882
|
+
rotation: e = [0, 0, 0],
|
|
883
|
+
scale: s = 1,
|
|
884
|
+
morphTargets: c,
|
|
885
|
+
meshVisibility: u,
|
|
886
|
+
materialColors: g,
|
|
887
|
+
materialTextures: b,
|
|
888
|
+
onMorphTargetsFound: m,
|
|
889
|
+
onLoad: a,
|
|
890
|
+
onError: o
|
|
891
|
+
}, p) => {
|
|
892
|
+
const { scene: f } = F(r), M = k(a);
|
|
893
|
+
M.current = a;
|
|
894
|
+
const n = k(m);
|
|
895
|
+
n.current = m;
|
|
896
|
+
const i = P(() => f.clone(), [f]), { setMorphTarget: l, getMorphTargetNames: w, getMorphTargetValues: h } = le(
|
|
897
|
+
i,
|
|
898
|
+
c
|
|
899
|
+
), { setMeshVisibility: y, getMeshNames: E } = J(
|
|
900
|
+
i,
|
|
901
|
+
u
|
|
902
|
+
), { setMaterialColor: d, getMaterialNames: S, getMaterialColor: W } = Q(
|
|
903
|
+
i,
|
|
904
|
+
g
|
|
905
|
+
), { setMaterialTextures: T, clearMaterialTextures: v } = ee(
|
|
906
|
+
i,
|
|
907
|
+
b
|
|
855
908
|
);
|
|
856
|
-
return
|
|
857
|
-
var
|
|
858
|
-
const $ =
|
|
859
|
-
$.length > 0 && ((
|
|
860
|
-
}, [
|
|
861
|
-
var
|
|
862
|
-
if (!
|
|
863
|
-
const $ = [],
|
|
864
|
-
let
|
|
865
|
-
|
|
866
|
-
if (
|
|
867
|
-
const
|
|
868
|
-
$.push(
|
|
909
|
+
return C(() => {
|
|
910
|
+
var I;
|
|
911
|
+
const $ = w();
|
|
912
|
+
$.length > 0 && ((I = n.current) == null || I.call(n, $));
|
|
913
|
+
}, [i, w]), C(() => {
|
|
914
|
+
var D;
|
|
915
|
+
if (!i) return;
|
|
916
|
+
const $ = [], I = /* @__PURE__ */ new Set(), L = [];
|
|
917
|
+
let B = 0;
|
|
918
|
+
i.traverse((O) => {
|
|
919
|
+
if (B++, O.type === "Bone" && L.push(O.name), O.isMesh) {
|
|
920
|
+
const j = O;
|
|
921
|
+
$.push(j.name), j.castShadow = !0, j.receiveShadow = !0, (Array.isArray(j.material) ? j.material : [j.material]).forEach((K) => I.add(K.name));
|
|
869
922
|
}
|
|
870
|
-
}), (
|
|
923
|
+
}), (D = M.current) == null || D.call(M, {
|
|
871
924
|
meshes: $.sort(),
|
|
872
|
-
materials: Array.from(
|
|
873
|
-
bones:
|
|
874
|
-
nodeCount:
|
|
925
|
+
materials: Array.from(I).sort(),
|
|
926
|
+
bones: L.sort(),
|
|
927
|
+
nodeCount: B
|
|
875
928
|
});
|
|
876
|
-
}, [
|
|
877
|
-
setMorphTarget:
|
|
878
|
-
getMorphTargetNames:
|
|
879
|
-
getMorphTargetValues:
|
|
880
|
-
setMeshVisibility:
|
|
929
|
+
}, [i]), se(p, () => ({
|
|
930
|
+
setMorphTarget: l,
|
|
931
|
+
getMorphTargetNames: w,
|
|
932
|
+
getMorphTargetValues: h,
|
|
933
|
+
setMeshVisibility: y,
|
|
881
934
|
getMeshNames: E,
|
|
882
|
-
setMaterialColor:
|
|
883
|
-
getMaterialNames:
|
|
884
|
-
getMaterialColor:
|
|
885
|
-
setMaterialTextures:
|
|
886
|
-
clearMaterialTextures:
|
|
887
|
-
})), /* @__PURE__ */
|
|
935
|
+
setMaterialColor: d,
|
|
936
|
+
getMaterialNames: S,
|
|
937
|
+
getMaterialColor: W,
|
|
938
|
+
setMaterialTextures: T,
|
|
939
|
+
clearMaterialTextures: v
|
|
940
|
+
})), /* @__PURE__ */ x("group", { position: t, rotation: e, scale: typeof s == "number" ? [s, s, s] : s, children: /* @__PURE__ */ x("primitive", { object: i }) });
|
|
888
941
|
}
|
|
889
942
|
);
|
|
890
|
-
|
|
891
|
-
function
|
|
892
|
-
children:
|
|
893
|
-
bone:
|
|
894
|
-
position:
|
|
895
|
-
rotation:
|
|
896
|
-
scale:
|
|
943
|
+
je.displayName = "MorphableModel";
|
|
944
|
+
function Fe({
|
|
945
|
+
children: r,
|
|
946
|
+
bone: t,
|
|
947
|
+
position: e = [0, 0, 0],
|
|
948
|
+
rotation: s = [0, 0, 0],
|
|
949
|
+
scale: c = 1
|
|
897
950
|
}) {
|
|
898
|
-
const { getBone:
|
|
899
|
-
return
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
}, [
|
|
903
|
-
/* @__PURE__ */
|
|
951
|
+
const { getBone: u } = Be(), [g, b] = Z(null);
|
|
952
|
+
return C(() => {
|
|
953
|
+
const a = u(t);
|
|
954
|
+
a ? b(a) : console.warn(`Bone "${t}" not found in model`);
|
|
955
|
+
}, [t, u]), g ? be(
|
|
956
|
+
/* @__PURE__ */ x(
|
|
904
957
|
"group",
|
|
905
958
|
{
|
|
906
|
-
position:
|
|
907
|
-
rotation:
|
|
908
|
-
scale: typeof
|
|
909
|
-
children:
|
|
959
|
+
position: e,
|
|
960
|
+
rotation: s,
|
|
961
|
+
scale: typeof c == "number" ? [c, c, c] : c,
|
|
962
|
+
children: r
|
|
910
963
|
}
|
|
911
964
|
),
|
|
912
|
-
|
|
965
|
+
g
|
|
913
966
|
) : null;
|
|
914
967
|
}
|
|
915
|
-
function
|
|
916
|
-
const { scene:
|
|
917
|
-
return
|
|
918
|
-
var
|
|
919
|
-
if (!
|
|
920
|
-
const
|
|
921
|
-
let
|
|
922
|
-
|
|
923
|
-
if (
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
|
|
968
|
+
function Ue(r, t) {
|
|
969
|
+
const { scene: e, animations: s } = F(r), c = P(() => ie.clone(e), [e]);
|
|
970
|
+
return C(() => {
|
|
971
|
+
var a;
|
|
972
|
+
if (!c) return;
|
|
973
|
+
const u = [], g = [], b = /* @__PURE__ */ new Set();
|
|
974
|
+
let m = 0;
|
|
975
|
+
c.traverse((o) => {
|
|
976
|
+
if (m++, o.type === "Bone" && u.push(o.name), o.isMesh) {
|
|
977
|
+
const p = o;
|
|
978
|
+
g.push(p.name), p.castShadow = !0, p.receiveShadow = !0, (Array.isArray(p.material) ? p.material : [p.material]).forEach((M) => {
|
|
979
|
+
b.add(M.name), M.shadowSide = A.DoubleSide;
|
|
927
980
|
});
|
|
928
981
|
}
|
|
929
|
-
}), (
|
|
930
|
-
meshes:
|
|
931
|
-
materials: Array.from(
|
|
932
|
-
bones:
|
|
933
|
-
nodeCount:
|
|
982
|
+
}), (a = t == null ? void 0 : t.onLoad) == null || a.call(t, {
|
|
983
|
+
meshes: g.sort(),
|
|
984
|
+
materials: Array.from(b).sort(),
|
|
985
|
+
bones: u.sort(),
|
|
986
|
+
nodeCount: m
|
|
934
987
|
});
|
|
935
|
-
}, [
|
|
988
|
+
}, [c, t]), { scene: c, animations: s };
|
|
936
989
|
}
|
|
937
|
-
function
|
|
938
|
-
|
|
990
|
+
function He(r) {
|
|
991
|
+
F.preload(r);
|
|
939
992
|
}
|
|
940
993
|
export {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
994
|
+
ue as AnimatedModel,
|
|
995
|
+
Fe as BoneAttachment,
|
|
996
|
+
Re as Model,
|
|
997
|
+
je as MorphableModel,
|
|
998
|
+
ze as Scene3D,
|
|
999
|
+
He as preloadModel,
|
|
1000
|
+
Le as useAnimationController,
|
|
1001
|
+
Ue as useClonedModel,
|
|
1002
|
+
Q as useMaterialColor,
|
|
1003
|
+
ee as useMaterialTexture,
|
|
1004
|
+
J as useMeshVisibility,
|
|
1005
|
+
le as useMorphTargets
|
|
953
1006
|
};
|
|
954
1007
|
//# sourceMappingURL=mbt-3d.js.map
|