@tresjs/core 3.6.0-next.0 → 3.7.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tres.js CHANGED
@@ -1,433 +1,441 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v3.6.0-next.0
3
+ * version: v3.7.0-next.0
4
4
  * (c) 2023
5
5
  * description: Declarative ThreeJS using Vue Components
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
7
  */
8
- import { ref as S, computed as k, watchEffect as D, onUnmounted as $, shallowRef as L, watch as re, reactive as pe, readonly as ve, provide as V, inject as de, createRenderer as ge, defineComponent as q, useSlots as ye, getCurrentInstance as J, onMounted as we, openBlock as Ee, createElementBlock as _e, normalizeClass as Ce, normalizeStyle as Me, h as K, Fragment as he } from "vue";
9
- import * as Pe from "three";
10
- import { PerspectiveCamera as G, OrthographicCamera as Ae, Camera as ke, Clock as be, Vector3 as De, Color as F, REVISION as Te, SRGBColorSpace as Le, ACESFilmicToneMapping as xe, PCFSoftShadowMap as Se, WebGLRenderer as I, LoadingManager as Be, TextureLoader as Oe, Vector2 as Re, Raycaster as He, BufferAttribute as Fe, Scene as je } from "three";
11
- import { createEventHook as x, useRafFn as ne, toValue as h, unrefElement as ze, useDevicePixelRatio as $e, usePointer as Ne, useElementBounding as Ie, useWindowSize as Ve, useElementSize as Ge, useFps as We, useMemory as Ue } from "@vueuse/core";
12
- const Ye = ({ sizes: e, scene: a }) => {
13
- const t = S([]), r = k(
8
+ import { ref as L, computed as D, watchEffect as k, onUnmounted as O, shallowRef as S, watch as ae, reactive as ge, readonly as ye, provide as G, inject as he, createRenderer as we, defineComponent as J, useSlots as Ee, getCurrentInstance as K, onMounted as _e, openBlock as Ce, createElementBlock as Me, normalizeClass as Pe, normalizeStyle as Ae, h as X, Fragment as be } from "vue";
9
+ import * as De from "three";
10
+ import { PerspectiveCamera as W, OrthographicCamera as ke, Camera as Te, Clock as Se, Vector3 as xe, Color as F, REVISION as Le, SRGBColorSpace as Oe, ACESFilmicToneMapping as Be, PCFSoftShadowMap as Re, WebGLRenderer as N, LoadingManager as je, TextureLoader as He, Vector2 as Fe, Raycaster as ze, BufferAttribute as $e, Scene as Ie } from "three";
11
+ import { createEventHook as x, useRafFn as ne, toValue as C, unrefElement as Ne, useDevicePixelRatio as Ve, usePointer as Ge, useElementBounding as We, useWindowSize as qe, useElementSize as Ue, useFps as Ye, useMemory as Je } from "@vueuse/core";
12
+ const Ke = ({ sizes: e, scene: n }) => {
13
+ const t = L([]), r = D(
14
14
  () => t.value[0]
15
- ), n = (s, c = !1) => {
16
- t.value.some(({ uuid: i }) => i === s.uuid) || (c ? l(s) : t.value.push(s));
17
- }, o = (s) => {
18
- t.value = t.value.filter(({ uuid: c }) => c !== s.uuid);
19
- }, l = (s) => {
20
- const c = s instanceof ke ? s : t.value.find((p) => p.uuid === s);
15
+ ), a = (l, c = !1) => {
16
+ t.value.some(({ uuid: m }) => m === l.uuid) || (c ? u(l) : t.value.push(l));
17
+ }, o = (l) => {
18
+ t.value = t.value.filter(({ uuid: c }) => c !== l.uuid);
19
+ }, u = (l) => {
20
+ const c = l instanceof Te ? l : t.value.find((h) => h.uuid === l);
21
21
  if (!c)
22
22
  return;
23
- const i = t.value.filter(({ uuid: p }) => p !== c.uuid);
24
- t.value = [c, ...i];
23
+ const m = t.value.filter(({ uuid: h }) => h !== c.uuid);
24
+ t.value = [c, ...m];
25
25
  };
26
- return D(() => {
27
- e.aspectRatio.value && t.value.forEach((s) => {
28
- s instanceof G && (s.aspect = e.aspectRatio.value), (s instanceof G || s instanceof Ae) && s.updateProjectionMatrix();
26
+ return k(() => {
27
+ e.aspectRatio.value && t.value.forEach((l) => {
28
+ l instanceof W && (l.aspect = e.aspectRatio.value), (l instanceof W || l instanceof ke) && l.updateProjectionMatrix();
29
29
  });
30
- }), a.userData.tres__registerCamera = n, a.userData.tres__deregisterCamera = o, $(() => {
30
+ }), n.userData.tres__registerCamera = a, n.userData.tres__deregisterCamera = o, O(() => {
31
31
  t.value = [];
32
32
  }), {
33
33
  camera: r,
34
34
  cameras: t,
35
- registerCamera: n,
35
+ registerCamera: a,
36
36
  deregisterCamera: o,
37
- setCameraActive: l
37
+ setCameraActive: u
38
38
  };
39
- }, ae = x(), oe = x(), U = x(), T = new be();
40
- let j = 0, z = 0;
41
- const { pause: qe, resume: Je, isActive: Ke } = ne(
39
+ }, oe = x(), se = x(), U = x(), T = new Se();
40
+ let z = 0, $ = 0;
41
+ const { pause: Xe, resume: Qe, isActive: Ze } = ne(
42
42
  () => {
43
- ae.trigger({ delta: j, elapsed: z, clock: T }), oe.trigger({ delta: j, elapsed: z, clock: T }), U.trigger({ delta: j, elapsed: z, clock: T });
43
+ oe.trigger({ delta: z, elapsed: $, clock: T }), se.trigger({ delta: z, elapsed: $, clock: T }), U.trigger({ delta: z, elapsed: $, clock: T });
44
44
  },
45
45
  { immediate: !1 }
46
46
  );
47
47
  U.on(() => {
48
- j = T.getDelta(), z = T.getElapsedTime();
48
+ z = T.getDelta(), $ = T.getElapsedTime();
49
49
  });
50
- const se = () => ({
51
- onBeforeLoop: ae.on,
52
- onLoop: oe.on,
50
+ const ie = () => ({
51
+ onBeforeLoop: oe.on,
52
+ onLoop: se.on,
53
53
  onAfterLoop: U.on,
54
- pause: qe,
55
- resume: Je,
56
- isActive: Ke
57
- }), Pt = !0, X = "[TresJS ▲ ■ ●] ";
54
+ pause: Xe,
55
+ resume: Qe,
56
+ isActive: Ze
57
+ }), bt = !0, Q = "[TresJS ▲ ■ ●] ";
58
58
  function B() {
59
- function e(r, n) {
60
- console.error(`${X} ${r}`, n || "");
59
+ function e(r, a) {
60
+ console.error(`${Q} ${r}`, a || "");
61
61
  }
62
- function a(r) {
63
- console.warn(`${X} ${r}`);
62
+ function n(r) {
63
+ console.warn(`${Q} ${r}`);
64
64
  }
65
- function t(r, n) {
65
+ function t(r, a) {
66
66
  }
67
67
  return {
68
68
  logError: e,
69
- logWarning: a,
69
+ logWarning: n,
70
70
  logMessage: t
71
71
  };
72
72
  }
73
- function At(e) {
74
- return typeof e == "number" ? [e, e, e] : e instanceof De ? [e.x, e.y, e.z] : e;
73
+ function Dt(e) {
74
+ return typeof e == "number" ? [e, e, e] : e instanceof xe ? [e.x, e.y, e.z] : e;
75
75
  }
76
- function Xe(e) {
76
+ function et(e) {
77
77
  return e instanceof F ? e : Array.isArray(e) ? new F(...e) : new F(e);
78
78
  }
79
- const ie = (e, a) => {
80
- for (const t of Object.keys(a))
81
- a[t] instanceof Object && Object.assign(a[t], ie(e[t], a[t]));
82
- return Object.assign(e || {}, a), e;
83
- }, Qe = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", Ze = /* @__PURE__ */ et(Qe);
84
- function Q(e) {
79
+ const le = (e, n) => {
80
+ for (const t of Object.keys(n))
81
+ n[t] instanceof Object && Object.assign(n[t], le(e[t], n[t]));
82
+ return Object.assign(e || {}, n), e;
83
+ }, tt = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", rt = /* @__PURE__ */ at(tt);
84
+ function Z(e) {
85
85
  return e && e.nodeType === 1;
86
86
  }
87
- function R(e) {
88
- return e.replace(/-([a-z])/g, (a, t) => t.toUpperCase());
87
+ function j(e) {
88
+ return e.replace(/-([a-z])/g, (n, t) => t.toUpperCase());
89
89
  }
90
- function et(e, a) {
90
+ function at(e, n) {
91
91
  const t = /* @__PURE__ */ Object.create(null), r = e.split(",");
92
- for (let n = 0; n < r.length; n++)
93
- t[r[n]] = !0;
94
- return a ? (n) => !!t[n.toLowerCase()] : (n) => !!t[n];
92
+ for (let a = 0; a < r.length; a++)
93
+ t[r[a]] = !0;
94
+ return n ? (a) => !!t[a.toLowerCase()] : (a) => !!t[a];
95
95
  }
96
- const tt = (e, a) => {
96
+ const nt = (e, n) => {
97
97
  const t = /* @__PURE__ */ new Set(), r = [];
98
- for (const n of e) {
99
- const o = a(n);
100
- t.has(o) || (t.add(o), r.push(n));
98
+ for (const a of e) {
99
+ const o = n(a);
100
+ t.has(o) || (t.add(o), r.push(a));
101
101
  }
102
102
  return r;
103
- }, Z = (e, a) => {
104
- if (!a)
103
+ }, ee = (e, n) => {
104
+ if (!n)
105
105
  return;
106
- const t = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
107
- return t == null ? void 0 : t.reduce((r, n) => r && r[n], e);
108
- }, rt = (e, a, t) => {
109
- const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
110
- r && r.reduce((n, o, l) => (n[o] === void 0 && (n[o] = {}), l === r.length - 1 && (n[o] = t), n[o]), e);
106
+ const t = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
107
+ return t == null ? void 0 : t.reduce((r, a) => r && r[a], e);
108
+ }, ot = (e, n, t) => {
109
+ const r = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
110
+ r && r.reduce((a, o, u) => (a[o] === void 0 && (a[o] = {}), u === r.length - 1 && (a[o] = t), a[o]), e);
111
111
  };
112
- function ue(e, a) {
113
- if (Q(e) && Q(a)) {
114
- const n = e.attributes, o = a.attributes;
115
- return n.length !== o.length ? !1 : Array.from(n).every(({ name: l, value: s }) => a.getAttribute(l) === s);
112
+ function ue(e, n) {
113
+ if (Z(e) && Z(n)) {
114
+ const a = e.attributes, o = n.attributes;
115
+ return a.length !== o.length ? !1 : Array.from(a).every(({ name: u, value: l }) => n.getAttribute(u) === l);
116
116
  }
117
- if (e === a)
117
+ if (e === n)
118
118
  return !0;
119
- if (e === null || typeof e != "object" || a === null || typeof a != "object")
119
+ if (e === null || typeof e != "object" || n === null || typeof n != "object")
120
120
  return !1;
121
- const t = Object.keys(e), r = Object.keys(a);
121
+ const t = Object.keys(e), r = Object.keys(n);
122
122
  if (t.length !== r.length)
123
123
  return !1;
124
- for (const n of t)
125
- if (!r.includes(n) || !ue(e[n], a[n]))
124
+ for (const a of t)
125
+ if (!r.includes(a) || !ue(e[a], n[a]))
126
126
  return !1;
127
127
  return !0;
128
128
  }
129
- function nt(e, a) {
130
- if (!Array.isArray(e) || !Array.isArray(a) || e.length !== a.length)
129
+ function st(e, n) {
130
+ if (!Array.isArray(e) || !Array.isArray(n) || e.length !== n.length)
131
131
  return !1;
132
132
  for (let t = 0; t < e.length; t++)
133
- if (!ue(e[t], a[t]))
133
+ if (!ue(e[t], n[t]))
134
134
  return !1;
135
135
  return !0;
136
136
  }
137
- const at = Array.isArray, ot = Number.parseInt(Te.replace("dev", "")), H = {
137
+ const it = Array.isArray;
138
+ function ce(e) {
139
+ var n, t;
140
+ e.children && e.children.forEach((r) => ce(r));
141
+ for (const r in e)
142
+ (t = (n = e[r]) == null ? void 0 : n.dispose) == null || t.call(n), delete e[r];
143
+ e.dispose && e.type !== "Scene" && e.dispose();
144
+ }
145
+ const lt = Number.parseInt(Le.replace("dev", "")), H = {
138
146
  realistic: {
139
147
  shadows: !0,
140
148
  physicallyCorrectLights: !0,
141
- outputColorSpace: Le,
142
- toneMapping: xe,
149
+ outputColorSpace: Oe,
150
+ toneMapping: Be,
143
151
  toneMappingExposure: 3,
144
152
  shadowMap: {
145
153
  enabled: !0,
146
- type: Se
154
+ type: Re
147
155
  }
148
156
  }
149
157
  };
150
- function st({
158
+ function ut({
151
159
  scene: e,
152
- canvas: a,
160
+ canvas: n,
153
161
  options: t,
154
162
  disableRender: r,
155
- contextParts: { sizes: n, camera: o }
163
+ contextParts: { sizes: a, camera: o }
156
164
  }) {
157
- const l = k(() => ({
158
- alpha: h(t.alpha),
159
- depth: h(t.depth),
160
- canvas: ze(a),
161
- context: h(t.context),
162
- stencil: h(t.stencil),
163
- antialias: h(t.antialias) === void 0 ? !0 : h(t.antialias),
164
- precision: h(t.precision),
165
- powerPreference: h(t.powerPreference),
166
- premultipliedAlpha: h(t.premultipliedAlpha),
167
- preserveDrawingBuffer: h(t.preserveDrawingBuffer),
168
- logarithmicDepthBuffer: h(t.logarithmicDepthBuffer),
169
- failIfMajorPerformanceCaveat: h(t.failIfMajorPerformanceCaveat)
170
- })), s = L(new I(l.value));
171
- re(l, () => {
172
- s.value.dispose(), s.value = new I(l.value);
173
- }), D(() => {
174
- s.value.setSize(n.width.value, n.height.value);
165
+ const u = D(() => ({
166
+ alpha: C(t.alpha),
167
+ depth: C(t.depth),
168
+ canvas: Ne(n),
169
+ context: C(t.context),
170
+ stencil: C(t.stencil),
171
+ antialias: C(t.antialias) === void 0 ? !0 : C(t.antialias),
172
+ precision: C(t.precision),
173
+ powerPreference: C(t.powerPreference),
174
+ premultipliedAlpha: C(t.premultipliedAlpha),
175
+ preserveDrawingBuffer: C(t.preserveDrawingBuffer),
176
+ logarithmicDepthBuffer: C(t.logarithmicDepthBuffer),
177
+ failIfMajorPerformanceCaveat: C(t.failIfMajorPerformanceCaveat)
178
+ })), l = S(new N(u.value));
179
+ ae(u, () => {
180
+ l.value.dispose(), l.value = new N(u.value);
181
+ }), k(() => {
182
+ l.value.setSize(a.width.value, a.height.value);
175
183
  });
176
- const { pixelRatio: c } = $e();
177
- D(() => {
178
- s.value.setPixelRatio(c.value);
184
+ const { pixelRatio: c } = Ve();
185
+ k(() => {
186
+ l.value.setPixelRatio(c.value);
179
187
  });
180
- const { logError: i } = B(), f = (() => {
181
- const d = new I(), C = {
188
+ const { logError: m } = B(), i = (() => {
189
+ const p = new N(), w = {
182
190
  shadowMap: {
183
- enabled: d.shadowMap.enabled,
184
- type: d.shadowMap.type
191
+ enabled: p.shadowMap.enabled,
192
+ type: p.shadowMap.type
185
193
  },
186
- toneMapping: d.toneMapping,
187
- toneMappingExposure: d.toneMappingExposure,
188
- outputColorSpace: d.outputColorSpace
194
+ toneMapping: p.toneMapping,
195
+ toneMappingExposure: p.toneMappingExposure,
196
+ outputColorSpace: p.outputColorSpace
189
197
  };
190
- return d.dispose(), C;
198
+ return p.dispose(), w;
191
199
  })();
192
- D(() => {
193
- const d = h(t.preset);
194
- d && (d in H || i(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), ie(s.value, H[d]));
195
- const C = (E, _) => {
196
- const A = h(E), b = () => {
197
- if (d)
198
- return Z(H[d], _);
200
+ k(() => {
201
+ const p = C(t.preset);
202
+ p && (p in H || m(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), le(l.value, H[p]));
203
+ const w = (P, A) => {
204
+ const E = C(P), b = () => {
205
+ if (p)
206
+ return ee(H[p], A);
199
207
  };
200
- if (A !== void 0)
201
- return A;
208
+ if (E !== void 0)
209
+ return E;
202
210
  const g = b();
203
- return g !== void 0 ? g : Z(f, _);
204
- }, w = (E, _) => rt(s.value, _, C(E, _));
205
- w(t.shadows, "shadowMap.enabled"), w(t.toneMapping, "toneMapping"), w(t.shadowMapType, "shadowMap.type"), ot < 150 && w(!t.useLegacyLights, "physicallyCorrectLights"), w(t.outputColorSpace, "outputColorSpace"), w(t.toneMappingExposure, "toneMappingExposure");
206
- const P = C(t.clearColor, "clearColor");
207
- P && s.value.setClearColor(
208
- P ? Xe(P) : new F(0)
211
+ return g !== void 0 ? g : ee(i, A);
212
+ }, v = (P, A) => ot(l.value, A, w(P, A));
213
+ v(t.shadows, "shadowMap.enabled"), v(t.toneMapping, "toneMapping"), v(t.shadowMapType, "shadowMap.type"), lt < 150 && v(!t.useLegacyLights, "physicallyCorrectLights"), v(t.outputColorSpace, "outputColorSpace"), v(t.toneMappingExposure, "toneMappingExposure");
214
+ const M = w(t.clearColor, "clearColor");
215
+ M && l.value.setClearColor(
216
+ M ? et(M) : new F(0)
209
217
  // default clear color is not easily/efficiently retrievable from three
210
218
  );
211
219
  });
212
- const { pause: u, resume: m, onLoop: v } = se();
213
- return v(() => {
214
- o.value && !h(r) && s.value.render(e, o.value);
215
- }), m(), $(() => {
216
- u(), s.value.dispose(), s.value.forceContextLoss();
220
+ const { pause: s, resume: f, onLoop: d } = ie();
221
+ return d(() => {
222
+ o.value && !C(r) && l.value.render(e, o.value);
223
+ }), f(), O(() => {
224
+ s(), l.value.dispose(), l.value.forceContextLoss();
217
225
  }), {
218
- renderer: s
226
+ renderer: l
219
227
  };
220
228
  }
221
- const ee = (e) => typeof e == "function", it = (e) => !!e && e.constructor === Array;
222
- function ut(e) {
223
- const a = { nodes: {}, materials: {} };
229
+ const te = (e) => typeof e == "function", ct = (e) => !!e && e.constructor === Array;
230
+ function ft(e) {
231
+ const n = { nodes: {}, materials: {} };
224
232
  return e && e.traverse((t) => {
225
- t.name && (a.nodes[t.name] = t), t.material && !a.materials[t.material.name] && (a.materials[t.material.name] = t.material);
226
- }), a;
233
+ t.name && (n.nodes[t.name] = t), t.material && !n.materials[t.material.name] && (n.materials[t.material.name] = t.material);
234
+ }), n;
227
235
  }
228
- async function kt(e, a, t, r, n) {
229
- const { logError: o } = B(), l = new e();
230
- n && n(l), t && t(l);
231
- const c = (Array.isArray(a) ? a : [a]).map(
232
- (i) => new Promise((p, f) => {
233
- l.load(
234
- i,
235
- (u) => {
236
- u.scene && Object.assign(u, ut(u.scene)), p(u);
236
+ async function kt(e, n, t, r, a) {
237
+ const { logError: o } = B(), u = new e();
238
+ a && a(u), t && t(u);
239
+ const c = (Array.isArray(n) ? n : [n]).map(
240
+ (m) => new Promise((h, i) => {
241
+ u.load(
242
+ m,
243
+ (s) => {
244
+ s.scene && Object.assign(s, ft(s.scene)), h(s);
237
245
  },
238
246
  r,
239
- (u) => f(o("[useLoader] - Failed to load resource", u))
247
+ (s) => i(o("[useLoader] - Failed to load resource", s))
240
248
  );
241
249
  })
242
250
  );
243
- return it(a) ? await Promise.all(c) : await c[0];
251
+ return ct(n) ? await Promise.all(c) : await c[0];
244
252
  }
245
- async function bt(e) {
246
- const a = new Be(), t = new Oe(a), r = (n) => new Promise((o, l) => {
253
+ async function Tt(e) {
254
+ const n = new je(), t = new He(n), r = (a) => new Promise((o, u) => {
247
255
  t.load(
248
- n,
249
- (s) => o(s),
256
+ a,
257
+ (l) => o(l),
250
258
  () => null,
251
259
  () => {
252
- l(new Error("[useTextures] - Failed to load texture"));
260
+ u(new Error("[useTextures] - Failed to load texture"));
253
261
  }
254
262
  );
255
263
  });
256
- if (at(e)) {
257
- const n = await Promise.all(e.map((o) => r(o)));
258
- return e.length > 1 ? n : n[0];
264
+ if (it(e)) {
265
+ const a = await Promise.all(e.map((o) => r(o)));
266
+ return e.length > 1 ? a : a[0];
259
267
  } else {
260
268
  const {
261
- map: n,
269
+ map: a,
262
270
  displacementMap: o,
263
- normalMap: l,
264
- roughnessMap: s,
271
+ normalMap: u,
272
+ roughnessMap: l,
265
273
  metalnessMap: c,
266
- aoMap: i,
267
- alphaMap: p,
268
- matcap: f
274
+ aoMap: m,
275
+ alphaMap: h,
276
+ matcap: i
269
277
  } = e;
270
278
  return {
271
- map: n ? await r(n) : null,
279
+ map: a ? await r(a) : null,
272
280
  displacementMap: o ? await r(o) : null,
273
- normalMap: l ? await r(l) : null,
274
- roughnessMap: s ? await r(s) : null,
281
+ normalMap: u ? await r(u) : null,
282
+ roughnessMap: l ? await r(l) : null,
275
283
  metalnessMap: c ? await r(c) : null,
276
- aoMap: i ? await r(i) : null,
277
- alphaMap: p ? await r(p) : null,
278
- matcap: f ? await r(f) : null
284
+ aoMap: m ? await r(m) : null,
285
+ alphaMap: h ? await r(h) : null,
286
+ matcap: i ? await r(i) : null
279
287
  };
280
288
  }
281
289
  }
282
- const lt = (e, { renderer: a, camera: t, raycaster: r }) => {
283
- const n = k(() => a.value.domElement), { x: o, y: l } = Ne({ target: n }), { width: s, height: c, top: i, left: p } = Ie(n), f = ({ x: g, y: M }) => {
284
- if (n.value)
290
+ const mt = (e, { renderer: n, camera: t, raycaster: r }) => {
291
+ const a = D(() => n.value.domElement), { x: o, y: u } = Ge({ target: a }), { width: l, height: c, top: m, left: h } = We(a), i = ({ x: g, y: _ }) => {
292
+ if (a.value)
285
293
  return {
286
- x: (g - p.value) / s.value * 2 - 1,
287
- y: -((M - i.value) / c.value) * 2 + 1
294
+ x: (g - h.value) / l.value * 2 - 1,
295
+ y: -((_ - m.value) / c.value) * 2 + 1
288
296
  };
289
- }, u = ({ x: g, y: M }) => {
297
+ }, s = ({ x: g, y: _ }) => {
290
298
  if (t.value)
291
- return r.value.setFromCamera(new Re(g, M), t.value), r.value.intersectObjects(e.value, !1);
292
- }, m = (g) => {
293
- const M = f({
299
+ return r.value.setFromCamera(new Fe(g, _), t.value), r.value.intersectObjects(e.value, !1);
300
+ }, f = (g) => {
301
+ const _ = i({
294
302
  x: (g == null ? void 0 : g.clientX) ?? o.value,
295
- y: (g == null ? void 0 : g.clientY) ?? l.value
303
+ y: (g == null ? void 0 : g.clientY) ?? u.value
296
304
  });
297
- return M ? u(M) || [] : [];
298
- }, v = k(() => m()), d = x(), C = x(), w = (g, M) => {
299
- g.trigger({ event: M, intersects: m(M) });
300
- }, P = (g) => {
301
- w(C, g);
305
+ return _ ? s(_) || [] : [];
306
+ }, d = D(() => f()), p = x(), w = x(), v = (g, _) => {
307
+ g.trigger({ event: _, intersects: f(_) });
308
+ }, M = (g) => {
309
+ v(w, g);
302
310
  };
303
- let E;
304
- const _ = (g) => {
305
- var M;
306
- E = (M = m(g)[0]) == null ? void 0 : M.object;
307
- }, A = (g) => {
308
- var M;
309
- g instanceof PointerEvent && E === ((M = m(g)[0]) == null ? void 0 : M.object) && w(d, g);
310
- }, b = (g) => C.trigger({ event: g, intersects: [] });
311
- return n.value.addEventListener("pointerup", A), n.value.addEventListener("pointerdown", _), n.value.addEventListener("pointermove", P), n.value.addEventListener("pointerleave", b), $(() => {
312
- n != null && n.value && (n.value.removeEventListener("pointerup", A), n.value.removeEventListener("pointerdown", _), n.value.removeEventListener("pointermove", P), n.value.removeEventListener("pointerleave", b));
311
+ let P;
312
+ const A = (g) => {
313
+ var _;
314
+ P = (_ = f(g)[0]) == null ? void 0 : _.object;
315
+ }, E = (g) => {
316
+ var _;
317
+ g instanceof PointerEvent && P === ((_ = f(g)[0]) == null ? void 0 : _.object) && v(p, g);
318
+ }, b = (g) => w.trigger({ event: g, intersects: [] });
319
+ return a.value.addEventListener("pointerup", E), a.value.addEventListener("pointerdown", A), a.value.addEventListener("pointermove", M), a.value.addEventListener("pointerleave", b), O(() => {
320
+ a != null && a.value && (a.value.removeEventListener("pointerup", E), a.value.removeEventListener("pointerdown", A), a.value.removeEventListener("pointermove", M), a.value.removeEventListener("pointerleave", b));
313
321
  }), {
314
- intersects: v,
315
- onClick: (g) => d.on(g).off,
316
- onPointerMove: (g) => C.on(g).off
322
+ intersects: d,
323
+ onClick: (g) => p.on(g).off,
324
+ onPointerMove: (g) => w.on(g).off
317
325
  };
318
326
  };
319
- function Dt() {
327
+ function St() {
320
328
  const { logWarning: e } = B();
321
- function a(o, l, s) {
329
+ function n(o, u, l) {
322
330
  let c = null;
323
- return o.traverse((i) => {
324
- i[l] === s && (c = i);
325
- }), c || e(`Child with ${l} '${s}' not found.`), c;
331
+ return o.traverse((m) => {
332
+ m[u] === l && (c = m);
333
+ }), c || e(`Child with ${u} '${l}' not found.`), c;
326
334
  }
327
- function t(o, l, s) {
335
+ function t(o, u, l) {
328
336
  const c = [];
329
- return o.traverse((i) => {
330
- i[l].includes(s) && c.push(i);
331
- }), c.length || e(`Children with ${l} '${s}' not found.`), c;
337
+ return o.traverse((m) => {
338
+ m[u].includes(l) && c.push(m);
339
+ }), c.length || e(`Children with ${u} '${l}' not found.`), c;
332
340
  }
333
- function r(o, l) {
334
- return a(o, "name", l);
341
+ function r(o, u) {
342
+ return n(o, "name", u);
335
343
  }
336
- function n(o, l) {
337
- return t(o, "name", l);
344
+ function a(o, u) {
345
+ return t(o, "name", u);
338
346
  }
339
347
  return {
340
- seek: a,
348
+ seek: n,
341
349
  seekByName: r,
342
350
  seekAll: t,
343
- seekAllByName: n
351
+ seekAllByName: a
344
352
  };
345
353
  }
346
- const ct = ({ scene: e, contextParts: a }) => {
347
- const t = pe({
354
+ const pt = ({ scene: e, contextParts: n }) => {
355
+ const t = ge({
348
356
  click: /* @__PURE__ */ new Map(),
349
357
  pointerMove: /* @__PURE__ */ new Map(),
350
358
  pointerEnter: /* @__PURE__ */ new Map(),
351
359
  pointerLeave: /* @__PURE__ */ new Map()
352
- }), r = S(/* @__PURE__ */ new Set()), n = (u) => {
353
- r.value.add(u);
354
- }, o = (u) => {
355
- r.value.delete(u);
356
- }, l = (u) => {
357
- Object.values(t).forEach((m) => m.delete(u)), o(u);
358
- }, s = (u) => {
359
- const { onClick: m, onPointerMove: v, onPointerEnter: d, onPointerLeave: C } = u;
360
- m && t.click.set(u, m), v && t.pointerMove.set(u, v), d && t.pointerEnter.set(u, d), C && t.pointerLeave.set(u, C);
360
+ }), r = L(/* @__PURE__ */ new Set()), a = (s) => {
361
+ r.value.add(s);
362
+ }, o = (s) => {
363
+ r.value.delete(s);
364
+ }, u = (s) => {
365
+ Object.values(t).forEach((f) => f.delete(s)), o(s);
366
+ }, l = (s) => {
367
+ const { onClick: f, onPointerMove: d, onPointerEnter: p, onPointerLeave: w } = s;
368
+ f && t.click.set(s, f), d && t.pointerMove.set(s, d), p && t.pointerEnter.set(s, p), w && t.pointerLeave.set(s, w);
361
369
  };
362
- e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = l, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
363
- const c = k(
364
- () => tt(
370
+ e.userData.tres__registerAtPointerEventHandler = l, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = a, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
371
+ const c = D(
372
+ () => nt(
365
373
  [
366
374
  ...Array.from(r.value),
367
- ...Object.values(t).map((u) => Array.from(u.keys())).flat()
375
+ ...Object.values(t).map((s) => Array.from(s.keys())).flat()
368
376
  ],
369
- ({ uuid: u }) => u
377
+ ({ uuid: s }) => s
370
378
  )
371
- ), { onClick: i, onPointerMove: p } = lt(c, a);
372
- i(({ intersects: u, event: m }) => {
373
- var v;
374
- u.length && ((v = t.click.get(u[0].object)) == null || v(u[0], m));
379
+ ), { onClick: m, onPointerMove: h } = mt(c, n);
380
+ m(({ intersects: s, event: f }) => {
381
+ var d;
382
+ s.length && ((d = t.click.get(s[0].object)) == null || d(s[0], f));
375
383
  });
376
- let f;
377
- return p(({ intersects: u, event: m }) => {
378
- var P, E, _, A;
379
- const v = (P = u == null ? void 0 : u[0]) == null ? void 0 : P.object, { pointerLeave: d, pointerEnter: C, pointerMove: w } = t;
380
- f && f !== v && ((E = d.get(f)) == null || E(f, m)), v && (f !== v && ((_ = C.get(v)) == null || _(u[0], m)), (A = w.get(v)) == null || A(u[0], m)), f = v || null;
384
+ let i;
385
+ return h(({ intersects: s, event: f }) => {
386
+ var M, P, A, E;
387
+ const d = (M = s == null ? void 0 : s[0]) == null ? void 0 : M.object, { pointerLeave: p, pointerEnter: w, pointerMove: v } = t;
388
+ i && i !== d && ((P = p.get(i)) == null || P(i, f)), d && (i !== d && ((A = w.get(d)) == null || A(s[0], f)), (E = v.get(d)) == null || E(s[0], f)), i = d || null;
381
389
  }), {
382
- registerObject: s,
383
- deregisterObject: l
390
+ registerObject: l,
391
+ deregisterObject: u
384
392
  };
385
393
  };
386
- function ft(e) {
387
- let a = 0;
394
+ function dt(e) {
395
+ let n = 0;
388
396
  return e.traverse((t) => {
389
397
  if (t.isMesh && t.geometry) {
390
- const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, l = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = n + o + l + s;
391
- a += c;
398
+ const r = t.geometry, a = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, u = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, l = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = a + o + u + l;
399
+ n += c;
392
400
  }
393
- }), a;
401
+ }), n;
394
402
  }
395
- const W = S({}), Y = (e) => Object.assign(W.value, e);
396
- function mt({
403
+ const q = L({}), Y = (e) => Object.assign(q.value, e);
404
+ function vt({
397
405
  scene: e,
398
- canvas: a,
406
+ canvas: n,
399
407
  windowSize: t,
400
408
  disableRender: r,
401
- rendererOptions: n
409
+ rendererOptions: a
402
410
  }) {
403
- const o = k(
404
- () => h(t) ? Ve() : Ge(h(a).parentElement)
405
- ), l = k(() => o.value.width.value), s = k(() => o.value.height.value), c = k(() => l.value / s.value), i = {
406
- height: s,
407
- width: l,
411
+ const o = D(
412
+ () => C(t) ? qe() : Ue(C(n).parentElement)
413
+ ), u = D(() => o.value.width.value), l = D(() => o.value.height.value), c = D(() => u.value / l.value), m = {
414
+ height: l,
415
+ width: u,
408
416
  aspectRatio: c
409
- }, p = L(e), {
410
- camera: f,
411
- cameras: u,
412
- registerCamera: m,
413
- deregisterCamera: v,
414
- setCameraActive: d
415
- } = Ye({ sizes: i, scene: e }), { renderer: C } = st(
417
+ }, h = S(e), {
418
+ camera: i,
419
+ cameras: s,
420
+ registerCamera: f,
421
+ deregisterCamera: d,
422
+ setCameraActive: p
423
+ } = Ke({ sizes: m, scene: e }), { renderer: w } = ut(
416
424
  {
417
425
  scene: e,
418
- canvas: a,
419
- options: n,
420
- contextParts: { sizes: i, camera: f },
426
+ canvas: n,
427
+ options: a,
428
+ contextParts: { sizes: m, camera: i },
421
429
  disableRender: r
422
430
  }
423
- ), w = {
424
- sizes: i,
425
- scene: p,
426
- camera: f,
427
- cameras: ve(u),
428
- renderer: C,
429
- raycaster: L(new He()),
430
- controls: S(null),
431
+ ), v = {
432
+ sizes: m,
433
+ scene: h,
434
+ camera: i,
435
+ cameras: ye(s),
436
+ renderer: w,
437
+ raycaster: S(new ze()),
438
+ controls: L(null),
431
439
  perf: {
432
440
  maxFrames: 160,
433
441
  fps: {
@@ -441,130 +449,135 @@ function mt({
441
449
  }
442
450
  },
443
451
  extend: Y,
444
- registerCamera: m,
445
- setCameraActive: d,
446
- deregisterCamera: v
452
+ registerCamera: f,
453
+ setCameraActive: p,
454
+ deregisterCamera: d
447
455
  };
448
- V("useTres", w);
449
- const P = 100, E = We({ every: P }), { isSupported: _, memory: A } = Ue({ interval: P }), b = 160;
456
+ G("useTres", v);
457
+ const M = 100, P = Ye({ every: M }), { isSupported: A, memory: E } = Je({ interval: M }), b = 160;
450
458
  let g = performance.now();
451
- const M = ({ timestamp: O }) => {
452
- w.scene.value && (w.perf.memory.allocatedMem = ft(w.scene.value)), O - g >= P && (g = O, w.perf.fps.accumulator.push(E.value), w.perf.fps.accumulator.length > b && w.perf.fps.accumulator.shift(), w.perf.fps.value = E.value, _.value && A.value && (w.perf.memory.accumulator.push(A.value.usedJSHeapSize / 1024 / 1024), w.perf.memory.accumulator.length > b && w.perf.memory.accumulator.shift(), w.perf.memory.currentMem = w.perf.memory.accumulator.reduce((fe, me) => fe + me, 0) / w.perf.memory.accumulator.length));
459
+ const _ = ({ timestamp: R }) => {
460
+ v.scene.value && (v.perf.memory.allocatedMem = dt(v.scene.value)), R - g >= M && (g = R, v.perf.fps.accumulator.push(P.value), v.perf.fps.accumulator.length > b && v.perf.fps.accumulator.shift(), v.perf.fps.value = P.value, A.value && E.value && (v.perf.memory.accumulator.push(E.value.usedJSHeapSize / 1024 / 1024), v.perf.memory.accumulator.length > b && v.perf.memory.accumulator.shift(), v.perf.memory.currentMem = v.perf.memory.accumulator.reduce((de, ve) => de + ve, 0) / v.perf.memory.accumulator.length));
453
461
  };
454
- let N = 0;
455
- const le = 1, { pause: ce, resume: _t } = ne(({ delta: O }) => {
456
- window.__TRES__DEVTOOLS__ && (M({ timestamp: performance.now() }), N += O, N >= le && (window.__TRES__DEVTOOLS__.cb(w), N = 0));
462
+ let I = 0;
463
+ const me = 1, { pause: pe, resume: Ct } = ne(({ delta: R }) => {
464
+ window.__TRES__DEVTOOLS__ && (_({ timestamp: performance.now() }), I += R, I >= me && (window.__TRES__DEVTOOLS__.cb(v), I = 0));
457
465
  }, { immediate: !0 });
458
- return $(() => {
459
- ce();
460
- }), w;
466
+ return O(() => {
467
+ pe();
468
+ }), v;
461
469
  }
462
- function pt() {
463
- const e = de("useTres");
470
+ function gt() {
471
+ const e = he("useTres");
464
472
  if (!e)
465
473
  throw new Error("useTresContext must be used together with useTresContextProvider");
466
474
  return e;
467
475
  }
468
- const Tt = pt;
476
+ const xt = gt;
469
477
  let y = null;
470
- const { logError: te } = B(), vt = {
471
- createElement(e, a, t, r) {
472
- var l, s;
473
- if (r || (r = {}), r.args || (r.args = []), e === "template" || Ze(e))
478
+ const { logError: re } = B(), V = [
479
+ "onClick",
480
+ "onPointerMove",
481
+ "onPointerEnter",
482
+ "onPointerLeave"
483
+ ], fe = {
484
+ createElement(e, n, t, r) {
485
+ var u, l;
486
+ if (r || (r = {}), r.args || (r.args = []), e === "template" || rt(e))
474
487
  return null;
475
- let n = e.replace("Tres", ""), o;
488
+ let a = e.replace("Tres", ""), o;
476
489
  if (e === "primitive") {
477
- (r == null ? void 0 : r.object) === void 0 && te("Tres primitives need a prop 'object'");
490
+ (r == null ? void 0 : r.object) === void 0 && re("Tres primitives need a prop 'object'");
478
491
  const c = r.object;
479
- n = c.type, o = Object.assign(c, { type: n, attach: r.attach, primitive: !0 });
492
+ a = c.type, o = Object.assign(c, { type: a, attach: r.attach, primitive: !0 });
480
493
  } else {
481
- const c = W.value[n];
482
- c || te(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new c(...r.args);
494
+ const c = q.value[a];
495
+ c || re(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new c(...r.args);
483
496
  }
484
- return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((l = r == null ? void 0 : r.material) != null && l.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
497
+ return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((u = r == null ? void 0 : r.material) != null && u.isMaterial && (o.userData.tres__materialViaProp = !0), (l = r == null ? void 0 : r.geometry) != null && l.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
485
498
  ...o.userData,
486
- tres__name: n
499
+ tres__name: a
487
500
  }, o;
488
501
  },
489
- insert(e, a) {
490
- var r, n, o, l;
491
- a && a.isScene && (y = a);
492
- const t = a || y;
502
+ insert(e, n) {
503
+ var r, a, o, u;
504
+ n && n.isScene && (y = n);
505
+ const t = n || y;
493
506
  if (e != null && e.isObject3D) {
494
507
  if (e != null && e.isCamera) {
495
508
  if (!(y != null && y.userData.tres__registerCamera))
496
509
  throw "could not find tres__registerCamera on scene's userData";
497
- (n = y == null ? void 0 : (r = y.userData).tres__registerCamera) == null || n.call(r, e);
510
+ (a = y == null ? void 0 : (r = y.userData).tres__registerCamera) == null || a.call(r, e);
498
511
  }
499
- if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) {
512
+ if (e && V.some((l) => e[l])) {
500
513
  if (!(y != null && y.userData.tres__registerAtPointerEventHandler))
501
514
  throw "could not find tres__registerAtPointerEventHandler on scene's userData";
502
- (l = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || l.call(o, e);
515
+ (u = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
503
516
  }
504
517
  }
505
518
  e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? t.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
506
519
  },
507
520
  remove(e) {
508
- var a, t;
509
- if (e) {
510
- if (e.isObject3D) {
511
- const r = e, n = (i) => {
512
- var f, u;
513
- const p = i;
514
- i.userData.tres__materialViaProp || (f = p.material) == null || f.dispose(), i.userData.tres__geometryViaProp || (u = p.geometry) == null || u.dispose();
515
- }, o = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, l = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => {
516
- var p, f;
517
- if (!l)
518
- throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
519
- if ((f = y == null ? void 0 : (p = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(p, i), !o)
520
- throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
521
- (i != null && i.onClick || i != null && i.onPointerMove || i != null && i.onPointerEnter || i != null && i.onPointerLeave) && (o == null || o(i));
522
- }, c = (i) => {
523
- const p = y == null ? void 0 : y.userData.tres__deregisterCamera;
524
- if (!p)
525
- throw "could not find tres__deregisterCamera on scene's userData";
526
- i.isCamera && (p == null || p(i));
527
- };
528
- r.traverse((i) => {
529
- n(i), c(i), s == null || s(i);
530
- }), n(r), c(r), s == null || s(r);
531
- }
532
- (a = e.removeFromParent) == null || a.call(e), (t = e.dispose) == null || t.call(e);
521
+ var c, m, h;
522
+ if (!e)
523
+ return;
524
+ const n = (i) => {
525
+ var f, d;
526
+ const s = i;
527
+ i.userData.tres__materialViaProp || ((f = s.material) == null || f.dispose(), delete s.material), i.userData.tres__geometryViaProp || ((d = s.geometry) == null || d.dispose(), delete s.geometry);
528
+ }, t = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, r = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, a = (i) => {
529
+ var s, f;
530
+ if (!r)
531
+ throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
532
+ if ((f = y == null ? void 0 : (s = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(s, i), !t)
533
+ throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
534
+ i && V.some((d) => i[d]) && (t == null || t(i));
535
+ }, o = (i) => {
536
+ const s = y == null ? void 0 : y.userData.tres__deregisterCamera;
537
+ if (!s)
538
+ throw "could not find tres__deregisterCamera on scene's userData";
539
+ i.isCamera && (s == null || s(i));
540
+ }, u = e == null ? void 0 : e.primitive, l = !u && (e.dispose === void 0 ? e.dispose !== null : !1);
541
+ if (e != null && e.isObject3D && ((c = e.parent) != null && c.isObject3D) && (e.parent.remove(e), (m = e.removeFromParent) == null || m.call(e)), !u && (e != null && e.isObject3D)) {
542
+ e.children.forEach((i) => fe.remove(i)), n(e), o(e), a == null || a(e);
543
+ for (const i in e)
544
+ i !== "geometry" && i !== "material" && ((h = i.dispose) == null || h.call(i), delete e[i]);
533
545
  }
546
+ l && e.dispose && e.type !== "Scene" && e.dispose();
534
547
  },
535
- patchProp(e, a, t, r) {
536
- var n, o, l, s;
548
+ patchProp(e, n, t, r) {
549
+ var a, o, u, l;
537
550
  if (e) {
538
- let c = e, i = a;
539
- if (e.isObject3D && i === "blocks-pointer-events") {
540
- r || r === "" ? (o = y == null ? void 0 : (n = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = y == null ? void 0 : (l = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(l, e);
551
+ let c = e, m = n;
552
+ if (e.isObject3D && m === "blocks-pointer-events") {
553
+ r || r === "" ? (o = y == null ? void 0 : (a = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(a, e) : (l = y == null ? void 0 : (u = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || l.call(u, e);
541
554
  return;
542
555
  }
543
- let p = R(i), f = c == null ? void 0 : c[p];
544
- if (i === "args") {
545
- const m = e, v = t ?? [], d = r ?? [], C = e.userData.tres__name || e.type;
546
- C && v.length && !nt(v, d) && (c = Object.assign(m, new W.value[C](...r)));
556
+ let h = j(m), i = c == null ? void 0 : c[h];
557
+ if (m === "args") {
558
+ const f = e, d = t ?? [], p = r ?? [], w = e.userData.tres__name || e.type;
559
+ w && d.length && !st(d, p) && (c = Object.assign(f, new q.value[w](...r)));
547
560
  return;
548
561
  }
549
562
  if (c.type === "BufferGeometry") {
550
- if (i === "args")
563
+ if (m === "args")
551
564
  return;
552
565
  c.setAttribute(
553
- R(i),
554
- new Fe(...r)
566
+ j(m),
567
+ new $e(...r)
555
568
  );
556
569
  return;
557
570
  }
558
- if (i.includes("-") && f === void 0) {
559
- const m = i.split("-");
560
- f = m.reduce((v, d) => v[R(d)], c), i = m.pop(), p = i.toLowerCase(), f != null && f.set || (c = m.reduce((v, d) => v[R(d)], c));
571
+ if (m.includes("-") && i === void 0) {
572
+ const f = m.split("-");
573
+ i = f.reduce((d, p) => d[j(p)], c), m = f.pop(), h = m.toLowerCase(), i != null && i.set || (c = f.reduce((d, p) => d[j(p)], c));
561
574
  }
562
- let u = r;
563
- if (u === "" && (u = !0), ee(f)) {
564
- Array.isArray(u) ? e[p](...u) : e[p](u);
575
+ let s = r;
576
+ if (s === "" && (s = !0), te(i)) {
577
+ V.includes(n) || (Array.isArray(s) ? e[h](...s) : e[h](s));
565
578
  return;
566
579
  }
567
- !(f != null && f.set) && !ee(f) ? c[p] = u : f.constructor === u.constructor && (f != null && f.copy) ? f == null || f.copy(u) : Array.isArray(u) ? f.set(...u) : !f.isColor && f.setScalar ? f.setScalar(u) : f.set(u);
580
+ !(i != null && i.set) && !te(i) ? c[h] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
568
581
  }
569
582
  },
570
583
  parentNode(e) {
@@ -579,9 +592,9 @@ const { logError: te } = B(), vt = {
579
592
  setScopeId: () => void 0,
580
593
  cloneNode: () => void 0,
581
594
  insertStaticContent: () => void 0
582
- }, { render: dt } = ge(vt);
583
- Y(Pe);
584
- const gt = ["data-scene"], yt = /* @__PURE__ */ q({
595
+ }, { render: yt } = we(fe);
596
+ Y(De);
597
+ const ht = ["data-scene"], wt = /* @__PURE__ */ J({
585
598
  __name: "TresCanvas",
586
599
  props: {
587
600
  shadows: { type: Boolean, default: void 0 },
@@ -607,107 +620,113 @@ const gt = ["data-scene"], yt = /* @__PURE__ */ q({
607
620
  logarithmicDepthBuffer: { type: Boolean, default: void 0 },
608
621
  failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
609
622
  },
610
- setup(e, { expose: a }) {
611
- var u;
612
- const t = e, { logWarning: r } = B(), n = S(), o = L(new je());
613
- se();
614
- const l = ye(), s = (u = J()) == null ? void 0 : u.appContext.app, c = (m) => q({
623
+ setup(e, { expose: n }) {
624
+ var d;
625
+ const t = e, { logWarning: r } = B(), a = L(), o = S(new Ie());
626
+ ie();
627
+ const u = Ee(), l = (d = K()) == null ? void 0 : d.appContext.app;
628
+ let c = null;
629
+ const m = (p) => J({
615
630
  setup() {
616
- var d;
617
- const v = (d = J()) == null ? void 0 : d.appContext;
618
- return v && (v.app = s), V("useTres", m), V("extend", Y), () => K(he, null, l != null && l.default ? l.default() : []);
631
+ var v;
632
+ const w = (v = K()) == null ? void 0 : v.appContext;
633
+ return w && (w.app = l), G("useTres", p), G("extend", Y), () => X(be, null, u != null && u.default ? u.default() : []);
619
634
  }
620
- }), i = (m) => {
621
- const v = c(m);
622
- dt(K(v), o.value);
623
- }, p = k(() => t.disableRender), f = L(null);
624
- return a({ context: f }), we(() => {
625
- const m = n;
626
- f.value = mt({
635
+ }), h = (p) => {
636
+ c = m(p), yt(X(c), o.value);
637
+ }, i = (p) => {
638
+ ce(o.value), o.value = null;
639
+ }, s = D(() => t.disableRender), f = S(null);
640
+ return n({ context: f, dispose: () => i(f.value) }), _e(() => {
641
+ const p = a;
642
+ f.value = vt({
627
643
  scene: o.value,
628
- canvas: m,
644
+ canvas: p,
629
645
  windowSize: t.windowSize,
630
- disableRender: p,
646
+ disableRender: s,
631
647
  rendererOptions: t
632
- }), ct({ scene: o.value, contextParts: f.value });
633
- const { registerCamera: v, camera: d, cameras: C, deregisterCamera: w } = f.value;
634
- i(f.value);
635
- const P = () => {
636
- const E = new G(
648
+ }), pt({ scene: o.value, contextParts: f.value });
649
+ const { registerCamera: w, camera: v, cameras: M, deregisterCamera: P } = f.value;
650
+ h(f.value);
651
+ const A = () => {
652
+ const E = new W(
637
653
  45,
638
654
  window.innerWidth / window.innerHeight,
639
655
  0.1,
640
656
  1e3
641
657
  );
642
- E.position.set(3, 3, 3), E.lookAt(0, 0, 0), v(E);
643
- const _ = D(() => {
644
- C.value.length >= 2 && (E.removeFromParent(), w(E), _ == null || _());
658
+ E.position.set(3, 3, 3), E.lookAt(0, 0, 0), w(E);
659
+ const b = k(() => {
660
+ M.value.length >= 2 && (E.removeFromParent(), P(E), b == null || b());
645
661
  });
646
662
  };
647
- re(
663
+ ae(
648
664
  () => t.camera,
649
- (E, _) => {
650
- E && v(E), _ && (_.removeFromParent(), w(_));
665
+ (E, b) => {
666
+ E && w(E), b && (b.removeFromParent(), P(b));
651
667
  },
652
668
  {
653
669
  immediate: !0
654
670
  }
655
- ), d.value || (r(
671
+ ), v.value || (r(
656
672
  "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
657
- ), P());
658
- }), (m, v) => (Ee(), _e("canvas", {
673
+ ), A());
674
+ }), O(() => {
675
+ f.value && i(f.value);
676
+ }), (p, w) => (Ce(), Me("canvas", {
659
677
  ref_key: "canvas",
660
- ref: n,
678
+ ref: a,
661
679
  "data-scene": o.value.uuid,
662
- class: Ce(m.$attrs.class),
663
- style: Me({
680
+ class: Pe(p.$attrs.class),
681
+ style: Ae({
664
682
  display: "block",
665
683
  width: "100%",
666
684
  height: "100%",
667
- position: m.windowSize ? "fixed" : "relative",
685
+ position: p.windowSize ? "fixed" : "relative",
668
686
  top: 0,
669
687
  left: 0,
670
688
  pointerEvents: "auto",
671
689
  touchAction: "none",
672
- ...m.$attrs.style
690
+ ...p.$attrs.style
673
691
  })
674
- }, null, 14, gt));
692
+ }, null, 14, ht));
675
693
  }
676
- }), wt = [
694
+ }), Et = [
677
695
  "TresCanvas",
678
696
  "TresLeches",
679
697
  "TresScene"
680
- ], Et = {
698
+ ], _t = {
681
699
  template: {
682
700
  compilerOptions: {
683
- isCustomElement: (e) => e.startsWith("Tres") && !wt.includes(e) || e === "primitive"
701
+ isCustomElement: (e) => e.startsWith("Tres") && !Et.includes(e) || e === "primitive"
684
702
  }
685
703
  }
686
- }, Lt = Et, xt = {
704
+ }, Lt = _t, Ot = {
687
705
  install(e) {
688
- e.component("TresCanvas", yt);
706
+ e.component("TresCanvas", wt);
689
707
  }
690
708
  };
691
709
  export {
692
- yt as TresCanvas,
693
- W as catalogue,
694
- xt as default,
710
+ wt as TresCanvas,
711
+ q as catalogue,
712
+ Ot as default,
713
+ ce as dispose,
695
714
  Y as extend,
696
- Pt as isProd,
697
- Xe as normalizeColor,
698
- At as normalizeVectorFlexibleParam,
715
+ bt as isProd,
716
+ et as normalizeColor,
717
+ Dt as normalizeVectorFlexibleParam,
699
718
  Lt as templateCompilerOptions,
700
- ut as trasverseObjects,
701
- Ye as useCamera,
719
+ ft as trasverseObjects,
720
+ Ke as useCamera,
702
721
  kt as useLoader,
703
722
  B as useLogger,
704
- ct as usePointerEventHandler,
705
- lt as useRaycaster,
706
- se as useRenderLoop,
707
- st as useRenderer,
708
- Dt as useSeek,
709
- bt as useTexture,
710
- Tt as useTres,
711
- pt as useTresContext,
712
- mt as useTresContextProvider
723
+ pt as usePointerEventHandler,
724
+ mt as useRaycaster,
725
+ ie as useRenderLoop,
726
+ ut as useRenderer,
727
+ St as useSeek,
728
+ Tt as useTexture,
729
+ xt as useTres,
730
+ gt as useTresContext,
731
+ vt as useTresContextProvider
713
732
  };