mbt-3d 0.3.8 → 0.4.0

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