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