@tresjs/core 2.1.1 → 2.1.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,28 +1,28 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.1.1
3
+ * version: v2.1.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 E, shallowReactive as de, computed as me, toRefs as pe, provide as _e, inject as Oe, watchEffect as ve, toRef as ke, shallowRef as ge, watch as H, onUnmounted as he, createRenderer as je, defineComponent as we, onMounted as De, h as D } from "vue";
9
- import * as be from "three";
10
- import { PerspectiveCamera as N, OrthographicCamera as Ie, Clock as ye, Color as U, SRGBColorSpace as Be, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as ze, PCFShadowMap as Ge, LinearSRGBColorSpace as ne, NoToneMapping as re, WebGLRenderer as Ve, LoadingManager as He, TextureLoader as We, Raycaster as Ye, Vector2 as $e, BufferAttribute as Ne } from "three";
11
- import { createEventHook as J, useRafFn as Ue, toValue as u, useWindowSize as Ke, useElementSize as qe, useDevicePixelRatio as Je, unrefElement as K, useEventListener as Xe } from "@vueuse/core";
12
- const oe = (e) => typeof e == "function", Qe = (e) => typeof e == "string", Ce = (e) => !!e && e.constructor === Array, Me = E({}), xe = (e) => void Object.assign(Me.value, e), p = ["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 Ze() {
8
+ import { ref as E, shallowReactive as me, computed as pe, toRefs as ve, provide as Oe, inject as ke, watchEffect as ge, toRef as je, shallowRef as we, watch as H, onUnmounted as he, createRenderer as De, defineComponent as be, onMounted as Ie, h as D } from "vue";
9
+ import * as ye from "three";
10
+ import { PerspectiveCamera as N, OrthographicCamera as Be, Clock as Ce, Color as U, SRGBColorSpace as Fe, ACESFilmicToneMapping as ze, PCFSoftShadowMap as Ge, PCFShadowMap as Ve, LinearSRGBColorSpace as re, NoToneMapping as oe, WebGLRenderer as He, LoadingManager as We, TextureLoader as Ye, Raycaster as $e, Vector2 as Ne, BufferAttribute as Ue } from "three";
11
+ import { createEventHook as X, useRafFn as Ke, toValue as u, useWindowSize as qe, useElementSize as Je, useDevicePixelRatio as Xe, unrefElement as K, useEventListener as Qe } from "@vueuse/core";
12
+ const ie = (e) => typeof e == "function", Ze = (e) => typeof e == "string", Me = (e) => !!e && e.constructor === Array, xe = E({}), Re = (e) => void Object.assign(xe.value, e), p = ["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 et() {
14
14
  const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, o = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0;
15
15
  return (p[e & 255] + p[e >> 8 & 255] + p[e >> 16 & 255] + p[e >> 24 & 255] + "-" + p[t & 255] + p[t >> 8 & 255] + "-" + p[t >> 16 & 15 | 64] + p[t >> 24 & 255] + "-" + p[o & 63 | 128] + p[o >> 8 & 255] + "-" + p[o >> 16 & 255] + p[o >> 24 & 255] + p[a & 255] + p[a >> 8 & 255] + p[a >> 16 & 255] + p[a >> 24 & 255]).toLowerCase();
16
16
  }
17
- const X = Symbol();
18
- function et() {
19
- const e = de({
20
- uuid: Ze(),
17
+ const Q = Symbol();
18
+ function tt() {
19
+ const e = me({
20
+ uuid: et(),
21
21
  camera: void 0,
22
22
  cameras: [],
23
23
  scene: void 0,
24
24
  renderer: void 0,
25
- aspectRatio: me(() => window.innerWidth / window.innerHeight)
25
+ aspectRatio: pe(() => window.innerWidth / window.innerHeight)
26
26
  });
27
27
  function t(n) {
28
28
  return e[n];
@@ -32,36 +32,36 @@ function et() {
32
32
  }
33
33
  const a = {
34
34
  state: e,
35
- ...pe(e),
35
+ ...ve(e),
36
36
  getState: t,
37
37
  setState: o
38
38
  };
39
- return _e(X, a), a;
39
+ return Oe(Q, a), a;
40
40
  }
41
- const B = () => Oe(X, {
42
- state: de({
41
+ const B = () => ke(Q, {
42
+ state: me({
43
43
  camera: void 0,
44
44
  cameras: [],
45
45
  scene: void 0,
46
46
  renderer: void 0
47
47
  })
48
48
  });
49
- var tt = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(tt || {});
50
- const at = 45;
51
- let _;
52
- function Re() {
49
+ var at = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(at || {});
50
+ const nt = 45;
51
+ let A;
52
+ function Ee() {
53
53
  const { state: e, setState: t, aspectRatio: o } = B();
54
54
  function a(s = "Perspective", f) {
55
55
  var l, d, v;
56
56
  if (s === "Perspective") {
57
- const { near: C, far: M, fov: w } = f || {
57
+ const { near: C, far: M, fov: h } = f || {
58
58
  near: 0.1,
59
59
  far: 1e3,
60
- fov: at
60
+ fov: nt
61
61
  };
62
- _ = new N(w, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, C, M), (d = e.cameras) == null || d.push(_);
62
+ A = new N(h, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, C, M), (d = e.cameras) == null || d.push(A);
63
63
  } else {
64
- const { left: C, right: M, top: w, bottom: P, near: h, far: x } = f || {
64
+ const { left: C, right: M, top: h, bottom: S, near: w, far: x } = f || {
65
65
  left: -100,
66
66
  right: 100,
67
67
  top: 100,
@@ -69,9 +69,9 @@ function Re() {
69
69
  near: 0.1,
70
70
  far: 1e3
71
71
  };
72
- _ = new Ie(C, M, w, P, h, x), (v = e.cameras) == null || v.push(_);
72
+ A = new Be(C, M, h, S, w, x), (v = e.cameras) == null || v.push(A);
73
73
  }
74
- return e.camera = _, t("camera", e.camera), _;
74
+ return e.camera = A, t("camera", e.camera), A;
75
75
  }
76
76
  function n() {
77
77
  var s;
@@ -88,10 +88,10 @@ function Re() {
88
88
  function i() {
89
89
  e.cameras = [];
90
90
  }
91
- return ve(() => {
91
+ return ge(() => {
92
92
  o != null && o.value && n();
93
93
  }), {
94
- activeCamera: ke(e, "camera"),
94
+ activeCamera: je(e, "camera"),
95
95
  createCamera: a,
96
96
  updateCamera: n,
97
97
  pushCamera: r,
@@ -99,61 +99,61 @@ function Re() {
99
99
  setFirstCamera: c
100
100
  };
101
101
  }
102
- const Ee = J(), Pe = J(), Q = J(), I = new ye();
102
+ const Se = X(), Pe = X(), Z = X(), I = new Ce();
103
103
  let W = 0, Y = 0;
104
- const { pause: nt, resume: rt, isActive: ot } = Ue(
104
+ const { pause: rt, resume: ot, isActive: it } = Ke(
105
105
  () => {
106
- Ee.trigger({ delta: W, elapsed: Y, clock: I }), Pe.trigger({ delta: W, elapsed: Y, clock: I }), Q.trigger({ delta: W, elapsed: Y, clock: I });
106
+ Se.trigger({ delta: W, elapsed: Y, clock: I }), Pe.trigger({ delta: W, elapsed: Y, clock: I }), Z.trigger({ delta: W, elapsed: Y, clock: I });
107
107
  },
108
108
  { immediate: !1 }
109
109
  );
110
- Q.on(() => {
110
+ Z.on(() => {
111
111
  W = I.getDelta(), Y = I.getElapsedTime();
112
112
  });
113
- function Se() {
113
+ function Te() {
114
114
  return {
115
- onBeforeLoop: Ee.on,
115
+ onBeforeLoop: Se.on,
116
116
  onLoop: Pe.on,
117
- onAfterLoop: Q.on,
118
- pause: nt,
119
- resume: rt,
120
- isActive: ot
117
+ onAfterLoop: Z.on,
118
+ pause: rt,
119
+ resume: ot,
120
+ isActive: it
121
121
  };
122
122
  }
123
- function it(e) {
123
+ function st(e) {
124
124
  return e instanceof U ? e : Array.isArray(e) ? new U(...e) : new U(e);
125
125
  }
126
126
  const q = {
127
127
  realistic: {
128
- outputColorSpace: Be,
129
- toneMapping: Fe,
128
+ outputColorSpace: Fe,
129
+ toneMapping: ze,
130
130
  toneMappingExposure: 3,
131
131
  shadowMap: {
132
132
  enabled: !0,
133
- type: ze
133
+ type: Ge
134
134
  }
135
135
  }
136
- }, Te = (e, t) => {
136
+ }, Le = (e, t) => {
137
137
  for (const o of Object.keys(t))
138
- t[o] instanceof Object && Object.assign(t[o], Te(e[o], t[o]));
138
+ t[o] instanceof Object && Object.assign(t[o], Le(e[o], t[o]));
139
139
  return Object.assign(e || {}, t), e;
140
- }, st = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", ct = /* @__PURE__ */ ft(st);
140
+ }, ct = "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", ft = /* @__PURE__ */ ut(ct);
141
141
  function V(e) {
142
142
  return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase());
143
143
  }
144
- function ft(e, t) {
144
+ function ut(e, t) {
145
145
  const o = /* @__PURE__ */ Object.create(null), a = e.split(",");
146
146
  for (let n = 0; n < a.length; n++)
147
147
  o[a[n]] = !0;
148
148
  return t ? (n) => !!o[n.toLowerCase()] : (n) => !!o[n];
149
149
  }
150
- const xt = !0, ie = "[TresJS ▲ ■ ●] ";
150
+ const Rt = !0, se = "[TresJS ▲ ■ ●] ";
151
151
  function F() {
152
152
  function e(a, n) {
153
- console.error(`${ie} ${a}`, n || "");
153
+ console.error(`${se} ${a}`, n || "");
154
154
  }
155
155
  function t(a) {
156
- console.warn(`${ie} ${a}`);
156
+ console.warn(`${se} ${a}`);
157
157
  }
158
158
  function o(a, n) {
159
159
  }
@@ -163,9 +163,9 @@ function F() {
163
163
  logMessage: o
164
164
  };
165
165
  }
166
- function ut(e) {
167
- var te, ae;
168
- const t = ge(), o = E(!1), {
166
+ function lt(e) {
167
+ var ae, ne;
168
+ const t = we(), o = E(!1), {
169
169
  alpha: a = !0,
170
170
  antialias: n = !0,
171
171
  depth: r,
@@ -175,38 +175,38 @@ function ut(e) {
175
175
  premultipliedAlpha: f,
176
176
  stencil: l,
177
177
  shadows: d = !1,
178
- shadowMapType: v = Ge,
178
+ shadowMapType: v = Ve,
179
179
  useLegacyLights: C = !1,
180
- outputColorSpace: M = ne,
181
- toneMapping: w = re,
182
- toneMappingExposure: P = 1,
183
- context: h = void 0,
180
+ outputColorSpace: M = re,
181
+ toneMapping: h = oe,
182
+ toneMappingExposure: S = 1,
183
+ context: w = void 0,
184
184
  powerPreference: x = "default",
185
185
  preserveDrawingBuffer: $ = !1,
186
186
  clearColor: y,
187
187
  windowSize: m = !1,
188
188
  preset: R = void 0
189
- } = pe(e), { state: g, setState: b } = B(), { width: O, height: k } = u(m) == !0 || u(m) === "" || u(m) === "true" ? Ke() : qe(g.container), { logError: S, logWarning: z } = F(), { pixelRatio: j } = Je(), { pause: T, resume: G } = Se(), L = me(() => O.value / k.value);
190
- !u(m) && ((ae = (te = g.container) == null ? void 0 : te.value) == null ? void 0 : ae.offsetHeight) === 0 && z(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
189
+ } = ve(e), { state: g, setState: b } = B(), { width: O, height: k } = u(m) == !0 || u(m) === "" || u(m) === "true" ? qe() : Je(g.container), { logError: P, logWarning: z } = F(), { pixelRatio: j } = Xe(), { pause: T, resume: G } = Te(), L = pe(() => O.value / k.value);
190
+ !u(m) && ((ne = (ae = g.container) == null ? void 0 : ae.value) == null ? void 0 : ne.offsetHeight) === 0 && z(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
191
191
  You could set windowSize=true to force the canvas to be the size of the window.`);
192
- const Z = () => {
192
+ const ee = () => {
193
193
  t.value && (t.value.setSize(O.value, k.value), t.value.setPixelRatio(Math.min(j.value, 2)));
194
- }, ee = () => {
194
+ }, te = () => {
195
195
  if (!t.value)
196
196
  return;
197
- const A = u(R);
198
- if (A) {
199
- A in q || S("Renderer Preset must be one of these: " + Object.keys(q).join(", ")), Te(t.value, q[A]);
197
+ const _ = u(R);
198
+ if (_) {
199
+ _ in q || P("Renderer Preset must be one of these: " + Object.keys(q).join(", ")), Le(t.value, q[_]);
200
200
  return;
201
201
  }
202
- t.value.shadowMap.enabled = u(d), t.value.shadowMap.type = u(v), t.value.toneMapping = u(w) || re, t.value.toneMappingExposure = u(P), t.value.outputColorSpace = u(M) || ne, y != null && y.value && t.value.setClearColor(it(u(y))), t.value.useLegacyLights = u(C);
203
- }, Le = () => {
204
- const A = K(g.canvas);
205
- A && (t.value = new Ve({
206
- canvas: A,
202
+ t.value.shadowMap.enabled = u(d), t.value.shadowMap.type = u(v), t.value.toneMapping = u(h) || oe, t.value.toneMappingExposure = u(S), t.value.outputColorSpace = u(M) || re, y != null && y.value && t.value.setClearColor(st(u(y))), t.value.useLegacyLights = u(C);
203
+ }, _e = () => {
204
+ const _ = K(g.canvas);
205
+ _ && (t.value = new He({
206
+ canvas: _,
207
207
  alpha: u(a),
208
208
  antialias: u(n),
209
- context: u(h),
209
+ context: u(w),
210
210
  depth: u(r),
211
211
  failIfMajorPerformanceCaveat: u(i),
212
212
  logarithmicDepthBuffer: u(c),
@@ -215,17 +215,17 @@ You could set windowSize=true to force the canvas to be the size of the window.`
215
215
  stencil: u(l),
216
216
  preserveDrawingBuffer: u($),
217
217
  premultipliedAlpha: u(f)
218
- }), b("renderer", t.value), b("clock", new ye()), b("aspectRatio", L), ee(), Z(), G(), o.value = !0);
218
+ }), b("renderer", t.value), b("clock", new Ce()), b("aspectRatio", L), te(), ee(), G(), o.value = !0);
219
219
  }, Ae = () => {
220
220
  t.value && (t.value.dispose(), t.value = void 0, o.value = !1, T());
221
221
  };
222
- return H([L, j], Z), H(
223
- [d, v, M, C, w, P, y],
224
- ee
222
+ return H([L, j], ee), H(
223
+ [d, v, M, C, h, S, y],
224
+ te
225
225
  ), H(
226
226
  () => [g.canvas, g.container],
227
227
  () => {
228
- K(g.canvas) && K(g.container) && Le();
228
+ K(g.canvas) && K(g.container) && _e();
229
229
  },
230
230
  { immediate: !0, deep: !0 }
231
231
  ), {
@@ -235,13 +235,13 @@ You could set windowSize=true to force the canvas to be the size of the window.`
235
235
  aspectRatio: L
236
236
  };
237
237
  }
238
- function lt(e) {
238
+ function dt(e) {
239
239
  const t = { nodes: {}, materials: {} };
240
240
  return e && e.traverse((o) => {
241
241
  o.name && (t.nodes[o.name] = o), o.material && !t.materials[o.material.name] && (t.materials[o.material.name] = o.material);
242
242
  }), t;
243
243
  }
244
- async function Rt(e, t, o, a, n) {
244
+ async function Et(e, t, o, a, n) {
245
245
  const { logError: r } = F(), c = new e();
246
246
  n && n(c), o && o(c);
247
247
  const s = (Array.isArray(t) ? t : [t]).map(
@@ -249,17 +249,17 @@ async function Rt(e, t, o, a, n) {
249
249
  c.load(
250
250
  f,
251
251
  (v) => {
252
- v.scene && Object.assign(v, lt(v.scene)), l(v);
252
+ v.scene && Object.assign(v, dt(v.scene)), l(v);
253
253
  },
254
254
  a,
255
255
  (v) => d(r("[useLoader] - Failed to load resource", v))
256
256
  );
257
257
  })
258
258
  );
259
- return Ce(t) ? await Promise.all(s) : await s[0];
259
+ return Me(t) ? await Promise.all(s) : await s[0];
260
260
  }
261
- async function Et(e) {
262
- const t = new He(), o = new We(t), a = (n) => new Promise((r, c) => {
261
+ async function St(e) {
262
+ const t = new We(), o = new Ye(t), a = (n) => new Promise((r, c) => {
263
263
  o.load(
264
264
  n,
265
265
  (i) => r(i),
@@ -269,7 +269,7 @@ async function Et(e) {
269
269
  }
270
270
  );
271
271
  });
272
- if (Ce(e)) {
272
+ if (Me(e)) {
273
273
  const n = await Promise.all(e.map((r) => a(r)));
274
274
  return e.length > 1 ? n : n[0];
275
275
  } else {
@@ -295,9 +295,9 @@ async function Et(e) {
295
295
  };
296
296
  }
297
297
  }
298
- function dt() {
298
+ function mt() {
299
299
  var c;
300
- const e = ge(new Ye()), t = E(new $e()), o = E(null), { setState: a, state: n } = B();
300
+ const e = we(new $e()), t = E(new Ne()), o = E(null), { setState: a, state: n } = B();
301
301
  a("raycaster", e.value), a("pointer", t), a("currentInstance", o);
302
302
  function r(i) {
303
303
  t.value.x = i.clientX / window.innerWidth * 2 - 1, t.value.y = -(i.clientY / window.innerHeight) * 2 + 1;
@@ -326,43 +326,44 @@ function Pt() {
326
326
  seekByName: o
327
327
  };
328
328
  }
329
- const mt = /^on[^a-z]/, pt = (e) => mt.test(e);
330
- let se = null;
331
- const ce = {
329
+ const pt = /^on[^a-z]/, vt = (e) => pt.test(e);
330
+ let J = null, ce = null;
331
+ const fe = {
332
332
  GEOMETRY_VIA_PROP: "tres__geometryViaProp",
333
333
  MATERIAL_VIA_PROP: "tres__materialViaProp"
334
- }, { logError: fe } = F();
335
- let ue = !0;
336
- const vt = {
334
+ }, { logError: ue } = F();
335
+ let le = !0;
336
+ const gt = {
337
337
  createElement(e, t, o, a) {
338
338
  var s, f;
339
- if (a || (a = {}), a.args || (a.args = []), e === "template" || ct(e))
339
+ if (a || (a = {}), a.args || (a.args = []), e === "template" || ft(e))
340
340
  return null;
341
341
  let n = e.replace("Tres", ""), r;
342
342
  if (e === "primitive") {
343
- (a == null ? void 0 : a.object) === void 0 && fe("Tres primitives need a prop 'object'");
343
+ (a == null ? void 0 : a.object) === void 0 && ue("Tres primitives need a prop 'object'");
344
344
  const l = a.object;
345
345
  n = l.type, r = Object.assign(l, { type: n, attach: a.attach, primitive: !0 });
346
346
  } else {
347
- const l = Me.value[n];
348
- l || fe(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new l(...a.args);
347
+ const l = xe.value[n];
348
+ l || ue(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new l(...a.args);
349
349
  }
350
- if (r.isCamera && ue) {
350
+ if (r.isCamera && le) {
351
351
  a != null && a.position || r.position.set(3, 3, 3), a != null && a.lookAt || r.lookAt(0, 0, 0);
352
- const { setFirstCamera: l } = Re();
353
- l(r), ue = !1;
352
+ const { setFirstCamera: l } = Ee();
353
+ l(r), le = !1;
354
354
  }
355
355
  (a == null ? void 0 : a.attach) === void 0 && (r.isMaterial ? r.attach = "material" : r.isBufferGeometry && (r.attach = "geometry"));
356
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
356
+ const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = fe;
357
357
  return r.isObject3D && ((s = a == null ? void 0 : a.material) != null && s.isMaterial && (r.userData[i] = !0), (f = a == null ? void 0 : a.geometry) != null && f.isBufferGeometry && (r.userData[c] = !0)), r.events = {}, r;
358
358
  },
359
359
  insert(e, t) {
360
- var o, a, n, r;
361
- if ((((o = e == null ? void 0 : e.__vnode) == null ? void 0 : o.type) === "TresGroup" || ((a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.type) === "TresObject3D") && t === null && !((r = (n = e == null ? void 0 : e.__vnode) == null ? void 0 : n.ctx) != null && r.asyncResolved)) {
362
- se = e;
360
+ var o, a, n, r, c;
361
+ if (t && t.isScene && (ce = t), (((o = e == null ? void 0 : e.__vnode) == null ? void 0 : o.type) === "TresGroup" || ((a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.type) === "TresObject3D") && t === null && !((r = (n = e == null ? void 0 : e.__vnode) == null ? void 0 : n.ctx) != null && r.asyncResolved)) {
362
+ J = e;
363
363
  return;
364
- }
365
- t || (t = se), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : 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));
364
+ } else
365
+ (c = e == null ? void 0 : e.__vnode) != null && c.type.includes("Controls") && t === null && (J = ce);
366
+ t || (t = J), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : 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));
366
367
  },
367
368
  remove(e) {
368
369
  var t, o;
@@ -370,7 +371,7 @@ const vt = {
370
371
  if (e.isObject3D) {
371
372
  const a = e, n = (r) => {
372
373
  var s, f;
373
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
374
+ const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = fe;
374
375
  r.userData[i] || (s = r.material) == null || s.dispose(), r.userData[c] || (f = r.geometry) == null || f.dispose();
375
376
  };
376
377
  a.traverse((r) => n(r)), n(a);
@@ -386,7 +387,7 @@ const vt = {
386
387
  return;
387
388
  n.setAttribute(
388
389
  V(r),
389
- new Ne(...a)
390
+ new Ue(...a)
390
391
  );
391
392
  return;
392
393
  }
@@ -394,16 +395,16 @@ const vt = {
394
395
  const f = r.split("-");
395
396
  i = f.reduce((l, d) => l[V(d)], n), r = f.pop(), c = r.toLowerCase(), i != null && i.set || (n = f.reduce((l, d) => l[V(d)], n));
396
397
  }
397
- if (pt(r)) {
398
+ if (vt(r)) {
398
399
  const f = r;
399
400
  e.events[f] = a;
400
401
  }
401
402
  let s = a;
402
- if (s === "" && (s = !0), oe(i)) {
403
+ if (s === "" && (s = !0), ie(i)) {
403
404
  Array.isArray(s) ? e[c](...s) : e[c](s);
404
405
  return;
405
406
  }
406
- !(i != null && i.set) && !oe(i) ? n[c] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
407
+ !(i != null && i.set) && !ie(i) ? n[c] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
407
408
  }
408
409
  },
409
410
  parentNode(e) {
@@ -418,15 +419,15 @@ const vt = {
418
419
  setScopeId: () => void 0,
419
420
  cloneNode: () => void 0,
420
421
  insertStaticContent: () => void 0
421
- }, { createApp: gt } = je(vt), ht = (e) => {
422
- const t = gt(o);
422
+ }, { createApp: wt } = De(gt), ht = (e) => {
423
+ const t = wt(o);
423
424
  function o() {
424
425
  return e && e.default ? e.default() : [];
425
426
  }
426
427
  return t;
427
428
  };
428
- xe(be);
429
- const { logWarning: le } = F(), wt = we({
429
+ Re(ye);
430
+ const { logWarning: de } = F(), bt = be({
430
431
  name: "TresScene",
431
432
  props: [
432
433
  "shadows",
@@ -446,48 +447,48 @@ const { logWarning: le } = F(), wt = we({
446
447
  "camera"
447
448
  ],
448
449
  setup(e, { slots: t, expose: o }) {
449
- e.physicallyCorrectLights === !0 && le("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
450
- const a = E(), n = E(), r = new be.Scene(), { setState: c } = B();
450
+ e.physicallyCorrectLights === !0 && de("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
451
+ const a = E(), n = E(), r = new ye.Scene(), { setState: c } = B();
451
452
  c("scene", r), c("canvas", n), c("container", a);
452
453
  const i = E(), s = t && t.default && t.default();
453
- s && (s == null ? void 0 : s.length) > 0 && (i.value = s.some((h) => Qe(h.type) && h.type.includes("Camera")) || e.camera, i.value || le("No camera found in the scene, please add one!"));
454
- const { onLoop: f, resume: l } = Se();
455
- De(() => {
454
+ s && (s == null ? void 0 : s.length) > 0 && (i.value = s.some((w) => Ze(w.type) && w.type.includes("Camera")) || e.camera, i.value || de("No camera found in the scene, please add one!"));
455
+ const { onLoop: f, resume: l } = Te();
456
+ Ie(() => {
456
457
  M();
457
458
  }), he(() => {
458
459
  c("renderer", null);
459
460
  });
460
- const { activeCamera: d, pushCamera: v, clearCameras: C } = Re();
461
+ const { activeCamera: d, pushCamera: v, clearCameras: C } = Ee();
461
462
  function M() {
462
- const { renderer: h } = ut(e);
463
+ const { renderer: w } = lt(e);
463
464
  e.camera && v(e.camera);
464
- const { raycaster: x, pointer: $ } = dt();
465
+ const { raycaster: x, pointer: $ } = mt();
465
466
  let y = null, m = null;
466
- ve(() => {
467
+ ge(() => {
467
468
  d.value && x.value.setFromCamera($.value, d.value);
468
469
  }), f(() => {
469
- var R, g, b, O, k, S, z, j, T, G;
470
- if (d.value && e.disableRender !== !0 && ((R = h.value) == null || R.render(r, d.value)), x.value) {
470
+ var R, g, b, O, k, P, z, j, T, G;
471
+ if (d.value && e.disableRender !== !0 && ((R = w.value) == null || R.render(r, d.value)), x.value) {
471
472
  const L = x.value.intersectObjects(r.children);
472
- L.length > 0 ? (m = L[0], y === null && ((O = (b = (g = m.object) == null ? void 0 : g.events) == null ? void 0 : b.onPointerEnter) == null || O.call(b, m)), (z = (S = (k = m.object) == null ? void 0 : k.events) == null ? void 0 : S.onPointerMove) == null || z.call(S, m)) : y !== null && ((G = (T = (j = m == null ? void 0 : m.object) == null ? void 0 : j.events) == null ? void 0 : T.onPointerLeave) == null || G.call(T, y), m = null), y = m;
473
+ L.length > 0 ? (m = L[0], y === null && ((O = (b = (g = m.object) == null ? void 0 : g.events) == null ? void 0 : b.onPointerEnter) == null || O.call(b, m)), (z = (P = (k = m.object) == null ? void 0 : k.events) == null ? void 0 : P.onPointerMove) == null || z.call(P, m)) : y !== null && ((G = (T = (j = m == null ? void 0 : m.object) == null ? void 0 : j.events) == null ? void 0 : T.onPointerLeave) == null || G.call(T, y), m = null), y = m;
473
474
  }
474
- }), Xe(n.value, "click", () => {
475
+ }), Qe(n.value, "click", () => {
475
476
  var R, g, b;
476
477
  m !== null && ((b = (g = (R = m.object) == null ? void 0 : R.events) == null ? void 0 : g.onClick) == null || b.call(g, m));
477
478
  });
478
479
  }
479
- let w;
480
- function P() {
481
- w = ht(t);
482
- const h = B();
483
- w.provide("useTres", h), w.provide(X, h), w.provide("extend", xe), w.mount(r);
480
+ let h;
481
+ function S() {
482
+ h = ht(t);
483
+ const w = B();
484
+ h.provide("useTres", w), h.provide(Q, w), h.provide("extend", Re), h.mount(r);
484
485
  }
485
- return P(), o({
486
+ return S(), o({
486
487
  scene: r
487
488
  }), H(
488
489
  () => e.camera,
489
- (h) => {
490
- h && (C(), v(h));
490
+ (w) => {
491
+ w && (C(), v(w));
491
492
  }
492
493
  ), () => D(
493
494
  D(
@@ -532,7 +533,7 @@ const { logWarning: le } = F(), wt = we({
532
533
  )
533
534
  );
534
535
  }
535
- }), bt = we({
536
+ }), yt = be({
536
537
  name: "TresCanvas",
537
538
  props: [
538
539
  "shadows",
@@ -552,31 +553,31 @@ const { logWarning: le } = F(), wt = we({
552
553
  "camera"
553
554
  ],
554
555
  setup(e, { slots: t, expose: o }) {
555
- const a = et();
556
- return o(a), () => D(wt, e, t);
556
+ const a = tt();
557
+ return o(a), () => D(bt, e, t);
557
558
  }
558
- }), St = {
559
+ }), Tt = {
559
560
  install(e) {
560
- e.component("TresCanvas", bt);
561
+ e.component("TresCanvas", yt);
561
562
  }
562
563
  };
563
564
  export {
564
- tt as CameraType,
565
- X as TRES_CONTEXT_KEY,
566
- bt as TresCanvas,
567
- Me as catalogue,
568
- St as default,
569
- xe as extend,
570
- xt as isProd,
571
- lt as trasverseObjects,
572
- Re as useCamera,
573
- Rt as useLoader,
565
+ at as CameraType,
566
+ Q as TRES_CONTEXT_KEY,
567
+ yt as TresCanvas,
568
+ xe as catalogue,
569
+ Tt as default,
570
+ Re as extend,
571
+ Rt as isProd,
572
+ dt as trasverseObjects,
573
+ Ee as useCamera,
574
+ Et as useLoader,
574
575
  F as useLogger,
575
- dt as useRaycaster,
576
- Se as useRenderLoop,
577
- ut as useRenderer,
576
+ mt as useRaycaster,
577
+ Te as useRenderLoop,
578
+ lt as useRenderer,
578
579
  Pt as useSeek,
579
- Et as useTexture,
580
+ St as useTexture,
580
581
  B as useTres,
581
- et as useTresProvider
582
+ tt as useTresProvider
582
583
  };
package/dist/tres.umd.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.1.1
3
+ * version: v2.1.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(d,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):(d=typeof globalThis<"u"?globalThis:d||self,c(d.tres={},d.Vue,d.Three,d.VueUseCore))})(this,function(d,c,m,u){"use strict";function Ce(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const H=Ce(m),ee=e=>typeof e=="function",Me=e=>typeof e=="string",te=e=>!!e&&e.constructor===Array,$=c.ref({}),q=e=>void Object.assign($.value,e),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"];function Se(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,o=Math.random()*4294967295|0,a=Math.random()*4294967295|0;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[o&63|128]+h[o>>8&255]+"-"+h[o>>16&255]+h[o>>24&255]+h[a&255]+h[a>>8&255]+h[a>>16&255]+h[a>>24&255]).toLowerCase()}const F=Symbol();function ae(){const e=c.shallowReactive({uuid:Se(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:c.computed(()=>window.innerWidth/window.innerHeight)});function t(n){return e[n]}function o(n,r){e[n]=r}const a={state:e,...c.toRefs(e),getState:t,setState:o};return c.provide(F,a),a}const x=()=>c.inject(F,{state:c.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});var ne=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(ne||{});const Pe=45;let A;function K(){const{state:e,setState:t,aspectRatio:o}=x();function a(s="Perspective",l){var p,v,w;if(s==="Perspective"){const{near:P,far:L,fov:C}=l||{near:.1,far:1e3,fov:Pe};A=new m.PerspectiveCamera(C,((p=e.aspectRatio)==null?void 0:p.value)||window.innerWidth/window.innerHeight,P,L),(v=e.cameras)==null||v.push(A)}else{const{left:P,right:L,top:C,bottom:V,near:y,far:_}=l||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};A=new m.OrthographicCamera(P,L,C,V,y,_),(w=e.cameras)==null||w.push(A)}return e.camera=A,t("camera",e.camera),A}function n(){var s;e.camera instanceof m.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(s=e.camera)==null||s.updateProjectionMatrix()}function r(s){var l;(l=e.cameras)==null||l.push(s),s instanceof m.PerspectiveCamera&&e.aspectRatio&&(s.aspect=e.aspectRatio.value),s.updateProjectionMatrix(),t("camera",s)}function f(s){var l;((l=e.cameras)==null?void 0:l.length)===0&&r(s)}function i(){e.cameras=[]}return c.watchEffect(()=>{o!=null&&o.value&&n()}),{activeCamera:c.toRef(e,"camera"),createCamera:a,updateCamera:n,pushCamera:r,clearCameras:i,setFirstCamera:f}}const re=u.createEventHook(),oe=u.createEventHook(),X=u.createEventHook(),I=new m.Clock;let E=0,W=0;const{pause:Le,resume:_e,isActive:Oe}=u.useRafFn(()=>{re.trigger({delta:E,elapsed:W,clock:I}),oe.trigger({delta:E,elapsed:W,clock:I}),X.trigger({delta:E,elapsed:W,clock:I})},{immediate:!1});X.on(()=>{E=I.getDelta(),W=I.getElapsedTime()});function J(){return{onBeforeLoop:re.on,onLoop:oe.on,onAfterLoop:X.on,pause:Le,resume:_e,isActive:Oe}}function xe(e){return e instanceof m.Color?e:Array.isArray(e)?new m.Color(...e):new m.Color(e)}const Q={realistic:{outputColorSpace:m.SRGBColorSpace,toneMapping:m.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:m.PCFSoftShadowMap}}},ie=(e,t)=>{for(const o of Object.keys(t))t[o]instanceof Object&&Object.assign(t[o],ie(e[o],t[o]));return Object.assign(e||{},t),e},Ae=Te("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,(t,o)=>o.toUpperCase())}function Te(e,t){const o=Object.create(null),a=e.split(",");for(let n=0;n<a.length;n++)o[a[n]]=!0;return t?n=>!!o[n.toLowerCase()]:n=>!!o[n]}const Ve=!0,se="[TresJS ▲ ■ ●] ";function T(){function e(a,n){console.error(`${se} ${a}`,n||"")}function t(a){console.warn(`${se} ${a}`)}function o(a,n){}return{logError:e,logWarning:t,logMessage:o}}function ce(e){var be,ye;const t=c.shallowRef(),o=c.ref(!1),{alpha:a=!0,antialias:n=!0,depth:r,logarithmicDepthBuffer:f,failIfMajorPerformanceCaveat:i,precision:s,premultipliedAlpha:l,stencil:p,shadows:v=!1,shadowMapType:w=m.PCFShadowMap,useLegacyLights:P=!1,outputColorSpace:L=m.LinearSRGBColorSpace,toneMapping:C=m.NoToneMapping,toneMappingExposure:V=1,context:y=void 0,powerPreference:_="default",preserveDrawingBuffer:Z=!1,clearColor:S,windowSize:g=!1,preset:O=void 0}=c.toRefs(e),{state:b,setState:M}=x(),{width:B,height:G}=u.toValue(g)==!0||u.toValue(g)===""||u.toValue(g)==="true"?u.useWindowSize():u.useElementSize(b.container),{logError:R,logWarning:U}=T(),{pixelRatio:z}=u.useDevicePixelRatio(),{pause:k,resume:Y}=J(),j=c.computed(()=>B.value/G.value);!u.toValue(g)&&((ye=(be=b.container)==null?void 0:be.value)==null?void 0:ye.offsetHeight)===0&&U(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
9
- You could set windowSize=true to force the canvas to be the size of the window.`);const he=()=>{t.value&&(t.value.setSize(B.value,G.value),t.value.setPixelRatio(Math.min(z.value,2)))},we=()=>{if(!t.value)return;const D=u.toValue(O);if(D){D in Q||R("Renderer Preset must be one of these: "+Object.keys(Q).join(", ")),ie(t.value,Q[D]);return}t.value.shadowMap.enabled=u.toValue(v),t.value.shadowMap.type=u.toValue(w),t.value.toneMapping=u.toValue(C)||m.NoToneMapping,t.value.toneMappingExposure=u.toValue(V),t.value.outputColorSpace=u.toValue(L)||m.LinearSRGBColorSpace,S!=null&&S.value&&t.value.setClearColor(xe(u.toValue(S))),t.value.useLegacyLights=u.toValue(P)},We=()=>{const D=u.unrefElement(b.canvas);D&&(t.value=new m.WebGLRenderer({canvas:D,alpha:u.toValue(a),antialias:u.toValue(n),context:u.toValue(y),depth:u.toValue(r),failIfMajorPerformanceCaveat:u.toValue(i),logarithmicDepthBuffer:u.toValue(f),powerPreference:u.toValue(_),precision:u.toValue(s),stencil:u.toValue(p),preserveDrawingBuffer:u.toValue(Z),premultipliedAlpha:u.toValue(l)}),M("renderer",t.value),M("clock",new m.Clock),M("aspectRatio",j),we(),he(),Y(),o.value=!0)},Ne=()=>{t.value&&(t.value.dispose(),t.value=void 0,o.value=!1,k())};return c.watch([j,z],he),c.watch([v,w,L,P,C,V,S],we),c.watch(()=>[b.canvas,b.container],()=>{u.unrefElement(b.canvas)&&u.unrefElement(b.container)&&We()},{immediate:!0,deep:!0}),{renderer:t,isReady:o,dispose:Ne,aspectRatio:j}}function ue(e){const t={nodes:{},materials:{}};return e&&e.traverse(o=>{o.name&&(t.nodes[o.name]=o),o.material&&!t.materials[o.material.name]&&(t.materials[o.material.name]=o.material)}),t}async function Re(e,t,o,a,n){const{logError:r}=T(),f=new e;n&&n(f),o&&o(f);const s=(Array.isArray(t)?t:[t]).map(l=>new Promise((p,v)=>{f.load(l,w=>{w.scene&&Object.assign(w,ue(w.scene)),p(w)},a,w=>v(r("[useLoader] - Failed to load resource",w)))}));return te(t)?await Promise.all(s):await s[0]}async function ke(e){const t=new m.LoadingManager,o=new m.TextureLoader(t),a=n=>new Promise((r,f)=>{o.load(n,i=>r(i),()=>null,()=>{f(new Error("[useTextures] - Failed to load texture"))})});if(te(e)){const n=await Promise.all(e.map(r=>a(r)));return e.length>1?n:n[0]}else{const{map:n,displacementMap:r,normalMap:f,roughnessMap:i,metalnessMap:s,aoMap:l,alphaMap:p,matcap:v}=e;return{map:n?await a(n):null,displacementMap:r?await a(r):null,normalMap:f?await a(f):null,roughnessMap:i?await a(i):null,metalnessMap:s?await a(s):null,aoMap:l?await a(l):null,alphaMap:p?await a(p):null,matcap:v?await a(v):null}}}function fe(){var f;const e=c.shallowRef(new m.Raycaster),t=c.ref(new m.Vector2),o=c.ref(null),{setState:a,state:n}=x();a("raycaster",e.value),a("pointer",t),a("currentInstance",o);function r(i){t.value.x=i.clientX/window.innerWidth*2-1,t.value.y=-(i.clientY/window.innerHeight)*2+1}return(f=n==null?void 0:n.renderer)==null||f.domElement.addEventListener("pointermove",r),c.onUnmounted(()=>{var i;(i=n==null?void 0:n.renderer)==null||i.domElement.removeEventListener("pointermove",r)}),{raycaster:e,pointer:t}}function je(){const{logWarning:e}=T();function t(a,n,r){let f=null;return a.traverse(i=>{i[n]===r&&(f=i)}),f||e(`Child with ${n} '${r}' not found.`),f}function o(a,n){return t(a,"name",n)}return{seek:t,seekByName:o}}const De=/^on[^a-z]/,Ie=e=>De.test(e);function Ye(e){}let le=null;const de={GEOMETRY_VIA_PROP:"tres__geometryViaProp",MATERIAL_VIA_PROP:"tres__materialViaProp"},{logError:me}=T();let pe=!0;const Be={createElement(e,t,o,a){var s,l;if(a||(a={}),a.args||(a.args=[]),e==="template"||Ae(e))return null;let n=e.replace("Tres",""),r;if(e==="primitive"){(a==null?void 0:a.object)===void 0&&me("Tres primitives need a prop 'object'");const p=a.object;n=p.type,r=Object.assign(p,{type:n,attach:a.attach,primitive:!0})}else{const p=$.value[n];p||me(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`),r=new p(...a.args)}if(r.isCamera&&pe){a!=null&&a.position||r.position.set(3,3,3),a!=null&&a.lookAt||r.lookAt(0,0,0);const{setFirstCamera:p}=K();p(r),pe=!1}(a==null?void 0:a.attach)===void 0&&(r.isMaterial?r.attach="material":r.isBufferGeometry&&(r.attach="geometry"));const{GEOMETRY_VIA_PROP:f,MATERIAL_VIA_PROP:i}=de;return r.isObject3D&&((s=a==null?void 0:a.material)!=null&&s.isMaterial&&(r.userData[i]=!0),(l=a==null?void 0:a.geometry)!=null&&l.isBufferGeometry&&(r.userData[f]=!0)),r.events={},r},insert(e,t){var o,a,n,r;if((((o=e==null?void 0:e.__vnode)==null?void 0:o.type)==="TresGroup"||((a=e==null?void 0:e.__vnode)==null?void 0:a.type)==="TresObject3D")&&t===null&&!((r=(n=e==null?void 0:e.__vnode)==null?void 0:n.ctx)!=null&&r.asyncResolved)){le=e;return}t||(t=le),e!=null&&e.isObject3D&&(t!=null&&t.isObject3D)?(t.add(e),e.dispatchEvent({type:"added"})):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,o;if(e){if(e.isObject3D){const a=e,n=r=>{var s,l;const{GEOMETRY_VIA_PROP:f,MATERIAL_VIA_PROP:i}=de;r.userData[i]||(s=r.material)==null||s.dispose(),r.userData[f]||(l=r.geometry)==null||l.dispose()};a.traverse(r=>n(r)),n(a)}(t=e.removeFromParent)==null||t.call(e),(o=e.dispose)==null||o.call(e)}},patchProp(e,t,o,a){if(e){let n=e,r=t,f=N(r),i=n==null?void 0:n[f];if(n.type==="BufferGeometry"){if(r==="args")return;n.setAttribute(N(r),new m.BufferAttribute(...a));return}if(r.includes("-")&&i===void 0){const l=r.split("-");i=l.reduce((p,v)=>p[N(v)],n),r=l.pop(),f=r.toLowerCase(),i!=null&&i.set||(n=l.reduce((p,v)=>p[N(v)],n))}if(Ie(r)){const l=r;e.events[l]=a}let s=a;if(s===""&&(s=!0),ee(i)){Array.isArray(s)?e[f](...s):e[f](s);return}!(i!=null&&i.set)&&!ee(i)?n[f]=s:i.constructor===s.constructor&&(i!=null&&i.copy)?i==null||i.copy(s):Array.isArray(s)?i.set(...s):!i.isColor&&i.setScalar?i.setScalar(s):i.set(s)}},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:Ge}=c.createRenderer(Be),ze=e=>{const t=Ge(o);function o(){return e&&e.default?e.default():[]}return t};q(H);const{logWarning:ve}=T(),Fe=c.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputColorSpace","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender","camera"],setup(e,{slots:t,expose:o}){e.physicallyCorrectLights===!0&&ve("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const a=c.ref(),n=c.ref(),r=new H.Scene,{setState:f}=x();f("scene",r),f("canvas",n),f("container",a);const i=c.ref(),s=t&&t.default&&t.default();s&&(s==null?void 0:s.length)>0&&(i.value=s.some(y=>Me(y.type)&&y.type.includes("Camera"))||e.camera,i.value||ve("No camera found in the scene, please add one!"));const{onLoop:l,resume:p}=J();c.onMounted(()=>{L()}),c.onUnmounted(()=>{f("renderer",null)});const{activeCamera:v,pushCamera:w,clearCameras:P}=K();function L(){const{renderer:y}=ce(e);e.camera&&w(e.camera);const{raycaster:_,pointer:Z}=fe();let S=null,g=null;c.watchEffect(()=>{v.value&&_.value.setFromCamera(Z.value,v.value)}),l(()=>{var O,b,M,B,G,R,U,z,k,Y;if(v.value&&e.disableRender!==!0&&((O=y.value)==null||O.render(r,v.value)),_.value){const j=_.value.intersectObjects(r.children);j.length>0?(g=j[0],S===null&&((B=(M=(b=g.object)==null?void 0:b.events)==null?void 0:M.onPointerEnter)==null||B.call(M,g)),(U=(R=(G=g.object)==null?void 0:G.events)==null?void 0:R.onPointerMove)==null||U.call(R,g)):S!==null&&((Y=(k=(z=g==null?void 0:g.object)==null?void 0:z.events)==null?void 0:k.onPointerLeave)==null||Y.call(k,S),g=null),S=g}}),u.useEventListener(n.value,"click",()=>{var O,b,M;g!==null&&((M=(b=(O=g.object)==null?void 0:O.events)==null?void 0:b.onClick)==null||M.call(b,g))})}let C;function V(){C=ze(t);const y=x();C.provide("useTres",y),C.provide(F,y),C.provide("extend",q),C.mount(r)}return V(),o({scene:r}),c.watch(()=>e.camera,y=>{y&&(P(),w(y))}),()=>c.h(c.h("div",{ref:a,"data-scene":r.uuid,key:r.uuid,style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto",touchAction:"none"}},[c.h("div",{style:{width:"100%",height:"100%"}},[c.h("canvas",{ref:n,"data-scene":r.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),ge=c.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputColorSpace","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender","camera"],setup(e,{slots:t,expose:o}){const a=ae();return o(a),()=>c.h(Fe,e,t)}}),Ee={install(e){e.component("TresCanvas",ge)}};d.CameraType=ne,d.TRES_CONTEXT_KEY=F,d.TresCanvas=ge,d.catalogue=$,d.default=Ee,d.extend=q,d.isProd=Ve,d.trasverseObjects=ue,d.useCamera=K,d.useLoader=Re,d.useLogger=T,d.useRaycaster=fe,d.useRenderLoop=J,d.useRenderer=ce,d.useSeek=je,d.useTexture=ke,d.useTres=x,d.useTresProvider=ae,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
8
+ (function(d,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):(d=typeof globalThis<"u"?globalThis:d||self,c(d.tres={},d.Vue,d.Three,d.VueUseCore))})(this,function(d,c,m,f){"use strict";function Me(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const ee=Me(m),te=e=>typeof e=="function",Se=e=>typeof e=="string",ae=e=>!!e&&e.constructor===Array,$=c.ref({}),q=e=>void Object.assign($.value,e),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"];function Pe(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,o=Math.random()*4294967295|0,a=Math.random()*4294967295|0;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[o&63|128]+h[o>>8&255]+"-"+h[o>>16&255]+h[o>>24&255]+h[a&255]+h[a>>8&255]+h[a>>16&255]+h[a>>24&255]).toLowerCase()}const F=Symbol();function ne(){const e=c.shallowReactive({uuid:Pe(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:c.computed(()=>window.innerWidth/window.innerHeight)});function t(n){return e[n]}function o(n,r){e[n]=r}const a={state:e,...c.toRefs(e),getState:t,setState:o};return c.provide(F,a),a}const x=()=>c.inject(F,{state:c.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});var re=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(re||{});const _e=45;let A;function K(){const{state:e,setState:t,aspectRatio:o}=x();function a(s="Perspective",l){var p,v,w;if(s==="Perspective"){const{near:P,far:_,fov:C}=l||{near:.1,far:1e3,fov:_e};A=new m.PerspectiveCamera(C,((p=e.aspectRatio)==null?void 0:p.value)||window.innerWidth/window.innerHeight,P,_),(v=e.cameras)==null||v.push(A)}else{const{left:P,right:_,top:C,bottom:V,near:y,far:L}=l||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};A=new m.OrthographicCamera(P,_,C,V,y,L),(w=e.cameras)==null||w.push(A)}return e.camera=A,t("camera",e.camera),A}function n(){var s;e.camera instanceof m.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(s=e.camera)==null||s.updateProjectionMatrix()}function r(s){var l;(l=e.cameras)==null||l.push(s),s instanceof m.PerspectiveCamera&&e.aspectRatio&&(s.aspect=e.aspectRatio.value),s.updateProjectionMatrix(),t("camera",s)}function u(s){var l;((l=e.cameras)==null?void 0:l.length)===0&&r(s)}function i(){e.cameras=[]}return c.watchEffect(()=>{o!=null&&o.value&&n()}),{activeCamera:c.toRef(e,"camera"),createCamera:a,updateCamera:n,pushCamera:r,clearCameras:i,setFirstCamera:u}}const oe=f.createEventHook(),ie=f.createEventHook(),X=f.createEventHook(),I=new m.Clock;let E=0,W=0;const{pause:Le,resume:Oe,isActive:xe}=f.useRafFn(()=>{oe.trigger({delta:E,elapsed:W,clock:I}),ie.trigger({delta:E,elapsed:W,clock:I}),X.trigger({delta:E,elapsed:W,clock:I})},{immediate:!1});X.on(()=>{E=I.getDelta(),W=I.getElapsedTime()});function J(){return{onBeforeLoop:oe.on,onLoop:ie.on,onAfterLoop:X.on,pause:Le,resume:Oe,isActive:xe}}function Ae(e){return e instanceof m.Color?e:Array.isArray(e)?new m.Color(...e):new m.Color(e)}const Q={realistic:{outputColorSpace:m.SRGBColorSpace,toneMapping:m.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:m.PCFSoftShadowMap}}},se=(e,t)=>{for(const o of Object.keys(t))t[o]instanceof Object&&Object.assign(t[o],se(e[o],t[o]));return Object.assign(e||{},t),e},Te=Ve("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,(t,o)=>o.toUpperCase())}function Ve(e,t){const o=Object.create(null),a=e.split(",");for(let n=0;n<a.length;n++)o[a[n]]=!0;return t?n=>!!o[n.toLowerCase()]:n=>!!o[n]}const Re=!0,ce="[TresJS ▲ ■ ●] ";function T(){function e(a,n){console.error(`${ce} ${a}`,n||"")}function t(a){console.warn(`${ce} ${a}`)}function o(a,n){}return{logError:e,logWarning:t,logMessage:o}}function ue(e){var ye,Ce;const t=c.shallowRef(),o=c.ref(!1),{alpha:a=!0,antialias:n=!0,depth:r,logarithmicDepthBuffer:u,failIfMajorPerformanceCaveat:i,precision:s,premultipliedAlpha:l,stencil:p,shadows:v=!1,shadowMapType:w=m.PCFShadowMap,useLegacyLights:P=!1,outputColorSpace:_=m.LinearSRGBColorSpace,toneMapping:C=m.NoToneMapping,toneMappingExposure:V=1,context:y=void 0,powerPreference:L="default",preserveDrawingBuffer:H=!1,clearColor:S,windowSize:g=!1,preset:O=void 0}=c.toRefs(e),{state:b,setState:M}=x(),{width:B,height:G}=f.toValue(g)==!0||f.toValue(g)===""||f.toValue(g)==="true"?f.useWindowSize():f.useElementSize(b.container),{logError:R,logWarning:U}=T(),{pixelRatio:z}=f.useDevicePixelRatio(),{pause:k,resume:Y}=J(),j=c.computed(()=>B.value/G.value);!f.toValue(g)&&((Ce=(ye=b.container)==null?void 0:ye.value)==null?void 0:Ce.offsetHeight)===0&&U(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
9
+ You could set windowSize=true to force the canvas to be the size of the window.`);const we=()=>{t.value&&(t.value.setSize(B.value,G.value),t.value.setPixelRatio(Math.min(z.value,2)))},be=()=>{if(!t.value)return;const D=f.toValue(O);if(D){D in Q||R("Renderer Preset must be one of these: "+Object.keys(Q).join(", ")),se(t.value,Q[D]);return}t.value.shadowMap.enabled=f.toValue(v),t.value.shadowMap.type=f.toValue(w),t.value.toneMapping=f.toValue(C)||m.NoToneMapping,t.value.toneMappingExposure=f.toValue(V),t.value.outputColorSpace=f.toValue(_)||m.LinearSRGBColorSpace,S!=null&&S.value&&t.value.setClearColor(Ae(f.toValue(S))),t.value.useLegacyLights=f.toValue(P)},Ne=()=>{const D=f.unrefElement(b.canvas);D&&(t.value=new m.WebGLRenderer({canvas:D,alpha:f.toValue(a),antialias:f.toValue(n),context:f.toValue(y),depth:f.toValue(r),failIfMajorPerformanceCaveat:f.toValue(i),logarithmicDepthBuffer:f.toValue(u),powerPreference:f.toValue(L),precision:f.toValue(s),stencil:f.toValue(p),preserveDrawingBuffer:f.toValue(H),premultipliedAlpha:f.toValue(l)}),M("renderer",t.value),M("clock",new m.Clock),M("aspectRatio",j),be(),we(),Y(),o.value=!0)},Ue=()=>{t.value&&(t.value.dispose(),t.value=void 0,o.value=!1,k())};return c.watch([j,z],we),c.watch([v,w,_,P,C,V,S],be),c.watch(()=>[b.canvas,b.container],()=>{f.unrefElement(b.canvas)&&f.unrefElement(b.container)&&Ne()},{immediate:!0,deep:!0}),{renderer:t,isReady:o,dispose:Ue,aspectRatio:j}}function fe(e){const t={nodes:{},materials:{}};return e&&e.traverse(o=>{o.name&&(t.nodes[o.name]=o),o.material&&!t.materials[o.material.name]&&(t.materials[o.material.name]=o.material)}),t}async function ke(e,t,o,a,n){const{logError:r}=T(),u=new e;n&&n(u),o&&o(u);const s=(Array.isArray(t)?t:[t]).map(l=>new Promise((p,v)=>{u.load(l,w=>{w.scene&&Object.assign(w,fe(w.scene)),p(w)},a,w=>v(r("[useLoader] - Failed to load resource",w)))}));return ae(t)?await Promise.all(s):await s[0]}async function je(e){const t=new m.LoadingManager,o=new m.TextureLoader(t),a=n=>new Promise((r,u)=>{o.load(n,i=>r(i),()=>null,()=>{u(new Error("[useTextures] - Failed to load texture"))})});if(ae(e)){const n=await Promise.all(e.map(r=>a(r)));return e.length>1?n:n[0]}else{const{map:n,displacementMap:r,normalMap:u,roughnessMap:i,metalnessMap:s,aoMap:l,alphaMap:p,matcap:v}=e;return{map:n?await a(n):null,displacementMap:r?await a(r):null,normalMap:u?await a(u):null,roughnessMap:i?await a(i):null,metalnessMap:s?await a(s):null,aoMap:l?await a(l):null,alphaMap:p?await a(p):null,matcap:v?await a(v):null}}}function le(){var u;const e=c.shallowRef(new m.Raycaster),t=c.ref(new m.Vector2),o=c.ref(null),{setState:a,state:n}=x();a("raycaster",e.value),a("pointer",t),a("currentInstance",o);function r(i){t.value.x=i.clientX/window.innerWidth*2-1,t.value.y=-(i.clientY/window.innerHeight)*2+1}return(u=n==null?void 0:n.renderer)==null||u.domElement.addEventListener("pointermove",r),c.onUnmounted(()=>{var i;(i=n==null?void 0:n.renderer)==null||i.domElement.removeEventListener("pointermove",r)}),{raycaster:e,pointer:t}}function De(){const{logWarning:e}=T();function t(a,n,r){let u=null;return a.traverse(i=>{i[n]===r&&(u=i)}),u||e(`Child with ${n} '${r}' not found.`),u}function o(a,n){return t(a,"name",n)}return{seek:t,seekByName:o}}const Ie=/^on[^a-z]/,Be=e=>Ie.test(e);function $e(e){}let Z=null,de=null;const me={GEOMETRY_VIA_PROP:"tres__geometryViaProp",MATERIAL_VIA_PROP:"tres__materialViaProp"},{logError:pe}=T();let ve=!0;const Ge={createElement(e,t,o,a){var s,l;if(a||(a={}),a.args||(a.args=[]),e==="template"||Te(e))return null;let n=e.replace("Tres",""),r;if(e==="primitive"){(a==null?void 0:a.object)===void 0&&pe("Tres primitives need a prop 'object'");const p=a.object;n=p.type,r=Object.assign(p,{type:n,attach:a.attach,primitive:!0})}else{const p=$.value[n];p||pe(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`),r=new p(...a.args)}if(r.isCamera&&ve){a!=null&&a.position||r.position.set(3,3,3),a!=null&&a.lookAt||r.lookAt(0,0,0);const{setFirstCamera:p}=K();p(r),ve=!1}(a==null?void 0:a.attach)===void 0&&(r.isMaterial?r.attach="material":r.isBufferGeometry&&(r.attach="geometry"));const{GEOMETRY_VIA_PROP:u,MATERIAL_VIA_PROP:i}=me;return r.isObject3D&&((s=a==null?void 0:a.material)!=null&&s.isMaterial&&(r.userData[i]=!0),(l=a==null?void 0:a.geometry)!=null&&l.isBufferGeometry&&(r.userData[u]=!0)),r.events={},r},insert(e,t){var o,a,n,r,u;if(t&&t.isScene&&(de=t),(((o=e==null?void 0:e.__vnode)==null?void 0:o.type)==="TresGroup"||((a=e==null?void 0:e.__vnode)==null?void 0:a.type)==="TresObject3D")&&t===null&&!((r=(n=e==null?void 0:e.__vnode)==null?void 0:n.ctx)!=null&&r.asyncResolved)){Z=e;return}else(u=e==null?void 0:e.__vnode)!=null&&u.type.includes("Controls")&&t===null&&(Z=de);t||(t=Z),e!=null&&e.isObject3D&&(t!=null&&t.isObject3D)?(t.add(e),e.dispatchEvent({type:"added"})):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,o;if(e){if(e.isObject3D){const a=e,n=r=>{var s,l;const{GEOMETRY_VIA_PROP:u,MATERIAL_VIA_PROP:i}=me;r.userData[i]||(s=r.material)==null||s.dispose(),r.userData[u]||(l=r.geometry)==null||l.dispose()};a.traverse(r=>n(r)),n(a)}(t=e.removeFromParent)==null||t.call(e),(o=e.dispose)==null||o.call(e)}},patchProp(e,t,o,a){if(e){let n=e,r=t,u=N(r),i=n==null?void 0:n[u];if(n.type==="BufferGeometry"){if(r==="args")return;n.setAttribute(N(r),new m.BufferAttribute(...a));return}if(r.includes("-")&&i===void 0){const l=r.split("-");i=l.reduce((p,v)=>p[N(v)],n),r=l.pop(),u=r.toLowerCase(),i!=null&&i.set||(n=l.reduce((p,v)=>p[N(v)],n))}if(Be(r)){const l=r;e.events[l]=a}let s=a;if(s===""&&(s=!0),te(i)){Array.isArray(s)?e[u](...s):e[u](s);return}!(i!=null&&i.set)&&!te(i)?n[u]=s:i.constructor===s.constructor&&(i!=null&&i.copy)?i==null||i.copy(s):Array.isArray(s)?i.set(...s):!i.isColor&&i.setScalar?i.setScalar(s):i.set(s)}},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:ze}=c.createRenderer(Ge),Fe=e=>{const t=ze(o);function o(){return e&&e.default?e.default():[]}return t};q(ee);const{logWarning:ge}=T(),Ee=c.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputColorSpace","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender","camera"],setup(e,{slots:t,expose:o}){e.physicallyCorrectLights===!0&&ge("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const a=c.ref(),n=c.ref(),r=new ee.Scene,{setState:u}=x();u("scene",r),u("canvas",n),u("container",a);const i=c.ref(),s=t&&t.default&&t.default();s&&(s==null?void 0:s.length)>0&&(i.value=s.some(y=>Se(y.type)&&y.type.includes("Camera"))||e.camera,i.value||ge("No camera found in the scene, please add one!"));const{onLoop:l,resume:p}=J();c.onMounted(()=>{_()}),c.onUnmounted(()=>{u("renderer",null)});const{activeCamera:v,pushCamera:w,clearCameras:P}=K();function _(){const{renderer:y}=ue(e);e.camera&&w(e.camera);const{raycaster:L,pointer:H}=le();let S=null,g=null;c.watchEffect(()=>{v.value&&L.value.setFromCamera(H.value,v.value)}),l(()=>{var O,b,M,B,G,R,U,z,k,Y;if(v.value&&e.disableRender!==!0&&((O=y.value)==null||O.render(r,v.value)),L.value){const j=L.value.intersectObjects(r.children);j.length>0?(g=j[0],S===null&&((B=(M=(b=g.object)==null?void 0:b.events)==null?void 0:M.onPointerEnter)==null||B.call(M,g)),(U=(R=(G=g.object)==null?void 0:G.events)==null?void 0:R.onPointerMove)==null||U.call(R,g)):S!==null&&((Y=(k=(z=g==null?void 0:g.object)==null?void 0:z.events)==null?void 0:k.onPointerLeave)==null||Y.call(k,S),g=null),S=g}}),f.useEventListener(n.value,"click",()=>{var O,b,M;g!==null&&((M=(b=(O=g.object)==null?void 0:O.events)==null?void 0:b.onClick)==null||M.call(b,g))})}let C;function V(){C=Fe(t);const y=x();C.provide("useTres",y),C.provide(F,y),C.provide("extend",q),C.mount(r)}return V(),o({scene:r}),c.watch(()=>e.camera,y=>{y&&(P(),w(y))}),()=>c.h(c.h("div",{ref:a,"data-scene":r.uuid,key:r.uuid,style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto",touchAction:"none"}},[c.h("div",{style:{width:"100%",height:"100%"}},[c.h("canvas",{ref:n,"data-scene":r.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),he=c.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputColorSpace","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender","camera"],setup(e,{slots:t,expose:o}){const a=ne();return o(a),()=>c.h(Ee,e,t)}}),We={install(e){e.component("TresCanvas",he)}};d.CameraType=re,d.TRES_CONTEXT_KEY=F,d.TresCanvas=he,d.catalogue=$,d.default=We,d.extend=q,d.isProd=Re,d.trasverseObjects=fe,d.useCamera=K,d.useLoader=ke,d.useLogger=T,d.useRaycaster=le,d.useRenderLoop=J,d.useRenderer=ue,d.useSeek=De,d.useTexture=je,d.useTres=x,d.useTresProvider=ne,Object.defineProperties(d,{__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.1.1",
4
+ "version": "2.1.2",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.3.1",
7
7
  "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
@@ -72,17 +72,16 @@
72
72
  "@stackblitz/sdk": "^1.9.0",
73
73
  "@tresjs/cientos": "2.0.0",
74
74
  "@types/three": "^0.152.0",
75
- "@typescript-eslint/eslint-plugin": "^5.59.6",
76
- "@typescript-eslint/parser": "^5.59.6",
75
+ "@typescript-eslint/eslint-plugin": "^5.59.7",
76
+ "@typescript-eslint/parser": "^5.59.7",
77
77
  "@vitejs/plugin-vue": "^4.2.3",
78
78
  "@vitest/coverage-c8": "^0.31.1",
79
79
  "@vitest/ui": "^0.31.1",
80
80
  "@vue/test-utils": "^2.3.2",
81
- "eslint": "^8.40.0",
81
+ "eslint": "^8.41.0",
82
82
  "eslint-config-prettier": "^8.8.0",
83
- "eslint-plugin-vue": "^9.13.0",
83
+ "eslint-plugin-vue": "^9.14.0",
84
84
  "gsap": "^3.11.5",
85
- "happy-dom": "^9.18.3",
86
85
  "jsdom": "^22.0.0",
87
86
  "kolorist": "^1.8.0",
88
87
  "pathe": "^1.1.0",
@@ -92,10 +91,10 @@
92
91
  "rollup-plugin-copy": "^3.4.0",
93
92
  "rollup-plugin-visualizer": "^5.9.0",
94
93
  "three": "^0.152.2",
95
- "unocss": "^0.51.13",
94
+ "unocss": "^0.52.1",
96
95
  "unplugin": "^1.3.1",
97
96
  "unplugin-vue-components": "^0.24.1",
98
- "vite": "^4.3.7",
97
+ "vite": "^4.3.8",
99
98
  "vite-plugin-banner": "^0.7.0",
100
99
  "vite-plugin-dts": "2.3.0",
101
100
  "vite-plugin-inspect": "^0.7.26",