@tresjs/core 4.0.0-next.0 → 4.0.0-next.2

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