@sage-rsc/talking-head-react 1.0.65 → 1.0.67
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 +495 -478
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +35 -10
- package/src/components/TalkingHeadAvatar.jsx +58 -18
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as De, jsx as ge } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ze, useRef as N, useState as be, useEffect as ve, useCallback as M, useImperativeHandle as Ce, useLayoutEffect as Xe } from "react";
|
|
3
3
|
import * as f from "three";
|
|
4
|
-
import { OrbitControls as
|
|
5
|
-
import { GLTFLoader as
|
|
6
|
-
import { DRACOLoader as
|
|
7
|
-
import { FBXLoader as
|
|
8
|
-
import { RoomEnvironment as
|
|
9
|
-
import
|
|
10
|
-
let m,
|
|
11
|
-
const A = [0, 0, 0, 0], k = new f.Vector3(),
|
|
4
|
+
import { OrbitControls as Ye } from "three/addons/controls/OrbitControls.js";
|
|
5
|
+
import { GLTFLoader as je } from "three/addons/loaders/GLTFLoader.js";
|
|
6
|
+
import { DRACOLoader as Qe } from "three/addons/loaders/DRACOLoader.js";
|
|
7
|
+
import { FBXLoader as Me } from "three/addons/loaders/FBXLoader.js";
|
|
8
|
+
import { RoomEnvironment as qe } from "three/addons/environments/RoomEnvironment.js";
|
|
9
|
+
import _e from "three/addons/libs/stats.module.js";
|
|
10
|
+
let m, ee, ne;
|
|
11
|
+
const A = [0, 0, 0, 0], k = new f.Vector3(), Ae = new f.Vector3(), _ = new f.Vector3(), Se = new f.Vector3();
|
|
12
12
|
new f.Plane();
|
|
13
13
|
new f.Ray();
|
|
14
14
|
new f.Euler();
|
|
15
|
-
const
|
|
15
|
+
const K = new f.Quaternion(), Ee = new f.Quaternion(), le = new f.Matrix4(), he = new f.Matrix4();
|
|
16
16
|
new f.Vector3();
|
|
17
|
-
const
|
|
18
|
-
class
|
|
17
|
+
const ke = new f.Vector3(0, 0, 1), Ke = new f.Vector3(1, 0, 0), Je = new f.Vector3(0, 1, 0), $e = new f.Vector3(0, 0, 1);
|
|
18
|
+
class et {
|
|
19
19
|
constructor(t = null) {
|
|
20
20
|
this.opt = Object.assign({
|
|
21
21
|
warmupMs: 2e3,
|
|
@@ -338,7 +338,7 @@ class _e {
|
|
|
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, K, _), k.copy(ke).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ee.setFromUnitVectors(ke, k).invert()).normalize(), h.qWorldInverseYaw = K.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 _e {
|
|
|
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), le.copy(o.boneParent.matrixWorld), he.copy(le).invert(), o.vWorld.setFromMatrixPosition(le), k.applyMatrix4(he), 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
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
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
363
|
o.vBasis.x + A[0],
|
|
364
364
|
o.vBasis.y + A[1],
|
|
365
365
|
o.vBasis.z + A[2]
|
|
366
|
-
), k.applyMatrix4(
|
|
366
|
+
), k.applyMatrix4(le), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(he), 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
368
|
o.vBasis.x + A[0],
|
|
369
369
|
o.vBasis.y + A[1],
|
|
370
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, K, _), k.copy(ke).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ee.setFromUnitVectors(ke, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(K)), 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), K.setFromAxisAngle(Ke, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(K)), 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], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), he.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(he), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), ee = _.length(), !(ee > m.radius + ne) && (ee < Math.abs(m.radius - ne) || (ee = (ee * ee + ne * ne - m.radiusSq) / (2 * ee), _.normalize(), Se.copy(_).multiplyScalar(ee), ee = Math.sqrt(ne * ne - ee * ee), k.subVectors(k, Se).projectOnPlane(_).normalize().multiplyScalar(ee), Ae.subVectors(o.vBasis, Se).projectOnPlane(_).normalize(), ne = Ae.dot(k), ne < 0 && (ne = Math.sqrt(ee * ee - ne * ne), Ae.multiplyScalar(ne), k.add(Ae)), k.add(Se).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
|
|
375
375
|
}
|
|
376
376
|
this.helpers.isActive && this.updateHelpers();
|
|
377
377
|
}
|
|
@@ -442,17 +442,17 @@ class _e {
|
|
|
442
442
|
*/
|
|
443
443
|
updateHelpers() {
|
|
444
444
|
if (m = this.helpers.points, m.bones.length) {
|
|
445
|
-
|
|
445
|
+
he.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
|
+
le.multiplyMatrices(he, m.bones[e].matrixWorld), k.setFromMatrixPosition(le), 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
|
+
he.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
|
+
le.multiplyMatrices(he, m.bones[e].matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(n, k.x, k.y, k.z), le.multiplyMatrices(he, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(le), 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 _e {
|
|
|
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 tt {
|
|
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 Ke {
|
|
|
814
814
|
return i * s;
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
-
class
|
|
817
|
+
class nt {
|
|
818
818
|
/**
|
|
819
819
|
* @constructor
|
|
820
820
|
*/
|
|
@@ -1396,11 +1396,11 @@ class Je {
|
|
|
1396
1396
|
return e;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
const
|
|
1399
|
+
const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1400
1400
|
__proto__: null,
|
|
1401
|
-
LipsyncEn:
|
|
1401
|
+
LipsyncEn: nt
|
|
1402
1402
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1403
|
-
class
|
|
1403
|
+
class ot {
|
|
1404
1404
|
/**
|
|
1405
1405
|
* @constructor
|
|
1406
1406
|
*/
|
|
@@ -1754,11 +1754,11 @@ class et {
|
|
|
1754
1754
|
return e;
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
|
-
const
|
|
1757
|
+
const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1758
1758
|
__proto__: null,
|
|
1759
|
-
LipsyncDe:
|
|
1759
|
+
LipsyncDe: ot
|
|
1760
1760
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1761
|
-
class
|
|
1761
|
+
class at {
|
|
1762
1762
|
/**
|
|
1763
1763
|
* @constructor
|
|
1764
1764
|
*/
|
|
@@ -2289,11 +2289,11 @@ class nt {
|
|
|
2289
2289
|
return e;
|
|
2290
2290
|
}
|
|
2291
2291
|
}
|
|
2292
|
-
const
|
|
2292
|
+
const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2293
2293
|
__proto__: null,
|
|
2294
|
-
LipsyncFr:
|
|
2294
|
+
LipsyncFr: at
|
|
2295
2295
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2296
|
-
class
|
|
2296
|
+
class lt {
|
|
2297
2297
|
/**
|
|
2298
2298
|
* @constructor
|
|
2299
2299
|
*/
|
|
@@ -2436,11 +2436,11 @@ class ot {
|
|
|
2436
2436
|
return e;
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
const
|
|
2439
|
+
const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2440
2440
|
__proto__: null,
|
|
2441
|
-
LipsyncFi:
|
|
2441
|
+
LipsyncFi: lt
|
|
2442
2442
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2443
|
-
class
|
|
2443
|
+
class ut {
|
|
2444
2444
|
/**
|
|
2445
2445
|
* @constructor
|
|
2446
2446
|
*/
|
|
@@ -2620,24 +2620,24 @@ class at {
|
|
|
2620
2620
|
return e;
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
2623
|
-
const
|
|
2623
|
+
const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2624
2624
|
__proto__: null,
|
|
2625
|
-
LipsyncLt:
|
|
2626
|
-
}, Symbol.toStringTag, { value: "Module" })), lt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9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NzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cm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NpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETE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mV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Fe = {
|
|
2627
|
+
en: it,
|
|
2628
|
+
de: st,
|
|
2629
|
+
fr: rt,
|
|
2630
|
+
fi: ht,
|
|
2631
|
+
lt: ct
|
|
2632
|
+
}, G = new f.Quaternion(), E = new f.Euler(), ce = new f.Vector3(), pe = new f.Vector3(), Pe = 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 mt = new f.Vector3(1, 0, 0);
|
|
2638
2638
|
new f.Vector3(0, 1, 0);
|
|
2639
2639
|
new f.Vector3(0, 0, 1);
|
|
2640
|
-
class
|
|
2640
|
+
class Oe {
|
|
2641
2641
|
/**
|
|
2642
2642
|
* Avatar.
|
|
2643
2643
|
* @typedef {Object} Avatar
|
|
@@ -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 _e(), 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 qe()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ye(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 et(), 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 tt(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 je();
|
|
4232
4232
|
if (this.dracoEnabled) {
|
|
4233
|
-
const a = new
|
|
4233
|
+
const a = new Qe();
|
|
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
|
+
E.set(e.x, e.y, e.z);
|
|
4378
4378
|
const n = this.poseAvatar.props[t];
|
|
4379
|
-
n.isQuaternion ? (
|
|
4379
|
+
n.isQuaternion ? (G.setFromEuler(E), n.multiply(G)) : n.isVector3 && n.add(E);
|
|
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) && (E.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), E.x = Math.max(-0.9, Math.min(0.9, 2 * E.x - 0.5)), E.y = Math.max(-0.9, Math.min(0.9, -2.5 * E.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: E.x < 0 ? -E.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: E.x < 0 ? 0 : E.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: E.y < 0 ? -E.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 && (
|
|
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 && (G.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(G)), Pe.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(pe), pe.sub(this.armature.position), this.objectHips.position.y -= Pe.min.y / 2, this.objectHips.position.x -= (ce.x + pe.x) / 4, this.objectHips.position.z -= (ce.z + pe.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) {
|
|
@@ -5211,8 +5211,8 @@ class Fe {
|
|
|
5211
5211
|
if (!this.lipsync.hasOwnProperty(t)) {
|
|
5212
5212
|
const n = t.toLowerCase(), i = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
|
|
5213
5213
|
try {
|
|
5214
|
-
const s =
|
|
5215
|
-
s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(
|
|
5214
|
+
const s = Fe[n];
|
|
5215
|
+
s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Fe));
|
|
5216
5216
|
} catch (s) {
|
|
5217
5217
|
console.warn(`Failed to load lip-sync module for ${t}:`, s);
|
|
5218
5218
|
}
|
|
@@ -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, B = 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]), B && (!i || i.every((v) => x < v[0] || x > v[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 T =
|
|
5271
|
-
for (let
|
|
5268
|
+
const v = this.lipsyncWordsToVisemes(r, a);
|
|
5269
|
+
if (v && v.visemes && v.visemes.length) {
|
|
5270
|
+
const T = v.times[v.visemes.length - 1] + v.durations[v.visemes.length - 1];
|
|
5271
|
+
for (let F = 0; F < v.visemes.length; F++)
|
|
5272
5272
|
g.push({
|
|
5273
5273
|
mark: c,
|
|
5274
5274
|
template: { name: "viseme" },
|
|
5275
|
-
ts: [(
|
|
5275
|
+
ts: [(v.times[F] - 0.6) / T, (v.times[F] + 0.5) / T, (v.times[F] + v.durations[F] + 0.5) / T],
|
|
5276
5276
|
vs: {
|
|
5277
|
-
["viseme_" +
|
|
5277
|
+
["viseme_" + v.visemes[F]]: [null, v.visemes[F] === "PP" || v.visemes[F] === "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 v = {
|
|
5286
5286
|
anim: g
|
|
5287
5287
|
};
|
|
5288
|
-
n && (
|
|
5288
|
+
n && (v.onSubtitles = n), d.length && !e.avatarMute && (v.text = d, e.avatarMood && (v.mood = e.avatarMood), e.ttsLang && (v.lang = e.ttsLang), e.ttsVoice && (v.voice = e.ttsVoice), e.ttsRate && (v.rate = e.ttsRate), e.ttsVoice && (v.pitch = e.ttsPitch), e.ttsVolume && (v.volume = e.ttsVolume)), this.speechQueue.push(v), d = [], r = "", c = 0, g = [];
|
|
5289
5289
|
}
|
|
5290
5290
|
if (H) {
|
|
5291
|
-
let
|
|
5292
|
-
|
|
5291
|
+
let v = this.animEmojis[y[x]];
|
|
5292
|
+
v && v.link && (v = this.animEmojis[v.link]), v && this.speechQueue.push({ emoji: v });
|
|
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, B = 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 * B / 3), I + Math.min(25, B / 2), I + B + Math.min(60, B / 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], v = x.times[H] / p, T = x.durations[H] / p, F = v * c, J = T * c;
|
|
5490
5490
|
I.push({
|
|
5491
5491
|
template: { name: "viseme" },
|
|
5492
|
-
ts: [
|
|
5492
|
+
ts: [F - Math.min(60, 2 * J / 3), F + Math.min(25, J / 2), F + J + Math.min(60, J / 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 B = [...t.anim, ...I];
|
|
5500
|
+
this.audioPlaylist.push({ anim: B, 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(dt.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), ce.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), pe.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ce, pe).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), ce.setFromMatrixPosition(this.objectLeftEye.matrixWorld), pe.setFromMatrixPosition(this.objectRightEye.matrixWorld), ce.add(pe).divideScalar(2), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]);
|
|
6150
|
+
const n = new f.Vector3().subVectors(e, ce).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
|
|
6151
|
+
E.set(s, i, 0, "YXZ");
|
|
6152
|
+
const l = new f.Quaternion().setFromEuler(E), u = new f.Quaternion().copy(l).multiply(G.clone().invert());
|
|
6153
|
+
E.setFromQuaternion(u, "YXZ");
|
|
6154
|
+
let a = E.x / (40 / 24) + 0.2, h = E.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),
|
|
6190
|
-
let h =
|
|
6189
|
+
t === null && (t = u), e === null && (e = a), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]), E.setFromQuaternion(G);
|
|
6190
|
+
let h = E.x / (40 / 24), r = E.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 B = (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((v) => v.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 + B],
|
|
6201
6201
|
bodyRotateY: [I + p],
|
|
6202
|
-
eyesRotateX: [-3 *
|
|
6202
|
+
eyesRotateX: [-3 * B + 0.1],
|
|
6203
6203
|
eyesRotateY: [-5 * p],
|
|
6204
6204
|
browInnerUp: [[0, 0.7]],
|
|
6205
6205
|
mouthLeft: [[0, 0.7]],
|
|
@@ -6403,7 +6403,7 @@ class Fe {
|
|
|
6403
6403
|
} catch (c) {
|
|
6404
6404
|
console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, c);
|
|
6405
6405
|
}
|
|
6406
|
-
const h = new
|
|
6406
|
+
const h = new Me();
|
|
6407
6407
|
let r;
|
|
6408
6408
|
try {
|
|
6409
6409
|
r = await h.loadAsync(t, e);
|
|
@@ -6480,7 +6480,7 @@ class Fe {
|
|
|
6480
6480
|
let l = this.animQueue.find((u) => u.template.name === "pose");
|
|
6481
6481
|
l && (l.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(o);
|
|
6482
6482
|
} else {
|
|
6483
|
-
let u = await new
|
|
6483
|
+
let u = await new Me().loadAsync(t, e);
|
|
6484
6484
|
if (u && u.animations && u.animations[i]) {
|
|
6485
6485
|
let a = u.animations[i];
|
|
6486
6486
|
const h = {};
|
|
@@ -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 B = !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 v = s.dot(l);
|
|
6585
|
+
v > 1 ? v = 1 : v < -1 && (v = -1), v = Math.acos(v), !(v < 1e-5) && (y[p].minAngle !== void 0 && v < y[p].minAngle && (v = y[p].minAngle), y[p].maxAngle !== void 0 && v > y[p].maxAngle && (v = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), G.setFromAxisAngle(r, v), z.quaternion.multiply(G), 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), B = !0);
|
|
6594
6594
|
}
|
|
6595
|
-
if (!
|
|
6595
|
+
if (!B) 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 Re = {
|
|
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",
|
|
@@ -6625,7 +6625,7 @@ const ye = {
|
|
|
6625
6625
|
josh: "VR6AewLTigWG4xSOukaG"
|
|
6626
6626
|
// Male, American
|
|
6627
6627
|
}
|
|
6628
|
-
},
|
|
6628
|
+
}, Be = {
|
|
6629
6629
|
defaultVoice: "aura-2-thalia-en",
|
|
6630
6630
|
// Thalia (Female, English)
|
|
6631
6631
|
voices: {
|
|
@@ -6645,26 +6645,26 @@ const ye = {
|
|
|
6645
6645
|
// Male, English - Powerful
|
|
6646
6646
|
}
|
|
6647
6647
|
};
|
|
6648
|
-
function
|
|
6648
|
+
function He() {
|
|
6649
6649
|
return {
|
|
6650
6650
|
service: "elevenlabs",
|
|
6651
|
-
endpoint:
|
|
6652
|
-
apiKey:
|
|
6653
|
-
defaultVoice:
|
|
6654
|
-
voices:
|
|
6651
|
+
endpoint: Re.endpoint,
|
|
6652
|
+
apiKey: Re.apiKey,
|
|
6653
|
+
defaultVoice: Re.defaultVoice,
|
|
6654
|
+
voices: Re.voices
|
|
6655
6655
|
};
|
|
6656
6656
|
}
|
|
6657
|
-
function
|
|
6658
|
-
const
|
|
6659
|
-
return Object.entries(
|
|
6657
|
+
function St() {
|
|
6658
|
+
const U = He(), t = [];
|
|
6659
|
+
return Object.entries(U.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)} (${U.service})`
|
|
6663
6663
|
});
|
|
6664
6664
|
}), t;
|
|
6665
6665
|
}
|
|
6666
|
-
const
|
|
6667
|
-
avatarUrl:
|
|
6666
|
+
const Ne = ze(({
|
|
6667
|
+
avatarUrl: U = "/avatars/brunette.glb",
|
|
6668
6668
|
avatarBody: t = "F",
|
|
6669
6669
|
mood: e = "neutral",
|
|
6670
6670
|
ttsLang: n = "en",
|
|
@@ -6685,256 +6685,261 @@ const Pe = Ie(({
|
|
|
6685
6685
|
style: y = {},
|
|
6686
6686
|
animations: x = {}
|
|
6687
6687
|
}, I) => {
|
|
6688
|
-
const
|
|
6689
|
-
|
|
6690
|
-
T.current =
|
|
6691
|
-
}, [
|
|
6688
|
+
const B = N(null), p = N(null), H = N(a), z = N(null), v = N(null), T = N(!1), F = N({ remainingText: null, originalText: null, options: null }), J = N([]), ye = N(0), [S, W] = be(!0), [Y, Z] = be(null), [$, se] = be(!1), [de, me] = be(!1);
|
|
6689
|
+
ve(() => {
|
|
6690
|
+
T.current = de;
|
|
6691
|
+
}, [de]), ve(() => {
|
|
6692
6692
|
H.current = a;
|
|
6693
6693
|
}, [a]);
|
|
6694
|
-
const
|
|
6695
|
-
let
|
|
6696
|
-
|
|
6694
|
+
const ie = He(), fe = i || ie.service;
|
|
6695
|
+
let X;
|
|
6696
|
+
fe === "browser" ? X = {
|
|
6697
6697
|
service: "browser",
|
|
6698
6698
|
endpoint: "",
|
|
6699
6699
|
apiKey: null,
|
|
6700
6700
|
defaultVoice: "Google US English"
|
|
6701
|
-
} :
|
|
6701
|
+
} : fe === "elevenlabs" ? X = {
|
|
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 || ie.apiKey,
|
|
6705
|
+
defaultVoice: s || ie.defaultVoice || Re.defaultVoice,
|
|
6706
|
+
voices: ie.voices || Re.voices
|
|
6707
|
+
} : fe === "deepgram" ? X = {
|
|
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 || ie.apiKey,
|
|
6711
|
+
defaultVoice: s || ie.defaultVoice || Be.defaultVoice,
|
|
6712
|
+
voices: ie.voices || Be.voices
|
|
6713
|
+
} : X = {
|
|
6714
|
+
...ie,
|
|
6715
6715
|
// Override API key if provided via props
|
|
6716
|
-
apiKey: o !== null ? o :
|
|
6716
|
+
apiKey: o !== null ? o : ie.apiKey
|
|
6717
6717
|
};
|
|
6718
|
-
const
|
|
6719
|
-
url:
|
|
6718
|
+
const b = {
|
|
6719
|
+
url: U,
|
|
6720
6720
|
body: t,
|
|
6721
6721
|
avatarMood: e,
|
|
6722
|
-
ttsLang:
|
|
6723
|
-
ttsVoice: s ||
|
|
6722
|
+
ttsLang: fe === "browser" ? "en-US" : n,
|
|
6723
|
+
ttsVoice: s || X.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
|
+
}, R = {
|
|
6729
|
+
ttsEndpoint: X.endpoint,
|
|
6730
|
+
ttsApikey: X.apiKey,
|
|
6731
|
+
ttsService: fe,
|
|
6732
6732
|
lipsyncModules: ["en"],
|
|
6733
6733
|
cameraView: h
|
|
6734
|
-
},
|
|
6735
|
-
if (!(!
|
|
6734
|
+
}, w = M(async () => {
|
|
6735
|
+
if (!(!B.current || p.current))
|
|
6736
6736
|
try {
|
|
6737
|
-
if (
|
|
6738
|
-
if (
|
|
6739
|
-
const
|
|
6740
|
-
c(
|
|
6737
|
+
if (W(!0), Z(null), p.current = new Oe(B.current, R), 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(b, (V) => {
|
|
6738
|
+
if (V.lengthComputable) {
|
|
6739
|
+
const Q = Math.min(100, Math.round(V.loaded / V.total * 100));
|
|
6740
|
+
c(Q);
|
|
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 Q = () => {
|
|
6744
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? V() : setTimeout(Q, 100);
|
|
6745
6745
|
};
|
|
6746
|
-
|
|
6746
|
+
Q();
|
|
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()),
|
|
6754
|
-
const
|
|
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()), W(!1), se(!0), r(p.current);
|
|
6754
|
+
const P = () => {
|
|
6755
6755
|
document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
|
|
6756
6756
|
};
|
|
6757
|
-
return document.addEventListener("visibilitychange",
|
|
6758
|
-
document.removeEventListener("visibilitychange",
|
|
6757
|
+
return document.addEventListener("visibilitychange", P), () => {
|
|
6758
|
+
document.removeEventListener("visibilitychange", P);
|
|
6759
6759
|
};
|
|
6760
6760
|
} catch (L) {
|
|
6761
|
-
console.error("Error initializing TalkingHead:", L),
|
|
6761
|
+
console.error("Error initializing TalkingHead:", L), Z(L.message || "Failed to initialize avatar"), W(!1), d(L);
|
|
6762
6762
|
}
|
|
6763
|
-
}, [
|
|
6764
|
-
|
|
6763
|
+
}, [U, t, e, n, i, s, o, a, l, u, h]);
|
|
6764
|
+
ve(() => (w(), () => {
|
|
6765
6765
|
p.current && (p.current.stop(), p.current.dispose(), p.current = null);
|
|
6766
|
-
}), [
|
|
6767
|
-
if (!
|
|
6768
|
-
const L = new ResizeObserver((
|
|
6769
|
-
for (const
|
|
6766
|
+
}), [w]), ve(() => {
|
|
6767
|
+
if (!B.current || !p.current) return;
|
|
6768
|
+
const L = new ResizeObserver((V) => {
|
|
6769
|
+
for (const Q of V)
|
|
6770
6770
|
p.current && p.current.onResize && p.current.onResize();
|
|
6771
6771
|
});
|
|
6772
|
-
L.observe(
|
|
6773
|
-
const
|
|
6772
|
+
L.observe(B.current);
|
|
6773
|
+
const P = () => {
|
|
6774
6774
|
p.current && p.current.onResize && p.current.onResize();
|
|
6775
6775
|
};
|
|
6776
|
-
return window.addEventListener("resize",
|
|
6777
|
-
L.disconnect(), window.removeEventListener("resize",
|
|
6776
|
+
return window.addEventListener("resize", P), () => {
|
|
6777
|
+
L.disconnect(), window.removeEventListener("resize", P);
|
|
6778
6778
|
};
|
|
6779
|
-
}, [
|
|
6780
|
-
const
|
|
6779
|
+
}, [$]);
|
|
6780
|
+
const C = M(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
6784
|
} catch (L) {
|
|
6785
6785
|
console.warn("Failed to resume audio context:", L);
|
|
6786
6786
|
}
|
|
6787
|
-
}, []),
|
|
6788
|
-
if (p.current &&
|
|
6787
|
+
}, []), D = M(async (L, P = {}) => {
|
|
6788
|
+
if (p.current && $)
|
|
6789
6789
|
try {
|
|
6790
|
-
|
|
6791
|
-
const
|
|
6792
|
-
|
|
6793
|
-
|
|
6790
|
+
v.current && (clearInterval(v.current), v.current = null), z.current = { text: L, options: P }, F.current = { remainingText: null, originalText: null, options: null };
|
|
6791
|
+
const V = /[!\.\?\n\p{Extended_Pictographic}]/ug, Q = L.split(V).map((O) => O.trim()).filter((O) => O.length > 0);
|
|
6792
|
+
J.current = Q, ye.current = 0, me(!1), T.current = !1, await C();
|
|
6793
|
+
const ae = {
|
|
6794
|
+
...P,
|
|
6795
|
+
lipsyncLang: P.lipsyncLang || b.lipsyncLang || "en"
|
|
6794
6796
|
};
|
|
6795
|
-
if (
|
|
6796
|
-
const
|
|
6797
|
-
let
|
|
6798
|
-
const
|
|
6799
|
-
let
|
|
6800
|
-
|
|
6801
|
-
if (
|
|
6797
|
+
if (P.onSpeechEnd && p.current) {
|
|
6798
|
+
const O = p.current;
|
|
6799
|
+
let oe = null, Ie = 0;
|
|
6800
|
+
const xe = 1200;
|
|
6801
|
+
let ue = !1;
|
|
6802
|
+
oe = setInterval(() => {
|
|
6803
|
+
if (Ie++, T.current)
|
|
6802
6804
|
return;
|
|
6803
|
-
if (
|
|
6804
|
-
if (
|
|
6805
|
-
|
|
6805
|
+
if (Ie > xe) {
|
|
6806
|
+
if (oe && (clearInterval(oe), oe = null, v.current = null), !ue && !T.current) {
|
|
6807
|
+
ue = !0;
|
|
6806
6808
|
try {
|
|
6807
|
-
|
|
6808
|
-
} catch (
|
|
6809
|
-
console.error("Error in onSpeechEnd callback (timeout):",
|
|
6809
|
+
P.onSpeechEnd();
|
|
6810
|
+
} catch (Te) {
|
|
6811
|
+
console.error("Error in onSpeechEnd callback (timeout):", Te);
|
|
6810
6812
|
}
|
|
6811
6813
|
}
|
|
6812
6814
|
return;
|
|
6813
6815
|
}
|
|
6814
|
-
const
|
|
6815
|
-
|
|
6816
|
-
if (
|
|
6817
|
-
|
|
6816
|
+
const re = !O.speechQueue || O.speechQueue.length === 0, Le = !O.audioPlaylist || O.audioPlaylist.length === 0;
|
|
6817
|
+
O && O.isSpeaking === !1 && re && Le && O.isAudioPlaying === !1 && !ue && !T.current && setTimeout(() => {
|
|
6818
|
+
if (O && !T.current && O.isSpeaking === !1 && (!O.speechQueue || O.speechQueue.length === 0) && (!O.audioPlaylist || O.audioPlaylist.length === 0) && O.isAudioPlaying === !1 && !ue && !T.current) {
|
|
6819
|
+
ue = !0, oe && (clearInterval(oe), oe = null, v.current = null);
|
|
6818
6820
|
try {
|
|
6819
|
-
|
|
6820
|
-
} catch (
|
|
6821
|
-
console.error("Error in onSpeechEnd callback:",
|
|
6821
|
+
P.onSpeechEnd();
|
|
6822
|
+
} catch (Ze) {
|
|
6823
|
+
console.error("Error in onSpeechEnd callback:", Ze);
|
|
6822
6824
|
}
|
|
6823
6825
|
}
|
|
6824
6826
|
}, 100);
|
|
6825
|
-
}, 100),
|
|
6827
|
+
}, 100), v.current = oe;
|
|
6826
6828
|
}
|
|
6827
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L,
|
|
6828
|
-
await
|
|
6829
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae)) : setTimeout(async () => {
|
|
6830
|
+
await C(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae));
|
|
6829
6831
|
}, 100);
|
|
6830
|
-
} catch (
|
|
6831
|
-
console.error("Error speaking text:",
|
|
6832
|
+
} catch (V) {
|
|
6833
|
+
console.error("Error speaking text:", V), Z(V.message || "Failed to speak text");
|
|
6832
6834
|
}
|
|
6833
|
-
}, [
|
|
6834
|
-
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null,
|
|
6835
|
-
}, []),
|
|
6835
|
+
}, [$, C, b.lipsyncLang]), te = M(() => {
|
|
6836
|
+
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, me(!1));
|
|
6837
|
+
}, []), q = M(() => {
|
|
6836
6838
|
if (p.current && p.current.pauseSpeaking) {
|
|
6837
6839
|
const L = p.current;
|
|
6838
6840
|
if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
|
|
6839
|
-
|
|
6840
|
-
let
|
|
6841
|
-
if (
|
|
6842
|
-
const
|
|
6843
|
-
|
|
6841
|
+
v.current && (clearInterval(v.current), v.current = null);
|
|
6842
|
+
let V = "";
|
|
6843
|
+
if (z.current && J.current.length > 0) {
|
|
6844
|
+
const Q = J.current.length, ae = L.speechQueue ? L.speechQueue.filter((xe) => xe && xe.text && Array.isArray(xe.text) && xe.text.length > 0).length : 0, O = L.audioPlaylist && L.audioPlaylist.length > 0, oe = ae + (O ? 1 : 0), Ie = Q - oe;
|
|
6845
|
+
if (oe > 0 && Ie < Q && (V = J.current.slice(Ie).join(". ").trim(), !V && ae > 0 && L.speechQueue)) {
|
|
6846
|
+
const ue = L.speechQueue.filter((re) => re && re.text && Array.isArray(re.text) && re.text.length > 0).map((re) => re.text.map((Le) => Le.word || "").filter((Le) => Le.length > 0).join(" ")).filter((re) => re.length > 0).join(" ");
|
|
6847
|
+
ue && ue.trim() && (V = ue.trim());
|
|
6848
|
+
}
|
|
6844
6849
|
}
|
|
6845
|
-
z.current && (
|
|
6846
|
-
remainingText:
|
|
6850
|
+
z.current && (F.current = {
|
|
6851
|
+
remainingText: V || null,
|
|
6847
6852
|
originalText: z.current.text,
|
|
6848
6853
|
options: z.current.options
|
|
6849
|
-
}), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0,
|
|
6854
|
+
}), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, me(!0);
|
|
6850
6855
|
}
|
|
6851
6856
|
}
|
|
6852
|
-
}, []),
|
|
6853
|
-
if (!p.current || !
|
|
6857
|
+
}, []), j = M(async () => {
|
|
6858
|
+
if (!p.current || !de)
|
|
6854
6859
|
return;
|
|
6855
|
-
let L = "",
|
|
6856
|
-
if (
|
|
6857
|
-
L =
|
|
6860
|
+
let L = "", P = {};
|
|
6861
|
+
if (F.current && F.current.remainingText)
|
|
6862
|
+
L = F.current.remainingText, P = F.current.options || {}, F.current = { remainingText: null, originalText: null, options: null };
|
|
6858
6863
|
else if (z.current && z.current.text)
|
|
6859
|
-
L = z.current.text,
|
|
6864
|
+
L = z.current.text, P = z.current.options || {};
|
|
6860
6865
|
else {
|
|
6861
|
-
console.warn("Resume called but no paused speech found"),
|
|
6866
|
+
console.warn("Resume called but no paused speech found"), me(!1), T.current = !1;
|
|
6862
6867
|
return;
|
|
6863
6868
|
}
|
|
6864
|
-
|
|
6865
|
-
const
|
|
6866
|
-
...
|
|
6867
|
-
lipsyncLang:
|
|
6869
|
+
me(!1), T.current = !1, await C();
|
|
6870
|
+
const V = {
|
|
6871
|
+
...P,
|
|
6872
|
+
lipsyncLang: P.lipsyncLang || b.lipsyncLang || "en"
|
|
6868
6873
|
};
|
|
6869
6874
|
try {
|
|
6870
|
-
await
|
|
6871
|
-
} catch (
|
|
6872
|
-
console.error("Error resuming speech:",
|
|
6875
|
+
await D(L, V);
|
|
6876
|
+
} catch (Q) {
|
|
6877
|
+
console.error("Error resuming speech:", Q), me(!1), T.current = !1;
|
|
6873
6878
|
}
|
|
6874
|
-
}, [
|
|
6879
|
+
}, [C, de, D, b]), we = M((L) => {
|
|
6875
6880
|
p.current && p.current.setMood(L);
|
|
6876
|
-
}, []),
|
|
6881
|
+
}, []), We = M((L) => {
|
|
6877
6882
|
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
|
|
6878
|
-
}, []),
|
|
6883
|
+
}, []), Ve = M((L, P = !1) => {
|
|
6879
6884
|
if (p.current && p.current.playAnimation) {
|
|
6880
6885
|
if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
|
|
6881
6886
|
try {
|
|
6882
6887
|
p.current.setShowFullAvatar(H.current);
|
|
6883
|
-
} catch (
|
|
6884
|
-
console.warn("Error setting full body mode:",
|
|
6888
|
+
} catch (Q) {
|
|
6889
|
+
console.warn("Error setting full body mode:", Q);
|
|
6885
6890
|
}
|
|
6886
6891
|
if (L.includes("."))
|
|
6887
6892
|
try {
|
|
6888
|
-
p.current.playAnimation(L, null, 10, 0, 0.01,
|
|
6889
|
-
} catch (
|
|
6890
|
-
console.warn(`Failed to play ${L}:`,
|
|
6893
|
+
p.current.playAnimation(L, null, 10, 0, 0.01, P);
|
|
6894
|
+
} catch (Q) {
|
|
6895
|
+
console.warn(`Failed to play ${L}:`, Q);
|
|
6891
6896
|
try {
|
|
6892
6897
|
p.current.setBodyMovement("idle");
|
|
6893
|
-
} catch (
|
|
6894
|
-
console.warn("Fallback animation also failed:",
|
|
6898
|
+
} catch (ae) {
|
|
6899
|
+
console.warn("Fallback animation also failed:", ae);
|
|
6895
6900
|
}
|
|
6896
6901
|
}
|
|
6897
6902
|
else {
|
|
6898
|
-
const
|
|
6899
|
-
let
|
|
6900
|
-
for (const
|
|
6903
|
+
const Q = [".fbx", ".glb", ".gltf"];
|
|
6904
|
+
let ae = !1;
|
|
6905
|
+
for (const O of Q)
|
|
6901
6906
|
try {
|
|
6902
|
-
p.current.playAnimation(L +
|
|
6907
|
+
p.current.playAnimation(L + O, null, 10, 0, 0.01, P), ae = !0;
|
|
6903
6908
|
break;
|
|
6904
6909
|
} catch {
|
|
6905
6910
|
}
|
|
6906
|
-
if (!
|
|
6911
|
+
if (!ae) {
|
|
6907
6912
|
console.warn("Animation not found:", L);
|
|
6908
6913
|
try {
|
|
6909
6914
|
p.current.setBodyMovement("idle");
|
|
6910
|
-
} catch (
|
|
6911
|
-
console.warn("Fallback animation also failed:",
|
|
6915
|
+
} catch (O) {
|
|
6916
|
+
console.warn("Fallback animation also failed:", O);
|
|
6912
6917
|
}
|
|
6913
6918
|
}
|
|
6914
6919
|
}
|
|
6915
6920
|
}
|
|
6916
|
-
}, [x]),
|
|
6921
|
+
}, [x]), Ge = M(() => {
|
|
6917
6922
|
p.current && p.current.onResize && p.current.onResize();
|
|
6918
6923
|
}, []);
|
|
6919
|
-
return
|
|
6920
|
-
speakText:
|
|
6921
|
-
stopSpeaking:
|
|
6922
|
-
pauseSpeaking:
|
|
6923
|
-
resumeSpeaking:
|
|
6924
|
-
resumeAudioContext:
|
|
6925
|
-
setMood:
|
|
6926
|
-
setTimingAdjustment:
|
|
6927
|
-
playAnimation:
|
|
6928
|
-
isReady:
|
|
6929
|
-
isPaused:
|
|
6924
|
+
return Ce(I, () => ({
|
|
6925
|
+
speakText: D,
|
|
6926
|
+
stopSpeaking: te,
|
|
6927
|
+
pauseSpeaking: q,
|
|
6928
|
+
resumeSpeaking: j,
|
|
6929
|
+
resumeAudioContext: C,
|
|
6930
|
+
setMood: we,
|
|
6931
|
+
setTimingAdjustment: We,
|
|
6932
|
+
playAnimation: Ve,
|
|
6933
|
+
isReady: $,
|
|
6934
|
+
isPaused: de,
|
|
6930
6935
|
talkingHead: p.current,
|
|
6931
|
-
handleResize:
|
|
6936
|
+
handleResize: Ge,
|
|
6932
6937
|
setBodyMovement: (L) => {
|
|
6933
6938
|
if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
|
|
6934
6939
|
try {
|
|
6935
6940
|
p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(L);
|
|
6936
|
-
} catch (
|
|
6937
|
-
console.warn("Error setting body movement:",
|
|
6941
|
+
} catch (P) {
|
|
6942
|
+
console.warn("Error setting body movement:", P);
|
|
6938
6943
|
}
|
|
6939
6944
|
},
|
|
6940
6945
|
setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
|
|
@@ -6950,8 +6955,8 @@ const Pe = Ie(({
|
|
|
6950
6955
|
if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
|
|
6951
6956
|
try {
|
|
6952
6957
|
p.current.setShowFullAvatar(H.current), p.current.playReaction(L);
|
|
6953
|
-
} catch (
|
|
6954
|
-
console.warn("Error playing reaction:",
|
|
6958
|
+
} catch (P) {
|
|
6959
|
+
console.warn("Error playing reaction:", P);
|
|
6955
6960
|
}
|
|
6956
6961
|
},
|
|
6957
6962
|
playCelebration: () => {
|
|
@@ -6966,8 +6971,8 @@ const Pe = Ie(({
|
|
|
6966
6971
|
if (p.current && p.current.setShowFullAvatar)
|
|
6967
6972
|
try {
|
|
6968
6973
|
H.current = L, p.current.setShowFullAvatar(L);
|
|
6969
|
-
} catch (
|
|
6970
|
-
console.warn("Error setting showFullAvatar:",
|
|
6974
|
+
} catch (P) {
|
|
6975
|
+
console.warn("Error setting showFullAvatar:", P);
|
|
6971
6976
|
}
|
|
6972
6977
|
},
|
|
6973
6978
|
lockAvatarPosition: () => {
|
|
@@ -6986,7 +6991,7 @@ const Pe = Ie(({
|
|
|
6986
6991
|
console.warn("Error unlocking avatar position:", L);
|
|
6987
6992
|
}
|
|
6988
6993
|
}
|
|
6989
|
-
})), /* @__PURE__ */
|
|
6994
|
+
})), /* @__PURE__ */ De(
|
|
6990
6995
|
"div",
|
|
6991
6996
|
{
|
|
6992
6997
|
className: `talking-head-avatar ${g}`,
|
|
@@ -6997,10 +7002,10 @@ const Pe = Ie(({
|
|
|
6997
7002
|
...y
|
|
6998
7003
|
},
|
|
6999
7004
|
children: [
|
|
7000
|
-
/* @__PURE__ */
|
|
7005
|
+
/* @__PURE__ */ ge(
|
|
7001
7006
|
"div",
|
|
7002
7007
|
{
|
|
7003
|
-
ref:
|
|
7008
|
+
ref: B,
|
|
7004
7009
|
className: "talking-head-viewer",
|
|
7005
7010
|
style: {
|
|
7006
7011
|
width: "100%",
|
|
@@ -7009,7 +7014,7 @@ const Pe = Ie(({
|
|
|
7009
7014
|
}
|
|
7010
7015
|
}
|
|
7011
7016
|
),
|
|
7012
|
-
|
|
7017
|
+
S && /* @__PURE__ */ ge("div", { className: "loading-overlay", style: {
|
|
7013
7018
|
position: "absolute",
|
|
7014
7019
|
top: "50%",
|
|
7015
7020
|
left: "50%",
|
|
@@ -7018,7 +7023,7 @@ const Pe = Ie(({
|
|
|
7018
7023
|
fontSize: "18px",
|
|
7019
7024
|
zIndex: 10
|
|
7020
7025
|
}, children: "Loading avatar..." }),
|
|
7021
|
-
|
|
7026
|
+
Y && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
|
|
7022
7027
|
position: "absolute",
|
|
7023
7028
|
top: "50%",
|
|
7024
7029
|
left: "50%",
|
|
@@ -7029,14 +7034,14 @@ const Pe = Ie(({
|
|
|
7029
7034
|
zIndex: 10,
|
|
7030
7035
|
padding: "20px",
|
|
7031
7036
|
borderRadius: "8px"
|
|
7032
|
-
}, children:
|
|
7037
|
+
}, children: Y })
|
|
7033
7038
|
]
|
|
7034
7039
|
}
|
|
7035
7040
|
);
|
|
7036
7041
|
});
|
|
7037
|
-
|
|
7038
|
-
const
|
|
7039
|
-
text:
|
|
7042
|
+
Ne.displayName = "TalkingHeadAvatar";
|
|
7043
|
+
const pt = ze(({
|
|
7044
|
+
text: U = "Hello! I'm a talking avatar. How are you today?",
|
|
7040
7045
|
onLoading: t = () => {
|
|
7041
7046
|
},
|
|
7042
7047
|
onError: e = () => {
|
|
@@ -7047,7 +7052,7 @@ const ut = Ie(({
|
|
|
7047
7052
|
style: s = {},
|
|
7048
7053
|
avatarConfig: o = {}
|
|
7049
7054
|
}, l) => {
|
|
7050
|
-
const u =
|
|
7055
|
+
const u = N(null), a = N(null), [h, r] = be(!0), [c, d] = be(null), [g, y] = be(!1), x = He(), I = o.ttsService || x.service, B = I === "browser" ? {
|
|
7051
7056
|
endpoint: "",
|
|
7052
7057
|
apiKey: null,
|
|
7053
7058
|
defaultVoice: "Google US English"
|
|
@@ -7063,7 +7068,7 @@ const ut = Ie(({
|
|
|
7063
7068
|
body: "F",
|
|
7064
7069
|
avatarMood: "neutral",
|
|
7065
7070
|
ttsLang: I === "browser" ? "en-US" : "en",
|
|
7066
|
-
ttsVoice: o.ttsVoice ||
|
|
7071
|
+
ttsVoice: o.ttsVoice || B.defaultVoice,
|
|
7067
7072
|
lipsyncLang: "en",
|
|
7068
7073
|
// English lip-sync
|
|
7069
7074
|
showFullAvatar: !0,
|
|
@@ -7072,122 +7077,122 @@ const ut = Ie(({
|
|
|
7072
7077
|
movementIntensity: 0.5,
|
|
7073
7078
|
...o
|
|
7074
7079
|
}, H = {
|
|
7075
|
-
ttsEndpoint:
|
|
7076
|
-
ttsApikey:
|
|
7080
|
+
ttsEndpoint: B.endpoint,
|
|
7081
|
+
ttsApikey: B.apiKey,
|
|
7077
7082
|
ttsService: I,
|
|
7078
7083
|
lipsyncModules: ["en"],
|
|
7079
7084
|
cameraView: "upper"
|
|
7080
|
-
}, z =
|
|
7085
|
+
}, z = M(async () => {
|
|
7081
7086
|
if (!(!u.current || a.current))
|
|
7082
7087
|
try {
|
|
7083
|
-
if (r(!0), d(null), a.current = new
|
|
7084
|
-
if (
|
|
7085
|
-
const
|
|
7086
|
-
t(
|
|
7088
|
+
if (r(!0), d(null), a.current = new Oe(u.current, H), await a.current.showAvatar(p, (Y) => {
|
|
7089
|
+
if (Y.lengthComputable) {
|
|
7090
|
+
const Z = Math.min(100, Math.round(Y.loaded / Y.total * 100));
|
|
7091
|
+
t(Z);
|
|
7087
7092
|
}
|
|
7088
7093
|
}), a.current.morphs && a.current.morphs.length > 0) {
|
|
7089
|
-
const
|
|
7090
|
-
console.log("Available morph targets:", Object.keys(
|
|
7091
|
-
const
|
|
7092
|
-
console.log("Viseme morph targets found:",
|
|
7094
|
+
const Y = a.current.morphs[0].morphTargetDictionary;
|
|
7095
|
+
console.log("Available morph targets:", Object.keys(Y));
|
|
7096
|
+
const Z = Object.keys(Y).filter(($) => $.startsWith("viseme_"));
|
|
7097
|
+
console.log("Viseme morph targets found:", Z), Z.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"));
|
|
7093
7098
|
}
|
|
7094
|
-
if (await new Promise((
|
|
7095
|
-
const
|
|
7096
|
-
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)),
|
|
7099
|
+
if (await new Promise((Y) => {
|
|
7100
|
+
const Z = () => {
|
|
7101
|
+
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), Y()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Z, 100));
|
|
7097
7102
|
};
|
|
7098
|
-
|
|
7103
|
+
Z();
|
|
7099
7104
|
}), a.current && a.current.setShowFullAvatar)
|
|
7100
7105
|
try {
|
|
7101
7106
|
a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
|
|
7102
|
-
} catch (
|
|
7103
|
-
console.warn("Error setting full body mode on initialization:",
|
|
7107
|
+
} catch (Y) {
|
|
7108
|
+
console.warn("Error setting full body mode on initialization:", Y);
|
|
7104
7109
|
}
|
|
7105
7110
|
r(!1), y(!0), n(a.current);
|
|
7106
|
-
const
|
|
7111
|
+
const W = () => {
|
|
7107
7112
|
document.visibilityState === "visible" ? a.current?.start() : a.current?.stop();
|
|
7108
7113
|
};
|
|
7109
|
-
return document.addEventListener("visibilitychange",
|
|
7110
|
-
document.removeEventListener("visibilitychange",
|
|
7114
|
+
return document.addEventListener("visibilitychange", W), () => {
|
|
7115
|
+
document.removeEventListener("visibilitychange", W);
|
|
7111
7116
|
};
|
|
7112
7117
|
} catch (S) {
|
|
7113
7118
|
console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), r(!1), e(S);
|
|
7114
7119
|
}
|
|
7115
7120
|
}, []);
|
|
7116
|
-
|
|
7121
|
+
ve(() => (z(), () => {
|
|
7117
7122
|
a.current && (a.current.stop(), a.current.dispose(), a.current = null);
|
|
7118
7123
|
}), [z]);
|
|
7119
|
-
const
|
|
7124
|
+
const v = M((S) => {
|
|
7120
7125
|
if (a.current && g)
|
|
7121
7126
|
try {
|
|
7122
7127
|
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(() => {
|
|
7123
7128
|
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");
|
|
7124
7129
|
}, 500));
|
|
7125
|
-
} catch (
|
|
7126
|
-
console.error("Error speaking text:",
|
|
7130
|
+
} catch (W) {
|
|
7131
|
+
console.error("Error speaking text:", W), d(W.message || "Failed to speak text");
|
|
7127
7132
|
}
|
|
7128
7133
|
else
|
|
7129
7134
|
console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
|
|
7130
|
-
}, [g, p]), T =
|
|
7135
|
+
}, [g, p]), T = M(() => {
|
|
7131
7136
|
a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
|
|
7132
|
-
}, []),
|
|
7137
|
+
}, []), F = M((S) => {
|
|
7133
7138
|
a.current && a.current.setMood(S);
|
|
7134
|
-
}, []),
|
|
7139
|
+
}, []), J = M((S) => {
|
|
7135
7140
|
a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
|
|
7136
|
-
}, []),
|
|
7141
|
+
}, []), ye = M((S, W = !1) => {
|
|
7137
7142
|
if (a.current && a.current.playAnimation) {
|
|
7138
7143
|
if (a.current.setShowFullAvatar)
|
|
7139
7144
|
try {
|
|
7140
7145
|
a.current.setShowFullAvatar(!0);
|
|
7141
|
-
} catch (
|
|
7142
|
-
console.warn("Error setting full body mode:",
|
|
7146
|
+
} catch (Z) {
|
|
7147
|
+
console.warn("Error setting full body mode:", Z);
|
|
7143
7148
|
}
|
|
7144
7149
|
if (S.includes("."))
|
|
7145
7150
|
try {
|
|
7146
|
-
a.current.playAnimation(S, null, 10, 0, 0.01,
|
|
7147
|
-
} catch (
|
|
7148
|
-
console.log(`Failed to play ${S}:`,
|
|
7151
|
+
a.current.playAnimation(S, null, 10, 0, 0.01, W), console.log("Playing animation:", S);
|
|
7152
|
+
} catch (Z) {
|
|
7153
|
+
console.log(`Failed to play ${S}:`, Z);
|
|
7149
7154
|
try {
|
|
7150
7155
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7151
|
-
} catch (
|
|
7152
|
-
console.warn("Fallback animation also failed:",
|
|
7156
|
+
} catch ($) {
|
|
7157
|
+
console.warn("Fallback animation also failed:", $);
|
|
7153
7158
|
}
|
|
7154
7159
|
}
|
|
7155
7160
|
else {
|
|
7156
|
-
const
|
|
7157
|
-
let
|
|
7158
|
-
for (const
|
|
7161
|
+
const Z = [".fbx", ".glb", ".gltf"];
|
|
7162
|
+
let $ = !1;
|
|
7163
|
+
for (const se of Z)
|
|
7159
7164
|
try {
|
|
7160
|
-
a.current.playAnimation(S +
|
|
7165
|
+
a.current.playAnimation(S + se, null, 10, 0, 0.01, W), console.log("Playing animation:", S + se), $ = !0;
|
|
7161
7166
|
break;
|
|
7162
7167
|
} catch {
|
|
7163
|
-
console.log(`Failed to play ${S}${
|
|
7168
|
+
console.log(`Failed to play ${S}${se}, trying next format...`);
|
|
7164
7169
|
}
|
|
7165
|
-
if (
|
|
7170
|
+
if (!$) {
|
|
7166
7171
|
console.warn("Animation system not available or animation not found:", S);
|
|
7167
7172
|
try {
|
|
7168
7173
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7169
|
-
} catch (
|
|
7170
|
-
console.warn("Fallback animation also failed:",
|
|
7174
|
+
} catch (se) {
|
|
7175
|
+
console.warn("Fallback animation also failed:", se);
|
|
7171
7176
|
}
|
|
7172
7177
|
}
|
|
7173
7178
|
}
|
|
7174
7179
|
} else
|
|
7175
7180
|
console.warn("Animation system not available or animation not found:", S);
|
|
7176
7181
|
}, []);
|
|
7177
|
-
return
|
|
7178
|
-
speakText:
|
|
7182
|
+
return Ce(l, () => ({
|
|
7183
|
+
speakText: v,
|
|
7179
7184
|
stopSpeaking: T,
|
|
7180
|
-
setMood:
|
|
7181
|
-
setTimingAdjustment:
|
|
7182
|
-
playAnimation:
|
|
7185
|
+
setMood: F,
|
|
7186
|
+
setTimingAdjustment: J,
|
|
7187
|
+
playAnimation: ye,
|
|
7183
7188
|
isReady: g,
|
|
7184
7189
|
talkingHead: a.current,
|
|
7185
7190
|
setBodyMovement: (S) => {
|
|
7186
7191
|
if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
|
|
7187
7192
|
try {
|
|
7188
7193
|
a.current.setShowFullAvatar(!0), a.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
|
|
7189
|
-
} catch (
|
|
7190
|
-
console.warn("Error setting body movement:",
|
|
7194
|
+
} catch (W) {
|
|
7195
|
+
console.warn("Error setting body movement:", W);
|
|
7191
7196
|
}
|
|
7192
7197
|
},
|
|
7193
7198
|
setMovementIntensity: (S) => a.current?.setMovementIntensity(S),
|
|
@@ -7203,8 +7208,8 @@ const ut = Ie(({
|
|
|
7203
7208
|
if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
|
|
7204
7209
|
try {
|
|
7205
7210
|
a.current.setShowFullAvatar(!0), a.current.playReaction(S), console.log("Reaction played with full body mode:", S);
|
|
7206
|
-
} catch (
|
|
7207
|
-
console.warn("Error playing reaction:",
|
|
7211
|
+
} catch (W) {
|
|
7212
|
+
console.warn("Error playing reaction:", W);
|
|
7208
7213
|
}
|
|
7209
7214
|
},
|
|
7210
7215
|
playCelebration: () => {
|
|
@@ -7219,8 +7224,8 @@ const ut = Ie(({
|
|
|
7219
7224
|
if (a.current && a.current.setShowFullAvatar)
|
|
7220
7225
|
try {
|
|
7221
7226
|
a.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
|
|
7222
|
-
} catch (
|
|
7223
|
-
console.warn("Error setting showFullAvatar:",
|
|
7227
|
+
} catch (W) {
|
|
7228
|
+
console.warn("Error setting showFullAvatar:", W);
|
|
7224
7229
|
}
|
|
7225
7230
|
},
|
|
7226
7231
|
lockAvatarPosition: () => {
|
|
@@ -7239,8 +7244,8 @@ const ut = Ie(({
|
|
|
7239
7244
|
console.warn("Error unlocking avatar position:", S);
|
|
7240
7245
|
}
|
|
7241
7246
|
}
|
|
7242
|
-
})), /* @__PURE__ */
|
|
7243
|
-
/* @__PURE__ */
|
|
7247
|
+
})), /* @__PURE__ */ De("div", { className: `talking-head-container ${i}`, style: s, children: [
|
|
7248
|
+
/* @__PURE__ */ ge(
|
|
7244
7249
|
"div",
|
|
7245
7250
|
{
|
|
7246
7251
|
ref: u,
|
|
@@ -7252,7 +7257,7 @@ const ut = Ie(({
|
|
|
7252
7257
|
}
|
|
7253
7258
|
}
|
|
7254
7259
|
),
|
|
7255
|
-
h && /* @__PURE__ */
|
|
7260
|
+
h && /* @__PURE__ */ ge("div", { className: "loading-overlay", style: {
|
|
7256
7261
|
position: "absolute",
|
|
7257
7262
|
top: "50%",
|
|
7258
7263
|
left: "50%",
|
|
@@ -7261,7 +7266,7 @@ const ut = Ie(({
|
|
|
7261
7266
|
fontSize: "18px",
|
|
7262
7267
|
zIndex: 10
|
|
7263
7268
|
}, children: "Loading avatar..." }),
|
|
7264
|
-
c && /* @__PURE__ */
|
|
7269
|
+
c && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
|
|
7265
7270
|
position: "absolute",
|
|
7266
7271
|
top: "50%",
|
|
7267
7272
|
left: "50%",
|
|
@@ -7275,9 +7280,9 @@ const ut = Ie(({
|
|
|
7275
7280
|
}, children: c })
|
|
7276
7281
|
] });
|
|
7277
7282
|
});
|
|
7278
|
-
|
|
7279
|
-
const
|
|
7280
|
-
curriculumData:
|
|
7283
|
+
pt.displayName = "TalkingHeadComponent";
|
|
7284
|
+
const gt = ze(({
|
|
7285
|
+
curriculumData: U = null,
|
|
7281
7286
|
avatarConfig: t = {},
|
|
7282
7287
|
animations: e = {},
|
|
7283
7288
|
onLessonStart: n = () => {
|
|
@@ -7292,7 +7297,7 @@ const ct = Ie(({
|
|
|
7292
7297
|
},
|
|
7293
7298
|
autoStart: u = !1
|
|
7294
7299
|
}, a) => {
|
|
7295
|
-
const h =
|
|
7300
|
+
const h = N(null), r = N({
|
|
7296
7301
|
currentModuleIndex: 0,
|
|
7297
7302
|
currentLessonIndex: 0,
|
|
7298
7303
|
currentQuestionIndex: 0,
|
|
@@ -7302,18 +7307,18 @@ const ct = Ie(({
|
|
|
7302
7307
|
curriculumCompleted: !1,
|
|
7303
7308
|
score: 0,
|
|
7304
7309
|
totalQuestions: 0
|
|
7305
|
-
}), c =
|
|
7310
|
+
}), c = N({
|
|
7306
7311
|
onLessonStart: n,
|
|
7307
7312
|
onLessonComplete: i,
|
|
7308
7313
|
onQuestionAnswer: s,
|
|
7309
7314
|
onCurriculumComplete: o,
|
|
7310
7315
|
onCustomAction: l
|
|
7311
|
-
}), d =
|
|
7316
|
+
}), d = N(null), g = N(null), y = N(null), x = N(null), I = N(null), B = N(null), p = N(null), H = N(U?.curriculum || {
|
|
7312
7317
|
title: "Default Curriculum",
|
|
7313
7318
|
description: "No curriculum data provided",
|
|
7314
7319
|
language: "en",
|
|
7315
7320
|
modules: []
|
|
7316
|
-
}), z =
|
|
7321
|
+
}), z = N({
|
|
7317
7322
|
avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
|
|
7318
7323
|
avatarBody: t.avatarBody || "F",
|
|
7319
7324
|
mood: t.mood || "happy",
|
|
@@ -7327,7 +7332,7 @@ const ct = Ie(({
|
|
|
7327
7332
|
animations: e,
|
|
7328
7333
|
lipsyncLang: "en"
|
|
7329
7334
|
});
|
|
7330
|
-
|
|
7335
|
+
ve(() => {
|
|
7331
7336
|
c.current = {
|
|
7332
7337
|
onLessonStart: n,
|
|
7333
7338
|
onLessonComplete: i,
|
|
@@ -7335,8 +7340,8 @@ const ct = Ie(({
|
|
|
7335
7340
|
onCurriculumComplete: o,
|
|
7336
7341
|
onCustomAction: l
|
|
7337
7342
|
};
|
|
7338
|
-
}, [n, i, s, o, l]),
|
|
7339
|
-
H.current =
|
|
7343
|
+
}, [n, i, s, o, l]), ve(() => {
|
|
7344
|
+
H.current = U?.curriculum || {
|
|
7340
7345
|
title: "Default Curriculum",
|
|
7341
7346
|
description: "No curriculum data provided",
|
|
7342
7347
|
language: "en",
|
|
@@ -7355,12 +7360,12 @@ const ct = Ie(({
|
|
|
7355
7360
|
animations: e,
|
|
7356
7361
|
lipsyncLang: "en"
|
|
7357
7362
|
};
|
|
7358
|
-
}, [
|
|
7359
|
-
const
|
|
7363
|
+
}, [U, t, e]);
|
|
7364
|
+
const v = M(() => (H.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), T = M(() => v()?.questions[r.current.currentQuestionIndex], [v]), F = M((b, R) => R.type === "multiple_choice" || R.type === "true_false" ? b === R.answer : R.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), J = M(() => {
|
|
7360
7365
|
r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
|
|
7361
7366
|
const b = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
|
|
7362
|
-
let
|
|
7363
|
-
if (r.current.totalQuestions > 0 ?
|
|
7367
|
+
let R = "Congratulations! You've completed this lesson";
|
|
7368
|
+
if (r.current.totalQuestions > 0 ? R += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : R += "! ", b >= 80 ? R += "Excellent work! You have a great understanding of this topic." : b >= 60 ? R += "Good job! You understand most of the concepts." : R += "Keep practicing! You're making progress.", c.current.onLessonComplete({
|
|
7364
7369
|
moduleIndex: r.current.currentModuleIndex,
|
|
7365
7370
|
lessonIndex: r.current.currentLessonIndex,
|
|
7366
7371
|
score: r.current.score,
|
|
@@ -7380,9 +7385,9 @@ const ct = Ie(({
|
|
|
7380
7385
|
} catch {
|
|
7381
7386
|
h.current.playCelebration();
|
|
7382
7387
|
}
|
|
7383
|
-
const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex],
|
|
7384
|
-
h.current.speakText(
|
|
7385
|
-
lipsyncLang:
|
|
7388
|
+
const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex], D = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = D || te, j = z.current || { lipsyncLang: "en" };
|
|
7389
|
+
h.current.speakText(R, {
|
|
7390
|
+
lipsyncLang: j.lipsyncLang,
|
|
7386
7391
|
onSpeechEnd: () => {
|
|
7387
7392
|
c.current.onCustomAction({
|
|
7388
7393
|
type: "lessonCompleteFeedbackDone",
|
|
@@ -7391,17 +7396,17 @@ const ct = Ie(({
|
|
|
7391
7396
|
score: r.current.score,
|
|
7392
7397
|
totalQuestions: r.current.totalQuestions,
|
|
7393
7398
|
percentage: b,
|
|
7394
|
-
hasNextLesson:
|
|
7399
|
+
hasNextLesson: q
|
|
7395
7400
|
});
|
|
7396
7401
|
}
|
|
7397
7402
|
});
|
|
7398
7403
|
}
|
|
7399
|
-
}, [e.lessonComplete]),
|
|
7404
|
+
}, [e.lessonComplete]), ye = M(() => {
|
|
7400
7405
|
r.current.curriculumCompleted = !0;
|
|
7401
7406
|
const b = H.current || { modules: [] };
|
|
7402
7407
|
if (c.current.onCurriculumComplete({
|
|
7403
7408
|
modules: b.modules.length,
|
|
7404
|
-
totalLessons: b.modules.reduce((
|
|
7409
|
+
totalLessons: b.modules.reduce((R, w) => R + w.lessons.length, 0)
|
|
7405
7410
|
}), h.current) {
|
|
7406
7411
|
if (h.current.setMood("celebrating"), e.curriculumComplete)
|
|
7407
7412
|
try {
|
|
@@ -7409,82 +7414,94 @@ const ct = Ie(({
|
|
|
7409
7414
|
} catch {
|
|
7410
7415
|
h.current.playCelebration();
|
|
7411
7416
|
}
|
|
7412
|
-
const
|
|
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:
|
|
7417
|
+
const R = z.current || { lipsyncLang: "en" };
|
|
7418
|
+
h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: R.lipsyncLang });
|
|
7414
7419
|
}
|
|
7415
|
-
}, [e.curriculumComplete]), S =
|
|
7416
|
-
const b =
|
|
7420
|
+
}, [e.curriculumComplete]), S = M(() => {
|
|
7421
|
+
const b = v();
|
|
7417
7422
|
r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = b?.questions?.length || 0, r.current.score = 0;
|
|
7418
|
-
const
|
|
7419
|
-
|
|
7423
|
+
const R = T();
|
|
7424
|
+
R && c.current.onCustomAction({
|
|
7420
7425
|
type: "questionStart",
|
|
7421
7426
|
moduleIndex: r.current.currentModuleIndex,
|
|
7422
7427
|
lessonIndex: r.current.currentLessonIndex,
|
|
7423
7428
|
questionIndex: r.current.currentQuestionIndex,
|
|
7424
7429
|
totalQuestions: r.current.totalQuestions,
|
|
7425
|
-
question:
|
|
7430
|
+
question: R,
|
|
7426
7431
|
score: r.current.score
|
|
7427
7432
|
});
|
|
7428
7433
|
const w = () => {
|
|
7429
|
-
if (!h.current || !
|
|
7434
|
+
if (!h.current || !R) return;
|
|
7430
7435
|
if (h.current.setMood("happy"), e.questionStart)
|
|
7431
7436
|
try {
|
|
7432
7437
|
h.current.playAnimation(e.questionStart, !0);
|
|
7433
|
-
} catch (
|
|
7434
|
-
console.warn("Failed to play questionStart animation:",
|
|
7438
|
+
} catch (D) {
|
|
7439
|
+
console.warn("Failed to play questionStart animation:", D);
|
|
7435
7440
|
}
|
|
7436
7441
|
const C = z.current || { lipsyncLang: "en" };
|
|
7437
|
-
|
|
7442
|
+
R.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang });
|
|
7438
7443
|
};
|
|
7439
|
-
if (h.current && h.current.isReady &&
|
|
7444
|
+
if (h.current && h.current.isReady && R)
|
|
7440
7445
|
w();
|
|
7441
7446
|
else if (h.current && h.current.isReady) {
|
|
7442
7447
|
const C = z.current || { lipsyncLang: "en" };
|
|
7443
7448
|
h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
|
|
7444
7449
|
} else {
|
|
7445
7450
|
const C = setInterval(() => {
|
|
7446
|
-
h.current && h.current.isReady && (clearInterval(C),
|
|
7451
|
+
h.current && h.current.isReady && (clearInterval(C), R && w());
|
|
7447
7452
|
}, 100);
|
|
7448
7453
|
setTimeout(() => {
|
|
7449
7454
|
clearInterval(C);
|
|
7450
7455
|
}, 5e3);
|
|
7451
7456
|
}
|
|
7452
|
-
}, [e.questionStart,
|
|
7453
|
-
const b =
|
|
7457
|
+
}, [e.questionStart, v, T]), W = M(() => {
|
|
7458
|
+
const b = v();
|
|
7454
7459
|
if (r.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
|
|
7455
7460
|
h.current && h.current.stopSpeaking && h.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
|
|
7456
|
-
const
|
|
7457
|
-
|
|
7461
|
+
const R = T();
|
|
7462
|
+
R && c.current.onCustomAction({
|
|
7458
7463
|
type: "nextQuestion",
|
|
7459
7464
|
moduleIndex: r.current.currentModuleIndex,
|
|
7460
7465
|
lessonIndex: r.current.currentLessonIndex,
|
|
7461
7466
|
questionIndex: r.current.currentQuestionIndex,
|
|
7462
7467
|
totalQuestions: r.current.totalQuestions,
|
|
7463
|
-
question:
|
|
7468
|
+
question: R,
|
|
7464
7469
|
score: r.current.score
|
|
7465
7470
|
});
|
|
7466
7471
|
const w = () => {
|
|
7467
|
-
if (!h.current || !
|
|
7472
|
+
if (!h.current || !R) return;
|
|
7468
7473
|
if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
|
|
7469
7474
|
try {
|
|
7470
7475
|
h.current.playAnimation(e.nextQuestion, !0);
|
|
7471
|
-
} catch (
|
|
7472
|
-
console.warn("Failed to play nextQuestion animation:",
|
|
7476
|
+
} catch (j) {
|
|
7477
|
+
console.warn("Failed to play nextQuestion animation:", j);
|
|
7473
7478
|
}
|
|
7474
|
-
const C = z.current || { lipsyncLang: "en" };
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7479
|
+
const C = z.current || { lipsyncLang: "en" }, te = v()?.questions?.length || 0, q = r.current.currentQuestionIndex >= te - 1;
|
|
7480
|
+
if (R.type === "code_test") {
|
|
7481
|
+
const j = q ? `Great! Here's your final coding challenge: ${R.question}` : `Great! Now let's move on to your next coding challenge: ${R.question}`;
|
|
7482
|
+
h.current.speakText(j, {
|
|
7483
|
+
lipsyncLang: C.lipsyncLang
|
|
7484
|
+
});
|
|
7485
|
+
} else if (R.type === "multiple_choice") {
|
|
7486
|
+
const j = q ? `Alright! Here's your final question: ${R.question}` : `Alright! Here's your next question: ${R.question}`;
|
|
7487
|
+
h.current.speakText(j, {
|
|
7488
|
+
lipsyncLang: C.lipsyncLang
|
|
7489
|
+
});
|
|
7490
|
+
} else if (R.type === "true_false") {
|
|
7491
|
+
const j = q ? `Now let's try this final one: ${R.question}` : `Now let's try this one: ${R.question}`;
|
|
7492
|
+
h.current.speakText(j, {
|
|
7493
|
+
lipsyncLang: C.lipsyncLang
|
|
7494
|
+
});
|
|
7495
|
+
} else {
|
|
7496
|
+
const j = q ? `Here's your final question: ${R.question}` : `Here's the next question: ${R.question}`;
|
|
7497
|
+
h.current.speakText(j, {
|
|
7498
|
+
lipsyncLang: C.lipsyncLang
|
|
7499
|
+
});
|
|
7500
|
+
}
|
|
7484
7501
|
};
|
|
7485
|
-
if (h.current && h.current.isReady &&
|
|
7502
|
+
if (h.current && h.current.isReady && R)
|
|
7486
7503
|
w();
|
|
7487
|
-
else if (
|
|
7504
|
+
else if (R) {
|
|
7488
7505
|
const C = setInterval(() => {
|
|
7489
7506
|
h.current && h.current.isReady && (clearInterval(C), w());
|
|
7490
7507
|
}, 100);
|
|
@@ -7500,52 +7517,52 @@ const ct = Ie(({
|
|
|
7500
7517
|
totalQuestions: r.current.totalQuestions,
|
|
7501
7518
|
score: r.current.score
|
|
7502
7519
|
});
|
|
7503
|
-
}, [e.nextQuestion,
|
|
7504
|
-
const b = H.current || { modules: [] },
|
|
7505
|
-
if (r.current.currentLessonIndex < (
|
|
7520
|
+
}, [e.nextQuestion, v, T]), Y = M(() => {
|
|
7521
|
+
const b = H.current || { modules: [] }, R = b.modules[r.current.currentModuleIndex];
|
|
7522
|
+
if (r.current.currentLessonIndex < (R?.lessons?.length || 0) - 1) {
|
|
7506
7523
|
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;
|
|
7507
|
-
const C = b.modules[r.current.currentModuleIndex],
|
|
7524
|
+
const C = b.modules[r.current.currentModuleIndex], D = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = D || te;
|
|
7508
7525
|
c.current.onCustomAction({
|
|
7509
7526
|
type: "lessonStart",
|
|
7510
7527
|
moduleIndex: r.current.currentModuleIndex,
|
|
7511
7528
|
lessonIndex: r.current.currentLessonIndex,
|
|
7512
|
-
hasNextLesson:
|
|
7529
|
+
hasNextLesson: q
|
|
7513
7530
|
}), c.current.onLessonStart({
|
|
7514
7531
|
moduleIndex: r.current.currentModuleIndex,
|
|
7515
7532
|
lessonIndex: r.current.currentLessonIndex,
|
|
7516
|
-
lesson:
|
|
7533
|
+
lesson: v()
|
|
7517
7534
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7518
7535
|
} else if (r.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
|
|
7519
7536
|
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;
|
|
7520
|
-
const
|
|
7537
|
+
const D = b.modules[r.current.currentModuleIndex], te = r.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, q = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, j = te || q;
|
|
7521
7538
|
c.current.onCustomAction({
|
|
7522
7539
|
type: "lessonStart",
|
|
7523
7540
|
moduleIndex: r.current.currentModuleIndex,
|
|
7524
7541
|
lessonIndex: r.current.currentLessonIndex,
|
|
7525
|
-
hasNextLesson:
|
|
7542
|
+
hasNextLesson: j
|
|
7526
7543
|
}), c.current.onLessonStart({
|
|
7527
7544
|
moduleIndex: r.current.currentModuleIndex,
|
|
7528
7545
|
lessonIndex: r.current.currentLessonIndex,
|
|
7529
|
-
lesson:
|
|
7546
|
+
lesson: v()
|
|
7530
7547
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7531
7548
|
} else
|
|
7532
7549
|
I.current && I.current();
|
|
7533
|
-
}, []),
|
|
7534
|
-
const b =
|
|
7535
|
-
let
|
|
7550
|
+
}, []), Z = M(() => {
|
|
7551
|
+
const b = v();
|
|
7552
|
+
let R = null;
|
|
7536
7553
|
if (b?.avatar_script && b?.body) {
|
|
7537
|
-
const w = b.avatar_script.trim(), C = b.body.trim(),
|
|
7538
|
-
|
|
7554
|
+
const w = b.avatar_script.trim(), C = b.body.trim(), D = w.match(/[.!?]$/) ? " " : ". ";
|
|
7555
|
+
R = `${w}${D}${C}`;
|
|
7539
7556
|
} else
|
|
7540
|
-
|
|
7541
|
-
if (h.current && h.current.isReady &&
|
|
7557
|
+
R = b?.avatar_script || b?.body || null;
|
|
7558
|
+
if (h.current && h.current.isReady && R) {
|
|
7542
7559
|
r.current.isTeaching = !0, r.current.isQuestionMode = !1, r.current.score = 0, r.current.totalQuestions = 0, h.current.setMood("happy");
|
|
7543
7560
|
let w = !1;
|
|
7544
7561
|
if (e.teaching)
|
|
7545
7562
|
try {
|
|
7546
7563
|
h.current.playAnimation(e.teaching, !0), w = !0;
|
|
7547
|
-
} catch (
|
|
7548
|
-
console.warn("Failed to play teaching animation:",
|
|
7564
|
+
} catch (D) {
|
|
7565
|
+
console.warn("Failed to play teaching animation:", D);
|
|
7549
7566
|
}
|
|
7550
7567
|
w || h.current.setBodyMovement("gesturing");
|
|
7551
7568
|
const C = z.current || { lipsyncLang: "en" };
|
|
@@ -7558,7 +7575,7 @@ const ct = Ie(({
|
|
|
7558
7575
|
moduleIndex: r.current.currentModuleIndex,
|
|
7559
7576
|
lessonIndex: r.current.currentLessonIndex,
|
|
7560
7577
|
lesson: b
|
|
7561
|
-
}), h.current.speakText(
|
|
7578
|
+
}), h.current.speakText(R, {
|
|
7562
7579
|
lipsyncLang: C.lipsyncLang,
|
|
7563
7580
|
onSpeechEnd: () => {
|
|
7564
7581
|
r.current.isTeaching = !1, c.current.onCustomAction({
|
|
@@ -7571,15 +7588,15 @@ const ct = Ie(({
|
|
|
7571
7588
|
}
|
|
7572
7589
|
});
|
|
7573
7590
|
}
|
|
7574
|
-
}, [e.teaching,
|
|
7575
|
-
const
|
|
7591
|
+
}, [e.teaching, v]), $ = M((b) => {
|
|
7592
|
+
const R = T(), w = F(b, R);
|
|
7576
7593
|
if (w && (r.current.score += 1), c.current.onQuestionAnswer({
|
|
7577
7594
|
moduleIndex: r.current.currentModuleIndex,
|
|
7578
7595
|
lessonIndex: r.current.currentLessonIndex,
|
|
7579
7596
|
questionIndex: r.current.currentQuestionIndex,
|
|
7580
7597
|
answer: b,
|
|
7581
7598
|
isCorrect: w,
|
|
7582
|
-
question:
|
|
7599
|
+
question: R
|
|
7583
7600
|
}), h.current)
|
|
7584
7601
|
if (w) {
|
|
7585
7602
|
if (h.current.setMood("happy"), e.correct)
|
|
@@ -7589,18 +7606,19 @@ const ct = Ie(({
|
|
|
7589
7606
|
h.current.setBodyMovement("happy");
|
|
7590
7607
|
}
|
|
7591
7608
|
h.current.setBodyMovement("gesturing");
|
|
7592
|
-
const
|
|
7593
|
-
|
|
7594
|
-
|
|
7609
|
+
const D = v()?.questions?.length || 0;
|
|
7610
|
+
r.current.currentQuestionIndex >= D - 1;
|
|
7611
|
+
const te = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, q = z.current || { lipsyncLang: "en" };
|
|
7612
|
+
h.current.speakText(te, {
|
|
7613
|
+
lipsyncLang: q.lipsyncLang,
|
|
7595
7614
|
onSpeechEnd: () => {
|
|
7596
|
-
const ie = R()?.questions?.length || 0;
|
|
7597
7615
|
c.current.onCustomAction({
|
|
7598
7616
|
type: "answerFeedbackComplete",
|
|
7599
7617
|
moduleIndex: r.current.currentModuleIndex,
|
|
7600
7618
|
lessonIndex: r.current.currentLessonIndex,
|
|
7601
7619
|
questionIndex: r.current.currentQuestionIndex,
|
|
7602
7620
|
isCorrect: !0,
|
|
7603
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7621
|
+
hasNextQuestion: r.current.currentQuestionIndex < D - 1,
|
|
7604
7622
|
score: r.current.score,
|
|
7605
7623
|
totalQuestions: r.current.totalQuestions
|
|
7606
7624
|
});
|
|
@@ -7614,18 +7632,17 @@ const ct = Ie(({
|
|
|
7614
7632
|
h.current.setBodyMovement("idle");
|
|
7615
7633
|
}
|
|
7616
7634
|
h.current.setBodyMovement("gesturing");
|
|
7617
|
-
const
|
|
7618
|
-
h.current.speakText(
|
|
7619
|
-
lipsyncLang:
|
|
7635
|
+
const D = v()?.questions?.length || 0, te = r.current.currentQuestionIndex >= D - 1, q = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""}${te ? "" : " Let's move on to the next question."}`, j = z.current || { lipsyncLang: "en" };
|
|
7636
|
+
h.current.speakText(q, {
|
|
7637
|
+
lipsyncLang: j.lipsyncLang,
|
|
7620
7638
|
onSpeechEnd: () => {
|
|
7621
|
-
const ie = R()?.questions?.length || 0;
|
|
7622
7639
|
c.current.onCustomAction({
|
|
7623
7640
|
type: "answerFeedbackComplete",
|
|
7624
7641
|
moduleIndex: r.current.currentModuleIndex,
|
|
7625
7642
|
lessonIndex: r.current.currentLessonIndex,
|
|
7626
7643
|
questionIndex: r.current.currentQuestionIndex,
|
|
7627
7644
|
isCorrect: !1,
|
|
7628
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7645
|
+
hasNextQuestion: r.current.currentQuestionIndex < D - 1,
|
|
7629
7646
|
score: r.current.score,
|
|
7630
7647
|
totalQuestions: r.current.totalQuestions
|
|
7631
7648
|
});
|
|
@@ -7633,26 +7650,26 @@ const ct = Ie(({
|
|
|
7633
7650
|
});
|
|
7634
7651
|
}
|
|
7635
7652
|
else {
|
|
7636
|
-
const
|
|
7653
|
+
const D = v()?.questions?.length || 0;
|
|
7637
7654
|
c.current.onCustomAction({
|
|
7638
7655
|
type: "answerFeedbackComplete",
|
|
7639
7656
|
moduleIndex: r.current.currentModuleIndex,
|
|
7640
7657
|
lessonIndex: r.current.currentLessonIndex,
|
|
7641
7658
|
questionIndex: r.current.currentQuestionIndex,
|
|
7642
7659
|
isCorrect: w,
|
|
7643
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7660
|
+
hasNextQuestion: r.current.currentQuestionIndex < D - 1,
|
|
7644
7661
|
score: r.current.score,
|
|
7645
7662
|
totalQuestions: r.current.totalQuestions,
|
|
7646
7663
|
avatarNotReady: !0
|
|
7647
7664
|
});
|
|
7648
7665
|
}
|
|
7649
|
-
}, [e.correct, e.incorrect, T,
|
|
7650
|
-
const
|
|
7666
|
+
}, [e.correct, e.incorrect, T, v, F]), se = M((b) => {
|
|
7667
|
+
const R = T();
|
|
7651
7668
|
if (!b || typeof b != "object") {
|
|
7652
7669
|
console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
|
|
7653
7670
|
return;
|
|
7654
7671
|
}
|
|
7655
|
-
if (
|
|
7672
|
+
if (R?.type !== "code_test") {
|
|
7656
7673
|
console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
|
|
7657
7674
|
return;
|
|
7658
7675
|
}
|
|
@@ -7672,9 +7689,9 @@ const ct = Ie(({
|
|
|
7672
7689
|
lessonIndex: r.current.currentLessonIndex,
|
|
7673
7690
|
questionIndex: r.current.currentQuestionIndex,
|
|
7674
7691
|
testResult: w,
|
|
7675
|
-
question:
|
|
7692
|
+
question: R
|
|
7676
7693
|
}), p.current && p.current(w);
|
|
7677
|
-
}, [T,
|
|
7694
|
+
}, [T, F]), de = M(() => {
|
|
7678
7695
|
if (r.current.currentQuestionIndex > 0) {
|
|
7679
7696
|
r.current.currentQuestionIndex -= 1;
|
|
7680
7697
|
const b = T();
|
|
@@ -7687,7 +7704,7 @@ const ct = Ie(({
|
|
|
7687
7704
|
question: b,
|
|
7688
7705
|
score: r.current.score
|
|
7689
7706
|
});
|
|
7690
|
-
const
|
|
7707
|
+
const R = () => {
|
|
7691
7708
|
if (!h.current || !b) return;
|
|
7692
7709
|
h.current.setMood("happy"), h.current.setBodyMovement("idle");
|
|
7693
7710
|
const w = z.current || { lipsyncLang: "en" };
|
|
@@ -7698,17 +7715,17 @@ const ct = Ie(({
|
|
|
7698
7715
|
});
|
|
7699
7716
|
};
|
|
7700
7717
|
if (h.current && h.current.isReady && b)
|
|
7701
|
-
|
|
7718
|
+
R();
|
|
7702
7719
|
else if (b) {
|
|
7703
7720
|
const w = setInterval(() => {
|
|
7704
|
-
h.current && h.current.isReady && (clearInterval(w),
|
|
7721
|
+
h.current && h.current.isReady && (clearInterval(w), R());
|
|
7705
7722
|
}, 100);
|
|
7706
7723
|
setTimeout(() => {
|
|
7707
7724
|
clearInterval(w);
|
|
7708
7725
|
}, 5e3);
|
|
7709
7726
|
}
|
|
7710
7727
|
}
|
|
7711
|
-
}, [T]),
|
|
7728
|
+
}, [T]), me = M(() => {
|
|
7712
7729
|
const b = H.current || { modules: [] };
|
|
7713
7730
|
if (b.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
|
|
7714
7731
|
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({
|
|
@@ -7718,7 +7735,7 @@ const ct = Ie(({
|
|
|
7718
7735
|
}), c.current.onLessonStart({
|
|
7719
7736
|
moduleIndex: r.current.currentModuleIndex,
|
|
7720
7737
|
lessonIndex: r.current.currentLessonIndex,
|
|
7721
|
-
lesson:
|
|
7738
|
+
lesson: v()
|
|
7722
7739
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7723
7740
|
else if (r.current.currentModuleIndex > 0) {
|
|
7724
7741
|
const C = b.modules[r.current.currentModuleIndex - 1];
|
|
@@ -7729,53 +7746,53 @@ const ct = Ie(({
|
|
|
7729
7746
|
}), c.current.onLessonStart({
|
|
7730
7747
|
moduleIndex: r.current.currentModuleIndex,
|
|
7731
7748
|
lessonIndex: r.current.currentLessonIndex,
|
|
7732
|
-
lesson:
|
|
7749
|
+
lesson: v()
|
|
7733
7750
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7734
7751
|
}
|
|
7735
|
-
}, [
|
|
7752
|
+
}, [v]), ie = M(() => {
|
|
7736
7753
|
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;
|
|
7737
|
-
}, []),
|
|
7754
|
+
}, []), fe = M((b) => {
|
|
7738
7755
|
console.log("Avatar is ready!", b);
|
|
7739
|
-
const
|
|
7756
|
+
const R = v(), w = R?.avatar_script || R?.body;
|
|
7740
7757
|
u && w && setTimeout(() => {
|
|
7741
7758
|
d.current && d.current();
|
|
7742
7759
|
}, 10);
|
|
7743
|
-
}, [u,
|
|
7744
|
-
|
|
7745
|
-
d.current =
|
|
7746
|
-
}),
|
|
7760
|
+
}, [u, v]);
|
|
7761
|
+
Xe(() => {
|
|
7762
|
+
d.current = Z, g.current = Y, y.current = J, x.current = W, I.current = ye, B.current = S, p.current = $;
|
|
7763
|
+
}), Ce(a, () => ({
|
|
7747
7764
|
// Curriculum control methods
|
|
7748
|
-
startTeaching:
|
|
7765
|
+
startTeaching: Z,
|
|
7749
7766
|
startQuestions: S,
|
|
7750
|
-
handleAnswerSelect:
|
|
7751
|
-
handleCodeTestResult:
|
|
7752
|
-
nextQuestion:
|
|
7753
|
-
previousQuestion:
|
|
7754
|
-
nextLesson:
|
|
7755
|
-
previousLesson:
|
|
7756
|
-
completeLesson:
|
|
7757
|
-
completeCurriculum:
|
|
7758
|
-
resetCurriculum:
|
|
7767
|
+
handleAnswerSelect: $,
|
|
7768
|
+
handleCodeTestResult: se,
|
|
7769
|
+
nextQuestion: W,
|
|
7770
|
+
previousQuestion: de,
|
|
7771
|
+
nextLesson: Y,
|
|
7772
|
+
previousLesson: me,
|
|
7773
|
+
completeLesson: J,
|
|
7774
|
+
completeCurriculum: ye,
|
|
7775
|
+
resetCurriculum: ie,
|
|
7759
7776
|
getState: () => ({ ...r.current }),
|
|
7760
7777
|
getCurrentQuestion: () => T(),
|
|
7761
|
-
getCurrentLesson: () =>
|
|
7778
|
+
getCurrentLesson: () => v(),
|
|
7762
7779
|
// Direct access to avatar ref (always returns current value)
|
|
7763
7780
|
getAvatarRef: () => h.current,
|
|
7764
7781
|
// Convenience methods that delegate to avatar (always check current ref)
|
|
7765
|
-
speakText: async (b,
|
|
7782
|
+
speakText: async (b, R = {}) => {
|
|
7766
7783
|
await h.current?.resumeAudioContext?.();
|
|
7767
7784
|
const w = z.current || { lipsyncLang: "en" };
|
|
7768
|
-
h.current?.speakText(b, { ...
|
|
7785
|
+
h.current?.speakText(b, { ...R, lipsyncLang: R.lipsyncLang || w.lipsyncLang });
|
|
7769
7786
|
},
|
|
7770
7787
|
resumeAudioContext: async () => {
|
|
7771
7788
|
if (h.current?.resumeAudioContext)
|
|
7772
7789
|
return await h.current.resumeAudioContext();
|
|
7773
7790
|
const b = h.current?.talkingHead;
|
|
7774
7791
|
if (b?.audioCtx) {
|
|
7775
|
-
const
|
|
7776
|
-
if (
|
|
7792
|
+
const R = b.audioCtx;
|
|
7793
|
+
if (R.state === "suspended" || R.state === "interrupted")
|
|
7777
7794
|
try {
|
|
7778
|
-
await
|
|
7795
|
+
await R.resume(), console.log("Audio context resumed via talkingHead");
|
|
7779
7796
|
} catch (w) {
|
|
7780
7797
|
console.warn("Failed to resume audio context:", w);
|
|
7781
7798
|
}
|
|
@@ -7787,7 +7804,7 @@ const ct = Ie(({
|
|
|
7787
7804
|
resumeSpeaking: async () => await h.current?.resumeSpeaking(),
|
|
7788
7805
|
isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
|
|
7789
7806
|
setMood: (b) => h.current?.setMood(b),
|
|
7790
|
-
playAnimation: (b,
|
|
7807
|
+
playAnimation: (b, R) => h.current?.playAnimation(b, R),
|
|
7791
7808
|
setBodyMovement: (b) => h.current?.setBodyMovement(b),
|
|
7792
7809
|
setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
|
|
7793
7810
|
playRandomDance: () => h.current?.playRandomDance(),
|
|
@@ -7798,10 +7815,10 @@ const ct = Ie(({
|
|
|
7798
7815
|
lockAvatarPosition: () => h.current?.lockAvatarPosition(),
|
|
7799
7816
|
unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
|
|
7800
7817
|
// Custom action trigger
|
|
7801
|
-
triggerCustomAction: (b,
|
|
7818
|
+
triggerCustomAction: (b, R) => {
|
|
7802
7819
|
c.current.onCustomAction({
|
|
7803
7820
|
type: b,
|
|
7804
|
-
...
|
|
7821
|
+
...R,
|
|
7805
7822
|
state: { ...r.current }
|
|
7806
7823
|
});
|
|
7807
7824
|
},
|
|
@@ -7809,8 +7826,8 @@ const ct = Ie(({
|
|
|
7809
7826
|
handleResize: () => h.current?.handleResize(),
|
|
7810
7827
|
// Avatar readiness check (always returns current value)
|
|
7811
7828
|
isAvatarReady: () => h.current?.isReady || !1
|
|
7812
|
-
}), [
|
|
7813
|
-
const
|
|
7829
|
+
}), [Z, S, $, se, W, Y, J, ye, ie, T, v]);
|
|
7830
|
+
const X = z.current || {
|
|
7814
7831
|
avatarUrl: "/avatars/brunette.glb",
|
|
7815
7832
|
avatarBody: "F",
|
|
7816
7833
|
mood: "happy",
|
|
@@ -7823,23 +7840,23 @@ const ct = Ie(({
|
|
|
7823
7840
|
showFullAvatar: !1,
|
|
7824
7841
|
animations: e
|
|
7825
7842
|
};
|
|
7826
|
-
return /* @__PURE__ */
|
|
7827
|
-
|
|
7843
|
+
return /* @__PURE__ */ ge("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ ge(
|
|
7844
|
+
Ne,
|
|
7828
7845
|
{
|
|
7829
7846
|
ref: h,
|
|
7830
|
-
avatarUrl:
|
|
7831
|
-
avatarBody:
|
|
7832
|
-
mood:
|
|
7833
|
-
ttsLang:
|
|
7834
|
-
ttsService:
|
|
7835
|
-
ttsVoice:
|
|
7836
|
-
ttsApiKey:
|
|
7837
|
-
bodyMovement:
|
|
7838
|
-
movementIntensity:
|
|
7839
|
-
showFullAvatar:
|
|
7847
|
+
avatarUrl: X.avatarUrl,
|
|
7848
|
+
avatarBody: X.avatarBody,
|
|
7849
|
+
mood: X.mood,
|
|
7850
|
+
ttsLang: X.ttsLang,
|
|
7851
|
+
ttsService: X.ttsService,
|
|
7852
|
+
ttsVoice: X.ttsVoice,
|
|
7853
|
+
ttsApiKey: X.ttsApiKey,
|
|
7854
|
+
bodyMovement: X.bodyMovement,
|
|
7855
|
+
movementIntensity: X.movementIntensity,
|
|
7856
|
+
showFullAvatar: X.showFullAvatar,
|
|
7840
7857
|
cameraView: "upper",
|
|
7841
|
-
animations:
|
|
7842
|
-
onReady:
|
|
7858
|
+
animations: X.animations,
|
|
7859
|
+
onReady: fe,
|
|
7843
7860
|
onLoading: () => {
|
|
7844
7861
|
},
|
|
7845
7862
|
onError: (b) => {
|
|
@@ -7848,8 +7865,8 @@ const ct = Ie(({
|
|
|
7848
7865
|
}
|
|
7849
7866
|
) });
|
|
7850
7867
|
});
|
|
7851
|
-
|
|
7852
|
-
const
|
|
7868
|
+
gt.displayName = "CurriculumLearning";
|
|
7869
|
+
const Ue = {
|
|
7853
7870
|
// Code-based dance animations (no FBX required)
|
|
7854
7871
|
dance: {
|
|
7855
7872
|
name: "dance",
|
|
@@ -7952,14 +7969,14 @@ const Be = {
|
|
|
7952
7969
|
duration: 5e3,
|
|
7953
7970
|
description: "Excited, energetic movement"
|
|
7954
7971
|
}
|
|
7955
|
-
},
|
|
7972
|
+
}, kt = (U) => Ue[U] || null, wt = (U) => Ue.hasOwnProperty(U);
|
|
7956
7973
|
export {
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7974
|
+
gt as CurriculumLearning,
|
|
7975
|
+
Ne as TalkingHeadAvatar,
|
|
7976
|
+
pt as TalkingHeadComponent,
|
|
7977
|
+
Ue as animations,
|
|
7978
|
+
He as getActiveTTSConfig,
|
|
7979
|
+
kt as getAnimation,
|
|
7980
|
+
St as getVoiceOptions,
|
|
7981
|
+
wt as hasAnimation
|
|
7965
7982
|
};
|