mbt-3d 0.3.9 → 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,80 +1,106 @@
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
- import * as R from "three";
4
- import * as se from "three/examples/jsm/utils/SkeletonUtils.js";
5
- import { Canvas as be, useThree as ie, useFrame as Z, createPortal as Te } from "@react-three/fiber";
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
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({
7
+ import { jsxs as z, jsx as x } from "react/jsx-runtime";
8
+ function xe({
9
9
  position: r,
10
- controlsConfig: t
10
+ target: t,
11
+ controlsConfig: e
11
12
  }) {
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(
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(
16
17
  ge,
17
18
  {
18
- ref: i,
19
+ ref: c,
19
20
  makeDefault: !0,
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
21
+ enabled: e.enabled,
22
+ enablePan: e.enablePan,
23
+ enableZoom: e.enableZoom,
24
+ enableRotate: e.enableRotate,
25
+ minDistance: e.minDistance,
26
+ maxDistance: e.maxDistance,
27
+ minPolarAngle: e.minPolarAngle,
28
+ maxPolarAngle: e.maxPolarAngle,
29
+ autoRotate: e.autoRotate,
30
+ autoRotateSpeed: e.autoRotateSpeed
30
31
  }
31
32
  );
32
33
  }
33
- function xe({ background: r }) {
34
+ function $e({ background: r }) {
34
35
  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
+ return r ? t ? /* @__PURE__ */ x("color", { attach: "background", args: [r] }) : /* @__PURE__ */ x(we, { url: r }) : null;
36
37
  }
37
38
  function we({ url: r }) {
38
39
  const t = Me(r);
39
- return B(() => {
40
- t.colorSpace = R.SRGBColorSpace;
41
- }, [t]), /* @__PURE__ */ T("primitive", { attach: "background", object: t });
40
+ return P(() => {
41
+ t.colorSpace = A.SRGBColorSpace;
42
+ }, [t]), /* @__PURE__ */ x("primitive", { attach: "background", object: t });
42
43
  }
43
44
  function Ae({ config: r }) {
44
- return /* @__PURE__ */ T(
45
+ return /* @__PURE__ */ x(
45
46
  fe,
46
47
  {
47
48
  files: r.files,
48
49
  background: r.background ?? !1,
49
- blur: r.blur ?? 0,
50
- children: /* @__PURE__ */ T("group", { scale: r.intensity ?? 1, children: /* @__PURE__ */ T("ambientLight", { intensity: 0 }) })
50
+ blur: r.blur ?? 0
51
51
  }
52
52
  );
53
53
  }
54
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 }) {
55
78
  switch (r.type) {
56
79
  case "spot": {
57
80
  const {
58
81
  position: t = [5, 10, 5],
59
82
  intensity: e = 50,
60
- castShadow: i = !0,
61
- angle: c = Math.PI / 6,
62
- penumbra: d = 0.5,
63
- decay: M = 2,
64
- distance: S = 0,
65
- color: f = "#ffffff"
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"
66
90
  } = r;
67
- return /* @__PURE__ */ T(
91
+ return /* @__PURE__ */ x(
68
92
  "spotLight",
69
93
  {
70
94
  position: t,
71
95
  intensity: e,
72
- castShadow: i,
73
- angle: c,
74
- penumbra: d,
75
- decay: M,
76
- distance: S,
77
- color: f
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
  }
@@ -82,20 +108,23 @@ function ve({ config: r }) {
82
108
  const {
83
109
  position: t = [0, 5, 0],
84
110
  intensity: e = 20,
85
- color: i = "#ffffff",
111
+ color: s = "#ffffff",
86
112
  distance: c = 0,
87
- decay: d = 2,
88
- castShadow: M = !1
113
+ decay: u = 2,
114
+ castShadow: g = !1,
115
+ shadowMapSize: b = 2048
89
116
  } = r;
90
- return /* @__PURE__ */ T(
117
+ return /* @__PURE__ */ x(
91
118
  "pointLight",
92
119
  {
93
120
  position: t,
94
121
  intensity: e,
95
- color: i,
122
+ color: s,
96
123
  distance: c,
97
- decay: d,
98
- castShadow: M
124
+ decay: u,
125
+ castShadow: g,
126
+ "shadow-mapSize-width": b,
127
+ "shadow-mapSize-height": b
99
128
  }
100
129
  );
101
130
  }
@@ -103,16 +132,19 @@ function ve({ config: r }) {
103
132
  const {
104
133
  position: t = [10, 20, 10],
105
134
  intensity: e = 40,
106
- color: i = "#ffffff",
107
- castShadow: c = !0
135
+ color: s = "#ffffff",
136
+ castShadow: c = !0,
137
+ shadowMapSize: u = 2048
108
138
  } = r;
109
- return /* @__PURE__ */ T(
139
+ return /* @__PURE__ */ x(
110
140
  "directionalLight",
111
141
  {
112
142
  position: t,
113
143
  intensity: e,
114
- color: i,
115
- castShadow: c
144
+ color: s,
145
+ castShadow: c,
146
+ "shadow-mapSize-width": u,
147
+ "shadow-mapSize-height": u
116
148
  }
117
149
  );
118
150
  }
@@ -120,13 +152,13 @@ function ve({ config: r }) {
120
152
  const {
121
153
  skyColor: t = "#ffffff",
122
154
  groundColor: e = "#444444",
123
- intensity: i = 0.5,
155
+ intensity: s = 0.5,
124
156
  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(
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: [d, M, i],
161
+ args: [u, g, s],
130
162
  position: c
131
163
  }
132
164
  );
@@ -136,7 +168,7 @@ function ve({ config: r }) {
136
168
  intensity: t = 0.5,
137
169
  color: e = "#ffffff"
138
170
  } = r;
139
- return /* @__PURE__ */ T(
171
+ return /* @__PURE__ */ x(
140
172
  "ambientLight",
141
173
  {
142
174
  intensity: t,
@@ -148,46 +180,53 @@ function ve({ config: r }) {
148
180
  return null;
149
181
  }
150
182
  }
151
- function Ee({
183
+ function Ie({
152
184
  onChange: r
153
185
  }) {
154
186
  const { active: t, progress: e } = he();
155
- return k(() => {
187
+ return C(() => {
156
188
  r(t, e);
157
189
  }, [t, e, r]), null;
158
190
  }
159
- function De({
191
+ function ze({
160
192
  children: r,
161
193
  camera: t = {},
162
194
  controls: e = {},
163
- background: i,
195
+ background: s,
164
196
  shadows: c = !0,
165
- lights: d = [
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: S = !0,
171
- showLoadingOverlay: f = !0,
172
- style: a,
173
- className: n
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 [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))));
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), s.current = window.setTimeout(() => {
181
- p(!1), o(0), s.current = null;
218
+ i(100), l.current = window.setTimeout(() => {
219
+ M(!1), i(0), l.current = null;
182
220
  }, 200);
183
221
  }, []);
184
- k(() => () => {
185
- s.current !== null && window.clearTimeout(s.current);
222
+ C(() => () => {
223
+ l.current !== null && window.clearTimeout(l.current);
186
224
  }, []);
187
- const $ = {
225
+ const h = {
188
226
  position: t.position || [0, 2, 5],
189
227
  fov: t.fov || 45
190
- }, g = {
228
+ }, y = {
229
+ target: e.target || [0, 0, 0],
191
230
  enabled: e.enabled ?? !0,
192
231
  enablePan: e.enablePan ?? !0,
193
232
  enableZoom: e.enableZoom ?? !0,
@@ -198,59 +237,66 @@ function De({
198
237
  maxPolarAngle: e.maxPolarAngle,
199
238
  autoRotate: e.autoRotate ?? !1,
200
239
  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
- /* @__PURE__ */ _(
208
- be,
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
249
  shadows: c,
211
250
  camera: {
212
- position: $.position,
213
- fov: $.fov
251
+ position: h.position,
252
+ fov: h.fov
214
253
  },
215
254
  style: { width: "100%", height: "100%" },
216
255
  children: [
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,
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: $.position,
225
- controlsConfig: g
267
+ position: h.position,
268
+ target: y.target,
269
+ controlsConfig: y
226
270
  }
227
271
  ),
228
- h && /* @__PURE__ */ T(
229
- de,
272
+ E && /* @__PURE__ */ x(
273
+ me,
230
274
  {
231
- position: h.position,
232
- opacity: h.opacity,
233
- blur: h.blur
275
+ position: E.position,
276
+ opacity: E.opacity,
277
+ blur: E.blur
234
278
  }
235
279
  ),
236
- /* @__PURE__ */ T(Ee, { onChange: l })
280
+ /* @__PURE__ */ x(Ie, { onChange: w })
237
281
  ]
238
282
  }
239
283
  ),
240
- f && u && /* @__PURE__ */ T(
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 De({
265
311
  textAlign: "center"
266
312
  },
267
313
  children: [
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(
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 De({
275
321
  stroke: "#67b4ff",
276
322
  strokeWidth: "4",
277
323
  strokeLinecap: "round",
278
- children: /* @__PURE__ */ T(
324
+ children: /* @__PURE__ */ x(
279
325
  "animateTransform",
280
326
  {
281
327
  attributeName: "transform",
@@ -289,8 +335,8 @@ function De({
289
335
  }
290
336
  )
291
337
  ] }) }),
292
- /* @__PURE__ */ _("div", { style: { fontSize: 12, opacity: 0.82, marginTop: 4 }, children: [
293
- y,
338
+ /* @__PURE__ */ z("div", { style: { fontSize: 12, opacity: 0.82, marginTop: 4 }, children: [
339
+ n,
294
340
  "%"
295
341
  ] })
296
342
  ]
@@ -300,526 +346,526 @@ function De({
300
346
  )
301
347
  ] });
302
348
  }
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(() => {
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(() => {
308
354
  if (!r) return;
309
- const f = /* @__PURE__ */ new Map();
355
+ const m = /* @__PURE__ */ new Map();
310
356
  r.traverse((a) => {
311
357
  if (a.isMesh) {
312
- const n = a;
313
- n.name && f.set(n.name, n);
358
+ const o = a;
359
+ o.name && m.set(o.name, o);
314
360
  }
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);
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 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;
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: d,
337
- getMeshNames: M,
338
- getMeshVisibility: S
382
+ setMeshVisibility: u,
383
+ getMeshNames: g,
384
+ getMeshVisibility: b
339
385
  };
340
386
  }
341
- function J(r, t) {
342
- const e = E(/* @__PURE__ */ new Map()), i = E(/* @__PURE__ */ new Map());
343
- k(() => {
387
+ function Q(r, t) {
388
+ const e = k(/* @__PURE__ */ new Map()), s = k(/* @__PURE__ */ new Map());
389
+ C(() => {
344
390
  if (!r) return;
345
391
  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);
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
- }), 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);
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
- }, [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);
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 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);
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 = 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();
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
- }, []), f = I(() => {
431
+ }, []), m = R(() => {
386
432
  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());
433
+ return e.current.forEach((o, p) => {
434
+ if (!Array.isArray(o)) {
435
+ const f = o;
436
+ f.color && (a[p] = "#" + f.color.getHexString());
391
437
  }
392
438
  }), a;
393
439
  }, []);
394
440
  return {
395
- setMaterialColor: d,
396
- getMaterialNames: M,
397
- getMaterialColor: S,
398
- getAllMaterialColors: f
441
+ setMaterialColor: u,
442
+ getMaterialNames: g,
443
+ getMaterialColor: b,
444
+ getAllMaterialColors: m
399
445
  };
400
446
  }
401
447
  function G(r) {
402
448
  const t = r.toLowerCase();
403
449
  if (t.endsWith(".ktx2")) return !0;
404
450
  try {
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");
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
454
  return t.includes(".ktx2");
409
455
  }
410
456
  }
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)
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: ${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) => {
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) => {
420
466
  l.ok ? console.log("[useMaterialTexture] ✅ basis_transcoder.wasm is accessible") : console.error("[useMaterialTexture] ❌ basis_transcoder.wasm returned", l.status);
421
467
  }).catch((l) => {
422
468
  console.error("[useMaterialTexture] ❌ Failed to check basis_transcoder.wasm:", l);
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);
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
- d.current && (d.current.dispose(), d.current = null);
474
+ u.current && (u.current.dispose(), u.current = null);
429
475
  };
430
- }, [e]), k(() => {
476
+ }, [e]), C(() => {
431
477
  if (!r) return;
432
- const o = /* @__PURE__ */ new Map();
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);
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;
486
+ }), s.current = n;
441
487
  }, [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(() => {
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(() => {
444
490
  if (!t || !r) return;
445
- const o = i.current;
446
- if (o.size === 0) return;
447
- const s = JSON.stringify(t);
448
- if (f.current === s) {
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
- f.current = s;
498
+ m.current = i;
453
499
  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`);
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 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
- if (j) {
475
- console.log(`[useMaterialTexture] Using cached texture: ${w}.${x}`), l || n(b, x, 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 (S.current.has(L)) {
479
- console.log(`[useMaterialTexture] Skipping already loading: ${w}.${x}`);
524
+ if (b.current.has(L)) {
525
+ console.log(`[useMaterialTexture] Skipping already loading: ${S}.${$}`);
480
526
  return;
481
527
  }
482
- g.push({ materialName: w, textureType: x, url: C, material: b });
528
+ h.push({ materialName: S, textureType: $, url: I, material: T });
483
529
  });
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}`);
530
+ }), console.log(`[useMaterialTexture] Queued ${h.length} textures to load`);
531
+ let y = 0;
532
+ const E = () => {
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 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
- (A) => {
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();
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 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);
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 N = Math.round(A.loaded / A.total * 100);
514
- N % 25 === 0 && console.log(`[useMaterialTexture] Progress ${m.materialName}.${m.textureType}: ${N}%`);
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
- 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);
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
- return v(), () => {
568
+ return E(), () => {
523
569
  console.log("[useMaterialTexture] Cleanup: disposed"), l = !0;
524
570
  };
525
571
  }, [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) {
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 = l;
576
+ n.map = l;
531
577
  break;
532
578
  case "normalMap":
533
- o.normalMap = l;
579
+ n.normalMap = l;
534
580
  break;
535
581
  case "roughnessMap":
536
- o.roughnessMap = l;
582
+ n.roughnessMap = l;
537
583
  break;
538
584
  case "metalnessMap":
539
- o.metalnessMap = l;
585
+ n.metalnessMap = l;
540
586
  break;
541
587
  case "emissiveMap":
542
- o.emissiveMap = l, 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 = l;
594
+ n.aoMap = l;
549
595
  break;
550
596
  }
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
- 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 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);
604
+ const h = w;
605
+ Object.entries(l).forEach(([y, E]) => {
606
+ if (!E) return;
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
- 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);
612
+ a(E).load(
613
+ E,
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
- (b) => {
573
- console.error(`Failed to load texture ${v}:`, b);
618
+ (T) => {
619
+ console.error(`Failed to load texture ${E}:`, T);
574
620
  }
575
621
  );
576
622
  });
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;
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: u,
585
- getMaterialNames: p,
586
- clearMaterialTextures: y
630
+ setMaterialTextures: p,
631
+ getMaterialNames: f,
632
+ clearMaterialTextures: M
587
633
  };
588
634
  }
589
635
  function Re({
590
636
  url: r,
591
637
  position: t = [0, 0, 0],
592
638
  rotation: e = [0, 0, 0],
593
- scale: i = 1,
639
+ scale: s = 1,
594
640
  meshVisibility: c,
595
- materialColors: d,
596
- materialTextures: M,
597
- onLoad: S,
598
- onError: f
641
+ materialColors: u,
642
+ materialTextures: g,
643
+ onLoad: b,
644
+ onError: m
599
645
  }) {
600
- const { scene: a } = U(r), n = E(S);
601
- n.current = S;
602
- const u = B(() => {
603
- const y = a.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 = [], 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"}`);
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, ${s.size} materials`), setTimeout(() => {
617
- var g;
618
- (g = n.current) == null || g.call(n, {
619
- meshes: o.sort(),
620
- materials: Array.from(s).sort(),
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(),
621
667
  bones: l.sort(),
622
- nodeCount: $
668
+ nodeCount: w
623
669
  });
624
- }, 0), y;
670
+ }, 0), M;
625
671
  }, [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 }) });
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
674
  Re.preload = (r) => {
629
- U.preload(r);
675
+ F.preload(r);
630
676
  };
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(() => {
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(() => {
636
682
  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);
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);
642
688
  }
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) => {
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) => {
648
694
  const {
649
- loop: p = !1,
650
- crossFadeDuration: y = 0.2,
651
- restoreDefault: o = !0
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())
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())
657
703
  );
658
- $ && (s = i[$]);
704
+ w && (i = s[w]);
659
705
  }
660
- if (!s) {
661
- console.warn(`Animation "${n}" not found. Available: ${c.join(", ")}`);
706
+ if (!i) {
707
+ console.warn(`Animation "${o}" not found. Available: ${c.join(", ")}`);
662
708
  return;
663
709
  }
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);
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);
674
720
  }
675
721
  };
676
- $.addEventListener("finished", g);
722
+ w.addEventListener("finished", h);
677
723
  }
678
724
  },
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]);
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]);
684
730
  return {
685
- playAnimation: S,
686
- stopAnimation: f,
731
+ playAnimation: b,
732
+ stopAnimation: m,
687
733
  getAnimationNames: a,
688
- actions: i
734
+ actions: s
689
735
  };
690
736
  }
691
737
  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);
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);
698
744
  }));
699
- }), i.current = Array.from(f).sort(), c.current = a;
700
- }, [r]), Z(() => {
701
- const f = e.current;
745
+ }), s.current = Array.from(m).sort(), c.current = a;
746
+ }, [r]), q(() => {
747
+ const m = e.current;
702
748
  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);
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);
706
752
  });
707
753
  });
708
- }), k(() => {
754
+ }), C(() => {
709
755
  t && (e.current = { ...t });
710
756
  }, [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 }), []);
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 }), []);
714
760
  return {
715
- setMorphTarget: d,
716
- getMorphTargetNames: M,
717
- getMorphTargetValues: S
761
+ setMorphTarget: u,
762
+ getMorphTargetNames: g,
763
+ getMorphTargetValues: b
718
764
  };
719
765
  }
720
- const ce = me(null);
721
- function Ce() {
722
- const r = pe(ce);
766
+ const ce = pe(null);
767
+ function Be() {
768
+ const r = de(ce);
723
769
  if (!r)
724
770
  throw new Error("BoneAttachment must be used within an AnimatedModel");
725
771
  return r;
726
772
  }
727
- const ue = ne(
773
+ const ue = ae(
728
774
  ({
729
775
  url: r,
730
776
  position: t = [0, 0, 0],
731
777
  rotation: e = [0, 0, 0],
732
- scale: i = 1,
778
+ scale: s = 1,
733
779
  defaultAnimation: c,
734
- animation: d,
735
- morphTargets: M,
736
- meshVisibility: S,
737
- materialColors: f,
780
+ animation: u,
781
+ morphTargets: g,
782
+ meshVisibility: b,
783
+ materialColors: m,
738
784
  materialTextures: a,
739
- onLoad: n,
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,
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(
747
792
  h,
793
+ y,
748
794
  { defaultAnimation: c }
749
795
  );
750
- k(() => {
751
- d && v(d, { loop: !0, restoreDefault: !1 });
752
- }, [d, v]);
753
- const { setMorphTarget: P } = le(
754
- h,
755
- M
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,
796
+ C(() => {
797
+ u && E(u, { loop: !0, restoreDefault: !1 });
798
+ }, [u, E]);
799
+ const { setMorphTarget: W } = le(
800
+ y,
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,
764
810
  a
765
811
  );
766
- k(() => {
767
- if (!h) return;
768
- const O = setTimeout(() => {
812
+ C(() => {
813
+ if (!y) return;
814
+ const j = setTimeout(() => {
769
815
  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);
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(_);
779
825
  });
780
826
  }
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
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
788
834
  });
789
835
  }, 0);
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,
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,
800
846
  setMaterialColor: N,
801
- getMaterialNames: x,
802
- getMaterialColor: C,
847
+ getMaterialNames: $,
848
+ getMaterialColor: I,
803
849
  setMaterialTextures: L,
804
- clearMaterialTextures: j
850
+ clearMaterialTextures: B
805
851
  }));
806
- const W = B(
852
+ const D = P(
807
853
  () => ({
808
- scene: h,
809
- getBone: (O) => h.getObjectByName(O) || null
854
+ scene: y,
855
+ getBone: (j) => y.getObjectByName(j) || null
810
856
  }),
811
- [h]
812
- ), X = typeof i == "number" ? [i, i, i] : i;
813
- return /* @__PURE__ */ T(ce.Provider, { value: W, children: /* @__PURE__ */ _(
857
+ [y]
858
+ ), O = typeof s == "number" ? [s, s, s] : s;
859
+ return /* @__PURE__ */ x(ce.Provider, { value: D, children: /* @__PURE__ */ z(
814
860
  "group",
815
861
  {
816
- ref: o,
862
+ ref: n,
817
863
  position: t,
818
864
  rotation: e,
819
- scale: X,
865
+ scale: O,
820
866
  children: [
821
- /* @__PURE__ */ T("primitive", { object: h }),
822
- p
867
+ /* @__PURE__ */ x("primitive", { object: y }),
868
+ f
823
869
  ]
824
870
  }
825
871
  ) });
@@ -827,135 +873,135 @@ const ue = ne(
827
873
  );
828
874
  ue.displayName = "AnimatedModel";
829
875
  ue.preload = (r) => {
830
- U.preload(r);
876
+ F.preload(r);
831
877
  };
832
- const Ie = ne(
878
+ const je = ae(
833
879
  ({
834
880
  url: r,
835
881
  position: t = [0, 0, 0],
836
882
  rotation: e = [0, 0, 0],
837
- scale: i = 1,
883
+ scale: s = 1,
838
884
  morphTargets: c,
839
- meshVisibility: d,
840
- materialColors: M,
841
- materialTextures: S,
842
- onMorphTargetsFound: f,
885
+ meshVisibility: u,
886
+ materialColors: g,
887
+ materialTextures: b,
888
+ onMorphTargetsFound: m,
843
889
  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,
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,
852
898
  c
853
- ), { setMeshVisibility: h, getMeshNames: v } = q(
854
- s,
855
- d
856
- ), { setMaterialColor: m, getMaterialNames: w, getMaterialColor: P } = J(
857
- s,
858
- M
859
- ), { setMaterialTextures: b, clearMaterialTextures: A } = Q(
860
- s,
861
- S
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
862
908
  );
863
- return k(() => {
864
- var C;
865
- const x = $();
866
- x.length > 0 && ((C = o.current) == null || C.call(o, x));
867
- }, [s, $]), k(() => {
868
- var W;
869
- if (!s) return;
870
- const x = [], C = /* @__PURE__ */ new Set(), L = [];
871
- let j = 0;
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));
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));
876
922
  }
877
- }), (W = y.current) == null || W.call(y, {
878
- meshes: x.sort(),
879
- materials: Array.from(C).sort(),
923
+ }), (D = M.current) == null || D.call(M, {
924
+ meshes: $.sort(),
925
+ materials: Array.from(I).sort(),
880
926
  bones: L.sort(),
881
- nodeCount: j
927
+ nodeCount: B
882
928
  });
883
- }, [s]), ae(u, () => ({
929
+ }, [i]), se(p, () => ({
884
930
  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,
893
- clearMaterialTextures: A
894
- })), /* @__PURE__ */ T("group", { position: t, rotation: e, scale: typeof i == "number" ? [i, i, i] : i, children: /* @__PURE__ */ T("primitive", { object: s }) });
931
+ getMorphTargetNames: w,
932
+ getMorphTargetValues: h,
933
+ setMeshVisibility: y,
934
+ getMeshNames: E,
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 }) });
895
941
  }
896
942
  );
897
- Ie.displayName = "MorphableModel";
898
- function Be({
943
+ je.displayName = "MorphableModel";
944
+ function Fe({
899
945
  children: r,
900
946
  bone: t,
901
947
  position: e = [0, 0, 0],
902
- rotation: i = [0, 0, 0],
948
+ rotation: s = [0, 0, 0],
903
949
  scale: c = 1
904
950
  }) {
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(
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(
911
957
  "group",
912
958
  {
913
959
  position: e,
914
- rotation: i,
960
+ rotation: s,
915
961
  scale: typeof c == "number" ? [c, c, c] : c,
916
962
  children: r
917
963
  }
918
964
  ),
919
- M
965
+ g
920
966
  ) : null;
921
967
  }
922
- function We(r, t) {
923
- const { scene: e, animations: i } = U(r), c = B(() => se.clone(e), [e]);
924
- return k(() => {
968
+ function Ue(r, t) {
969
+ const { scene: e, animations: s } = F(r), c = P(() => ie.clone(e), [e]);
970
+ return C(() => {
925
971
  var a;
926
972
  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;
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;
934
980
  });
935
981
  }
936
982
  }), (a = t == null ? void 0 : t.onLoad) == null || a.call(t, {
937
- meshes: M.sort(),
938
- materials: Array.from(S).sort(),
939
- bones: d.sort(),
940
- nodeCount: f
983
+ meshes: g.sort(),
984
+ materials: Array.from(b).sort(),
985
+ bones: u.sort(),
986
+ nodeCount: m
941
987
  });
942
- }, [c, t]), { scene: c, animations: i };
988
+ }, [c, t]), { scene: c, animations: s };
943
989
  }
944
- function Ue(r) {
945
- U.preload(r);
990
+ function He(r) {
991
+ F.preload(r);
946
992
  }
947
993
  export {
948
994
  ue as AnimatedModel,
949
- Be as BoneAttachment,
995
+ Fe as BoneAttachment,
950
996
  Re as Model,
951
- Ie as MorphableModel,
952
- De as Scene3D,
953
- Ue as preloadModel,
954
- ke as useAnimationController,
955
- We as useClonedModel,
956
- J as useMaterialColor,
957
- Q as useMaterialTexture,
958
- q as useMeshVisibility,
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,
959
1005
  le as useMorphTargets
960
1006
  };
961
1007
  //# sourceMappingURL=mbt-3d.js.map