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