@tresjs/core 4.2.7 → 4.2.9
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/src/composables/useLoader/index.d.ts +1 -1
- package/dist/tres.js +305 -308
- package/dist/tres.umd.cjs +2 -2
- package/package.json +3 -3
package/dist/tres.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.2.
|
|
3
|
+
* version: v4.2.9
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
8
|
var bt = Object.defineProperty;
|
|
9
|
-
var
|
|
10
|
-
var me = (e, t, n) =>
|
|
11
|
-
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as
|
|
9
|
+
var Ct = (e, t, n) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
10
|
+
var me = (e, t, n) => Ct(e, typeof t != "symbol" ? t + "" : t, n);
|
|
11
|
+
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as Mt, isRef as Pt, reactive as Et, defineComponent as Be, useSlots as Tt, getCurrentInstance as Ie, onMounted as St, openBlock as At, createElementBlock as xt, normalizeClass as kt, normalizeStyle as Lt, createRenderer as Rt, h as He, Fragment as Ot } from "vue";
|
|
12
12
|
import * as et from "three";
|
|
13
13
|
import { PerspectiveCamera as we, Camera as Dt, Clock as tt, Vector3 as Se, Color as Z, Scene as nt, MathUtils as rt, MeshBasicMaterial as ot, DoubleSide as jt, REVISION as Bt, SRGBColorSpace as It, ACESFilmicToneMapping as st, PCFSoftShadowMap as Ht, NoToneMapping as $t, WebGLRenderer as he, TextureLoader as Ut, Vector2 as ge, Raycaster as Ft, BufferAttribute as Wt, Object3D as Nt, Line as zt, BufferGeometry as $e, Float32BufferAttribute as Ue, LineBasicMaterial as Gt, Mesh as Vt, BackSide as Yt, DirectionalLightHelper as qt, PointLightHelper as Jt, SpotLightHelper as Kt, HemisphereLightHelper as Qt, ArrowHelper as Xt } from "three";
|
|
14
14
|
import { createEventHook as j, useRafFn as it, toValue as k, unrefElement as Zt, useDevicePixelRatio as en, usePointer as tn, useElementBounding as nn, useWindowSize as rn, useElementSize as on, refDebounced as Fe, tryOnScopeDispose as sn, useFps as an, useMemory as ln } from "@vueuse/core";
|
|
15
|
-
const cn = "@tresjs/core", un = "module", fn = "4.2.
|
|
15
|
+
const cn = "@tresjs/core", un = "module", fn = "4.2.9", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = {
|
|
16
16
|
type: "git",
|
|
17
17
|
url: "git+https://github.com/Tresjs/tres.git"
|
|
18
18
|
}, vn = [
|
|
@@ -40,15 +40,15 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.7", dn = "pnpm@9.1.4", pn =
|
|
|
40
40
|
types: "./dist/src/utils/index.d.ts"
|
|
41
41
|
},
|
|
42
42
|
"./*": "./*"
|
|
43
|
-
}, wn = "./dist/tres.js", bn = "./dist/tres.js",
|
|
43
|
+
}, wn = "./dist/tres.js", bn = "./dist/tres.js", Cn = "./dist/index.d.ts", Mn = [
|
|
44
44
|
"*.d.ts",
|
|
45
45
|
"dist"
|
|
46
|
-
],
|
|
46
|
+
], Pn = {
|
|
47
47
|
access: "public"
|
|
48
48
|
}, En = {
|
|
49
|
-
dev: "cd playground && npm run dev",
|
|
49
|
+
dev: "cd playground/vue && npm run dev",
|
|
50
|
+
"dev:nuxt": "cd playground/nuxt && npm run dev",
|
|
50
51
|
build: "vite build",
|
|
51
|
-
playground: "cd playground && npm run dev",
|
|
52
52
|
test: "vitest",
|
|
53
53
|
"test:ci": "vitest run",
|
|
54
54
|
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
@@ -124,9 +124,9 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.7", dn = "pnpm@9.1.4", pn =
|
|
|
124
124
|
exports: _n,
|
|
125
125
|
main: wn,
|
|
126
126
|
module: bn,
|
|
127
|
-
types:
|
|
128
|
-
files:
|
|
129
|
-
publishConfig:
|
|
127
|
+
types: Cn,
|
|
128
|
+
files: Mn,
|
|
129
|
+
publishConfig: Pn,
|
|
130
130
|
scripts: En,
|
|
131
131
|
peerDependencies: Tn,
|
|
132
132
|
dependencies: Sn,
|
|
@@ -228,14 +228,14 @@ Ae.on(() => {
|
|
|
228
228
|
ue = ee.getDelta(), fe = ee.getElapsedTime();
|
|
229
229
|
});
|
|
230
230
|
let ze = !1;
|
|
231
|
-
const
|
|
231
|
+
const Ur = () => (ze || (ze = !0, Ne()), {
|
|
232
232
|
onBeforeLoop: lt.on,
|
|
233
233
|
onLoop: ct.on,
|
|
234
234
|
onAfterLoop: Ae.on,
|
|
235
235
|
pause: $n,
|
|
236
236
|
resume: Ne,
|
|
237
237
|
isActive: Un
|
|
238
|
-
}),
|
|
238
|
+
}), Fr = !0, se = "[TresJS ▲ ■ ●] ";
|
|
239
239
|
function Y() {
|
|
240
240
|
function e(...r) {
|
|
241
241
|
typeof r[0] == "string" ? r[0] = se + r[0] : r.unshift(se), console.error(...r);
|
|
@@ -251,7 +251,7 @@ function Y() {
|
|
|
251
251
|
logMessage: n
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function Wr(e) {
|
|
255
255
|
return typeof e == "number" ? [e, e, e] : e instanceof Se ? [e.x, e.y, e.z] : e;
|
|
256
256
|
}
|
|
257
257
|
function Fn(e) {
|
|
@@ -387,7 +387,7 @@ function tr(e, t) {
|
|
|
387
387
|
t(e[r], r) && (e[n] = e[r], n++);
|
|
388
388
|
return e.length = n, e;
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Ce(e, t) {
|
|
391
391
|
let n = e;
|
|
392
392
|
if (t.includes("-")) {
|
|
393
393
|
const r = t.split("-");
|
|
@@ -405,7 +405,7 @@ const Je = /-\d+$/;
|
|
|
405
405
|
function nr(e, t, n) {
|
|
406
406
|
if (at(n)) {
|
|
407
407
|
if (Je.test(n)) {
|
|
408
|
-
const l = n.replace(Je, ""), { target: i, key: a } =
|
|
408
|
+
const l = n.replace(Je, ""), { target: i, key: a } = Ce(e, l);
|
|
409
409
|
if (!Array.isArray(i[a])) {
|
|
410
410
|
const c = i[a], o = [];
|
|
411
411
|
o.__tresDetach = () => {
|
|
@@ -413,7 +413,7 @@ function nr(e, t, n) {
|
|
|
413
413
|
}, i[a] = o;
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
const { target: r, key: s } =
|
|
416
|
+
const { target: r, key: s } = Ce(e, n);
|
|
417
417
|
t.__tres.previousAttach = r[s], r[s] = Q(t);
|
|
418
418
|
} else
|
|
419
419
|
t.__tres.previousAttach = n(e, t);
|
|
@@ -421,7 +421,7 @@ function nr(e, t, n) {
|
|
|
421
421
|
function rr(e, t, n) {
|
|
422
422
|
var r, s, l;
|
|
423
423
|
if (at(n)) {
|
|
424
|
-
const { target: i, key: a } =
|
|
424
|
+
const { target: i, key: a } = Ce(e, n), c = t.__tres.previousAttach;
|
|
425
425
|
c === void 0 ? delete i[a] : i[a] = c, "__tresDetach" in i && i.__tresDetach();
|
|
426
426
|
} else
|
|
427
427
|
(s = (r = t.__tres) == null ? void 0 : r.previousAttach) == null || s.call(r, e, t);
|
|
@@ -534,37 +534,37 @@ function ar({
|
|
|
534
534
|
}, {
|
|
535
535
|
immediate: !0
|
|
536
536
|
}), ce(() => t.clearColor, c);
|
|
537
|
-
const { pixelRatio: o } = en(), { logError: u } = Y(),
|
|
538
|
-
const
|
|
537
|
+
const { pixelRatio: o } = en(), { logError: u } = Y(), d = (() => {
|
|
538
|
+
const h = new he(), b = {
|
|
539
539
|
shadowMap: {
|
|
540
|
-
enabled:
|
|
541
|
-
type:
|
|
540
|
+
enabled: h.shadowMap.enabled,
|
|
541
|
+
type: h.shadowMap.type
|
|
542
542
|
},
|
|
543
|
-
toneMapping:
|
|
544
|
-
toneMappingExposure:
|
|
545
|
-
outputColorSpace:
|
|
543
|
+
toneMapping: h.toneMapping,
|
|
544
|
+
toneMappingExposure: h.toneMappingExposure,
|
|
545
|
+
outputColorSpace: h.outputColorSpace
|
|
546
546
|
};
|
|
547
|
-
return
|
|
548
|
-
})(),
|
|
549
|
-
return
|
|
547
|
+
return h.dispose(), b;
|
|
548
|
+
})(), g = k(t.renderMode);
|
|
549
|
+
return g === "on-demand" && s(), g === "manual" && setTimeout(() => {
|
|
550
550
|
l();
|
|
551
551
|
}, 100), Te(() => {
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
const b = (
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
557
|
-
return Ve(ae[
|
|
552
|
+
const h = k(t.preset);
|
|
553
|
+
h && (h in ae || u(`Renderer Preset must be one of these: ${Object.keys(ae).join(", ")}`), ut(a.value, ae[h])), or(a.value, o.value, k(t.dpr)), g === "always" && (r.frames.value = Math.max(1, r.frames.value));
|
|
554
|
+
const b = (M, P) => {
|
|
555
|
+
const C = k(M), E = () => {
|
|
556
|
+
if (h)
|
|
557
|
+
return Ve(ae[h], P);
|
|
558
558
|
};
|
|
559
|
-
if (
|
|
560
|
-
return
|
|
559
|
+
if (C !== void 0)
|
|
560
|
+
return C;
|
|
561
561
|
const S = E();
|
|
562
|
-
return S !== void 0 ? S : Ve(
|
|
563
|
-
}, y = (
|
|
562
|
+
return S !== void 0 ? S : Ve(d, P);
|
|
563
|
+
}, y = (M, P) => qn(a.value, P, b(M, P));
|
|
564
564
|
y(t.shadows, "shadowMap.enabled"), y(t.toneMapping ?? st, "toneMapping"), y(t.shadowMapType, "shadowMap.type"), ir < 150 && y(!t.useLegacyLights, "physicallyCorrectLights"), y(t.outputColorSpace, "outputColorSpace"), y(t.toneMappingExposure, "toneMappingExposure");
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
const f = b(t.clearColor, "clearColor");
|
|
566
|
+
f && a.value.setClearColor(
|
|
567
|
+
f ? Fn(f) : new Z(0)
|
|
568
568
|
// default clear color is not easily/efficiently retrievable from three
|
|
569
569
|
);
|
|
570
570
|
}), K(() => {
|
|
@@ -573,32 +573,29 @@ function ar({
|
|
|
573
573
|
renderer: a
|
|
574
574
|
};
|
|
575
575
|
}
|
|
576
|
-
|
|
577
|
-
function cr(e) {
|
|
576
|
+
function lr(e) {
|
|
578
577
|
const t = { nodes: {}, materials: {} };
|
|
579
578
|
return e && e.traverse((n) => {
|
|
580
579
|
n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
|
|
581
580
|
}), t;
|
|
582
581
|
}
|
|
583
|
-
async function
|
|
582
|
+
async function Nr(e, t, n, r, s) {
|
|
584
583
|
const { logError: l } = Y(), i = new e();
|
|
585
|
-
s && s(i), n && n(i)
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
o
|
|
590
|
-
(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
);
|
|
599
|
-
return lr(t) ? await Promise.all(c) : await c[0];
|
|
584
|
+
return s && s(i), n && n(i), await new Promise((a, c) => {
|
|
585
|
+
i.load(
|
|
586
|
+
t,
|
|
587
|
+
(o) => {
|
|
588
|
+
const u = o;
|
|
589
|
+
u.scene && Object.assign(u, lr(u.scene)), a(u);
|
|
590
|
+
},
|
|
591
|
+
r,
|
|
592
|
+
(o) => {
|
|
593
|
+
l("[useLoader] - Failed to load resource", o), c(o);
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
});
|
|
600
597
|
}
|
|
601
|
-
async function
|
|
598
|
+
async function zr(e, t) {
|
|
602
599
|
const n = new Ut(t), r = (s) => new Promise((l, i) => {
|
|
603
600
|
n.load(
|
|
604
601
|
s,
|
|
@@ -635,7 +632,7 @@ async function Gr(e, t) {
|
|
|
635
632
|
};
|
|
636
633
|
}
|
|
637
634
|
}
|
|
638
|
-
const
|
|
635
|
+
const cr = (e, t) => {
|
|
639
636
|
const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = tn({ target: n });
|
|
640
637
|
let i = 0;
|
|
641
638
|
const { width: a, height: c, top: o, left: u } = nn(n), v = ({ x: m, y: T }) => {
|
|
@@ -644,16 +641,16 @@ const ur = (e, t) => {
|
|
|
644
641
|
x: (m - u.value) / a.value * 2 - 1,
|
|
645
642
|
y: -((T - o.value) / c.value) * 2 + 1
|
|
646
643
|
};
|
|
647
|
-
},
|
|
644
|
+
}, d = ({ x: m, y: T }) => {
|
|
648
645
|
if (t.camera.value)
|
|
649
646
|
return t.raycaster.value.setFromCamera(new ge(m, T), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
|
|
650
|
-
},
|
|
647
|
+
}, g = (m) => {
|
|
651
648
|
const T = v({
|
|
652
649
|
x: (m == null ? void 0 : m.clientX) ?? s.value,
|
|
653
650
|
y: (m == null ? void 0 : m.clientY) ?? l.value
|
|
654
651
|
});
|
|
655
|
-
return T ?
|
|
656
|
-
},
|
|
652
|
+
return T ? d(T) || [] : [];
|
|
653
|
+
}, h = j(), b = j(), y = j(), f = j(), M = j(), P = j(), C = j(), E = j();
|
|
657
654
|
function S(m) {
|
|
658
655
|
const T = {};
|
|
659
656
|
for (const F in m)
|
|
@@ -677,7 +674,7 @@ const ur = (e, t) => {
|
|
|
677
674
|
};
|
|
678
675
|
let A;
|
|
679
676
|
const L = (m) => {
|
|
680
|
-
|
|
677
|
+
g(m), _(y, m), A = m;
|
|
681
678
|
}, p = () => {
|
|
682
679
|
A && L(A);
|
|
683
680
|
};
|
|
@@ -687,15 +684,15 @@ const ur = (e, t) => {
|
|
|
687
684
|
w = (T = r.value[0]) == null ? void 0 : T.object, i = 0, x = new ge(
|
|
688
685
|
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
689
686
|
(m == null ? void 0 : m.clientY) ?? l.value
|
|
690
|
-
), _(
|
|
687
|
+
), _(M, m);
|
|
691
688
|
};
|
|
692
689
|
let B, R = !1;
|
|
693
690
|
const ne = (m) => {
|
|
694
691
|
var T, F, re;
|
|
695
|
-
m instanceof PointerEvent && (r.value.length === 0 && _(
|
|
692
|
+
m instanceof PointerEvent && (r.value.length === 0 && _(P, m), w === ((T = r.value[0]) == null ? void 0 : T.object) && (D = new ge(
|
|
696
693
|
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
697
694
|
(m == null ? void 0 : m.clientY) ?? l.value
|
|
698
|
-
), i = x == null ? void 0 : x.distanceTo(D), m.button === 0 ? (_(
|
|
695
|
+
), i = x == null ? void 0 : x.distanceTo(D), m.button === 0 ? (_(h, m), B === ((F = r.value[0]) == null ? void 0 : F.object) ? R = !0 : (B = (re = r.value[0]) == null ? void 0 : re.object, R = !1)) : m.button === 2 && _(C, m)), _(f, m));
|
|
699
696
|
}, ke = (m) => {
|
|
700
697
|
R && (_(b, m), B = void 0, R = !1);
|
|
701
698
|
}, Le = (m) => _(y, m), Re = (m) => _(E, m);
|
|
@@ -703,18 +700,18 @@ const ur = (e, t) => {
|
|
|
703
700
|
n != null && n.value && (n.value.removeEventListener("pointerup", ne), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove", L), n.value.removeEventListener("pointerleave", Le), n.value.removeEventListener("dblclick", ke), n.value.removeEventListener("wheel", Re));
|
|
704
701
|
}), {
|
|
705
702
|
intersects: r,
|
|
706
|
-
onClick: (m) =>
|
|
703
|
+
onClick: (m) => h.on(m).off,
|
|
707
704
|
onDblClick: (m) => b.on(m).off,
|
|
708
|
-
onContextMenu: (m) =>
|
|
705
|
+
onContextMenu: (m) => C.on(m).off,
|
|
709
706
|
onPointerMove: (m) => y.on(m).off,
|
|
710
|
-
onPointerUp: (m) =>
|
|
711
|
-
onPointerDown: (m) =>
|
|
712
|
-
onPointerMissed: (m) =>
|
|
707
|
+
onPointerUp: (m) => f.on(m).off,
|
|
708
|
+
onPointerDown: (m) => M.on(m).off,
|
|
709
|
+
onPointerMissed: (m) => P.on(m).off,
|
|
713
710
|
onWheel: (m) => E.on(m).off,
|
|
714
711
|
forceUpdate: p
|
|
715
712
|
};
|
|
716
713
|
};
|
|
717
|
-
function
|
|
714
|
+
function Gr() {
|
|
718
715
|
const { logWarning: e } = Y();
|
|
719
716
|
function t(l, i, a) {
|
|
720
717
|
let c = null;
|
|
@@ -750,11 +747,11 @@ function xe(e) {
|
|
|
750
747
|
}
|
|
751
748
|
}), t;
|
|
752
749
|
}
|
|
753
|
-
function
|
|
750
|
+
function ur(e) {
|
|
754
751
|
return (e / 1024).toFixed(2);
|
|
755
752
|
}
|
|
756
|
-
const
|
|
757
|
-
function
|
|
753
|
+
const Me = H({}), Pe = (e) => Object.assign(Me.value, e);
|
|
754
|
+
function fr(e, t, n) {
|
|
758
755
|
var L;
|
|
759
756
|
const r = $(), s = $();
|
|
760
757
|
e && (r.value = e), t && (s.value = t);
|
|
@@ -790,28 +787,28 @@ function dr(e, t, n) {
|
|
|
790
787
|
const {
|
|
791
788
|
onClick: u,
|
|
792
789
|
onDblClick: v,
|
|
793
|
-
onContextMenu:
|
|
794
|
-
onPointerMove:
|
|
795
|
-
onPointerDown:
|
|
790
|
+
onContextMenu: d,
|
|
791
|
+
onPointerMove: g,
|
|
792
|
+
onPointerDown: h,
|
|
796
793
|
onPointerUp: b,
|
|
797
794
|
onPointerMissed: y,
|
|
798
|
-
onWheel:
|
|
799
|
-
forceUpdate:
|
|
800
|
-
} =
|
|
801
|
-
b((p) => o("onPointerUp", p)),
|
|
802
|
-
let
|
|
803
|
-
|
|
795
|
+
onWheel: f,
|
|
796
|
+
forceUpdate: M
|
|
797
|
+
} = cr(a, t);
|
|
798
|
+
b((p) => o("onPointerUp", p)), h((p) => o("onPointerDown", p)), u((p) => o("onClick", p)), v((p) => o("onDoubleClick", p)), d((p) => o("onContextMenu", p)), f((p) => o("onWheel", p));
|
|
799
|
+
let P = [];
|
|
800
|
+
g((p) => {
|
|
804
801
|
const w = p.intersections.map(({ object: D }) => D), x = p.intersections;
|
|
805
|
-
|
|
806
|
-
w.includes(D) || (p.intersections =
|
|
802
|
+
P.forEach(({ object: D }) => {
|
|
803
|
+
w.includes(D) || (p.intersections = P, o("onPointerLeave", p), o("onPointerOut", p));
|
|
807
804
|
}), p.intersections = x, p.intersections.forEach(({ object: D }) => {
|
|
808
|
-
|
|
809
|
-
}), o("onPointerMove", p),
|
|
805
|
+
P.includes(D) || (o("onPointerEnter", p), o("onPointerOver", p));
|
|
806
|
+
}), o("onPointerMove", p), P = p.intersections;
|
|
810
807
|
});
|
|
811
|
-
const
|
|
808
|
+
const C = [];
|
|
812
809
|
y((p) => {
|
|
813
810
|
const w = () => p.stopPropagating = !0;
|
|
814
|
-
p.stopPropagation = w,
|
|
811
|
+
p.stopPropagation = w, C.forEach((x) => {
|
|
815
812
|
p.stopPropagating || (p.eventObject = x, c(x.onPointerMissed, p));
|
|
816
813
|
}), n("pointer-missed", { event: p });
|
|
817
814
|
});
|
|
@@ -825,29 +822,29 @@ function dr(e, t, n) {
|
|
|
825
822
|
}
|
|
826
823
|
}
|
|
827
824
|
function _(p) {
|
|
828
|
-
oe(p) && N(p) && p.onPointerMissed &&
|
|
825
|
+
oe(p) && N(p) && p.onPointerMissed && C.push(p);
|
|
829
826
|
}
|
|
830
827
|
function A(p) {
|
|
831
828
|
if (oe(p) && N(p)) {
|
|
832
|
-
const w =
|
|
833
|
-
w > -1 &&
|
|
829
|
+
const w = C.indexOf(p);
|
|
830
|
+
w > -1 && C.splice(w, 1);
|
|
834
831
|
}
|
|
835
832
|
}
|
|
836
833
|
return t.eventManager = {
|
|
837
|
-
forceUpdate:
|
|
834
|
+
forceUpdate: M,
|
|
838
835
|
registerObject: E,
|
|
839
836
|
deregisterObject: S,
|
|
840
837
|
registerPointerMissedObject: _,
|
|
841
838
|
deregisterPointerMissedObject: A
|
|
842
839
|
}, {
|
|
843
|
-
forceUpdate:
|
|
840
|
+
forceUpdate: M,
|
|
844
841
|
registerObject: E,
|
|
845
842
|
deregisterObject: S,
|
|
846
843
|
registerPointerMissedObject: _,
|
|
847
844
|
deregisterPointerMissedObject: A
|
|
848
845
|
};
|
|
849
846
|
}
|
|
850
|
-
function
|
|
847
|
+
function dr(e, t, n = 10) {
|
|
851
848
|
const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)), l = ye(Fe(r.height, n)), i = V(() => s.value / l.value);
|
|
852
849
|
return {
|
|
853
850
|
height: l,
|
|
@@ -860,8 +857,8 @@ function ve() {
|
|
|
860
857
|
let n = 0, r = !1;
|
|
861
858
|
const s = () => {
|
|
862
859
|
const o = Array.from(e.entries()).sort((u, v) => {
|
|
863
|
-
const
|
|
864
|
-
return
|
|
860
|
+
const d = u[1].priority - v[1].priority;
|
|
861
|
+
return d === 0 ? u[1].addI - v[1].addI : d;
|
|
865
862
|
});
|
|
866
863
|
t.clear(), o.forEach((u) => t.add(u[0]));
|
|
867
864
|
}, l = (o) => {
|
|
@@ -881,7 +878,7 @@ function ve() {
|
|
|
881
878
|
return e.size;
|
|
882
879
|
} };
|
|
883
880
|
}
|
|
884
|
-
function
|
|
881
|
+
function pr() {
|
|
885
882
|
let e = !0, t = !0, n = !1;
|
|
886
883
|
const r = new tt(!1), s = H(r.running), l = H(!1);
|
|
887
884
|
let i;
|
|
@@ -889,11 +886,11 @@ function mr() {
|
|
|
889
886
|
let c = null;
|
|
890
887
|
const o = ve(), u = ve(), v = ve();
|
|
891
888
|
S();
|
|
892
|
-
let
|
|
893
|
-
function
|
|
894
|
-
|
|
889
|
+
let d = {};
|
|
890
|
+
function g(_) {
|
|
891
|
+
d = _;
|
|
895
892
|
}
|
|
896
|
-
function
|
|
893
|
+
function h(_, A, L = 0) {
|
|
897
894
|
switch (A) {
|
|
898
895
|
case "before":
|
|
899
896
|
return o.on(_, L);
|
|
@@ -909,16 +906,16 @@ function mr() {
|
|
|
909
906
|
function y() {
|
|
910
907
|
t = !0, S(), cancelAnimationFrame(i);
|
|
911
908
|
}
|
|
912
|
-
function
|
|
909
|
+
function f() {
|
|
913
910
|
n = !1, S();
|
|
914
911
|
}
|
|
915
|
-
function
|
|
912
|
+
function M() {
|
|
916
913
|
n = !0, S();
|
|
917
914
|
}
|
|
918
|
-
function
|
|
915
|
+
function P() {
|
|
919
916
|
l.value = !0;
|
|
920
917
|
}
|
|
921
|
-
function
|
|
918
|
+
function C() {
|
|
922
919
|
l.value = !1;
|
|
923
920
|
}
|
|
924
921
|
function E() {
|
|
@@ -927,13 +924,13 @@ function mr() {
|
|
|
927
924
|
return;
|
|
928
925
|
}
|
|
929
926
|
const _ = r.getDelta(), A = r.getElapsedTime(), L = {
|
|
930
|
-
camera: J(
|
|
931
|
-
scene: J(
|
|
932
|
-
renderer: J(
|
|
933
|
-
raycaster: J(
|
|
934
|
-
controls: J(
|
|
935
|
-
invalidate:
|
|
936
|
-
advance:
|
|
927
|
+
camera: J(d.camera),
|
|
928
|
+
scene: J(d.scene),
|
|
929
|
+
renderer: J(d.renderer),
|
|
930
|
+
raycaster: J(d.raycaster),
|
|
931
|
+
controls: J(d.controls),
|
|
932
|
+
invalidate: d.invalidate,
|
|
933
|
+
advance: d.advance
|
|
937
934
|
}, p = { delta: _, elapsed: A, clock: r, ...L };
|
|
938
935
|
s.value && o.trigger(p), l.value || (u.count ? u.trigger(p) : c && c(p)), s.value && v.trigger(p), i = requestAnimationFrame(E);
|
|
939
936
|
}
|
|
@@ -943,41 +940,41 @@ function mr() {
|
|
|
943
940
|
}
|
|
944
941
|
return {
|
|
945
942
|
loopId: a,
|
|
946
|
-
register: (_, A, L) =>
|
|
943
|
+
register: (_, A, L) => h(_, A, L),
|
|
947
944
|
start: b,
|
|
948
945
|
stop: y,
|
|
949
|
-
pause:
|
|
950
|
-
resume:
|
|
951
|
-
pauseRender:
|
|
952
|
-
resumeRender:
|
|
946
|
+
pause: M,
|
|
947
|
+
resume: f,
|
|
948
|
+
pauseRender: P,
|
|
949
|
+
resumeRender: C,
|
|
953
950
|
isRenderPaused: l,
|
|
954
951
|
isActive: s,
|
|
955
|
-
setContext:
|
|
952
|
+
setContext: g,
|
|
956
953
|
setReady: (_) => e = _
|
|
957
954
|
};
|
|
958
955
|
}
|
|
959
|
-
function
|
|
956
|
+
function mr(e, t, n = 100) {
|
|
960
957
|
n = n <= 0 ? 100 : n;
|
|
961
958
|
const r = j(), s = /* @__PURE__ */ new Set();
|
|
962
959
|
let l = !1, i = !1, a = null;
|
|
963
960
|
function c() {
|
|
964
|
-
a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((
|
|
961
|
+
a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((d) => d()), s.clear(), l = !0) : !i && !l && (a = setTimeout(c, n));
|
|
965
962
|
}
|
|
966
963
|
function o() {
|
|
967
964
|
i = !0, a && clearTimeout(a);
|
|
968
965
|
}
|
|
969
966
|
c();
|
|
970
|
-
const u = (
|
|
971
|
-
|
|
967
|
+
const u = (d, ...g) => {
|
|
968
|
+
d(...g);
|
|
972
969
|
};
|
|
973
970
|
return {
|
|
974
|
-
on: (
|
|
971
|
+
on: (d) => {
|
|
975
972
|
if (l)
|
|
976
|
-
return u(
|
|
973
|
+
return u(d, t), { off: () => {
|
|
977
974
|
} };
|
|
978
975
|
{
|
|
979
|
-
const
|
|
980
|
-
return s.add(
|
|
976
|
+
const g = r.on(d);
|
|
977
|
+
return s.add(g.off), r.on(d);
|
|
981
978
|
}
|
|
982
979
|
},
|
|
983
980
|
off: r.off,
|
|
@@ -989,7 +986,7 @@ const te = /* @__PURE__ */ new WeakMap();
|
|
|
989
986
|
function gt(e) {
|
|
990
987
|
if (e = e || pe(), te.has(e))
|
|
991
988
|
return te.get(e);
|
|
992
|
-
const t = 100, n = Date.now(), l =
|
|
989
|
+
const t = 100, n = Date.now(), l = mr(() => {
|
|
993
990
|
if (Date.now() - n >= t)
|
|
994
991
|
return !0;
|
|
995
992
|
{
|
|
@@ -999,12 +996,12 @@ function gt(e) {
|
|
|
999
996
|
}, e);
|
|
1000
997
|
return te.set(e, l), l;
|
|
1001
998
|
}
|
|
1002
|
-
function
|
|
999
|
+
function Vr(e) {
|
|
1003
1000
|
const t = pe();
|
|
1004
1001
|
if (t)
|
|
1005
1002
|
return te.has(t) ? te.get(t).on(e) : gt(t).on(e);
|
|
1006
1003
|
}
|
|
1007
|
-
function
|
|
1004
|
+
function hr({
|
|
1008
1005
|
scene: e,
|
|
1009
1006
|
canvas: t,
|
|
1010
1007
|
windowSize: n,
|
|
@@ -1012,24 +1009,24 @@ function gr({
|
|
|
1012
1009
|
rendererOptions: s,
|
|
1013
1010
|
emit: l
|
|
1014
1011
|
}) {
|
|
1015
|
-
const i = $(e), a =
|
|
1012
|
+
const i = $(e), a = dr(n, t), {
|
|
1016
1013
|
camera: c,
|
|
1017
1014
|
cameras: o,
|
|
1018
1015
|
registerCamera: u,
|
|
1019
1016
|
deregisterCamera: v,
|
|
1020
|
-
setCameraActive:
|
|
1021
|
-
} = In({ sizes: a, scene: e }),
|
|
1017
|
+
setCameraActive: d
|
|
1018
|
+
} = In({ sizes: a, scene: e }), g = {
|
|
1022
1019
|
mode: H(s.renderMode || "always"),
|
|
1023
1020
|
priority: H(0),
|
|
1024
1021
|
frames: H(0),
|
|
1025
1022
|
maxFrames: 60,
|
|
1026
|
-
canBeInvalidated: V(() =>
|
|
1023
|
+
canBeInvalidated: V(() => g.mode.value === "on-demand" && g.frames.value === 0)
|
|
1027
1024
|
};
|
|
1028
|
-
function
|
|
1029
|
-
s.renderMode === "on-demand" && (
|
|
1025
|
+
function h(O = 1) {
|
|
1026
|
+
s.renderMode === "on-demand" && (g.frames.value = Math.min(g.maxFrames, g.frames.value + O));
|
|
1030
1027
|
}
|
|
1031
1028
|
function b() {
|
|
1032
|
-
s.renderMode === "manual" && (
|
|
1029
|
+
s.renderMode === "manual" && (g.frames.value = 1);
|
|
1033
1030
|
}
|
|
1034
1031
|
const { renderer: y } = ar(
|
|
1035
1032
|
{
|
|
@@ -1038,10 +1035,10 @@ function gr({
|
|
|
1038
1035
|
options: s,
|
|
1039
1036
|
emit: l,
|
|
1040
1037
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
1041
|
-
contextParts: { sizes: a, camera: c, render:
|
|
1038
|
+
contextParts: { sizes: a, camera: c, render: g, invalidate: h, advance: b },
|
|
1042
1039
|
disableRender: r
|
|
1043
1040
|
}
|
|
1044
|
-
),
|
|
1041
|
+
), f = {
|
|
1045
1042
|
sizes: a,
|
|
1046
1043
|
scene: i,
|
|
1047
1044
|
camera: c,
|
|
@@ -1061,47 +1058,47 @@ function gr({
|
|
|
1061
1058
|
accumulator: []
|
|
1062
1059
|
}
|
|
1063
1060
|
},
|
|
1064
|
-
render:
|
|
1061
|
+
render: g,
|
|
1065
1062
|
advance: b,
|
|
1066
|
-
extend:
|
|
1067
|
-
invalidate:
|
|
1063
|
+
extend: Pe,
|
|
1064
|
+
invalidate: h,
|
|
1068
1065
|
registerCamera: u,
|
|
1069
|
-
setCameraActive:
|
|
1066
|
+
setCameraActive: d,
|
|
1070
1067
|
deregisterCamera: v,
|
|
1071
|
-
loop:
|
|
1068
|
+
loop: pr()
|
|
1072
1069
|
};
|
|
1073
|
-
_e("useTres",
|
|
1074
|
-
root:
|
|
1075
|
-
},
|
|
1076
|
-
c.value &&
|
|
1070
|
+
_e("useTres", f), f.scene.value.__tres = {
|
|
1071
|
+
root: f
|
|
1072
|
+
}, f.loop.register(() => {
|
|
1073
|
+
c.value && g.frames.value > 0 && (y.value.render(e, c.value), l("render", f.renderer.value)), g.priority.value = 0, g.mode.value === "always" ? g.frames.value = 1 : g.frames.value = Math.max(0, g.frames.value - 1);
|
|
1077
1074
|
}, "render");
|
|
1078
|
-
const { on:
|
|
1079
|
-
|
|
1080
|
-
l("ready",
|
|
1075
|
+
const { on: M, cancel: P } = gt(f);
|
|
1076
|
+
f.loop.setReady(!1), f.loop.start(), M(() => {
|
|
1077
|
+
l("ready", f), f.loop.setReady(!0), fr(e, f, l);
|
|
1081
1078
|
}), K(() => {
|
|
1082
|
-
|
|
1079
|
+
P(), f.loop.stop();
|
|
1083
1080
|
});
|
|
1084
|
-
const
|
|
1081
|
+
const C = 100, E = an({ every: C }), { isSupported: S, memory: _ } = ln({ interval: C }), A = 160;
|
|
1085
1082
|
let L = performance.now();
|
|
1086
1083
|
const p = ({ timestamp: O }) => {
|
|
1087
|
-
|
|
1084
|
+
f.scene.value && (f.perf.memory.allocatedMem = xe(f.scene.value)), O - L >= C && (L = O, f.perf.fps.accumulator.push(E.value), f.perf.fps.accumulator.length > A && f.perf.fps.accumulator.shift(), f.perf.fps.value = E.value, S.value && _.value && (f.perf.memory.accumulator.push(_.value.usedJSHeapSize / 1024 / 1024), f.perf.memory.accumulator.length > A && f.perf.memory.accumulator.shift(), f.perf.memory.currentMem = f.perf.memory.accumulator.reduce((B, R) => B + R, 0) / f.perf.memory.accumulator.length));
|
|
1088
1085
|
};
|
|
1089
1086
|
let w = 0;
|
|
1090
1087
|
const x = 1, { pause: D } = it(({ delta: O }) => {
|
|
1091
|
-
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= x && (window.__TRES__DEVTOOLS__.cb(
|
|
1088
|
+
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= x && (window.__TRES__DEVTOOLS__.cb(f), w = 0));
|
|
1092
1089
|
}, { immediate: !0 });
|
|
1093
1090
|
return K(() => {
|
|
1094
1091
|
D();
|
|
1095
|
-
}),
|
|
1092
|
+
}), f;
|
|
1096
1093
|
}
|
|
1097
1094
|
function pe() {
|
|
1098
|
-
const e =
|
|
1095
|
+
const e = Mt("useTres");
|
|
1099
1096
|
if (!e)
|
|
1100
1097
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
1101
1098
|
return e;
|
|
1102
1099
|
}
|
|
1103
|
-
const
|
|
1104
|
-
function
|
|
1100
|
+
const Yr = pe;
|
|
1101
|
+
function qr() {
|
|
1105
1102
|
const {
|
|
1106
1103
|
camera: e,
|
|
1107
1104
|
scene: t,
|
|
@@ -1121,14 +1118,14 @@ function Jr() {
|
|
|
1121
1118
|
invalidate: i,
|
|
1122
1119
|
advance: a
|
|
1123
1120
|
});
|
|
1124
|
-
function c(v,
|
|
1125
|
-
return r.register(v, "before",
|
|
1121
|
+
function c(v, d = 0) {
|
|
1122
|
+
return r.register(v, "before", d);
|
|
1126
1123
|
}
|
|
1127
1124
|
function o(v) {
|
|
1128
1125
|
return r.register(v, "render");
|
|
1129
1126
|
}
|
|
1130
|
-
function u(v,
|
|
1131
|
-
return r.register(v, "after",
|
|
1127
|
+
function u(v, d = 0) {
|
|
1128
|
+
return r.register(v, "after", d);
|
|
1132
1129
|
}
|
|
1133
1130
|
return {
|
|
1134
1131
|
pause: r.pause,
|
|
@@ -1141,7 +1138,7 @@ function Jr() {
|
|
|
1141
1138
|
onAfterRender: u
|
|
1142
1139
|
};
|
|
1143
1140
|
}
|
|
1144
|
-
function
|
|
1141
|
+
function gr(e, t = {}, n = {}) {
|
|
1145
1142
|
let r = e;
|
|
1146
1143
|
const s = (a) => {
|
|
1147
1144
|
r = a;
|
|
@@ -1175,65 +1172,65 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1175
1172
|
"onPointerMissed",
|
|
1176
1173
|
"onLostPointerCapture",
|
|
1177
1174
|
"onWheel"
|
|
1178
|
-
],
|
|
1175
|
+
], vr = (e) => {
|
|
1179
1176
|
const t = e.scene.value;
|
|
1180
|
-
function n(o, u, v,
|
|
1181
|
-
if (
|
|
1177
|
+
function n(o, u, v, d) {
|
|
1178
|
+
if (d || (d = {}), d.args || (d.args = []), o === "template" || zn(o))
|
|
1182
1179
|
return null;
|
|
1183
|
-
let
|
|
1180
|
+
let g = o.replace("Tres", ""), h;
|
|
1184
1181
|
if (o === "primitive") {
|
|
1185
|
-
(!U(
|
|
1182
|
+
(!U(d.object) || Pt(d.object)) && Ke(
|
|
1186
1183
|
"Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
|
|
1187
|
-
),
|
|
1184
|
+
), g = d.object.type;
|
|
1188
1185
|
const b = {};
|
|
1189
|
-
|
|
1190
|
-
|
|
1186
|
+
h = gr(
|
|
1187
|
+
d.object,
|
|
1191
1188
|
{
|
|
1192
|
-
object: (
|
|
1189
|
+
object: (f) => f,
|
|
1193
1190
|
isPrimitive: () => !0,
|
|
1194
1191
|
__tres: () => b
|
|
1195
1192
|
},
|
|
1196
1193
|
{
|
|
1197
|
-
object: (
|
|
1198
|
-
sr(
|
|
1194
|
+
object: (f, M, P, C) => {
|
|
1195
|
+
sr(f, P, C, { patchProp: l, remove: s, insert: r }, e);
|
|
1199
1196
|
},
|
|
1200
|
-
__tres: (
|
|
1201
|
-
Object.assign(b,
|
|
1197
|
+
__tres: (f) => {
|
|
1198
|
+
Object.assign(b, f);
|
|
1202
1199
|
}
|
|
1203
1200
|
}
|
|
1204
1201
|
);
|
|
1205
1202
|
} else {
|
|
1206
|
-
const b =
|
|
1203
|
+
const b = Me.value[g];
|
|
1207
1204
|
b || Ke(
|
|
1208
|
-
`${
|
|
1209
|
-
),
|
|
1205
|
+
`${g} is not defined on the THREE namespace. Use extend to add it to the catalog.`
|
|
1206
|
+
), h = new b(...d.args);
|
|
1210
1207
|
}
|
|
1211
|
-
return
|
|
1212
|
-
...
|
|
1213
|
-
type:
|
|
1214
|
-
memoizedProps:
|
|
1208
|
+
return h ? (h.isCamera && (d != null && d.position || h.position.set(3, 3, 3), d != null && d.lookAt || h.lookAt(0, 0, 0)), h = z(h, {
|
|
1209
|
+
...h.__tres,
|
|
1210
|
+
type: g,
|
|
1211
|
+
memoizedProps: d,
|
|
1215
1212
|
eventCount: 0,
|
|
1216
1213
|
primitive: o === "primitive",
|
|
1217
|
-
attach:
|
|
1218
|
-
}, e),
|
|
1214
|
+
attach: d.attach
|
|
1215
|
+
}, e), h) : null;
|
|
1219
1216
|
}
|
|
1220
1217
|
function r(o, u) {
|
|
1221
|
-
var
|
|
1218
|
+
var g, h, b;
|
|
1222
1219
|
if (!o)
|
|
1223
1220
|
return;
|
|
1224
1221
|
u = u || t;
|
|
1225
|
-
const v = o.__tres ? o : z(o, {}, e),
|
|
1226
|
-
o = Q(v), u = Q(
|
|
1222
|
+
const v = o.__tres ? o : z(o, {}, e), d = u.__tres ? u : z(u, {}, e);
|
|
1223
|
+
o = Q(v), u = Q(d), o.__tres && ((g = o.__tres) == null ? void 0 : g.eventCount) > 0 && ((h = e.eventManager) == null || h.registerObject(o)), e.registerCamera(o), (b = e.eventManager) == null || b.registerPointerMissedObject(o), v.__tres.attach ? nr(d, v, v.__tres.attach) : N(o) && N(d) && (d.add(o), o.dispatchEvent({ type: "added" })), v.__tres.parent = d, d.__tres.objects && !d.__tres.objects.includes(v) && d.__tres.objects.push(v);
|
|
1227
1224
|
}
|
|
1228
1225
|
function s(o, u) {
|
|
1229
|
-
var
|
|
1226
|
+
var h, b, y, f;
|
|
1230
1227
|
if (!o)
|
|
1231
1228
|
return;
|
|
1232
|
-
o != null && o.__tres && ((
|
|
1229
|
+
o != null && o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((b = e.eventManager) == null || b.deregisterObject(o)), u = be(u) ? "default" : u;
|
|
1233
1230
|
const v = (y = o.__tres) == null ? void 0 : y.dispose;
|
|
1234
1231
|
be(v) || (v === null ? u = !1 : u = v);
|
|
1235
|
-
const
|
|
1236
|
-
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((
|
|
1232
|
+
const d = (f = o.__tres) == null ? void 0 : f.primitive, g = u === "default" ? !d : !!u;
|
|
1233
|
+
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((M) => s(M, u)), g && o.children && [...o.children].forEach((M) => s(M, u)), mt(o, e), ht(o, e), g && !jn(o)) {
|
|
1237
1234
|
if (G(u))
|
|
1238
1235
|
u(o);
|
|
1239
1236
|
else if (G(o.dispose))
|
|
@@ -1244,53 +1241,53 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1244
1241
|
}
|
|
1245
1242
|
"__tres" in o && delete o.__tres;
|
|
1246
1243
|
}
|
|
1247
|
-
function l(o, u, v,
|
|
1248
|
-
var
|
|
1244
|
+
function l(o, u, v, d) {
|
|
1245
|
+
var M, P;
|
|
1249
1246
|
if (!o)
|
|
1250
1247
|
return;
|
|
1251
|
-
let
|
|
1252
|
-
if (o.__tres && (o.__tres.memoizedProps[u] =
|
|
1253
|
-
const
|
|
1254
|
-
s(o), z(o, { attach:
|
|
1248
|
+
let g = o, h = u;
|
|
1249
|
+
if (o.__tres && (o.__tres.memoizedProps[u] = d), u === "attach") {
|
|
1250
|
+
const C = ((M = o.__tres) == null ? void 0 : M.parent) || o.parent;
|
|
1251
|
+
s(o), z(o, { attach: d }, e), C && r(o, C);
|
|
1255
1252
|
return;
|
|
1256
1253
|
}
|
|
1257
1254
|
if (u === "dispose") {
|
|
1258
|
-
o.__tres || (o = z(o, {}, e)), o.__tres.dispose =
|
|
1255
|
+
o.__tres || (o = z(o, {}, e)), o.__tres.dispose = d;
|
|
1259
1256
|
return;
|
|
1260
1257
|
}
|
|
1261
|
-
if (N(o) &&
|
|
1262
|
-
|
|
1258
|
+
if (N(o) && h === "blocks-pointer-events") {
|
|
1259
|
+
d || d === "" ? o[h] = d : delete o[h];
|
|
1263
1260
|
return;
|
|
1264
1261
|
}
|
|
1265
1262
|
Qe.includes(u) && o.__tres && (o.__tres.eventCount += 1);
|
|
1266
|
-
let b = ie(
|
|
1267
|
-
if (
|
|
1268
|
-
const
|
|
1269
|
-
_ && E.length && !Jn(E, S) && (
|
|
1270
|
-
|
|
1271
|
-
new
|
|
1263
|
+
let b = ie(h), y = g == null ? void 0 : g[b];
|
|
1264
|
+
if (h === "args") {
|
|
1265
|
+
const C = o, E = v ?? [], S = d ?? [], _ = ((P = o.__tres) == null ? void 0 : P.type) || o.type;
|
|
1266
|
+
_ && E.length && !Jn(E, S) && (g = Object.assign(
|
|
1267
|
+
C,
|
|
1268
|
+
new Me.value[_](...d)
|
|
1272
1269
|
));
|
|
1273
1270
|
return;
|
|
1274
1271
|
}
|
|
1275
|
-
if (
|
|
1276
|
-
if (
|
|
1272
|
+
if (g.type === "BufferGeometry") {
|
|
1273
|
+
if (h === "args")
|
|
1277
1274
|
return;
|
|
1278
|
-
|
|
1279
|
-
ie(
|
|
1280
|
-
new Wt(...
|
|
1275
|
+
g.setAttribute(
|
|
1276
|
+
ie(h),
|
|
1277
|
+
new Wt(...d)
|
|
1281
1278
|
);
|
|
1282
1279
|
return;
|
|
1283
1280
|
}
|
|
1284
|
-
if (
|
|
1285
|
-
const
|
|
1286
|
-
y =
|
|
1281
|
+
if (h.includes("-") && y === void 0) {
|
|
1282
|
+
const C = h.split("-");
|
|
1283
|
+
y = C.reduce((E, S) => E[ie(S)], g), h = C.pop(), b = h, y != null && y.set || (g = C.reduce((E, S) => E[ie(S)], g));
|
|
1287
1284
|
}
|
|
1288
|
-
let
|
|
1289
|
-
if (
|
|
1290
|
-
Qe.includes(u) || (de(
|
|
1285
|
+
let f = d;
|
|
1286
|
+
if (f === "" && (f = !0), G(y)) {
|
|
1287
|
+
Qe.includes(u) || (de(f) ? o[b](...f) : o[b](f)), b.startsWith("on") && G(f) && (g[b] = f);
|
|
1291
1288
|
return;
|
|
1292
1289
|
}
|
|
1293
|
-
!(y != null && y.set) && !G(y) ?
|
|
1290
|
+
!(y != null && y.set) && !G(y) ? g[b] = f : y.constructor === f.constructor && (y != null && y.copy) ? y == null || y.copy(f) : de(f) ? y.set(...f) : !y.isColor && y.setScalar ? y.setScalar(f) : y.set(f), pt(o);
|
|
1294
1291
|
}
|
|
1295
1292
|
function i(o) {
|
|
1296
1293
|
var u;
|
|
@@ -1301,9 +1298,9 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1301
1298
|
return u.name = o, u;
|
|
1302
1299
|
}
|
|
1303
1300
|
function c(o) {
|
|
1304
|
-
var
|
|
1305
|
-
const u = i(o), v = ((
|
|
1306
|
-
return
|
|
1301
|
+
var g;
|
|
1302
|
+
const u = i(o), v = ((g = u == null ? void 0 : u.__tres) == null ? void 0 : g.objects) || [], d = v.indexOf(o);
|
|
1303
|
+
return d < 0 || d >= v.length - 1 ? null : v[d + 1];
|
|
1307
1304
|
}
|
|
1308
1305
|
return {
|
|
1309
1306
|
insert: r,
|
|
@@ -1322,13 +1319,13 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1322
1319
|
insertStaticContent: () => void 0
|
|
1323
1320
|
};
|
|
1324
1321
|
};
|
|
1325
|
-
function
|
|
1322
|
+
function yr() {
|
|
1326
1323
|
return vt().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
|
1327
1324
|
}
|
|
1328
1325
|
function vt() {
|
|
1329
1326
|
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
|
|
1330
1327
|
}
|
|
1331
|
-
const
|
|
1328
|
+
const _r = typeof Proxy == "function", wr = "devtools-plugin:setup", br = "plugin:settings:set";
|
|
1332
1329
|
let q, Ee;
|
|
1333
1330
|
function Cr() {
|
|
1334
1331
|
var e;
|
|
@@ -1337,7 +1334,7 @@ function Cr() {
|
|
|
1337
1334
|
function Mr() {
|
|
1338
1335
|
return Cr() ? Ee.now() : Date.now();
|
|
1339
1336
|
}
|
|
1340
|
-
class
|
|
1337
|
+
class Pr {
|
|
1341
1338
|
constructor(t, n) {
|
|
1342
1339
|
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
|
|
1343
1340
|
const r = {};
|
|
@@ -1367,7 +1364,7 @@ class Er {
|
|
|
1367
1364
|
now() {
|
|
1368
1365
|
return Mr();
|
|
1369
1366
|
}
|
|
1370
|
-
}, n && n.on(
|
|
1367
|
+
}, n && n.on(br, (i, a) => {
|
|
1371
1368
|
i === this.plugin.id && this.fallbacks.setSettings(a);
|
|
1372
1369
|
}), this.proxiedOn = new Proxy({}, {
|
|
1373
1370
|
get: (i, a) => this.target ? this.target.on[a] : (...c) => {
|
|
@@ -1399,12 +1396,12 @@ class Er {
|
|
|
1399
1396
|
n.resolve(await this.target[n.method](...n.args));
|
|
1400
1397
|
}
|
|
1401
1398
|
}
|
|
1402
|
-
function
|
|
1403
|
-
const n = e, r = vt(), s =
|
|
1399
|
+
function Er(e, t) {
|
|
1400
|
+
const n = e, r = vt(), s = yr(), l = _r && n.enableEarlyProxy;
|
|
1404
1401
|
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
|
|
1405
|
-
s.emit(
|
|
1402
|
+
s.emit(wr, e, t);
|
|
1406
1403
|
else {
|
|
1407
|
-
const i = l ? new
|
|
1404
|
+
const i = l ? new Pr(n, s) : null;
|
|
1408
1405
|
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1409
1406
|
pluginDescriptor: n,
|
|
1410
1407
|
setupFn: t,
|
|
@@ -1412,7 +1409,7 @@ function Tr(e, t) {
|
|
|
1412
1409
|
}), i && t(i.proxiedTarget);
|
|
1413
1410
|
}
|
|
1414
1411
|
}
|
|
1415
|
-
function
|
|
1412
|
+
function Tr(e, t) {
|
|
1416
1413
|
const n = `▲ ■ ●${e}`;
|
|
1417
1414
|
typeof Xe == "function" ? Xe(n, t) : console.log(n);
|
|
1418
1415
|
}
|
|
@@ -1433,7 +1430,7 @@ const yt = (e) => {
|
|
|
1433
1430
|
});
|
|
1434
1431
|
const n = xe(e);
|
|
1435
1432
|
return n > 0 && t.tags.push({
|
|
1436
|
-
label: `${
|
|
1433
|
+
label: `${ur(n)} KB`,
|
|
1437
1434
|
textColor: 15707189,
|
|
1438
1435
|
backgroundColor: 16775644,
|
|
1439
1436
|
tooltip: "Memory usage"
|
|
@@ -1467,22 +1464,22 @@ function _t(e, t, n = "") {
|
|
|
1467
1464
|
t.children.push(s), _t(r, s, n);
|
|
1468
1465
|
});
|
|
1469
1466
|
}
|
|
1470
|
-
const
|
|
1467
|
+
const Sr = [], X = "tres:inspector", Ar = Et({
|
|
1471
1468
|
sceneGraph: null
|
|
1472
1469
|
});
|
|
1473
|
-
function
|
|
1474
|
-
|
|
1470
|
+
function xr(e, t) {
|
|
1471
|
+
Er(
|
|
1475
1472
|
{
|
|
1476
1473
|
id: "dev.esm.tres",
|
|
1477
1474
|
label: "TresJS 🪐",
|
|
1478
1475
|
logo: "https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",
|
|
1479
1476
|
packageName: "tresjs",
|
|
1480
1477
|
homepage: "https://tresjs.org",
|
|
1481
|
-
componentStateTypes:
|
|
1478
|
+
componentStateTypes: Sr,
|
|
1482
1479
|
app: e
|
|
1483
1480
|
},
|
|
1484
1481
|
(n) => {
|
|
1485
|
-
typeof n.now != "function" &&
|
|
1482
|
+
typeof n.now != "function" && Tr(
|
|
1486
1483
|
"You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."
|
|
1487
1484
|
), n.addInspector({
|
|
1488
1485
|
id: X,
|
|
@@ -1496,7 +1493,7 @@ function kr(e, t) {
|
|
|
1496
1493
|
}, 5e3), n.on.getInspectorTree((l) => {
|
|
1497
1494
|
if (l.inspectorId === X) {
|
|
1498
1495
|
const i = yt(t.scene.value);
|
|
1499
|
-
_t(t.scene.value, i, l.filter),
|
|
1496
|
+
_t(t.scene.value, i, l.filter), Ar.sceneGraph = i, l.rootNodes = [i];
|
|
1500
1497
|
}
|
|
1501
1498
|
});
|
|
1502
1499
|
let r = null, s = null;
|
|
@@ -1535,7 +1532,7 @@ function kr(e, t) {
|
|
|
1535
1532
|
}
|
|
1536
1533
|
);
|
|
1537
1534
|
}
|
|
1538
|
-
const
|
|
1535
|
+
const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
|
|
1539
1536
|
__name: "TresCanvas",
|
|
1540
1537
|
props: {
|
|
1541
1538
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -1582,37 +1579,37 @@ const Lr = ["data-scene", "data-tres"], Rr = /* @__PURE__ */ Be({
|
|
|
1582
1579
|
setup(e, { expose: t, emit: n }) {
|
|
1583
1580
|
var y;
|
|
1584
1581
|
const r = e, s = n, l = Tt(), { logWarning: i } = Y(), a = H(), c = $(new nt()), o = (y = Ie()) == null ? void 0 : y.appContext.app;
|
|
1585
|
-
|
|
1586
|
-
const u = (
|
|
1582
|
+
Pe(et);
|
|
1583
|
+
const u = (f, M = !1) => Be({
|
|
1587
1584
|
setup() {
|
|
1588
|
-
var
|
|
1589
|
-
const
|
|
1590
|
-
return
|
|
1585
|
+
var C;
|
|
1586
|
+
const P = (C = Ie()) == null ? void 0 : C.appContext;
|
|
1587
|
+
return P && (P.app = o), _e("useTres", f), _e("extend", Pe), typeof window < "u" && xr(P == null ? void 0 : P.app, f), () => He(Ot, null, M ? [] : l.default());
|
|
1591
1588
|
}
|
|
1592
|
-
}), v = (
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1595
|
-
},
|
|
1596
|
-
dt(
|
|
1597
|
-
root:
|
|
1589
|
+
}), v = (f, M = !1) => {
|
|
1590
|
+
const P = u(f, M), { render: C } = Rt(vr(f));
|
|
1591
|
+
C(He(P), c.value);
|
|
1592
|
+
}, d = (f, M = !1) => {
|
|
1593
|
+
dt(f.scene.value), M && (f.renderer.value.dispose(), f.renderer.value.renderLists.dispose(), f.renderer.value.forceContextLoss()), c.value.__tres = {
|
|
1594
|
+
root: f
|
|
1598
1595
|
};
|
|
1599
|
-
},
|
|
1600
|
-
t({ context:
|
|
1596
|
+
}, g = V(() => r.disableRender), h = $(null);
|
|
1597
|
+
t({ context: h, dispose: () => d(h.value, !0) });
|
|
1601
1598
|
const b = () => {
|
|
1602
|
-
|
|
1599
|
+
d(h.value), v(h.value, !0);
|
|
1603
1600
|
};
|
|
1604
1601
|
return St(() => {
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1602
|
+
const f = a;
|
|
1603
|
+
h.value = hr({
|
|
1607
1604
|
scene: c.value,
|
|
1608
|
-
canvas:
|
|
1605
|
+
canvas: f,
|
|
1609
1606
|
windowSize: r.windowSize ?? !1,
|
|
1610
|
-
disableRender:
|
|
1607
|
+
disableRender: g.value ?? !1,
|
|
1611
1608
|
rendererOptions: r,
|
|
1612
1609
|
emit: s
|
|
1613
1610
|
});
|
|
1614
|
-
const { registerCamera:
|
|
1615
|
-
v(
|
|
1611
|
+
const { registerCamera: M, camera: P, cameras: C, deregisterCamera: E } = h.value;
|
|
1612
|
+
v(h.value);
|
|
1616
1613
|
const S = () => {
|
|
1617
1614
|
const _ = new we(
|
|
1618
1615
|
45,
|
|
@@ -1620,52 +1617,52 @@ const Lr = ["data-scene", "data-tres"], Rr = /* @__PURE__ */ Be({
|
|
|
1620
1617
|
0.1,
|
|
1621
1618
|
1e3
|
|
1622
1619
|
);
|
|
1623
|
-
_.position.set(3, 3, 3), _.lookAt(0, 0, 0),
|
|
1620
|
+
_.position.set(3, 3, 3), _.lookAt(0, 0, 0), M(_);
|
|
1624
1621
|
const A = Te(() => {
|
|
1625
|
-
|
|
1622
|
+
C.value.length >= 2 && (_.removeFromParent(), E(_), A == null || A());
|
|
1626
1623
|
});
|
|
1627
1624
|
};
|
|
1628
1625
|
ce(
|
|
1629
1626
|
() => r.camera,
|
|
1630
1627
|
(_, A) => {
|
|
1631
|
-
_ &&
|
|
1628
|
+
_ && M(_), A && (A.removeFromParent(), E(A));
|
|
1632
1629
|
},
|
|
1633
1630
|
{
|
|
1634
1631
|
immediate: !0
|
|
1635
1632
|
}
|
|
1636
|
-
),
|
|
1633
|
+
), P.value || (i(
|
|
1637
1634
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
1638
1635
|
), S());
|
|
1639
|
-
}), K(b), (
|
|
1636
|
+
}), K(b), (f, M) => (At(), xt("canvas", {
|
|
1640
1637
|
ref_key: "canvas",
|
|
1641
1638
|
ref: a,
|
|
1642
1639
|
"data-scene": c.value.uuid,
|
|
1643
|
-
class: kt(
|
|
1640
|
+
class: kt(f.$attrs.class),
|
|
1644
1641
|
"data-tres": `tresjs ${J(xn).version}`,
|
|
1645
1642
|
style: Lt({
|
|
1646
1643
|
display: "block",
|
|
1647
1644
|
width: "100%",
|
|
1648
1645
|
height: "100%",
|
|
1649
|
-
position:
|
|
1646
|
+
position: f.windowSize ? "fixed" : "relative",
|
|
1650
1647
|
top: 0,
|
|
1651
1648
|
left: 0,
|
|
1652
1649
|
pointerEvents: "auto",
|
|
1653
1650
|
touchAction: "none",
|
|
1654
|
-
...
|
|
1651
|
+
...f.$attrs.style
|
|
1655
1652
|
})
|
|
1656
|
-
}, null, 14,
|
|
1653
|
+
}, null, 14, kr));
|
|
1657
1654
|
}
|
|
1658
|
-
}),
|
|
1655
|
+
}), Rr = [
|
|
1659
1656
|
"TresCanvas",
|
|
1660
1657
|
"TresLeches",
|
|
1661
1658
|
"TresScene"
|
|
1662
|
-
],
|
|
1659
|
+
], Or = {
|
|
1663
1660
|
template: {
|
|
1664
1661
|
compilerOptions: {
|
|
1665
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
1662
|
+
isCustomElement: (e) => e.startsWith("Tres") && !Rr.includes(e) || e === "primitive"
|
|
1666
1663
|
}
|
|
1667
1664
|
}
|
|
1668
|
-
},
|
|
1665
|
+
}, Jr = Or, Kr = {
|
|
1669
1666
|
mounted: (e, t) => {
|
|
1670
1667
|
if (t.arg) {
|
|
1671
1668
|
console.log(`v-log:${t.arg}`, e[t.arg]);
|
|
@@ -1699,19 +1696,19 @@ class wt extends zt {
|
|
|
1699
1696
|
}
|
|
1700
1697
|
const { logWarning: Ze } = Y();
|
|
1701
1698
|
let le, W;
|
|
1702
|
-
const
|
|
1699
|
+
const Dr = {
|
|
1703
1700
|
DirectionalLight: qt,
|
|
1704
1701
|
PointLight: Jt,
|
|
1705
1702
|
SpotLight: Kt,
|
|
1706
1703
|
HemisphereLight: Qt,
|
|
1707
1704
|
RectAreaLight: wt
|
|
1708
|
-
},
|
|
1705
|
+
}, Qr = {
|
|
1709
1706
|
mounted: (e) => {
|
|
1710
1707
|
if (!e.isLight) {
|
|
1711
1708
|
Ze(`${e.type} is not a light`);
|
|
1712
1709
|
return;
|
|
1713
1710
|
}
|
|
1714
|
-
le =
|
|
1711
|
+
le = Dr[e.type], e.parent.add(new le(e, 1, e.color.getHex()));
|
|
1715
1712
|
},
|
|
1716
1713
|
updated: (e) => {
|
|
1717
1714
|
W = e.parent.children.find((t) => t instanceof le), !(W instanceof wt) && W.update();
|
|
@@ -1723,14 +1720,14 @@ const jr = {
|
|
|
1723
1720
|
}
|
|
1724
1721
|
W = e.parent.children.find((t) => t instanceof le), W && W.dispose && W.dispose(), e.parent.remove(W);
|
|
1725
1722
|
}
|
|
1726
|
-
}, { logWarning:
|
|
1723
|
+
}, { logWarning: jr } = Y();
|
|
1727
1724
|
let I = null;
|
|
1728
|
-
const
|
|
1725
|
+
const Xr = {
|
|
1729
1726
|
updated: (e, t) => {
|
|
1730
1727
|
var s;
|
|
1731
1728
|
const n = Zn(t);
|
|
1732
1729
|
if (!n) {
|
|
1733
|
-
|
|
1730
|
+
jr(`v-distance-to: problem with binding value: ${t.value}`);
|
|
1734
1731
|
return;
|
|
1735
1732
|
}
|
|
1736
1733
|
I && (I.dispose(), e.parent.remove(I));
|
|
@@ -1746,38 +1743,38 @@ const Zr = {
|
|
|
1746
1743
|
unmounted: (e) => {
|
|
1747
1744
|
I == null || I.dispose(), e.parent.remove(I);
|
|
1748
1745
|
}
|
|
1749
|
-
},
|
|
1746
|
+
}, Zr = {
|
|
1750
1747
|
install(e) {
|
|
1751
|
-
e.component("TresCanvas",
|
|
1748
|
+
e.component("TresCanvas", Lr);
|
|
1752
1749
|
}
|
|
1753
1750
|
};
|
|
1754
1751
|
export {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1752
|
+
Lr as TresCanvas,
|
|
1753
|
+
Me as catalogue,
|
|
1754
|
+
pr as createRenderLoop,
|
|
1755
|
+
Zr as default,
|
|
1759
1756
|
dt as dispose,
|
|
1760
|
-
|
|
1761
|
-
|
|
1757
|
+
Pe as extend,
|
|
1758
|
+
Fr as isProd,
|
|
1762
1759
|
Fn as normalizeColor,
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1760
|
+
Wr as normalizeVectorFlexibleParam,
|
|
1761
|
+
Vr as onTresReady,
|
|
1762
|
+
Jr as templateCompilerOptions,
|
|
1763
|
+
lr as trasverseObjects,
|
|
1767
1764
|
In as useCamera,
|
|
1768
|
-
|
|
1765
|
+
Nr as useLoader,
|
|
1769
1766
|
Y as useLogger,
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1767
|
+
qr as useLoop,
|
|
1768
|
+
cr as useRaycaster,
|
|
1769
|
+
Ur as useRenderLoop,
|
|
1773
1770
|
ar as useRenderer,
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1771
|
+
Gr as useSeek,
|
|
1772
|
+
zr as useTexture,
|
|
1773
|
+
Yr as useTres,
|
|
1777
1774
|
pe as useTresContext,
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1775
|
+
hr as useTresContextProvider,
|
|
1776
|
+
fr as useTresEventManager,
|
|
1777
|
+
Xr as vDistanceTo,
|
|
1778
|
+
Qr as vLightHelper,
|
|
1779
|
+
Kr as vLog
|
|
1783
1780
|
};
|