@sage-rsc/talking-head-react 1.0.62 → 1.0.64
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.cjs +2 -2
- package/dist/index.js +468 -444
- package/package.json +1 -1
- package/src/components/TalkingHeadAvatar.jsx +74 -26
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsxs as Ee, jsx as ue } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Ie, useRef as G, useState as
|
|
2
|
+
import { forwardRef as Ie, useRef as G, useState as me, useEffect as pe, useCallback as E, useImperativeHandle as Le, useLayoutEffect as We } from "react";
|
|
3
3
|
import * as f from "three";
|
|
4
|
-
import { OrbitControls as
|
|
5
|
-
import { GLTFLoader as
|
|
6
|
-
import { DRACOLoader as
|
|
4
|
+
import { OrbitControls as Ve } from "three/addons/controls/OrbitControls.js";
|
|
5
|
+
import { GLTFLoader as Ge } from "three/addons/loaders/GLTFLoader.js";
|
|
6
|
+
import { DRACOLoader as Ze } from "three/addons/loaders/DRACOLoader.js";
|
|
7
7
|
import { FBXLoader as ze } from "three/addons/loaders/FBXLoader.js";
|
|
8
|
-
import { RoomEnvironment as
|
|
9
|
-
import
|
|
10
|
-
let m,
|
|
11
|
-
const
|
|
8
|
+
import { RoomEnvironment as Xe } from "three/addons/environments/RoomEnvironment.js";
|
|
9
|
+
import Ye from "three/addons/libs/stats.module.js";
|
|
10
|
+
let m, K, $;
|
|
11
|
+
const A = [0, 0, 0, 0], k = new f.Vector3(), be = new f.Vector3(), Q = new f.Vector3(), ve = new f.Vector3();
|
|
12
12
|
new f.Plane();
|
|
13
13
|
new f.Ray();
|
|
14
14
|
new f.Euler();
|
|
15
|
-
const
|
|
15
|
+
const q = new f.Quaternion(), Ce = new f.Quaternion(), se = new f.Matrix4(), ae = new f.Matrix4();
|
|
16
16
|
new f.Vector3();
|
|
17
|
-
const
|
|
18
|
-
class
|
|
17
|
+
const Re = new f.Vector3(0, 0, 1), je = new f.Vector3(1, 0, 0), Qe = new f.Vector3(0, 1, 0), qe = new f.Vector3(0, 0, 1);
|
|
18
|
+
class _e {
|
|
19
19
|
constructor(t = null) {
|
|
20
20
|
this.opt = Object.assign({
|
|
21
21
|
warmupMs: 2e3,
|
|
@@ -338,7 +338,7 @@ class qe {
|
|
|
338
338
|
ea: [0, 0, 0, 0]
|
|
339
339
|
// External acceleration [m/s^2]
|
|
340
340
|
};
|
|
341
|
-
h.boneParent.matrixWorld.decompose(k,
|
|
341
|
+
h.boneParent.matrixWorld.decompose(k, q, Q), k.copy(Re).applyQuaternion(q).setY(0).normalize(), q.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), h.qWorldInverseYaw = q.clone().normalize(), this.data.push(h), this.dict[u] = h;
|
|
342
342
|
try {
|
|
343
343
|
this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
|
|
344
344
|
} catch (r) {
|
|
@@ -356,22 +356,22 @@ class qe {
|
|
|
356
356
|
for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, i = this.objectsUpdate.length; e < i; e++)
|
|
357
357
|
o = this.objectsUpdate[e], o.updateMatrix(), o.parent === null ? o.matrixWorld.copy(o.matrix) : o.matrixWorld.multiplyMatrices(o.parent.matrixWorld, o.matrix), o.matrixWorldNeedsUpdate = !1;
|
|
358
358
|
for (e = 0, i = this.data.length; e < i; e++) {
|
|
359
|
-
if (o = this.data[e], k.copy(o.vWorld),
|
|
359
|
+
if (o = this.data[e], k.copy(o.vWorld), se.copy(o.boneParent.matrixWorld), ae.copy(se).invert(), o.vWorld.setFromMatrixPosition(se), k.applyMatrix4(ae), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
|
|
360
360
|
for (n = 0, s = o.children.length; n < s; n++)
|
|
361
|
-
m = o.children[n],
|
|
362
|
-
if (m = this.opt.sensitivityFactor,
|
|
363
|
-
o.vBasis.x +
|
|
364
|
-
o.vBasis.y +
|
|
365
|
-
o.vBasis.z +
|
|
366
|
-
), k.applyMatrix4(
|
|
361
|
+
m = o.children[n], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
|
|
362
|
+
if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, k.set(
|
|
363
|
+
o.vBasis.x + A[0],
|
|
364
|
+
o.vBasis.y + A[1],
|
|
365
|
+
o.vBasis.z + A[2]
|
|
366
|
+
), k.applyMatrix4(se), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(ae), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
|
|
367
367
|
o.bone.position.set(
|
|
368
|
-
o.vBasis.x +
|
|
369
|
-
o.vBasis.y +
|
|
370
|
-
o.vBasis.z -
|
|
368
|
+
o.vBasis.x + A[0],
|
|
369
|
+
o.vBasis.y + A[1],
|
|
370
|
+
o.vBasis.z - A[2]
|
|
371
371
|
);
|
|
372
|
-
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k,
|
|
372
|
+
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, q, Q), k.copy(Re).applyQuaternion(q).setY(0).normalize(), q.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), o.boneParent.quaternion.multiply(q.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), q.setFromAxisAngle(qe, -m), o.boneParent.quaternion.multiply(q)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), q.setFromAxisAngle(je, -m), o.boneParent.quaternion.multiply(q)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), q.setFromAxisAngle(Qe, -m), o.boneParent.quaternion.multiply(q)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
|
|
373
373
|
for (n = 0, s = o.excludes.length; n < s; n++)
|
|
374
|
-
m = o.excludes[n],
|
|
374
|
+
m = o.excludes[n], Q.set(0, 0, 0), m.deltaLocal && (Q.x += m.deltaLocal[0], Q.y += m.deltaLocal[1], Q.z += m.deltaLocal[2]), Q.applyMatrix4(m.bone.matrixWorld), ae.copy(o.boneParent.matrixWorld).invert(), Q.applyMatrix4(ae), k.copy(o.bone.position), !(k.distanceToSquared(Q) >= m.radiusSq) && ($ = k.length(), K = Q.length(), !(K > m.radius + $) && (K < Math.abs(m.radius - $) || (K = (K * K + $ * $ - m.radiusSq) / (2 * K), Q.normalize(), ve.copy(Q).multiplyScalar(K), K = Math.sqrt($ * $ - K * K), k.subVectors(k, ve).projectOnPlane(Q).normalize().multiplyScalar(K), be.subVectors(o.vBasis, ve).projectOnPlane(Q).normalize(), $ = be.dot(k), $ < 0 && ($ = Math.sqrt(K * K - $ * $), be.multiplyScalar($), k.add(be)), k.add(ve).normalize(), Q.copy(o.bone.position).normalize(), q.setFromUnitVectors(Q, k), o.boneParent.quaternion.premultiply(q), o.boneParent.updateWorldMatrix(!1, !0))));
|
|
375
375
|
}
|
|
376
376
|
this.helpers.isActive && this.updateHelpers();
|
|
377
377
|
}
|
|
@@ -442,17 +442,17 @@ class qe {
|
|
|
442
442
|
*/
|
|
443
443
|
updateHelpers() {
|
|
444
444
|
if (m = this.helpers.points, m.bones.length) {
|
|
445
|
-
|
|
445
|
+
ae.copy(this.armature.matrixWorld).invert();
|
|
446
446
|
const t = m.object.geometry.getAttribute("position");
|
|
447
447
|
for (let e = 0, n = m.bones.length; e < n; e++)
|
|
448
|
-
|
|
448
|
+
se.multiplyMatrices(ae, m.bones[e].matrixWorld), k.setFromMatrixPosition(se), t.setXYZ(e, k.x, k.y, k.z);
|
|
449
449
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
450
450
|
}
|
|
451
451
|
if (m = this.helpers.lines, m.bones.length) {
|
|
452
|
-
|
|
452
|
+
ae.copy(this.armature.matrixWorld).invert();
|
|
453
453
|
const t = m.object.geometry.getAttribute("position");
|
|
454
454
|
for (let e = 0, n = 0, i = m.bones.length; e < i; e++, n += 2)
|
|
455
|
-
|
|
455
|
+
se.multiplyMatrices(ae, m.bones[e].matrixWorld), k.setFromMatrixPosition(se), t.setXYZ(n, k.x, k.y, k.z), se.multiplyMatrices(ae, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(se), t.setXYZ(n + 1, k.x, k.y, k.z);
|
|
456
456
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
457
457
|
}
|
|
458
458
|
}
|
|
@@ -489,7 +489,7 @@ class qe {
|
|
|
489
489
|
this.stop(), this.scene = null, this.armature = null, this.config = [], this.data = [], this.dict = {}, this.objectsUpdate = [], this.timerMs = 0;
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
class
|
|
492
|
+
class Ke {
|
|
493
493
|
constructor(t) {
|
|
494
494
|
this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
|
|
495
495
|
}
|
|
@@ -814,7 +814,7 @@ class _e {
|
|
|
814
814
|
return i * s;
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
-
class
|
|
817
|
+
class Je {
|
|
818
818
|
/**
|
|
819
819
|
* @constructor
|
|
820
820
|
*/
|
|
@@ -1396,11 +1396,11 @@ class Ke {
|
|
|
1396
1396
|
return e;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
const
|
|
1399
|
+
const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1400
1400
|
__proto__: null,
|
|
1401
|
-
LipsyncEn:
|
|
1401
|
+
LipsyncEn: Je
|
|
1402
1402
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1403
|
-
class
|
|
1403
|
+
class et {
|
|
1404
1404
|
/**
|
|
1405
1405
|
* @constructor
|
|
1406
1406
|
*/
|
|
@@ -1754,11 +1754,11 @@ class $e {
|
|
|
1754
1754
|
return e;
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
|
-
const
|
|
1757
|
+
const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1758
1758
|
__proto__: null,
|
|
1759
|
-
LipsyncDe:
|
|
1759
|
+
LipsyncDe: et
|
|
1760
1760
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1761
|
-
class
|
|
1761
|
+
class nt {
|
|
1762
1762
|
/**
|
|
1763
1763
|
* @constructor
|
|
1764
1764
|
*/
|
|
@@ -2289,11 +2289,11 @@ class tt {
|
|
|
2289
2289
|
return e;
|
|
2290
2290
|
}
|
|
2291
2291
|
}
|
|
2292
|
-
const
|
|
2292
|
+
const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2293
2293
|
__proto__: null,
|
|
2294
|
-
LipsyncFr:
|
|
2294
|
+
LipsyncFr: nt
|
|
2295
2295
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2296
|
-
class
|
|
2296
|
+
class ot {
|
|
2297
2297
|
/**
|
|
2298
2298
|
* @constructor
|
|
2299
2299
|
*/
|
|
@@ -2436,11 +2436,11 @@ class it {
|
|
|
2436
2436
|
return e;
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
const
|
|
2439
|
+
const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2440
2440
|
__proto__: null,
|
|
2441
|
-
LipsyncFi:
|
|
2441
|
+
LipsyncFi: ot
|
|
2442
2442
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2443
|
-
class
|
|
2443
|
+
class at {
|
|
2444
2444
|
/**
|
|
2445
2445
|
* @constructor
|
|
2446
2446
|
*/
|
|
@@ -2620,21 +2620,21 @@ class st {
|
|
|
2620
2620
|
return e;
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
2623
|
-
const
|
|
2623
|
+
const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2624
2624
|
__proto__: null,
|
|
2625
|
-
LipsyncLt:
|
|
2626
|
-
}, Symbol.toStringTag, { value: "Module" })), rt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRT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AgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBt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), He = {
|
|
2627
|
-
en:
|
|
2628
|
-
de:
|
|
2629
|
-
fr:
|
|
2630
|
-
fi:
|
|
2631
|
-
lt:
|
|
2632
|
-
}, U = new f.Quaternion(),
|
|
2625
|
+
LipsyncLt: at
|
|
2626
|
+
}, Symbol.toStringTag, { value: "Module" })), lt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25zPy5wcm9jZXNzb3JPcHRpb25zPy5tZXRyaWNzIHx8IHt9OwogICAgdGhpcy5fbWV0cmljc0VuYWJsZWQgP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GlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAg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3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), He = {
|
|
2627
|
+
en: $e,
|
|
2628
|
+
de: tt,
|
|
2629
|
+
fr: it,
|
|
2630
|
+
fi: st,
|
|
2631
|
+
lt: rt
|
|
2632
|
+
}, U = new f.Quaternion(), F = new f.Euler(), le = new f.Vector3(), he = new f.Vector3(), Te = new f.Box3();
|
|
2633
2633
|
new f.Matrix4();
|
|
2634
2634
|
new f.Matrix4();
|
|
2635
2635
|
new f.Vector3();
|
|
2636
2636
|
new f.Vector3(0, 0, 1);
|
|
2637
|
-
const
|
|
2637
|
+
const ht = new f.Vector3(1, 0, 0);
|
|
2638
2638
|
new f.Vector3(0, 1, 0);
|
|
2639
2639
|
new f.Vector3(0, 0, 1);
|
|
2640
2640
|
class Fe {
|
|
@@ -2763,7 +2763,7 @@ class Fe {
|
|
|
2763
2763
|
avatarOnlyCamera: null,
|
|
2764
2764
|
statsNode: null,
|
|
2765
2765
|
statsStyle: null
|
|
2766
|
-
}, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new
|
|
2766
|
+
}, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new Ye(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
|
|
2767
2767
|
side: {
|
|
2768
2768
|
standing: !0,
|
|
2769
2769
|
props: {
|
|
@@ -4062,7 +4062,7 @@ class Fe {
|
|
|
4062
4062
|
this.opt.lightSpotDispersion
|
|
4063
4063
|
), this.setLighting(this.opt);
|
|
4064
4064
|
const l = new f.PMREMGenerator(this.renderer);
|
|
4065
|
-
l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new
|
|
4065
|
+
l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new Xe()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ve(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
|
|
4066
4066
|
}
|
|
4067
4067
|
this.ikMesh = new f.SkinnedMesh();
|
|
4068
4068
|
const s = {
|
|
@@ -4080,14 +4080,14 @@ class Fe {
|
|
|
4080
4080
|
Object.entries(s).forEach((l, u) => {
|
|
4081
4081
|
const a = new f.Bone();
|
|
4082
4082
|
a.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(a) : this.ikMesh.add(a), o.push(a);
|
|
4083
|
-
}), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new
|
|
4083
|
+
}), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new _e(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
|
|
4084
4084
|
}
|
|
4085
4085
|
/**
|
|
4086
4086
|
* Helper that re/creates the audio context and the other nodes.
|
|
4087
4087
|
* @param {number} sampleRate
|
|
4088
4088
|
*/
|
|
4089
4089
|
initAudioGraph(t = null) {
|
|
4090
|
-
if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new
|
|
4090
|
+
if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new Ke(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
|
|
4091
4091
|
this.opt.mixerGainSpeech,
|
|
4092
4092
|
this.opt.mixerGainBackground
|
|
4093
4093
|
), this.workletLoaded = !1, this.streamWorkletNode) {
|
|
@@ -4228,9 +4228,9 @@ class Fe {
|
|
|
4228
4228
|
async showAvatar(t, e = null) {
|
|
4229
4229
|
if (!t || !t.hasOwnProperty("url"))
|
|
4230
4230
|
throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
|
|
4231
|
-
const n = new
|
|
4231
|
+
const n = new Ge();
|
|
4232
4232
|
if (this.dracoEnabled) {
|
|
4233
|
-
const a = new
|
|
4233
|
+
const a = new Ze();
|
|
4234
4234
|
a.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(a);
|
|
4235
4235
|
}
|
|
4236
4236
|
let i = await n.loadAsync(t.url, e);
|
|
@@ -4374,9 +4374,9 @@ class Fe {
|
|
|
4374
4374
|
updatePoseDelta() {
|
|
4375
4375
|
for (const [t, e] of Object.entries(this.poseDelta.props)) {
|
|
4376
4376
|
if (e.x === 0 && e.y === 0 && e.z === 0) continue;
|
|
4377
|
-
|
|
4377
|
+
F.set(e.x, e.y, e.z);
|
|
4378
4378
|
const n = this.poseAvatar.props[t];
|
|
4379
|
-
n.isQuaternion ? (U.setFromEuler(
|
|
4379
|
+
n.isQuaternion ? (U.setFromEuler(F), n.multiply(U)) : n.isVector3 && n.add(F);
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
4382
|
/**
|
|
@@ -5159,7 +5159,7 @@ class Fe {
|
|
|
5159
5159
|
}, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
|
|
5160
5160
|
break;
|
|
5161
5161
|
}
|
|
5162
|
-
if ((u || a) && (
|
|
5162
|
+
if ((u || a) && (F.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), F.x = Math.max(-0.9, Math.min(0.9, 2 * F.x - 0.5)), F.y = Math.max(-0.9, Math.min(0.9, -2.5 * F.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: F.x < 0 ? -F.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: F.x < 0 ? 0 : F.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: F.y < 0 ? -F.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: F.y < 0 ? 0 : F.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: F.y < 0 ? 0 : F.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: F.y < 0 ? -F.y : 0, needsUpdate: !0 }), a && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
|
|
5163
5163
|
name: "headmove",
|
|
5164
5164
|
dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
|
|
5165
5165
|
vs: {
|
|
@@ -5180,7 +5180,7 @@ class Fe {
|
|
|
5180
5180
|
eyeLookOutRight: [null, 0],
|
|
5181
5181
|
eyeContact: [0]
|
|
5182
5182
|
}
|
|
5183
|
-
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (U.setFromAxisAngle(
|
|
5183
|
+
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (U.setFromAxisAngle(ht, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(U)), Te.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(le), le.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(he), he.sub(this.armature.position), this.objectHips.position.y -= Te.min.y / 2, this.objectHips.position.x -= (le.x + he.x) / 4, this.objectHips.position.z -= (le.z + he.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
|
|
5184
5184
|
this.stats && this.stats.end();
|
|
5185
5185
|
else {
|
|
5186
5186
|
if (this.cameraClock !== null && this.cameraClock < 1e3) {
|
|
@@ -5251,10 +5251,10 @@ class Fe {
|
|
|
5251
5251
|
let h = "", r = "", c = 0, d = [], g = [];
|
|
5252
5252
|
const y = Array.from(this.segmenter.segment(t), (x) => x.segment);
|
|
5253
5253
|
for (let x = 0; x < y.length; x++) {
|
|
5254
|
-
const I = x === y.length - 1,
|
|
5254
|
+
const I = x === y.length - 1, D = y[x].match(l);
|
|
5255
5255
|
let p = y[x].match(s);
|
|
5256
5256
|
const H = y[x].match(u), z = y[x].match(o);
|
|
5257
|
-
if (p && !I && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]),
|
|
5257
|
+
if (p && !I && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), D && (!i || i.every((R) => x < R[0] || x > R[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
|
|
5258
5258
|
mark: c,
|
|
5259
5259
|
word: r
|
|
5260
5260
|
})), h.length && (g.push({
|
|
@@ -5265,16 +5265,16 @@ class Fe {
|
|
|
5265
5265
|
subtitles: [h]
|
|
5266
5266
|
}
|
|
5267
5267
|
}), h = ""), r.length)) {
|
|
5268
|
-
const
|
|
5269
|
-
if (
|
|
5270
|
-
const
|
|
5271
|
-
for (let
|
|
5268
|
+
const R = this.lipsyncWordsToVisemes(r, a);
|
|
5269
|
+
if (R && R.visemes && R.visemes.length) {
|
|
5270
|
+
const T = R.times[R.visemes.length - 1] + R.durations[R.visemes.length - 1];
|
|
5271
|
+
for (let P = 0; P < R.visemes.length; P++)
|
|
5272
5272
|
g.push({
|
|
5273
5273
|
mark: c,
|
|
5274
5274
|
template: { name: "viseme" },
|
|
5275
|
-
ts: [(
|
|
5275
|
+
ts: [(R.times[P] - 0.6) / T, (R.times[P] + 0.5) / T, (R.times[P] + R.durations[P] + 0.5) / T],
|
|
5276
5276
|
vs: {
|
|
5277
|
-
["viseme_" +
|
|
5277
|
+
["viseme_" + R.visemes[P]]: [null, R.visemes[P] === "PP" || R.visemes[P] === "FF" ? 0.9 : 0.6, 0]
|
|
5278
5278
|
}
|
|
5279
5279
|
});
|
|
5280
5280
|
}
|
|
@@ -5282,14 +5282,14 @@ class Fe {
|
|
|
5282
5282
|
}
|
|
5283
5283
|
if (p || I) {
|
|
5284
5284
|
if (d.length || I && g.length) {
|
|
5285
|
-
const
|
|
5285
|
+
const R = {
|
|
5286
5286
|
anim: g
|
|
5287
5287
|
};
|
|
5288
|
-
n && (
|
|
5288
|
+
n && (R.onSubtitles = n), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], r = "", c = 0, g = [];
|
|
5289
5289
|
}
|
|
5290
5290
|
if (H) {
|
|
5291
|
-
let
|
|
5292
|
-
|
|
5291
|
+
let R = this.animEmojis[y[x]];
|
|
5292
|
+
R && R.link && (R = this.animEmojis[R.link]), R && this.speechQueue.push({ emoji: R });
|
|
5293
5293
|
}
|
|
5294
5294
|
this.speechQueue.push({ break: 100 });
|
|
5295
5295
|
}
|
|
@@ -5385,10 +5385,10 @@ class Fe {
|
|
|
5385
5385
|
let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
|
|
5386
5386
|
if (h = Math.min(h, c.visemes.length * 200), d > 0)
|
|
5387
5387
|
for (let x = 0; x < c.visemes.length; x++) {
|
|
5388
|
-
const I = a + c.times[x] / d * h,
|
|
5388
|
+
const I = a + c.times[x] / d * h, D = c.durations[x] / d * h;
|
|
5389
5389
|
o.push({
|
|
5390
5390
|
template: { name: "viseme" },
|
|
5391
|
-
ts: [I - Math.min(60, 2 *
|
|
5391
|
+
ts: [I - Math.min(60, 2 * D / 3), I + Math.min(25, D / 2), I + D + Math.min(60, D / 2)],
|
|
5392
5392
|
vs: {
|
|
5393
5393
|
["viseme_" + c.visemes[x]]: [null, c.visemes[x] === "PP" || c.visemes[x] === "FF" ? 0.9 : y, 0]
|
|
5394
5394
|
}
|
|
@@ -5486,18 +5486,18 @@ class Fe {
|
|
|
5486
5486
|
if (x && x.visemes && x.visemes.length > 0) {
|
|
5487
5487
|
const p = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
|
|
5488
5488
|
for (let H = 0; H < x.visemes.length; H++) {
|
|
5489
|
-
const z = x.visemes[H],
|
|
5489
|
+
const z = x.visemes[H], R = x.times[H] / p, T = x.durations[H] / p, P = R * c, ee = T * c;
|
|
5490
5490
|
I.push({
|
|
5491
5491
|
template: { name: "viseme" },
|
|
5492
|
-
ts: [
|
|
5492
|
+
ts: [P - Math.min(60, 2 * ee / 3), P + Math.min(25, ee / 2), P + ee + Math.min(60, ee / 2)],
|
|
5493
5493
|
vs: {
|
|
5494
5494
|
["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
|
|
5495
5495
|
}
|
|
5496
5496
|
});
|
|
5497
5497
|
}
|
|
5498
5498
|
}
|
|
5499
|
-
const
|
|
5500
|
-
this.audioPlaylist.push({ anim:
|
|
5499
|
+
const D = [...t.anim, ...I];
|
|
5500
|
+
this.audioPlaylist.push({ anim: D, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
|
|
5501
5501
|
e();
|
|
5502
5502
|
}, s.onerror = (p) => {
|
|
5503
5503
|
console.error("Speech synthesis error:", p.error), n(p.error);
|
|
@@ -5895,7 +5895,7 @@ class Fe {
|
|
|
5895
5895
|
}
|
|
5896
5896
|
if (!this.workletLoaded)
|
|
5897
5897
|
try {
|
|
5898
|
-
const l = this.audioCtx.audioWorklet.addModule(
|
|
5898
|
+
const l = this.audioCtx.audioWorklet.addModule(lt.href), u = new Promise(
|
|
5899
5899
|
(a, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
|
|
5900
5900
|
);
|
|
5901
5901
|
await Promise.race([l, u]), this.workletLoaded = !0;
|
|
@@ -6133,7 +6133,7 @@ class Fe {
|
|
|
6133
6133
|
*/
|
|
6134
6134
|
lookAtCamera(t) {
|
|
6135
6135
|
let e;
|
|
6136
|
-
if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0),
|
|
6136
|
+
if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), le.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), he.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(le, he).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
|
|
6137
6137
|
if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
|
|
6138
6138
|
if (this.avatar.avatarIgnoreCamera) {
|
|
6139
6139
|
this.lookAhead(t);
|
|
@@ -6146,12 +6146,12 @@ class Fe {
|
|
|
6146
6146
|
this.lookAt(null, null, t);
|
|
6147
6147
|
return;
|
|
6148
6148
|
}
|
|
6149
|
-
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0),
|
|
6150
|
-
const n = new f.Vector3().subVectors(e,
|
|
6151
|
-
|
|
6152
|
-
const l = new f.Quaternion().setFromEuler(
|
|
6153
|
-
|
|
6154
|
-
let a =
|
|
6149
|
+
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), le.setFromMatrixPosition(this.objectLeftEye.matrixWorld), he.setFromMatrixPosition(this.objectRightEye.matrixWorld), le.add(he).divideScalar(2), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]);
|
|
6150
|
+
const n = new f.Vector3().subVectors(e, le).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
|
|
6151
|
+
F.set(s, i, 0, "YXZ");
|
|
6152
|
+
const l = new f.Quaternion().setFromEuler(F), u = new f.Quaternion().copy(l).multiply(U.clone().invert());
|
|
6153
|
+
F.setFromQuaternion(u, "YXZ");
|
|
6154
|
+
let a = F.x / (40 / 24) + 0.2, h = F.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, a)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
|
|
6155
6155
|
if (t) {
|
|
6156
6156
|
let y = this.animQueue.findIndex((I) => I.template.name === "lookat");
|
|
6157
6157
|
y !== -1 && this.animQueue.splice(y, 1);
|
|
@@ -6186,20 +6186,20 @@ class Fe {
|
|
|
6186
6186
|
const s = new f.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new f.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), l = new f.Vector3().addVectors(s, o).divideScalar(2);
|
|
6187
6187
|
l.project(this.camera);
|
|
6188
6188
|
let u = (l.x + 1) / 2 * i.width + i.left, a = -(l.y - 1) / 2 * i.height + i.top;
|
|
6189
|
-
t === null && (t = u), e === null && (e = a), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]),
|
|
6190
|
-
let h =
|
|
6189
|
+
t === null && (t = u), e === null && (e = a), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]), F.setFromQuaternion(U);
|
|
6190
|
+
let h = F.x / (40 / 24), r = F.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - r + d;
|
|
6191
6191
|
x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
|
|
6192
|
-
let
|
|
6192
|
+
let D = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
|
|
6193
6193
|
if (n) {
|
|
6194
|
-
let H = this.animQueue.findIndex((
|
|
6194
|
+
let H = this.animQueue.findIndex((R) => R.template.name === "lookat");
|
|
6195
6195
|
H !== -1 && this.animQueue.splice(H, 1);
|
|
6196
6196
|
const z = {
|
|
6197
6197
|
name: "lookat",
|
|
6198
6198
|
dt: [750, n],
|
|
6199
6199
|
vs: {
|
|
6200
|
-
bodyRotateX: [x +
|
|
6200
|
+
bodyRotateX: [x + D],
|
|
6201
6201
|
bodyRotateY: [I + p],
|
|
6202
|
-
eyesRotateX: [-3 *
|
|
6202
|
+
eyesRotateX: [-3 * D + 0.1],
|
|
6203
6203
|
eyesRotateY: [-5 * p],
|
|
6204
6204
|
browInnerUp: [[0, 0.7]],
|
|
6205
6205
|
mouthLeft: [[0, 0.7]],
|
|
@@ -6577,12 +6577,12 @@ class Fe {
|
|
|
6577
6577
|
const x = t.iterations || 10;
|
|
6578
6578
|
if (e)
|
|
6579
6579
|
for (let I = 0; I < x; I++) {
|
|
6580
|
-
let
|
|
6580
|
+
let D = !1;
|
|
6581
6581
|
for (let p = 0, H = y.length; p < H; p++) {
|
|
6582
6582
|
const z = y[p].bone;
|
|
6583
6583
|
z.matrixWorld.decompose(u, a, h), a.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(a), l.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
|
|
6584
|
-
let
|
|
6585
|
-
|
|
6584
|
+
let R = s.dot(l);
|
|
6585
|
+
R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), U.setFromAxisAngle(r, R), z.quaternion.multiply(U), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
|
|
6586
6586
|
y[p].minx !== void 0 ? y[p].minx : -1 / 0,
|
|
6587
6587
|
y[p].miny !== void 0 ? y[p].miny : -1 / 0,
|
|
6588
6588
|
y[p].minz !== void 0 ? y[p].minz : -1 / 0
|
|
@@ -6590,9 +6590,9 @@ class Fe {
|
|
|
6590
6590
|
y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
|
|
6591
6591
|
y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
|
|
6592
6592
|
y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
|
|
6593
|
-
))), z.updateMatrixWorld(!0),
|
|
6593
|
+
))), z.updateMatrixWorld(!0), D = !0);
|
|
6594
6594
|
}
|
|
6595
|
-
if (!
|
|
6595
|
+
if (!D) break;
|
|
6596
6596
|
}
|
|
6597
6597
|
i && y.forEach((I) => {
|
|
6598
6598
|
this.poseTarget.props[I.link + ".quaternion"].copy(I.bone.quaternion), this.poseTarget.props[I.link + ".quaternion"].t = this.animClock, this.poseTarget.props[I.link + ".quaternion"].d = i;
|
|
@@ -6605,7 +6605,7 @@ class Fe {
|
|
|
6605
6605
|
this.isRunning = !1, this.stop(), this.stopSpeaking(), this.streamStop(), this.isAvatarOnly ? this.armature && (this.armature.parent && this.armature.parent.remove(this.armature), this.clearThree(this.armature)) : (this.clearThree(this.scene), this.resizeobserver.disconnect(), this.renderer && (this.renderer.dispose(), this.renderer.domElement && this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement), this.renderer = null)), this.clearThree(this.ikMesh), this.dynamicbones.dispose();
|
|
6606
6606
|
}
|
|
6607
6607
|
}
|
|
6608
|
-
const
|
|
6608
|
+
const ye = {
|
|
6609
6609
|
apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
|
|
6610
6610
|
// Replace with your actual API key (should start with sk_)
|
|
6611
6611
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
@@ -6648,23 +6648,23 @@ const ge = {
|
|
|
6648
6648
|
function Ae() {
|
|
6649
6649
|
return {
|
|
6650
6650
|
service: "elevenlabs",
|
|
6651
|
-
endpoint:
|
|
6652
|
-
apiKey:
|
|
6653
|
-
defaultVoice:
|
|
6654
|
-
voices:
|
|
6651
|
+
endpoint: ye.endpoint,
|
|
6652
|
+
apiKey: ye.apiKey,
|
|
6653
|
+
defaultVoice: ye.defaultVoice,
|
|
6654
|
+
voices: ye.voices
|
|
6655
6655
|
};
|
|
6656
6656
|
}
|
|
6657
|
-
function
|
|
6658
|
-
const
|
|
6659
|
-
return Object.entries(
|
|
6657
|
+
function Rt() {
|
|
6658
|
+
const O = Ae(), t = [];
|
|
6659
|
+
return Object.entries(O.voices).forEach(([e, n]) => {
|
|
6660
6660
|
t.push({
|
|
6661
6661
|
value: n,
|
|
6662
|
-
label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${
|
|
6662
|
+
label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${O.service})`
|
|
6663
6663
|
});
|
|
6664
6664
|
}), t;
|
|
6665
6665
|
}
|
|
6666
6666
|
const Pe = Ie(({
|
|
6667
|
-
avatarUrl:
|
|
6667
|
+
avatarUrl: O = "/avatars/brunette.glb",
|
|
6668
6668
|
avatarBody: t = "F",
|
|
6669
6669
|
mood: e = "neutral",
|
|
6670
6670
|
ttsLang: n = "en",
|
|
@@ -6685,124 +6685,124 @@ const Pe = Ie(({
|
|
|
6685
6685
|
style: y = {},
|
|
6686
6686
|
animations: x = {}
|
|
6687
6687
|
}, I) => {
|
|
6688
|
-
const
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
}, [
|
|
6688
|
+
const D = G(null), p = G(null), H = G(a), z = G(null), R = G(null), T = G(!1), P = G({ remainingText: null, originalText: null, options: null }), [ee, re] = me(!0), [S, N] = me(null), [Z, X] = me(!1), [j, _] = me(!1);
|
|
6689
|
+
pe(() => {
|
|
6690
|
+
T.current = j;
|
|
6691
|
+
}, [j]), pe(() => {
|
|
6692
6692
|
H.current = a;
|
|
6693
6693
|
}, [a]);
|
|
6694
|
-
const
|
|
6695
|
-
let
|
|
6696
|
-
|
|
6694
|
+
const te = Ae(), ce = i || te.service;
|
|
6695
|
+
let oe;
|
|
6696
|
+
ce === "browser" ? oe = {
|
|
6697
6697
|
service: "browser",
|
|
6698
6698
|
endpoint: "",
|
|
6699
6699
|
apiKey: null,
|
|
6700
6700
|
defaultVoice: "Google US English"
|
|
6701
|
-
} :
|
|
6701
|
+
} : ce === "elevenlabs" ? oe = {
|
|
6702
6702
|
service: "elevenlabs",
|
|
6703
6703
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
6704
|
-
apiKey: o ||
|
|
6705
|
-
defaultVoice: s ||
|
|
6706
|
-
voices:
|
|
6707
|
-
} :
|
|
6704
|
+
apiKey: o || te.apiKey,
|
|
6705
|
+
defaultVoice: s || te.defaultVoice || ye.defaultVoice,
|
|
6706
|
+
voices: te.voices || ye.voices
|
|
6707
|
+
} : ce === "deepgram" ? oe = {
|
|
6708
6708
|
service: "deepgram",
|
|
6709
6709
|
endpoint: "https://api.deepgram.com/v1/speak",
|
|
6710
|
-
apiKey: o ||
|
|
6711
|
-
defaultVoice: s ||
|
|
6712
|
-
voices:
|
|
6713
|
-
} :
|
|
6714
|
-
...
|
|
6710
|
+
apiKey: o || te.apiKey,
|
|
6711
|
+
defaultVoice: s || te.defaultVoice || Me.defaultVoice,
|
|
6712
|
+
voices: te.voices || Me.voices
|
|
6713
|
+
} : oe = {
|
|
6714
|
+
...te,
|
|
6715
6715
|
// Override API key if provided via props
|
|
6716
|
-
apiKey: o !== null ? o :
|
|
6716
|
+
apiKey: o !== null ? o : te.apiKey
|
|
6717
6717
|
};
|
|
6718
|
-
const
|
|
6719
|
-
url:
|
|
6718
|
+
const de = {
|
|
6719
|
+
url: O,
|
|
6720
6720
|
body: t,
|
|
6721
6721
|
avatarMood: e,
|
|
6722
|
-
ttsLang:
|
|
6723
|
-
ttsVoice: s ||
|
|
6722
|
+
ttsLang: ce === "browser" ? "en-US" : n,
|
|
6723
|
+
ttsVoice: s || oe.defaultVoice,
|
|
6724
6724
|
lipsyncLang: "en",
|
|
6725
6725
|
showFullAvatar: a,
|
|
6726
6726
|
bodyMovement: l,
|
|
6727
6727
|
movementIntensity: u
|
|
6728
|
-
},
|
|
6729
|
-
ttsEndpoint:
|
|
6730
|
-
ttsApikey:
|
|
6731
|
-
ttsService:
|
|
6728
|
+
}, J = {
|
|
6729
|
+
ttsEndpoint: oe.endpoint,
|
|
6730
|
+
ttsApikey: oe.apiKey,
|
|
6731
|
+
ttsService: ce,
|
|
6732
6732
|
lipsyncModules: ["en"],
|
|
6733
6733
|
cameraView: h
|
|
6734
|
-
},
|
|
6735
|
-
if (!(!
|
|
6734
|
+
}, b = E(async () => {
|
|
6735
|
+
if (!(!D.current || p.current))
|
|
6736
6736
|
try {
|
|
6737
|
-
if (
|
|
6738
|
-
if (
|
|
6739
|
-
const
|
|
6740
|
-
c(
|
|
6737
|
+
if (re(!0), N(null), p.current = new Fe(D.current, J), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(de, (V) => {
|
|
6738
|
+
if (V.lengthComputable) {
|
|
6739
|
+
const M = Math.min(100, Math.round(V.loaded / V.total * 100));
|
|
6740
|
+
c(M);
|
|
6741
6741
|
}
|
|
6742
|
-
}), await new Promise((
|
|
6743
|
-
const
|
|
6744
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ?
|
|
6742
|
+
}), await new Promise((V) => {
|
|
6743
|
+
const M = () => {
|
|
6744
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? V() : setTimeout(M, 100);
|
|
6745
6745
|
};
|
|
6746
|
-
|
|
6746
|
+
M();
|
|
6747
6747
|
}), p.current && p.current.setShowFullAvatar)
|
|
6748
6748
|
try {
|
|
6749
6749
|
p.current.setShowFullAvatar(a);
|
|
6750
|
-
} catch (
|
|
6751
|
-
console.warn("Error setting full body mode on initialization:",
|
|
6750
|
+
} catch (V) {
|
|
6751
|
+
console.warn("Error setting full body mode on initialization:", V);
|
|
6752
6752
|
}
|
|
6753
|
-
p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()),
|
|
6753
|
+
p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), re(!1), X(!0), r(p.current);
|
|
6754
6754
|
const B = () => {
|
|
6755
6755
|
document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
|
|
6756
6756
|
};
|
|
6757
6757
|
return document.addEventListener("visibilitychange", B), () => {
|
|
6758
6758
|
document.removeEventListener("visibilitychange", B);
|
|
6759
6759
|
};
|
|
6760
|
-
} catch (
|
|
6761
|
-
console.error("Error initializing TalkingHead:",
|
|
6760
|
+
} catch (L) {
|
|
6761
|
+
console.error("Error initializing TalkingHead:", L), N(L.message || "Failed to initialize avatar"), re(!1), d(L);
|
|
6762
6762
|
}
|
|
6763
|
-
}, [
|
|
6764
|
-
|
|
6763
|
+
}, [O, t, e, n, i, s, o, a, l, u, h]);
|
|
6764
|
+
pe(() => (b(), () => {
|
|
6765
6765
|
p.current && (p.current.stop(), p.current.dispose(), p.current = null);
|
|
6766
|
-
}), [
|
|
6767
|
-
if (!
|
|
6768
|
-
const
|
|
6769
|
-
for (const
|
|
6766
|
+
}), [b]), pe(() => {
|
|
6767
|
+
if (!D.current || !p.current) return;
|
|
6768
|
+
const L = new ResizeObserver((V) => {
|
|
6769
|
+
for (const M of V)
|
|
6770
6770
|
p.current && p.current.onResize && p.current.onResize();
|
|
6771
6771
|
});
|
|
6772
|
-
|
|
6772
|
+
L.observe(D.current);
|
|
6773
6773
|
const B = () => {
|
|
6774
6774
|
p.current && p.current.onResize && p.current.onResize();
|
|
6775
6775
|
};
|
|
6776
6776
|
return window.addEventListener("resize", B), () => {
|
|
6777
|
-
|
|
6777
|
+
L.disconnect(), window.removeEventListener("resize", B);
|
|
6778
6778
|
};
|
|
6779
|
-
}, [
|
|
6780
|
-
const
|
|
6779
|
+
}, [Z]);
|
|
6780
|
+
const v = E(async () => {
|
|
6781
6781
|
if (p.current && p.current.audioCtx)
|
|
6782
6782
|
try {
|
|
6783
6783
|
(p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
|
|
6784
|
-
} catch (
|
|
6785
|
-
console.warn("Failed to resume audio context:",
|
|
6784
|
+
} catch (L) {
|
|
6785
|
+
console.warn("Failed to resume audio context:", L);
|
|
6786
6786
|
}
|
|
6787
|
-
}, []),
|
|
6788
|
-
if (p.current &&
|
|
6787
|
+
}, []), w = E(async (L, B = {}) => {
|
|
6788
|
+
if (p.current && Z)
|
|
6789
6789
|
try {
|
|
6790
|
-
|
|
6791
|
-
const
|
|
6790
|
+
R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: B }, P.current = { remainingText: null, originalText: null, options: null }, _(!1), T.current = !1, await v();
|
|
6791
|
+
const V = {
|
|
6792
6792
|
...B,
|
|
6793
|
-
lipsyncLang: B.lipsyncLang ||
|
|
6793
|
+
lipsyncLang: B.lipsyncLang || de.lipsyncLang || "en"
|
|
6794
6794
|
};
|
|
6795
6795
|
if (B.onSpeechEnd && p.current) {
|
|
6796
|
-
const
|
|
6797
|
-
let
|
|
6796
|
+
const M = p.current;
|
|
6797
|
+
let Y = null, ge = 0;
|
|
6798
6798
|
const ke = 1200;
|
|
6799
|
-
let
|
|
6800
|
-
|
|
6801
|
-
if (
|
|
6799
|
+
let xe = !1;
|
|
6800
|
+
Y = setInterval(() => {
|
|
6801
|
+
if (ge++, T.current)
|
|
6802
6802
|
return;
|
|
6803
|
-
if (
|
|
6804
|
-
if (
|
|
6805
|
-
|
|
6803
|
+
if (ge > ke) {
|
|
6804
|
+
if (Y && (clearInterval(Y), Y = null, R.current = null), !xe && !T.current) {
|
|
6805
|
+
xe = !0;
|
|
6806
6806
|
try {
|
|
6807
6807
|
B.onSpeechEnd();
|
|
6808
6808
|
} catch (we) {
|
|
@@ -6811,121 +6811,145 @@ const Pe = Ie(({
|
|
|
6811
6811
|
}
|
|
6812
6812
|
return;
|
|
6813
6813
|
}
|
|
6814
|
-
const
|
|
6815
|
-
|
|
6816
|
-
if (
|
|
6817
|
-
|
|
6814
|
+
const Oe = !M.speechQueue || M.speechQueue.length === 0, Ne = !M.audioPlaylist || M.audioPlaylist.length === 0;
|
|
6815
|
+
M && M.isSpeaking === !1 && Oe && Ne && M.isAudioPlaying === !1 && !xe && !T.current && setTimeout(() => {
|
|
6816
|
+
if (M && !T.current && M.isSpeaking === !1 && (!M.speechQueue || M.speechQueue.length === 0) && (!M.audioPlaylist || M.audioPlaylist.length === 0) && M.isAudioPlaying === !1 && !xe && !T.current) {
|
|
6817
|
+
xe = !0, Y && (clearInterval(Y), Y = null, R.current = null);
|
|
6818
6818
|
try {
|
|
6819
6819
|
B.onSpeechEnd();
|
|
6820
|
-
} catch (
|
|
6821
|
-
console.error("Error in onSpeechEnd callback:",
|
|
6820
|
+
} catch (Ue) {
|
|
6821
|
+
console.error("Error in onSpeechEnd callback:", Ue);
|
|
6822
6822
|
}
|
|
6823
6823
|
}
|
|
6824
6824
|
}, 100);
|
|
6825
|
-
}, 100),
|
|
6825
|
+
}, 100), R.current = Y;
|
|
6826
6826
|
}
|
|
6827
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(
|
|
6828
|
-
await
|
|
6827
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, V)) : setTimeout(async () => {
|
|
6828
|
+
await v(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, V));
|
|
6829
6829
|
}, 100);
|
|
6830
|
-
} catch (
|
|
6831
|
-
console.error("Error speaking text:",
|
|
6830
|
+
} catch (V) {
|
|
6831
|
+
console.error("Error speaking text:", V), N(V.message || "Failed to speak text");
|
|
6832
6832
|
}
|
|
6833
|
-
}, [
|
|
6834
|
-
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null,
|
|
6835
|
-
}, []),
|
|
6833
|
+
}, [Z, v, de.lipsyncLang]), C = E(() => {
|
|
6834
|
+
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, _(!1));
|
|
6835
|
+
}, []), W = E(() => {
|
|
6836
6836
|
if (p.current && p.current.pauseSpeaking) {
|
|
6837
|
-
const
|
|
6838
|
-
(
|
|
6837
|
+
const L = p.current;
|
|
6838
|
+
if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
|
|
6839
|
+
R.current && (clearInterval(R.current), R.current = null);
|
|
6840
|
+
let V = "";
|
|
6841
|
+
if (L.speechQueue && L.speechQueue.length > 0 && z.current) {
|
|
6842
|
+
const M = L.speechQueue.filter((Y) => Y && Y.text).map((Y) => Y.text).join(" ");
|
|
6843
|
+
M && M.trim() && (V = M.trim());
|
|
6844
|
+
}
|
|
6845
|
+
z.current && (P.current = {
|
|
6846
|
+
remainingText: V || null,
|
|
6847
|
+
originalText: z.current.text,
|
|
6848
|
+
options: z.current.options
|
|
6849
|
+
}), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, _(!0);
|
|
6850
|
+
}
|
|
6839
6851
|
}
|
|
6840
|
-
}, []),
|
|
6841
|
-
if (p.current
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
};
|
|
6848
|
-
|
|
6852
|
+
}, []), ne = E(async () => {
|
|
6853
|
+
if (!p.current || !j)
|
|
6854
|
+
return;
|
|
6855
|
+
let L = "", B = {};
|
|
6856
|
+
if (P.current && P.current.remainingText)
|
|
6857
|
+
L = P.current.remainingText, B = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
|
|
6858
|
+
else if (z.current && z.current.text)
|
|
6859
|
+
L = z.current.text, B = z.current.options || {};
|
|
6860
|
+
else {
|
|
6861
|
+
console.warn("Resume called but no paused speech found"), _(!1), T.current = !1;
|
|
6862
|
+
return;
|
|
6849
6863
|
}
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6864
|
+
_(!1), T.current = !1, await v();
|
|
6865
|
+
const V = {
|
|
6866
|
+
...B,
|
|
6867
|
+
lipsyncLang: B.lipsyncLang || de.lipsyncLang || "en"
|
|
6868
|
+
};
|
|
6869
|
+
try {
|
|
6870
|
+
await w(L, V);
|
|
6871
|
+
} catch (M) {
|
|
6872
|
+
console.error("Error resuming speech:", M), _(!1), T.current = !1;
|
|
6873
|
+
}
|
|
6874
|
+
}, [v, j, w, de]), ie = E((L) => {
|
|
6875
|
+
p.current && p.current.setMood(L);
|
|
6876
|
+
}, []), fe = E((L) => {
|
|
6877
|
+
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
|
|
6878
|
+
}, []), Se = E((L, B = !1) => {
|
|
6855
6879
|
if (p.current && p.current.playAnimation) {
|
|
6856
|
-
if (x && x[
|
|
6880
|
+
if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
|
|
6857
6881
|
try {
|
|
6858
6882
|
p.current.setShowFullAvatar(H.current);
|
|
6859
|
-
} catch (
|
|
6860
|
-
console.warn("Error setting full body mode:",
|
|
6883
|
+
} catch (M) {
|
|
6884
|
+
console.warn("Error setting full body mode:", M);
|
|
6861
6885
|
}
|
|
6862
|
-
if (
|
|
6886
|
+
if (L.includes("."))
|
|
6863
6887
|
try {
|
|
6864
|
-
p.current.playAnimation(
|
|
6865
|
-
} catch (
|
|
6866
|
-
console.warn(`Failed to play ${
|
|
6888
|
+
p.current.playAnimation(L, null, 10, 0, 0.01, B);
|
|
6889
|
+
} catch (M) {
|
|
6890
|
+
console.warn(`Failed to play ${L}:`, M);
|
|
6867
6891
|
try {
|
|
6868
6892
|
p.current.setBodyMovement("idle");
|
|
6869
|
-
} catch (
|
|
6870
|
-
console.warn("Fallback animation also failed:",
|
|
6893
|
+
} catch (Y) {
|
|
6894
|
+
console.warn("Fallback animation also failed:", Y);
|
|
6871
6895
|
}
|
|
6872
6896
|
}
|
|
6873
6897
|
else {
|
|
6874
|
-
const
|
|
6875
|
-
let
|
|
6876
|
-
for (const
|
|
6898
|
+
const M = [".fbx", ".glb", ".gltf"];
|
|
6899
|
+
let Y = !1;
|
|
6900
|
+
for (const ge of M)
|
|
6877
6901
|
try {
|
|
6878
|
-
p.current.playAnimation(
|
|
6902
|
+
p.current.playAnimation(L + ge, null, 10, 0, 0.01, B), Y = !0;
|
|
6879
6903
|
break;
|
|
6880
6904
|
} catch {
|
|
6881
6905
|
}
|
|
6882
|
-
if (
|
|
6883
|
-
console.warn("Animation not found:",
|
|
6906
|
+
if (!Y) {
|
|
6907
|
+
console.warn("Animation not found:", L);
|
|
6884
6908
|
try {
|
|
6885
6909
|
p.current.setBodyMovement("idle");
|
|
6886
|
-
} catch (
|
|
6887
|
-
console.warn("Fallback animation also failed:",
|
|
6910
|
+
} catch (ge) {
|
|
6911
|
+
console.warn("Fallback animation also failed:", ge);
|
|
6888
6912
|
}
|
|
6889
6913
|
}
|
|
6890
6914
|
}
|
|
6891
6915
|
}
|
|
6892
|
-
}, [x]),
|
|
6916
|
+
}, [x]), De = E(() => {
|
|
6893
6917
|
p.current && p.current.onResize && p.current.onResize();
|
|
6894
6918
|
}, []);
|
|
6895
6919
|
return Le(I, () => ({
|
|
6896
|
-
speakText:
|
|
6897
|
-
stopSpeaking:
|
|
6898
|
-
pauseSpeaking:
|
|
6899
|
-
resumeSpeaking:
|
|
6900
|
-
resumeAudioContext:
|
|
6901
|
-
setMood:
|
|
6902
|
-
setTimingAdjustment:
|
|
6903
|
-
playAnimation:
|
|
6904
|
-
isReady:
|
|
6905
|
-
isPaused:
|
|
6920
|
+
speakText: w,
|
|
6921
|
+
stopSpeaking: C,
|
|
6922
|
+
pauseSpeaking: W,
|
|
6923
|
+
resumeSpeaking: ne,
|
|
6924
|
+
resumeAudioContext: v,
|
|
6925
|
+
setMood: ie,
|
|
6926
|
+
setTimingAdjustment: fe,
|
|
6927
|
+
playAnimation: Se,
|
|
6928
|
+
isReady: Z,
|
|
6929
|
+
isPaused: j,
|
|
6906
6930
|
talkingHead: p.current,
|
|
6907
|
-
handleResize:
|
|
6908
|
-
setBodyMovement: (
|
|
6931
|
+
handleResize: De,
|
|
6932
|
+
setBodyMovement: (L) => {
|
|
6909
6933
|
if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
|
|
6910
6934
|
try {
|
|
6911
|
-
p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(
|
|
6935
|
+
p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(L);
|
|
6912
6936
|
} catch (B) {
|
|
6913
6937
|
console.warn("Error setting body movement:", B);
|
|
6914
6938
|
}
|
|
6915
6939
|
},
|
|
6916
|
-
setMovementIntensity: (
|
|
6940
|
+
setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
|
|
6917
6941
|
playRandomDance: () => {
|
|
6918
6942
|
if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
|
|
6919
6943
|
try {
|
|
6920
6944
|
p.current.setShowFullAvatar(H.current), p.current.playRandomDance();
|
|
6921
|
-
} catch (
|
|
6922
|
-
console.warn("Error playing random dance:",
|
|
6945
|
+
} catch (L) {
|
|
6946
|
+
console.warn("Error playing random dance:", L);
|
|
6923
6947
|
}
|
|
6924
6948
|
},
|
|
6925
|
-
playReaction: (
|
|
6949
|
+
playReaction: (L) => {
|
|
6926
6950
|
if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
|
|
6927
6951
|
try {
|
|
6928
|
-
p.current.setShowFullAvatar(H.current), p.current.playReaction(
|
|
6952
|
+
p.current.setShowFullAvatar(H.current), p.current.playReaction(L);
|
|
6929
6953
|
} catch (B) {
|
|
6930
6954
|
console.warn("Error playing reaction:", B);
|
|
6931
6955
|
}
|
|
@@ -6934,14 +6958,14 @@ const Pe = Ie(({
|
|
|
6934
6958
|
if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
|
|
6935
6959
|
try {
|
|
6936
6960
|
p.current.setShowFullAvatar(H.current), p.current.playCelebration();
|
|
6937
|
-
} catch (
|
|
6938
|
-
console.warn("Error playing celebration:",
|
|
6961
|
+
} catch (L) {
|
|
6962
|
+
console.warn("Error playing celebration:", L);
|
|
6939
6963
|
}
|
|
6940
6964
|
},
|
|
6941
|
-
setShowFullAvatar: (
|
|
6965
|
+
setShowFullAvatar: (L) => {
|
|
6942
6966
|
if (p.current && p.current.setShowFullAvatar)
|
|
6943
6967
|
try {
|
|
6944
|
-
H.current =
|
|
6968
|
+
H.current = L, p.current.setShowFullAvatar(L);
|
|
6945
6969
|
} catch (B) {
|
|
6946
6970
|
console.warn("Error setting showFullAvatar:", B);
|
|
6947
6971
|
}
|
|
@@ -6950,16 +6974,16 @@ const Pe = Ie(({
|
|
|
6950
6974
|
if (p.current && p.current.lockAvatarPosition)
|
|
6951
6975
|
try {
|
|
6952
6976
|
p.current.lockAvatarPosition();
|
|
6953
|
-
} catch (
|
|
6954
|
-
console.warn("Error locking avatar position:",
|
|
6977
|
+
} catch (L) {
|
|
6978
|
+
console.warn("Error locking avatar position:", L);
|
|
6955
6979
|
}
|
|
6956
6980
|
},
|
|
6957
6981
|
unlockAvatarPosition: () => {
|
|
6958
6982
|
if (p.current && p.current.unlockAvatarPosition)
|
|
6959
6983
|
try {
|
|
6960
6984
|
p.current.unlockAvatarPosition();
|
|
6961
|
-
} catch (
|
|
6962
|
-
console.warn("Error unlocking avatar position:",
|
|
6985
|
+
} catch (L) {
|
|
6986
|
+
console.warn("Error unlocking avatar position:", L);
|
|
6963
6987
|
}
|
|
6964
6988
|
}
|
|
6965
6989
|
})), /* @__PURE__ */ Ee(
|
|
@@ -6976,7 +7000,7 @@ const Pe = Ie(({
|
|
|
6976
7000
|
/* @__PURE__ */ ue(
|
|
6977
7001
|
"div",
|
|
6978
7002
|
{
|
|
6979
|
-
ref:
|
|
7003
|
+
ref: D,
|
|
6980
7004
|
className: "talking-head-viewer",
|
|
6981
7005
|
style: {
|
|
6982
7006
|
width: "100%",
|
|
@@ -6985,7 +7009,7 @@ const Pe = Ie(({
|
|
|
6985
7009
|
}
|
|
6986
7010
|
}
|
|
6987
7011
|
),
|
|
6988
|
-
|
|
7012
|
+
ee && /* @__PURE__ */ ue("div", { className: "loading-overlay", style: {
|
|
6989
7013
|
position: "absolute",
|
|
6990
7014
|
top: "50%",
|
|
6991
7015
|
left: "50%",
|
|
@@ -6994,7 +7018,7 @@ const Pe = Ie(({
|
|
|
6994
7018
|
fontSize: "18px",
|
|
6995
7019
|
zIndex: 10
|
|
6996
7020
|
}, children: "Loading avatar..." }),
|
|
6997
|
-
|
|
7021
|
+
S && /* @__PURE__ */ ue("div", { className: "error-overlay", style: {
|
|
6998
7022
|
position: "absolute",
|
|
6999
7023
|
top: "50%",
|
|
7000
7024
|
left: "50%",
|
|
@@ -7005,14 +7029,14 @@ const Pe = Ie(({
|
|
|
7005
7029
|
zIndex: 10,
|
|
7006
7030
|
padding: "20px",
|
|
7007
7031
|
borderRadius: "8px"
|
|
7008
|
-
}, children:
|
|
7032
|
+
}, children: S })
|
|
7009
7033
|
]
|
|
7010
7034
|
}
|
|
7011
7035
|
);
|
|
7012
7036
|
});
|
|
7013
7037
|
Pe.displayName = "TalkingHeadAvatar";
|
|
7014
|
-
const
|
|
7015
|
-
text:
|
|
7038
|
+
const ut = Ie(({
|
|
7039
|
+
text: O = "Hello! I'm a talking avatar. How are you today?",
|
|
7016
7040
|
onLoading: t = () => {
|
|
7017
7041
|
},
|
|
7018
7042
|
onError: e = () => {
|
|
@@ -7023,7 +7047,7 @@ const ht = Ie(({
|
|
|
7023
7047
|
style: s = {},
|
|
7024
7048
|
avatarConfig: o = {}
|
|
7025
7049
|
}, l) => {
|
|
7026
|
-
const u = G(null), a = G(null), [h, r] =
|
|
7050
|
+
const u = G(null), a = G(null), [h, r] = me(!0), [c, d] = me(null), [g, y] = me(!1), x = Ae(), I = o.ttsService || x.service, D = I === "browser" ? {
|
|
7027
7051
|
endpoint: "",
|
|
7028
7052
|
apiKey: null,
|
|
7029
7053
|
defaultVoice: "Google US English"
|
|
@@ -7039,7 +7063,7 @@ const ht = Ie(({
|
|
|
7039
7063
|
body: "F",
|
|
7040
7064
|
avatarMood: "neutral",
|
|
7041
7065
|
ttsLang: I === "browser" ? "en-US" : "en",
|
|
7042
|
-
ttsVoice: o.ttsVoice ||
|
|
7066
|
+
ttsVoice: o.ttsVoice || D.defaultVoice,
|
|
7043
7067
|
lipsyncLang: "en",
|
|
7044
7068
|
// English lip-sync
|
|
7045
7069
|
showFullAvatar: !0,
|
|
@@ -7048,102 +7072,102 @@ const ht = Ie(({
|
|
|
7048
7072
|
movementIntensity: 0.5,
|
|
7049
7073
|
...o
|
|
7050
7074
|
}, H = {
|
|
7051
|
-
ttsEndpoint:
|
|
7052
|
-
ttsApikey:
|
|
7075
|
+
ttsEndpoint: D.endpoint,
|
|
7076
|
+
ttsApikey: D.apiKey,
|
|
7053
7077
|
ttsService: I,
|
|
7054
7078
|
lipsyncModules: ["en"],
|
|
7055
7079
|
cameraView: "upper"
|
|
7056
|
-
}, z =
|
|
7080
|
+
}, z = E(async () => {
|
|
7057
7081
|
if (!(!u.current || a.current))
|
|
7058
7082
|
try {
|
|
7059
|
-
if (r(!0), d(null), a.current = new Fe(u.current, H), await a.current.showAvatar(p, (
|
|
7060
|
-
if (
|
|
7061
|
-
const
|
|
7062
|
-
t(
|
|
7083
|
+
if (r(!0), d(null), a.current = new Fe(u.current, H), await a.current.showAvatar(p, (Z) => {
|
|
7084
|
+
if (Z.lengthComputable) {
|
|
7085
|
+
const X = Math.min(100, Math.round(Z.loaded / Z.total * 100));
|
|
7086
|
+
t(X);
|
|
7063
7087
|
}
|
|
7064
7088
|
}), a.current.morphs && a.current.morphs.length > 0) {
|
|
7065
|
-
const
|
|
7066
|
-
console.log("Available morph targets:", Object.keys(
|
|
7067
|
-
const
|
|
7068
|
-
console.log("Viseme morph targets found:",
|
|
7089
|
+
const Z = a.current.morphs[0].morphTargetDictionary;
|
|
7090
|
+
console.log("Available morph targets:", Object.keys(Z));
|
|
7091
|
+
const X = Object.keys(Z).filter((j) => j.startsWith("viseme_"));
|
|
7092
|
+
console.log("Viseme morph targets found:", X), X.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
|
|
7069
7093
|
}
|
|
7070
|
-
if (await new Promise((
|
|
7071
|
-
const
|
|
7072
|
-
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)),
|
|
7094
|
+
if (await new Promise((Z) => {
|
|
7095
|
+
const X = () => {
|
|
7096
|
+
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), Z()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(X, 100));
|
|
7073
7097
|
};
|
|
7074
|
-
|
|
7098
|
+
X();
|
|
7075
7099
|
}), a.current && a.current.setShowFullAvatar)
|
|
7076
7100
|
try {
|
|
7077
7101
|
a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
|
|
7078
|
-
} catch (
|
|
7079
|
-
console.warn("Error setting full body mode on initialization:",
|
|
7102
|
+
} catch (Z) {
|
|
7103
|
+
console.warn("Error setting full body mode on initialization:", Z);
|
|
7080
7104
|
}
|
|
7081
7105
|
r(!1), y(!0), n(a.current);
|
|
7082
|
-
const
|
|
7106
|
+
const N = () => {
|
|
7083
7107
|
document.visibilityState === "visible" ? a.current?.start() : a.current?.stop();
|
|
7084
7108
|
};
|
|
7085
|
-
return document.addEventListener("visibilitychange",
|
|
7086
|
-
document.removeEventListener("visibilitychange",
|
|
7109
|
+
return document.addEventListener("visibilitychange", N), () => {
|
|
7110
|
+
document.removeEventListener("visibilitychange", N);
|
|
7087
7111
|
};
|
|
7088
7112
|
} catch (S) {
|
|
7089
7113
|
console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), r(!1), e(S);
|
|
7090
7114
|
}
|
|
7091
7115
|
}, []);
|
|
7092
|
-
|
|
7116
|
+
pe(() => (z(), () => {
|
|
7093
7117
|
a.current && (a.current.stop(), a.current.dispose(), a.current = null);
|
|
7094
7118
|
}), [z]);
|
|
7095
|
-
const
|
|
7119
|
+
const R = E((S) => {
|
|
7096
7120
|
if (a.current && g)
|
|
7097
7121
|
try {
|
|
7098
7122
|
console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", a.current), a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
|
|
7099
7123
|
a.current && a.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
|
|
7100
7124
|
}, 500));
|
|
7101
|
-
} catch (
|
|
7102
|
-
console.error("Error speaking text:",
|
|
7125
|
+
} catch (N) {
|
|
7126
|
+
console.error("Error speaking text:", N), d(N.message || "Failed to speak text");
|
|
7103
7127
|
}
|
|
7104
7128
|
else
|
|
7105
7129
|
console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
|
|
7106
|
-
}, [g, p]),
|
|
7130
|
+
}, [g, p]), T = E(() => {
|
|
7107
7131
|
a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
|
|
7108
|
-
}, []),
|
|
7132
|
+
}, []), P = E((S) => {
|
|
7109
7133
|
a.current && a.current.setMood(S);
|
|
7110
|
-
}, []),
|
|
7134
|
+
}, []), ee = E((S) => {
|
|
7111
7135
|
a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
|
|
7112
|
-
}, []), re =
|
|
7136
|
+
}, []), re = E((S, N = !1) => {
|
|
7113
7137
|
if (a.current && a.current.playAnimation) {
|
|
7114
7138
|
if (a.current.setShowFullAvatar)
|
|
7115
7139
|
try {
|
|
7116
7140
|
a.current.setShowFullAvatar(!0);
|
|
7117
|
-
} catch (
|
|
7118
|
-
console.warn("Error setting full body mode:",
|
|
7141
|
+
} catch (X) {
|
|
7142
|
+
console.warn("Error setting full body mode:", X);
|
|
7119
7143
|
}
|
|
7120
7144
|
if (S.includes("."))
|
|
7121
7145
|
try {
|
|
7122
|
-
a.current.playAnimation(S, null, 10, 0, 0.01,
|
|
7123
|
-
} catch (
|
|
7124
|
-
console.log(`Failed to play ${S}:`,
|
|
7146
|
+
a.current.playAnimation(S, null, 10, 0, 0.01, N), console.log("Playing animation:", S);
|
|
7147
|
+
} catch (X) {
|
|
7148
|
+
console.log(`Failed to play ${S}:`, X);
|
|
7125
7149
|
try {
|
|
7126
7150
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7127
|
-
} catch (
|
|
7128
|
-
console.warn("Fallback animation also failed:",
|
|
7151
|
+
} catch (j) {
|
|
7152
|
+
console.warn("Fallback animation also failed:", j);
|
|
7129
7153
|
}
|
|
7130
7154
|
}
|
|
7131
7155
|
else {
|
|
7132
|
-
const
|
|
7133
|
-
let
|
|
7134
|
-
for (const
|
|
7156
|
+
const X = [".fbx", ".glb", ".gltf"];
|
|
7157
|
+
let j = !1;
|
|
7158
|
+
for (const _ of X)
|
|
7135
7159
|
try {
|
|
7136
|
-
a.current.playAnimation(S +
|
|
7160
|
+
a.current.playAnimation(S + _, null, 10, 0, 0.01, N), console.log("Playing animation:", S + _), j = !0;
|
|
7137
7161
|
break;
|
|
7138
7162
|
} catch {
|
|
7139
|
-
console.log(`Failed to play ${S}${
|
|
7163
|
+
console.log(`Failed to play ${S}${_}, trying next format...`);
|
|
7140
7164
|
}
|
|
7141
|
-
if (!
|
|
7165
|
+
if (!j) {
|
|
7142
7166
|
console.warn("Animation system not available or animation not found:", S);
|
|
7143
7167
|
try {
|
|
7144
7168
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7145
|
-
} catch (
|
|
7146
|
-
console.warn("Fallback animation also failed:",
|
|
7169
|
+
} catch (_) {
|
|
7170
|
+
console.warn("Fallback animation also failed:", _);
|
|
7147
7171
|
}
|
|
7148
7172
|
}
|
|
7149
7173
|
}
|
|
@@ -7151,10 +7175,10 @@ const ht = Ie(({
|
|
|
7151
7175
|
console.warn("Animation system not available or animation not found:", S);
|
|
7152
7176
|
}, []);
|
|
7153
7177
|
return Le(l, () => ({
|
|
7154
|
-
speakText:
|
|
7155
|
-
stopSpeaking:
|
|
7156
|
-
setMood:
|
|
7157
|
-
setTimingAdjustment:
|
|
7178
|
+
speakText: R,
|
|
7179
|
+
stopSpeaking: T,
|
|
7180
|
+
setMood: P,
|
|
7181
|
+
setTimingAdjustment: ee,
|
|
7158
7182
|
playAnimation: re,
|
|
7159
7183
|
isReady: g,
|
|
7160
7184
|
talkingHead: a.current,
|
|
@@ -7162,8 +7186,8 @@ const ht = Ie(({
|
|
|
7162
7186
|
if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
|
|
7163
7187
|
try {
|
|
7164
7188
|
a.current.setShowFullAvatar(!0), a.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
|
|
7165
|
-
} catch (
|
|
7166
|
-
console.warn("Error setting body movement:",
|
|
7189
|
+
} catch (N) {
|
|
7190
|
+
console.warn("Error setting body movement:", N);
|
|
7167
7191
|
}
|
|
7168
7192
|
},
|
|
7169
7193
|
setMovementIntensity: (S) => a.current?.setMovementIntensity(S),
|
|
@@ -7179,8 +7203,8 @@ const ht = Ie(({
|
|
|
7179
7203
|
if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
|
|
7180
7204
|
try {
|
|
7181
7205
|
a.current.setShowFullAvatar(!0), a.current.playReaction(S), console.log("Reaction played with full body mode:", S);
|
|
7182
|
-
} catch (
|
|
7183
|
-
console.warn("Error playing reaction:",
|
|
7206
|
+
} catch (N) {
|
|
7207
|
+
console.warn("Error playing reaction:", N);
|
|
7184
7208
|
}
|
|
7185
7209
|
},
|
|
7186
7210
|
playCelebration: () => {
|
|
@@ -7195,8 +7219,8 @@ const ht = Ie(({
|
|
|
7195
7219
|
if (a.current && a.current.setShowFullAvatar)
|
|
7196
7220
|
try {
|
|
7197
7221
|
a.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
|
|
7198
|
-
} catch (
|
|
7199
|
-
console.warn("Error setting showFullAvatar:",
|
|
7222
|
+
} catch (N) {
|
|
7223
|
+
console.warn("Error setting showFullAvatar:", N);
|
|
7200
7224
|
}
|
|
7201
7225
|
},
|
|
7202
7226
|
lockAvatarPosition: () => {
|
|
@@ -7251,9 +7275,9 @@ const ht = Ie(({
|
|
|
7251
7275
|
}, children: c })
|
|
7252
7276
|
] });
|
|
7253
7277
|
});
|
|
7254
|
-
|
|
7255
|
-
const
|
|
7256
|
-
curriculumData:
|
|
7278
|
+
ut.displayName = "TalkingHeadComponent";
|
|
7279
|
+
const ct = Ie(({
|
|
7280
|
+
curriculumData: O = null,
|
|
7257
7281
|
avatarConfig: t = {},
|
|
7258
7282
|
animations: e = {},
|
|
7259
7283
|
onLessonStart: n = () => {
|
|
@@ -7284,7 +7308,7 @@ const ut = Ie(({
|
|
|
7284
7308
|
onQuestionAnswer: s,
|
|
7285
7309
|
onCurriculumComplete: o,
|
|
7286
7310
|
onCustomAction: l
|
|
7287
|
-
}), d = G(null), g = G(null), y = G(null), x = G(null), I = G(null),
|
|
7311
|
+
}), d = G(null), g = G(null), y = G(null), x = G(null), I = G(null), D = G(null), p = G(null), H = G(O?.curriculum || {
|
|
7288
7312
|
title: "Default Curriculum",
|
|
7289
7313
|
description: "No curriculum data provided",
|
|
7290
7314
|
language: "en",
|
|
@@ -7303,7 +7327,7 @@ const ut = Ie(({
|
|
|
7303
7327
|
animations: e,
|
|
7304
7328
|
lipsyncLang: "en"
|
|
7305
7329
|
});
|
|
7306
|
-
|
|
7330
|
+
pe(() => {
|
|
7307
7331
|
c.current = {
|
|
7308
7332
|
onLessonStart: n,
|
|
7309
7333
|
onLessonComplete: i,
|
|
@@ -7311,8 +7335,8 @@ const ut = Ie(({
|
|
|
7311
7335
|
onCurriculumComplete: o,
|
|
7312
7336
|
onCustomAction: l
|
|
7313
7337
|
};
|
|
7314
|
-
}, [n, i, s, o, l]),
|
|
7315
|
-
H.current =
|
|
7338
|
+
}, [n, i, s, o, l]), pe(() => {
|
|
7339
|
+
H.current = O?.curriculum || {
|
|
7316
7340
|
title: "Default Curriculum",
|
|
7317
7341
|
description: "No curriculum data provided",
|
|
7318
7342
|
language: "en",
|
|
@@ -7331,12 +7355,12 @@ const ut = Ie(({
|
|
|
7331
7355
|
animations: e,
|
|
7332
7356
|
lipsyncLang: "en"
|
|
7333
7357
|
};
|
|
7334
|
-
}, [
|
|
7335
|
-
const
|
|
7358
|
+
}, [O, t, e]);
|
|
7359
|
+
const R = E(() => (H.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), T = E(() => R()?.questions[r.current.currentQuestionIndex], [R]), P = E((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), ee = E(() => {
|
|
7336
7360
|
r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
|
|
7337
7361
|
const b = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
|
|
7338
|
-
let
|
|
7339
|
-
if (r.current.totalQuestions > 0 ?
|
|
7362
|
+
let v = "Congratulations! You've completed this lesson";
|
|
7363
|
+
if (r.current.totalQuestions > 0 ? v += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
|
|
7340
7364
|
moduleIndex: r.current.currentModuleIndex,
|
|
7341
7365
|
lessonIndex: r.current.currentLessonIndex,
|
|
7342
7366
|
score: r.current.score,
|
|
@@ -7356,9 +7380,9 @@ const ut = Ie(({
|
|
|
7356
7380
|
} catch {
|
|
7357
7381
|
h.current.playCelebration();
|
|
7358
7382
|
}
|
|
7359
|
-
const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex],
|
|
7360
|
-
h.current.speakText(
|
|
7361
|
-
lipsyncLang:
|
|
7383
|
+
const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex], W = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, ie = W || ne, fe = z.current || { lipsyncLang: "en" };
|
|
7384
|
+
h.current.speakText(v, {
|
|
7385
|
+
lipsyncLang: fe.lipsyncLang,
|
|
7362
7386
|
onSpeechEnd: () => {
|
|
7363
7387
|
c.current.onCustomAction({
|
|
7364
7388
|
type: "lessonCompleteFeedbackDone",
|
|
@@ -7367,17 +7391,17 @@ const ut = Ie(({
|
|
|
7367
7391
|
score: r.current.score,
|
|
7368
7392
|
totalQuestions: r.current.totalQuestions,
|
|
7369
7393
|
percentage: b,
|
|
7370
|
-
hasNextLesson:
|
|
7394
|
+
hasNextLesson: ie
|
|
7371
7395
|
});
|
|
7372
7396
|
}
|
|
7373
7397
|
});
|
|
7374
7398
|
}
|
|
7375
|
-
}, [e.lessonComplete]), re =
|
|
7399
|
+
}, [e.lessonComplete]), re = E(() => {
|
|
7376
7400
|
r.current.curriculumCompleted = !0;
|
|
7377
7401
|
const b = H.current || { modules: [] };
|
|
7378
7402
|
if (c.current.onCurriculumComplete({
|
|
7379
7403
|
modules: b.modules.length,
|
|
7380
|
-
totalLessons: b.modules.reduce((
|
|
7404
|
+
totalLessons: b.modules.reduce((v, w) => v + w.lessons.length, 0)
|
|
7381
7405
|
}), h.current) {
|
|
7382
7406
|
if (h.current.setMood("celebrating"), e.curriculumComplete)
|
|
7383
7407
|
try {
|
|
@@ -7385,82 +7409,82 @@ const ut = Ie(({
|
|
|
7385
7409
|
} catch {
|
|
7386
7410
|
h.current.playCelebration();
|
|
7387
7411
|
}
|
|
7388
|
-
const
|
|
7389
|
-
h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang:
|
|
7412
|
+
const v = z.current || { lipsyncLang: "en" };
|
|
7413
|
+
h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: v.lipsyncLang });
|
|
7390
7414
|
}
|
|
7391
|
-
}, [e.curriculumComplete]), S =
|
|
7392
|
-
const b =
|
|
7415
|
+
}, [e.curriculumComplete]), S = E(() => {
|
|
7416
|
+
const b = R();
|
|
7393
7417
|
r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = b?.questions?.length || 0, r.current.score = 0;
|
|
7394
|
-
const
|
|
7395
|
-
|
|
7418
|
+
const v = T();
|
|
7419
|
+
v && c.current.onCustomAction({
|
|
7396
7420
|
type: "questionStart",
|
|
7397
7421
|
moduleIndex: r.current.currentModuleIndex,
|
|
7398
7422
|
lessonIndex: r.current.currentLessonIndex,
|
|
7399
7423
|
questionIndex: r.current.currentQuestionIndex,
|
|
7400
7424
|
totalQuestions: r.current.totalQuestions,
|
|
7401
|
-
question:
|
|
7425
|
+
question: v,
|
|
7402
7426
|
score: r.current.score
|
|
7403
7427
|
});
|
|
7404
7428
|
const w = () => {
|
|
7405
|
-
if (!h.current || !
|
|
7429
|
+
if (!h.current || !v) return;
|
|
7406
7430
|
if (h.current.setMood("happy"), e.questionStart)
|
|
7407
7431
|
try {
|
|
7408
7432
|
h.current.playAnimation(e.questionStart, !0);
|
|
7409
|
-
} catch (
|
|
7410
|
-
console.warn("Failed to play questionStart animation:",
|
|
7433
|
+
} catch (W) {
|
|
7434
|
+
console.warn("Failed to play questionStart animation:", W);
|
|
7411
7435
|
}
|
|
7412
7436
|
const C = z.current || { lipsyncLang: "en" };
|
|
7413
|
-
|
|
7437
|
+
v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang });
|
|
7414
7438
|
};
|
|
7415
|
-
if (h.current && h.current.isReady &&
|
|
7439
|
+
if (h.current && h.current.isReady && v)
|
|
7416
7440
|
w();
|
|
7417
7441
|
else if (h.current && h.current.isReady) {
|
|
7418
7442
|
const C = z.current || { lipsyncLang: "en" };
|
|
7419
7443
|
h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
|
|
7420
7444
|
} else {
|
|
7421
7445
|
const C = setInterval(() => {
|
|
7422
|
-
h.current && h.current.isReady && (clearInterval(C),
|
|
7446
|
+
h.current && h.current.isReady && (clearInterval(C), v && w());
|
|
7423
7447
|
}, 100);
|
|
7424
7448
|
setTimeout(() => {
|
|
7425
7449
|
clearInterval(C);
|
|
7426
7450
|
}, 5e3);
|
|
7427
7451
|
}
|
|
7428
|
-
}, [e.questionStart,
|
|
7429
|
-
const b =
|
|
7452
|
+
}, [e.questionStart, R, T]), N = E(() => {
|
|
7453
|
+
const b = R();
|
|
7430
7454
|
if (r.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
|
|
7431
7455
|
h.current && h.current.stopSpeaking && h.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
|
|
7432
|
-
const
|
|
7433
|
-
|
|
7456
|
+
const v = T();
|
|
7457
|
+
v && c.current.onCustomAction({
|
|
7434
7458
|
type: "nextQuestion",
|
|
7435
7459
|
moduleIndex: r.current.currentModuleIndex,
|
|
7436
7460
|
lessonIndex: r.current.currentLessonIndex,
|
|
7437
7461
|
questionIndex: r.current.currentQuestionIndex,
|
|
7438
7462
|
totalQuestions: r.current.totalQuestions,
|
|
7439
|
-
question:
|
|
7463
|
+
question: v,
|
|
7440
7464
|
score: r.current.score
|
|
7441
7465
|
});
|
|
7442
7466
|
const w = () => {
|
|
7443
|
-
if (!h.current || !
|
|
7467
|
+
if (!h.current || !v) return;
|
|
7444
7468
|
if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
|
|
7445
7469
|
try {
|
|
7446
7470
|
h.current.playAnimation(e.nextQuestion, !0);
|
|
7447
|
-
} catch (
|
|
7448
|
-
console.warn("Failed to play nextQuestion animation:",
|
|
7471
|
+
} catch (W) {
|
|
7472
|
+
console.warn("Failed to play nextQuestion animation:", W);
|
|
7449
7473
|
}
|
|
7450
7474
|
const C = z.current || { lipsyncLang: "en" };
|
|
7451
|
-
|
|
7475
|
+
v.type === "code_test" ? h.current.speakText(`Great! Now let's move on to your next coding challenge: ${v.question}`, {
|
|
7452
7476
|
lipsyncLang: C.lipsyncLang
|
|
7453
|
-
}) :
|
|
7477
|
+
}) : v.type === "multiple_choice" ? h.current.speakText(`Alright! Here's your next question: ${v.question}`, {
|
|
7454
7478
|
lipsyncLang: C.lipsyncLang
|
|
7455
|
-
}) :
|
|
7479
|
+
}) : v.type === "true_false" ? h.current.speakText(`Now let's try this one: ${v.question}`, {
|
|
7456
7480
|
lipsyncLang: C.lipsyncLang
|
|
7457
|
-
}) : h.current.speakText(`Here's the next question: ${
|
|
7481
|
+
}) : h.current.speakText(`Here's the next question: ${v.question}`, {
|
|
7458
7482
|
lipsyncLang: C.lipsyncLang
|
|
7459
7483
|
});
|
|
7460
7484
|
};
|
|
7461
|
-
if (h.current && h.current.isReady &&
|
|
7485
|
+
if (h.current && h.current.isReady && v)
|
|
7462
7486
|
w();
|
|
7463
|
-
else if (
|
|
7487
|
+
else if (v) {
|
|
7464
7488
|
const C = setInterval(() => {
|
|
7465
7489
|
h.current && h.current.isReady && (clearInterval(C), w());
|
|
7466
7490
|
}, 100);
|
|
@@ -7476,52 +7500,52 @@ const ut = Ie(({
|
|
|
7476
7500
|
totalQuestions: r.current.totalQuestions,
|
|
7477
7501
|
score: r.current.score
|
|
7478
7502
|
});
|
|
7479
|
-
}, [e.nextQuestion,
|
|
7480
|
-
const b = H.current || { modules: [] },
|
|
7481
|
-
if (r.current.currentLessonIndex < (
|
|
7503
|
+
}, [e.nextQuestion, R, T]), Z = E(() => {
|
|
7504
|
+
const b = H.current || { modules: [] }, v = b.modules[r.current.currentModuleIndex];
|
|
7505
|
+
if (r.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
|
|
7482
7506
|
r.current.currentLessonIndex += 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
|
|
7483
|
-
const C = b.modules[r.current.currentModuleIndex],
|
|
7507
|
+
const C = b.modules[r.current.currentModuleIndex], W = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ie = W || ne;
|
|
7484
7508
|
c.current.onCustomAction({
|
|
7485
7509
|
type: "lessonStart",
|
|
7486
7510
|
moduleIndex: r.current.currentModuleIndex,
|
|
7487
7511
|
lessonIndex: r.current.currentLessonIndex,
|
|
7488
|
-
hasNextLesson:
|
|
7512
|
+
hasNextLesson: ie
|
|
7489
7513
|
}), c.current.onLessonStart({
|
|
7490
7514
|
moduleIndex: r.current.currentModuleIndex,
|
|
7491
7515
|
lessonIndex: r.current.currentLessonIndex,
|
|
7492
|
-
lesson:
|
|
7516
|
+
lesson: R()
|
|
7493
7517
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7494
7518
|
} else if (r.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
|
|
7495
7519
|
r.current.currentModuleIndex += 1, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
|
|
7496
|
-
const
|
|
7520
|
+
const W = b.modules[r.current.currentModuleIndex], ne = r.current.currentLessonIndex < (W?.lessons?.length || 0) - 1, ie = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, fe = ne || ie;
|
|
7497
7521
|
c.current.onCustomAction({
|
|
7498
7522
|
type: "lessonStart",
|
|
7499
7523
|
moduleIndex: r.current.currentModuleIndex,
|
|
7500
7524
|
lessonIndex: r.current.currentLessonIndex,
|
|
7501
|
-
hasNextLesson:
|
|
7525
|
+
hasNextLesson: fe
|
|
7502
7526
|
}), c.current.onLessonStart({
|
|
7503
7527
|
moduleIndex: r.current.currentModuleIndex,
|
|
7504
7528
|
lessonIndex: r.current.currentLessonIndex,
|
|
7505
|
-
lesson:
|
|
7529
|
+
lesson: R()
|
|
7506
7530
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7507
7531
|
} else
|
|
7508
7532
|
I.current && I.current();
|
|
7509
|
-
}, []),
|
|
7510
|
-
const b =
|
|
7511
|
-
let
|
|
7533
|
+
}, []), X = E(() => {
|
|
7534
|
+
const b = R();
|
|
7535
|
+
let v = null;
|
|
7512
7536
|
if (b?.avatar_script && b?.body) {
|
|
7513
|
-
const w = b.avatar_script.trim(), C = b.body.trim(),
|
|
7514
|
-
|
|
7537
|
+
const w = b.avatar_script.trim(), C = b.body.trim(), W = w.match(/[.!?]$/) ? " " : ". ";
|
|
7538
|
+
v = `${w}${W}${C}`;
|
|
7515
7539
|
} else
|
|
7516
|
-
|
|
7517
|
-
if (h.current && h.current.isReady &&
|
|
7540
|
+
v = b?.avatar_script || b?.body || null;
|
|
7541
|
+
if (h.current && h.current.isReady && v) {
|
|
7518
7542
|
r.current.isTeaching = !0, r.current.isQuestionMode = !1, r.current.score = 0, r.current.totalQuestions = 0, h.current.setMood("happy");
|
|
7519
7543
|
let w = !1;
|
|
7520
7544
|
if (e.teaching)
|
|
7521
7545
|
try {
|
|
7522
7546
|
h.current.playAnimation(e.teaching, !0), w = !0;
|
|
7523
|
-
} catch (
|
|
7524
|
-
console.warn("Failed to play teaching animation:",
|
|
7547
|
+
} catch (W) {
|
|
7548
|
+
console.warn("Failed to play teaching animation:", W);
|
|
7525
7549
|
}
|
|
7526
7550
|
w || h.current.setBodyMovement("gesturing");
|
|
7527
7551
|
const C = z.current || { lipsyncLang: "en" };
|
|
@@ -7534,7 +7558,7 @@ const ut = Ie(({
|
|
|
7534
7558
|
moduleIndex: r.current.currentModuleIndex,
|
|
7535
7559
|
lessonIndex: r.current.currentLessonIndex,
|
|
7536
7560
|
lesson: b
|
|
7537
|
-
}), h.current.speakText(
|
|
7561
|
+
}), h.current.speakText(v, {
|
|
7538
7562
|
lipsyncLang: C.lipsyncLang,
|
|
7539
7563
|
onSpeechEnd: () => {
|
|
7540
7564
|
r.current.isTeaching = !1, c.current.onCustomAction({
|
|
@@ -7547,15 +7571,15 @@ const ut = Ie(({
|
|
|
7547
7571
|
}
|
|
7548
7572
|
});
|
|
7549
7573
|
}
|
|
7550
|
-
}, [e.teaching,
|
|
7551
|
-
const
|
|
7574
|
+
}, [e.teaching, R]), j = E((b) => {
|
|
7575
|
+
const v = T(), w = P(b, v);
|
|
7552
7576
|
if (w && (r.current.score += 1), c.current.onQuestionAnswer({
|
|
7553
7577
|
moduleIndex: r.current.currentModuleIndex,
|
|
7554
7578
|
lessonIndex: r.current.currentLessonIndex,
|
|
7555
7579
|
questionIndex: r.current.currentQuestionIndex,
|
|
7556
7580
|
answer: b,
|
|
7557
7581
|
isCorrect: w,
|
|
7558
|
-
question:
|
|
7582
|
+
question: v
|
|
7559
7583
|
}), h.current)
|
|
7560
7584
|
if (w) {
|
|
7561
7585
|
if (h.current.setMood("happy"), e.correct)
|
|
@@ -7565,18 +7589,18 @@ const ut = Ie(({
|
|
|
7565
7589
|
h.current.setBodyMovement("happy");
|
|
7566
7590
|
}
|
|
7567
7591
|
h.current.setBodyMovement("gesturing");
|
|
7568
|
-
const C =
|
|
7592
|
+
const C = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, W = z.current || { lipsyncLang: "en" };
|
|
7569
7593
|
h.current.speakText(C, {
|
|
7570
|
-
lipsyncLang:
|
|
7594
|
+
lipsyncLang: W.lipsyncLang,
|
|
7571
7595
|
onSpeechEnd: () => {
|
|
7572
|
-
const
|
|
7596
|
+
const ie = R()?.questions?.length || 0;
|
|
7573
7597
|
c.current.onCustomAction({
|
|
7574
7598
|
type: "answerFeedbackComplete",
|
|
7575
7599
|
moduleIndex: r.current.currentModuleIndex,
|
|
7576
7600
|
lessonIndex: r.current.currentLessonIndex,
|
|
7577
7601
|
questionIndex: r.current.currentQuestionIndex,
|
|
7578
7602
|
isCorrect: !0,
|
|
7579
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7603
|
+
hasNextQuestion: r.current.currentQuestionIndex < ie - 1,
|
|
7580
7604
|
score: r.current.score,
|
|
7581
7605
|
totalQuestions: r.current.totalQuestions
|
|
7582
7606
|
});
|
|
@@ -7590,18 +7614,18 @@ const ut = Ie(({
|
|
|
7590
7614
|
h.current.setBodyMovement("idle");
|
|
7591
7615
|
}
|
|
7592
7616
|
h.current.setBodyMovement("gesturing");
|
|
7593
|
-
const C =
|
|
7617
|
+
const C = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""} Let's move on to the next question.`, W = z.current || { lipsyncLang: "en" };
|
|
7594
7618
|
h.current.speakText(C, {
|
|
7595
|
-
lipsyncLang:
|
|
7619
|
+
lipsyncLang: W.lipsyncLang,
|
|
7596
7620
|
onSpeechEnd: () => {
|
|
7597
|
-
const
|
|
7621
|
+
const ie = R()?.questions?.length || 0;
|
|
7598
7622
|
c.current.onCustomAction({
|
|
7599
7623
|
type: "answerFeedbackComplete",
|
|
7600
7624
|
moduleIndex: r.current.currentModuleIndex,
|
|
7601
7625
|
lessonIndex: r.current.currentLessonIndex,
|
|
7602
7626
|
questionIndex: r.current.currentQuestionIndex,
|
|
7603
7627
|
isCorrect: !1,
|
|
7604
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7628
|
+
hasNextQuestion: r.current.currentQuestionIndex < ie - 1,
|
|
7605
7629
|
score: r.current.score,
|
|
7606
7630
|
totalQuestions: r.current.totalQuestions
|
|
7607
7631
|
});
|
|
@@ -7609,26 +7633,26 @@ const ut = Ie(({
|
|
|
7609
7633
|
});
|
|
7610
7634
|
}
|
|
7611
7635
|
else {
|
|
7612
|
-
const
|
|
7636
|
+
const W = R()?.questions?.length || 0;
|
|
7613
7637
|
c.current.onCustomAction({
|
|
7614
7638
|
type: "answerFeedbackComplete",
|
|
7615
7639
|
moduleIndex: r.current.currentModuleIndex,
|
|
7616
7640
|
lessonIndex: r.current.currentLessonIndex,
|
|
7617
7641
|
questionIndex: r.current.currentQuestionIndex,
|
|
7618
7642
|
isCorrect: w,
|
|
7619
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7643
|
+
hasNextQuestion: r.current.currentQuestionIndex < W - 1,
|
|
7620
7644
|
score: r.current.score,
|
|
7621
7645
|
totalQuestions: r.current.totalQuestions,
|
|
7622
7646
|
avatarNotReady: !0
|
|
7623
7647
|
});
|
|
7624
7648
|
}
|
|
7625
|
-
}, [e.correct, e.incorrect,
|
|
7626
|
-
const
|
|
7649
|
+
}, [e.correct, e.incorrect, T, R, P]), _ = E((b) => {
|
|
7650
|
+
const v = T();
|
|
7627
7651
|
if (!b || typeof b != "object") {
|
|
7628
7652
|
console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
|
|
7629
7653
|
return;
|
|
7630
7654
|
}
|
|
7631
|
-
if (
|
|
7655
|
+
if (v?.type !== "code_test") {
|
|
7632
7656
|
console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
|
|
7633
7657
|
return;
|
|
7634
7658
|
}
|
|
@@ -7648,12 +7672,12 @@ const ut = Ie(({
|
|
|
7648
7672
|
lessonIndex: r.current.currentLessonIndex,
|
|
7649
7673
|
questionIndex: r.current.currentQuestionIndex,
|
|
7650
7674
|
testResult: w,
|
|
7651
|
-
question:
|
|
7675
|
+
question: v
|
|
7652
7676
|
}), p.current && p.current(w);
|
|
7653
|
-
}, [
|
|
7677
|
+
}, [T, P]), te = E(() => {
|
|
7654
7678
|
if (r.current.currentQuestionIndex > 0) {
|
|
7655
7679
|
r.current.currentQuestionIndex -= 1;
|
|
7656
|
-
const b =
|
|
7680
|
+
const b = T();
|
|
7657
7681
|
b && c.current.onCustomAction({
|
|
7658
7682
|
type: "questionStart",
|
|
7659
7683
|
moduleIndex: r.current.currentModuleIndex,
|
|
@@ -7663,7 +7687,7 @@ const ut = Ie(({
|
|
|
7663
7687
|
question: b,
|
|
7664
7688
|
score: r.current.score
|
|
7665
7689
|
});
|
|
7666
|
-
const
|
|
7690
|
+
const v = () => {
|
|
7667
7691
|
if (!h.current || !b) return;
|
|
7668
7692
|
h.current.setMood("happy"), h.current.setBodyMovement("idle");
|
|
7669
7693
|
const w = z.current || { lipsyncLang: "en" };
|
|
@@ -7674,17 +7698,17 @@ const ut = Ie(({
|
|
|
7674
7698
|
});
|
|
7675
7699
|
};
|
|
7676
7700
|
if (h.current && h.current.isReady && b)
|
|
7677
|
-
|
|
7701
|
+
v();
|
|
7678
7702
|
else if (b) {
|
|
7679
7703
|
const w = setInterval(() => {
|
|
7680
|
-
h.current && h.current.isReady && (clearInterval(w),
|
|
7704
|
+
h.current && h.current.isReady && (clearInterval(w), v());
|
|
7681
7705
|
}, 100);
|
|
7682
7706
|
setTimeout(() => {
|
|
7683
7707
|
clearInterval(w);
|
|
7684
7708
|
}, 5e3);
|
|
7685
7709
|
}
|
|
7686
7710
|
}
|
|
7687
|
-
}, [
|
|
7711
|
+
}, [T]), ce = E(() => {
|
|
7688
7712
|
const b = H.current || { modules: [] };
|
|
7689
7713
|
if (b.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
|
|
7690
7714
|
r.current.currentLessonIndex -= 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
|
|
@@ -7694,7 +7718,7 @@ const ut = Ie(({
|
|
|
7694
7718
|
}), c.current.onLessonStart({
|
|
7695
7719
|
moduleIndex: r.current.currentModuleIndex,
|
|
7696
7720
|
lessonIndex: r.current.currentLessonIndex,
|
|
7697
|
-
lesson:
|
|
7721
|
+
lesson: R()
|
|
7698
7722
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7699
7723
|
else if (r.current.currentModuleIndex > 0) {
|
|
7700
7724
|
const C = b.modules[r.current.currentModuleIndex - 1];
|
|
@@ -7705,53 +7729,53 @@ const ut = Ie(({
|
|
|
7705
7729
|
}), c.current.onLessonStart({
|
|
7706
7730
|
moduleIndex: r.current.currentModuleIndex,
|
|
7707
7731
|
lessonIndex: r.current.currentLessonIndex,
|
|
7708
|
-
lesson:
|
|
7732
|
+
lesson: R()
|
|
7709
7733
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7710
7734
|
}
|
|
7711
|
-
}, [
|
|
7735
|
+
}, [R]), oe = E(() => {
|
|
7712
7736
|
r.current.currentModuleIndex = 0, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.isTeaching = !1, r.current.isQuestionMode = !1, r.current.lessonCompleted = !1, r.current.curriculumCompleted = !1, r.current.score = 0, r.current.totalQuestions = 0;
|
|
7713
|
-
}, []),
|
|
7737
|
+
}, []), de = E((b) => {
|
|
7714
7738
|
console.log("Avatar is ready!", b);
|
|
7715
|
-
const
|
|
7739
|
+
const v = R(), w = v?.avatar_script || v?.body;
|
|
7716
7740
|
u && w && setTimeout(() => {
|
|
7717
7741
|
d.current && d.current();
|
|
7718
7742
|
}, 10);
|
|
7719
|
-
}, [u,
|
|
7720
|
-
|
|
7721
|
-
d.current =
|
|
7743
|
+
}, [u, R]);
|
|
7744
|
+
We(() => {
|
|
7745
|
+
d.current = X, g.current = Z, y.current = ee, x.current = N, I.current = re, D.current = S, p.current = j;
|
|
7722
7746
|
}), Le(a, () => ({
|
|
7723
7747
|
// Curriculum control methods
|
|
7724
|
-
startTeaching:
|
|
7748
|
+
startTeaching: X,
|
|
7725
7749
|
startQuestions: S,
|
|
7726
|
-
handleAnswerSelect:
|
|
7727
|
-
handleCodeTestResult:
|
|
7728
|
-
nextQuestion:
|
|
7729
|
-
previousQuestion:
|
|
7730
|
-
nextLesson:
|
|
7731
|
-
previousLesson:
|
|
7732
|
-
completeLesson:
|
|
7750
|
+
handleAnswerSelect: j,
|
|
7751
|
+
handleCodeTestResult: _,
|
|
7752
|
+
nextQuestion: N,
|
|
7753
|
+
previousQuestion: te,
|
|
7754
|
+
nextLesson: Z,
|
|
7755
|
+
previousLesson: ce,
|
|
7756
|
+
completeLesson: ee,
|
|
7733
7757
|
completeCurriculum: re,
|
|
7734
|
-
resetCurriculum:
|
|
7758
|
+
resetCurriculum: oe,
|
|
7735
7759
|
getState: () => ({ ...r.current }),
|
|
7736
|
-
getCurrentQuestion: () =>
|
|
7737
|
-
getCurrentLesson: () =>
|
|
7760
|
+
getCurrentQuestion: () => T(),
|
|
7761
|
+
getCurrentLesson: () => R(),
|
|
7738
7762
|
// Direct access to avatar ref (always returns current value)
|
|
7739
7763
|
getAvatarRef: () => h.current,
|
|
7740
7764
|
// Convenience methods that delegate to avatar (always check current ref)
|
|
7741
|
-
speakText: async (b,
|
|
7765
|
+
speakText: async (b, v = {}) => {
|
|
7742
7766
|
await h.current?.resumeAudioContext?.();
|
|
7743
7767
|
const w = z.current || { lipsyncLang: "en" };
|
|
7744
|
-
h.current?.speakText(b, { ...
|
|
7768
|
+
h.current?.speakText(b, { ...v, lipsyncLang: v.lipsyncLang || w.lipsyncLang });
|
|
7745
7769
|
},
|
|
7746
7770
|
resumeAudioContext: async () => {
|
|
7747
7771
|
if (h.current?.resumeAudioContext)
|
|
7748
7772
|
return await h.current.resumeAudioContext();
|
|
7749
7773
|
const b = h.current?.talkingHead;
|
|
7750
7774
|
if (b?.audioCtx) {
|
|
7751
|
-
const
|
|
7752
|
-
if (
|
|
7775
|
+
const v = b.audioCtx;
|
|
7776
|
+
if (v.state === "suspended" || v.state === "interrupted")
|
|
7753
7777
|
try {
|
|
7754
|
-
await
|
|
7778
|
+
await v.resume(), console.log("Audio context resumed via talkingHead");
|
|
7755
7779
|
} catch (w) {
|
|
7756
7780
|
console.warn("Failed to resume audio context:", w);
|
|
7757
7781
|
}
|
|
@@ -7763,7 +7787,7 @@ const ut = Ie(({
|
|
|
7763
7787
|
resumeSpeaking: async () => await h.current?.resumeSpeaking(),
|
|
7764
7788
|
isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
|
|
7765
7789
|
setMood: (b) => h.current?.setMood(b),
|
|
7766
|
-
playAnimation: (b,
|
|
7790
|
+
playAnimation: (b, v) => h.current?.playAnimation(b, v),
|
|
7767
7791
|
setBodyMovement: (b) => h.current?.setBodyMovement(b),
|
|
7768
7792
|
setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
|
|
7769
7793
|
playRandomDance: () => h.current?.playRandomDance(),
|
|
@@ -7774,10 +7798,10 @@ const ut = Ie(({
|
|
|
7774
7798
|
lockAvatarPosition: () => h.current?.lockAvatarPosition(),
|
|
7775
7799
|
unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
|
|
7776
7800
|
// Custom action trigger
|
|
7777
|
-
triggerCustomAction: (b,
|
|
7801
|
+
triggerCustomAction: (b, v) => {
|
|
7778
7802
|
c.current.onCustomAction({
|
|
7779
7803
|
type: b,
|
|
7780
|
-
...
|
|
7804
|
+
...v,
|
|
7781
7805
|
state: { ...r.current }
|
|
7782
7806
|
});
|
|
7783
7807
|
},
|
|
@@ -7785,8 +7809,8 @@ const ut = Ie(({
|
|
|
7785
7809
|
handleResize: () => h.current?.handleResize(),
|
|
7786
7810
|
// Avatar readiness check (always returns current value)
|
|
7787
7811
|
isAvatarReady: () => h.current?.isReady || !1
|
|
7788
|
-
}), [
|
|
7789
|
-
const
|
|
7812
|
+
}), [X, S, j, _, N, Z, ee, re, oe, T, R]);
|
|
7813
|
+
const J = z.current || {
|
|
7790
7814
|
avatarUrl: "/avatars/brunette.glb",
|
|
7791
7815
|
avatarBody: "F",
|
|
7792
7816
|
mood: "happy",
|
|
@@ -7803,19 +7827,19 @@ const ut = Ie(({
|
|
|
7803
7827
|
Pe,
|
|
7804
7828
|
{
|
|
7805
7829
|
ref: h,
|
|
7806
|
-
avatarUrl:
|
|
7807
|
-
avatarBody:
|
|
7808
|
-
mood:
|
|
7809
|
-
ttsLang:
|
|
7810
|
-
ttsService:
|
|
7811
|
-
ttsVoice:
|
|
7812
|
-
ttsApiKey:
|
|
7813
|
-
bodyMovement:
|
|
7814
|
-
movementIntensity:
|
|
7815
|
-
showFullAvatar:
|
|
7830
|
+
avatarUrl: J.avatarUrl,
|
|
7831
|
+
avatarBody: J.avatarBody,
|
|
7832
|
+
mood: J.mood,
|
|
7833
|
+
ttsLang: J.ttsLang,
|
|
7834
|
+
ttsService: J.ttsService,
|
|
7835
|
+
ttsVoice: J.ttsVoice,
|
|
7836
|
+
ttsApiKey: J.ttsApiKey,
|
|
7837
|
+
bodyMovement: J.bodyMovement,
|
|
7838
|
+
movementIntensity: J.movementIntensity,
|
|
7839
|
+
showFullAvatar: J.showFullAvatar,
|
|
7816
7840
|
cameraView: "upper",
|
|
7817
|
-
animations:
|
|
7818
|
-
onReady:
|
|
7841
|
+
animations: J.animations,
|
|
7842
|
+
onReady: de,
|
|
7819
7843
|
onLoading: () => {
|
|
7820
7844
|
},
|
|
7821
7845
|
onError: (b) => {
|
|
@@ -7824,7 +7848,7 @@ const ut = Ie(({
|
|
|
7824
7848
|
}
|
|
7825
7849
|
) });
|
|
7826
7850
|
});
|
|
7827
|
-
|
|
7851
|
+
ct.displayName = "CurriculumLearning";
|
|
7828
7852
|
const Be = {
|
|
7829
7853
|
// Code-based dance animations (no FBX required)
|
|
7830
7854
|
dance: {
|
|
@@ -7928,14 +7952,14 @@ const Be = {
|
|
|
7928
7952
|
duration: 5e3,
|
|
7929
7953
|
description: "Excited, energetic movement"
|
|
7930
7954
|
}
|
|
7931
|
-
},
|
|
7955
|
+
}, It = (O) => Be[O] || null, Lt = (O) => Be.hasOwnProperty(O);
|
|
7932
7956
|
export {
|
|
7933
|
-
|
|
7957
|
+
ct as CurriculumLearning,
|
|
7934
7958
|
Pe as TalkingHeadAvatar,
|
|
7935
|
-
|
|
7959
|
+
ut as TalkingHeadComponent,
|
|
7936
7960
|
Be as animations,
|
|
7937
7961
|
Ae as getActiveTTSConfig,
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7962
|
+
It as getAnimation,
|
|
7963
|
+
Rt as getVoiceOptions,
|
|
7964
|
+
Lt as hasAnimation
|
|
7941
7965
|
};
|