@tresjs/core 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tres.js CHANGED
@@ -1,31 +1,31 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v0.3.0
3
+ * version: v0.5.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 v, watch as F, ref as L, defineComponent as J, reactive as ee, toRefs as te, useSlots as re, useAttrs as ne, provide as ae, onMounted as oe, onBeforeUnmount as se, openBlock as _, createElementBlock as j, normalizeStyle as V, unref as U, createElementVNode as ce, createBlock as ie, Suspense as le, withCtx as ue, renderSlot as W, createCommentVNode as D, Fragment as fe } from "vue";
9
- import * as pe from "three";
10
- import { PerspectiveCamera as B, OrthographicCamera as de, Vector3 as me, Color as A, Scene as ge, Clock as he, LoadingManager as we, TextureLoader as ye, WebGLRenderer as Ce, PCFSoftShadowMap as Me, sRGBEncoding as Se } from "three";
11
- import { useWindowSize as K } from "@vueuse/core";
12
- var E = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(E || {});
13
- const R = {
8
+ import { computed as j, watch as O, inject as Y, defineComponent as _, shallowRef as $, reactive as pe, toRefs as le, ref as D, provide as R, onBeforeUnmount as fe, h as q } from "vue";
9
+ import { useWindowSize as Z, createEventHook as U, useRafFn as me, useElementSize as de, useDevicePixelRatio as ge, unrefElement as B, resolveUnref as v } from "@vueuse/core";
10
+ import * as he from "three";
11
+ import { PerspectiveCamera as I, OrthographicCamera as we, Color as z, Vector3 as Ce, Clock as ve, Scene as ye, LoadingManager as Me, TextureLoader as Se, PCFShadowMap as Ee, LinearEncoding as Pe, NoToneMapping as xe, WebGLRenderer as Le } from "three";
12
+ var Oe = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Oe || {});
13
+ const x = {
14
14
  cameras: []
15
- }, xe = 45;
16
- let x;
17
- function z() {
18
- const { width: e, height: t } = K();
19
- function u(o = "Perspective", a) {
20
- if (o === "Perspective") {
21
- const { near: p, far: g, fov: f } = a || {
15
+ }, Re = 45;
16
+ let S;
17
+ function k() {
18
+ const { width: e, height: t } = Z();
19
+ function r(i = "Perspective", s) {
20
+ if (i === "Perspective") {
21
+ const { near: p, far: d, fov: f } = s || {
22
22
  near: 0.1,
23
23
  far: 1e3,
24
- fov: xe
24
+ fov: Re
25
25
  };
26
- x = new B(f, r.value, p, g), R.cameras.push(x);
26
+ S = new I(f, a.value, p, d), x.cameras.push(S);
27
27
  } else {
28
- const { left: p, right: g, top: f, bottom: w, near: S, far: h } = a || {
28
+ const { left: p, right: d, top: f, bottom: m, near: y, far: M } = s || {
29
29
  left: -100,
30
30
  right: 100,
31
31
  top: 100,
@@ -33,328 +33,343 @@ function z() {
33
33
  near: 0.1,
34
34
  far: 1e3
35
35
  };
36
- x = new de(p, g, f, w, S, h), R.cameras.push(x);
36
+ S = new we(p, d, f, m, y, M), x.cameras.push(S);
37
37
  }
38
- return R.cameras.push(x), x;
38
+ return x.cameras.push(S), S;
39
39
  }
40
- const r = v(() => e.value / t.value), n = v(() => R.cameras[0]);
41
- function s() {
42
- n.value instanceof B && (n.value.aspect = r.value), n.value.updateProjectionMatrix();
40
+ const a = j(() => e.value / t.value), n = j(() => x.cameras[0]);
41
+ function o() {
42
+ n.value instanceof I && (n.value.aspect = a.value), n.value.updateProjectionMatrix();
43
43
  }
44
- function c(o) {
45
- R.cameras.push(o), o instanceof B && (o.aspect = r.value), o.updateProjectionMatrix();
44
+ function u(i) {
45
+ const s = Y("camera");
46
+ i && s && (s.value = i), x.cameras.push(i), i instanceof I && (i.aspect = a.value), i.updateProjectionMatrix();
46
47
  }
47
- return F(r, s), {
48
+ return O(a, o), {
48
49
  activeCamera: n,
49
- createCamera: u,
50
- updateCamera: s,
51
- pushCamera: c
50
+ createCamera: r,
51
+ updateCamera: o,
52
+ pushCamera: u
52
53
  };
53
54
  }
54
- let I = { ...pe };
55
- function Re() {
55
+ let T = { ...he };
56
+ delete T.Scene;
57
+ function Te() {
56
58
  return {
57
59
  extend: (t) => {
58
- I = Object.assign(I, t);
60
+ T = Object.assign(T, t);
59
61
  },
60
- catalogue: I
62
+ catalogue: T
61
63
  };
62
64
  }
63
- const Pe = (e) => typeof e < "u", Q = (e) => !!e && e.constructor === Array;
64
- function X(e) {
65
- return typeof e == "number" ? [e, e, e] : e instanceof me ? [e.x, e.y, e.z] : e;
65
+ const be = (e) => typeof e < "u", V = (e) => !!e && e.constructor === Array;
66
+ function Ae(e) {
67
+ return typeof e == "number" ? [e, e, e] : e instanceof Ce ? [e.x, e.y, e.z] : e;
66
68
  }
67
- function Ee(e) {
68
- return e instanceof A ? e : Array.isArray(e) ? new A(...e) : new A(e);
69
+ function K(e) {
70
+ return e instanceof z ? e : Array.isArray(e) ? new z(...e) : new z(e);
69
71
  }
70
- const q = "[TresJS \u25B2 \u25A0 \u25CF] ";
71
- function $() {
72
- function e(r, n) {
73
- console.error(`${q} ${r}`, n);
72
+ const Q = "[TresJS \u25B2 \u25A0 \u25CF] ";
73
+ function W() {
74
+ function e(a, n) {
75
+ console.error(`${Q} ${a}`, n || "");
74
76
  }
75
- function t(r) {
76
- console.warn(`${q} ${r}`);
77
+ function t(a) {
78
+ console.warn(`${Q} ${a}`);
77
79
  }
78
- function u(r, n) {
80
+ function r(a, n) {
79
81
  }
80
82
  return {
81
83
  logError: e,
82
84
  logWarning: t,
83
- logMessage: u
85
+ logMessage: r
84
86
  };
85
87
  }
86
- const P = new ge(), k = L(!1);
87
- function b() {
88
- const { logMessage: e } = $();
89
- function t() {
90
- P == null || P.clear(), k.value = !k.value, e("clear Scene", P);
91
- }
92
- return {
93
- isSceneReset: k,
94
- clearScene: t,
95
- scene: P
96
- };
97
- }
98
- const Te = ["rotation", "scale", "position"];
99
- function Le() {
100
- const { catalogue: e } = Re(), { logMessage: t, logError: u } = $();
101
- function r() {
102
- return Object.entries(e).filter(([n, s]) => {
103
- var c, o;
104
- return (o = (c = s == null ? void 0 : s.prototype) == null ? void 0 : c.constructor) == null ? void 0 : o.toString().includes("class");
105
- }).map(([n, s]) => {
106
- const c = J({
88
+ const Be = ["rotation", "scale", "position"];
89
+ function Ie() {
90
+ const { catalogue: e } = Te(), { logMessage: t, logError: r } = W();
91
+ function a() {
92
+ return Object.entries(e).filter(([n, o]) => {
93
+ var u, i;
94
+ return (i = (u = o == null ? void 0 : o.prototype) == null ? void 0 : u.constructor) == null ? void 0 : i.toString().includes("class");
95
+ }).map(([n, o]) => {
96
+ const u = _({
107
97
  name: n,
108
- setup(o, { slots: a, attrs: p, ...g }) {
98
+ setup(i, { slots: s, attrs: p, ...d }) {
109
99
  t(n, {
110
- props: o,
111
- slots: a,
100
+ props: i,
101
+ slots: s,
112
102
  attrs: p,
113
- ctx: g
103
+ ctx: d
114
104
  });
115
105
  let f;
116
- const { scene: w } = b(), { pushCamera: S } = z();
117
- function h() {
118
- if ((a == null ? void 0 : a.default) && (a == null ? void 0 : a.default())) {
119
- const M = a.default().map((i) => {
120
- var m;
121
- let y;
122
- return (m = i == null ? void 0 : i.props) != null && m.args ? y = new e[i.type.name](...i.props.args) : y = new e[i.type.name](), i != null && i.props && d(i.props, y), y;
106
+ const { scene: m } = ae(), { pushCamera: y } = k();
107
+ function M() {
108
+ if ((s == null ? void 0 : s.default) && (s == null ? void 0 : s.default())) {
109
+ const C = s.default().map((c) => {
110
+ var g;
111
+ let w;
112
+ return (g = c == null ? void 0 : c.props) != null && g.args ? w = new e[c.type.name](...c.props.args) : w = new e[c.type.name](), c != null && c.props && E(c.props, w), w;
123
113
  });
124
- f = new s(...M);
114
+ f = new o(...C);
125
115
  } else
126
- p.args ? f = new s(...p.args) : f = new s();
127
- d(p, f), n === "PerspectiveCamera" || n === "OrtographicCamera" ? S(f) : w == null || w.add(f), t("Instance added", w), g.expose(f);
116
+ p.args ? f = new o(...p.args) : f = new o();
117
+ E(p, f), n === "PerspectiveCamera" || n === "OrtographicCamera" ? y(f) : m == null || m.value.add(f), t("Instance added", m), d.expose(f);
128
118
  }
129
- function d(M, i) {
130
- Object.entries(M).forEach(([y, m]) => {
131
- const C = y.replace(/(-\w)/g, (O) => O[1].toUpperCase());
132
- if (!(C === "args" || m === void 0)) {
133
- Te.includes(y) && m && (m = X(m));
119
+ function E(C, c) {
120
+ Object.entries(C).forEach(([w, g]) => {
121
+ const h = w.replace(/(-\w)/g, (P) => P[1].toUpperCase());
122
+ if (!(h === "args" || g === void 0)) {
123
+ Be.includes(w) && g && (g = Ae(g));
134
124
  try {
135
- i[C] && Pe(i[C].set) ? Q(m) ? i[C].set(...m) : i[C].set(m) : (m === "" && (m = !0), i[C] = m);
136
- } catch (O) {
137
- u(`There was an error setting ${C} property`, O);
125
+ c[h] && be(c[h].set) ? V(g) ? c[h].set(...g) : c[h].set(g) : (g === "" && (g = !0), c[h] = g);
126
+ } catch (P) {
127
+ r(`There was an error setting ${h} property`, P);
138
128
  }
139
129
  }
140
- }), M.ref && (M.ref = i);
130
+ }), C.ref && (C.ref = c);
141
131
  }
142
- return h(), () => {
132
+ return M(), () => {
143
133
  };
144
134
  }
145
135
  });
146
- return [n, c];
136
+ return [n, u];
147
137
  });
148
138
  }
149
139
  return {
150
- createComponentInstances: r
140
+ createComponentInstances: a
151
141
  };
152
142
  }
153
- let G;
154
- function N(e, t, u) {
155
- const r = new he(), { scene: n } = b(), s = () => {
156
- const o = r.getElapsedTime(), a = r.getDelta();
157
- n && (t && t(a, o), e(a, o), u && u(a, o)), G = requestAnimationFrame(s);
143
+ const ee = U(), te = U(), ne = U(), X = new ve(), { pause: ze, resume: Fe, isActive: je } = me(
144
+ () => {
145
+ const e = X.getElapsedTime(), t = X.getDelta();
146
+ ee.trigger({ delta: t, elapsed: e }), te.trigger({ delta: t, elapsed: e }), ne.trigger({ delta: t, elapsed: e });
147
+ },
148
+ { immediate: !1 }
149
+ );
150
+ function re() {
151
+ return {
152
+ onBeforeLoop: ee.on,
153
+ onLoop: te.on,
154
+ onAfterLoop: ne.on,
155
+ pause: ze,
156
+ resume: Fe,
157
+ isActive: je
158
158
  };
159
- s();
160
- function c() {
161
- cancelAnimationFrame(G);
162
- }
159
+ }
160
+ const De = $(new ye());
161
+ function ae() {
163
162
  return {
164
- disposeLoop: c
163
+ scene: De
165
164
  };
166
165
  }
167
- function be() {
168
- const e = new we(), t = L(e);
169
- return { loadingManager: e, loadingManagerRef: t };
166
+ function _e(e) {
167
+ const t = { nodes: {}, materials: {} };
168
+ return e && e.traverse((r) => {
169
+ r.name && (t.nodes[r.name] = r), r.material && !t.materials[r.material.name] && (t.materials[r.material.name] = r.material);
170
+ }), t;
171
+ }
172
+ async function Ge(e, t, r, a, n) {
173
+ const { logError: o } = W(), u = new e();
174
+ n && n(u), r && r(e);
175
+ const s = (Array.isArray(t) ? t : [t]).map(
176
+ (p) => new Promise((d, f) => {
177
+ u.load(
178
+ p,
179
+ (m) => {
180
+ m.scene && Object.assign(m, _e(m.scene)), d(m);
181
+ },
182
+ a,
183
+ (m) => f(o("[useLoader] - Failed to load resource", m))
184
+ );
185
+ })
186
+ );
187
+ return V(t) ? await Promise.all(s) : await s[0];
170
188
  }
171
- async function Ie(e) {
172
- const { loadingManager: t } = be(), u = new ye(t), r = (n) => new Promise((s, c) => {
173
- u.load(
189
+ async function Je(e) {
190
+ const t = new Me(), r = new Se(t), a = (n) => new Promise((o, u) => {
191
+ r.load(
174
192
  n,
175
- (o) => s(o),
193
+ (i) => o(i),
176
194
  () => null,
177
195
  () => {
178
- c(new Error("[useTextures] - Failed to load texture"));
196
+ u(new Error("[useTextures] - Failed to load texture"));
179
197
  }
180
198
  );
181
199
  });
182
- if (Q(e)) {
183
- const n = await Promise.all(e.map((s) => r(s)));
200
+ if (V(e)) {
201
+ const n = await Promise.all(e.map((o) => a(o)));
184
202
  return e.length > 1 ? n : n[0];
185
203
  } else {
186
- const { map: n, displacementMap: s, normalMap: c, roughnessMap: o, metalnessMap: a, aoMap: p } = e;
204
+ const { map: n, displacementMap: o, normalMap: u, roughnessMap: i, metalnessMap: s, aoMap: p } = e;
187
205
  return {
188
- map: n ? await r(n) : null,
189
- displacementMap: s ? await r(s) : null,
190
- normalMap: c ? await r(c) : null,
191
- roughnessMap: o ? await r(o) : null,
192
- metalnessMap: a ? await r(a) : null,
193
- aoMap: p ? await r(p) : null
206
+ map: n ? await a(n) : null,
207
+ displacementMap: o ? await a(o) : null,
208
+ normalMap: u ? await a(u) : null,
209
+ roughnessMap: i ? await a(i) : null,
210
+ metalnessMap: s ? await a(s) : null,
211
+ aoMap: p ? await a(p) : null
194
212
  };
195
213
  }
196
214
  }
197
- const T = ee({});
198
- function Y() {
199
- function e(u) {
200
- return T[u];
215
+ const L = pe({});
216
+ function qe() {
217
+ function e(r) {
218
+ return L[r];
201
219
  }
202
- function t(u, r) {
203
- T[u] = r;
220
+ function t(r, a) {
221
+ L[r] = a;
204
222
  }
205
223
  return {
206
- state: T,
207
- ...te(T),
224
+ state: L,
225
+ ...le(L),
208
226
  getState: e,
209
227
  setState: t
210
228
  };
211
229
  }
212
- let l, H;
213
- function Oe(e, t) {
214
- const { width: u, height: r } = K(), { logMessage: n } = $(), s = v(() => u.value / r.value), { scene: c } = b(), { activeCamera: o } = z(), { setState: a } = Y();
215
- a("scene", c), a("camera", o);
216
- function p() {
217
- l && (l.shadowMap.enabled = !0, l.shadowMap.type = Me);
218
- }
219
- function g() {
220
- l && (l.setSize(u.value, r.value), l.setPixelRatio(Math.min(window.devicePixelRatio, 2)));
221
- }
222
- function f() {
223
- l && (l.dispose(), l = null), n("disposeRenderer", l), H();
224
- }
225
- F(s, g);
226
- function w() {
227
- if (n("Render init", {
228
- renderer: l,
229
- canvas: e,
230
- scene: c
231
- }), !l && e.value && c) {
232
- const h = {
233
- canvas: e.value,
234
- ...t
235
- };
236
- t != null && t.context && (h.context = t.context), l = new Ce(h), t != null && t.shadows && p(), l.physicallyCorrectLights = (t == null ? void 0 : t.physicallyCorrectLights) || !1, t != null && t.outputEncoding && (l.outputEncoding = t.outputEncoding), t != null && t.toneMapping && (l.toneMapping = t.toneMapping, l.toneMappingExposure = 1), g(), l.render(c, o.value), a("renderer", l), H = N(() => {
237
- c && l && l.render(c, o.value);
238
- }).disposeLoop;
239
- }
240
- a("loop", N);
241
- }
242
- function S(h) {
243
- l && l.setClearColor(Ee(h));
244
- }
245
- return w(), {
230
+ const l = $(), F = D(!1);
231
+ function $e(e, t, r) {
232
+ const {
233
+ alpha: a = !1,
234
+ antialias: n,
235
+ depth: o,
236
+ logarithmicDepthBuffer: u,
237
+ failIfMajorPerformanceCaveat: i,
238
+ precision: s,
239
+ premultipliedAlpha: p,
240
+ stencil: d,
241
+ shadows: f = !1,
242
+ shadowMapType: m = Ee,
243
+ physicallyCorrectLights: y = !1,
244
+ outputEncoding: M = Pe,
245
+ toneMapping: E = xe,
246
+ toneMappingExposure: C = 1,
247
+ context: c = void 0,
248
+ powerPreference: w = "default",
249
+ preserveDrawingBuffer: g = !1,
250
+ clearColor: h = K("#000000"),
251
+ windowSize: P = !1
252
+ } = r, { width: b, height: A } = P ? Z() : de(t), { pixelRatio: H } = ge(), { pause: oe, resume: se } = re(), ie = j(() => b.value / A.value), N = () => {
253
+ !l.value || (l.value.setSize(b.value, A.value), l.value.setPixelRatio(H.value));
254
+ }, G = () => {
255
+ !l.value || (l.value.shadowMap.enabled = v(f), l.value.outputEncoding = v(M), l.value.shadowMap.type = v(m), l.value.physicallyCorrectLights = v(y), l.value.toneMapping = v(E), l.value.toneMappingExposure = v(C), l.value.setClearColor(K(v(h))));
256
+ }, ce = () => {
257
+ const J = B(e);
258
+ l.value || !J || (l.value = new Le({
259
+ canvas: J,
260
+ alpha: a,
261
+ antialias: n,
262
+ context: c,
263
+ depth: o,
264
+ failIfMajorPerformanceCaveat: i,
265
+ logarithmicDepthBuffer: u,
266
+ powerPreference: w,
267
+ precision: s,
268
+ stencil: d,
269
+ preserveDrawingBuffer: g,
270
+ premultipliedAlpha: p
271
+ }), G(), N(), se(), F.value = !0);
272
+ }, ue = () => {
273
+ !l.value || (l.value.dispose(), l.value = void 0, F.value = !1, oe());
274
+ };
275
+ return O([b, A, H], N), O(
276
+ () => [
277
+ f,
278
+ m,
279
+ M,
280
+ y,
281
+ E,
282
+ C,
283
+ h
284
+ ],
285
+ G
286
+ ), O(
287
+ () => [e, t],
288
+ () => {
289
+ B(e) && B(t) && ce();
290
+ },
291
+ { immediate: !0, deep: !0 }
292
+ ), {
246
293
  renderer: l,
247
- setClearColor: S,
248
- updateRenderer: g,
249
- disposeRenderer: f
294
+ isReady: F,
295
+ dispose: ue,
296
+ aspectRatio: ie
250
297
  };
251
298
  }
252
- const Z = /* @__PURE__ */ J({
253
- __name: "TresCanvas",
299
+ const Ue = _({
300
+ name: "TresCanvas",
254
301
  props: {
255
- camera: null,
256
- ortographic: { type: Boolean },
257
- gl: null,
258
- shadows: { type: Boolean, default: !1 },
259
- physicallyCorrectLights: { type: Boolean, default: !1 },
260
- outputEncoding: { default: Se },
261
- alpha: { type: Boolean, default: !1 },
262
- background: null,
263
- async: { type: Boolean, default: !1 }
302
+ shadows: Boolean,
303
+ shadowMapType: Object,
304
+ physicallyCorrectLights: Boolean,
305
+ outputEncoding: Object,
306
+ toneMapping: Object,
307
+ toneMappingExposure: Number,
308
+ context: Object,
309
+ powerPreference: Object,
310
+ preserveDrawingBuffer: Boolean,
311
+ clearColor: String,
312
+ windowSize: Boolean
264
313
  },
265
- setup(e) {
266
- const t = e;
267
- let u, r = () => {
268
- };
269
- const n = L(), s = L(!0), { scene: c, clearScene: o } = b(), a = re(), p = ne(), { createCamera: g } = z();
270
- let f;
271
- const w = Y();
272
- ae("UseTresState", w.state);
273
- const S = a.default ? a == null ? void 0 : a.default().some(
314
+ setup(e, { slots: t, attrs: r }) {
315
+ const { logError: a } = W(), n = D(), o = D(), { renderer: u, dispose: i, aspectRatio: s } = $e(n, o, e), p = $();
316
+ return R("camera", p), R("renderer", u), R("aspect-ratio", s), t.default && !t.default().some((d) => d.type.name === "Scene") && a("TresCanvas must contain a Scene component."), t.default && !t.default().some(
274
317
  (d) => d.type.name === "PerspectiveCamera" || d.type.name === "OrtographicCamera"
275
- ) : !1;
276
- if (c && !S)
277
- if (t.camera) {
278
- const { position: d, ...M } = t.camera;
279
- if (f = g(t.ortographic === !0 ? E.Orthographic : E.Perspective, M || {}), d) {
280
- const i = X(d);
281
- f.position.set(i[0], i[1], i[2]);
282
- }
283
- c.add(f);
284
- } else
285
- f = g(t.ortographic === !0 ? E.Orthographic : E.Perspective, {}), f.position.set(5, 5, 5), c.add(f);
286
- F(t, () => {
287
- u && (r(), o(), h());
288
- });
289
- function h() {
290
- const d = Oe(n, {
291
- antialias: !0,
292
- physicallyCorrectLights: t.physicallyCorrectLights,
293
- shadows: t.shadows,
294
- context: t.gl || null,
295
- alpha: t.alpha
296
- });
297
- u = d.renderer, r = d.disposeRenderer, t.background && d.setClearColor(t.background);
298
- }
299
- return oe(() => {
300
- h();
301
- }), se(() => {
302
- o(), r();
303
- }), (d, M) => {
304
- var i, y, m, C;
305
- return _(), j("div", {
306
- id: "tres-container",
307
- style: V({
308
- position: "relative",
309
- top: 0,
310
- left: 0,
311
- right: 0,
312
- bottom: 0,
313
- overflow: "hidden",
314
- width: ((y = (i = U(p)) == null ? void 0 : i.style) == null ? void 0 : y.width) || "100%",
315
- height: "100%"
316
- })
317
- }, [
318
- ce("canvas", {
319
- ref_key: "canvasRef",
320
- ref: n,
321
- style: V({ width: ((C = (m = U(p)) == null ? void 0 : m.style) == null ? void 0 : C.width) || "100%", height: "100%", overflow: "hidden" })
322
- }, null, 4),
323
- e.async ? (_(), ie(le, { key: 0 }, {
324
- default: ue(() => [
325
- s.value ? W(d.$slots, "default", { key: 0 }) : D("", !0)
326
- ]),
327
- _: 3
328
- })) : (_(), j(fe, { key: 1 }, [
329
- s.value ? W(d.$slots, "default", { key: 0 }) : D("", !0)
330
- ], 64))
331
- ], 4);
318
+ ) && a("Scene must contain a Camera component."), fe(() => i()), () => {
319
+ if (t.default)
320
+ return q(
321
+ "div",
322
+ {
323
+ ref: o,
324
+ style: {
325
+ position: "relative",
326
+ width: "100%",
327
+ height: "100vh",
328
+ ...r.style
329
+ }
330
+ },
331
+ [
332
+ q("canvas", {
333
+ ref: n,
334
+ style: { width: "100%", height: "100%", position: "absolute", top: 0, left: 0 }
335
+ }),
336
+ t.default()
337
+ ]
338
+ );
339
+ };
340
+ }
341
+ }), Ve = _({
342
+ name: "Scene",
343
+ setup(e, { slots: t }) {
344
+ const { scene: r } = ae(), a = Y("renderer"), { activeCamera: n } = k(), { onLoop: o } = re();
345
+ return R("local-scene", r), o(() => {
346
+ (a == null ? void 0 : a.value) && (n == null ? void 0 : n.value) && (r == null ? void 0 : r.value) && a.value.render(r == null ? void 0 : r.value, n.value);
347
+ }), () => {
348
+ if (t.default)
349
+ return t.default();
332
350
  };
333
351
  }
334
- }), ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
335
- __proto__: null,
336
- default: Z
337
- }, Symbol.toStringTag, { value: "Module" })), ve = Symbol("UseTresState"), Fe = {
352
+ }), Ke = Symbol("UseTresState"), Qe = {
338
353
  install(e) {
339
- e.component("TresCanvas", Z);
340
- const { createComponentInstances: t } = Le();
341
- t().forEach(([r, n]) => {
342
- e.component(r, n);
354
+ e.component("TresCanvas", Ue), e.component("Scene", Ve);
355
+ const { createComponentInstances: t } = Ie();
356
+ t().forEach(([a, n]) => {
357
+ e.component(a, n);
343
358
  });
344
359
  }
345
360
  };
346
361
  export {
347
- E as CameraType,
348
- ke as TresCanvas,
349
- ve as UseTresStateSymbol,
350
- Fe as default,
351
- z as useCamera,
352
- Re as useCatalog,
353
- Le as useInstanceCreator,
354
- be as useLoadingManager,
355
- N as useLoop,
356
- Oe as useRenderer,
357
- b as useScene,
358
- Ie as useTexture,
359
- Y as useTres
362
+ Oe as CameraType,
363
+ Ke as UseTresStateSymbol,
364
+ Qe as default,
365
+ _e as trasverseObjects,
366
+ k as useCamera,
367
+ Te as useCatalog,
368
+ Ie as useInstanceCreator,
369
+ Ge as useLoader,
370
+ re as useRenderLoop,
371
+ $e as useRenderer,
372
+ ae as useScene,
373
+ Je as useTexture,
374
+ qe as useTres
360
375
  };