mbt-3d 0.3.5 → 0.3.7

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