@tresjs/core 1.1.0 → 1.2.1

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.
@@ -3,5 +3,5 @@ import { TresCatalogue, TresInstance, TresVNode } from '../../types';
3
3
  export declare function useInstanceCreator(prefix: string): {
4
4
  createComponentInstances: (catalogue: Ref<TresCatalogue>) => (string | import("vue").DefineComponent<{}, () => void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>)[][];
5
5
  processProps: (props: Record<string, any>, instance: TresInstance) => void;
6
- createInstanceFromVNode: (vnode: TresVNode, catalogue: Ref<TresCatalogue>) => TresInstance;
6
+ createInstanceFromVNode: (vnode: TresVNode) => TresInstance | TresInstance[] | undefined;
7
7
  };
package/dist/env.d.ts CHANGED
@@ -8,3 +8,4 @@ declare module '*.vue' {
8
8
  }
9
9
 
10
10
  declare module '*.glsl' {}
11
+ declare module '*.json' {}
package/dist/tres.js CHANGED
@@ -1,31 +1,31 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v1.1.0
3
+ * version: v1.2.0
4
4
  * (c) 2022
5
5
  * description: Declarative ThreeJS using Vue Components
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
7
  */
8
- import { computed as D, watch as x, inject as X, ref as S, defineComponent as _, shallowRef as V, reactive as he, toRefs as we, provide as P, onBeforeUnmount as ve, h as J, watchEffect as Ce } from "vue";
9
- import { useWindowSize as Y, createEventHook as j, useRafFn as ye, useElementSize as Me, useDevicePixelRatio as Se, unrefElement as I, resolveUnref as C } from "@vueuse/core";
10
- import * as Ee from "three";
11
- import { PerspectiveCamera as T, OrthographicCamera as Z, Color as $, Vector3 as xe, Clock as Pe, Scene as Te, LoadingManager as Le, TextureLoader as Re, PCFShadowMap as Oe, LinearEncoding as Ae, NoToneMapping as Be, WebGLRenderer as Ie } from "three";
12
- var $e = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))($e || {});
8
+ import { computed as j, watch as O, inject as T, ref as P, defineComponent as k, shallowRef as N, reactive as ve, toRefs as ye, provide as b, onBeforeUnmount as Ce, h as q } from "vue";
9
+ import { useWindowSize as ee, createEventHook as W, useRafFn as Se, useElementSize as Me, useDevicePixelRatio as xe, unrefElement as z, resolveUnref as y } from "@vueuse/core";
10
+ import * as Q from "three";
11
+ import { PerspectiveCamera as A, OrthographicCamera as te, Color as D, Vector3 as Ee, Clock as Te, Scene as Pe, LoadingManager as Re, TextureLoader as Le, PCFShadowMap as Oe, LinearEncoding as be, NoToneMapping as Ae, WebGLRenderer as $e } from "three";
12
+ var Be = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Be || {});
13
13
  const M = {
14
14
  cameras: []
15
- }, be = 45;
16
- let y;
17
- function ee() {
18
- const { width: e, height: t } = Y(), { setState: r } = ce();
19
- function a(o = "Perspective", u) {
20
- if (o === "Perspective") {
21
- const { near: n, far: i, fov: p } = u || {
15
+ }, Ie = 45;
16
+ let C;
17
+ function ne() {
18
+ const { width: e, height: t } = ee(), { setState: n } = le();
19
+ function o(r = "Perspective", u) {
20
+ if (r === "Perspective") {
21
+ const { near: s, far: c, fov: p } = u || {
22
22
  near: 0.1,
23
23
  far: 1e3,
24
- fov: be
24
+ fov: Ie
25
25
  };
26
- y = new T(p, s.value, n, i), M.cameras.push(y);
26
+ C = new A(p, i.value, s, c), M.cameras.push(C);
27
27
  } else {
28
- const { left: n, right: i, top: p, bottom: h, near: g, far: w } = u || {
28
+ const { left: s, right: c, top: p, bottom: m, near: g, far: v } = u || {
29
29
  left: -100,
30
30
  right: 100,
31
31
  top: 100,
@@ -33,289 +33,306 @@ function ee() {
33
33
  near: 0.1,
34
34
  far: 1e3
35
35
  };
36
- y = new Z(n, i, p, h, g, w), M.cameras.push(y);
36
+ C = new te(s, c, p, m, g, v), M.cameras.push(C);
37
37
  }
38
- return M.cameras.push(y), y;
38
+ return M.cameras.push(C), C;
39
39
  }
40
- const s = D(() => e.value / t.value), l = D(() => M.cameras[0]);
40
+ const i = j(() => e.value / t.value), l = j(() => M.cameras[0]);
41
41
  function f() {
42
- l.value instanceof T && (l.value.aspect = s.value), l.value.updateProjectionMatrix();
42
+ l.value instanceof A && (l.value.aspect = i.value), l.value.updateProjectionMatrix();
43
43
  }
44
- function c(o) {
45
- const u = X("camera");
46
- o && u && (u.value = o, r("camera", u.value)), M.cameras.push(o), o instanceof T && (o.aspect = s.value), o.updateProjectionMatrix();
44
+ function a(r) {
45
+ const u = T("camera");
46
+ r && u && (u.value = r, n("camera", u.value)), M.cameras.push(r), r instanceof A && (r.aspect = i.value), r.updateProjectionMatrix();
47
47
  }
48
- return x(s, f), {
48
+ return O(i, f), {
49
49
  activeCamera: l,
50
- createCamera: a,
50
+ createCamera: o,
51
51
  updateCamera: f,
52
- pushCamera: c
52
+ pushCamera: a
53
53
  };
54
54
  }
55
- const L = S({ ...Ee });
56
- delete L.value.Scene;
57
- let b;
58
- function Fe(e, t = "Tres") {
59
- !b && e && (b = e);
60
- const { createComponentInstances: r } = te(t);
61
- return {
62
- extend: (s) => {
63
- L.value = Object.assign(L.value, s), r(S(s)).forEach(([f, c]) => {
64
- b.component(f, c);
65
- });
66
- },
67
- catalogue: L
68
- };
69
- }
70
- const F = (e) => typeof e < "u", ze = (e) => typeof e == "function", R = (e) => !!e && e.constructor === Array;
71
- function De(e) {
72
- return typeof e == "number" ? [e, e, e] : e instanceof xe ? [e.x, e.y, e.z] : e;
73
- }
74
- function K(e) {
75
- return e instanceof $ ? e : Array.isArray(e) ? new $(...e) : new $(e);
76
- }
77
- const q = "[TresJS \u25B2 \u25A0 \u25CF] ";
78
- function U() {
79
- function e(a, s) {
80
- console.error(`${q} ${a}`, s || "");
55
+ const X = "[TresJS \u25B2 \u25A0 \u25CF] ";
56
+ function B() {
57
+ function e(o, i) {
58
+ console.error(`${X} ${o}`, i || "");
81
59
  }
82
- function t(a) {
83
- console.warn(`${q} ${a}`);
60
+ function t(o) {
61
+ console.warn(`${X} ${o}`);
84
62
  }
85
- function r(a, s) {
63
+ function n(o, i) {
86
64
  }
87
65
  return {
88
66
  logError: e,
89
67
  logWarning: t,
90
- logMessage: r
68
+ logMessage: n
91
69
  };
92
70
  }
93
- const _e = ["rotation", "scale", "position"];
94
- function te(e) {
95
- const { logMessage: t, logError: r } = U();
96
- function a(c, o) {
97
- !F(c) || !F(o) || Object.entries(c).forEach(([u, n]) => {
98
- const i = u.replace(/(-\w)/g, (p) => p[1].toUpperCase());
99
- if (!(i === "args" || n === void 0)) {
100
- _e.includes(i) && n && (n = De(n)), c.ref && (c.ref = o);
71
+ const E = P({ ...Q, uuid: Q.MathUtils.generateUUID() });
72
+ delete E.value.Scene;
73
+ let x;
74
+ function re(e, t = "Tres") {
75
+ const { logMessage: n, logError: o } = B();
76
+ !x && e && (x = e);
77
+ const { createComponentInstances: i } = ae(t);
78
+ return {
79
+ extend: (f) => {
80
+ if (!f) {
81
+ o("No objects provided to extend catalogue");
82
+ return;
83
+ }
84
+ E.value = Object.assign(E.value, f);
85
+ const a = i(P(f));
86
+ n("Adding objects to catalogue", { objects: f, catalogue: E.value.uuid }), x && a.forEach(([r, u]) => {
87
+ x._context.components[r] || x.component(r, u);
88
+ });
89
+ },
90
+ catalogue: E
91
+ };
92
+ }
93
+ const U = (e) => typeof e < "u", _e = (e) => typeof e == "function", $ = (e) => !!e && e.constructor === Array;
94
+ function Fe(e) {
95
+ return typeof e == "number" ? [e, e, e] : e instanceof Ee ? [e.x, e.y, e.z] : e;
96
+ }
97
+ function Y(e) {
98
+ return e instanceof D ? e : Array.isArray(e) ? new D(...e) : new D(e);
99
+ }
100
+ const ze = ["rotation", "scale", "position"];
101
+ function ae(e) {
102
+ const { logMessage: t, logError: n } = B();
103
+ function o(a, r) {
104
+ !U(a) || !U(r) || Object.entries(a).forEach(([u, s]) => {
105
+ const c = u.replace(/(-\w)/g, (p) => p[1].toUpperCase());
106
+ if (!(c === "args" || s === void 0)) {
107
+ ze.includes(c) && s && (s = Fe(s)), a.ref && (a.ref = r);
101
108
  try {
102
- if (o[i] && F(o[i].set))
103
- o[i].set(...R(n) ? n : [n]);
109
+ if (r[c] && U(r[c].set))
110
+ r[c].set(...$(s) ? s : [s]);
104
111
  else {
105
- if (n === "" && (n = !0), ze(o[i])) {
106
- o[i](...R(n) ? n : [n]);
112
+ if (s === "" && (s = !0), _e(r[c])) {
113
+ r[c](...$(s) ? s : [s]);
107
114
  return;
108
115
  }
109
- o[i] = n;
116
+ r[c] = s;
110
117
  }
111
118
  } catch (p) {
112
- r(`There was an error setting ${i} property`, p);
119
+ n(`There was an error setting ${c} property`, p);
113
120
  }
114
121
  }
115
122
  });
116
123
  }
117
- function s(c, o) {
118
- var i;
119
- const u = c.type.name.replace(e, "");
120
- let n;
121
- return (i = c == null ? void 0 : c.props) != null && i.args ? n = new o.value[u](...c.props.args) : n = new o.value[u](), c != null && c.props && a(c.props, n), n;
124
+ function i(a) {
125
+ var s;
126
+ const r = /^Symbol\(Fragment\)$/g, u = /^Symbol\(Text\)$/g;
127
+ if (r.test(a.type.toString()))
128
+ return a.children.map((c) => i(c));
129
+ if (u.test(a.type.toString()))
130
+ return;
131
+ {
132
+ const c = a.type.name.replace(e, ""), { catalogue: p } = re(), m = T("catalogue") || p;
133
+ let g;
134
+ return m && ((s = a == null ? void 0 : a.props) != null && s.args ? m != null && m.value[c] ? g = new m.value[c](...a.props.args) : n(`There is no ${c} in the catalogue`, m == null ? void 0 : m.value.uuid) : g = new m.value[c]()), a != null && a.props && o(a.props, g), g;
135
+ }
122
136
  }
123
- function l(c, o, u, n) {
124
- if (n.default && (n == null ? void 0 : n.default())) {
125
- const i = n.default().map((p) => s(p, c));
126
- return new o(...i);
137
+ function l(a, r, u) {
138
+ if (u.default && (u == null ? void 0 : u.default())) {
139
+ const s = u.default().map((c) => i(c));
140
+ return new a(...s.flat().filter(Boolean));
127
141
  } else
128
- return u.args ? new o(...u.args) : new o();
142
+ return r.args ? new a(...r.args) : new a();
129
143
  }
130
- function f(c) {
131
- return Object.entries(c.value).filter(([o, u]) => {
132
- var n, i;
133
- return (i = (n = u == null ? void 0 : u.prototype) == null ? void 0 : n.constructor) == null ? void 0 : i.toString().includes("class");
134
- }).map(([o, u]) => {
135
- const n = `${e}${o}`, i = _({
136
- name: n,
137
- setup(p, { slots: h, attrs: g, ...w }) {
138
- const { scene: v } = se(), { pushCamera: O } = ee(), d = l(c, u, g, h);
139
- return a(g, d), (d instanceof T || d instanceof Z) && O(d), d.isObject3D && (v == null || v.value.add(d)), w.expose(d), t(n, {
144
+ function f(a) {
145
+ return Object.entries(a.value).filter(([r, u]) => {
146
+ var s, c;
147
+ return (c = (s = u == null ? void 0 : u.prototype) == null ? void 0 : s.constructor) == null ? void 0 : c.toString().includes("class");
148
+ }).map(([r, u]) => {
149
+ const s = `${e}${r}`, c = k({
150
+ name: s,
151
+ setup(p, { slots: m, attrs: g, ...v }) {
152
+ const { scene: R } = ue(), w = T("local-scene") || R, S = T("catalogue"), { pushCamera: I } = ne();
153
+ let h = l(u, g, m);
154
+ return o(g, h), (h instanceof A || h instanceof te) && I(h), h.isObject3D && (w == null || w.value.add(h)), v.expose(h), t(s, {
155
+ sceneuuid: w == null ? void 0 : w.value.uuid,
156
+ catalogue: S == null ? void 0 : S.value.uuid,
140
157
  props: p,
141
- slots: h,
158
+ slots: m.default ? m.default() : void 0,
142
159
  attrs: g,
143
- ctx: w,
144
- scene: v
160
+ ctx: v,
161
+ scene: w
145
162
  }), () => {
146
163
  };
147
164
  }
148
165
  });
149
- return [n, i];
166
+ return [s, c];
150
167
  });
151
168
  }
152
169
  return {
153
170
  createComponentInstances: f,
154
- processProps: a,
155
- createInstanceFromVNode: s
171
+ processProps: o,
172
+ createInstanceFromVNode: i
156
173
  };
157
174
  }
158
- const ne = j(), re = j(), oe = j(), Q = new Pe(), { pause: Ve, resume: je, isActive: Ue } = ye(
175
+ const oe = W(), se = W(), ie = W(), Z = new Te(), { pause: De, resume: Ue, isActive: Ve } = Se(
159
176
  () => {
160
- const e = Q.getElapsedTime(), t = Q.getDelta();
161
- ne.trigger({ delta: t, elapsed: e }), re.trigger({ delta: t, elapsed: e }), oe.trigger({ delta: t, elapsed: e });
177
+ const e = Z.getElapsedTime(), t = Z.getDelta();
178
+ oe.trigger({ delta: t, elapsed: e }), se.trigger({ delta: t, elapsed: e }), ie.trigger({ delta: t, elapsed: e });
162
179
  },
163
180
  { immediate: !1 }
164
181
  );
165
- function ae() {
182
+ function ce() {
166
183
  return {
167
- onBeforeLoop: ne.on,
168
- onLoop: re.on,
169
- onAfterLoop: oe.on,
170
- pause: Ve,
171
- resume: je,
172
- isActive: Ue
184
+ onBeforeLoop: oe.on,
185
+ onLoop: se.on,
186
+ onAfterLoop: ie.on,
187
+ pause: De,
188
+ resume: Ue,
189
+ isActive: Ve
173
190
  };
174
191
  }
175
- const ke = V(new Te());
176
- function se() {
192
+ const je = N(new Pe());
193
+ function ue() {
177
194
  return {
178
- scene: ke
195
+ scene: je
179
196
  };
180
197
  }
181
- function Ne(e) {
198
+ function ke(e) {
182
199
  const t = { nodes: {}, materials: {} };
183
- return e && e.traverse((r) => {
184
- r.name && (t.nodes[r.name] = r), r.material && !t.materials[r.material.name] && (t.materials[r.material.name] = r.material);
200
+ return e && e.traverse((n) => {
201
+ n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
185
202
  }), t;
186
203
  }
187
- async function Qe(e, t, r, a, s) {
188
- const { logError: l } = U(), f = new e();
189
- s && s(f), r && r(e);
190
- const o = (Array.isArray(t) ? t : [t]).map(
191
- (u) => new Promise((n, i) => {
204
+ async function Qe(e, t, n, o, i) {
205
+ const { logError: l } = B(), f = new e();
206
+ i && i(f), n && n(e);
207
+ const r = (Array.isArray(t) ? t : [t]).map(
208
+ (u) => new Promise((s, c) => {
192
209
  f.load(
193
210
  u,
194
211
  (p) => {
195
- p.scene && Object.assign(p, Ne(p.scene)), n(p);
212
+ p.scene && Object.assign(p, ke(p.scene)), s(p);
196
213
  },
197
- a,
198
- (p) => i(l("[useLoader] - Failed to load resource", p))
214
+ o,
215
+ (p) => c(l("[useLoader] - Failed to load resource", p))
199
216
  );
200
217
  })
201
218
  );
202
- return R(t) ? await Promise.all(o) : await o[0];
219
+ return $(t) ? await Promise.all(r) : await r[0];
203
220
  }
204
221
  async function Xe(e) {
205
- const t = new Le(), r = new Re(t), a = (s) => new Promise((l, f) => {
206
- r.load(
207
- s,
208
- (c) => l(c),
222
+ const t = new Re(), n = new Le(t), o = (i) => new Promise((l, f) => {
223
+ n.load(
224
+ i,
225
+ (a) => l(a),
209
226
  () => null,
210
227
  () => {
211
228
  f(new Error("[useTextures] - Failed to load texture"));
212
229
  }
213
230
  );
214
231
  });
215
- if (R(e)) {
216
- const s = await Promise.all(e.map((l) => a(l)));
217
- return e.length > 1 ? s : s[0];
232
+ if ($(e)) {
233
+ const i = await Promise.all(e.map((l) => o(l)));
234
+ return e.length > 1 ? i : i[0];
218
235
  } else {
219
- const { map: s, displacementMap: l, normalMap: f, roughnessMap: c, metalnessMap: o, aoMap: u } = e;
236
+ const { map: i, displacementMap: l, normalMap: f, roughnessMap: a, metalnessMap: r, aoMap: u } = e;
220
237
  return {
221
- map: s ? await a(s) : null,
222
- displacementMap: l ? await a(l) : null,
223
- normalMap: f ? await a(f) : null,
224
- roughnessMap: c ? await a(c) : null,
225
- metalnessMap: o ? await a(o) : null,
226
- aoMap: u ? await a(u) : null
238
+ map: i ? await o(i) : null,
239
+ displacementMap: l ? await o(l) : null,
240
+ normalMap: f ? await o(f) : null,
241
+ roughnessMap: a ? await o(a) : null,
242
+ metalnessMap: r ? await o(r) : null,
243
+ aoMap: u ? await o(u) : null
227
244
  };
228
245
  }
229
246
  }
230
- const E = he({});
231
- function ce() {
232
- function e(r) {
233
- return E[r];
247
+ const L = ve({});
248
+ function le() {
249
+ function e(n) {
250
+ return L[n];
234
251
  }
235
- function t(r, a) {
236
- E[r] = a;
252
+ function t(n, o) {
253
+ L[n] = o;
237
254
  }
238
255
  return {
239
- state: E,
240
- ...we(E),
256
+ state: L,
257
+ ...ye(L),
241
258
  getState: e,
242
259
  setState: t
243
260
  };
244
261
  }
245
- const m = V(), z = S(!1);
246
- function We(e, t, r) {
262
+ const d = N(), V = P(!1);
263
+ function Ne(e, t, n) {
247
264
  const {
248
- alpha: a = !1,
249
- antialias: s,
265
+ alpha: o = !1,
266
+ antialias: i,
250
267
  depth: l,
251
268
  logarithmicDepthBuffer: f,
252
- failIfMajorPerformanceCaveat: c,
253
- precision: o,
269
+ failIfMajorPerformanceCaveat: a,
270
+ precision: r,
254
271
  premultipliedAlpha: u,
255
- stencil: n,
256
- shadows: i = !1,
272
+ stencil: s,
273
+ shadows: c = !1,
257
274
  shadowMapType: p = Oe,
258
- physicallyCorrectLights: h = !1,
259
- outputEncoding: g = Ae,
260
- toneMapping: w = Be,
261
- toneMappingExposure: v = 1,
262
- context: O = void 0,
263
- powerPreference: d = "default",
264
- preserveDrawingBuffer: ie = !1,
265
- clearColor: k = K("#000000"),
266
- windowSize: ue = !1
267
- } = r, { width: A, height: B } = ue ? Y() : Me(t), { pixelRatio: N } = Se(), { pause: le, resume: pe } = ae(), fe = D(() => A.value / B.value), W = () => {
268
- !m.value || (m.value.setSize(A.value, B.value), m.value.setPixelRatio(N.value));
269
- }, H = () => {
270
- !m.value || (m.value.shadowMap.enabled = C(i), m.value.outputEncoding = C(g), m.value.shadowMap.type = C(p), m.value.physicallyCorrectLights = C(h), m.value.toneMapping = C(w), m.value.toneMappingExposure = C(v), m.value.setClearColor(K(C(k))));
271
- }, me = () => {
272
- const G = I(e);
273
- if (m.value || !G)
275
+ physicallyCorrectLights: m = !1,
276
+ outputEncoding: g = be,
277
+ toneMapping: v = Ae,
278
+ toneMappingExposure: R = 1,
279
+ context: w = void 0,
280
+ powerPreference: S = "default",
281
+ preserveDrawingBuffer: I = !1,
282
+ clearColor: h = Y("#000000"),
283
+ windowSize: fe = !1
284
+ } = n, { width: _, height: F } = fe ? ee() : Me(t), { pixelRatio: H } = xe(), { pause: pe, resume: me } = ce(), de = j(() => _.value / F.value), G = () => {
285
+ !d.value || (d.value.setSize(_.value, F.value), d.value.setPixelRatio(Math.min(H.value, 2)));
286
+ }, J = () => {
287
+ !d.value || (d.value.shadowMap.enabled = y(c), d.value.outputEncoding = y(g), d.value.shadowMap.type = y(p), d.value.physicallyCorrectLights = y(m), d.value.toneMapping = y(v), d.value.toneMappingExposure = y(R), d.value.setClearColor(Y(y(h))));
288
+ }, ge = () => {
289
+ const K = z(e);
290
+ if (d.value || !K)
274
291
  return;
275
- m.value = new Ie({
276
- canvas: G,
277
- alpha: a,
278
- antialias: s,
279
- context: O,
292
+ d.value = new $e({
293
+ canvas: K,
294
+ alpha: o,
295
+ antialias: i,
296
+ context: w,
280
297
  depth: l,
281
- failIfMajorPerformanceCaveat: c,
298
+ failIfMajorPerformanceCaveat: a,
282
299
  logarithmicDepthBuffer: f,
283
- powerPreference: d,
284
- precision: o,
285
- stencil: n,
286
- preserveDrawingBuffer: ie,
300
+ powerPreference: S,
301
+ precision: r,
302
+ stencil: s,
303
+ preserveDrawingBuffer: I,
287
304
  premultipliedAlpha: u
288
305
  });
289
- const { setState: ge } = ce();
290
- ge("renderer", m.value), H(), W(), pe(), z.value = !0;
291
- }, de = () => {
292
- !m.value || (m.value.dispose(), m.value = void 0, z.value = !1, le());
306
+ const { setState: we } = le();
307
+ we("renderer", d.value), J(), G(), me(), V.value = !0;
308
+ }, he = () => {
309
+ !d.value || (d.value.dispose(), d.value = void 0, V.value = !1, pe());
293
310
  };
294
- return x([A, B, N], W), x(
311
+ return O([_, F, H], G), O(
295
312
  () => [
296
- i,
313
+ c,
297
314
  p,
298
315
  g,
299
- h,
300
- w,
316
+ m,
301
317
  v,
302
- k
318
+ R,
319
+ h
303
320
  ],
304
- H
305
- ), x(
321
+ J
322
+ ), O(
306
323
  () => [e, t],
307
324
  () => {
308
- I(e) && I(t) && me();
325
+ z(e) && z(t) && ge();
309
326
  },
310
327
  { immediate: !0, deep: !0 }
311
328
  ), {
312
- renderer: m,
313
- isReady: z,
314
- dispose: de,
315
- aspectRatio: fe
329
+ renderer: d,
330
+ isReady: V,
331
+ dispose: he,
332
+ aspectRatio: de
316
333
  };
317
334
  }
318
- const He = _({
335
+ const We = k({
319
336
  name: "TresCanvas",
320
337
  props: {
321
338
  shadows: Boolean,
@@ -330,14 +347,14 @@ const He = _({
330
347
  clearColor: String,
331
348
  windowSize: Boolean
332
349
  },
333
- setup(e, { slots: t, attrs: r }) {
334
- const { logError: a } = U(), s = S(), l = S(), { renderer: f, dispose: c, aspectRatio: o } = We(s, l, e), u = V();
335
- return P("camera", u), P("renderer", f), P("aspect-ratio", o), t.default && !t.default().some((n) => n.type.name === "Scene") && a("TresCanvas must contain a Scene component."), t.default && !t.default().some((n) => {
336
- var i;
337
- return (i = n.type.name) == null ? void 0 : i.includes("Camera");
338
- }) && a("Scene must contain a Camera component."), ve(() => c()), () => {
350
+ setup(e, { slots: t, attrs: n }) {
351
+ const { logError: o } = B(), i = P(), l = P(), { renderer: f, dispose: a, aspectRatio: r } = Ne(i, l, e), u = N();
352
+ return b("camera", u), b("renderer", f), b("aspect-ratio", r), t.default && !t.default().some((s) => s.type.name === "Scene") && o("TresCanvas must contain a Scene component."), t.default && !t.default().some((s) => {
353
+ var c;
354
+ return (c = s.type.name) == null ? void 0 : c.includes("Camera");
355
+ }) && o("Scene must contain a Camera component."), Ce(() => a()), () => {
339
356
  if (t.default)
340
- return J(
357
+ return q(
341
358
  "div",
342
359
  {
343
360
  ref: l,
@@ -345,12 +362,12 @@ const He = _({
345
362
  position: "relative",
346
363
  width: "100%",
347
364
  height: "100vh",
348
- ...r.style
365
+ ...n.style
349
366
  }
350
367
  },
351
368
  [
352
- J("canvas", {
353
- ref: s,
369
+ q("canvas", {
370
+ ref: i,
354
371
  style: { width: "100%", height: "100%", position: "absolute", top: 0, left: 0 }
355
372
  }),
356
373
  t.default()
@@ -358,41 +375,44 @@ const He = _({
358
375
  );
359
376
  };
360
377
  }
361
- }), Ge = _({
378
+ }), He = k({
362
379
  name: "Scene",
363
380
  setup(e, { slots: t }) {
364
- const { scene: r } = se(), a = X("renderer"), { activeCamera: s } = ee(), { onLoop: l } = ae();
365
- return P("local-scene", r), l(() => {
366
- (a == null ? void 0 : a.value) && (s == null ? void 0 : s.value) && (r == null ? void 0 : r.value) && a.value.render(r == null ? void 0 : r.value, s.value);
381
+ const { scene: n } = ue(), o = T("renderer"), { activeCamera: i } = ne(), { onLoop: l } = ce();
382
+ return b("local-scene", n), l(() => {
383
+ (o == null ? void 0 : o.value) && (i == null ? void 0 : i.value) && (n == null ? void 0 : n.value) && o.value.render(n == null ? void 0 : n.value, i.value);
367
384
  }), () => {
368
385
  if (t.default)
369
386
  return t.default();
370
387
  };
371
388
  }
372
- }), Ye = Symbol("UseTresState"), Ze = {
389
+ }), Ye = Symbol("UseTresState"), Ge = "1.2.0", Ze = {
373
390
  install(e, t) {
374
- const r = (t == null ? void 0 : t.prefix) || "Tres";
375
- e.component(`${r}Canvas`, He), e.component(`${r}Scene`, Ge);
376
- const { catalogue: a } = Fe(e, r), { createComponentInstances: s } = te(r);
377
- s(a).forEach(([f, c]) => {
378
- e.component(f, c);
379
- }), Ce(() => {
380
- console.log({ catalogue: a });
381
- });
391
+ const n = (t == null ? void 0 : t.prefix) || "Tres";
392
+ e.component(`${n}Canvas`, We), e.component(`${n}Scene`, He);
393
+ const { catalogue: o, extend: i } = re(e, n);
394
+ e.provide("catalogue", o), e.provide("extend", i);
395
+ const { createComponentInstances: l } = ae(n);
396
+ l(o).forEach(([a, r]) => {
397
+ e.component(a, r);
398
+ }), window.__TRES__ = {
399
+ app: e,
400
+ version: Ge
401
+ };
382
402
  }
383
403
  };
384
404
  export {
385
- $e as CameraType,
405
+ Be as CameraType,
386
406
  Ye as UseTresStateSymbol,
387
407
  Ze as default,
388
- Ne as trasverseObjects,
389
- ee as useCamera,
390
- Fe as useCatalogue,
391
- te as useInstanceCreator,
408
+ ke as trasverseObjects,
409
+ ne as useCamera,
410
+ re as useCatalogue,
411
+ ae as useInstanceCreator,
392
412
  Qe as useLoader,
393
- ae as useRenderLoop,
394
- We as useRenderer,
395
- se as useScene,
413
+ ce as useRenderLoop,
414
+ Ne as useRenderer,
415
+ ue as useScene,
396
416
  Xe as useTexture,
397
- ce as useTres
417
+ le as useTres
398
418
  };