@tresjs/core 3.0.1 → 3.1.0-next.1

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