mbt-3d 0.3.6 → 0.3.8

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