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