@tresjs/core 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tres.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.3.
|
|
3
|
+
* version: v4.3.1
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
var Et = Object.defineProperty;
|
|
9
9
|
var Tt = (e, t, n) => t in e ? Et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
10
10
|
var he = (e, t, n) => Tt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
11
|
-
import { defineComponent as fe, withAsyncContext as nt, reactive as Se, renderSlot as rt, unref as W, ref as I, computed as
|
|
11
|
+
import { defineComponent as fe, withAsyncContext as nt, reactive as Se, renderSlot as rt, unref as W, ref as I, computed as K, watchEffect as xe, onUnmounted as J, shallowRef as $, watch as ae, readonly as we, provide as le, inject as St, isRef as xt, useSlots as At, getCurrentInstance as He, onMounted as kt, openBlock as Lt, createElementBlock as Rt, normalizeClass as Ot, normalizeStyle as Dt, createRenderer as jt, h as Ue, Fragment as Bt } from "vue";
|
|
12
12
|
import * as ot from "three";
|
|
13
|
-
import { Scene as st, Vector3 as Ae, MathUtils as it, MeshBasicMaterial as at, DoubleSide as It, TextureLoader as $t, PerspectiveCamera as be, Camera as Ht, Clock as lt, REVISION as Ut, Color as Z, SRGBColorSpace as Ft, ACESFilmicToneMapping as ct, PCFSoftShadowMap as Wt, NoToneMapping as Nt, WebGLRenderer as ge, Vector2 as ve, Raycaster as zt, BufferAttribute as Gt, Object3D as Vt, ArrowHelper as Yt, Line as qt, BufferGeometry as Fe, Float32BufferAttribute as We, LineBasicMaterial as
|
|
13
|
+
import { Scene as st, Vector3 as Ae, MathUtils as it, MeshBasicMaterial as at, DoubleSide as It, TextureLoader as $t, PerspectiveCamera as be, Camera as Ht, Clock as lt, REVISION as Ut, Color as Z, SRGBColorSpace as Ft, ACESFilmicToneMapping as ct, PCFSoftShadowMap as Wt, NoToneMapping as Nt, WebGLRenderer as ge, Vector2 as ve, Raycaster as zt, BufferAttribute as Gt, Object3D as Vt, ArrowHelper as Yt, Line as qt, BufferGeometry as Fe, Float32BufferAttribute as We, LineBasicMaterial as Kt, Mesh as Jt, BackSide as Qt, DirectionalLightHelper as Xt, PointLightHelper as Zt, SpotLightHelper as en, HemisphereLightHelper as tn } from "three";
|
|
14
14
|
import { tryOnScopeDispose as nn, toValue as x, unrefElement as rn, useDevicePixelRatio as on, useWindowSize as sn, useElementSize as an, refDebounced as Ne, usePointer as ln, useElementBounding as cn, createEventHook as D, useFps as un, useMemory as fn, useRafFn as ut } from "@vueuse/core";
|
|
15
|
-
const
|
|
15
|
+
const dn = "@tresjs/core", pn = "module", mn = "4.3.1", hn = "pnpm@9.1.4", gn = "Declarative ThreeJS using Vue Components", vn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", yn = "MIT", _n = {
|
|
16
16
|
type: "git",
|
|
17
17
|
url: "git+https://github.com/Tresjs/tres.git"
|
|
18
18
|
}, wn = [
|
|
@@ -69,49 +69,49 @@ const pn = "@tresjs/core", dn = "module", mn = "4.3.0", hn = "pnpm@9.1.4", gn =
|
|
|
69
69
|
"@vue/devtools-api": "^6.6.3",
|
|
70
70
|
"@vueuse/core": "^11.1.0"
|
|
71
71
|
}, Ln = {
|
|
72
|
-
"@release-it/conventional-changelog": "^
|
|
72
|
+
"@release-it/conventional-changelog": "^9.0.0",
|
|
73
73
|
"@stackblitz/sdk": "^1.11.0",
|
|
74
|
-
"@tresjs/cientos": "4.0.
|
|
75
|
-
"@tresjs/eslint-config": "^1.
|
|
76
|
-
"@types/three": "^0.
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
78
|
-
"@typescript-eslint/parser": "^8.
|
|
79
|
-
"@vitejs/plugin-vue": "^5.1.
|
|
74
|
+
"@tresjs/cientos": "4.0.3",
|
|
75
|
+
"@tresjs/eslint-config": "^1.4.0",
|
|
76
|
+
"@types/three": "^0.169.0",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.8.1",
|
|
78
|
+
"@typescript-eslint/parser": "^8.8.1",
|
|
79
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
80
80
|
"@vitest/coverage-c8": "^0.33.0",
|
|
81
|
-
"@vitest/coverage-v8": "^2.1.
|
|
82
|
-
"@vitest/ui": "^2.1.
|
|
81
|
+
"@vitest/coverage-v8": "^2.1.2",
|
|
82
|
+
"@vitest/ui": "^2.1.2",
|
|
83
83
|
"@vue/test-utils": "^2.4.6",
|
|
84
|
-
eslint: "^9.
|
|
85
|
-
"eslint-plugin-vue": "^9.
|
|
86
|
-
esno: "^4.
|
|
84
|
+
eslint: "^9.12.0",
|
|
85
|
+
"eslint-plugin-vue": "^9.29.0",
|
|
86
|
+
esno: "^4.8.0",
|
|
87
87
|
gsap: "^3.12.5",
|
|
88
88
|
husky: "^9.1.6",
|
|
89
|
-
jsdom: "^25.0.
|
|
89
|
+
jsdom: "^25.0.1",
|
|
90
90
|
kolorist: "^1.8.0",
|
|
91
91
|
ohmyfetch: "^0.4.21",
|
|
92
92
|
pathe: "^1.1.2",
|
|
93
|
-
"release-it": "^17.
|
|
93
|
+
"release-it": "^17.8.2",
|
|
94
94
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
95
95
|
"rollup-plugin-copy": "^3.5.0",
|
|
96
96
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
97
97
|
sponsorkit: "^0.15.5",
|
|
98
|
-
three: "^0.
|
|
99
|
-
unocss: "^0.
|
|
98
|
+
three: "^0.169.0",
|
|
99
|
+
unocss: "^0.63.4",
|
|
100
100
|
unplugin: "^1.14.1",
|
|
101
101
|
"unplugin-vue-components": "^0.27.4",
|
|
102
|
-
vite: "^5.4.
|
|
102
|
+
vite: "^5.4.8",
|
|
103
103
|
"vite-plugin-banner": "^0.8.0",
|
|
104
|
-
"vite-plugin-dts": "4.2.
|
|
104
|
+
"vite-plugin-dts": "4.2.4",
|
|
105
105
|
"vite-plugin-inspect": "^0.8.7",
|
|
106
106
|
"vite-plugin-require-transform": "^1.0.21",
|
|
107
107
|
"vite-svg-loader": "^5.1.0",
|
|
108
|
-
vitepress: "1.
|
|
109
|
-
vitest: "^2.1.
|
|
110
|
-
vue: "3.5.
|
|
108
|
+
vitepress: "1.4.0",
|
|
109
|
+
vitest: "^2.1.2",
|
|
110
|
+
vue: "3.5.12",
|
|
111
111
|
"vue-demi": "^0.14.10"
|
|
112
|
-
},
|
|
113
|
-
name:
|
|
114
|
-
type:
|
|
112
|
+
}, Rn = {
|
|
113
|
+
name: dn,
|
|
114
|
+
type: pn,
|
|
115
115
|
version: mn,
|
|
116
116
|
packageManager: hn,
|
|
117
117
|
description: gn,
|
|
@@ -131,7 +131,7 @@ const pn = "@tresjs/core", dn = "module", mn = "4.3.0", hn = "pnpm@9.1.4", gn =
|
|
|
131
131
|
dependencies: kn,
|
|
132
132
|
devDependencies: Ln
|
|
133
133
|
};
|
|
134
|
-
function
|
|
134
|
+
function On(e) {
|
|
135
135
|
const t = { nodes: {}, materials: {} };
|
|
136
136
|
return e && e.traverse((n) => {
|
|
137
137
|
n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
|
|
@@ -144,7 +144,7 @@ async function Dn(e, t, n, r, s) {
|
|
|
144
144
|
t,
|
|
145
145
|
(o) => {
|
|
146
146
|
const f = o;
|
|
147
|
-
f.scene && Object.assign(f,
|
|
147
|
+
f.scene && Object.assign(f, On(f.scene)), a(f);
|
|
148
148
|
},
|
|
149
149
|
r,
|
|
150
150
|
(o) => {
|
|
@@ -153,7 +153,7 @@ async function Dn(e, t, n, r, s) {
|
|
|
153
153
|
);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
const
|
|
156
|
+
const Yr = /* @__PURE__ */ fe({
|
|
157
157
|
__name: "component",
|
|
158
158
|
props: {
|
|
159
159
|
loader: {},
|
|
@@ -180,7 +180,7 @@ class jn extends ot.Mesh {
|
|
|
180
180
|
function Me(e) {
|
|
181
181
|
return typeof e > "u";
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function de(e) {
|
|
184
184
|
return Array.isArray(e);
|
|
185
185
|
}
|
|
186
186
|
function Bn(e) {
|
|
@@ -193,7 +193,7 @@ function G(e) {
|
|
|
193
193
|
return typeof e == "function";
|
|
194
194
|
}
|
|
195
195
|
function H(e) {
|
|
196
|
-
return e === Object(e) && !
|
|
196
|
+
return e === Object(e) && !de(e) && !G(e);
|
|
197
197
|
}
|
|
198
198
|
function N(e) {
|
|
199
199
|
return H(e) && "isObject3D" in e && !!e.isObject3D;
|
|
@@ -222,9 +222,9 @@ function re(e) {
|
|
|
222
222
|
function Wn(e) {
|
|
223
223
|
return H(e) && !!e.isPrimitive;
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const dt = (e, t) => {
|
|
226
226
|
for (const n of Object.keys(t))
|
|
227
|
-
t[n] instanceof Object && Object.assign(t[n],
|
|
227
|
+
t[n] instanceof Object && Object.assign(t[n], dt(e[n], t[n]));
|
|
228
228
|
return Object.assign(e || {}, t), e;
|
|
229
229
|
}, Nn = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", zn = /* @__PURE__ */ Yn(Nn);
|
|
230
230
|
function Ge(e) {
|
|
@@ -252,7 +252,7 @@ const Ve = (e, t) => {
|
|
|
252
252
|
const r = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
|
|
253
253
|
r && r.reduce((s, l, i) => (s[l] === void 0 && (s[l] = {}), i === r.length - 1 && (s[l] = n), s[l]), e);
|
|
254
254
|
};
|
|
255
|
-
function
|
|
255
|
+
function pt(e, t) {
|
|
256
256
|
if (Ge(e) && Ge(t)) {
|
|
257
257
|
const s = e.attributes, l = t.attributes;
|
|
258
258
|
return s.length !== l.length ? !1 : Array.from(s).every(({ name: i, value: a }) => t.getAttribute(i) === a);
|
|
@@ -265,19 +265,19 @@ function dt(e, t) {
|
|
|
265
265
|
if (n.length !== r.length)
|
|
266
266
|
return !1;
|
|
267
267
|
for (const s of n)
|
|
268
|
-
if (!r.includes(s) || !
|
|
268
|
+
if (!r.includes(s) || !pt(e[s], t[s]))
|
|
269
269
|
return !1;
|
|
270
270
|
return !0;
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Kn(e, t) {
|
|
273
273
|
if (!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length)
|
|
274
274
|
return !1;
|
|
275
275
|
for (let n = 0; n < e.length; n++)
|
|
276
|
-
if (!
|
|
276
|
+
if (!pt(e[n], t[n]))
|
|
277
277
|
return !1;
|
|
278
278
|
return !0;
|
|
279
279
|
}
|
|
280
|
-
const
|
|
280
|
+
const Jn = Array.isArray;
|
|
281
281
|
function Qn(e, t, n, r) {
|
|
282
282
|
const s = (c) => {
|
|
283
283
|
if (c.uuid === t)
|
|
@@ -354,11 +354,11 @@ function Pe(e, t) {
|
|
|
354
354
|
function qe(...e) {
|
|
355
355
|
return e.map((t, n) => n === 0 ? t : t.charAt(0).toUpperCase() + t.slice(1)).join("");
|
|
356
356
|
}
|
|
357
|
-
const
|
|
357
|
+
const Ke = /-\d+$/;
|
|
358
358
|
function nr(e, t, n) {
|
|
359
359
|
if (ft(n)) {
|
|
360
|
-
if (
|
|
361
|
-
const l = n.replace(
|
|
360
|
+
if (Ke.test(n)) {
|
|
361
|
+
const l = n.replace(Ke, ""), { target: i, key: a } = Pe(e, l);
|
|
362
362
|
if (!Array.isArray(i[a])) {
|
|
363
363
|
const c = i[a], o = [];
|
|
364
364
|
o.__tresDetach = () => {
|
|
@@ -404,7 +404,7 @@ function or(e, t, n) {
|
|
|
404
404
|
if (!G(e.setPixelRatio))
|
|
405
405
|
return;
|
|
406
406
|
let r = 0;
|
|
407
|
-
if (
|
|
407
|
+
if (de(n) && n.length >= 2) {
|
|
408
408
|
const [l, i] = n;
|
|
409
409
|
r = it.clamp(t, l, i);
|
|
410
410
|
} else Bn(n) ? r = n : r = t;
|
|
@@ -452,7 +452,7 @@ async function ir(e, t) {
|
|
|
452
452
|
}
|
|
453
453
|
);
|
|
454
454
|
});
|
|
455
|
-
if (
|
|
455
|
+
if (Jn(e)) {
|
|
456
456
|
const s = await Promise.all(e.map((l) => r(l)));
|
|
457
457
|
return e.length > 1 ? s : s[0];
|
|
458
458
|
} else {
|
|
@@ -478,7 +478,7 @@ async function ir(e, t) {
|
|
|
478
478
|
};
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
const
|
|
481
|
+
const qr = /* @__PURE__ */ fe({
|
|
482
482
|
__name: "component",
|
|
483
483
|
props: {
|
|
484
484
|
map: {},
|
|
@@ -496,7 +496,7 @@ const Jr = /* @__PURE__ */ fe({
|
|
|
496
496
|
return (l, i) => rt(l.$slots, "default", { textures: W(s) });
|
|
497
497
|
}
|
|
498
498
|
}), ar = ({ sizes: e }) => {
|
|
499
|
-
const t = I([]), n =
|
|
499
|
+
const t = I([]), n = K(
|
|
500
500
|
() => t.value[0]
|
|
501
501
|
), r = (i) => {
|
|
502
502
|
const a = i instanceof Ht ? i : t.value.find((o) => o.uuid === i);
|
|
@@ -521,7 +521,7 @@ const Jr = /* @__PURE__ */ fe({
|
|
|
521
521
|
e.aspectRatio.value && t.value.forEach((i) => {
|
|
522
522
|
!i.manual && (i instanceof be || lr(i)) && (i instanceof be ? i.aspect = e.aspectRatio.value : (i.left = e.width.value * -0.5, i.right = e.width.value * 0.5, i.top = e.height.value * 0.5, i.bottom = e.height.value * -0.5), i.updateProjectionMatrix());
|
|
523
523
|
});
|
|
524
|
-
}),
|
|
524
|
+
}), J(() => {
|
|
525
525
|
t.value = [];
|
|
526
526
|
}), {
|
|
527
527
|
camera: n,
|
|
@@ -534,12 +534,12 @@ const Jr = /* @__PURE__ */ fe({
|
|
|
534
534
|
function lr(e) {
|
|
535
535
|
return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera;
|
|
536
536
|
}
|
|
537
|
-
const Kr = !0,
|
|
537
|
+
const Kr = !0, pe = "[TresJS ▲ ■ ●] ";
|
|
538
538
|
function cr(...e) {
|
|
539
|
-
typeof e[0] == "string" ? e[0] =
|
|
539
|
+
typeof e[0] == "string" ? e[0] = pe + e[0] : e.unshift(pe), console.error(...e);
|
|
540
540
|
}
|
|
541
541
|
function ur(...e) {
|
|
542
|
-
typeof e[0] == "string" ? e[0] =
|
|
542
|
+
typeof e[0] == "string" ? e[0] = pe + e[0] : e.unshift(pe), console.warn(...e);
|
|
543
543
|
}
|
|
544
544
|
function fr(e, t) {
|
|
545
545
|
}
|
|
@@ -577,41 +577,41 @@ function ye() {
|
|
|
577
577
|
return e.size;
|
|
578
578
|
} };
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function dr() {
|
|
581
581
|
let e = !0, t = !0, n = !1;
|
|
582
582
|
const r = new lt(!1), s = I(r.running), l = I(!1);
|
|
583
583
|
let i;
|
|
584
584
|
const a = it.generateUUID();
|
|
585
585
|
let c = null;
|
|
586
586
|
const o = ye(), f = ye(), y = ye();
|
|
587
|
-
|
|
587
|
+
E();
|
|
588
588
|
let u = {};
|
|
589
589
|
function v(M) {
|
|
590
590
|
u = M;
|
|
591
591
|
}
|
|
592
|
-
function h(M, A,
|
|
592
|
+
function h(M, A, p = 0) {
|
|
593
593
|
switch (A) {
|
|
594
594
|
case "before":
|
|
595
|
-
return o.on(M,
|
|
595
|
+
return o.on(M, p);
|
|
596
596
|
case "render":
|
|
597
597
|
return c || (c = M), f.dispose(), f.on(M);
|
|
598
598
|
case "after":
|
|
599
|
-
return y.on(M,
|
|
599
|
+
return y.on(M, p);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
function g() {
|
|
603
|
-
t && (t = !1,
|
|
603
|
+
t && (t = !1, E(), b());
|
|
604
604
|
}
|
|
605
|
-
function
|
|
606
|
-
t = !0,
|
|
605
|
+
function d() {
|
|
606
|
+
t = !0, E(), cancelAnimationFrame(i);
|
|
607
607
|
}
|
|
608
608
|
function _() {
|
|
609
|
-
n = !1,
|
|
609
|
+
n = !1, E();
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
n = !0,
|
|
611
|
+
function P() {
|
|
612
|
+
n = !0, E();
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function C() {
|
|
615
615
|
l.value = !0;
|
|
616
616
|
}
|
|
617
617
|
function T() {
|
|
@@ -622,7 +622,7 @@ function pr() {
|
|
|
622
622
|
i = requestAnimationFrame(b);
|
|
623
623
|
return;
|
|
624
624
|
}
|
|
625
|
-
const M = r.getDelta(), A = r.getElapsedTime(),
|
|
625
|
+
const M = r.getDelta(), A = r.getElapsedTime(), p = {
|
|
626
626
|
camera: W(u.camera),
|
|
627
627
|
scene: W(u.scene),
|
|
628
628
|
renderer: W(u.renderer),
|
|
@@ -630,21 +630,21 @@ function pr() {
|
|
|
630
630
|
controls: W(u.controls),
|
|
631
631
|
invalidate: u.invalidate,
|
|
632
632
|
advance: u.advance
|
|
633
|
-
}, w = { delta: M, elapsed: A, clock: r, ...
|
|
633
|
+
}, w = { delta: M, elapsed: A, clock: r, ...p };
|
|
634
634
|
s.value && o.trigger(w), l.value || (f.count ? f.trigger(w) : c && c(w)), s.value && y.trigger(w), i = requestAnimationFrame(b);
|
|
635
635
|
}
|
|
636
|
-
function
|
|
636
|
+
function E() {
|
|
637
637
|
const M = !t && !n;
|
|
638
638
|
r.running !== M && (r.running ? r.stop() : r.start()), s.value = r.running;
|
|
639
639
|
}
|
|
640
640
|
return {
|
|
641
641
|
loopId: a,
|
|
642
|
-
register: (M, A,
|
|
642
|
+
register: (M, A, p) => h(M, A, p),
|
|
643
643
|
start: g,
|
|
644
|
-
stop:
|
|
645
|
-
pause:
|
|
644
|
+
stop: d,
|
|
645
|
+
pause: P,
|
|
646
646
|
resume: _,
|
|
647
|
-
pauseRender:
|
|
647
|
+
pauseRender: C,
|
|
648
648
|
resumeRender: T,
|
|
649
649
|
isRenderPaused: l,
|
|
650
650
|
isActive: s,
|
|
@@ -661,11 +661,11 @@ function ke(e) {
|
|
|
661
661
|
}
|
|
662
662
|
}), t;
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function pr(e) {
|
|
665
665
|
return (e / 1024).toFixed(2);
|
|
666
666
|
}
|
|
667
667
|
const mr = Number.parseInt(Ut.replace("dev", ""));
|
|
668
|
-
function
|
|
668
|
+
function Jr(e) {
|
|
669
669
|
return typeof e == "number" ? [e, e, e] : e instanceof Ae ? [e.x, e.y, e.z] : e;
|
|
670
670
|
}
|
|
671
671
|
function hr(e) {
|
|
@@ -693,7 +693,7 @@ function gr({
|
|
|
693
693
|
options: t,
|
|
694
694
|
contextParts: { sizes: n, render: r, invalidate: s, advance: l }
|
|
695
695
|
}) {
|
|
696
|
-
const i =
|
|
696
|
+
const i = K(() => ({
|
|
697
697
|
alpha: x(t.alpha) ?? !0,
|
|
698
698
|
depth: x(t.depth),
|
|
699
699
|
canvas: rn(e),
|
|
@@ -733,31 +733,31 @@ function gr({
|
|
|
733
733
|
l();
|
|
734
734
|
}, 100), xe(() => {
|
|
735
735
|
const h = x(t.preset);
|
|
736
|
-
h && (h in se || f(`Renderer Preset must be one of these: ${Object.keys(se).join(", ")}`),
|
|
737
|
-
const g = (
|
|
738
|
-
const T = x(
|
|
736
|
+
h && (h in se || f(`Renderer Preset must be one of these: ${Object.keys(se).join(", ")}`), dt(a.value, se[h])), or(a.value, o.value, x(t.dpr)), v === "always" && (r.frames.value = Math.max(1, r.frames.value));
|
|
737
|
+
const g = (P, C) => {
|
|
738
|
+
const T = x(P), b = () => {
|
|
739
739
|
if (h)
|
|
740
|
-
return Ve(se[h],
|
|
740
|
+
return Ve(se[h], C);
|
|
741
741
|
};
|
|
742
742
|
if (T !== void 0)
|
|
743
743
|
return T;
|
|
744
|
-
const
|
|
745
|
-
return
|
|
746
|
-
},
|
|
747
|
-
|
|
744
|
+
const E = b();
|
|
745
|
+
return E !== void 0 ? E : Ve(u, C);
|
|
746
|
+
}, d = (P, C) => qn(a.value, C, g(P, C));
|
|
747
|
+
d(t.shadows, "shadowMap.enabled"), d(t.toneMapping ?? ct, "toneMapping"), d(t.shadowMapType, "shadowMap.type"), mr < 150 && d(!t.useLegacyLights, "physicallyCorrectLights"), d(t.outputColorSpace, "outputColorSpace"), d(t.toneMappingExposure, "toneMappingExposure");
|
|
748
748
|
const _ = g(t.clearColor, "clearColor");
|
|
749
749
|
_ && a.value.setClearColor(
|
|
750
750
|
_ ? hr(_) : new Z(0)
|
|
751
751
|
// default clear color is not easily/efficiently retrievable from three
|
|
752
752
|
);
|
|
753
|
-
}),
|
|
753
|
+
}), J(() => {
|
|
754
754
|
a.value.dispose(), a.value.forceContextLoss();
|
|
755
755
|
}), {
|
|
756
756
|
renderer: a
|
|
757
757
|
};
|
|
758
758
|
}
|
|
759
759
|
function vr(e, t, n = 10) {
|
|
760
|
-
const r = x(e) ? sn() : an(
|
|
760
|
+
const r = x(e) ? sn() : an(K(() => x(t).parentElement)), s = we(Ne(r.width, n)), l = we(Ne(r.height, n)), i = K(() => s.value / l.value);
|
|
761
761
|
return {
|
|
762
762
|
height: l,
|
|
763
763
|
width: s,
|
|
@@ -765,7 +765,7 @@ function vr(e, t, n = 10) {
|
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
767
|
const yr = (e, t) => {
|
|
768
|
-
const n =
|
|
768
|
+
const n = K(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = ln({ target: n });
|
|
769
769
|
let i = 0;
|
|
770
770
|
const { width: a, height: c, top: o, left: f } = cn(n), y = ({ x: m, y: S }) => {
|
|
771
771
|
if (n.value)
|
|
@@ -782,8 +782,8 @@ const yr = (e, t) => {
|
|
|
782
782
|
y: (m == null ? void 0 : m.clientY) ?? l.value
|
|
783
783
|
});
|
|
784
784
|
return S ? u(S) || [] : [];
|
|
785
|
-
}, h = D(), g = D(),
|
|
786
|
-
function
|
|
785
|
+
}, h = D(), g = D(), d = D(), _ = D(), P = D(), C = D(), T = D(), b = D();
|
|
786
|
+
function E(m) {
|
|
787
787
|
const S = {};
|
|
788
788
|
for (const U in m)
|
|
789
789
|
typeof U != "function" && (S[U] = m[U]);
|
|
@@ -791,7 +791,7 @@ const yr = (e, t) => {
|
|
|
791
791
|
}
|
|
792
792
|
const M = (m, S) => {
|
|
793
793
|
var Be, Ie, $e;
|
|
794
|
-
const U =
|
|
794
|
+
const U = E(S), ne = new Ae(S == null ? void 0 : S.clientX, S == null ? void 0 : S.clientY, 0).unproject((Be = t.camera) == null ? void 0 : Be.value);
|
|
795
795
|
m.trigger({
|
|
796
796
|
...U,
|
|
797
797
|
intersections: r.value,
|
|
@@ -805,40 +805,40 @@ const yr = (e, t) => {
|
|
|
805
805
|
});
|
|
806
806
|
};
|
|
807
807
|
let A;
|
|
808
|
-
const
|
|
809
|
-
v(m), M(
|
|
808
|
+
const p = (m) => {
|
|
809
|
+
v(m), M(d, m), A = m;
|
|
810
810
|
}, w = () => {
|
|
811
|
-
A &&
|
|
811
|
+
A && p(A);
|
|
812
812
|
};
|
|
813
|
-
let k, L,
|
|
813
|
+
let k, L, R;
|
|
814
814
|
const j = (m) => {
|
|
815
815
|
var S;
|
|
816
816
|
k = (S = r.value[0]) == null ? void 0 : S.object, i = 0, L = new ve(
|
|
817
817
|
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
818
818
|
(m == null ? void 0 : m.clientY) ?? l.value
|
|
819
|
-
), M(
|
|
819
|
+
), M(P, m);
|
|
820
820
|
};
|
|
821
|
-
let
|
|
822
|
-
const
|
|
821
|
+
let O, Y = !1;
|
|
822
|
+
const Re = (m) => {
|
|
823
823
|
var S, U, ne;
|
|
824
|
-
m instanceof PointerEvent && (r.value.length === 0 && M(
|
|
824
|
+
m instanceof PointerEvent && (r.value.length === 0 && M(C, m), k === ((S = r.value[0]) == null ? void 0 : S.object) && (R = new ve(
|
|
825
825
|
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
826
826
|
(m == null ? void 0 : m.clientY) ?? l.value
|
|
827
|
-
), i = L == null ? void 0 : L.distanceTo(
|
|
828
|
-
},
|
|
829
|
-
Y && (M(g, m),
|
|
830
|
-
}, De = (m) => M(
|
|
831
|
-
return n.value.addEventListener("pointerup",
|
|
832
|
-
n != null && n.value && (n.value.removeEventListener("pointerup",
|
|
827
|
+
), i = L == null ? void 0 : L.distanceTo(R), m.button === 0 ? (M(h, m), O === ((U = r.value[0]) == null ? void 0 : U.object) ? Y = !0 : (O = (ne = r.value[0]) == null ? void 0 : ne.object, Y = !1)) : m.button === 2 && M(T, m)), M(_, m));
|
|
828
|
+
}, Oe = (m) => {
|
|
829
|
+
Y && (M(g, m), O = void 0, Y = !1);
|
|
830
|
+
}, De = (m) => M(d, m), je = (m) => M(b, m);
|
|
831
|
+
return n.value.addEventListener("pointerup", Re), n.value.addEventListener("pointerdown", j), n.value.addEventListener("pointermove", p), n.value.addEventListener("pointerleave", De), n.value.addEventListener("dblclick", Oe), n.value.addEventListener("wheel", je), J(() => {
|
|
832
|
+
n != null && n.value && (n.value.removeEventListener("pointerup", Re), n.value.removeEventListener("pointerdown", j), n.value.removeEventListener("pointermove", p), n.value.removeEventListener("pointerleave", De), n.value.removeEventListener("dblclick", Oe), n.value.removeEventListener("wheel", je));
|
|
833
833
|
}), {
|
|
834
834
|
intersects: r,
|
|
835
835
|
onClick: (m) => h.on(m).off,
|
|
836
836
|
onDblClick: (m) => g.on(m).off,
|
|
837
837
|
onContextMenu: (m) => T.on(m).off,
|
|
838
|
-
onPointerMove: (m) =>
|
|
838
|
+
onPointerMove: (m) => d.on(m).off,
|
|
839
839
|
onPointerUp: (m) => _.on(m).off,
|
|
840
|
-
onPointerDown: (m) =>
|
|
841
|
-
onPointerMissed: (m) =>
|
|
840
|
+
onPointerDown: (m) => P.on(m).off,
|
|
841
|
+
onPointerMissed: (m) => C.on(m).off,
|
|
842
842
|
onWheel: (m) => b.on(m).off,
|
|
843
843
|
forceUpdate: w
|
|
844
844
|
};
|
|
@@ -853,27 +853,27 @@ function _r(e, t, n) {
|
|
|
853
853
|
var A;
|
|
854
854
|
const r = $(), s = $();
|
|
855
855
|
e && (r.value = e), t && (s.value = t);
|
|
856
|
-
const l = (
|
|
856
|
+
const l = (p) => {
|
|
857
857
|
var w;
|
|
858
|
-
return ((w =
|
|
859
|
-
}, i = (
|
|
858
|
+
return ((w = p.__tres) == null ? void 0 : w.eventCount) > 0;
|
|
859
|
+
}, i = (p) => {
|
|
860
860
|
var w;
|
|
861
|
-
return ((w =
|
|
861
|
+
return ((w = p.children) == null ? void 0 : w.some((k) => i(k))) || l(p);
|
|
862
862
|
}, a = $(((A = r.value) == null ? void 0 : A.children).filter(i) || []);
|
|
863
|
-
function c(
|
|
863
|
+
function c(p, w) {
|
|
864
864
|
const k = [], L = () => w.stopPropagating = !0;
|
|
865
865
|
w.stopPropagation = L;
|
|
866
|
-
for (const
|
|
866
|
+
for (const R of w == null ? void 0 : w.intersections) {
|
|
867
867
|
if (w.stopPropagating)
|
|
868
868
|
return;
|
|
869
|
-
w = { ...w, ...
|
|
870
|
-
const { object: j } =
|
|
871
|
-
w.eventObject = j, _e(j[
|
|
872
|
-
let
|
|
873
|
-
for (;
|
|
874
|
-
w.eventObject =
|
|
875
|
-
const Y = Vn(
|
|
876
|
-
n(Y, { intersection:
|
|
869
|
+
w = { ...w, ...R };
|
|
870
|
+
const { object: j } = R;
|
|
871
|
+
w.eventObject = j, _e(j[p], w), k.push(j);
|
|
872
|
+
let O = j.parent;
|
|
873
|
+
for (; O !== null && !w.stopPropagating && !k.includes(O); )
|
|
874
|
+
w.eventObject = O, _e(O[p], w), k.push(O), O = O.parent;
|
|
875
|
+
const Y = Vn(p.slice(2));
|
|
876
|
+
n(Y, { intersection: R, event: w });
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
879
|
const {
|
|
@@ -884,55 +884,55 @@ function _r(e, t, n) {
|
|
|
884
884
|
onPointerDown: v,
|
|
885
885
|
onPointerUp: h,
|
|
886
886
|
onPointerMissed: g,
|
|
887
|
-
onWheel:
|
|
887
|
+
onWheel: d,
|
|
888
888
|
forceUpdate: _
|
|
889
889
|
} = yr(a, t);
|
|
890
|
-
h((
|
|
891
|
-
let
|
|
892
|
-
u((
|
|
893
|
-
const w =
|
|
894
|
-
|
|
895
|
-
w.includes(L) || (
|
|
896
|
-
}),
|
|
897
|
-
|
|
898
|
-
}), c("onPointerMove",
|
|
890
|
+
h((p) => c("onPointerUp", p)), v((p) => c("onPointerDown", p)), o((p) => c("onClick", p)), f((p) => c("onDoubleClick", p)), y((p) => c("onContextMenu", p)), d((p) => c("onWheel", p));
|
|
891
|
+
let P = [];
|
|
892
|
+
u((p) => {
|
|
893
|
+
const w = p.intersections.map(({ object: L }) => L), k = p.intersections;
|
|
894
|
+
P.forEach(({ object: L }) => {
|
|
895
|
+
w.includes(L) || (p.intersections = P, c("onPointerLeave", p), c("onPointerOut", p));
|
|
896
|
+
}), p.intersections = k, p.intersections.forEach(({ object: L }) => {
|
|
897
|
+
P.includes(L) || (c("onPointerEnter", p), c("onPointerOver", p));
|
|
898
|
+
}), c("onPointerMove", p), P = p.intersections;
|
|
899
899
|
});
|
|
900
|
-
const
|
|
901
|
-
g((
|
|
902
|
-
const w = () =>
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}), n("pointer-missed", { event:
|
|
900
|
+
const C = [];
|
|
901
|
+
g((p) => {
|
|
902
|
+
const w = () => p.stopPropagating = !0;
|
|
903
|
+
p.stopPropagation = w, C.forEach((k) => {
|
|
904
|
+
p.stopPropagating || (p.eventObject = k, _e(k.onPointerMissed, p));
|
|
905
|
+
}), n("pointer-missed", { event: p });
|
|
906
906
|
});
|
|
907
|
-
function T(
|
|
908
|
-
re(
|
|
907
|
+
function T(p) {
|
|
908
|
+
re(p) && N(p) && a.value.push(p);
|
|
909
909
|
}
|
|
910
|
-
function b(
|
|
911
|
-
if (re(
|
|
912
|
-
const w = a.value.indexOf(
|
|
910
|
+
function b(p) {
|
|
911
|
+
if (re(p) && N(p)) {
|
|
912
|
+
const w = a.value.indexOf(p);
|
|
913
913
|
w > -1 && a.value.splice(w, 1);
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
|
-
function
|
|
917
|
-
re(
|
|
916
|
+
function E(p) {
|
|
917
|
+
re(p) && N(p) && p.onPointerMissed && C.push(p);
|
|
918
918
|
}
|
|
919
|
-
function M(
|
|
920
|
-
if (re(
|
|
921
|
-
const w =
|
|
922
|
-
w > -1 &&
|
|
919
|
+
function M(p) {
|
|
920
|
+
if (re(p) && N(p)) {
|
|
921
|
+
const w = C.indexOf(p);
|
|
922
|
+
w > -1 && C.splice(w, 1);
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
925
|
return t.eventManager = {
|
|
926
926
|
forceUpdate: _,
|
|
927
927
|
registerObject: T,
|
|
928
928
|
deregisterObject: b,
|
|
929
|
-
registerPointerMissedObject:
|
|
929
|
+
registerPointerMissedObject: E,
|
|
930
930
|
deregisterPointerMissedObject: M
|
|
931
931
|
}, {
|
|
932
932
|
forceUpdate: _,
|
|
933
933
|
registerObject: T,
|
|
934
934
|
deregisterObject: b,
|
|
935
|
-
registerPointerMissedObject:
|
|
935
|
+
registerPointerMissedObject: E,
|
|
936
936
|
deregisterPointerMissedObject: M
|
|
937
937
|
};
|
|
938
938
|
}
|
|
@@ -979,7 +979,7 @@ function yt(e) {
|
|
|
979
979
|
}, e);
|
|
980
980
|
return ee.set(e, l), l;
|
|
981
981
|
}
|
|
982
|
-
function
|
|
982
|
+
function Qr(e) {
|
|
983
983
|
const t = me();
|
|
984
984
|
if (t)
|
|
985
985
|
return ee.has(t) ? ee.get(t).on(e) : yt(t).on(e);
|
|
@@ -1002,10 +1002,10 @@ function br({
|
|
|
1002
1002
|
priority: I(0),
|
|
1003
1003
|
frames: I(0),
|
|
1004
1004
|
maxFrames: 60,
|
|
1005
|
-
canBeInvalidated:
|
|
1005
|
+
canBeInvalidated: K(() => u.mode.value === "on-demand" && u.frames.value === 0)
|
|
1006
1006
|
};
|
|
1007
|
-
function v(
|
|
1008
|
-
r.renderMode === "on-demand" && (u.frames.value = Math.min(u.maxFrames, u.frames.value +
|
|
1007
|
+
function v(R = 1) {
|
|
1008
|
+
r.renderMode === "on-demand" && (u.frames.value = Math.min(u.maxFrames, u.frames.value + R));
|
|
1009
1009
|
}
|
|
1010
1010
|
function h() {
|
|
1011
1011
|
r.renderMode === "manual" && (u.frames.value = 1);
|
|
@@ -1019,7 +1019,7 @@ function br({
|
|
|
1019
1019
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
1020
1020
|
contextParts: { sizes: i, camera: a, render: u, invalidate: v, advance: h }
|
|
1021
1021
|
}
|
|
1022
|
-
),
|
|
1022
|
+
), d = {
|
|
1023
1023
|
sizes: i,
|
|
1024
1024
|
scene: l,
|
|
1025
1025
|
camera: a,
|
|
@@ -1046,31 +1046,31 @@ function br({
|
|
|
1046
1046
|
registerCamera: o,
|
|
1047
1047
|
setCameraActive: y,
|
|
1048
1048
|
deregisterCamera: f,
|
|
1049
|
-
loop:
|
|
1049
|
+
loop: dr()
|
|
1050
1050
|
};
|
|
1051
|
-
le("useTres",
|
|
1052
|
-
root:
|
|
1053
|
-
},
|
|
1054
|
-
a.value && u.frames.value > 0 && (g.value.render(e, a.value), s("render",
|
|
1051
|
+
le("useTres", d), d.scene.value.__tres = {
|
|
1052
|
+
root: d
|
|
1053
|
+
}, d.loop.register(() => {
|
|
1054
|
+
a.value && u.frames.value > 0 && (g.value.render(e, a.value), s("render", d.renderer.value)), u.priority.value = 0, u.mode.value === "always" ? u.frames.value = 1 : u.frames.value = Math.max(0, u.frames.value - 1);
|
|
1055
1055
|
}, "render");
|
|
1056
|
-
const { on: _, cancel:
|
|
1057
|
-
|
|
1058
|
-
s("ready",
|
|
1059
|
-
}),
|
|
1060
|
-
|
|
1056
|
+
const { on: _, cancel: P } = yt(d);
|
|
1057
|
+
d.loop.setReady(!1), d.loop.start(), _(() => {
|
|
1058
|
+
s("ready", d), d.loop.setReady(!0), _r(e, d, s);
|
|
1059
|
+
}), J(() => {
|
|
1060
|
+
P(), d.loop.stop();
|
|
1061
1061
|
});
|
|
1062
|
-
const
|
|
1062
|
+
const C = 100, T = un({ every: C }), { isSupported: b, memory: E } = fn({ interval: C }), M = 160;
|
|
1063
1063
|
let A = performance.now();
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1064
|
+
const p = ({ timestamp: R }) => {
|
|
1065
|
+
d.scene.value && (d.perf.memory.allocatedMem = ke(d.scene.value)), R - A >= C && (A = R, d.perf.fps.accumulator.push(T.value), d.perf.fps.accumulator.length > M && d.perf.fps.accumulator.shift(), d.perf.fps.value = T.value, b.value && E.value && (d.perf.memory.accumulator.push(E.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > M && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((j, O) => j + O, 0) / d.perf.memory.accumulator.length));
|
|
1066
1066
|
};
|
|
1067
1067
|
let w = 0;
|
|
1068
|
-
const k = 1, { pause: L } = ut(({ delta:
|
|
1069
|
-
window.__TRES__DEVTOOLS__ && (
|
|
1068
|
+
const k = 1, { pause: L } = ut(({ delta: R }) => {
|
|
1069
|
+
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += R, w >= k && (window.__TRES__DEVTOOLS__.cb(d), w = 0));
|
|
1070
1070
|
}, { immediate: !0 });
|
|
1071
|
-
return
|
|
1071
|
+
return J(() => {
|
|
1072
1072
|
L();
|
|
1073
|
-
}),
|
|
1073
|
+
}), d;
|
|
1074
1074
|
}
|
|
1075
1075
|
function me() {
|
|
1076
1076
|
const e = St("useTres");
|
|
@@ -1078,8 +1078,8 @@ function me() {
|
|
|
1078
1078
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
1079
1079
|
return e;
|
|
1080
1080
|
}
|
|
1081
|
-
const
|
|
1082
|
-
function
|
|
1081
|
+
const Xr = me;
|
|
1082
|
+
function Zr() {
|
|
1083
1083
|
const {
|
|
1084
1084
|
camera: e,
|
|
1085
1085
|
scene: t,
|
|
@@ -1121,7 +1121,7 @@ function eo() {
|
|
|
1121
1121
|
}
|
|
1122
1122
|
const _t = D(), wt = D(), Le = D(), te = new lt();
|
|
1123
1123
|
let ce = 0, ue = 0;
|
|
1124
|
-
const { pause: Mr, resume:
|
|
1124
|
+
const { pause: Mr, resume: Je, isActive: Pr } = ut(
|
|
1125
1125
|
() => {
|
|
1126
1126
|
_t.trigger({ delta: ce, elapsed: ue, clock: te }), wt.trigger({ delta: ce, elapsed: ue, clock: te }), Le.trigger({ delta: ce, elapsed: ue, clock: te });
|
|
1127
1127
|
},
|
|
@@ -1131,15 +1131,15 @@ Le.on(() => {
|
|
|
1131
1131
|
ce = te.getDelta(), ue = te.getElapsedTime();
|
|
1132
1132
|
});
|
|
1133
1133
|
let Qe = !1;
|
|
1134
|
-
const
|
|
1134
|
+
const eo = () => (Qe || (Qe = !0, Je()), {
|
|
1135
1135
|
onBeforeLoop: _t.on,
|
|
1136
1136
|
onLoop: wt.on,
|
|
1137
1137
|
onAfterLoop: Le.on,
|
|
1138
1138
|
pause: Mr,
|
|
1139
|
-
resume:
|
|
1139
|
+
resume: Je,
|
|
1140
1140
|
isActive: Pr
|
|
1141
1141
|
});
|
|
1142
|
-
function
|
|
1142
|
+
function to() {
|
|
1143
1143
|
const { logWarning: e } = V();
|
|
1144
1144
|
function t(l, i, a) {
|
|
1145
1145
|
let c = null;
|
|
@@ -1219,8 +1219,8 @@ const { logError: Xe } = V(), Ze = [
|
|
|
1219
1219
|
__tres: () => g
|
|
1220
1220
|
},
|
|
1221
1221
|
{
|
|
1222
|
-
object: (_,
|
|
1223
|
-
sr(_,
|
|
1222
|
+
object: (_, P, C, T) => {
|
|
1223
|
+
sr(_, C, T, { patchProp: l, remove: s, insert: r }, e);
|
|
1224
1224
|
},
|
|
1225
1225
|
__tres: (_) => {
|
|
1226
1226
|
Object.assign(g, _);
|
|
@@ -1251,14 +1251,14 @@ const { logError: Xe } = V(), Ze = [
|
|
|
1251
1251
|
o = Q(y), f = Q(u), o.__tres && ((v = o.__tres) == null ? void 0 : v.eventCount) > 0 && ((h = e.eventManager) == null || h.registerObject(o)), e.registerCamera(o), (g = e.eventManager) == null || g.registerPointerMissedObject(o), y.__tres.attach ? nr(u, y, y.__tres.attach) : N(o) && N(u) && (u.add(o), o.dispatchEvent({ type: "added" })), y.__tres.parent = u, u.__tres.objects && !u.__tres.objects.includes(y) && u.__tres.objects.push(y);
|
|
1252
1252
|
}
|
|
1253
1253
|
function s(o, f) {
|
|
1254
|
-
var h, g,
|
|
1254
|
+
var h, g, d, _;
|
|
1255
1255
|
if (!o)
|
|
1256
1256
|
return;
|
|
1257
1257
|
o != null && o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((g = e.eventManager) == null || g.deregisterObject(o)), f = Me(f) ? "default" : f;
|
|
1258
|
-
const y = (
|
|
1258
|
+
const y = (d = o.__tres) == null ? void 0 : d.dispose;
|
|
1259
1259
|
Me(y) || (y === null ? f = !1 : f = y);
|
|
1260
1260
|
const u = (_ = o.__tres) == null ? void 0 : _.primitive, v = f === "default" ? !u : !!f;
|
|
1261
|
-
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((
|
|
1261
|
+
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((P) => s(P, f)), v && o.children && [...o.children].forEach((P) => s(P, f)), gt(o, e), vt(o, e), v && !Fn(o)) {
|
|
1262
1262
|
if (G(f))
|
|
1263
1263
|
f(o);
|
|
1264
1264
|
else if (G(o.dispose))
|
|
@@ -1270,12 +1270,12 @@ const { logError: Xe } = V(), Ze = [
|
|
|
1270
1270
|
"__tres" in o && delete o.__tres;
|
|
1271
1271
|
}
|
|
1272
1272
|
function l(o, f, y, u) {
|
|
1273
|
-
var
|
|
1273
|
+
var P, C;
|
|
1274
1274
|
if (!o)
|
|
1275
1275
|
return;
|
|
1276
1276
|
let v = o, h = f;
|
|
1277
1277
|
if (o.__tres && (o.__tres.memoizedProps[f] = u), f === "attach") {
|
|
1278
|
-
const T = ((
|
|
1278
|
+
const T = ((P = o.__tres) == null ? void 0 : P.parent) || o.parent;
|
|
1279
1279
|
s(o), z(o, { attach: u }, e), T && r(o, T);
|
|
1280
1280
|
return;
|
|
1281
1281
|
}
|
|
@@ -1288,10 +1288,10 @@ const { logError: Xe } = V(), Ze = [
|
|
|
1288
1288
|
return;
|
|
1289
1289
|
}
|
|
1290
1290
|
Ze.includes(f) && o.__tres && (o.__tres.eventCount += 1);
|
|
1291
|
-
let g = oe(h),
|
|
1291
|
+
let g = oe(h), d = v == null ? void 0 : v[g];
|
|
1292
1292
|
if (h === "args") {
|
|
1293
|
-
const T = o, b = y ?? [],
|
|
1294
|
-
M && b.length && !
|
|
1293
|
+
const T = o, b = y ?? [], E = u ?? [], M = ((C = o.__tres) == null ? void 0 : C.type) || o.type;
|
|
1294
|
+
M && b.length && !Kn(b, E) && (v = Object.assign(
|
|
1295
1295
|
T,
|
|
1296
1296
|
new Ce.value[M](...u)
|
|
1297
1297
|
));
|
|
@@ -1306,16 +1306,16 @@ const { logError: Xe } = V(), Ze = [
|
|
|
1306
1306
|
);
|
|
1307
1307
|
return;
|
|
1308
1308
|
}
|
|
1309
|
-
if (h.includes("-") &&
|
|
1309
|
+
if (h.includes("-") && d === void 0) {
|
|
1310
1310
|
const T = h.split("-");
|
|
1311
|
-
|
|
1311
|
+
d = T.reduce((b, E) => b[oe(E)], v), h = T.pop(), g = h, d != null && d.set || (v = T.reduce((b, E) => b[oe(E)], v));
|
|
1312
1312
|
}
|
|
1313
1313
|
let _ = u;
|
|
1314
|
-
if (_ === "" && (_ = !0), G(
|
|
1315
|
-
Ze.includes(f) || (
|
|
1314
|
+
if (_ === "" && (_ = !0), G(d)) {
|
|
1315
|
+
Ze.includes(f) || (de(_) ? o[g](..._) : o[g](_)), g.startsWith("on") && G(_) && (v[g] = _);
|
|
1316
1316
|
return;
|
|
1317
1317
|
}
|
|
1318
|
-
!(
|
|
1318
|
+
!(d != null && d.set) && !G(d) ? v[g] = _ : d.constructor === _.constructor && (d != null && d.copy) ? d == null || d.copy(_) : de(_) ? d.set(..._) : !d.isColor && d.setScalar ? d.setScalar(_) : d.set(_), ht(o);
|
|
1319
1319
|
}
|
|
1320
1320
|
function i(o) {
|
|
1321
1321
|
var f;
|
|
@@ -1362,7 +1362,7 @@ function kr() {
|
|
|
1362
1362
|
function Lr() {
|
|
1363
1363
|
return kr() ? Te.now() : Date.now();
|
|
1364
1364
|
}
|
|
1365
|
-
class
|
|
1365
|
+
class Rr {
|
|
1366
1366
|
constructor(t, n) {
|
|
1367
1367
|
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
|
|
1368
1368
|
const r = {};
|
|
@@ -1424,12 +1424,12 @@ class Or {
|
|
|
1424
1424
|
n.resolve(await this.target[n.method](...n.args));
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
|
-
function
|
|
1427
|
+
function Or(e, t) {
|
|
1428
1428
|
const n = e, r = bt(), s = Tr(), l = Sr && n.enableEarlyProxy;
|
|
1429
1429
|
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
|
|
1430
1430
|
s.emit(xr, e, t);
|
|
1431
1431
|
else {
|
|
1432
|
-
const i = l ? new
|
|
1432
|
+
const i = l ? new Rr(n, s) : null;
|
|
1433
1433
|
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1434
1434
|
pluginDescriptor: n,
|
|
1435
1435
|
setupFn: t,
|
|
@@ -1458,7 +1458,7 @@ const Mt = (e) => {
|
|
|
1458
1458
|
});
|
|
1459
1459
|
const n = ke(e);
|
|
1460
1460
|
return n > 0 && t.tags.push({
|
|
1461
|
-
label: `${
|
|
1461
|
+
label: `${pr(n)} KB`,
|
|
1462
1462
|
textColor: 15707189,
|
|
1463
1463
|
backgroundColor: 16775644,
|
|
1464
1464
|
tooltip: "Memory usage"
|
|
@@ -1496,7 +1496,7 @@ const jr = [], X = "tres:inspector", Br = Se({
|
|
|
1496
1496
|
sceneGraph: null
|
|
1497
1497
|
});
|
|
1498
1498
|
function Ir(e, t) {
|
|
1499
|
-
|
|
1499
|
+
Or(
|
|
1500
1500
|
{
|
|
1501
1501
|
id: "dev.esm.tres",
|
|
1502
1502
|
label: "TresJS 🪐",
|
|
@@ -1577,7 +1577,6 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1577
1577
|
windowSize: { type: Boolean, default: void 0 },
|
|
1578
1578
|
enableProvideBridge: { type: Boolean, default: !0 },
|
|
1579
1579
|
context: {},
|
|
1580
|
-
precision: {},
|
|
1581
1580
|
alpha: { type: Boolean, default: void 0 },
|
|
1582
1581
|
premultipliedAlpha: { type: Boolean },
|
|
1583
1582
|
antialias: { type: Boolean, default: void 0 },
|
|
@@ -1585,8 +1584,10 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1585
1584
|
preserveDrawingBuffer: { type: Boolean, default: void 0 },
|
|
1586
1585
|
powerPreference: {},
|
|
1587
1586
|
depth: { type: Boolean, default: void 0 },
|
|
1587
|
+
failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 },
|
|
1588
|
+
precision: {},
|
|
1588
1589
|
logarithmicDepthBuffer: { type: Boolean, default: void 0 },
|
|
1589
|
-
|
|
1590
|
+
reverseDepthBuffer: { type: Boolean }
|
|
1590
1591
|
},
|
|
1591
1592
|
emits: [
|
|
1592
1593
|
"render",
|
|
@@ -1607,24 +1608,24 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1607
1608
|
setup(e, { expose: t, emit: n }) {
|
|
1608
1609
|
const r = e, s = n, l = At(), { logWarning: i } = V(), a = I(), c = $(new st()), o = He();
|
|
1609
1610
|
Ee(ot);
|
|
1610
|
-
const f = (g,
|
|
1611
|
+
const f = (g, d = !1) => fe({
|
|
1611
1612
|
setup() {
|
|
1612
1613
|
var T;
|
|
1613
1614
|
const _ = (T = He()) == null ? void 0 : T.appContext;
|
|
1614
1615
|
_ && (_.app = o == null ? void 0 : o.appContext.app);
|
|
1615
|
-
const
|
|
1616
|
-
function
|
|
1617
|
-
b && (b.parent &&
|
|
1616
|
+
const P = {};
|
|
1617
|
+
function C(b) {
|
|
1618
|
+
b && (b.parent && C(b.parent), b.provides && Object.assign(P, b.provides));
|
|
1618
1619
|
}
|
|
1619
|
-
return o != null && o.parent && r.enableProvideBridge && (
|
|
1620
|
-
le(b, P);
|
|
1621
|
-
})), le("useTres", g), le("extend", Ee), typeof window < "u" && Ir(_ == null ? void 0 : _.app, g), () => Ue(Bt, null,
|
|
1620
|
+
return o != null && o.parent && r.enableProvideBridge && (C(o.parent), Reflect.ownKeys(P).forEach((b) => {
|
|
1621
|
+
le(b, P[b]);
|
|
1622
|
+
})), le("useTres", g), le("extend", Ee), typeof window < "u" && Ir(_ == null ? void 0 : _.app, g), () => Ue(Bt, null, d ? [] : l.default());
|
|
1622
1623
|
}
|
|
1623
|
-
}), y = (g,
|
|
1624
|
-
const _ = f(g,
|
|
1625
|
-
|
|
1626
|
-
}, u = (g,
|
|
1627
|
-
mt(g.scene.value),
|
|
1624
|
+
}), y = (g, d = !1) => {
|
|
1625
|
+
const _ = f(g, d), { render: P } = jt(Er(g));
|
|
1626
|
+
P(Ue(_), c.value);
|
|
1627
|
+
}, u = (g, d = !1) => {
|
|
1628
|
+
mt(g.scene.value), d && (g.renderer.value.dispose(), g.renderer.value.renderLists.dispose(), g.renderer.value.forceContextLoss()), c.value.__tres = {
|
|
1628
1629
|
root: g
|
|
1629
1630
|
};
|
|
1630
1631
|
}, v = $(null);
|
|
@@ -1641,7 +1642,7 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1641
1642
|
rendererOptions: r,
|
|
1642
1643
|
emit: s
|
|
1643
1644
|
});
|
|
1644
|
-
const { registerCamera:
|
|
1645
|
+
const { registerCamera: d, camera: _, cameras: P, deregisterCamera: C } = v.value;
|
|
1645
1646
|
y(v.value);
|
|
1646
1647
|
const T = () => {
|
|
1647
1648
|
const b = new be(
|
|
@@ -1650,15 +1651,15 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1650
1651
|
0.1,
|
|
1651
1652
|
1e3
|
|
1652
1653
|
);
|
|
1653
|
-
b.position.set(3, 3, 3), b.lookAt(0, 0, 0),
|
|
1654
|
-
const
|
|
1655
|
-
|
|
1654
|
+
b.position.set(3, 3, 3), b.lookAt(0, 0, 0), d(b);
|
|
1655
|
+
const E = xe(() => {
|
|
1656
|
+
P.value.length >= 2 && (b.removeFromParent(), C(b), E == null || E());
|
|
1656
1657
|
});
|
|
1657
1658
|
};
|
|
1658
1659
|
ae(
|
|
1659
1660
|
() => r.camera,
|
|
1660
|
-
(b,
|
|
1661
|
-
b &&
|
|
1661
|
+
(b, E) => {
|
|
1662
|
+
b && d(b), E && (E.removeFromParent(), C(E));
|
|
1662
1663
|
},
|
|
1663
1664
|
{
|
|
1664
1665
|
immediate: !0
|
|
@@ -1666,12 +1667,12 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1666
1667
|
), _.value || (i(
|
|
1667
1668
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
1668
1669
|
), T());
|
|
1669
|
-
}),
|
|
1670
|
+
}), J(h), (g, d) => (Lt(), Rt("canvas", {
|
|
1670
1671
|
ref_key: "canvas",
|
|
1671
1672
|
ref: a,
|
|
1672
1673
|
"data-scene": c.value.uuid,
|
|
1673
|
-
class:
|
|
1674
|
-
"data-tres": `tresjs ${W(
|
|
1674
|
+
class: Ot(g.$attrs.class),
|
|
1675
|
+
"data-tres": `tresjs ${W(Rn).version}`,
|
|
1675
1676
|
style: Dt({
|
|
1676
1677
|
display: "block",
|
|
1677
1678
|
width: "100%",
|
|
@@ -1689,20 +1690,20 @@ const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
|
1689
1690
|
"TresCanvas",
|
|
1690
1691
|
"TresLeches",
|
|
1691
1692
|
"TresScene"
|
|
1692
|
-
],
|
|
1693
|
+
], no = {
|
|
1693
1694
|
template: {
|
|
1694
1695
|
compilerOptions: {
|
|
1695
1696
|
isCustomElement: (e) => e.startsWith("Tres") && !Ur.includes(e) || e === "primitive"
|
|
1696
1697
|
}
|
|
1697
1698
|
}
|
|
1698
|
-
},
|
|
1699
|
+
}, { logWarning: Fr } = V();
|
|
1699
1700
|
let B = null;
|
|
1700
|
-
const
|
|
1701
|
+
const ro = {
|
|
1701
1702
|
updated: (e, t) => {
|
|
1702
1703
|
var s;
|
|
1703
1704
|
const n = Zn(t);
|
|
1704
1705
|
if (!n) {
|
|
1705
|
-
|
|
1706
|
+
Fr(`v-distance-to: problem with binding value: ${t.value}`);
|
|
1706
1707
|
return;
|
|
1707
1708
|
}
|
|
1708
1709
|
B && (B.dispose(), e.parent.remove(B));
|
|
@@ -1723,10 +1724,10 @@ class Ct extends qt {
|
|
|
1723
1724
|
constructor(t, n) {
|
|
1724
1725
|
const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new Fe();
|
|
1725
1726
|
s.setAttribute("position", new We(r, 3)), s.computeBoundingSphere();
|
|
1726
|
-
const l = new
|
|
1727
|
+
const l = new Kt({ fog: !1 });
|
|
1727
1728
|
super(s, l), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
|
|
1728
1729
|
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new Fe();
|
|
1729
|
-
a.setAttribute("position", new We(i, 3)), a.computeBoundingSphere(), this.add(new
|
|
1730
|
+
a.setAttribute("position", new We(i, 3)), a.computeBoundingSphere(), this.add(new Jt(a, new at({ side: Qt, fog: !1 })));
|
|
1730
1731
|
}
|
|
1731
1732
|
updateMatrixWorld() {
|
|
1732
1733
|
if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
|
|
@@ -1744,19 +1745,19 @@ class Ct extends qt {
|
|
|
1744
1745
|
}
|
|
1745
1746
|
const { logWarning: tt } = V();
|
|
1746
1747
|
let ie, F;
|
|
1747
|
-
const
|
|
1748
|
+
const Wr = {
|
|
1748
1749
|
DirectionalLight: Xt,
|
|
1749
1750
|
PointLight: Zt,
|
|
1750
1751
|
SpotLight: en,
|
|
1751
1752
|
HemisphereLight: tn,
|
|
1752
1753
|
RectAreaLight: Ct
|
|
1753
|
-
},
|
|
1754
|
+
}, oo = {
|
|
1754
1755
|
mounted: (e) => {
|
|
1755
1756
|
if (!e.isLight) {
|
|
1756
1757
|
tt(`${e.type} is not a light`);
|
|
1757
1758
|
return;
|
|
1758
1759
|
}
|
|
1759
|
-
ie =
|
|
1760
|
+
ie = Wr[e.type], e.parent.add(new ie(e, 1, e.color.getHex()));
|
|
1760
1761
|
},
|
|
1761
1762
|
updated: (e) => {
|
|
1762
1763
|
F = e.parent.children.find((t) => t instanceof ie), !(F instanceof Ct) && F.update();
|
|
@@ -1768,7 +1769,7 @@ const Nr = {
|
|
|
1768
1769
|
}
|
|
1769
1770
|
F = e.parent.children.find((t) => t instanceof ie), F && F.dispose && F.dispose(), e.parent.remove(F);
|
|
1770
1771
|
}
|
|
1771
|
-
},
|
|
1772
|
+
}, so = {
|
|
1772
1773
|
mounted: (e, t) => {
|
|
1773
1774
|
if (t.arg) {
|
|
1774
1775
|
console.log(`v-log:${t.arg}`, e[t.arg]);
|
|
@@ -1776,40 +1777,40 @@ const Nr = {
|
|
|
1776
1777
|
}
|
|
1777
1778
|
console.log("v-log", e);
|
|
1778
1779
|
}
|
|
1779
|
-
},
|
|
1780
|
+
}, io = {
|
|
1780
1781
|
install(e) {
|
|
1781
1782
|
e.component("TresCanvas", Hr);
|
|
1782
1783
|
}
|
|
1783
1784
|
};
|
|
1784
1785
|
export {
|
|
1785
1786
|
Hr as TresCanvas,
|
|
1786
|
-
|
|
1787
|
-
|
|
1787
|
+
Yr as UseLoader,
|
|
1788
|
+
qr as UseTexture,
|
|
1788
1789
|
Ce as catalogue,
|
|
1789
|
-
|
|
1790
|
-
|
|
1790
|
+
dr as createRenderLoop,
|
|
1791
|
+
io as default,
|
|
1791
1792
|
mt as dispose,
|
|
1792
1793
|
Ee as extend,
|
|
1793
1794
|
Kr as isProd,
|
|
1794
1795
|
hr as normalizeColor,
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1796
|
+
Jr as normalizeVectorFlexibleParam,
|
|
1797
|
+
Qr as onTresReady,
|
|
1798
|
+
no as templateCompilerOptions,
|
|
1799
|
+
On as trasverseObjects,
|
|
1799
1800
|
ar as useCamera,
|
|
1800
1801
|
Dn as useLoader,
|
|
1801
1802
|
V as useLogger,
|
|
1802
|
-
|
|
1803
|
+
Zr as useLoop,
|
|
1803
1804
|
yr as useRaycaster,
|
|
1804
|
-
|
|
1805
|
+
eo as useRenderLoop,
|
|
1805
1806
|
gr as useRenderer,
|
|
1806
|
-
|
|
1807
|
+
to as useSeek,
|
|
1807
1808
|
ir as useTexture,
|
|
1808
|
-
|
|
1809
|
+
Xr as useTres,
|
|
1809
1810
|
me as useTresContext,
|
|
1810
1811
|
br as useTresContextProvider,
|
|
1811
1812
|
_r as useTresEventManager,
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1813
|
+
ro as vDistanceTo,
|
|
1814
|
+
oo as vLightHelper,
|
|
1815
|
+
so as vLog
|
|
1815
1816
|
};
|