@tresjs/core 2.4.0-next.3 → 2.4.0-next.5

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