@tresjs/core 4.2.0 → 4.2.2
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 +9 -9
- package/dist/tres.js +430 -429
- package/dist/tres.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/tres.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.2.
|
|
3
|
+
* version: v4.2.2
|
|
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 bt = Object.defineProperty;
|
|
9
9
|
var Pt = (e, t, n) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
10
10
|
var me = (e, t, n) => Pt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
11
|
-
import { ref as
|
|
11
|
+
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as le, readonly as ye, unref as J, provide as _e, inject as Ct, isRef as Mt, reactive as Et, defineComponent as Be, useSlots as Tt, getCurrentInstance as Ie, onMounted as St, openBlock as At, createElementBlock as kt, normalizeClass as xt, 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 ce, 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.2", 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
|
"vue",
|
|
17
17
|
"3d",
|
|
18
18
|
"threejs",
|
|
@@ -40,9 +40,9 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.0", dn = "pnpm@9.1.4", pn =
|
|
|
40
40
|
}, _n = "./dist/tres.js", wn = "./dist/tres.js", bn = "./dist/index.d.ts", Pn = [
|
|
41
41
|
"*.d.ts",
|
|
42
42
|
"dist"
|
|
43
|
-
],
|
|
43
|
+
], Cn = {
|
|
44
44
|
access: "public"
|
|
45
|
-
},
|
|
45
|
+
}, Mn = {
|
|
46
46
|
dev: "cd playground && npm run dev",
|
|
47
47
|
build: "vite build",
|
|
48
48
|
playground: "cd playground && npm run dev",
|
|
@@ -122,8 +122,8 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.0", dn = "pnpm@9.1.4", pn =
|
|
|
122
122
|
module: wn,
|
|
123
123
|
types: bn,
|
|
124
124
|
files: Pn,
|
|
125
|
-
publishConfig:
|
|
126
|
-
scripts:
|
|
125
|
+
publishConfig: Cn,
|
|
126
|
+
scripts: Mn,
|
|
127
127
|
peerDependencies: En,
|
|
128
128
|
dependencies: Tn,
|
|
129
129
|
devDependencies: Sn
|
|
@@ -140,11 +140,11 @@ function kn(e) {
|
|
|
140
140
|
function at(e) {
|
|
141
141
|
return typeof e == "string";
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function G(e) {
|
|
144
144
|
return typeof e == "function";
|
|
145
145
|
}
|
|
146
146
|
function N(e) {
|
|
147
|
-
return e === Object(e) && !de(e) && !
|
|
147
|
+
return e === Object(e) && !de(e) && !G(e);
|
|
148
148
|
}
|
|
149
149
|
function W(e) {
|
|
150
150
|
return N(e) && "isObject3D" in e && !!e.isObject3D;
|
|
@@ -171,7 +171,7 @@ function Dn(e) {
|
|
|
171
171
|
return N(e) && !!e.isPrimitive;
|
|
172
172
|
}
|
|
173
173
|
const jn = ({ sizes: e }) => {
|
|
174
|
-
const t =
|
|
174
|
+
const t = H([]), n = V(
|
|
175
175
|
() => t.value[0]
|
|
176
176
|
), r = (i) => {
|
|
177
177
|
const l = i instanceof Dt ? i : t.value.find((o) => o.uuid === i);
|
|
@@ -196,7 +196,7 @@ const jn = ({ sizes: e }) => {
|
|
|
196
196
|
e.aspectRatio.value && t.value.forEach((i) => {
|
|
197
197
|
!i.manual && (i instanceof we || Bn(i)) && (i instanceof we ? i.aspect = e.aspectRatio.value : (i.left = e.width.value * -0.5, i.right = e.width.value * 0.5, i.top = e.height.value * 0.5, i.bottom = e.height.value * -0.5), i.updateProjectionMatrix());
|
|
198
198
|
});
|
|
199
|
-
}),
|
|
199
|
+
}), K(() => {
|
|
200
200
|
t.value = [];
|
|
201
201
|
}), {
|
|
202
202
|
camera: n,
|
|
@@ -209,16 +209,16 @@ const jn = ({ sizes: e }) => {
|
|
|
209
209
|
function Bn(e) {
|
|
210
210
|
return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera;
|
|
211
211
|
}
|
|
212
|
-
const lt = j(), ct = j(), Ae = j(),
|
|
212
|
+
const lt = j(), ct = j(), Ae = j(), Z = new tt();
|
|
213
213
|
let ue = 0, fe = 0;
|
|
214
214
|
const { pause: In, resume: Ne, isActive: Hn } = it(
|
|
215
215
|
() => {
|
|
216
|
-
lt.trigger({ delta: ue, elapsed: fe, clock:
|
|
216
|
+
lt.trigger({ delta: ue, elapsed: fe, clock: Z }), ct.trigger({ delta: ue, elapsed: fe, clock: Z }), Ae.trigger({ delta: ue, elapsed: fe, clock: Z });
|
|
217
217
|
},
|
|
218
218
|
{ immediate: !1 }
|
|
219
219
|
);
|
|
220
220
|
Ae.on(() => {
|
|
221
|
-
ue =
|
|
221
|
+
ue = Z.getDelta(), fe = Z.getElapsedTime();
|
|
222
222
|
});
|
|
223
223
|
let ze = !1;
|
|
224
224
|
const $r = () => (ze || (ze = !0, Ne()), {
|
|
@@ -229,7 +229,7 @@ const $r = () => (ze || (ze = !0, Ne()), {
|
|
|
229
229
|
resume: Ne,
|
|
230
230
|
isActive: Hn
|
|
231
231
|
}), Ur = !0, oe = "[TresJS ▲ ■ ●] ";
|
|
232
|
-
function
|
|
232
|
+
function Y() {
|
|
233
233
|
function e(...r) {
|
|
234
234
|
typeof r[0] == "string" ? r[0] = oe + r[0] : r.unshift(oe), console.error(...r);
|
|
235
235
|
}
|
|
@@ -323,9 +323,9 @@ function Jn(e, t, n, r) {
|
|
|
323
323
|
if (c.uuid === t)
|
|
324
324
|
return c;
|
|
325
325
|
for (const o of c.children) {
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
return
|
|
326
|
+
const u = s(o);
|
|
327
|
+
if (u)
|
|
328
|
+
return u;
|
|
329
329
|
}
|
|
330
330
|
}, a = s(e);
|
|
331
331
|
if (!a) {
|
|
@@ -402,12 +402,12 @@ function er(e, t, n) {
|
|
|
402
402
|
if (!Array.isArray(i[l])) {
|
|
403
403
|
const c = i[l], o = [];
|
|
404
404
|
o.__tresDetach = () => {
|
|
405
|
-
o.every((
|
|
405
|
+
o.every((u) => be(u)) && (i[l] = c);
|
|
406
406
|
}, i[l] = o;
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
const { target: r, key: s } = Pe(e, n);
|
|
410
|
-
t.__tres.previousAttach = r[s], r[s] =
|
|
410
|
+
t.__tres.previousAttach = r[s], r[s] = Q(t);
|
|
411
411
|
} else
|
|
412
412
|
t.__tres.previousAttach = n(e, t);
|
|
413
413
|
}
|
|
@@ -420,7 +420,7 @@ function tr(e, t, n) {
|
|
|
420
420
|
(s = (r = t.__tres) == null ? void 0 : r.previousAttach) == null || s.call(r, e, t);
|
|
421
421
|
(a = t.__tres) == null || delete a.previousAttach;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function z(e, t, n) {
|
|
424
424
|
const r = e;
|
|
425
425
|
return r.__tres = {
|
|
426
426
|
type: "unknown",
|
|
@@ -441,7 +441,7 @@ function pt(e) {
|
|
|
441
441
|
}
|
|
442
442
|
function nr(e, t, n) {
|
|
443
443
|
var s;
|
|
444
|
-
if (!
|
|
444
|
+
if (!G(e.setPixelRatio))
|
|
445
445
|
return;
|
|
446
446
|
let r = 0;
|
|
447
447
|
if (de(n) && n.length >= 2) {
|
|
@@ -451,28 +451,28 @@ function nr(e, t, n) {
|
|
|
451
451
|
r !== ((s = e.getPixelRatio) == null ? void 0 : s.call(e)) && e.setPixelRatio(r);
|
|
452
452
|
}
|
|
453
453
|
function rr(e, t, n, r, s) {
|
|
454
|
-
const a = [...t.__tres.objects], i =
|
|
455
|
-
if (e =
|
|
454
|
+
const a = [...t.__tres.objects], i = Q(t);
|
|
455
|
+
if (e = Q(e), i === e)
|
|
456
456
|
return !0;
|
|
457
|
-
const l =
|
|
457
|
+
const l = z(e, t.__tres ?? {}, s), c = t.parent ?? t.__tres.parent ?? null, o = { ...t.__tres.memoizedProps };
|
|
458
458
|
delete o.object;
|
|
459
|
-
for (const
|
|
460
|
-
mt(
|
|
459
|
+
for (const u of a)
|
|
460
|
+
mt(u, s), ht(u, s);
|
|
461
461
|
i.__tres.objects = [], r.remove(t);
|
|
462
|
-
for (const [
|
|
463
|
-
r.patchProp(l,
|
|
462
|
+
for (const [u, y] of Object.entries(o))
|
|
463
|
+
r.patchProp(l, u, l[u], y);
|
|
464
464
|
n(e), r.insert(t, c);
|
|
465
|
-
for (const
|
|
466
|
-
r.insert(
|
|
465
|
+
for (const u of a)
|
|
466
|
+
r.insert(u, t);
|
|
467
467
|
return !0;
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function Q(e) {
|
|
470
470
|
return Dn(e) ? (e.object.__tres = e.__tres, e.object) : e;
|
|
471
471
|
}
|
|
472
472
|
function mt(e, t) {
|
|
473
473
|
var r, s, a, i;
|
|
474
474
|
const n = ((r = e.__tres) == null ? void 0 : r.parent) || t.scene.value;
|
|
475
|
-
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && Zn(n.__tres.objects, (l) => l !== e), (s = e.__tres) != null && s.attach ? tr(n, e, e.__tres.attach) : ((i = (a = e.parent) == null ? void 0 : a.remove) == null || i.call(a,
|
|
475
|
+
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && Zn(n.__tres.objects, (l) => l !== e), (s = e.__tres) != null && s.attach ? tr(n, e, e.__tres.attach) : ((i = (a = e.parent) == null ? void 0 : a.remove) == null || i.call(a, Q(e)), e.parent = null);
|
|
476
476
|
}
|
|
477
477
|
function ht(e, t) {
|
|
478
478
|
var n;
|
|
@@ -503,7 +503,7 @@ function sr({
|
|
|
503
503
|
options: t,
|
|
504
504
|
contextParts: { sizes: n, render: r, invalidate: s, advance: a }
|
|
505
505
|
}) {
|
|
506
|
-
const i =
|
|
506
|
+
const i = V(() => ({
|
|
507
507
|
alpha: k(t.alpha) ?? !0,
|
|
508
508
|
depth: k(t.depth),
|
|
509
509
|
canvas: Zt(e),
|
|
@@ -516,7 +516,7 @@ function sr({
|
|
|
516
516
|
preserveDrawingBuffer: k(t.preserveDrawingBuffer),
|
|
517
517
|
logarithmicDepthBuffer: k(t.logarithmicDepthBuffer),
|
|
518
518
|
failIfMajorPerformanceCaveat: k(t.failIfMajorPerformanceCaveat)
|
|
519
|
-
})), l =
|
|
519
|
+
})), l = $(new he(i.value));
|
|
520
520
|
function c() {
|
|
521
521
|
t.renderMode === "on-demand" && s();
|
|
522
522
|
}
|
|
@@ -527,40 +527,40 @@ function sr({
|
|
|
527
527
|
}, {
|
|
528
528
|
immediate: !0
|
|
529
529
|
}), le(() => t.clearColor, c);
|
|
530
|
-
const { pixelRatio: o } = en(), { logError:
|
|
531
|
-
const
|
|
530
|
+
const { pixelRatio: o } = en(), { logError: u } = Y(), f = (() => {
|
|
531
|
+
const v = new he(), b = {
|
|
532
532
|
shadowMap: {
|
|
533
|
-
enabled:
|
|
534
|
-
type:
|
|
533
|
+
enabled: v.shadowMap.enabled,
|
|
534
|
+
type: v.shadowMap.type
|
|
535
535
|
},
|
|
536
|
-
toneMapping:
|
|
537
|
-
toneMappingExposure:
|
|
538
|
-
outputColorSpace:
|
|
536
|
+
toneMapping: v.toneMapping,
|
|
537
|
+
toneMappingExposure: v.toneMappingExposure,
|
|
538
|
+
outputColorSpace: v.outputColorSpace
|
|
539
539
|
};
|
|
540
|
-
return
|
|
541
|
-
})(),
|
|
542
|
-
return
|
|
540
|
+
return v.dispose(), b;
|
|
541
|
+
})(), g = k(t.renderMode);
|
|
542
|
+
return g === "on-demand" && s(), g === "manual" && setTimeout(() => {
|
|
543
543
|
a();
|
|
544
544
|
}, 100), Te(() => {
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
if (
|
|
550
|
-
return Ve(ie[
|
|
545
|
+
const v = k(t.preset);
|
|
546
|
+
v && (v in ie || u(`Renderer Preset must be one of these: ${Object.keys(ie).join(", ")}`), ut(l.value, ie[v])), nr(l.value, o.value, k(t.dpr)), g === "always" && (r.frames.value = Math.max(1, r.frames.value));
|
|
547
|
+
const b = (M, E) => {
|
|
548
|
+
const P = k(M), S = () => {
|
|
549
|
+
if (v)
|
|
550
|
+
return Ve(ie[v], E);
|
|
551
551
|
};
|
|
552
|
-
if (
|
|
553
|
-
return
|
|
554
|
-
const
|
|
555
|
-
return
|
|
556
|
-
}, m = (
|
|
552
|
+
if (P !== void 0)
|
|
553
|
+
return P;
|
|
554
|
+
const C = S();
|
|
555
|
+
return C !== void 0 ? C : Ve(f, E);
|
|
556
|
+
}, m = (M, E) => Vn(l.value, E, b(M, E));
|
|
557
557
|
m(t.shadows, "shadowMap.enabled"), m(t.toneMapping ?? st, "toneMapping"), m(t.shadowMapType, "shadowMap.type"), or < 150 && m(!t.useLegacyLights, "physicallyCorrectLights"), m(t.outputColorSpace, "outputColorSpace"), m(t.toneMappingExposure, "toneMappingExposure");
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
558
|
+
const d = b(t.clearColor, "clearColor");
|
|
559
|
+
d && l.value.setClearColor(
|
|
560
|
+
d ? $n(d) : new ce(0)
|
|
561
561
|
// default clear color is not easily/efficiently retrievable from three
|
|
562
562
|
);
|
|
563
|
-
}),
|
|
563
|
+
}), K(() => {
|
|
564
564
|
l.value.dispose(), l.value.forceContextLoss();
|
|
565
565
|
}), {
|
|
566
566
|
renderer: l
|
|
@@ -574,17 +574,18 @@ function ar(e) {
|
|
|
574
574
|
}), t;
|
|
575
575
|
}
|
|
576
576
|
async function Wr(e, t, n, r, s) {
|
|
577
|
-
const { logError: a } =
|
|
577
|
+
const { logError: a } = Y(), i = new e();
|
|
578
578
|
s && s(i), n && n(i);
|
|
579
579
|
const c = (Array.isArray(t) ? t : [t]).map(
|
|
580
|
-
(o) => new Promise((
|
|
580
|
+
(o) => new Promise((u, y) => {
|
|
581
581
|
i.load(
|
|
582
582
|
o,
|
|
583
|
-
(
|
|
584
|
-
|
|
583
|
+
(f) => {
|
|
584
|
+
const g = f;
|
|
585
|
+
g.scene && Object.assign(g, ar(g.scene)), u(g);
|
|
585
586
|
},
|
|
586
587
|
r,
|
|
587
|
-
(
|
|
588
|
+
(f) => y(a("[useLoader] - Failed to load resource", f))
|
|
588
589
|
);
|
|
589
590
|
})
|
|
590
591
|
);
|
|
@@ -612,8 +613,8 @@ async function Nr(e, t) {
|
|
|
612
613
|
roughnessMap: l,
|
|
613
614
|
metalnessMap: c,
|
|
614
615
|
aoMap: o,
|
|
615
|
-
alphaMap:
|
|
616
|
-
matcap:
|
|
616
|
+
alphaMap: u,
|
|
617
|
+
matcap: y
|
|
617
618
|
} = e;
|
|
618
619
|
return {
|
|
619
620
|
map: s ? await r(s) : null,
|
|
@@ -622,39 +623,39 @@ async function Nr(e, t) {
|
|
|
622
623
|
roughnessMap: l ? await r(l) : null,
|
|
623
624
|
metalnessMap: c ? await r(c) : null,
|
|
624
625
|
aoMap: o ? await r(o) : null,
|
|
625
|
-
alphaMap:
|
|
626
|
-
matcap:
|
|
626
|
+
alphaMap: u ? await r(u) : null,
|
|
627
|
+
matcap: y ? await r(y) : null
|
|
627
628
|
};
|
|
628
629
|
}
|
|
629
630
|
}
|
|
630
631
|
const lr = (e, t) => {
|
|
631
|
-
const n =
|
|
632
|
+
const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y: a } = tn({ target: n });
|
|
632
633
|
let i = 0;
|
|
633
|
-
const { width: l, height: c, top: o, left:
|
|
634
|
+
const { width: l, height: c, top: o, left: u } = nn(n), y = ({ x: h, y: T }) => {
|
|
634
635
|
if (n.value)
|
|
635
636
|
return {
|
|
636
|
-
x: (h -
|
|
637
|
-
y: -((
|
|
637
|
+
x: (h - u.value) / l.value * 2 - 1,
|
|
638
|
+
y: -((T - o.value) / c.value) * 2 + 1
|
|
638
639
|
};
|
|
639
|
-
},
|
|
640
|
+
}, f = ({ x: h, y: T }) => {
|
|
640
641
|
if (t.camera.value)
|
|
641
|
-
return t.raycaster.value.setFromCamera(new ge(h,
|
|
642
|
-
},
|
|
643
|
-
const
|
|
642
|
+
return t.raycaster.value.setFromCamera(new ge(h, T), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
|
|
643
|
+
}, g = (h) => {
|
|
644
|
+
const T = y({
|
|
644
645
|
x: (h == null ? void 0 : h.clientX) ?? s.value,
|
|
645
646
|
y: (h == null ? void 0 : h.clientY) ?? a.value
|
|
646
647
|
});
|
|
647
|
-
return
|
|
648
|
-
},
|
|
649
|
-
function
|
|
650
|
-
const
|
|
648
|
+
return T ? f(T) || [] : [];
|
|
649
|
+
}, v = j(), b = j(), m = j(), d = j(), M = j(), E = j(), P = j(), S = j();
|
|
650
|
+
function C(h) {
|
|
651
|
+
const T = {};
|
|
651
652
|
for (const U in h)
|
|
652
|
-
typeof U != "function" && (
|
|
653
|
-
return
|
|
653
|
+
typeof U != "function" && (T[U] = h[U]);
|
|
654
|
+
return T;
|
|
654
655
|
}
|
|
655
|
-
const
|
|
656
|
+
const _ = (h, T) => {
|
|
656
657
|
var Oe, De, je;
|
|
657
|
-
const U =
|
|
658
|
+
const U = C(T), ne = new Se(T == null ? void 0 : T.clientX, T == null ? void 0 : T.clientY, 0).unproject((Oe = t.camera) == null ? void 0 : Oe.value);
|
|
658
659
|
h.trigger({
|
|
659
660
|
...U,
|
|
660
661
|
intersections: r.value,
|
|
@@ -662,52 +663,52 @@ const lr = (e, t) => {
|
|
|
662
663
|
unprojectedPoint: ne,
|
|
663
664
|
ray: (De = t.raycaster) == null ? void 0 : De.value.ray,
|
|
664
665
|
camera: (je = t.camera) == null ? void 0 : je.value,
|
|
665
|
-
sourceEvent:
|
|
666
|
+
sourceEvent: T,
|
|
666
667
|
delta: i,
|
|
667
668
|
stopPropagating: !1
|
|
668
669
|
});
|
|
669
670
|
};
|
|
670
671
|
let L;
|
|
671
672
|
const x = (h) => {
|
|
672
|
-
|
|
673
|
-
},
|
|
673
|
+
g(h), _(m, h), L = h;
|
|
674
|
+
}, p = () => {
|
|
674
675
|
L && x(L);
|
|
675
676
|
};
|
|
676
|
-
let
|
|
677
|
-
const
|
|
678
|
-
var
|
|
679
|
-
|
|
677
|
+
let w, A, D;
|
|
678
|
+
const O = (h) => {
|
|
679
|
+
var T;
|
|
680
|
+
w = (T = r.value[0]) == null ? void 0 : T.object, i = 0, A = new ge(
|
|
680
681
|
(h == null ? void 0 : h.clientX) ?? s.value,
|
|
681
682
|
(h == null ? void 0 : h.clientY) ?? a.value
|
|
682
|
-
),
|
|
683
|
+
), _(M, h);
|
|
683
684
|
};
|
|
684
|
-
let
|
|
685
|
-
const
|
|
686
|
-
var
|
|
687
|
-
h instanceof PointerEvent && (r.value.length === 0 &&
|
|
685
|
+
let B, R = !1;
|
|
686
|
+
const te = (h) => {
|
|
687
|
+
var T, U, ne;
|
|
688
|
+
h instanceof PointerEvent && (r.value.length === 0 && _(E, h), w === ((T = r.value[0]) == null ? void 0 : T.object) && (D = new ge(
|
|
688
689
|
(h == null ? void 0 : h.clientX) ?? s.value,
|
|
689
690
|
(h == null ? void 0 : h.clientY) ?? a.value
|
|
690
|
-
), i = A == null ? void 0 : A.distanceTo(D), h.button === 0 ? (
|
|
691
|
+
), i = A == null ? void 0 : A.distanceTo(D), h.button === 0 ? (_(v, h), B === ((U = r.value[0]) == null ? void 0 : U.object) ? R = !0 : (B = (ne = r.value[0]) == null ? void 0 : ne.object, R = !1)) : h.button === 2 && _(P, h)), _(d, h));
|
|
691
692
|
}, xe = (h) => {
|
|
692
|
-
|
|
693
|
-
}, Le = (h) =>
|
|
694
|
-
return n.value.addEventListener("pointerup",
|
|
695
|
-
n != null && n.value && (n.value.removeEventListener("pointerup",
|
|
693
|
+
R && (_(b, h), B = void 0, R = !1);
|
|
694
|
+
}, Le = (h) => _(m, h), Re = (h) => _(S, h);
|
|
695
|
+
return n.value.addEventListener("pointerup", te), n.value.addEventListener("pointerdown", O), n.value.addEventListener("pointermove", x), n.value.addEventListener("pointerleave", Le), n.value.addEventListener("dblclick", xe), n.value.addEventListener("wheel", Re), K(() => {
|
|
696
|
+
n != null && n.value && (n.value.removeEventListener("pointerup", te), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove", x), n.value.removeEventListener("pointerleave", Le), n.value.removeEventListener("dblclick", xe), n.value.removeEventListener("wheel", Re));
|
|
696
697
|
}), {
|
|
697
698
|
intersects: r,
|
|
698
|
-
onClick: (h) =>
|
|
699
|
-
onDblClick: (h) =>
|
|
700
|
-
onContextMenu: (h) =>
|
|
699
|
+
onClick: (h) => v.on(h).off,
|
|
700
|
+
onDblClick: (h) => b.on(h).off,
|
|
701
|
+
onContextMenu: (h) => P.on(h).off,
|
|
701
702
|
onPointerMove: (h) => m.on(h).off,
|
|
702
|
-
onPointerUp: (h) =>
|
|
703
|
-
onPointerDown: (h) =>
|
|
703
|
+
onPointerUp: (h) => d.on(h).off,
|
|
704
|
+
onPointerDown: (h) => M.on(h).off,
|
|
704
705
|
onPointerMissed: (h) => E.on(h).off,
|
|
705
|
-
onWheel: (h) =>
|
|
706
|
-
forceUpdate:
|
|
706
|
+
onWheel: (h) => S.on(h).off,
|
|
707
|
+
forceUpdate: p
|
|
707
708
|
};
|
|
708
709
|
};
|
|
709
710
|
function zr() {
|
|
710
|
-
const { logWarning: e } =
|
|
711
|
+
const { logWarning: e } = Y();
|
|
711
712
|
function t(a, i, l) {
|
|
712
713
|
let c = null;
|
|
713
714
|
return a.traverse((o) => {
|
|
@@ -745,102 +746,102 @@ function ke(e) {
|
|
|
745
746
|
function cr(e) {
|
|
746
747
|
return (e / 1024).toFixed(2);
|
|
747
748
|
}
|
|
748
|
-
const
|
|
749
|
+
const Ce = H({}), Me = (e) => Object.assign(Ce.value, e);
|
|
749
750
|
function ur(e, t, n) {
|
|
750
751
|
var x;
|
|
751
|
-
const r =
|
|
752
|
+
const r = $(), s = $();
|
|
752
753
|
e && (r.value = e), t && (s.value = t);
|
|
753
|
-
const a = (
|
|
754
|
-
var
|
|
755
|
-
return ((
|
|
756
|
-
}, i = (
|
|
757
|
-
var
|
|
758
|
-
return ((
|
|
759
|
-
}, l =
|
|
760
|
-
function c(
|
|
761
|
-
if (Array.isArray(
|
|
762
|
-
for (const A of
|
|
763
|
-
A(
|
|
764
|
-
typeof
|
|
754
|
+
const a = (p) => {
|
|
755
|
+
var w;
|
|
756
|
+
return ((w = p.__tres) == null ? void 0 : w.eventCount) > 0;
|
|
757
|
+
}, i = (p) => {
|
|
758
|
+
var w;
|
|
759
|
+
return ((w = p.children) == null ? void 0 : w.some((A) => i(A))) || a(p);
|
|
760
|
+
}, l = $(((x = r.value) == null ? void 0 : x.children).filter(i) || []);
|
|
761
|
+
function c(p, w) {
|
|
762
|
+
if (Array.isArray(p))
|
|
763
|
+
for (const A of p)
|
|
764
|
+
A(w);
|
|
765
|
+
typeof p == "function" && p(w);
|
|
765
766
|
}
|
|
766
|
-
function o(
|
|
767
|
-
const A = [], D = () =>
|
|
768
|
-
|
|
769
|
-
for (const
|
|
770
|
-
if (
|
|
767
|
+
function o(p, w) {
|
|
768
|
+
const A = [], D = () => w.stopPropagating = !0;
|
|
769
|
+
w.stopPropagation = D;
|
|
770
|
+
for (const O of w == null ? void 0 : w.intersections) {
|
|
771
|
+
if (w.stopPropagating)
|
|
771
772
|
return;
|
|
772
|
-
|
|
773
|
-
const { object:
|
|
774
|
-
|
|
775
|
-
let
|
|
776
|
-
for (;
|
|
777
|
-
|
|
778
|
-
const
|
|
779
|
-
n(
|
|
773
|
+
w = { ...w, ...O };
|
|
774
|
+
const { object: B } = O;
|
|
775
|
+
w.eventObject = B, c(B[p], w), A.push(B);
|
|
776
|
+
let R = B.parent;
|
|
777
|
+
for (; R !== null && !w.stopPropagating && !A.includes(R); )
|
|
778
|
+
w.eventObject = R, c(R[p], w), A.push(R), R = R.parent;
|
|
779
|
+
const te = zn(p.slice(2));
|
|
780
|
+
n(te, { intersection: O, event: w });
|
|
780
781
|
}
|
|
781
782
|
}
|
|
782
783
|
const {
|
|
783
|
-
onClick:
|
|
784
|
-
onDblClick:
|
|
785
|
-
onContextMenu:
|
|
786
|
-
onPointerMove:
|
|
787
|
-
onPointerDown:
|
|
788
|
-
onPointerUp:
|
|
784
|
+
onClick: u,
|
|
785
|
+
onDblClick: y,
|
|
786
|
+
onContextMenu: f,
|
|
787
|
+
onPointerMove: g,
|
|
788
|
+
onPointerDown: v,
|
|
789
|
+
onPointerUp: b,
|
|
789
790
|
onPointerMissed: m,
|
|
790
|
-
onWheel:
|
|
791
|
-
forceUpdate:
|
|
791
|
+
onWheel: d,
|
|
792
|
+
forceUpdate: M
|
|
792
793
|
} = lr(l, t);
|
|
793
|
-
|
|
794
|
+
b((p) => o("onPointerUp", p)), v((p) => o("onPointerDown", p)), u((p) => o("onClick", p)), y((p) => o("onDoubleClick", p)), f((p) => o("onContextMenu", p)), d((p) => o("onWheel", p));
|
|
794
795
|
let E = [];
|
|
795
|
-
|
|
796
|
-
const
|
|
796
|
+
g((p) => {
|
|
797
|
+
const w = p.intersections.map(({ object: D }) => D), A = p.intersections;
|
|
797
798
|
E.forEach(({ object: D }) => {
|
|
798
|
-
|
|
799
|
-
}),
|
|
800
|
-
E.includes(D) || (o("onPointerEnter",
|
|
801
|
-
}), o("onPointerMove",
|
|
799
|
+
w.includes(D) || (p.intersections = E, o("onPointerLeave", p), o("onPointerOut", p));
|
|
800
|
+
}), p.intersections = A, p.intersections.forEach(({ object: D }) => {
|
|
801
|
+
E.includes(D) || (o("onPointerEnter", p), o("onPointerOver", p));
|
|
802
|
+
}), o("onPointerMove", p), E = p.intersections;
|
|
802
803
|
});
|
|
803
|
-
const
|
|
804
|
-
m((
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}), n("pointer-missed", { event:
|
|
804
|
+
const P = [];
|
|
805
|
+
m((p) => {
|
|
806
|
+
const w = () => p.stopPropagating = !0;
|
|
807
|
+
p.stopPropagation = w, P.forEach((A) => {
|
|
808
|
+
p.stopPropagating || (p.eventObject = A, c(A.onPointerMissed, p));
|
|
809
|
+
}), n("pointer-missed", { event: p });
|
|
809
810
|
});
|
|
810
|
-
function
|
|
811
|
-
re(
|
|
811
|
+
function S(p) {
|
|
812
|
+
re(p) && W(p) && l.value.push(p);
|
|
812
813
|
}
|
|
813
|
-
function
|
|
814
|
-
if (re(
|
|
815
|
-
const
|
|
816
|
-
|
|
814
|
+
function C(p) {
|
|
815
|
+
if (re(p) && W(p)) {
|
|
816
|
+
const w = l.value.indexOf(p);
|
|
817
|
+
w > -1 && l.value.splice(w, 1);
|
|
817
818
|
}
|
|
818
819
|
}
|
|
819
|
-
function
|
|
820
|
-
re(
|
|
820
|
+
function _(p) {
|
|
821
|
+
re(p) && W(p) && p.onPointerMissed && P.push(p);
|
|
821
822
|
}
|
|
822
|
-
function L(
|
|
823
|
-
if (re(
|
|
824
|
-
const
|
|
825
|
-
|
|
823
|
+
function L(p) {
|
|
824
|
+
if (re(p) && W(p)) {
|
|
825
|
+
const w = P.indexOf(p);
|
|
826
|
+
w > -1 && P.splice(w, 1);
|
|
826
827
|
}
|
|
827
828
|
}
|
|
828
829
|
return t.eventManager = {
|
|
829
|
-
forceUpdate:
|
|
830
|
-
registerObject:
|
|
831
|
-
deregisterObject:
|
|
832
|
-
registerPointerMissedObject:
|
|
830
|
+
forceUpdate: M,
|
|
831
|
+
registerObject: S,
|
|
832
|
+
deregisterObject: C,
|
|
833
|
+
registerPointerMissedObject: _,
|
|
833
834
|
deregisterPointerMissedObject: L
|
|
834
835
|
}, {
|
|
835
|
-
forceUpdate:
|
|
836
|
-
registerObject:
|
|
837
|
-
deregisterObject:
|
|
838
|
-
registerPointerMissedObject:
|
|
836
|
+
forceUpdate: M,
|
|
837
|
+
registerObject: S,
|
|
838
|
+
deregisterObject: C,
|
|
839
|
+
registerPointerMissedObject: _,
|
|
839
840
|
deregisterPointerMissedObject: L
|
|
840
841
|
};
|
|
841
842
|
}
|
|
842
843
|
function fr(e, t, n = 10) {
|
|
843
|
-
const r = k(e) ? rn() : on(
|
|
844
|
+
const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)), a = ye(Fe(r.height, n)), i = V(() => s.value / a.value);
|
|
844
845
|
return {
|
|
845
846
|
height: a,
|
|
846
847
|
width: s,
|
|
@@ -851,22 +852,22 @@ function ve() {
|
|
|
851
852
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
852
853
|
let n = 0, r = !1;
|
|
853
854
|
const s = () => {
|
|
854
|
-
const o = Array.from(e.entries()).sort((
|
|
855
|
-
const
|
|
856
|
-
return
|
|
855
|
+
const o = Array.from(e.entries()).sort((u, y) => {
|
|
856
|
+
const f = u[1].priority - y[1].priority;
|
|
857
|
+
return f === 0 ? u[1].addI - y[1].addI : f;
|
|
857
858
|
});
|
|
858
|
-
t.clear(), o.forEach((
|
|
859
|
+
t.clear(), o.forEach((u) => t.add(u[0]));
|
|
859
860
|
}, a = (o) => {
|
|
860
861
|
e.delete(o), t.delete(o);
|
|
861
862
|
};
|
|
862
|
-
return { on: (o,
|
|
863
|
-
e.set(o, { priority:
|
|
864
|
-
const
|
|
865
|
-
return sn(
|
|
866
|
-
off:
|
|
863
|
+
return { on: (o, u = 0) => {
|
|
864
|
+
e.set(o, { priority: u, addI: n++ });
|
|
865
|
+
const y = () => a(o);
|
|
866
|
+
return sn(y), r = !0, {
|
|
867
|
+
off: y
|
|
867
868
|
};
|
|
868
869
|
}, off: a, trigger: (...o) => {
|
|
869
|
-
r && (s(), r = !1), t.forEach((
|
|
870
|
+
r && (s(), r = !1), t.forEach((u) => u(...o));
|
|
870
871
|
}, dispose: () => {
|
|
871
872
|
e.clear(), t.clear();
|
|
872
873
|
}, get count() {
|
|
@@ -875,77 +876,77 @@ function ve() {
|
|
|
875
876
|
}
|
|
876
877
|
function dr() {
|
|
877
878
|
let e = !0, t = !0, n = !1;
|
|
878
|
-
const r = new tt(!1), s =
|
|
879
|
+
const r = new tt(!1), s = H(r.running), a = H(!1);
|
|
879
880
|
let i;
|
|
880
881
|
const l = rt.generateUUID();
|
|
881
882
|
let c = null;
|
|
882
|
-
const o = ve(),
|
|
883
|
-
|
|
884
|
-
let
|
|
885
|
-
function _
|
|
886
|
-
|
|
883
|
+
const o = ve(), u = ve(), y = ve();
|
|
884
|
+
C();
|
|
885
|
+
let f = {};
|
|
886
|
+
function g(_) {
|
|
887
|
+
f = _;
|
|
887
888
|
}
|
|
888
|
-
function
|
|
889
|
+
function v(_, L, x = 0) {
|
|
889
890
|
switch (L) {
|
|
890
891
|
case "before":
|
|
891
|
-
return o.on(
|
|
892
|
+
return o.on(_, x);
|
|
892
893
|
case "render":
|
|
893
|
-
return c || (c =
|
|
894
|
+
return c || (c = _), u.dispose(), u.on(_);
|
|
894
895
|
case "after":
|
|
895
|
-
return
|
|
896
|
+
return y.on(_, x);
|
|
896
897
|
}
|
|
897
898
|
}
|
|
898
|
-
function
|
|
899
|
-
t && (t = !1,
|
|
899
|
+
function b() {
|
|
900
|
+
t && (t = !1, C(), S());
|
|
900
901
|
}
|
|
901
902
|
function m() {
|
|
902
|
-
t = !0,
|
|
903
|
+
t = !0, C(), cancelAnimationFrame(i);
|
|
903
904
|
}
|
|
904
|
-
function
|
|
905
|
-
n = !1,
|
|
905
|
+
function d() {
|
|
906
|
+
n = !1, C();
|
|
906
907
|
}
|
|
907
|
-
function
|
|
908
|
-
n = !0,
|
|
908
|
+
function M() {
|
|
909
|
+
n = !0, C();
|
|
909
910
|
}
|
|
910
911
|
function E() {
|
|
911
912
|
a.value = !0;
|
|
912
913
|
}
|
|
913
|
-
function
|
|
914
|
+
function P() {
|
|
914
915
|
a.value = !1;
|
|
915
916
|
}
|
|
916
|
-
function
|
|
917
|
+
function S() {
|
|
917
918
|
if (!e) {
|
|
918
|
-
i = requestAnimationFrame(
|
|
919
|
+
i = requestAnimationFrame(S);
|
|
919
920
|
return;
|
|
920
921
|
}
|
|
921
|
-
const
|
|
922
|
-
camera:
|
|
923
|
-
scene:
|
|
924
|
-
renderer:
|
|
925
|
-
raycaster:
|
|
926
|
-
controls:
|
|
927
|
-
invalidate:
|
|
928
|
-
advance:
|
|
929
|
-
},
|
|
930
|
-
s.value && o.trigger(
|
|
922
|
+
const _ = r.getDelta(), L = r.getElapsedTime(), x = {
|
|
923
|
+
camera: J(f.camera),
|
|
924
|
+
scene: J(f.scene),
|
|
925
|
+
renderer: J(f.renderer),
|
|
926
|
+
raycaster: J(f.raycaster),
|
|
927
|
+
controls: J(f.controls),
|
|
928
|
+
invalidate: f.invalidate,
|
|
929
|
+
advance: f.advance
|
|
930
|
+
}, p = { delta: _, elapsed: L, clock: r, ...x };
|
|
931
|
+
s.value && o.trigger(p), a.value || (u.count ? u.trigger(p) : c && c(p)), s.value && y.trigger(p), i = requestAnimationFrame(S);
|
|
931
932
|
}
|
|
932
|
-
function
|
|
933
|
-
const
|
|
934
|
-
r.running !==
|
|
933
|
+
function C() {
|
|
934
|
+
const _ = !t && !n;
|
|
935
|
+
r.running !== _ && (r.running ? r.stop() : r.start()), s.value = r.running;
|
|
935
936
|
}
|
|
936
937
|
return {
|
|
937
938
|
loopId: l,
|
|
938
|
-
register: (
|
|
939
|
-
start:
|
|
939
|
+
register: (_, L, x) => v(_, L, x),
|
|
940
|
+
start: b,
|
|
940
941
|
stop: m,
|
|
941
|
-
pause:
|
|
942
|
-
resume:
|
|
942
|
+
pause: M,
|
|
943
|
+
resume: d,
|
|
943
944
|
pauseRender: E,
|
|
944
|
-
resumeRender:
|
|
945
|
+
resumeRender: P,
|
|
945
946
|
isRenderPaused: a,
|
|
946
947
|
isActive: s,
|
|
947
|
-
setContext:
|
|
948
|
-
setReady: (
|
|
948
|
+
setContext: g,
|
|
949
|
+
setReady: (_) => e = _
|
|
949
950
|
};
|
|
950
951
|
}
|
|
951
952
|
function pr(e, t, n = 100) {
|
|
@@ -953,23 +954,23 @@ function pr(e, t, n = 100) {
|
|
|
953
954
|
const r = j(), s = /* @__PURE__ */ new Set();
|
|
954
955
|
let a = !1, i = !1, l = null;
|
|
955
956
|
function c() {
|
|
956
|
-
l && clearTimeout(l), !i && !a && e() ? (r.trigger(t), s.forEach((
|
|
957
|
+
l && clearTimeout(l), !i && !a && e() ? (r.trigger(t), s.forEach((f) => f()), s.clear(), a = !0) : !i && !a && (l = setTimeout(c, n));
|
|
957
958
|
}
|
|
958
959
|
function o() {
|
|
959
960
|
i = !0, l && clearTimeout(l);
|
|
960
961
|
}
|
|
961
962
|
c();
|
|
962
|
-
const
|
|
963
|
-
|
|
963
|
+
const u = (f, ...g) => {
|
|
964
|
+
f(...g);
|
|
964
965
|
};
|
|
965
966
|
return {
|
|
966
|
-
on: (
|
|
967
|
+
on: (f) => {
|
|
967
968
|
if (a)
|
|
968
|
-
return f
|
|
969
|
+
return u(f, t), { off: () => {
|
|
969
970
|
} };
|
|
970
971
|
{
|
|
971
|
-
const
|
|
972
|
-
return s.add(
|
|
972
|
+
const g = r.on(f);
|
|
973
|
+
return s.add(g.off), r.on(f);
|
|
973
974
|
}
|
|
974
975
|
},
|
|
975
976
|
off: r.off,
|
|
@@ -977,10 +978,10 @@ function pr(e, t, n = 100) {
|
|
|
977
978
|
cancel: o
|
|
978
979
|
};
|
|
979
980
|
}
|
|
980
|
-
const
|
|
981
|
+
const ee = /* @__PURE__ */ new WeakMap();
|
|
981
982
|
function gt(e) {
|
|
982
|
-
if (e = e || pe(),
|
|
983
|
-
return
|
|
983
|
+
if (e = e || pe(), ee.has(e))
|
|
984
|
+
return ee.get(e);
|
|
984
985
|
const t = 100, n = Date.now(), a = pr(() => {
|
|
985
986
|
if (Date.now() - n >= t)
|
|
986
987
|
return !0;
|
|
@@ -989,12 +990,12 @@ function gt(e) {
|
|
|
989
990
|
return !!(i && l.width > 0 && l.height > 0);
|
|
990
991
|
}
|
|
991
992
|
}, e);
|
|
992
|
-
return
|
|
993
|
+
return ee.set(e, a), a;
|
|
993
994
|
}
|
|
994
995
|
function Gr(e) {
|
|
995
996
|
const t = pe();
|
|
996
997
|
if (t)
|
|
997
|
-
return
|
|
998
|
+
return ee.has(t) ? ee.get(t).on(e) : gt(t).on(e);
|
|
998
999
|
}
|
|
999
1000
|
function mr({
|
|
1000
1001
|
scene: e,
|
|
@@ -1004,43 +1005,43 @@ function mr({
|
|
|
1004
1005
|
rendererOptions: s,
|
|
1005
1006
|
emit: a
|
|
1006
1007
|
}) {
|
|
1007
|
-
const
|
|
1008
|
-
camera:
|
|
1009
|
-
cameras:
|
|
1010
|
-
registerCamera:
|
|
1011
|
-
deregisterCamera:
|
|
1012
|
-
setCameraActive:
|
|
1013
|
-
} = jn({ sizes:
|
|
1014
|
-
mode:
|
|
1015
|
-
priority:
|
|
1016
|
-
frames:
|
|
1008
|
+
const i = $(e), l = fr(n, t), {
|
|
1009
|
+
camera: c,
|
|
1010
|
+
cameras: o,
|
|
1011
|
+
registerCamera: u,
|
|
1012
|
+
deregisterCamera: y,
|
|
1013
|
+
setCameraActive: f
|
|
1014
|
+
} = jn({ sizes: l, scene: e }), g = {
|
|
1015
|
+
mode: H(s.renderMode || "always"),
|
|
1016
|
+
priority: H(0),
|
|
1017
|
+
frames: H(0),
|
|
1017
1018
|
maxFrames: 60,
|
|
1018
|
-
canBeInvalidated:
|
|
1019
|
+
canBeInvalidated: V(() => g.mode.value === "on-demand" && g.frames.value === 0)
|
|
1019
1020
|
};
|
|
1020
|
-
function
|
|
1021
|
-
s.renderMode === "on-demand"
|
|
1021
|
+
function v(O = 1) {
|
|
1022
|
+
s.renderMode === "on-demand" && (g.frames.value = Math.min(g.maxFrames, g.frames.value + O));
|
|
1022
1023
|
}
|
|
1023
|
-
function
|
|
1024
|
-
s.renderMode === "manual"
|
|
1024
|
+
function b() {
|
|
1025
|
+
s.renderMode === "manual" && (g.frames.value = 1);
|
|
1025
1026
|
}
|
|
1026
|
-
const { renderer:
|
|
1027
|
+
const { renderer: m } = sr(
|
|
1027
1028
|
{
|
|
1028
1029
|
scene: e,
|
|
1029
1030
|
canvas: t,
|
|
1030
1031
|
options: s,
|
|
1031
1032
|
emit: a,
|
|
1032
1033
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
1033
|
-
contextParts: { sizes:
|
|
1034
|
+
contextParts: { sizes: l, camera: c, render: g, invalidate: v, advance: b },
|
|
1034
1035
|
disableRender: r
|
|
1035
1036
|
}
|
|
1036
|
-
),
|
|
1037
|
-
sizes:
|
|
1038
|
-
scene:
|
|
1039
|
-
camera:
|
|
1040
|
-
cameras: ye(
|
|
1041
|
-
renderer:
|
|
1042
|
-
raycaster:
|
|
1043
|
-
controls:
|
|
1037
|
+
), d = {
|
|
1038
|
+
sizes: l,
|
|
1039
|
+
scene: i,
|
|
1040
|
+
camera: c,
|
|
1041
|
+
cameras: ye(o),
|
|
1042
|
+
renderer: m,
|
|
1043
|
+
raycaster: $(new Ft()),
|
|
1044
|
+
controls: H(null),
|
|
1044
1045
|
perf: {
|
|
1045
1046
|
maxFrames: 160,
|
|
1046
1047
|
fps: {
|
|
@@ -1053,41 +1054,41 @@ function mr({
|
|
|
1053
1054
|
accumulator: []
|
|
1054
1055
|
}
|
|
1055
1056
|
},
|
|
1056
|
-
render:
|
|
1057
|
-
advance:
|
|
1058
|
-
extend:
|
|
1059
|
-
invalidate:
|
|
1060
|
-
registerCamera:
|
|
1061
|
-
setCameraActive:
|
|
1062
|
-
deregisterCamera:
|
|
1057
|
+
render: g,
|
|
1058
|
+
advance: b,
|
|
1059
|
+
extend: Me,
|
|
1060
|
+
invalidate: v,
|
|
1061
|
+
registerCamera: u,
|
|
1062
|
+
setCameraActive: f,
|
|
1063
|
+
deregisterCamera: y,
|
|
1063
1064
|
loop: dr()
|
|
1064
1065
|
};
|
|
1065
|
-
_e("useTres",
|
|
1066
|
-
root:
|
|
1067
|
-
},
|
|
1068
|
-
|
|
1066
|
+
_e("useTres", d), d.scene.value.__tres = {
|
|
1067
|
+
root: d
|
|
1068
|
+
}, d.loop.register(() => {
|
|
1069
|
+
c.value && g.frames.value > 0 && (m.value.render(e, c.value), a("render", d.renderer.value)), g.priority.value = 0, g.mode.value === "always" ? g.frames.value = 1 : g.frames.value = Math.max(0, g.frames.value - 1);
|
|
1069
1070
|
}, "render");
|
|
1070
|
-
const { on:
|
|
1071
|
-
|
|
1072
|
-
a("ready",
|
|
1073
|
-
}),
|
|
1074
|
-
|
|
1071
|
+
const { on: M, cancel: E } = gt(d);
|
|
1072
|
+
d.loop.setReady(!1), d.loop.start(), M(() => {
|
|
1073
|
+
a("ready", d), d.loop.setReady(!0), ur(e, d, a);
|
|
1074
|
+
}), K(() => {
|
|
1075
|
+
E(), d.loop.stop();
|
|
1075
1076
|
});
|
|
1076
|
-
const
|
|
1077
|
-
let
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1077
|
+
const P = 100, S = an({ every: P }), { isSupported: C, memory: _ } = ln({ interval: P }), L = 160;
|
|
1078
|
+
let x = performance.now();
|
|
1079
|
+
const p = ({ timestamp: O }) => {
|
|
1080
|
+
d.scene.value && (d.perf.memory.allocatedMem = ke(d.scene.value)), O - x >= P && (x = O, d.perf.fps.accumulator.push(S.value), d.perf.fps.accumulator.length > L && d.perf.fps.accumulator.shift(), d.perf.fps.value = S.value, C.value && _.value && (d.perf.memory.accumulator.push(_.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > L && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((B, R) => B + R, 0) / d.perf.memory.accumulator.length));
|
|
1080
1081
|
};
|
|
1081
|
-
let
|
|
1082
|
-
const
|
|
1083
|
-
window.__TRES__DEVTOOLS__ && (
|
|
1082
|
+
let w = 0;
|
|
1083
|
+
const A = 1, { pause: D } = it(({ delta: O }) => {
|
|
1084
|
+
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= A && (window.__TRES__DEVTOOLS__.cb(d), w = 0));
|
|
1084
1085
|
}, { immediate: !0 });
|
|
1085
|
-
return
|
|
1086
|
-
|
|
1087
|
-
}),
|
|
1086
|
+
return K(() => {
|
|
1087
|
+
D();
|
|
1088
|
+
}), d;
|
|
1088
1089
|
}
|
|
1089
1090
|
function pe() {
|
|
1090
|
-
const e =
|
|
1091
|
+
const e = Ct("useTres");
|
|
1091
1092
|
if (!e)
|
|
1092
1093
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
1093
1094
|
return e;
|
|
@@ -1113,14 +1114,14 @@ function Yr() {
|
|
|
1113
1114
|
invalidate: i,
|
|
1114
1115
|
advance: l
|
|
1115
1116
|
});
|
|
1116
|
-
function c(
|
|
1117
|
-
return r.register(
|
|
1117
|
+
function c(y, f = 0) {
|
|
1118
|
+
return r.register(y, "before", f);
|
|
1118
1119
|
}
|
|
1119
|
-
function o(
|
|
1120
|
-
return r.register(
|
|
1120
|
+
function o(y) {
|
|
1121
|
+
return r.register(y, "render");
|
|
1121
1122
|
}
|
|
1122
|
-
function
|
|
1123
|
-
return r.register(
|
|
1123
|
+
function u(y, f = 0) {
|
|
1124
|
+
return r.register(y, "after", f);
|
|
1124
1125
|
}
|
|
1125
1126
|
return {
|
|
1126
1127
|
pause: r.pause,
|
|
@@ -1130,7 +1131,7 @@ function Yr() {
|
|
|
1130
1131
|
isActive: r.isActive,
|
|
1131
1132
|
onBeforeRender: c,
|
|
1132
1133
|
render: o,
|
|
1133
|
-
onAfterRender:
|
|
1134
|
+
onAfterRender: u
|
|
1134
1135
|
};
|
|
1135
1136
|
}
|
|
1136
1137
|
function hr(e, t = {}, n = {}) {
|
|
@@ -1152,7 +1153,7 @@ function hr(e, t = {}, n = {}) {
|
|
|
1152
1153
|
};
|
|
1153
1154
|
return a = new Proxy({}, i), a;
|
|
1154
1155
|
}
|
|
1155
|
-
const { logError: Ke } =
|
|
1156
|
+
const { logError: Ke } = Y(), Qe = [
|
|
1156
1157
|
"onClick",
|
|
1157
1158
|
"onContextMenu",
|
|
1158
1159
|
"onPointerMove",
|
|
@@ -1169,66 +1170,66 @@ const { logError: Ke } = z(), Qe = [
|
|
|
1169
1170
|
"onWheel"
|
|
1170
1171
|
], gr = (e) => {
|
|
1171
1172
|
const t = e.scene.value;
|
|
1172
|
-
function n(o,
|
|
1173
|
-
if (
|
|
1173
|
+
function n(o, u, y, f) {
|
|
1174
|
+
if (f || (f = {}), f.args || (f.args = []), o === "template" || Wn(o))
|
|
1174
1175
|
return null;
|
|
1175
|
-
let
|
|
1176
|
+
let g = o.replace("Tres", ""), v;
|
|
1176
1177
|
if (o === "primitive") {
|
|
1177
|
-
(!N(
|
|
1178
|
+
(!N(f.object) || Mt(f.object)) && Ke(
|
|
1178
1179
|
"Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
|
|
1179
|
-
),
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1180
|
+
), g = f.object.type;
|
|
1181
|
+
const b = {};
|
|
1182
|
+
v = hr(
|
|
1183
|
+
f.object,
|
|
1183
1184
|
{
|
|
1184
|
-
object: (
|
|
1185
|
+
object: (d) => d,
|
|
1185
1186
|
isPrimitive: () => !0,
|
|
1186
|
-
__tres: () =>
|
|
1187
|
+
__tres: () => b
|
|
1187
1188
|
},
|
|
1188
1189
|
{
|
|
1189
|
-
object: (
|
|
1190
|
-
rr(
|
|
1190
|
+
object: (d, M, E, P) => {
|
|
1191
|
+
rr(d, E, P, { patchProp: a, remove: s, insert: r }, e);
|
|
1191
1192
|
},
|
|
1192
|
-
__tres: (
|
|
1193
|
-
Object.assign(
|
|
1193
|
+
__tres: (d) => {
|
|
1194
|
+
Object.assign(b, d);
|
|
1194
1195
|
}
|
|
1195
1196
|
}
|
|
1196
1197
|
);
|
|
1197
1198
|
} else {
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
`${
|
|
1201
|
-
),
|
|
1199
|
+
const b = Ce.value[g];
|
|
1200
|
+
b || Ke(
|
|
1201
|
+
`${g} is not defined on the THREE namespace. Use extend to add it to the catalog.`
|
|
1202
|
+
), v = new b(...f.args);
|
|
1202
1203
|
}
|
|
1203
|
-
return
|
|
1204
|
-
...
|
|
1205
|
-
type:
|
|
1206
|
-
memoizedProps:
|
|
1204
|
+
return v ? (v.isCamera && (f != null && f.position || v.position.set(3, 3, 3), f != null && f.lookAt || v.lookAt(0, 0, 0)), v = z(v, {
|
|
1205
|
+
...v.__tres,
|
|
1206
|
+
type: g,
|
|
1207
|
+
memoizedProps: f,
|
|
1207
1208
|
eventCount: 0,
|
|
1208
1209
|
primitive: o === "primitive",
|
|
1209
|
-
attach:
|
|
1210
|
-
}, e),
|
|
1210
|
+
attach: f.attach
|
|
1211
|
+
}, e), v) : null;
|
|
1211
1212
|
}
|
|
1212
|
-
function r(o,
|
|
1213
|
-
var
|
|
1213
|
+
function r(o, u) {
|
|
1214
|
+
var g, v, b;
|
|
1214
1215
|
if (!o)
|
|
1215
1216
|
return;
|
|
1216
|
-
|
|
1217
|
-
const
|
|
1218
|
-
o =
|
|
1217
|
+
u = u || t;
|
|
1218
|
+
const y = o.__tres ? o : z(o, {}, e), f = u.__tres ? u : z(u, {}, e);
|
|
1219
|
+
o = Q(y), u = Q(f), o.__tres && ((g = o.__tres) == null ? void 0 : g.eventCount) > 0 && ((v = e.eventManager) == null || v.registerObject(o)), e.registerCamera(o), (b = e.eventManager) == null || b.registerPointerMissedObject(o), y.__tres.attach ? er(f, y, y.__tres.attach) : W(o) && W(f) && (f.add(o), o.dispatchEvent({ type: "added" })), y.__tres.parent = f, f.__tres.objects && !f.__tres.objects.includes(y) && f.__tres.objects.push(y);
|
|
1219
1220
|
}
|
|
1220
|
-
function s(o,
|
|
1221
|
-
var
|
|
1221
|
+
function s(o, u) {
|
|
1222
|
+
var v, b, m, d;
|
|
1222
1223
|
if (!o)
|
|
1223
1224
|
return;
|
|
1224
|
-
o != null && o.__tres && ((
|
|
1225
|
-
const
|
|
1226
|
-
be(
|
|
1227
|
-
const
|
|
1228
|
-
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1231
|
-
else if (
|
|
1225
|
+
o != null && o.__tres && ((v = o.__tres) == null ? void 0 : v.eventCount) > 0 && ((b = e.eventManager) == null || b.deregisterObject(o)), u = be(u) ? "default" : u;
|
|
1226
|
+
const y = (m = o.__tres) == null ? void 0 : m.dispose;
|
|
1227
|
+
be(y) || (y === null ? u = !1 : u = y);
|
|
1228
|
+
const f = (d = o.__tres) == null ? void 0 : d.primitive, g = u === "default" ? !f : !!u;
|
|
1229
|
+
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 && !On(o)) {
|
|
1230
|
+
if (G(u))
|
|
1231
|
+
u(o);
|
|
1232
|
+
else if (G(o.dispose))
|
|
1232
1233
|
try {
|
|
1233
1234
|
o.dispose();
|
|
1234
1235
|
} catch {
|
|
@@ -1236,66 +1237,66 @@ const { logError: Ke } = z(), Qe = [
|
|
|
1236
1237
|
}
|
|
1237
1238
|
"__tres" in o && delete o.__tres;
|
|
1238
1239
|
}
|
|
1239
|
-
function a(o,
|
|
1240
|
-
var
|
|
1240
|
+
function a(o, u, y, f) {
|
|
1241
|
+
var M, E;
|
|
1241
1242
|
if (!o)
|
|
1242
1243
|
return;
|
|
1243
|
-
let
|
|
1244
|
-
if (o.__tres && (o.__tres.memoizedProps[
|
|
1245
|
-
const
|
|
1246
|
-
s(o),
|
|
1244
|
+
let g = o, v = u;
|
|
1245
|
+
if (o.__tres && (o.__tres.memoizedProps[u] = f), u === "attach") {
|
|
1246
|
+
const P = ((M = o.__tres) == null ? void 0 : M.parent) || o.parent;
|
|
1247
|
+
s(o), z(o, { attach: f }, e), P && r(o, P);
|
|
1247
1248
|
return;
|
|
1248
1249
|
}
|
|
1249
|
-
if (
|
|
1250
|
-
o.__tres || (o =
|
|
1250
|
+
if (u === "dispose") {
|
|
1251
|
+
o.__tres || (o = z(o, {}, e)), o.__tres.dispose = f;
|
|
1251
1252
|
return;
|
|
1252
1253
|
}
|
|
1253
|
-
if (W(o) &&
|
|
1254
|
-
|
|
1254
|
+
if (W(o) && v === "blocks-pointer-events") {
|
|
1255
|
+
f || f === "" ? o[v] = f : delete o[v];
|
|
1255
1256
|
return;
|
|
1256
1257
|
}
|
|
1257
|
-
Qe.includes(
|
|
1258
|
-
let
|
|
1259
|
-
if (
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
new
|
|
1258
|
+
Qe.includes(u) && o.__tres && (o.__tres.eventCount += 1);
|
|
1259
|
+
let b = se(v), m = g == null ? void 0 : g[b];
|
|
1260
|
+
if (v === "args") {
|
|
1261
|
+
const P = o, S = y ?? [], C = f ?? [], _ = ((E = o.__tres) == null ? void 0 : E.type) || o.type;
|
|
1262
|
+
_ && S.length && !Yn(S, C) && (g = Object.assign(
|
|
1263
|
+
P,
|
|
1264
|
+
new Ce.value[_](...f)
|
|
1264
1265
|
));
|
|
1265
1266
|
return;
|
|
1266
1267
|
}
|
|
1267
|
-
if (
|
|
1268
|
-
if (
|
|
1268
|
+
if (g.type === "BufferGeometry") {
|
|
1269
|
+
if (v === "args")
|
|
1269
1270
|
return;
|
|
1270
|
-
|
|
1271
|
-
se(
|
|
1272
|
-
new Wt(...
|
|
1271
|
+
g.setAttribute(
|
|
1272
|
+
se(v),
|
|
1273
|
+
new Wt(...f)
|
|
1273
1274
|
);
|
|
1274
1275
|
return;
|
|
1275
1276
|
}
|
|
1276
|
-
if (
|
|
1277
|
-
const
|
|
1278
|
-
m =
|
|
1277
|
+
if (v.includes("-") && m === void 0) {
|
|
1278
|
+
const P = v.split("-");
|
|
1279
|
+
m = P.reduce((S, C) => S[se(C)], g), v = P.pop(), b = v, m != null && m.set || (g = P.reduce((S, C) => S[se(C)], g));
|
|
1279
1280
|
}
|
|
1280
|
-
let
|
|
1281
|
-
if (
|
|
1282
|
-
Qe.includes(
|
|
1281
|
+
let d = f;
|
|
1282
|
+
if (d === "" && (d = !0), G(m)) {
|
|
1283
|
+
Qe.includes(u) || (de(d) ? o[b](...d) : o[b](d)), b.startsWith("on") && G(d) && (g[b] = d);
|
|
1283
1284
|
return;
|
|
1284
1285
|
}
|
|
1285
|
-
!(m != null && m.set) && !
|
|
1286
|
+
!(m != null && m.set) && !G(m) ? g[b] = d : m.constructor === d.constructor && (m != null && m.copy) ? m == null || m.copy(d) : de(d) ? m.set(...d) : !m.isColor && m.setScalar ? m.setScalar(d) : m.set(d), pt(o);
|
|
1286
1287
|
}
|
|
1287
1288
|
function i(o) {
|
|
1288
|
-
var
|
|
1289
|
-
return ((
|
|
1289
|
+
var u;
|
|
1290
|
+
return ((u = o == null ? void 0 : o.__tres) == null ? void 0 : u.parent) || null;
|
|
1290
1291
|
}
|
|
1291
1292
|
function l(o) {
|
|
1292
|
-
const
|
|
1293
|
-
return
|
|
1293
|
+
const u = z(new Nt(), { type: "Comment" }, e);
|
|
1294
|
+
return u.name = o, u;
|
|
1294
1295
|
}
|
|
1295
1296
|
function c(o) {
|
|
1296
|
-
var
|
|
1297
|
-
const
|
|
1298
|
-
return
|
|
1297
|
+
var g;
|
|
1298
|
+
const u = i(o), y = ((g = u == null ? void 0 : u.__tres) == null ? void 0 : g.objects) || [], f = y.indexOf(o);
|
|
1299
|
+
return f < 0 || f >= y.length - 1 ? null : y[f + 1];
|
|
1299
1300
|
}
|
|
1300
1301
|
return {
|
|
1301
1302
|
insert: r,
|
|
@@ -1321,15 +1322,15 @@ function vt() {
|
|
|
1321
1322
|
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
|
|
1322
1323
|
}
|
|
1323
1324
|
const yr = typeof Proxy == "function", _r = "devtools-plugin:setup", wr = "plugin:settings:set";
|
|
1324
|
-
let
|
|
1325
|
+
let q, Ee;
|
|
1325
1326
|
function br() {
|
|
1326
1327
|
var e;
|
|
1327
|
-
return
|
|
1328
|
+
return q !== void 0 || (typeof window < "u" && window.performance ? (q = !0, Ee = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (q = !0, Ee = globalThis.perf_hooks.performance) : q = !1), q;
|
|
1328
1329
|
}
|
|
1329
1330
|
function Pr() {
|
|
1330
1331
|
return br() ? Ee.now() : Date.now();
|
|
1331
1332
|
}
|
|
1332
|
-
class
|
|
1333
|
+
class Cr {
|
|
1333
1334
|
constructor(t, n) {
|
|
1334
1335
|
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
|
|
1335
1336
|
const r = {};
|
|
@@ -1391,12 +1392,12 @@ class Mr {
|
|
|
1391
1392
|
n.resolve(await this.target[n.method](...n.args));
|
|
1392
1393
|
}
|
|
1393
1394
|
}
|
|
1394
|
-
function
|
|
1395
|
+
function Mr(e, t) {
|
|
1395
1396
|
const n = e, r = vt(), s = vr(), a = yr && n.enableEarlyProxy;
|
|
1396
1397
|
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !a))
|
|
1397
1398
|
s.emit(_r, e, t);
|
|
1398
1399
|
else {
|
|
1399
|
-
const i = a ? new
|
|
1400
|
+
const i = a ? new Cr(n, s) : null;
|
|
1400
1401
|
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1401
1402
|
pluginDescriptor: n,
|
|
1402
1403
|
setupFn: t,
|
|
@@ -1459,11 +1460,11 @@ function _t(e, t, n = "") {
|
|
|
1459
1460
|
t.children.push(s), _t(r, s, n);
|
|
1460
1461
|
});
|
|
1461
1462
|
}
|
|
1462
|
-
const Tr = [],
|
|
1463
|
+
const Tr = [], X = "tres:inspector", Sr = Et({
|
|
1463
1464
|
sceneGraph: null
|
|
1464
1465
|
});
|
|
1465
1466
|
function Ar(e, t) {
|
|
1466
|
-
|
|
1467
|
+
Mr(
|
|
1467
1468
|
{
|
|
1468
1469
|
id: "dev.esm.tres",
|
|
1469
1470
|
label: "TresJS 🪐",
|
|
@@ -1477,16 +1478,16 @@ function Ar(e, t) {
|
|
|
1477
1478
|
typeof n.now != "function" && Er(
|
|
1478
1479
|
"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."
|
|
1479
1480
|
), n.addInspector({
|
|
1480
|
-
id:
|
|
1481
|
+
id: X,
|
|
1481
1482
|
label: "TresJS 🪐",
|
|
1482
1483
|
icon: "account_tree",
|
|
1483
1484
|
treeFilterPlaceholder: "Search instances"
|
|
1484
1485
|
}), setInterval(() => {
|
|
1485
|
-
n.sendInspectorTree(
|
|
1486
|
+
n.sendInspectorTree(X);
|
|
1486
1487
|
}, 1e3), setInterval(() => {
|
|
1487
1488
|
n.notifyComponentUpdate();
|
|
1488
1489
|
}, 5e3), n.on.getInspectorTree((a) => {
|
|
1489
|
-
if (a.inspectorId ===
|
|
1490
|
+
if (a.inspectorId === X) {
|
|
1490
1491
|
const i = yt(t.scene.value);
|
|
1491
1492
|
_t(t.scene.value, i, a.filter), Sr.sceneGraph = i, a.rootNodes = [i];
|
|
1492
1493
|
}
|
|
@@ -1494,7 +1495,7 @@ function Ar(e, t) {
|
|
|
1494
1495
|
let r = null, s = null;
|
|
1495
1496
|
n.on.getInspectorState((a) => {
|
|
1496
1497
|
var i;
|
|
1497
|
-
if (a.inspectorId ===
|
|
1498
|
+
if (a.inspectorId === X) {
|
|
1498
1499
|
const [l] = t.scene.value.getObjectsByProperty("uuid", a.nodeId);
|
|
1499
1500
|
if (!l)
|
|
1500
1501
|
return;
|
|
@@ -1522,7 +1523,7 @@ function Ar(e, t) {
|
|
|
1522
1523
|
}))) || []);
|
|
1523
1524
|
}
|
|
1524
1525
|
}), n.on.editInspectorState((a) => {
|
|
1525
|
-
a.inspectorId ===
|
|
1526
|
+
a.inspectorId === X && Jn(t.scene.value, a.nodeId, a.path, a.state.value);
|
|
1526
1527
|
});
|
|
1527
1528
|
}
|
|
1528
1529
|
);
|
|
@@ -1572,66 +1573,66 @@ const kr = ["data-scene", "data-tres"], xr = /* @__PURE__ */ Be({
|
|
|
1572
1573
|
"ready"
|
|
1573
1574
|
],
|
|
1574
1575
|
setup(e, { expose: t, emit: n }) {
|
|
1575
|
-
var
|
|
1576
|
-
const r = e, s = n, a = Tt(), { logWarning: i } =
|
|
1577
|
-
|
|
1578
|
-
const
|
|
1576
|
+
var b;
|
|
1577
|
+
const r = e, s = n, a = Tt(), { logWarning: i } = Y(), l = H(), c = $(new nt()), o = (b = Ie()) == null ? void 0 : b.appContext.app;
|
|
1578
|
+
Me(et);
|
|
1579
|
+
const u = (m) => Be({
|
|
1579
1580
|
setup() {
|
|
1580
|
-
var
|
|
1581
|
-
const
|
|
1582
|
-
return
|
|
1581
|
+
var M;
|
|
1582
|
+
const d = (M = Ie()) == null ? void 0 : M.appContext;
|
|
1583
|
+
return d && (d.app = o), _e("useTres", m), _e("extend", Me), typeof window < "u" && Ar(d == null ? void 0 : d.app, m), () => He(Ot, null, a != null && a.default ? a.default() : []);
|
|
1583
1584
|
}
|
|
1584
|
-
}),
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1587
|
-
},
|
|
1588
|
-
dt(m.scene.value),
|
|
1585
|
+
}), y = (m) => {
|
|
1586
|
+
const d = u(m), { render: M } = Rt(gr(m));
|
|
1587
|
+
M(He(d), c.value);
|
|
1588
|
+
}, f = (m, d = !1) => {
|
|
1589
|
+
dt(m.scene.value), d && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), c.value.__tres = {
|
|
1589
1590
|
root: m
|
|
1590
|
-
},
|
|
1591
|
-
},
|
|
1592
|
-
return t({ context:
|
|
1591
|
+
}, y(m);
|
|
1592
|
+
}, g = V(() => r.disableRender), v = $(null);
|
|
1593
|
+
return t({ context: v, dispose: () => f(v.value, !0) }), St(() => {
|
|
1593
1594
|
const m = l;
|
|
1594
|
-
|
|
1595
|
+
v.value = mr({
|
|
1595
1596
|
scene: c.value,
|
|
1596
1597
|
canvas: m,
|
|
1597
1598
|
windowSize: r.windowSize ?? !1,
|
|
1598
|
-
disableRender:
|
|
1599
|
+
disableRender: g.value ?? !1,
|
|
1599
1600
|
rendererOptions: r,
|
|
1600
1601
|
emit: s
|
|
1601
1602
|
});
|
|
1602
|
-
const { registerCamera:
|
|
1603
|
-
v
|
|
1604
|
-
const
|
|
1605
|
-
const
|
|
1603
|
+
const { registerCamera: d, camera: M, cameras: E, deregisterCamera: P } = v.value;
|
|
1604
|
+
y(v.value);
|
|
1605
|
+
const S = () => {
|
|
1606
|
+
const C = new we(
|
|
1606
1607
|
45,
|
|
1607
1608
|
window.innerWidth / window.innerHeight,
|
|
1608
1609
|
0.1,
|
|
1609
1610
|
1e3
|
|
1610
1611
|
);
|
|
1611
|
-
|
|
1612
|
-
const
|
|
1613
|
-
E.value.length >= 2 && (
|
|
1612
|
+
C.position.set(3, 3, 3), C.lookAt(0, 0, 0), d(C);
|
|
1613
|
+
const _ = Te(() => {
|
|
1614
|
+
E.value.length >= 2 && (C.removeFromParent(), P(C), _ == null || _());
|
|
1614
1615
|
});
|
|
1615
1616
|
};
|
|
1616
1617
|
le(
|
|
1617
1618
|
() => r.camera,
|
|
1618
|
-
(
|
|
1619
|
-
|
|
1619
|
+
(C, _) => {
|
|
1620
|
+
C && d(C), _ && (_.removeFromParent(), P(_));
|
|
1620
1621
|
},
|
|
1621
1622
|
{
|
|
1622
1623
|
immediate: !0
|
|
1623
1624
|
}
|
|
1624
|
-
),
|
|
1625
|
+
), M.value || (i(
|
|
1625
1626
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
1626
|
-
),
|
|
1627
|
-
}),
|
|
1628
|
-
|
|
1629
|
-
}), (m,
|
|
1627
|
+
), S());
|
|
1628
|
+
}), K(() => {
|
|
1629
|
+
f(v.value);
|
|
1630
|
+
}), (m, d) => (At(), kt("canvas", {
|
|
1630
1631
|
ref_key: "canvas",
|
|
1631
1632
|
ref: l,
|
|
1632
1633
|
"data-scene": c.value.uuid,
|
|
1633
1634
|
class: xt(m.$attrs.class),
|
|
1634
|
-
"data-tres": `tresjs ${
|
|
1635
|
+
"data-tres": `tresjs ${J(An).version}`,
|
|
1635
1636
|
style: Lt({
|
|
1636
1637
|
display: "block",
|
|
1637
1638
|
width: "100%",
|
|
@@ -1687,7 +1688,7 @@ class wt extends zt {
|
|
|
1687
1688
|
this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
|
|
1688
1689
|
}
|
|
1689
1690
|
}
|
|
1690
|
-
const { logWarning: Ze } =
|
|
1691
|
+
const { logWarning: Ze } = Y();
|
|
1691
1692
|
let ae, F;
|
|
1692
1693
|
const Or = {
|
|
1693
1694
|
DirectionalLight: qt,
|
|
@@ -1713,8 +1714,8 @@ const Or = {
|
|
|
1713
1714
|
}
|
|
1714
1715
|
F = e.parent.children.find((t) => t instanceof ae), F && F.dispose && F.dispose(), e.parent.remove(F);
|
|
1715
1716
|
}
|
|
1716
|
-
}, { logWarning: Dr } =
|
|
1717
|
-
let
|
|
1717
|
+
}, { logWarning: Dr } = Y();
|
|
1718
|
+
let I = null;
|
|
1718
1719
|
const Qr = {
|
|
1719
1720
|
updated: (e, t) => {
|
|
1720
1721
|
var s;
|
|
@@ -1723,9 +1724,9 @@ const Qr = {
|
|
|
1723
1724
|
Dr(`v-distance-to: problem with binding value: ${t.value}`);
|
|
1724
1725
|
return;
|
|
1725
1726
|
}
|
|
1726
|
-
|
|
1727
|
+
I && (I.dispose(), e.parent.remove(I));
|
|
1727
1728
|
const r = n.clone().sub(e.position);
|
|
1728
|
-
r.normalize(),
|
|
1729
|
+
r.normalize(), I = new Xt(r, e.position, e.position.distanceTo(n), 16776960), e.parent.add(I), console.table(
|
|
1729
1730
|
[
|
|
1730
1731
|
["Distance:", e.position.distanceTo(n)],
|
|
1731
1732
|
[`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
|
|
@@ -1734,7 +1735,7 @@ const Qr = {
|
|
|
1734
1735
|
);
|
|
1735
1736
|
},
|
|
1736
1737
|
unmounted: (e) => {
|
|
1737
|
-
|
|
1738
|
+
I == null || I.dispose(), e.parent.remove(I);
|
|
1738
1739
|
}
|
|
1739
1740
|
}, Xr = {
|
|
1740
1741
|
install(e) {
|
|
@@ -1743,11 +1744,11 @@ const Qr = {
|
|
|
1743
1744
|
};
|
|
1744
1745
|
export {
|
|
1745
1746
|
xr as TresCanvas,
|
|
1746
|
-
|
|
1747
|
+
Ce as catalogue,
|
|
1747
1748
|
dr as createRenderLoop,
|
|
1748
1749
|
Xr as default,
|
|
1749
1750
|
dt as dispose,
|
|
1750
|
-
|
|
1751
|
+
Me as extend,
|
|
1751
1752
|
Ur as isProd,
|
|
1752
1753
|
$n as normalizeColor,
|
|
1753
1754
|
Fr as normalizeVectorFlexibleParam,
|
|
@@ -1756,7 +1757,7 @@ export {
|
|
|
1756
1757
|
ar as trasverseObjects,
|
|
1757
1758
|
jn as useCamera,
|
|
1758
1759
|
Wr as useLoader,
|
|
1759
|
-
|
|
1760
|
+
Y as useLogger,
|
|
1760
1761
|
Yr as useLoop,
|
|
1761
1762
|
lr as useRaycaster,
|
|
1762
1763
|
$r as useRenderLoop,
|