@tresjs/core 2.2.0 → 2.4.0-next.0

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