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