@sage-rsc/talking-head-react 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.js +852 -812
- package/package.json +6 -2
- package/scripts/generate-folder-listings.js +4 -2
- package/src/components/SimpleTalkingAvatar.jsx +89 -6
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as Re, jsx as ee } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Ne, useRef as X, useState as le, useEffect as ye, useCallback as V, useImperativeHandle as Ue, useLayoutEffect as Je } from "react";
|
|
3
3
|
import * as x 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 H = [0, 0, 0, 0],
|
|
4
|
+
import { OrbitControls as et } from "three/addons/controls/OrbitControls.js";
|
|
5
|
+
import { GLTFLoader as tt } from "three/addons/loaders/GLTFLoader.js";
|
|
6
|
+
import { DRACOLoader as nt } from "three/addons/loaders/DRACOLoader.js";
|
|
7
|
+
import { FBXLoader as Xe } from "three/addons/loaders/FBXLoader.js";
|
|
8
|
+
import { RoomEnvironment as it } from "three/addons/environments/RoomEnvironment.js";
|
|
9
|
+
import ot from "three/addons/libs/stats.module.js";
|
|
10
|
+
let m, ge, xe;
|
|
11
|
+
const H = [0, 0, 0, 0], O = new x.Vector3(), Pe = new x.Vector3(), de = new x.Vector3(), Be = new x.Vector3();
|
|
12
12
|
new x.Plane();
|
|
13
13
|
new x.Ray();
|
|
14
14
|
new x.Euler();
|
|
15
|
-
const
|
|
15
|
+
const me = new x.Quaternion(), je = new x.Quaternion(), Ie = new x.Matrix4(), Le = new x.Matrix4();
|
|
16
16
|
new x.Vector3();
|
|
17
|
-
const
|
|
18
|
-
class
|
|
17
|
+
const Oe = new x.Vector3(0, 0, 1), st = new x.Vector3(1, 0, 0), at = new x.Vector3(0, 1, 0), rt = new x.Vector3(0, 0, 1);
|
|
18
|
+
class lt {
|
|
19
19
|
constructor(t = null) {
|
|
20
20
|
this.opt = Object.assign({
|
|
21
21
|
warmupMs: 2e3,
|
|
@@ -321,7 +321,7 @@ class at {
|
|
|
321
321
|
/// Bone's parent object
|
|
322
322
|
vBasis: a.position.clone(),
|
|
323
323
|
// Original local position
|
|
324
|
-
vWorld: a.parent.getWorldPosition(
|
|
324
|
+
vWorld: a.parent.getWorldPosition(O).clone(),
|
|
325
325
|
// World position, parent
|
|
326
326
|
qBasis: a.parent.quaternion.clone(),
|
|
327
327
|
// Original quaternion, parent
|
|
@@ -338,7 +338,7 @@ class at {
|
|
|
338
338
|
ea: [0, 0, 0, 0]
|
|
339
339
|
// External acceleration [m/s^2]
|
|
340
340
|
};
|
|
341
|
-
c.boneParent.matrixWorld.decompose(
|
|
341
|
+
c.boneParent.matrixWorld.decompose(O, me, de), O.copy(Oe).applyQuaternion(me).setY(0).normalize(), me.premultiply(je.setFromUnitVectors(Oe, O).invert()).normalize(), c.qWorldInverseYaw = me.clone().normalize(), this.data.push(c), this.dict[u] = c;
|
|
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 (l) {
|
|
@@ -356,22 +356,22 @@ class at {
|
|
|
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],
|
|
359
|
+
if (o = this.data[e], O.copy(o.vWorld), Ie.copy(o.boneParent.matrixWorld), Le.copy(Ie).invert(), o.vWorld.setFromMatrixPosition(Ie), O.applyMatrix4(Le), O.length() > 0.5 && (console.info("Info: Unrealistic jump of " + O.length().toFixed(2) + " meters."), O.setLength(0.5)), O.applyQuaternion(o.bone.quaternion), H[0] = O.x, H[1] = O.y, H[2] = -O.z, H[3] = O.length() / 3, o.children)
|
|
360
360
|
for (n = 0, s = o.children.length; n < s; n++)
|
|
361
361
|
m = o.children[n], H[0] -= m.v[0] * t / 3, H[1] -= m.v[1] * t / 3, H[2] += m.v[2] * t / 3, H[3] -= m.v[3] * t / 3;
|
|
362
|
-
if (m = this.opt.sensitivityFactor, H[0] *= o.ext * m, H[1] *= o.ext * m, H[2] *= o.ext * m, H[3] *= o.ext * m, o.isX && (m = H[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 + H[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 = H[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 + H[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 = H[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 + H[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 = H[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 + H[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), H[0] = o.p[0], H[1] = o.p[1], H[2] = o.p[2], H[3] = o.p[3], m = this.opt.movementFactor, H[0] *= m, H[1] *= m, H[2] *= m, H[3] *= m, o.dl && (m = o.dl, H[0] += m[0], H[1] += m[1], H[2] += m[2]), o.dw && (m = o.dw,
|
|
362
|
+
if (m = this.opt.sensitivityFactor, H[0] *= o.ext * m, H[1] *= o.ext * m, H[2] *= o.ext * m, H[3] *= o.ext * m, o.isX && (m = H[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 + H[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 = H[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 + H[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 = H[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 + H[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 = H[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 + H[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), H[0] = o.p[0], H[1] = o.p[1], H[2] = o.p[2], H[3] = o.p[3], m = this.opt.movementFactor, H[0] *= m, H[1] *= m, H[2] *= m, H[3] *= m, o.dl && (m = o.dl, H[0] += m[0], H[1] += m[1], H[2] += m[2]), o.dw && (m = o.dw, O.set(
|
|
363
363
|
o.vBasis.x + H[0],
|
|
364
364
|
o.vBasis.y + H[1],
|
|
365
365
|
o.vBasis.z + H[2]
|
|
366
|
-
),
|
|
366
|
+
), O.applyMatrix4(Ie), O.x += m[0], O.y += m[1], O.z += m[2], O.applyMatrix4(Le), H[0] += O.x - o.vBasis.x, H[1] += O.y - o.vBasis.y, H[2] += O.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && H[0] < m[0][0] && (H[0] = m[0][0]), m[0][1] !== null && H[0] > m[0][1] && (H[0] = m[0][1])), m[1] && (m[1][0] !== null && H[1] < m[1][0] && (H[1] = m[1][0]), m[1][1] !== null && H[1] > m[1][1] && (H[1] = m[1][1])), m[2] && (m[2][0] !== null && H[2] < m[2][0] && (H[2] = m[2][0]), m[2][1] !== null && H[2] > m[2][1] && (H[2] = m[2][1])), m[3] && (m[3][0] !== null && H[3] < m[3][0] && (H[3] = m[3][0]), m[3][1] !== null && H[3] > m[3][1] && (H[3] = m[3][1]))), o.isPoint)
|
|
367
367
|
o.bone.position.set(
|
|
368
368
|
o.vBasis.x + H[0],
|
|
369
369
|
o.vBasis.y + H[1],
|
|
370
370
|
o.vBasis.z - H[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(
|
|
372
|
+
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(O, me, de), O.copy(Oe).applyQuaternion(me).setY(0).normalize(), me.premultiply(je.setFromUnitVectors(Oe, O).invert()).normalize(), o.boneParent.quaternion.multiply(me.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(H[0] / o.l), me.setFromAxisAngle(rt, -m), o.boneParent.quaternion.multiply(me)), o.isY && (m = o.l / 3, m = m * Math.tanh(H[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(H[2] / o.l), me.setFromAxisAngle(st, -m), o.boneParent.quaternion.multiply(me)), o.isT && (m = 1.5 * Math.tanh(H[3] * 1.5), me.setFromAxisAngle(at, -m), o.boneParent.quaternion.multiply(me)), 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], de.set(0, 0, 0), m.deltaLocal && (de.x += m.deltaLocal[0], de.y += m.deltaLocal[1], de.z += m.deltaLocal[2]), de.applyMatrix4(m.bone.matrixWorld), Le.copy(o.boneParent.matrixWorld).invert(), de.applyMatrix4(Le), O.copy(o.bone.position), !(O.distanceToSquared(de) >= m.radiusSq) && (xe = O.length(), ge = de.length(), !(ge > m.radius + xe) && (ge < Math.abs(m.radius - xe) || (ge = (ge * ge + xe * xe - m.radiusSq) / (2 * ge), de.normalize(), Be.copy(de).multiplyScalar(ge), ge = Math.sqrt(xe * xe - ge * ge), O.subVectors(O, Be).projectOnPlane(de).normalize().multiplyScalar(ge), Pe.subVectors(o.vBasis, Be).projectOnPlane(de).normalize(), xe = Pe.dot(O), xe < 0 && (xe = Math.sqrt(ge * ge - xe * xe), Pe.multiplyScalar(xe), O.add(Pe)), O.add(Be).normalize(), de.copy(o.bone.position).normalize(), me.setFromUnitVectors(de, O), o.boneParent.quaternion.premultiply(me), o.boneParent.updateWorldMatrix(!1, !0))));
|
|
375
375
|
}
|
|
376
376
|
this.helpers.isActive && this.updateHelpers();
|
|
377
377
|
}
|
|
@@ -442,17 +442,17 @@ class at {
|
|
|
442
442
|
*/
|
|
443
443
|
updateHelpers() {
|
|
444
444
|
if (m = this.helpers.points, m.bones.length) {
|
|
445
|
-
|
|
445
|
+
Le.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
|
+
Ie.multiplyMatrices(Le, m.bones[e].matrixWorld), O.setFromMatrixPosition(Ie), t.setXYZ(e, O.x, O.y, O.z);
|
|
449
449
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
450
450
|
}
|
|
451
451
|
if (m = this.helpers.lines, m.bones.length) {
|
|
452
|
-
|
|
452
|
+
Le.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
|
+
Ie.multiplyMatrices(Le, m.bones[e].matrixWorld), O.setFromMatrixPosition(Ie), t.setXYZ(n, O.x, O.y, O.z), Ie.multiplyMatrices(Le, m.bones[e].parent.matrixWorld), O.setFromMatrixPosition(Ie), t.setXYZ(n + 1, O.x, O.y, O.z);
|
|
456
456
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
457
457
|
}
|
|
458
458
|
}
|
|
@@ -489,7 +489,7 @@ class at {
|
|
|
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 ct {
|
|
493
493
|
constructor(t) {
|
|
494
494
|
this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
|
|
495
495
|
}
|
|
@@ -608,8 +608,8 @@ class rt {
|
|
|
608
608
|
for (let l = 0; l < i / 2; l++) {
|
|
609
609
|
const d = n[(u + l) * 2], h = n[(u + l) * 2 + 1], p = n[(u + l + i / 2) * 2] * a - n[(u + l + i / 2) * 2 + 1] * c, b = n[(u + l + i / 2) * 2] * c + n[(u + l + i / 2) * 2 + 1] * a;
|
|
610
610
|
n[(u + l) * 2] = d + p, n[(u + l) * 2 + 1] = h + b, n[(u + l + i / 2) * 2] = d - p, n[(u + l + i / 2) * 2 + 1] = h - b;
|
|
611
|
-
const f = a * o - c * r,
|
|
612
|
-
a = f, c =
|
|
611
|
+
const f = a * o - c * r, k = a * r + c * o;
|
|
612
|
+
a = f, c = k;
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
}
|
|
@@ -814,7 +814,7 @@ class rt {
|
|
|
814
814
|
return i * s;
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
-
class
|
|
817
|
+
class ut {
|
|
818
818
|
/**
|
|
819
819
|
* @constructor
|
|
820
820
|
*/
|
|
@@ -1396,11 +1396,11 @@ class lt {
|
|
|
1396
1396
|
return e;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
const
|
|
1399
|
+
const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1400
1400
|
__proto__: null,
|
|
1401
|
-
LipsyncEn:
|
|
1401
|
+
LipsyncEn: ut
|
|
1402
1402
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1403
|
-
class
|
|
1403
|
+
class dt {
|
|
1404
1404
|
/**
|
|
1405
1405
|
* @constructor
|
|
1406
1406
|
*/
|
|
@@ -1754,11 +1754,11 @@ class ut {
|
|
|
1754
1754
|
return e;
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
|
-
const
|
|
1757
|
+
const mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1758
1758
|
__proto__: null,
|
|
1759
|
-
LipsyncDe:
|
|
1759
|
+
LipsyncDe: dt
|
|
1760
1760
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1761
|
-
class
|
|
1761
|
+
class pt {
|
|
1762
1762
|
/**
|
|
1763
1763
|
* @constructor
|
|
1764
1764
|
*/
|
|
@@ -2289,11 +2289,11 @@ class dt {
|
|
|
2289
2289
|
return e;
|
|
2290
2290
|
}
|
|
2291
2291
|
}
|
|
2292
|
-
const
|
|
2292
|
+
const gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2293
2293
|
__proto__: null,
|
|
2294
|
-
LipsyncFr:
|
|
2294
|
+
LipsyncFr: pt
|
|
2295
2295
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2296
|
-
class
|
|
2296
|
+
class yt {
|
|
2297
2297
|
/**
|
|
2298
2298
|
* @constructor
|
|
2299
2299
|
*/
|
|
@@ -2436,11 +2436,11 @@ class pt {
|
|
|
2436
2436
|
return e;
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
const
|
|
2439
|
+
const ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2440
2440
|
__proto__: null,
|
|
2441
|
-
LipsyncFi:
|
|
2441
|
+
LipsyncFi: yt
|
|
2442
2442
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2443
|
-
class
|
|
2443
|
+
class xt {
|
|
2444
2444
|
/**
|
|
2445
2445
|
* @constructor
|
|
2446
2446
|
*/
|
|
@@ -2620,24 +2620,24 @@ class yt {
|
|
|
2620
2620
|
return e;
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
2623
|
-
const
|
|
2623
|
+
const bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2624
2624
|
__proto__: null,
|
|
2625
|
-
LipsyncLt:
|
|
2626
|
-
}, Symbol.toStringTag, { value: "Module" })), xt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSB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IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKH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ICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Ze = {
|
|
2627
|
-
en:
|
|
2628
|
-
de:
|
|
2629
|
-
fr:
|
|
2630
|
-
fi:
|
|
2631
|
-
lt:
|
|
2632
|
-
}, oe = new x.Quaternion(),
|
|
2625
|
+
LipsyncLt: xt
|
|
2626
|
+
}, Symbol.toStringTag, { value: "Module" })), vt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0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ICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb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: gt,
|
|
2630
|
+
fi: ft,
|
|
2631
|
+
lt: bt
|
|
2632
|
+
}, oe = new x.Quaternion(), K = new x.Euler(), ke = new x.Vector3(), Ce = new x.Vector3(), Qe = new x.Box3();
|
|
2633
2633
|
new x.Matrix4();
|
|
2634
2634
|
new x.Matrix4();
|
|
2635
2635
|
new x.Vector3();
|
|
2636
2636
|
new x.Vector3(0, 0, 1);
|
|
2637
|
-
const
|
|
2637
|
+
const Rt = new x.Vector3(1, 0, 0);
|
|
2638
2638
|
new x.Vector3(0, 1, 0);
|
|
2639
2639
|
new x.Vector3(0, 0, 1);
|
|
2640
|
-
class
|
|
2640
|
+
class Ze {
|
|
2641
2641
|
/**
|
|
2642
2642
|
* Avatar.
|
|
2643
2643
|
* @typedef {Object} Avatar
|
|
@@ -2763,7 +2763,7 @@ class Ue {
|
|
|
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 ot(), 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: {
|
|
@@ -4086,7 +4086,7 @@ class Ue {
|
|
|
4086
4086
|
this.opt.lightSpotDispersion
|
|
4087
4087
|
), this.setLighting(this.opt);
|
|
4088
4088
|
const r = new x.PMREMGenerator(this.renderer);
|
|
4089
|
-
r.compileEquirectangularShader(), this.scene.environment = r.fromScene(new
|
|
4089
|
+
r.compileEquirectangularShader(), this.scene.environment = r.fromScene(new it()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new et(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;
|
|
4090
4090
|
}
|
|
4091
4091
|
this.ikMesh = new x.SkinnedMesh();
|
|
4092
4092
|
const s = {
|
|
@@ -4104,14 +4104,14 @@ class Ue {
|
|
|
4104
4104
|
Object.entries(s).forEach((r, u) => {
|
|
4105
4105
|
const a = new x.Bone();
|
|
4106
4106
|
a.name = r[0], r[1] ? this.ikMesh.getObjectByName(r[1]).add(a) : this.ikMesh.add(a), o.push(a);
|
|
4107
|
-
}), this.ikMesh.bind(new x.Skeleton(o)), this.dynamicbones = new
|
|
4107
|
+
}), this.ikMesh.bind(new x.Skeleton(o)), this.dynamicbones = new lt(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
|
|
4108
4108
|
}
|
|
4109
4109
|
/**
|
|
4110
4110
|
* Helper that re/creates the audio context and the other nodes.
|
|
4111
4111
|
* @param {number} sampleRate
|
|
4112
4112
|
*/
|
|
4113
4113
|
initAudioGraph(t = null) {
|
|
4114
|
-
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
|
|
4114
|
+
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 ct(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(
|
|
4115
4115
|
this.opt.mixerGainSpeech,
|
|
4116
4116
|
this.opt.mixerGainBackground
|
|
4117
4117
|
), this.workletLoaded = !1, this.streamWorkletNode) {
|
|
@@ -4228,13 +4228,13 @@ class Ue {
|
|
|
4228
4228
|
const l = s.morphTargetDictionary[a], d = o.morphAttributes.position[l], h = o.morphAttributes.normal?.[l];
|
|
4229
4229
|
r || (r = new x.Float32BufferAttribute(d.count * 3, 3), h && (u = new x.Float32BufferAttribute(d.count * 3, 3)));
|
|
4230
4230
|
for (let p = 0; p < d.count; p++) {
|
|
4231
|
-
const b = r.getX(p) + d.getX(p) * c, f = r.getY(p) + d.getY(p) * c,
|
|
4232
|
-
r.setXYZ(p, b, f,
|
|
4231
|
+
const b = r.getX(p) + d.getX(p) * c, f = r.getY(p) + d.getY(p) * c, k = r.getZ(p) + d.getZ(p) * c;
|
|
4232
|
+
r.setXYZ(p, b, f, k);
|
|
4233
4233
|
}
|
|
4234
4234
|
if (h)
|
|
4235
4235
|
for (let p = 0; p < d.count; p++) {
|
|
4236
|
-
const b = u.getX(p) + h.getX(p) * c, f = u.getY(p) + h.getY(p) * c,
|
|
4237
|
-
u.setXYZ(p, b, f,
|
|
4236
|
+
const b = u.getX(p) + h.getX(p) * c, f = u.getY(p) + h.getY(p) * c, k = u.getZ(p) + h.getZ(p) * c;
|
|
4237
|
+
u.setXYZ(p, b, f, k);
|
|
4238
4238
|
}
|
|
4239
4239
|
}
|
|
4240
4240
|
if (r) {
|
|
@@ -4252,9 +4252,9 @@ class Ue {
|
|
|
4252
4252
|
async showAvatar(t, e = null) {
|
|
4253
4253
|
if (!t || !t.hasOwnProperty("url"))
|
|
4254
4254
|
throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
|
|
4255
|
-
const n = new
|
|
4255
|
+
const n = new tt();
|
|
4256
4256
|
if (this.dracoEnabled) {
|
|
4257
|
-
const a = new
|
|
4257
|
+
const a = new nt();
|
|
4258
4258
|
a.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(a);
|
|
4259
4259
|
}
|
|
4260
4260
|
let i = await n.loadAsync(t.url, e);
|
|
@@ -4412,9 +4412,9 @@ class Ue {
|
|
|
4412
4412
|
updatePoseDelta() {
|
|
4413
4413
|
for (const [t, e] of Object.entries(this.poseDelta.props)) {
|
|
4414
4414
|
if (e.x === 0 && e.y === 0 && e.z === 0) continue;
|
|
4415
|
-
|
|
4415
|
+
K.set(e.x, e.y, e.z);
|
|
4416
4416
|
const n = this.poseAvatar.props[t];
|
|
4417
|
-
n.isQuaternion ? (oe.setFromEuler(
|
|
4417
|
+
n.isQuaternion ? (oe.setFromEuler(K), n.multiply(oe)) : n.isVector3 && n.add(K);
|
|
4418
4418
|
}
|
|
4419
4419
|
}
|
|
4420
4420
|
/**
|
|
@@ -5186,7 +5186,7 @@ class Ue {
|
|
|
5186
5186
|
}, i.x ? new x.Vector3(i.x, i.y, i.z) : null, !0, i.d);
|
|
5187
5187
|
break;
|
|
5188
5188
|
}
|
|
5189
|
-
if ((u || a) && (
|
|
5189
|
+
if ((u || a) && (K.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), K.x = Math.max(-0.9, Math.min(0.9, 2 * K.x - 0.5)), K.y = Math.max(-0.9, Math.min(0.9, -2.5 * K.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: K.x < 0 ? -K.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: K.x < 0 ? 0 : K.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: K.y < 0 ? -K.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: K.y < 0 ? 0 : K.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: K.y < 0 ? 0 : K.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: K.y < 0 ? -K.y : 0, needsUpdate: !0 }), a && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
|
|
5190
5190
|
name: "headmove",
|
|
5191
5191
|
dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
|
|
5192
5192
|
vs: {
|
|
@@ -5207,7 +5207,7 @@ class Ue {
|
|
|
5207
5207
|
eyeLookOutRight: [null, 0],
|
|
5208
5208
|
eyeContact: [0]
|
|
5209
5209
|
}
|
|
5210
|
-
})))), 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 + r / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), this.applyShoulderAdjustmentToBones(), (this.isSpeaking || this.isListening) && u ? r > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = r) : (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 && (oe.setFromAxisAngle(
|
|
5210
|
+
})))), 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 + r / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), this.applyShoulderAdjustmentToBones(), (this.isSpeaking || this.isListening) && u ? r > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = r) : (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 && (oe.setFromAxisAngle(Rt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(oe)), Qe.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ke), ke.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(Ce), Ce.sub(this.armature.position), this.objectHips.position.y -= Qe.min.y / 2, this.objectHips.position.x -= (ke.x + Ce.x) / 4, this.objectHips.position.z -= (ke.z + Ce.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
|
|
5211
5211
|
this.stats && this.stats.end();
|
|
5212
5212
|
else {
|
|
5213
5213
|
if (this.cameraClock !== null && this.cameraClock < 1e3) {
|
|
@@ -5238,8 +5238,8 @@ class Ue {
|
|
|
5238
5238
|
if (!this.lipsync.hasOwnProperty(t)) {
|
|
5239
5239
|
const n = t.toLowerCase(), i = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
|
|
5240
5240
|
try {
|
|
5241
|
-
const s =
|
|
5242
|
-
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(
|
|
5241
|
+
const s = Ye[n];
|
|
5242
|
+
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(Ye));
|
|
5243
5243
|
} catch (s) {
|
|
5244
5244
|
console.warn(`Failed to load lip-sync module for ${t}:`, s);
|
|
5245
5245
|
}
|
|
@@ -5278,10 +5278,10 @@ class Ue {
|
|
|
5278
5278
|
let c = "", l = "", d = 0, h = [], p = [];
|
|
5279
5279
|
const b = Array.from(this.segmenter.segment(t), (f) => f.segment);
|
|
5280
5280
|
for (let f = 0; f < b.length; f++) {
|
|
5281
|
-
const
|
|
5281
|
+
const k = f === b.length - 1, T = b[f].match(r);
|
|
5282
5282
|
let g = b[f].match(s);
|
|
5283
|
-
const
|
|
5284
|
-
if (g && !
|
|
5283
|
+
const N = b[f].match(u), F = b[f].match(o);
|
|
5284
|
+
if (g && !k && !N && b[f + 1].match(s) && (g = !1), n && (c += b[f]), T && (!i || i.every((I) => f < I[0] || f > I[1])) && (l += b[f]), (F || g || k) && (l.length && (l = this.lipsyncPreProcessText(l, a), l.length && h.push({
|
|
5285
5285
|
mark: d,
|
|
5286
5286
|
word: l
|
|
5287
5287
|
})), c.length && (p.push({
|
|
@@ -5294,27 +5294,27 @@ class Ue {
|
|
|
5294
5294
|
}), c = ""), l.length)) {
|
|
5295
5295
|
const I = this.lipsyncWordsToVisemes(l, a);
|
|
5296
5296
|
if (I && I.visemes && I.visemes.length) {
|
|
5297
|
-
const
|
|
5298
|
-
for (let
|
|
5297
|
+
const U = I.times[I.visemes.length - 1] + I.durations[I.visemes.length - 1];
|
|
5298
|
+
for (let S = 0; S < I.visemes.length; S++)
|
|
5299
5299
|
p.push({
|
|
5300
5300
|
mark: d,
|
|
5301
5301
|
template: { name: "viseme" },
|
|
5302
|
-
ts: [(I.times[
|
|
5302
|
+
ts: [(I.times[S] - 0.6) / U, (I.times[S] + 0.5) / U, (I.times[S] + I.durations[S] + 0.5) / U],
|
|
5303
5303
|
vs: {
|
|
5304
|
-
["viseme_" + I.visemes[
|
|
5304
|
+
["viseme_" + I.visemes[S]]: [null, I.visemes[S] === "PP" || I.visemes[S] === "FF" ? 0.9 : 0.6, 0]
|
|
5305
5305
|
}
|
|
5306
5306
|
});
|
|
5307
5307
|
}
|
|
5308
5308
|
l = "", d++;
|
|
5309
5309
|
}
|
|
5310
|
-
if (g ||
|
|
5311
|
-
if (h.length ||
|
|
5310
|
+
if (g || k) {
|
|
5311
|
+
if (h.length || k && p.length) {
|
|
5312
5312
|
const I = {
|
|
5313
5313
|
anim: p
|
|
5314
5314
|
};
|
|
5315
5315
|
n && (I.onSubtitles = n), h.length && !e.avatarMute && (I.text = h, e.avatarMood && (I.mood = e.avatarMood), e.ttsLang && (I.lang = e.ttsLang), e.ttsVoice && (I.voice = e.ttsVoice), e.ttsRate && (I.rate = e.ttsRate), e.ttsVoice && (I.pitch = e.ttsPitch), e.ttsVolume && (I.volume = e.ttsVolume)), this.speechQueue.push(I), h = [], l = "", d = 0, p = [];
|
|
5316
5316
|
}
|
|
5317
|
-
if (
|
|
5317
|
+
if (N) {
|
|
5318
5318
|
let I = this.animEmojis[b[f]];
|
|
5319
5319
|
I && I.link && (I = this.animEmojis[I.link]), I && this.speechQueue.push({ emoji: I });
|
|
5320
5320
|
}
|
|
@@ -5412,10 +5412,10 @@ class Ue {
|
|
|
5412
5412
|
let b = 0.6 + this.convertRange(p, [0, c], [0, 0.4]);
|
|
5413
5413
|
if (c = Math.min(c, d.visemes.length * 200), h > 0)
|
|
5414
5414
|
for (let f = 0; f < d.visemes.length; f++) {
|
|
5415
|
-
const
|
|
5415
|
+
const k = a + d.times[f] / h * c, T = d.durations[f] / h * c;
|
|
5416
5416
|
o.push({
|
|
5417
5417
|
template: { name: "viseme" },
|
|
5418
|
-
ts: [
|
|
5418
|
+
ts: [k - Math.min(60, 2 * T / 3), k + Math.min(25, T / 2), k + T + Math.min(60, T / 2)],
|
|
5419
5419
|
vs: {
|
|
5420
5420
|
["viseme_" + d.visemes[f]]: [null, d.visemes[f] === "PP" || d.visemes[f] === "FF" ? 0.9 : b, 0]
|
|
5421
5421
|
}
|
|
@@ -5497,7 +5497,7 @@ class Ue {
|
|
|
5497
5497
|
s.lang = o, s.rate = Math.max(0.1, Math.min(10, r)), s.pitch = Math.max(0, Math.min(2, u)), s.volume = Math.max(0, Math.min(1, a));
|
|
5498
5498
|
const c = speechSynthesis.getVoices(), l = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
|
|
5499
5499
|
if (l && c.length > 0) {
|
|
5500
|
-
const g = c.find((
|
|
5500
|
+
const g = c.find((N) => N.name.includes(l) || N.lang === o);
|
|
5501
5501
|
g && (s.voice = g);
|
|
5502
5502
|
}
|
|
5503
5503
|
const d = i.length * 100 / s.rate, h = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (d / 1e3), this.audioCtx.sampleRate), p = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", b = this.lipsyncPreProcessText(i, p), f = this.lipsyncWordsToVisemes(b, p);
|
|
@@ -5509,22 +5509,22 @@ class Ue {
|
|
|
5509
5509
|
hasVisemes: f && f.visemes && f.visemes.length > 0,
|
|
5510
5510
|
estimatedDuration: d
|
|
5511
5511
|
});
|
|
5512
|
-
const
|
|
5512
|
+
const k = [];
|
|
5513
5513
|
if (f && f.visemes && f.visemes.length > 0) {
|
|
5514
5514
|
const g = f.times[f.visemes.length - 1] + f.durations[f.visemes.length - 1];
|
|
5515
|
-
for (let
|
|
5516
|
-
const
|
|
5517
|
-
|
|
5515
|
+
for (let N = 0; N < f.visemes.length; N++) {
|
|
5516
|
+
const F = f.visemes[N], I = f.times[N] / g, U = f.durations[N] / g, S = I * d, R = U * d;
|
|
5517
|
+
k.push({
|
|
5518
5518
|
template: { name: "viseme" },
|
|
5519
|
-
ts: [
|
|
5519
|
+
ts: [S - Math.min(60, 2 * R / 3), S + Math.min(25, R / 2), S + R + Math.min(60, R / 2)],
|
|
5520
5520
|
vs: {
|
|
5521
|
-
["viseme_" +
|
|
5521
|
+
["viseme_" + F]: [null, F === "PP" || F === "FF" ? 0.9 : 0.6, 0]
|
|
5522
5522
|
}
|
|
5523
5523
|
});
|
|
5524
5524
|
}
|
|
5525
5525
|
}
|
|
5526
|
-
const
|
|
5527
|
-
this.audioPlaylist.push({ anim:
|
|
5526
|
+
const T = [...t.anim, ...k];
|
|
5527
|
+
this.audioPlaylist.push({ anim: T, audio: h }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
|
|
5528
5528
|
e();
|
|
5529
5529
|
}, s.onerror = (g) => {
|
|
5530
5530
|
console.error("Speech synthesis error:", g.error), n(g.error);
|
|
@@ -5591,8 +5591,8 @@ class Ue {
|
|
|
5591
5591
|
const h = e.toLowerCase().split(/\s+/), p = [];
|
|
5592
5592
|
for (const b of h)
|
|
5593
5593
|
for (const f of b) {
|
|
5594
|
-
let
|
|
5595
|
-
"aeiou".includes(f) ?
|
|
5594
|
+
let k = "aa";
|
|
5595
|
+
"aeiou".includes(f) ? k = "aa" : "bp".includes(f) ? k = "PP" : "fv".includes(f) ? k = "FF" : "st".includes(f) ? k = "SS" : "dln".includes(f) ? k = "DD" : "kg".includes(f) ? k = "kk" : "rw".includes(f) && (k = "RR"), p.push(k);
|
|
5596
5596
|
}
|
|
5597
5597
|
a = {
|
|
5598
5598
|
visemes: p.map((b, f) => ({
|
|
@@ -5689,8 +5689,8 @@ class Ue {
|
|
|
5689
5689
|
const h = e.toLowerCase().split(/\s+/), p = [];
|
|
5690
5690
|
for (const b of h)
|
|
5691
5691
|
for (const f of b) {
|
|
5692
|
-
let
|
|
5693
|
-
"aeiou".includes(f) ?
|
|
5692
|
+
let k = "aa";
|
|
5693
|
+
"aeiou".includes(f) ? k = "aa" : "bp".includes(f) ? k = "PP" : "fv".includes(f) ? k = "FF" : "st".includes(f) ? k = "SS" : "dln".includes(f) ? k = "DD" : "kg".includes(f) ? k = "kk" : "rw".includes(f) && (k = "RR"), p.push(k);
|
|
5694
5694
|
}
|
|
5695
5695
|
a = {
|
|
5696
5696
|
visemes: p.map((b, f) => ({
|
|
@@ -5922,7 +5922,7 @@ class Ue {
|
|
|
5922
5922
|
}
|
|
5923
5923
|
if (!this.workletLoaded)
|
|
5924
5924
|
try {
|
|
5925
|
-
const r = this.audioCtx.audioWorklet.addModule(
|
|
5925
|
+
const r = this.audioCtx.audioWorklet.addModule(vt.href), u = new Promise(
|
|
5926
5926
|
(a, c) => setTimeout(() => c(new Error("Worklet loading timed out")), 5e3)
|
|
5927
5927
|
);
|
|
5928
5928
|
await Promise.race([r, u]), this.workletLoaded = !0;
|
|
@@ -6160,7 +6160,7 @@ class Ue {
|
|
|
6160
6160
|
*/
|
|
6161
6161
|
lookAtCamera(t) {
|
|
6162
6162
|
let e;
|
|
6163
|
-
if (this.speakTo && (e = new x.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0),
|
|
6163
|
+
if (this.speakTo && (e = new x.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ke.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), Ce.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ke, Ce).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) {
|
|
6164
6164
|
if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
|
|
6165
6165
|
if (this.avatar.avatarIgnoreCamera) {
|
|
6166
6166
|
this.lookAhead(t);
|
|
@@ -6173,14 +6173,14 @@ class Ue {
|
|
|
6173
6173
|
this.lookAt(null, null, t);
|
|
6174
6174
|
return;
|
|
6175
6175
|
}
|
|
6176
|
-
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0),
|
|
6177
|
-
const n = new x.Vector3().subVectors(e,
|
|
6178
|
-
|
|
6179
|
-
const r = new x.Quaternion().setFromEuler(
|
|
6180
|
-
|
|
6181
|
-
let a =
|
|
6176
|
+
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ke.setFromMatrixPosition(this.objectLeftEye.matrixWorld), Ce.setFromMatrixPosition(this.objectRightEye.matrixWorld), ke.add(Ce).divideScalar(2), oe.copy(this.armature.quaternion), oe.multiply(this.poseTarget.props["Hips.quaternion"]), oe.multiply(this.poseTarget.props["Spine.quaternion"]), oe.multiply(this.poseTarget.props["Spine1.quaternion"]), oe.multiply(this.poseTarget.props["Spine2.quaternion"]), oe.multiply(this.poseTarget.props["Neck.quaternion"]), oe.multiply(this.poseTarget.props["Head.quaternion"]);
|
|
6177
|
+
const n = new x.Vector3().subVectors(e, ke).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
|
|
6178
|
+
K.set(s, i, 0, "YXZ");
|
|
6179
|
+
const r = new x.Quaternion().setFromEuler(K), u = new x.Quaternion().copy(r).multiply(oe.clone().invert());
|
|
6180
|
+
K.setFromQuaternion(u, "YXZ");
|
|
6181
|
+
let a = K.x / (40 / 24) + 0.2, c = K.y / (9 / 4), l = Math.min(0.6, Math.max(-0.3, a)), d = Math.min(0.8, Math.max(-0.8, c)), h = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
|
|
6182
6182
|
if (t) {
|
|
6183
|
-
let b = this.animQueue.findIndex((
|
|
6183
|
+
let b = this.animQueue.findIndex((k) => k.template.name === "lookat");
|
|
6184
6184
|
b !== -1 && this.animQueue.splice(b, 1);
|
|
6185
6185
|
const f = {
|
|
6186
6186
|
name: "lookat",
|
|
@@ -6213,20 +6213,20 @@ class Ue {
|
|
|
6213
6213
|
const s = new x.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new x.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), r = new x.Vector3().addVectors(s, o).divideScalar(2);
|
|
6214
6214
|
r.project(this.camera);
|
|
6215
6215
|
let u = (r.x + 1) / 2 * i.width + i.left, a = -(r.y - 1) / 2 * i.height + i.top;
|
|
6216
|
-
t === null && (t = u), e === null && (e = a), oe.copy(this.armature.quaternion), oe.multiply(this.poseTarget.props["Hips.quaternion"]), oe.multiply(this.poseTarget.props["Spine.quaternion"]), oe.multiply(this.poseTarget.props["Spine1.quaternion"]), oe.multiply(this.poseTarget.props["Spine2.quaternion"]), oe.multiply(this.poseTarget.props["Neck.quaternion"]), oe.multiply(this.poseTarget.props["Head.quaternion"]),
|
|
6217
|
-
let c =
|
|
6218
|
-
f = Math.min(0.6, Math.max(-0.3, f)),
|
|
6219
|
-
let
|
|
6216
|
+
t === null && (t = u), e === null && (e = a), oe.copy(this.armature.quaternion), oe.multiply(this.poseTarget.props["Hips.quaternion"]), oe.multiply(this.poseTarget.props["Spine.quaternion"]), oe.multiply(this.poseTarget.props["Spine1.quaternion"]), oe.multiply(this.poseTarget.props["Spine2.quaternion"]), oe.multiply(this.poseTarget.props["Neck.quaternion"]), oe.multiply(this.poseTarget.props["Head.quaternion"]), K.setFromQuaternion(oe);
|
|
6217
|
+
let c = K.x / (40 / 24), l = K.y / (9 / 4), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), h = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), p = Math.max(window.innerWidth - u, u), b = Math.max(window.innerHeight - a, a), f = this.convertRange(e, [a - b, a + b], [-0.3, 0.6]) - c + d, k = this.convertRange(t, [u - p, u + p], [-0.8, 0.8]) - l + h;
|
|
6218
|
+
f = Math.min(0.6, Math.max(-0.3, f)), k = Math.min(0.8, Math.max(-0.8, k));
|
|
6219
|
+
let T = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
|
|
6220
6220
|
if (n) {
|
|
6221
|
-
let
|
|
6222
|
-
|
|
6223
|
-
const
|
|
6221
|
+
let N = this.animQueue.findIndex((I) => I.template.name === "lookat");
|
|
6222
|
+
N !== -1 && this.animQueue.splice(N, 1);
|
|
6223
|
+
const F = {
|
|
6224
6224
|
name: "lookat",
|
|
6225
6225
|
dt: [750, n],
|
|
6226
6226
|
vs: {
|
|
6227
|
-
bodyRotateX: [f +
|
|
6228
|
-
bodyRotateY: [
|
|
6229
|
-
eyesRotateX: [-3 *
|
|
6227
|
+
bodyRotateX: [f + T],
|
|
6228
|
+
bodyRotateY: [k + g],
|
|
6229
|
+
eyesRotateX: [-3 * T + 0.1],
|
|
6230
6230
|
eyesRotateY: [-5 * g],
|
|
6231
6231
|
browInnerUp: [[0, 0.7]],
|
|
6232
6232
|
mouthLeft: [[0, 0.7]],
|
|
@@ -6235,7 +6235,7 @@ class Ue {
|
|
|
6235
6235
|
headMove: [0]
|
|
6236
6236
|
}
|
|
6237
6237
|
};
|
|
6238
|
-
this.animQueue.push(this.animFactory(
|
|
6238
|
+
this.animQueue.push(this.animFactory(F));
|
|
6239
6239
|
}
|
|
6240
6240
|
}
|
|
6241
6241
|
/**
|
|
@@ -6445,7 +6445,7 @@ class Ue {
|
|
|
6445
6445
|
} catch (h) {
|
|
6446
6446
|
console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, h);
|
|
6447
6447
|
}
|
|
6448
|
-
const l = new
|
|
6448
|
+
const l = new Xe();
|
|
6449
6449
|
let d;
|
|
6450
6450
|
try {
|
|
6451
6451
|
d = await l.loadAsync(t, e);
|
|
@@ -6503,7 +6503,7 @@ class Ue {
|
|
|
6503
6503
|
return "LeftShoulder";
|
|
6504
6504
|
if (y.includes("right") && (y.includes("shoulder") || y.includes("clavicle")) && p.has("RightShoulder"))
|
|
6505
6505
|
return "RightShoulder";
|
|
6506
|
-
const
|
|
6506
|
+
const E = {
|
|
6507
6507
|
// Arm bones - exact matches
|
|
6508
6508
|
LeftArm: "LeftArm",
|
|
6509
6509
|
leftArm: "LeftArm",
|
|
@@ -6543,46 +6543,46 @@ class Ue {
|
|
|
6543
6543
|
Root: "Hips",
|
|
6544
6544
|
root: "Hips"
|
|
6545
6545
|
};
|
|
6546
|
-
if (
|
|
6547
|
-
const
|
|
6548
|
-
if (p.has(
|
|
6549
|
-
return
|
|
6546
|
+
if (E[z]) {
|
|
6547
|
+
const D = E[z];
|
|
6548
|
+
if (p.has(D))
|
|
6549
|
+
return D;
|
|
6550
6550
|
}
|
|
6551
|
-
for (const
|
|
6552
|
-
if (
|
|
6553
|
-
return
|
|
6554
|
-
for (const
|
|
6555
|
-
const
|
|
6556
|
-
if ((y.includes("left") &&
|
|
6557
|
-
return
|
|
6551
|
+
for (const D of p)
|
|
6552
|
+
if (D.toLowerCase() === y)
|
|
6553
|
+
return D;
|
|
6554
|
+
for (const D of p) {
|
|
6555
|
+
const B = D.toLowerCase();
|
|
6556
|
+
if ((y.includes("left") && B.includes("left") || y.includes("right") && B.includes("right")) && (y.includes("arm") && B.includes("arm") && !B.includes("fore") || y.includes("forearm") && B.includes("forearm") || y.includes("hand") && B.includes("hand") && !B.includes("index") && !B.includes("thumb") || y.includes("shoulder") && B.includes("shoulder")))
|
|
6557
|
+
return D;
|
|
6558
6558
|
}
|
|
6559
6559
|
return null;
|
|
6560
|
-
},
|
|
6560
|
+
}, k = /* @__PURE__ */ new Set();
|
|
6561
6561
|
h.tracks.forEach((R) => {
|
|
6562
6562
|
const z = R.name.split(".");
|
|
6563
|
-
|
|
6564
|
-
}), console.log("=== Ready Player Me Animation Bone Analysis ==="), console.log("FBX bone names:", Array.from(
|
|
6565
|
-
const
|
|
6563
|
+
k.add(z[0]);
|
|
6564
|
+
}), console.log("=== Ready Player Me Animation Bone Analysis ==="), console.log("FBX bone names:", Array.from(k).sort().join(", ")), console.log("Avatar skeleton bone names:", Array.from(p).sort().join(", "));
|
|
6565
|
+
const T = Array.from(k).filter(
|
|
6566
6566
|
(R) => R.toLowerCase().includes("arm") || R.toLowerCase().includes("hand") || R.toLowerCase().includes("shoulder")
|
|
6567
6567
|
), g = Array.from(p).filter(
|
|
6568
6568
|
(R) => R.includes("Arm") || R.includes("Hand") || R.includes("Shoulder")
|
|
6569
6569
|
);
|
|
6570
|
-
console.log("FBX arm/hand/shoulder bones:",
|
|
6571
|
-
const
|
|
6570
|
+
console.log("FBX arm/hand/shoulder bones:", T.sort().join(", ")), console.log("Avatar arm/hand/shoulder bones:", g.sort().join(", "));
|
|
6571
|
+
const N = [], F = /* @__PURE__ */ new Set();
|
|
6572
6572
|
let I = 0;
|
|
6573
6573
|
if (h.tracks.forEach((R) => {
|
|
6574
|
-
const y = R.name.replaceAll("mixamorig", "").split("."),
|
|
6575
|
-
if (
|
|
6574
|
+
const y = R.name.replaceAll("mixamorig", "").split("."), E = y[0], D = y[1], B = f(E);
|
|
6575
|
+
if (B && (B === "LeftShoulder" || B === "RightShoulder") && (D === "quaternion" || D === "rotation")) {
|
|
6576
6576
|
I++;
|
|
6577
6577
|
return;
|
|
6578
6578
|
}
|
|
6579
|
-
if (
|
|
6580
|
-
const
|
|
6581
|
-
ae.name =
|
|
6579
|
+
if (B && D) {
|
|
6580
|
+
const Y = `${B}.${D}`, ae = R.clone();
|
|
6581
|
+
ae.name = Y, N.push(ae), E !== B && b.set(E, B);
|
|
6582
6582
|
} else
|
|
6583
|
-
|
|
6584
|
-
}), I > 0 && console.log(`✓ Filtered out ${I} shoulder rotation track(s) to prevent high shoulders`),
|
|
6585
|
-
h = new x.AnimationClip(h.name, h.duration,
|
|
6583
|
+
F.add(E), (E.toLowerCase().includes("arm") || E.toLowerCase().includes("hand") || E.toLowerCase().includes("shoulder")) && console.warn(`⚠️ Arm bone "${E}" could not be mapped to avatar skeleton`);
|
|
6584
|
+
}), I > 0 && console.log(`✓ Filtered out ${I} shoulder rotation track(s) to prevent high shoulders`), F.size > 0 && console.warn(`⚠️ ${F.size} bone(s) could not be mapped:`, Array.from(F).sort().join(", ")), N.length > 0) {
|
|
6585
|
+
h = new x.AnimationClip(h.name, h.duration, N), console.log(`✓ Created animation with ${N.length} mapped tracks (from ${h.tracks.length} original tracks)`), b.size > 0 && console.log(
|
|
6586
6586
|
`✓ Mapped ${b.size} bone(s):`,
|
|
6587
6587
|
Array.from(b.entries()).map(([z, y]) => `${z}→${y}`).join(", ")
|
|
6588
6588
|
);
|
|
@@ -6592,21 +6592,21 @@ class Ue {
|
|
|
6592
6592
|
R.length > 0 ? console.log(`✓ Arm bones mapped: ${R.join(", ")}`) : console.warn("⚠️ No arm bones were mapped! This may cause arm rigging issues.");
|
|
6593
6593
|
} else
|
|
6594
6594
|
console.error("❌ No tracks could be mapped! Animation may not work correctly.");
|
|
6595
|
-
const
|
|
6595
|
+
const U = {};
|
|
6596
6596
|
h.tracks.forEach((R) => {
|
|
6597
6597
|
R.name = R.name.replaceAll("mixamorig", "");
|
|
6598
6598
|
const z = R.name.split(".");
|
|
6599
6599
|
if (z[1] === "position") {
|
|
6600
6600
|
for (let y = 0; y < R.values.length; y++)
|
|
6601
6601
|
R.values[y] = R.values[y] * s;
|
|
6602
|
-
|
|
6603
|
-
} else z[1] === "quaternion" ?
|
|
6602
|
+
U[R.name] = new x.Vector3(R.values[0], R.values[1], R.values[2]);
|
|
6603
|
+
} else z[1] === "quaternion" ? U[R.name] = new x.Quaternion(R.values[0], R.values[1], R.values[2], R.values[3]) : z[1] === "rotation" && (U[z[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(R.values[0], R.values[1], R.values[2], "XYZ")).normalize());
|
|
6604
6604
|
});
|
|
6605
|
-
const
|
|
6606
|
-
|
|
6605
|
+
const S = { props: U };
|
|
6606
|
+
U["Hips.position"] && (U["Hips.position"].y < 0.5 ? S.lying = !0 : S.standing = !0), this.animClips.push({
|
|
6607
6607
|
url: t + "-" + i,
|
|
6608
6608
|
clip: h,
|
|
6609
|
-
pose:
|
|
6609
|
+
pose: S
|
|
6610
6610
|
}), this.playAnimation(t, e, n, i, s);
|
|
6611
6611
|
} else {
|
|
6612
6612
|
const h = "Animation " + t + " (ndx=" + i + ") not found";
|
|
@@ -6644,7 +6644,7 @@ class Ue {
|
|
|
6644
6644
|
let r = this.animQueue.find((u) => u.template.name === "pose");
|
|
6645
6645
|
r && (r.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(o);
|
|
6646
6646
|
} else {
|
|
6647
|
-
let u = await new
|
|
6647
|
+
let u = await new Xe().loadAsync(t, e);
|
|
6648
6648
|
if (u && u.animations && u.animations[i]) {
|
|
6649
6649
|
let a = u.animations[i];
|
|
6650
6650
|
const c = {};
|
|
@@ -6699,7 +6699,7 @@ class Ue {
|
|
|
6699
6699
|
const d = [];
|
|
6700
6700
|
for (let b = 1; b < r.ts.length; b++) d.push(r.ts[b] - r.ts[b - 1]);
|
|
6701
6701
|
const h = o.template?.rescale || d.map((b) => b / c), p = e * 1e3 - c;
|
|
6702
|
-
r.ts = r.ts.map((b, f,
|
|
6702
|
+
r.ts = r.ts.map((b, f, k) => f === 0 ? u : k[f - 1] + d[f - 1] + h[f - 1] * p);
|
|
6703
6703
|
} else {
|
|
6704
6704
|
const d = e * 1e3 / c;
|
|
6705
6705
|
r.ts = r.ts.map((h) => u + d * (h - u));
|
|
@@ -6735,18 +6735,18 @@ class Ue {
|
|
|
6735
6735
|
const s = new x.Vector3(), o = new x.Vector3(), r = new x.Vector3(), u = new x.Vector3(), a = new x.Quaternion(), c = new x.Vector3(), l = new x.Vector3(), d = new x.Vector3(), h = this.ikMesh.getObjectByName(t.root);
|
|
6736
6736
|
h.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), h.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(h.position);
|
|
6737
6737
|
const p = this.ikMesh.getObjectByName(t.effector), b = t.links;
|
|
6738
|
-
b.forEach((
|
|
6739
|
-
|
|
6738
|
+
b.forEach((k) => {
|
|
6739
|
+
k.bone = this.ikMesh.getObjectByName(k.link), k.bone.quaternion.copy(this.getPoseTemplateProp(k.link + ".quaternion"));
|
|
6740
6740
|
}), h.updateMatrixWorld(!0);
|
|
6741
6741
|
const f = t.iterations || 10;
|
|
6742
6742
|
if (e)
|
|
6743
|
-
for (let
|
|
6744
|
-
let
|
|
6745
|
-
for (let g = 0,
|
|
6746
|
-
const
|
|
6747
|
-
|
|
6743
|
+
for (let k = 0; k < f; k++) {
|
|
6744
|
+
let T = !1;
|
|
6745
|
+
for (let g = 0, N = b.length; g < N; g++) {
|
|
6746
|
+
const F = b[g].bone;
|
|
6747
|
+
F.matrixWorld.decompose(u, a, c), a.invert(), o.setFromMatrixPosition(p.matrixWorld), r.subVectors(o, u), r.applyQuaternion(a), r.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
|
|
6748
6748
|
let I = s.dot(r);
|
|
6749
|
-
I > 1 ? I = 1 : I < -1 && (I = -1), I = Math.acos(I), !(I < 1e-5) && (b[g].minAngle !== void 0 && I < b[g].minAngle && (I = b[g].minAngle), b[g].maxAngle !== void 0 && I > b[g].maxAngle && (I = b[g].maxAngle), l.crossVectors(r, s), l.normalize(), oe.setFromAxisAngle(l, I),
|
|
6749
|
+
I > 1 ? I = 1 : I < -1 && (I = -1), I = Math.acos(I), !(I < 1e-5) && (b[g].minAngle !== void 0 && I < b[g].minAngle && (I = b[g].minAngle), b[g].maxAngle !== void 0 && I > b[g].maxAngle && (I = b[g].maxAngle), l.crossVectors(r, s), l.normalize(), oe.setFromAxisAngle(l, I), F.quaternion.multiply(oe), F.rotation.setFromVector3(d.setFromEuler(F.rotation).clamp(new x.Vector3(
|
|
6750
6750
|
b[g].minx !== void 0 ? b[g].minx : -1 / 0,
|
|
6751
6751
|
b[g].miny !== void 0 ? b[g].miny : -1 / 0,
|
|
6752
6752
|
b[g].minz !== void 0 ? b[g].minz : -1 / 0
|
|
@@ -6754,12 +6754,12 @@ class Ue {
|
|
|
6754
6754
|
b[g].maxx !== void 0 ? b[g].maxx : 1 / 0,
|
|
6755
6755
|
b[g].maxy !== void 0 ? b[g].maxy : 1 / 0,
|
|
6756
6756
|
b[g].maxz !== void 0 ? b[g].maxz : 1 / 0
|
|
6757
|
-
))),
|
|
6757
|
+
))), F.updateMatrixWorld(!0), T = !0);
|
|
6758
6758
|
}
|
|
6759
|
-
if (!
|
|
6759
|
+
if (!T) break;
|
|
6760
6760
|
}
|
|
6761
|
-
i && b.forEach((
|
|
6762
|
-
this.poseTarget.props[
|
|
6761
|
+
i && b.forEach((k) => {
|
|
6762
|
+
this.poseTarget.props[k.link + ".quaternion"].copy(k.bone.quaternion), this.poseTarget.props[k.link + ".quaternion"].t = this.animClock, this.poseTarget.props[k.link + ".quaternion"].d = i;
|
|
6763
6763
|
});
|
|
6764
6764
|
}
|
|
6765
6765
|
/**
|
|
@@ -6769,7 +6769,7 @@ class Ue {
|
|
|
6769
6769
|
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();
|
|
6770
6770
|
}
|
|
6771
6771
|
}
|
|
6772
|
-
const
|
|
6772
|
+
const ze = {
|
|
6773
6773
|
apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
|
|
6774
6774
|
// Replace with your actual API key (should start with sk_)
|
|
6775
6775
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
@@ -6789,7 +6789,7 @@ const ke = {
|
|
|
6789
6789
|
josh: "VR6AewLTigWG4xSOukaG"
|
|
6790
6790
|
// Male, American
|
|
6791
6791
|
}
|
|
6792
|
-
},
|
|
6792
|
+
}, De = {
|
|
6793
6793
|
defaultVoice: "aura-2-thalia-en",
|
|
6794
6794
|
// Thalia (Female, English)
|
|
6795
6795
|
voices: {
|
|
@@ -6809,26 +6809,26 @@ const ke = {
|
|
|
6809
6809
|
// Male, English - Powerful
|
|
6810
6810
|
}
|
|
6811
6811
|
};
|
|
6812
|
-
function
|
|
6812
|
+
function We() {
|
|
6813
6813
|
return {
|
|
6814
6814
|
service: "elevenlabs",
|
|
6815
|
-
endpoint:
|
|
6816
|
-
apiKey:
|
|
6817
|
-
defaultVoice:
|
|
6818
|
-
voices:
|
|
6815
|
+
endpoint: ze.endpoint,
|
|
6816
|
+
apiKey: ze.apiKey,
|
|
6817
|
+
defaultVoice: ze.defaultVoice,
|
|
6818
|
+
voices: ze.voices
|
|
6819
6819
|
};
|
|
6820
6820
|
}
|
|
6821
|
-
function
|
|
6822
|
-
const
|
|
6823
|
-
return Object.entries(
|
|
6821
|
+
function Et() {
|
|
6822
|
+
const G = We(), t = [];
|
|
6823
|
+
return Object.entries(G.voices).forEach(([e, n]) => {
|
|
6824
6824
|
t.push({
|
|
6825
6825
|
value: n,
|
|
6826
|
-
label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${
|
|
6826
|
+
label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${G.service})`
|
|
6827
6827
|
});
|
|
6828
6828
|
}), t;
|
|
6829
6829
|
}
|
|
6830
|
-
const
|
|
6831
|
-
avatarUrl:
|
|
6830
|
+
const _e = Ne(({
|
|
6831
|
+
avatarUrl: G = "/avatars/brunette.glb",
|
|
6832
6832
|
avatarBody: t = "F",
|
|
6833
6833
|
mood: e = "neutral",
|
|
6834
6834
|
ttsLang: n = "en",
|
|
@@ -6848,314 +6848,314 @@ const Ye = Be(({
|
|
|
6848
6848
|
className: p = "",
|
|
6849
6849
|
style: b = {},
|
|
6850
6850
|
animations: f = {}
|
|
6851
|
-
},
|
|
6852
|
-
const
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
}, [ce]),
|
|
6856
|
-
|
|
6851
|
+
}, k) => {
|
|
6852
|
+
const T = X(null), g = X(null), N = X(a), F = X(null), I = X(null), U = X(!1), S = X({ remainingText: null, originalText: null, options: null }), R = X([]), z = X(0), [y, E] = le(!0), [D, B] = le(null), [Y, ae] = le(!1), [ce, be] = le(!1);
|
|
6853
|
+
ye(() => {
|
|
6854
|
+
U.current = ce;
|
|
6855
|
+
}, [ce]), ye(() => {
|
|
6856
|
+
N.current = a;
|
|
6857
6857
|
}, [a]);
|
|
6858
|
-
const se =
|
|
6859
|
-
let
|
|
6860
|
-
|
|
6858
|
+
const se = We(), Se = i || se.service;
|
|
6859
|
+
let te;
|
|
6860
|
+
Se === "browser" ? te = {
|
|
6861
6861
|
service: "browser",
|
|
6862
6862
|
endpoint: "",
|
|
6863
6863
|
apiKey: null,
|
|
6864
6864
|
defaultVoice: "Google US English"
|
|
6865
|
-
} :
|
|
6865
|
+
} : Se === "elevenlabs" ? te = {
|
|
6866
6866
|
service: "elevenlabs",
|
|
6867
6867
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
6868
6868
|
apiKey: o || se.apiKey,
|
|
6869
|
-
defaultVoice: s || se.defaultVoice ||
|
|
6870
|
-
voices: se.voices ||
|
|
6871
|
-
} :
|
|
6869
|
+
defaultVoice: s || se.defaultVoice || ze.defaultVoice,
|
|
6870
|
+
voices: se.voices || ze.voices
|
|
6871
|
+
} : Se === "deepgram" ? te = {
|
|
6872
6872
|
service: "deepgram",
|
|
6873
6873
|
endpoint: "https://api.deepgram.com/v1/speak",
|
|
6874
6874
|
apiKey: o || se.apiKey,
|
|
6875
|
-
defaultVoice: s || se.defaultVoice ||
|
|
6876
|
-
voices: se.voices ||
|
|
6877
|
-
} :
|
|
6875
|
+
defaultVoice: s || se.defaultVoice || De.defaultVoice,
|
|
6876
|
+
voices: se.voices || De.voices
|
|
6877
|
+
} : te = {
|
|
6878
6878
|
...se,
|
|
6879
6879
|
// Override API key if provided via props
|
|
6880
6880
|
apiKey: o !== null ? o : se.apiKey
|
|
6881
6881
|
};
|
|
6882
6882
|
const v = {
|
|
6883
|
-
url:
|
|
6883
|
+
url: G,
|
|
6884
6884
|
body: t,
|
|
6885
6885
|
avatarMood: e,
|
|
6886
|
-
ttsLang:
|
|
6887
|
-
ttsVoice: s ||
|
|
6886
|
+
ttsLang: Se === "browser" ? "en-US" : n,
|
|
6887
|
+
ttsVoice: s || te.defaultVoice,
|
|
6888
6888
|
lipsyncLang: "en",
|
|
6889
6889
|
showFullAvatar: a,
|
|
6890
6890
|
bodyMovement: r,
|
|
6891
6891
|
movementIntensity: u
|
|
6892
6892
|
}, A = {
|
|
6893
|
-
ttsEndpoint:
|
|
6894
|
-
ttsApikey:
|
|
6895
|
-
ttsService:
|
|
6893
|
+
ttsEndpoint: te.endpoint,
|
|
6894
|
+
ttsApikey: te.apiKey,
|
|
6895
|
+
ttsService: Se,
|
|
6896
6896
|
lipsyncModules: ["en"],
|
|
6897
6897
|
cameraView: c
|
|
6898
|
-
},
|
|
6899
|
-
if (!(!
|
|
6898
|
+
}, M = V(async () => {
|
|
6899
|
+
if (!(!T.current || g.current))
|
|
6900
6900
|
try {
|
|
6901
|
-
if (
|
|
6902
|
-
if (
|
|
6903
|
-
const
|
|
6904
|
-
d(
|
|
6901
|
+
if (E(!0), B(null), g.current = new Ze(T.current, A), g.current.controls && (g.current.controls.enableRotate = !1, g.current.controls.enableZoom = !1, g.current.controls.enablePan = !1, g.current.controls.enableDamping = !1), f && Object.keys(f).length > 0 && (g.current.customAnimations = f), await g.current.showAvatar(v, (_) => {
|
|
6902
|
+
if (_.lengthComputable) {
|
|
6903
|
+
const ie = Math.min(100, Math.round(_.loaded / _.total * 100));
|
|
6904
|
+
d(ie);
|
|
6905
6905
|
}
|
|
6906
|
-
}), await new Promise((
|
|
6907
|
-
const
|
|
6908
|
-
g.current.lipsync && Object.keys(g.current.lipsync).length > 0 ?
|
|
6906
|
+
}), await new Promise((_) => {
|
|
6907
|
+
const ie = () => {
|
|
6908
|
+
g.current.lipsync && Object.keys(g.current.lipsync).length > 0 ? _() : setTimeout(ie, 100);
|
|
6909
6909
|
};
|
|
6910
|
-
|
|
6910
|
+
ie();
|
|
6911
6911
|
}), g.current && g.current.setShowFullAvatar)
|
|
6912
6912
|
try {
|
|
6913
6913
|
g.current.setShowFullAvatar(a);
|
|
6914
|
-
} catch (
|
|
6915
|
-
console.warn("Error setting full body mode on initialization:",
|
|
6914
|
+
} catch (_) {
|
|
6915
|
+
console.warn("Error setting full body mode on initialization:", _);
|
|
6916
6916
|
}
|
|
6917
|
-
g.current && g.current.controls && (g.current.controls.enableRotate = !1, g.current.controls.enableZoom = !1, g.current.controls.enablePan = !1, g.current.controls.enableDamping = !1, g.current.controls.update()),
|
|
6918
|
-
const
|
|
6917
|
+
g.current && g.current.controls && (g.current.controls.enableRotate = !1, g.current.controls.enableZoom = !1, g.current.controls.enablePan = !1, g.current.controls.enableDamping = !1, g.current.controls.update()), E(!1), ae(!0), l(g.current);
|
|
6918
|
+
const q = () => {
|
|
6919
6919
|
document.visibilityState === "visible" ? g.current?.start() : g.current?.stop();
|
|
6920
6920
|
};
|
|
6921
|
-
return document.addEventListener("visibilitychange",
|
|
6922
|
-
document.removeEventListener("visibilitychange",
|
|
6921
|
+
return document.addEventListener("visibilitychange", q), () => {
|
|
6922
|
+
document.removeEventListener("visibilitychange", q);
|
|
6923
6923
|
};
|
|
6924
|
-
} catch (
|
|
6925
|
-
console.error("Error initializing TalkingHead:",
|
|
6924
|
+
} catch (C) {
|
|
6925
|
+
console.error("Error initializing TalkingHead:", C), B(C.message || "Failed to initialize avatar"), E(!1), h(C);
|
|
6926
6926
|
}
|
|
6927
|
-
}, [
|
|
6928
|
-
|
|
6927
|
+
}, [G, t, e, n, i, s, o, a, r, u, c]);
|
|
6928
|
+
ye(() => (M(), () => {
|
|
6929
6929
|
g.current && (g.current.stop(), g.current.dispose(), g.current = null);
|
|
6930
|
-
}), [
|
|
6931
|
-
if (!
|
|
6932
|
-
const
|
|
6933
|
-
for (const
|
|
6930
|
+
}), [M]), ye(() => {
|
|
6931
|
+
if (!T.current || !g.current) return;
|
|
6932
|
+
const C = new ResizeObserver((_) => {
|
|
6933
|
+
for (const ie of _)
|
|
6934
6934
|
g.current && g.current.onResize && g.current.onResize();
|
|
6935
6935
|
});
|
|
6936
|
-
|
|
6937
|
-
const
|
|
6936
|
+
C.observe(T.current);
|
|
6937
|
+
const q = () => {
|
|
6938
6938
|
g.current && g.current.onResize && g.current.onResize();
|
|
6939
6939
|
};
|
|
6940
|
-
return window.addEventListener("resize",
|
|
6941
|
-
|
|
6940
|
+
return window.addEventListener("resize", q), () => {
|
|
6941
|
+
C.disconnect(), window.removeEventListener("resize", q);
|
|
6942
6942
|
};
|
|
6943
|
-
}, [
|
|
6944
|
-
const
|
|
6943
|
+
}, [Y]);
|
|
6944
|
+
const W = V(async () => {
|
|
6945
6945
|
if (g.current && g.current.audioCtx)
|
|
6946
6946
|
try {
|
|
6947
6947
|
(g.current.audioCtx.state === "suspended" || g.current.audioCtx.state === "interrupted") && (await g.current.audioCtx.resume(), console.log("Audio context resumed"));
|
|
6948
|
-
} catch (
|
|
6949
|
-
console.warn("Failed to resume audio context:",
|
|
6948
|
+
} catch (C) {
|
|
6949
|
+
console.warn("Failed to resume audio context:", C);
|
|
6950
6950
|
}
|
|
6951
|
-
}, []),
|
|
6952
|
-
if (g.current &&
|
|
6951
|
+
}, []), Q = V(async (C, q = {}) => {
|
|
6952
|
+
if (g.current && Y)
|
|
6953
6953
|
try {
|
|
6954
|
-
I.current && (clearInterval(I.current), I.current = null),
|
|
6955
|
-
const
|
|
6956
|
-
R.current =
|
|
6957
|
-
const
|
|
6958
|
-
...
|
|
6959
|
-
lipsyncLang:
|
|
6954
|
+
I.current && (clearInterval(I.current), I.current = null), F.current = { text: C, options: q }, S.current = { remainingText: null, originalText: null, options: null };
|
|
6955
|
+
const _ = /[!\.\?\n\p{Extended_Pictographic}]/ug, ie = C.split(_).map((J) => J.trim()).filter((J) => J.length > 0);
|
|
6956
|
+
R.current = ie, z.current = 0, be(!1), U.current = !1, await W();
|
|
6957
|
+
const ve = {
|
|
6958
|
+
...q,
|
|
6959
|
+
lipsyncLang: q.lipsyncLang || v.lipsyncLang || "en"
|
|
6960
6960
|
};
|
|
6961
|
-
if (
|
|
6962
|
-
const
|
|
6963
|
-
let
|
|
6964
|
-
const
|
|
6965
|
-
let
|
|
6966
|
-
|
|
6967
|
-
if (
|
|
6961
|
+
if (q.onSpeechEnd && g.current) {
|
|
6962
|
+
const J = g.current;
|
|
6963
|
+
let pe = null, w = 0;
|
|
6964
|
+
const L = 1200;
|
|
6965
|
+
let P = !1;
|
|
6966
|
+
pe = setInterval(() => {
|
|
6967
|
+
if (w++, U.current)
|
|
6968
6968
|
return;
|
|
6969
|
-
if (
|
|
6970
|
-
if (
|
|
6971
|
-
|
|
6969
|
+
if (w > L) {
|
|
6970
|
+
if (pe && (clearInterval(pe), pe = null, I.current = null), !P && !U.current) {
|
|
6971
|
+
P = !0;
|
|
6972
6972
|
try {
|
|
6973
|
-
|
|
6974
|
-
} catch (
|
|
6975
|
-
console.error("Error in onSpeechEnd callback (timeout):",
|
|
6973
|
+
q.onSpeechEnd();
|
|
6974
|
+
} catch (Ge) {
|
|
6975
|
+
console.error("Error in onSpeechEnd callback (timeout):", Ge);
|
|
6976
6976
|
}
|
|
6977
6977
|
}
|
|
6978
6978
|
return;
|
|
6979
6979
|
}
|
|
6980
|
-
const
|
|
6981
|
-
|
|
6982
|
-
if (
|
|
6983
|
-
|
|
6980
|
+
const Z = !J.speechQueue || J.speechQueue.length === 0, j = !J.audioPlaylist || J.audioPlaylist.length === 0;
|
|
6981
|
+
J && J.isSpeaking === !1 && Z && j && J.isAudioPlaying === !1 && !P && !U.current && setTimeout(() => {
|
|
6982
|
+
if (J && !U.current && J.isSpeaking === !1 && (!J.speechQueue || J.speechQueue.length === 0) && (!J.audioPlaylist || J.audioPlaylist.length === 0) && J.isAudioPlaying === !1 && !P && !U.current) {
|
|
6983
|
+
P = !0, pe && (clearInterval(pe), pe = null, I.current = null);
|
|
6984
6984
|
try {
|
|
6985
|
-
|
|
6986
|
-
} catch (
|
|
6987
|
-
console.error("Error in onSpeechEnd callback:",
|
|
6985
|
+
q.onSpeechEnd();
|
|
6986
|
+
} catch (ue) {
|
|
6987
|
+
console.error("Error in onSpeechEnd callback:", ue);
|
|
6988
6988
|
}
|
|
6989
6989
|
}
|
|
6990
6990
|
}, 100);
|
|
6991
|
-
}, 100), I.current =
|
|
6991
|
+
}, 100), I.current = pe;
|
|
6992
6992
|
}
|
|
6993
|
-
g.current.lipsync && Object.keys(g.current.lipsync).length > 0 ? (g.current.setSlowdownRate && g.current.setSlowdownRate(1.05), g.current.speakText(
|
|
6994
|
-
await
|
|
6993
|
+
g.current.lipsync && Object.keys(g.current.lipsync).length > 0 ? (g.current.setSlowdownRate && g.current.setSlowdownRate(1.05), g.current.speakText(C, ve)) : setTimeout(async () => {
|
|
6994
|
+
await W(), g.current && g.current.lipsync && (g.current.setSlowdownRate && g.current.setSlowdownRate(1.05), g.current.speakText(C, ve));
|
|
6995
6995
|
}, 100);
|
|
6996
|
-
} catch (
|
|
6997
|
-
console.error("Error speaking text:",
|
|
6996
|
+
} catch (_) {
|
|
6997
|
+
console.error("Error speaking text:", _), B(_.message || "Failed to speak text");
|
|
6998
6998
|
}
|
|
6999
|
-
}, [
|
|
7000
|
-
g.current && (g.current.stopSpeaking(), g.current.setSlowdownRate && g.current.setSlowdownRate(1),
|
|
7001
|
-
}, []),
|
|
6999
|
+
}, [Y, W, v.lipsyncLang]), re = V(() => {
|
|
7000
|
+
g.current && (g.current.stopSpeaking(), g.current.setSlowdownRate && g.current.setSlowdownRate(1), F.current = null, be(!1));
|
|
7001
|
+
}, []), $ = V(() => {
|
|
7002
7002
|
if (g.current && g.current.pauseSpeaking) {
|
|
7003
|
-
const
|
|
7004
|
-
if (
|
|
7003
|
+
const C = g.current;
|
|
7004
|
+
if (C.isSpeaking || C.audioPlaylist && C.audioPlaylist.length > 0 || C.speechQueue && C.speechQueue.length > 0) {
|
|
7005
7005
|
I.current && (clearInterval(I.current), I.current = null);
|
|
7006
|
-
let
|
|
7007
|
-
if (
|
|
7008
|
-
const
|
|
7009
|
-
if (
|
|
7010
|
-
const
|
|
7011
|
-
|
|
7006
|
+
let _ = "";
|
|
7007
|
+
if (F.current && R.current.length > 0) {
|
|
7008
|
+
const ie = R.current.length, ve = C.speechQueue ? C.speechQueue.filter((L) => L && L.text && Array.isArray(L.text) && L.text.length > 0).length : 0, J = C.audioPlaylist && C.audioPlaylist.length > 0, pe = ve + (J ? 1 : 0), w = ie - pe;
|
|
7009
|
+
if (pe > 0 && w < ie && (_ = R.current.slice(w).join(". ").trim(), !_ && ve > 0 && C.speechQueue)) {
|
|
7010
|
+
const P = C.speechQueue.filter((Z) => Z && Z.text && Array.isArray(Z.text) && Z.text.length > 0).map((Z) => Z.text.map((j) => j.word || "").filter((j) => j.length > 0).join(" ")).filter((Z) => Z.length > 0).join(" ");
|
|
7011
|
+
P && P.trim() && (_ = P.trim());
|
|
7012
7012
|
}
|
|
7013
7013
|
}
|
|
7014
|
-
|
|
7015
|
-
remainingText:
|
|
7016
|
-
originalText:
|
|
7017
|
-
options:
|
|
7018
|
-
}),
|
|
7014
|
+
F.current && (S.current = {
|
|
7015
|
+
remainingText: _ || null,
|
|
7016
|
+
originalText: F.current.text,
|
|
7017
|
+
options: F.current.options
|
|
7018
|
+
}), C.speechQueue && (C.speechQueue.length = 0), g.current.pauseSpeaking(), U.current = !0, be(!0);
|
|
7019
7019
|
}
|
|
7020
7020
|
}
|
|
7021
|
-
}, []),
|
|
7021
|
+
}, []), ne = V(async () => {
|
|
7022
7022
|
if (!g.current || !ce)
|
|
7023
7023
|
return;
|
|
7024
|
-
let
|
|
7025
|
-
if (
|
|
7026
|
-
|
|
7027
|
-
else if (
|
|
7028
|
-
|
|
7024
|
+
let C = "", q = {};
|
|
7025
|
+
if (S.current && S.current.remainingText)
|
|
7026
|
+
C = S.current.remainingText, q = S.current.options || {}, S.current = { remainingText: null, originalText: null, options: null };
|
|
7027
|
+
else if (F.current && F.current.text)
|
|
7028
|
+
C = F.current.text, q = F.current.options || {};
|
|
7029
7029
|
else {
|
|
7030
|
-
console.warn("Resume called but no paused speech found"),
|
|
7030
|
+
console.warn("Resume called but no paused speech found"), be(!1), U.current = !1;
|
|
7031
7031
|
return;
|
|
7032
7032
|
}
|
|
7033
|
-
|
|
7034
|
-
const
|
|
7035
|
-
...
|
|
7036
|
-
lipsyncLang:
|
|
7033
|
+
be(!1), U.current = !1, await W();
|
|
7034
|
+
const _ = {
|
|
7035
|
+
...q,
|
|
7036
|
+
lipsyncLang: q.lipsyncLang || v.lipsyncLang || "en"
|
|
7037
7037
|
};
|
|
7038
7038
|
try {
|
|
7039
|
-
await
|
|
7040
|
-
} catch (
|
|
7041
|
-
console.error("Error resuming speech:",
|
|
7039
|
+
await Q(C, _);
|
|
7040
|
+
} catch (ie) {
|
|
7041
|
+
console.error("Error resuming speech:", ie), be(!1), U.current = !1;
|
|
7042
7042
|
}
|
|
7043
|
-
}, [
|
|
7044
|
-
g.current && g.current.setMood(
|
|
7045
|
-
}, []),
|
|
7046
|
-
g.current && g.current.setSlowdownRate && g.current.setSlowdownRate(
|
|
7047
|
-
}, []),
|
|
7043
|
+
}, [W, ce, Q, v]), fe = V((C) => {
|
|
7044
|
+
g.current && g.current.setMood(C);
|
|
7045
|
+
}, []), He = V((C) => {
|
|
7046
|
+
g.current && g.current.setSlowdownRate && g.current.setSlowdownRate(C);
|
|
7047
|
+
}, []), Ve = V((C, q = !1) => {
|
|
7048
7048
|
if (g.current && g.current.playAnimation) {
|
|
7049
|
-
if (f && f[
|
|
7049
|
+
if (f && f[C] && (C = f[C]), g.current.setShowFullAvatar)
|
|
7050
7050
|
try {
|
|
7051
|
-
g.current.setShowFullAvatar(
|
|
7052
|
-
} catch (
|
|
7053
|
-
console.warn("Error setting full body mode:",
|
|
7051
|
+
g.current.setShowFullAvatar(N.current);
|
|
7052
|
+
} catch (ie) {
|
|
7053
|
+
console.warn("Error setting full body mode:", ie);
|
|
7054
7054
|
}
|
|
7055
|
-
if (
|
|
7055
|
+
if (C.includes("."))
|
|
7056
7056
|
try {
|
|
7057
|
-
g.current.playAnimation(
|
|
7058
|
-
} catch (
|
|
7059
|
-
console.warn(`Failed to play ${
|
|
7057
|
+
g.current.playAnimation(C, null, 10, 0, 0.01, q);
|
|
7058
|
+
} catch (ie) {
|
|
7059
|
+
console.warn(`Failed to play ${C}:`, ie);
|
|
7060
7060
|
try {
|
|
7061
7061
|
g.current.setBodyMovement("idle");
|
|
7062
|
-
} catch (
|
|
7063
|
-
console.warn("Fallback animation also failed:",
|
|
7062
|
+
} catch (ve) {
|
|
7063
|
+
console.warn("Fallback animation also failed:", ve);
|
|
7064
7064
|
}
|
|
7065
7065
|
}
|
|
7066
7066
|
else {
|
|
7067
|
-
const
|
|
7068
|
-
let
|
|
7069
|
-
for (const
|
|
7067
|
+
const ie = [".fbx", ".glb", ".gltf"];
|
|
7068
|
+
let ve = !1;
|
|
7069
|
+
for (const J of ie)
|
|
7070
7070
|
try {
|
|
7071
|
-
g.current.playAnimation(
|
|
7071
|
+
g.current.playAnimation(C + J, null, 10, 0, 0.01, q), ve = !0;
|
|
7072
7072
|
break;
|
|
7073
7073
|
} catch {
|
|
7074
7074
|
}
|
|
7075
|
-
if (!
|
|
7076
|
-
console.warn("Animation not found:",
|
|
7075
|
+
if (!ve) {
|
|
7076
|
+
console.warn("Animation not found:", C);
|
|
7077
7077
|
try {
|
|
7078
7078
|
g.current.setBodyMovement("idle");
|
|
7079
|
-
} catch (
|
|
7080
|
-
console.warn("Fallback animation also failed:",
|
|
7079
|
+
} catch (J) {
|
|
7080
|
+
console.warn("Fallback animation also failed:", J);
|
|
7081
7081
|
}
|
|
7082
7082
|
}
|
|
7083
7083
|
}
|
|
7084
7084
|
}
|
|
7085
|
-
}, [f]),
|
|
7085
|
+
}, [f]), Fe = V(() => {
|
|
7086
7086
|
g.current && g.current.onResize && g.current.onResize();
|
|
7087
7087
|
}, []);
|
|
7088
|
-
return
|
|
7089
|
-
speakText:
|
|
7088
|
+
return Ue(k, () => ({
|
|
7089
|
+
speakText: Q,
|
|
7090
7090
|
stopSpeaking: re,
|
|
7091
|
-
pauseSpeaking:
|
|
7092
|
-
resumeSpeaking:
|
|
7093
|
-
resumeAudioContext:
|
|
7094
|
-
setMood:
|
|
7095
|
-
setTimingAdjustment:
|
|
7096
|
-
playAnimation:
|
|
7097
|
-
isReady:
|
|
7091
|
+
pauseSpeaking: $,
|
|
7092
|
+
resumeSpeaking: ne,
|
|
7093
|
+
resumeAudioContext: W,
|
|
7094
|
+
setMood: fe,
|
|
7095
|
+
setTimingAdjustment: He,
|
|
7096
|
+
playAnimation: Ve,
|
|
7097
|
+
isReady: Y,
|
|
7098
7098
|
isPaused: ce,
|
|
7099
7099
|
talkingHead: g.current,
|
|
7100
|
-
handleResize:
|
|
7101
|
-
setBodyMovement: (
|
|
7100
|
+
handleResize: Fe,
|
|
7101
|
+
setBodyMovement: (C) => {
|
|
7102
7102
|
if (g.current && g.current.setShowFullAvatar && g.current.setBodyMovement)
|
|
7103
7103
|
try {
|
|
7104
|
-
g.current.setShowFullAvatar(
|
|
7105
|
-
} catch (
|
|
7106
|
-
console.warn("Error setting body movement:",
|
|
7104
|
+
g.current.setShowFullAvatar(N.current), g.current.setBodyMovement(C);
|
|
7105
|
+
} catch (q) {
|
|
7106
|
+
console.warn("Error setting body movement:", q);
|
|
7107
7107
|
}
|
|
7108
7108
|
},
|
|
7109
|
-
setMovementIntensity: (
|
|
7109
|
+
setMovementIntensity: (C) => g.current?.setMovementIntensity(C),
|
|
7110
7110
|
playRandomDance: () => {
|
|
7111
7111
|
if (g.current && g.current.setShowFullAvatar && g.current.playRandomDance)
|
|
7112
7112
|
try {
|
|
7113
|
-
g.current.setShowFullAvatar(
|
|
7114
|
-
} catch (
|
|
7115
|
-
console.warn("Error playing random dance:",
|
|
7113
|
+
g.current.setShowFullAvatar(N.current), g.current.playRandomDance();
|
|
7114
|
+
} catch (C) {
|
|
7115
|
+
console.warn("Error playing random dance:", C);
|
|
7116
7116
|
}
|
|
7117
7117
|
},
|
|
7118
|
-
playReaction: (
|
|
7118
|
+
playReaction: (C) => {
|
|
7119
7119
|
if (g.current && g.current.setShowFullAvatar && g.current.playReaction)
|
|
7120
7120
|
try {
|
|
7121
|
-
g.current.setShowFullAvatar(
|
|
7122
|
-
} catch (
|
|
7123
|
-
console.warn("Error playing reaction:",
|
|
7121
|
+
g.current.setShowFullAvatar(N.current), g.current.playReaction(C);
|
|
7122
|
+
} catch (q) {
|
|
7123
|
+
console.warn("Error playing reaction:", q);
|
|
7124
7124
|
}
|
|
7125
7125
|
},
|
|
7126
7126
|
playCelebration: () => {
|
|
7127
7127
|
if (g.current && g.current.setShowFullAvatar && g.current.playCelebration)
|
|
7128
7128
|
try {
|
|
7129
|
-
g.current.setShowFullAvatar(
|
|
7130
|
-
} catch (
|
|
7131
|
-
console.warn("Error playing celebration:",
|
|
7129
|
+
g.current.setShowFullAvatar(N.current), g.current.playCelebration();
|
|
7130
|
+
} catch (C) {
|
|
7131
|
+
console.warn("Error playing celebration:", C);
|
|
7132
7132
|
}
|
|
7133
7133
|
},
|
|
7134
|
-
setShowFullAvatar: (
|
|
7134
|
+
setShowFullAvatar: (C) => {
|
|
7135
7135
|
if (g.current && g.current.setShowFullAvatar)
|
|
7136
7136
|
try {
|
|
7137
|
-
|
|
7138
|
-
} catch (
|
|
7139
|
-
console.warn("Error setting showFullAvatar:",
|
|
7137
|
+
N.current = C, g.current.setShowFullAvatar(C);
|
|
7138
|
+
} catch (q) {
|
|
7139
|
+
console.warn("Error setting showFullAvatar:", q);
|
|
7140
7140
|
}
|
|
7141
7141
|
},
|
|
7142
7142
|
lockAvatarPosition: () => {
|
|
7143
7143
|
if (g.current && g.current.lockAvatarPosition)
|
|
7144
7144
|
try {
|
|
7145
7145
|
g.current.lockAvatarPosition();
|
|
7146
|
-
} catch (
|
|
7147
|
-
console.warn("Error locking avatar position:",
|
|
7146
|
+
} catch (C) {
|
|
7147
|
+
console.warn("Error locking avatar position:", C);
|
|
7148
7148
|
}
|
|
7149
7149
|
},
|
|
7150
7150
|
unlockAvatarPosition: () => {
|
|
7151
7151
|
if (g.current && g.current.unlockAvatarPosition)
|
|
7152
7152
|
try {
|
|
7153
7153
|
g.current.unlockAvatarPosition();
|
|
7154
|
-
} catch (
|
|
7155
|
-
console.warn("Error unlocking avatar position:",
|
|
7154
|
+
} catch (C) {
|
|
7155
|
+
console.warn("Error unlocking avatar position:", C);
|
|
7156
7156
|
}
|
|
7157
7157
|
}
|
|
7158
|
-
})), /* @__PURE__ */
|
|
7158
|
+
})), /* @__PURE__ */ Re(
|
|
7159
7159
|
"div",
|
|
7160
7160
|
{
|
|
7161
7161
|
className: `talking-head-avatar ${p}`,
|
|
@@ -7166,10 +7166,10 @@ const Ye = Be(({
|
|
|
7166
7166
|
...b
|
|
7167
7167
|
},
|
|
7168
7168
|
children: [
|
|
7169
|
-
/* @__PURE__ */
|
|
7169
|
+
/* @__PURE__ */ ee(
|
|
7170
7170
|
"div",
|
|
7171
7171
|
{
|
|
7172
|
-
ref:
|
|
7172
|
+
ref: T,
|
|
7173
7173
|
className: "talking-head-viewer",
|
|
7174
7174
|
style: {
|
|
7175
7175
|
width: "100%",
|
|
@@ -7178,7 +7178,7 @@ const Ye = Be(({
|
|
|
7178
7178
|
}
|
|
7179
7179
|
}
|
|
7180
7180
|
),
|
|
7181
|
-
y && /* @__PURE__ */
|
|
7181
|
+
y && /* @__PURE__ */ ee("div", { className: "loading-overlay", style: {
|
|
7182
7182
|
position: "absolute",
|
|
7183
7183
|
top: "50%",
|
|
7184
7184
|
left: "50%",
|
|
@@ -7187,7 +7187,7 @@ const Ye = Be(({
|
|
|
7187
7187
|
fontSize: "18px",
|
|
7188
7188
|
zIndex: 10
|
|
7189
7189
|
}, children: "Loading avatar..." }),
|
|
7190
|
-
|
|
7190
|
+
D && /* @__PURE__ */ ee("div", { className: "error-overlay", style: {
|
|
7191
7191
|
position: "absolute",
|
|
7192
7192
|
top: "50%",
|
|
7193
7193
|
left: "50%",
|
|
@@ -7198,14 +7198,14 @@ const Ye = Be(({
|
|
|
7198
7198
|
zIndex: 10,
|
|
7199
7199
|
padding: "20px",
|
|
7200
7200
|
borderRadius: "8px"
|
|
7201
|
-
}, children:
|
|
7201
|
+
}, children: D })
|
|
7202
7202
|
]
|
|
7203
7203
|
}
|
|
7204
7204
|
);
|
|
7205
7205
|
});
|
|
7206
|
-
|
|
7207
|
-
const
|
|
7208
|
-
text:
|
|
7206
|
+
_e.displayName = "TalkingHeadAvatar";
|
|
7207
|
+
const At = Ne(({
|
|
7208
|
+
text: G = "Hello! I'm a talking avatar. How are you today?",
|
|
7209
7209
|
onLoading: t = () => {
|
|
7210
7210
|
},
|
|
7211
7211
|
onError: e = () => {
|
|
@@ -7216,7 +7216,7 @@ const vt = Be(({
|
|
|
7216
7216
|
style: s = {},
|
|
7217
7217
|
avatarConfig: o = {}
|
|
7218
7218
|
}, r) => {
|
|
7219
|
-
const u = X(null), a = X(null), [c, l] = le(!0), [d, h] = le(null), [p, b] = le(!1), f =
|
|
7219
|
+
const u = X(null), a = X(null), [c, l] = le(!0), [d, h] = le(null), [p, b] = le(!1), f = We(), k = o.ttsService || f.service, T = k === "browser" ? {
|
|
7220
7220
|
endpoint: "",
|
|
7221
7221
|
apiKey: null,
|
|
7222
7222
|
defaultVoice: "Google US English"
|
|
@@ -7225,14 +7225,14 @@ const vt = Be(({
|
|
|
7225
7225
|
// Override API key if provided via avatarConfig
|
|
7226
7226
|
apiKey: o.ttsApiKey !== void 0 && o.ttsApiKey !== null ? o.ttsApiKey : f.apiKey,
|
|
7227
7227
|
// Override endpoint for ElevenLabs if service is explicitly set
|
|
7228
|
-
endpoint:
|
|
7228
|
+
endpoint: k === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : f.endpoint
|
|
7229
7229
|
}, g = {
|
|
7230
7230
|
url: "/avatars/brunette.glb",
|
|
7231
7231
|
// Use brunette avatar (working glTF file)
|
|
7232
7232
|
body: "F",
|
|
7233
7233
|
avatarMood: "neutral",
|
|
7234
|
-
ttsLang:
|
|
7235
|
-
ttsVoice: o.ttsVoice ||
|
|
7234
|
+
ttsLang: k === "browser" ? "en-US" : "en",
|
|
7235
|
+
ttsVoice: o.ttsVoice || T.defaultVoice,
|
|
7236
7236
|
lipsyncLang: "en",
|
|
7237
7237
|
// English lip-sync
|
|
7238
7238
|
showFullAvatar: !0,
|
|
@@ -7240,98 +7240,98 @@ const vt = Be(({
|
|
|
7240
7240
|
bodyMovement: "idle",
|
|
7241
7241
|
movementIntensity: 0.5,
|
|
7242
7242
|
...o
|
|
7243
|
-
},
|
|
7244
|
-
ttsEndpoint:
|
|
7245
|
-
ttsApikey:
|
|
7246
|
-
ttsService:
|
|
7243
|
+
}, N = {
|
|
7244
|
+
ttsEndpoint: T.endpoint,
|
|
7245
|
+
ttsApikey: T.apiKey,
|
|
7246
|
+
ttsService: k,
|
|
7247
7247
|
lipsyncModules: ["en"],
|
|
7248
7248
|
cameraView: "upper"
|
|
7249
|
-
},
|
|
7249
|
+
}, F = V(async () => {
|
|
7250
7250
|
if (!(!u.current || a.current))
|
|
7251
7251
|
try {
|
|
7252
|
-
if (l(!0), h(null), a.current = new
|
|
7253
|
-
if (
|
|
7254
|
-
const
|
|
7255
|
-
t(
|
|
7252
|
+
if (l(!0), h(null), a.current = new Ze(u.current, N), await a.current.showAvatar(g, (D) => {
|
|
7253
|
+
if (D.lengthComputable) {
|
|
7254
|
+
const B = Math.min(100, Math.round(D.loaded / D.total * 100));
|
|
7255
|
+
t(B);
|
|
7256
7256
|
}
|
|
7257
7257
|
}), a.current.morphs && a.current.morphs.length > 0) {
|
|
7258
|
-
const
|
|
7259
|
-
console.log("Available morph targets:", Object.keys(
|
|
7260
|
-
const
|
|
7261
|
-
console.log("Viseme morph targets found:",
|
|
7258
|
+
const D = a.current.morphs[0].morphTargetDictionary;
|
|
7259
|
+
console.log("Available morph targets:", Object.keys(D));
|
|
7260
|
+
const B = Object.keys(D).filter((Y) => Y.startsWith("viseme_"));
|
|
7261
|
+
console.log("Viseme morph targets found:", B), B.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"));
|
|
7262
7262
|
}
|
|
7263
|
-
if (await new Promise((
|
|
7264
|
-
const
|
|
7265
|
-
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)),
|
|
7263
|
+
if (await new Promise((D) => {
|
|
7264
|
+
const B = () => {
|
|
7265
|
+
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), D()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(B, 100));
|
|
7266
7266
|
};
|
|
7267
|
-
|
|
7267
|
+
B();
|
|
7268
7268
|
}), a.current && a.current.setShowFullAvatar)
|
|
7269
7269
|
try {
|
|
7270
7270
|
a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
|
|
7271
|
-
} catch (
|
|
7272
|
-
console.warn("Error setting full body mode on initialization:",
|
|
7271
|
+
} catch (D) {
|
|
7272
|
+
console.warn("Error setting full body mode on initialization:", D);
|
|
7273
7273
|
}
|
|
7274
7274
|
l(!1), b(!0), n(a.current);
|
|
7275
|
-
const
|
|
7275
|
+
const E = () => {
|
|
7276
7276
|
document.visibilityState === "visible" ? a.current?.start() : a.current?.stop();
|
|
7277
7277
|
};
|
|
7278
|
-
return document.addEventListener("visibilitychange",
|
|
7279
|
-
document.removeEventListener("visibilitychange",
|
|
7278
|
+
return document.addEventListener("visibilitychange", E), () => {
|
|
7279
|
+
document.removeEventListener("visibilitychange", E);
|
|
7280
7280
|
};
|
|
7281
7281
|
} catch (y) {
|
|
7282
7282
|
console.error("Error initializing TalkingHead:", y), h(y.message || "Failed to initialize avatar"), l(!1), e(y);
|
|
7283
7283
|
}
|
|
7284
7284
|
}, []);
|
|
7285
|
-
|
|
7285
|
+
ye(() => (F(), () => {
|
|
7286
7286
|
a.current && (a.current.stop(), a.current.dispose(), a.current = null);
|
|
7287
|
-
}), [
|
|
7288
|
-
const I =
|
|
7287
|
+
}), [F]);
|
|
7288
|
+
const I = V((y) => {
|
|
7289
7289
|
if (a.current && p)
|
|
7290
7290
|
try {
|
|
7291
7291
|
console.log("Speaking text:", y), console.log("Avatar config:", g), 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(y)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
|
|
7292
7292
|
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(y)) : console.error("Lip-sync still not ready after waiting");
|
|
7293
7293
|
}, 500));
|
|
7294
|
-
} catch (
|
|
7295
|
-
console.error("Error speaking text:",
|
|
7294
|
+
} catch (E) {
|
|
7295
|
+
console.error("Error speaking text:", E), h(E.message || "Failed to speak text");
|
|
7296
7296
|
}
|
|
7297
7297
|
else
|
|
7298
7298
|
console.warn("Avatar not ready for speaking. isReady:", p, "talkingHeadRef:", !!a.current);
|
|
7299
|
-
}, [p, g]),
|
|
7299
|
+
}, [p, g]), U = V(() => {
|
|
7300
7300
|
a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
|
|
7301
|
-
}, []),
|
|
7301
|
+
}, []), S = V((y) => {
|
|
7302
7302
|
a.current && a.current.setMood(y);
|
|
7303
|
-
}, []), R =
|
|
7303
|
+
}, []), R = V((y) => {
|
|
7304
7304
|
a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(y), console.log("Timing adjustment set to:", y));
|
|
7305
|
-
}, []), z =
|
|
7305
|
+
}, []), z = V((y, E = !1) => {
|
|
7306
7306
|
if (a.current && a.current.playAnimation) {
|
|
7307
7307
|
if (a.current.setShowFullAvatar)
|
|
7308
7308
|
try {
|
|
7309
7309
|
a.current.setShowFullAvatar(!0);
|
|
7310
|
-
} catch (
|
|
7311
|
-
console.warn("Error setting full body mode:",
|
|
7310
|
+
} catch (B) {
|
|
7311
|
+
console.warn("Error setting full body mode:", B);
|
|
7312
7312
|
}
|
|
7313
7313
|
if (y.includes("."))
|
|
7314
7314
|
try {
|
|
7315
|
-
a.current.playAnimation(y, null, 10, 0, 0.01,
|
|
7316
|
-
} catch (
|
|
7317
|
-
console.log(`Failed to play ${y}:`,
|
|
7315
|
+
a.current.playAnimation(y, null, 10, 0, 0.01, E), console.log("Playing animation:", y);
|
|
7316
|
+
} catch (B) {
|
|
7317
|
+
console.log(`Failed to play ${y}:`, B);
|
|
7318
7318
|
try {
|
|
7319
7319
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7320
|
-
} catch (
|
|
7321
|
-
console.warn("Fallback animation also failed:",
|
|
7320
|
+
} catch (Y) {
|
|
7321
|
+
console.warn("Fallback animation also failed:", Y);
|
|
7322
7322
|
}
|
|
7323
7323
|
}
|
|
7324
7324
|
else {
|
|
7325
|
-
const
|
|
7326
|
-
let
|
|
7327
|
-
for (const ae of
|
|
7325
|
+
const B = [".fbx", ".glb", ".gltf"];
|
|
7326
|
+
let Y = !1;
|
|
7327
|
+
for (const ae of B)
|
|
7328
7328
|
try {
|
|
7329
|
-
a.current.playAnimation(y + ae, null, 10, 0, 0.01,
|
|
7329
|
+
a.current.playAnimation(y + ae, null, 10, 0, 0.01, E), console.log("Playing animation:", y + ae), Y = !0;
|
|
7330
7330
|
break;
|
|
7331
7331
|
} catch {
|
|
7332
7332
|
console.log(`Failed to play ${y}${ae}, trying next format...`);
|
|
7333
7333
|
}
|
|
7334
|
-
if (!
|
|
7334
|
+
if (!Y) {
|
|
7335
7335
|
console.warn("Animation system not available or animation not found:", y);
|
|
7336
7336
|
try {
|
|
7337
7337
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
@@ -7343,10 +7343,10 @@ const vt = Be(({
|
|
|
7343
7343
|
} else
|
|
7344
7344
|
console.warn("Animation system not available or animation not found:", y);
|
|
7345
7345
|
}, []);
|
|
7346
|
-
return
|
|
7346
|
+
return Ue(r, () => ({
|
|
7347
7347
|
speakText: I,
|
|
7348
|
-
stopSpeaking:
|
|
7349
|
-
setMood:
|
|
7348
|
+
stopSpeaking: U,
|
|
7349
|
+
setMood: S,
|
|
7350
7350
|
setTimingAdjustment: R,
|
|
7351
7351
|
playAnimation: z,
|
|
7352
7352
|
isReady: p,
|
|
@@ -7355,8 +7355,8 @@ const vt = Be(({
|
|
|
7355
7355
|
if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
|
|
7356
7356
|
try {
|
|
7357
7357
|
a.current.setShowFullAvatar(!0), a.current.setBodyMovement(y), console.log("Body movement set with full body mode:", y);
|
|
7358
|
-
} catch (
|
|
7359
|
-
console.warn("Error setting body movement:",
|
|
7358
|
+
} catch (E) {
|
|
7359
|
+
console.warn("Error setting body movement:", E);
|
|
7360
7360
|
}
|
|
7361
7361
|
},
|
|
7362
7362
|
setMovementIntensity: (y) => a.current?.setMovementIntensity(y),
|
|
@@ -7372,8 +7372,8 @@ const vt = Be(({
|
|
|
7372
7372
|
if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
|
|
7373
7373
|
try {
|
|
7374
7374
|
a.current.setShowFullAvatar(!0), a.current.playReaction(y), console.log("Reaction played with full body mode:", y);
|
|
7375
|
-
} catch (
|
|
7376
|
-
console.warn("Error playing reaction:",
|
|
7375
|
+
} catch (E) {
|
|
7376
|
+
console.warn("Error playing reaction:", E);
|
|
7377
7377
|
}
|
|
7378
7378
|
},
|
|
7379
7379
|
playCelebration: () => {
|
|
@@ -7388,8 +7388,8 @@ const vt = Be(({
|
|
|
7388
7388
|
if (a.current && a.current.setShowFullAvatar)
|
|
7389
7389
|
try {
|
|
7390
7390
|
a.current.setShowFullAvatar(y), console.log("Show full avatar set to:", y);
|
|
7391
|
-
} catch (
|
|
7392
|
-
console.warn("Error setting showFullAvatar:",
|
|
7391
|
+
} catch (E) {
|
|
7392
|
+
console.warn("Error setting showFullAvatar:", E);
|
|
7393
7393
|
}
|
|
7394
7394
|
},
|
|
7395
7395
|
lockAvatarPosition: () => {
|
|
@@ -7408,8 +7408,8 @@ const vt = Be(({
|
|
|
7408
7408
|
console.warn("Error unlocking avatar position:", y);
|
|
7409
7409
|
}
|
|
7410
7410
|
}
|
|
7411
|
-
})), /* @__PURE__ */
|
|
7412
|
-
/* @__PURE__ */
|
|
7411
|
+
})), /* @__PURE__ */ Re("div", { className: `talking-head-container ${i}`, style: s, children: [
|
|
7412
|
+
/* @__PURE__ */ ee(
|
|
7413
7413
|
"div",
|
|
7414
7414
|
{
|
|
7415
7415
|
ref: u,
|
|
@@ -7421,7 +7421,7 @@ const vt = Be(({
|
|
|
7421
7421
|
}
|
|
7422
7422
|
}
|
|
7423
7423
|
),
|
|
7424
|
-
c && /* @__PURE__ */
|
|
7424
|
+
c && /* @__PURE__ */ ee("div", { className: "loading-overlay", style: {
|
|
7425
7425
|
position: "absolute",
|
|
7426
7426
|
top: "50%",
|
|
7427
7427
|
left: "50%",
|
|
@@ -7430,7 +7430,7 @@ const vt = Be(({
|
|
|
7430
7430
|
fontSize: "18px",
|
|
7431
7431
|
zIndex: 10
|
|
7432
7432
|
}, children: "Loading avatar..." }),
|
|
7433
|
-
d && /* @__PURE__ */
|
|
7433
|
+
d && /* @__PURE__ */ ee("div", { className: "error-overlay", style: {
|
|
7434
7434
|
position: "absolute",
|
|
7435
7435
|
top: "50%",
|
|
7436
7436
|
left: "50%",
|
|
@@ -7444,11 +7444,11 @@ const vt = Be(({
|
|
|
7444
7444
|
}, children: d })
|
|
7445
7445
|
] });
|
|
7446
7446
|
});
|
|
7447
|
-
|
|
7448
|
-
async function
|
|
7447
|
+
At.displayName = "TalkingHeadComponent";
|
|
7448
|
+
async function Me(G) {
|
|
7449
7449
|
try {
|
|
7450
|
-
console.log(`📥 Loading animation manifest from: ${
|
|
7451
|
-
const t = await fetch(
|
|
7450
|
+
console.log(`📥 Loading animation manifest from: ${G}`);
|
|
7451
|
+
const t = await fetch(G);
|
|
7452
7452
|
if (!t.ok)
|
|
7453
7453
|
throw new Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);
|
|
7454
7454
|
const e = await t.json();
|
|
@@ -7463,8 +7463,8 @@ async function Qe(Z) {
|
|
|
7463
7463
|
return console.error("❌ Failed to load animation manifest:", t), {};
|
|
7464
7464
|
}
|
|
7465
7465
|
}
|
|
7466
|
-
async function
|
|
7467
|
-
const e = [], n =
|
|
7466
|
+
async function It(G, t = "F") {
|
|
7467
|
+
const e = [], n = G.replace(/\/$/, "");
|
|
7468
7468
|
try {
|
|
7469
7469
|
const s = [
|
|
7470
7470
|
`${n}/.list.json`,
|
|
@@ -7502,19 +7502,19 @@ async function Rt(Z, t = "F") {
|
|
|
7502
7502
|
}
|
|
7503
7503
|
return e.length > 0 || (console.warn(`⚠️ Could not auto-discover animations from ${n}. Consider using a manifest.json file or a server-side directory listing API.`), console.info(`💡 Tip: Create a ${n}/.list.json file with an array of FBX filenames, or use animations: { manifest: "/animations/manifest.json" }`)), e;
|
|
7504
7504
|
}
|
|
7505
|
-
async function
|
|
7505
|
+
async function qe(G, t = "F") {
|
|
7506
7506
|
const e = {};
|
|
7507
|
-
for (const [n, i] of Object.entries(
|
|
7507
|
+
for (const [n, i] of Object.entries(G))
|
|
7508
7508
|
try {
|
|
7509
|
-
const s = await
|
|
7509
|
+
const s = await It(i, t);
|
|
7510
7510
|
s.length > 0 ? (e[n] = s, console.log(`✅ Auto-loaded ${s.length} animations for group "${n}"`)) : console.warn(`⚠️ No animations found in ${i} for group "${n}"`);
|
|
7511
7511
|
} catch (s) {
|
|
7512
7512
|
console.error(`❌ Failed to auto-load animations from ${i}:`, s);
|
|
7513
7513
|
}
|
|
7514
7514
|
return e;
|
|
7515
7515
|
}
|
|
7516
|
-
const
|
|
7517
|
-
text:
|
|
7516
|
+
const Lt = Ne(({
|
|
7517
|
+
text: G = null,
|
|
7518
7518
|
avatarUrl: t = "/avatars/brunette.glb",
|
|
7519
7519
|
avatarBody: e = "F",
|
|
7520
7520
|
mood: n = "neutral",
|
|
@@ -7535,273 +7535,313 @@ const At = Be(({
|
|
|
7535
7535
|
onSpeechEnd: b = () => {
|
|
7536
7536
|
},
|
|
7537
7537
|
className: f = "",
|
|
7538
|
-
style:
|
|
7539
|
-
animations:
|
|
7538
|
+
style: k = {},
|
|
7539
|
+
animations: T = {},
|
|
7540
7540
|
autoAnimationGroup: g = null,
|
|
7541
7541
|
// e.g., "talking" - will randomly select from this group when speaking
|
|
7542
|
-
autoIdleGroup:
|
|
7542
|
+
autoIdleGroup: N = null,
|
|
7543
7543
|
// e.g., "idle" - will randomly select from this group when idle
|
|
7544
|
-
autoSpeak:
|
|
7544
|
+
autoSpeak: F = !1
|
|
7545
7545
|
}, I) => {
|
|
7546
|
-
const
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
}, [
|
|
7546
|
+
const U = X(null), S = X(null), R = X(c), z = X(null), y = X(null), E = X(!1), D = X({ remainingText: null, originalText: null, options: null }), B = X([]), [Y, ae] = le(!0), [ce, be] = le(null), [se, Se] = le(!1), [te, v] = le(!1), [A, M] = le(T), W = X(null), Q = X(!1), re = X(null);
|
|
7547
|
+
ye(() => {
|
|
7548
|
+
E.current = te;
|
|
7549
|
+
}, [te]), ye(() => {
|
|
7550
7550
|
(async () => {
|
|
7551
|
-
if (
|
|
7551
|
+
if (T.manifest && T.auto)
|
|
7552
7552
|
try {
|
|
7553
|
-
console.log("🔄 Loading animations from manifest:",
|
|
7554
|
-
const
|
|
7555
|
-
|
|
7556
|
-
male: Object.keys(
|
|
7557
|
-
female: Object.keys(
|
|
7558
|
-
shared: Object.keys(
|
|
7553
|
+
console.log("🔄 Loading animations from manifest (priority over auto-discovery):", T.manifest);
|
|
7554
|
+
const L = await Me(T.manifest);
|
|
7555
|
+
M(L), console.log("✅ Animations loaded from manifest:", L), L._genderSpecific && console.log("👥 Gender-specific animations detected:", {
|
|
7556
|
+
male: Object.keys(L._genderSpecific.male || {}),
|
|
7557
|
+
female: Object.keys(L._genderSpecific.female || {}),
|
|
7558
|
+
shared: Object.keys(L._genderSpecific.shared || {})
|
|
7559
|
+
});
|
|
7560
|
+
return;
|
|
7561
|
+
} catch (L) {
|
|
7562
|
+
console.warn("⚠️ Manifest failed, falling back to auto-discovery:", L);
|
|
7563
|
+
}
|
|
7564
|
+
if (T.manifest && !T.auto)
|
|
7565
|
+
try {
|
|
7566
|
+
console.log("🔄 Loading animations from manifest:", T.manifest);
|
|
7567
|
+
const L = await Me(T.manifest);
|
|
7568
|
+
M(L), console.log("✅ Animations loaded and set:", L), L._genderSpecific ? console.log("👥 Gender-specific animations detected:", {
|
|
7569
|
+
male: Object.keys(L._genderSpecific.male || {}),
|
|
7570
|
+
female: Object.keys(L._genderSpecific.female || {}),
|
|
7571
|
+
shared: Object.keys(L._genderSpecific.shared || {})
|
|
7559
7572
|
}) : console.log("⚠️ No gender-specific animations found in manifest");
|
|
7560
|
-
} catch (
|
|
7561
|
-
console.error("❌ Failed to load animation manifest:",
|
|
7573
|
+
} catch (L) {
|
|
7574
|
+
console.error("❌ Failed to load animation manifest:", L), M(T);
|
|
7562
7575
|
}
|
|
7563
|
-
else if (
|
|
7576
|
+
else if (T.auto)
|
|
7564
7577
|
try {
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7578
|
+
console.log("🔄 Auto-discovering animations from folder:", T.auto);
|
|
7579
|
+
let L = null;
|
|
7580
|
+
if (T.manifest)
|
|
7581
|
+
try {
|
|
7582
|
+
L = await Me(T.manifest), console.log("📦 Loaded manifest as fallback:", L);
|
|
7583
|
+
} catch (P) {
|
|
7584
|
+
console.warn("⚠️ Could not load manifest fallback:", P);
|
|
7585
|
+
}
|
|
7586
|
+
if (typeof T.auto == "string") {
|
|
7587
|
+
const P = T.auto, Z = {
|
|
7588
|
+
talking: `${P}/talking`,
|
|
7589
|
+
idle: `${P}/idle`
|
|
7590
|
+
}, j = e === "M" ? "male" : "female";
|
|
7591
|
+
Z[`${j}_talking`] = `${P}/${j}/talking`, Z[`${j}_idle`] = `${P}/${j}/idle`, Z.shared_talking = `${P}/shared/talking`, Z.shared_idle = `${P}/shared/idle`;
|
|
7592
|
+
const Ae = await qe(Z, e);
|
|
7593
|
+
if (!Object.values(Ae).some((he) => Array.isArray(he) && he.length > 0) && L) {
|
|
7594
|
+
console.log("⚠️ No animations auto-discovered, using manifest fallback"), M(L);
|
|
7595
|
+
return;
|
|
7596
|
+
}
|
|
7597
|
+
const ue = {
|
|
7572
7598
|
_genderSpecific: {
|
|
7573
|
-
[
|
|
7599
|
+
[j]: {},
|
|
7574
7600
|
shared: {}
|
|
7575
7601
|
}
|
|
7576
7602
|
};
|
|
7577
|
-
Object.entries(
|
|
7578
|
-
if (
|
|
7579
|
-
const [
|
|
7580
|
-
|
|
7603
|
+
Object.entries(Ae).forEach(([he, we]) => {
|
|
7604
|
+
if (he.includes("_")) {
|
|
7605
|
+
const [Ee, ...$e] = he.split("_"), Te = $e.join("_");
|
|
7606
|
+
Ee === "shared" ? (ue._genderSpecific.shared[Te] || (ue._genderSpecific.shared[Te] = []), ue._genderSpecific.shared[Te].push(...we)) : Ee === j && (ue._genderSpecific[j][Te] || (ue._genderSpecific[j][Te] = []), ue._genderSpecific[j][Te].push(...we));
|
|
7581
7607
|
} else
|
|
7582
|
-
ue[
|
|
7583
|
-
}),
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7608
|
+
ue[he] = we;
|
|
7609
|
+
}), L && (L._genderSpecific && Object.keys(L._genderSpecific).forEach((he) => {
|
|
7610
|
+
ue._genderSpecific[he] || (ue._genderSpecific[he] = {}), Object.entries(L._genderSpecific[he]).forEach(([we, Ee]) => {
|
|
7611
|
+
ue._genderSpecific[he][we] || (ue._genderSpecific[he][we] = Ee);
|
|
7612
|
+
});
|
|
7613
|
+
}), Object.entries(L).forEach(([he, we]) => {
|
|
7614
|
+
he !== "_genderSpecific" && !ue[he] && (ue[he] = we);
|
|
7615
|
+
})), M(ue), console.log("✅ Auto-discovered animations:", ue);
|
|
7616
|
+
} else if (typeof T.auto == "object") {
|
|
7617
|
+
const P = await qe(T.auto, e);
|
|
7618
|
+
!Object.values(P).some((j) => Array.isArray(j) && j.length > 0) && L ? (console.log("⚠️ No animations auto-discovered, using manifest fallback"), M(L)) : (M(P), console.log("✅ Auto-discovered animations from folders:", P));
|
|
7587
7619
|
}
|
|
7588
|
-
} catch (
|
|
7589
|
-
console.error("❌ Failed to auto-discover animations:",
|
|
7620
|
+
} catch (L) {
|
|
7621
|
+
if (console.error("❌ Failed to auto-discover animations:", L), T.manifest)
|
|
7622
|
+
try {
|
|
7623
|
+
const P = await Me(T.manifest);
|
|
7624
|
+
M(P), console.log("✅ Using manifest fallback after auto-discovery error");
|
|
7625
|
+
} catch {
|
|
7626
|
+
M(T);
|
|
7627
|
+
}
|
|
7628
|
+
else
|
|
7629
|
+
M(T);
|
|
7590
7630
|
}
|
|
7591
7631
|
else
|
|
7592
|
-
console.log("📝 Using animations from props (no manifest or auto):",
|
|
7632
|
+
console.log("📝 Using animations from props (no manifest or auto):", T), M(T);
|
|
7593
7633
|
})();
|
|
7594
|
-
}, [
|
|
7634
|
+
}, [T, e]), ye(() => {
|
|
7595
7635
|
R.current = c;
|
|
7596
7636
|
}, [c]);
|
|
7597
|
-
const
|
|
7598
|
-
let
|
|
7599
|
-
|
|
7637
|
+
const $ = We(), ne = s || $.service;
|
|
7638
|
+
let fe;
|
|
7639
|
+
ne === "browser" ? fe = {
|
|
7600
7640
|
service: "browser",
|
|
7601
7641
|
endpoint: "",
|
|
7602
7642
|
apiKey: null,
|
|
7603
7643
|
defaultVoice: "Google US English"
|
|
7604
|
-
} :
|
|
7644
|
+
} : ne === "elevenlabs" ? fe = {
|
|
7605
7645
|
service: "elevenlabs",
|
|
7606
7646
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
7607
|
-
apiKey: r ||
|
|
7608
|
-
defaultVoice: o ||
|
|
7609
|
-
voices:
|
|
7610
|
-
} :
|
|
7647
|
+
apiKey: r || $.apiKey,
|
|
7648
|
+
defaultVoice: o || $.defaultVoice || ze.defaultVoice,
|
|
7649
|
+
voices: $.voices || ze.voices
|
|
7650
|
+
} : ne === "deepgram" ? fe = {
|
|
7611
7651
|
service: "deepgram",
|
|
7612
7652
|
endpoint: "https://api.deepgram.com/v1/speak",
|
|
7613
|
-
apiKey: r ||
|
|
7614
|
-
defaultVoice: o ||
|
|
7615
|
-
voices:
|
|
7616
|
-
} :
|
|
7617
|
-
|
|
7618
|
-
apiKey: r !== null ? r :
|
|
7653
|
+
apiKey: r || $.apiKey,
|
|
7654
|
+
defaultVoice: o || $.defaultVoice || De.defaultVoice,
|
|
7655
|
+
voices: $.voices || De.voices
|
|
7656
|
+
} : fe = {
|
|
7657
|
+
...$,
|
|
7658
|
+
apiKey: r !== null ? r : $.apiKey
|
|
7619
7659
|
};
|
|
7620
|
-
const
|
|
7660
|
+
const He = {
|
|
7621
7661
|
url: t,
|
|
7622
7662
|
body: e,
|
|
7623
7663
|
avatarMood: n,
|
|
7624
|
-
ttsLang:
|
|
7625
|
-
ttsVoice: o ||
|
|
7664
|
+
ttsLang: ne === "browser" ? "en-US" : i,
|
|
7665
|
+
ttsVoice: o || fe.defaultVoice,
|
|
7626
7666
|
lipsyncLang: "en",
|
|
7627
7667
|
showFullAvatar: c,
|
|
7628
7668
|
bodyMovement: u,
|
|
7629
7669
|
movementIntensity: a
|
|
7630
|
-
},
|
|
7631
|
-
ttsEndpoint:
|
|
7632
|
-
ttsApikey:
|
|
7633
|
-
ttsService:
|
|
7670
|
+
}, Ve = {
|
|
7671
|
+
ttsEndpoint: fe.endpoint,
|
|
7672
|
+
ttsApikey: fe.apiKey,
|
|
7673
|
+
ttsService: ne,
|
|
7634
7674
|
lipsyncModules: ["en"],
|
|
7635
7675
|
cameraView: l
|
|
7636
|
-
},
|
|
7637
|
-
if (!(!
|
|
7676
|
+
}, Fe = V(async () => {
|
|
7677
|
+
if (!(!U.current || S.current))
|
|
7638
7678
|
try {
|
|
7639
|
-
ae(!0),
|
|
7640
|
-
url:
|
|
7641
|
-
body:
|
|
7642
|
-
avatarMood:
|
|
7643
|
-
}), await
|
|
7644
|
-
if (
|
|
7645
|
-
const
|
|
7646
|
-
h(
|
|
7679
|
+
ae(!0), be(null), S.current = new Ze(U.current, Ve), console.log("Avatar config being passed:", {
|
|
7680
|
+
url: He.url,
|
|
7681
|
+
body: He.body,
|
|
7682
|
+
avatarMood: He.avatarMood
|
|
7683
|
+
}), await S.current.showAvatar(He, (L) => {
|
|
7684
|
+
if (L.lengthComputable) {
|
|
7685
|
+
const P = Math.min(100, Math.round(L.loaded / L.total * 100));
|
|
7686
|
+
h(P);
|
|
7647
7687
|
}
|
|
7648
|
-
}),
|
|
7649
|
-
const
|
|
7650
|
-
document.visibilityState === "visible" ?
|
|
7688
|
+
}), S.current?.avatar && console.log("Avatar body after initialization:", S.current.avatar.body), ae(!1), Se(!0), d(S.current);
|
|
7689
|
+
const w = () => {
|
|
7690
|
+
document.visibilityState === "visible" ? S.current?.start() : S.current?.stop();
|
|
7651
7691
|
};
|
|
7652
|
-
return document.addEventListener("visibilitychange",
|
|
7653
|
-
document.removeEventListener("visibilitychange",
|
|
7692
|
+
return document.addEventListener("visibilitychange", w), () => {
|
|
7693
|
+
document.removeEventListener("visibilitychange", w);
|
|
7654
7694
|
};
|
|
7655
|
-
} catch (
|
|
7656
|
-
console.error("Error initializing TalkingHead:",
|
|
7695
|
+
} catch (w) {
|
|
7696
|
+
console.error("Error initializing TalkingHead:", w), be(w.message || "Failed to initialize avatar"), ae(!1), p(w);
|
|
7657
7697
|
}
|
|
7658
7698
|
}, []);
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
}), [
|
|
7662
|
-
const
|
|
7663
|
-
if (
|
|
7699
|
+
ye(() => (Fe(), () => {
|
|
7700
|
+
S.current && (S.current.stop(), S.current.dispose(), S.current = null);
|
|
7701
|
+
}), [Fe]);
|
|
7702
|
+
const C = V(async () => {
|
|
7703
|
+
if (S.current)
|
|
7664
7704
|
try {
|
|
7665
|
-
const
|
|
7666
|
-
|
|
7667
|
-
} catch (
|
|
7668
|
-
console.warn("Failed to resume audio context:",
|
|
7705
|
+
const w = S.current.audioCtx || S.current.audioContext;
|
|
7706
|
+
w && (w.state === "suspended" || w.state === "interrupted") && (await w.resume(), console.log("Audio context resumed"));
|
|
7707
|
+
} catch (w) {
|
|
7708
|
+
console.warn("Failed to resume audio context:", w);
|
|
7669
7709
|
}
|
|
7670
|
-
}, []),
|
|
7710
|
+
}, []), q = V((w) => {
|
|
7671
7711
|
if (!A)
|
|
7672
7712
|
return console.warn("No animations loaded"), null;
|
|
7673
|
-
let
|
|
7713
|
+
let L = null;
|
|
7674
7714
|
if (A._genderSpecific) {
|
|
7675
|
-
const
|
|
7676
|
-
|
|
7715
|
+
const Z = (e?.toUpperCase() || "F") === "M" ? "male" : "female", j = A._genderSpecific[Z];
|
|
7716
|
+
j && j[w] ? (L = j[w], console.log(`Using ${Z} animations for "${w}":`, L)) : A._genderSpecific.shared && A._genderSpecific.shared[w] && (L = A._genderSpecific.shared[w], console.log(`Using shared animations for "${w}":`, L));
|
|
7677
7717
|
}
|
|
7678
|
-
if (!
|
|
7679
|
-
if (console.warn(`Animation group "${
|
|
7680
|
-
const
|
|
7681
|
-
console.warn(`Gender-specific groups (${
|
|
7718
|
+
if (!L && A[w] && (L = A[w], console.log(`Using root-level animations for "${w}":`, L)), !L) {
|
|
7719
|
+
if (console.warn(`Animation group "${w}" not found. Available groups:`, Object.keys(A).filter((P) => P !== "_genderSpecific")), A._genderSpecific) {
|
|
7720
|
+
const Z = (e?.toUpperCase() || "F") === "M" ? "male" : "female";
|
|
7721
|
+
console.warn(`Gender-specific groups (${Z}):`, Object.keys(A._genderSpecific[Z] || {}));
|
|
7682
7722
|
}
|
|
7683
7723
|
return null;
|
|
7684
7724
|
}
|
|
7685
|
-
if (Array.isArray(
|
|
7686
|
-
const
|
|
7687
|
-
return
|
|
7725
|
+
if (Array.isArray(L) && L.length > 0) {
|
|
7726
|
+
const P = Math.floor(Math.random() * L.length);
|
|
7727
|
+
return L[P];
|
|
7688
7728
|
}
|
|
7689
|
-
return typeof
|
|
7690
|
-
}, [A, e]),
|
|
7691
|
-
if (!
|
|
7729
|
+
return typeof L == "string" ? L : (console.warn(`Animation group "${w}" is not a valid format (expected array or string):`, L), null);
|
|
7730
|
+
}, [A, e]), _ = V((w, L = !1, P = null) => {
|
|
7731
|
+
if (!S.current)
|
|
7692
7732
|
return console.warn("TalkingHead not initialized yet"), null;
|
|
7693
|
-
const
|
|
7694
|
-
if (
|
|
7733
|
+
const Z = q(w);
|
|
7734
|
+
if (Z)
|
|
7695
7735
|
try {
|
|
7696
|
-
const
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
}, 100) :
|
|
7736
|
+
const j = () => {
|
|
7737
|
+
Q.current && re.current === w ? setTimeout(() => {
|
|
7738
|
+
_(w, L, P);
|
|
7739
|
+
}, 100) : P && P();
|
|
7700
7740
|
};
|
|
7701
|
-
return
|
|
7702
|
-
} catch (
|
|
7703
|
-
return console.error(`❌ Failed to play random animation from "${
|
|
7741
|
+
return S.current.playAnimation(Z, null, 10, 0, 0.01, L, j), console.log(`✅ Playing random animation from "${w}" group:`, Z), Z;
|
|
7742
|
+
} catch (j) {
|
|
7743
|
+
return console.error(`❌ Failed to play random animation from "${w}" group:`, j), null;
|
|
7704
7744
|
}
|
|
7705
7745
|
else
|
|
7706
|
-
console.warn(`⚠️ No animation found for group "${
|
|
7746
|
+
console.warn(`⚠️ No animation found for group "${w}"`);
|
|
7707
7747
|
return null;
|
|
7708
|
-
}, [
|
|
7709
|
-
if (!
|
|
7748
|
+
}, [q]), ie = V(async (w, L = {}) => {
|
|
7749
|
+
if (!S.current || !se) {
|
|
7710
7750
|
console.warn("Avatar not ready for speaking");
|
|
7711
7751
|
return;
|
|
7712
7752
|
}
|
|
7713
|
-
if (!
|
|
7753
|
+
if (!w || w.trim() === "") {
|
|
7714
7754
|
console.warn("No text provided to speak");
|
|
7715
7755
|
return;
|
|
7716
7756
|
}
|
|
7717
|
-
await
|
|
7718
|
-
const
|
|
7719
|
-
|
|
7720
|
-
const
|
|
7721
|
-
|
|
7722
|
-
const
|
|
7723
|
-
lipsyncLang:
|
|
7757
|
+
await C();
|
|
7758
|
+
const P = L.animationGroup || g;
|
|
7759
|
+
P && !L.skipAnimation ? (console.log(`🎬 Attempting to play animation from group: "${P}"`), console.log(`📊 Current avatarBody: "${e}", loadedAnimations:`, A), Q.current = !0, re.current = P, _(P)) : console.log(`⏭️ Skipping animation (group: ${P}, skipAnimation: ${L.skipAnimation})`), D.current = { remainingText: null, originalText: null, options: null }, B.current = [], z.current = { text: w, options: L }, y.current && (clearInterval(y.current), y.current = null), v(!1), E.current = !1;
|
|
7760
|
+
const Z = w.split(/[.!?]+/).filter((Ae) => Ae.trim().length > 0);
|
|
7761
|
+
B.current = Z;
|
|
7762
|
+
const j = {
|
|
7763
|
+
lipsyncLang: L.lipsyncLang || "en",
|
|
7724
7764
|
onSpeechEnd: () => {
|
|
7725
|
-
y.current && (clearInterval(y.current), y.current = null),
|
|
7765
|
+
y.current && (clearInterval(y.current), y.current = null), Q.current = !1, re.current = null, L.onSpeechEnd && L.onSpeechEnd(), b();
|
|
7726
7766
|
}
|
|
7727
7767
|
};
|
|
7728
7768
|
try {
|
|
7729
|
-
|
|
7730
|
-
} catch (
|
|
7731
|
-
console.error("Error speaking text:",
|
|
7769
|
+
S.current.speakText(w, j);
|
|
7770
|
+
} catch (Ae) {
|
|
7771
|
+
console.error("Error speaking text:", Ae), be(Ae.message || "Failed to speak text");
|
|
7732
7772
|
}
|
|
7733
|
-
}, [se, b,
|
|
7734
|
-
|
|
7735
|
-
if (!se || !
|
|
7773
|
+
}, [se, b, C, g, _]);
|
|
7774
|
+
ye(() => {
|
|
7775
|
+
if (!se || !N || !S.current)
|
|
7736
7776
|
return;
|
|
7737
|
-
|
|
7738
|
-
const
|
|
7739
|
-
|
|
7777
|
+
W.current && clearInterval(W.current);
|
|
7778
|
+
const w = () => {
|
|
7779
|
+
S.current && !E.current && _(N);
|
|
7740
7780
|
};
|
|
7741
|
-
return
|
|
7742
|
-
|
|
7781
|
+
return w(), W.current = setInterval(() => {
|
|
7782
|
+
w();
|
|
7743
7783
|
}, 12e3 + Math.random() * 3e3), () => {
|
|
7744
|
-
|
|
7784
|
+
W.current && (clearInterval(W.current), W.current = null);
|
|
7745
7785
|
};
|
|
7746
|
-
}, [se,
|
|
7747
|
-
se &&
|
|
7748
|
-
}, [se,
|
|
7749
|
-
const
|
|
7750
|
-
if (
|
|
7786
|
+
}, [se, N, _]), ye(() => {
|
|
7787
|
+
se && G && F && S.current && ie(G);
|
|
7788
|
+
}, [se, G, F, ie]);
|
|
7789
|
+
const ve = V(() => {
|
|
7790
|
+
if (S.current)
|
|
7751
7791
|
try {
|
|
7752
|
-
const
|
|
7753
|
-
if (
|
|
7792
|
+
const w = S.current.isSpeaking || !1, L = S.current.audioPlaylist || [], P = S.current.speechQueue || [];
|
|
7793
|
+
if (w || L.length > 0 || P.length > 0) {
|
|
7754
7794
|
y.current && (clearInterval(y.current), y.current = null);
|
|
7755
|
-
let
|
|
7756
|
-
|
|
7757
|
-
remainingText:
|
|
7795
|
+
let Z = "";
|
|
7796
|
+
P.length > 0 && (Z = P.map((j) => j.text && Array.isArray(j.text) ? j.text.map((Ae) => Ae.word).join(" ") : j.text || "").join(" ")), D.current = {
|
|
7797
|
+
remainingText: Z || null,
|
|
7758
7798
|
originalText: z.current?.text || null,
|
|
7759
7799
|
options: z.current?.options || null
|
|
7760
|
-
},
|
|
7800
|
+
}, S.current.speechQueue.length = 0, S.current.pauseSpeaking(), v(!0), E.current = !0;
|
|
7761
7801
|
}
|
|
7762
|
-
} catch (
|
|
7763
|
-
console.warn("Error pausing speech:",
|
|
7802
|
+
} catch (w) {
|
|
7803
|
+
console.warn("Error pausing speech:", w);
|
|
7764
7804
|
}
|
|
7765
|
-
}, []),
|
|
7766
|
-
if (!(!
|
|
7805
|
+
}, []), J = V(async () => {
|
|
7806
|
+
if (!(!S.current || !te))
|
|
7767
7807
|
try {
|
|
7768
|
-
await
|
|
7769
|
-
const
|
|
7770
|
-
|
|
7771
|
-
} catch (
|
|
7772
|
-
console.warn("Error resuming speech:",
|
|
7808
|
+
await C(), v(!1), E.current = !1;
|
|
7809
|
+
const w = D.current?.remainingText, L = D.current?.originalText || z.current?.text, P = D.current?.options || z.current?.options || {}, Z = w || L;
|
|
7810
|
+
Z && ie(Z, P);
|
|
7811
|
+
} catch (w) {
|
|
7812
|
+
console.warn("Error resuming speech:", w), v(!1), E.current = !1;
|
|
7773
7813
|
}
|
|
7774
|
-
}, [
|
|
7775
|
-
|
|
7814
|
+
}, [te, ie, C]), pe = V(() => {
|
|
7815
|
+
S.current && (S.current.stopSpeaking(), y.current && (clearInterval(y.current), y.current = null), Q.current = !1, re.current = null, v(!1), E.current = !1);
|
|
7776
7816
|
}, []);
|
|
7777
|
-
return
|
|
7778
|
-
speakText:
|
|
7779
|
-
pauseSpeaking:
|
|
7780
|
-
resumeSpeaking:
|
|
7781
|
-
stopSpeaking:
|
|
7782
|
-
resumeAudioContext:
|
|
7783
|
-
isPaused: () =>
|
|
7784
|
-
setMood: (
|
|
7785
|
-
setBodyMovement: (
|
|
7786
|
-
|
|
7817
|
+
return Ue(I, () => ({
|
|
7818
|
+
speakText: ie,
|
|
7819
|
+
pauseSpeaking: ve,
|
|
7820
|
+
resumeSpeaking: J,
|
|
7821
|
+
stopSpeaking: pe,
|
|
7822
|
+
resumeAudioContext: C,
|
|
7823
|
+
isPaused: () => te,
|
|
7824
|
+
setMood: (w) => S.current?.setMood(w),
|
|
7825
|
+
setBodyMovement: (w) => {
|
|
7826
|
+
S.current && S.current.setBodyMovement(w);
|
|
7787
7827
|
},
|
|
7788
|
-
playAnimation: (
|
|
7789
|
-
|
|
7828
|
+
playAnimation: (w, L = !1) => {
|
|
7829
|
+
S.current && S.current.playAnimation && S.current.playAnimation(w, null, 10, 0, 0.01, L);
|
|
7790
7830
|
},
|
|
7791
|
-
playRandomAnimation: (
|
|
7792
|
-
getRandomAnimation: (
|
|
7793
|
-
playReaction: (
|
|
7794
|
-
playCelebration: () =>
|
|
7795
|
-
setShowFullAvatar: (
|
|
7796
|
-
|
|
7831
|
+
playRandomAnimation: (w, L = !1) => _(w, L),
|
|
7832
|
+
getRandomAnimation: (w) => q(w),
|
|
7833
|
+
playReaction: (w) => S.current?.playReaction(w),
|
|
7834
|
+
playCelebration: () => S.current?.playCelebration(),
|
|
7835
|
+
setShowFullAvatar: (w) => {
|
|
7836
|
+
S.current && (R.current = w, S.current.setShowFullAvatar(w));
|
|
7797
7837
|
},
|
|
7798
7838
|
isReady: se,
|
|
7799
|
-
talkingHead:
|
|
7800
|
-
})), /* @__PURE__ */
|
|
7801
|
-
/* @__PURE__ */
|
|
7839
|
+
talkingHead: S.current
|
|
7840
|
+
})), /* @__PURE__ */ Re("div", { className: `simple-talking-avatar-container ${f}`, style: k, children: [
|
|
7841
|
+
/* @__PURE__ */ ee(
|
|
7802
7842
|
"div",
|
|
7803
7843
|
{
|
|
7804
|
-
ref:
|
|
7844
|
+
ref: U,
|
|
7805
7845
|
className: "talking-head-viewer",
|
|
7806
7846
|
style: {
|
|
7807
7847
|
width: "100%",
|
|
@@ -7810,7 +7850,7 @@ const At = Be(({
|
|
|
7810
7850
|
}
|
|
7811
7851
|
}
|
|
7812
7852
|
),
|
|
7813
|
-
|
|
7853
|
+
Y && /* @__PURE__ */ ee("div", { className: "loading-overlay", style: {
|
|
7814
7854
|
position: "absolute",
|
|
7815
7855
|
top: "50%",
|
|
7816
7856
|
left: "50%",
|
|
@@ -7819,7 +7859,7 @@ const At = Be(({
|
|
|
7819
7859
|
fontSize: "18px",
|
|
7820
7860
|
zIndex: 10
|
|
7821
7861
|
}, children: "Loading avatar..." }),
|
|
7822
|
-
ce && /* @__PURE__ */
|
|
7862
|
+
ce && /* @__PURE__ */ ee("div", { className: "error-overlay", style: {
|
|
7823
7863
|
position: "absolute",
|
|
7824
7864
|
top: "50%",
|
|
7825
7865
|
left: "50%",
|
|
@@ -7833,9 +7873,9 @@ const At = Be(({
|
|
|
7833
7873
|
}, children: ce })
|
|
7834
7874
|
] });
|
|
7835
7875
|
});
|
|
7836
|
-
|
|
7837
|
-
const
|
|
7838
|
-
curriculumData:
|
|
7876
|
+
Lt.displayName = "SimpleTalkingAvatar";
|
|
7877
|
+
const St = Ne(({
|
|
7878
|
+
curriculumData: G = null,
|
|
7839
7879
|
avatarConfig: t = {},
|
|
7840
7880
|
animations: e = {},
|
|
7841
7881
|
onLessonStart: n = () => {
|
|
@@ -7866,12 +7906,12 @@ const It = Be(({
|
|
|
7866
7906
|
onQuestionAnswer: s,
|
|
7867
7907
|
onCurriculumComplete: o,
|
|
7868
7908
|
onCustomAction: r
|
|
7869
|
-
}), h = X(null), p = X(null), b = X(null), f = X(null),
|
|
7909
|
+
}), h = X(null), p = X(null), b = X(null), f = X(null), k = X(null), T = X(null), g = X(null), N = X(G?.curriculum || {
|
|
7870
7910
|
title: "Default Curriculum",
|
|
7871
7911
|
description: "No curriculum data provided",
|
|
7872
7912
|
language: "en",
|
|
7873
7913
|
modules: []
|
|
7874
|
-
}),
|
|
7914
|
+
}), F = X({
|
|
7875
7915
|
avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
|
|
7876
7916
|
avatarBody: t.avatarBody || "F",
|
|
7877
7917
|
mood: t.mood || "happy",
|
|
@@ -7885,7 +7925,7 @@ const It = Be(({
|
|
|
7885
7925
|
animations: e,
|
|
7886
7926
|
lipsyncLang: "en"
|
|
7887
7927
|
});
|
|
7888
|
-
|
|
7928
|
+
ye(() => {
|
|
7889
7929
|
d.current = {
|
|
7890
7930
|
onLessonStart: n,
|
|
7891
7931
|
onLessonComplete: i,
|
|
@@ -7893,13 +7933,13 @@ const It = Be(({
|
|
|
7893
7933
|
onCurriculumComplete: o,
|
|
7894
7934
|
onCustomAction: r
|
|
7895
7935
|
};
|
|
7896
|
-
}, [n, i, s, o, r]),
|
|
7897
|
-
|
|
7936
|
+
}, [n, i, s, o, r]), ye(() => {
|
|
7937
|
+
N.current = G?.curriculum || {
|
|
7898
7938
|
title: "Default Curriculum",
|
|
7899
7939
|
description: "No curriculum data provided",
|
|
7900
7940
|
language: "en",
|
|
7901
7941
|
modules: []
|
|
7902
|
-
},
|
|
7942
|
+
}, F.current = {
|
|
7903
7943
|
avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
|
|
7904
7944
|
avatarBody: t.avatarBody || "F",
|
|
7905
7945
|
mood: t.mood || "happy",
|
|
@@ -7913,8 +7953,8 @@ const It = Be(({
|
|
|
7913
7953
|
animations: e,
|
|
7914
7954
|
lipsyncLang: "en"
|
|
7915
7955
|
};
|
|
7916
|
-
}, [
|
|
7917
|
-
const I =
|
|
7956
|
+
}, [G, t, e]);
|
|
7957
|
+
const I = V(() => (N.current || { modules: [] }).modules[l.current.currentModuleIndex]?.lessons[l.current.currentLessonIndex], []), U = V(() => I()?.questions[l.current.currentQuestionIndex], [I]), S = V((v, A) => A.type === "multiple_choice" || A.type === "true_false" ? v === A.answer : A.type === "code_test" && typeof v == "object" && v !== null ? v.passed === !0 : !1, []), R = V(() => {
|
|
7918
7958
|
l.current.lessonCompleted = !0, l.current.isQuestionMode = !1;
|
|
7919
7959
|
const v = l.current.totalQuestions > 0 ? Math.round(l.current.score / l.current.totalQuestions * 100) : 100;
|
|
7920
7960
|
let A = "Congratulations! You've completed this lesson";
|
|
@@ -7938,9 +7978,9 @@ const It = Be(({
|
|
|
7938
7978
|
} catch {
|
|
7939
7979
|
c.current.playCelebration();
|
|
7940
7980
|
}
|
|
7941
|
-
const
|
|
7981
|
+
const M = N.current || { modules: [] }, W = M.modules[l.current.currentModuleIndex], Q = l.current.currentLessonIndex < (W?.lessons?.length || 0) - 1, re = l.current.currentModuleIndex < (M.modules?.length || 0) - 1, $ = Q || re, ne = F.current || { lipsyncLang: "en" };
|
|
7942
7982
|
c.current.speakText(A, {
|
|
7943
|
-
lipsyncLang:
|
|
7983
|
+
lipsyncLang: ne.lipsyncLang,
|
|
7944
7984
|
onSpeechEnd: () => {
|
|
7945
7985
|
d.current.onCustomAction({
|
|
7946
7986
|
type: "lessonCompleteFeedbackDone",
|
|
@@ -7949,17 +7989,17 @@ const It = Be(({
|
|
|
7949
7989
|
score: l.current.score,
|
|
7950
7990
|
totalQuestions: l.current.totalQuestions,
|
|
7951
7991
|
percentage: v,
|
|
7952
|
-
hasNextLesson:
|
|
7992
|
+
hasNextLesson: $
|
|
7953
7993
|
});
|
|
7954
7994
|
}
|
|
7955
7995
|
});
|
|
7956
7996
|
}
|
|
7957
|
-
}, [e.lessonComplete]), z =
|
|
7997
|
+
}, [e.lessonComplete]), z = V(() => {
|
|
7958
7998
|
l.current.curriculumCompleted = !0;
|
|
7959
|
-
const v =
|
|
7999
|
+
const v = N.current || { modules: [] };
|
|
7960
8000
|
if (d.current.onCurriculumComplete({
|
|
7961
8001
|
modules: v.modules.length,
|
|
7962
|
-
totalLessons: v.modules.reduce((A,
|
|
8002
|
+
totalLessons: v.modules.reduce((A, M) => A + M.lessons.length, 0)
|
|
7963
8003
|
}), c.current) {
|
|
7964
8004
|
if (c.current.setMood("celebrating"), e.curriculumComplete)
|
|
7965
8005
|
try {
|
|
@@ -7967,13 +8007,13 @@ const It = Be(({
|
|
|
7967
8007
|
} catch {
|
|
7968
8008
|
c.current.playCelebration();
|
|
7969
8009
|
}
|
|
7970
|
-
const A =
|
|
8010
|
+
const A = F.current || { lipsyncLang: "en" };
|
|
7971
8011
|
c.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: A.lipsyncLang });
|
|
7972
8012
|
}
|
|
7973
|
-
}, [e.curriculumComplete]), y =
|
|
8013
|
+
}, [e.curriculumComplete]), y = V(() => {
|
|
7974
8014
|
const v = I();
|
|
7975
8015
|
l.current.isQuestionMode = !0, l.current.currentQuestionIndex = 0, l.current.totalQuestions = v?.questions?.length || 0, l.current.score = 0;
|
|
7976
|
-
const A =
|
|
8016
|
+
const A = U();
|
|
7977
8017
|
A && d.current.onCustomAction({
|
|
7978
8018
|
type: "questionStart",
|
|
7979
8019
|
moduleIndex: l.current.currentModuleIndex,
|
|
@@ -7983,35 +8023,35 @@ const It = Be(({
|
|
|
7983
8023
|
question: A,
|
|
7984
8024
|
score: l.current.score
|
|
7985
8025
|
});
|
|
7986
|
-
const
|
|
8026
|
+
const M = () => {
|
|
7987
8027
|
if (!c.current || !A) return;
|
|
7988
8028
|
if (c.current.setMood("happy"), e.questionStart)
|
|
7989
8029
|
try {
|
|
7990
8030
|
c.current.playAnimation(e.questionStart, !0);
|
|
7991
|
-
} catch (
|
|
7992
|
-
console.warn("Failed to play questionStart animation:",
|
|
8031
|
+
} catch (Q) {
|
|
8032
|
+
console.warn("Failed to play questionStart animation:", Q);
|
|
7993
8033
|
}
|
|
7994
|
-
const
|
|
7995
|
-
A.type === "code_test" ? c.current.speakText(`Let's test your coding skills! Here's your first challenge: ${A.question}`, { lipsyncLang:
|
|
8034
|
+
const W = F.current || { lipsyncLang: "en" };
|
|
8035
|
+
A.type === "code_test" ? c.current.speakText(`Let's test your coding skills! Here's your first challenge: ${A.question}`, { lipsyncLang: W.lipsyncLang }) : A.type === "multiple_choice" ? c.current.speakText(`Now let me ask you some questions. Here's the first one: ${A.question}`, { lipsyncLang: W.lipsyncLang }) : A.type === "true_false" ? c.current.speakText(`Let's start with some true or false questions. First question: ${A.question}`, { lipsyncLang: W.lipsyncLang }) : c.current.speakText(`Now let me ask you some questions. Here's the first one: ${A.question}`, { lipsyncLang: W.lipsyncLang });
|
|
7996
8036
|
};
|
|
7997
8037
|
if (c.current && c.current.isReady && A)
|
|
7998
|
-
|
|
8038
|
+
M();
|
|
7999
8039
|
else if (c.current && c.current.isReady) {
|
|
8000
|
-
const
|
|
8001
|
-
c.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang:
|
|
8040
|
+
const W = F.current || { lipsyncLang: "en" };
|
|
8041
|
+
c.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: W.lipsyncLang });
|
|
8002
8042
|
} else {
|
|
8003
|
-
const
|
|
8004
|
-
c.current && c.current.isReady && (clearInterval(
|
|
8043
|
+
const W = setInterval(() => {
|
|
8044
|
+
c.current && c.current.isReady && (clearInterval(W), A && M());
|
|
8005
8045
|
}, 100);
|
|
8006
8046
|
setTimeout(() => {
|
|
8007
|
-
clearInterval(
|
|
8047
|
+
clearInterval(W);
|
|
8008
8048
|
}, 5e3);
|
|
8009
8049
|
}
|
|
8010
|
-
}, [e.questionStart, I,
|
|
8050
|
+
}, [e.questionStart, I, U]), E = V(() => {
|
|
8011
8051
|
const v = I();
|
|
8012
8052
|
if (l.current.currentQuestionIndex < (v?.questions?.length || 0) - 1) {
|
|
8013
8053
|
c.current && c.current.stopSpeaking && c.current.stopSpeaking(), l.current.currentQuestionIndex += 1;
|
|
8014
|
-
const A =
|
|
8054
|
+
const A = U();
|
|
8015
8055
|
A && d.current.onCustomAction({
|
|
8016
8056
|
type: "nextQuestion",
|
|
8017
8057
|
moduleIndex: l.current.currentModuleIndex,
|
|
@@ -8021,45 +8061,45 @@ const It = Be(({
|
|
|
8021
8061
|
question: A,
|
|
8022
8062
|
score: l.current.score
|
|
8023
8063
|
});
|
|
8024
|
-
const
|
|
8064
|
+
const M = () => {
|
|
8025
8065
|
if (!c.current || !A) return;
|
|
8026
8066
|
if (c.current.setMood("happy"), c.current.setBodyMovement("idle"), e.nextQuestion)
|
|
8027
8067
|
try {
|
|
8028
8068
|
c.current.playAnimation(e.nextQuestion, !0);
|
|
8029
|
-
} catch (
|
|
8030
|
-
console.warn("Failed to play nextQuestion animation:",
|
|
8069
|
+
} catch (ne) {
|
|
8070
|
+
console.warn("Failed to play nextQuestion animation:", ne);
|
|
8031
8071
|
}
|
|
8032
|
-
const
|
|
8072
|
+
const W = F.current || { lipsyncLang: "en" }, re = I()?.questions?.length || 0, $ = l.current.currentQuestionIndex >= re - 1;
|
|
8033
8073
|
if (A.type === "code_test") {
|
|
8034
|
-
const
|
|
8035
|
-
c.current.speakText(
|
|
8036
|
-
lipsyncLang:
|
|
8074
|
+
const ne = $ ? `Great! Here's your final coding challenge: ${A.question}` : `Great! Now let's move on to your next coding challenge: ${A.question}`;
|
|
8075
|
+
c.current.speakText(ne, {
|
|
8076
|
+
lipsyncLang: W.lipsyncLang
|
|
8037
8077
|
});
|
|
8038
8078
|
} else if (A.type === "multiple_choice") {
|
|
8039
|
-
const
|
|
8040
|
-
c.current.speakText(
|
|
8041
|
-
lipsyncLang:
|
|
8079
|
+
const ne = $ ? `Alright! Here's your final question: ${A.question}` : `Alright! Here's your next question: ${A.question}`;
|
|
8080
|
+
c.current.speakText(ne, {
|
|
8081
|
+
lipsyncLang: W.lipsyncLang
|
|
8042
8082
|
});
|
|
8043
8083
|
} else if (A.type === "true_false") {
|
|
8044
|
-
const
|
|
8045
|
-
c.current.speakText(
|
|
8046
|
-
lipsyncLang:
|
|
8084
|
+
const ne = $ ? `Now let's try this final one: ${A.question}` : `Now let's try this one: ${A.question}`;
|
|
8085
|
+
c.current.speakText(ne, {
|
|
8086
|
+
lipsyncLang: W.lipsyncLang
|
|
8047
8087
|
});
|
|
8048
8088
|
} else {
|
|
8049
|
-
const
|
|
8050
|
-
c.current.speakText(
|
|
8051
|
-
lipsyncLang:
|
|
8089
|
+
const ne = $ ? `Here's your final question: ${A.question}` : `Here's the next question: ${A.question}`;
|
|
8090
|
+
c.current.speakText(ne, {
|
|
8091
|
+
lipsyncLang: W.lipsyncLang
|
|
8052
8092
|
});
|
|
8053
8093
|
}
|
|
8054
8094
|
};
|
|
8055
8095
|
if (c.current && c.current.isReady && A)
|
|
8056
|
-
|
|
8096
|
+
M();
|
|
8057
8097
|
else if (A) {
|
|
8058
|
-
const
|
|
8059
|
-
c.current && c.current.isReady && (clearInterval(
|
|
8098
|
+
const W = setInterval(() => {
|
|
8099
|
+
c.current && c.current.isReady && (clearInterval(W), M());
|
|
8060
8100
|
}, 100);
|
|
8061
8101
|
setTimeout(() => {
|
|
8062
|
-
clearInterval(
|
|
8102
|
+
clearInterval(W);
|
|
8063
8103
|
}, 5e3);
|
|
8064
8104
|
}
|
|
8065
8105
|
} else
|
|
@@ -8070,16 +8110,16 @@ const It = Be(({
|
|
|
8070
8110
|
totalQuestions: l.current.totalQuestions,
|
|
8071
8111
|
score: l.current.score
|
|
8072
8112
|
});
|
|
8073
|
-
}, [e.nextQuestion, I,
|
|
8074
|
-
const v =
|
|
8113
|
+
}, [e.nextQuestion, I, U]), D = V(() => {
|
|
8114
|
+
const v = N.current || { modules: [] }, A = v.modules[l.current.currentModuleIndex];
|
|
8075
8115
|
if (l.current.currentLessonIndex < (A?.lessons?.length || 0) - 1) {
|
|
8076
8116
|
l.current.currentLessonIndex += 1, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0;
|
|
8077
|
-
const
|
|
8117
|
+
const W = v.modules[l.current.currentModuleIndex], Q = l.current.currentLessonIndex < (W?.lessons?.length || 0) - 1, re = l.current.currentModuleIndex < (v.modules?.length || 0) - 1, $ = Q || re;
|
|
8078
8118
|
d.current.onCustomAction({
|
|
8079
8119
|
type: "lessonStart",
|
|
8080
8120
|
moduleIndex: l.current.currentModuleIndex,
|
|
8081
8121
|
lessonIndex: l.current.currentLessonIndex,
|
|
8082
|
-
hasNextLesson:
|
|
8122
|
+
hasNextLesson: $
|
|
8083
8123
|
}), d.current.onLessonStart({
|
|
8084
8124
|
moduleIndex: l.current.currentModuleIndex,
|
|
8085
8125
|
lessonIndex: l.current.currentLessonIndex,
|
|
@@ -8087,38 +8127,38 @@ const It = Be(({
|
|
|
8087
8127
|
}), c.current && (c.current.setMood("happy"), c.current.setBodyMovement("idle"));
|
|
8088
8128
|
} else if (l.current.currentModuleIndex < (v.modules?.length || 0) - 1) {
|
|
8089
8129
|
l.current.currentModuleIndex += 1, l.current.currentLessonIndex = 0, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0;
|
|
8090
|
-
const
|
|
8130
|
+
const Q = v.modules[l.current.currentModuleIndex], re = l.current.currentLessonIndex < (Q?.lessons?.length || 0) - 1, $ = l.current.currentModuleIndex < (v.modules?.length || 0) - 1, ne = re || $;
|
|
8091
8131
|
d.current.onCustomAction({
|
|
8092
8132
|
type: "lessonStart",
|
|
8093
8133
|
moduleIndex: l.current.currentModuleIndex,
|
|
8094
8134
|
lessonIndex: l.current.currentLessonIndex,
|
|
8095
|
-
hasNextLesson:
|
|
8135
|
+
hasNextLesson: ne
|
|
8096
8136
|
}), d.current.onLessonStart({
|
|
8097
8137
|
moduleIndex: l.current.currentModuleIndex,
|
|
8098
8138
|
lessonIndex: l.current.currentLessonIndex,
|
|
8099
8139
|
lesson: I()
|
|
8100
8140
|
}), c.current && (c.current.setMood("happy"), c.current.setBodyMovement("idle"));
|
|
8101
8141
|
} else
|
|
8102
|
-
|
|
8103
|
-
}, []),
|
|
8142
|
+
k.current && k.current();
|
|
8143
|
+
}, []), B = V(() => {
|
|
8104
8144
|
const v = I();
|
|
8105
8145
|
let A = null;
|
|
8106
8146
|
if (v?.avatar_script && v?.body) {
|
|
8107
|
-
const
|
|
8108
|
-
A = `${
|
|
8147
|
+
const M = v.avatar_script.trim(), W = v.body.trim(), Q = M.match(/[.!?]$/) ? " " : ". ";
|
|
8148
|
+
A = `${M}${Q}${W}`;
|
|
8109
8149
|
} else
|
|
8110
8150
|
A = v?.avatar_script || v?.body || null;
|
|
8111
8151
|
if (c.current && c.current.isReady && A) {
|
|
8112
8152
|
l.current.isTeaching = !0, l.current.isQuestionMode = !1, l.current.score = 0, l.current.totalQuestions = 0, c.current.setMood("happy");
|
|
8113
|
-
let
|
|
8153
|
+
let M = !1;
|
|
8114
8154
|
if (e.teaching)
|
|
8115
8155
|
try {
|
|
8116
|
-
c.current.playAnimation(e.teaching, !0),
|
|
8117
|
-
} catch (
|
|
8118
|
-
console.warn("Failed to play teaching animation:",
|
|
8156
|
+
c.current.playAnimation(e.teaching, !0), M = !0;
|
|
8157
|
+
} catch (Q) {
|
|
8158
|
+
console.warn("Failed to play teaching animation:", Q);
|
|
8119
8159
|
}
|
|
8120
|
-
|
|
8121
|
-
const
|
|
8160
|
+
M || c.current.setBodyMovement("gesturing");
|
|
8161
|
+
const W = F.current || { lipsyncLang: "en" };
|
|
8122
8162
|
d.current.onLessonStart({
|
|
8123
8163
|
moduleIndex: l.current.currentModuleIndex,
|
|
8124
8164
|
lessonIndex: l.current.currentLessonIndex,
|
|
@@ -8129,7 +8169,7 @@ const It = Be(({
|
|
|
8129
8169
|
lessonIndex: l.current.currentLessonIndex,
|
|
8130
8170
|
lesson: v
|
|
8131
8171
|
}), c.current.speakText(A, {
|
|
8132
|
-
lipsyncLang:
|
|
8172
|
+
lipsyncLang: W.lipsyncLang,
|
|
8133
8173
|
onSpeechEnd: () => {
|
|
8134
8174
|
l.current.isTeaching = !1, d.current.onCustomAction({
|
|
8135
8175
|
type: "teachingComplete",
|
|
@@ -8147,17 +8187,17 @@ const It = Be(({
|
|
|
8147
8187
|
}
|
|
8148
8188
|
});
|
|
8149
8189
|
}
|
|
8150
|
-
}, [e.teaching, I]),
|
|
8151
|
-
const A =
|
|
8152
|
-
if (
|
|
8190
|
+
}, [e.teaching, I]), Y = V((v) => {
|
|
8191
|
+
const A = U(), M = S(v, A);
|
|
8192
|
+
if (M && (l.current.score += 1), d.current.onQuestionAnswer({
|
|
8153
8193
|
moduleIndex: l.current.currentModuleIndex,
|
|
8154
8194
|
lessonIndex: l.current.currentLessonIndex,
|
|
8155
8195
|
questionIndex: l.current.currentQuestionIndex,
|
|
8156
8196
|
answer: v,
|
|
8157
|
-
isCorrect:
|
|
8197
|
+
isCorrect: M,
|
|
8158
8198
|
question: A
|
|
8159
8199
|
}), c.current)
|
|
8160
|
-
if (
|
|
8200
|
+
if (M) {
|
|
8161
8201
|
if (c.current.setMood("happy"), e.correct)
|
|
8162
8202
|
try {
|
|
8163
8203
|
c.current.playReaction("happy");
|
|
@@ -8165,13 +8205,13 @@ const It = Be(({
|
|
|
8165
8205
|
c.current.setBodyMovement("happy");
|
|
8166
8206
|
}
|
|
8167
8207
|
c.current.setBodyMovement("gesturing");
|
|
8168
|
-
const
|
|
8169
|
-
l.current.currentQuestionIndex >=
|
|
8170
|
-
const re = l.current.currentQuestionIndex <
|
|
8171
|
-
console.log("[CurriculumLearning] Answer feedback - questionIndex:", l.current.currentQuestionIndex, "totalQuestions:",
|
|
8172
|
-
const
|
|
8173
|
-
c.current.speakText(
|
|
8174
|
-
lipsyncLang:
|
|
8208
|
+
const Q = I()?.questions?.length || 0;
|
|
8209
|
+
l.current.currentQuestionIndex >= Q - 1;
|
|
8210
|
+
const re = l.current.currentQuestionIndex < Q - 1;
|
|
8211
|
+
console.log("[CurriculumLearning] Answer feedback - questionIndex:", l.current.currentQuestionIndex, "totalQuestions:", Q, "hasNextQuestion:", re);
|
|
8212
|
+
const $ = A.type === "code_test" ? `Great job! Your code passed all the tests! ${A.explanation || ""}` : `Excellent! That's correct! ${A.explanation || ""}`, ne = F.current || { lipsyncLang: "en" };
|
|
8213
|
+
c.current.speakText($, {
|
|
8214
|
+
lipsyncLang: ne.lipsyncLang,
|
|
8175
8215
|
onSpeechEnd: () => {
|
|
8176
8216
|
d.current.onCustomAction({
|
|
8177
8217
|
type: "answerFeedbackComplete",
|
|
@@ -8193,11 +8233,11 @@ const It = Be(({
|
|
|
8193
8233
|
c.current.setBodyMovement("idle");
|
|
8194
8234
|
}
|
|
8195
8235
|
c.current.setBodyMovement("gesturing");
|
|
8196
|
-
const
|
|
8197
|
-
console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", l.current.currentQuestionIndex, "totalQuestions:",
|
|
8198
|
-
const
|
|
8199
|
-
c.current.speakText(
|
|
8200
|
-
lipsyncLang:
|
|
8236
|
+
const Q = I()?.questions?.length || 0, re = l.current.currentQuestionIndex >= Q - 1, $ = l.current.currentQuestionIndex < Q - 1;
|
|
8237
|
+
console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", l.current.currentQuestionIndex, "totalQuestions:", Q, "hasNextQuestion:", $);
|
|
8238
|
+
const ne = A.type === "code_test" ? `Your code didn't pass all the tests. ${A.explanation || "Try again!"}` : `Not quite right, but don't worry! ${A.explanation || ""}${re ? "" : " Let's move on to the next question."}`, fe = F.current || { lipsyncLang: "en" };
|
|
8239
|
+
c.current.speakText(ne, {
|
|
8240
|
+
lipsyncLang: fe.lipsyncLang,
|
|
8201
8241
|
onSpeechEnd: () => {
|
|
8202
8242
|
d.current.onCustomAction({
|
|
8203
8243
|
type: "answerFeedbackComplete",
|
|
@@ -8205,7 +8245,7 @@ const It = Be(({
|
|
|
8205
8245
|
lessonIndex: l.current.currentLessonIndex,
|
|
8206
8246
|
questionIndex: l.current.currentQuestionIndex,
|
|
8207
8247
|
isCorrect: !1,
|
|
8208
|
-
hasNextQuestion:
|
|
8248
|
+
hasNextQuestion: $,
|
|
8209
8249
|
score: l.current.score,
|
|
8210
8250
|
totalQuestions: l.current.totalQuestions
|
|
8211
8251
|
});
|
|
@@ -8213,21 +8253,21 @@ const It = Be(({
|
|
|
8213
8253
|
});
|
|
8214
8254
|
}
|
|
8215
8255
|
else {
|
|
8216
|
-
const
|
|
8256
|
+
const Q = I()?.questions?.length || 0;
|
|
8217
8257
|
d.current.onCustomAction({
|
|
8218
8258
|
type: "answerFeedbackComplete",
|
|
8219
8259
|
moduleIndex: l.current.currentModuleIndex,
|
|
8220
8260
|
lessonIndex: l.current.currentLessonIndex,
|
|
8221
8261
|
questionIndex: l.current.currentQuestionIndex,
|
|
8222
|
-
isCorrect:
|
|
8223
|
-
hasNextQuestion: l.current.currentQuestionIndex <
|
|
8262
|
+
isCorrect: M,
|
|
8263
|
+
hasNextQuestion: l.current.currentQuestionIndex < Q - 1,
|
|
8224
8264
|
score: l.current.score,
|
|
8225
8265
|
totalQuestions: l.current.totalQuestions,
|
|
8226
8266
|
avatarNotReady: !0
|
|
8227
8267
|
});
|
|
8228
8268
|
}
|
|
8229
|
-
}, [e.correct, e.incorrect,
|
|
8230
|
-
const A =
|
|
8269
|
+
}, [e.correct, e.incorrect, U, I, S]), ae = V((v) => {
|
|
8270
|
+
const A = U();
|
|
8231
8271
|
if (!v || typeof v != "object") {
|
|
8232
8272
|
console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
|
|
8233
8273
|
return;
|
|
@@ -8236,7 +8276,7 @@ const It = Be(({
|
|
|
8236
8276
|
console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
|
|
8237
8277
|
return;
|
|
8238
8278
|
}
|
|
8239
|
-
const
|
|
8279
|
+
const M = {
|
|
8240
8280
|
passed: v.passed === !0,
|
|
8241
8281
|
results: v.results || [],
|
|
8242
8282
|
output: v.output || "",
|
|
@@ -8251,13 +8291,13 @@ const It = Be(({
|
|
|
8251
8291
|
moduleIndex: l.current.currentModuleIndex,
|
|
8252
8292
|
lessonIndex: l.current.currentLessonIndex,
|
|
8253
8293
|
questionIndex: l.current.currentQuestionIndex,
|
|
8254
|
-
testResult:
|
|
8294
|
+
testResult: M,
|
|
8255
8295
|
question: A
|
|
8256
|
-
}), g.current && g.current(
|
|
8257
|
-
}, [
|
|
8296
|
+
}), g.current && g.current(M);
|
|
8297
|
+
}, [U, S]), ce = V(() => {
|
|
8258
8298
|
if (l.current.currentQuestionIndex > 0) {
|
|
8259
8299
|
l.current.currentQuestionIndex -= 1;
|
|
8260
|
-
const v =
|
|
8300
|
+
const v = U();
|
|
8261
8301
|
v && d.current.onCustomAction({
|
|
8262
8302
|
type: "questionStart",
|
|
8263
8303
|
moduleIndex: l.current.currentModuleIndex,
|
|
@@ -8270,26 +8310,26 @@ const It = Be(({
|
|
|
8270
8310
|
const A = () => {
|
|
8271
8311
|
if (!c.current || !v) return;
|
|
8272
8312
|
c.current.setMood("happy"), c.current.setBodyMovement("idle");
|
|
8273
|
-
const
|
|
8313
|
+
const M = F.current || { lipsyncLang: "en" };
|
|
8274
8314
|
v.type === "code_test" ? c.current.speakText(`Let's go back to this coding challenge: ${v.question}`, {
|
|
8275
|
-
lipsyncLang:
|
|
8315
|
+
lipsyncLang: M.lipsyncLang
|
|
8276
8316
|
}) : c.current.speakText(`Going back to: ${v.question}`, {
|
|
8277
|
-
lipsyncLang:
|
|
8317
|
+
lipsyncLang: M.lipsyncLang
|
|
8278
8318
|
});
|
|
8279
8319
|
};
|
|
8280
8320
|
if (c.current && c.current.isReady && v)
|
|
8281
8321
|
A();
|
|
8282
8322
|
else if (v) {
|
|
8283
|
-
const
|
|
8284
|
-
c.current && c.current.isReady && (clearInterval(
|
|
8323
|
+
const M = setInterval(() => {
|
|
8324
|
+
c.current && c.current.isReady && (clearInterval(M), A());
|
|
8285
8325
|
}, 100);
|
|
8286
8326
|
setTimeout(() => {
|
|
8287
|
-
clearInterval(
|
|
8327
|
+
clearInterval(M);
|
|
8288
8328
|
}, 5e3);
|
|
8289
8329
|
}
|
|
8290
8330
|
}
|
|
8291
|
-
}, [
|
|
8292
|
-
const v =
|
|
8331
|
+
}, [U]), be = V(() => {
|
|
8332
|
+
const v = N.current || { modules: [] };
|
|
8293
8333
|
if (v.modules[l.current.currentModuleIndex], l.current.currentLessonIndex > 0)
|
|
8294
8334
|
l.current.currentLessonIndex -= 1, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0, d.current.onCustomAction({
|
|
8295
8335
|
type: "lessonStart",
|
|
@@ -8301,8 +8341,8 @@ const It = Be(({
|
|
|
8301
8341
|
lesson: I()
|
|
8302
8342
|
}), c.current && (c.current.setMood("happy"), c.current.setBodyMovement("idle"));
|
|
8303
8343
|
else if (l.current.currentModuleIndex > 0) {
|
|
8304
|
-
const
|
|
8305
|
-
l.current.currentModuleIndex -= 1, l.current.currentLessonIndex = (
|
|
8344
|
+
const W = v.modules[l.current.currentModuleIndex - 1];
|
|
8345
|
+
l.current.currentModuleIndex -= 1, l.current.currentLessonIndex = (W?.lessons?.length || 1) - 1, l.current.currentQuestionIndex = 0, l.current.lessonCompleted = !1, l.current.isQuestionMode = !1, l.current.isTeaching = !1, l.current.score = 0, l.current.totalQuestions = 0, d.current.onCustomAction({
|
|
8306
8346
|
type: "lessonStart",
|
|
8307
8347
|
moduleIndex: l.current.currentModuleIndex,
|
|
8308
8348
|
lessonIndex: l.current.currentLessonIndex
|
|
@@ -8312,40 +8352,40 @@ const It = Be(({
|
|
|
8312
8352
|
lesson: I()
|
|
8313
8353
|
}), c.current && (c.current.setMood("happy"), c.current.setBodyMovement("idle"));
|
|
8314
8354
|
}
|
|
8315
|
-
}, [I]), se =
|
|
8355
|
+
}, [I]), se = V(() => {
|
|
8316
8356
|
l.current.currentModuleIndex = 0, l.current.currentLessonIndex = 0, l.current.currentQuestionIndex = 0, l.current.isTeaching = !1, l.current.isQuestionMode = !1, l.current.lessonCompleted = !1, l.current.curriculumCompleted = !1, l.current.score = 0, l.current.totalQuestions = 0;
|
|
8317
|
-
}, []),
|
|
8357
|
+
}, []), Se = V((v) => {
|
|
8318
8358
|
console.log("Avatar is ready!", v);
|
|
8319
|
-
const A = I(),
|
|
8320
|
-
u &&
|
|
8359
|
+
const A = I(), M = A?.avatar_script || A?.body;
|
|
8360
|
+
u && M && setTimeout(() => {
|
|
8321
8361
|
h.current && h.current();
|
|
8322
8362
|
}, 10);
|
|
8323
8363
|
}, [u, I]);
|
|
8324
|
-
|
|
8325
|
-
h.current =
|
|
8326
|
-
}),
|
|
8364
|
+
Je(() => {
|
|
8365
|
+
h.current = B, p.current = D, b.current = R, f.current = E, k.current = z, T.current = y, g.current = Y;
|
|
8366
|
+
}), Ue(a, () => ({
|
|
8327
8367
|
// Curriculum control methods
|
|
8328
|
-
startTeaching:
|
|
8368
|
+
startTeaching: B,
|
|
8329
8369
|
startQuestions: y,
|
|
8330
|
-
handleAnswerSelect:
|
|
8370
|
+
handleAnswerSelect: Y,
|
|
8331
8371
|
handleCodeTestResult: ae,
|
|
8332
|
-
nextQuestion:
|
|
8372
|
+
nextQuestion: E,
|
|
8333
8373
|
previousQuestion: ce,
|
|
8334
|
-
nextLesson:
|
|
8335
|
-
previousLesson:
|
|
8374
|
+
nextLesson: D,
|
|
8375
|
+
previousLesson: be,
|
|
8336
8376
|
completeLesson: R,
|
|
8337
8377
|
completeCurriculum: z,
|
|
8338
8378
|
resetCurriculum: se,
|
|
8339
8379
|
getState: () => ({ ...l.current }),
|
|
8340
|
-
getCurrentQuestion: () =>
|
|
8380
|
+
getCurrentQuestion: () => U(),
|
|
8341
8381
|
getCurrentLesson: () => I(),
|
|
8342
8382
|
// Direct access to avatar ref (always returns current value)
|
|
8343
8383
|
getAvatarRef: () => c.current,
|
|
8344
8384
|
// Convenience methods that delegate to avatar (always check current ref)
|
|
8345
8385
|
speakText: async (v, A = {}) => {
|
|
8346
8386
|
await c.current?.resumeAudioContext?.();
|
|
8347
|
-
const
|
|
8348
|
-
c.current?.speakText(v, { ...A, lipsyncLang: A.lipsyncLang ||
|
|
8387
|
+
const M = F.current || { lipsyncLang: "en" };
|
|
8388
|
+
c.current?.speakText(v, { ...A, lipsyncLang: A.lipsyncLang || M.lipsyncLang });
|
|
8349
8389
|
},
|
|
8350
8390
|
resumeAudioContext: async () => {
|
|
8351
8391
|
if (c.current?.resumeAudioContext)
|
|
@@ -8356,8 +8396,8 @@ const It = Be(({
|
|
|
8356
8396
|
if (A.state === "suspended" || A.state === "interrupted")
|
|
8357
8397
|
try {
|
|
8358
8398
|
await A.resume(), console.log("Audio context resumed via talkingHead");
|
|
8359
|
-
} catch (
|
|
8360
|
-
console.warn("Failed to resume audio context:",
|
|
8399
|
+
} catch (M) {
|
|
8400
|
+
console.warn("Failed to resume audio context:", M);
|
|
8361
8401
|
}
|
|
8362
8402
|
} else
|
|
8363
8403
|
console.warn("Audio context not available yet");
|
|
@@ -8389,8 +8429,8 @@ const It = Be(({
|
|
|
8389
8429
|
handleResize: () => c.current?.handleResize(),
|
|
8390
8430
|
// Avatar readiness check (always returns current value)
|
|
8391
8431
|
isAvatarReady: () => c.current?.isReady || !1
|
|
8392
|
-
}), [
|
|
8393
|
-
const
|
|
8432
|
+
}), [B, y, Y, ae, E, D, R, z, se, U, I]);
|
|
8433
|
+
const te = F.current || {
|
|
8394
8434
|
avatarUrl: "/avatars/brunette.glb",
|
|
8395
8435
|
avatarBody: "F",
|
|
8396
8436
|
mood: "happy",
|
|
@@ -8403,23 +8443,23 @@ const It = Be(({
|
|
|
8403
8443
|
showFullAvatar: !1,
|
|
8404
8444
|
animations: e
|
|
8405
8445
|
};
|
|
8406
|
-
return /* @__PURE__ */
|
|
8407
|
-
|
|
8446
|
+
return /* @__PURE__ */ ee("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ ee(
|
|
8447
|
+
_e,
|
|
8408
8448
|
{
|
|
8409
8449
|
ref: c,
|
|
8410
|
-
avatarUrl:
|
|
8411
|
-
avatarBody:
|
|
8412
|
-
mood:
|
|
8413
|
-
ttsLang:
|
|
8414
|
-
ttsService:
|
|
8415
|
-
ttsVoice:
|
|
8416
|
-
ttsApiKey:
|
|
8417
|
-
bodyMovement:
|
|
8418
|
-
movementIntensity:
|
|
8419
|
-
showFullAvatar:
|
|
8450
|
+
avatarUrl: te.avatarUrl,
|
|
8451
|
+
avatarBody: te.avatarBody,
|
|
8452
|
+
mood: te.mood,
|
|
8453
|
+
ttsLang: te.ttsLang,
|
|
8454
|
+
ttsService: te.ttsService,
|
|
8455
|
+
ttsVoice: te.ttsVoice,
|
|
8456
|
+
ttsApiKey: te.ttsApiKey,
|
|
8457
|
+
bodyMovement: te.bodyMovement,
|
|
8458
|
+
movementIntensity: te.movementIntensity,
|
|
8459
|
+
showFullAvatar: te.showFullAvatar,
|
|
8420
8460
|
cameraView: "upper",
|
|
8421
|
-
animations:
|
|
8422
|
-
onReady:
|
|
8461
|
+
animations: te.animations,
|
|
8462
|
+
onReady: Se,
|
|
8423
8463
|
onLoading: () => {
|
|
8424
8464
|
},
|
|
8425
8465
|
onError: (v) => {
|
|
@@ -8428,50 +8468,50 @@ const It = Be(({
|
|
|
8428
8468
|
}
|
|
8429
8469
|
) });
|
|
8430
8470
|
});
|
|
8431
|
-
|
|
8432
|
-
function
|
|
8433
|
-
manifestPath:
|
|
8471
|
+
St.displayName = "CurriculumLearning";
|
|
8472
|
+
function Pt({
|
|
8473
|
+
manifestPath: G = "/animations/manifest.json",
|
|
8434
8474
|
avatarBody: t = "F",
|
|
8435
8475
|
onAnimationPlay: e = null,
|
|
8436
8476
|
onAnimationsSelected: n = null,
|
|
8437
8477
|
onDeleteAnimations: i = null,
|
|
8438
8478
|
style: s = {}
|
|
8439
8479
|
}) {
|
|
8440
|
-
const [o, r] = le([]), [u, a] = le(/* @__PURE__ */ new Set()), [c, l] = le(!0), [d, h] = le(null), [p, b] = le("all"), [f,
|
|
8441
|
-
|
|
8480
|
+
const [o, r] = le([]), [u, a] = le(/* @__PURE__ */ new Set()), [c, l] = le(!0), [d, h] = le(null), [p, b] = le("all"), [f, k] = le("");
|
|
8481
|
+
ye(() => {
|
|
8442
8482
|
(async () => {
|
|
8443
8483
|
l(!0), h(null);
|
|
8444
8484
|
try {
|
|
8445
|
-
const z = await
|
|
8485
|
+
const z = await Me(G), y = [];
|
|
8446
8486
|
if (z._genderSpecific) {
|
|
8447
|
-
const
|
|
8448
|
-
z._genderSpecific[
|
|
8449
|
-
(Array.isArray(
|
|
8487
|
+
const D = (t?.toUpperCase() || "F") === "M" ? "male" : "female";
|
|
8488
|
+
z._genderSpecific[D] && Object.entries(z._genderSpecific[D]).forEach(([B, Y]) => {
|
|
8489
|
+
(Array.isArray(Y) ? Y : [Y]).forEach((ce) => {
|
|
8450
8490
|
y.push({
|
|
8451
8491
|
path: ce,
|
|
8452
|
-
group:
|
|
8453
|
-
gender:
|
|
8492
|
+
group: B,
|
|
8493
|
+
gender: D,
|
|
8454
8494
|
name: ce.split("/").pop().replace(".fbx", "")
|
|
8455
8495
|
});
|
|
8456
8496
|
});
|
|
8457
|
-
}), z._genderSpecific.shared && Object.entries(z._genderSpecific.shared).forEach(([
|
|
8458
|
-
(Array.isArray(
|
|
8497
|
+
}), z._genderSpecific.shared && Object.entries(z._genderSpecific.shared).forEach(([B, Y]) => {
|
|
8498
|
+
(Array.isArray(Y) ? Y : [Y]).forEach((ce) => {
|
|
8459
8499
|
y.push({
|
|
8460
8500
|
path: ce,
|
|
8461
|
-
group:
|
|
8501
|
+
group: B,
|
|
8462
8502
|
gender: "shared",
|
|
8463
8503
|
name: ce.split("/").pop().replace(".fbx", "")
|
|
8464
8504
|
});
|
|
8465
8505
|
});
|
|
8466
8506
|
});
|
|
8467
8507
|
}
|
|
8468
|
-
Object.entries(z).forEach(([
|
|
8469
|
-
|
|
8470
|
-
typeof
|
|
8471
|
-
path:
|
|
8472
|
-
group:
|
|
8508
|
+
Object.entries(z).forEach(([E, D]) => {
|
|
8509
|
+
E !== "_genderSpecific" && (Array.isArray(D) ? D : [D]).forEach((Y) => {
|
|
8510
|
+
typeof Y == "string" && y.push({
|
|
8511
|
+
path: Y,
|
|
8512
|
+
group: E,
|
|
8473
8513
|
gender: "root",
|
|
8474
|
-
name:
|
|
8514
|
+
name: Y.split("/").pop().replace(".fbx", "")
|
|
8475
8515
|
});
|
|
8476
8516
|
});
|
|
8477
8517
|
}), r(y), l(!1);
|
|
@@ -8479,14 +8519,14 @@ function Ft({
|
|
|
8479
8519
|
console.error("Failed to load animations:", z), h(z.message), l(!1);
|
|
8480
8520
|
}
|
|
8481
8521
|
})();
|
|
8482
|
-
}, [
|
|
8483
|
-
const
|
|
8522
|
+
}, [G, t]);
|
|
8523
|
+
const T = ["all", ...new Set(o.map((R) => R.group))], g = o.filter((R) => {
|
|
8484
8524
|
const z = p === "all" || R.group === p, y = f === "" || R.name.toLowerCase().includes(f.toLowerCase()) || R.path.toLowerCase().includes(f.toLowerCase());
|
|
8485
8525
|
return z && y;
|
|
8486
|
-
}),
|
|
8526
|
+
}), N = (R) => {
|
|
8487
8527
|
const z = new Set(u);
|
|
8488
8528
|
z.has(R) ? z.delete(R) : z.add(R), a(z), n && n(Array.from(z));
|
|
8489
|
-
},
|
|
8529
|
+
}, F = () => {
|
|
8490
8530
|
const R = new Set(u);
|
|
8491
8531
|
g.forEach((z) => {
|
|
8492
8532
|
R.add(z.path);
|
|
@@ -8496,7 +8536,7 @@ function Ft({
|
|
|
8496
8536
|
g.forEach((z) => {
|
|
8497
8537
|
R.delete(z.path);
|
|
8498
8538
|
}), a(R), n && n(Array.from(R));
|
|
8499
|
-
},
|
|
8539
|
+
}, U = () => {
|
|
8500
8540
|
const z = o.filter((y) => !u.has(y.path)).map((y) => y.path);
|
|
8501
8541
|
if (z.length === 0) {
|
|
8502
8542
|
alert("No animations to delete. Select animations to keep, then delete will remove the unselected ones.");
|
|
@@ -8508,35 +8548,35 @@ This will delete:
|
|
|
8508
8548
|
${z.slice(0, 5).join(`
|
|
8509
8549
|
`)}${z.length > 5 ? `
|
|
8510
8550
|
...` : ""}`) && (i && i(z), r(o.filter((y) => u.has(y.path))), a(/* @__PURE__ */ new Set()));
|
|
8511
|
-
},
|
|
8551
|
+
}, S = (R) => {
|
|
8512
8552
|
e && e(R);
|
|
8513
8553
|
};
|
|
8514
|
-
return c ? /* @__PURE__ */
|
|
8554
|
+
return c ? /* @__PURE__ */ ee("div", { style: { padding: "20px", textAlign: "center", ...s }, children: /* @__PURE__ */ ee("p", { children: "Loading animations..." }) }) : d ? /* @__PURE__ */ ee("div", { style: { padding: "20px", color: "red", ...s }, children: /* @__PURE__ */ Re("p", { children: [
|
|
8515
8555
|
"Error loading animations: ",
|
|
8516
8556
|
d
|
|
8517
|
-
] }) }) : /* @__PURE__ */
|
|
8557
|
+
] }) }) : /* @__PURE__ */ Re("div", { style: {
|
|
8518
8558
|
padding: "20px",
|
|
8519
8559
|
backgroundColor: "#2a2a2a",
|
|
8520
8560
|
borderRadius: "8px",
|
|
8521
8561
|
color: "#fff",
|
|
8522
8562
|
...s
|
|
8523
8563
|
}, children: [
|
|
8524
|
-
/* @__PURE__ */
|
|
8525
|
-
/* @__PURE__ */
|
|
8526
|
-
/* @__PURE__ */
|
|
8564
|
+
/* @__PURE__ */ ee("h2", { style: { marginTop: 0 }, children: "Animation Selector" }),
|
|
8565
|
+
/* @__PURE__ */ ee("p", { style: { color: "#aaa", fontSize: "14px" }, children: "Click buttons to play animations. Select animations to keep, then delete will remove the rest." }),
|
|
8566
|
+
/* @__PURE__ */ Re("div", { style: {
|
|
8527
8567
|
display: "flex",
|
|
8528
8568
|
gap: "10px",
|
|
8529
8569
|
marginBottom: "20px",
|
|
8530
8570
|
flexWrap: "wrap",
|
|
8531
8571
|
alignItems: "center"
|
|
8532
8572
|
}, children: [
|
|
8533
|
-
/* @__PURE__ */
|
|
8573
|
+
/* @__PURE__ */ ee(
|
|
8534
8574
|
"input",
|
|
8535
8575
|
{
|
|
8536
8576
|
type: "text",
|
|
8537
8577
|
placeholder: "Search animations...",
|
|
8538
8578
|
value: f,
|
|
8539
|
-
onChange: (R) =>
|
|
8579
|
+
onChange: (R) => k(R.target.value),
|
|
8540
8580
|
style: {
|
|
8541
8581
|
padding: "8px 12px",
|
|
8542
8582
|
borderRadius: "6px",
|
|
@@ -8549,7 +8589,7 @@ ${z.slice(0, 5).join(`
|
|
|
8549
8589
|
}
|
|
8550
8590
|
}
|
|
8551
8591
|
),
|
|
8552
|
-
/* @__PURE__ */
|
|
8592
|
+
/* @__PURE__ */ ee(
|
|
8553
8593
|
"select",
|
|
8554
8594
|
{
|
|
8555
8595
|
value: p,
|
|
@@ -8562,13 +8602,13 @@ ${z.slice(0, 5).join(`
|
|
|
8562
8602
|
color: "#fff",
|
|
8563
8603
|
fontSize: "14px"
|
|
8564
8604
|
},
|
|
8565
|
-
children:
|
|
8605
|
+
children: T.map((R) => /* @__PURE__ */ ee("option", { value: R, children: R === "all" ? "All Groups" : R }, R))
|
|
8566
8606
|
}
|
|
8567
8607
|
),
|
|
8568
|
-
/* @__PURE__ */
|
|
8608
|
+
/* @__PURE__ */ ee(
|
|
8569
8609
|
"button",
|
|
8570
8610
|
{
|
|
8571
|
-
onClick:
|
|
8611
|
+
onClick: F,
|
|
8572
8612
|
style: {
|
|
8573
8613
|
padding: "8px 16px",
|
|
8574
8614
|
backgroundColor: "#4CAF50",
|
|
@@ -8581,7 +8621,7 @@ ${z.slice(0, 5).join(`
|
|
|
8581
8621
|
children: "Select All Visible"
|
|
8582
8622
|
}
|
|
8583
8623
|
),
|
|
8584
|
-
/* @__PURE__ */
|
|
8624
|
+
/* @__PURE__ */ ee(
|
|
8585
8625
|
"button",
|
|
8586
8626
|
{
|
|
8587
8627
|
onClick: I,
|
|
@@ -8597,10 +8637,10 @@ ${z.slice(0, 5).join(`
|
|
|
8597
8637
|
children: "Deselect All Visible"
|
|
8598
8638
|
}
|
|
8599
8639
|
),
|
|
8600
|
-
/* @__PURE__ */
|
|
8640
|
+
/* @__PURE__ */ Re(
|
|
8601
8641
|
"button",
|
|
8602
8642
|
{
|
|
8603
|
-
onClick:
|
|
8643
|
+
onClick: U,
|
|
8604
8644
|
style: {
|
|
8605
8645
|
padding: "8px 16px",
|
|
8606
8646
|
backgroundColor: "#f44336",
|
|
@@ -8619,7 +8659,7 @@ ${z.slice(0, 5).join(`
|
|
|
8619
8659
|
}
|
|
8620
8660
|
)
|
|
8621
8661
|
] }),
|
|
8622
|
-
/* @__PURE__ */
|
|
8662
|
+
/* @__PURE__ */ Re("div", { style: {
|
|
8623
8663
|
marginBottom: "15px",
|
|
8624
8664
|
fontSize: "14px",
|
|
8625
8665
|
color: "#aaa"
|
|
@@ -8631,7 +8671,7 @@ ${z.slice(0, 5).join(`
|
|
|
8631
8671
|
" | Showing: ",
|
|
8632
8672
|
g.length
|
|
8633
8673
|
] }),
|
|
8634
|
-
/* @__PURE__ */
|
|
8674
|
+
/* @__PURE__ */ ee("div", { style: {
|
|
8635
8675
|
display: "grid",
|
|
8636
8676
|
gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
|
|
8637
8677
|
gap: "10px",
|
|
@@ -8642,7 +8682,7 @@ ${z.slice(0, 5).join(`
|
|
|
8642
8682
|
borderRadius: "6px"
|
|
8643
8683
|
}, children: g.map((R, z) => {
|
|
8644
8684
|
const y = u.has(R.path);
|
|
8645
|
-
return /* @__PURE__ */
|
|
8685
|
+
return /* @__PURE__ */ Re(
|
|
8646
8686
|
"div",
|
|
8647
8687
|
{
|
|
8648
8688
|
style: {
|
|
@@ -8653,39 +8693,39 @@ ${z.slice(0, 5).join(`
|
|
|
8653
8693
|
cursor: "pointer",
|
|
8654
8694
|
transition: "all 0.2s"
|
|
8655
8695
|
},
|
|
8656
|
-
onClick: () =>
|
|
8696
|
+
onClick: () => N(R.path),
|
|
8657
8697
|
children: [
|
|
8658
|
-
/* @__PURE__ */
|
|
8659
|
-
/* @__PURE__ */
|
|
8698
|
+
/* @__PURE__ */ Re("div", { style: { marginBottom: "8px" }, children: [
|
|
8699
|
+
/* @__PURE__ */ ee(
|
|
8660
8700
|
"input",
|
|
8661
8701
|
{
|
|
8662
8702
|
type: "checkbox",
|
|
8663
8703
|
checked: y,
|
|
8664
|
-
onChange: () =>
|
|
8665
|
-
onClick: (
|
|
8704
|
+
onChange: () => N(R.path),
|
|
8705
|
+
onClick: (E) => E.stopPropagation(),
|
|
8666
8706
|
style: {
|
|
8667
8707
|
marginRight: "8px",
|
|
8668
8708
|
cursor: "pointer"
|
|
8669
8709
|
}
|
|
8670
8710
|
}
|
|
8671
8711
|
),
|
|
8672
|
-
/* @__PURE__ */
|
|
8712
|
+
/* @__PURE__ */ Re("span", { style: { fontSize: "12px", color: "#aaa" }, children: [
|
|
8673
8713
|
R.group,
|
|
8674
8714
|
" ",
|
|
8675
8715
|
R.gender !== "root" && `(${R.gender})`
|
|
8676
8716
|
] })
|
|
8677
8717
|
] }),
|
|
8678
|
-
/* @__PURE__ */
|
|
8718
|
+
/* @__PURE__ */ ee("div", { style: {
|
|
8679
8719
|
fontSize: "13px",
|
|
8680
8720
|
fontWeight: "bold",
|
|
8681
8721
|
marginBottom: "8px",
|
|
8682
8722
|
wordBreak: "break-word"
|
|
8683
8723
|
}, children: R.name }),
|
|
8684
|
-
/* @__PURE__ */
|
|
8724
|
+
/* @__PURE__ */ ee(
|
|
8685
8725
|
"button",
|
|
8686
8726
|
{
|
|
8687
|
-
onClick: (
|
|
8688
|
-
|
|
8727
|
+
onClick: (E) => {
|
|
8728
|
+
E.stopPropagation(), S(R.path);
|
|
8689
8729
|
},
|
|
8690
8730
|
style: {
|
|
8691
8731
|
width: "100%",
|
|
@@ -8705,14 +8745,14 @@ ${z.slice(0, 5).join(`
|
|
|
8705
8745
|
`${R.path}-${z}`
|
|
8706
8746
|
);
|
|
8707
8747
|
}) }),
|
|
8708
|
-
g.length === 0 && /* @__PURE__ */
|
|
8748
|
+
g.length === 0 && /* @__PURE__ */ ee("div", { style: {
|
|
8709
8749
|
padding: "40px",
|
|
8710
8750
|
textAlign: "center",
|
|
8711
8751
|
color: "#aaa"
|
|
8712
8752
|
}, children: "No animations found matching your filters." })
|
|
8713
8753
|
] });
|
|
8714
8754
|
}
|
|
8715
|
-
const
|
|
8755
|
+
const Ke = {
|
|
8716
8756
|
// Code-based dance animations (no FBX required)
|
|
8717
8757
|
dance: {
|
|
8718
8758
|
name: "dance",
|
|
@@ -8815,16 +8855,16 @@ const qe = {
|
|
|
8815
8855
|
duration: 5e3,
|
|
8816
8856
|
description: "Excited, energetic movement"
|
|
8817
8857
|
}
|
|
8818
|
-
},
|
|
8858
|
+
}, Bt = (G) => Ke[G] || null, Ot = (G) => Ke.hasOwnProperty(G);
|
|
8819
8859
|
export {
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8860
|
+
Pt as AnimationSelector,
|
|
8861
|
+
St as CurriculumLearning,
|
|
8862
|
+
Lt as SimpleTalkingAvatar,
|
|
8863
|
+
_e as TalkingHeadAvatar,
|
|
8864
|
+
At as TalkingHeadComponent,
|
|
8865
|
+
Ke as animations,
|
|
8866
|
+
We as getActiveTTSConfig,
|
|
8867
|
+
Bt as getAnimation,
|
|
8868
|
+
Et as getVoiceOptions,
|
|
8869
|
+
Ot as hasAnimation
|
|
8830
8870
|
};
|