mbt-3d 0.3.5 → 0.3.6

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