@tresjs/core 3.7.0-next.0 → 3.8.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.
Files changed (42) hide show
  1. package/dist/index.d.ts +3 -18
  2. package/dist/{components → src/components}/TresCanvas.vue.d.ts +11 -9
  3. package/dist/src/components/index.d.ts +3 -0
  4. package/dist/{composables → src/composables}/useCamera/index.d.ts +472 -433
  5. package/dist/{composables → src/composables}/useLogger.d.ts +5 -2
  6. package/dist/{composables → src/composables}/usePointerEventHandler/index.d.ts +4 -3
  7. package/dist/{composables → src/composables}/useRenderLoop/index.d.ts +3 -2
  8. package/dist/{composables → src/composables}/useRenderer/index.d.ts +8 -8
  9. package/dist/src/composables/useSizes/index.d.ts +12 -0
  10. package/dist/{composables → src/composables}/useTexture/index.d.ts +2 -1
  11. package/dist/{composables → src/composables}/useTresContextProvider/index.d.ts +6 -9
  12. package/dist/{core → src/core}/catalogue.d.ts +3 -2
  13. package/dist/src/core/nodeOps.d.ts +4 -0
  14. package/dist/{core → src/core}/renderer.d.ts +1 -1
  15. package/dist/src/devtools/highlight.d.ts +7 -0
  16. package/dist/src/devtools/index.d.ts +1 -0
  17. package/dist/src/devtools/plugin.d.ts +16 -0
  18. package/dist/src/devtools/utils.d.ts +7 -0
  19. package/dist/src/directives/index.d.ts +6 -0
  20. package/dist/src/directives/vAlwaysLookAt.d.ts +7 -0
  21. package/dist/src/directives/vDistanceTo.d.ts +7 -0
  22. package/dist/src/directives/vLightHelper.d.ts +7 -0
  23. package/dist/src/directives/vLog.d.ts +7 -0
  24. package/dist/src/index.d.ts +19 -0
  25. package/dist/{types → src/types}/index.d.ts +3 -2
  26. package/dist/{utils → src/utils}/index.d.ts +8 -8
  27. package/dist/{utils → src/utils}/normalize.d.ts +2 -2
  28. package/dist/{utils → src/utils}/perf.d.ts +3 -2
  29. package/dist/src/utils/test-utils.d.ts +1 -0
  30. package/dist/tres.js +999 -462
  31. package/dist/tres.umd.cjs +3 -3
  32. package/package.json +14 -13
  33. package/dist/components/index.d.ts +0 -2
  34. package/dist/composables/useLoader/index.d.ts +0 -44
  35. package/dist/composables/useRaycaster/index.d.ts +0 -18
  36. package/dist/composables/useSeek/index.d.ts +0 -19
  37. package/dist/core/nodeOps.d.ts +0 -3
  38. package/dist/utils/test-utils.d.ts +0 -1
  39. /package/dist/{composables → src/composables}/index.d.ts +0 -0
  40. /package/dist/{composables → src/composables}/useRenderer/const.d.ts +0 -0
  41. /package/dist/{core → src/core}/revision.d.ts +0 -0
  42. /package/dist/{utils → src/utils}/template-compiler-options.d.ts +0 -0
package/dist/tres.js CHANGED
@@ -1,192 +1,353 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v3.7.0-next.0
4
- * (c) 2023
3
+ * version: v3.8.0
4
+ * (c) 2024
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 L, computed as D, watchEffect as k, onUnmounted as O, shallowRef as S, watch as ae, reactive as ge, readonly as ye, provide as G, inject as he, createRenderer as we, defineComponent as J, useSlots as Ee, getCurrentInstance as K, onMounted as _e, openBlock as Ce, createElementBlock as Me, normalizeClass as Pe, normalizeStyle as Ae, h as X, Fragment as be } from "vue";
9
- import * as De from "three";
10
- import { PerspectiveCamera as W, OrthographicCamera as ke, Camera as Te, Clock as Se, Vector3 as xe, Color as F, REVISION as Le, SRGBColorSpace as Oe, ACESFilmicToneMapping as Be, PCFSoftShadowMap as Re, WebGLRenderer as N, LoadingManager as je, TextureLoader as He, Vector2 as Fe, Raycaster as ze, BufferAttribute as $e, Scene as Ie } from "three";
11
- import { createEventHook as x, useRafFn as ne, toValue as C, unrefElement as Ne, useDevicePixelRatio as Ve, usePointer as Ge, useElementBounding as We, useWindowSize as qe, useElementSize as Ue, useFps as Ye, useMemory as Je } from "@vueuse/core";
12
- const Ke = ({ sizes: e, scene: n }) => {
13
- const t = L([]), r = D(
8
+ var De = Object.defineProperty;
9
+ var Be = (e, r, t) => r in e ? De(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
10
+ var J = (e, r, t) => (Be(e, typeof r != "symbol" ? r + "" : r, t), t);
11
+ import { ref as R, computed as T, watchEffect as D, onUnmounted as G, shallowRef as j, watch as ge, reactive as ve, readonly as q, provide as K, inject as je, createRenderer as He, defineComponent as ne, useSlots as Re, getCurrentInstance as se, onMounted as Ie, openBlock as $e, createElementBlock as Ne, normalizeClass as Ve, unref as ze, normalizeStyle as We, h as ie, Fragment as Ue } from "vue";
12
+ import * as he from "three";
13
+ import { PerspectiveCamera as X, OrthographicCamera as Fe, Camera as Ge, Clock as Je, Vector3 as ye, Color as W, MeshBasicMaterial as we, DoubleSide as Qe, REVISION as Ye, SRGBColorSpace as qe, ACESFilmicToneMapping as Ke, PCFSoftShadowMap as Xe, WebGLRenderer as Q, TextureLoader as Ze, Vector2 as et, Raycaster as tt, BufferAttribute as rt, Scene as ot, Line as nt, BufferGeometry as ae, Float32BufferAttribute as le, LineBasicMaterial as st, Mesh as it, BackSide as at, DirectionalLightHelper as lt, PointLightHelper as ut, SpotLightHelper as ct, HemisphereLightHelper as dt, ArrowHelper as ft } from "three";
14
+ import { createEventHook as H, useRafFn as be, toValue as _, unrefElement as pt, useDevicePixelRatio as mt, usePointer as gt, useElementBounding as vt, useWindowSize as ht, useElementSize as yt, refDebounced as ue, useFps as wt, useMemory as bt } from "@vueuse/core";
15
+ const _t = "@tresjs/core", Et = "module", Ct = "3.8.0", Mt = "pnpm@8.15.6", xt = "Declarative ThreeJS using Vue Components", St = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Pt = "MIT", kt = [
16
+ "vue",
17
+ "3d",
18
+ "threejs",
19
+ "three",
20
+ "threejs-vue"
21
+ ], Tt = !1, At = {
22
+ ".": {
23
+ types: "./dist/index.d.ts",
24
+ require: "./dist/tres.umd.cjs",
25
+ import: "./dist/tres.js"
26
+ },
27
+ "./components": {
28
+ types: "./dist/components/index.d.ts"
29
+ },
30
+ "./composables": {
31
+ types: "./dist/composables/index.d.ts"
32
+ },
33
+ "./types": {
34
+ types: "./dist/types/index.d.ts"
35
+ },
36
+ "./utils": {
37
+ types: "./dist/utils/index.d.ts"
38
+ },
39
+ "./*": "./*"
40
+ }, Lt = "./dist/tres.js", Ot = "./dist/tres.js", Dt = "./dist/index.d.ts", Bt = [
41
+ "dist",
42
+ "*.d.ts"
43
+ ], jt = {
44
+ access: "public"
45
+ }, Ht = {
46
+ dev: "cd playground && npm run dev",
47
+ build: "vite build",
48
+ playground: "cd playground && npm run dev",
49
+ test: "vitest",
50
+ "test:ci": "vitest run",
51
+ "test:ui": "vitest --ui",
52
+ release: "release-it",
53
+ coverage: "vitest run --coverage",
54
+ lint: "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
55
+ "docs:dev": "vitepress dev docs",
56
+ "docs:build": "vitepress build docs",
57
+ "docs:serve": "vitepress serve docs",
58
+ "docs:preview": "vitepress preview docs",
59
+ "docs:contributors": "esno scripts/update-contributors.ts"
60
+ }, Rt = {
61
+ three: ">=0.133",
62
+ vue: ">=3.3"
63
+ }, It = {
64
+ "@alvarosabu/utils": "^3.1.1",
65
+ "@vue/devtools-api": "^6.6.1",
66
+ "@vueuse/core": "^10.7.0"
67
+ }, $t = {
68
+ "@release-it/conventional-changelog": "^8.0.1",
69
+ "@stackblitz/sdk": "^1.9.0",
70
+ "@tresjs/cientos": "3.8.0",
71
+ "@tresjs/eslint-config-vue": "^0.2.1",
72
+ "@types/three": "^0.163.0",
73
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
74
+ "@typescript-eslint/parser": "^7.5.0",
75
+ "@vitejs/plugin-vue": "^5.0.4",
76
+ "@vitest/coverage-c8": "^0.33.0",
77
+ "@vitest/ui": "^1.0.4",
78
+ "@vue/test-utils": "^2.4.3",
79
+ eslint: "^8.55.0",
80
+ "eslint-plugin-vue": "^9.19.2",
81
+ esno: "^4.0.0",
82
+ gsap: "^3.12.3",
83
+ jsdom: "^24.0.0",
84
+ kolorist: "^1.8.0",
85
+ ohmyfetch: "^0.4.21",
86
+ pathe: "^1.1.1",
87
+ "release-it": "^17.0.1",
88
+ "rollup-plugin-analyzer": "^4.0.0",
89
+ "rollup-plugin-copy": "^3.5.0",
90
+ "rollup-plugin-visualizer": "^5.11.0",
91
+ three: "^0.163.0",
92
+ unocss: "^0.58.0",
93
+ unplugin: "^1.10.1",
94
+ "unplugin-vue-components": "^0.26.0",
95
+ vite: "^5.2.7",
96
+ "vite-plugin-banner": "^0.7.1",
97
+ "vite-plugin-dts": "3.8.1",
98
+ "vite-plugin-inspect": "^0.8.1",
99
+ "vite-plugin-require-transform": "^1.0.21",
100
+ "vite-svg-loader": "^5.1.0",
101
+ vitepress: "1.0.2",
102
+ vitest: "^1.0.4",
103
+ vue: "^3.3.11",
104
+ "vue-demi": "^0.14.6"
105
+ }, Nt = {
106
+ name: _t,
107
+ type: Et,
108
+ version: Ct,
109
+ packageManager: Mt,
110
+ description: xt,
111
+ author: St,
112
+ license: Pt,
113
+ keywords: kt,
114
+ sideEffects: Tt,
115
+ exports: At,
116
+ main: Lt,
117
+ module: Ot,
118
+ types: Dt,
119
+ files: Bt,
120
+ publishConfig: jt,
121
+ scripts: Ht,
122
+ peerDependencies: Rt,
123
+ dependencies: It,
124
+ devDependencies: $t
125
+ }, Vt = ({ sizes: e, scene: r }) => {
126
+ const t = R([]), o = T(
14
127
  () => t.value[0]
15
- ), a = (l, c = !1) => {
16
- t.value.some(({ uuid: m }) => m === l.uuid) || (c ? u(l) : t.value.push(l));
17
- }, o = (l) => {
18
- t.value = t.value.filter(({ uuid: c }) => c !== l.uuid);
19
- }, u = (l) => {
20
- const c = l instanceof Te ? l : t.value.find((h) => h.uuid === l);
21
- if (!c)
128
+ ), s = (a, l = !1) => {
129
+ t.value.some(({ uuid: c }) => c === a.uuid) || (l ? n(a) : t.value.push(a));
130
+ }, i = (a) => {
131
+ t.value = t.value.filter(({ uuid: l }) => l !== a.uuid);
132
+ }, n = (a) => {
133
+ const l = a instanceof Ge ? a : t.value.find((m) => m.uuid === a);
134
+ if (!l)
22
135
  return;
23
- const m = t.value.filter(({ uuid: h }) => h !== c.uuid);
24
- t.value = [c, ...m];
136
+ const c = t.value.filter(({ uuid: m }) => m !== l.uuid);
137
+ t.value = [l, ...c];
25
138
  };
26
- return k(() => {
27
- e.aspectRatio.value && t.value.forEach((l) => {
28
- l instanceof W && (l.aspect = e.aspectRatio.value), (l instanceof W || l instanceof ke) && l.updateProjectionMatrix();
139
+ return D(() => {
140
+ e.aspectRatio.value && t.value.forEach((a) => {
141
+ a instanceof X && (a.aspect = e.aspectRatio.value), (a instanceof X || a instanceof Fe) && a.updateProjectionMatrix();
29
142
  });
30
- }), n.userData.tres__registerCamera = a, n.userData.tres__deregisterCamera = o, O(() => {
143
+ }), r.userData.tres__registerCamera = s, r.userData.tres__deregisterCamera = i, G(() => {
31
144
  t.value = [];
32
145
  }), {
33
- camera: r,
146
+ camera: o,
34
147
  cameras: t,
35
- registerCamera: a,
36
- deregisterCamera: o,
37
- setCameraActive: u
148
+ registerCamera: s,
149
+ deregisterCamera: i,
150
+ setCameraActive: n
38
151
  };
39
- }, oe = x(), se = x(), U = x(), T = new Se();
40
- let z = 0, $ = 0;
41
- const { pause: Xe, resume: Qe, isActive: Ze } = ne(
152
+ }, _e = H(), Ee = H(), te = H(), B = new Je();
153
+ let U = 0, F = 0;
154
+ const { pause: zt, resume: Wt, isActive: Ut } = be(
42
155
  () => {
43
- oe.trigger({ delta: z, elapsed: $, clock: T }), se.trigger({ delta: z, elapsed: $, clock: T }), U.trigger({ delta: z, elapsed: $, clock: T });
156
+ _e.trigger({ delta: U, elapsed: F, clock: B }), Ee.trigger({ delta: U, elapsed: F, clock: B }), te.trigger({ delta: U, elapsed: F, clock: B });
44
157
  },
45
158
  { immediate: !1 }
46
159
  );
47
- U.on(() => {
48
- z = T.getDelta(), $ = T.getElapsedTime();
160
+ te.on(() => {
161
+ U = B.getDelta(), F = B.getElapsedTime();
49
162
  });
50
- const ie = () => ({
51
- onBeforeLoop: oe.on,
52
- onLoop: se.on,
53
- onAfterLoop: U.on,
54
- pause: Xe,
55
- resume: Qe,
56
- isActive: Ze
57
- }), bt = !0, Q = "[TresJS ▲ ■ ●] ";
58
- function B() {
59
- function e(r, a) {
60
- console.error(`${Q} ${r}`, a || "");
163
+ const re = () => ({
164
+ onBeforeLoop: _e.on,
165
+ onLoop: Ee.on,
166
+ onAfterLoop: te.on,
167
+ pause: zt,
168
+ resume: Wt,
169
+ isActive: Ut
170
+ }), Rr = !0, $ = "[TresJS ▲ ■ ●] ";
171
+ function A() {
172
+ function e(...o) {
173
+ typeof o[0] == "string" ? o[0] = $ + o[0] : o.unshift($), console.error(...o);
61
174
  }
62
- function n(r) {
63
- console.warn(`${Q} ${r}`);
175
+ function r(...o) {
176
+ typeof o[0] == "string" ? o[0] = $ + o[0] : o.unshift($), console.warn(...o);
64
177
  }
65
- function t(r, a) {
178
+ function t(o, s) {
66
179
  }
67
180
  return {
68
181
  logError: e,
69
- logWarning: n,
182
+ logWarning: r,
70
183
  logMessage: t
71
184
  };
72
185
  }
73
- function Dt(e) {
74
- return typeof e == "number" ? [e, e, e] : e instanceof xe ? [e.x, e.y, e.z] : e;
186
+ function Ir(e) {
187
+ return typeof e == "number" ? [e, e, e] : e instanceof ye ? [e.x, e.y, e.z] : e;
188
+ }
189
+ function Ft(e) {
190
+ return e instanceof W ? e : Array.isArray(e) ? new W(...e) : new W(e);
75
191
  }
76
- function et(e) {
77
- return e instanceof F ? e : Array.isArray(e) ? new F(...e) : new F(e);
192
+ class Gt extends he.Mesh {
193
+ constructor(...t) {
194
+ super(...t);
195
+ J(this, "type", "HightlightMesh");
196
+ J(this, "createTime");
197
+ this.createTime = Date.now();
198
+ }
199
+ onBeforeRender() {
200
+ const o = (Date.now() - this.createTime) / 1e3, n = 1 + 0.07 * Math.sin(2.5 * o);
201
+ this.scale.set(n, n, n);
202
+ }
78
203
  }
79
- const le = (e, n) => {
80
- for (const t of Object.keys(n))
81
- n[t] instanceof Object && Object.assign(n[t], le(e[t], n[t]));
82
- return Object.assign(e || {}, n), e;
83
- }, tt = "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", rt = /* @__PURE__ */ at(tt);
84
- function Z(e) {
204
+ const Ce = (e, r) => {
205
+ for (const t of Object.keys(r))
206
+ r[t] instanceof Object && Object.assign(r[t], Ce(e[t], r[t]));
207
+ return Object.assign(e || {}, r), e;
208
+ }, Jt = "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", Qt = /* @__PURE__ */ Yt(Jt);
209
+ function ce(e) {
85
210
  return e && e.nodeType === 1;
86
211
  }
87
- function j(e) {
88
- return e.replace(/-([a-z])/g, (n, t) => t.toUpperCase());
212
+ function N(e) {
213
+ return e.replace(/-([a-z])/g, (r, t) => t.toUpperCase());
89
214
  }
90
- function at(e, n) {
91
- const t = /* @__PURE__ */ Object.create(null), r = e.split(",");
92
- for (let a = 0; a < r.length; a++)
93
- t[r[a]] = !0;
94
- return n ? (a) => !!t[a.toLowerCase()] : (a) => !!t[a];
215
+ function Yt(e, r) {
216
+ const t = /* @__PURE__ */ Object.create(null), o = e.split(",");
217
+ for (let s = 0; s < o.length; s++)
218
+ t[o[s]] = !0;
219
+ return r ? (s) => !!t[s.toLowerCase()] : (s) => !!t[s];
95
220
  }
96
- const nt = (e, n) => {
97
- const t = /* @__PURE__ */ new Set(), r = [];
98
- for (const a of e) {
99
- const o = n(a);
100
- t.has(o) || (t.add(o), r.push(a));
221
+ const qt = (e, r) => {
222
+ const t = /* @__PURE__ */ new Set(), o = [];
223
+ for (const s of e) {
224
+ const i = r(s);
225
+ t.has(i) || (t.add(i), o.push(s));
101
226
  }
102
- return r;
103
- }, ee = (e, n) => {
104
- if (!n)
227
+ return o;
228
+ }, de = (e, r) => {
229
+ if (!r)
105
230
  return;
106
- const t = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
107
- return t == null ? void 0 : t.reduce((r, a) => r && r[a], e);
108
- }, ot = (e, n, t) => {
109
- const r = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
110
- r && r.reduce((a, o, u) => (a[o] === void 0 && (a[o] = {}), u === r.length - 1 && (a[o] = t), a[o]), e);
231
+ const t = Array.isArray(r) ? r : r.match(/([^[.\]])+/g);
232
+ return t == null ? void 0 : t.reduce((o, s) => o && o[s], e);
233
+ }, Kt = (e, r, t) => {
234
+ const o = Array.isArray(r) ? r : r.match(/([^[.\]])+/g);
235
+ o && o.reduce((s, i, n) => (s[i] === void 0 && (s[i] = {}), n === o.length - 1 && (s[i] = t), s[i]), e);
111
236
  };
112
- function ue(e, n) {
113
- if (Z(e) && Z(n)) {
114
- const a = e.attributes, o = n.attributes;
115
- return a.length !== o.length ? !1 : Array.from(a).every(({ name: u, value: l }) => n.getAttribute(u) === l);
237
+ function Me(e, r) {
238
+ if (ce(e) && ce(r)) {
239
+ const s = e.attributes, i = r.attributes;
240
+ return s.length !== i.length ? !1 : Array.from(s).every(({ name: n, value: a }) => r.getAttribute(n) === a);
116
241
  }
117
- if (e === n)
242
+ if (e === r)
118
243
  return !0;
119
- if (e === null || typeof e != "object" || n === null || typeof n != "object")
244
+ if (e === null || typeof e != "object" || r === null || typeof r != "object")
120
245
  return !1;
121
- const t = Object.keys(e), r = Object.keys(n);
122
- if (t.length !== r.length)
246
+ const t = Object.keys(e), o = Object.keys(r);
247
+ if (t.length !== o.length)
123
248
  return !1;
124
- for (const a of t)
125
- if (!r.includes(a) || !ue(e[a], n[a]))
249
+ for (const s of t)
250
+ if (!o.includes(s) || !Me(e[s], r[s]))
126
251
  return !1;
127
252
  return !0;
128
253
  }
129
- function st(e, n) {
130
- if (!Array.isArray(e) || !Array.isArray(n) || e.length !== n.length)
254
+ function Xt(e, r) {
255
+ if (!Array.isArray(e) || !Array.isArray(r) || e.length !== r.length)
131
256
  return !1;
132
257
  for (let t = 0; t < e.length; t++)
133
- if (!ue(e[t], n[t]))
258
+ if (!Me(e[t], r[t]))
134
259
  return !1;
135
260
  return !0;
136
261
  }
137
- const it = Array.isArray;
138
- function ce(e) {
139
- var n, t;
140
- e.children && e.children.forEach((r) => ce(r));
141
- for (const r in e)
142
- (t = (n = e[r]) == null ? void 0 : n.dispose) == null || t.call(n), delete e[r];
143
- e.dispose && e.type !== "Scene" && e.dispose();
262
+ const Zt = Array.isArray;
263
+ function er(e, r, t, o) {
264
+ const s = (l) => {
265
+ if (l.uuid === r)
266
+ return l;
267
+ for (const c of l.children) {
268
+ const m = s(c);
269
+ if (m)
270
+ return m;
271
+ }
272
+ }, i = s(e);
273
+ if (!i) {
274
+ console.warn("Object with UUID not found in the scene.");
275
+ return;
276
+ }
277
+ let n = i;
278
+ for (let l = 0; l < t.length - 1; l++)
279
+ if (n[t[l]] !== void 0)
280
+ n = n[t[l]];
281
+ else {
282
+ console.warn(`Property path is not valid: ${t.join(".")}`);
283
+ return;
284
+ }
285
+ const a = t[t.length - 1];
286
+ n[a] !== void 0 ? n[a] = o : console.warn(`Property path is not valid: ${t.join(".")}`);
287
+ }
288
+ function tr(e) {
289
+ const r = new we({
290
+ color: 11003607,
291
+ // Highlight color, e.g., yellow
292
+ transparent: !0,
293
+ opacity: 0.2,
294
+ depthTest: !1,
295
+ // So the highlight is always visible
296
+ side: Qe
297
+ // To e
298
+ });
299
+ return new Gt(e.geometry.clone(), r);
300
+ }
301
+ function xe(e) {
302
+ var t;
303
+ let r = e.value;
304
+ return e.value && ((t = e.value) != null && t.isMesh) && (r = e.value.position), Array.isArray(e.value) && (r = new ye(...r)), r;
144
305
  }
145
- const lt = Number.parseInt(Le.replace("dev", "")), H = {
306
+ const rr = Number.parseInt(Ye.replace("dev", "")), V = {
146
307
  realistic: {
147
308
  shadows: !0,
148
309
  physicallyCorrectLights: !0,
149
- outputColorSpace: Oe,
150
- toneMapping: Be,
310
+ outputColorSpace: qe,
311
+ toneMapping: Ke,
151
312
  toneMappingExposure: 3,
152
313
  shadowMap: {
153
314
  enabled: !0,
154
- type: Re
315
+ type: Xe
155
316
  }
156
317
  }
157
318
  };
158
- function ut({
319
+ function or({
159
320
  scene: e,
160
- canvas: n,
321
+ canvas: r,
161
322
  options: t,
162
- disableRender: r,
163
- contextParts: { sizes: a, camera: o }
323
+ disableRender: o,
324
+ contextParts: { sizes: s, camera: i }
164
325
  }) {
165
- const u = D(() => ({
166
- alpha: C(t.alpha),
167
- depth: C(t.depth),
168
- canvas: Ne(n),
169
- context: C(t.context),
170
- stencil: C(t.stencil),
171
- antialias: C(t.antialias) === void 0 ? !0 : C(t.antialias),
172
- precision: C(t.precision),
173
- powerPreference: C(t.powerPreference),
174
- premultipliedAlpha: C(t.premultipliedAlpha),
175
- preserveDrawingBuffer: C(t.preserveDrawingBuffer),
176
- logarithmicDepthBuffer: C(t.logarithmicDepthBuffer),
177
- failIfMajorPerformanceCaveat: C(t.failIfMajorPerformanceCaveat)
178
- })), l = S(new N(u.value));
179
- ae(u, () => {
180
- l.value.dispose(), l.value = new N(u.value);
181
- }), k(() => {
182
- l.value.setSize(a.width.value, a.height.value);
326
+ const n = T(() => ({
327
+ alpha: _(t.alpha),
328
+ depth: _(t.depth),
329
+ canvas: pt(r),
330
+ context: _(t.context),
331
+ stencil: _(t.stencil),
332
+ antialias: _(t.antialias) === void 0 ? !0 : _(t.antialias),
333
+ precision: _(t.precision),
334
+ powerPreference: _(t.powerPreference),
335
+ premultipliedAlpha: _(t.premultipliedAlpha),
336
+ preserveDrawingBuffer: _(t.preserveDrawingBuffer),
337
+ logarithmicDepthBuffer: _(t.logarithmicDepthBuffer),
338
+ failIfMajorPerformanceCaveat: _(t.failIfMajorPerformanceCaveat)
339
+ })), a = j(new Q(n.value));
340
+ ge(n, () => {
341
+ a.value.dispose(), a.value = new Q(n.value);
342
+ }), D(() => {
343
+ a.value.setSize(s.width.value, s.height.value);
183
344
  });
184
- const { pixelRatio: c } = Ve();
185
- k(() => {
186
- l.value.setPixelRatio(c.value);
345
+ const { pixelRatio: l } = mt();
346
+ D(() => {
347
+ a.value.setPixelRatio(l.value);
187
348
  });
188
- const { logError: m } = B(), i = (() => {
189
- const p = new N(), w = {
349
+ const { logError: c } = A(), d = (() => {
350
+ const p = new Q(), y = {
190
351
  shadowMap: {
191
352
  enabled: p.shadowMap.enabled,
192
353
  type: p.shadowMap.type
@@ -195,247 +356,252 @@ function ut({
195
356
  toneMappingExposure: p.toneMappingExposure,
196
357
  outputColorSpace: p.outputColorSpace
197
358
  };
198
- return p.dispose(), w;
359
+ return p.dispose(), y;
199
360
  })();
200
- k(() => {
201
- const p = C(t.preset);
202
- p && (p in H || m(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), le(l.value, H[p]));
203
- const w = (P, A) => {
204
- const E = C(P), b = () => {
361
+ D(() => {
362
+ const p = _(t.preset);
363
+ p && (p in V || c(`Renderer Preset must be one of these: ${Object.keys(V).join(", ")}`), Ce(a.value, V[p]));
364
+ const y = (C, M) => {
365
+ const w = _(C), S = () => {
205
366
  if (p)
206
- return ee(H[p], A);
367
+ return de(V[p], M);
207
368
  };
208
- if (E !== void 0)
209
- return E;
210
- const g = b();
211
- return g !== void 0 ? g : ee(i, A);
212
- }, v = (P, A) => ot(l.value, A, w(P, A));
213
- v(t.shadows, "shadowMap.enabled"), v(t.toneMapping, "toneMapping"), v(t.shadowMapType, "shadowMap.type"), lt < 150 && v(!t.useLegacyLights, "physicallyCorrectLights"), v(t.outputColorSpace, "outputColorSpace"), v(t.toneMappingExposure, "toneMappingExposure");
214
- const M = w(t.clearColor, "clearColor");
215
- M && l.value.setClearColor(
216
- M ? et(M) : new F(0)
369
+ if (w !== void 0)
370
+ return w;
371
+ const v = S();
372
+ return v !== void 0 ? v : de(d, M);
373
+ }, b = (C, M) => Kt(a.value, M, y(C, M));
374
+ b(t.shadows, "shadowMap.enabled"), b(t.toneMapping, "toneMapping"), b(t.shadowMapType, "shadowMap.type"), rr < 150 && b(!t.useLegacyLights, "physicallyCorrectLights"), b(t.outputColorSpace, "outputColorSpace"), b(t.toneMappingExposure, "toneMappingExposure");
375
+ const x = y(t.clearColor, "clearColor");
376
+ x && a.value.setClearColor(
377
+ x ? Ft(x) : new W(0)
217
378
  // default clear color is not easily/efficiently retrievable from three
218
379
  );
219
380
  });
220
- const { pause: s, resume: f, onLoop: d } = ie();
221
- return d(() => {
222
- o.value && !C(r) && l.value.render(e, o.value);
223
- }), f(), O(() => {
224
- s(), l.value.dispose(), l.value.forceContextLoss();
381
+ const { pause: u, resume: f, onLoop: h } = re();
382
+ return h(() => {
383
+ i.value && !_(o) && a.value.render(e, i.value);
384
+ }), f(), G(() => {
385
+ u(), a.value.dispose(), a.value.forceContextLoss();
225
386
  }), {
226
- renderer: l
387
+ renderer: a
227
388
  };
228
389
  }
229
- const te = (e) => typeof e == "function", ct = (e) => !!e && e.constructor === Array;
230
- function ft(e) {
231
- const n = { nodes: {}, materials: {} };
390
+ const fe = (e) => typeof e == "function", nr = (e) => !!e && e.constructor === Array;
391
+ function sr(e) {
392
+ const r = { nodes: {}, materials: {} };
232
393
  return e && e.traverse((t) => {
233
- t.name && (n.nodes[t.name] = t), t.material && !n.materials[t.material.name] && (n.materials[t.material.name] = t.material);
234
- }), n;
235
- }
236
- async function kt(e, n, t, r, a) {
237
- const { logError: o } = B(), u = new e();
238
- a && a(u), t && t(u);
239
- const c = (Array.isArray(n) ? n : [n]).map(
240
- (m) => new Promise((h, i) => {
241
- u.load(
242
- m,
243
- (s) => {
244
- s.scene && Object.assign(s, ft(s.scene)), h(s);
394
+ t.name && (r.nodes[t.name] = t), t.material && !r.materials[t.material.name] && (r.materials[t.material.name] = t.material);
395
+ }), r;
396
+ }
397
+ async function $r(e, r, t, o, s) {
398
+ const { logError: i } = A(), n = new e();
399
+ s && s(n), t && t(n);
400
+ const l = (Array.isArray(r) ? r : [r]).map(
401
+ (c) => new Promise((m, d) => {
402
+ n.load(
403
+ c,
404
+ (u) => {
405
+ u.scene && Object.assign(u, sr(u.scene)), m(u);
245
406
  },
246
- r,
247
- (s) => i(o("[useLoader] - Failed to load resource", s))
407
+ o,
408
+ (u) => d(i("[useLoader] - Failed to load resource", u))
248
409
  );
249
410
  })
250
411
  );
251
- return ct(n) ? await Promise.all(c) : await c[0];
412
+ return nr(r) ? await Promise.all(l) : await l[0];
252
413
  }
253
- async function Tt(e) {
254
- const n = new je(), t = new He(n), r = (a) => new Promise((o, u) => {
414
+ async function Nr(e, r) {
415
+ const t = new Ze(r), o = (s) => new Promise((i, n) => {
255
416
  t.load(
256
- a,
257
- (l) => o(l),
417
+ s,
418
+ (a) => i(a),
258
419
  () => null,
259
420
  () => {
260
- u(new Error("[useTextures] - Failed to load texture"));
421
+ n(new Error("[useTextures] - Failed to load texture"));
261
422
  }
262
423
  );
263
424
  });
264
- if (it(e)) {
265
- const a = await Promise.all(e.map((o) => r(o)));
266
- return e.length > 1 ? a : a[0];
425
+ if (Zt(e)) {
426
+ const s = await Promise.all(e.map((i) => o(i)));
427
+ return e.length > 1 ? s : s[0];
267
428
  } else {
268
429
  const {
269
- map: a,
270
- displacementMap: o,
271
- normalMap: u,
272
- roughnessMap: l,
273
- metalnessMap: c,
274
- aoMap: m,
275
- alphaMap: h,
276
- matcap: i
430
+ map: s,
431
+ displacementMap: i,
432
+ normalMap: n,
433
+ roughnessMap: a,
434
+ metalnessMap: l,
435
+ aoMap: c,
436
+ alphaMap: m,
437
+ matcap: d
277
438
  } = e;
278
439
  return {
279
- map: a ? await r(a) : null,
280
- displacementMap: o ? await r(o) : null,
281
- normalMap: u ? await r(u) : null,
282
- roughnessMap: l ? await r(l) : null,
283
- metalnessMap: c ? await r(c) : null,
284
- aoMap: m ? await r(m) : null,
285
- alphaMap: h ? await r(h) : null,
286
- matcap: i ? await r(i) : null
440
+ map: s ? await o(s) : null,
441
+ displacementMap: i ? await o(i) : null,
442
+ normalMap: n ? await o(n) : null,
443
+ roughnessMap: a ? await o(a) : null,
444
+ metalnessMap: l ? await o(l) : null,
445
+ aoMap: c ? await o(c) : null,
446
+ alphaMap: m ? await o(m) : null,
447
+ matcap: d ? await o(d) : null
287
448
  };
288
449
  }
289
450
  }
290
- const mt = (e, { renderer: n, camera: t, raycaster: r }) => {
291
- const a = D(() => n.value.domElement), { x: o, y: u } = Ge({ target: a }), { width: l, height: c, top: m, left: h } = We(a), i = ({ x: g, y: _ }) => {
292
- if (a.value)
451
+ const ir = (e, { renderer: r, camera: t, raycaster: o }) => {
452
+ const s = T(() => r.value.domElement), { x: i, y: n } = gt({ target: s }), { width: a, height: l, top: c, left: m } = vt(s), d = ({ x: v, y: E }) => {
453
+ if (s.value)
293
454
  return {
294
- x: (g - h.value) / l.value * 2 - 1,
295
- y: -((_ - m.value) / c.value) * 2 + 1
455
+ x: (v - m.value) / a.value * 2 - 1,
456
+ y: -((E - c.value) / l.value) * 2 + 1
296
457
  };
297
- }, s = ({ x: g, y: _ }) => {
458
+ }, u = ({ x: v, y: E }) => {
298
459
  if (t.value)
299
- return r.value.setFromCamera(new Fe(g, _), t.value), r.value.intersectObjects(e.value, !1);
300
- }, f = (g) => {
301
- const _ = i({
302
- x: (g == null ? void 0 : g.clientX) ?? o.value,
303
- y: (g == null ? void 0 : g.clientY) ?? u.value
460
+ return o.value.setFromCamera(new et(v, E), t.value), o.value.intersectObjects(e.value, !1);
461
+ }, f = (v) => {
462
+ const E = d({
463
+ x: (v == null ? void 0 : v.clientX) ?? i.value,
464
+ y: (v == null ? void 0 : v.clientY) ?? n.value
304
465
  });
305
- return _ ? s(_) || [] : [];
306
- }, d = D(() => f()), p = x(), w = x(), v = (g, _) => {
307
- g.trigger({ event: _, intersects: f(_) });
308
- }, M = (g) => {
309
- v(w, g);
466
+ return E ? u(E) || [] : [];
467
+ }, h = T(() => f()), p = H(), y = H(), b = (v, E) => {
468
+ v.trigger({ event: E, intersects: f(E) });
469
+ }, x = (v) => {
470
+ b(y, v);
310
471
  };
311
- let P;
312
- const A = (g) => {
313
- var _;
314
- P = (_ = f(g)[0]) == null ? void 0 : _.object;
315
- }, E = (g) => {
316
- var _;
317
- g instanceof PointerEvent && P === ((_ = f(g)[0]) == null ? void 0 : _.object) && v(p, g);
318
- }, b = (g) => w.trigger({ event: g, intersects: [] });
319
- return a.value.addEventListener("pointerup", E), a.value.addEventListener("pointerdown", A), a.value.addEventListener("pointermove", M), a.value.addEventListener("pointerleave", b), O(() => {
320
- a != null && a.value && (a.value.removeEventListener("pointerup", E), a.value.removeEventListener("pointerdown", A), a.value.removeEventListener("pointermove", M), a.value.removeEventListener("pointerleave", b));
472
+ let C;
473
+ const M = (v) => {
474
+ var E;
475
+ C = (E = f(v)[0]) == null ? void 0 : E.object;
476
+ }, w = (v) => {
477
+ var E;
478
+ v instanceof PointerEvent && C === ((E = f(v)[0]) == null ? void 0 : E.object) && b(p, v);
479
+ }, S = (v) => y.trigger({ event: v, intersects: [] });
480
+ return s.value.addEventListener("pointerup", w), s.value.addEventListener("pointerdown", M), s.value.addEventListener("pointermove", x), s.value.addEventListener("pointerleave", S), G(() => {
481
+ s != null && s.value && (s.value.removeEventListener("pointerup", w), s.value.removeEventListener("pointerdown", M), s.value.removeEventListener("pointermove", x), s.value.removeEventListener("pointerleave", S));
321
482
  }), {
322
- intersects: d,
323
- onClick: (g) => p.on(g).off,
324
- onPointerMove: (g) => w.on(g).off
483
+ intersects: h,
484
+ onClick: (v) => p.on(v).off,
485
+ onPointerMove: (v) => y.on(v).off
325
486
  };
326
487
  };
327
- function St() {
328
- const { logWarning: e } = B();
329
- function n(o, u, l) {
330
- let c = null;
331
- return o.traverse((m) => {
332
- m[u] === l && (c = m);
333
- }), c || e(`Child with ${u} '${l}' not found.`), c;
488
+ function Vr() {
489
+ const { logWarning: e } = A();
490
+ function r(i, n, a) {
491
+ let l = null;
492
+ return i.traverse((c) => {
493
+ c[n] === a && (l = c);
494
+ }), l || e(`Child with ${n} '${a}' not found.`), l;
334
495
  }
335
- function t(o, u, l) {
336
- const c = [];
337
- return o.traverse((m) => {
338
- m[u].includes(l) && c.push(m);
339
- }), c.length || e(`Children with ${u} '${l}' not found.`), c;
496
+ function t(i, n, a) {
497
+ const l = [];
498
+ return i.traverse((c) => {
499
+ c[n].includes(a) && l.push(c);
500
+ }), l.length || e(`Children with ${n} '${a}' not found.`), l;
340
501
  }
341
- function r(o, u) {
342
- return n(o, "name", u);
502
+ function o(i, n) {
503
+ return r(i, "name", n);
343
504
  }
344
- function a(o, u) {
345
- return t(o, "name", u);
505
+ function s(i, n) {
506
+ return t(i, "name", n);
346
507
  }
347
508
  return {
348
- seek: n,
349
- seekByName: r,
509
+ seek: r,
510
+ seekByName: o,
350
511
  seekAll: t,
351
- seekAllByName: a
512
+ seekAllByName: s
352
513
  };
353
514
  }
354
- const pt = ({ scene: e, contextParts: n }) => {
355
- const t = ge({
515
+ const ar = ({ scene: e, contextParts: r }) => {
516
+ const t = ve({
356
517
  click: /* @__PURE__ */ new Map(),
357
518
  pointerMove: /* @__PURE__ */ new Map(),
358
519
  pointerEnter: /* @__PURE__ */ new Map(),
359
520
  pointerLeave: /* @__PURE__ */ new Map()
360
- }), r = L(/* @__PURE__ */ new Set()), a = (s) => {
361
- r.value.add(s);
362
- }, o = (s) => {
363
- r.value.delete(s);
364
- }, u = (s) => {
365
- Object.values(t).forEach((f) => f.delete(s)), o(s);
366
- }, l = (s) => {
367
- const { onClick: f, onPointerMove: d, onPointerEnter: p, onPointerLeave: w } = s;
368
- f && t.click.set(s, f), d && t.pointerMove.set(s, d), p && t.pointerEnter.set(s, p), w && t.pointerLeave.set(s, w);
521
+ }), o = R(/* @__PURE__ */ new Set()), s = (u) => {
522
+ o.value.add(u);
523
+ }, i = (u) => {
524
+ o.value.delete(u);
525
+ }, n = (u) => {
526
+ Object.values(t).forEach((f) => f.delete(u)), i(u);
527
+ }, a = (u) => {
528
+ const { onClick: f, onPointerMove: h, onPointerEnter: p, onPointerLeave: y } = u;
529
+ f && t.click.set(u, f), h && t.pointerMove.set(u, h), p && t.pointerEnter.set(u, p), y && t.pointerLeave.set(u, y);
369
530
  };
370
- e.userData.tres__registerAtPointerEventHandler = l, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = a, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
371
- const c = D(
372
- () => nt(
531
+ e.userData.tres__registerAtPointerEventHandler = a, e.userData.tres__deregisterAtPointerEventHandler = n, e.userData.tres__registerBlockingObjectAtPointerEventHandler = s, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = i;
532
+ const l = T(
533
+ () => qt(
373
534
  [
374
- ...Array.from(r.value),
375
- ...Object.values(t).map((s) => Array.from(s.keys())).flat()
535
+ ...Array.from(o.value),
536
+ ...Object.values(t).map((u) => Array.from(u.keys())).flat()
376
537
  ],
377
- ({ uuid: s }) => s
538
+ ({ uuid: u }) => u
378
539
  )
379
- ), { onClick: m, onPointerMove: h } = mt(c, n);
380
- m(({ intersects: s, event: f }) => {
381
- var d;
382
- s.length && ((d = t.click.get(s[0].object)) == null || d(s[0], f));
540
+ ), { onClick: c, onPointerMove: m } = ir(l, r);
541
+ c(({ intersects: u, event: f }) => {
542
+ var h;
543
+ u.length && ((h = t.click.get(u[0].object)) == null || h(u[0], f));
383
544
  });
384
- let i;
385
- return h(({ intersects: s, event: f }) => {
386
- var M, P, A, E;
387
- const d = (M = s == null ? void 0 : s[0]) == null ? void 0 : M.object, { pointerLeave: p, pointerEnter: w, pointerMove: v } = t;
388
- i && i !== d && ((P = p.get(i)) == null || P(i, f)), d && (i !== d && ((A = w.get(d)) == null || A(s[0], f)), (E = v.get(d)) == null || E(s[0], f)), i = d || null;
545
+ let d;
546
+ return m(({ intersects: u, event: f }) => {
547
+ var x, C, M, w;
548
+ const h = (x = u == null ? void 0 : u[0]) == null ? void 0 : x.object, { pointerLeave: p, pointerEnter: y, pointerMove: b } = t;
549
+ d && d !== h && ((C = p.get(d)) == null || C(d, f)), h && (d !== h && ((M = y.get(h)) == null || M(u[0], f)), (w = b.get(h)) == null || w(u[0], f)), d = h || null;
389
550
  }), {
390
- registerObject: l,
391
- deregisterObject: u
551
+ registerObject: a,
552
+ deregisterObject: n
392
553
  };
393
554
  };
394
- function dt(e) {
395
- let n = 0;
555
+ function Se(e) {
556
+ let r = 0;
396
557
  return e.traverse((t) => {
397
558
  if (t.isMesh && t.geometry) {
398
- const r = t.geometry, a = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, u = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, l = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = a + o + u + l;
399
- n += c;
559
+ const o = t.geometry, s = o.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, i = o.index ? o.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, n = o.attributes.normal ? o.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = o.attributes.uv ? o.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = s + i + n + a;
560
+ r += l;
400
561
  }
401
- }), n;
562
+ }), r;
563
+ }
564
+ function lr(e) {
565
+ return (e / 1024).toFixed(2);
566
+ }
567
+ const Z = R({}), oe = (e) => Object.assign(Z.value, e);
568
+ function ur(e, r, t = 10) {
569
+ const o = _(e) ? ht() : yt(T(() => _(r).parentElement)), s = q(ue(o.width, t)), i = q(ue(o.height, t)), n = T(() => s.value / i.value);
570
+ return {
571
+ height: i,
572
+ width: s,
573
+ aspectRatio: n
574
+ };
402
575
  }
403
- const q = L({}), Y = (e) => Object.assign(q.value, e);
404
- function vt({
576
+ function cr({
405
577
  scene: e,
406
- canvas: n,
578
+ canvas: r,
407
579
  windowSize: t,
408
- disableRender: r,
409
- rendererOptions: a
580
+ disableRender: o,
581
+ rendererOptions: s
410
582
  }) {
411
- const o = D(
412
- () => C(t) ? qe() : Ue(C(n).parentElement)
413
- ), u = D(() => o.value.width.value), l = D(() => o.value.height.value), c = D(() => u.value / l.value), m = {
414
- height: l,
415
- width: u,
416
- aspectRatio: c
417
- }, h = S(e), {
418
- camera: i,
419
- cameras: s,
420
- registerCamera: f,
421
- deregisterCamera: d,
422
- setCameraActive: p
423
- } = Ke({ sizes: m, scene: e }), { renderer: w } = ut(
583
+ const i = ur(t, r), n = j(e), {
584
+ camera: a,
585
+ cameras: l,
586
+ registerCamera: c,
587
+ deregisterCamera: m,
588
+ setCameraActive: d
589
+ } = Vt({ sizes: i, scene: e }), { renderer: u } = or(
424
590
  {
425
591
  scene: e,
426
- canvas: n,
427
- options: a,
428
- contextParts: { sizes: m, camera: i },
429
- disableRender: r
592
+ canvas: r,
593
+ options: s,
594
+ contextParts: { sizes: i, camera: a },
595
+ disableRender: o
430
596
  }
431
- ), v = {
432
- sizes: m,
433
- scene: h,
434
- camera: i,
435
- cameras: ye(s),
436
- renderer: w,
437
- raycaster: S(new ze()),
438
- controls: L(null),
597
+ ), f = {
598
+ sizes: i,
599
+ scene: n,
600
+ camera: a,
601
+ cameras: q(l),
602
+ renderer: u,
603
+ raycaster: j(new tt()),
604
+ controls: R(null),
439
605
  perf: {
440
606
  maxFrames: 160,
441
607
  fps: {
@@ -448,136 +614,136 @@ function vt({
448
614
  accumulator: []
449
615
  }
450
616
  },
451
- extend: Y,
452
- registerCamera: f,
453
- setCameraActive: p,
454
- deregisterCamera: d
617
+ extend: oe,
618
+ registerCamera: c,
619
+ setCameraActive: d,
620
+ deregisterCamera: m
455
621
  };
456
- G("useTres", v);
457
- const M = 100, P = Ye({ every: M }), { isSupported: A, memory: E } = Je({ interval: M }), b = 160;
458
- let g = performance.now();
459
- const _ = ({ timestamp: R }) => {
460
- v.scene.value && (v.perf.memory.allocatedMem = dt(v.scene.value)), R - g >= M && (g = R, v.perf.fps.accumulator.push(P.value), v.perf.fps.accumulator.length > b && v.perf.fps.accumulator.shift(), v.perf.fps.value = P.value, A.value && E.value && (v.perf.memory.accumulator.push(E.value.usedJSHeapSize / 1024 / 1024), v.perf.memory.accumulator.length > b && v.perf.memory.accumulator.shift(), v.perf.memory.currentMem = v.perf.memory.accumulator.reduce((de, ve) => de + ve, 0) / v.perf.memory.accumulator.length));
622
+ K("useTres", f);
623
+ const h = 100, p = wt({ every: h }), { isSupported: y, memory: b } = bt({ interval: h }), x = 160;
624
+ let C = performance.now();
625
+ const M = ({ timestamp: I }) => {
626
+ f.scene.value && (f.perf.memory.allocatedMem = Se(f.scene.value)), I - C >= h && (C = I, f.perf.fps.accumulator.push(p.value), f.perf.fps.accumulator.length > x && f.perf.fps.accumulator.shift(), f.perf.fps.value = p.value, y.value && b.value && (f.perf.memory.accumulator.push(b.value.usedJSHeapSize / 1024 / 1024), f.perf.memory.accumulator.length > x && f.perf.memory.accumulator.shift(), f.perf.memory.currentMem = f.perf.memory.accumulator.reduce((Le, Oe) => Le + Oe, 0) / f.perf.memory.accumulator.length));
461
627
  };
462
- let I = 0;
463
- const me = 1, { pause: pe, resume: Ct } = ne(({ delta: R }) => {
464
- window.__TRES__DEVTOOLS__ && (_({ timestamp: performance.now() }), I += R, I >= me && (window.__TRES__DEVTOOLS__.cb(v), I = 0));
628
+ let w = 0;
629
+ const S = 1, { pause: v, resume: E } = be(({ delta: I }) => {
630
+ window.__TRES__DEVTOOLS__ && (M({ timestamp: performance.now() }), w += I, w >= S && (window.__TRES__DEVTOOLS__.cb(f), w = 0));
465
631
  }, { immediate: !0 });
466
- return O(() => {
467
- pe();
468
- }), v;
632
+ return G(() => {
633
+ v();
634
+ }), f;
469
635
  }
470
- function gt() {
471
- const e = he("useTres");
636
+ function dr() {
637
+ const e = je("useTres");
472
638
  if (!e)
473
639
  throw new Error("useTresContext must be used together with useTresContextProvider");
474
640
  return e;
475
641
  }
476
- const xt = gt;
477
- let y = null;
478
- const { logError: re } = B(), V = [
642
+ const zr = dr;
643
+ let g = null;
644
+ const { logError: pe } = A(), Y = [
479
645
  "onClick",
480
646
  "onPointerMove",
481
647
  "onPointerEnter",
482
648
  "onPointerLeave"
483
- ], fe = {
484
- createElement(e, n, t, r) {
485
- var u, l;
486
- if (r || (r = {}), r.args || (r.args = []), e === "template" || rt(e))
649
+ ], fr = {
650
+ createElement(e, r, t, o) {
651
+ var n, a;
652
+ if (o || (o = {}), o.args || (o.args = []), e === "template" || Qt(e))
487
653
  return null;
488
- let a = e.replace("Tres", ""), o;
654
+ let s = e.replace("Tres", ""), i;
489
655
  if (e === "primitive") {
490
- (r == null ? void 0 : r.object) === void 0 && re("Tres primitives need a prop 'object'");
491
- const c = r.object;
492
- a = c.type, o = Object.assign(c, { type: a, attach: r.attach, primitive: !0 });
656
+ (o == null ? void 0 : o.object) === void 0 && pe("Tres primitives need a prop 'object'");
657
+ const l = o.object;
658
+ s = l.type, i = Object.assign(l, { type: s, attach: o.attach, primitive: !0 });
493
659
  } else {
494
- const c = q.value[a];
495
- c || re(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new c(...r.args);
660
+ const l = Z.value[s];
661
+ l || pe(`${s} is not defined on the THREE namespace. Use extend to add it to the catalog.`), i = new l(...o.args);
496
662
  }
497
- return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((u = r == null ? void 0 : r.material) != null && u.isMaterial && (o.userData.tres__materialViaProp = !0), (l = r == null ? void 0 : r.geometry) != null && l.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
498
- ...o.userData,
499
- tres__name: a
500
- }, o;
663
+ return i.isCamera && (o != null && o.position || i.position.set(3, 3, 3), o != null && o.lookAt || i.lookAt(0, 0, 0)), (o == null ? void 0 : o.attach) === void 0 && (i.isMaterial ? i.attach = "material" : i.isBufferGeometry && (i.attach = "geometry")), i.isObject3D && ((n = o == null ? void 0 : o.material) != null && n.isMaterial && (i.userData.tres__materialViaProp = !0), (a = o == null ? void 0 : o.geometry) != null && a.isBufferGeometry && (i.userData.tres__geometryViaProp = !0)), i.userData = {
664
+ ...i.userData,
665
+ tres__name: s
666
+ }, i;
501
667
  },
502
- insert(e, n) {
503
- var r, a, o, u;
504
- n && n.isScene && (y = n);
505
- const t = n || y;
668
+ insert(e, r) {
669
+ var o, s, i, n;
670
+ r && r.isScene && (g = r);
671
+ const t = r || g;
506
672
  if (e != null && e.isObject3D) {
507
673
  if (e != null && e.isCamera) {
508
- if (!(y != null && y.userData.tres__registerCamera))
674
+ if (!(g != null && g.userData.tres__registerCamera))
509
675
  throw "could not find tres__registerCamera on scene's userData";
510
- (a = y == null ? void 0 : (r = y.userData).tres__registerCamera) == null || a.call(r, e);
676
+ (s = g == null ? void 0 : (o = g.userData).tres__registerCamera) == null || s.call(o, e);
511
677
  }
512
- if (e && V.some((l) => e[l])) {
513
- if (!(y != null && y.userData.tres__registerAtPointerEventHandler))
678
+ if (e && Y.some((a) => e[a])) {
679
+ if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
514
680
  throw "could not find tres__registerAtPointerEventHandler on scene's userData";
515
- (u = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
681
+ (n = g == null ? void 0 : (i = g.userData).tres__registerAtPointerEventHandler) == null || n.call(i, e);
516
682
  }
517
683
  }
518
684
  e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : 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));
519
685
  },
520
686
  remove(e) {
521
- var c, m, h;
522
- if (!e)
523
- return;
524
- const n = (i) => {
525
- var f, d;
526
- const s = i;
527
- i.userData.tres__materialViaProp || ((f = s.material) == null || f.dispose(), delete s.material), i.userData.tres__geometryViaProp || ((d = s.geometry) == null || d.dispose(), delete s.geometry);
528
- }, t = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, r = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, a = (i) => {
529
- var s, f;
530
- if (!r)
531
- throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
532
- if ((f = y == null ? void 0 : (s = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(s, i), !t)
533
- throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
534
- i && V.some((d) => i[d]) && (t == null || t(i));
535
- }, o = (i) => {
536
- const s = y == null ? void 0 : y.userData.tres__deregisterCamera;
537
- if (!s)
538
- throw "could not find tres__deregisterCamera on scene's userData";
539
- i.isCamera && (s == null || s(i));
540
- }, u = e == null ? void 0 : e.primitive, l = !u && (e.dispose === void 0 ? e.dispose !== null : !1);
541
- if (e != null && e.isObject3D && ((c = e.parent) != null && c.isObject3D) && (e.parent.remove(e), (m = e.removeFromParent) == null || m.call(e)), !u && (e != null && e.isObject3D)) {
542
- e.children.forEach((i) => fe.remove(i)), n(e), o(e), a == null || a(e);
543
- for (const i in e)
544
- i !== "geometry" && i !== "material" && ((h = i.dispose) == null || h.call(i), delete e[i]);
687
+ var r, t;
688
+ if (e) {
689
+ if (e.isObject3D) {
690
+ const o = e, s = (c) => {
691
+ var d, u;
692
+ const m = c;
693
+ c.userData.tres__materialViaProp || ((d = m.material) == null || d.dispose(), m.material = void 0), c.userData.tres__geometryViaProp || ((u = m.geometry) == null || u.dispose(), m.geometry = void 0);
694
+ }, i = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, n = g == null ? void 0 : g.userData.tres__deregisterBlockingObjectAtPointerEventHandler, a = (c) => {
695
+ var m, d;
696
+ if (!n)
697
+ throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
698
+ if ((d = g == null ? void 0 : (m = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || d.call(m, c), !i)
699
+ throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
700
+ c && Y.some((u) => c[u]) && (i == null || i(c));
701
+ }, l = (c) => {
702
+ const m = g == null ? void 0 : g.userData.tres__deregisterCamera;
703
+ if (!m)
704
+ throw "could not find tres__deregisterCamera on scene's userData";
705
+ c.isCamera && (m == null || m(c));
706
+ };
707
+ (r = e.removeFromParent) == null || r.call(e), o.traverse((c) => {
708
+ s(c), l(c), a == null || a(c);
709
+ }), s(o), l(o), a == null || a(o);
710
+ }
711
+ (t = e.dispose) == null || t.call(e);
545
712
  }
546
- l && e.dispose && e.type !== "Scene" && e.dispose();
547
713
  },
548
- patchProp(e, n, t, r) {
549
- var a, o, u, l;
714
+ patchProp(e, r, t, o) {
715
+ var s, i, n, a;
550
716
  if (e) {
551
- let c = e, m = n;
552
- if (e.isObject3D && m === "blocks-pointer-events") {
553
- r || r === "" ? (o = y == null ? void 0 : (a = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(a, e) : (l = y == null ? void 0 : (u = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || l.call(u, e);
717
+ let l = e, c = r;
718
+ if (e.isObject3D && c === "blocks-pointer-events") {
719
+ o || o === "" ? (i = g == null ? void 0 : (s = g.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || i.call(s, e) : (a = g == null ? void 0 : (n = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || a.call(n, e);
554
720
  return;
555
721
  }
556
- let h = j(m), i = c == null ? void 0 : c[h];
557
- if (m === "args") {
558
- const f = e, d = t ?? [], p = r ?? [], w = e.userData.tres__name || e.type;
559
- w && d.length && !st(d, p) && (c = Object.assign(f, new q.value[w](...r)));
722
+ let m = N(c), d = l == null ? void 0 : l[m];
723
+ if (c === "args") {
724
+ const f = e, h = t ?? [], p = o ?? [], y = e.userData.tres__name || e.type;
725
+ y && h.length && !Xt(h, p) && (l = Object.assign(f, new Z.value[y](...o)));
560
726
  return;
561
727
  }
562
- if (c.type === "BufferGeometry") {
563
- if (m === "args")
728
+ if (l.type === "BufferGeometry") {
729
+ if (c === "args")
564
730
  return;
565
- c.setAttribute(
566
- j(m),
567
- new $e(...r)
731
+ l.setAttribute(
732
+ N(c),
733
+ new rt(...o)
568
734
  );
569
735
  return;
570
736
  }
571
- if (m.includes("-") && i === void 0) {
572
- const f = m.split("-");
573
- i = f.reduce((d, p) => d[j(p)], c), m = f.pop(), h = m.toLowerCase(), i != null && i.set || (c = f.reduce((d, p) => d[j(p)], c));
737
+ if (c.includes("-") && d === void 0) {
738
+ const f = c.split("-");
739
+ d = f.reduce((h, p) => h[N(p)], l), c = f.pop(), m = c.toLowerCase(), d != null && d.set || (l = f.reduce((h, p) => h[N(p)], l));
574
740
  }
575
- let s = r;
576
- if (s === "" && (s = !0), te(i)) {
577
- V.includes(n) || (Array.isArray(s) ? e[h](...s) : e[h](s));
741
+ let u = o;
742
+ if (u === "" && (u = !0), fe(d)) {
743
+ Y.includes(r) || (Array.isArray(u) ? e[m](...u) : e[m](u));
578
744
  return;
579
745
  }
580
- !(i != null && i.set) && !te(i) ? c[h] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
746
+ !(d != null && d.set) && !fe(d) ? l[m] = u : d.constructor === u.constructor && (d != null && d.copy) ? d == null || d.copy(u) : Array.isArray(u) ? d.set(...u) : !d.isColor && d.setScalar ? d.setScalar(u) : d.set(u);
581
747
  }
582
748
  },
583
749
  parentNode(e) {
@@ -592,9 +758,288 @@ const { logError: re } = B(), V = [
592
758
  setScopeId: () => void 0,
593
759
  cloneNode: () => void 0,
594
760
  insertStaticContent: () => void 0
595
- }, { render: yt } = we(fe);
596
- Y(De);
597
- const ht = ["data-scene"], wt = /* @__PURE__ */ J({
761
+ }, { render: pr } = He(fr);
762
+ oe(he);
763
+ function mr() {
764
+ return Pe().__VUE_DEVTOOLS_GLOBAL_HOOK__;
765
+ }
766
+ function Pe() {
767
+ return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
768
+ }
769
+ const gr = typeof Proxy == "function", vr = "devtools-plugin:setup", hr = "plugin:settings:set";
770
+ let L, ee;
771
+ function yr() {
772
+ var e;
773
+ return L !== void 0 || (typeof window < "u" && window.performance ? (L = !0, ee = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (L = !0, ee = globalThis.perf_hooks.performance) : L = !1), L;
774
+ }
775
+ function wr() {
776
+ return yr() ? ee.now() : Date.now();
777
+ }
778
+ class br {
779
+ constructor(r, t) {
780
+ this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = r, this.hook = t;
781
+ const o = {};
782
+ if (r.settings)
783
+ for (const n in r.settings) {
784
+ const a = r.settings[n];
785
+ o[n] = a.defaultValue;
786
+ }
787
+ const s = `__vue-devtools-plugin-settings__${r.id}`;
788
+ let i = Object.assign({}, o);
789
+ try {
790
+ const n = localStorage.getItem(s), a = JSON.parse(n);
791
+ Object.assign(i, a);
792
+ } catch {
793
+ }
794
+ this.fallbacks = {
795
+ getSettings() {
796
+ return i;
797
+ },
798
+ setSettings(n) {
799
+ try {
800
+ localStorage.setItem(s, JSON.stringify(n));
801
+ } catch {
802
+ }
803
+ i = n;
804
+ },
805
+ now() {
806
+ return wr();
807
+ }
808
+ }, t && t.on(hr, (n, a) => {
809
+ n === this.plugin.id && this.fallbacks.setSettings(a);
810
+ }), this.proxiedOn = new Proxy({}, {
811
+ get: (n, a) => this.target ? this.target.on[a] : (...l) => {
812
+ this.onQueue.push({
813
+ method: a,
814
+ args: l
815
+ });
816
+ }
817
+ }), this.proxiedTarget = new Proxy({}, {
818
+ get: (n, a) => this.target ? this.target[a] : a === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(a) ? (...l) => (this.targetQueue.push({
819
+ method: a,
820
+ args: l,
821
+ resolve: () => {
822
+ }
823
+ }), this.fallbacks[a](...l)) : (...l) => new Promise((c) => {
824
+ this.targetQueue.push({
825
+ method: a,
826
+ args: l,
827
+ resolve: c
828
+ });
829
+ })
830
+ });
831
+ }
832
+ async setRealTarget(r) {
833
+ this.target = r;
834
+ for (const t of this.onQueue)
835
+ this.target.on[t.method](...t.args);
836
+ for (const t of this.targetQueue)
837
+ t.resolve(await this.target[t.method](...t.args));
838
+ }
839
+ }
840
+ function _r(e, r) {
841
+ const t = e, o = Pe(), s = mr(), i = gr && t.enableEarlyProxy;
842
+ if (s && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !i))
843
+ s.emit(vr, e, r);
844
+ else {
845
+ const n = i ? new br(t, s) : null;
846
+ (o.__VUE_DEVTOOLS_PLUGINS__ = o.__VUE_DEVTOOLS_PLUGINS__ || []).push({
847
+ pluginDescriptor: t,
848
+ setupFn: r,
849
+ proxy: n
850
+ }), n && r(n.proxiedTarget);
851
+ }
852
+ }
853
+ function Er(e, r) {
854
+ const t = `▲ ■ ●${e}`;
855
+ typeof __VUE_DEVTOOLS_TOAST__ == "function" ? __VUE_DEVTOOLS_TOAST__(t, r) : r === "error" ? console.error(t) : r === "warn" ? console.warn(t) : console.log(t);
856
+ }
857
+ const ke = (e) => {
858
+ const r = {
859
+ id: e.uuid,
860
+ label: e.type,
861
+ children: [],
862
+ tags: []
863
+ };
864
+ e.name !== "" && r.tags.push({
865
+ label: e.name,
866
+ textColor: 5750629,
867
+ backgroundColor: 15793395
868
+ });
869
+ const t = Se(e);
870
+ return t > 0 && r.tags.push({
871
+ label: `${lr(t)} KB`,
872
+ textColor: 15707189,
873
+ backgroundColor: 16775644,
874
+ tooltip: "Memory usage"
875
+ }), e.type.includes("Light") && (r.tags.push({
876
+ label: `${e.intensity}`,
877
+ textColor: 9738662,
878
+ backgroundColor: 16316922,
879
+ tooltip: "Intensity"
880
+ }), r.tags.push({
881
+ label: `#${e.color.getHexString()}`,
882
+ textColor: 9738662,
883
+ backgroundColor: 16316922,
884
+ tooltip: "Color"
885
+ })), e.type.includes("Camera") && (r.tags.push({
886
+ label: `${e.fov}°`,
887
+ textColor: 9738662,
888
+ backgroundColor: 16316922,
889
+ tooltip: "Field of view"
890
+ }), r.tags.push({
891
+ // eslint-disable-next-line max-len
892
+ label: `x: ${Math.round(e.position.x)} y: ${Math.round(e.position.y)} z: ${Math.round(e.position.z)}`,
893
+ textColor: 9738662,
894
+ backgroundColor: 16316922,
895
+ tooltip: "Position"
896
+ })), r;
897
+ };
898
+ function Te(e, r) {
899
+ e.children.forEach((t) => {
900
+ if (t.type === "HightlightMesh")
901
+ return;
902
+ const o = ke(t);
903
+ r.children.push(o), Te(t, o);
904
+ });
905
+ }
906
+ const Cr = [], O = "tres:inspector", Mr = ve({
907
+ sceneGraph: null
908
+ });
909
+ function xr(e, r) {
910
+ _r(
911
+ {
912
+ id: "dev.esm.tres",
913
+ label: "TresJS 🪐",
914
+ logo: "https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",
915
+ packageName: "tresjs",
916
+ homepage: "https://tresjs.org",
917
+ componentStateTypes: Cr,
918
+ app: e
919
+ },
920
+ (t) => {
921
+ typeof t.now != "function" && Er(
922
+ // eslint-disable-next-line max-len
923
+ "You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."
924
+ ), t.addInspector({
925
+ id: O,
926
+ label: "TresJS 🪐",
927
+ icon: "account_tree",
928
+ treeFilterPlaceholder: "Search instances"
929
+ }), setInterval(() => {
930
+ t.sendInspectorTree(O);
931
+ }, 1e3), setInterval(() => {
932
+ t.notifyComponentUpdate();
933
+ }, 5e3), t.on.getInspectorTree((i) => {
934
+ if (i.inspectorId === O) {
935
+ const n = ke(r.scene.value);
936
+ Te(r.scene.value, n), Mr.sceneGraph = n, i.rootNodes = [n];
937
+ }
938
+ });
939
+ let o = null, s = null;
940
+ t.on.getInspectorState((i) => {
941
+ if (i.inspectorId === O) {
942
+ const [n] = r.scene.value.getObjectsByProperty("uuid", i.nodeId);
943
+ if (!n)
944
+ return;
945
+ if (s && o && o.parent && s.remove(o), n.isMesh) {
946
+ const a = tr(n);
947
+ n.add(a), o = a, s = n;
948
+ }
949
+ i.state = {
950
+ object: [
951
+ {
952
+ key: "uuid",
953
+ editable: !0,
954
+ value: n.uuid
955
+ },
956
+ {
957
+ key: "name",
958
+ editable: !0,
959
+ value: n.name
960
+ },
961
+ {
962
+ key: "type",
963
+ editable: !0,
964
+ value: n.type
965
+ },
966
+ {
967
+ key: "position",
968
+ editable: !0,
969
+ value: n.position
970
+ },
971
+ {
972
+ key: "rotation",
973
+ editable: !0,
974
+ value: n.rotation
975
+ },
976
+ {
977
+ key: "scale",
978
+ editable: !0,
979
+ value: n.scale
980
+ },
981
+ {
982
+ key: "geometry",
983
+ value: n.geometry
984
+ },
985
+ {
986
+ key: "material",
987
+ value: n.material
988
+ },
989
+ {
990
+ key: "color",
991
+ editable: !0,
992
+ value: n.color
993
+ },
994
+ {
995
+ key: "intensity",
996
+ editable: !0,
997
+ value: n.intensity
998
+ },
999
+ {
1000
+ key: "castShadow",
1001
+ editable: !0,
1002
+ value: n.castShadow
1003
+ },
1004
+ {
1005
+ key: "receiveShadow",
1006
+ editable: !0,
1007
+ value: n.receiveShadow
1008
+ },
1009
+ {
1010
+ key: "frustumCulled",
1011
+ editable: !0,
1012
+ value: n.frustumCulled
1013
+ },
1014
+ {
1015
+ key: "matrixAutoUpdate",
1016
+ editable: !0,
1017
+ value: n.matrixAutoUpdate
1018
+ },
1019
+ {
1020
+ key: "matrixWorldNeedsUpdate",
1021
+ editable: !0,
1022
+ value: n.matrixWorldNeedsUpdate
1023
+ },
1024
+ {
1025
+ key: "matrixWorld",
1026
+ value: n.matrixWorld
1027
+ },
1028
+ {
1029
+ key: "visible",
1030
+ editable: !0,
1031
+ value: n.visible
1032
+ }
1033
+ ]
1034
+ };
1035
+ }
1036
+ }), t.on.editInspectorState((i) => {
1037
+ i.inspectorId === O && er(r.scene.value, i.nodeId, i.path, i.state.value);
1038
+ });
1039
+ }
1040
+ );
1041
+ }
1042
+ const Sr = ["data-scene", "data-tres"], Pr = /* @__PURE__ */ ne({
598
1043
  __name: "TresCanvas",
599
1044
  props: {
600
1045
  shadows: { type: Boolean, default: void 0 },
@@ -620,65 +1065,61 @@ const ht = ["data-scene"], wt = /* @__PURE__ */ J({
620
1065
  logarithmicDepthBuffer: { type: Boolean, default: void 0 },
621
1066
  failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
622
1067
  },
623
- setup(e, { expose: n }) {
624
- var d;
625
- const t = e, { logWarning: r } = B(), a = L(), o = S(new Ie());
626
- ie();
627
- const u = Ee(), l = (d = K()) == null ? void 0 : d.appContext.app;
628
- let c = null;
629
- const m = (p) => J({
1068
+ setup(e, { expose: r }) {
1069
+ var h;
1070
+ const t = e, { logWarning: o } = A(), s = R(), i = j(new ot()), { resume: n } = re(), a = Re(), l = (h = se()) == null ? void 0 : h.appContext.app, c = (p) => ne({
630
1071
  setup() {
631
- var v;
632
- const w = (v = K()) == null ? void 0 : v.appContext;
633
- return w && (w.app = l), G("useTres", p), G("extend", Y), () => X(be, null, u != null && u.default ? u.default() : []);
1072
+ var b;
1073
+ const y = (b = se()) == null ? void 0 : b.appContext;
1074
+ return y && (y.app = l), K("useTres", p), K("extend", oe), typeof window < "u" && xr(y.app, p), () => ie(Ue, null, a != null && a.default ? a.default() : []);
634
1075
  }
635
- }), h = (p) => {
636
- c = m(p), yt(X(c), o.value);
637
- }, i = (p) => {
638
- ce(o.value), o.value = null;
639
- }, s = D(() => t.disableRender), f = S(null);
640
- return n({ context: f, dispose: () => i(f.value) }), _e(() => {
641
- const p = a;
642
- f.value = vt({
643
- scene: o.value,
1076
+ }), m = (p) => {
1077
+ const y = c(p);
1078
+ pr(ie(y), i.value);
1079
+ }, d = (p, y = !1) => {
1080
+ i.value.children = [], y && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), m(p), n();
1081
+ }, u = T(() => t.disableRender), f = j(null);
1082
+ return r({ context: f, dispose: () => d(f.value, !0) }), Ie(() => {
1083
+ const p = s;
1084
+ f.value = cr({
1085
+ scene: i.value,
644
1086
  canvas: p,
645
1087
  windowSize: t.windowSize,
646
- disableRender: s,
1088
+ disableRender: u,
647
1089
  rendererOptions: t
648
- }), pt({ scene: o.value, contextParts: f.value });
649
- const { registerCamera: w, camera: v, cameras: M, deregisterCamera: P } = f.value;
650
- h(f.value);
651
- const A = () => {
652
- const E = new W(
1090
+ }), ar({ scene: i.value, contextParts: f.value });
1091
+ const { registerCamera: y, camera: b, cameras: x, deregisterCamera: C } = f.value;
1092
+ m(f.value);
1093
+ const M = () => {
1094
+ const w = new X(
653
1095
  45,
654
1096
  window.innerWidth / window.innerHeight,
655
1097
  0.1,
656
1098
  1e3
657
1099
  );
658
- E.position.set(3, 3, 3), E.lookAt(0, 0, 0), w(E);
659
- const b = k(() => {
660
- M.value.length >= 2 && (E.removeFromParent(), P(E), b == null || b());
1100
+ w.position.set(3, 3, 3), w.lookAt(0, 0, 0), y(w);
1101
+ const S = D(() => {
1102
+ x.value.length >= 2 && (w.removeFromParent(), C(w), S == null || S());
661
1103
  });
662
1104
  };
663
- ae(
1105
+ ge(
664
1106
  () => t.camera,
665
- (E, b) => {
666
- E && w(E), b && (b.removeFromParent(), P(b));
1107
+ (w, S) => {
1108
+ w && y(w), S && (S.removeFromParent(), C(S));
667
1109
  },
668
1110
  {
669
1111
  immediate: !0
670
1112
  }
671
- ), v.value || (r(
1113
+ ), b.value || (o(
672
1114
  "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
673
- ), A());
674
- }), O(() => {
675
- f.value && i(f.value);
676
- }), (p, w) => (Ce(), Me("canvas", {
1115
+ ), M());
1116
+ }), (p, y) => ($e(), Ne("canvas", {
677
1117
  ref_key: "canvas",
678
- ref: a,
679
- "data-scene": o.value.uuid,
680
- class: Pe(p.$attrs.class),
681
- style: Ae({
1118
+ ref: s,
1119
+ "data-scene": i.value.uuid,
1120
+ class: Ve(p.$attrs.class),
1121
+ "data-tres": `tresjs ${ze(Nt).version}`,
1122
+ style: We({
682
1123
  display: "block",
683
1124
  width: "100%",
684
1125
  height: "100%",
@@ -689,44 +1130,140 @@ const ht = ["data-scene"], wt = /* @__PURE__ */ J({
689
1130
  touchAction: "none",
690
1131
  ...p.$attrs.style
691
1132
  })
692
- }, null, 14, ht));
1133
+ }, null, 14, Sr));
693
1134
  }
694
- }), Et = [
1135
+ }), kr = [
695
1136
  "TresCanvas",
696
1137
  "TresLeches",
697
1138
  "TresScene"
698
- ], _t = {
1139
+ ], Tr = {
699
1140
  template: {
700
1141
  compilerOptions: {
701
- isCustomElement: (e) => e.startsWith("Tres") && !Et.includes(e) || e === "primitive"
1142
+ isCustomElement: (e) => e.startsWith("Tres") && !kr.includes(e) || e === "primitive"
1143
+ }
1144
+ }
1145
+ }, Wr = Tr, Ur = {
1146
+ mounted: (e, r) => {
1147
+ if (r.arg) {
1148
+ console.log(`v-log:${r.arg}`, e[r.arg]);
1149
+ return;
1150
+ }
1151
+ console.log("v-log", e);
1152
+ }
1153
+ };
1154
+ class Ae extends nt {
1155
+ constructor(r, t) {
1156
+ const o = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new ae();
1157
+ s.setAttribute("position", new le(o, 3)), s.computeBoundingSphere();
1158
+ const i = new st({ fog: !1 });
1159
+ super(s, i), this.light = r, this.color = t, this.type = "RectAreaLightHelper";
1160
+ const n = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new ae();
1161
+ a.setAttribute("position", new le(n, 3)), a.computeBoundingSphere(), this.add(new it(a, new we({ side: at, fog: !1 })));
1162
+ }
1163
+ updateMatrixWorld() {
1164
+ if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
1165
+ this.material.color.set(this.color), this.children[0].material.color.set(this.color);
1166
+ else {
1167
+ this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
1168
+ const r = this.material.color, t = Math.max(r.r, r.g, r.b);
1169
+ t > 1 && r.multiplyScalar(1 / t), this.children[0].material.color.copy(this.material.color);
1170
+ }
1171
+ this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld), this.children[0].matrixWorld.copy(this.matrixWorld);
1172
+ }
1173
+ dispose() {
1174
+ this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
1175
+ }
1176
+ }
1177
+ const { logWarning: me } = A();
1178
+ let z, k;
1179
+ const Ar = {
1180
+ DirectionalLight: lt,
1181
+ PointLight: ut,
1182
+ SpotLight: ct,
1183
+ HemisphereLight: dt,
1184
+ RectAreaLight: Ae
1185
+ }, Fr = {
1186
+ mounted: (e) => {
1187
+ if (!e.isLight) {
1188
+ me(`${e.type} is not a light`);
1189
+ return;
1190
+ }
1191
+ z = Ar[e.type], e.parent.add(new z(e, 1, e.color.getHex()));
1192
+ },
1193
+ updated: (e) => {
1194
+ k = e.parent.children.find((r) => r instanceof z), !(k instanceof Ae) && k.update();
1195
+ },
1196
+ unmounted: (e) => {
1197
+ if (!e.isLight) {
1198
+ me(`${e.type} is not a light`);
1199
+ return;
702
1200
  }
1201
+ k = e.parent.children.find((r) => r instanceof z), k && k.dispose && k.dispose(), e.parent.remove(k);
703
1202
  }
704
- }, Lt = _t, Ot = {
1203
+ }, { logWarning: Lr } = A(), Gr = {
1204
+ updated: (e, r) => {
1205
+ const t = xe(r);
1206
+ if (!t) {
1207
+ Lr(`v-always-look-at: problem with binding value: ${r.value}`);
1208
+ return;
1209
+ }
1210
+ const { onLoop: o } = re();
1211
+ o(() => {
1212
+ e.lookAt(t);
1213
+ });
1214
+ }
1215
+ }, { logWarning: Or } = A(), Jr = {
1216
+ updated: (e, r) => {
1217
+ var s;
1218
+ const t = xe(r);
1219
+ if (!t) {
1220
+ Or(`v-distance-to: problem with binding value: ${r.value}`);
1221
+ return;
1222
+ }
1223
+ P && (P.dispose(), e.parent.remove(P));
1224
+ const o = t.clone().sub(e.position);
1225
+ o.normalize(), P = new ft(o, e.position, e.position.distanceTo(t), 16776960), e.parent.add(P), console.table(
1226
+ [
1227
+ ["Distance:", e.position.distanceTo(t)],
1228
+ [`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
1229
+ [`Destiny: ${e.name || e.type}`, `x:${t.x}, y:${t.y}, z:${t == null ? void 0 : t.z}`]
1230
+ ]
1231
+ );
1232
+ },
1233
+ unmounted: (e) => {
1234
+ P == null || P.dispose(), e.parent.remove(P);
1235
+ }
1236
+ };
1237
+ let P = null;
1238
+ const Qr = {
705
1239
  install(e) {
706
- e.component("TresCanvas", wt);
1240
+ e.component("TresCanvas", Pr);
707
1241
  }
708
1242
  };
709
1243
  export {
710
- wt as TresCanvas,
711
- q as catalogue,
712
- Ot as default,
713
- ce as dispose,
714
- Y as extend,
715
- bt as isProd,
716
- et as normalizeColor,
717
- Dt as normalizeVectorFlexibleParam,
718
- Lt as templateCompilerOptions,
719
- ft as trasverseObjects,
720
- Ke as useCamera,
721
- kt as useLoader,
722
- B as useLogger,
723
- pt as usePointerEventHandler,
724
- mt as useRaycaster,
725
- ie as useRenderLoop,
726
- ut as useRenderer,
727
- St as useSeek,
728
- Tt as useTexture,
729
- xt as useTres,
730
- gt as useTresContext,
731
- vt as useTresContextProvider
1244
+ Pr as TresCanvas,
1245
+ Z as catalogue,
1246
+ Qr as default,
1247
+ oe as extend,
1248
+ Rr as isProd,
1249
+ Ft as normalizeColor,
1250
+ Ir as normalizeVectorFlexibleParam,
1251
+ Wr as templateCompilerOptions,
1252
+ sr as trasverseObjects,
1253
+ Vt as useCamera,
1254
+ $r as useLoader,
1255
+ A as useLogger,
1256
+ ar as usePointerEventHandler,
1257
+ ir as useRaycaster,
1258
+ re as useRenderLoop,
1259
+ or as useRenderer,
1260
+ Vr as useSeek,
1261
+ Nr as useTexture,
1262
+ zr as useTres,
1263
+ dr as useTresContext,
1264
+ cr as useTresContextProvider,
1265
+ Gr as vAlwaysLookAt,
1266
+ Jr as vDistanceTo,
1267
+ Fr as vLightHelper,
1268
+ Ur as vLog
732
1269
  };