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