@tresjs/core 2.0.0-beta.1 → 2.0.0-beta.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.
@@ -1,3 +1,4 @@
1
1
  import { RendererOptions } from 'vue';
2
2
  import { TresObject } from '../types';
3
+ export declare const isOn: (key: string) => boolean;
3
4
  export declare const nodeOps: RendererOptions<TresObject, TresObject>;
package/dist/tres.js CHANGED
@@ -1,31 +1,31 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.0.0-beta.1
3
+ * version: v2.0.0-beta.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 M, watchEffect as oe, toRef as ke, shallowRef as ie, toRefs as se, computed as ce, watch as z, shallowReactive as ue, provide as Ae, inject as Oe, createRenderer as je, defineComponent as fe, onMounted as _e, onUnmounted as Be, h as L } from "vue";
9
- import * as le from "three";
10
- import { MathUtils as De, PerspectiveCamera as O, OrthographicCamera as ze, Clock as de, Color as W, sRGBEncoding as We, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ie, PCFShadowMap as He, LinearEncoding as ee, NoToneMapping as te, WebGLRenderer as Ue, LoadingManager as $e, TextureLoader as Ge, Raycaster as Ne, Vector2 as Ve, Mesh as qe, BufferAttribute as Ye } from "three";
11
- import { createEventHook as $, useRafFn as Ke, resolveUnref as f, useWindowSize as Xe, useElementSize as Je, useDevicePixelRatio as Qe, unrefElement as F, useEventListener as Ze, isFunction as ne } from "@vueuse/core";
12
- const H = M({ uuid: De.generateUUID() }), pe = (e) => void Object.assign(H.value, e);
13
- var et = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(et || {});
14
- const tt = 45;
15
- let x;
16
- function U() {
17
- const { state: e, setState: t, aspectRatio: r } = S();
8
+ import { ref as S, watchEffect as ie, toRef as Pe, shallowRef as se, toRefs as ce, computed as ue, watch as H, shallowReactive as le, provide as Re, inject as ke, onUnmounted as fe, createRenderer as Ae, defineComponent as de, onMounted as Oe, h as P } from "vue";
9
+ import * as pe from "three";
10
+ import { MathUtils as je, PerspectiveCamera as B, OrthographicCamera as _e, Clock as me, Color as U, sRGBEncoding as ze, ACESFilmicToneMapping as Be, PCFSoftShadowMap as De, PCFShadowMap as We, LinearEncoding as ne, NoToneMapping as ae, WebGLRenderer as Fe, LoadingManager as Ie, TextureLoader as He, Raycaster as Ue, Vector2 as $e, BufferAttribute as Ge } from "three";
11
+ import { createEventHook as V, useRafFn as Ne, resolveUnref as u, useWindowSize as qe, useElementSize as Ve, useDevicePixelRatio as Ye, unrefElement as $, isFunction as re, useEventListener as Ke } from "@vueuse/core";
12
+ const N = S({ uuid: je.generateUUID() }), ve = (e) => void Object.assign(N.value, e);
13
+ var Xe = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Xe || {});
14
+ const Je = 45;
15
+ let L;
16
+ function q() {
17
+ const { state: e, setState: t, aspectRatio: r } = k();
18
18
  function a(o = "Perspective", c) {
19
- var u, l, p;
19
+ var l, v, d;
20
20
  if (o === "Perspective") {
21
- const { near: d, far: w, fov: v } = c || {
21
+ const { near: f, far: M, fov: h } = c || {
22
22
  near: 0.1,
23
23
  far: 1e3,
24
- fov: tt
24
+ fov: Je
25
25
  };
26
- x = new O(v, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, d, w), (l = e.cameras) == null || l.push(x);
26
+ L = new B(h, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, f, M), (v = e.cameras) == null || v.push(L);
27
27
  } else {
28
- const { left: d, right: w, top: v, bottom: b, near: g, far: P } = c || {
28
+ const { left: f, right: M, top: h, bottom: C, near: g, far: p } = c || {
29
29
  left: -100,
30
30
  right: 100,
31
31
  top: 100,
@@ -33,178 +33,178 @@ function U() {
33
33
  near: 0.1,
34
34
  far: 1e3
35
35
  };
36
- x = new ze(d, w, v, b, g, P), (p = e.cameras) == null || p.push(x);
36
+ L = new _e(f, M, h, C, g, p), (d = e.cameras) == null || d.push(L);
37
37
  }
38
- return e.camera = x, t("camera", e.camera), x;
38
+ return e.camera = L, t("camera", e.camera), L;
39
39
  }
40
40
  function n() {
41
41
  var o;
42
- e.camera instanceof O && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (o = e.camera) == null || o.updateProjectionMatrix();
42
+ e.camera instanceof B && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (o = e.camera) == null || o.updateProjectionMatrix();
43
43
  }
44
44
  function i(o) {
45
45
  var c;
46
- (c = e.cameras) == null || c.push(o), o instanceof O && e.aspectRatio && (o.aspect = e.aspectRatio.value), o.updateProjectionMatrix(), t("camera", o);
46
+ (c = e.cameras) == null || c.push(o), o instanceof B && e.aspectRatio && (o.aspect = e.aspectRatio.value), o.updateProjectionMatrix(), t("camera", o);
47
47
  }
48
48
  function s() {
49
49
  e.cameras = [];
50
50
  }
51
- return oe(() => {
51
+ return ie(() => {
52
52
  r != null && r.value && n();
53
53
  }), {
54
- activeCamera: ke(e, "camera"),
54
+ activeCamera: Pe(e, "camera"),
55
55
  createCamera: a,
56
56
  updateCamera: n,
57
57
  pushCamera: i,
58
58
  clearCameras: s
59
59
  };
60
60
  }
61
- const me = $(), ve = $(), G = $(), E = new de();
62
- let j = 0, _ = 0;
63
- const { pause: nt, resume: at, isActive: rt } = Ke(
61
+ const he = V(), ge = V(), Y = V(), R = new me();
62
+ let D = 0, W = 0;
63
+ const { pause: Qe, resume: Ze, isActive: et } = Ne(
64
64
  () => {
65
- me.trigger({ delta: j, elapsed: _, clock: E }), ve.trigger({ delta: j, elapsed: _, clock: E }), G.trigger({ delta: j, elapsed: _, clock: E });
65
+ he.trigger({ delta: D, elapsed: W, clock: R }), ge.trigger({ delta: D, elapsed: W, clock: R }), Y.trigger({ delta: D, elapsed: W, clock: R });
66
66
  },
67
67
  { immediate: !1 }
68
68
  );
69
- G.on(() => {
70
- j = E.getDelta(), _ = E.getElapsedTime();
69
+ Y.on(() => {
70
+ D = R.getDelta(), W = R.getElapsedTime();
71
71
  });
72
- function N() {
72
+ function we() {
73
73
  return {
74
- onBeforeLoop: me.on,
75
- onLoop: ve.on,
76
- onAfterLoop: G.on,
77
- pause: nt,
78
- resume: at,
79
- isActive: rt
74
+ onBeforeLoop: he.on,
75
+ onLoop: ge.on,
76
+ onAfterLoop: Y.on,
77
+ pause: Qe,
78
+ resume: Ze,
79
+ isActive: et
80
80
  };
81
81
  }
82
- function ot(e) {
83
- return e instanceof W ? e : Array.isArray(e) ? new W(...e) : new W(e);
82
+ function tt(e) {
83
+ return e instanceof U ? e : Array.isArray(e) ? new U(...e) : new U(e);
84
84
  }
85
- const I = {
85
+ const G = {
86
86
  realistic: {
87
- outputEncoding: We,
88
- toneMapping: Fe,
87
+ outputEncoding: ze,
88
+ toneMapping: Be,
89
89
  toneMappingExposure: 3,
90
90
  shadowMap: {
91
91
  enabled: !0,
92
- type: Ie
92
+ type: De
93
93
  }
94
94
  }
95
- }, ge = (e, t) => {
95
+ }, be = (e, t) => {
96
96
  for (const r of Object.keys(t))
97
- t[r] instanceof Object && Object.assign(t[r], ge(e[r], t[r]));
97
+ t[r] instanceof Object && Object.assign(t[r], be(e[r], t[r]));
98
98
  return Object.assign(e || {}, t), e;
99
- }, it = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", st = /* @__PURE__ */ ct(it);
100
- function R(e) {
99
+ }, nt = "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", at = /* @__PURE__ */ rt(nt);
100
+ function _(e) {
101
101
  return e.replace(/-([a-z])/g, (t, r) => r.toUpperCase());
102
102
  }
103
- function ct(e, t) {
103
+ function rt(e, t) {
104
104
  const r = /* @__PURE__ */ Object.create(null), a = e.split(",");
105
105
  for (let n = 0; n < a.length; n++)
106
106
  r[a[n]] = !0;
107
107
  return t ? (n) => !!r[n.toLowerCase()] : (n) => !!r[n];
108
108
  }
109
- function ut(e) {
110
- var Q, Z;
111
- const t = ie(), r = M(!1), {
109
+ function ot(e) {
110
+ var ee, te;
111
+ const t = se(), r = S(!1), {
112
112
  alpha: a = !0,
113
113
  antialias: n = !0,
114
114
  depth: i,
115
115
  logarithmicDepthBuffer: s,
116
116
  failIfMajorPerformanceCaveat: o,
117
117
  precision: c,
118
- premultipliedAlpha: u,
119
- stencil: l,
120
- shadows: p = !1,
121
- shadowMapType: d = He,
122
- physicallyCorrectLights: w = !1,
123
- useLegacyLights: v = !1,
124
- outputEncoding: b = ee,
125
- toneMapping: g = te,
126
- toneMappingExposure: P = 1,
127
- context: ye = void 0,
128
- powerPreference: xe = "default",
129
- preserveDrawingBuffer: Me = !1,
130
- clearColor: C,
131
- windowSize: V = !1,
132
- preset: Ce = void 0
133
- } = se(e), { state: h, setState: B } = S(), { width: q, height: Y } = f(V) ? Xe() : Je(h.container), { logError: Le, logWarning: Ee } = T(), { pixelRatio: K } = Qe(), { pause: Se, resume: Te } = N(), D = ce(() => q.value / Y.value);
134
- !f(V) && ((Z = (Q = h.container) == null ? void 0 : Q.value) == null ? void 0 : Z.offsetHeight) === 0 && Ee(`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.
118
+ premultipliedAlpha: l,
119
+ stencil: v,
120
+ shadows: d = !1,
121
+ shadowMapType: f = We,
122
+ physicallyCorrectLights: M = !1,
123
+ useLegacyLights: h = !1,
124
+ outputEncoding: C = ne,
125
+ toneMapping: g = ae,
126
+ toneMappingExposure: p = 1,
127
+ context: b = void 0,
128
+ powerPreference: y = "default",
129
+ preserveDrawingBuffer: O = !1,
130
+ clearColor: w,
131
+ windowSize: T = !1,
132
+ preset: j = void 0
133
+ } = ce(e), { state: x, setState: F } = k(), { width: K, height: X } = u(T) ? qe() : Ve(x.container), { logError: Me, logWarning: Ce } = A(), { pixelRatio: J } = Ye(), { pause: Ee, resume: Le } = we(), I = ue(() => K.value / X.value);
134
+ !u(T) && ((te = (ee = x.container) == null ? void 0 : ee.value) == null ? void 0 : te.offsetHeight) === 0 && Ce(`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.
135
135
  You could set windowSize=true to force the canvas to be the size of the window.`);
136
- const X = () => {
137
- t.value && (t.value.setSize(q.value, Y.value), t.value.setPixelRatio(Math.min(K.value, 2)));
138
- }, J = () => {
136
+ const Q = () => {
137
+ t.value && (t.value.setSize(K.value, X.value), t.value.setPixelRatio(Math.min(J.value, 2)));
138
+ }, Z = () => {
139
139
  if (!t.value)
140
140
  return;
141
- const y = f(Ce);
142
- if (y) {
143
- y in I || Le("Renderer Preset must be one of these: " + Object.keys(I).join(", ")), ge(t.value, I[y]);
141
+ const E = u(j);
142
+ if (E) {
143
+ E in G || Me("Renderer Preset must be one of these: " + Object.keys(G).join(", ")), be(t.value, G[E]);
144
144
  return;
145
145
  }
146
- t.value.shadowMap.enabled = f(p), t.value.shadowMap.type = f(d), t.value.toneMapping = f(g) || te, t.value.toneMappingExposure = f(P), t.value.outputEncoding = f(b) || ee, C != null && C.value && t.value.setClearColor(ot(f(C))), t.value.useLegacyLights = f(v);
147
- }, Pe = () => {
148
- const y = F(h.canvas);
149
- y && (t.value = new Ue({
150
- canvas: y,
151
- alpha: f(a),
152
- antialias: f(n),
153
- context: f(ye),
154
- depth: f(i),
155
- failIfMajorPerformanceCaveat: f(o),
156
- logarithmicDepthBuffer: f(s),
157
- powerPreference: f(xe),
158
- precision: f(c),
159
- stencil: f(l),
160
- preserveDrawingBuffer: f(Me),
161
- premultipliedAlpha: f(u)
162
- }), B("renderer", t.value), B("clock", new de()), B("aspectRatio", D), J(), X(), Te(), r.value = !0);
163
- }, Re = () => {
164
- t.value && (t.value.dispose(), t.value = void 0, r.value = !1, Se());
146
+ t.value.shadowMap.enabled = u(d), t.value.shadowMap.type = u(f), t.value.toneMapping = u(g) || ae, t.value.toneMappingExposure = u(p), t.value.outputEncoding = u(C) || ne, w != null && w.value && t.value.setClearColor(tt(u(w))), t.value.useLegacyLights = u(h);
147
+ }, Se = () => {
148
+ const E = $(x.canvas);
149
+ E && (t.value = new Fe({
150
+ canvas: E,
151
+ alpha: u(a),
152
+ antialias: u(n),
153
+ context: u(b),
154
+ depth: u(i),
155
+ failIfMajorPerformanceCaveat: u(o),
156
+ logarithmicDepthBuffer: u(s),
157
+ powerPreference: u(y),
158
+ precision: u(c),
159
+ stencil: u(v),
160
+ preserveDrawingBuffer: u(O),
161
+ premultipliedAlpha: u(l)
162
+ }), F("renderer", t.value), F("clock", new me()), F("aspectRatio", I), Z(), Q(), Le(), r.value = !0);
163
+ }, Te = () => {
164
+ t.value && (t.value.dispose(), t.value = void 0, r.value = !1, Ee());
165
165
  };
166
- return z([D, K], X), z(
167
- [p, d, b, v, g, P, C],
168
- J
169
- ), z(
170
- () => [h.canvas, h.container],
166
+ return H([I, J], Q), H(
167
+ [d, f, C, h, g, p, w],
168
+ Z
169
+ ), H(
170
+ () => [x.canvas, x.container],
171
171
  () => {
172
- F(h.canvas) && F(h.container) && Pe();
172
+ $(x.canvas) && $(x.container) && Se();
173
173
  },
174
174
  { immediate: !0, deep: !0 }
175
175
  ), {
176
176
  renderer: t,
177
177
  isReady: r,
178
- dispose: Re,
179
- aspectRatio: D
178
+ dispose: Te,
179
+ aspectRatio: I
180
180
  };
181
181
  }
182
- const he = (e) => !!e && e.constructor === Array;
183
- function ft(e) {
182
+ const ye = (e) => !!e && e.constructor === Array;
183
+ function it(e) {
184
184
  const t = { nodes: {}, materials: {} };
185
185
  return e && e.traverse((r) => {
186
186
  r.name && (t.nodes[r.name] = r), r.material && !t.materials[r.material.name] && (t.materials[r.material.name] = r.material);
187
187
  }), t;
188
188
  }
189
- async function Et(e, t, r, a, n) {
190
- const { logError: i } = T(), s = new e();
189
+ async function Mt(e, t, r, a, n) {
190
+ const { logError: i } = A(), s = new e();
191
191
  n && n(s), r && r(s);
192
192
  const c = (Array.isArray(t) ? t : [t]).map(
193
- (u) => new Promise((l, p) => {
193
+ (l) => new Promise((v, d) => {
194
194
  s.load(
195
- u,
196
- (d) => {
197
- d.scene && Object.assign(d, ft(d.scene)), l(d);
195
+ l,
196
+ (f) => {
197
+ f.scene && Object.assign(f, it(f.scene)), v(f);
198
198
  },
199
199
  a,
200
- (d) => p(i("[useLoader] - Failed to load resource", d))
200
+ (f) => d(i("[useLoader] - Failed to load resource", f))
201
201
  );
202
202
  })
203
203
  );
204
- return he(t) ? await Promise.all(c) : await c[0];
204
+ return ye(t) ? await Promise.all(c) : await c[0];
205
205
  }
206
- async function St(e) {
207
- const t = new $e(), r = new Ge(t), a = (n) => new Promise((i, s) => {
206
+ async function Ct(e) {
207
+ const t = new Ie(), r = new He(t), a = (n) => new Promise((i, s) => {
208
208
  r.load(
209
209
  n,
210
210
  (o) => i(o),
@@ -214,7 +214,7 @@ async function St(e) {
214
214
  }
215
215
  );
216
216
  });
217
- if (he(e)) {
217
+ if (ye(e)) {
218
218
  const n = await Promise.all(e.map((i) => a(i)));
219
219
  return e.length > 1 ? n : n[0];
220
220
  } else {
@@ -224,9 +224,9 @@ async function St(e) {
224
224
  normalMap: s,
225
225
  roughnessMap: o,
226
226
  metalnessMap: c,
227
- aoMap: u,
228
- alphaMap: l,
229
- matcap: p
227
+ aoMap: l,
228
+ alphaMap: v,
229
+ matcap: d
230
230
  } = e;
231
231
  return {
232
232
  map: n ? await a(n) : null,
@@ -234,26 +234,26 @@ async function St(e) {
234
234
  normalMap: s ? await a(s) : null,
235
235
  roughnessMap: o ? await a(o) : null,
236
236
  metalnessMap: c ? await a(c) : null,
237
- aoMap: u ? await a(u) : null,
238
- alphaMap: l ? await a(l) : null,
239
- matcap: p ? await a(p) : null
237
+ aoMap: l ? await a(l) : null,
238
+ alphaMap: v ? await a(v) : null,
239
+ matcap: d ? await a(d) : null
240
240
  };
241
241
  }
242
242
  }
243
243
  const m = ["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"];
244
- function lt() {
244
+ function st() {
245
245
  const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0;
246
246
  return (m[e & 255] + m[e >> 8 & 255] + m[e >> 16 & 255] + m[e >> 24 & 255] + "-" + m[t & 255] + m[t >> 8 & 255] + "-" + m[t >> 16 & 15 | 64] + m[t >> 24 & 255] + "-" + m[r & 63 | 128] + m[r >> 8 & 255] + "-" + m[r >> 16 & 255] + m[r >> 24 & 255] + m[a & 255] + m[a >> 8 & 255] + m[a >> 16 & 255] + m[a >> 24 & 255]).toLowerCase();
247
247
  }
248
- const we = Symbol();
249
- function dt() {
250
- const e = ue({
251
- uuid: lt(),
248
+ const xe = Symbol();
249
+ function ct() {
250
+ const e = le({
251
+ uuid: st(),
252
252
  camera: void 0,
253
253
  cameras: [],
254
254
  scene: void 0,
255
255
  renderer: void 0,
256
- aspectRatio: ce(() => window.innerWidth / window.innerHeight)
256
+ aspectRatio: ue(() => window.innerWidth / window.innerHeight)
257
257
  });
258
258
  function t(n) {
259
259
  return e[n];
@@ -263,38 +263,42 @@ function dt() {
263
263
  }
264
264
  const a = {
265
265
  state: e,
266
- ...se(e),
266
+ ...ce(e),
267
267
  getState: t,
268
268
  setState: r
269
269
  };
270
- return Ae(we, a), a;
270
+ return Re(xe, a), a;
271
271
  }
272
- const S = () => Oe(we, {
273
- state: ue({
272
+ const k = () => ke(xe, {
273
+ state: le({
274
274
  camera: void 0,
275
275
  cameras: [],
276
276
  scene: void 0,
277
277
  renderer: void 0
278
278
  })
279
- }), ae = ie(new Ne()), k = M(new Ve()), pt = M(null);
280
- function be() {
281
- const { setState: e } = S();
282
- e("raycaster", ae.value), e("pointer", k), e("currentInstance", pt);
283
- function t(r) {
284
- k.value.x = r.clientX / window.innerWidth * 2 - 1, k.value.y = -(r.clientY / window.innerHeight) * 2 + 1;
279
+ });
280
+ function ut() {
281
+ var s;
282
+ const e = se(new Ue()), t = S(new $e()), r = S(null), { setState: a, state: n } = k();
283
+ a("raycaster", e.value), a("pointer", t), a("currentInstance", r);
284
+ function i(o) {
285
+ t.value.x = o.clientX / window.innerWidth * 2 - 1, t.value.y = -(o.clientY / window.innerHeight) * 2 + 1;
285
286
  }
286
- return window.addEventListener("pointermove", t), {
287
- raycaster: ae,
288
- pointer: k
287
+ return (s = n == null ? void 0 : n.renderer) == null || s.domElement.addEventListener("pointermove", i), fe(() => {
288
+ var o;
289
+ (o = n == null ? void 0 : n.renderer) == null || o.domElement.removeEventListener("pointermove", i);
290
+ }), {
291
+ raycaster: e,
292
+ pointer: t
289
293
  };
290
294
  }
291
- const Tt = !0, re = "[TresJS ▲ ■ ●] ";
292
- function T() {
295
+ const Et = !0, oe = "[TresJS ▲ ■ ●] ";
296
+ function A() {
293
297
  function e(a, n) {
294
- console.error(`${re} ${a}`, n || "");
298
+ console.error(`${oe} ${a}`, n || "");
295
299
  }
296
300
  function t(a) {
297
- console.warn(`${re} ${a}`);
301
+ console.warn(`${oe} ${a}`);
298
302
  }
299
303
  function r(a, n) {
300
304
  }
@@ -304,8 +308,8 @@ function T() {
304
308
  logMessage: r
305
309
  };
306
310
  }
307
- function Pt() {
308
- const { logWarning: e } = T();
311
+ function Lt() {
312
+ const { logWarning: e } = A();
309
313
  function t(a, n, i) {
310
314
  let s = null;
311
315
  return a.traverse((o) => {
@@ -320,50 +324,29 @@ function Pt() {
320
324
  seekByName: r
321
325
  };
322
326
  }
323
- const { logWarning: mt } = T();
324
- function vt(e) {
325
- for (const t in e)
326
- if (t.indexOf("on") === 0)
327
- return !0;
328
- return !1;
329
- }
330
- let A = null;
331
- const gt = {
327
+ const { logWarning: lt } = A(), ft = /^on[^a-z]/, dt = (e) => ft.test(e);
328
+ let z = null;
329
+ const pt = {
332
330
  createElement(e, t, r, a) {
333
- if (e === "template" || st(e))
331
+ if (e === "template" || at(e))
334
332
  return null;
335
333
  let n;
336
- if (a === null && (a = {}), a != null && a.args ? n = new H.value[e.replace("Tres", "")](...a.args) : n = new H.value[e.replace("Tres", "")](), n.isCamera) {
337
- (!(a != null && a.position) || a != null && a.position.every((s) => s == 0)) && mt(
334
+ if (a === null && (a = {}), a != null && a.args ? n = new N.value[e.replace("Tres", "")](...a.args) : n = new N.value[e.replace("Tres", "")](), n.isCamera) {
335
+ (!(a != null && a.position) || a != null && a.position.every((s) => s == 0)) && lt(
338
336
  // eslint-disable-next-line max-len
339
337
  "Camera is positioned at the center of the scene [0,0,0], if this is not intentional try setting a position if your scene seems empty 🤗"
340
338
  );
341
- const { pushCamera: i } = U();
339
+ const { pushCamera: i } = q();
342
340
  i(n);
343
341
  }
344
- return (a == null ? void 0 : a.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n;
342
+ return (a == null ? void 0 : a.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n.events = {}, n;
345
343
  },
346
344
  insert(e, t, r) {
347
- if (A === null && t.isScene && (A = t), t === null && (t = A), t != null && t.isObject3D && (e != null && e.isObject3D)) {
348
- const s = r ? t.children.indexOf(r) : 0;
349
- e.parent = t, t.children.splice(s, 0, e), e.dispatchEvent({ type: "added" });
345
+ if (z === null && t.isScene && (z = t), t === null && (t = z), t != null && t.isObject3D && (e != null && e.isObject3D)) {
346
+ const a = r ? t.children.indexOf(r) : 0;
347
+ e.parent = t, t.children.splice(a, 0, e), e.dispatchEvent({ type: "added" });
350
348
  } else
351
349
  typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
352
- const { onLoop: a } = N();
353
- let n = null, i = null;
354
- if (e && e instanceof qe && vt(e)) {
355
- const { raycaster: s } = be();
356
- a(() => {
357
- var o, c, u;
358
- if (t != null && t.children && e && s) {
359
- const l = s.value.intersectObjects(t.children);
360
- l.length > 0 && l[0].object.uuid === e.uuid ? (i = l[0], (n === null || n.object.uuid !== (i == null ? void 0 : i.object.uuid)) && ((o = e.onPointerEnter) == null || o.call(e, i)), (c = e.onPointerMove) == null || c.call(e, i)) : (i = null, n !== null && ((u = e.onPointerLeave) == null || u.call(e, n))), n = i;
361
- }
362
- }), Ze(window, "click", () => {
363
- var o;
364
- i !== null && ((o = e.onClick) == null || o.call(e, i));
365
- });
366
- }
367
350
  },
368
351
  remove(e) {
369
352
  if (!e)
@@ -374,25 +357,26 @@ const gt = {
374
357
  patchProp(e, t, r, a) {
375
358
  if (e) {
376
359
  let n = e, i = t;
377
- const s = R(i);
360
+ const s = _(i);
378
361
  let o = n == null ? void 0 : n[s];
379
- if (e.parent || (e.parent = A), n.type === "BufferGeometry") {
362
+ if (e.parent || (e.parent = z), n.type === "BufferGeometry") {
380
363
  n.setAttribute(
381
- R(i),
382
- new Ye(...a)
364
+ _(i),
365
+ new Ge(...a)
383
366
  );
384
367
  return;
385
368
  }
386
369
  if (i.includes("-") && o === void 0) {
387
- const u = i.split("-");
388
- o = u.reduce((l, p) => l[R(p)], n), i = u.pop(), o != null && o.set || (n = u.reduce((l, p) => l[R(p)], n));
370
+ const l = i.split("-");
371
+ o = l.reduce((v, d) => v[_(d)], n), i = l.pop(), o != null && o.set || (n = l.reduce((v, d) => v[_(d)], n));
389
372
  }
373
+ dt(i) && (e.events[i] = a);
390
374
  let c = a;
391
- if (c === "" && (c = !0), ne(o)) {
375
+ if (c === "" && (c = !0), re(o)) {
392
376
  Array.isArray(c) ? e[s](...c) : e[s](c);
393
377
  return;
394
378
  }
395
- !(o != null && o.set) && !ne(o) ? n[s] = c : o.constructor === c.constructor && (o != null && o.copy) ? o == null || o.copy(c) : Array.isArray(c) ? o.set(...c) : !o.isColor && o.setScalar ? o.setScalar(c) : o.set(c);
379
+ !(o != null && o.set) && !re(o) ? n[s] = c : o.constructor === c.constructor && (o != null && o.copy) ? o == null || o.copy(c) : Array.isArray(c) ? o.set(...c) : !o.isColor && o.setScalar ? o.setScalar(c) : o.set(c);
396
380
  }
397
381
  },
398
382
  parentNode(e) {
@@ -407,15 +391,15 @@ const gt = {
407
391
  setScopeId: () => void 0,
408
392
  cloneNode: () => void 0,
409
393
  insertStaticContent: () => void 0
410
- }, { createApp: ht } = je(gt), wt = (e) => {
411
- const t = ht(r);
394
+ }, { createApp: mt } = Ae(pt), vt = (e) => {
395
+ const t = mt(r);
412
396
  function r() {
413
397
  return e && e.default ? e.default() : [];
414
398
  }
415
399
  return t;
416
400
  };
417
- pe(le);
418
- const { logWarning: bt } = T(), yt = fe({
401
+ ve(pe);
402
+ const { logWarning: ht } = A(), gt = de({
419
403
  name: "TresScene",
420
404
  props: [
421
405
  "shadows",
@@ -433,32 +417,39 @@ const { logWarning: bt } = T(), yt = fe({
433
417
  "preset"
434
418
  ],
435
419
  setup(e, { slots: t, expose: r }) {
436
- e.physicallyCorrectLights === !0 && bt("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
437
- const a = M(), n = M(), i = new le.Scene(), { setState: s } = S();
420
+ e.physicallyCorrectLights === !0 && ht("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
421
+ const a = S(), n = S(), i = new pe.Scene(), { setState: s } = k();
438
422
  s("scene", i), s("canvas", n), s("container", a);
439
- const { pushCamera: o } = U();
440
- o(new O()), _e(() => {
423
+ const { pushCamera: o } = q();
424
+ o(new B()), Oe(() => {
441
425
  c();
442
- }), Be(() => {
426
+ }), fe(() => {
443
427
  s("renderer", null);
444
428
  });
445
429
  function c() {
446
- const { renderer: p } = ut(e), { activeCamera: d } = U(), { onLoop: w } = N(), { raycaster: v, pointer: b } = be();
447
- oe(() => {
448
- d.value && v.value.setFromCamera(b.value, d.value);
449
- }), w(() => {
450
- var g;
451
- d.value && ((g = p.value) == null || g.render(i, d.value));
430
+ const { renderer: d } = ot(e), { activeCamera: f } = q(), { onLoop: M } = we(), { raycaster: h, pointer: C } = ut();
431
+ let g = null, p = null;
432
+ ie(() => {
433
+ f.value && h.value.setFromCamera(C.value, f.value);
434
+ }), M(() => {
435
+ var b, y, O, w, T;
436
+ if (f.value && ((b = d.value) == null || b.render(i, f.value)), h.value) {
437
+ const j = h.value.intersectObjects(i.children);
438
+ j.length > 0 ? (p = j[0], g === null && ((O = (y = p.object.events).onPointerEnter) == null || O.call(y, p))) : g !== null && ((T = p == null ? void 0 : (w = p.object.events).onPointerLeave) == null || T.call(w, g), p = null), g = p;
439
+ }
440
+ }), Ke(n.value, "click", () => {
441
+ var b, y;
442
+ p !== null && ((y = (b = p.object.events).onClick) == null || y.call(b, p));
452
443
  });
453
444
  }
454
- let u;
455
- function l() {
456
- u = wt(t), u.provide("useTres", S()), u.provide("extend", pe), u.mount(i);
445
+ let l;
446
+ function v() {
447
+ l = vt(t), l.provide("useTres", k()), l.provide("extend", ve), l.mount(i);
457
448
  }
458
- return l(), r({
449
+ return v(), r({
459
450
  scene: i
460
- }), () => L(
461
- L(
451
+ }), () => P(
452
+ P(
462
453
  "div",
463
454
  {
464
455
  ref: a,
@@ -473,7 +464,7 @@ const { logWarning: bt } = T(), yt = fe({
473
464
  }
474
465
  },
475
466
  [
476
- L(
467
+ P(
477
468
  "div",
478
469
  {
479
470
  style: {
@@ -482,7 +473,7 @@ const { logWarning: bt } = T(), yt = fe({
482
473
  }
483
474
  },
484
475
  [
485
- L("canvas", {
476
+ P("canvas", {
486
477
  ref: n,
487
478
  "data-scene": i.uuid,
488
479
  style: {
@@ -500,7 +491,7 @@ const { logWarning: bt } = T(), yt = fe({
500
491
  )
501
492
  );
502
493
  }
503
- }), xt = fe({
494
+ }), wt = de({
504
495
  name: "TresCanvas",
505
496
  props: [
506
497
  "shadows",
@@ -518,30 +509,30 @@ const { logWarning: bt } = T(), yt = fe({
518
509
  "preset"
519
510
  ],
520
511
  setup(e, { slots: t, expose: r }) {
521
- const a = dt();
522
- return r(a), () => L(yt, e, t);
512
+ const a = ct();
513
+ return r(a), () => P(gt, e, t);
523
514
  }
524
- }), Rt = {
515
+ }), St = {
525
516
  install(e) {
526
- e.component("TresCanvas", xt);
517
+ e.component("TresCanvas", wt);
527
518
  }
528
519
  };
529
520
  export {
530
- et as CameraType,
531
- xt as TresCanvas,
532
- H as catalogue,
533
- Rt as default,
534
- pe as extend,
535
- Tt as isProd,
536
- ft as trasverseObjects,
537
- U as useCamera,
538
- Et as useLoader,
539
- T as useLogger,
540
- be as useRaycaster,
541
- N as useRenderLoop,
542
- ut as useRenderer,
543
- Pt as useSeek,
544
- St as useTexture,
545
- S as useTres,
546
- dt as useTresProvider
521
+ Xe as CameraType,
522
+ wt as TresCanvas,
523
+ N as catalogue,
524
+ St as default,
525
+ ve as extend,
526
+ Et as isProd,
527
+ it as trasverseObjects,
528
+ q as useCamera,
529
+ Mt as useLoader,
530
+ A as useLogger,
531
+ ut as useRaycaster,
532
+ we as useRenderLoop,
533
+ ot as useRenderer,
534
+ Lt as useSeek,
535
+ Ct as useTexture,
536
+ k as useTres,
537
+ ct as useTresProvider
547
538
  };
package/dist/tres.umd.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.0.0-beta.1
3
+ * version: v2.0.0-beta.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,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("three"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","three","@vueuse/core"],i):(d=typeof globalThis<"u"?globalThis:d||self,i(d.tres={},d.Vue,d.Three,d.VueUseCore))})(this,function(d,i,l,c){"use strict";function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const q=le(l),U=i.ref({uuid:l.MathUtils.generateUUID()}),W=e=>void Object.assign(U.value,e);var V=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(V||{});const de=45;let C;function A(){const{state:e,setState:t,aspectRatio:r}=M();function a(o="Perspective",u){var p,m,h;if(o==="Perspective"){const{near:v,far:x,fov:w}=u||{near:.1,far:1e3,fov:de};C=new l.PerspectiveCamera(w,((p=e.aspectRatio)==null?void 0:p.value)||window.innerWidth/window.innerHeight,v,x),(m=e.cameras)==null||m.push(C)}else{const{left:v,right:x,top:w,bottom:S,near:b,far:F}=u||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};C=new l.OrthographicCamera(v,x,w,S,b,F),(h=e.cameras)==null||h.push(C)}return e.camera=C,t("camera",e.camera),C}function n(){var o;e.camera instanceof l.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(o=e.camera)==null||o.updateProjectionMatrix()}function s(o){var u;(u=e.cameras)==null||u.push(o),o instanceof l.PerspectiveCamera&&e.aspectRatio&&(o.aspect=e.aspectRatio.value),o.updateProjectionMatrix(),t("camera",o)}function f(){e.cameras=[]}return i.watchEffect(()=>{r!=null&&r.value&&n()}),{activeCamera:i.toRef(e,"camera"),createCamera:a,updateCamera:n,pushCamera:s,clearCameras:f}}const Y=c.createEventHook(),K=c.createEventHook(),I=c.createEventHook(),k=new l.Clock;let j=0,T=0;const{pause:pe,resume:me,isActive:ve}=c.useRafFn(()=>{Y.trigger({delta:j,elapsed:T,clock:k}),K.trigger({delta:j,elapsed:T,clock:k}),I.trigger({delta:j,elapsed:T,clock:k})},{immediate:!1});I.on(()=>{j=k.getDelta(),T=k.getElapsedTime()});function _(){return{onBeforeLoop:Y.on,onLoop:K.on,onAfterLoop:I.on,pause:pe,resume:me,isActive:ve}}function ge(e){return e instanceof l.Color?e:Array.isArray(e)?new l.Color(...e):new l.Color(e)}const R={realistic:{outputEncoding:l.sRGBEncoding,toneMapping:l.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:l.PCFSoftShadowMap}}},X=(e,t)=>{for(const r of Object.keys(t))t[r]instanceof Object&&Object.assign(t[r],X(e[r],t[r]));return Object.assign(e||{},t),e},he=we("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 D(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function we(e,t){const r=Object.create(null),a=e.split(",");for(let n=0;n<a.length;n++)r[a[n]]=!0;return t?n=>!!r[n.toLowerCase()]:n=>!!r[n]}function J(e){var fe,ue;const t=i.shallowRef(),r=i.ref(!1),{alpha:a=!0,antialias:n=!0,depth:s,logarithmicDepthBuffer:f,failIfMajorPerformanceCaveat:o,precision:u,premultipliedAlpha:p,stencil:m,shadows:h=!1,shadowMapType:v=l.PCFShadowMap,physicallyCorrectLights:x=!1,useLegacyLights:w=!1,outputEncoding:S=l.LinearEncoding,toneMapping:b=l.NoToneMapping,toneMappingExposure:F=1,context:_e=void 0,powerPreference:De="default",preserveDrawingBuffer:ze=!1,clearColor:O,windowSize:ae=!1,preset:Be=void 0}=i.toRefs(e),{state:y,setState:G}=M(),{width:re,height:oe}=c.resolveUnref(ae)?c.useWindowSize():c.useElementSize(y.container),{logError:Fe,logWarning:We}=L(),{pixelRatio:se}=c.useDevicePixelRatio(),{pause:Ie,resume:Re}=_(),$=i.computed(()=>re.value/oe.value);!c.resolveUnref(ae)&&((ue=(fe=y.container)==null?void 0:fe.value)==null?void 0:ue.offsetHeight)===0&&We(`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 ie=()=>{t.value&&(t.value.setSize(re.value,oe.value),t.value.setPixelRatio(Math.min(se.value,2)))},ce=()=>{if(!t.value)return;const P=c.resolveUnref(Be);if(P){P in R||Fe("Renderer Preset must be one of these: "+Object.keys(R).join(", ")),X(t.value,R[P]);return}t.value.shadowMap.enabled=c.resolveUnref(h),t.value.shadowMap.type=c.resolveUnref(v),t.value.toneMapping=c.resolveUnref(b)||l.NoToneMapping,t.value.toneMappingExposure=c.resolveUnref(F),t.value.outputEncoding=c.resolveUnref(S)||l.LinearEncoding,O!=null&&O.value&&t.value.setClearColor(ge(c.resolveUnref(O))),t.value.useLegacyLights=c.resolveUnref(w)},Ne=()=>{const P=c.unrefElement(y.canvas);P&&(t.value=new l.WebGLRenderer({canvas:P,alpha:c.resolveUnref(a),antialias:c.resolveUnref(n),context:c.resolveUnref(_e),depth:c.resolveUnref(s),failIfMajorPerformanceCaveat:c.resolveUnref(o),logarithmicDepthBuffer:c.resolveUnref(f),powerPreference:c.resolveUnref(De),precision:c.resolveUnref(u),stencil:c.resolveUnref(m),preserveDrawingBuffer:c.resolveUnref(ze),premultipliedAlpha:c.resolveUnref(p)}),G("renderer",t.value),G("clock",new l.Clock),G("aspectRatio",$),ce(),ie(),Re(),r.value=!0)},Ge=()=>{t.value&&(t.value.dispose(),t.value=void 0,r.value=!1,Ie())};return i.watch([$,se],ie),i.watch([h,v,S,w,b,F,O],ce),i.watch(()=>[y.canvas,y.container],()=>{c.unrefElement(y.canvas)&&c.unrefElement(y.container)&&Ne()},{immediate:!0,deep:!0}),{renderer:t,isReady:r,dispose:Ge,aspectRatio:$}}const Q=e=>!!e&&e.constructor===Array;function Z(e){const t={nodes:{},materials:{}};return e&&e.traverse(r=>{r.name&&(t.nodes[r.name]=r),r.material&&!t.materials[r.material.name]&&(t.materials[r.material.name]=r.material)}),t}async function be(e,t,r,a,n){const{logError:s}=L(),f=new e;n&&n(f),r&&r(f);const u=(Array.isArray(t)?t:[t]).map(p=>new Promise((m,h)=>{f.load(p,v=>{v.scene&&Object.assign(v,Z(v.scene)),m(v)},a,v=>h(s("[useLoader] - Failed to load resource",v)))}));return Q(t)?await Promise.all(u):await u[0]}async function ye(e){const t=new l.LoadingManager,r=new l.TextureLoader(t),a=n=>new Promise((s,f)=>{r.load(n,o=>s(o),()=>null,()=>{f(new Error("[useTextures] - Failed to load texture"))})});if(Q(e)){const n=await Promise.all(e.map(s=>a(s)));return e.length>1?n:n[0]}else{const{map:n,displacementMap:s,normalMap:f,roughnessMap:o,metalnessMap:u,aoMap:p,alphaMap:m,matcap:h}=e;return{map:n?await a(n):null,displacementMap:s?await a(s):null,normalMap:f?await a(f):null,roughnessMap:o?await a(o):null,metalnessMap:u?await a(u):null,aoMap:p?await a(p):null,alphaMap:m?await a(m):null,matcap:h?await a(h):null}}}const g=["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 Ce(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0,a=Math.random()*4294967295|0;return(g[e&255]+g[e>>8&255]+g[e>>16&255]+g[e>>24&255]+"-"+g[t&255]+g[t>>8&255]+"-"+g[t>>16&15|64]+g[t>>24&255]+"-"+g[r&63|128]+g[r>>8&255]+"-"+g[r>>16&255]+g[r>>24&255]+g[a&255]+g[a>>8&255]+g[a>>16&255]+g[a>>24&255]).toLowerCase()}const E=Symbol();function H(){const e=i.shallowReactive({uuid:Ce(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:i.computed(()=>window.innerWidth/window.innerHeight)});function t(n){return e[n]}function r(n,s){e[n]=s}const a={state:e,...i.toRefs(e),getState:t,setState:r};return i.provide(E,a),a}const M=()=>i.inject(E,{state:i.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})}),ee=i.shallowRef(new l.Raycaster),z=i.ref(new l.Vector2),Me=i.ref(null);function N(){const{setState:e}=M();e("raycaster",ee.value),e("pointer",z),e("currentInstance",Me);function t(r){z.value.x=r.clientX/window.innerWidth*2-1,z.value.y=-(r.clientY/window.innerHeight)*2+1}return window.addEventListener("pointermove",t),{raycaster:ee,pointer:z}}const Le=!0,te="[TresJS ▲ ■ ●] ";function L(){function e(a,n){console.error(`${te} ${a}`,n||"")}function t(a){console.warn(`${te} ${a}`)}function r(a,n){}return{logError:e,logWarning:t,logMessage:r}}function xe(){const{logWarning:e}=L();function t(a,n,s){let f=null;return a.traverse(o=>{o[n]===s&&(f=o)}),f||e(`Child with ${n} '${s}' not found.`),f}function r(a,n){return t(a,"name",n)}return{seek:t,seekByName:r}}const{logWarning:Se}=L();function Pe(e){for(const t in e)if(t.indexOf("on")===0)return!0;return!1}function qe(e){}let B=null;const ke={createElement(e,t,r,a){if(e==="template"||he(e))return null;let n;if(a===null&&(a={}),a!=null&&a.args?n=new U.value[e.replace("Tres","")](...a.args):n=new U.value[e.replace("Tres","")],n.isCamera){(!(a!=null&&a.position)||a!=null&&a.position.every(f=>f==0))&&Se("Camera is positioned at the center of the scene [0,0,0], if this is not intentional try setting a position if your scene seems empty 🤗");const{pushCamera:s}=A();s(n)}return(a==null?void 0:a.attach)===void 0&&(n.isMaterial?n.attach="material":n.isBufferGeometry&&(n.attach="geometry")),n},insert(e,t,r){if(B===null&&t.isScene&&(B=t),t===null&&(t=B),t!=null&&t.isObject3D&&(e!=null&&e.isObject3D)){const f=r?t.children.indexOf(r):0;e.parent=t,t.children.splice(f,0,e),e.dispatchEvent({type:"added"})}else typeof(e==null?void 0:e.attach)=="string"&&(e.__previousAttach=e[t==null?void 0:t.attach],t&&(t[e.attach]=e));const{onLoop:a}=_();let n=null,s=null;if(e&&e instanceof l.Mesh&&Pe(e)){const{raycaster:f}=N();a(()=>{var o,u,p;if(t!=null&&t.children&&e&&f){const m=f.value.intersectObjects(t.children);m.length>0&&m[0].object.uuid===e.uuid?(s=m[0],(n===null||n.object.uuid!==(s==null?void 0:s.object.uuid))&&((o=e.onPointerEnter)==null||o.call(e,s)),(u=e.onPointerMove)==null||u.call(e,s)):(s=null,n!==null&&((p=e.onPointerLeave)==null||p.call(e,n))),n=s}}),c.useEventListener(window,"click",()=>{var o;s!==null&&((o=e.onClick)==null||o.call(e,s))})}},remove(e){if(!e)return;const t=e.parentNode;t&&t.removeChild(e)},patchProp(e,t,r,a){if(e){let n=e,s=t;const f=D(s);let o=n==null?void 0:n[f];if(e.parent||(e.parent=B),n.type==="BufferGeometry"){n.setAttribute(D(s),new l.BufferAttribute(...a));return}if(s.includes("-")&&o===void 0){const p=s.split("-");o=p.reduce((m,h)=>m[D(h)],n),s=p.pop(),o!=null&&o.set||(n=p.reduce((m,h)=>m[D(h)],n))}let u=a;if(u===""&&(u=!0),c.isFunction(o)){Array.isArray(u)?e[f](...u):e[f](u);return}!(o!=null&&o.set)&&!c.isFunction(o)?n[f]=u:o.constructor===u.constructor&&(o!=null&&o.copy)?o==null||o.copy(u):Array.isArray(u)?o.set(...u):!o.isColor&&o.setScalar?o.setScalar(u):o.set(u)}},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:Oe}=i.createRenderer(ke),Ue=e=>{const t=Oe(r);function r(){return e&&e.default?e.default():[]}return t};W(q);const{logWarning:Ae}=L(),je=i.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset"],setup(e,{slots:t,expose:r}){e.physicallyCorrectLights===!0&&Ae("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const a=i.ref(),n=i.ref(),s=new q.Scene,{setState:f}=M();f("scene",s),f("canvas",n),f("container",a);const{pushCamera:o}=A();o(new l.PerspectiveCamera),i.onMounted(()=>{u()}),i.onUnmounted(()=>{f("renderer",null)});function u(){const{renderer:h}=J(e),{activeCamera:v}=A(),{onLoop:x}=_(),{raycaster:w,pointer:S}=N();i.watchEffect(()=>{v.value&&w.value.setFromCamera(S.value,v.value)}),x(()=>{var b;v.value&&((b=h.value)==null||b.render(s,v.value))})}let p;function m(){p=Ue(t),p.provide("useTres",M()),p.provide("extend",W),p.mount(s)}return m(),r({scene:s}),()=>i.h(i.h("div",{ref:a,"data-scene":s.uuid,key:s.uuid,style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto",touchAction:"none"}},[i.h("div",{style:{width:"100%",height:"100%"}},[i.h("canvas",{ref:n,"data-scene":s.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),ne=i.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset"],setup(e,{slots:t,expose:r}){const a=H();return r(a),()=>i.h(je,e,t)}}),Te={install(e){e.component("TresCanvas",ne)}};d.CameraType=V,d.TresCanvas=ne,d.catalogue=U,d.default=Te,d.extend=W,d.isProd=Le,d.trasverseObjects=Z,d.useCamera=A,d.useLoader=be,d.useLogger=L,d.useRaycaster=N,d.useRenderLoop=_,d.useRenderer=J,d.useSeek=xe,d.useTexture=ye,d.useTres=M,d.useTresProvider=H,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
8
+ (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("three"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","three","@vueuse/core"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.tres={},d.Vue,d.Three,d.VueUseCore))})(this,function(d,s,u,c){"use strict";function pe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const K=pe(u),_=s.ref({uuid:u.MathUtils.generateUUID()}),N=e=>void Object.assign(_.value,e);var X=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(X||{});const me=45;let x;function D(){const{state:e,setState:t,aspectRatio:r}=P();function n(o="Perspective",l){var p,w,v;if(o==="Perspective"){const{near:m,far:U,fov:b}=l||{near:.1,far:1e3,fov:me};x=new u.PerspectiveCamera(b,((p=e.aspectRatio)==null?void 0:p.value)||window.innerWidth/window.innerHeight,m,U),(w=e.cameras)==null||w.push(x)}else{const{left:m,right:U,top:b,bottom:O,near:y,far:g}=l||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};x=new u.OrthographicCamera(m,U,b,O,y,g),(v=e.cameras)==null||v.push(x)}return e.camera=x,t("camera",e.camera),x}function a(){var o;e.camera instanceof u.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(o=e.camera)==null||o.updateProjectionMatrix()}function i(o){var l;(l=e.cameras)==null||l.push(o),o instanceof u.PerspectiveCamera&&e.aspectRatio&&(o.aspect=e.aspectRatio.value),o.updateProjectionMatrix(),t("camera",o)}function f(){e.cameras=[]}return s.watchEffect(()=>{r!=null&&r.value&&a()}),{activeCamera:s.toRef(e,"camera"),createCamera:n,updateCamera:a,pushCamera:i,clearCameras:f}}const J=c.createEventHook(),Q=c.createEventHook(),G=c.createEventHook(),j=new u.Clock;let z=0,B=0;const{pause:he,resume:ve,isActive:ge}=c.useRafFn(()=>{J.trigger({delta:z,elapsed:B,clock:j}),Q.trigger({delta:z,elapsed:B,clock:j}),G.trigger({delta:z,elapsed:B,clock:j})},{immediate:!1});G.on(()=>{z=j.getDelta(),B=j.getElapsedTime()});function $(){return{onBeforeLoop:J.on,onLoop:Q.on,onAfterLoop:G.on,pause:he,resume:ve,isActive:ge}}function we(e){return e instanceof u.Color?e:Array.isArray(e)?new u.Color(...e):new u.Color(e)}const q={realistic:{outputEncoding:u.sRGBEncoding,toneMapping:u.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:u.PCFSoftShadowMap}}},Z=(e,t)=>{for(const r of Object.keys(t))t[r]instanceof Object&&Object.assign(t[r],Z(e[r],t[r]));return Object.assign(e||{},t),e},be=ye("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 F(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function ye(e,t){const r=Object.create(null),n=e.split(",");for(let a=0;a<n.length;a++)r[n[a]]=!0;return t?a=>!!r[a.toLowerCase()]:a=>!!r[a]}function E(e){var ue,de;const t=s.shallowRef(),r=s.ref(!1),{alpha:n=!0,antialias:a=!0,depth:i,logarithmicDepthBuffer:f,failIfMajorPerformanceCaveat:o,precision:l,premultipliedAlpha:p,stencil:w,shadows:v=!1,shadowMapType:m=u.PCFShadowMap,physicallyCorrectLights:U=!1,useLegacyLights:b=!1,outputEncoding:O=u.LinearEncoding,toneMapping:y=u.NoToneMapping,toneMappingExposure:g=1,context:M=void 0,powerPreference:L="default",preserveDrawingBuffer:W=!1,clearColor:C,windowSize:T=!1,preset:I=void 0}=s.toRefs(e),{state:S,setState:V}=P(),{width:ie,height:se}=c.resolveUnref(T)?c.useWindowSize():c.useElementSize(S.container),{logError:ze,logWarning:Be}=k(),{pixelRatio:ce}=c.useDevicePixelRatio(),{pause:Fe,resume:Re}=$(),Y=s.computed(()=>ie.value/se.value);!c.resolveUnref(T)&&((de=(ue=S.container)==null?void 0:ue.value)==null?void 0:de.offsetHeight)===0&&Be(`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 fe=()=>{t.value&&(t.value.setSize(ie.value,se.value),t.value.setPixelRatio(Math.min(ce.value,2)))},le=()=>{if(!t.value)return;const A=c.resolveUnref(I);if(A){A in q||ze("Renderer Preset must be one of these: "+Object.keys(q).join(", ")),Z(t.value,q[A]);return}t.value.shadowMap.enabled=c.resolveUnref(v),t.value.shadowMap.type=c.resolveUnref(m),t.value.toneMapping=c.resolveUnref(y)||u.NoToneMapping,t.value.toneMappingExposure=c.resolveUnref(g),t.value.outputEncoding=c.resolveUnref(O)||u.LinearEncoding,C!=null&&C.value&&t.value.setClearColor(we(c.resolveUnref(C))),t.value.useLegacyLights=c.resolveUnref(b)},We=()=>{const A=c.unrefElement(S.canvas);A&&(t.value=new u.WebGLRenderer({canvas:A,alpha:c.resolveUnref(n),antialias:c.resolveUnref(a),context:c.resolveUnref(M),depth:c.resolveUnref(i),failIfMajorPerformanceCaveat:c.resolveUnref(o),logarithmicDepthBuffer:c.resolveUnref(f),powerPreference:c.resolveUnref(L),precision:c.resolveUnref(l),stencil:c.resolveUnref(w),preserveDrawingBuffer:c.resolveUnref(W),premultipliedAlpha:c.resolveUnref(p)}),V("renderer",t.value),V("clock",new u.Clock),V("aspectRatio",Y),le(),fe(),Re(),r.value=!0)},Ie=()=>{t.value&&(t.value.dispose(),t.value=void 0,r.value=!1,Fe())};return s.watch([Y,ce],fe),s.watch([v,m,O,b,y,g,C],le),s.watch(()=>[S.canvas,S.container],()=>{c.unrefElement(S.canvas)&&c.unrefElement(S.container)&&We()},{immediate:!0,deep:!0}),{renderer:t,isReady:r,dispose:Ie,aspectRatio:Y}}const H=e=>!!e&&e.constructor===Array;function ee(e){const t={nodes:{},materials:{}};return e&&e.traverse(r=>{r.name&&(t.nodes[r.name]=r),r.material&&!t.materials[r.material.name]&&(t.materials[r.material.name]=r.material)}),t}async function Ce(e,t,r,n,a){const{logError:i}=k(),f=new e;a&&a(f),r&&r(f);const l=(Array.isArray(t)?t:[t]).map(p=>new Promise((w,v)=>{f.load(p,m=>{m.scene&&Object.assign(m,ee(m.scene)),w(m)},n,m=>v(i("[useLoader] - Failed to load resource",m)))}));return H(t)?await Promise.all(l):await l[0]}async function Me(e){const t=new u.LoadingManager,r=new u.TextureLoader(t),n=a=>new Promise((i,f)=>{r.load(a,o=>i(o),()=>null,()=>{f(new Error("[useTextures] - Failed to load texture"))})});if(H(e)){const a=await Promise.all(e.map(i=>n(i)));return e.length>1?a:a[0]}else{const{map:a,displacementMap:i,normalMap:f,roughnessMap:o,metalnessMap:l,aoMap:p,alphaMap:w,matcap:v}=e;return{map:a?await n(a):null,displacementMap:i?await n(i):null,normalMap:f?await n(f):null,roughnessMap:o?await n(o):null,metalnessMap:l?await n(l):null,aoMap:p?await n(p):null,alphaMap:w?await n(w):null,matcap:v?await n(v):null}}}const 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 Le(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0,n=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[r&63|128]+h[r>>8&255]+"-"+h[r>>16&255]+h[r>>24&255]+h[n&255]+h[n>>8&255]+h[n>>16&255]+h[n>>24&255]).toLowerCase()}const te=Symbol();function ne(){const e=s.shallowReactive({uuid:Le(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:s.computed(()=>window.innerWidth/window.innerHeight)});function t(a){return e[a]}function r(a,i){e[a]=i}const n={state:e,...s.toRefs(e),getState:t,setState:r};return s.provide(te,n),n}const P=()=>s.inject(te,{state:s.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});function ae(){var f;const e=s.shallowRef(new u.Raycaster),t=s.ref(new u.Vector2),r=s.ref(null),{setState:n,state:a}=P();n("raycaster",e.value),n("pointer",t),n("currentInstance",r);function i(o){t.value.x=o.clientX/window.innerWidth*2-1,t.value.y=-(o.clientY/window.innerHeight)*2+1}return(f=a==null?void 0:a.renderer)==null||f.domElement.addEventListener("pointermove",i),s.onUnmounted(()=>{var o;(o=a==null?void 0:a.renderer)==null||o.domElement.removeEventListener("pointermove",i)}),{raycaster:e,pointer:t}}const Se=!0,re="[TresJS ▲ ■ ●] ";function k(){function e(n,a){console.error(`${re} ${n}`,a||"")}function t(n){console.warn(`${re} ${n}`)}function r(n,a){}return{logError:e,logWarning:t,logMessage:r}}function xe(){const{logWarning:e}=k();function t(n,a,i){let f=null;return n.traverse(o=>{o[a]===i&&(f=o)}),f||e(`Child with ${a} '${i}' not found.`),f}function r(n,a){return t(n,"name",a)}return{seek:t,seekByName:r}}const{logWarning:Pe}=k(),ke=/^on[^a-z]/,Ue=e=>ke.test(e);function Ge(e){}let R=null;const Oe={createElement(e,t,r,n){if(e==="template"||be(e))return null;let a;if(n===null&&(n={}),n!=null&&n.args?a=new _.value[e.replace("Tres","")](...n.args):a=new _.value[e.replace("Tres","")],a.isCamera){(!(n!=null&&n.position)||n!=null&&n.position.every(f=>f==0))&&Pe("Camera is positioned at the center of the scene [0,0,0], if this is not intentional try setting a position if your scene seems empty 🤗");const{pushCamera:i}=D();i(a)}return(n==null?void 0:n.attach)===void 0&&(a.isMaterial?a.attach="material":a.isBufferGeometry&&(a.attach="geometry")),a.events={},a},insert(e,t,r){if(R===null&&t.isScene&&(R=t),t===null&&(t=R),t!=null&&t.isObject3D&&(e!=null&&e.isObject3D)){const n=r?t.children.indexOf(r):0;e.parent=t,t.children.splice(n,0,e),e.dispatchEvent({type:"added"})}else typeof(e==null?void 0:e.attach)=="string"&&(e.__previousAttach=e[t==null?void 0:t.attach],t&&(t[e.attach]=e))},remove(e){if(!e)return;const t=e.parentNode;t&&t.removeChild(e)},patchProp(e,t,r,n){if(e){let a=e,i=t;const f=F(i);let o=a==null?void 0:a[f];if(e.parent||(e.parent=R),a.type==="BufferGeometry"){a.setAttribute(F(i),new u.BufferAttribute(...n));return}if(i.includes("-")&&o===void 0){const p=i.split("-");o=p.reduce((w,v)=>w[F(v)],a),i=p.pop(),o!=null&&o.set||(a=p.reduce((w,v)=>w[F(v)],a))}Ue(i)&&(e.events[i]=n);let l=n;if(l===""&&(l=!0),c.isFunction(o)){Array.isArray(l)?e[f](...l):e[f](l);return}!(o!=null&&o.set)&&!c.isFunction(o)?a[f]=l:o.constructor===l.constructor&&(o!=null&&o.copy)?o==null||o.copy(l):Array.isArray(l)?o.set(...l):!o.isColor&&o.setScalar?o.setScalar(l):o.set(l)}},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:Ae}=s.createRenderer(Oe),je=e=>{const t=Ae(r);function r(){return e&&e.default?e.default():[]}return t};N(K);const{logWarning:Te}=k(),_e=s.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset"],setup(e,{slots:t,expose:r}){e.physicallyCorrectLights===!0&&Te("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const n=s.ref(),a=s.ref(),i=new K.Scene,{setState:f}=P();f("scene",i),f("canvas",a),f("container",n);const{pushCamera:o}=D();o(new u.PerspectiveCamera),s.onMounted(()=>{l()}),s.onUnmounted(()=>{f("renderer",null)});function l(){const{renderer:v}=E(e),{activeCamera:m}=D(),{onLoop:U}=$(),{raycaster:b,pointer:O}=ae();let y=null,g=null;s.watchEffect(()=>{m.value&&b.value.setFromCamera(O.value,m.value)}),U(()=>{var M,L,W,C,T;if(m.value&&((M=v.value)==null||M.render(i,m.value)),b.value){const I=b.value.intersectObjects(i.children);I.length>0?(g=I[0],y===null&&((W=(L=g.object.events).onPointerEnter)==null||W.call(L,g))):y!==null&&((T=g==null?void 0:(C=g.object.events).onPointerLeave)==null||T.call(C,y),g=null),y=g}}),c.useEventListener(a.value,"click",()=>{var M,L;g!==null&&((L=(M=g.object.events).onClick)==null||L.call(M,g))})}let p;function w(){p=je(t),p.provide("useTres",P()),p.provide("extend",N),p.mount(i)}return w(),r({scene:i}),()=>s.h(s.h("div",{ref:n,"data-scene":i.uuid,key:i.uuid,style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto",touchAction:"none"}},[s.h("div",{style:{width:"100%",height:"100%"}},[s.h("canvas",{ref:a,"data-scene":i.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),oe=s.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset"],setup(e,{slots:t,expose:r}){const n=ne();return r(n),()=>s.h(_e,e,t)}}),De={install(e){e.component("TresCanvas",oe)}};d.CameraType=X,d.TresCanvas=oe,d.catalogue=_,d.default=De,d.extend=N,d.isProd=Se,d.trasverseObjects=ee,d.useCamera=D,d.useLoader=Ce,d.useLogger=k,d.useRaycaster=ae,d.useRenderLoop=$,d.useRenderer=E,d.useSeek=xe,d.useTexture=Me,d.useTres=P,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.0.0-beta.1",
4
+ "version": "2.0.0-beta.2",
5
5
  "type": "module",
6
6
  "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
7
7
  "files": [