@tresjs/core 2.4.1 → 2.4.2

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