@tresjs/core 2.0.0-beta.12 → 2.0.0-beta.13

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,4 +1,5 @@
1
1
  import { ShadowMapType, TextureEncoding, ToneMapping } from 'three';
2
+ import { CameraType } from '../composables';
2
3
  import { RendererPresetsType } from '../composables/useRenderer/const';
3
4
  export interface TresCanvasProps {
4
5
  shadows?: boolean;
@@ -15,6 +16,7 @@ export interface TresCanvasProps {
15
16
  windowSize?: boolean;
16
17
  preset?: RendererPresetsType;
17
18
  disableRender?: boolean;
19
+ camera?: CameraType;
18
20
  }
19
21
  /**
20
22
  * Vue component for rendering a Tres component.
@@ -1,4 +1,5 @@
1
1
  import { ShadowMapType, TextureEncoding, ToneMapping } from 'three';
2
+ import { CameraType } from '../composables';
2
3
  import { RendererPresetsType } from '../composables/useRenderer/const';
3
4
  export interface TresSceneProps {
4
5
  shadows?: boolean;
@@ -15,6 +16,7 @@ export interface TresSceneProps {
15
16
  windowSize?: boolean;
16
17
  preset?: RendererPresetsType;
17
18
  disableRender?: boolean;
19
+ camera?: CameraType;
18
20
  }
19
21
  export declare const TresScene: import("vue").DefineComponent<TresSceneProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<TresSceneProps>, {}>;
20
22
  export default TresScene;
package/dist/tres.js CHANGED
@@ -1,31 +1,31 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.0.0-beta.12
3
+ * version: v2.0.0-beta.13
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 P, watchEffect as fe, toRef as Se, shallowRef as le, toRefs as de, computed as pe, watch as W, shallowReactive as me, provide as Oe, inject as ke, onUnmounted as ve, createRenderer as je, defineComponent as ge, onMounted as De, h as k } from "vue";
9
- import * as he from "three";
10
- import { MathUtils as Ie, PerspectiveCamera as H, OrthographicCamera as Be, Clock as we, Color as Y, sRGBEncoding as ze, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ge, PCFShadowMap as Ve, LinearEncoding as ae, NoToneMapping as ne, WebGLRenderer as Ue, LoadingManager as We, TextureLoader as He, Raycaster as Ye, Vector2 as $e, BufferAttribute as Ne } from "three";
11
- import { createEventHook as q, useRafFn as qe, resolveUnref as f, useWindowSize as Ke, useElementSize as Je, useDevicePixelRatio as Xe, unrefElement as $, isFunction as re, useEventListener as Qe } from "@vueuse/core";
12
- const be = P({ uuid: Ie.generateUUID() }), ye = (e) => void Object.assign(be.value, e);
8
+ import { ref as R, watchEffect as le, toRef as Se, shallowRef as de, toRefs as me, computed as pe, watch as V, shallowReactive as ve, provide as Oe, inject as ke, onUnmounted as ge, createRenderer as je, defineComponent as he, onMounted as De, h as D } from "vue";
9
+ import * as we from "three";
10
+ import { MathUtils as Ie, PerspectiveCamera as $, OrthographicCamera as Be, Clock as be, Color as N, sRGBEncoding as ze, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ge, PCFShadowMap as Ve, LinearEncoding as ne, NoToneMapping as re, WebGLRenderer as Ue, LoadingManager as We, TextureLoader as He, Raycaster as Ye, Vector2 as $e, BufferAttribute as Ne } from "three";
11
+ import { createEventHook as J, useRafFn as qe, resolveUnref as l, useWindowSize as Ke, useElementSize as Je, useDevicePixelRatio as Xe, unrefElement as q, isFunction as oe, useEventListener as Qe } from "@vueuse/core";
12
+ const ye = R({ uuid: Ie.generateUUID() }), Me = (e) => void Object.assign(ye.value, e);
13
13
  var Ze = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ze || {});
14
14
  const et = 45;
15
- let _;
16
- function Me() {
17
- const { state: e, setState: t, aspectRatio: o } = S();
15
+ let S;
16
+ function xe() {
17
+ const { state: e, setState: t, aspectRatio: o } = O();
18
18
  function a(i = "Perspective", s) {
19
- var l, u, p;
19
+ var u, f, d;
20
20
  if (i === "Perspective") {
21
- const { near: d, far: w, fov: M } = s || {
21
+ const { near: p, far: b, fov: x } = s || {
22
22
  near: 0.1,
23
23
  far: 1e3,
24
24
  fov: et
25
25
  };
26
- _ = new H(M, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, d, w), (u = e.cameras) == null || u.push(_);
26
+ S = new $(x, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, p, b), (f = e.cameras) == null || f.push(S);
27
27
  } else {
28
- const { left: d, right: w, top: M, bottom: x, near: L, far: b } = s || {
28
+ const { left: p, right: b, top: x, bottom: g, near: P, far: E } = s || {
29
29
  left: -100,
30
30
  right: 100,
31
31
  top: 100,
@@ -33,22 +33,22 @@ function Me() {
33
33
  near: 0.1,
34
34
  far: 1e3
35
35
  };
36
- _ = new Be(d, w, M, x, L, b), (p = e.cameras) == null || p.push(_);
36
+ S = new Be(p, b, x, g, P, E), (d = e.cameras) == null || d.push(S);
37
37
  }
38
- return e.camera = _, t("camera", e.camera), _;
38
+ return e.camera = S, t("camera", e.camera), S;
39
39
  }
40
40
  function n() {
41
41
  var i;
42
- e.camera instanceof H && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (i = e.camera) == null || i.updateProjectionMatrix();
42
+ e.camera instanceof $ && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (i = e.camera) == null || i.updateProjectionMatrix();
43
43
  }
44
44
  function r(i) {
45
45
  var s;
46
- (s = e.cameras) == null || s.push(i), i instanceof H && e.aspectRatio && (i.aspect = e.aspectRatio.value), i.updateProjectionMatrix(), t("camera", i);
46
+ (s = e.cameras) == null || s.push(i), i instanceof $ && e.aspectRatio && (i.aspect = e.aspectRatio.value), i.updateProjectionMatrix(), t("camera", i);
47
47
  }
48
48
  function c() {
49
49
  e.cameras = [];
50
50
  }
51
- return fe(() => {
51
+ return le(() => {
52
52
  o != null && o.value && n();
53
53
  }), {
54
54
  activeCamera: Se(e, "camera"),
@@ -58,31 +58,31 @@ function Me() {
58
58
  clearCameras: c
59
59
  };
60
60
  }
61
- const xe = q(), Ee = q(), K = q(), j = new we();
62
- let G = 0, V = 0;
61
+ const Ee = J(), Ce = J(), X = J(), I = new be();
62
+ let U = 0, W = 0;
63
63
  const { pause: tt, resume: at, isActive: nt } = qe(
64
64
  () => {
65
- xe.trigger({ delta: G, elapsed: V, clock: j }), Ee.trigger({ delta: G, elapsed: V, clock: j }), K.trigger({ delta: G, elapsed: V, clock: j });
65
+ Ee.trigger({ delta: U, elapsed: W, clock: I }), Ce.trigger({ delta: U, elapsed: W, clock: I }), X.trigger({ delta: U, elapsed: W, clock: I });
66
66
  },
67
67
  { immediate: !1 }
68
68
  );
69
- K.on(() => {
70
- G = j.getDelta(), V = j.getElapsedTime();
69
+ X.on(() => {
70
+ U = I.getDelta(), W = I.getElapsedTime();
71
71
  });
72
- function Ce() {
72
+ function Re() {
73
73
  return {
74
- onBeforeLoop: xe.on,
75
- onLoop: Ee.on,
76
- onAfterLoop: K.on,
74
+ onBeforeLoop: Ee.on,
75
+ onLoop: Ce.on,
76
+ onAfterLoop: X.on,
77
77
  pause: tt,
78
78
  resume: at,
79
79
  isActive: nt
80
80
  };
81
81
  }
82
82
  function rt(e) {
83
- return e instanceof Y ? e : Array.isArray(e) ? new Y(...e) : new Y(e);
83
+ return e instanceof N ? e : Array.isArray(e) ? new N(...e) : new N(e);
84
84
  }
85
- const N = {
85
+ const K = {
86
86
  realistic: {
87
87
  outputEncoding: ze,
88
88
  toneMapping: Fe,
@@ -92,12 +92,12 @@ const N = {
92
92
  type: Ge
93
93
  }
94
94
  }
95
- }, Re = (e, t) => {
95
+ }, Pe = (e, t) => {
96
96
  for (const o of Object.keys(t))
97
- t[o] instanceof Object && Object.assign(t[o], Re(e[o], t[o]));
97
+ t[o] instanceof Object && Object.assign(t[o], Pe(e[o], t[o]));
98
98
  return Object.assign(e || {}, t), e;
99
99
  }, ot = "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", it = /* @__PURE__ */ st(ot);
100
- function F(e) {
100
+ function G(e) {
101
101
  return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase());
102
102
  }
103
103
  function st(e, t) {
@@ -107,79 +107,79 @@ function st(e, t) {
107
107
  return t ? (n) => !!o[n.toLowerCase()] : (n) => !!o[n];
108
108
  }
109
109
  function ct(e) {
110
- var ee, te;
111
- const t = le(), o = P(!1), {
110
+ var te, ae;
111
+ const t = de(), o = R(!1), {
112
112
  alpha: a = !0,
113
113
  antialias: n = !0,
114
114
  depth: r,
115
115
  logarithmicDepthBuffer: c,
116
116
  failIfMajorPerformanceCaveat: i,
117
117
  precision: s,
118
- premultipliedAlpha: l,
119
- stencil: u,
120
- shadows: p = !1,
121
- shadowMapType: d = Ve,
122
- physicallyCorrectLights: w = !1,
123
- useLegacyLights: M = !1,
124
- outputEncoding: x = ae,
125
- toneMapping: L = ne,
126
- toneMappingExposure: b = 1,
127
- context: v = void 0,
128
- powerPreference: E = "default",
129
- preserveDrawingBuffer: y = !1,
130
- clearColor: g,
131
- windowSize: C = !1,
132
- preset: I = void 0
133
- } = de(e), { state: h, setState: T } = S(), { width: O, height: R } = f(C) == !0 || f(C) === "" || f(C) === "true" ? Ke() : Je(h.container), { logError: B, logWarning: z } = D(), { pixelRatio: X } = Xe(), { pause: Le, resume: Te } = Ce(), U = pe(() => O.value / R.value);
134
- !f(C) && ((te = (ee = h.container) == null ? void 0 : ee.value) == null ? void 0 : te.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.
118
+ premultipliedAlpha: u,
119
+ stencil: f,
120
+ shadows: d = !1,
121
+ shadowMapType: p = Ve,
122
+ physicallyCorrectLights: b = !1,
123
+ useLegacyLights: x = !1,
124
+ outputEncoding: g = ne,
125
+ toneMapping: P = re,
126
+ toneMappingExposure: E = 1,
127
+ context: H = void 0,
128
+ powerPreference: L = "default",
129
+ preserveDrawingBuffer: v = !1,
130
+ clearColor: w,
131
+ windowSize: h = !1,
132
+ preset: M = void 0
133
+ } = me(e), { state: y, setState: T } = O(), { width: C, height: k } = l(h) == !0 || l(h) === "" || l(h) === "true" ? Ke() : Je(y.container), { logError: z, logWarning: A } = B(), { pixelRatio: j } = Xe(), { pause: F, resume: Te } = Re(), Y = pe(() => C.value / k.value);
134
+ !l(h) && ((ae = (te = y.container) == null ? void 0 : te.value) == null ? void 0 : ae.offsetHeight) === 0 && A(`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 Q = () => {
137
- t.value && (t.value.setSize(O.value, R.value), t.value.setPixelRatio(Math.min(X.value, 2)));
138
- }, Z = () => {
136
+ const Z = () => {
137
+ t.value && (t.value.setSize(C.value, k.value), t.value.setPixelRatio(Math.min(j.value, 2)));
138
+ }, ee = () => {
139
139
  if (!t.value)
140
140
  return;
141
- const A = f(I);
142
- if (A) {
143
- A in N || B("Renderer Preset must be one of these: " + Object.keys(N).join(", ")), Re(t.value, N[A]);
141
+ const _ = l(M);
142
+ if (_) {
143
+ _ in K || z("Renderer Preset must be one of these: " + Object.keys(K).join(", ")), Pe(t.value, K[_]);
144
144
  return;
145
145
  }
146
- t.value.shadowMap.enabled = f(p), t.value.shadowMap.type = f(d), t.value.toneMapping = f(L) || ne, t.value.toneMappingExposure = f(b), t.value.outputEncoding = f(x) || ae, g != null && g.value && t.value.setClearColor(rt(f(g))), t.value.useLegacyLights = f(M);
146
+ t.value.shadowMap.enabled = l(d), t.value.shadowMap.type = l(p), t.value.toneMapping = l(P) || re, t.value.toneMappingExposure = l(E), t.value.outputEncoding = l(g) || ne, w != null && w.value && t.value.setClearColor(rt(l(w))), t.value.useLegacyLights = l(x);
147
147
  }, Ae = () => {
148
- const A = $(h.canvas);
149
- A && (t.value = new Ue({
150
- canvas: A,
151
- alpha: f(a),
152
- antialias: f(n),
153
- context: f(v),
154
- depth: f(r),
155
- failIfMajorPerformanceCaveat: f(i),
156
- logarithmicDepthBuffer: f(c),
157
- powerPreference: f(E),
158
- precision: f(s),
159
- stencil: f(u),
160
- preserveDrawingBuffer: f(y),
161
- premultipliedAlpha: f(l)
162
- }), T("renderer", t.value), T("clock", new we()), T("aspectRatio", U), Z(), Q(), Te(), o.value = !0);
148
+ const _ = q(y.canvas);
149
+ _ && (t.value = new Ue({
150
+ canvas: _,
151
+ alpha: l(a),
152
+ antialias: l(n),
153
+ context: l(H),
154
+ depth: l(r),
155
+ failIfMajorPerformanceCaveat: l(i),
156
+ logarithmicDepthBuffer: l(c),
157
+ powerPreference: l(L),
158
+ precision: l(s),
159
+ stencil: l(f),
160
+ preserveDrawingBuffer: l(v),
161
+ premultipliedAlpha: l(u)
162
+ }), T("renderer", t.value), T("clock", new be()), T("aspectRatio", Y), ee(), Z(), Te(), o.value = !0);
163
163
  }, _e = () => {
164
- t.value && (t.value.dispose(), t.value = void 0, o.value = !1, Le());
164
+ t.value && (t.value.dispose(), t.value = void 0, o.value = !1, F());
165
165
  };
166
- return W([U, X], Q), W(
167
- [p, d, x, M, L, b, g],
168
- Z
169
- ), W(
170
- () => [h.canvas, h.container],
166
+ return V([Y, j], Z), V(
167
+ [d, p, g, x, P, E, w],
168
+ ee
169
+ ), V(
170
+ () => [y.canvas, y.container],
171
171
  () => {
172
- $(h.canvas) && $(h.container) && Ae();
172
+ q(y.canvas) && q(y.container) && Ae();
173
173
  },
174
174
  { immediate: !0, deep: !0 }
175
175
  ), {
176
176
  renderer: t,
177
177
  isReady: o,
178
178
  dispose: _e,
179
- aspectRatio: U
179
+ aspectRatio: Y
180
180
  };
181
181
  }
182
- const ut = (e) => typeof e == "string", Pe = (e) => !!e && e.constructor === Array;
182
+ const ut = (e) => typeof e == "string", Le = (e) => !!e && e.constructor === Array;
183
183
  function ft(e) {
184
184
  const t = { nodes: {}, materials: {} };
185
185
  return e && e.traverse((o) => {
@@ -187,21 +187,21 @@ function ft(e) {
187
187
  }), t;
188
188
  }
189
189
  async function Ct(e, t, o, a, n) {
190
- const { logError: r } = D(), c = new e();
190
+ const { logError: r } = B(), c = new e();
191
191
  n && n(c), o && o(c);
192
192
  const s = (Array.isArray(t) ? t : [t]).map(
193
- (l) => new Promise((u, p) => {
193
+ (u) => new Promise((f, d) => {
194
194
  c.load(
195
- l,
196
- (d) => {
197
- d.scene && Object.assign(d, ft(d.scene)), u(d);
195
+ u,
196
+ (p) => {
197
+ p.scene && Object.assign(p, ft(p.scene)), f(p);
198
198
  },
199
199
  a,
200
- (d) => p(r("[useLoader] - Failed to load resource", d))
200
+ (p) => d(r("[useLoader] - Failed to load resource", p))
201
201
  );
202
202
  })
203
203
  );
204
- return Pe(t) ? await Promise.all(s) : await s[0];
204
+ return Le(t) ? await Promise.all(s) : await s[0];
205
205
  }
206
206
  async function Rt(e) {
207
207
  const t = new We(), o = new He(t), a = (n) => new Promise((r, c) => {
@@ -214,7 +214,7 @@ async function Rt(e) {
214
214
  }
215
215
  );
216
216
  });
217
- if (Pe(e)) {
217
+ if (Le(e)) {
218
218
  const n = await Promise.all(e.map((r) => a(r)));
219
219
  return e.length > 1 ? n : n[0];
220
220
  } else {
@@ -224,9 +224,9 @@ async function Rt(e) {
224
224
  normalMap: c,
225
225
  roughnessMap: i,
226
226
  metalnessMap: s,
227
- aoMap: l,
228
- alphaMap: u,
229
- matcap: p
227
+ aoMap: u,
228
+ alphaMap: f,
229
+ matcap: d
230
230
  } = e;
231
231
  return {
232
232
  map: n ? await a(n) : null,
@@ -234,9 +234,9 @@ async function Rt(e) {
234
234
  normalMap: c ? await a(c) : null,
235
235
  roughnessMap: i ? await a(i) : null,
236
236
  metalnessMap: s ? await a(s) : null,
237
- aoMap: l ? await a(l) : null,
238
- alphaMap: u ? await a(u) : null,
239
- matcap: p ? await a(p) : null
237
+ aoMap: u ? await a(u) : null,
238
+ alphaMap: f ? await a(f) : null,
239
+ matcap: d ? await a(d) : null
240
240
  };
241
241
  }
242
242
  }
@@ -245,9 +245,9 @@ function lt() {
245
245
  const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, o = 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[o & 63 | 128] + m[o >> 8 & 255] + "-" + m[o >> 16 & 255] + m[o >> 24 & 255] + m[a & 255] + m[a >> 8 & 255] + m[a >> 16 & 255] + m[a >> 24 & 255]).toLowerCase();
247
247
  }
248
- const J = Symbol();
248
+ const Q = Symbol();
249
249
  function dt() {
250
- const e = me({
250
+ const e = ve({
251
251
  uuid: lt(),
252
252
  camera: void 0,
253
253
  cameras: [],
@@ -263,28 +263,28 @@ function dt() {
263
263
  }
264
264
  const a = {
265
265
  state: e,
266
- ...de(e),
266
+ ...me(e),
267
267
  getState: t,
268
268
  setState: o
269
269
  };
270
- return Oe(J, a), a;
270
+ return Oe(Q, a), a;
271
271
  }
272
- const S = () => ke(J, {
273
- state: me({
272
+ const O = () => ke(Q, {
273
+ state: ve({
274
274
  camera: void 0,
275
275
  cameras: [],
276
276
  scene: void 0,
277
277
  renderer: void 0
278
278
  })
279
279
  });
280
- function pt() {
280
+ function mt() {
281
281
  var c;
282
- const e = le(new Ye()), t = P(new $e()), o = P(null), { setState: a, state: n } = S();
282
+ const e = de(new Ye()), t = R(new $e()), o = R(null), { setState: a, state: n } = O();
283
283
  a("raycaster", e.value), a("pointer", t), a("currentInstance", o);
284
284
  function r(i) {
285
285
  t.value.x = i.clientX / window.innerWidth * 2 - 1, t.value.y = -(i.clientY / window.innerHeight) * 2 + 1;
286
286
  }
287
- return (c = n == null ? void 0 : n.renderer) == null || c.domElement.addEventListener("pointermove", r), ve(() => {
287
+ return (c = n == null ? void 0 : n.renderer) == null || c.domElement.addEventListener("pointermove", r), ge(() => {
288
288
  var i;
289
289
  (i = n == null ? void 0 : n.renderer) == null || i.domElement.removeEventListener("pointermove", r);
290
290
  }), {
@@ -292,13 +292,13 @@ function pt() {
292
292
  pointer: t
293
293
  };
294
294
  }
295
- const Pt = !0, oe = "[TresJS ▲ ■ ●] ";
296
- function D() {
295
+ const Pt = !0, ie = "[TresJS ▲ ■ ●] ";
296
+ function B() {
297
297
  function e(a, n) {
298
- console.error(`${oe} ${a}`, n || "");
298
+ console.error(`${ie} ${a}`, n || "");
299
299
  }
300
300
  function t(a) {
301
- console.warn(`${oe} ${a}`);
301
+ console.warn(`${ie} ${a}`);
302
302
  }
303
303
  function o(a, n) {
304
304
  }
@@ -309,7 +309,7 @@ function D() {
309
309
  };
310
310
  }
311
311
  function Lt() {
312
- const { logWarning: e } = D();
312
+ const { logWarning: e } = B();
313
313
  function t(a, n, r) {
314
314
  let c = null;
315
315
  return a.traverse((i) => {
@@ -324,50 +324,50 @@ function Lt() {
324
324
  seekByName: o
325
325
  };
326
326
  }
327
- const mt = /^on[^a-z]/, vt = (e) => mt.test(e);
328
- let ie = null;
329
- const se = {
327
+ const pt = /^on[^a-z]/, vt = (e) => pt.test(e);
328
+ let se = null;
329
+ const ce = {
330
330
  GEOMETRY_VIA_PROP: "tres__geometryViaProp",
331
331
  MATERIAL_VIA_PROP: "tres__materialViaProp"
332
- }, { logError: ce } = D(), gt = {
332
+ }, { logError: ue } = B(), gt = {
333
333
  createElement(e, t, o, a) {
334
- var s, l;
334
+ var s, u;
335
335
  if (a || (a = {}), a.args || (a.args = []), e === "template" || it(e))
336
336
  return null;
337
337
  let n = e.replace("Tres", ""), r;
338
338
  if (e === "primitive") {
339
- (a == null ? void 0 : a.object) === void 0 && ce("Tres primitives need a prop 'object'");
340
- const u = a.object;
341
- n = u.type, r = Object.assign(u, { type: n, attach: a.attach, primitive: !0 });
339
+ (a == null ? void 0 : a.object) === void 0 && ue("Tres primitives need a prop 'object'");
340
+ const f = a.object;
341
+ n = f.type, r = Object.assign(f, { type: n, attach: a.attach, primitive: !0 });
342
342
  } else {
343
- const u = be.value[n];
344
- u || ce(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new u(...a.args);
343
+ const f = ye.value[n];
344
+ f || ue(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new f(...a.args);
345
345
  }
346
346
  if (r.isCamera) {
347
347
  a != null && a.position || r.position.set(3, 3, 3), a != null && a.lookAt || r.lookAt(0, 0, 0);
348
- const { pushCamera: u } = Me();
349
- u(r);
348
+ const { pushCamera: f } = xe();
349
+ f(r);
350
350
  }
351
351
  (a == null ? void 0 : a.attach) === void 0 && (r.isMaterial ? r.attach = "material" : r.isBufferGeometry && (r.attach = "geometry"));
352
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = se;
353
- 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[c] = !0)), r.events = {}, r;
352
+ const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
353
+ return r.isObject3D && ((s = a == null ? void 0 : a.material) != null && s.isMaterial && (r.userData[i] = !0), (u = a == null ? void 0 : a.geometry) != null && u.isBufferGeometry && (r.userData[c] = !0)), r.events = {}, r;
354
354
  },
355
355
  insert(e, t) {
356
356
  var o, a, n, r;
357
357
  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)) {
358
- ie = e;
358
+ se = e;
359
359
  return;
360
360
  }
361
- t || (t = ie), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
361
+ t || (t = se), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
362
362
  },
363
363
  remove(e) {
364
364
  var t, o;
365
365
  if (e) {
366
366
  if (e.isObject3D) {
367
367
  const a = e, n = (r) => {
368
- var s, l;
369
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = se;
370
- r.userData[i] || (s = r.material) == null || s.dispose(), r.userData[c] || (l = r.geometry) == null || l.dispose();
368
+ var s, u;
369
+ const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
370
+ r.userData[i] || (s = r.material) == null || s.dispose(), r.userData[c] || (u = r.geometry) == null || u.dispose();
371
371
  };
372
372
  a.traverse((r) => n(r)), n(a);
373
373
  }
@@ -376,27 +376,27 @@ const se = {
376
376
  },
377
377
  patchProp(e, t, o, a) {
378
378
  if (e) {
379
- let n = e, r = t, c = F(r), i = n == null ? void 0 : n[c];
379
+ let n = e, r = t, c = G(r), i = n == null ? void 0 : n[c];
380
380
  if (n.type === "BufferGeometry") {
381
381
  if (r === "args")
382
382
  return;
383
383
  n.setAttribute(
384
- F(r),
384
+ G(r),
385
385
  new Ne(...a)
386
386
  );
387
387
  return;
388
388
  }
389
389
  if (r.includes("-") && i === void 0) {
390
- const l = r.split("-");
391
- i = l.reduce((u, p) => u[F(p)], n), r = l.pop(), c = r.toLowerCase(), i != null && i.set || (n = l.reduce((u, p) => u[F(p)], n));
390
+ const u = r.split("-");
391
+ i = u.reduce((f, d) => f[G(d)], n), r = u.pop(), c = r.toLowerCase(), i != null && i.set || (n = u.reduce((f, d) => f[G(d)], n));
392
392
  }
393
393
  vt(r) && (e.events[r] = a);
394
394
  let s = a;
395
- if (s === "" && (s = !0), re(i)) {
395
+ if (s === "" && (s = !0), oe(i)) {
396
396
  Array.isArray(s) ? e[c](...s) : e[c](s);
397
397
  return;
398
398
  }
399
- !(i != null && i.set) && !re(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);
399
+ !(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);
400
400
  }
401
401
  },
402
402
  parentNode(e) {
@@ -418,8 +418,8 @@ const se = {
418
418
  }
419
419
  return t;
420
420
  };
421
- ye(he);
422
- const { logWarning: ue } = D(), bt = ge({
421
+ Me(we);
422
+ const { logWarning: fe } = B(), bt = he({
423
423
  name: "TresScene",
424
424
  props: [
425
425
  "shadows",
@@ -435,42 +435,51 @@ const { logWarning: ue } = D(), bt = ge({
435
435
  "clearColor",
436
436
  "windowSize",
437
437
  "preset",
438
- "disableRender"
438
+ "disableRender",
439
+ "camera"
439
440
  ],
440
441
  setup(e, { slots: t, expose: o }) {
441
- e.physicallyCorrectLights === !0 && ue("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
442
- const a = P(), n = P(), r = new he.Scene(), { setState: c } = S();
442
+ e.physicallyCorrectLights === !0 && fe("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
443
+ const a = R(), n = R(), r = new we.Scene(), { setState: c } = O();
443
444
  c("scene", r), c("canvas", n), c("container", a);
444
- const i = P(), s = t && t.default && t.default();
445
- (s == null ? void 0 : s.length) > 0 && (i.value = s.some((d) => ut(d.type) && d.type.includes("Camera")), i.value || ue("No camera found in the scene, please add one!")), De(() => {
446
- l();
447
- }), ve(() => {
445
+ const i = R(), s = t && t.default && t.default();
446
+ (s == null ? void 0 : s.length) > 0 && (i.value = s.some((g) => ut(g.type) && g.type.includes("Camera")) || e.camera, i.value || fe("No camera found in the scene, please add one!")), De(() => {
447
+ p();
448
+ }), ge(() => {
448
449
  c("renderer", null);
449
450
  });
450
- function l() {
451
- const { renderer: d } = ct(e), { activeCamera: w } = Me(), { onLoop: M } = Ce(), { raycaster: x, pointer: L } = pt();
452
- let b = null, v = null;
453
- fe(() => {
454
- w.value && x.value.setFromCamera(L.value, w.value);
455
- }), M(() => {
456
- var E, y, g, C, I, h, T, O, R, B;
457
- if (w.value && e.disableRender !== !0 && e.disableRender !== "" && ((E = d.value) == null || E.render(r, w.value)), x.value) {
458
- const z = x.value.intersectObjects(r.children);
459
- z.length > 0 ? (v = z[0], b === null && ((C = (g = (y = v.object) == null ? void 0 : y.events) == null ? void 0 : g.onPointerEnter) == null || C.call(g, v)), (T = (h = (I = v.object) == null ? void 0 : I.events) == null ? void 0 : h.onPointerMove) == null || T.call(h, v)) : b !== null && ((B = (R = (O = v == null ? void 0 : v.object) == null ? void 0 : O.events) == null ? void 0 : R.onPointerLeave) == null || B.call(R, b), v = null), b = v;
451
+ const { activeCamera: u, pushCamera: f, clearCameras: d } = xe();
452
+ function p() {
453
+ const { renderer: g } = ct(e);
454
+ e.camera && f(e.camera);
455
+ const { onLoop: P } = Re(), { raycaster: E, pointer: H } = mt();
456
+ let L = null, v = null;
457
+ le(() => {
458
+ u.value && E.value.setFromCamera(H.value, u.value);
459
+ }), P(() => {
460
+ var w, h, M, y, T, C, k, z, A, j;
461
+ if (u.value && e.disableRender !== !0 && e.disableRender !== "" && ((w = g.value) == null || w.render(r, u.value)), E.value) {
462
+ const F = E.value.intersectObjects(r.children);
463
+ F.length > 0 ? (v = F[0], L === null && ((y = (M = (h = v.object) == null ? void 0 : h.events) == null ? void 0 : M.onPointerEnter) == null || y.call(M, v)), (k = (C = (T = v.object) == null ? void 0 : T.events) == null ? void 0 : C.onPointerMove) == null || k.call(C, v)) : L !== null && ((j = (A = (z = v == null ? void 0 : v.object) == null ? void 0 : z.events) == null ? void 0 : A.onPointerLeave) == null || j.call(A, L), v = null), L = v;
460
464
  }
461
465
  }), Qe(n.value, "click", () => {
462
- var E, y, g;
463
- v !== null && ((g = (y = (E = v.object) == null ? void 0 : E.events) == null ? void 0 : y.onClick) == null || g.call(y, v));
466
+ var w, h, M;
467
+ v !== null && ((M = (h = (w = v.object) == null ? void 0 : w.events) == null ? void 0 : h.onClick) == null || M.call(h, v));
464
468
  });
465
469
  }
466
- let u;
467
- function p() {
468
- u = wt(t), u.provide("useTres", S()), u.provide(J, S()), u.provide("extend", ye), u.mount(r);
470
+ let b;
471
+ function x() {
472
+ b = wt(t), b.provide("useTres", O()), b.provide(Q, O()), b.provide("extend", Me), b.mount(r);
469
473
  }
470
- return p(), o({
474
+ return x(), o({
471
475
  scene: r
472
- }), () => k(
473
- k(
476
+ }), V(
477
+ () => e.camera,
478
+ (g) => {
479
+ g && (d(), f(g));
480
+ }
481
+ ), () => D(
482
+ D(
474
483
  "div",
475
484
  {
476
485
  ref: a,
@@ -485,7 +494,7 @@ const { logWarning: ue } = D(), bt = ge({
485
494
  }
486
495
  },
487
496
  [
488
- k(
497
+ D(
489
498
  "div",
490
499
  {
491
500
  style: {
@@ -494,7 +503,7 @@ const { logWarning: ue } = D(), bt = ge({
494
503
  }
495
504
  },
496
505
  [
497
- k("canvas", {
506
+ D("canvas", {
498
507
  ref: n,
499
508
  "data-scene": r.uuid,
500
509
  style: {
@@ -512,7 +521,7 @@ const { logWarning: ue } = D(), bt = ge({
512
521
  )
513
522
  );
514
523
  }
515
- }), yt = ge({
524
+ }), yt = he({
516
525
  name: "TresCanvas",
517
526
  props: [
518
527
  "shadows",
@@ -528,11 +537,12 @@ const { logWarning: ue } = D(), bt = ge({
528
537
  "clearColor",
529
538
  "windowSize",
530
539
  "preset",
531
- "disableRender"
540
+ "disableRender",
541
+ "camera"
532
542
  ],
533
543
  setup(e, { slots: t, expose: o }) {
534
544
  const a = dt();
535
- return o(a), () => k(bt, e, t);
545
+ return o(a), () => D(bt, e, t);
536
546
  }
537
547
  }), Tt = {
538
548
  install(e) {
@@ -541,21 +551,21 @@ const { logWarning: ue } = D(), bt = ge({
541
551
  };
542
552
  export {
543
553
  Ze as CameraType,
544
- J as TRES_CONTEXT_KEY,
554
+ Q as TRES_CONTEXT_KEY,
545
555
  yt as TresCanvas,
546
- be as catalogue,
556
+ ye as catalogue,
547
557
  Tt as default,
548
- ye as extend,
558
+ Me as extend,
549
559
  Pt as isProd,
550
560
  ft as trasverseObjects,
551
- Me as useCamera,
561
+ xe as useCamera,
552
562
  Ct as useLoader,
553
- D as useLogger,
554
- pt as useRaycaster,
555
- Ce as useRenderLoop,
563
+ B as useLogger,
564
+ mt as useRaycaster,
565
+ Re as useRenderLoop,
556
566
  ct as useRenderer,
557
567
  Lt as useSeek,
558
568
  Rt as useTexture,
559
- S as useTres,
569
+ O as useTres,
560
570
  dt as useTresProvider
561
571
  };
package/dist/tres.umd.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.0.0-beta.12
3
+ * version: v2.0.0-beta.13
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,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,m,f){"use strict";function be(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const Q=be(m),N=s.ref({uuid:m.MathUtils.generateUUID()}),Y=e=>void Object.assign(N.value,e);var Z=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(Z||{});const we=45;let T;function $(){const{state:e,setState:t,aspectRatio:i}=S();function n(o="Perspective",c){var p,u,h;if(o==="Perspective"){const{near:v,far:M,fov:L}=c||{near:.1,far:1e3,fov:we};T=new m.PerspectiveCamera(L,((p=e.aspectRatio)==null?void 0:p.value)||window.innerWidth/window.innerHeight,v,M),(u=e.cameras)==null||u.push(T)}else{const{left:v,right:M,top:L,bottom:_,near:k,far:C}=c||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};T=new m.OrthographicCamera(v,M,L,_,k,C),(h=e.cameras)==null||h.push(T)}return e.camera=T,t("camera",e.camera),T}function a(){var o;e.camera instanceof m.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(o=e.camera)==null||o.updateProjectionMatrix()}function r(o){var c;(c=e.cameras)==null||c.push(o),o instanceof m.PerspectiveCamera&&e.aspectRatio&&(o.aspect=e.aspectRatio.value),o.updateProjectionMatrix(),t("camera",o)}function l(){e.cameras=[]}return s.watchEffect(()=>{i!=null&&i.value&&a()}),{activeCamera:s.toRef(e,"camera"),createCamera:n,updateCamera:a,pushCamera:r,clearCameras:l}}const H=f.createEventHook(),ee=f.createEventHook(),q=f.createEventHook(),D=new m.Clock;let E=0,B=0;const{pause:ye,resume:Me,isActive:Ce}=f.useRafFn(()=>{H.trigger({delta:E,elapsed:B,clock:D}),ee.trigger({delta:E,elapsed:B,clock:D}),q.trigger({delta:E,elapsed:B,clock:D})},{immediate:!1});q.on(()=>{E=D.getDelta(),B=D.getElapsedTime()});function K(){return{onBeforeLoop:H.on,onLoop:ee.on,onAfterLoop:q.on,pause:ye,resume:Me,isActive:Ce}}function Pe(e){return e instanceof m.Color?e:Array.isArray(e)?new m.Color(...e):new m.Color(e)}const X={realistic:{outputEncoding:m.sRGBEncoding,toneMapping:m.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:m.PCFSoftShadowMap}}},te=(e,t)=>{for(const i of Object.keys(t))t[i]instanceof Object&&Object.assign(t[i],te(e[i],t[i]));return Object.assign(e||{},t),e},Le=_e("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 z(e){return e.replace(/-([a-z])/g,(t,i)=>i.toUpperCase())}function _e(e,t){const i=Object.create(null),n=e.split(",");for(let a=0;a<n.length;a++)i[n[a]]=!0;return t?a=>!!i[a.toLowerCase()]:a=>!!i[a]}function ne(e){var ge,he;const t=s.shallowRef(),i=s.ref(!1),{alpha:n=!0,antialias:a=!0,depth:r,logarithmicDepthBuffer:l,failIfMajorPerformanceCaveat:o,precision:c,premultipliedAlpha:p,stencil:u,shadows:h=!1,shadowMapType:v=m.PCFShadowMap,physicallyCorrectLights:M=!1,useLegacyLights:L=!1,outputEncoding:_=m.LinearEncoding,toneMapping:k=m.NoToneMapping,toneMappingExposure:C=1,context:b=void 0,powerPreference:O="default",preserveDrawingBuffer:P=!1,clearColor:w,windowSize:x=!1,preset:G=void 0}=s.toRefs(e),{state:y,setState:R}=S(),{width:I,height:A}=f.resolveUnref(x)==!0||f.resolveUnref(x)===""||f.resolveUnref(x)==="true"?f.useWindowSize():f.useElementSize(y.container),{logError:V,logWarning:W}=U(),{pixelRatio:me}=f.useDevicePixelRatio(),{pause:ze,resume:Fe}=K(),J=s.computed(()=>I.value/A.value);!f.resolveUnref(x)&&((he=(ge=y.container)==null?void 0:ge.value)==null?void 0:he.offsetHeight)===0&&W(`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 pe=()=>{t.value&&(t.value.setSize(I.value,A.value),t.value.setPixelRatio(Math.min(me.value,2)))},ve=()=>{if(!t.value)return;const j=f.resolveUnref(G);if(j){j in X||V("Renderer Preset must be one of these: "+Object.keys(X).join(", ")),te(t.value,X[j]);return}t.value.shadowMap.enabled=f.resolveUnref(h),t.value.shadowMap.type=f.resolveUnref(v),t.value.toneMapping=f.resolveUnref(k)||m.NoToneMapping,t.value.toneMappingExposure=f.resolveUnref(C),t.value.outputEncoding=f.resolveUnref(_)||m.LinearEncoding,w!=null&&w.value&&t.value.setClearColor(Pe(f.resolveUnref(w))),t.value.useLegacyLights=f.resolveUnref(L)},Ge=()=>{const j=f.unrefElement(y.canvas);j&&(t.value=new m.WebGLRenderer({canvas:j,alpha:f.resolveUnref(n),antialias:f.resolveUnref(a),context:f.resolveUnref(b),depth:f.resolveUnref(r),failIfMajorPerformanceCaveat:f.resolveUnref(o),logarithmicDepthBuffer:f.resolveUnref(l),powerPreference:f.resolveUnref(O),precision:f.resolveUnref(c),stencil:f.resolveUnref(u),preserveDrawingBuffer:f.resolveUnref(P),premultipliedAlpha:f.resolveUnref(p)}),R("renderer",t.value),R("clock",new m.Clock),R("aspectRatio",J),ve(),pe(),Fe(),i.value=!0)},Ve=()=>{t.value&&(t.value.dispose(),t.value=void 0,i.value=!1,ze())};return s.watch([J,me],pe),s.watch([h,v,_,L,k,C,w],ve),s.watch(()=>[y.canvas,y.container],()=>{f.unrefElement(y.canvas)&&f.unrefElement(y.container)&&Ge()},{immediate:!0,deep:!0}),{renderer:t,isReady:i,dispose:Ve,aspectRatio:J}}const Se=e=>typeof e=="string",ae=e=>!!e&&e.constructor===Array;function re(e){const t={nodes:{},materials:{}};return e&&e.traverse(i=>{i.name&&(t.nodes[i.name]=i),i.material&&!t.materials[i.material.name]&&(t.materials[i.material.name]=i.material)}),t}async function Oe(e,t,i,n,a){const{logError:r}=U(),l=new e;a&&a(l),i&&i(l);const c=(Array.isArray(t)?t:[t]).map(p=>new Promise((u,h)=>{l.load(p,v=>{v.scene&&Object.assign(v,re(v.scene)),u(v)},n,v=>h(r("[useLoader] - Failed to load resource",v)))}));return ae(t)?await Promise.all(c):await c[0]}async function xe(e){const t=new m.LoadingManager,i=new m.TextureLoader(t),n=a=>new Promise((r,l)=>{i.load(a,o=>r(o),()=>null,()=>{l(new Error("[useTextures] - Failed to load texture"))})});if(ae(e)){const a=await Promise.all(e.map(r=>n(r)));return e.length>1?a:a[0]}else{const{map:a,displacementMap:r,normalMap:l,roughnessMap:o,metalnessMap:c,aoMap:p,alphaMap:u,matcap:h}=e;return{map:a?await n(a):null,displacementMap:r?await n(r):null,normalMap:l?await n(l):null,roughnessMap:o?await n(o):null,metalnessMap:c?await n(c):null,aoMap:p?await n(p):null,alphaMap:u?await n(u):null,matcap:h?await n(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 Ae(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,n=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[i&63|128]+g[i>>8&255]+"-"+g[i>>16&255]+g[i>>24&255]+g[n&255]+g[n>>8&255]+g[n>>16&255]+g[n>>24&255]).toLowerCase()}const F=Symbol();function ie(){const e=s.shallowReactive({uuid:Ae(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:s.computed(()=>window.innerWidth/window.innerHeight)});function t(a){return e[a]}function i(a,r){e[a]=r}const n={state:e,...s.toRefs(e),getState:t,setState:i};return s.provide(F,n),n}const S=()=>s.inject(F,{state:s.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});function oe(){var l;const e=s.shallowRef(new m.Raycaster),t=s.ref(new m.Vector2),i=s.ref(null),{setState:n,state:a}=S();n("raycaster",e.value),n("pointer",t),n("currentInstance",i);function r(o){t.value.x=o.clientX/window.innerWidth*2-1,t.value.y=-(o.clientY/window.innerHeight)*2+1}return(l=a==null?void 0:a.renderer)==null||l.domElement.addEventListener("pointermove",r),s.onUnmounted(()=>{var o;(o=a==null?void 0:a.renderer)==null||o.domElement.removeEventListener("pointermove",r)}),{raycaster:e,pointer:t}}const Te=!0,se="[TresJS ▲ ■ ●] ";function U(){function e(n,a){console.error(`${se} ${n}`,a||"")}function t(n){console.warn(`${se} ${n}`)}function i(n,a){}return{logError:e,logWarning:t,logMessage:i}}function Ue(){const{logWarning:e}=U();function t(n,a,r){let l=null;return n.traverse(o=>{o[a]===r&&(l=o)}),l||e(`Child with ${a} '${r}' not found.`),l}function i(n,a){return t(n,"name",a)}return{seek:t,seekByName:i}}const ke=/^on[^a-z]/,Re=e=>ke.test(e);function Ne(e){}let ce=null;const fe={GEOMETRY_VIA_PROP:"tres__geometryViaProp",MATERIAL_VIA_PROP:"tres__materialViaProp"},{logError:le}=U(),je={createElement(e,t,i,n){var c,p;if(n||(n={}),n.args||(n.args=[]),e==="template"||Le(e))return null;let a=e.replace("Tres",""),r;if(e==="primitive"){(n==null?void 0:n.object)===void 0&&le("Tres primitives need a prop 'object'");const u=n.object;a=u.type,r=Object.assign(u,{type:a,attach:n.attach,primitive:!0})}else{const u=N.value[a];u||le(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`),r=new u(...n.args)}if(r.isCamera){n!=null&&n.position||r.position.set(3,3,3),n!=null&&n.lookAt||r.lookAt(0,0,0);const{pushCamera:u}=$();u(r)}(n==null?void 0:n.attach)===void 0&&(r.isMaterial?r.attach="material":r.isBufferGeometry&&(r.attach="geometry"));const{GEOMETRY_VIA_PROP:l,MATERIAL_VIA_PROP:o}=fe;return r.isObject3D&&((c=n==null?void 0:n.material)!=null&&c.isMaterial&&(r.userData[o]=!0),(p=n==null?void 0:n.geometry)!=null&&p.isBufferGeometry&&(r.userData[l]=!0)),r.events={},r},insert(e,t){var i,n,a,r;if((((i=e==null?void 0:e.__vnode)==null?void 0:i.type)==="TresGroup"||((n=e==null?void 0:e.__vnode)==null?void 0:n.type)==="TresObject3D")&&t===null&&!((r=(a=e==null?void 0:e.__vnode)==null?void 0:a.ctx)!=null&&r.asyncResolved)){ce=e;return}t||(t=ce),e!=null&&e.isObject3D&&(t!=null&&t.isObject3D)?(t.add(e),e.dispatchEvent({type:"added"})):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,i;if(e){if(e.isObject3D){const n=e,a=r=>{var c,p;const{GEOMETRY_VIA_PROP:l,MATERIAL_VIA_PROP:o}=fe;r.userData[o]||(c=r.material)==null||c.dispose(),r.userData[l]||(p=r.geometry)==null||p.dispose()};n.traverse(r=>a(r)),a(n)}(t=e.removeFromParent)==null||t.call(e),(i=e.dispose)==null||i.call(e)}},patchProp(e,t,i,n){if(e){let a=e,r=t,l=z(r),o=a==null?void 0:a[l];if(a.type==="BufferGeometry"){if(r==="args")return;a.setAttribute(z(r),new m.BufferAttribute(...n));return}if(r.includes("-")&&o===void 0){const p=r.split("-");o=p.reduce((u,h)=>u[z(h)],a),r=p.pop(),l=r.toLowerCase(),o!=null&&o.set||(a=p.reduce((u,h)=>u[z(h)],a))}Re(r)&&(e.events[r]=n);let c=n;if(c===""&&(c=!0),f.isFunction(o)){Array.isArray(c)?e[l](...c):e[l](c);return}!(o!=null&&o.set)&&!f.isFunction(o)?a[l]=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)}},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:De}=s.createRenderer(je),Ie=e=>{const t=De(i);function i(){return e&&e.default?e.default():[]}return t};Y(Q);const{logWarning:ue}=U(),Ee=s.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender"],setup(e,{slots:t,expose:i}){e.physicallyCorrectLights===!0&&ue("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const n=s.ref(),a=s.ref(),r=new Q.Scene,{setState:l}=S();l("scene",r),l("canvas",a),l("container",n);const o=s.ref(),c=t&&t.default&&t.default();(c==null?void 0:c.length)>0&&(o.value=c.some(v=>Se(v.type)&&v.type.includes("Camera")),o.value||ue("No camera found in the scene, please add one!")),s.onMounted(()=>{p()}),s.onUnmounted(()=>{l("renderer",null)});function p(){const{renderer:v}=ne(e),{activeCamera:M}=$(),{onLoop:L}=K(),{raycaster:_,pointer:k}=oe();let C=null,b=null;s.watchEffect(()=>{M.value&&_.value.setFromCamera(k.value,M.value)}),L(()=>{var O,P,w,x,G,y,R,I,A,V;if(M.value&&e.disableRender!==!0&&e.disableRender!==""&&((O=v.value)==null||O.render(r,M.value)),_.value){const W=_.value.intersectObjects(r.children);W.length>0?(b=W[0],C===null&&((x=(w=(P=b.object)==null?void 0:P.events)==null?void 0:w.onPointerEnter)==null||x.call(w,b)),(R=(y=(G=b.object)==null?void 0:G.events)==null?void 0:y.onPointerMove)==null||R.call(y,b)):C!==null&&((V=(A=(I=b==null?void 0:b.object)==null?void 0:I.events)==null?void 0:A.onPointerLeave)==null||V.call(A,C),b=null),C=b}}),f.useEventListener(a.value,"click",()=>{var O,P,w;b!==null&&((w=(P=(O=b.object)==null?void 0:O.events)==null?void 0:P.onClick)==null||w.call(P,b))})}let u;function h(){u=Ie(t),u.provide("useTres",S()),u.provide(F,S()),u.provide("extend",Y),u.mount(r)}return h(),i({scene:r}),()=>s.h(s.h("div",{ref:n,"data-scene":r.uuid,key:r.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":r.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),de=s.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender"],setup(e,{slots:t,expose:i}){const n=ie();return i(n),()=>s.h(Ee,e,t)}}),Be={install(e){e.component("TresCanvas",de)}};d.CameraType=Z,d.TRES_CONTEXT_KEY=F,d.TresCanvas=de,d.catalogue=N,d.default=Be,d.extend=Y,d.isProd=Te,d.trasverseObjects=re,d.useCamera=$,d.useLoader=Oe,d.useLogger=U,d.useRaycaster=oe,d.useRenderLoop=K,d.useRenderer=ne,d.useSeek=Ue,d.useTexture=xe,d.useTres=S,d.useTresProvider=ie,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
8
+ (function(u,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):(u=typeof globalThis<"u"?globalThis:u||self,s(u.tres={},u.Vue,u.Three,u.VueUseCore))})(this,function(u,s,d,f){"use strict";function be(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const H=be(d),Y=s.ref({uuid:d.MathUtils.generateUUID()}),$=e=>void Object.assign(Y.value,e);var ee=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(ee||{});const ye=45;let A;function q(){const{state:e,setState:t,aspectRatio:i}=O();function n(o="Perspective",c){var m,p,g;if(o==="Perspective"){const{near:h,far:C,fov:_}=c||{near:.1,far:1e3,fov:ye};A=new d.PerspectiveCamera(_,((m=e.aspectRatio)==null?void 0:m.value)||window.innerWidth/window.innerHeight,h,C),(p=e.cameras)==null||p.push(A)}else{const{left:h,right:C,top:_,bottom:b,near:U,far:S}=c||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};A=new d.OrthographicCamera(h,C,_,b,U,S),(g=e.cameras)==null||g.push(A)}return e.camera=A,t("camera",e.camera),A}function a(){var o;e.camera instanceof d.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(o=e.camera)==null||o.updateProjectionMatrix()}function r(o){var c;(c=e.cameras)==null||c.push(o),o instanceof d.PerspectiveCamera&&e.aspectRatio&&(o.aspect=e.aspectRatio.value),o.updateProjectionMatrix(),t("camera",o)}function l(){e.cameras=[]}return s.watchEffect(()=>{i!=null&&i.value&&a()}),{activeCamera:s.toRef(e,"camera"),createCamera:n,updateCamera:a,pushCamera:r,clearCameras:l}}const te=f.createEventHook(),ne=f.createEventHook(),K=f.createEventHook(),I=new d.Clock;let z=0,F=0;const{pause:Me,resume:Ce,isActive:Pe}=f.useRafFn(()=>{te.trigger({delta:z,elapsed:F,clock:I}),ne.trigger({delta:z,elapsed:F,clock:I}),K.trigger({delta:z,elapsed:F,clock:I})},{immediate:!1});K.on(()=>{z=I.getDelta(),F=I.getElapsedTime()});function X(){return{onBeforeLoop:te.on,onLoop:ne.on,onAfterLoop:K.on,pause:Me,resume:Ce,isActive:Pe}}function Le(e){return e instanceof d.Color?e:Array.isArray(e)?new d.Color(...e):new d.Color(e)}const J={realistic:{outputEncoding:d.sRGBEncoding,toneMapping:d.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:d.PCFSoftShadowMap}}},ae=(e,t)=>{for(const i of Object.keys(t))t[i]instanceof Object&&Object.assign(t[i],ae(e[i],t[i]));return Object.assign(e||{},t),e},_e=Se("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 G(e){return e.replace(/-([a-z])/g,(t,i)=>i.toUpperCase())}function Se(e,t){const i=Object.create(null),n=e.split(",");for(let a=0;a<n.length;a++)i[n[a]]=!0;return t?a=>!!i[a.toLowerCase()]:a=>!!i[a]}function re(e){var he,we;const t=s.shallowRef(),i=s.ref(!1),{alpha:n=!0,antialias:a=!0,depth:r,logarithmicDepthBuffer:l,failIfMajorPerformanceCaveat:o,precision:c,premultipliedAlpha:m,stencil:p,shadows:g=!1,shadowMapType:h=d.PCFShadowMap,physicallyCorrectLights:C=!1,useLegacyLights:_=!1,outputEncoding:b=d.LinearEncoding,toneMapping:U=d.NoToneMapping,toneMappingExposure:S=1,context:Q=void 0,powerPreference:k="default",preserveDrawingBuffer:w=!1,clearColor:M,windowSize:y=!1,preset:L=void 0}=s.toRefs(e),{state:P,setState:R}=O(),{width:x,height:E}=f.resolveUnref(y)==!0||f.resolveUnref(y)===""||f.resolveUnref(y)==="true"?f.useWindowSize():f.useElementSize(P.container),{logError:W,logWarning:j}=T(),{pixelRatio:B}=f.useDevicePixelRatio(),{pause:N,resume:Fe}=X(),Z=s.computed(()=>x.value/E.value);!f.resolveUnref(y)&&((we=(he=P.container)==null?void 0:he.value)==null?void 0:we.offsetHeight)===0&&j(`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 ve=()=>{t.value&&(t.value.setSize(x.value,E.value),t.value.setPixelRatio(Math.min(B.value,2)))},ge=()=>{if(!t.value)return;const D=f.resolveUnref(L);if(D){D in J||W("Renderer Preset must be one of these: "+Object.keys(J).join(", ")),ae(t.value,J[D]);return}t.value.shadowMap.enabled=f.resolveUnref(g),t.value.shadowMap.type=f.resolveUnref(h),t.value.toneMapping=f.resolveUnref(U)||d.NoToneMapping,t.value.toneMappingExposure=f.resolveUnref(S),t.value.outputEncoding=f.resolveUnref(b)||d.LinearEncoding,M!=null&&M.value&&t.value.setClearColor(Le(f.resolveUnref(M))),t.value.useLegacyLights=f.resolveUnref(_)},Ge=()=>{const D=f.unrefElement(P.canvas);D&&(t.value=new d.WebGLRenderer({canvas:D,alpha:f.resolveUnref(n),antialias:f.resolveUnref(a),context:f.resolveUnref(Q),depth:f.resolveUnref(r),failIfMajorPerformanceCaveat:f.resolveUnref(o),logarithmicDepthBuffer:f.resolveUnref(l),powerPreference:f.resolveUnref(k),precision:f.resolveUnref(c),stencil:f.resolveUnref(p),preserveDrawingBuffer:f.resolveUnref(w),premultipliedAlpha:f.resolveUnref(m)}),R("renderer",t.value),R("clock",new d.Clock),R("aspectRatio",Z),ge(),ve(),Fe(),i.value=!0)},Ve=()=>{t.value&&(t.value.dispose(),t.value=void 0,i.value=!1,N())};return s.watch([Z,B],ve),s.watch([g,h,b,_,U,S,M],ge),s.watch(()=>[P.canvas,P.container],()=>{f.unrefElement(P.canvas)&&f.unrefElement(P.container)&&Ge()},{immediate:!0,deep:!0}),{renderer:t,isReady:i,dispose:Ve,aspectRatio:Z}}const Oe=e=>typeof e=="string",ie=e=>!!e&&e.constructor===Array;function oe(e){const t={nodes:{},materials:{}};return e&&e.traverse(i=>{i.name&&(t.nodes[i.name]=i),i.material&&!t.materials[i.material.name]&&(t.materials[i.material.name]=i.material)}),t}async function xe(e,t,i,n,a){const{logError:r}=T(),l=new e;a&&a(l),i&&i(l);const c=(Array.isArray(t)?t:[t]).map(m=>new Promise((p,g)=>{l.load(m,h=>{h.scene&&Object.assign(h,oe(h.scene)),p(h)},n,h=>g(r("[useLoader] - Failed to load resource",h)))}));return ie(t)?await Promise.all(c):await c[0]}async function Ae(e){const t=new d.LoadingManager,i=new d.TextureLoader(t),n=a=>new Promise((r,l)=>{i.load(a,o=>r(o),()=>null,()=>{l(new Error("[useTextures] - Failed to load texture"))})});if(ie(e)){const a=await Promise.all(e.map(r=>n(r)));return e.length>1?a:a[0]}else{const{map:a,displacementMap:r,normalMap:l,roughnessMap:o,metalnessMap:c,aoMap:m,alphaMap:p,matcap:g}=e;return{map:a?await n(a):null,displacementMap:r?await n(r):null,normalMap:l?await n(l):null,roughnessMap:o?await n(o):null,metalnessMap:c?await n(c):null,aoMap:m?await n(m):null,alphaMap:p?await n(p):null,matcap:g?await n(g):null}}}const v=["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 Te(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(v[e&255]+v[e>>8&255]+v[e>>16&255]+v[e>>24&255]+"-"+v[t&255]+v[t>>8&255]+"-"+v[t>>16&15|64]+v[t>>24&255]+"-"+v[i&63|128]+v[i>>8&255]+"-"+v[i>>16&255]+v[i>>24&255]+v[n&255]+v[n>>8&255]+v[n>>16&255]+v[n>>24&255]).toLowerCase()}const V=Symbol();function se(){const e=s.shallowReactive({uuid:Te(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:s.computed(()=>window.innerWidth/window.innerHeight)});function t(a){return e[a]}function i(a,r){e[a]=r}const n={state:e,...s.toRefs(e),getState:t,setState:i};return s.provide(V,n),n}const O=()=>s.inject(V,{state:s.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});function ce(){var l;const e=s.shallowRef(new d.Raycaster),t=s.ref(new d.Vector2),i=s.ref(null),{setState:n,state:a}=O();n("raycaster",e.value),n("pointer",t),n("currentInstance",i);function r(o){t.value.x=o.clientX/window.innerWidth*2-1,t.value.y=-(o.clientY/window.innerHeight)*2+1}return(l=a==null?void 0:a.renderer)==null||l.domElement.addEventListener("pointermove",r),s.onUnmounted(()=>{var o;(o=a==null?void 0:a.renderer)==null||o.domElement.removeEventListener("pointermove",r)}),{raycaster:e,pointer:t}}const Ue=!0,fe="[TresJS ▲ ■ ●] ";function T(){function e(n,a){console.error(`${fe} ${n}`,a||"")}function t(n){console.warn(`${fe} ${n}`)}function i(n,a){}return{logError:e,logWarning:t,logMessage:i}}function ke(){const{logWarning:e}=T();function t(n,a,r){let l=null;return n.traverse(o=>{o[a]===r&&(l=o)}),l||e(`Child with ${a} '${r}' not found.`),l}function i(n,a){return t(n,"name",a)}return{seek:t,seekByName:i}}const Re=/^on[^a-z]/,je=e=>Re.test(e);function Ne(e){}let le=null;const ue={GEOMETRY_VIA_PROP:"tres__geometryViaProp",MATERIAL_VIA_PROP:"tres__materialViaProp"},{logError:de}=T(),De={createElement(e,t,i,n){var c,m;if(n||(n={}),n.args||(n.args=[]),e==="template"||_e(e))return null;let a=e.replace("Tres",""),r;if(e==="primitive"){(n==null?void 0:n.object)===void 0&&de("Tres primitives need a prop 'object'");const p=n.object;a=p.type,r=Object.assign(p,{type:a,attach:n.attach,primitive:!0})}else{const p=Y.value[a];p||de(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`),r=new p(...n.args)}if(r.isCamera){n!=null&&n.position||r.position.set(3,3,3),n!=null&&n.lookAt||r.lookAt(0,0,0);const{pushCamera:p}=q();p(r)}(n==null?void 0:n.attach)===void 0&&(r.isMaterial?r.attach="material":r.isBufferGeometry&&(r.attach="geometry"));const{GEOMETRY_VIA_PROP:l,MATERIAL_VIA_PROP:o}=ue;return r.isObject3D&&((c=n==null?void 0:n.material)!=null&&c.isMaterial&&(r.userData[o]=!0),(m=n==null?void 0:n.geometry)!=null&&m.isBufferGeometry&&(r.userData[l]=!0)),r.events={},r},insert(e,t){var i,n,a,r;if((((i=e==null?void 0:e.__vnode)==null?void 0:i.type)==="TresGroup"||((n=e==null?void 0:e.__vnode)==null?void 0:n.type)==="TresObject3D")&&t===null&&!((r=(a=e==null?void 0:e.__vnode)==null?void 0:a.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"})):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,i;if(e){if(e.isObject3D){const n=e,a=r=>{var c,m;const{GEOMETRY_VIA_PROP:l,MATERIAL_VIA_PROP:o}=ue;r.userData[o]||(c=r.material)==null||c.dispose(),r.userData[l]||(m=r.geometry)==null||m.dispose()};n.traverse(r=>a(r)),a(n)}(t=e.removeFromParent)==null||t.call(e),(i=e.dispose)==null||i.call(e)}},patchProp(e,t,i,n){if(e){let a=e,r=t,l=G(r),o=a==null?void 0:a[l];if(a.type==="BufferGeometry"){if(r==="args")return;a.setAttribute(G(r),new d.BufferAttribute(...n));return}if(r.includes("-")&&o===void 0){const m=r.split("-");o=m.reduce((p,g)=>p[G(g)],a),r=m.pop(),l=r.toLowerCase(),o!=null&&o.set||(a=m.reduce((p,g)=>p[G(g)],a))}je(r)&&(e.events[r]=n);let c=n;if(c===""&&(c=!0),f.isFunction(o)){Array.isArray(c)?e[l](...c):e[l](c);return}!(o!=null&&o.set)&&!f.isFunction(o)?a[l]=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)}},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:Ie}=s.createRenderer(De),Ee=e=>{const t=Ie(i);function i(){return e&&e.default?e.default():[]}return t};$(H);const{logWarning:me}=T(),Be=s.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender","camera"],setup(e,{slots:t,expose:i}){e.physicallyCorrectLights===!0&&me("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const n=s.ref(),a=s.ref(),r=new H.Scene,{setState:l}=O();l("scene",r),l("canvas",a),l("container",n);const o=s.ref(),c=t&&t.default&&t.default();(c==null?void 0:c.length)>0&&(o.value=c.some(b=>Oe(b.type)&&b.type.includes("Camera"))||e.camera,o.value||me("No camera found in the scene, please add one!")),s.onMounted(()=>{h()}),s.onUnmounted(()=>{l("renderer",null)});const{activeCamera:m,pushCamera:p,clearCameras:g}=q();function h(){const{renderer:b}=re(e);e.camera&&p(e.camera);const{onLoop:U}=X(),{raycaster:S,pointer:Q}=ce();let k=null,w=null;s.watchEffect(()=>{m.value&&S.value.setFromCamera(Q.value,m.value)}),U(()=>{var M,y,L,P,R,x,E,W,j,B;if(m.value&&e.disableRender!==!0&&e.disableRender!==""&&((M=b.value)==null||M.render(r,m.value)),S.value){const N=S.value.intersectObjects(r.children);N.length>0?(w=N[0],k===null&&((P=(L=(y=w.object)==null?void 0:y.events)==null?void 0:L.onPointerEnter)==null||P.call(L,w)),(E=(x=(R=w.object)==null?void 0:R.events)==null?void 0:x.onPointerMove)==null||E.call(x,w)):k!==null&&((B=(j=(W=w==null?void 0:w.object)==null?void 0:W.events)==null?void 0:j.onPointerLeave)==null||B.call(j,k),w=null),k=w}}),f.useEventListener(a.value,"click",()=>{var M,y,L;w!==null&&((L=(y=(M=w.object)==null?void 0:M.events)==null?void 0:y.onClick)==null||L.call(y,w))})}let C;function _(){C=Ee(t),C.provide("useTres",O()),C.provide(V,O()),C.provide("extend",$),C.mount(r)}return _(),i({scene:r}),s.watch(()=>e.camera,b=>{b&&(g(),p(b))}),()=>s.h(s.h("div",{ref:n,"data-scene":r.uuid,key:r.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":r.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),pe=s.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender","camera"],setup(e,{slots:t,expose:i}){const n=se();return i(n),()=>s.h(Be,e,t)}}),ze={install(e){e.component("TresCanvas",pe)}};u.CameraType=ee,u.TRES_CONTEXT_KEY=V,u.TresCanvas=pe,u.catalogue=Y,u.default=ze,u.extend=$,u.isProd=Ue,u.trasverseObjects=oe,u.useCamera=q,u.useLoader=xe,u.useLogger=T,u.useRaycaster=ce,u.useRenderLoop=X,u.useRenderer=re,u.useSeek=ke,u.useTexture=Ae,u.useTres=O,u.useTresProvider=se,Object.defineProperties(u,{__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.12",
4
+ "version": "2.0.0-beta.13",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.3.1",
7
7
  "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",