@tresjs/core 4.2.10 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tres.js CHANGED
@@ -1,27 +1,27 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v4.2.10
3
+ * version: v4.3.0
4
4
  * (c) 2024
5
5
  * description: Declarative ThreeJS using Vue Components
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
7
  */
8
- var bt = Object.defineProperty;
9
- var Ct = (e, t, n) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
10
- var me = (e, t, n) => Ct(e, typeof t != "symbol" ? t + "" : t, n);
11
- import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as Mt, isRef as Pt, reactive as Et, defineComponent as Be, useSlots as Tt, getCurrentInstance as Ie, onMounted as St, openBlock as At, createElementBlock as xt, normalizeClass as kt, normalizeStyle as Lt, createRenderer as Rt, h as He, Fragment as Ot } from "vue";
12
- import * as et from "three";
13
- import { PerspectiveCamera as we, Camera as Dt, Clock as tt, Vector3 as Se, Color as Z, Scene as nt, MathUtils as rt, MeshBasicMaterial as ot, DoubleSide as jt, REVISION as Bt, SRGBColorSpace as It, ACESFilmicToneMapping as st, PCFSoftShadowMap as Ht, NoToneMapping as $t, WebGLRenderer as he, TextureLoader as Ut, Vector2 as ge, Raycaster as Ft, BufferAttribute as Wt, Object3D as Nt, Line as zt, BufferGeometry as $e, Float32BufferAttribute as Ue, LineBasicMaterial as Gt, Mesh as Vt, BackSide as Yt, DirectionalLightHelper as qt, PointLightHelper as Jt, SpotLightHelper as Kt, HemisphereLightHelper as Qt, ArrowHelper as Xt } from "three";
14
- import { createEventHook as j, useRafFn as it, toValue as k, unrefElement as Zt, useDevicePixelRatio as en, usePointer as tn, useElementBounding as nn, useWindowSize as rn, useElementSize as on, refDebounced as Fe, tryOnScopeDispose as sn, useFps as an, useMemory as ln } from "@vueuse/core";
15
- const cn = "@tresjs/core", un = "module", fn = "4.2.10", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = {
8
+ var Et = Object.defineProperty;
9
+ var Tt = (e, t, n) => t in e ? Et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
10
+ var he = (e, t, n) => Tt(e, typeof t != "symbol" ? t + "" : t, n);
11
+ import { defineComponent as fe, withAsyncContext as nt, reactive as Se, renderSlot as rt, unref as W, ref as I, computed as J, watchEffect as xe, onUnmounted as K, shallowRef as $, watch as ae, readonly as we, provide as le, inject as St, isRef as xt, useSlots as At, getCurrentInstance as He, onMounted as kt, openBlock as Lt, createElementBlock as Ot, normalizeClass as Rt, normalizeStyle as Dt, createRenderer as jt, h as Ue, Fragment as Bt } from "vue";
12
+ import * as ot from "three";
13
+ import { Scene as st, Vector3 as Ae, MathUtils as it, MeshBasicMaterial as at, DoubleSide as It, TextureLoader as $t, PerspectiveCamera as be, Camera as Ht, Clock as lt, REVISION as Ut, Color as Z, SRGBColorSpace as Ft, ACESFilmicToneMapping as ct, PCFSoftShadowMap as Wt, NoToneMapping as Nt, WebGLRenderer as ge, Vector2 as ve, Raycaster as zt, BufferAttribute as Gt, Object3D as Vt, ArrowHelper as Yt, Line as qt, BufferGeometry as Fe, Float32BufferAttribute as We, LineBasicMaterial as Jt, Mesh as Kt, BackSide as Qt, DirectionalLightHelper as Xt, PointLightHelper as Zt, SpotLightHelper as en, HemisphereLightHelper as tn } from "three";
14
+ import { tryOnScopeDispose as nn, toValue as x, unrefElement as rn, useDevicePixelRatio as on, useWindowSize as sn, useElementSize as an, refDebounced as Ne, usePointer as ln, useElementBounding as cn, createEventHook as D, useFps as un, useMemory as fn, useRafFn as ut } from "@vueuse/core";
15
+ const pn = "@tresjs/core", dn = "module", mn = "4.3.0", hn = "pnpm@9.1.4", gn = "Declarative ThreeJS using Vue Components", vn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", yn = "MIT", _n = {
16
16
  type: "git",
17
17
  url: "git+https://github.com/Tresjs/tres.git"
18
- }, vn = [
18
+ }, wn = [
19
19
  "vue",
20
20
  "3d",
21
21
  "threejs",
22
22
  "three",
23
23
  "threejs-vue"
24
- ], yn = !1, _n = {
24
+ ], bn = !1, Mn = {
25
25
  ".": {
26
26
  types: "./dist/index.d.ts",
27
27
  import: "./dist/tres.js",
@@ -40,12 +40,12 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.10", dn = "pnpm@9.1.4", pn =
40
40
  types: "./dist/src/utils/index.d.ts"
41
41
  },
42
42
  "./*": "./*"
43
- }, wn = "./dist/tres.js", bn = "./dist/tres.js", Cn = "./dist/index.d.ts", Mn = [
43
+ }, Pn = "./dist/tres.js", Cn = "./dist/tres.js", En = "./dist/index.d.ts", Tn = [
44
44
  "*.d.ts",
45
45
  "dist"
46
- ], Pn = {
46
+ ], Sn = {
47
47
  access: "public"
48
- }, En = {
48
+ }, xn = {
49
49
  dev: "cd playground/vue && npm run dev",
50
50
  "dev:nuxt": "cd playground/nuxt && npm run dev",
51
51
  build: "vite build",
@@ -60,33 +60,32 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.10", dn = "pnpm@9.1.4", pn =
60
60
  "docs:build": "vitepress build docs",
61
61
  "docs:serve": "vitepress serve docs",
62
62
  "docs:preview": "vitepress preview docs",
63
- "docs:contributors": "esno scripts/update-contributors.ts",
64
- prepare: "node .husky/install.mjs"
65
- }, Tn = {
63
+ "docs:contributors": "esno scripts/update-contributors.ts"
64
+ }, An = {
66
65
  three: ">=0.133",
67
66
  vue: ">=3.4"
68
- }, Sn = {
67
+ }, kn = {
69
68
  "@alvarosabu/utils": "^3.2.0",
70
69
  "@vue/devtools-api": "^6.6.3",
71
- "@vueuse/core": "^10.11.0"
72
- }, An = {
73
- "@release-it/conventional-changelog": "^8.0.1",
70
+ "@vueuse/core": "^11.1.0"
71
+ }, Ln = {
72
+ "@release-it/conventional-changelog": "^8.0.2",
74
73
  "@stackblitz/sdk": "^1.11.0",
75
74
  "@tresjs/cientos": "4.0.2",
76
- "@tresjs/eslint-config": "^1.1.0",
75
+ "@tresjs/eslint-config": "^1.3.1",
77
76
  "@types/three": "^0.168.0",
78
- "@typescript-eslint/eslint-plugin": "^8.4.0",
79
- "@typescript-eslint/parser": "^8.4.0",
80
- "@vitejs/plugin-vue": "^5.0.5",
77
+ "@typescript-eslint/eslint-plugin": "^8.6.0",
78
+ "@typescript-eslint/parser": "^8.6.0",
79
+ "@vitejs/plugin-vue": "^5.1.3",
81
80
  "@vitest/coverage-c8": "^0.33.0",
82
- "@vitest/coverage-v8": "^2.0.2",
83
- "@vitest/ui": "^2.0.2",
81
+ "@vitest/coverage-v8": "^2.1.1",
82
+ "@vitest/ui": "^2.1.1",
84
83
  "@vue/test-utils": "^2.4.6",
85
- eslint: "^9.6.0",
84
+ eslint: "^9.10.0",
86
85
  "eslint-plugin-vue": "^9.28.0",
87
86
  esno: "^4.7.0",
88
87
  gsap: "^3.12.5",
89
- husky: "^9.0.11",
88
+ husky: "^9.1.6",
90
89
  jsdom: "^25.0.0",
91
90
  kolorist: "^1.8.0",
92
91
  ohmyfetch: "^0.4.21",
@@ -95,189 +94,143 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.10", dn = "pnpm@9.1.4", pn =
95
94
  "rollup-plugin-analyzer": "^4.0.0",
96
95
  "rollup-plugin-copy": "^3.5.0",
97
96
  "rollup-plugin-visualizer": "^5.12.0",
98
- sponsorkit: "^0.15.4",
97
+ sponsorkit: "^0.15.5",
99
98
  three: "^0.168.0",
100
- unocss: "^0.62.3",
101
- unplugin: "^1.13.1",
102
- "unplugin-vue-components": "^0.27.2",
103
- vite: "^5.4.3",
99
+ unocss: "^0.62.4",
100
+ unplugin: "^1.14.1",
101
+ "unplugin-vue-components": "^0.27.4",
102
+ vite: "^5.4.6",
104
103
  "vite-plugin-banner": "^0.8.0",
105
- "vite-plugin-dts": "4.1.0",
106
- "vite-plugin-inspect": "^0.8.4",
104
+ "vite-plugin-dts": "4.2.1",
105
+ "vite-plugin-inspect": "^0.8.7",
107
106
  "vite-plugin-require-transform": "^1.0.21",
108
107
  "vite-svg-loader": "^5.1.0",
109
108
  vitepress: "1.3.4",
110
- vitest: "^2.0.2",
111
- vue: "3.5.0",
112
- "vue-demi": "^0.14.8"
113
- }, xn = {
114
- name: cn,
115
- type: un,
116
- version: fn,
117
- packageManager: dn,
118
- description: pn,
119
- author: mn,
120
- license: hn,
121
- repository: gn,
122
- keywords: vn,
123
- sideEffects: yn,
124
- exports: _n,
125
- main: wn,
126
- module: bn,
127
- types: Cn,
128
- files: Mn,
129
- publishConfig: Pn,
130
- scripts: En,
131
- peerDependencies: Tn,
132
- dependencies: Sn,
133
- devDependencies: An
109
+ vitest: "^2.1.1",
110
+ vue: "3.5.6",
111
+ "vue-demi": "^0.14.10"
112
+ }, On = {
113
+ name: pn,
114
+ type: dn,
115
+ version: mn,
116
+ packageManager: hn,
117
+ description: gn,
118
+ author: vn,
119
+ license: yn,
120
+ repository: _n,
121
+ keywords: wn,
122
+ sideEffects: bn,
123
+ exports: Mn,
124
+ main: Pn,
125
+ module: Cn,
126
+ types: En,
127
+ files: Tn,
128
+ publishConfig: Sn,
129
+ scripts: xn,
130
+ peerDependencies: An,
131
+ dependencies: kn,
132
+ devDependencies: Ln
134
133
  };
135
- function be(e) {
134
+ function Rn(e) {
135
+ const t = { nodes: {}, materials: {} };
136
+ return e && e.traverse((n) => {
137
+ n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
138
+ }), t;
139
+ }
140
+ async function Dn(e, t, n, r, s) {
141
+ const { logError: l } = V(), i = new e();
142
+ return s && s(i), n && n(i), await new Promise((a, c) => {
143
+ i.load(
144
+ t,
145
+ (o) => {
146
+ const f = o;
147
+ f.scene && Object.assign(f, Rn(f.scene)), a(f);
148
+ },
149
+ r,
150
+ (o) => {
151
+ l("[useLoader] - Failed to load resource", o), c(o);
152
+ }
153
+ );
154
+ });
155
+ }
156
+ const qr = /* @__PURE__ */ fe({
157
+ __name: "component",
158
+ props: {
159
+ loader: {},
160
+ url: {}
161
+ },
162
+ async setup(e) {
163
+ let t, n;
164
+ const r = e, s = ([t, n] = nt(() => Se(Dn(r.loader, r.url))), t = await t, n(), t);
165
+ return (l, i) => rt(l.$slots, "default", { data: W(s) });
166
+ }
167
+ });
168
+ class jn extends ot.Mesh {
169
+ constructor(...n) {
170
+ super(...n);
171
+ he(this, "type", "HightlightMesh");
172
+ he(this, "createTime");
173
+ this.createTime = Date.now();
174
+ }
175
+ onBeforeRender() {
176
+ const r = (Date.now() - this.createTime) / 1e3, i = 1 + 0.07 * Math.sin(2.5 * r);
177
+ this.scale.set(i, i, i);
178
+ }
179
+ }
180
+ function Me(e) {
136
181
  return typeof e > "u";
137
182
  }
138
- function de(e) {
183
+ function pe(e) {
139
184
  return Array.isArray(e);
140
185
  }
141
- function kn(e) {
186
+ function Bn(e) {
142
187
  return typeof e == "number";
143
188
  }
144
- function at(e) {
189
+ function ft(e) {
145
190
  return typeof e == "string";
146
191
  }
147
192
  function G(e) {
148
193
  return typeof e == "function";
149
194
  }
150
- function U(e) {
151
- return e === Object(e) && !de(e) && !G(e);
195
+ function H(e) {
196
+ return e === Object(e) && !pe(e) && !G(e);
152
197
  }
153
198
  function N(e) {
154
- return U(e) && "isObject3D" in e && !!e.isObject3D;
155
- }
156
- function We(e) {
157
- return U(e) && "isCamera" in e && !!e.isCamera;
158
- }
159
- function Ln(e) {
160
- return U(e) && "isBufferGeometry" in e && !!e.isBufferGeometry;
161
- }
162
- function Rn(e) {
163
- return U(e) && "isMaterial" in e && !!e.isMaterial;
164
- }
165
- function On(e) {
166
- return U(e) && "isLight" in e && !!e.isLight;
167
- }
168
- function Dn(e) {
169
- return U(e) && "isFog" in e && !!e.isFog;
199
+ return H(e) && "isObject3D" in e && !!e.isObject3D;
170
200
  }
171
- function jn(e) {
172
- return U(e) && "isScene" in e && !!e.isScene;
201
+ function ze(e) {
202
+ return H(e) && "isCamera" in e && !!e.isCamera;
173
203
  }
174
- function oe(e) {
175
- return N(e) || Ln(e) || Rn(e) || Dn(e);
204
+ function In(e) {
205
+ return H(e) && "isBufferGeometry" in e && !!e.isBufferGeometry;
176
206
  }
177
- function Bn(e) {
178
- return U(e) && !!e.isPrimitive;
207
+ function $n(e) {
208
+ return H(e) && "isMaterial" in e && !!e.isMaterial;
179
209
  }
180
- const In = ({ sizes: e }) => {
181
- const t = H([]), n = V(
182
- () => t.value[0]
183
- ), r = (i) => {
184
- const a = i instanceof Dt ? i : t.value.find((o) => o.uuid === i);
185
- if (!a)
186
- return;
187
- const c = t.value.filter(({ uuid: o }) => o !== a.uuid);
188
- t.value = [a, ...c];
189
- }, s = (i, a = !1) => {
190
- if (We(i)) {
191
- const c = i;
192
- if (t.value.some(({ uuid: o }) => o === c.uuid))
193
- return;
194
- a ? r(c) : t.value.push(c);
195
- }
196
- }, l = (i) => {
197
- if (We(i)) {
198
- const a = i;
199
- t.value = t.value.filter(({ uuid: c }) => c !== a.uuid);
200
- }
201
- };
202
- return Te(() => {
203
- e.aspectRatio.value && t.value.forEach((i) => {
204
- !i.manual && (i instanceof we || Hn(i)) && (i instanceof we ? i.aspect = e.aspectRatio.value : (i.left = e.width.value * -0.5, i.right = e.width.value * 0.5, i.top = e.height.value * 0.5, i.bottom = e.height.value * -0.5), i.updateProjectionMatrix());
205
- });
206
- }), K(() => {
207
- t.value = [];
208
- }), {
209
- camera: n,
210
- cameras: t,
211
- registerCamera: s,
212
- deregisterCamera: l,
213
- setCameraActive: r
214
- };
215
- };
216
210
  function Hn(e) {
217
- return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera;
211
+ return H(e) && "isLight" in e && !!e.isLight;
218
212
  }
219
- const lt = j(), ct = j(), Ae = j(), ee = new tt();
220
- let ue = 0, fe = 0;
221
- const { pause: $n, resume: Ne, isActive: Un } = it(
222
- () => {
223
- lt.trigger({ delta: ue, elapsed: fe, clock: ee }), ct.trigger({ delta: ue, elapsed: fe, clock: ee }), Ae.trigger({ delta: ue, elapsed: fe, clock: ee });
224
- },
225
- { immediate: !1 }
226
- );
227
- Ae.on(() => {
228
- ue = ee.getDelta(), fe = ee.getElapsedTime();
229
- });
230
- let ze = !1;
231
- const Ur = () => (ze || (ze = !0, Ne()), {
232
- onBeforeLoop: lt.on,
233
- onLoop: ct.on,
234
- onAfterLoop: Ae.on,
235
- pause: $n,
236
- resume: Ne,
237
- isActive: Un
238
- }), Fr = !0, se = "[TresJS ▲ ■ ●] ";
239
- function Y() {
240
- function e(...r) {
241
- typeof r[0] == "string" ? r[0] = se + r[0] : r.unshift(se), console.error(...r);
242
- }
243
- function t(...r) {
244
- typeof r[0] == "string" ? r[0] = se + r[0] : r.unshift(se), console.warn(...r);
245
- }
246
- function n(r, s) {
247
- }
248
- return {
249
- logError: e,
250
- logWarning: t,
251
- logMessage: n
252
- };
253
- }
254
- function Wr(e) {
255
- return typeof e == "number" ? [e, e, e] : e instanceof Se ? [e.x, e.y, e.z] : e;
213
+ function Un(e) {
214
+ return H(e) && "isFog" in e && !!e.isFog;
256
215
  }
257
216
  function Fn(e) {
258
- return e instanceof Z ? e : Array.isArray(e) ? new Z(...e) : new Z(e);
217
+ return H(e) && "isScene" in e && !!e.isScene;
259
218
  }
260
- class Wn extends et.Mesh {
261
- constructor(...n) {
262
- super(...n);
263
- me(this, "type", "HightlightMesh");
264
- me(this, "createTime");
265
- this.createTime = Date.now();
266
- }
267
- onBeforeRender() {
268
- const r = (Date.now() - this.createTime) / 1e3, i = 1 + 0.07 * Math.sin(2.5 * r);
269
- this.scale.set(i, i, i);
270
- }
219
+ function re(e) {
220
+ return N(e) || In(e) || $n(e) || Un(e);
221
+ }
222
+ function Wn(e) {
223
+ return H(e) && !!e.isPrimitive;
271
224
  }
272
- const ut = (e, t) => {
225
+ const pt = (e, t) => {
273
226
  for (const n of Object.keys(t))
274
- t[n] instanceof Object && Object.assign(t[n], ut(e[n], t[n]));
227
+ t[n] instanceof Object && Object.assign(t[n], pt(e[n], t[n]));
275
228
  return Object.assign(e || {}, t), e;
276
229
  }, Nn = "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", zn = /* @__PURE__ */ Yn(Nn);
277
230
  function Ge(e) {
278
231
  return e && e.nodeType === 1;
279
232
  }
280
- function ie(e) {
233
+ function oe(e) {
281
234
  return e.replace(/-([a-z])/g, (t, n) => n.toUpperCase());
282
235
  }
283
236
  const Gn = /\B([A-Z])/g;
@@ -299,7 +252,7 @@ const Ve = (e, t) => {
299
252
  const r = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
300
253
  r && r.reduce((s, l, i) => (s[l] === void 0 && (s[l] = {}), i === r.length - 1 && (s[l] = n), s[l]), e);
301
254
  };
302
- function ft(e, t) {
255
+ function dt(e, t) {
303
256
  if (Ge(e) && Ge(t)) {
304
257
  const s = e.attributes, l = t.attributes;
305
258
  return s.length !== l.length ? !1 : Array.from(s).every(({ name: i, value: a }) => t.getAttribute(i) === a);
@@ -312,7 +265,7 @@ function ft(e, t) {
312
265
  if (n.length !== r.length)
313
266
  return !1;
314
267
  for (const s of n)
315
- if (!r.includes(s) || !ft(e[s], t[s]))
268
+ if (!r.includes(s) || !dt(e[s], t[s]))
316
269
  return !1;
317
270
  return !0;
318
271
  }
@@ -320,7 +273,7 @@ function Jn(e, t) {
320
273
  if (!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length)
321
274
  return !1;
322
275
  for (let n = 0; n < e.length; n++)
323
- if (!ft(e[n], t[n]))
276
+ if (!dt(e[n], t[n]))
324
277
  return !1;
325
278
  return !0;
326
279
  }
@@ -330,9 +283,9 @@ function Qn(e, t, n, r) {
330
283
  if (c.uuid === t)
331
284
  return c;
332
285
  for (const o of c.children) {
333
- const u = s(o);
334
- if (u)
335
- return u;
286
+ const f = s(o);
287
+ if (f)
288
+ return f;
336
289
  }
337
290
  }, l = s(e);
338
291
  if (!l) {
@@ -351,22 +304,22 @@ function Qn(e, t, n, r) {
351
304
  i[a] !== void 0 ? i[a] = r : console.warn(`Property path is not valid: ${n.join(".")}`);
352
305
  }
353
306
  function Xn(e) {
354
- const t = new ot({
307
+ const t = new at({
355
308
  color: 11003607,
356
309
  // Highlight color, e.g., yellow
357
310
  transparent: !0,
358
311
  opacity: 0.2,
359
312
  depthTest: !1,
360
313
  // So the highlight is always visible
361
- side: jt
314
+ side: It
362
315
  // To e
363
316
  });
364
- return new Wn(e.geometry.clone(), t);
317
+ return new jn(e.geometry.clone(), t);
365
318
  }
366
319
  function Zn(e) {
367
320
  var n;
368
321
  let t = e.value;
369
- return e.value && ((n = e.value) != null && n.isMesh) && (t = e.value.position), Array.isArray(e.value) && (t = new Se(...t)), t;
322
+ return e.value && ((n = e.value) != null && n.isMesh) && (t = e.value.position), Array.isArray(e.value) && (t = new Ae(...t)), t;
370
323
  }
371
324
  function er(e) {
372
325
  return "map" in e;
@@ -374,9 +327,9 @@ function er(e) {
374
327
  function Ye(e) {
375
328
  er(e) && e.map && e.map.dispose(), e.dispose();
376
329
  }
377
- function dt(e) {
330
+ function mt(e) {
378
331
  var n, r;
379
- if (e.parent && ((n = e.removeFromParent) == null || n.call(e)), delete e.__tres, [...e.children].forEach((s) => dt(s)), !(e instanceof nt)) {
332
+ if (e.parent && ((n = e.removeFromParent) == null || n.call(e)), delete e.__tres, [...e.children].forEach((s) => mt(s)), !(e instanceof st)) {
380
333
  const s = e;
381
334
  e && ((r = e.dispose) == null || r.call(e)), s.geometry && (s.geometry.dispose(), delete s.geometry), Array.isArray(s.material) ? (s.material.forEach((l) => Ye(l)), delete s.material) : s.material && (Ye(s.material), delete s.material);
382
335
  }
@@ -387,7 +340,7 @@ function tr(e, t) {
387
340
  t(e[r], r) && (e[n] = e[r], n++);
388
341
  return e.length = n, e;
389
342
  }
390
- function Ce(e, t) {
343
+ function Pe(e, t) {
391
344
  let n = e;
392
345
  if (t.includes("-")) {
393
346
  const r = t.split("-");
@@ -403,25 +356,25 @@ function qe(...e) {
403
356
  }
404
357
  const Je = /-\d+$/;
405
358
  function nr(e, t, n) {
406
- if (at(n)) {
359
+ if (ft(n)) {
407
360
  if (Je.test(n)) {
408
- const l = n.replace(Je, ""), { target: i, key: a } = Ce(e, l);
361
+ const l = n.replace(Je, ""), { target: i, key: a } = Pe(e, l);
409
362
  if (!Array.isArray(i[a])) {
410
363
  const c = i[a], o = [];
411
364
  o.__tresDetach = () => {
412
- o.every((u) => be(u)) && (i[a] = c);
365
+ o.every((f) => Me(f)) && (i[a] = c);
413
366
  }, i[a] = o;
414
367
  }
415
368
  }
416
- const { target: r, key: s } = Ce(e, n);
369
+ const { target: r, key: s } = Pe(e, n);
417
370
  t.__tres.previousAttach = r[s], r[s] = Q(t);
418
371
  } else
419
372
  t.__tres.previousAttach = n(e, t);
420
373
  }
421
374
  function rr(e, t, n) {
422
375
  var r, s, l;
423
- if (at(n)) {
424
- const { target: i, key: a } = Ce(e, n), c = t.__tres.previousAttach;
376
+ if (ft(n)) {
377
+ const { target: i, key: a } = Pe(e, n), c = t.__tres.previousAttach;
425
378
  c === void 0 ? delete i[a] : i[a] = c, "__tresDetach" in i && i.__tresDetach();
426
379
  } else
427
380
  (s = (r = t.__tres) == null ? void 0 : r.previousAttach) == null || s.call(r, e, t);
@@ -441,7 +394,7 @@ function z(e, t, n) {
441
394
  ...t
442
395
  }, r.__tres.attach || (r.isMaterial ? r.__tres.attach = "material" : r.isBufferGeometry ? r.__tres.attach = "geometry" : r.isFog && (r.__tres.attach = "fog")), r;
443
396
  }
444
- function pt(e) {
397
+ function ht(e) {
445
398
  var n;
446
399
  const t = (n = e == null ? void 0 : e.__tres) == null ? void 0 : n.root;
447
400
  t && t.render && t.render.canBeInvalidated.value && t.invalidate();
@@ -451,10 +404,10 @@ function or(e, t, n) {
451
404
  if (!G(e.setPixelRatio))
452
405
  return;
453
406
  let r = 0;
454
- if (de(n) && n.length >= 2) {
407
+ if (pe(n) && n.length >= 2) {
455
408
  const [l, i] = n;
456
- r = rt.clamp(t, l, i);
457
- } else kn(n) ? r = n : r = t;
409
+ r = it.clamp(t, l, i);
410
+ } else Bn(n) ? r = n : r = t;
458
411
  r !== ((s = e.getPixelRatio) == null ? void 0 : s.call(e)) && e.setPixelRatio(r);
459
412
  }
460
413
  function sr(e, t, n, r, s) {
@@ -463,79 +416,309 @@ function sr(e, t, n, r, s) {
463
416
  return !0;
464
417
  const a = z(e, t.__tres ?? {}, s), c = t.parent ?? t.__tres.parent ?? null, o = { ...t.__tres.memoizedProps };
465
418
  delete o.object;
466
- for (const u of l)
467
- mt(u, s), ht(u, s);
419
+ for (const f of l)
420
+ gt(f, s), vt(f, s);
468
421
  i.__tres.objects = [], r.remove(t);
469
- for (const [u, v] of Object.entries(o))
470
- r.patchProp(a, u, a[u], v);
422
+ for (const [f, y] of Object.entries(o))
423
+ r.patchProp(a, f, a[f], y);
471
424
  n(e), r.insert(t, c);
472
- for (const u of l)
473
- r.insert(u, t);
425
+ for (const f of l)
426
+ r.insert(f, t);
474
427
  return !0;
475
428
  }
476
429
  function Q(e) {
477
- return Bn(e) ? (e.object.__tres = e.__tres, e.object) : e;
430
+ return Wn(e) ? (e.object.__tres = e.__tres, e.object) : e;
478
431
  }
479
- function mt(e, t) {
432
+ function gt(e, t) {
480
433
  var r, s, l, i;
481
434
  const n = ((r = e.__tres) == null ? void 0 : r.parent) || t.scene.value;
482
435
  e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && tr(n.__tres.objects, (a) => a !== e), (s = e.__tres) != null && s.attach ? rr(n, e, e.__tres.attach) : ((i = (l = e.parent) == null ? void 0 : l.remove) == null || i.call(l, Q(e)), e.parent = null);
483
436
  }
484
- function ht(e, t) {
437
+ function vt(e, t) {
485
438
  var n;
486
439
  (n = e.traverse) == null || n.call(e, (r) => {
487
440
  var s;
488
441
  t.deregisterCamera(r), (s = t.eventManager) == null || s.deregisterPointerMissedObject(r);
489
- }), t.deregisterCamera(e), pt(e);
442
+ }), t.deregisterCamera(e), ht(e);
490
443
  }
491
- const ir = Number.parseInt(Bt.replace("dev", "")), ae = {
444
+ async function ir(e, t) {
445
+ const n = new $t(t), r = (s) => new Promise((l, i) => {
446
+ n.load(
447
+ s,
448
+ (a) => l(a),
449
+ () => null,
450
+ () => {
451
+ i(new Error("[useTextures] - Failed to load texture"));
452
+ }
453
+ );
454
+ });
455
+ if (Kn(e)) {
456
+ const s = await Promise.all(e.map((l) => r(l)));
457
+ return e.length > 1 ? s : s[0];
458
+ } else {
459
+ const {
460
+ map: s,
461
+ displacementMap: l,
462
+ normalMap: i,
463
+ roughnessMap: a,
464
+ metalnessMap: c,
465
+ aoMap: o,
466
+ alphaMap: f,
467
+ matcap: y
468
+ } = e;
469
+ return {
470
+ map: s ? await r(s) : null,
471
+ displacementMap: l ? await r(l) : null,
472
+ normalMap: i ? await r(i) : null,
473
+ roughnessMap: a ? await r(a) : null,
474
+ metalnessMap: c ? await r(c) : null,
475
+ aoMap: o ? await r(o) : null,
476
+ alphaMap: f ? await r(f) : null,
477
+ matcap: y ? await r(y) : null
478
+ };
479
+ }
480
+ }
481
+ const Jr = /* @__PURE__ */ fe({
482
+ __name: "component",
483
+ props: {
484
+ map: {},
485
+ displacementMap: {},
486
+ normalMap: {},
487
+ roughnessMap: {},
488
+ metalnessMap: {},
489
+ aoMap: {},
490
+ alphaMap: {},
491
+ matcap: {}
492
+ },
493
+ async setup(e) {
494
+ let t, n;
495
+ const r = e, s = ([t, n] = nt(() => Se(ir(r))), t = await t, n(), t);
496
+ return (l, i) => rt(l.$slots, "default", { textures: W(s) });
497
+ }
498
+ }), ar = ({ sizes: e }) => {
499
+ const t = I([]), n = J(
500
+ () => t.value[0]
501
+ ), r = (i) => {
502
+ const a = i instanceof Ht ? i : t.value.find((o) => o.uuid === i);
503
+ if (!a)
504
+ return;
505
+ const c = t.value.filter(({ uuid: o }) => o !== a.uuid);
506
+ t.value = [a, ...c];
507
+ }, s = (i, a = !1) => {
508
+ if (ze(i)) {
509
+ const c = i;
510
+ if (t.value.some(({ uuid: o }) => o === c.uuid))
511
+ return;
512
+ a ? r(c) : t.value.push(c);
513
+ }
514
+ }, l = (i) => {
515
+ if (ze(i)) {
516
+ const a = i;
517
+ t.value = t.value.filter(({ uuid: c }) => c !== a.uuid);
518
+ }
519
+ };
520
+ return xe(() => {
521
+ e.aspectRatio.value && t.value.forEach((i) => {
522
+ !i.manual && (i instanceof be || lr(i)) && (i instanceof be ? i.aspect = e.aspectRatio.value : (i.left = e.width.value * -0.5, i.right = e.width.value * 0.5, i.top = e.height.value * 0.5, i.bottom = e.height.value * -0.5), i.updateProjectionMatrix());
523
+ });
524
+ }), K(() => {
525
+ t.value = [];
526
+ }), {
527
+ camera: n,
528
+ cameras: t,
529
+ registerCamera: s,
530
+ deregisterCamera: l,
531
+ setCameraActive: r
532
+ };
533
+ };
534
+ function lr(e) {
535
+ return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera;
536
+ }
537
+ const Kr = !0, de = "[TresJS ▲ ■ ●] ";
538
+ function cr(...e) {
539
+ typeof e[0] == "string" ? e[0] = de + e[0] : e.unshift(de), console.error(...e);
540
+ }
541
+ function ur(...e) {
542
+ typeof e[0] == "string" ? e[0] = de + e[0] : e.unshift(de), console.warn(...e);
543
+ }
544
+ function fr(e, t) {
545
+ }
546
+ function V() {
547
+ return {
548
+ logError: cr,
549
+ logWarning: ur,
550
+ logMessage: fr
551
+ };
552
+ }
553
+ const Ce = I({}), Ee = (e) => Object.assign(Ce.value, e);
554
+ function ye() {
555
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
556
+ let n = 0, r = !1;
557
+ const s = () => {
558
+ const o = Array.from(e.entries()).sort((f, y) => {
559
+ const u = f[1].priority - y[1].priority;
560
+ return u === 0 ? f[1].addI - y[1].addI : u;
561
+ });
562
+ t.clear(), o.forEach((f) => t.add(f[0]));
563
+ }, l = (o) => {
564
+ e.delete(o), t.delete(o);
565
+ };
566
+ return { on: (o, f = 0) => {
567
+ e.set(o, { priority: f, addI: n++ });
568
+ const y = () => l(o);
569
+ return nn(y), r = !0, {
570
+ off: y
571
+ };
572
+ }, off: l, trigger: (...o) => {
573
+ r && (s(), r = !1), t.forEach((f) => f(...o));
574
+ }, dispose: () => {
575
+ e.clear(), t.clear();
576
+ }, get count() {
577
+ return e.size;
578
+ } };
579
+ }
580
+ function pr() {
581
+ let e = !0, t = !0, n = !1;
582
+ const r = new lt(!1), s = I(r.running), l = I(!1);
583
+ let i;
584
+ const a = it.generateUUID();
585
+ let c = null;
586
+ const o = ye(), f = ye(), y = ye();
587
+ P();
588
+ let u = {};
589
+ function v(M) {
590
+ u = M;
591
+ }
592
+ function h(M, A, d = 0) {
593
+ switch (A) {
594
+ case "before":
595
+ return o.on(M, d);
596
+ case "render":
597
+ return c || (c = M), f.dispose(), f.on(M);
598
+ case "after":
599
+ return y.on(M, d);
600
+ }
601
+ }
602
+ function g() {
603
+ t && (t = !1, P(), b());
604
+ }
605
+ function p() {
606
+ t = !0, P(), cancelAnimationFrame(i);
607
+ }
608
+ function _() {
609
+ n = !1, P();
610
+ }
611
+ function C() {
612
+ n = !0, P();
613
+ }
614
+ function E() {
615
+ l.value = !0;
616
+ }
617
+ function T() {
618
+ l.value = !1;
619
+ }
620
+ function b() {
621
+ if (!e) {
622
+ i = requestAnimationFrame(b);
623
+ return;
624
+ }
625
+ const M = r.getDelta(), A = r.getElapsedTime(), d = {
626
+ camera: W(u.camera),
627
+ scene: W(u.scene),
628
+ renderer: W(u.renderer),
629
+ raycaster: W(u.raycaster),
630
+ controls: W(u.controls),
631
+ invalidate: u.invalidate,
632
+ advance: u.advance
633
+ }, w = { delta: M, elapsed: A, clock: r, ...d };
634
+ s.value && o.trigger(w), l.value || (f.count ? f.trigger(w) : c && c(w)), s.value && y.trigger(w), i = requestAnimationFrame(b);
635
+ }
636
+ function P() {
637
+ const M = !t && !n;
638
+ r.running !== M && (r.running ? r.stop() : r.start()), s.value = r.running;
639
+ }
640
+ return {
641
+ loopId: a,
642
+ register: (M, A, d) => h(M, A, d),
643
+ start: g,
644
+ stop: p,
645
+ pause: C,
646
+ resume: _,
647
+ pauseRender: E,
648
+ resumeRender: T,
649
+ isRenderPaused: l,
650
+ isActive: s,
651
+ setContext: v,
652
+ setReady: (M) => e = M
653
+ };
654
+ }
655
+ function ke(e) {
656
+ let t = 0;
657
+ return e.traverse((n) => {
658
+ if (n.isMesh && n.geometry && n.type !== "HightlightMesh") {
659
+ const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, i = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = s + l + i + a;
660
+ t += c;
661
+ }
662
+ }), t;
663
+ }
664
+ function dr(e) {
665
+ return (e / 1024).toFixed(2);
666
+ }
667
+ const mr = Number.parseInt(Ut.replace("dev", ""));
668
+ function Qr(e) {
669
+ return typeof e == "number" ? [e, e, e] : e instanceof Ae ? [e.x, e.y, e.z] : e;
670
+ }
671
+ function hr(e) {
672
+ return e instanceof Z ? e : Array.isArray(e) ? new Z(...e) : new Z(e);
673
+ }
674
+ const se = {
492
675
  realistic: {
493
676
  shadows: !0,
494
677
  physicallyCorrectLights: !0,
495
- outputColorSpace: It,
496
- toneMapping: st,
678
+ outputColorSpace: Ft,
679
+ toneMapping: ct,
497
680
  toneMappingExposure: 3,
498
681
  shadowMap: {
499
682
  enabled: !0,
500
- type: Ht
683
+ type: Wt
501
684
  }
502
685
  },
503
686
  flat: {
504
- toneMapping: $t,
687
+ toneMapping: Nt,
505
688
  toneMappingExposure: 1
506
689
  }
507
690
  };
508
- function ar({
691
+ function gr({
509
692
  canvas: e,
510
693
  options: t,
511
694
  contextParts: { sizes: n, render: r, invalidate: s, advance: l }
512
695
  }) {
513
- const i = V(() => ({
514
- alpha: k(t.alpha) ?? !0,
515
- depth: k(t.depth),
516
- canvas: Zt(e),
517
- context: k(t.context),
518
- stencil: k(t.stencil),
519
- antialias: k(t.antialias) ?? !0,
520
- precision: k(t.precision),
521
- powerPreference: k(t.powerPreference),
522
- premultipliedAlpha: k(t.premultipliedAlpha),
523
- preserveDrawingBuffer: k(t.preserveDrawingBuffer),
524
- logarithmicDepthBuffer: k(t.logarithmicDepthBuffer),
525
- failIfMajorPerformanceCaveat: k(t.failIfMajorPerformanceCaveat)
526
- })), a = $(new he(i.value));
696
+ const i = J(() => ({
697
+ alpha: x(t.alpha) ?? !0,
698
+ depth: x(t.depth),
699
+ canvas: rn(e),
700
+ context: x(t.context),
701
+ stencil: x(t.stencil),
702
+ antialias: x(t.antialias) ?? !0,
703
+ precision: x(t.precision),
704
+ powerPreference: x(t.powerPreference),
705
+ premultipliedAlpha: x(t.premultipliedAlpha),
706
+ preserveDrawingBuffer: x(t.preserveDrawingBuffer),
707
+ logarithmicDepthBuffer: x(t.logarithmicDepthBuffer),
708
+ failIfMajorPerformanceCaveat: x(t.failIfMajorPerformanceCaveat)
709
+ })), a = $(new ge(i.value));
527
710
  function c() {
528
711
  t.renderMode === "on-demand" && s();
529
712
  }
530
- ce(i, () => {
531
- a.value.dispose(), a.value = new he(i.value), c();
532
- }), ce([n.width, n.height], () => {
713
+ ae(i, () => {
714
+ a.value.dispose(), a.value = new ge(i.value), c();
715
+ }), ae([n.width, n.height], () => {
533
716
  a.value.setSize(n.width.value, n.height.value), c();
534
717
  }, {
535
718
  immediate: !0
536
- }), ce(() => t.clearColor, c);
537
- const { pixelRatio: o } = en(), { logError: u } = Y(), d = (() => {
538
- const h = new he(), b = {
719
+ }), ae(() => t.clearColor, c);
720
+ const { pixelRatio: o } = on(), { logError: f } = V(), u = (() => {
721
+ const h = new ge(), g = {
539
722
  shadowMap: {
540
723
  enabled: h.shadowMap.enabled,
541
724
  type: h.shadowMap.type
@@ -544,27 +727,27 @@ function ar({
544
727
  toneMappingExposure: h.toneMappingExposure,
545
728
  outputColorSpace: h.outputColorSpace
546
729
  };
547
- return h.dispose(), b;
548
- })(), g = k(t.renderMode);
549
- return g === "on-demand" && s(), g === "manual" && setTimeout(() => {
730
+ return h.dispose(), g;
731
+ })(), v = x(t.renderMode);
732
+ return v === "on-demand" && s(), v === "manual" && setTimeout(() => {
550
733
  l();
551
- }, 100), Te(() => {
552
- const h = k(t.preset);
553
- h && (h in ae || u(`Renderer Preset must be one of these: ${Object.keys(ae).join(", ")}`), ut(a.value, ae[h])), or(a.value, o.value, k(t.dpr)), g === "always" && (r.frames.value = Math.max(1, r.frames.value));
554
- const b = (M, P) => {
555
- const C = k(M), E = () => {
734
+ }, 100), xe(() => {
735
+ const h = x(t.preset);
736
+ h && (h in se || f(`Renderer Preset must be one of these: ${Object.keys(se).join(", ")}`), pt(a.value, se[h])), or(a.value, o.value, x(t.dpr)), v === "always" && (r.frames.value = Math.max(1, r.frames.value));
737
+ const g = (C, E) => {
738
+ const T = x(C), b = () => {
556
739
  if (h)
557
- return Ve(ae[h], P);
740
+ return Ve(se[h], E);
558
741
  };
559
- if (C !== void 0)
560
- return C;
561
- const S = E();
562
- return S !== void 0 ? S : Ve(d, P);
563
- }, y = (M, P) => qn(a.value, P, b(M, P));
564
- y(t.shadows, "shadowMap.enabled"), y(t.toneMapping ?? st, "toneMapping"), y(t.shadowMapType, "shadowMap.type"), ir < 150 && y(!t.useLegacyLights, "physicallyCorrectLights"), y(t.outputColorSpace, "outputColorSpace"), y(t.toneMappingExposure, "toneMappingExposure");
565
- const f = b(t.clearColor, "clearColor");
566
- f && a.value.setClearColor(
567
- f ? Fn(f) : new Z(0)
742
+ if (T !== void 0)
743
+ return T;
744
+ const P = b();
745
+ return P !== void 0 ? P : Ve(u, E);
746
+ }, p = (C, E) => qn(a.value, E, g(C, E));
747
+ p(t.shadows, "shadowMap.enabled"), p(t.toneMapping ?? ct, "toneMapping"), p(t.shadowMapType, "shadowMap.type"), mr < 150 && p(!t.useLegacyLights, "physicallyCorrectLights"), p(t.outputColorSpace, "outputColorSpace"), p(t.toneMappingExposure, "toneMappingExposure");
748
+ const _ = g(t.clearColor, "clearColor");
749
+ _ && a.value.setClearColor(
750
+ _ ? hr(_) : new Z(0)
568
751
  // default clear color is not easily/efficiently retrievable from three
569
752
  );
570
753
  }), K(() => {
@@ -573,408 +756,208 @@ function ar({
573
756
  renderer: a
574
757
  };
575
758
  }
576
- function lr(e) {
577
- const t = { nodes: {}, materials: {} };
578
- return e && e.traverse((n) => {
579
- n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
580
- }), t;
581
- }
582
- async function Nr(e, t, n, r, s) {
583
- const { logError: l } = Y(), i = new e();
584
- return s && s(i), n && n(i), await new Promise((a, c) => {
585
- i.load(
586
- t,
587
- (o) => {
588
- const u = o;
589
- u.scene && Object.assign(u, lr(u.scene)), a(u);
590
- },
591
- r,
592
- (o) => {
593
- l("[useLoader] - Failed to load resource", o), c(o);
594
- }
595
- );
596
- });
597
- }
598
- async function zr(e, t) {
599
- const n = new Ut(t), r = (s) => new Promise((l, i) => {
600
- n.load(
601
- s,
602
- (a) => l(a),
603
- () => null,
604
- () => {
605
- i(new Error("[useTextures] - Failed to load texture"));
606
- }
607
- );
608
- });
609
- if (Kn(e)) {
610
- const s = await Promise.all(e.map((l) => r(l)));
611
- return e.length > 1 ? s : s[0];
612
- } else {
613
- const {
614
- map: s,
615
- displacementMap: l,
616
- normalMap: i,
617
- roughnessMap: a,
618
- metalnessMap: c,
619
- aoMap: o,
620
- alphaMap: u,
621
- matcap: v
622
- } = e;
623
- return {
624
- map: s ? await r(s) : null,
625
- displacementMap: l ? await r(l) : null,
626
- normalMap: i ? await r(i) : null,
627
- roughnessMap: a ? await r(a) : null,
628
- metalnessMap: c ? await r(c) : null,
629
- aoMap: o ? await r(o) : null,
630
- alphaMap: u ? await r(u) : null,
631
- matcap: v ? await r(v) : null
632
- };
633
- }
759
+ function vr(e, t, n = 10) {
760
+ const r = x(e) ? sn() : an(J(() => x(t).parentElement)), s = we(Ne(r.width, n)), l = we(Ne(r.height, n)), i = J(() => s.value / l.value);
761
+ return {
762
+ height: l,
763
+ width: s,
764
+ aspectRatio: i
765
+ };
634
766
  }
635
- const cr = (e, t) => {
636
- const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = tn({ target: n });
767
+ const yr = (e, t) => {
768
+ const n = J(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = ln({ target: n });
637
769
  let i = 0;
638
- const { width: a, height: c, top: o, left: u } = nn(n), v = ({ x: m, y: T }) => {
770
+ const { width: a, height: c, top: o, left: f } = cn(n), y = ({ x: m, y: S }) => {
639
771
  if (n.value)
640
772
  return {
641
- x: (m - u.value) / a.value * 2 - 1,
642
- y: -((T - o.value) / c.value) * 2 + 1
773
+ x: (m - f.value) / a.value * 2 - 1,
774
+ y: -((S - o.value) / c.value) * 2 + 1
643
775
  };
644
- }, d = ({ x: m, y: T }) => {
776
+ }, u = ({ x: m, y: S }) => {
645
777
  if (t.camera.value)
646
- return t.raycaster.value.setFromCamera(new ge(m, T), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
647
- }, g = (m) => {
648
- const T = v({
778
+ return t.raycaster.value.setFromCamera(new ve(m, S), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
779
+ }, v = (m) => {
780
+ const S = y({
649
781
  x: (m == null ? void 0 : m.clientX) ?? s.value,
650
782
  y: (m == null ? void 0 : m.clientY) ?? l.value
651
783
  });
652
- return T ? d(T) || [] : [];
653
- }, h = j(), b = j(), y = j(), f = j(), M = j(), P = j(), C = j(), E = j();
654
- function S(m) {
655
- const T = {};
656
- for (const F in m)
657
- typeof F != "function" && (T[F] = m[F]);
658
- return T;
784
+ return S ? u(S) || [] : [];
785
+ }, h = D(), g = D(), p = D(), _ = D(), C = D(), E = D(), T = D(), b = D();
786
+ function P(m) {
787
+ const S = {};
788
+ for (const U in m)
789
+ typeof U != "function" && (S[U] = m[U]);
790
+ return S;
659
791
  }
660
- const _ = (m, T) => {
661
- var Oe, De, je;
662
- const F = S(T), re = new Se(T == null ? void 0 : T.clientX, T == null ? void 0 : T.clientY, 0).unproject((Oe = t.camera) == null ? void 0 : Oe.value);
792
+ const M = (m, S) => {
793
+ var Be, Ie, $e;
794
+ const U = P(S), ne = new Ae(S == null ? void 0 : S.clientX, S == null ? void 0 : S.clientY, 0).unproject((Be = t.camera) == null ? void 0 : Be.value);
663
795
  m.trigger({
664
- ...F,
796
+ ...U,
665
797
  intersections: r.value,
666
798
  // The unprojectedPoint is wrong, math needs to be fixed
667
- unprojectedPoint: re,
668
- ray: (De = t.raycaster) == null ? void 0 : De.value.ray,
669
- camera: (je = t.camera) == null ? void 0 : je.value,
670
- sourceEvent: T,
799
+ unprojectedPoint: ne,
800
+ ray: (Ie = t.raycaster) == null ? void 0 : Ie.value.ray,
801
+ camera: ($e = t.camera) == null ? void 0 : $e.value,
802
+ sourceEvent: S,
671
803
  delta: i,
672
804
  stopPropagating: !1
673
805
  });
674
806
  };
675
807
  let A;
676
- const L = (m) => {
677
- g(m), _(y, m), A = m;
678
- }, p = () => {
679
- A && L(A);
808
+ const d = (m) => {
809
+ v(m), M(p, m), A = m;
810
+ }, w = () => {
811
+ A && d(A);
680
812
  };
681
- let w, x, D;
682
- const O = (m) => {
683
- var T;
684
- w = (T = r.value[0]) == null ? void 0 : T.object, i = 0, x = new ge(
813
+ let k, L, O;
814
+ const j = (m) => {
815
+ var S;
816
+ k = (S = r.value[0]) == null ? void 0 : S.object, i = 0, L = new ve(
685
817
  (m == null ? void 0 : m.clientX) ?? s.value,
686
818
  (m == null ? void 0 : m.clientY) ?? l.value
687
- ), _(M, m);
819
+ ), M(C, m);
688
820
  };
689
- let B, R = !1;
690
- const ne = (m) => {
691
- var T, F, re;
692
- m instanceof PointerEvent && (r.value.length === 0 && _(P, m), w === ((T = r.value[0]) == null ? void 0 : T.object) && (D = new ge(
821
+ let R, Y = !1;
822
+ const Oe = (m) => {
823
+ var S, U, ne;
824
+ m instanceof PointerEvent && (r.value.length === 0 && M(E, m), k === ((S = r.value[0]) == null ? void 0 : S.object) && (O = new ve(
693
825
  (m == null ? void 0 : m.clientX) ?? s.value,
694
826
  (m == null ? void 0 : m.clientY) ?? l.value
695
- ), i = x == null ? void 0 : x.distanceTo(D), m.button === 0 ? (_(h, m), B === ((F = r.value[0]) == null ? void 0 : F.object) ? R = !0 : (B = (re = r.value[0]) == null ? void 0 : re.object, R = !1)) : m.button === 2 && _(C, m)), _(f, m));
696
- }, ke = (m) => {
697
- R && (_(b, m), B = void 0, R = !1);
698
- }, Le = (m) => _(y, m), Re = (m) => _(E, m);
699
- return n.value.addEventListener("pointerup", ne), n.value.addEventListener("pointerdown", O), n.value.addEventListener("pointermove", L), n.value.addEventListener("pointerleave", Le), n.value.addEventListener("dblclick", ke), n.value.addEventListener("wheel", Re), K(() => {
700
- n != null && n.value && (n.value.removeEventListener("pointerup", ne), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove", L), n.value.removeEventListener("pointerleave", Le), n.value.removeEventListener("dblclick", ke), n.value.removeEventListener("wheel", Re));
827
+ ), i = L == null ? void 0 : L.distanceTo(O), m.button === 0 ? (M(h, m), R === ((U = r.value[0]) == null ? void 0 : U.object) ? Y = !0 : (R = (ne = r.value[0]) == null ? void 0 : ne.object, Y = !1)) : m.button === 2 && M(T, m)), M(_, m));
828
+ }, Re = (m) => {
829
+ Y && (M(g, m), R = void 0, Y = !1);
830
+ }, De = (m) => M(p, m), je = (m) => M(b, m);
831
+ return n.value.addEventListener("pointerup", Oe), n.value.addEventListener("pointerdown", j), n.value.addEventListener("pointermove", d), n.value.addEventListener("pointerleave", De), n.value.addEventListener("dblclick", Re), n.value.addEventListener("wheel", je), K(() => {
832
+ n != null && n.value && (n.value.removeEventListener("pointerup", Oe), n.value.removeEventListener("pointerdown", j), n.value.removeEventListener("pointermove", d), n.value.removeEventListener("pointerleave", De), n.value.removeEventListener("dblclick", Re), n.value.removeEventListener("wheel", je));
701
833
  }), {
702
834
  intersects: r,
703
835
  onClick: (m) => h.on(m).off,
704
- onDblClick: (m) => b.on(m).off,
705
- onContextMenu: (m) => C.on(m).off,
706
- onPointerMove: (m) => y.on(m).off,
707
- onPointerUp: (m) => f.on(m).off,
708
- onPointerDown: (m) => M.on(m).off,
709
- onPointerMissed: (m) => P.on(m).off,
710
- onWheel: (m) => E.on(m).off,
711
- forceUpdate: p
836
+ onDblClick: (m) => g.on(m).off,
837
+ onContextMenu: (m) => T.on(m).off,
838
+ onPointerMove: (m) => p.on(m).off,
839
+ onPointerUp: (m) => _.on(m).off,
840
+ onPointerDown: (m) => C.on(m).off,
841
+ onPointerMissed: (m) => E.on(m).off,
842
+ onWheel: (m) => b.on(m).off,
843
+ forceUpdate: w
712
844
  };
713
845
  };
714
- function Gr() {
715
- const { logWarning: e } = Y();
716
- function t(l, i, a) {
717
- let c = null;
718
- return l.traverse((o) => {
719
- o[i] === a && (c = o);
720
- }), c || e(`Child with ${i} '${a}' not found.`), c;
721
- }
722
- function n(l, i, a) {
723
- const c = [];
724
- return l.traverse((o) => {
725
- o[i].includes(a) && c.push(o);
726
- }), c.length || e(`Children with ${i} '${a}' not found.`), c;
727
- }
728
- function r(l, i) {
729
- return t(l, "name", i);
730
- }
731
- function s(l, i) {
732
- return n(l, "name", i);
733
- }
734
- return {
735
- seek: t,
736
- seekByName: r,
737
- seekAll: n,
738
- seekAllByName: s
739
- };
740
- }
741
- function xe(e) {
742
- let t = 0;
743
- return e.traverse((n) => {
744
- if (n.isMesh && n.geometry && n.type !== "HightlightMesh") {
745
- const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, i = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = s + l + i + a;
746
- t += c;
747
- }
748
- }), t;
749
- }
750
- function ur(e) {
751
- return (e / 1024).toFixed(2);
752
- }
753
- const Me = H({}), Pe = (e) => Object.assign(Me.value, e);
754
- function fr(e, t, n) {
755
- var L;
846
+ function _e(e, t) {
847
+ if (Array.isArray(e))
848
+ for (const n of e)
849
+ n(t);
850
+ typeof e == "function" && e(t);
851
+ }
852
+ function _r(e, t, n) {
853
+ var A;
756
854
  const r = $(), s = $();
757
855
  e && (r.value = e), t && (s.value = t);
758
- const l = (p) => {
856
+ const l = (d) => {
759
857
  var w;
760
- return ((w = p.__tres) == null ? void 0 : w.eventCount) > 0;
761
- }, i = (p) => {
858
+ return ((w = d.__tres) == null ? void 0 : w.eventCount) > 0;
859
+ }, i = (d) => {
762
860
  var w;
763
- return ((w = p.children) == null ? void 0 : w.some((x) => i(x))) || l(p);
764
- }, a = $(((L = r.value) == null ? void 0 : L.children).filter(i) || []);
765
- function c(p, w) {
766
- if (Array.isArray(p))
767
- for (const x of p)
768
- x(w);
769
- typeof p == "function" && p(w);
770
- }
771
- function o(p, w) {
772
- const x = [], D = () => w.stopPropagating = !0;
773
- w.stopPropagation = D;
861
+ return ((w = d.children) == null ? void 0 : w.some((k) => i(k))) || l(d);
862
+ }, a = $(((A = r.value) == null ? void 0 : A.children).filter(i) || []);
863
+ function c(d, w) {
864
+ const k = [], L = () => w.stopPropagating = !0;
865
+ w.stopPropagation = L;
774
866
  for (const O of w == null ? void 0 : w.intersections) {
775
867
  if (w.stopPropagating)
776
868
  return;
777
869
  w = { ...w, ...O };
778
- const { object: B } = O;
779
- w.eventObject = B, c(B[p], w), x.push(B);
780
- let R = B.parent;
781
- for (; R !== null && !w.stopPropagating && !x.includes(R); )
782
- w.eventObject = R, c(R[p], w), x.push(R), R = R.parent;
783
- const ne = Vn(p.slice(2));
784
- n(ne, { intersection: O, event: w });
870
+ const { object: j } = O;
871
+ w.eventObject = j, _e(j[d], w), k.push(j);
872
+ let R = j.parent;
873
+ for (; R !== null && !w.stopPropagating && !k.includes(R); )
874
+ w.eventObject = R, _e(R[d], w), k.push(R), R = R.parent;
875
+ const Y = Vn(d.slice(2));
876
+ n(Y, { intersection: O, event: w });
785
877
  }
786
878
  }
787
879
  const {
788
- onClick: u,
789
- onDblClick: v,
790
- onContextMenu: d,
791
- onPointerMove: g,
792
- onPointerDown: h,
793
- onPointerUp: b,
794
- onPointerMissed: y,
795
- onWheel: f,
796
- forceUpdate: M
797
- } = cr(a, t);
798
- b((p) => o("onPointerUp", p)), h((p) => o("onPointerDown", p)), u((p) => o("onClick", p)), v((p) => o("onDoubleClick", p)), d((p) => o("onContextMenu", p)), f((p) => o("onWheel", p));
799
- let P = [];
800
- g((p) => {
801
- const w = p.intersections.map(({ object: D }) => D), x = p.intersections;
802
- P.forEach(({ object: D }) => {
803
- w.includes(D) || (p.intersections = P, o("onPointerLeave", p), o("onPointerOut", p));
804
- }), p.intersections = x, p.intersections.forEach(({ object: D }) => {
805
- P.includes(D) || (o("onPointerEnter", p), o("onPointerOver", p));
806
- }), o("onPointerMove", p), P = p.intersections;
880
+ onClick: o,
881
+ onDblClick: f,
882
+ onContextMenu: y,
883
+ onPointerMove: u,
884
+ onPointerDown: v,
885
+ onPointerUp: h,
886
+ onPointerMissed: g,
887
+ onWheel: p,
888
+ forceUpdate: _
889
+ } = yr(a, t);
890
+ h((d) => c("onPointerUp", d)), v((d) => c("onPointerDown", d)), o((d) => c("onClick", d)), f((d) => c("onDoubleClick", d)), y((d) => c("onContextMenu", d)), p((d) => c("onWheel", d));
891
+ let C = [];
892
+ u((d) => {
893
+ const w = d.intersections.map(({ object: L }) => L), k = d.intersections;
894
+ C.forEach(({ object: L }) => {
895
+ w.includes(L) || (d.intersections = C, c("onPointerLeave", d), c("onPointerOut", d));
896
+ }), d.intersections = k, d.intersections.forEach(({ object: L }) => {
897
+ C.includes(L) || (c("onPointerEnter", d), c("onPointerOver", d));
898
+ }), c("onPointerMove", d), C = d.intersections;
807
899
  });
808
- const C = [];
809
- y((p) => {
810
- const w = () => p.stopPropagating = !0;
811
- p.stopPropagation = w, C.forEach((x) => {
812
- p.stopPropagating || (p.eventObject = x, c(x.onPointerMissed, p));
813
- }), n("pointer-missed", { event: p });
900
+ const E = [];
901
+ g((d) => {
902
+ const w = () => d.stopPropagating = !0;
903
+ d.stopPropagation = w, E.forEach((k) => {
904
+ d.stopPropagating || (d.eventObject = k, _e(k.onPointerMissed, d));
905
+ }), n("pointer-missed", { event: d });
814
906
  });
815
- function E(p) {
816
- oe(p) && N(p) && a.value.push(p);
907
+ function T(d) {
908
+ re(d) && N(d) && a.value.push(d);
817
909
  }
818
- function S(p) {
819
- if (oe(p) && N(p)) {
820
- const w = a.value.indexOf(p);
910
+ function b(d) {
911
+ if (re(d) && N(d)) {
912
+ const w = a.value.indexOf(d);
821
913
  w > -1 && a.value.splice(w, 1);
822
914
  }
823
915
  }
824
- function _(p) {
825
- oe(p) && N(p) && p.onPointerMissed && C.push(p);
916
+ function P(d) {
917
+ re(d) && N(d) && d.onPointerMissed && E.push(d);
826
918
  }
827
- function A(p) {
828
- if (oe(p) && N(p)) {
829
- const w = C.indexOf(p);
830
- w > -1 && C.splice(w, 1);
919
+ function M(d) {
920
+ if (re(d) && N(d)) {
921
+ const w = E.indexOf(d);
922
+ w > -1 && E.splice(w, 1);
831
923
  }
832
924
  }
833
925
  return t.eventManager = {
834
- forceUpdate: M,
835
- registerObject: E,
836
- deregisterObject: S,
837
- registerPointerMissedObject: _,
838
- deregisterPointerMissedObject: A
926
+ forceUpdate: _,
927
+ registerObject: T,
928
+ deregisterObject: b,
929
+ registerPointerMissedObject: P,
930
+ deregisterPointerMissedObject: M
839
931
  }, {
840
- forceUpdate: M,
841
- registerObject: E,
842
- deregisterObject: S,
843
- registerPointerMissedObject: _,
844
- deregisterPointerMissedObject: A
845
- };
846
- }
847
- function dr(e, t, n = 10) {
848
- const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)), l = ye(Fe(r.height, n)), i = V(() => s.value / l.value);
849
- return {
850
- height: l,
851
- width: s,
852
- aspectRatio: i
853
- };
854
- }
855
- function ve() {
856
- const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
857
- let n = 0, r = !1;
858
- const s = () => {
859
- const o = Array.from(e.entries()).sort((u, v) => {
860
- const d = u[1].priority - v[1].priority;
861
- return d === 0 ? u[1].addI - v[1].addI : d;
862
- });
863
- t.clear(), o.forEach((u) => t.add(u[0]));
864
- }, l = (o) => {
865
- e.delete(o), t.delete(o);
932
+ forceUpdate: _,
933
+ registerObject: T,
934
+ deregisterObject: b,
935
+ registerPointerMissedObject: P,
936
+ deregisterPointerMissedObject: M
866
937
  };
867
- return { on: (o, u = 0) => {
868
- e.set(o, { priority: u, addI: n++ });
869
- const v = () => l(o);
870
- return sn(v), r = !0, {
871
- off: v
872
- };
873
- }, off: l, trigger: (...o) => {
874
- r && (s(), r = !1), t.forEach((u) => u(...o));
875
- }, dispose: () => {
876
- e.clear(), t.clear();
877
- }, get count() {
878
- return e.size;
879
- } };
880
938
  }
881
- function pr() {
882
- let e = !0, t = !0, n = !1;
883
- const r = new tt(!1), s = H(r.running), l = H(!1);
884
- let i;
885
- const a = rt.generateUUID();
886
- let c = null;
887
- const o = ve(), u = ve(), v = ve();
888
- S();
889
- let d = {};
890
- function g(_) {
891
- d = _;
892
- }
893
- function h(_, A, L = 0) {
894
- switch (A) {
895
- case "before":
896
- return o.on(_, L);
897
- case "render":
898
- return c || (c = _), u.dispose(), u.on(_);
899
- case "after":
900
- return v.on(_, L);
901
- }
902
- }
903
- function b() {
904
- t && (t = !1, S(), E());
905
- }
906
- function y() {
907
- t = !0, S(), cancelAnimationFrame(i);
908
- }
909
- function f() {
910
- n = !1, S();
911
- }
912
- function M() {
913
- n = !0, S();
914
- }
915
- function P() {
916
- l.value = !0;
917
- }
918
- function C() {
919
- l.value = !1;
920
- }
921
- function E() {
922
- if (!e) {
923
- i = requestAnimationFrame(E);
924
- return;
925
- }
926
- const _ = r.getDelta(), A = r.getElapsedTime(), L = {
927
- camera: J(d.camera),
928
- scene: J(d.scene),
929
- renderer: J(d.renderer),
930
- raycaster: J(d.raycaster),
931
- controls: J(d.controls),
932
- invalidate: d.invalidate,
933
- advance: d.advance
934
- }, p = { delta: _, elapsed: A, clock: r, ...L };
935
- s.value && o.trigger(p), l.value || (u.count ? u.trigger(p) : c && c(p)), s.value && v.trigger(p), i = requestAnimationFrame(E);
936
- }
937
- function S() {
938
- const _ = !t && !n;
939
- r.running !== _ && (r.running ? r.stop() : r.start()), s.value = r.running;
940
- }
941
- return {
942
- loopId: a,
943
- register: (_, A, L) => h(_, A, L),
944
- start: b,
945
- stop: y,
946
- pause: M,
947
- resume: f,
948
- pauseRender: P,
949
- resumeRender: C,
950
- isRenderPaused: l,
951
- isActive: s,
952
- setContext: g,
953
- setReady: (_) => e = _
954
- };
955
- }
956
- function mr(e, t, n = 100) {
939
+ function wr(e, t, n = 100) {
957
940
  n = n <= 0 ? 100 : n;
958
- const r = j(), s = /* @__PURE__ */ new Set();
941
+ const r = D(), s = /* @__PURE__ */ new Set();
959
942
  let l = !1, i = !1, a = null;
960
943
  function c() {
961
- a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((d) => d()), s.clear(), l = !0) : !i && !l && (a = setTimeout(c, n));
944
+ a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((u) => u()), s.clear(), l = !0) : !i && !l && (a = setTimeout(c, n));
962
945
  }
963
946
  function o() {
964
947
  i = !0, a && clearTimeout(a);
965
948
  }
966
949
  c();
967
- const u = (d, ...g) => {
968
- d(...g);
950
+ const f = (u, ...v) => {
951
+ u(...v);
969
952
  };
970
953
  return {
971
- on: (d) => {
954
+ on: (u) => {
972
955
  if (l)
973
- return u(d, t), { off: () => {
956
+ return f(u, t), { off: () => {
974
957
  } };
975
958
  {
976
- const g = r.on(d);
977
- return s.add(g.off), r.on(d);
959
+ const v = r.on(u);
960
+ return s.add(v.off), r.on(u);
978
961
  }
979
962
  },
980
963
  off: r.off,
@@ -982,11 +965,11 @@ function mr(e, t, n = 100) {
982
965
  cancel: o
983
966
  };
984
967
  }
985
- const te = /* @__PURE__ */ new WeakMap();
986
- function gt(e) {
987
- if (e = e || pe(), te.has(e))
988
- return te.get(e);
989
- const t = 100, n = Date.now(), l = mr(() => {
968
+ const ee = /* @__PURE__ */ new WeakMap();
969
+ function yt(e) {
970
+ if (e = e || me(), ee.has(e))
971
+ return ee.get(e);
972
+ const t = 100, n = Date.now(), l = wr(() => {
990
973
  if (Date.now() - n >= t)
991
974
  return !0;
992
975
  {
@@ -994,58 +977,56 @@ function gt(e) {
994
977
  return !!(i && a.width > 0 && a.height > 0);
995
978
  }
996
979
  }, e);
997
- return te.set(e, l), l;
980
+ return ee.set(e, l), l;
998
981
  }
999
- function Vr(e) {
1000
- const t = pe();
982
+ function Xr(e) {
983
+ const t = me();
1001
984
  if (t)
1002
- return te.has(t) ? te.get(t).on(e) : gt(t).on(e);
985
+ return ee.has(t) ? ee.get(t).on(e) : yt(t).on(e);
1003
986
  }
1004
- function hr({
987
+ function br({
1005
988
  scene: e,
1006
989
  canvas: t,
1007
990
  windowSize: n,
1008
- disableRender: r,
1009
- rendererOptions: s,
1010
- emit: l
991
+ rendererOptions: r,
992
+ emit: s
1011
993
  }) {
1012
- const i = $(e), a = dr(n, t), {
1013
- camera: c,
1014
- cameras: o,
1015
- registerCamera: u,
1016
- deregisterCamera: v,
1017
- setCameraActive: d
1018
- } = In({ sizes: a, scene: e }), g = {
1019
- mode: H(s.renderMode || "always"),
1020
- priority: H(0),
1021
- frames: H(0),
994
+ const l = $(e), i = vr(n, t), {
995
+ camera: a,
996
+ cameras: c,
997
+ registerCamera: o,
998
+ deregisterCamera: f,
999
+ setCameraActive: y
1000
+ } = ar({ sizes: i, scene: e }), u = {
1001
+ mode: I(r.renderMode || "always"),
1002
+ priority: I(0),
1003
+ frames: I(0),
1022
1004
  maxFrames: 60,
1023
- canBeInvalidated: V(() => g.mode.value === "on-demand" && g.frames.value === 0)
1005
+ canBeInvalidated: J(() => u.mode.value === "on-demand" && u.frames.value === 0)
1024
1006
  };
1025
- function h(O = 1) {
1026
- s.renderMode === "on-demand" && (g.frames.value = Math.min(g.maxFrames, g.frames.value + O));
1007
+ function v(O = 1) {
1008
+ r.renderMode === "on-demand" && (u.frames.value = Math.min(u.maxFrames, u.frames.value + O));
1027
1009
  }
1028
- function b() {
1029
- s.renderMode === "manual" && (g.frames.value = 1);
1010
+ function h() {
1011
+ r.renderMode === "manual" && (u.frames.value = 1);
1030
1012
  }
1031
- const { renderer: y } = ar(
1013
+ const { renderer: g } = gr(
1032
1014
  {
1033
1015
  scene: e,
1034
1016
  canvas: t,
1035
- options: s,
1036
- emit: l,
1017
+ options: r,
1018
+ emit: s,
1037
1019
  // TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
1038
- contextParts: { sizes: a, camera: c, render: g, invalidate: h, advance: b },
1039
- disableRender: r
1020
+ contextParts: { sizes: i, camera: a, render: u, invalidate: v, advance: h }
1040
1021
  }
1041
- ), f = {
1042
- sizes: a,
1043
- scene: i,
1044
- camera: c,
1045
- cameras: ye(o),
1046
- renderer: y,
1047
- raycaster: $(new Ft()),
1048
- controls: H(null),
1022
+ ), p = {
1023
+ sizes: i,
1024
+ scene: l,
1025
+ camera: a,
1026
+ cameras: we(c),
1027
+ renderer: g,
1028
+ raycaster: $(new zt()),
1029
+ controls: I(null),
1049
1030
  perf: {
1050
1031
  maxFrames: 160,
1051
1032
  fps: {
@@ -1058,47 +1039,47 @@ function hr({
1058
1039
  accumulator: []
1059
1040
  }
1060
1041
  },
1061
- render: g,
1062
- advance: b,
1063
- extend: Pe,
1064
- invalidate: h,
1065
- registerCamera: u,
1066
- setCameraActive: d,
1067
- deregisterCamera: v,
1042
+ render: u,
1043
+ advance: h,
1044
+ extend: Ee,
1045
+ invalidate: v,
1046
+ registerCamera: o,
1047
+ setCameraActive: y,
1048
+ deregisterCamera: f,
1068
1049
  loop: pr()
1069
1050
  };
1070
- _e("useTres", f), f.scene.value.__tres = {
1071
- root: f
1072
- }, f.loop.register(() => {
1073
- c.value && g.frames.value > 0 && (y.value.render(e, c.value), l("render", f.renderer.value)), g.priority.value = 0, g.mode.value === "always" ? g.frames.value = 1 : g.frames.value = Math.max(0, g.frames.value - 1);
1051
+ le("useTres", p), p.scene.value.__tres = {
1052
+ root: p
1053
+ }, p.loop.register(() => {
1054
+ a.value && u.frames.value > 0 && (g.value.render(e, a.value), s("render", p.renderer.value)), u.priority.value = 0, u.mode.value === "always" ? u.frames.value = 1 : u.frames.value = Math.max(0, u.frames.value - 1);
1074
1055
  }, "render");
1075
- const { on: M, cancel: P } = gt(f);
1076
- f.loop.setReady(!1), f.loop.start(), M(() => {
1077
- l("ready", f), f.loop.setReady(!0), fr(e, f, l);
1056
+ const { on: _, cancel: C } = yt(p);
1057
+ p.loop.setReady(!1), p.loop.start(), _(() => {
1058
+ s("ready", p), p.loop.setReady(!0), _r(e, p, s);
1078
1059
  }), K(() => {
1079
- P(), f.loop.stop();
1060
+ C(), p.loop.stop();
1080
1061
  });
1081
- const C = 100, E = an({ every: C }), { isSupported: S, memory: _ } = ln({ interval: C }), A = 160;
1082
- let L = performance.now();
1083
- const p = ({ timestamp: O }) => {
1084
- f.scene.value && (f.perf.memory.allocatedMem = xe(f.scene.value)), O - L >= C && (L = O, f.perf.fps.accumulator.push(E.value), f.perf.fps.accumulator.length > A && f.perf.fps.accumulator.shift(), f.perf.fps.value = E.value, S.value && _.value && (f.perf.memory.accumulator.push(_.value.usedJSHeapSize / 1024 / 1024), f.perf.memory.accumulator.length > A && f.perf.memory.accumulator.shift(), f.perf.memory.currentMem = f.perf.memory.accumulator.reduce((B, R) => B + R, 0) / f.perf.memory.accumulator.length));
1062
+ const E = 100, T = un({ every: E }), { isSupported: b, memory: P } = fn({ interval: E }), M = 160;
1063
+ let A = performance.now();
1064
+ const d = ({ timestamp: O }) => {
1065
+ p.scene.value && (p.perf.memory.allocatedMem = ke(p.scene.value)), O - A >= E && (A = O, p.perf.fps.accumulator.push(T.value), p.perf.fps.accumulator.length > M && p.perf.fps.accumulator.shift(), p.perf.fps.value = T.value, b.value && P.value && (p.perf.memory.accumulator.push(P.value.usedJSHeapSize / 1024 / 1024), p.perf.memory.accumulator.length > M && p.perf.memory.accumulator.shift(), p.perf.memory.currentMem = p.perf.memory.accumulator.reduce((j, R) => j + R, 0) / p.perf.memory.accumulator.length));
1085
1066
  };
1086
1067
  let w = 0;
1087
- const x = 1, { pause: D } = it(({ delta: O }) => {
1088
- window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= x && (window.__TRES__DEVTOOLS__.cb(f), w = 0));
1068
+ const k = 1, { pause: L } = ut(({ delta: O }) => {
1069
+ window.__TRES__DEVTOOLS__ && (d({ timestamp: performance.now() }), w += O, w >= k && (window.__TRES__DEVTOOLS__.cb(p), w = 0));
1089
1070
  }, { immediate: !0 });
1090
1071
  return K(() => {
1091
- D();
1092
- }), f;
1072
+ L();
1073
+ }), p;
1093
1074
  }
1094
- function pe() {
1095
- const e = Mt("useTres");
1075
+ function me() {
1076
+ const e = St("useTres");
1096
1077
  if (!e)
1097
1078
  throw new Error("useTresContext must be used together with useTresContextProvider");
1098
1079
  return e;
1099
1080
  }
1100
- const Yr = pe;
1101
- function qr() {
1081
+ const Zr = me;
1082
+ function eo() {
1102
1083
  const {
1103
1084
  camera: e,
1104
1085
  scene: t,
@@ -1108,7 +1089,7 @@ function qr() {
1108
1089
  controls: l,
1109
1090
  invalidate: i,
1110
1091
  advance: a
1111
- } = pe();
1092
+ } = me();
1112
1093
  r.setContext({
1113
1094
  camera: e,
1114
1095
  scene: t,
@@ -1118,14 +1099,14 @@ function qr() {
1118
1099
  invalidate: i,
1119
1100
  advance: a
1120
1101
  });
1121
- function c(v, d = 0) {
1122
- return r.register(v, "before", d);
1102
+ function c(y, u = 0) {
1103
+ return r.register(y, "before", u);
1123
1104
  }
1124
- function o(v) {
1125
- return r.register(v, "render");
1105
+ function o(y) {
1106
+ return r.register(y, "render");
1126
1107
  }
1127
- function u(v, d = 0) {
1128
- return r.register(v, "after", d);
1108
+ function f(y, u = 0) {
1109
+ return r.register(y, "after", u);
1129
1110
  }
1130
1111
  return {
1131
1112
  pause: r.pause,
@@ -1135,10 +1116,57 @@ function qr() {
1135
1116
  isActive: r.isActive,
1136
1117
  onBeforeRender: c,
1137
1118
  render: o,
1138
- onAfterRender: u
1119
+ onAfterRender: f
1120
+ };
1121
+ }
1122
+ const _t = D(), wt = D(), Le = D(), te = new lt();
1123
+ let ce = 0, ue = 0;
1124
+ const { pause: Mr, resume: Ke, isActive: Pr } = ut(
1125
+ () => {
1126
+ _t.trigger({ delta: ce, elapsed: ue, clock: te }), wt.trigger({ delta: ce, elapsed: ue, clock: te }), Le.trigger({ delta: ce, elapsed: ue, clock: te });
1127
+ },
1128
+ { immediate: !1 }
1129
+ );
1130
+ Le.on(() => {
1131
+ ce = te.getDelta(), ue = te.getElapsedTime();
1132
+ });
1133
+ let Qe = !1;
1134
+ const to = () => (Qe || (Qe = !0, Ke()), {
1135
+ onBeforeLoop: _t.on,
1136
+ onLoop: wt.on,
1137
+ onAfterLoop: Le.on,
1138
+ pause: Mr,
1139
+ resume: Ke,
1140
+ isActive: Pr
1141
+ });
1142
+ function no() {
1143
+ const { logWarning: e } = V();
1144
+ function t(l, i, a) {
1145
+ let c = null;
1146
+ return l.traverse((o) => {
1147
+ o[i] === a && (c = o);
1148
+ }), c || e(`Child with ${i} '${a}' not found.`), c;
1149
+ }
1150
+ function n(l, i, a) {
1151
+ const c = [];
1152
+ return l.traverse((o) => {
1153
+ o[i].includes(a) && c.push(o);
1154
+ }), c.length || e(`Children with ${i} '${a}' not found.`), c;
1155
+ }
1156
+ function r(l, i) {
1157
+ return t(l, "name", i);
1158
+ }
1159
+ function s(l, i) {
1160
+ return n(l, "name", i);
1161
+ }
1162
+ return {
1163
+ seek: t,
1164
+ seekByName: r,
1165
+ seekAll: n,
1166
+ seekAllByName: s
1139
1167
  };
1140
1168
  }
1141
- function gr(e, t = {}, n = {}) {
1169
+ function Cr(e, t = {}, n = {}) {
1142
1170
  let r = e;
1143
1171
  const s = (a) => {
1144
1172
  r = a;
@@ -1157,7 +1185,7 @@ function gr(e, t = {}, n = {}) {
1157
1185
  };
1158
1186
  return l = new Proxy({}, i), l;
1159
1187
  }
1160
- const { logError: Ke } = Y(), Qe = [
1188
+ const { logError: Xe } = V(), Ze = [
1161
1189
  "onClick",
1162
1190
  "onContextMenu",
1163
1191
  "onPointerMove",
@@ -1172,67 +1200,67 @@ const { logError: Ke } = Y(), Qe = [
1172
1200
  "onPointerMissed",
1173
1201
  "onLostPointerCapture",
1174
1202
  "onWheel"
1175
- ], vr = (e) => {
1203
+ ], Er = (e) => {
1176
1204
  const t = e.scene.value;
1177
- function n(o, u, v, d) {
1178
- if (d || (d = {}), d.args || (d.args = []), o === "template" || zn(o))
1205
+ function n(o, f, y, u) {
1206
+ if (u || (u = {}), u.args || (u.args = []), o === "template" || zn(o))
1179
1207
  return null;
1180
- let g = o.replace("Tres", ""), h;
1208
+ let v = o.replace("Tres", ""), h;
1181
1209
  if (o === "primitive") {
1182
- (!U(d.object) || Pt(d.object)) && Ke(
1210
+ (!H(u.object) || xt(u.object)) && Xe(
1183
1211
  "Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
1184
- ), g = d.object.type;
1185
- const b = {};
1186
- h = gr(
1187
- d.object,
1212
+ ), v = u.object.type;
1213
+ const g = {};
1214
+ h = Cr(
1215
+ u.object,
1188
1216
  {
1189
- object: (f) => f,
1217
+ object: (_) => _,
1190
1218
  isPrimitive: () => !0,
1191
- __tres: () => b
1219
+ __tres: () => g
1192
1220
  },
1193
1221
  {
1194
- object: (f, M, P, C) => {
1195
- sr(f, P, C, { patchProp: l, remove: s, insert: r }, e);
1222
+ object: (_, C, E, T) => {
1223
+ sr(_, E, T, { patchProp: l, remove: s, insert: r }, e);
1196
1224
  },
1197
- __tres: (f) => {
1198
- Object.assign(b, f);
1225
+ __tres: (_) => {
1226
+ Object.assign(g, _);
1199
1227
  }
1200
1228
  }
1201
1229
  );
1202
1230
  } else {
1203
- const b = Me.value[g];
1204
- b || Ke(
1205
- `${g} is not defined on the THREE namespace. Use extend to add it to the catalog.`
1206
- ), h = new b(...d.args);
1231
+ const g = Ce.value[v];
1232
+ g || Xe(
1233
+ `${v} is not defined on the THREE namespace. Use extend to add it to the catalog.`
1234
+ ), h = new g(...u.args);
1207
1235
  }
1208
- return h ? (h.isCamera && (d != null && d.position || h.position.set(3, 3, 3), d != null && d.lookAt || h.lookAt(0, 0, 0)), h = z(h, {
1236
+ return h ? (h.isCamera && (u != null && u.position || h.position.set(3, 3, 3), u != null && u.lookAt || h.lookAt(0, 0, 0)), h = z(h, {
1209
1237
  ...h.__tres,
1210
- type: g,
1211
- memoizedProps: d,
1238
+ type: v,
1239
+ memoizedProps: u,
1212
1240
  eventCount: 0,
1213
1241
  primitive: o === "primitive",
1214
- attach: d.attach
1242
+ attach: u.attach
1215
1243
  }, e), h) : null;
1216
1244
  }
1217
- function r(o, u) {
1218
- var g, h, b;
1245
+ function r(o, f) {
1246
+ var v, h, g;
1219
1247
  if (!o)
1220
1248
  return;
1221
- u = u || t;
1222
- const v = o.__tres ? o : z(o, {}, e), d = u.__tres ? u : z(u, {}, e);
1223
- o = Q(v), u = Q(d), o.__tres && ((g = o.__tres) == null ? void 0 : g.eventCount) > 0 && ((h = e.eventManager) == null || h.registerObject(o)), e.registerCamera(o), (b = e.eventManager) == null || b.registerPointerMissedObject(o), v.__tres.attach ? nr(d, v, v.__tres.attach) : N(o) && N(d) && (d.add(o), o.dispatchEvent({ type: "added" })), v.__tres.parent = d, d.__tres.objects && !d.__tres.objects.includes(v) && d.__tres.objects.push(v);
1249
+ f = f || t;
1250
+ const y = o.__tres ? o : z(o, {}, e), u = f.__tres ? f : z(f, {}, e);
1251
+ o = Q(y), f = Q(u), o.__tres && ((v = o.__tres) == null ? void 0 : v.eventCount) > 0 && ((h = e.eventManager) == null || h.registerObject(o)), e.registerCamera(o), (g = e.eventManager) == null || g.registerPointerMissedObject(o), y.__tres.attach ? nr(u, y, y.__tres.attach) : N(o) && N(u) && (u.add(o), o.dispatchEvent({ type: "added" })), y.__tres.parent = u, u.__tres.objects && !u.__tres.objects.includes(y) && u.__tres.objects.push(y);
1224
1252
  }
1225
- function s(o, u) {
1226
- var h, b, y, f;
1253
+ function s(o, f) {
1254
+ var h, g, p, _;
1227
1255
  if (!o)
1228
1256
  return;
1229
- o != null && o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((b = e.eventManager) == null || b.deregisterObject(o)), u = be(u) ? "default" : u;
1230
- const v = (y = o.__tres) == null ? void 0 : y.dispose;
1231
- be(v) || (v === null ? u = !1 : u = v);
1232
- const d = (f = o.__tres) == null ? void 0 : f.primitive, g = u === "default" ? !d : !!u;
1233
- if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((M) => s(M, u)), g && o.children && [...o.children].forEach((M) => s(M, u)), mt(o, e), ht(o, e), g && !jn(o)) {
1234
- if (G(u))
1235
- u(o);
1257
+ o != null && o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((g = e.eventManager) == null || g.deregisterObject(o)), f = Me(f) ? "default" : f;
1258
+ const y = (p = o.__tres) == null ? void 0 : p.dispose;
1259
+ Me(y) || (y === null ? f = !1 : f = y);
1260
+ const u = (_ = o.__tres) == null ? void 0 : _.primitive, v = f === "default" ? !u : !!f;
1261
+ if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((C) => s(C, f)), v && o.children && [...o.children].forEach((C) => s(C, f)), gt(o, e), vt(o, e), v && !Fn(o)) {
1262
+ if (G(f))
1263
+ f(o);
1236
1264
  else if (G(o.dispose))
1237
1265
  try {
1238
1266
  o.dispose();
@@ -1241,66 +1269,66 @@ const { logError: Ke } = Y(), Qe = [
1241
1269
  }
1242
1270
  "__tres" in o && delete o.__tres;
1243
1271
  }
1244
- function l(o, u, v, d) {
1245
- var M, P;
1272
+ function l(o, f, y, u) {
1273
+ var C, E;
1246
1274
  if (!o)
1247
1275
  return;
1248
- let g = o, h = u;
1249
- if (o.__tres && (o.__tres.memoizedProps[u] = d), u === "attach") {
1250
- const C = ((M = o.__tres) == null ? void 0 : M.parent) || o.parent;
1251
- s(o), z(o, { attach: d }, e), C && r(o, C);
1276
+ let v = o, h = f;
1277
+ if (o.__tres && (o.__tres.memoizedProps[f] = u), f === "attach") {
1278
+ const T = ((C = o.__tres) == null ? void 0 : C.parent) || o.parent;
1279
+ s(o), z(o, { attach: u }, e), T && r(o, T);
1252
1280
  return;
1253
1281
  }
1254
- if (u === "dispose") {
1255
- o.__tres || (o = z(o, {}, e)), o.__tres.dispose = d;
1282
+ if (f === "dispose") {
1283
+ o.__tres || (o = z(o, {}, e)), o.__tres.dispose = u;
1256
1284
  return;
1257
1285
  }
1258
1286
  if (N(o) && h === "blocks-pointer-events") {
1259
- d || d === "" ? o[h] = d : delete o[h];
1287
+ u || u === "" ? o[h] = u : delete o[h];
1260
1288
  return;
1261
1289
  }
1262
- Qe.includes(u) && o.__tres && (o.__tres.eventCount += 1);
1263
- let b = ie(h), y = g == null ? void 0 : g[b];
1290
+ Ze.includes(f) && o.__tres && (o.__tres.eventCount += 1);
1291
+ let g = oe(h), p = v == null ? void 0 : v[g];
1264
1292
  if (h === "args") {
1265
- const C = o, E = v ?? [], S = d ?? [], _ = ((P = o.__tres) == null ? void 0 : P.type) || o.type;
1266
- _ && E.length && !Jn(E, S) && (g = Object.assign(
1267
- C,
1268
- new Me.value[_](...d)
1293
+ const T = o, b = y ?? [], P = u ?? [], M = ((E = o.__tres) == null ? void 0 : E.type) || o.type;
1294
+ M && b.length && !Jn(b, P) && (v = Object.assign(
1295
+ T,
1296
+ new Ce.value[M](...u)
1269
1297
  ));
1270
1298
  return;
1271
1299
  }
1272
- if (g.type === "BufferGeometry") {
1300
+ if (v.type === "BufferGeometry") {
1273
1301
  if (h === "args")
1274
1302
  return;
1275
- g.setAttribute(
1276
- ie(h),
1277
- new Wt(...d)
1303
+ v.setAttribute(
1304
+ oe(h),
1305
+ new Gt(...u)
1278
1306
  );
1279
1307
  return;
1280
1308
  }
1281
- if (h.includes("-") && y === void 0) {
1282
- const C = h.split("-");
1283
- y = C.reduce((E, S) => E[ie(S)], g), h = C.pop(), b = h, y != null && y.set || (g = C.reduce((E, S) => E[ie(S)], g));
1309
+ if (h.includes("-") && p === void 0) {
1310
+ const T = h.split("-");
1311
+ p = T.reduce((b, P) => b[oe(P)], v), h = T.pop(), g = h, p != null && p.set || (v = T.reduce((b, P) => b[oe(P)], v));
1284
1312
  }
1285
- let f = d;
1286
- if (f === "" && (f = !0), G(y)) {
1287
- Qe.includes(u) || (de(f) ? o[b](...f) : o[b](f)), b.startsWith("on") && G(f) && (g[b] = f);
1313
+ let _ = u;
1314
+ if (_ === "" && (_ = !0), G(p)) {
1315
+ Ze.includes(f) || (pe(_) ? o[g](..._) : o[g](_)), g.startsWith("on") && G(_) && (v[g] = _);
1288
1316
  return;
1289
1317
  }
1290
- !(y != null && y.set) && !G(y) ? g[b] = f : y.constructor === f.constructor && (y != null && y.copy) ? y == null || y.copy(f) : de(f) ? y.set(...f) : !y.isColor && y.setScalar ? y.setScalar(f) : y.set(f), pt(o);
1318
+ !(p != null && p.set) && !G(p) ? v[g] = _ : p.constructor === _.constructor && (p != null && p.copy) ? p == null || p.copy(_) : pe(_) ? p.set(..._) : !p.isColor && p.setScalar ? p.setScalar(_) : p.set(_), ht(o);
1291
1319
  }
1292
1320
  function i(o) {
1293
- var u;
1294
- return ((u = o == null ? void 0 : o.__tres) == null ? void 0 : u.parent) || null;
1321
+ var f;
1322
+ return ((f = o == null ? void 0 : o.__tres) == null ? void 0 : f.parent) || null;
1295
1323
  }
1296
1324
  function a(o) {
1297
- const u = z(new Nt(), { type: "Comment" }, e);
1298
- return u.name = o, u;
1325
+ const f = z(new Vt(), { type: "Comment" }, e);
1326
+ return f.name = o, f;
1299
1327
  }
1300
1328
  function c(o) {
1301
- var g;
1302
- const u = i(o), v = ((g = u == null ? void 0 : u.__tres) == null ? void 0 : g.objects) || [], d = v.indexOf(o);
1303
- return d < 0 || d >= v.length - 1 ? null : v[d + 1];
1329
+ var v;
1330
+ const f = i(o), y = ((v = f == null ? void 0 : f.__tres) == null ? void 0 : v.objects) || [], u = y.indexOf(o);
1331
+ return u < 0 || u >= y.length - 1 ? null : y[u + 1];
1304
1332
  }
1305
1333
  return {
1306
1334
  insert: r,
@@ -1319,22 +1347,22 @@ const { logError: Ke } = Y(), Qe = [
1319
1347
  insertStaticContent: () => void 0
1320
1348
  };
1321
1349
  };
1322
- function yr() {
1323
- return vt().__VUE_DEVTOOLS_GLOBAL_HOOK__;
1350
+ function Tr() {
1351
+ return bt().__VUE_DEVTOOLS_GLOBAL_HOOK__;
1324
1352
  }
1325
- function vt() {
1353
+ function bt() {
1326
1354
  return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
1327
1355
  }
1328
- const _r = typeof Proxy == "function", wr = "devtools-plugin:setup", br = "plugin:settings:set";
1329
- let q, Ee;
1330
- function Cr() {
1356
+ const Sr = typeof Proxy == "function", xr = "devtools-plugin:setup", Ar = "plugin:settings:set";
1357
+ let q, Te;
1358
+ function kr() {
1331
1359
  var e;
1332
- return q !== void 0 || (typeof window < "u" && window.performance ? (q = !0, Ee = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (q = !0, Ee = globalThis.perf_hooks.performance) : q = !1), q;
1360
+ return q !== void 0 || (typeof window < "u" && window.performance ? (q = !0, Te = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (q = !0, Te = globalThis.perf_hooks.performance) : q = !1), q;
1333
1361
  }
1334
- function Mr() {
1335
- return Cr() ? Ee.now() : Date.now();
1362
+ function Lr() {
1363
+ return kr() ? Te.now() : Date.now();
1336
1364
  }
1337
- class Pr {
1365
+ class Or {
1338
1366
  constructor(t, n) {
1339
1367
  this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
1340
1368
  const r = {};
@@ -1362,9 +1390,9 @@ class Pr {
1362
1390
  l = i;
1363
1391
  },
1364
1392
  now() {
1365
- return Mr();
1393
+ return Lr();
1366
1394
  }
1367
- }, n && n.on(br, (i, a) => {
1395
+ }, n && n.on(Ar, (i, a) => {
1368
1396
  i === this.plugin.id && this.fallbacks.setSettings(a);
1369
1397
  }), this.proxiedOn = new Proxy({}, {
1370
1398
  get: (i, a) => this.target ? this.target.on[a] : (...c) => {
@@ -1396,12 +1424,12 @@ class Pr {
1396
1424
  n.resolve(await this.target[n.method](...n.args));
1397
1425
  }
1398
1426
  }
1399
- function Er(e, t) {
1400
- const n = e, r = vt(), s = yr(), l = _r && n.enableEarlyProxy;
1427
+ function Rr(e, t) {
1428
+ const n = e, r = bt(), s = Tr(), l = Sr && n.enableEarlyProxy;
1401
1429
  if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
1402
- s.emit(wr, e, t);
1430
+ s.emit(xr, e, t);
1403
1431
  else {
1404
- const i = l ? new Pr(n, s) : null;
1432
+ const i = l ? new Or(n, s) : null;
1405
1433
  (r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
1406
1434
  pluginDescriptor: n,
1407
1435
  setupFn: t,
@@ -1409,14 +1437,14 @@ function Er(e, t) {
1409
1437
  }), i && t(i.proxiedTarget);
1410
1438
  }
1411
1439
  }
1412
- function Tr(e, t) {
1440
+ function Dr(e, t) {
1413
1441
  const n = `▲ ■ ●${e}`;
1414
- typeof Xe == "function" ? Xe(n, t) : console.log(n);
1442
+ typeof et == "function" ? et(n, t) : console.log(n);
1415
1443
  }
1416
- function Xe(e, t) {
1444
+ function et(e, t) {
1417
1445
  throw new Error(e + t);
1418
1446
  }
1419
- const yt = (e) => {
1447
+ const Mt = (e) => {
1420
1448
  const t = {
1421
1449
  id: e.uuid,
1422
1450
  label: e.type,
@@ -1428,13 +1456,13 @@ const yt = (e) => {
1428
1456
  textColor: 5750629,
1429
1457
  backgroundColor: 15793395
1430
1458
  });
1431
- const n = xe(e);
1459
+ const n = ke(e);
1432
1460
  return n > 0 && t.tags.push({
1433
- label: `${ur(n)} KB`,
1461
+ label: `${dr(n)} KB`,
1434
1462
  textColor: 15707189,
1435
1463
  backgroundColor: 16775644,
1436
1464
  tooltip: "Memory usage"
1437
- }), e.type.includes("Light") && (On(e) && t.tags.push({
1465
+ }), e.type.includes("Light") && (Hn(e) && t.tags.push({
1438
1466
  label: `${e.intensity}`,
1439
1467
  textColor: 9738662,
1440
1468
  backgroundColor: 16316922,
@@ -1456,30 +1484,30 @@ const yt = (e) => {
1456
1484
  tooltip: "Position"
1457
1485
  })), t;
1458
1486
  };
1459
- function _t(e, t, n = "") {
1487
+ function Pt(e, t, n = "") {
1460
1488
  e.children.forEach((r) => {
1461
1489
  if (r.type === "HightlightMesh" || n && !r.type.includes(n) && !r.name.includes(n))
1462
1490
  return;
1463
- const s = yt(r);
1464
- t.children.push(s), _t(r, s, n);
1491
+ const s = Mt(r);
1492
+ t.children.push(s), Pt(r, s, n);
1465
1493
  });
1466
1494
  }
1467
- const Sr = [], X = "tres:inspector", Ar = Et({
1495
+ const jr = [], X = "tres:inspector", Br = Se({
1468
1496
  sceneGraph: null
1469
1497
  });
1470
- function xr(e, t) {
1471
- Er(
1498
+ function Ir(e, t) {
1499
+ Rr(
1472
1500
  {
1473
1501
  id: "dev.esm.tres",
1474
1502
  label: "TresJS 🪐",
1475
1503
  logo: "https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",
1476
1504
  packageName: "tresjs",
1477
1505
  homepage: "https://tresjs.org",
1478
- componentStateTypes: Sr,
1506
+ componentStateTypes: jr,
1479
1507
  app: e
1480
1508
  },
1481
1509
  (n) => {
1482
- typeof n.now != "function" && Tr(
1510
+ typeof n.now != "function" && Dr(
1483
1511
  "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."
1484
1512
  ), n.addInspector({
1485
1513
  id: X,
@@ -1492,8 +1520,8 @@ function xr(e, t) {
1492
1520
  n.notifyComponentUpdate();
1493
1521
  }, 5e3), n.on.getInspectorTree((l) => {
1494
1522
  if (l.inspectorId === X) {
1495
- const i = yt(t.scene.value);
1496
- _t(t.scene.value, i, l.filter), Ar.sceneGraph = i, l.rootNodes = [i];
1523
+ const i = Mt(t.scene.value);
1524
+ Pt(t.scene.value, i, l.filter), Br.sceneGraph = i, l.rootNodes = [i];
1497
1525
  }
1498
1526
  });
1499
1527
  let r = null, s = null;
@@ -1508,10 +1536,10 @@ function xr(e, t) {
1508
1536
  a.add(c), r = c, s = a;
1509
1537
  }
1510
1538
  l.state = {
1511
- object: Object.entries(a).map(([c, o]) => c === "children" ? { key: c, value: o.filter((u) => u.type !== "HightlightMesh") } : { key: c, value: o, editable: !0 }).filter(({ key: c }) => c !== "parent")
1539
+ object: Object.entries(a).map(([c, o]) => c === "children" ? { key: c, value: o.filter((f) => f.type !== "HightlightMesh") } : { key: c, value: o, editable: !0 }).filter(({ key: c }) => c !== "parent")
1512
1540
  }, a.isScene && (l.state.info = {
1513
- memory: xe(a),
1514
1541
  objects: a.children.length,
1542
+ memory: ke(a),
1515
1543
  calls: t.renderer.value.info.render.calls,
1516
1544
  triangles: t.renderer.value.info.render.triangles,
1517
1545
  points: t.renderer.value.info.render.points,
@@ -1532,7 +1560,7 @@ function xr(e, t) {
1532
1560
  }
1533
1561
  );
1534
1562
  }
1535
- const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
1563
+ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
1536
1564
  __name: "TresCanvas",
1537
1565
  props: {
1538
1566
  shadows: { type: Boolean, default: void 0 },
@@ -1547,7 +1575,7 @@ const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
1547
1575
  camera: {},
1548
1576
  preset: {},
1549
1577
  windowSize: { type: Boolean, default: void 0 },
1550
- disableRender: { type: Boolean, default: void 0 },
1578
+ enableProvideBridge: { type: Boolean, default: !0 },
1551
1579
  context: {},
1552
1580
  precision: {},
1553
1581
  alpha: { type: Boolean, default: void 0 },
@@ -1577,108 +1605,128 @@ const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
1577
1605
  "ready"
1578
1606
  ],
1579
1607
  setup(e, { expose: t, emit: n }) {
1580
- var y;
1581
- const r = e, s = n, l = Tt(), { logWarning: i } = Y(), a = H(), c = $(new nt()), o = (y = Ie()) == null ? void 0 : y.appContext.app;
1582
- Pe(et);
1583
- const u = (f, M = !1) => Be({
1608
+ const r = e, s = n, l = At(), { logWarning: i } = V(), a = I(), c = $(new st()), o = He();
1609
+ Ee(ot);
1610
+ const f = (g, p = !1) => fe({
1584
1611
  setup() {
1585
- var C;
1586
- const P = (C = Ie()) == null ? void 0 : C.appContext;
1587
- return P && (P.app = o), _e("useTres", f), _e("extend", Pe), typeof window < "u" && xr(P == null ? void 0 : P.app, f), () => He(Ot, null, M ? [] : l.default());
1612
+ var T;
1613
+ const _ = (T = He()) == null ? void 0 : T.appContext;
1614
+ _ && (_.app = o == null ? void 0 : o.appContext.app);
1615
+ const C = {};
1616
+ function E(b) {
1617
+ b && (b.parent && E(b.parent), b.provides && Object.assign(C, b.provides));
1618
+ }
1619
+ return o != null && o.parent && r.enableProvideBridge && (E(o.parent), Object.entries(C).forEach(([b, P]) => {
1620
+ le(b, P);
1621
+ })), le("useTres", g), le("extend", Ee), typeof window < "u" && Ir(_ == null ? void 0 : _.app, g), () => Ue(Bt, null, p ? [] : l.default());
1588
1622
  }
1589
- }), v = (f, M = !1) => {
1590
- const P = u(f, M), { render: C } = Rt(vr(f));
1591
- C(He(P), c.value);
1592
- }, d = (f, M = !1) => {
1593
- dt(f.scene.value), M && (f.renderer.value.dispose(), f.renderer.value.renderLists.dispose(), f.renderer.value.forceContextLoss()), c.value.__tres = {
1594
- root: f
1623
+ }), y = (g, p = !1) => {
1624
+ const _ = f(g, p), { render: C } = jt(Er(g));
1625
+ C(Ue(_), c.value);
1626
+ }, u = (g, p = !1) => {
1627
+ mt(g.scene.value), p && (g.renderer.value.dispose(), g.renderer.value.renderLists.dispose(), g.renderer.value.forceContextLoss()), c.value.__tres = {
1628
+ root: g
1595
1629
  };
1596
- }, g = V(() => r.disableRender), h = $(null);
1597
- t({ context: h, dispose: () => d(h.value, !0) });
1598
- const b = () => {
1599
- d(h.value), v(h.value, !0);
1630
+ }, v = $(null);
1631
+ t({ context: v, dispose: () => u(v.value, !0) });
1632
+ const h = () => {
1633
+ u(v.value), y(v.value, !0);
1600
1634
  };
1601
- return St(() => {
1602
- const f = a;
1603
- h.value = hr({
1635
+ return kt(() => {
1636
+ const g = a;
1637
+ v.value = br({
1604
1638
  scene: c.value,
1605
- canvas: f,
1639
+ canvas: g,
1606
1640
  windowSize: r.windowSize ?? !1,
1607
- disableRender: g.value ?? !1,
1608
1641
  rendererOptions: r,
1609
1642
  emit: s
1610
1643
  });
1611
- const { registerCamera: M, camera: P, cameras: C, deregisterCamera: E } = h.value;
1612
- v(h.value);
1613
- const S = () => {
1614
- const _ = new we(
1644
+ const { registerCamera: p, camera: _, cameras: C, deregisterCamera: E } = v.value;
1645
+ y(v.value);
1646
+ const T = () => {
1647
+ const b = new be(
1615
1648
  45,
1616
1649
  window.innerWidth / window.innerHeight,
1617
1650
  0.1,
1618
1651
  1e3
1619
1652
  );
1620
- _.position.set(3, 3, 3), _.lookAt(0, 0, 0), M(_);
1621
- const A = Te(() => {
1622
- C.value.length >= 2 && (_.removeFromParent(), E(_), A == null || A());
1653
+ b.position.set(3, 3, 3), b.lookAt(0, 0, 0), p(b);
1654
+ const P = xe(() => {
1655
+ C.value.length >= 2 && (b.removeFromParent(), E(b), P == null || P());
1623
1656
  });
1624
1657
  };
1625
- ce(
1658
+ ae(
1626
1659
  () => r.camera,
1627
- (_, A) => {
1628
- _ && M(_), A && (A.removeFromParent(), E(A));
1660
+ (b, P) => {
1661
+ b && p(b), P && (P.removeFromParent(), E(P));
1629
1662
  },
1630
1663
  {
1631
1664
  immediate: !0
1632
1665
  }
1633
- ), P.value || (i(
1666
+ ), _.value || (i(
1634
1667
  "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
1635
- ), S());
1636
- }), K(b), (f, M) => (At(), xt("canvas", {
1668
+ ), T());
1669
+ }), K(h), (g, p) => (Lt(), Ot("canvas", {
1637
1670
  ref_key: "canvas",
1638
1671
  ref: a,
1639
1672
  "data-scene": c.value.uuid,
1640
- class: kt(f.$attrs.class),
1641
- "data-tres": `tresjs ${J(xn).version}`,
1642
- style: Lt({
1673
+ class: Rt(g.$attrs.class),
1674
+ "data-tres": `tresjs ${W(On).version}`,
1675
+ style: Dt({
1643
1676
  display: "block",
1644
1677
  width: "100%",
1645
1678
  height: "100%",
1646
- position: f.windowSize ? "fixed" : "relative",
1679
+ position: g.windowSize ? "fixed" : "relative",
1647
1680
  top: 0,
1648
1681
  left: 0,
1649
1682
  pointerEvents: "auto",
1650
1683
  touchAction: "none",
1651
- ...f.$attrs.style
1684
+ ...g.$attrs.style
1652
1685
  })
1653
- }, null, 14, kr));
1686
+ }, null, 14, $r));
1654
1687
  }
1655
- }), Rr = [
1688
+ }), Ur = [
1656
1689
  "TresCanvas",
1657
1690
  "TresLeches",
1658
1691
  "TresScene"
1659
- ], Or = {
1692
+ ], Fr = {
1660
1693
  template: {
1661
1694
  compilerOptions: {
1662
- isCustomElement: (e) => e.startsWith("Tres") && !Rr.includes(e) || e === "primitive"
1695
+ isCustomElement: (e) => e.startsWith("Tres") && !Ur.includes(e) || e === "primitive"
1663
1696
  }
1664
1697
  }
1665
- }, Jr = Or, Kr = {
1666
- mounted: (e, t) => {
1667
- if (t.arg) {
1668
- console.log(`v-log:${t.arg}`, e[t.arg]);
1698
+ }, ro = Fr, { logWarning: Wr } = V();
1699
+ let B = null;
1700
+ const oo = {
1701
+ updated: (e, t) => {
1702
+ var s;
1703
+ const n = Zn(t);
1704
+ if (!n) {
1705
+ Wr(`v-distance-to: problem with binding value: ${t.value}`);
1669
1706
  return;
1670
1707
  }
1671
- console.log("v-log", e);
1708
+ B && (B.dispose(), e.parent.remove(B));
1709
+ const r = n.clone().sub(e.position);
1710
+ r.normalize(), B = new Yt(r, e.position, e.position.distanceTo(n), 16776960), e.parent.add(B), console.table(
1711
+ [
1712
+ ["Distance:", e.position.distanceTo(n)],
1713
+ [`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
1714
+ [`Destiny: ${e.name || e.type}`, `x:${n.x}, y:${n.y}, z:${n == null ? void 0 : n.z}`]
1715
+ ]
1716
+ );
1717
+ },
1718
+ unmounted: (e) => {
1719
+ B == null || B.dispose(), e.parent.remove(B);
1672
1720
  }
1673
1721
  };
1674
- class wt extends zt {
1722
+ class Ct extends qt {
1675
1723
  constructor(t, n) {
1676
- const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new $e();
1677
- s.setAttribute("position", new Ue(r, 3)), s.computeBoundingSphere();
1678
- const l = new Gt({ fog: !1 });
1724
+ const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new Fe();
1725
+ s.setAttribute("position", new We(r, 3)), s.computeBoundingSphere();
1726
+ const l = new Jt({ fog: !1 });
1679
1727
  super(s, l), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
1680
- const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new $e();
1681
- a.setAttribute("position", new Ue(i, 3)), a.computeBoundingSphere(), this.add(new Vt(a, new ot({ side: Yt, fog: !1 })));
1728
+ const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new Fe();
1729
+ a.setAttribute("position", new We(i, 3)), a.computeBoundingSphere(), this.add(new Kt(a, new at({ side: Qt, fog: !1 })));
1682
1730
  }
1683
1731
  updateMatrixWorld() {
1684
1732
  if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
@@ -1694,87 +1742,74 @@ class wt extends zt {
1694
1742
  this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
1695
1743
  }
1696
1744
  }
1697
- const { logWarning: Ze } = Y();
1698
- let le, W;
1699
- const Dr = {
1700
- DirectionalLight: qt,
1701
- PointLight: Jt,
1702
- SpotLight: Kt,
1703
- HemisphereLight: Qt,
1704
- RectAreaLight: wt
1705
- }, Qr = {
1745
+ const { logWarning: tt } = V();
1746
+ let ie, F;
1747
+ const Nr = {
1748
+ DirectionalLight: Xt,
1749
+ PointLight: Zt,
1750
+ SpotLight: en,
1751
+ HemisphereLight: tn,
1752
+ RectAreaLight: Ct
1753
+ }, so = {
1706
1754
  mounted: (e) => {
1707
1755
  if (!e.isLight) {
1708
- Ze(`${e.type} is not a light`);
1756
+ tt(`${e.type} is not a light`);
1709
1757
  return;
1710
1758
  }
1711
- le = Dr[e.type], e.parent.add(new le(e, 1, e.color.getHex()));
1759
+ ie = Nr[e.type], e.parent.add(new ie(e, 1, e.color.getHex()));
1712
1760
  },
1713
1761
  updated: (e) => {
1714
- W = e.parent.children.find((t) => t instanceof le), !(W instanceof wt) && W.update();
1762
+ F = e.parent.children.find((t) => t instanceof ie), !(F instanceof Ct) && F.update();
1715
1763
  },
1716
1764
  unmounted: (e) => {
1717
1765
  if (!e.isLight) {
1718
- Ze(`${e.type} is not a light`);
1766
+ tt(`${e.type} is not a light`);
1719
1767
  return;
1720
1768
  }
1721
- W = e.parent.children.find((t) => t instanceof le), W && W.dispose && W.dispose(), e.parent.remove(W);
1769
+ F = e.parent.children.find((t) => t instanceof ie), F && F.dispose && F.dispose(), e.parent.remove(F);
1722
1770
  }
1723
- }, { logWarning: jr } = Y();
1724
- let I = null;
1725
- const Xr = {
1726
- updated: (e, t) => {
1727
- var s;
1728
- const n = Zn(t);
1729
- if (!n) {
1730
- jr(`v-distance-to: problem with binding value: ${t.value}`);
1771
+ }, io = {
1772
+ mounted: (e, t) => {
1773
+ if (t.arg) {
1774
+ console.log(`v-log:${t.arg}`, e[t.arg]);
1731
1775
  return;
1732
1776
  }
1733
- I && (I.dispose(), e.parent.remove(I));
1734
- const r = n.clone().sub(e.position);
1735
- r.normalize(), I = new Xt(r, e.position, e.position.distanceTo(n), 16776960), e.parent.add(I), console.table(
1736
- [
1737
- ["Distance:", e.position.distanceTo(n)],
1738
- [`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
1739
- [`Destiny: ${e.name || e.type}`, `x:${n.x}, y:${n.y}, z:${n == null ? void 0 : n.z}`]
1740
- ]
1741
- );
1742
- },
1743
- unmounted: (e) => {
1744
- I == null || I.dispose(), e.parent.remove(I);
1777
+ console.log("v-log", e);
1745
1778
  }
1746
- }, Zr = {
1779
+ }, ao = {
1747
1780
  install(e) {
1748
- e.component("TresCanvas", Lr);
1781
+ e.component("TresCanvas", Hr);
1749
1782
  }
1750
1783
  };
1751
1784
  export {
1752
- Lr as TresCanvas,
1753
- Me as catalogue,
1785
+ Hr as TresCanvas,
1786
+ qr as UseLoader,
1787
+ Jr as UseTexture,
1788
+ Ce as catalogue,
1754
1789
  pr as createRenderLoop,
1755
- Zr as default,
1756
- dt as dispose,
1757
- Pe as extend,
1758
- Fr as isProd,
1759
- Fn as normalizeColor,
1760
- Wr as normalizeVectorFlexibleParam,
1761
- Vr as onTresReady,
1762
- Jr as templateCompilerOptions,
1763
- lr as trasverseObjects,
1764
- In as useCamera,
1765
- Nr as useLoader,
1766
- Y as useLogger,
1767
- qr as useLoop,
1768
- cr as useRaycaster,
1769
- Ur as useRenderLoop,
1770
- ar as useRenderer,
1771
- Gr as useSeek,
1772
- zr as useTexture,
1773
- Yr as useTres,
1774
- pe as useTresContext,
1775
- hr as useTresContextProvider,
1776
- fr as useTresEventManager,
1777
- Xr as vDistanceTo,
1778
- Qr as vLightHelper,
1779
- Kr as vLog
1790
+ ao as default,
1791
+ mt as dispose,
1792
+ Ee as extend,
1793
+ Kr as isProd,
1794
+ hr as normalizeColor,
1795
+ Qr as normalizeVectorFlexibleParam,
1796
+ Xr as onTresReady,
1797
+ ro as templateCompilerOptions,
1798
+ Rn as trasverseObjects,
1799
+ ar as useCamera,
1800
+ Dn as useLoader,
1801
+ V as useLogger,
1802
+ eo as useLoop,
1803
+ yr as useRaycaster,
1804
+ to as useRenderLoop,
1805
+ gr as useRenderer,
1806
+ no as useSeek,
1807
+ ir as useTexture,
1808
+ Zr as useTres,
1809
+ me as useTresContext,
1810
+ br as useTresContextProvider,
1811
+ _r as useTresEventManager,
1812
+ oo as vDistanceTo,
1813
+ so as vLightHelper,
1814
+ io as vLog
1780
1815
  };