mbt-3d 0.3.8 → 0.3.9

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