@tresjs/core 4.0.0-next.2 → 4.0.0-rc.1

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