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