@tresjs/core 2.4.1 → 3.0.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,479 +1,473 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v2.4.1
3
+ * version: v3.0.0
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 V, shallowReactive as se, toRefs as ce, provide as Re, inject as Te, watchEffect as ue, toRef as Le, shallowRef as Se, computed as z, watch as B, onUnmounted as fe, reactive as Ae, createRenderer as Oe, defineComponent as le, getCurrentInstance as ke, onMounted as Be, useSlots as je, openBlock as pe, createElementBlock as De, unref as F, createElementVNode as te, normalizeStyle as Ie, createBlock as He, normalizeProps as Ve, guardReactiveProps as ze, withCtx as Ge, renderSlot as Ne } from "vue";
9
- import * as Fe from "three";
10
- import { PerspectiveCamera as j, OrthographicCamera as We, Clock as de, Vector3 as $e, Color as W, SRGBColorSpace as Ue, ACESFilmicToneMapping as Ye, PCFSoftShadowMap as qe, PCFShadowMap as Ke, LinearSRGBColorSpace as ne, NoToneMapping as ae, WebGLRenderer as Je, LoadingManager as Xe, TextureLoader as Qe, Raycaster as Ze, Vector2 as et, BufferAttribute as tt, Scene as nt } from "three";
11
- import { createEventHook as S, useRafFn as at, toValue as m, useWindowSize as ot, useElementSize as rt, useDevicePixelRatio as it, unrefElement as $, usePointer as st, useElementBounding as ct } from "@vueuse/core";
12
- const me = V({}), ve = (e) => void Object.assign(me.value, e), oe = (e) => typeof e == "function", ge = (e) => !!e && e.constructor === Array, h = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
13
- function ut() {
14
- const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0;
15
- return (h[e & 255] + h[e >> 8 & 255] + h[e >> 16 & 255] + h[e >> 24 & 255] + "-" + h[t & 255] + h[t >> 8 & 255] + "-" + h[t >> 16 & 15 | 64] + h[t >> 24 & 255] + "-" + h[n & 63 | 128] + h[n >> 8 & 255] + "-" + h[n >> 16 & 255] + h[n >> 24 & 255] + h[a & 255] + h[a >> 8 & 255] + h[a >> 16 & 255] + h[a >> 24 & 255]).toLowerCase();
16
- }
17
- const q = Symbol();
18
- function ft() {
19
- const e = se({
20
- uuid: ut(),
21
- camera: void 0,
22
- cameras: [],
23
- canvas: void 0,
24
- scene: void 0,
25
- renderer: void 0,
26
- aspectRatio: void 0,
27
- pointerEventHandler: void 0
28
- });
29
- function t(r) {
30
- return e[r];
31
- }
32
- function n(r, s) {
33
- e[r] = s;
34
- }
35
- const a = {
36
- state: e,
37
- ...ce(e),
38
- getState: t,
39
- setState: n
8
+ import { ref as W, computed as _, watchEffect as b, onUnmounted as j, shallowRef as z, watch as J, reactive as re, readonly as ne, provide as ae, inject as oe, createRenderer as se, defineComponent as ie, useSlots as ue, onMounted as le, openBlock as ce, createElementBlock as fe, normalizeStyle as me } from "vue";
9
+ import * as pe from "three";
10
+ import { PerspectiveCamera as G, OrthographicCamera as ve, Camera as de, Clock as ge, SRGBColorSpace as we, ACESFilmicToneMapping as ye, PCFSoftShadowMap as Ce, Vector3 as Pe, Color as O, WebGLRenderer as H, LoadingManager as Me, TextureLoader as _e, Vector2 as Ee, Raycaster as xe, BufferAttribute as Le, Scene as Te } from "three";
11
+ import { createEventHook as A, useRafFn as be, toValue as y, unrefElement as De, useDevicePixelRatio as Ae, usePointer as ke, useElementBounding as Se, useWindowSize as he, useElementSize as Be } from "@vueuse/core";
12
+ const K = W({}), X = (e) => void Object.assign(K.value, e), I = (e) => typeof e == "function", Y = (e) => !!e && e.constructor === Array, Oe = ({ sizes: e, scene: a }) => {
13
+ const t = W([]), n = _(
14
+ () => t.value[0]
15
+ ), r = (o, s = !1) => {
16
+ t.value.some(({ uuid: u }) => u === o.uuid) || (s ? l(o) : t.value.push(o));
17
+ }, i = (o) => {
18
+ t.value = t.value.filter(({ uuid: s }) => s !== o.uuid);
19
+ }, l = (o) => {
20
+ const s = o instanceof de ? o : t.value.find((c) => c.uuid === o);
21
+ if (!s)
22
+ return;
23
+ const u = t.value.filter(({ uuid: c }) => c !== s.uuid);
24
+ t.value = [s, ...u];
40
25
  };
41
- return Re(q, a), a;
42
- }
43
- const A = () => Te(q, {
44
- state: se({
45
- camera: void 0,
46
- cameras: [],
47
- canvas: void 0,
48
- scene: void 0,
49
- renderer: void 0,
50
- pointerEventHandler: void 0
51
- })
52
- });
53
- var lt = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(lt || {});
54
- const pt = 45;
55
- let R;
56
- function dt() {
57
- const { state: e, setState: t, aspectRatio: n } = A();
58
- function a(i = "Perspective", u) {
59
- var l, d, p;
60
- if (i === "Perspective") {
61
- const { near: _, far: E, fov: b } = u || {
62
- near: 0.1,
63
- far: 1e3,
64
- fov: pt
65
- };
66
- R = new j(b, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, _, E), (d = e.cameras) == null || d.push(R);
67
- } else {
68
- const { left: _, right: E, top: b, bottom: y, near: C, far: M } = u || {
69
- left: -100,
70
- right: 100,
71
- top: 100,
72
- bottom: -100,
73
- near: 0.1,
74
- far: 1e3
75
- };
76
- R = new We(_, E, b, y, C, M), (p = e.cameras) == null || p.push(R);
77
- }
78
- return e.camera = R, t("camera", e.camera), R;
79
- }
80
- function r() {
81
- var i;
82
- e.camera instanceof j && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (i = e.camera) == null || i.updateProjectionMatrix();
83
- }
84
- function s(i) {
85
- var u;
86
- (u = e.cameras) == null || u.push(i), i instanceof j && e.aspectRatio && (i.aspect = e.aspectRatio.value), i.updateProjectionMatrix(), t("camera", i);
87
- }
88
- function c(i) {
89
- var u;
90
- ((u = e.cameras) == null ? void 0 : u.length) === 0 && s(i);
91
- }
92
- function o() {
93
- e.cameras = [];
94
- }
95
- return ue(() => {
96
- n != null && n.value && r();
26
+ return b(() => {
27
+ e.aspectRatio.value && t.value.forEach((o) => {
28
+ o instanceof G && (o.aspect = e.aspectRatio.value), (o instanceof G || o instanceof ve) && o.updateProjectionMatrix();
29
+ });
30
+ }), a.userData.tres__registerCamera = r, a.userData.tres__deregisterCamera = i, j(() => {
31
+ t.value = [];
97
32
  }), {
98
- activeCamera: Le(e, "camera"),
99
- createCamera: a,
100
- updateCamera: r,
101
- pushCamera: s,
102
- clearCameras: o,
103
- setFirstCamera: c
33
+ camera: n,
34
+ cameras: t,
35
+ addCamera: r,
36
+ removeCamera: i,
37
+ setCameraActive: l
104
38
  };
105
- }
106
- const ye = S(), we = S(), K = S(), L = new de();
107
- let D = 0, I = 0;
108
- const { pause: mt, resume: vt, isActive: gt } = at(
39
+ }, Q = A(), Z = A(), $ = A(), D = new ge();
40
+ let R = 0, F = 0;
41
+ const { pause: Re, resume: Fe, isActive: ze } = be(
109
42
  () => {
110
- ye.trigger({ delta: D, elapsed: I, clock: L }), we.trigger({ delta: D, elapsed: I, clock: L }), K.trigger({ delta: D, elapsed: I, clock: L });
43
+ Q.trigger({ delta: R, elapsed: F, clock: D }), Z.trigger({ delta: R, elapsed: F, clock: D }), $.trigger({ delta: R, elapsed: F, clock: D });
111
44
  },
112
45
  { immediate: !1 }
113
46
  );
114
- K.on(() => {
115
- D = L.getDelta(), I = L.getElapsedTime();
47
+ $.on(() => {
48
+ R = D.getDelta(), F = D.getElapsedTime();
116
49
  });
117
- function he() {
118
- return {
119
- onBeforeLoop: ye.on,
120
- onLoop: we.on,
121
- onAfterLoop: K.on,
122
- pause: mt,
123
- resume: vt,
124
- isActive: gt
125
- };
126
- }
127
- function Vt(e) {
128
- return typeof e == "number" ? [e, e, e] : e instanceof $e ? [e.x, e.y, e.z] : e;
129
- }
130
- function yt(e) {
131
- return e instanceof W ? e : Array.isArray(e) ? new W(...e) : new W(e);
132
- }
133
- const U = {
50
+ const ee = () => ({
51
+ onBeforeLoop: Q.on,
52
+ onLoop: Z.on,
53
+ onAfterLoop: $.on,
54
+ pause: Re,
55
+ resume: Fe,
56
+ isActive: ze
57
+ }), h = {
134
58
  realistic: {
135
- outputColorSpace: Ue,
136
- toneMapping: Ye,
59
+ outputColorSpace: we,
60
+ toneMapping: ye,
137
61
  toneMappingExposure: 3,
138
62
  shadowMap: {
139
63
  enabled: !0,
140
- type: qe
64
+ type: Ce
141
65
  }
142
66
  }
143
- }, be = (e, t) => {
144
- for (const n of Object.keys(t))
145
- t[n] instanceof Object && Object.assign(t[n], be(e[n], t[n]));
146
- return Object.assign(e || {}, t), e;
147
- }, wt = "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", ht = /* @__PURE__ */ bt(wt);
148
- function k(e) {
149
- return e.replace(/-([a-z])/g, (t, n) => n.toUpperCase());
67
+ }, te = (e, a) => {
68
+ for (const t of Object.keys(a))
69
+ a[t] instanceof Object && Object.assign(a[t], te(e[t], a[t]));
70
+ return Object.assign(e || {}, a), e;
71
+ }, He = "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", Ve = /* @__PURE__ */ Ge(He);
72
+ function B(e) {
73
+ return e.replace(/-([a-z])/g, (a, t) => t.toUpperCase());
150
74
  }
151
- function bt(e, t) {
152
- const n = /* @__PURE__ */ Object.create(null), a = e.split(",");
153
- for (let r = 0; r < a.length; r++)
154
- n[a[r]] = !0;
155
- return t ? (r) => !!n[r.toLowerCase()] : (r) => !!n[r];
75
+ function Ge(e, a) {
76
+ const t = /* @__PURE__ */ Object.create(null), n = e.split(",");
77
+ for (let r = 0; r < n.length; r++)
78
+ t[n[r]] = !0;
79
+ return a ? (r) => !!t[r.toLowerCase()] : (r) => !!t[r];
156
80
  }
157
- const Et = (e, t) => {
158
- const n = /* @__PURE__ */ new Set(), a = [];
81
+ const We = (e, a) => {
82
+ const t = /* @__PURE__ */ new Set(), n = [];
159
83
  for (const r of e) {
160
- const s = t(r);
161
- n.has(s) || (n.add(s), a.push(r));
84
+ const i = a(r);
85
+ t.has(i) || (t.add(i), n.push(r));
162
86
  }
163
- return a;
164
- }, zt = !0, re = "[TresJS ▲ ■ ●] ";
165
- function O() {
166
- function e(a, r) {
167
- console.error(`${re} ${a}`, r || "");
87
+ return n;
88
+ }, N = (e, a) => {
89
+ if (!a)
90
+ return;
91
+ const t = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
92
+ return t == null ? void 0 : t.reduce((n, r) => n && n[r], e);
93
+ }, je = (e, a, t) => {
94
+ const n = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
95
+ n && n.reduce((r, i, l) => (r[i] === void 0 && (r[i] = {}), l === n.length - 1 && (r[i] = t), r[i]), e);
96
+ }, st = !0, q = "[TresJS ▲ ■ ●] ";
97
+ function k() {
98
+ function e(n, r) {
99
+ console.error(`${q} ${n}`, r || "");
168
100
  }
169
- function t(a) {
170
- console.warn(`${re} ${a}`);
101
+ function a(n) {
102
+ console.warn(`${q} ${n}`);
171
103
  }
172
- function n(a, r) {
104
+ function t(n, r) {
173
105
  }
174
106
  return {
175
107
  logError: e,
176
- logWarning: t,
177
- logMessage: n
108
+ logWarning: a,
109
+ logMessage: t
178
110
  };
179
111
  }
180
- function _t(e) {
181
- const t = Se(), n = V(!1), {
182
- alpha: a = !0,
183
- antialias: r = !0,
184
- depth: s,
185
- logarithmicDepthBuffer: c,
186
- failIfMajorPerformanceCaveat: o,
187
- precision: i,
188
- premultipliedAlpha: u,
189
- stencil: l,
190
- shadows: d = !1,
191
- shadowMapType: p = Ke,
192
- useLegacyLights: _ = !1,
193
- outputColorSpace: E = ne,
194
- toneMapping: b = ae,
195
- toneMappingExposure: y = 1,
196
- context: C = void 0,
197
- powerPreference: M = "default",
198
- preserveDrawingBuffer: g = !1,
199
- clearColor: w,
200
- windowSize: x = !1,
201
- preset: G = void 0
202
- } = ce(e), { state: f, setState: v } = A(), { width: J, height: X } = m(x) == !0 || m(x) === "" || m(x) === "true" ? ot() : rt(f.container), { logError: Ee, logWarning: _e } = O(), { pixelRatio: Q } = it(), { pause: Pe, resume: Ce } = he(), N = z(() => J.value / X.value);
203
- setTimeout(() => {
204
- var P;
205
- !m(x) && !((P = f.canvas) != null && P.value.offsetHeight) && _e(`Oops... Seems like your canvas height is currently 0px, it's posible that you couldn't watch your scene.
206
- You could set windowSize=true to force the canvas to be the size of the window.`);
207
- }, 1e3);
208
- const Z = () => {
209
- t.value && (t.value.setSize(J.value, X.value), t.value.setPixelRatio(Math.min(Q.value, 2)));
210
- }, ee = () => {
211
- if (!t.value)
212
- return;
213
- const P = m(G);
214
- if (P) {
215
- P in U || Ee("Renderer Preset must be one of these: " + Object.keys(U).join(", ")), be(t.value, U[P]);
216
- return;
217
- }
218
- t.value.shadowMap.enabled = m(d), t.value.shadowMap.type = m(p), t.value.toneMapping = m(b) || ae, t.value.toneMappingExposure = m(y), t.value.outputColorSpace = m(E) || ne, w != null && w.value && t.value.setClearColor(yt(m(w))), t.value.useLegacyLights = m(_);
219
- }, Me = () => {
220
- const P = $(f.canvas);
221
- P && (t.value = new Je({
222
- canvas: P,
223
- alpha: m(a),
224
- antialias: m(r),
225
- context: m(C),
226
- depth: m(s),
227
- failIfMajorPerformanceCaveat: m(o),
228
- logarithmicDepthBuffer: m(c),
229
- powerPreference: m(M),
230
- precision: m(i),
231
- stencil: m(l),
232
- preserveDrawingBuffer: m(g),
233
- premultipliedAlpha: m(u)
234
- }), v("renderer", t.value), v("clock", new de()), v("aspectRatio", N), ee(), Z(), Ce(), n.value = !0);
235
- }, xe = () => {
236
- t.value && (t.value.dispose(), t.value = void 0, n.value = !1, Pe());
237
- };
238
- return B([N, Q], Z), B(
239
- [d, p, E, _, b, y, w],
240
- ee
241
- ), B(
242
- () => [f.canvas, f.container],
243
- () => {
244
- $(f.canvas) && $(f.container) && Me();
245
- },
246
- { immediate: !0, deep: !0 }
247
- ), {
248
- renderer: t,
249
- isReady: n,
250
- dispose: xe,
251
- aspectRatio: N
112
+ function it(e) {
113
+ return typeof e == "number" ? [e, e, e] : e instanceof Pe ? [e.x, e.y, e.z] : e;
114
+ }
115
+ function $e(e) {
116
+ return e instanceof O ? e : Array.isArray(e) ? new O(...e) : new O(e);
117
+ }
118
+ function Ie({
119
+ scene: e,
120
+ canvas: a,
121
+ options: t,
122
+ disableRender: n,
123
+ contextParts: { sizes: r, camera: i }
124
+ }) {
125
+ const l = _(() => ({
126
+ alpha: y(t.alpha),
127
+ depth: y(t.depth),
128
+ canvas: De(a),
129
+ context: y(t.context),
130
+ stencil: y(t.stencil),
131
+ antialias: y(t.antialias) === void 0 ? (
132
+ // an opinionated default of tres
133
+ !0
134
+ ) : y(t.antialias),
135
+ precision: y(t.precision),
136
+ powerPreference: y(t.powerPreference),
137
+ premultipliedAlpha: y(t.premultipliedAlpha),
138
+ preserveDrawingBuffer: y(t.preserveDrawingBuffer),
139
+ logarithmicDepthBuffer: y(t.logarithmicDepthBuffer),
140
+ failIfMajorPerformanceCaveat: y(t.failIfMajorPerformanceCaveat)
141
+ })), o = z(new H(l.value));
142
+ J(l, () => {
143
+ o.value.dispose(), o.value = new H(l.value);
144
+ }), b(() => {
145
+ o.value.setSize(r.width.value, r.height.value);
146
+ });
147
+ const { pixelRatio: s } = Ae();
148
+ b(() => {
149
+ o.value.setPixelRatio(s.value);
150
+ });
151
+ const { logError: u } = k(), f = (() => {
152
+ const p = new H(), d = {
153
+ shadowMap: {
154
+ enabled: p.shadowMap.enabled,
155
+ type: p.shadowMap.type
156
+ },
157
+ toneMapping: p.toneMapping,
158
+ toneMappingExposure: p.toneMappingExposure,
159
+ outputColorSpace: p.outputColorSpace,
160
+ useLegacyLights: p.useLegacyLights
161
+ };
162
+ return p.dispose(), d;
163
+ })();
164
+ b(() => {
165
+ const p = y(t.preset);
166
+ p && (p in h || u("Renderer Preset must be one of these: " + Object.keys(h).join(", ")), te(o.value, h[p]));
167
+ const d = (L, x) => {
168
+ const T = y(L), S = () => {
169
+ if (p)
170
+ return N(h[p], x);
171
+ };
172
+ if (T !== void 0)
173
+ return T;
174
+ const m = S();
175
+ return m !== void 0 ? m : N(f, x);
176
+ }, v = (L, x) => je(o.value, x, d(L, x));
177
+ v(t.shadows, "shadowMap.enabled"), v(t.toneMapping, "toneMapping"), v(t.shadowMapType, "shadowMap.type"), v(t.useLegacyLights, "useLegacyLights"), v(t.outputColorSpace, "outputColorSpace"), v(t.toneMappingExposure, "toneMappingExposure");
178
+ const E = d(t.clearColor, "clearColor");
179
+ E && o.value.setClearColor(
180
+ E ? $e(E) : new O(0)
181
+ // default clear color is not easily/efficiently retrievable from three
182
+ );
183
+ });
184
+ const { pause: w, resume: C, onLoop: M } = ee();
185
+ return M(() => {
186
+ i.value && !y(n) && o.value.render(e, i.value);
187
+ }), C(), j(() => {
188
+ w(), o.value.dispose(), o.value.forceContextLoss();
189
+ }), {
190
+ renderer: o
252
191
  };
253
192
  }
254
- function Pt(e) {
255
- const t = { nodes: {}, materials: {} };
256
- return e && e.traverse((n) => {
257
- n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
258
- }), t;
193
+ function Ne(e) {
194
+ const a = { nodes: {}, materials: {} };
195
+ return e && e.traverse((t) => {
196
+ t.name && (a.nodes[t.name] = t), t.material && !a.materials[t.material.name] && (a.materials[t.material.name] = t.material);
197
+ }), a;
259
198
  }
260
- async function Gt(e, t, n, a, r) {
261
- const { logError: s } = O(), c = new e();
262
- r && r(c), n && n(c);
263
- const i = (Array.isArray(t) ? t : [t]).map(
264
- (u) => new Promise((l, d) => {
265
- c.load(
199
+ async function ut(e, a, t, n, r) {
200
+ const { logError: i } = k(), l = new e();
201
+ r && r(l), t && t(l);
202
+ const s = (Array.isArray(a) ? a : [a]).map(
203
+ (u) => new Promise((c, f) => {
204
+ l.load(
266
205
  u,
267
- (p) => {
268
- p.scene && Object.assign(p, Pt(p.scene)), l(p);
206
+ (w) => {
207
+ w.scene && Object.assign(w, Ne(w.scene)), c(w);
269
208
  },
270
- a,
271
- (p) => d(s("[useLoader] - Failed to load resource", p))
209
+ n,
210
+ (w) => f(i("[useLoader] - Failed to load resource", w))
272
211
  );
273
212
  })
274
213
  );
275
- return ge(t) ? await Promise.all(i) : await i[0];
214
+ return Y(a) ? await Promise.all(s) : await s[0];
276
215
  }
277
- async function Nt(e) {
278
- const t = new Xe(), n = new Qe(t), a = (r) => new Promise((s, c) => {
279
- n.load(
216
+ async function lt(e) {
217
+ const a = new Me(), t = new _e(a), n = (r) => new Promise((i, l) => {
218
+ t.load(
280
219
  r,
281
- (o) => s(o),
220
+ (o) => i(o),
282
221
  () => null,
283
222
  () => {
284
- c(new Error("[useTextures] - Failed to load texture"));
223
+ l(new Error("[useTextures] - Failed to load texture"));
285
224
  }
286
225
  );
287
226
  });
288
- if (ge(e)) {
289
- const r = await Promise.all(e.map((s) => a(s)));
227
+ if (Y(e)) {
228
+ const r = await Promise.all(e.map((i) => n(i)));
290
229
  return e.length > 1 ? r : r[0];
291
230
  } else {
292
231
  const {
293
232
  map: r,
294
- displacementMap: s,
295
- normalMap: c,
233
+ displacementMap: i,
234
+ normalMap: l,
296
235
  roughnessMap: o,
297
- metalnessMap: i,
236
+ metalnessMap: s,
298
237
  aoMap: u,
299
- alphaMap: l,
300
- matcap: d
238
+ alphaMap: c,
239
+ matcap: f
301
240
  } = e;
302
241
  return {
303
- map: r ? await a(r) : null,
304
- displacementMap: s ? await a(s) : null,
305
- normalMap: c ? await a(c) : null,
306
- roughnessMap: o ? await a(o) : null,
307
- metalnessMap: i ? await a(i) : null,
308
- aoMap: u ? await a(u) : null,
309
- alphaMap: l ? await a(l) : null,
310
- matcap: d ? await a(d) : null
242
+ map: r ? await n(r) : null,
243
+ displacementMap: i ? await n(i) : null,
244
+ normalMap: l ? await n(l) : null,
245
+ roughnessMap: o ? await n(o) : null,
246
+ metalnessMap: s ? await n(s) : null,
247
+ aoMap: u ? await n(u) : null,
248
+ alphaMap: c ? await n(c) : null,
249
+ matcap: f ? await n(f) : null
311
250
  };
312
251
  }
313
252
  }
314
- const Ct = (e) => {
315
- const { state: t } = A(), n = z(() => {
316
- var f;
317
- return (f = t.canvas) == null ? void 0 : f.value;
318
- }), { x: a, y: r } = st({ target: n }), { width: s, height: c, top: o, left: i } = ct(n), u = new Ze(), l = ({ x: f, y: v }) => {
319
- if (n.value)
253
+ const qe = (e, { renderer: a, camera: t, raycaster: n }) => {
254
+ const r = _(() => a.value.domElement), { x: i, y: l } = ke({ target: r }), { width: o, height: s, top: u, left: c } = Se(r), f = ({ x: m, y: P }) => {
255
+ if (r.value)
320
256
  return {
321
- x: (f - i.value) / s.value * 2 - 1,
322
- y: -((v - o.value) / c.value) * 2 + 1
257
+ x: (m - c.value) / o.value * 2 - 1,
258
+ y: -((P - u.value) / s.value) * 2 + 1
323
259
  };
324
- }, d = ({ x: f, y: v }) => {
325
- if (t.camera)
326
- return u.setFromCamera(new et(f, v), t.camera), u.intersectObjects(e.value, !1);
327
- }, p = (f) => {
328
- const v = l({
329
- x: (f == null ? void 0 : f.clientX) ?? a.value,
330
- y: (f == null ? void 0 : f.clientY) ?? r.value
260
+ }, w = ({ x: m, y: P }) => {
261
+ if (t.value)
262
+ return n.value.setFromCamera(new Ee(m, P), t.value), n.value.intersectObjects(e.value, !1);
263
+ }, C = (m) => {
264
+ const P = f({
265
+ x: (m == null ? void 0 : m.clientX) ?? i.value,
266
+ y: (m == null ? void 0 : m.clientY) ?? l.value
331
267
  });
332
- return v ? d(v) || [] : [];
333
- }, _ = z(() => p()), E = S(), b = S(), y = (f, v) => {
334
- f.trigger({ event: v, intersects: p(v) });
335
- }, C = (f) => {
336
- y(b, f);
268
+ return P ? w(P) || [] : [];
269
+ }, M = _(() => C()), p = A(), d = A(), v = (m, P) => {
270
+ m.trigger({ event: P, intersects: C(P) });
271
+ }, E = (m) => {
272
+ v(d, m);
337
273
  };
338
- let M;
339
- const g = (f) => {
340
- var v;
341
- M = (v = p(f)[0]) == null ? void 0 : v.object;
342
- }, w = (f) => {
343
- var v;
344
- f instanceof PointerEvent && M === ((v = p(f)[0]) == null ? void 0 : v.object) && y(E, f);
345
- }, x = (f) => b.trigger({ event: f, intersects: [] }), G = ue(() => {
346
- n != null && n.value && (n.value.addEventListener("pointerup", w), n.value.addEventListener("pointerdown", g), n.value.addEventListener("pointermove", C), n.value.addEventListener("pointerleave", x), G());
347
- });
348
- return fe(() => {
349
- n != null && n.value && (n.value.removeEventListener("pointerup", w), n.value.removeEventListener("pointerdown", g), n.value.removeEventListener("pointermove", C), n.value.removeEventListener("pointerleave", x));
274
+ let L;
275
+ const x = (m) => {
276
+ var P;
277
+ L = (P = C(m)[0]) == null ? void 0 : P.object;
278
+ }, T = (m) => {
279
+ var P;
280
+ m instanceof PointerEvent && L === ((P = C(m)[0]) == null ? void 0 : P.object) && v(p, m);
281
+ }, S = (m) => d.trigger({ event: m, intersects: [] });
282
+ return r.value.addEventListener("pointerup", T), r.value.addEventListener("pointerdown", x), r.value.addEventListener("pointermove", E), r.value.addEventListener("pointerleave", S), j(() => {
283
+ r != null && r.value && (r.value.removeEventListener("pointerup", T), r.value.removeEventListener("pointerdown", x), r.value.removeEventListener("pointermove", E), r.value.removeEventListener("pointerleave", S));
350
284
  }), {
351
- intersects: _,
352
- onClick: (f) => E.on(f).off,
353
- onPointerMove: (f) => b.on(f).off
285
+ intersects: M,
286
+ onClick: (m) => p.on(m).off,
287
+ onPointerMove: (m) => d.on(m).off
354
288
  };
355
289
  };
356
- function Ft() {
357
- const { logWarning: e } = O();
358
- function t(a, r, s) {
359
- let c = null;
360
- return a.traverse((o) => {
361
- o[r] === s && (c = o);
362
- }), c || e(`Child with ${r} '${s}' not found.`), c;
290
+ function ct() {
291
+ const { logWarning: e } = k();
292
+ function a(n, r, i) {
293
+ let l = null;
294
+ return n.traverse((o) => {
295
+ o[r] === i && (l = o);
296
+ }), l || e(`Child with ${r} '${i}' not found.`), l;
363
297
  }
364
- function n(a, r) {
365
- return t(a, "name", r);
298
+ function t(n, r) {
299
+ return a(n, "name", r);
366
300
  }
367
301
  return {
368
- seek: t,
369
- seekByName: n
302
+ seek: a,
303
+ seekByName: t
370
304
  };
371
305
  }
372
- const Mt = () => {
373
- const e = Ae({
306
+ const Ue = ({ scene: e, contextParts: a }) => {
307
+ const t = re({
374
308
  click: /* @__PURE__ */ new Map(),
375
309
  pointerMove: /* @__PURE__ */ new Map(),
376
310
  pointerEnter: /* @__PURE__ */ new Map(),
377
311
  pointerLeave: /* @__PURE__ */ new Map()
378
- }), t = (o) => {
379
- Object.values(e).forEach((i) => i.delete(o));
380
- }, n = (o) => {
381
- const { onClick: i, onPointerMove: u, onPointerEnter: l, onPointerLeave: d } = o;
382
- i && e.click.set(o, i), u && e.pointerMove.set(o, u), l && e.pointerEnter.set(o, l), d && e.pointerLeave.set(o, d), o.addEventListener("removed", () => {
383
- o.traverse((p) => {
384
- t(p);
385
- }), t(o);
386
- });
387
- }, a = z(
388
- () => Et(
389
- Object.values(e).map((o) => Array.from(o.keys())).flat(),
390
- ({ uuid: o }) => o
312
+ }), n = (u) => {
313
+ Object.values(t).forEach((c) => c.delete(u));
314
+ }, r = (u) => {
315
+ const { onClick: c, onPointerMove: f, onPointerEnter: w, onPointerLeave: C } = u;
316
+ c && t.click.set(u, c), f && t.pointerMove.set(u, f), w && t.pointerEnter.set(u, w), C && t.pointerLeave.set(u, C);
317
+ };
318
+ e.userData.tres__registerAtPointerEventHandler = r, e.userData.tres__deregisterAtPointerEventHandler = n;
319
+ const i = _(
320
+ () => We(
321
+ Object.values(t).map((u) => Array.from(u.keys())).flat(),
322
+ ({ uuid: u }) => u
391
323
  )
392
- ), { onClick: r, onPointerMove: s } = Ct(a);
393
- r(({ intersects: o, event: i }) => {
394
- var u;
395
- o.length && ((u = e.click.get(o[0].object)) == null || u(o[0], i));
324
+ ), { onClick: l, onPointerMove: o } = qe(i, a);
325
+ l(({ intersects: u, event: c }) => {
326
+ var f;
327
+ u.length && ((f = t.click.get(u[0].object)) == null || f(u[0], c));
396
328
  });
397
- let c;
398
- return s(({ intersects: o, event: i }) => {
399
- var _, E, b, y;
400
- const u = (_ = o == null ? void 0 : o[0]) == null ? void 0 : _.object, { pointerLeave: l, pointerEnter: d, pointerMove: p } = e;
401
- c && c !== u && ((E = l.get(c)) == null || E(c, i)), u && (c !== u && ((b = d.get(u)) == null || b(o[0], i)), (y = p.get(u)) == null || y(o[0], i)), c = u || null;
329
+ let s;
330
+ return o(({ intersects: u, event: c }) => {
331
+ var p, d, v, E;
332
+ const f = (p = u == null ? void 0 : u[0]) == null ? void 0 : p.object, { pointerLeave: w, pointerEnter: C, pointerMove: M } = t;
333
+ s && s !== f && ((d = w.get(s)) == null || d(s, c)), f && (s !== f && ((v = C.get(f)) == null || v(u[0], c)), (E = M.get(f)) == null || E(u[0], c)), s = f || null;
402
334
  }), {
403
- registerObject: n,
404
- deregisterObject: t
335
+ registerObject: r,
336
+ deregisterObject: n
405
337
  };
406
- }, H = {
407
- GEOMETRY_VIA_PROP: "tres__geometryViaProp",
408
- MATERIAL_VIA_PROP: "tres__materialViaProp",
409
- REGISTER_AT_POINTER_EVENT_HANDLER: "tres__registerAtPointerEventHandler"
410
338
  };
411
- let Y = null, T = null;
412
- const { logError: ie } = O(), xt = {
413
- createElement(e, t, n, a) {
414
- var i, u;
415
- if (a || (a = {}), a.args || (a.args = []), e === "template" || ht(e))
339
+ function Je({
340
+ scene: e,
341
+ canvas: a,
342
+ windowSize: t,
343
+ disableRender: n,
344
+ rendererOptions: r
345
+ }) {
346
+ const i = _(
347
+ () => y(t) ? he() : Be(y(a).parentElement)
348
+ ), l = _(() => i.value.width.value), o = _(() => i.value.height.value), s = _(() => l.value / o.value), u = {
349
+ height: o,
350
+ width: l,
351
+ aspectRatio: s
352
+ }, c = z(e), {
353
+ camera: f,
354
+ cameras: w,
355
+ addCamera: C,
356
+ removeCamera: M,
357
+ setCameraActive: p
358
+ } = Oe({ sizes: u, scene: e }), { renderer: d } = Ie(
359
+ {
360
+ scene: e,
361
+ canvas: a,
362
+ options: r,
363
+ contextParts: { sizes: u, camera: f },
364
+ disableRender: n
365
+ }
366
+ ), v = {
367
+ sizes: u,
368
+ scene: c,
369
+ camera: f,
370
+ cameras: ne(w),
371
+ renderer: d,
372
+ raycaster: z(new xe()),
373
+ addCamera: C,
374
+ removeCamera: M,
375
+ setCameraActive: p
376
+ };
377
+ return ae("useTres", v), v;
378
+ }
379
+ function Ke() {
380
+ const e = oe("useTres");
381
+ if (!e)
382
+ throw new Error("useTresContext must be used together with useTresContextProvider");
383
+ return e;
384
+ }
385
+ const ft = Ke;
386
+ let V = null, g = null;
387
+ const { logError: U } = k(), Xe = {
388
+ createElement(e, a, t, n) {
389
+ var l, o;
390
+ if (n || (n = {}), n.args || (n.args = []), e === "template" || Ve(e))
416
391
  return null;
417
- let r = e.replace("Tres", ""), s;
392
+ let r = e.replace("Tres", ""), i;
418
393
  if (e === "primitive") {
419
- (a == null ? void 0 : a.object) === void 0 && ie("Tres primitives need a prop 'object'");
420
- const l = a.object;
421
- r = l.type, s = Object.assign(l, { type: r, attach: a.attach, primitive: !0 });
394
+ (n == null ? void 0 : n.object) === void 0 && U("Tres primitives need a prop 'object'");
395
+ const s = n.object;
396
+ r = s.type, i = Object.assign(s, { type: r, attach: n.attach, primitive: !0 });
422
397
  } else {
423
- const l = me.value[r];
424
- l || ie(`${r} is not defined on the THREE namespace. Use extend to add it to the catalog.`), s = new l(...a.args);
398
+ const s = K.value[r];
399
+ s || U(`${r} is not defined on the THREE namespace. Use extend to add it to the catalog.`), i = new s(...n.args);
425
400
  }
426
- s.isCamera && (a != null && a.position || s.position.set(3, 3, 3), a != null && a.lookAt || s.lookAt(0, 0, 0)), (a == null ? void 0 : a.attach) === void 0 && (s.isMaterial ? s.attach = "material" : s.isBufferGeometry && (s.attach = "geometry"));
427
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: o } = H;
428
- return s.isObject3D && ((i = a == null ? void 0 : a.material) != null && i.isMaterial && (s.userData[o] = !0), (u = a == null ? void 0 : a.geometry) != null && u.isBufferGeometry && (s.userData[c] = !0)), s;
401
+ return i.isCamera && (n != null && n.position || i.position.set(3, 3, 3), n != null && n.lookAt || i.lookAt(0, 0, 0)), (n == null ? void 0 : n.attach) === void 0 && (i.isMaterial ? i.attach = "material" : i.isBufferGeometry && (i.attach = "geometry")), i.isObject3D && ((l = n == null ? void 0 : n.material) != null && l.isMaterial && (i.userData.tres__materialViaProp = !0), (o = n == null ? void 0 : n.geometry) != null && o.isBufferGeometry && (i.userData.tres__geometryViaProp = !0)), i;
429
402
  },
430
- insert(e, t) {
431
- var n, a, r, s, c, o, i;
432
- if (t && t.isScene && (T = t), (((n = e == null ? void 0 : e.__vnode) == null ? void 0 : n.type) === "TresGroup" || ((a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.type) === "TresObject3D") && t === null && !((s = (r = e == null ? void 0 : e.__vnode) == null ? void 0 : r.ctx) != null && s.asyncResolved)) {
433
- Y = e;
403
+ insert(e, a) {
404
+ var t, n, r, i, l, o, s, u, c;
405
+ if (a && a.isScene && (g = a), (((t = e == null ? void 0 : e.__vnode) == null ? void 0 : t.type) === "TresGroup" || ((n = e == null ? void 0 : e.__vnode) == null ? void 0 : n.type) === "TresObject3D") && a === null && !((i = (r = e == null ? void 0 : e.__vnode) == null ? void 0 : r.ctx) != null && i.asyncResolved)) {
406
+ V = e;
434
407
  return;
435
408
  } else
436
- (c = e == null ? void 0 : e.__vnode) != null && c.type.includes("Controls") && t === null && (Y = T);
437
- t || (t = Y), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" }), (i = (o = T == null ? void 0 : T.userData) == null ? void 0 : o[H.REGISTER_AT_POINTER_EVENT_HANDLER]) == null || i.call(o, e)) : e != null && e.isFog ? t.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
409
+ (l = e == null ? void 0 : e.__vnode) != null && l.type.includes("Controls") && a === null && (V = g);
410
+ if (a || (a = V), e != null && e.isObject3D) {
411
+ if (e != null && e.isCamera) {
412
+ if (!(g != null && g.userData.tres__registerCamera))
413
+ throw "could not find tres__registerCamera on scene's userData";
414
+ (s = g == null ? void 0 : (o = g.userData).tres__registerCamera) == null || s.call(o, e);
415
+ }
416
+ if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) {
417
+ if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
418
+ throw "could not find tres__registerAtPointerEventHandler on scene's userData";
419
+ (c = g == null ? void 0 : (u = g.userData).tres__registerAtPointerEventHandler) == null || c.call(u, e);
420
+ }
421
+ }
422
+ e != null && e.isObject3D && (a != null && a.isObject3D) ? (a.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? a.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[a == null ? void 0 : a.attach], a && (a[e.attach] = e));
438
423
  },
439
424
  remove(e) {
440
- var t, n;
425
+ var a, t;
441
426
  if (e) {
442
427
  if (e.isObject3D) {
443
- const a = e, r = (s) => {
444
- var i, u;
445
- const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: o } = H;
446
- s.userData[o] || (i = s.material) == null || i.dispose(), s.userData[c] || (u = s.geometry) == null || u.dispose();
428
+ const n = e, r = (s) => {
429
+ var c, f;
430
+ const u = s;
431
+ s.userData.tres__materialViaProp || (c = u.material) == null || c.dispose(), s.userData.tres__geometryViaProp || (f = u.geometry) == null || f.dispose();
432
+ }, i = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, l = (s) => {
433
+ if (!i)
434
+ throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
435
+ (s != null && s.onClick || s != null && s.onPointerMove || s != null && s.onPointerEnter || s != null && s.onPointerLeave) && (i == null || i(s));
436
+ }, o = (s) => {
437
+ const u = g == null ? void 0 : g.userData.tres__deregisterCamera;
438
+ if (!u)
439
+ throw "could not find tres__deregisterCamera on scene's userData";
440
+ s.isCamera && (u == null || u(s));
447
441
  };
448
- a.traverse((s) => {
449
- r(s);
450
- }), r(a);
442
+ n.traverse((s) => {
443
+ r(s), o(s), l == null || l(s);
444
+ }), r(n), o(n), l == null || l(n);
451
445
  }
452
- (t = e.removeFromParent) == null || t.call(e), (n = e.dispose) == null || n.call(e);
446
+ (a = e.removeFromParent) == null || a.call(e), (t = e.dispose) == null || t.call(e);
453
447
  }
454
448
  },
455
- patchProp(e, t, n, a) {
449
+ patchProp(e, a, t, n) {
456
450
  if (e) {
457
- let r = e, s = t, c = k(s), o = r == null ? void 0 : r[c];
451
+ let r = e, i = a, l = B(i), o = r == null ? void 0 : r[l];
458
452
  if (r.type === "BufferGeometry") {
459
- if (s === "args")
453
+ if (i === "args")
460
454
  return;
461
455
  r.setAttribute(
462
- k(s),
463
- new tt(...a)
456
+ B(i),
457
+ new Le(...n)
464
458
  );
465
459
  return;
466
460
  }
467
- if (s.includes("-") && o === void 0) {
468
- const u = s.split("-");
469
- o = u.reduce((l, d) => l[k(d)], r), s = u.pop(), c = s.toLowerCase(), o != null && o.set || (r = u.reduce((l, d) => l[k(d)], r));
461
+ if (i.includes("-") && o === void 0) {
462
+ const u = i.split("-");
463
+ o = u.reduce((c, f) => c[B(f)], r), i = u.pop(), l = i.toLowerCase(), o != null && o.set || (r = u.reduce((c, f) => c[B(f)], r));
470
464
  }
471
- let i = a;
472
- if (i === "" && (i = !0), oe(o)) {
473
- Array.isArray(i) ? e[c](...i) : e[c](i);
465
+ let s = n;
466
+ if (s === "" && (s = !0), I(o)) {
467
+ Array.isArray(s) ? e[l](...s) : e[l](s);
474
468
  return;
475
469
  }
476
- !(o != null && o.set) && !oe(o) ? r[c] = i : o.constructor === i.constructor && (o != null && o.copy) ? o == null || o.copy(i) : Array.isArray(i) ? o.set(...i) : !o.isColor && o.setScalar ? o.setScalar(i) : o.set(i);
470
+ !(o != null && o.set) && !I(o) ? r[l] = s : o.constructor === s.constructor && (o != null && o.copy) ? o == null || o.copy(s) : Array.isArray(s) ? o.set(...s) : !o.isColor && o.setScalar ? o.setScalar(s) : o.set(s);
477
471
  }
478
472
  },
479
473
  parentNode(e) {
@@ -488,156 +482,127 @@ const { logError: ie } = O(), xt = {
488
482
  setScopeId: () => void 0,
489
483
  cloneNode: () => void 0,
490
484
  insertStaticContent: () => void 0
491
- }, { createApp: Rt } = Oe(xt), Tt = (e) => {
492
- const t = Rt(n);
493
- function n() {
485
+ }, { createApp: Ye } = se(Xe), Qe = (e) => {
486
+ const a = Ye(t);
487
+ function t() {
494
488
  return e && e.default ? e.default() : [];
495
489
  }
496
- return t;
490
+ return a;
497
491
  };
498
- ve(Fe);
499
- const Lt = ["data-scene"], St = { style: { width: "100%", height: "100%" } }, At = ["data-scene"], Ot = /* @__PURE__ */ le({
500
- __name: "TresScene",
492
+ X(pe);
493
+ const Ze = ["data-scene"], et = /* @__PURE__ */ ie({
494
+ __name: "TresCanvas",
501
495
  props: {
502
496
  shadows: { type: Boolean },
497
+ clearColor: {},
498
+ toneMapping: {},
503
499
  shadowMapType: {},
504
- physicallyCorrectLights: { type: Boolean, default: !1 },
505
500
  useLegacyLights: { type: Boolean },
506
501
  outputColorSpace: {},
507
- toneMapping: {},
508
502
  toneMappingExposure: {},
509
- context: {},
510
- powerPreference: {},
511
- preserveDrawingBuffer: { type: Boolean },
512
- clearColor: {},
513
503
  windowSize: { type: Boolean },
514
504
  preset: {},
515
505
  disableRender: { type: Boolean },
516
- camera: {}
517
- },
518
- setup(e, { expose: t }) {
519
- const n = e, { logWarning: a } = O();
520
- n.physicallyCorrectLights === !0 && a("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
521
- const r = V(), s = V(), c = new nt(), o = Mt(), { setState: i } = A();
522
- c.userData[H.REGISTER_AT_POINTER_EVENT_HANDLER] = o.registerObject, i("scene", c), i("canvas", s), i("container", r), i("pointerEventHandler", o), i("appContext", ke());
523
- const { onLoop: u, resume: l } = he(), { activeCamera: d, pushCamera: p, clearCameras: _ } = dt();
524
- Be(() => {
525
- b();
526
- }), fe(() => {
527
- i("renderer", null);
528
- });
529
- function E() {
530
- const g = c.getObjectByProperty("isCamera", !0);
531
- if (g)
532
- p(g);
533
- else {
534
- a("No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene.");
535
- const w = new j(45, window.innerWidth / window.innerHeight, 0.1, 1e3);
536
- w.position.set(3, 3, 3), w.lookAt(0, 0, 0), p(w);
537
- }
538
- }
539
- function b() {
540
- const { renderer: g } = _t(n);
541
- n.camera && p(n.camera), u(() => {
542
- var w;
543
- d.value && n.disableRender !== !0 && ((w = g.value) == null || w.render(c, d.value));
544
- });
545
- }
546
- let y;
547
- const C = je();
548
- function M() {
549
- y = Tt(C);
550
- const g = A();
551
- y.provide("useTres", g), y.provide(q, g), y.provide("extend", ve), y.mount(c), E();
552
- }
553
- return M(), t({
554
- scene: c
555
- }), B(
556
- () => n.camera,
557
- (g) => {
558
- g && (_(), p(g));
559
- }
560
- ), (g, w) => (pe(), De("div", {
561
- ref_key: "container",
562
- ref: r,
563
- key: F(c).uuid,
564
- "data-scene": F(c).uuid,
565
- style: { position: "relative", width: "100%", height: "100%", pointerEvents: "auto", touchAction: "none" }
566
- }, [
567
- te("div", St, [
568
- te("canvas", {
569
- ref_key: "canvas",
570
- ref: s,
571
- "data-scene": F(c).uuid,
572
- style: Ie({ display: "block", width: "100%", height: "100%", position: g.windowSize ? "fixed" : "absolute", top: 0, left: 0 })
573
- }, null, 12, At)
574
- ])
575
- ], 8, Lt));
576
- }
577
- }), kt = /* @__PURE__ */ le({
578
- __name: "TresCanvas",
579
- props: {
580
- shadows: { type: Boolean },
581
- shadowMapType: {},
582
- physicallyCorrectLights: { type: Boolean },
583
- useLegacyLights: { type: Boolean },
584
- outputColorSpace: {},
585
- toneMapping: {},
586
- toneMappingExposure: {},
506
+ camera: {},
587
507
  context: {},
508
+ precision: {},
509
+ alpha: { type: Boolean, default: !1 },
510
+ premultipliedAlpha: { type: Boolean },
511
+ antialias: { type: Boolean, default: !0 },
512
+ stencil: { type: Boolean, default: !0 },
513
+ preserveDrawingBuffer: { type: Boolean, default: !1 },
588
514
  powerPreference: {},
589
- preserveDrawingBuffer: { type: Boolean },
590
- clearColor: {},
591
- windowSize: { type: Boolean },
592
- preset: {},
593
- disableRender: { type: Boolean },
594
- camera: {}
515
+ depth: { type: Boolean, default: !0 },
516
+ logarithmicDepthBuffer: { type: Boolean },
517
+ failIfMajorPerformanceCaveat: { type: Boolean }
595
518
  },
596
- setup(e, { expose: t }) {
597
- const n = e, a = ft();
598
- return t(a), (r, s) => (pe(), He(Ot, Ve(ze(n)), {
599
- default: Ge(() => [
600
- Ne(r.$slots, "default")
601
- ]),
602
- _: 3
603
- }, 16));
519
+ setup(e) {
520
+ const a = e, { logWarning: t } = k(), n = W(), r = z(new Te());
521
+ ee();
522
+ const i = ue();
523
+ let l;
524
+ const o = (u) => {
525
+ l = Qe(i), l.provide("useTres", u), l.provide("extend", X), l.mount(r.value);
526
+ }, s = _(() => a.disableRender);
527
+ return le(() => {
528
+ const u = n, c = Je({
529
+ scene: r.value,
530
+ canvas: u,
531
+ windowSize: a.windowSize,
532
+ disableRender: s,
533
+ rendererOptions: a
534
+ });
535
+ Ue({ scene: r.value, contextParts: c });
536
+ const { addCamera: f, camera: w, cameras: C, removeCamera: M } = c;
537
+ o(c);
538
+ const p = () => {
539
+ const d = new G(45, window.innerWidth / window.innerHeight, 0.1, 1e3);
540
+ d.position.set(3, 3, 3), d.lookAt(0, 0, 0), f(d);
541
+ const v = b(
542
+ () => {
543
+ C.value.length >= 2 && (d.removeFromParent(), M(d), v == null || v());
544
+ }
545
+ );
546
+ };
547
+ J(() => a.camera, (d, v) => {
548
+ d ? f(d) : v && (v.removeFromParent(), M(v));
549
+ }, {
550
+ immediate: !0
551
+ }), w.value || (t(
552
+ "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
553
+ ), p());
554
+ }), (u, c) => (ce(), fe("canvas", {
555
+ ref_key: "canvas",
556
+ ref: n,
557
+ "data-scene": r.value.uuid,
558
+ style: me({
559
+ display: "block",
560
+ width: "100%",
561
+ height: "100%",
562
+ position: u.windowSize ? "fixed" : "relative",
563
+ top: 0,
564
+ left: 0,
565
+ pointerEvents: "auto",
566
+ touchAction: "none",
567
+ zIndex: 1
568
+ })
569
+ }, null, 12, Ze));
604
570
  }
605
- }), Bt = [
571
+ }), tt = [
606
572
  "TresCanvas",
607
573
  "TresLeches",
608
574
  "TresScene"
609
- ], jt = {
575
+ ], rt = {
610
576
  template: {
611
577
  compilerOptions: {
612
- isCustomElement: (e) => e.startsWith("Tres") && !Bt.includes(e) || e === "primitive"
578
+ isCustomElement: (e) => e.startsWith("Tres") && !tt.includes(e) || e === "primitive"
613
579
  }
614
580
  }
615
- }, Wt = jt, $t = {
581
+ }, mt = rt, pt = {
616
582
  install(e) {
617
- e.component("TresCanvas", kt);
583
+ e.component("TresCanvas", et);
618
584
  }
619
585
  };
620
586
  export {
621
- lt as CameraType,
622
- q as TRES_CONTEXT_KEY,
623
- kt as TresCanvas,
624
- me as catalogue,
625
- $t as default,
626
- ve as extend,
627
- zt as isProd,
628
- yt as normalizeColor,
629
- Vt as normalizeVectorFlexibleParam,
630
- Wt as templateCompilerOptions,
631
- Pt as trasverseObjects,
632
- dt as useCamera,
633
- Gt as useLoader,
634
- O as useLogger,
635
- Mt as usePointerEventHandler,
636
- Ct as useRaycaster,
637
- he as useRenderLoop,
638
- _t as useRenderer,
639
- Ft as useSeek,
640
- Nt as useTexture,
641
- A as useTres,
642
- ft as useTresProvider
587
+ et as TresCanvas,
588
+ K as catalogue,
589
+ pt as default,
590
+ X as extend,
591
+ st as isProd,
592
+ $e as normalizeColor,
593
+ it as normalizeVectorFlexibleParam,
594
+ mt as templateCompilerOptions,
595
+ Ne as trasverseObjects,
596
+ Oe as useCamera,
597
+ ut as useLoader,
598
+ k as useLogger,
599
+ Ue as usePointerEventHandler,
600
+ qe as useRaycaster,
601
+ ee as useRenderLoop,
602
+ Ie as useRenderer,
603
+ ct as useSeek,
604
+ lt as useTexture,
605
+ ft as useTres,
606
+ Ke as useTresContext,
607
+ Je as useTresContextProvider
643
608
  };