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

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