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