@davi-ai/react-bodyengine-three 1.0.25 → 1.0.26
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/index.js +74 -74
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import M, { useState as D, useMemo as ye, useEffect as V, useRef as se, useCallback as Ye, Suspense as Xe } from "react";
|
|
2
2
|
import * as A from "three/webgpu";
|
|
3
3
|
import { Vector3 as $e, TempNode as et, NodeUpdateType as tt, Matrix4 as X, Vector2 as ge, RenderTarget as be, DepthTexture as we, HalfFloatType as Me, NodeMaterial as st, RendererUtils as Te, Color as rt, QuadMesh as at, FloatType as nt } from "three/webgpu";
|
|
4
4
|
import { Object3D as $s } from "three/webgpu";
|
|
@@ -14,19 +14,19 @@ const Ie = (e) => {
|
|
|
14
14
|
const s = /* @__PURE__ */ new Set(), r = (h, p) => {
|
|
15
15
|
const g = typeof h == "function" ? h(t) : h;
|
|
16
16
|
if (!Object.is(g, t)) {
|
|
17
|
-
const
|
|
18
|
-
t = p ?? (typeof g != "object" || g === null) ? g : Object.assign({}, t, g), s.forEach((i) => i(t,
|
|
17
|
+
const b = t;
|
|
18
|
+
t = p ?? (typeof g != "object" || g === null) ? g : Object.assign({}, t, g), s.forEach((i) => i(t, b));
|
|
19
19
|
}
|
|
20
|
-
}, o = () => t,
|
|
21
|
-
return
|
|
20
|
+
}, o = () => t, v = { setState: r, getState: o, getInitialState: () => x, subscribe: (h) => (s.add(h), () => s.delete(h)) }, x = t = e(r, o, v);
|
|
21
|
+
return v;
|
|
22
22
|
}, Ft = (e) => e ? Ie(e) : Ie, Rt = (e) => e;
|
|
23
23
|
function Bt(e, t = Rt) {
|
|
24
|
-
const s =
|
|
24
|
+
const s = M.useSyncExternalStore(
|
|
25
25
|
e.subscribe,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
M.useCallback(() => t(e.getState()), [e, t]),
|
|
27
|
+
M.useCallback(() => t(e.getInitialState()), [e, t])
|
|
28
28
|
);
|
|
29
|
-
return
|
|
29
|
+
return M.useDebugValue(s), s;
|
|
30
30
|
}
|
|
31
31
|
const zt = (e) => {
|
|
32
32
|
const t = Ft(e), s = (r) => Bt(t, r);
|
|
@@ -358,7 +358,7 @@ const De = /* @__PURE__ */ new Map([
|
|
|
358
358
|
let r = s[e.position || F.eye].getComponent(0);
|
|
359
359
|
const o = s[e.position || F.mouth].getComponent(1);
|
|
360
360
|
let n = 0;
|
|
361
|
-
const f = typeof e.distance == "string" ? parseInt(e.distance) : e.distance,
|
|
361
|
+
const f = typeof e.distance == "string" ? parseInt(e.distance) : e.distance, v = typeof e.rotation == "string" ? parseInt(e.rotation) : e.rotation;
|
|
362
362
|
switch (f) {
|
|
363
363
|
case R.veryclose:
|
|
364
364
|
n = t.veryclose;
|
|
@@ -390,8 +390,8 @@ const De = /* @__PURE__ */ new Map([
|
|
|
390
390
|
n = t.veryfar;
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
switch (
|
|
393
|
+
if (v && v !== G.face)
|
|
394
|
+
switch (v) {
|
|
395
395
|
case G.eighthleft: {
|
|
396
396
|
const x = 0.2588190451;
|
|
397
397
|
r = r - n * x, n = n * Math.sqrt(1 - Math.pow(x, 2));
|
|
@@ -434,16 +434,16 @@ function Je(e) {
|
|
|
434
434
|
function f() {
|
|
435
435
|
return n = n * 1664525 + 1013904223 & 4294967295, (n >>> 0) / 4294967296;
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function v(h, p) {
|
|
438
438
|
const g = p;
|
|
439
|
-
let
|
|
439
|
+
let b;
|
|
440
440
|
if (g <= s.length) {
|
|
441
441
|
const d = [];
|
|
442
442
|
for (let c = 0; c < g; c++)
|
|
443
443
|
s[c] || d.push(c);
|
|
444
|
-
|
|
444
|
+
b = d[Math.floor(f() * d.length)];
|
|
445
445
|
} else
|
|
446
|
-
|
|
446
|
+
b = Math.floor(f() * g);
|
|
447
447
|
let i;
|
|
448
448
|
if (g <= r.length) {
|
|
449
449
|
const d = [];
|
|
@@ -452,8 +452,8 @@ function Je(e) {
|
|
|
452
452
|
i = d[Math.floor(f() * d.length)];
|
|
453
453
|
} else
|
|
454
454
|
i = Math.floor(f() * g);
|
|
455
|
-
const l = (
|
|
456
|
-
return
|
|
455
|
+
const l = (b + f()) / g, y = (i + f()) / g;
|
|
456
|
+
return b < s.length && (s[b] = !0), i < r.length && (r[i] = !0), [l, y];
|
|
457
457
|
}
|
|
458
458
|
o(1), t.push([f(), f()]), s[0] = !0, r[0] = !0;
|
|
459
459
|
let x = 1;
|
|
@@ -461,11 +461,11 @@ function Je(e) {
|
|
|
461
461
|
const h = x * 2;
|
|
462
462
|
o(h);
|
|
463
463
|
for (let p = 0; p < x; p++) {
|
|
464
|
-
const [g,
|
|
464
|
+
const [g, b] = t[p], i = Math.min(Math.floor(g * h), h - 1), l = Math.min(Math.floor(b * h), h - 1);
|
|
465
465
|
i < s.length && (s[i] = !0), l < r.length && (r[l] = !0);
|
|
466
466
|
}
|
|
467
467
|
for (let p = 0; p < x; p++) {
|
|
468
|
-
const g =
|
|
468
|
+
const g = v(p, h);
|
|
469
469
|
t.push(g);
|
|
470
470
|
}
|
|
471
471
|
x = h;
|
|
@@ -541,15 +541,15 @@ class us extends et {
|
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
543
543
|
o && (this._accumulatedFrames = 0), this._accumulatedFrames++;
|
|
544
|
-
const
|
|
545
|
-
this._progressiveWeight.value = o ? 0 : 1 /
|
|
544
|
+
const b = Math.min(this._accumulatedFrames, this.maxAccumulationFrames);
|
|
545
|
+
this._progressiveWeight.value = o ? 0 : 1 / b, this._prevCameraMatrix.copy(r);
|
|
546
546
|
} else
|
|
547
547
|
this._progressiveWeight.value = 0, this._accumulatedFrames = 0;
|
|
548
548
|
this._previousCameraWorldMatrix.value.copy(this._cameraWorldMatrix.value), this._previousCameraProjectionMatrixInverse.value.copy(this._cameraProjectionMatrixInverse.value), this._cameraNearFar.value.set(this.camera.near, this.camera.far), this._cameraWorldMatrix.value.copy(this.camera.matrixWorld), this._cameraWorldMatrixInverse.value.copy(this.camera.matrixWorldInverse), this._cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse);
|
|
549
|
-
const n = this.beautyNode.isRTTNode ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget, f = n.texture.width,
|
|
550
|
-
this._needsPostProcessingSync === !0 && (this.setViewOffset(f,
|
|
551
|
-
const x = this._historyRenderTarget.width !== f || this._historyRenderTarget.height !==
|
|
552
|
-
this.setSize(f,
|
|
549
|
+
const n = this.beautyNode.isRTTNode ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget, f = n.texture.width, v = n.texture.height;
|
|
550
|
+
this._needsPostProcessingSync === !0 && (this.setViewOffset(f, v), this._needsPostProcessingSync = !1), pe = Te.resetRendererState(s, pe), s.setClearColor(new rt(0), 0);
|
|
551
|
+
const x = this._historyRenderTarget.width !== f || this._historyRenderTarget.height !== v;
|
|
552
|
+
this.setSize(f, v), x === !0 && (s.initRenderTarget(this._historyRenderTarget), s.initRenderTarget(this._resolveRenderTarget), s.copyTextureToTexture(n.texture, this._historyRenderTarget.texture)), s.setRenderTarget(this._resolveRenderTarget), me.material = this._resolveMaterial, me.name = "PMJTAA", me.render(s), s.setRenderTarget(null), s.copyTextureToTexture(this._resolveRenderTarget.texture, this._historyRenderTarget.texture);
|
|
553
553
|
const h = s.getDrawingBufferSize(Ee);
|
|
554
554
|
if (this._historyRenderTarget.height === h.height && this._historyRenderTarget.width === h.width) {
|
|
555
555
|
const p = this.depthNode.value;
|
|
@@ -590,7 +590,7 @@ class us extends et {
|
|
|
590
590
|
t.renderer.logarithmicDepthBuffer && (l = r(l));
|
|
591
591
|
const y = vt(i, l, this._previousCameraProjectionMatrixInverse), d = this._previousCameraWorldMatrix.mul($(y, 1)).xyz, c = this._cameraWorldMatrixInverse.mul($(d, 1)).z;
|
|
592
592
|
return this.camera.isOrthographicCamera ? bt(c, this._cameraNearFar.x, this._cameraNearFar.y) : Pe(c, this._cameraNearFar.x, this._cameraNearFar.y);
|
|
593
|
-
},
|
|
593
|
+
}, v = te(([i, l, y, d]) => {
|
|
594
594
|
const c = d.rgb.add(y.rgb).mul(0.5), a = d.rgb.sub(y.rgb).mul(0.5).add(1e-7), S = l.sub($(c, i.a)), P = S.xyz.div(a).abs(), B = oe(P.x, P.y, P.z);
|
|
595
595
|
return B.greaterThan(1).select(
|
|
596
596
|
$(c, i.a).add(S.div(B)),
|
|
@@ -620,8 +620,8 @@ class us extends et {
|
|
|
620
620
|
const I = this.beautyNode.offset(yt(U, q)).load(i).max(0), L = $(I.rgb.mul(I.a), I.a);
|
|
621
621
|
a.addAssign(L), S.addAssign(L.pow2());
|
|
622
622
|
}
|
|
623
|
-
const m = Y(c.length + 1), P = a.div(m), B = S.div(m).sub(P.pow2()).max(0).sqrt().mul(d), u = P.sub(B),
|
|
624
|
-
return
|
|
623
|
+
const m = Y(c.length + 1), P = a.div(m), B = S.div(m).sub(P.pow2()).max(0).sqrt().mul(d), u = P.sub(B), w = P.add(B);
|
|
624
|
+
return v(P.clamp(u, w), y, u, w);
|
|
625
625
|
}), h = te(([i, l]) => {
|
|
626
626
|
const d = i.mul(l).fract().abs(), c = oe(d, d.oneMinus());
|
|
627
627
|
return c.x.mul(c.y).oneMinus().div(0.75);
|
|
@@ -635,8 +635,8 @@ class us extends et {
|
|
|
635
635
|
}), p = te(([i, l, y]) => {
|
|
636
636
|
const d = y.oneMinus(), c = i.mul(Y(1).div(oe(i.r, i.g, i.b).add(1))), a = l.mul(Y(1).div(oe(l.r, l.g, l.b).add(1))), S = Ce(c.rgb), m = Ce(a.rgb);
|
|
637
637
|
return y.mulAssign(Y(1).div(S.add(1))), d.mulAssign(Y(1).div(m.add(1))), Oe(i.mul(y), l.mul(d)).div(oe(y.add(d), 1e-5)).toVar();
|
|
638
|
-
}), g = Ae(this._historyRenderTarget.texture),
|
|
639
|
-
const i = St(), l = this.beautyNode.size(), y = i.mul(l), d = n(y), c = d.get("closestDepth"), a = d.get("closestPositionTexel"), S = d.get("farthestDepth"), m = this.velocityNode.load(a).xy.mul(de(0.5, -0.5)), P = i.sub(m), B = f(P), u = P.greaterThanEqual(0).all().and(P.lessThanEqual(1).all()),
|
|
638
|
+
}), g = Ae(this._historyRenderTarget.texture), b = te(() => {
|
|
639
|
+
const i = St(), l = this.beautyNode.size(), y = i.mul(l), d = n(y), c = d.get("closestDepth"), a = d.get("closestPositionTexel"), S = d.get("farthestDepth"), m = this.velocityNode.load(a).xy.mul(de(0.5, -0.5)), P = i.sub(m), B = f(P), u = P.greaterThanEqual(0).all().and(P.lessThanEqual(1).all()), w = S.sub(c).greaterThan(this.edgeDepthDiff), U = c.sub(B).greaterThan(this.depthThreshold), q = u.and(w.or(U.not())), I = this.beautyNode.sample(i), L = g.sample(i.sub(m)), ne = $(I.rgb.mul(I.a), I.a).toVar(), ce = i.sub(P).mul(l).length().div(this.maxVelocityLength).saturate().sqrt(), T = Y(0.05).toVar();
|
|
640
640
|
this.useSubpixelCorrection && T.addAssign(h(m, l).mul(0.5)), T.assign(q.select(T.add(ce.mul(0.6)).saturate(), 1));
|
|
641
641
|
const _ = this._progressiveWeight, N = _.greaterThan(0).and(q);
|
|
642
642
|
T.assign(N.select(_, T));
|
|
@@ -649,14 +649,14 @@ class us extends et {
|
|
|
649
649
|
p(ne, Z, T)
|
|
650
650
|
);
|
|
651
651
|
});
|
|
652
|
-
return this._resolveMaterial.fragmentNode =
|
|
652
|
+
return this._resolveMaterial.fragmentNode = b(), this._textureNode;
|
|
653
653
|
}
|
|
654
654
|
dispose() {
|
|
655
655
|
this._historyRenderTarget.dispose(), this._resolveRenderTarget.dispose(), this._resolveMaterial.dispose();
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
659
|
-
const e = k((a) => a.animationsLoaded), t = k((a) => a.characterState), s = k((a) => a.lipSyncManager), r = k((a) => a.blendshapeManager), o = C((a) => a.credentials), n = C((a) => a.currentUtterance), f = C((a) => a.textToSpeak),
|
|
659
|
+
const e = k((a) => a.animationsLoaded), t = k((a) => a.characterState), s = k((a) => a.lipSyncManager), r = k((a) => a.blendshapeManager), o = C((a) => a.credentials), n = C((a) => a.currentUtterance), f = C((a) => a.textToSpeak), v = C((a) => a.visemes), x = C((a) => a.blendshapes), h = C((a) => a.visemeIntensity), p = C((a) => a.currentVisemeIndex), g = C((a) => a.currentBlendshapeIndex), b = C((a) => a.useBlendshapeManager), [i, l] = D(!1), [y, d] = D(!1), c = ye(() => o != null && o.region && (o.subscriptionKey || o.token) ? Nt({
|
|
660
660
|
credentials: {
|
|
661
661
|
region: o.region,
|
|
662
662
|
authorizationToken: o.token,
|
|
@@ -671,8 +671,8 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
673
|
}, [c]), V(() => {
|
|
674
|
-
i && (
|
|
675
|
-
}, [i, s, r, e,
|
|
674
|
+
i && (b ? !!r : !!s) && e && d(!0);
|
|
675
|
+
}, [i, s, r, e, b]), V(() => {
|
|
676
676
|
if (f) {
|
|
677
677
|
const a = new It(f);
|
|
678
678
|
os(a);
|
|
@@ -690,9 +690,9 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
690
690
|
}, [n]), V(() => {
|
|
691
691
|
s && (s.visemeIntensity = h);
|
|
692
692
|
}, [h]), V(() => {
|
|
693
|
-
if (!
|
|
694
|
-
if (!s.isStarted && s.start(),
|
|
695
|
-
|
|
693
|
+
if (!b && s && t === J.speaking) {
|
|
694
|
+
if (!s.isStarted && s.start(), v.length > 1 && p === 0)
|
|
695
|
+
v.forEach((a) => {
|
|
696
696
|
const S = parseInt(a.name);
|
|
697
697
|
if (!isNaN(S)) {
|
|
698
698
|
const m = De.get(S);
|
|
@@ -700,17 +700,17 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
700
700
|
}
|
|
701
701
|
});
|
|
702
702
|
else
|
|
703
|
-
for (let a = p + 1; a <
|
|
704
|
-
const S =
|
|
703
|
+
for (let a = p + 1; a < v.length; a++) {
|
|
704
|
+
const S = v[a], m = parseInt(S.name);
|
|
705
705
|
if (!isNaN(m)) {
|
|
706
706
|
const P = De.get(m);
|
|
707
707
|
P && s.PlayVisemeAsync(P, S.elapsedTime / 1e4);
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
-
is(
|
|
710
|
+
is(v.length - 1);
|
|
711
711
|
}
|
|
712
|
-
}, [t,
|
|
713
|
-
if (
|
|
712
|
+
}, [t, v, s, b]), V(() => {
|
|
713
|
+
if (b && r && t === J.speaking) {
|
|
714
714
|
if (!r.isStarted && r.start(), x.length > 1 && g === 0)
|
|
715
715
|
x.forEach((a) => {
|
|
716
716
|
r.PlayBlendShapeAsync(a);
|
|
@@ -722,7 +722,7 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
722
722
|
}
|
|
723
723
|
cs(x.length - 1);
|
|
724
724
|
}
|
|
725
|
-
}, [t, x, r,
|
|
725
|
+
}, [t, x, r, b]), V(() => {
|
|
726
726
|
t !== J.speaking && (qe(), Ge());
|
|
727
727
|
}, [t]), null;
|
|
728
728
|
}, ps = ({ points: e, color: t = "red" }) => {
|
|
@@ -730,20 +730,20 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
730
730
|
const r = new A.BufferGeometry().setFromPoints(e), o = new A.LineBasicMaterial({ color: t, toneMapped: !1 });
|
|
731
731
|
return new A.Line(r, o);
|
|
732
732
|
}, [e, t]);
|
|
733
|
-
return /* @__PURE__ */
|
|
733
|
+
return /* @__PURE__ */ M.createElement("primitive", { object: s });
|
|
734
734
|
}, gs = ({ parentGpuTier: e, setIsGpuAvailable: t, children: s, tonemapping: r }) => {
|
|
735
|
-
const o = z((u) => u.cameraPosition), n = z((u) => u.lookAt), f = z((u) => u.movable),
|
|
735
|
+
const o = z((u) => u.cameraPosition), n = z((u) => u.lookAt), f = z((u) => u.movable), v = E((u) => u.targets), x = E((u) => u.showFirstTarget), [h] = D(e || lt()), [p, g] = D(), [b, i] = D(null), [l, y] = D(void 0), d = se(null), c = se(null), a = se(null), S = (u) => {
|
|
736
736
|
u.preventDefault(), u.stopPropagation();
|
|
737
737
|
};
|
|
738
738
|
V(() => {
|
|
739
739
|
Et(c.current);
|
|
740
740
|
}, [c.current]), V(() => {
|
|
741
|
-
var u,
|
|
741
|
+
var u, w, U, q;
|
|
742
742
|
if (f)
|
|
743
|
-
|
|
743
|
+
b == null || b.abort(), i(null);
|
|
744
744
|
else {
|
|
745
745
|
const I = new AbortController();
|
|
746
|
-
i(I), (u = d.current) == null || u.addEventListener("wheel", S, { passive: !1, signal: I.signal }), (
|
|
746
|
+
i(I), (u = d.current) == null || u.addEventListener("wheel", S, { passive: !1, signal: I.signal }), (w = d.current) == null || w.addEventListener("pointerdown", S, { passive: !1, signal: I.signal }), (U = d.current) == null || U.addEventListener("pointermove", S, { passive: !1, signal: I.signal }), (q = d.current) == null || q.addEventListener("click", S, { passive: !1, signal: I.signal });
|
|
747
747
|
}
|
|
748
748
|
}, [f]), V(() => {
|
|
749
749
|
a != null && a.current && n && o && a.current.setLookAt(o.x, o.y, o.z, n.x, n.y, n.z, !0);
|
|
@@ -796,26 +796,26 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
796
796
|
}
|
|
797
797
|
}, [p]);
|
|
798
798
|
const m = se(void 0), P = Ye(async (u) => {
|
|
799
|
-
const
|
|
799
|
+
const w = new A.WebGPURenderer({
|
|
800
800
|
canvas: u.canvas,
|
|
801
801
|
antialias: !1,
|
|
802
802
|
alpha: !0,
|
|
803
803
|
powerPreference: "high-performance"
|
|
804
804
|
});
|
|
805
|
-
return
|
|
805
|
+
return w.setClearColor(new A.Color("#000000"), 0), w.setPixelRatio(devicePixelRatio), w.shadowMap.type = A.PCFSoftShadowMap, await w.init(), w;
|
|
806
806
|
}, []), B = ye(() => {
|
|
807
|
-
if (
|
|
808
|
-
const u =
|
|
809
|
-
return [
|
|
807
|
+
if (v.length) {
|
|
808
|
+
const u = v[0], w = new A.Vector3(u.position.x - 0.5, u.position.y, u.position.z - 0.1), U = new A.Vector3(u.position.x + 0.5, u.position.y, u.position.z - 0.1);
|
|
809
|
+
return [w, U];
|
|
810
810
|
} else if (o) {
|
|
811
|
-
const u = new A.Vector3(o.x - 0.5, o.y, o.z - 0.1),
|
|
812
|
-
return [u,
|
|
811
|
+
const u = new A.Vector3(o.x - 0.5, o.y, o.z - 0.1), w = new A.Vector3(o.x + 0.5, o.y, o.z - 0.1);
|
|
812
|
+
return [u, w];
|
|
813
813
|
}
|
|
814
814
|
return [];
|
|
815
|
-
}, [
|
|
816
|
-
return l ? /* @__PURE__ */
|
|
815
|
+
}, [v, o]);
|
|
816
|
+
return l ? /* @__PURE__ */ M.createElement(Pt, { gl: P, dpr: l, ref: d, shadows: !0 }, /* @__PURE__ */ M.createElement(fs, { tonemapping: r, processedTier: p }), /* @__PURE__ */ M.createElement(ht, null), /* @__PURE__ */ M.createElement(ms, null), /* @__PURE__ */ M.createElement(dt, { ref: c, makeDefault: !0, fov: 28 }), /* @__PURE__ */ M.createElement(ut, { ref: a }), x && B.length && /* @__PURE__ */ M.createElement(ps, { points: B, color: "red" }), /* @__PURE__ */ M.createElement(Xe, { fallback: null }, s)) : /* @__PURE__ */ M.createElement(M.Fragment, null);
|
|
817
817
|
}, fs = ({ tonemapping: e, processedTier: t }) => {
|
|
818
|
-
const { gl: s, scene: r, camera: o, size: n } = Vt(), [f] = D(new A.Vector3(-3, 2, 2)), [
|
|
818
|
+
const { gl: s, scene: r, camera: o, size: n } = Vt(), [f] = D(new A.Vector3(-3, 2, 2)), [v] = D(new A.Vector3(0, 1, 0)), [x] = D(2), [h] = D(-3e-3), [p] = D(0.6), g = se(null), b = se(null);
|
|
819
819
|
return V(() => {
|
|
820
820
|
s && (s.shadowMap.type = A.PCFSoftShadowMap, s.toneMapping = e, t !== "low" ? r.environmentIntensity = p : r.environmentIntensity = 1);
|
|
821
821
|
}, [s, e]), V(() => {
|
|
@@ -831,7 +831,7 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
831
831
|
if (i) {
|
|
832
832
|
const c = l.getTextureNode("output"), a = l.getTextureNode("diffuseColor"), S = l.getTextureNode("depth"), m = l.getTextureNode("velocity"), P = l.getTextureNode("normal"), B = kt((L) => Ct(P.sample(L))), u = _t(c, S, B, o);
|
|
833
833
|
u.aoIntensity.value = 1, u.giIntensity.value = 5, u.sliceCount.value = 2, u.stepCount.value = 8, u.thickness.value = 0.03, u.radius.value = 0.5, u.expFactor.value = 0.1, u.backfaceLighting.value = 0.1;
|
|
834
|
-
const
|
|
834
|
+
const w = u.rgb, U = u.a, q = $(Oe(c.rgb.mul(U), a.rgb.mul(w)), c.a), I = Le(q, S, m, o);
|
|
835
835
|
I.jitterIntensity = 0.25, y = I;
|
|
836
836
|
} else {
|
|
837
837
|
const c = Le(
|
|
@@ -843,16 +843,16 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
843
843
|
c.jitterIntensity = 0.25, y = c;
|
|
844
844
|
}
|
|
845
845
|
const d = new A.RenderPipeline(s);
|
|
846
|
-
return d.outputNode = y,
|
|
847
|
-
d.dispose(),
|
|
846
|
+
return d.outputNode = y, b.current = d, () => {
|
|
847
|
+
d.dispose(), b.current = null;
|
|
848
848
|
};
|
|
849
849
|
}, [s, r, o, t]), V(() => {
|
|
850
850
|
!s || !n || s.setSize(n.width, n.height);
|
|
851
851
|
}, [n]), He(({ gl: i, scene: l, camera: y }) => {
|
|
852
|
-
|
|
853
|
-
}, 1), /* @__PURE__ */
|
|
852
|
+
b.current && b.current.render();
|
|
853
|
+
}, 1), /* @__PURE__ */ M.createElement(M.Fragment, null, t !== "low" && s && /* @__PURE__ */ M.createElement(M.Fragment, null, /* @__PURE__ */ M.createElement("directionalLight", { ref: g, color: "white", position: f.toArray(), "target-position": v.toArray(), intensity: x, castShadow: !0, "shadow-mapSize-width": 512, "shadow-mapSize-height": 512, "shadow-bias": h, "shadow-intensity": 0.7, "shadow-radius": 1.5 }, /* @__PURE__ */ M.createElement("orthographicCamera", { attach: "shadow-camera", args: [-1, 1, 2, -0.5, 2, 8] }))));
|
|
854
854
|
}, ys = ({ character: e, autoLookAt: t }) => {
|
|
855
|
-
const s = k((h) => h.characterState), r = E((h) => h.currentAUs), o = E((h) => h.currentGaze), n = E((h) => h.currentHeadPose), f = E((h) => h.lookAtCamera),
|
|
855
|
+
const s = k((h) => h.characterState), r = E((h) => h.currentAUs), o = E((h) => h.currentGaze), n = E((h) => h.currentHeadPose), f = E((h) => h.lookAtCamera), v = z((h) => h.cameraPosition), x = E((h) => h.targets);
|
|
856
856
|
return He((h, p) => {
|
|
857
857
|
const g = {
|
|
858
858
|
deltaTime: p,
|
|
@@ -861,7 +861,7 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
861
861
|
gaze: o,
|
|
862
862
|
headPose: n,
|
|
863
863
|
characterState: s,
|
|
864
|
-
lookAt: f ?
|
|
864
|
+
lookAt: f ? v : void 0,
|
|
865
865
|
targets: x
|
|
866
866
|
};
|
|
867
867
|
e.update(g);
|
|
@@ -882,8 +882,8 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
882
882
|
}, [s, t]), V(() => {
|
|
883
883
|
Dt(e);
|
|
884
884
|
}, [e]), null;
|
|
885
|
-
}, Gs = ({ url: e, type: t, animationsUrl: s, gender: r, speechSynthesis: o, camera: n, onLoadingCompleted: f, autoLookAt:
|
|
886
|
-
const S = k((T) => T.animationsLoaded), m = z((T) => T.defaultPositions), P = z((T) => T.defaultDistances), [B, u] = D(), [
|
|
885
|
+
}, Gs = ({ url: e, type: t, animationsUrl: s, gender: r, speechSynthesis: o, camera: n, onLoadingCompleted: f, autoLookAt: v, breathing: x, disableAnimations: h, debug: p, enableBml: g, animationWeights: b, license: i, detectGpuData: l, environmentPreset: y = "apartment", tonemapping: d = A.NeutralToneMapping, targets: c, useBlendshapeManager: a = !1 }) => {
|
|
886
|
+
const S = k((T) => T.animationsLoaded), m = z((T) => T.defaultPositions), P = z((T) => T.defaultDistances), [B, u] = D(), [w, U] = D(null), [q, I] = D(), [L, ne] = D(!1), xe = async (T) => {
|
|
887
887
|
let _ = null;
|
|
888
888
|
switch (t) {
|
|
889
889
|
case ee.cc3:
|
|
@@ -907,7 +907,7 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
907
907
|
type: t,
|
|
908
908
|
debug: p,
|
|
909
909
|
enableBmlManager: !!g,
|
|
910
|
-
animationWeights:
|
|
910
|
+
animationWeights: b,
|
|
911
911
|
useBlendshapeManager: a,
|
|
912
912
|
license: i
|
|
913
913
|
};
|
|
@@ -929,10 +929,10 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
929
929
|
};
|
|
930
930
|
V(() => {
|
|
931
931
|
var T, _;
|
|
932
|
-
|
|
932
|
+
w && S && (x === !1 && ((_ = (T = w.animationManager) == null ? void 0 : T.disableBreathing) == null || _.call(T)), L ? (Jt(w.getAllAnimationNames()), Kt(w.getAllAnimations()), setTimeout(() => {
|
|
933
933
|
f == null || f();
|
|
934
934
|
}, 1e3)) : ce());
|
|
935
|
-
}, [
|
|
935
|
+
}, [w, S, L]), V(() => {
|
|
936
936
|
Wt(c || []);
|
|
937
937
|
}, [c]), V(() => {
|
|
938
938
|
Fe(!1), B !== void 0 && (B ? xe(e) : f == null || f());
|
|
@@ -951,9 +951,9 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
951
951
|
hs(a);
|
|
952
952
|
}, [a]);
|
|
953
953
|
const ce = () => {
|
|
954
|
-
if (
|
|
954
|
+
if (w && q) {
|
|
955
955
|
try {
|
|
956
|
-
const T = new A.Box3().setFromObject(
|
|
956
|
+
const T = new A.Box3().setFromObject(w), _ = T.max, N = T.min, O = new A.Vector3((_.x + N.x) / 2, (_.y + N.y) / 2, (_.z + N.z) / 2);
|
|
957
957
|
Ut(O);
|
|
958
958
|
const Z = Math.abs(_.x - N.x), j = Math.abs(_.y - N.y), Ke = Math.abs(_.z - N.z);
|
|
959
959
|
jt({
|
|
@@ -993,7 +993,7 @@ const Le = (e, t, s, r) => new us(pt(e), t, s, r), ms = () => {
|
|
|
993
993
|
ne(!0);
|
|
994
994
|
}
|
|
995
995
|
};
|
|
996
|
-
return /* @__PURE__ */
|
|
996
|
+
return /* @__PURE__ */ M.createElement(gs, { parentGpuTier: l, setIsGpuAvailable: u, tonemapping: d }, B ? /* @__PURE__ */ M.createElement(M.Fragment, null, w && /* @__PURE__ */ M.createElement(ys, { character: w, autoLookAt: !!v }), w && /* @__PURE__ */ M.createElement(M.Fragment, null, /* @__PURE__ */ M.createElement(mt, { preset: y }), /* @__PURE__ */ M.createElement("primitive", { object: w, castShadow: !0, receiveShadow: !0 }))) : /* @__PURE__ */ M.createElement(M.Fragment, null));
|
|
997
997
|
}, Ss = {
|
|
998
998
|
emotions: [],
|
|
999
999
|
currentTopEmotion: Se.Neutral,
|
package/dist/stats.html
CHANGED
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"D:/a/1/s/packages/reactjs","children":[{"name":"node_modules/zustand/esm","children":[{"uid":"
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"D:/a/1/s/packages/reactjs","children":[{"name":"node_modules/zustand/esm","children":[{"uid":"adeb88b4-1","name":"vanilla.mjs"},{"uid":"adeb88b4-3","name":"react.mjs"}]},{"name":"src","children":[{"name":"contexts","children":[{"uid":"adeb88b4-5","name":"characterStore.ts"},{"uid":"adeb88b4-7","name":"cameraStore.ts"},{"uid":"adeb88b4-9","name":"headStore.ts"},{"uid":"adeb88b4-11","name":"animationStore.ts"},{"uid":"adeb88b4-17","name":"speechStore.ts"},{"uid":"adeb88b4-33","name":"emotionStore.ts"}]},{"name":"models","children":[{"uid":"adeb88b4-13","name":"enums.ts"},{"uid":"adeb88b4-15","name":"constants.ts"}]},{"name":"utils/getCameraPositionVector.ts","uid":"adeb88b4-19"},{"name":"components","children":[{"name":"PostProcessing/PMJTAANode.js","uid":"adeb88b4-21"},{"uid":"adeb88b4-23","name":"SpeechManager.tsx"},{"uid":"adeb88b4-25","name":"HorizontalLine.tsx"},{"uid":"adeb88b4-27","name":"Scene.tsx"},{"name":"Controllers/CharacterController.ts","uid":"adeb88b4-29"},{"uid":"adeb88b4-31","name":"Character.tsx"}]},{"uid":"adeb88b4-35","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"adeb88b4-1":{"renderedLength":975,"gzipLength":394,"brotliLength":353,"metaUid":"adeb88b4-0"},"adeb88b4-3":{"renderedLength":593,"gzipLength":285,"brotliLength":235,"metaUid":"adeb88b4-2"},"adeb88b4-5":{"renderedLength":2066,"gzipLength":439,"brotliLength":380,"metaUid":"adeb88b4-4"},"adeb88b4-7":{"renderedLength":1028,"gzipLength":293,"brotliLength":249,"metaUid":"adeb88b4-6"},"adeb88b4-9":{"renderedLength":1484,"gzipLength":395,"brotliLength":345,"metaUid":"adeb88b4-8"},"adeb88b4-11":{"renderedLength":854,"gzipLength":308,"brotliLength":274,"metaUid":"adeb88b4-10"},"adeb88b4-13":{"renderedLength":2645,"gzipLength":700,"brotliLength":620,"metaUid":"adeb88b4-12"},"adeb88b4-15":{"renderedLength":2774,"gzipLength":852,"brotliLength":740,"metaUid":"adeb88b4-14"},"adeb88b4-17":{"renderedLength":2675,"gzipLength":668,"brotliLength":633,"metaUid":"adeb88b4-16"},"adeb88b4-19":{"renderedLength":2356,"gzipLength":571,"brotliLength":491,"metaUid":"adeb88b4-18"},"adeb88b4-21":{"renderedLength":25773,"gzipLength":6596,"brotliLength":5811,"metaUid":"adeb88b4-20"},"adeb88b4-23":{"renderedLength":5139,"gzipLength":1153,"brotliLength":1063,"metaUid":"adeb88b4-22"},"adeb88b4-25":{"renderedLength":383,"gzipLength":251,"brotliLength":209,"metaUid":"adeb88b4-24"},"adeb88b4-27":{"renderedLength":8713,"gzipLength":2368,"brotliLength":2099,"metaUid":"adeb88b4-26"},"adeb88b4-29":{"renderedLength":1366,"gzipLength":442,"brotliLength":408,"metaUid":"adeb88b4-28"},"adeb88b4-31":{"renderedLength":7048,"gzipLength":1843,"brotliLength":1639,"metaUid":"adeb88b4-30"},"adeb88b4-33":{"renderedLength":949,"gzipLength":361,"brotliLength":320,"metaUid":"adeb88b4-32"},"adeb88b4-35":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"adeb88b4-34"}},"nodeMetas":{"adeb88b4-0":{"id":"D:/a/1/s/packages/reactjs/node_modules/zustand/esm/vanilla.mjs","moduleParts":{"index.js":"adeb88b4-1"},"imported":[],"importedBy":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-2"}]},"adeb88b4-2":{"id":"D:/a/1/s/packages/reactjs/node_modules/zustand/esm/react.mjs","moduleParts":{"index.js":"adeb88b4-3"},"imported":[{"uid":"adeb88b4-38"},{"uid":"adeb88b4-0"}],"importedBy":[{"uid":"adeb88b4-40"}]},"adeb88b4-4":{"id":"D:/a/1/s/packages/reactjs/src/contexts/characterStore.ts","moduleParts":{"index.js":"adeb88b4-5"},"imported":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-36"}],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-16"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-32"},{"uid":"adeb88b4-10"},{"uid":"adeb88b4-28"},{"uid":"adeb88b4-22"}]},"adeb88b4-6":{"id":"D:/a/1/s/packages/reactjs/src/contexts/cameraStore.ts","moduleParts":{"index.js":"adeb88b4-7"},"imported":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-37"}],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-26"},{"uid":"adeb88b4-28"}]},"adeb88b4-8":{"id":"D:/a/1/s/packages/reactjs/src/contexts/headStore.ts","moduleParts":{"index.js":"adeb88b4-9"},"imported":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-6"}],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-26"},{"uid":"adeb88b4-28"}]},"adeb88b4-10":{"id":"D:/a/1/s/packages/reactjs/src/contexts/animationStore.ts","moduleParts":{"index.js":"adeb88b4-11"},"imported":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-4"}],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"}]},"adeb88b4-12":{"id":"D:/a/1/s/packages/reactjs/src/models/enums.ts","moduleParts":{"index.js":"adeb88b4-13"},"imported":[],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-32"},{"uid":"adeb88b4-14"},{"uid":"adeb88b4-18"}]},"adeb88b4-14":{"id":"D:/a/1/s/packages/reactjs/src/models/constants.ts","moduleParts":{"index.js":"adeb88b4-15"},"imported":[{"uid":"adeb88b4-12"}],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-16"},{"uid":"adeb88b4-22"}]},"adeb88b4-16":{"id":"D:/a/1/s/packages/reactjs/src/contexts/speechStore.ts","moduleParts":{"index.js":"adeb88b4-17"},"imported":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-14"}],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-22"}]},"adeb88b4-18":{"id":"D:/a/1/s/packages/reactjs/src/utils/getCameraPositionVector.ts","moduleParts":{"index.js":"adeb88b4-19"},"imported":[{"uid":"adeb88b4-37"},{"uid":"adeb88b4-12"}],"importedBy":[{"uid":"adeb88b4-30"}]},"adeb88b4-20":{"id":"D:/a/1/s/packages/reactjs/src/components/PostProcessing/PMJTAANode.js","moduleParts":{"index.js":"adeb88b4-21"},"imported":[{"uid":"adeb88b4-37"},{"uid":"adeb88b4-41"}],"importedBy":[{"uid":"adeb88b4-26"}]},"adeb88b4-22":{"id":"D:/a/1/s/packages/reactjs/src/components/SpeechManager.tsx","moduleParts":{"index.js":"adeb88b4-23"},"imported":[{"uid":"adeb88b4-38"},{"uid":"adeb88b4-16"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-44"},{"uid":"adeb88b4-14"},{"uid":"adeb88b4-36"}],"importedBy":[{"uid":"adeb88b4-26"}]},"adeb88b4-24":{"id":"D:/a/1/s/packages/reactjs/src/components/HorizontalLine.tsx","moduleParts":{"index.js":"adeb88b4-25"},"imported":[{"uid":"adeb88b4-38"},{"uid":"adeb88b4-37"}],"importedBy":[{"uid":"adeb88b4-26"}]},"adeb88b4-26":{"id":"D:/a/1/s/packages/reactjs/src/components/Scene.tsx","moduleParts":{"index.js":"adeb88b4-27"},"imported":[{"uid":"adeb88b4-38"},{"uid":"adeb88b4-37"},{"uid":"adeb88b4-41"},{"uid":"adeb88b4-20"},{"uid":"adeb88b4-42"},{"uid":"adeb88b4-39"},{"uid":"adeb88b4-43"},{"uid":"adeb88b4-6"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-22"},{"uid":"adeb88b4-24"}],"importedBy":[{"uid":"adeb88b4-30"}]},"adeb88b4-28":{"id":"D:/a/1/s/packages/reactjs/src/components/Controllers/CharacterController.ts","moduleParts":{"index.js":"adeb88b4-29"},"imported":[{"uid":"adeb88b4-38"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-36"},{"uid":"adeb88b4-43"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-6"}],"importedBy":[{"uid":"adeb88b4-30"}]},"adeb88b4-30":{"id":"D:/a/1/s/packages/reactjs/src/components/Character.tsx","moduleParts":{"index.js":"adeb88b4-31"},"imported":[{"uid":"adeb88b4-38"},{"uid":"adeb88b4-37"},{"uid":"adeb88b4-36"},{"uid":"adeb88b4-39"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-10"},{"uid":"adeb88b4-6"},{"uid":"adeb88b4-16"},{"uid":"adeb88b4-12"},{"uid":"adeb88b4-18"},{"uid":"adeb88b4-26"},{"uid":"adeb88b4-28"}],"importedBy":[{"uid":"adeb88b4-34"}]},"adeb88b4-32":{"id":"D:/a/1/s/packages/reactjs/src/contexts/emotionStore.ts","moduleParts":{"index.js":"adeb88b4-33"},"imported":[{"uid":"adeb88b4-40"},{"uid":"adeb88b4-12"},{"uid":"adeb88b4-4"}],"importedBy":[{"uid":"adeb88b4-34"}]},"adeb88b4-34":{"id":"D:/a/1/s/packages/reactjs/src/index.ts","moduleParts":{"index.js":"adeb88b4-35"},"imported":[{"uid":"adeb88b4-30"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-16"},{"uid":"adeb88b4-6"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-32"},{"uid":"adeb88b4-10"},{"uid":"adeb88b4-36"},{"uid":"adeb88b4-12"},{"uid":"adeb88b4-14"},{"uid":"adeb88b4-37"}],"importedBy":[],"isEntry":true},"adeb88b4-36":{"id":"@davi-ai/bodyengine-three","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-4"},{"uid":"adeb88b4-28"},{"uid":"adeb88b4-22"}],"isExternal":true},"adeb88b4-37":{"id":"three/webgpu","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-34"},{"uid":"adeb88b4-30"},{"uid":"adeb88b4-6"},{"uid":"adeb88b4-18"},{"uid":"adeb88b4-26"},{"uid":"adeb88b4-20"},{"uid":"adeb88b4-24"}],"isExternal":true},"adeb88b4-38":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-30"},{"uid":"adeb88b4-26"},{"uid":"adeb88b4-28"},{"uid":"adeb88b4-22"},{"uid":"adeb88b4-24"},{"uid":"adeb88b4-2"}],"isExternal":true},"adeb88b4-39":{"id":"@react-three/drei","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-30"},{"uid":"adeb88b4-26"}],"isExternal":true},"adeb88b4-40":{"id":"D:/a/1/s/packages/reactjs/node_modules/zustand/esm/index.mjs","moduleParts":{},"imported":[{"uid":"adeb88b4-0"},{"uid":"adeb88b4-2"}],"importedBy":[{"uid":"adeb88b4-4"},{"uid":"adeb88b4-16"},{"uid":"adeb88b4-6"},{"uid":"adeb88b4-8"},{"uid":"adeb88b4-32"},{"uid":"adeb88b4-10"}]},"adeb88b4-41":{"id":"three/tsl","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-26"},{"uid":"adeb88b4-20"}],"isExternal":true},"adeb88b4-42":{"id":"three/addons/tsl/display/SSGINode.js","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-26"}],"isExternal":true},"adeb88b4-43":{"id":"@react-three/fiber","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-26"},{"uid":"adeb88b4-28"}],"isExternal":true},"adeb88b4-44":{"id":"@davi-ai/web-speech-cognitive-services-davi","moduleParts":{},"imported":[],"importedBy":[{"uid":"adeb88b4-22"}],"isExternal":true}},"env":{"rollup":"4.61.1"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|