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