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