@tresjs/core 2.3.0 → 2.4.0-next.1

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