@tresjs/core 2.4.0-next.1 → 2.4.0-next.10

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,477 +1,471 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.4.0-next.0
3
+ * version: v2.4.0-next.10
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 { shallowRef as A, computed as R, watchEffect as $, ref as U, toRefs as ne, watch as W, shallowReactive as ae, provide as oe, inject as re, onUnmounted as ie, reactive as Ce, readonly as z, createRenderer as Te, defineComponent as Pe, useSlots as _e, onMounted as xe, openBlock as he, createElementBlock as Ae, normalizeStyle as Re } from "vue";
9
- import * as Se from "three";
10
- import { PerspectiveCamera as se, Clock as Le, Vector3 as Oe, Color as G, SRGBColorSpace as ke, ACESFilmicToneMapping as Ie, PCFSoftShadowMap as Be, PCFShadowMap as De, LinearSRGBColorSpace as J, NoToneMapping as X, WebGLRenderer as je, LoadingManager as Ve, TextureLoader as ze, Raycaster as Ge, Vector2 as He, BufferAttribute as Fe, Scene as Ne } from "three";
11
- import { createEventHook as S, useRafFn as We, useDevicePixelRatio as $e, unrefElement as Q, toValue as m, usePointer as Ue, useElementBounding as Ye, useWindowSize as qe, useElementSize as Ke } from "@vueuse/core";
12
- function Je(e) {
13
- const n = A([]), o = R(() => n.value.find((c) => c.userData.IS_ACTIVE_CAMERA));
14
- function t(c, a = !0) {
15
- n.value.push(c), a && r(c.uuid);
16
- }
17
- function r(c) {
18
- const a = n.value.find((s) => s.uuid === c);
19
- a && (n.value.forEach((s) => s.userData.IS_ACTIVE_CAMERA = !1), a.userData.IS_ACTIVE_CAMERA = !0);
20
- }
21
- function i() {
22
- n.value = [];
23
- }
24
- return $(() => {
25
- var c;
26
- (c = e.aspectRatio) != null && c.value && (console.log("camera watcher aspectRatio", e.aspectRatio.value), n.value.forEach((a) => {
27
- a instanceof se && (a.aspect = e.aspectRatio.value), a.updateProjectionMatrix();
28
- }));
8
+ import { ref as G, computed as _, watchEffect as b, onUnmounted as W, shallowRef as j, watch as J, 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 V, 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 z, LoadingManager as Me, TextureLoader as _e, Raycaster as Ee, Vector2 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 K = G({}), X = (e) => void Object.assign(K.value, e), I = (e) => typeof e == "function", Y = (e) => !!e && e.constructor === Array, Oe = ({ sizes: e, scene: n }) => {
13
+ const r = G([]), t = _(
14
+ () => r.value[0]
15
+ ), o = (a, s = !1) => {
16
+ r.value.some(({ uuid: u }) => u === a.uuid) || (s ? l(a) : r.value.push(a));
17
+ }, i = (a) => {
18
+ r.value = r.value.filter(({ uuid: s }) => s !== a.uuid);
19
+ }, l = (a) => {
20
+ const s = a instanceof de ? a : r.value.find((c) => c.uuid === a);
21
+ if (!s)
22
+ return;
23
+ const u = r.value.filter(({ uuid: c }) => c !== s.uuid);
24
+ r.value = [s, ...u];
25
+ };
26
+ return b(() => {
27
+ e.aspectRatio.value && r.value.forEach((a) => {
28
+ a instanceof V && (a.aspect = e.aspectRatio.value), (a instanceof V || a instanceof ve) && a.updateProjectionMatrix();
29
+ });
30
+ }), n.userData.tres__registerCamera = o, n.userData.tres__deregisterCamera = i, W(() => {
31
+ r.value = [];
29
32
  }), {
30
- cameras: n,
31
- camera: o,
32
- addCamera: t,
33
- setCameraToActive: r,
34
- clearCameras: i
33
+ camera: t,
34
+ cameras: r,
35
+ addCamera: o,
36
+ removeCamera: i,
37
+ setCameraActive: l
35
38
  };
36
- }
37
- const ce = S(), ue = S(), Y = S(), h = new Le();
38
- let D = 0, j = 0;
39
- const { pause: Xe, resume: Qe, isActive: Ze } = We(
39
+ }, Q = A(), Z = A(), $ = A(), D = new ge();
40
+ let R = 0, F = 0;
41
+ const { pause: Re, resume: Fe, isActive: ze } = be(
40
42
  () => {
41
- ce.trigger({ delta: D, elapsed: j, clock: h }), ue.trigger({ delta: D, elapsed: j, clock: h }), Y.trigger({ delta: D, elapsed: j, clock: h });
43
+ Q.trigger({ delta: R, elapsed: F, clock: D }), Z.trigger({ delta: R, elapsed: F, clock: D }), $.trigger({ delta: R, elapsed: F, clock: D });
42
44
  },
43
45
  { immediate: !1 }
44
46
  );
45
- Y.on(() => {
46
- D = h.getDelta(), j = h.getElapsedTime();
47
+ $.on(() => {
48
+ R = D.getDelta(), F = D.getElapsedTime();
47
49
  });
48
- function fe() {
49
- return {
50
- onBeforeLoop: ce.on,
51
- onLoop: ue.on,
52
- onAfterLoop: Y.on,
53
- pause: Xe,
54
- resume: Qe,
55
- isActive: Ze
56
- };
57
- }
58
- function Pt(e) {
59
- return typeof e == "number" ? [e, e, e] : e instanceof Oe ? [e.x, e.y, e.z] : e;
60
- }
61
- function et(e) {
62
- return e instanceof G ? e : Array.isArray(e) ? new G(...e) : new G(e);
63
- }
64
- const H = {
50
+ const ee = () => ({
51
+ onBeforeLoop: Q.on,
52
+ onLoop: Z.on,
53
+ onAfterLoop: $.on,
54
+ pause: Re,
55
+ resume: Fe,
56
+ isActive: ze
57
+ }), h = {
65
58
  realistic: {
66
- outputColorSpace: ke,
67
- toneMapping: Ie,
59
+ outputColorSpace: we,
60
+ toneMapping: ye,
68
61
  toneMappingExposure: 3,
69
62
  shadowMap: {
70
63
  enabled: !0,
71
- type: Be
64
+ type: Ce
72
65
  }
73
66
  }
74
- }, le = (e, n) => {
75
- for (const o of Object.keys(n))
76
- n[o] instanceof Object && Object.assign(n[o], le(e[o], n[o]));
67
+ }, te = (e, n) => {
68
+ for (const r of Object.keys(n))
69
+ n[r] instanceof Object && Object.assign(n[r], te(e[r], n[r]));
77
70
  return Object.assign(e || {}, n), e;
78
- }, tt = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", nt = /* @__PURE__ */ at(tt);
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);
79
72
  function B(e) {
80
- return e.replace(/-([a-z])/g, (n, o) => o.toUpperCase());
73
+ return e.replace(/-([a-z])/g, (n, r) => r.toUpperCase());
81
74
  }
82
- function at(e, n) {
83
- const o = /* @__PURE__ */ Object.create(null), t = e.split(",");
84
- for (let r = 0; r < t.length; r++)
85
- o[t[r]] = !0;
86
- return n ? (r) => !!o[r.toLowerCase()] : (r) => !!o[r];
75
+ function Ge(e, n) {
76
+ const r = /* @__PURE__ */ Object.create(null), t = e.split(",");
77
+ for (let o = 0; o < t.length; o++)
78
+ r[t[o]] = !0;
79
+ return n ? (o) => !!r[o.toLowerCase()] : (o) => !!r[o];
87
80
  }
88
- const ot = (e, n) => {
89
- const o = /* @__PURE__ */ new Set(), t = [];
90
- for (const r of e) {
91
- const i = n(r);
92
- o.has(i) || (o.add(i), t.push(r));
81
+ const We = (e, n) => {
82
+ const r = /* @__PURE__ */ new Set(), t = [];
83
+ for (const o of e) {
84
+ const i = n(o);
85
+ r.has(i) || (r.add(i), t.push(o));
93
86
  }
94
87
  return t;
95
- }, _t = !0, Z = "[TresJS ▲ ■ ●] ";
96
- function P() {
97
- function e(t, r) {
98
- console.error(`${Z} ${t}`, r || "");
88
+ }, N = (e, n) => {
89
+ if (!n)
90
+ return;
91
+ const r = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
92
+ return r == null ? void 0 : r.reduce((t, o) => t && t[o], e);
93
+ }, je = (e, n, r) => {
94
+ const t = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
95
+ t && t.reduce((o, i, l) => (o[i] === void 0 && (o[i] = {}), l === t.length - 1 && (o[i] = r), o[i]), e);
96
+ }, ot = !0, q = "[TresJS ▲ ■ ●] ";
97
+ function k() {
98
+ function e(t, o) {
99
+ console.error(`${q} ${t}`, o || "");
99
100
  }
100
101
  function n(t) {
101
- console.warn(`${Z} ${t}`);
102
+ console.warn(`${q} ${t}`);
102
103
  }
103
- function o(t, r) {
104
+ function r(t, o) {
104
105
  }
105
106
  return {
106
107
  logError: e,
107
108
  logWarning: n,
108
- logMessage: o
109
+ logMessage: r
109
110
  };
110
111
  }
111
- function rt(e, n, o) {
112
- const t = A(), r = U(!1), {
113
- alpha: i = !0,
114
- antialias: c = !0,
115
- depth: a,
116
- logarithmicDepthBuffer: s,
117
- failIfMajorPerformanceCaveat: u,
118
- precision: l,
119
- premultipliedAlpha: p,
120
- stencil: d,
121
- shadows: M = !1,
122
- shadowMapType: E = De,
123
- useLegacyLights: b = !1,
124
- outputColorSpace: g = J,
125
- toneMapping: y = X,
126
- toneMappingExposure: _ = 1,
127
- context: L = void 0,
128
- powerPreference: O = "default",
129
- preserveDrawingBuffer: k = !1,
130
- clearColor: T,
131
- windowSize: f = !1,
132
- preset: v = void 0
133
- } = ne(o), { cameras: Et, setRenderer: ge, sizes: V } = n, { logError: we, logWarning: yt } = P(), { pixelRatio: I } = $e(), { pause: be, resume: Ee } = fe(), q = () => {
134
- t.value && (t.value.setSize(V.width.value, V.height.value), t.value.setPixelRatio(Math.min(I.value, 2)));
135
- }, K = () => {
136
- if (!t.value)
137
- return;
138
- const C = m(v);
139
- if (C) {
140
- C in H || we("Renderer Preset must be one of these: " + Object.keys(H).join(", ")), le(t.value, H[C]);
141
- return;
142
- }
143
- t.value.shadowMap.enabled = m(M), t.value.shadowMap.type = m(E), t.value.toneMapping = m(y) || X, t.value.toneMappingExposure = m(_), t.value.outputColorSpace = m(g) || J, T != null && T.value && t.value.setClearColor(et(m(T))), t.value.useLegacyLights = m(b);
144
- }, ye = () => {
145
- const C = Q(e);
146
- console.count("init renderer"), C && (t.value = new je({
147
- canvas: C,
148
- alpha: m(i),
149
- antialias: m(c),
150
- context: m(L),
151
- depth: m(a),
152
- failIfMajorPerformanceCaveat: m(u),
153
- logarithmicDepthBuffer: m(s),
154
- powerPreference: m(O),
155
- precision: m(l),
156
- stencil: m(d),
157
- preserveDrawingBuffer: m(k),
158
- premultipliedAlpha: m(p)
159
- }), ge(t.value), K(), q(), Ee(), r.value = !0);
160
- }, Me = () => {
161
- t.value && (t.value.dispose(), t.value = void 0, r.value = !1, be());
162
- };
163
- return $(() => {
164
- var C;
165
- ((C = V.aspectRatio) != null && C.value || I != null && I.value) && q();
166
- }), W(
167
- [M, E, g, b, y, _, T],
168
- K
169
- ), W(
170
- e,
171
- () => {
172
- Q(e) && ye();
173
- },
174
- { immediate: !0, deep: !0 }
175
- ), {
176
- renderer: t,
177
- isReady: r,
178
- dispose: Me
112
+ function st(e) {
113
+ return typeof e == "number" ? [e, e, e] : e instanceof Pe ? [e.x, e.y, e.z] : e;
114
+ }
115
+ function $e(e) {
116
+ return e instanceof O ? e : Array.isArray(e) ? new O(...e) : new O(e);
117
+ }
118
+ function Ie({
119
+ scene: e,
120
+ canvas: n,
121
+ options: r,
122
+ disableRender: t,
123
+ contextParts: { sizes: o, camera: i }
124
+ }) {
125
+ const l = _(() => ({
126
+ alpha: y(r.alpha),
127
+ depth: y(r.depth),
128
+ canvas: De(n),
129
+ context: y(r.context),
130
+ stencil: y(r.stencil),
131
+ antialias: y(r.antialias) === void 0 ? (
132
+ // an opinionated default of tres
133
+ !0
134
+ ) : y(r.antialias),
135
+ precision: y(r.precision),
136
+ powerPreference: y(r.powerPreference),
137
+ premultipliedAlpha: y(r.premultipliedAlpha),
138
+ preserveDrawingBuffer: y(r.preserveDrawingBuffer),
139
+ logarithmicDepthBuffer: y(r.logarithmicDepthBuffer),
140
+ failIfMajorPerformanceCaveat: y(r.failIfMajorPerformanceCaveat)
141
+ })), a = j(new z(l.value));
142
+ J(l, () => {
143
+ a.value.dispose(), a.value = new z(l.value);
144
+ }), b(() => {
145
+ a.value.setSize(o.width.value, o.height.value);
146
+ });
147
+ const { pixelRatio: s } = Ae();
148
+ b(() => {
149
+ a.value.setPixelRatio(s.value);
150
+ });
151
+ const { logError: u } = k(), f = (() => {
152
+ const p = new z(), d = {
153
+ shadowMap: {
154
+ enabled: p.shadowMap.enabled,
155
+ type: p.shadowMap.type
156
+ },
157
+ toneMapping: p.toneMapping,
158
+ toneMappingExposure: p.toneMappingExposure,
159
+ outputColorSpace: p.outputColorSpace,
160
+ useLegacyLights: p.useLegacyLights
161
+ };
162
+ return p.dispose(), d;
163
+ })();
164
+ b(() => {
165
+ const p = y(r.preset);
166
+ p && (p in h || u("Renderer Preset must be one of these: " + Object.keys(h).join(", ")), te(a.value, h[p]));
167
+ const d = (L, x) => {
168
+ const T = y(L), S = () => {
169
+ if (p)
170
+ return N(h[p], x);
171
+ };
172
+ if (T !== void 0)
173
+ return T;
174
+ const m = S();
175
+ return m !== void 0 ? m : N(f, x);
176
+ }, v = (L, x) => je(a.value, x, d(L, x));
177
+ v(r.shadows, "shadowMap.enabled"), v(r.toneMapping, "toneMapping"), v(r.shadowMapType, "shadowMap.type"), v(r.useLegacyLights, "useLegacyLights"), v(r.outputColorSpace, "outputColorSpace"), v(r.toneMappingExposure, "toneMappingExposure");
178
+ const E = d(r.clearColor, "clearColor");
179
+ E && a.value.setClearColor(
180
+ E ? $e(E) : new O(0)
181
+ // default clear color is not easily/efficiently retrievable from three
182
+ );
183
+ });
184
+ const { pause: w, resume: C, onLoop: M } = ee();
185
+ return M(() => {
186
+ i.value && !y(t) && a.value.render(e, i.value);
187
+ }), C(), W(() => {
188
+ w(), a.value.dispose(), a.value.forceContextLoss();
189
+ }), {
190
+ renderer: a
179
191
  };
180
192
  }
181
- const ee = (e) => typeof e == "function", de = (e) => !!e && e.constructor === Array;
182
- function it(e) {
193
+ function Ne(e) {
183
194
  const n = { nodes: {}, materials: {} };
184
- return e && e.traverse((o) => {
185
- o.name && (n.nodes[o.name] = o), o.material && !n.materials[o.material.name] && (n.materials[o.material.name] = o.material);
195
+ return e && e.traverse((r) => {
196
+ r.name && (n.nodes[r.name] = r), r.material && !n.materials[r.material.name] && (n.materials[r.material.name] = r.material);
186
197
  }), n;
187
198
  }
188
- async function xt(e, n, o, t, r) {
189
- const { logError: i } = P(), c = new e();
190
- r && r(c), o && o(c);
199
+ async function it(e, n, r, t, o) {
200
+ const { logError: i } = k(), l = new e();
201
+ o && o(l), r && r(l);
191
202
  const s = (Array.isArray(n) ? n : [n]).map(
192
- (u) => new Promise((l, p) => {
193
- c.load(
203
+ (u) => new Promise((c, f) => {
204
+ l.load(
194
205
  u,
195
- (d) => {
196
- d.scene && Object.assign(d, it(d.scene)), l(d);
206
+ (w) => {
207
+ w.scene && Object.assign(w, Ne(w.scene)), c(w);
197
208
  },
198
209
  t,
199
- (d) => p(i("[useLoader] - Failed to load resource", d))
210
+ (w) => f(i("[useLoader] - Failed to load resource", w))
200
211
  );
201
212
  })
202
213
  );
203
- return de(n) ? await Promise.all(s) : await s[0];
214
+ return Y(n) ? await Promise.all(s) : await s[0];
204
215
  }
205
- async function ht(e) {
206
- const n = new Ve(), o = new ze(n), t = (r) => new Promise((i, c) => {
207
- o.load(
208
- r,
216
+ async function ut(e) {
217
+ const n = new Me(), r = new _e(n), t = (o) => new Promise((i, l) => {
218
+ r.load(
219
+ o,
209
220
  (a) => i(a),
210
221
  () => null,
211
222
  () => {
212
- c(new Error("[useTextures] - Failed to load texture"));
223
+ l(new Error("[useTextures] - Failed to load texture"));
213
224
  }
214
225
  );
215
226
  });
216
- if (de(e)) {
217
- const r = await Promise.all(e.map((i) => t(i)));
218
- return e.length > 1 ? r : r[0];
227
+ if (Y(e)) {
228
+ const o = await Promise.all(e.map((i) => t(i)));
229
+ return e.length > 1 ? o : o[0];
219
230
  } else {
220
231
  const {
221
- map: r,
232
+ map: o,
222
233
  displacementMap: i,
223
- normalMap: c,
234
+ normalMap: l,
224
235
  roughnessMap: a,
225
236
  metalnessMap: s,
226
237
  aoMap: u,
227
- alphaMap: l,
228
- matcap: p
238
+ alphaMap: c,
239
+ matcap: f
229
240
  } = e;
230
241
  return {
231
- map: r ? await t(r) : null,
242
+ map: o ? await t(o) : null,
232
243
  displacementMap: i ? await t(i) : null,
233
- normalMap: c ? await t(c) : null,
244
+ normalMap: l ? await t(l) : null,
234
245
  roughnessMap: a ? await t(a) : null,
235
246
  metalnessMap: s ? await t(s) : null,
236
247
  aoMap: u ? await t(u) : null,
237
- alphaMap: l ? await t(l) : null,
238
- matcap: p ? await t(p) : null
248
+ alphaMap: c ? await t(c) : null,
249
+ matcap: f ? await t(f) : null
239
250
  };
240
251
  }
241
252
  }
242
- const w = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
243
- function st() {
244
- const e = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0, o = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0;
245
- return (w[e & 255] + w[e >> 8 & 255] + w[e >> 16 & 255] + w[e >> 24 & 255] + "-" + w[n & 255] + w[n >> 8 & 255] + "-" + w[n >> 16 & 15 | 64] + w[n >> 24 & 255] + "-" + w[o & 63 | 128] + w[o >> 8 & 255] + "-" + w[o >> 16 & 255] + w[o >> 24 & 255] + w[t & 255] + w[t >> 8 & 255] + w[t >> 16 & 255] + w[t >> 24 & 255]).toLowerCase();
246
- }
247
- const me = Symbol();
248
- function At() {
249
- const e = ae({
250
- uuid: st(),
251
- camera: void 0,
252
- cameras: [],
253
- canvas: void 0,
254
- scene: void 0,
255
- renderer: void 0,
256
- aspectRatio: void 0,
257
- pointerEventHandler: void 0
258
- });
259
- function n(r) {
260
- return e[r];
261
- }
262
- function o(r, i) {
263
- e[r] = i;
264
- }
265
- const t = {
266
- state: e,
267
- ...ne(e),
268
- getState: n,
269
- setState: o
270
- };
271
- return oe(me, t), t;
272
- }
273
- const ct = () => re(me, {
274
- state: ae({
275
- camera: void 0,
276
- cameras: [],
277
- canvas: void 0,
278
- scene: void 0,
279
- renderer: void 0,
280
- pointerEventHandler: void 0
281
- })
282
- }), ut = (e) => {
283
- const { state: n } = ct(), o = R(() => {
284
- var f;
285
- return (f = n.canvas) == null ? void 0 : f.value;
286
- }), { x: t, y: r } = Ue({ target: o }), { width: i, height: c, top: a, left: s } = Ye(o), u = new Ge(), l = ({ x: f, y: v }) => {
287
- if (o.value)
253
+ const qe = (e, { renderer: n, camera: r }) => {
254
+ const t = _(() => n.value.domElement), { x: o, y: i } = ke({ target: t }), { width: l, height: a, top: s, left: u } = Se(t), c = new Ee(), f = ({ x: m, y: P }) => {
255
+ if (t.value)
288
256
  return {
289
- x: (f - s.value) / i.value * 2 - 1,
290
- y: -((v - a.value) / c.value) * 2 + 1
257
+ x: (m - u.value) / l.value * 2 - 1,
258
+ y: -((P - s.value) / a.value) * 2 + 1
291
259
  };
292
- }, p = ({ x: f, y: v }) => {
293
- if (n.camera)
294
- return u.setFromCamera(new He(f, v), n.camera), u.intersectObjects(e.value, !1);
295
- }, d = (f) => {
296
- const v = l({
297
- x: (f == null ? void 0 : f.clientX) ?? t.value,
298
- y: (f == null ? void 0 : f.clientY) ?? r.value
260
+ }, w = ({ x: m, y: P }) => {
261
+ if (r.value)
262
+ return c.setFromCamera(new xe(m, P), r.value), c.intersectObjects(e.value, !1);
263
+ }, C = (m) => {
264
+ const P = f({
265
+ x: (m == null ? void 0 : m.clientX) ?? o.value,
266
+ y: (m == null ? void 0 : m.clientY) ?? i.value
299
267
  });
300
- return v ? p(v) || [] : [];
301
- }, M = R(() => d()), E = S(), b = S(), g = (f, v) => {
302
- f.trigger({ event: v, intersects: d(v) });
303
- }, y = (f) => {
304
- g(b, f);
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);
305
273
  };
306
- let _;
307
- const L = (f) => {
308
- var v;
309
- _ = (v = d(f)[0]) == null ? void 0 : v.object;
310
- }, O = (f) => {
311
- var v;
312
- f instanceof PointerEvent && _ === ((v = d(f)[0]) == null ? void 0 : v.object) && g(E, f);
313
- }, k = (f) => b.trigger({ event: f, intersects: [] }), T = $(() => {
314
- o != null && o.value && (o.value.addEventListener("pointerup", O), o.value.addEventListener("pointerdown", L), o.value.addEventListener("pointermove", y), o.value.addEventListener("pointerleave", k), T());
315
- });
316
- return ie(() => {
317
- o != null && o.value && (o.value.removeEventListener("pointerup", O), o.value.removeEventListener("pointerdown", L), o.value.removeEventListener("pointermove", y), o.value.removeEventListener("pointerleave", k));
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 t.value.addEventListener("pointerup", T), t.value.addEventListener("pointerdown", x), t.value.addEventListener("pointermove", E), t.value.addEventListener("pointerleave", S), W(() => {
283
+ t != null && t.value && (t.value.removeEventListener("pointerup", T), t.value.removeEventListener("pointerdown", x), t.value.removeEventListener("pointermove", E), t.value.removeEventListener("pointerleave", S));
318
284
  }), {
319
285
  intersects: M,
320
- onClick: (f) => E.on(f).off,
321
- onPointerMove: (f) => b.on(f).off
286
+ onClick: (m) => p.on(m).off,
287
+ onPointerMove: (m) => d.on(m).off
322
288
  };
323
289
  };
324
- function Rt() {
325
- const { logWarning: e } = P();
326
- function n(t, r, i) {
327
- let c = null;
290
+ function lt() {
291
+ const { logWarning: e } = k();
292
+ function n(t, o, i) {
293
+ let l = null;
328
294
  return t.traverse((a) => {
329
- a[r] === i && (c = a);
330
- }), c || e(`Child with ${r} '${i}' not found.`), c;
295
+ a[o] === i && (l = a);
296
+ }), l || e(`Child with ${o} '${i}' not found.`), l;
331
297
  }
332
- function o(t, r) {
333
- return n(t, "name", r);
298
+ function r(t, o) {
299
+ return n(t, "name", o);
334
300
  }
335
301
  return {
336
302
  seek: n,
337
- seekByName: o
303
+ seekByName: r
338
304
  };
339
305
  }
340
- const St = () => {
341
- const e = Ce({
306
+ const Ue = ({ scene: e, contextParts: n }) => {
307
+ const r = re({
342
308
  click: /* @__PURE__ */ new Map(),
343
309
  pointerMove: /* @__PURE__ */ new Map(),
344
310
  pointerEnter: /* @__PURE__ */ new Map(),
345
311
  pointerLeave: /* @__PURE__ */ new Map()
346
- }), n = (a) => {
347
- Object.values(e).forEach((s) => s.delete(a));
348
- }, o = (a) => {
349
- const { onClick: s, onPointerMove: u, onPointerEnter: l, onPointerLeave: p } = a;
350
- s && e.click.set(a, s), u && e.pointerMove.set(a, u), l && e.pointerEnter.set(a, l), p && e.pointerLeave.set(a, p), a.addEventListener("removed", () => {
351
- a.traverse((d) => {
352
- n(d);
353
- }), n(a);
354
- });
355
- }, t = R(
356
- () => ot(
357
- Object.values(e).map((a) => Array.from(a.keys())).flat(),
358
- ({ uuid: a }) => a
312
+ }), t = (u) => {
313
+ Object.values(r).forEach((c) => c.delete(u));
314
+ }, o = (u) => {
315
+ const { onClick: c, onPointerMove: f, onPointerEnter: w, onPointerLeave: C } = u;
316
+ c && r.click.set(u, c), f && r.pointerMove.set(u, f), w && r.pointerEnter.set(u, w), C && r.pointerLeave.set(u, C);
317
+ };
318
+ e.userData.tres__registerAtPointerEventHandler = o, e.userData.tres__deregisterAtPointerEventHandler = t;
319
+ const i = _(
320
+ () => We(
321
+ Object.values(r).map((u) => Array.from(u.keys())).flat(),
322
+ ({ uuid: u }) => u
359
323
  )
360
- ), { onClick: r, onPointerMove: i } = ut(t);
361
- r(({ intersects: a, event: s }) => {
362
- var u;
363
- a.length && ((u = e.click.get(a[0].object)) == null || u(a[0], s));
324
+ ), { onClick: l, onPointerMove: a } = qe(i, n);
325
+ l(({ intersects: u, event: c }) => {
326
+ var f;
327
+ u.length && ((f = r.click.get(u[0].object)) == null || f(u[0], c));
364
328
  });
365
- let c;
366
- return i(({ intersects: a, event: s }) => {
367
- var M, E, b, g;
368
- const u = (M = a == null ? void 0 : a[0]) == null ? void 0 : M.object, { pointerLeave: l, pointerEnter: p, pointerMove: d } = e;
369
- c && c !== u && ((E = l.get(c)) == null || E(c, s)), u && (c !== u && ((b = p.get(u)) == null || b(a[0], s)), (g = d.get(u)) == null || g(a[0], s)), c = u || null;
329
+ let s;
330
+ return a(({ 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 } = r;
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;
370
334
  }), {
371
335
  registerObject: o,
372
- deregisterObject: n
336
+ deregisterObject: t
373
337
  };
374
- }, { logError: ft } = P();
375
- function lt(e, n, o) {
376
- var b;
377
- e || ft("A scene most be provided to the TresProvider");
378
- const { width: t, height: r } = m(o.windowSize) == !0 || m(o.windowSize) === "" || m(o.windowSize) === "true" || n.value === void 0 ? qe() : Ke((b = n.value) == null ? void 0 : b.parentElement), i = R(() => t.value / r.value), c = {
379
- height: r,
380
- width: t,
381
- aspectRatio: i
382
- }, a = A(e), { camera: s, cameras: u, addCamera: l, setCameraToActive: p } = Je(c), d = A(null);
383
- function M(g) {
384
- d.value || (d.value = g);
385
- }
386
- const E = {
387
- scene: z(a),
388
- cameras: z(u),
389
- camera: s,
390
- addCamera: l,
391
- setCameraToActive: p,
392
- renderer: z(d),
393
- setRenderer: M,
394
- sizes: c
338
+ };
339
+ function Je({
340
+ scene: e,
341
+ canvas: n,
342
+ windowSize: r,
343
+ disableRender: t,
344
+ rendererOptions: o
345
+ }) {
346
+ const i = _(
347
+ () => y(r) ? he() : Be(y(n).parentElement)
348
+ ), l = _(() => i.value.width.value), a = _(() => i.value.height.value), s = _(() => l.value / a.value), u = {
349
+ height: a,
350
+ width: l,
351
+ aspectRatio: s
352
+ }, c = j(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(
359
+ {
360
+ scene: e,
361
+ canvas: n,
362
+ options: o,
363
+ contextParts: { sizes: u, camera: f },
364
+ disableRender: t
365
+ }
366
+ ), v = {
367
+ sizes: u,
368
+ scene: c,
369
+ camera: f,
370
+ cameras: ne(w),
371
+ renderer: d,
372
+ addCamera: C,
373
+ removeCamera: M,
374
+ setCameraActive: p
395
375
  };
396
- return oe("useTres", E), E;
376
+ return ae("useTres", v), v;
397
377
  }
398
- function Lt() {
399
- const e = re("useTres");
378
+ function ct() {
379
+ const e = oe("useTres");
400
380
  if (!e)
401
- throw new Error("useTresContext must be used within a TresProvider");
381
+ throw new Error("useTresContext must be used together with useTresContextProvider");
402
382
  return e;
403
383
  }
404
- const pe = U({}), ve = (e) => void Object.assign(pe.value, e), F = {
405
- GEOMETRY_VIA_PROP: "tres__geometryViaProp",
406
- MATERIAL_VIA_PROP: "tres__materialViaProp",
407
- REGISTER_AT_POINTER_EVENT_HANDLER: "tres__registerAtPointerEventHandler"
408
- };
409
- let N = null, x = null;
410
- const { logError: te } = P(), dt = {
411
- createElement(e, n, o, t) {
412
- var s, u;
413
- if (t || (t = {}), t.args || (t.args = []), e === "template" || nt(e))
384
+ let H = null, g = null;
385
+ const { logError: U } = k(), Ke = {
386
+ createElement(e, n, r, t) {
387
+ var l, a;
388
+ if (t || (t = {}), t.args || (t.args = []), e === "template" || Ve(e))
414
389
  return null;
415
- let r = e.replace("Tres", ""), i;
390
+ let o = e.replace("Tres", ""), i;
416
391
  if (e === "primitive") {
417
- (t == null ? void 0 : t.object) === void 0 && te("Tres primitives need a prop 'object'");
418
- const l = t.object;
419
- r = l.type, i = Object.assign(l, { type: r, attach: t.attach, primitive: !0 });
392
+ (t == null ? void 0 : t.object) === void 0 && U("Tres primitives need a prop 'object'");
393
+ const s = t.object;
394
+ o = s.type, i = Object.assign(s, { type: o, attach: t.attach, primitive: !0 });
420
395
  } else {
421
- const l = pe.value[r];
422
- l || te(`${r} is not defined on the THREE namespace. Use extend to add it to the catalog.`), i = new l(...t.args);
396
+ const s = K.value[o];
397
+ s || U(`${o} is not defined on the THREE namespace. Use extend to add it to the catalog.`), i = new s(...t.args);
423
398
  }
424
- i.isCamera && (t != null && t.position || i.position.set(3, 3, 3), t != null && t.lookAt || i.lookAt(0, 0, 0)), (t == null ? void 0 : t.attach) === void 0 && (i.isMaterial ? i.attach = "material" : i.isBufferGeometry && (i.attach = "geometry"));
425
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: a } = F;
426
- return i.isObject3D && ((s = t == null ? void 0 : t.material) != null && s.isMaterial && (i.userData[a] = !0), (u = t == null ? void 0 : t.geometry) != null && u.isBufferGeometry && (i.userData[c] = !0)), i;
399
+ return i.isCamera && (t != null && t.position || i.position.set(3, 3, 3), t != null && t.lookAt || i.lookAt(0, 0, 0)), (t == null ? void 0 : t.attach) === void 0 && (i.isMaterial ? i.attach = "material" : i.isBufferGeometry && (i.attach = "geometry")), i.isObject3D && ((l = t == null ? void 0 : t.material) != null && l.isMaterial && (i.userData.tres__materialViaProp = !0), (a = t == null ? void 0 : t.geometry) != null && a.isBufferGeometry && (i.userData.tres__geometryViaProp = !0)), i;
427
400
  },
428
401
  insert(e, n) {
429
- var o, t, r, i, c, a, s;
430
- if (n && n.isScene && (x = n), (((o = e == null ? void 0 : e.__vnode) == null ? void 0 : o.type) === "TresGroup" || ((t = e == null ? void 0 : e.__vnode) == null ? void 0 : t.type) === "TresObject3D") && n === null && !((i = (r = e == null ? void 0 : e.__vnode) == null ? void 0 : r.ctx) != null && i.asyncResolved)) {
431
- N = e;
402
+ var r, t, o, i, l, a, s, u, c;
403
+ if (n && n.isScene && (g = n), (((r = e == null ? void 0 : e.__vnode) == null ? void 0 : r.type) === "TresGroup" || ((t = e == null ? void 0 : e.__vnode) == null ? void 0 : t.type) === "TresObject3D") && n === null && !((i = (o = e == null ? void 0 : e.__vnode) == null ? void 0 : o.ctx) != null && i.asyncResolved)) {
404
+ H = e;
432
405
  return;
433
406
  } else
434
- (c = e == null ? void 0 : e.__vnode) != null && c.type.includes("Controls") && n === null && (N = x);
435
- n || (n = N), e != null && e.isObject3D && (n != null && n.isObject3D) ? (n.add(e), e.dispatchEvent({ type: "added" }), (s = (a = x == null ? void 0 : x.userData) == null ? void 0 : a[F.REGISTER_AT_POINTER_EVENT_HANDLER]) == null || s.call(a, e)) : 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));
407
+ (l = e == null ? void 0 : e.__vnode) != null && l.type.includes("Controls") && n === null && (H = g);
408
+ if (n || (n = H), e != null && e.isObject3D) {
409
+ if (e != null && e.isCamera) {
410
+ if (!(g != null && g.userData.tres__registerCamera))
411
+ throw "could not find tres__registerCamera on scene's userData";
412
+ (s = g == null ? void 0 : (a = g.userData).tres__registerCamera) == null || s.call(a, e);
413
+ }
414
+ if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) {
415
+ if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
416
+ throw "could not find tres__registerAtPointerEventHandler on scene's userData";
417
+ (c = g == null ? void 0 : (u = g.userData).tres__registerAtPointerEventHandler) == null || c.call(u, e);
418
+ }
419
+ }
420
+ 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));
436
421
  },
437
422
  remove(e) {
438
- var n, o;
423
+ var n, r;
439
424
  if (e) {
440
425
  if (e.isObject3D) {
441
- const t = e, r = (i) => {
442
- var s, u;
443
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: a } = F;
444
- i.userData[a] || (s = i.material) == null || s.dispose(), i.userData[c] || (u = i.geometry) == null || u.dispose();
426
+ const t = e, o = (s) => {
427
+ var c, f;
428
+ const u = s;
429
+ s.userData.tres__materialViaProp || (c = u.material) == null || c.dispose(), s.userData.tres__geometryViaProp || (f = u.geometry) == null || f.dispose();
430
+ }, i = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, l = (s) => {
431
+ if (!i)
432
+ throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
433
+ (s != null && s.onClick || s != null && s.onPointerMove || s != null && s.onPointerEnter || s != null && s.onPointerLeave) && (i == null || i(s));
434
+ }, a = (s) => {
435
+ const u = g == null ? void 0 : g.userData.tres__deregisterCamera;
436
+ if (!u)
437
+ throw "could not find tres__deregisterCamera on scene's userData";
438
+ s.isCamera && (u == null || u(s));
445
439
  };
446
- t.traverse((i) => {
447
- r(i);
448
- }), r(t);
440
+ t.traverse((s) => {
441
+ o(s), a(s), l == null || l(s);
442
+ }), o(t), a(t), l == null || l(t);
449
443
  }
450
- (n = e.removeFromParent) == null || n.call(e), (o = e.dispose) == null || o.call(e);
444
+ (n = e.removeFromParent) == null || n.call(e), (r = e.dispose) == null || r.call(e);
451
445
  }
452
446
  },
453
- patchProp(e, n, o, t) {
447
+ patchProp(e, n, r, t) {
454
448
  if (e) {
455
- let r = e, i = n, c = B(i), a = r == null ? void 0 : r[c];
456
- if (r.type === "BufferGeometry") {
449
+ let o = e, i = n, l = B(i), a = o == null ? void 0 : o[l];
450
+ if (o.type === "BufferGeometry") {
457
451
  if (i === "args")
458
452
  return;
459
- r.setAttribute(
453
+ o.setAttribute(
460
454
  B(i),
461
- new Fe(...t)
455
+ new Le(...t)
462
456
  );
463
457
  return;
464
458
  }
465
459
  if (i.includes("-") && a === void 0) {
466
460
  const u = i.split("-");
467
- a = u.reduce((l, p) => l[B(p)], r), i = u.pop(), c = i.toLowerCase(), a != null && a.set || (r = u.reduce((l, p) => l[B(p)], r));
461
+ a = u.reduce((c, f) => c[B(f)], o), i = u.pop(), l = i.toLowerCase(), a != null && a.set || (o = u.reduce((c, f) => c[B(f)], o));
468
462
  }
469
463
  let s = t;
470
- if (s === "" && (s = !0), ee(a)) {
471
- Array.isArray(s) ? e[c](...s) : e[c](s);
464
+ if (s === "" && (s = !0), I(a)) {
465
+ Array.isArray(s) ? e[l](...s) : e[l](s);
472
466
  return;
473
467
  }
474
- !(a != null && a.set) && !ee(a) ? r[c] = s : a.constructor === s.constructor && (a != null && a.copy) ? a == null || a.copy(s) : Array.isArray(s) ? a.set(...s) : !a.isColor && a.setScalar ? a.setScalar(s) : a.set(s);
468
+ !(a != null && a.set) && !I(a) ? o[l] = s : a.constructor === s.constructor && (a != null && a.copy) ? a == null || a.copy(s) : Array.isArray(s) ? a.set(...s) : !a.isColor && a.setScalar ? a.setScalar(s) : a.set(s);
475
469
  }
476
470
  },
477
471
  parentNode(e) {
@@ -486,120 +480,126 @@ const { logError: te } = P(), dt = {
486
480
  setScopeId: () => void 0,
487
481
  cloneNode: () => void 0,
488
482
  insertStaticContent: () => void 0
489
- }, { createApp: mt } = Te(dt), pt = (e) => {
490
- const n = mt(o);
491
- function o() {
483
+ }, { createApp: Xe } = se(Ke), Ye = (e) => {
484
+ const n = Xe(r);
485
+ function r() {
492
486
  return e && e.default ? e.default() : [];
493
487
  }
494
488
  return n;
495
489
  };
496
- ve(Se);
497
- const vt = ["data-scene"], gt = /* @__PURE__ */ Pe({
490
+ X(pe);
491
+ const Qe = ["data-scene"], Ze = /* @__PURE__ */ ie({
498
492
  __name: "TresCanvas",
499
493
  props: {
500
494
  shadows: { type: Boolean },
495
+ clearColor: {},
496
+ toneMapping: {},
501
497
  shadowMapType: {},
502
498
  useLegacyLights: { type: Boolean },
503
499
  outputColorSpace: {},
504
- toneMapping: {},
505
500
  toneMappingExposure: {},
506
- context: {},
507
- powerPreference: {},
508
- preserveDrawingBuffer: { type: Boolean },
509
- clearColor: {},
510
501
  windowSize: { type: Boolean },
511
502
  preset: {},
512
503
  disableRender: { type: Boolean },
513
- camera: {}
504
+ camera: {},
505
+ context: {},
506
+ precision: {},
507
+ alpha: { type: Boolean, default: !1 },
508
+ premultipliedAlpha: { type: Boolean },
509
+ antialias: { type: Boolean, default: !0 },
510
+ stencil: { type: Boolean, default: !0 },
511
+ preserveDrawingBuffer: { type: Boolean, default: !1 },
512
+ powerPreference: {},
513
+ depth: { type: Boolean, default: !0 },
514
+ logarithmicDepthBuffer: { type: Boolean },
515
+ failIfMajorPerformanceCaveat: { type: Boolean }
514
516
  },
515
517
  setup(e) {
516
- const n = e, { logWarning: o } = P(), t = U(), r = A(new Ne()), { onLoop: i } = fe(), c = _e();
517
- function a() {
518
- const s = lt(r.value, t, n), { addCamera: u, camera: l, clearCameras: p } = s;
519
- let d;
520
- function M() {
521
- d = pt(c), d.provide("useTres", s), d.provide("extend", ve), d.mount(r.value), b();
522
- }
523
- M();
524
- const { renderer: E } = rt(t, s, n);
525
- n.camera && u(n.camera), i(() => {
526
- var g;
527
- l.value && n.disableRender !== !0 && ((g = E.value) == null || g.render(r.value, l.value));
518
+ const n = e, { logWarning: r } = k(), t = G(), o = j(new Te());
519
+ ee();
520
+ const i = ue();
521
+ let l;
522
+ const a = (u) => {
523
+ l = Ye(i), l.provide("useTres", u), l.provide("extend", X), l.mount(o.value);
524
+ }, s = _(() => n.disableRender);
525
+ return le(() => {
526
+ const u = t, c = Je({
527
+ scene: o.value,
528
+ canvas: u,
529
+ windowSize: n.windowSize,
530
+ disableRender: s,
531
+ rendererOptions: n
528
532
  });
529
- function b() {
530
- const g = r.value.getObjectByProperty("isCamera", !0);
531
- if (g)
532
- u(g);
533
- else {
534
- o("No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene.");
535
- const y = new se(45, window.innerWidth / window.innerHeight, 0.1, 1e3);
536
- y.position.set(3, 3, 3), y.lookAt(0, 0, 0), u(y);
537
- }
538
- W(
539
- () => n.camera,
540
- (y) => {
541
- y && (p(), u(y));
533
+ Ue({ scene: o.value, contextParts: c });
534
+ const { addCamera: f, camera: w, cameras: C, removeCamera: M } = c;
535
+ a(c);
536
+ const p = () => {
537
+ const d = new V(45, window.innerWidth / window.innerHeight, 0.1, 1e3);
538
+ d.position.set(3, 3, 3), d.lookAt(0, 0, 0), f(d);
539
+ const v = b(
540
+ () => {
541
+ C.value.length >= 2 && (d.removeFromParent(), M(d), v == null || v());
542
542
  }
543
543
  );
544
- }
545
- }
546
- return xe(() => {
547
- a();
548
- }), ie(() => {
549
- }), (s, u) => (he(), Ae("canvas", {
544
+ };
545
+ J(() => n.camera, (d, v) => {
546
+ d ? f(d) : v && (v.removeFromParent(), M(v));
547
+ }, {
548
+ immediate: !0
549
+ }), w.value || (r(
550
+ "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
551
+ ), p());
552
+ }), (u, c) => (ce(), fe("canvas", {
550
553
  ref_key: "canvas",
551
554
  ref: t,
552
- "data-scene": r.value.uuid,
553
- style: Re({
555
+ "data-scene": o.value.uuid,
556
+ style: me({
554
557
  display: "block",
555
558
  width: "100%",
556
559
  height: "100%",
557
- position: s.windowSize ? "fixed" : "relative",
560
+ position: u.windowSize ? "fixed" : "relative",
558
561
  top: 0,
559
562
  left: 0,
560
563
  pointerEvents: "auto",
561
564
  touchAction: "none",
562
565
  zIndex: 1
563
566
  })
564
- }, null, 12, vt));
567
+ }, null, 12, Qe));
565
568
  }
566
- }), wt = [
569
+ }), et = [
567
570
  "TresCanvas",
568
571
  "TresLeches",
569
572
  "TresScene"
570
- ], bt = {
573
+ ], tt = {
571
574
  template: {
572
575
  compilerOptions: {
573
- isCustomElement: (e) => e.startsWith("Tres") && !wt.includes(e) || e === "primitive"
576
+ isCustomElement: (e) => e.startsWith("Tres") && !et.includes(e) || e === "primitive"
574
577
  }
575
578
  }
576
- }, Ot = bt, kt = {
579
+ }, ft = tt, mt = {
577
580
  install(e) {
578
- e.component("TresCanvas", gt);
581
+ e.component("TresCanvas", Ze);
579
582
  }
580
583
  };
581
584
  export {
582
- me as TRES_CONTEXT_KEY,
583
- gt as TresCanvas,
584
- pe as catalogue,
585
- kt as default,
586
- ve as extend,
587
- _t as isProd,
588
- et as normalizeColor,
589
- Pt as normalizeVectorFlexibleParam,
590
- Ot as templateCompilerOptions,
591
- it as trasverseObjects,
592
- Je as useCamera,
593
- xt as useLoader,
594
- P as useLogger,
595
- St as usePointerEventHandler,
596
- ut as useRaycaster,
597
- fe as useRenderLoop,
598
- rt as useRenderer,
599
- Rt as useSeek,
600
- ht as useTexture,
601
- ct as useTres,
602
- Lt as useTresContext,
603
- lt as useTresContextProvider,
604
- At as useTresProvider
585
+ Ze as TresCanvas,
586
+ K as catalogue,
587
+ mt as default,
588
+ X as extend,
589
+ ot as isProd,
590
+ $e as normalizeColor,
591
+ st as normalizeVectorFlexibleParam,
592
+ ft as templateCompilerOptions,
593
+ Ne as trasverseObjects,
594
+ Oe as useCamera,
595
+ it as useLoader,
596
+ k as useLogger,
597
+ Ue as usePointerEventHandler,
598
+ qe as useRaycaster,
599
+ ee as useRenderLoop,
600
+ Ie as useRenderer,
601
+ lt as useSeek,
602
+ ut as useTexture,
603
+ ct as useTresContext,
604
+ Je as useTresContextProvider
605
605
  };