@tresjs/core 3.6.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +6 -6
  2. package/dist/index.d.ts +3 -17
  3. package/dist/{components → src/components}/TresCanvas.vue.d.ts +5 -4
  4. package/dist/{composables → src/composables}/useCamera/index.d.ts +12 -12
  5. package/dist/{composables → src/composables}/useRenderer/index.d.ts +1 -1
  6. package/dist/src/index.d.ts +17 -0
  7. package/dist/{types → src/types}/index.d.ts +1 -1
  8. package/dist/tres.js +509 -386
  9. package/dist/tres.umd.cjs +3 -3
  10. package/package.json +1 -1
  11. /package/dist/{components → src/components}/index.d.ts +0 -0
  12. /package/dist/{composables → src/composables}/index.d.ts +0 -0
  13. /package/dist/{composables → src/composables}/useLoader/index.d.ts +0 -0
  14. /package/dist/{composables → src/composables}/useLogger.d.ts +0 -0
  15. /package/dist/{composables → src/composables}/usePointerEventHandler/index.d.ts +0 -0
  16. /package/dist/{composables → src/composables}/useRaycaster/index.d.ts +0 -0
  17. /package/dist/{composables → src/composables}/useRenderLoop/index.d.ts +0 -0
  18. /package/dist/{composables → src/composables}/useRenderer/const.d.ts +0 -0
  19. /package/dist/{composables → src/composables}/useSeek/index.d.ts +0 -0
  20. /package/dist/{composables → src/composables}/useTexture/index.d.ts +0 -0
  21. /package/dist/{composables → src/composables}/useTresContextProvider/index.d.ts +0 -0
  22. /package/dist/{core → src/core}/catalogue.d.ts +0 -0
  23. /package/dist/{core → src/core}/nodeOps.d.ts +0 -0
  24. /package/dist/{core → src/core}/renderer.d.ts +0 -0
  25. /package/dist/{core → src/core}/revision.d.ts +0 -0
  26. /package/dist/{utils → src/utils}/index.d.ts +0 -0
  27. /package/dist/{utils → src/utils}/normalize.d.ts +0 -0
  28. /package/dist/{utils → src/utils}/perf.d.ts +0 -0
  29. /package/dist/{utils → src/utils}/template-compiler-options.d.ts +0 -0
  30. /package/dist/{utils → src/utils}/test-utils.d.ts +0 -0
package/dist/tres.js CHANGED
@@ -1,433 +1,550 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v3.6.0
4
- * (c) 2023
3
+ * version: v3.6.1
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 B, computed as b, watchEffect as D, onUnmounted as $, shallowRef as L, watch as re, reactive as pe, readonly as de, provide as V, inject as ve, createRenderer as ge, defineComponent as q, useSlots as ye, getCurrentInstance as J, onMounted as we, openBlock as Ee, createElementBlock as Ce, normalizeClass as _e, normalizeStyle as Me, h as K, Fragment as he } from "vue";
9
- import * as Pe from "three";
10
- import { PerspectiveCamera as G, OrthographicCamera as Ae, Camera as ke, Clock as be, Vector3 as De, Color as F, REVISION as Te, SRGBColorSpace as Le, ACESFilmicToneMapping as Se, PCFSoftShadowMap as Be, WebGLRenderer as I, LoadingManager as xe, TextureLoader as Oe, Vector2 as Re, Raycaster as He, BufferAttribute as Fe, Scene as je } from "three";
11
- import { createEventHook as S, useRafFn as ne, toValue as M, unrefElement as ze, useDevicePixelRatio as $e, usePointer as Ne, useElementBounding as Ie, useWindowSize as Ve, useElementSize as Ge, useFps as We, useMemory as Ue } from "@vueuse/core";
12
- const Ye = ({ sizes: e, scene: a }) => {
13
- const t = B([]), r = b(
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 = [
13
+ "vue",
14
+ "3d",
15
+ "threejs",
16
+ "three",
17
+ "threejs-vue"
18
+ ], ot = !1, at = {
19
+ ".": {
20
+ types: "./dist/index.d.ts",
21
+ require: "./dist/tres.umd.cjs",
22
+ import: "./dist/tres.js"
23
+ },
24
+ "./components": {
25
+ types: "./dist/components/index.d.ts"
26
+ },
27
+ "./composables": {
28
+ types: "./dist/composables/index.d.ts"
29
+ },
30
+ "./types": {
31
+ types: "./dist/types/index.d.ts"
32
+ },
33
+ "./utils": {
34
+ types: "./dist/utils/index.d.ts"
35
+ },
36
+ "./*": "./*"
37
+ }, it = "./dist/tres.js", lt = "./dist/tres.js", ut = "./dist/index.d.ts", ct = [
38
+ "dist",
39
+ "*.d.ts"
40
+ ], ft = {
41
+ access: "public"
42
+ }, pt = {
43
+ dev: "cd playground && npm run dev",
44
+ build: "vite build",
45
+ playground: "cd playground && npm run dev",
46
+ test: "vitest",
47
+ "test:ci": "vitest run",
48
+ "test:ui": "vitest --ui",
49
+ release: "release-it",
50
+ coverage: "vitest run --coverage",
51
+ lint: "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
52
+ "docs:dev": "vitepress dev docs",
53
+ "docs:build": "vitepress build docs",
54
+ "docs:serve": "vitepress serve docs",
55
+ "docs:preview": "vitepress preview docs",
56
+ "docs:contributors": "esno scripts/update-contributors.ts"
57
+ }, dt = {
58
+ three: ">=0.133",
59
+ vue: ">=3.3"
60
+ }, mt = {
61
+ "@alvarosabu/utils": "^3.1.1",
62
+ "@vueuse/core": "^10.7.0"
63
+ }, vt = {
64
+ "@release-it/conventional-changelog": "^8.0.1",
65
+ "@stackblitz/sdk": "^1.9.0",
66
+ "@tresjs/cientos": "3.6.0",
67
+ "@tresjs/eslint-config-vue": "^0.2.1",
68
+ "@types/three": "^0.159.0",
69
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
70
+ "@typescript-eslint/parser": "^6.14.0",
71
+ "@vitejs/plugin-vue": "^4.5.2",
72
+ "@vitest/coverage-c8": "^0.33.0",
73
+ "@vitest/ui": "^1.0.4",
74
+ "@vue/test-utils": "^2.4.3",
75
+ eslint: "^8.55.0",
76
+ "eslint-plugin-vue": "^9.19.2",
77
+ esno: "^4.0.0",
78
+ gsap: "^3.12.3",
79
+ jsdom: "^23.0.1",
80
+ kolorist: "^1.8.0",
81
+ ohmyfetch: "^0.4.21",
82
+ pathe: "^1.1.1",
83
+ "release-it": "^17.0.1",
84
+ "rollup-plugin-analyzer": "^4.0.0",
85
+ "rollup-plugin-copy": "^3.5.0",
86
+ "rollup-plugin-visualizer": "^5.11.0",
87
+ three: "^0.159.0",
88
+ unocss: "^0.58.0",
89
+ unplugin: "^1.5.1",
90
+ "unplugin-vue-components": "^0.26.0",
91
+ vite: "^5.0.8",
92
+ "vite-plugin-banner": "^0.7.1",
93
+ "vite-plugin-dts": "3.6.4",
94
+ "vite-plugin-inspect": "^0.8.1",
95
+ "vite-plugin-require-transform": "^1.0.21",
96
+ "vite-svg-loader": "^5.1.0",
97
+ vitepress: "1.0.0-rc.31",
98
+ vitest: "^1.0.4",
99
+ vue: "^3.3.11",
100
+ "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(
14
123
  () => t.value[0]
15
- ), n = (s, l = !1) => {
16
- t.value.some(({ uuid: i }) => i === s.uuid) || (l ? c(s) : t.value.push(s));
17
- }, o = (s) => {
18
- t.value = t.value.filter(({ uuid: l }) => l !== s.uuid);
19
- }, c = (s) => {
20
- const l = s instanceof ke ? s : t.value.find((p) => p.uuid === s);
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);
21
130
  if (!l)
22
131
  return;
23
- const i = t.value.filter(({ uuid: p }) => p !== l.uuid);
24
- t.value = [l, ...i];
132
+ const c = t.value.filter(({ uuid: d }) => d !== l.uuid);
133
+ t.value = [l, ...c];
25
134
  };
26
135
  return D(() => {
27
- e.aspectRatio.value && t.value.forEach((s) => {
28
- s instanceof G && (s.aspect = e.aspectRatio.value), (s instanceof G || s instanceof Ae) && s.updateProjectionMatrix();
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();
29
138
  });
30
- }), a.userData.tres__registerCamera = n, a.userData.tres__deregisterCamera = o, $(() => {
139
+ }), s.userData.tres__registerCamera = n, s.userData.tres__deregisterCamera = o, $(() => {
31
140
  t.value = [];
32
141
  }), {
33
142
  camera: r,
34
143
  cameras: t,
35
144
  registerCamera: n,
36
145
  deregisterCamera: o,
37
- setCameraActive: c
146
+ setCameraActive: u
38
147
  };
39
- }, ae = S(), oe = S(), U = S(), T = new be();
40
- let j = 0, z = 0;
41
- const { pause: qe, resume: Je, isActive: Ke } = ne(
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(
42
151
  () => {
43
- ae.trigger({ delta: j, elapsed: z, clock: T }), oe.trigger({ delta: j, elapsed: z, clock: T }), U.trigger({ delta: j, elapsed: z, clock: T });
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 });
44
153
  },
45
154
  { immediate: !1 }
46
155
  );
47
156
  U.on(() => {
48
- j = T.getDelta(), z = T.getElapsedTime();
157
+ z = T.getDelta(), F = T.getElapsedTime();
49
158
  });
50
- const se = () => ({
51
- onBeforeLoop: ae.on,
52
- onLoop: oe.on,
159
+ const ie = () => ({
160
+ onBeforeLoop: oe.on,
161
+ onLoop: ae.on,
53
162
  onAfterLoop: U.on,
54
- pause: qe,
55
- resume: Je,
56
- isActive: Ke
57
- }), Pt = !0, X = "[TresJS ▲ ■ ●] ";
58
- function x() {
163
+ pause: ht,
164
+ resume: wt,
165
+ isActive: Et
166
+ }), Yt = !0, Q = "[TresJS ▲ ■ ●] ";
167
+ function j() {
59
168
  function e(r, n) {
60
- console.error(`${X} ${r}`, n || "");
169
+ console.error(`${Q} ${r}`, n || "");
61
170
  }
62
- function a(r) {
63
- console.warn(`${X} ${r}`);
171
+ function s(r) {
172
+ console.warn(`${Q} ${r}`);
64
173
  }
65
174
  function t(r, n) {
66
175
  }
67
176
  return {
68
177
  logError: e,
69
- logWarning: a,
178
+ logWarning: s,
70
179
  logMessage: t
71
180
  };
72
181
  }
73
- function At(e) {
74
- return typeof e == "number" ? [e, e, e] : e instanceof De ? [e.x, e.y, e.z] : e;
182
+ function Jt(e) {
183
+ return typeof e == "number" ? [e, e, e] : e instanceof Se ? [e.x, e.y, e.z] : e;
75
184
  }
76
- function Xe(e) {
77
- return e instanceof F ? e : Array.isArray(e) ? new F(...e) : new F(e);
185
+ function bt(e) {
186
+ return e instanceof H ? e : Array.isArray(e) ? new H(...e) : new H(e);
78
187
  }
79
- const ie = (e, a) => {
80
- for (const t of Object.keys(a))
81
- a[t] instanceof Object && Object.assign(a[t], ie(e[t], a[t]));
82
- return Object.assign(e || {}, a), e;
83
- }, Qe = "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", Ze = /* @__PURE__ */ et(Qe);
84
- function Q(e) {
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) {
85
194
  return e && e.nodeType === 1;
86
195
  }
87
- function R(e) {
88
- return e.replace(/-([a-z])/g, (a, t) => t.toUpperCase());
196
+ function O(e) {
197
+ return e.replace(/-([a-z])/g, (s, t) => t.toUpperCase());
89
198
  }
90
- function et(e, a) {
199
+ function Mt(e, s) {
91
200
  const t = /* @__PURE__ */ Object.create(null), r = e.split(",");
92
201
  for (let n = 0; n < r.length; n++)
93
202
  t[r[n]] = !0;
94
- return a ? (n) => !!t[n.toLowerCase()] : (n) => !!t[n];
203
+ return s ? (n) => !!t[n.toLowerCase()] : (n) => !!t[n];
95
204
  }
96
- const tt = (e, a) => {
205
+ const Pt = (e, s) => {
97
206
  const t = /* @__PURE__ */ new Set(), r = [];
98
207
  for (const n of e) {
99
- const o = a(n);
208
+ const o = s(n);
100
209
  t.has(o) || (t.add(o), r.push(n));
101
210
  }
102
211
  return r;
103
- }, Z = (e, a) => {
104
- if (!a)
212
+ }, ee = (e, s) => {
213
+ if (!s)
105
214
  return;
106
- const t = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
215
+ const t = Array.isArray(s) ? s : s.match(/([^[.\]])+/g);
107
216
  return t == null ? void 0 : t.reduce((r, n) => r && r[n], e);
108
- }, rt = (e, a, t) => {
109
- const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
110
- r && r.reduce((n, o, c) => (n[o] === void 0 && (n[o] = {}), c === r.length - 1 && (n[o] = t), n[o]), 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);
111
220
  };
112
- function ue(e, a) {
113
- if (Q(e) && Q(a)) {
114
- const n = e.attributes, o = a.attributes;
115
- return n.length !== o.length ? !1 : Array.from(n).every(({ name: c, value: s }) => a.getAttribute(c) === s);
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);
116
225
  }
117
- if (e === a)
226
+ if (e === s)
118
227
  return !0;
119
- if (e === null || typeof e != "object" || a === null || typeof a != "object")
228
+ if (e === null || typeof e != "object" || s === null || typeof s != "object")
120
229
  return !1;
121
- const t = Object.keys(e), r = Object.keys(a);
230
+ const t = Object.keys(e), r = Object.keys(s);
122
231
  if (t.length !== r.length)
123
232
  return !1;
124
233
  for (const n of t)
125
- if (!r.includes(n) || !ue(e[n], a[n]))
234
+ if (!r.includes(n) || !ue(e[n], s[n]))
126
235
  return !1;
127
236
  return !0;
128
237
  }
129
- function nt(e, a) {
130
- if (!Array.isArray(e) || !Array.isArray(a) || e.length !== a.length)
238
+ function kt(e, s) {
239
+ if (!Array.isArray(e) || !Array.isArray(s) || e.length !== s.length)
131
240
  return !1;
132
241
  for (let t = 0; t < e.length; t++)
133
- if (!ue(e[t], a[t]))
242
+ if (!ue(e[t], s[t]))
134
243
  return !1;
135
244
  return !0;
136
245
  }
137
- const at = Array.isArray, ot = Number.parseInt(Te.replace("dev", "")), H = {
246
+ const Dt = Array.isArray, xt = Number.parseInt(Le.replace("dev", "")), R = {
138
247
  realistic: {
139
248
  shadows: !0,
140
249
  physicallyCorrectLights: !0,
141
- outputColorSpace: Le,
142
- toneMapping: Se,
250
+ outputColorSpace: je,
251
+ toneMapping: Be,
143
252
  toneMappingExposure: 3,
144
253
  shadowMap: {
145
254
  enabled: !0,
146
- type: Be
255
+ type: Oe
147
256
  }
148
257
  }
149
258
  };
150
- function st({
259
+ function Tt({
151
260
  scene: e,
152
- canvas: a,
261
+ canvas: s,
153
262
  options: t,
154
263
  disableRender: r,
155
264
  contextParts: { sizes: n, camera: o }
156
265
  }) {
157
- const c = b(() => ({
158
- alpha: M(t.alpha),
159
- depth: M(t.depth),
160
- canvas: ze(a),
161
- context: M(t.context),
162
- stencil: M(t.stencil),
163
- antialias: M(t.antialias) === void 0 ? !0 : M(t.antialias),
164
- precision: M(t.precision),
165
- powerPreference: M(t.powerPreference),
166
- premultipliedAlpha: M(t.premultipliedAlpha),
167
- preserveDrawingBuffer: M(t.preserveDrawingBuffer),
168
- logarithmicDepthBuffer: M(t.logarithmicDepthBuffer),
169
- failIfMajorPerformanceCaveat: M(t.failIfMajorPerformanceCaveat)
170
- })), s = L(new I(c.value));
171
- re(c, () => {
172
- s.value.dispose(), s.value = new I(c.value);
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);
173
282
  }), D(() => {
174
- s.value.setSize(n.width.value, n.height.value);
283
+ a.value.setSize(n.width.value, n.height.value);
175
284
  });
176
- const { pixelRatio: l } = $e();
285
+ const { pixelRatio: l } = Ve();
177
286
  D(() => {
178
- s.value.setPixelRatio(l.value);
287
+ a.value.setPixelRatio(l.value);
179
288
  });
180
- const { logError: i } = x(), f = (() => {
181
- const m = new I(), w = {
289
+ const { logError: c } = j(), f = (() => {
290
+ const p = new I(), y = {
182
291
  shadowMap: {
183
- enabled: m.shadowMap.enabled,
184
- type: m.shadowMap.type
292
+ enabled: p.shadowMap.enabled,
293
+ type: p.shadowMap.type
185
294
  },
186
- toneMapping: m.toneMapping,
187
- toneMappingExposure: m.toneMappingExposure,
188
- outputColorSpace: m.outputColorSpace
295
+ toneMapping: p.toneMapping,
296
+ toneMappingExposure: p.toneMappingExposure,
297
+ outputColorSpace: p.outputColorSpace
189
298
  };
190
- return m.dispose(), w;
299
+ return p.dispose(), y;
191
300
  })();
192
301
  D(() => {
193
- const m = M(t.preset);
194
- m && (m in H || i(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), ie(s.value, H[m]));
195
- const w = (P, A) => {
196
- const C = M(P), k = () => {
197
- if (m)
198
- return Z(H[m], A);
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);
199
308
  };
200
- if (C !== void 0)
201
- return C;
202
- const g = k();
203
- return g !== void 0 ? g : Z(f, A);
204
- }, d = (P, A) => rt(s.value, A, w(P, A));
205
- d(t.shadows, "shadowMap.enabled"), d(t.toneMapping, "toneMapping"), d(t.shadowMapType, "shadowMap.type"), ot < 150 && d(!t.useLegacyLights, "physicallyCorrectLights"), d(t.outputColorSpace, "outputColorSpace"), d(t.toneMappingExposure, "toneMappingExposure");
206
- const h = w(t.clearColor, "clearColor");
207
- h && s.value.setClearColor(
208
- h ? Xe(h) : new F(0)
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)
209
318
  // default clear color is not easily/efficiently retrievable from three
210
319
  );
211
320
  });
212
- const { pause: u, resume: v, onLoop: E } = se();
213
- return E(() => {
214
- o.value && !M(r) && s.value.render(e, o.value);
215
- }), v(), $(() => {
216
- u(), s.value.dispose(), s.value.forceContextLoss();
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();
217
326
  }), {
218
- renderer: s
327
+ renderer: a
219
328
  };
220
329
  }
221
- const ee = (e) => typeof e == "function", it = (e) => !!e && e.constructor === Array;
222
- function ut(e) {
223
- const a = { nodes: {}, materials: {} };
330
+ const te = (e) => typeof e == "function", St = (e) => !!e && e.constructor === Array;
331
+ function Lt(e) {
332
+ const s = { nodes: {}, materials: {} };
224
333
  return e && e.traverse((t) => {
225
- t.name && (a.nodes[t.name] = t), t.material && !a.materials[t.material.name] && (a.materials[t.material.name] = t.material);
226
- }), a;
334
+ t.name && (s.nodes[t.name] = t), t.material && !s.materials[t.material.name] && (s.materials[t.material.name] = t.material);
335
+ }), s;
227
336
  }
228
- async function kt(e, a, t, r, n) {
229
- const { logError: o } = x(), c = new e();
230
- n && n(c), t && t(c);
231
- const l = (Array.isArray(a) ? a : [a]).map(
232
- (i) => new Promise((p, f) => {
233
- c.load(
234
- i,
235
- (u) => {
236
- u.scene && Object.assign(u, ut(u.scene)), p(u);
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(
343
+ c,
344
+ (i) => {
345
+ i.scene && Object.assign(i, Lt(i.scene)), d(i);
237
346
  },
238
347
  r,
239
- (u) => f(o("[useLoader] - Failed to load resource", u))
348
+ (i) => f(o("[useLoader] - Failed to load resource", i))
240
349
  );
241
350
  })
242
351
  );
243
- return it(a) ? await Promise.all(l) : await l[0];
352
+ return St(s) ? await Promise.all(l) : await l[0];
244
353
  }
245
- async function bt(e) {
246
- const a = new xe(), t = new Oe(a), r = (n) => new Promise((o, c) => {
354
+ async function Xt(e) {
355
+ const s = new Re(), t = new He(s), r = (n) => new Promise((o, u) => {
247
356
  t.load(
248
357
  n,
249
- (s) => o(s),
358
+ (a) => o(a),
250
359
  () => null,
251
360
  () => {
252
- c(new Error("[useTextures] - Failed to load texture"));
361
+ u(new Error("[useTextures] - Failed to load texture"));
253
362
  }
254
363
  );
255
364
  });
256
- if (at(e)) {
365
+ if (Dt(e)) {
257
366
  const n = await Promise.all(e.map((o) => r(o)));
258
367
  return e.length > 1 ? n : n[0];
259
368
  } else {
260
369
  const {
261
370
  map: n,
262
371
  displacementMap: o,
263
- normalMap: c,
264
- roughnessMap: s,
372
+ normalMap: u,
373
+ roughnessMap: a,
265
374
  metalnessMap: l,
266
- aoMap: i,
267
- alphaMap: p,
375
+ aoMap: c,
376
+ alphaMap: d,
268
377
  matcap: f
269
378
  } = e;
270
379
  return {
271
380
  map: n ? await r(n) : null,
272
381
  displacementMap: o ? await r(o) : null,
273
- normalMap: c ? await r(c) : null,
274
- roughnessMap: s ? await r(s) : null,
382
+ normalMap: u ? await r(u) : null,
383
+ roughnessMap: a ? await r(a) : null,
275
384
  metalnessMap: l ? await r(l) : null,
276
- aoMap: i ? await r(i) : null,
277
- alphaMap: p ? await r(p) : null,
385
+ aoMap: c ? await r(c) : null,
386
+ alphaMap: d ? await r(d) : null,
278
387
  matcap: f ? await r(f) : null
279
388
  };
280
389
  }
281
390
  }
282
- const lt = (e, { renderer: a, camera: t, raycaster: r }) => {
283
- const n = b(() => a.value.domElement), { x: o, y: c } = Ne({ target: n }), { width: s, height: l, top: i, left: p } = Ie(n), f = ({ x: g, y: _ }) => {
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 }) => {
284
393
  if (n.value)
285
394
  return {
286
- x: (g - p.value) / s.value * 2 - 1,
287
- y: -((_ - i.value) / l.value) * 2 + 1
395
+ x: (v - d.value) / a.value * 2 - 1,
396
+ y: -((C - c.value) / l.value) * 2 + 1
288
397
  };
289
- }, u = ({ x: g, y: _ }) => {
398
+ }, i = ({ x: v, y: C }) => {
290
399
  if (t.value)
291
- return r.value.setFromCamera(new Re(g, _), t.value), r.value.intersectObjects(e.value, !1);
292
- }, v = (g) => {
293
- const _ = f({
294
- x: (g == null ? void 0 : g.clientX) ?? o.value,
295
- y: (g == null ? void 0 : g.clientY) ?? c.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
296
405
  });
297
- return _ ? u(_) || [] : [];
298
- }, E = b(() => v()), m = S(), w = S(), d = (g, _) => {
299
- g.trigger({ event: _, intersects: v(_) });
300
- }, h = (g) => {
301
- d(w, g);
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);
302
411
  };
303
- let P;
304
- const A = (g) => {
305
- var _;
306
- P = (_ = v(g)[0]) == null ? void 0 : _.object;
307
- }, C = (g) => {
308
- var _;
309
- g instanceof PointerEvent && P === ((_ = v(g)[0]) == null ? void 0 : _.object) && d(m, g);
310
- }, k = (g) => w.trigger({ event: g, intersects: [] });
311
- return n.value.addEventListener("pointerup", C), n.value.addEventListener("pointerdown", A), n.value.addEventListener("pointermove", h), n.value.addEventListener("pointerleave", k), $(() => {
312
- n != null && n.value && (n.value.removeEventListener("pointerup", C), n.value.removeEventListener("pointerdown", A), n.value.removeEventListener("pointermove", h), n.value.removeEventListener("pointerleave", k));
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));
313
422
  }), {
314
- intersects: E,
315
- onClick: (g) => m.on(g).off,
316
- onPointerMove: (g) => w.on(g).off
423
+ intersects: h,
424
+ onClick: (v) => p.on(v).off,
425
+ onPointerMove: (v) => y.on(v).off
317
426
  };
318
427
  };
319
- function Dt() {
320
- const { logWarning: e } = x();
321
- function a(o, c, s) {
428
+ function Qt() {
429
+ const { logWarning: e } = j();
430
+ function s(o, u, a) {
322
431
  let l = null;
323
- return o.traverse((i) => {
324
- i[c] === s && (l = i);
325
- }), l || e(`Child with ${c} '${s}' not found.`), l;
432
+ return o.traverse((c) => {
433
+ c[u] === a && (l = c);
434
+ }), l || e(`Child with ${u} '${a}' not found.`), l;
326
435
  }
327
- function t(o, c, s) {
436
+ function t(o, u, a) {
328
437
  const l = [];
329
- return o.traverse((i) => {
330
- i[c].includes(s) && l.push(i);
331
- }), l.length || e(`Children with ${c} '${s}' not found.`), 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;
332
441
  }
333
- function r(o, c) {
334
- return a(o, "name", c);
442
+ function r(o, u) {
443
+ return s(o, "name", u);
335
444
  }
336
- function n(o, c) {
337
- return t(o, "name", c);
445
+ function n(o, u) {
446
+ return t(o, "name", u);
338
447
  }
339
448
  return {
340
- seek: a,
449
+ seek: s,
341
450
  seekByName: r,
342
451
  seekAll: t,
343
452
  seekAllByName: n
344
453
  };
345
454
  }
346
- const ct = ({ scene: e, contextParts: a }) => {
347
- const t = pe({
455
+ const Bt = ({ scene: e, contextParts: s }) => {
456
+ const t = ve({
348
457
  click: /* @__PURE__ */ new Map(),
349
458
  pointerMove: /* @__PURE__ */ new Map(),
350
459
  pointerEnter: /* @__PURE__ */ new Map(),
351
460
  pointerLeave: /* @__PURE__ */ new Map()
352
- }), r = B(/* @__PURE__ */ new Set()), n = (u) => {
353
- r.value.add(u);
354
- }, o = (u) => {
355
- r.value.delete(u);
356
- }, c = (u) => {
357
- Object.values(t).forEach((v) => v.delete(u)), o(u);
358
- }, s = (u) => {
359
- const { onClick: v, onPointerMove: E, onPointerEnter: m, onPointerLeave: w } = u;
360
- v && t.click.set(u, v), E && t.pointerMove.set(u, E), m && t.pointerEnter.set(u, m), w && t.pointerLeave.set(u, w);
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);
361
470
  };
362
- e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
363
- const l = b(
364
- () => tt(
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(
365
474
  [
366
475
  ...Array.from(r.value),
367
- ...Object.values(t).map((u) => Array.from(u.keys())).flat()
476
+ ...Object.values(t).map((i) => Array.from(i.keys())).flat()
368
477
  ],
369
- ({ uuid: u }) => u
478
+ ({ uuid: i }) => i
370
479
  )
371
- ), { onClick: i, onPointerMove: p } = lt(l, a);
372
- i(({ intersects: u, event: v }) => {
373
- var E;
374
- u.length && ((E = t.click.get(u[0].object)) == null || E(u[0], v));
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));
375
484
  });
376
485
  let f;
377
- return p(({ intersects: u, event: v }) => {
378
- var h, P, A, C;
379
- const E = (h = u == null ? void 0 : u[0]) == null ? void 0 : h.object, { pointerLeave: m, pointerEnter: w, pointerMove: d } = t;
380
- f && f !== E && ((P = m.get(f)) == null || P(f, v)), E && (f !== E && ((A = w.get(E)) == null || A(u[0], v)), (C = d.get(E)) == null || C(u[0], v)), f = E || null;
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;
381
490
  }), {
382
- registerObject: s,
383
- deregisterObject: c
491
+ registerObject: a,
492
+ deregisterObject: u
384
493
  };
385
494
  };
386
- function ft(e) {
387
- let a = 0;
495
+ function Ot(e) {
496
+ let s = 0;
388
497
  return e.traverse((t) => {
389
498
  if (t.isMesh && t.geometry) {
390
- 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, c = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = n + o + c + s;
391
- a += l;
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;
392
501
  }
393
- }), a;
502
+ }), s;
394
503
  }
395
- const W = B({}), Y = (e) => Object.assign(W.value, e);
396
- function mt({
504
+ const q = L({}), Y = (e) => Object.assign(q.value, e);
505
+ function Rt({
397
506
  scene: e,
398
- canvas: a,
507
+ canvas: s,
399
508
  windowSize: t,
400
509
  disableRender: r,
401
510
  rendererOptions: n
402
511
  }) {
403
- const o = b(
404
- () => M(t) ? Ve() : Ge(M(a).parentElement)
405
- ), c = b(() => o.value.width.value), s = b(() => o.value.height.value), l = b(() => c.value / s.value), i = {
406
- height: s,
407
- width: c,
408
- aspectRatio: l
409
- }, p = L(e), {
410
- camera: f,
411
- cameras: u,
412
- registerCamera: v,
413
- deregisterCamera: E,
414
- setCameraActive: m
415
- } = Ye({ sizes: i, scene: e }), { renderer: w } = st(
512
+ const o = k(
513
+ () => _(t) ? qe() : Ue(_(s).parentElement)
514
+ ), u = x({
515
+ width: 0,
516
+ height: 0
517
+ }), a = Ye(u, 10), l = D(() => {
518
+ u.value = {
519
+ width: o.value.width.value,
520
+ height: o.value.height.value
521
+ };
522
+ }), c = k(() => a.value.width / a.value.height), d = {
523
+ height: k(() => a.value.height),
524
+ width: k(() => a.value.width),
525
+ aspectRatio: c
526
+ }, f = x(e), {
527
+ camera: i,
528
+ cameras: m,
529
+ registerCamera: h,
530
+ deregisterCamera: p,
531
+ setCameraActive: y
532
+ } = yt({ sizes: d, scene: e }), { renderer: b } = Tt(
416
533
  {
417
534
  scene: e,
418
- canvas: a,
535
+ canvas: s,
419
536
  options: n,
420
- contextParts: { sizes: i, camera: f },
537
+ contextParts: { sizes: d, camera: i },
421
538
  disableRender: r
422
539
  }
423
- ), d = {
424
- sizes: i,
425
- scene: p,
426
- camera: f,
427
- cameras: de(u),
428
- renderer: w,
429
- raycaster: L(new He()),
430
- controls: B(null),
540
+ ), 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),
431
548
  perf: {
432
549
  maxFrames: 160,
433
550
  fps: {
@@ -441,130 +558,135 @@ function mt({
441
558
  }
442
559
  },
443
560
  extend: Y,
444
- registerCamera: v,
445
- setCameraActive: m,
446
- deregisterCamera: E
561
+ registerCamera: h,
562
+ setCameraActive: y,
563
+ deregisterCamera: p
447
564
  };
448
- V("useTres", d);
449
- const h = 100, P = We({ every: h }), { isSupported: A, memory: C } = Ue({ interval: h }), k = 160;
450
- let g = performance.now();
451
- const _ = ({ timestamp: O }) => {
452
- d.scene.value && (d.perf.memory.allocatedMem = ft(d.scene.value)), O - g >= h && (g = O, d.perf.fps.accumulator.push(P.value), d.perf.fps.accumulator.length > k && d.perf.fps.accumulator.shift(), d.perf.fps.value = P.value, A.value && C.value && (d.perf.memory.accumulator.push(C.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > k && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((fe, me) => fe + me, 0) / d.perf.memory.accumulator.length));
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));
453
570
  };
454
571
  let N = 0;
455
- const le = 1, { pause: ce, resume: Ct } = ne(({ delta: O }) => {
456
- window.__TRES__DEVTOOLS__ && (_({ timestamp: performance.now() }), N += O, N >= le && (window.__TRES__DEVTOOLS__.cb(d), 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));
457
574
  }, { immediate: !0 });
458
575
  return $(() => {
459
- ce();
460
- }), d;
576
+ l(), pe();
577
+ }), w;
461
578
  }
462
- function pt() {
463
- const e = ve("useTres");
579
+ function Ht() {
580
+ const e = ye("useTres");
464
581
  if (!e)
465
582
  throw new Error("useTresContext must be used together with useTresContextProvider");
466
583
  return e;
467
584
  }
468
- const Tt = pt;
469
- let y = null;
470
- const { logError: te } = x(), dt = {
471
- createElement(e, a, t, r) {
472
- var c, s;
473
- if (r || (r = {}), r.args || (r.args = []), e === "template" || Ze(e))
585
+ const Zt = Ht;
586
+ let g = null;
587
+ const { logError: re } = j(), V = [
588
+ "onClick",
589
+ "onPointerMove",
590
+ "onPointerEnter",
591
+ "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))
474
596
  return null;
475
597
  let n = e.replace("Tres", ""), o;
476
598
  if (e === "primitive") {
477
- (r == null ? void 0 : r.object) === void 0 && te("Tres primitives need a prop 'object'");
599
+ (r == null ? void 0 : r.object) === void 0 && re("Tres primitives need a prop 'object'");
478
600
  const l = r.object;
479
601
  n = l.type, o = Object.assign(l, { type: n, attach: r.attach, primitive: !0 });
480
602
  } else {
481
- const l = W.value[n];
482
- l || te(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new l(...r.args);
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);
483
605
  }
484
- 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 && ((c = r == null ? void 0 : r.material) != null && c.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
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 = {
485
607
  ...o.userData,
486
608
  tres__name: n
487
609
  }, o;
488
610
  },
489
- insert(e, a) {
490
- var r, n, o, c;
491
- a && a.isScene && (y = a);
492
- const t = a || y;
611
+ insert(e, s) {
612
+ var r, n, o, u;
613
+ s && s.isScene && (g = s);
614
+ const t = s || g;
493
615
  if (e != null && e.isObject3D) {
494
616
  if (e != null && e.isCamera) {
495
- if (!(y != null && y.userData.tres__registerCamera))
617
+ if (!(g != null && g.userData.tres__registerCamera))
496
618
  throw "could not find tres__registerCamera on scene's userData";
497
- (n = y == null ? void 0 : (r = y.userData).tres__registerCamera) == null || n.call(r, e);
619
+ (n = g == null ? void 0 : (r = g.userData).tres__registerCamera) == null || n.call(r, e);
498
620
  }
499
- if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) {
500
- if (!(y != null && y.userData.tres__registerAtPointerEventHandler))
621
+ if (e && V.some((a) => e[a])) {
622
+ if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
501
623
  throw "could not find tres__registerAtPointerEventHandler on scene's userData";
502
- (c = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || c.call(o, e);
624
+ (u = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
503
625
  }
504
626
  }
505
627
  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));
506
628
  },
507
629
  remove(e) {
508
- var a, t;
630
+ var s, t;
509
631
  if (e) {
510
632
  if (e.isObject3D) {
511
- const r = e, n = (i) => {
512
- var f, u;
513
- const p = i;
514
- i.userData.tres__materialViaProp || ((f = p.material) == null || f.dispose(), p.material = void 0), i.userData.tres__geometryViaProp || ((u = p.geometry) == null || u.dispose(), p.geometry = void 0);
515
- }, o = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, c = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => {
516
- var p, f;
517
- if (!c)
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)
518
640
  throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
519
- if ((f = y == null ? void 0 : (p = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(p, i), !o)
641
+ if ((f = g == null ? void 0 : (d = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(d, c), !o)
520
642
  throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
521
- (i != null && i.onClick || i != null && i.onPointerMove || i != null && i.onPointerEnter || i != null && i.onPointerLeave) && (o == null || o(i));
522
- }, l = (i) => {
523
- const p = y == null ? void 0 : y.userData.tres__deregisterCamera;
524
- if (!p)
643
+ c && V.some((i) => c[i]) && (o == null || o(c));
644
+ }, l = (c) => {
645
+ const d = g == null ? void 0 : g.userData.tres__deregisterCamera;
646
+ if (!d)
525
647
  throw "could not find tres__deregisterCamera on scene's userData";
526
- i.isCamera && (p == null || p(i));
648
+ c.isCamera && (d == null || d(c));
527
649
  };
528
- (a = e.removeFromParent) == null || a.call(e), r.traverse((i) => {
529
- n(i), l(i), s == null || s(i);
530
- }), n(r), l(r), s == null || s(r);
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);
531
653
  }
532
654
  (t = e.dispose) == null || t.call(e);
533
655
  }
534
656
  },
535
- patchProp(e, a, t, r) {
536
- var n, o, c, s;
657
+ patchProp(e, s, t, r) {
658
+ var n, o, u, a;
537
659
  if (e) {
538
- let l = e, i = a;
539
- if (e.isObject3D && i === "blocks-pointer-events") {
540
- r || r === "" ? (o = y == null ? void 0 : (n = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = y == null ? void 0 : (c = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(c, e);
660
+ let l = e, c = s;
661
+ 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);
541
663
  return;
542
664
  }
543
- let p = R(i), f = l == null ? void 0 : l[p];
544
- if (i === "args") {
545
- const v = e, E = t ?? [], m = r ?? [], w = e.userData.tres__name || e.type;
546
- w && E.length && !nt(E, m) && (l = Object.assign(v, new W.value[w](...r)));
665
+ let d = O(c), f = l == null ? void 0 : l[d];
666
+ 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)));
547
669
  return;
548
670
  }
549
671
  if (l.type === "BufferGeometry") {
550
- if (i === "args")
672
+ if (c === "args")
551
673
  return;
552
674
  l.setAttribute(
553
- R(i),
554
- new Fe(...r)
675
+ O(c),
676
+ new $e(...r)
555
677
  );
556
678
  return;
557
679
  }
558
- if (i.includes("-") && f === void 0) {
559
- const v = i.split("-");
560
- f = v.reduce((E, m) => E[R(m)], l), i = v.pop(), p = i.toLowerCase(), f != null && f.set || (l = v.reduce((E, m) => E[R(m)], l));
680
+ if (c.includes("-") && f === void 0) {
681
+ 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));
561
683
  }
562
- let u = r;
563
- if (u === "" && (u = !0), ee(f)) {
564
- Array.isArray(u) ? e[p](...u) : e[p](u);
684
+ let i = r;
685
+ if (i === "" && (i = !0), te(f)) {
686
+ V.includes(s) || (Array.isArray(i) ? e[d](...i) : e[d](i));
565
687
  return;
566
688
  }
567
- !(f != null && f.set) && !ee(f) ? l[p] = u : f.constructor === u.constructor && (f != null && f.copy) ? f == null || f.copy(u) : Array.isArray(u) ? f.set(...u) : !f.isColor && f.setScalar ? f.setScalar(u) : f.set(u);
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);
568
690
  }
569
691
  },
570
692
  parentNode(e) {
@@ -579,9 +701,9 @@ const { logError: te } = x(), dt = {
579
701
  setScopeId: () => void 0,
580
702
  cloneNode: () => void 0,
581
703
  insertStaticContent: () => void 0
582
- }, { render: vt } = ge(dt);
583
- Y(Pe);
584
- const gt = ["data-scene"], yt = /* @__PURE__ */ q({
704
+ }, { render: Ft } = he(zt);
705
+ Y(ke);
706
+ const $t = ["data-scene", "data-tres"], Nt = /* @__PURE__ */ J({
585
707
  __name: "TresCanvas",
586
708
  props: {
587
709
  shadows: { type: Boolean, default: void 0 },
@@ -607,107 +729,108 @@ const gt = ["data-scene"], yt = /* @__PURE__ */ q({
607
729
  logarithmicDepthBuffer: { type: Boolean, default: void 0 },
608
730
  failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
609
731
  },
610
- setup(e, { expose: a }) {
611
- var E;
612
- const t = e, { logWarning: r } = x(), n = B(), o = L(new je()), { resume: c } = se(), s = ye(), l = (E = J()) == null ? void 0 : E.appContext.app, i = (m) => q({
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({
613
735
  setup() {
614
- var d;
615
- const w = (d = J()) == null ? void 0 : d.appContext;
616
- return w && (w.app = l), V("useTres", m), V("extend", Y), () => K(he, null, s != null && s.default ? s.default() : []);
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() : []);
617
739
  }
618
- }), p = (m) => {
619
- const w = i(m);
620
- vt(K(w), o.value);
621
- }, f = (m, w = !1) => {
622
- o.value.children = [], w && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), p(m), c();
623
- }, u = b(() => t.disableRender), v = L(null);
624
- return a({ context: v, dispose: () => f(v.value, !0) }), we(() => {
625
- const m = n;
626
- v.value = mt({
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({
627
749
  scene: o.value,
628
- canvas: m,
750
+ canvas: p,
629
751
  windowSize: t.windowSize,
630
- disableRender: u,
752
+ disableRender: i,
631
753
  rendererOptions: t
632
- }), ct({ scene: o.value, contextParts: v.value });
633
- const { registerCamera: w, camera: d, cameras: h, deregisterCamera: P } = v.value;
634
- p(v.value);
635
- const A = () => {
636
- const C = new G(
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(
637
759
  45,
638
760
  window.innerWidth / window.innerHeight,
639
761
  0.1,
640
762
  1e3
641
763
  );
642
- C.position.set(3, 3, 3), C.lookAt(0, 0, 0), w(C);
643
- const k = D(() => {
644
- h.value.length >= 2 && (C.removeFromParent(), P(C), k == null || k());
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());
645
767
  });
646
768
  };
647
- re(
769
+ ne(
648
770
  () => t.camera,
649
- (C, k) => {
650
- C && w(C), k && (k.removeFromParent(), P(k));
771
+ (E, A) => {
772
+ E && y(E), A && (A.removeFromParent(), M(A));
651
773
  },
652
774
  {
653
775
  immediate: !0
654
776
  }
655
- ), d.value || (r(
777
+ ), b.value || (r(
656
778
  "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
657
- ), A());
658
- }), (m, w) => (Ee(), Ce("canvas", {
779
+ ), P());
780
+ }), (p, y) => (be(), Ce("canvas", {
659
781
  ref_key: "canvas",
660
782
  ref: n,
661
783
  "data-scene": o.value.uuid,
662
- class: _e(m.$attrs.class),
663
- style: Me({
784
+ class: _e(p.$attrs.class),
785
+ "data-tres": `tresjs ${Me(gt).version}`,
786
+ style: Pe({
664
787
  display: "block",
665
788
  width: "100%",
666
789
  height: "100%",
667
- position: m.windowSize ? "fixed" : "relative",
790
+ position: p.windowSize ? "fixed" : "relative",
668
791
  top: 0,
669
792
  left: 0,
670
793
  pointerEvents: "auto",
671
794
  touchAction: "none",
672
- ...m.$attrs.style
795
+ ...p.$attrs.style
673
796
  })
674
- }, null, 14, gt));
797
+ }, null, 14, $t));
675
798
  }
676
- }), wt = [
799
+ }), It = [
677
800
  "TresCanvas",
678
801
  "TresLeches",
679
802
  "TresScene"
680
- ], Et = {
803
+ ], Vt = {
681
804
  template: {
682
805
  compilerOptions: {
683
- isCustomElement: (e) => e.startsWith("Tres") && !wt.includes(e) || e === "primitive"
806
+ isCustomElement: (e) => e.startsWith("Tres") && !It.includes(e) || e === "primitive"
684
807
  }
685
808
  }
686
- }, Lt = Et, St = {
809
+ }, er = Vt, tr = {
687
810
  install(e) {
688
- e.component("TresCanvas", yt);
811
+ e.component("TresCanvas", Nt);
689
812
  }
690
813
  };
691
814
  export {
692
- yt as TresCanvas,
693
- W as catalogue,
694
- St as default,
815
+ Nt as TresCanvas,
816
+ q as catalogue,
817
+ tr as default,
695
818
  Y as extend,
696
- Pt as isProd,
697
- Xe as normalizeColor,
698
- At as normalizeVectorFlexibleParam,
699
- Lt as templateCompilerOptions,
700
- ut as trasverseObjects,
701
- Ye as useCamera,
702
- kt as useLoader,
703
- x as useLogger,
704
- ct as usePointerEventHandler,
705
- lt as useRaycaster,
706
- se as useRenderLoop,
707
- st as useRenderer,
708
- Dt as useSeek,
709
- bt as useTexture,
710
- Tt as useTres,
711
- pt as useTresContext,
712
- mt as useTresContextProvider
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
713
836
  };