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