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