@sage-rsc/talking-head-react 1.0.52 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.js +675 -616
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +136 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as ke, jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as ke, jsx as ne } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as fe, useRef as V, useState as re, useEffect as le, useCallback as M, useImperativeHandle as xe, useLayoutEffect as Ee } from "react";
|
|
3
3
|
import * as f from "three";
|
|
4
4
|
import { OrbitControls as Fe } from "three/addons/controls/OrbitControls.js";
|
|
5
5
|
import { GLTFLoader as Pe } from "three/addons/loaders/GLTFLoader.js";
|
|
@@ -7,14 +7,14 @@ import { DRACOLoader as Be } from "three/addons/loaders/DRACOLoader.js";
|
|
|
7
7
|
import { FBXLoader as ve } from "three/addons/loaders/FBXLoader.js";
|
|
8
8
|
import { RoomEnvironment as De } from "three/addons/environments/RoomEnvironment.js";
|
|
9
9
|
import Oe from "three/addons/libs/stats.module.js";
|
|
10
|
-
let m,
|
|
11
|
-
const A = [0, 0, 0, 0],
|
|
10
|
+
let m, j, q;
|
|
11
|
+
const A = [0, 0, 0, 0], w = new f.Vector3(), de = new f.Vector3(), G = new f.Vector3(), ce = new f.Vector3();
|
|
12
12
|
new f.Plane();
|
|
13
13
|
new f.Ray();
|
|
14
14
|
new f.Euler();
|
|
15
|
-
const
|
|
15
|
+
const Z = new f.Quaternion(), Ie = new f.Quaternion(), J = new f.Matrix4(), $ = new f.Matrix4();
|
|
16
16
|
new f.Vector3();
|
|
17
|
-
const
|
|
17
|
+
const me = new f.Vector3(0, 0, 1), Ne = new f.Vector3(1, 0, 0), Ue = new f.Vector3(0, 1, 0), We = new f.Vector3(0, 0, 1);
|
|
18
18
|
class Ve {
|
|
19
19
|
constructor(t = null) {
|
|
20
20
|
this.opt = Object.assign({
|
|
@@ -321,7 +321,7 @@ class Ve {
|
|
|
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(w).clone(),
|
|
325
325
|
// World position, parent
|
|
326
326
|
qBasis: a.parent.quaternion.clone(),
|
|
327
327
|
// Original quaternion, parent
|
|
@@ -338,7 +338,7 @@ class Ve {
|
|
|
338
338
|
ea: [0, 0, 0, 0]
|
|
339
339
|
// External acceleration [m/s^2]
|
|
340
340
|
};
|
|
341
|
-
h.boneParent.matrixWorld.decompose(
|
|
341
|
+
h.boneParent.matrixWorld.decompose(w, Z, G), w.copy(me).applyQuaternion(Z).setY(0).normalize(), Z.premultiply(Ie.setFromUnitVectors(me, w).invert()).normalize(), h.qWorldInverseYaw = Z.clone().normalize(), this.data.push(h), this.dict[u] = h;
|
|
342
342
|
try {
|
|
343
343
|
this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
|
|
344
344
|
} catch (l) {
|
|
@@ -356,22 +356,22 @@ class Ve {
|
|
|
356
356
|
for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, n = this.objectsUpdate.length; e < n; 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, n = this.data.length; e < n; e++) {
|
|
359
|
-
if (o = this.data[e],
|
|
359
|
+
if (o = this.data[e], w.copy(o.vWorld), J.copy(o.boneParent.matrixWorld), $.copy(J).invert(), o.vWorld.setFromMatrixPosition(J), w.applyMatrix4($), w.length() > 0.5 && (console.info("Info: Unrealistic jump of " + w.length().toFixed(2) + " meters."), w.setLength(0.5)), w.applyQuaternion(o.bone.quaternion), A[0] = w.x, A[1] = w.y, A[2] = -w.z, A[3] = w.length() / 3, o.children)
|
|
360
360
|
for (i = 0, s = o.children.length; i < s; i++)
|
|
361
361
|
m = o.children[i], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
|
|
362
|
-
if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw,
|
|
362
|
+
if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, w.set(
|
|
363
363
|
o.vBasis.x + A[0],
|
|
364
364
|
o.vBasis.y + A[1],
|
|
365
365
|
o.vBasis.z + A[2]
|
|
366
|
-
),
|
|
366
|
+
), w.applyMatrix4(J), w.x += m[0], w.y += m[1], w.z += m[2], w.applyMatrix4($), A[0] += w.x - o.vBasis.x, A[1] += w.y - o.vBasis.y, A[2] += w.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
|
|
367
367
|
o.bone.position.set(
|
|
368
368
|
o.vBasis.x + A[0],
|
|
369
369
|
o.vBasis.y + A[1],
|
|
370
370
|
o.vBasis.z - A[2]
|
|
371
371
|
);
|
|
372
|
-
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(
|
|
372
|
+
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(w, Z, G), w.copy(me).applyQuaternion(Z).setY(0).normalize(), Z.premultiply(Ie.setFromUnitVectors(me, w).invert()).normalize(), o.boneParent.quaternion.multiply(Z.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), Z.setFromAxisAngle(We, -m), o.boneParent.quaternion.multiply(Z)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), Z.setFromAxisAngle(Ne, -m), o.boneParent.quaternion.multiply(Z)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), Z.setFromAxisAngle(Ue, -m), o.boneParent.quaternion.multiply(Z)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
|
|
373
373
|
for (i = 0, s = o.excludes.length; i < s; i++)
|
|
374
|
-
m = o.excludes[i],
|
|
374
|
+
m = o.excludes[i], G.set(0, 0, 0), m.deltaLocal && (G.x += m.deltaLocal[0], G.y += m.deltaLocal[1], G.z += m.deltaLocal[2]), G.applyMatrix4(m.bone.matrixWorld), $.copy(o.boneParent.matrixWorld).invert(), G.applyMatrix4($), w.copy(o.bone.position), !(w.distanceToSquared(G) >= m.radiusSq) && (q = w.length(), j = G.length(), !(j > m.radius + q) && (j < Math.abs(m.radius - q) || (j = (j * j + q * q - m.radiusSq) / (2 * j), G.normalize(), ce.copy(G).multiplyScalar(j), j = Math.sqrt(q * q - j * j), w.subVectors(w, ce).projectOnPlane(G).normalize().multiplyScalar(j), de.subVectors(o.vBasis, ce).projectOnPlane(G).normalize(), q = de.dot(w), q < 0 && (q = Math.sqrt(j * j - q * q), de.multiplyScalar(q), w.add(de)), w.add(ce).normalize(), G.copy(o.bone.position).normalize(), Z.setFromUnitVectors(G, w), o.boneParent.quaternion.premultiply(Z), o.boneParent.updateWorldMatrix(!1, !0))));
|
|
375
375
|
}
|
|
376
376
|
this.helpers.isActive && this.updateHelpers();
|
|
377
377
|
}
|
|
@@ -442,17 +442,17 @@ class Ve {
|
|
|
442
442
|
*/
|
|
443
443
|
updateHelpers() {
|
|
444
444
|
if (m = this.helpers.points, m.bones.length) {
|
|
445
|
-
|
|
445
|
+
$.copy(this.armature.matrixWorld).invert();
|
|
446
446
|
const t = m.object.geometry.getAttribute("position");
|
|
447
447
|
for (let e = 0, i = m.bones.length; e < i; e++)
|
|
448
|
-
|
|
448
|
+
J.multiplyMatrices($, m.bones[e].matrixWorld), w.setFromMatrixPosition(J), t.setXYZ(e, w.x, w.y, w.z);
|
|
449
449
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
450
450
|
}
|
|
451
451
|
if (m = this.helpers.lines, m.bones.length) {
|
|
452
|
-
|
|
452
|
+
$.copy(this.armature.matrixWorld).invert();
|
|
453
453
|
const t = m.object.geometry.getAttribute("position");
|
|
454
454
|
for (let e = 0, i = 0, n = m.bones.length; e < n; e++, i += 2)
|
|
455
|
-
|
|
455
|
+
J.multiplyMatrices($, m.bones[e].matrixWorld), w.setFromMatrixPosition(J), t.setXYZ(i, w.x, w.y, w.z), J.multiplyMatrices($, m.bones[e].parent.matrixWorld), w.setFromMatrixPosition(J), t.setXYZ(i + 1, w.x, w.y, w.z);
|
|
456
456
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
457
457
|
}
|
|
458
458
|
}
|
|
@@ -521,10 +521,10 @@ class Ge {
|
|
|
521
521
|
for (let r = 0; r < o; r++) {
|
|
522
522
|
const u = r * s, a = Math.min(u + n, t.length), h = t.slice(u, a), l = this.calculateEnergy(h);
|
|
523
523
|
i.energy.push(l);
|
|
524
|
-
const
|
|
525
|
-
i.spectralCentroid.push(
|
|
526
|
-
const
|
|
527
|
-
i.zeroCrossingRate.push(
|
|
524
|
+
const d = this.calculateSpectralCentroid(h);
|
|
525
|
+
i.spectralCentroid.push(d);
|
|
526
|
+
const c = this.calculateZeroCrossingRate(h);
|
|
527
|
+
i.zeroCrossingRate.push(c);
|
|
528
528
|
const g = this.calculateMFCC(h);
|
|
529
529
|
i.mfcc.push(g);
|
|
530
530
|
}
|
|
@@ -606,10 +606,10 @@ class Ge {
|
|
|
606
606
|
for (let u = 0; u < e; u += n) {
|
|
607
607
|
let a = 1, h = 0;
|
|
608
608
|
for (let l = 0; l < n / 2; l++) {
|
|
609
|
-
const
|
|
610
|
-
i[(u + l) * 2] =
|
|
611
|
-
const x = a * o - h * r,
|
|
612
|
-
a = x, h =
|
|
609
|
+
const d = i[(u + l) * 2], c = i[(u + l) * 2 + 1], g = i[(u + l + n / 2) * 2] * a - i[(u + l + n / 2) * 2 + 1] * h, y = i[(u + l + n / 2) * 2] * h + i[(u + l + n / 2) * 2 + 1] * a;
|
|
610
|
+
i[(u + l) * 2] = d + g, i[(u + l) * 2 + 1] = c + y, i[(u + l + n / 2) * 2] = d - g, i[(u + l + n / 2) * 2 + 1] = c - y;
|
|
611
|
+
const x = a * o - h * r, L = a * r + h * o;
|
|
612
|
+
a = x, h = L;
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
}
|
|
@@ -703,15 +703,15 @@ class Ge {
|
|
|
703
703
|
const o = this.textToVisemes(e);
|
|
704
704
|
let r = 0, u = 0;
|
|
705
705
|
for (let a = 0; a < s.length && r < o.length; a++) {
|
|
706
|
-
const h = s[a], l = o[r],
|
|
706
|
+
const h = s[a], l = o[r], d = t.energy[Math.floor(h / 0.023)] || 0, c = this.calculateVisemeDuration(l, d);
|
|
707
707
|
n.push({
|
|
708
708
|
viseme: l,
|
|
709
709
|
startTime: u,
|
|
710
|
-
endTime: u +
|
|
711
|
-
duration:
|
|
712
|
-
intensity: Math.min(1,
|
|
710
|
+
endTime: u + c,
|
|
711
|
+
duration: c,
|
|
712
|
+
intensity: Math.min(1, d * 2)
|
|
713
713
|
// Map energy to viseme intensity
|
|
714
|
-
}), u +=
|
|
714
|
+
}), u += c, r++;
|
|
715
715
|
}
|
|
716
716
|
for (; r < o.length; ) {
|
|
717
717
|
const a = o[r], h = this.calculateVisemeDuration(a, 0.5);
|
|
@@ -1207,10 +1207,10 @@ class Ze {
|
|
|
1207
1207
|
Object.keys(this.rules).forEach((e) => {
|
|
1208
1208
|
this.rules[e] = this.rules[e].map((i) => {
|
|
1209
1209
|
const n = i.indexOf("["), s = i.indexOf("]"), o = i.indexOf("="), r = i.substring(0, n), u = i.substring(n + 1, s), a = i.substring(s + 1, o), h = i.substring(o + 1), l = { regex: "", move: 0, visemes: [] };
|
|
1210
|
-
let
|
|
1211
|
-
|
|
1212
|
-
const
|
|
1213
|
-
return
|
|
1210
|
+
let d = "";
|
|
1211
|
+
d += [...r].map((g) => t[g] || g).join("");
|
|
1212
|
+
const c = [...u];
|
|
1213
|
+
return c[0] = c[0].toLowerCase(), d += c.join(""), l.move = c.length, d += [...a].map((g) => t[g] || g).join(""), l.regex = new RegExp(d), h.length && h.split(" ").forEach((g) => {
|
|
1214
1214
|
l.visemes.push(g);
|
|
1215
1215
|
}), l;
|
|
1216
1216
|
});
|
|
@@ -1380,11 +1380,11 @@ class Ze {
|
|
|
1380
1380
|
if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(u.regex)) {
|
|
1381
1381
|
u.visemes.forEach((l) => {
|
|
1382
1382
|
if (e.visemes.length && e.visemes[e.visemes.length - 1] === l) {
|
|
1383
|
-
const
|
|
1384
|
-
e.durations[e.durations.length - 1] +=
|
|
1383
|
+
const d = 0.7 * (this.visemeDurations[l] || 1);
|
|
1384
|
+
e.durations[e.durations.length - 1] += d, i += d;
|
|
1385
1385
|
} else {
|
|
1386
|
-
const
|
|
1387
|
-
e.visemes.push(l), e.times.push(i), e.durations.push(
|
|
1386
|
+
const d = this.visemeDurations[l] || 1;
|
|
1387
|
+
e.visemes.push(l), e.times.push(i), e.durations.push(d), i += d;
|
|
1388
1388
|
}
|
|
1389
1389
|
}), e.i += u.move;
|
|
1390
1390
|
break;
|
|
@@ -1617,10 +1617,10 @@ class Ye {
|
|
|
1617
1617
|
Object.keys(this.rules).forEach((e) => {
|
|
1618
1618
|
this.rules[e] = this.rules[e].map((i) => {
|
|
1619
1619
|
const n = i.indexOf("["), s = i.indexOf("]"), o = i.indexOf("="), r = i.substring(0, n), u = i.substring(n + 1, s), a = i.substring(s + 1, o), h = i.substring(o + 1), l = { regex: "", move: 0, visemes: [] };
|
|
1620
|
-
let
|
|
1621
|
-
|
|
1622
|
-
const
|
|
1623
|
-
return
|
|
1620
|
+
let d = "";
|
|
1621
|
+
d += [...r].map((g) => t[g] || g).join("");
|
|
1622
|
+
const c = [...u];
|
|
1623
|
+
return c[0] = c[0].toLowerCase(), d += c.join(""), l.move = c.length, d += [...a].map((g) => t[g] || g).join(""), l.regex = new RegExp(d), h.length && h.split(" ").forEach((g) => {
|
|
1624
1624
|
l.visemes.push(g);
|
|
1625
1625
|
}), l;
|
|
1626
1626
|
});
|
|
@@ -1735,13 +1735,13 @@ class Ye {
|
|
|
1735
1735
|
for (let u = 0; u < o.length; u++) {
|
|
1736
1736
|
const a = o[u];
|
|
1737
1737
|
if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(a.regex)) {
|
|
1738
|
-
a.visemes.forEach((
|
|
1739
|
-
if (e.visemes.length && e.visemes[e.visemes.length - 1] ===
|
|
1740
|
-
const
|
|
1741
|
-
e.durations[e.durations.length - 1] +=
|
|
1738
|
+
a.visemes.forEach((d) => {
|
|
1739
|
+
if (e.visemes.length && e.visemes[e.visemes.length - 1] === d) {
|
|
1740
|
+
const c = 0.7 * (this.visemeDurations[d] || 1);
|
|
1741
|
+
e.durations[e.durations.length - 1] += c, i += c;
|
|
1742
1742
|
} else {
|
|
1743
|
-
const
|
|
1744
|
-
e.visemes.push(
|
|
1743
|
+
const c = this.visemeDurations[d] || 1;
|
|
1744
|
+
e.visemes.push(d), e.times.push(i), e.durations.push(c), i += c;
|
|
1745
1745
|
}
|
|
1746
1746
|
}), e.i += a.move, r = !0;
|
|
1747
1747
|
break;
|
|
@@ -2132,10 +2132,10 @@ class Qe {
|
|
|
2132
2132
|
Object.keys(this.rules).forEach((e) => {
|
|
2133
2133
|
this.rules[e] = this.rules[e].map((i) => {
|
|
2134
2134
|
const n = i.indexOf("["), s = i.indexOf("]"), o = i.indexOf("="), r = i.substring(0, n), u = i.substring(n + 1, s), a = i.substring(s + 1, o), h = i.substring(o + 1), l = { regex: "", move: 0, visemes: [] };
|
|
2135
|
-
let
|
|
2136
|
-
|
|
2137
|
-
const
|
|
2138
|
-
return
|
|
2135
|
+
let d = "";
|
|
2136
|
+
d += [...r].map((g) => t[g] || g).join("");
|
|
2137
|
+
const c = [...u];
|
|
2138
|
+
return c[0] = c[0].toLowerCase(), d += c.join(""), l.move = c.length, d += [...a].map((g) => t[g] || g).join(""), l.regex = new RegExp(d, "i"), h.length && h.split(" ").forEach((g) => {
|
|
2139
2139
|
g && l.visemes.push(g);
|
|
2140
2140
|
}), l;
|
|
2141
2141
|
});
|
|
@@ -2270,13 +2270,13 @@ class Qe {
|
|
|
2270
2270
|
for (let u = 0; u < o.length; u++) {
|
|
2271
2271
|
const a = o[u];
|
|
2272
2272
|
if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(a.regex)) {
|
|
2273
|
-
a.visemes.forEach((
|
|
2274
|
-
if (e.visemes.length && e.visemes[e.visemes.length - 1] ===
|
|
2275
|
-
const
|
|
2276
|
-
e.durations[e.durations.length - 1] +=
|
|
2273
|
+
a.visemes.forEach((d) => {
|
|
2274
|
+
if (e.visemes.length && e.visemes[e.visemes.length - 1] === d) {
|
|
2275
|
+
const c = 0.7 * (this.visemeDurations[d] || 1);
|
|
2276
|
+
e.durations[e.durations.length - 1] += c, i += c;
|
|
2277
2277
|
} else {
|
|
2278
|
-
const
|
|
2279
|
-
e.visemes.push(
|
|
2278
|
+
const c = this.visemeDurations[d] || 1;
|
|
2279
|
+
e.visemes.push(d), e.times.push(i), e.durations.push(c), i += c;
|
|
2280
2280
|
}
|
|
2281
2281
|
}), e.i += a.move, r = !0;
|
|
2282
2282
|
break;
|
|
@@ -2623,13 +2623,13 @@ class Je {
|
|
|
2623
2623
|
const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2624
2624
|
__proto__: null,
|
|
2625
2625
|
LipsyncLt: Je
|
|
2626
|
-
}, Symbol.toStringTag, { value: "Module" })), et = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2Ft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c3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICA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NzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Ae = {
|
|
2626
|
+
}, Symbol.toStringTag, { value: "Module" })), et = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICA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gLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICA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2630
2630
|
fi: Ke,
|
|
2631
2631
|
lt: $e
|
|
2632
|
-
}, U = new f.Quaternion(),
|
|
2632
|
+
}, U = new f.Quaternion(), E = new f.Euler(), ee = new f.Vector3(), ie = new f.Vector3(), Ae = new f.Box3();
|
|
2633
2633
|
new f.Matrix4();
|
|
2634
2634
|
new f.Matrix4();
|
|
2635
2635
|
new f.Vector3();
|
|
@@ -4201,16 +4201,16 @@ class we {
|
|
|
4201
4201
|
let r = null, u = null;
|
|
4202
4202
|
for (const [a, h] of Object.entries(i))
|
|
4203
4203
|
if (s.morphTargetDictionary.hasOwnProperty(a)) {
|
|
4204
|
-
const l = s.morphTargetDictionary[a],
|
|
4205
|
-
r || (r = new f.Float32BufferAttribute(
|
|
4206
|
-
for (let g = 0; g <
|
|
4207
|
-
const y = r.getX(g) +
|
|
4208
|
-
r.setXYZ(g, y, x,
|
|
4204
|
+
const l = s.morphTargetDictionary[a], d = o.morphAttributes.position[l], c = o.morphAttributes.normal?.[l];
|
|
4205
|
+
r || (r = new f.Float32BufferAttribute(d.count * 3, 3), c && (u = new f.Float32BufferAttribute(d.count * 3, 3)));
|
|
4206
|
+
for (let g = 0; g < d.count; g++) {
|
|
4207
|
+
const y = r.getX(g) + d.getX(g) * h, x = r.getY(g) + d.getY(g) * h, L = r.getZ(g) + d.getZ(g) * h;
|
|
4208
|
+
r.setXYZ(g, y, x, L);
|
|
4209
4209
|
}
|
|
4210
|
-
if (
|
|
4211
|
-
for (let g = 0; g <
|
|
4212
|
-
const y = u.getX(g) +
|
|
4213
|
-
u.setXYZ(g, y, x,
|
|
4210
|
+
if (c)
|
|
4211
|
+
for (let g = 0; g < d.count; g++) {
|
|
4212
|
+
const y = u.getX(g) + c.getX(g) * h, x = u.getY(g) + c.getY(g) * h, L = u.getZ(g) + c.getZ(g) * h;
|
|
4213
|
+
u.setXYZ(g, y, x, L);
|
|
4214
4214
|
}
|
|
4215
4215
|
}
|
|
4216
4216
|
if (r) {
|
|
@@ -4275,8 +4275,8 @@ class we {
|
|
|
4275
4275
|
h && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((l) => {
|
|
4276
4276
|
r[a][l] = h[l];
|
|
4277
4277
|
}), this.morphs.forEach((l) => {
|
|
4278
|
-
const
|
|
4279
|
-
|
|
4278
|
+
const d = l.morphTargetDictionary[a];
|
|
4279
|
+
d !== void 0 && (r[a].ms.push(l.morphTargetInfluences), r[a].is.push(d), l.morphTargetInfluences[d] = r[a].applied);
|
|
4280
4280
|
});
|
|
4281
4281
|
}), this.mtAvatar = r, this.poseAvatar = { props: {} }, this.posePropNames.forEach((a) => {
|
|
4282
4282
|
const h = a.split("."), l = this.armature.getObjectByName(h[0]);
|
|
@@ -4374,9 +4374,9 @@ class we {
|
|
|
4374
4374
|
updatePoseDelta() {
|
|
4375
4375
|
for (const [t, e] of Object.entries(this.poseDelta.props)) {
|
|
4376
4376
|
if (e.x === 0 && e.y === 0 && e.z === 0) continue;
|
|
4377
|
-
|
|
4377
|
+
E.set(e.x, e.y, e.z);
|
|
4378
4378
|
const i = this.poseAvatar.props[t];
|
|
4379
|
-
i.isQuaternion ? (U.setFromEuler(
|
|
4379
|
+
i.isQuaternion ? (U.setFromEuler(E), i.multiply(U)) : i.isVector3 && i.add(E);
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
4382
|
/**
|
|
@@ -4975,10 +4975,10 @@ class we {
|
|
|
4975
4975
|
if (r.alt.length > 1) {
|
|
4976
4976
|
const h = Math.random();
|
|
4977
4977
|
let l = 0;
|
|
4978
|
-
for (let
|
|
4979
|
-
let
|
|
4980
|
-
if (l +=
|
|
4981
|
-
a = r.alt[
|
|
4978
|
+
for (let d = 0; d < r.alt.length; d++) {
|
|
4979
|
+
let c = this.valueFn(r.alt[d].p);
|
|
4980
|
+
if (l += c === void 0 ? (1 - l) / (r.alt.length - 1 - d) : c, h < l) {
|
|
4981
|
+
a = r.alt[d];
|
|
4982
4982
|
break;
|
|
4983
4983
|
}
|
|
4984
4984
|
}
|
|
@@ -4998,8 +4998,8 @@ class we {
|
|
|
4998
4998
|
}
|
|
4999
4999
|
s ? o.ts = o.ts.map((a) => u + a * i) : o.ts = o.ts.map((a) => this.animClock + u + a * i);
|
|
5000
5000
|
for (let [a, h] of Object.entries(r.vs)) {
|
|
5001
|
-
const l = this.getBaselineValue(a),
|
|
5002
|
-
a === "eyesRotateY" ? (o.vs.eyeLookOutLeft = [null, ...
|
|
5001
|
+
const l = this.getBaselineValue(a), d = h.map((c) => (c = this.valueFn(c), c === null ? null : typeof c == "function" ? c : typeof c == "string" || c instanceof String ? c.slice() : Array.isArray(c) ? a === "gesture" ? c.slice() : (l === void 0 ? 0 : l) + n * this.gaussianRandom(...c) : typeof c == "boolean" ? c : c instanceof Object && c.constructor === Object ? Object.assign({}, c) : (l === void 0 ? 0 : l) + n * c));
|
|
5002
|
+
a === "eyesRotateY" ? (o.vs.eyeLookOutLeft = [null, ...d.map((c) => c > 0 ? c : 0)], o.vs.eyeLookInLeft = [null, ...d.map((c) => c > 0 ? 0 : -c)], o.vs.eyeLookOutRight = [null, ...d.map((c) => c > 0 ? 0 : -c)], o.vs.eyeLookInRight = [null, ...d.map((c) => c > 0 ? c : 0)]) : a === "eyesRotateX" ? (o.vs.eyesLookDown = [null, ...d.map((c) => c > 0 ? c : 0)], o.vs.eyesLookUp = [null, ...d.map((c) => c > 0 ? 0 : -c)]) : o.vs[a] = [null, ...d];
|
|
5003
5003
|
}
|
|
5004
5004
|
for (let a of Object.keys(o.vs))
|
|
5005
5005
|
for (; o.vs[a].length <= o.ts.length; ) o.vs[a].push(o.vs[a][o.vs[a].length - 1]);
|
|
@@ -5086,20 +5086,20 @@ class we {
|
|
|
5086
5086
|
const l = this.animQueue[i];
|
|
5087
5087
|
if (!(!l || !l.ts || !l.ts.length || this.animClock < l.ts[0])) {
|
|
5088
5088
|
for (n = l.ndx || 0, o = l.ts.length; n < o && !(this.animClock < l.ts[n]); n++)
|
|
5089
|
-
for (let [
|
|
5090
|
-
if (this.mtAvatar.hasOwnProperty(
|
|
5091
|
-
if (
|
|
5092
|
-
const g = this.mtAvatar[
|
|
5093
|
-
if (
|
|
5094
|
-
g.newvalue =
|
|
5089
|
+
for (let [d, c] of Object.entries(l.vs))
|
|
5090
|
+
if (this.mtAvatar.hasOwnProperty(d)) {
|
|
5091
|
+
if (c[n + 1] === null) continue;
|
|
5092
|
+
const g = this.mtAvatar[d];
|
|
5093
|
+
if (c[n] === null && (c[n] = g.value), n === o - 1)
|
|
5094
|
+
g.newvalue = c[n];
|
|
5095
5095
|
else {
|
|
5096
|
-
g.newvalue =
|
|
5096
|
+
g.newvalue = c[n + 1];
|
|
5097
5097
|
const y = l.ts[n + 1] - l.ts[n];
|
|
5098
5098
|
let x = 1;
|
|
5099
|
-
y > 1e-4 && (x = (this.animClock - l.ts[n]) / y), x < 1 && (g.easing && (x = g.easing(x)), g.newvalue = (1 - x) *
|
|
5099
|
+
y > 1e-4 && (x = (this.animClock - l.ts[n]) / y), x < 1 && (g.easing && (x = g.easing(x)), g.newvalue = (1 - x) * c[n] + x * g.newvalue), g.ref && g.ref !== l.vs && g.ref.hasOwnProperty(d) && delete g.ref[d], g.ref = l.vs;
|
|
5100
5100
|
}
|
|
5101
5101
|
if (r)
|
|
5102
|
-
switch (
|
|
5102
|
+
switch (d) {
|
|
5103
5103
|
case "viseme_aa":
|
|
5104
5104
|
case "viseme_E":
|
|
5105
5105
|
case "viseme_I":
|
|
@@ -5108,11 +5108,11 @@ class we {
|
|
|
5108
5108
|
g.newvalue *= 1 + r / 255 - 0.5;
|
|
5109
5109
|
}
|
|
5110
5110
|
g.needsUpdate = !0;
|
|
5111
|
-
} else
|
|
5111
|
+
} else d === "eyeContact" && c[n] !== null && u !== !1 ? u = !!c[n] : d === "headMove" && c[n] !== null && a !== !1 ? c[n] === 0 ? a = !1 : (Math.random() < c[n] && (a = !0), c[n] = null) : c[n] !== null && (h.push({ mt: d, val: c[n] }), c[n] = null);
|
|
5112
5112
|
n === o ? (l.hasOwnProperty("mood") && this.setMood(l.mood), l.loop ? (o = this.isSpeaking && (l.template.name === "head" || l.template.name === "eyes") ? 4 : 1, this.animQueue[i] = this.animFactory(l.template, l.loop > 0 ? l.loop - 1 : l.loop, 1, 1 / o)) : (this.animQueue.splice(i--, 1), s--)) : l.ndx = n - 1;
|
|
5113
5113
|
}
|
|
5114
5114
|
}
|
|
5115
|
-
for (let l = 0,
|
|
5115
|
+
for (let l = 0, d = h.length; l < d; l++)
|
|
5116
5116
|
switch (n = h[l].val, h[l].mt) {
|
|
5117
5117
|
case "speak":
|
|
5118
5118
|
this.speakText(n);
|
|
@@ -5130,8 +5130,8 @@ class we {
|
|
|
5130
5130
|
n && typeof n == "function" && n();
|
|
5131
5131
|
break;
|
|
5132
5132
|
case "moveto":
|
|
5133
|
-
Object.entries(n.props).forEach((
|
|
5134
|
-
|
|
5133
|
+
Object.entries(n.props).forEach((c) => {
|
|
5134
|
+
c[1] ? this.poseTarget.props[c[0]].copy(c[1]) : this.poseTarget.props[c[0]].copy(this.getPoseTemplateProp(c[0])), this.poseTarget.props[c[0]].t = this.animClock, this.poseTarget.props[c[0]].d = c[1] && c[1].d ? c[1].d : c.duration || 2e3;
|
|
5135
5135
|
});
|
|
5136
5136
|
break;
|
|
5137
5137
|
case "handLeft":
|
|
@@ -5159,7 +5159,7 @@ class we {
|
|
|
5159
5159
|
}, n.x ? new f.Vector3(n.x, n.y, n.z) : null, !0, n.d);
|
|
5160
5160
|
break;
|
|
5161
5161
|
}
|
|
5162
|
-
if ((u || a) && (
|
|
5162
|
+
if ((u || a) && (E.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), E.x = Math.max(-0.9, Math.min(0.9, 2 * E.x - 0.5)), E.y = Math.max(-0.9, Math.min(0.9, -2.5 * E.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: E.x < 0 ? -E.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: E.x < 0 ? 0 : E.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), a && (i = -this.mtAvatar.bodyRotateY.value, n = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
|
|
5163
5163
|
name: "headmove",
|
|
5164
5164
|
dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
|
|
5165
5165
|
vs: {
|
|
@@ -5180,13 +5180,13 @@ class we {
|
|
|
5180
5180
|
eyeLookOutRight: [null, 0],
|
|
5181
5181
|
eyeContact: [0]
|
|
5182
5182
|
}
|
|
5183
|
-
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (i = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], n = this.mtAvatar[i], n.needsUpdate || Object.assign(n, { base: (this.mood.baseline[i] || 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.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), i = this.volumeHeadTarget - this.volumeHeadCurrent, n = Math.abs(i), n > 1e-4 && (o = n * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / n) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(i) * Math.min(n, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (U.setFromAxisAngle(tt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(U)),
|
|
5183
|
+
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (i = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], n = this.mtAvatar[i], n.needsUpdate || Object.assign(n, { base: (this.mood.baseline[i] || 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.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), i = this.volumeHeadTarget - this.volumeHeadCurrent, n = Math.abs(i), n > 1e-4 && (o = n * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / n) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(i) * Math.min(n, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (U.setFromAxisAngle(tt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(U)), Ae.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ee), ee.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(ie), ie.sub(this.armature.position), this.objectHips.position.y -= Ae.min.y / 2, this.objectHips.position.x -= (ee.x + ie.x) / 4, this.objectHips.position.z -= (ee.z + ie.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
|
|
5184
5184
|
this.stats && this.stats.end();
|
|
5185
5185
|
else {
|
|
5186
5186
|
if (this.cameraClock !== null && this.cameraClock < 1e3) {
|
|
5187
5187
|
this.cameraClock += e, this.cameraClock > 1e3 && (this.cameraClock = 1e3);
|
|
5188
|
-
let l = new f.Spherical().setFromVector3(this.cameraStart),
|
|
5189
|
-
l.phi += this.easing(this.cameraClock / 1e3) * (
|
|
5188
|
+
let l = new f.Spherical().setFromVector3(this.cameraStart), d = new f.Spherical().setFromVector3(this.cameraEnd);
|
|
5189
|
+
l.phi += this.easing(this.cameraClock / 1e3) * (d.phi - l.phi), l.theta += this.easing(this.cameraClock / 1e3) * (d.theta - l.theta), l.radius += this.easing(this.cameraClock / 1e3) * (d.radius - l.radius), l.makeSafe(), this.camera.position.setFromSpherical(l), this.controlsStart.x !== this.controlsEnd.x ? this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd, this.easing(this.cameraClock / 1e3))) : (l.setFromVector3(this.controlsStart), d.setFromVector3(this.controlsEnd), l.phi += this.easing(this.cameraClock / 1e3) * (d.phi - l.phi), l.theta += this.easing(this.cameraClock / 1e3) * (d.theta - l.theta), l.radius += this.easing(this.cameraClock / 1e3) * (d.radius - l.radius), l.makeSafe(), this.controls.target.setFromSpherical(l)), this.controls.update();
|
|
5190
5190
|
}
|
|
5191
5191
|
this.controls.autoRotate && this.controls.update(), this.stats && this.stats.end(), this.render();
|
|
5192
5192
|
}
|
|
@@ -5211,8 +5211,8 @@ class we {
|
|
|
5211
5211
|
if (!this.lipsync.hasOwnProperty(t)) {
|
|
5212
5212
|
const i = t.toLowerCase(), n = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
|
|
5213
5213
|
try {
|
|
5214
|
-
const s =
|
|
5215
|
-
s && s[n] ? (this.lipsync[t] = new s[n](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(
|
|
5214
|
+
const s = Le[i];
|
|
5215
|
+
s && s[n] ? (this.lipsync[t] = new s[n](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Le));
|
|
5216
5216
|
} catch (s) {
|
|
5217
5217
|
console.warn(`Failed to load lip-sync module for ${t}:`, s);
|
|
5218
5218
|
}
|
|
@@ -5248,48 +5248,48 @@ class we {
|
|
|
5248
5248
|
speakText(t, e = null, i = null, n = null) {
|
|
5249
5249
|
e = e || {};
|
|
5250
5250
|
const s = /[!\.\?\n\p{Extended_Pictographic}]/ug, o = /[ ]/ug, r = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug, u = /[\p{Extended_Pictographic}]/ug, a = e.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang;
|
|
5251
|
-
let h = "", l = "",
|
|
5251
|
+
let h = "", l = "", d = 0, c = [], g = [];
|
|
5252
5252
|
const y = Array.from(this.segmenter.segment(t), (x) => x.segment);
|
|
5253
5253
|
for (let x = 0; x < y.length; x++) {
|
|
5254
|
-
const
|
|
5254
|
+
const L = x === y.length - 1, F = y[x].match(r);
|
|
5255
5255
|
let p = y[x].match(s);
|
|
5256
5256
|
const z = y[x].match(u), C = y[x].match(o);
|
|
5257
|
-
if (p && !
|
|
5258
|
-
mark:
|
|
5257
|
+
if (p && !L && !z && y[x + 1].match(s) && (p = !1), i && (h += y[x]), F && (!n || n.every((I) => x < I[0] || x > I[1])) && (l += y[x]), (C || p || L) && (l.length && (l = this.lipsyncPreProcessText(l, a), l.length && c.push({
|
|
5258
|
+
mark: d,
|
|
5259
5259
|
word: l
|
|
5260
5260
|
})), h.length && (g.push({
|
|
5261
|
-
mark:
|
|
5261
|
+
mark: d,
|
|
5262
5262
|
template: { name: "subtitles" },
|
|
5263
5263
|
ts: [0],
|
|
5264
5264
|
vs: {
|
|
5265
5265
|
subtitles: [h]
|
|
5266
5266
|
}
|
|
5267
5267
|
}), h = ""), l.length)) {
|
|
5268
|
-
const
|
|
5269
|
-
if (
|
|
5270
|
-
const
|
|
5271
|
-
for (let D = 0; D <
|
|
5268
|
+
const I = this.lipsyncWordsToVisemes(l, a);
|
|
5269
|
+
if (I && I.visemes && I.visemes.length) {
|
|
5270
|
+
const B = I.times[I.visemes.length - 1] + I.durations[I.visemes.length - 1];
|
|
5271
|
+
for (let D = 0; D < I.visemes.length; D++)
|
|
5272
5272
|
g.push({
|
|
5273
|
-
mark:
|
|
5273
|
+
mark: d,
|
|
5274
5274
|
template: { name: "viseme" },
|
|
5275
|
-
ts: [(
|
|
5275
|
+
ts: [(I.times[D] - 0.6) / B, (I.times[D] + 0.5) / B, (I.times[D] + I.durations[D] + 0.5) / B],
|
|
5276
5276
|
vs: {
|
|
5277
|
-
["viseme_" +
|
|
5277
|
+
["viseme_" + I.visemes[D]]: [null, I.visemes[D] === "PP" || I.visemes[D] === "FF" ? 0.9 : 0.6, 0]
|
|
5278
5278
|
}
|
|
5279
5279
|
});
|
|
5280
5280
|
}
|
|
5281
|
-
l = "",
|
|
5281
|
+
l = "", d++;
|
|
5282
5282
|
}
|
|
5283
|
-
if (p ||
|
|
5284
|
-
if (
|
|
5285
|
-
const
|
|
5283
|
+
if (p || L) {
|
|
5284
|
+
if (c.length || L && g.length) {
|
|
5285
|
+
const I = {
|
|
5286
5286
|
anim: g
|
|
5287
5287
|
};
|
|
5288
|
-
i && (
|
|
5288
|
+
i && (I.onSubtitles = i), c.length && !e.avatarMute && (I.text = c, 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), c = [], l = "", d = 0, g = [];
|
|
5289
5289
|
}
|
|
5290
5290
|
if (z) {
|
|
5291
|
-
let
|
|
5292
|
-
|
|
5291
|
+
let I = this.animEmojis[y[x]];
|
|
5292
|
+
I && I.link && (I = this.animEmojis[I.link]), I && this.speechQueue.push({ emoji: I });
|
|
5293
5293
|
}
|
|
5294
5294
|
this.speechQueue.push({ break: 100 });
|
|
5295
5295
|
}
|
|
@@ -5379,18 +5379,18 @@ class we {
|
|
|
5379
5379
|
subtitles: [" " + u]
|
|
5380
5380
|
}
|
|
5381
5381
|
}), !t.visemes)) {
|
|
5382
|
-
const l = this.lipsyncPreProcessText(u, n),
|
|
5383
|
-
if (
|
|
5384
|
-
const
|
|
5382
|
+
const l = this.lipsyncPreProcessText(u, n), d = this.lipsyncWordsToVisemes(l, n);
|
|
5383
|
+
if (d && d.visemes && d.visemes.length) {
|
|
5384
|
+
const c = d.times[d.visemes.length - 1] + d.durations[d.visemes.length - 1], g = Math.min(h, Math.max(0, h - d.visemes.length * 150));
|
|
5385
5385
|
let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
|
|
5386
|
-
if (h = Math.min(h,
|
|
5387
|
-
for (let x = 0; x <
|
|
5388
|
-
const
|
|
5386
|
+
if (h = Math.min(h, d.visemes.length * 200), c > 0)
|
|
5387
|
+
for (let x = 0; x < d.visemes.length; x++) {
|
|
5388
|
+
const L = a + d.times[x] / c * h, F = d.durations[x] / c * h;
|
|
5389
5389
|
o.push({
|
|
5390
5390
|
template: { name: "viseme" },
|
|
5391
|
-
ts: [
|
|
5391
|
+
ts: [L - Math.min(60, 2 * F / 3), L + Math.min(25, F / 2), L + F + Math.min(60, F / 2)],
|
|
5392
5392
|
vs: {
|
|
5393
|
-
["viseme_" +
|
|
5393
|
+
["viseme_" + d.visemes[x]]: [null, d.visemes[x] === "PP" || d.visemes[x] === "FF" ? 0.9 : y, 0]
|
|
5394
5394
|
}
|
|
5395
5395
|
});
|
|
5396
5396
|
}
|
|
@@ -5473,31 +5473,31 @@ class we {
|
|
|
5473
5473
|
const p = h.find((z) => z.name.includes(l) || z.lang === o);
|
|
5474
5474
|
p && (s.voice = p);
|
|
5475
5475
|
}
|
|
5476
|
-
const
|
|
5476
|
+
const d = n.length * 100 / s.rate, c = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (d / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", y = this.lipsyncPreProcessText(n, g), x = this.lipsyncWordsToVisemes(y, g);
|
|
5477
5477
|
console.log("Browser TTS Lip-sync Debug:", {
|
|
5478
5478
|
text: n,
|
|
5479
5479
|
lipsyncLang: g,
|
|
5480
5480
|
processedText: y,
|
|
5481
5481
|
lipsyncData: x,
|
|
5482
5482
|
hasVisemes: x && x.visemes && x.visemes.length > 0,
|
|
5483
|
-
estimatedDuration:
|
|
5483
|
+
estimatedDuration: d
|
|
5484
5484
|
});
|
|
5485
|
-
const
|
|
5485
|
+
const L = [];
|
|
5486
5486
|
if (x && x.visemes && x.visemes.length > 0) {
|
|
5487
5487
|
const p = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
|
|
5488
5488
|
for (let z = 0; z < x.visemes.length; z++) {
|
|
5489
|
-
const C = x.visemes[z],
|
|
5490
|
-
|
|
5489
|
+
const C = x.visemes[z], I = x.times[z] / p, B = x.durations[z] / p, D = I * d, X = B * d;
|
|
5490
|
+
L.push({
|
|
5491
5491
|
template: { name: "viseme" },
|
|
5492
|
-
ts: [D - Math.min(60, 2 *
|
|
5492
|
+
ts: [D - Math.min(60, 2 * X / 3), D + Math.min(25, X / 2), D + X + Math.min(60, X / 2)],
|
|
5493
5493
|
vs: {
|
|
5494
5494
|
["viseme_" + C]: [null, C === "PP" || C === "FF" ? 0.9 : 0.6, 0]
|
|
5495
5495
|
}
|
|
5496
5496
|
});
|
|
5497
5497
|
}
|
|
5498
5498
|
}
|
|
5499
|
-
const F = [...t.anim, ...
|
|
5500
|
-
this.audioPlaylist.push({ anim: F, audio:
|
|
5499
|
+
const F = [...t.anim, ...L];
|
|
5500
|
+
this.audioPlaylist.push({ anim: F, audio: c }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
|
|
5501
5501
|
e();
|
|
5502
5502
|
}, s.onerror = (p) => {
|
|
5503
5503
|
console.error("Speech synthesis error:", p.error), i(p.error);
|
|
@@ -5509,7 +5509,7 @@ class we {
|
|
|
5509
5509
|
* @param {Object} line Speech line object
|
|
5510
5510
|
*/
|
|
5511
5511
|
async synthesizeWithElevenLabsTTS(t) {
|
|
5512
|
-
const e = t.text.map((
|
|
5512
|
+
const e = t.text.map((d) => d.word).join(" "), i = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "21m00Tcm4TlvDq8ikWAM", n = {
|
|
5513
5513
|
text: e,
|
|
5514
5514
|
model_id: "eleven_monolingual_v1",
|
|
5515
5515
|
voice_settings: {
|
|
@@ -5539,18 +5539,18 @@ class we {
|
|
|
5539
5539
|
lipsyncKeys: this.lipsync ? Object.keys(this.lipsync) : [],
|
|
5540
5540
|
lipsyncLang: u
|
|
5541
5541
|
});
|
|
5542
|
-
const
|
|
5542
|
+
const d = this.lipsyncPreProcessText(e, u), c = this.lipsyncWordsToVisemes(d, u);
|
|
5543
5543
|
if (console.log("Lip-sync data:", {
|
|
5544
|
-
processedText:
|
|
5545
|
-
lipsyncData:
|
|
5546
|
-
hasVisemes:
|
|
5547
|
-
}),
|
|
5544
|
+
processedText: d,
|
|
5545
|
+
lipsyncData: c,
|
|
5546
|
+
hasVisemes: c && c.visemes && c.visemes.length > 0
|
|
5547
|
+
}), c && c.visemes && c.visemes.length > 0)
|
|
5548
5548
|
a = {
|
|
5549
|
-
visemes:
|
|
5549
|
+
visemes: c.visemes.map((g, y) => ({
|
|
5550
5550
|
viseme: g,
|
|
5551
|
-
startTime: y * r.duration /
|
|
5552
|
-
endTime: (y + 1) * r.duration /
|
|
5553
|
-
duration: r.duration /
|
|
5551
|
+
startTime: y * r.duration / c.visemes.length,
|
|
5552
|
+
endTime: (y + 1) * r.duration / c.visemes.length,
|
|
5553
|
+
duration: r.duration / c.visemes.length,
|
|
5554
5554
|
intensity: 0.7
|
|
5555
5555
|
})),
|
|
5556
5556
|
words: [],
|
|
@@ -5559,13 +5559,13 @@ class we {
|
|
|
5559
5559
|
};
|
|
5560
5560
|
else
|
|
5561
5561
|
throw new Error("No visemes generated from text");
|
|
5562
|
-
} catch (
|
|
5563
|
-
console.error("Text-based lip-sync failed, using fallback:",
|
|
5564
|
-
const
|
|
5565
|
-
for (const y of
|
|
5562
|
+
} catch (d) {
|
|
5563
|
+
console.error("Text-based lip-sync failed, using fallback:", d);
|
|
5564
|
+
const c = e.toLowerCase().split(/\s+/), g = [];
|
|
5565
|
+
for (const y of c)
|
|
5566
5566
|
for (const x of y) {
|
|
5567
|
-
let
|
|
5568
|
-
"aeiou".includes(x) ?
|
|
5567
|
+
let L = "aa";
|
|
5568
|
+
"aeiou".includes(x) ? L = "aa" : "bp".includes(x) ? L = "PP" : "fv".includes(x) ? L = "FF" : "st".includes(x) ? L = "SS" : "dln".includes(x) ? L = "DD" : "kg".includes(x) ? L = "kk" : "rw".includes(x) && (L = "RR"), g.push(L);
|
|
5569
5569
|
}
|
|
5570
5570
|
a = {
|
|
5571
5571
|
visemes: g.map((y, x) => ({
|
|
@@ -5595,13 +5595,13 @@ class we {
|
|
|
5595
5595
|
const h = [];
|
|
5596
5596
|
if (a.visemes && a.visemes.length > 0) {
|
|
5597
5597
|
console.log("ElevenLabs: Generating lip-sync animation from", a.visemes.length, "visemes");
|
|
5598
|
-
for (let
|
|
5599
|
-
const
|
|
5598
|
+
for (let d = 0; d < a.visemes.length; d++) {
|
|
5599
|
+
const c = a.visemes[d], g = c.startTime * 1e3, y = c.duration * 1e3, x = c.intensity;
|
|
5600
5600
|
h.push({
|
|
5601
5601
|
template: { name: "viseme" },
|
|
5602
5602
|
ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
|
|
5603
5603
|
vs: {
|
|
5604
|
-
["viseme_" +
|
|
5604
|
+
["viseme_" + c.viseme]: [null, x, 0]
|
|
5605
5605
|
}
|
|
5606
5606
|
});
|
|
5607
5607
|
}
|
|
@@ -5616,7 +5616,7 @@ class we {
|
|
|
5616
5616
|
* @param {Object} line Speech line object
|
|
5617
5617
|
*/
|
|
5618
5618
|
async synthesizeWithDeepgramTTS(t) {
|
|
5619
|
-
const e = t.text.map((
|
|
5619
|
+
const e = t.text.map((d) => d.word).join(" "), i = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "aura-2-thalia-en", n = `${this.opt.ttsEndpoint}?model=${i}`, s = await fetch(n, {
|
|
5620
5620
|
method: "POST",
|
|
5621
5621
|
headers: {
|
|
5622
5622
|
Authorization: `Token ${this.opt.ttsApikey}`,
|
|
@@ -5637,18 +5637,18 @@ class we {
|
|
|
5637
5637
|
lipsyncKeys: this.lipsync ? Object.keys(this.lipsync) : [],
|
|
5638
5638
|
lipsyncLang: u
|
|
5639
5639
|
});
|
|
5640
|
-
const
|
|
5640
|
+
const d = this.lipsyncPreProcessText(e, u), c = this.lipsyncWordsToVisemes(d, u);
|
|
5641
5641
|
if (console.log("Lip-sync data:", {
|
|
5642
|
-
processedText:
|
|
5643
|
-
lipsyncData:
|
|
5644
|
-
hasVisemes:
|
|
5645
|
-
}),
|
|
5642
|
+
processedText: d,
|
|
5643
|
+
lipsyncData: c,
|
|
5644
|
+
hasVisemes: c && c.visemes && c.visemes.length > 0
|
|
5645
|
+
}), c && c.visemes && c.visemes.length > 0)
|
|
5646
5646
|
a = {
|
|
5647
|
-
visemes:
|
|
5647
|
+
visemes: c.visemes.map((g, y) => ({
|
|
5648
5648
|
viseme: g,
|
|
5649
|
-
startTime: y * r.duration /
|
|
5650
|
-
endTime: (y + 1) * r.duration /
|
|
5651
|
-
duration: r.duration /
|
|
5649
|
+
startTime: y * r.duration / c.visemes.length,
|
|
5650
|
+
endTime: (y + 1) * r.duration / c.visemes.length,
|
|
5651
|
+
duration: r.duration / c.visemes.length,
|
|
5652
5652
|
intensity: 0.7
|
|
5653
5653
|
})),
|
|
5654
5654
|
words: [],
|
|
@@ -5657,13 +5657,13 @@ class we {
|
|
|
5657
5657
|
};
|
|
5658
5658
|
else
|
|
5659
5659
|
throw new Error("No visemes generated from text");
|
|
5660
|
-
} catch (
|
|
5661
|
-
console.error("Text-based lip-sync failed, using fallback:",
|
|
5662
|
-
const
|
|
5663
|
-
for (const y of
|
|
5660
|
+
} catch (d) {
|
|
5661
|
+
console.error("Text-based lip-sync failed, using fallback:", d);
|
|
5662
|
+
const c = e.toLowerCase().split(/\s+/), g = [];
|
|
5663
|
+
for (const y of c)
|
|
5664
5664
|
for (const x of y) {
|
|
5665
|
-
let
|
|
5666
|
-
"aeiou".includes(x) ?
|
|
5665
|
+
let L = "aa";
|
|
5666
|
+
"aeiou".includes(x) ? L = "aa" : "bp".includes(x) ? L = "PP" : "fv".includes(x) ? L = "FF" : "st".includes(x) ? L = "SS" : "dln".includes(x) ? L = "DD" : "kg".includes(x) ? L = "kk" : "rw".includes(x) && (L = "RR"), g.push(L);
|
|
5667
5667
|
}
|
|
5668
5668
|
a = {
|
|
5669
5669
|
visemes: g.map((y, x) => ({
|
|
@@ -5693,13 +5693,13 @@ class we {
|
|
|
5693
5693
|
const h = [];
|
|
5694
5694
|
if (a.visemes && a.visemes.length > 0) {
|
|
5695
5695
|
console.log("Deepgram: Generating lip-sync animation from", a.visemes.length, "visemes");
|
|
5696
|
-
for (let
|
|
5697
|
-
const
|
|
5696
|
+
for (let d = 0; d < a.visemes.length; d++) {
|
|
5697
|
+
const c = a.visemes[d], g = c.startTime * 1e3, y = c.duration * 1e3, x = c.intensity;
|
|
5698
5698
|
h.push({
|
|
5699
5699
|
template: { name: "viseme" },
|
|
5700
5700
|
ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
|
|
5701
5701
|
vs: {
|
|
5702
|
-
["viseme_" +
|
|
5702
|
+
["viseme_" + c.viseme]: [null, x, 0]
|
|
5703
5703
|
}
|
|
5704
5704
|
});
|
|
5705
5705
|
}
|
|
@@ -5746,12 +5746,12 @@ class we {
|
|
|
5746
5746
|
});
|
|
5747
5747
|
const a = [];
|
|
5748
5748
|
for (let l = 0; l < u.visemes.length; l++) {
|
|
5749
|
-
const
|
|
5749
|
+
const d = u.visemes[l], c = d.startTime * 1e3, g = d.duration * 1e3, y = d.intensity;
|
|
5750
5750
|
a.push({
|
|
5751
5751
|
template: { name: "viseme" },
|
|
5752
|
-
ts: [
|
|
5752
|
+
ts: [c - Math.min(60, 2 * g / 3), c + Math.min(25, g / 2), c + g + Math.min(60, g / 2)],
|
|
5753
5753
|
vs: {
|
|
5754
|
-
["viseme_" +
|
|
5754
|
+
["viseme_" + d.viseme]: [null, y, 0]
|
|
5755
5755
|
}
|
|
5756
5756
|
});
|
|
5757
5757
|
}
|
|
@@ -5797,25 +5797,25 @@ class we {
|
|
|
5797
5797
|
this.speakWithHands();
|
|
5798
5798
|
const u = [0];
|
|
5799
5799
|
let a = 0;
|
|
5800
|
-
t.text.forEach((
|
|
5801
|
-
if (
|
|
5800
|
+
t.text.forEach((d, c) => {
|
|
5801
|
+
if (c > 0) {
|
|
5802
5802
|
let g = u[u.length - 1];
|
|
5803
|
-
s.timepoints[a] && (g = s.timepoints[a].timeSeconds * 1e3, s.timepoints[a].markName === "" +
|
|
5803
|
+
s.timepoints[a] && (g = s.timepoints[a].timeSeconds * 1e3, s.timepoints[a].markName === "" + d.mark && a++), u.push(g);
|
|
5804
5804
|
}
|
|
5805
5805
|
});
|
|
5806
5806
|
const h = [{ mark: 0, time: 0 }];
|
|
5807
|
-
u.forEach((
|
|
5808
|
-
if (
|
|
5809
|
-
let g =
|
|
5810
|
-
h[
|
|
5807
|
+
u.forEach((d, c) => {
|
|
5808
|
+
if (c > 0) {
|
|
5809
|
+
let g = d - u[c - 1];
|
|
5810
|
+
h[c - 1].duration = g, h.push({ mark: c, time: d });
|
|
5811
5811
|
}
|
|
5812
5812
|
});
|
|
5813
5813
|
let l = 1e3 * r.duration;
|
|
5814
|
-
l > this.opt.ttsTrimEnd && (l = l - this.opt.ttsTrimEnd), h[h.length - 1].duration = l - h[h.length - 1].time, t.anim.forEach((
|
|
5815
|
-
const
|
|
5816
|
-
if (
|
|
5817
|
-
for (let g = 0; g <
|
|
5818
|
-
|
|
5814
|
+
l > this.opt.ttsTrimEnd && (l = l - this.opt.ttsTrimEnd), h[h.length - 1].duration = l - h[h.length - 1].time, t.anim.forEach((d) => {
|
|
5815
|
+
const c = h[d.mark];
|
|
5816
|
+
if (c)
|
|
5817
|
+
for (let g = 0; g < d.ts.length; g++)
|
|
5818
|
+
d.ts[g] = c.time + d.ts[g] * c.duration + this.opt.ttsTrimStart;
|
|
5819
5819
|
}), this.audioPlaylist.push({ anim: t.anim, audio: r }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
|
|
5820
5820
|
} else
|
|
5821
5821
|
this.startSpeaking(!0);
|
|
@@ -6034,15 +6034,15 @@ class we {
|
|
|
6034
6034
|
const r = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, u = this.lipsyncPreProcessText(n, r), a = this.lipsyncWordsToVisemes(u, r);
|
|
6035
6035
|
if (a && a.visemes && a.visemes.length) {
|
|
6036
6036
|
const h = a.times[a.visemes.length - 1] + a.durations[a.visemes.length - 1], l = Math.min(o, Math.max(0, o - a.visemes.length * 150));
|
|
6037
|
-
let
|
|
6037
|
+
let d = 0.6 + this.convertRange(l, [0, o], [0, 0.4]);
|
|
6038
6038
|
if (o = Math.min(o, a.visemes.length * 200), h > 0)
|
|
6039
|
-
for (let
|
|
6040
|
-
const g = e + s + a.times[
|
|
6039
|
+
for (let c = 0; c < a.visemes.length; c++) {
|
|
6040
|
+
const g = e + s + a.times[c] / h * o, y = a.durations[c] / h * o;
|
|
6041
6041
|
this.animQueue.push({
|
|
6042
6042
|
template: { name: "viseme" },
|
|
6043
6043
|
ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
|
|
6044
6044
|
vs: {
|
|
6045
|
-
["viseme_" + a.visemes[
|
|
6045
|
+
["viseme_" + a.visemes[c]]: [null, a.visemes[c] === "PP" || a.visemes[c] === "FF" ? 0.9 : d, 0]
|
|
6046
6046
|
}
|
|
6047
6047
|
});
|
|
6048
6048
|
}
|
|
@@ -6133,7 +6133,7 @@ class we {
|
|
|
6133
6133
|
*/
|
|
6134
6134
|
lookAtCamera(t) {
|
|
6135
6135
|
let e;
|
|
6136
|
-
if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0),
|
|
6136
|
+
if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ee.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), ie.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ee, ie).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
|
|
6137
6137
|
if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
|
|
6138
6138
|
if (this.avatar.avatarIgnoreCamera) {
|
|
6139
6139
|
this.lookAhead(t);
|
|
@@ -6146,22 +6146,22 @@ class we {
|
|
|
6146
6146
|
this.lookAt(null, null, t);
|
|
6147
6147
|
return;
|
|
6148
6148
|
}
|
|
6149
|
-
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0),
|
|
6150
|
-
const i = new f.Vector3().subVectors(e,
|
|
6151
|
-
|
|
6152
|
-
const r = new f.Quaternion().setFromEuler(
|
|
6153
|
-
|
|
6154
|
-
let a =
|
|
6149
|
+
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ee.setFromMatrixPosition(this.objectLeftEye.matrixWorld), ie.setFromMatrixPosition(this.objectRightEye.matrixWorld), ee.add(ie).divideScalar(2), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]);
|
|
6150
|
+
const i = new f.Vector3().subVectors(e, ee).normalize(), n = Math.atan2(i.x, i.z), s = Math.asin(-i.y);
|
|
6151
|
+
E.set(s, n, 0, "YXZ");
|
|
6152
|
+
const r = new f.Quaternion().setFromEuler(E), u = new f.Quaternion().copy(r).multiply(U.clone().invert());
|
|
6153
|
+
E.setFromQuaternion(u, "YXZ");
|
|
6154
|
+
let a = E.x / (40 / 24) + 0.2, h = E.y / (9 / 4), l = Math.min(0.6, Math.max(-0.3, a)), d = Math.min(0.8, Math.max(-0.8, h)), c = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
|
|
6155
6155
|
if (t) {
|
|
6156
|
-
let y = this.animQueue.findIndex((
|
|
6156
|
+
let y = this.animQueue.findIndex((L) => L.template.name === "lookat");
|
|
6157
6157
|
y !== -1 && this.animQueue.splice(y, 1);
|
|
6158
6158
|
const x = {
|
|
6159
6159
|
name: "lookat",
|
|
6160
6160
|
dt: [750, t],
|
|
6161
6161
|
vs: {
|
|
6162
|
-
bodyRotateX: [l +
|
|
6163
|
-
bodyRotateY: [
|
|
6164
|
-
eyesRotateX: [-3 *
|
|
6162
|
+
bodyRotateX: [l + c],
|
|
6163
|
+
bodyRotateY: [d + g],
|
|
6164
|
+
eyesRotateX: [-3 * c + 0.1],
|
|
6165
6165
|
eyesRotateY: [-5 * g],
|
|
6166
6166
|
browInnerUp: [[0, 0.7]],
|
|
6167
6167
|
mouthLeft: [[0, 0.7]],
|
|
@@ -6186,19 +6186,19 @@ class we {
|
|
|
6186
6186
|
const s = new f.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new f.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), r = new f.Vector3().addVectors(s, o).divideScalar(2);
|
|
6187
6187
|
r.project(this.camera);
|
|
6188
6188
|
let u = (r.x + 1) / 2 * n.width + n.left, a = -(r.y - 1) / 2 * n.height + n.top;
|
|
6189
|
-
t === null && (t = u), e === null && (e = a), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]),
|
|
6190
|
-
let h =
|
|
6191
|
-
x = Math.min(0.6, Math.max(-0.3, x)),
|
|
6189
|
+
t === null && (t = u), e === null && (e = a), U.copy(this.armature.quaternion), U.multiply(this.poseTarget.props["Hips.quaternion"]), U.multiply(this.poseTarget.props["Spine.quaternion"]), U.multiply(this.poseTarget.props["Spine1.quaternion"]), U.multiply(this.poseTarget.props["Spine2.quaternion"]), U.multiply(this.poseTarget.props["Neck.quaternion"]), U.multiply(this.poseTarget.props["Head.quaternion"]), E.setFromQuaternion(U);
|
|
6190
|
+
let h = E.x / (40 / 24), l = E.y / (9 / 4), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + d, L = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - l + c;
|
|
6191
|
+
x = Math.min(0.6, Math.max(-0.3, x)), L = Math.min(0.8, Math.max(-0.8, L));
|
|
6192
6192
|
let F = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
|
|
6193
6193
|
if (i) {
|
|
6194
|
-
let z = this.animQueue.findIndex((
|
|
6194
|
+
let z = this.animQueue.findIndex((I) => I.template.name === "lookat");
|
|
6195
6195
|
z !== -1 && this.animQueue.splice(z, 1);
|
|
6196
6196
|
const C = {
|
|
6197
6197
|
name: "lookat",
|
|
6198
6198
|
dt: [750, i],
|
|
6199
6199
|
vs: {
|
|
6200
6200
|
bodyRotateX: [x + F],
|
|
6201
|
-
bodyRotateY: [
|
|
6201
|
+
bodyRotateY: [L + p],
|
|
6202
6202
|
eyesRotateX: [-3 * F + 0.1],
|
|
6203
6203
|
eyesRotateY: [-5 * p],
|
|
6204
6204
|
browInnerUp: [[0, 0.7]],
|
|
@@ -6395,58 +6395,58 @@ class we {
|
|
|
6395
6395
|
}
|
|
6396
6396
|
let a = !1;
|
|
6397
6397
|
try {
|
|
6398
|
-
const
|
|
6399
|
-
if (a =
|
|
6400
|
-
console.error(`FBX file not found at ${t}. Status: ${
|
|
6398
|
+
const d = await fetch(t, { method: "HEAD" });
|
|
6399
|
+
if (a = d.ok, !a) {
|
|
6400
|
+
console.error(`FBX file not found at ${t}. Status: ${d.status}`), console.error("Please check:"), console.error("1. File path is correct (note: path is case-sensitive)"), console.error("2. File exists in your public folder"), console.error("3. File is accessible (not blocked by server)");
|
|
6401
6401
|
return;
|
|
6402
6402
|
}
|
|
6403
|
-
} catch (
|
|
6404
|
-
console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`,
|
|
6403
|
+
} catch (d) {
|
|
6404
|
+
console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, d);
|
|
6405
6405
|
}
|
|
6406
6406
|
const h = new ve();
|
|
6407
6407
|
let l;
|
|
6408
6408
|
try {
|
|
6409
6409
|
l = await h.loadAsync(t, e);
|
|
6410
|
-
} catch (
|
|
6411
|
-
console.error(`Failed to load FBX animation from ${t}:`,
|
|
6412
|
-
message:
|
|
6410
|
+
} catch (d) {
|
|
6411
|
+
console.error(`Failed to load FBX animation from ${t}:`, d), console.error("Error details:", {
|
|
6412
|
+
message: d.message,
|
|
6413
6413
|
url: t,
|
|
6414
6414
|
suggestion: "Make sure the file is a valid FBX file and the path is correct"
|
|
6415
|
-
}),
|
|
6415
|
+
}), d.message && d.message.includes("version number") && (console.error("FBX Loader Error: Cannot find version number"), console.error("This error usually means:"), console.error("1. The file is not a valid FBX file (might be GLB, corrupted, or wrong format)"), console.error("2. The file might be corrupted"), console.error("3. The file path might be incorrect"), console.error("4. The server returned an HTML error page instead of the FBX file"), console.error("5. The file might not exist at that path"), console.error(""), console.error("Solution: Please verify:"), console.error(` - File exists at: ${t}`), console.error(" - File is a valid FBX binary file"), console.error(" - File path matches your public folder structure"), console.error(" - File is not corrupted"));
|
|
6416
6416
|
try {
|
|
6417
|
-
const
|
|
6417
|
+
const c = await fetch(t), g = c.headers.get("content-type"), y = await c.text();
|
|
6418
6418
|
console.error("Response details:", {
|
|
6419
|
-
status:
|
|
6419
|
+
status: c.status,
|
|
6420
6420
|
contentType: g,
|
|
6421
6421
|
firstBytes: y.substring(0, 100),
|
|
6422
6422
|
isHTML: y.trim().startsWith("<!DOCTYPE") || y.trim().startsWith("<html")
|
|
6423
6423
|
}), (y.trim().startsWith("<!DOCTYPE") || y.trim().startsWith("<html")) && console.error("The server returned an HTML page instead of an FBX file. The file path is likely incorrect.");
|
|
6424
|
-
} catch (
|
|
6425
|
-
console.error("Could not fetch file for debugging:",
|
|
6424
|
+
} catch (c) {
|
|
6425
|
+
console.error("Could not fetch file for debugging:", c);
|
|
6426
6426
|
}
|
|
6427
6427
|
return;
|
|
6428
6428
|
}
|
|
6429
6429
|
if (l && l.animations && l.animations[n]) {
|
|
6430
|
-
let
|
|
6431
|
-
const
|
|
6432
|
-
|
|
6430
|
+
let d = l.animations[n];
|
|
6431
|
+
const c = {};
|
|
6432
|
+
d.tracks.forEach((y) => {
|
|
6433
6433
|
y.name = y.name.replaceAll("mixamorig", "");
|
|
6434
6434
|
const x = y.name.split(".");
|
|
6435
6435
|
if (x[1] === "position") {
|
|
6436
|
-
for (let
|
|
6437
|
-
y.values[
|
|
6438
|
-
|
|
6439
|
-
} else x[1] === "quaternion" ?
|
|
6436
|
+
for (let L = 0; L < y.values.length; L++)
|
|
6437
|
+
y.values[L] = y.values[L] * s;
|
|
6438
|
+
c[y.name] = new f.Vector3(y.values[0], y.values[1], y.values[2]);
|
|
6439
|
+
} else x[1] === "quaternion" ? c[y.name] = new f.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : x[1] === "rotation" && (c[x[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
|
|
6440
6440
|
});
|
|
6441
|
-
const g = { props:
|
|
6442
|
-
|
|
6441
|
+
const g = { props: c };
|
|
6442
|
+
c["Hips.position"] && (c["Hips.position"].y < 0.5 ? g.lying = !0 : g.standing = !0), this.animClips.push({
|
|
6443
6443
|
url: t + "-" + n,
|
|
6444
|
-
clip:
|
|
6444
|
+
clip: d,
|
|
6445
6445
|
pose: g
|
|
6446
6446
|
}), this.playAnimation(t, e, i, n, s);
|
|
6447
6447
|
} else {
|
|
6448
|
-
const
|
|
6449
|
-
console.error(
|
|
6448
|
+
const d = "Animation " + t + " (ndx=" + n + ") not found";
|
|
6449
|
+
console.error(d), l && l.animations ? console.error(`FBX file loaded but has ${l.animations.length} animation(s), requested index ${n}`) : console.error(l ? "FBX file loaded but contains no animations" : "FBX file failed to load or is invalid");
|
|
6450
6450
|
}
|
|
6451
6451
|
}
|
|
6452
6452
|
}
|
|
@@ -6484,10 +6484,10 @@ class we {
|
|
|
6484
6484
|
if (u && u.animations && u.animations[n]) {
|
|
6485
6485
|
let a = u.animations[n];
|
|
6486
6486
|
const h = {};
|
|
6487
|
-
a.tracks.forEach((
|
|
6488
|
-
|
|
6489
|
-
const
|
|
6490
|
-
|
|
6487
|
+
a.tracks.forEach((d) => {
|
|
6488
|
+
d.name = d.name.replaceAll("mixamorig", "");
|
|
6489
|
+
const c = d.name.split(".");
|
|
6490
|
+
c[1] === "position" ? h[d.name] = new f.Vector3(d.values[0] * s, d.values[1] * s, d.values[2] * s) : c[1] === "quaternion" ? h[d.name] = new f.Quaternion(d.values[0], d.values[1], d.values[2], d.values[3]) : c[1] === "rotation" && (h[c[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(d.values[0], d.values[1], d.values[2], "XYZ")).normalize());
|
|
6491
6491
|
});
|
|
6492
6492
|
const l = { props: h };
|
|
6493
6493
|
h["Hips.position"] && (h["Hips.position"].y < 0.5 ? l.lying = !0 : l.standing = !0), this.animPoses.push({
|
|
@@ -6532,13 +6532,13 @@ class we {
|
|
|
6532
6532
|
if (r.gesture = !0, e && Number.isFinite(e)) {
|
|
6533
6533
|
const u = r.ts[0], h = r.ts[r.ts.length - 1] - u;
|
|
6534
6534
|
if (e * 1e3 - h > 0) {
|
|
6535
|
-
const
|
|
6536
|
-
for (let y = 1; y < r.ts.length; y++)
|
|
6537
|
-
const
|
|
6538
|
-
r.ts = r.ts.map((y, x,
|
|
6535
|
+
const d = [];
|
|
6536
|
+
for (let y = 1; y < r.ts.length; y++) d.push(r.ts[y] - r.ts[y - 1]);
|
|
6537
|
+
const c = o.template?.rescale || d.map((y) => y / h), g = e * 1e3 - h;
|
|
6538
|
+
r.ts = r.ts.map((y, x, L) => x === 0 ? u : L[x - 1] + d[x - 1] + c[x - 1] * g);
|
|
6539
6539
|
} else {
|
|
6540
|
-
const
|
|
6541
|
-
r.ts = r.ts.map((
|
|
6540
|
+
const d = e * 1e3 / h;
|
|
6541
|
+
r.ts = r.ts.map((c) => u + d * (c - u));
|
|
6542
6542
|
}
|
|
6543
6543
|
}
|
|
6544
6544
|
this.animQueue.push(r);
|
|
@@ -6568,21 +6568,21 @@ class we {
|
|
|
6568
6568
|
* @param {numeric} [d=null] If set, apply in d milliseconds
|
|
6569
6569
|
*/
|
|
6570
6570
|
ikSolve(t, e = null, i = !1, n = null) {
|
|
6571
|
-
const s = new f.Vector3(), o = new f.Vector3(), r = new f.Vector3(), u = new f.Vector3(), a = new f.Quaternion(), h = new f.Vector3(), l = new f.Vector3(),
|
|
6572
|
-
|
|
6571
|
+
const s = new f.Vector3(), o = new f.Vector3(), r = new f.Vector3(), u = new f.Vector3(), a = new f.Quaternion(), h = new f.Vector3(), l = new f.Vector3(), d = new f.Vector3(), c = this.ikMesh.getObjectByName(t.root);
|
|
6572
|
+
c.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), c.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && i && e.applyQuaternion(this.armature.quaternion).add(c.position);
|
|
6573
6573
|
const g = this.ikMesh.getObjectByName(t.effector), y = t.links;
|
|
6574
|
-
y.forEach((
|
|
6575
|
-
|
|
6576
|
-
}),
|
|
6574
|
+
y.forEach((L) => {
|
|
6575
|
+
L.bone = this.ikMesh.getObjectByName(L.link), L.bone.quaternion.copy(this.getPoseTemplateProp(L.link + ".quaternion"));
|
|
6576
|
+
}), c.updateMatrixWorld(!0);
|
|
6577
6577
|
const x = t.iterations || 10;
|
|
6578
6578
|
if (e)
|
|
6579
|
-
for (let
|
|
6579
|
+
for (let L = 0; L < x; L++) {
|
|
6580
6580
|
let F = !1;
|
|
6581
6581
|
for (let p = 0, z = y.length; p < z; p++) {
|
|
6582
6582
|
const C = y[p].bone;
|
|
6583
6583
|
C.matrixWorld.decompose(u, a, h), a.invert(), o.setFromMatrixPosition(g.matrixWorld), r.subVectors(o, u), r.applyQuaternion(a), r.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
|
|
6584
|
-
let
|
|
6585
|
-
|
|
6584
|
+
let I = s.dot(r);
|
|
6585
|
+
I > 1 ? I = 1 : I < -1 && (I = -1), I = Math.acos(I), !(I < 1e-5) && (y[p].minAngle !== void 0 && I < y[p].minAngle && (I = y[p].minAngle), y[p].maxAngle !== void 0 && I > y[p].maxAngle && (I = y[p].maxAngle), l.crossVectors(r, s), l.normalize(), U.setFromAxisAngle(l, I), C.quaternion.multiply(U), C.rotation.setFromVector3(d.setFromEuler(C.rotation).clamp(new f.Vector3(
|
|
6586
6586
|
y[p].minx !== void 0 ? y[p].minx : -1 / 0,
|
|
6587
6587
|
y[p].miny !== void 0 ? y[p].miny : -1 / 0,
|
|
6588
6588
|
y[p].minz !== void 0 ? y[p].minz : -1 / 0
|
|
@@ -6594,8 +6594,8 @@ class we {
|
|
|
6594
6594
|
}
|
|
6595
6595
|
if (!F) break;
|
|
6596
6596
|
}
|
|
6597
|
-
n && y.forEach((
|
|
6598
|
-
this.poseTarget.props[
|
|
6597
|
+
n && y.forEach((L) => {
|
|
6598
|
+
this.poseTarget.props[L.link + ".quaternion"].copy(L.bone.quaternion), this.poseTarget.props[L.link + ".quaternion"].t = this.animClock, this.poseTarget.props[L.link + ".quaternion"].d = n;
|
|
6599
6599
|
});
|
|
6600
6600
|
}
|
|
6601
6601
|
/**
|
|
@@ -6605,7 +6605,7 @@ class we {
|
|
|
6605
6605
|
this.isRunning = !1, this.stop(), this.stopSpeaking(), this.streamStop(), this.isAvatarOnly ? this.armature && (this.armature.parent && this.armature.parent.remove(this.armature), this.clearThree(this.armature)) : (this.clearThree(this.scene), this.resizeobserver.disconnect(), this.renderer && (this.renderer.dispose(), this.renderer.domElement && this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement), this.renderer = null)), this.clearThree(this.ikMesh), this.dynamicbones.dispose();
|
|
6606
6606
|
}
|
|
6607
6607
|
}
|
|
6608
|
-
const
|
|
6608
|
+
const ae = {
|
|
6609
6609
|
apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
|
|
6610
6610
|
// Replace with your actual API key (should start with sk_)
|
|
6611
6611
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
@@ -6645,17 +6645,17 @@ const le = {
|
|
|
6645
6645
|
// Male, English - Powerful
|
|
6646
6646
|
}
|
|
6647
6647
|
};
|
|
6648
|
-
function
|
|
6648
|
+
function be() {
|
|
6649
6649
|
return {
|
|
6650
6650
|
service: "elevenlabs",
|
|
6651
|
-
endpoint:
|
|
6652
|
-
apiKey:
|
|
6653
|
-
defaultVoice:
|
|
6654
|
-
voices:
|
|
6651
|
+
endpoint: ae.endpoint,
|
|
6652
|
+
apiKey: ae.apiKey,
|
|
6653
|
+
defaultVoice: ae.defaultVoice,
|
|
6654
|
+
voices: ae.voices
|
|
6655
6655
|
};
|
|
6656
6656
|
}
|
|
6657
6657
|
function mt() {
|
|
6658
|
-
const N =
|
|
6658
|
+
const N = be(), t = [];
|
|
6659
6659
|
return Object.entries(N.voices).forEach(([e, i]) => {
|
|
6660
6660
|
t.push({
|
|
6661
6661
|
value: i,
|
|
@@ -6663,7 +6663,7 @@ function mt() {
|
|
|
6663
6663
|
});
|
|
6664
6664
|
}), t;
|
|
6665
6665
|
}
|
|
6666
|
-
const ze =
|
|
6666
|
+
const ze = fe(({
|
|
6667
6667
|
avatarUrl: N = "/avatars/brunette.glb",
|
|
6668
6668
|
avatarBody: t = "F",
|
|
6669
6669
|
mood: e = "neutral",
|
|
@@ -6677,19 +6677,19 @@ const ze = ye(({
|
|
|
6677
6677
|
cameraView: h = "upper",
|
|
6678
6678
|
onReady: l = () => {
|
|
6679
6679
|
},
|
|
6680
|
-
onLoading:
|
|
6680
|
+
onLoading: d = () => {
|
|
6681
6681
|
},
|
|
6682
|
-
onError:
|
|
6682
|
+
onError: c = () => {
|
|
6683
6683
|
},
|
|
6684
6684
|
className: g = "",
|
|
6685
6685
|
style: y = {},
|
|
6686
6686
|
animations: x = {}
|
|
6687
|
-
},
|
|
6688
|
-
const F =
|
|
6689
|
-
|
|
6687
|
+
}, L) => {
|
|
6688
|
+
const F = V(null), p = V(null), z = V(a), [C, I] = re(!0), [B, D] = re(null), [X, oe] = re(!1);
|
|
6689
|
+
le(() => {
|
|
6690
6690
|
z.current = a;
|
|
6691
6691
|
}, [a]);
|
|
6692
|
-
const S =
|
|
6692
|
+
const S = be(), P = n || S.service;
|
|
6693
6693
|
let O;
|
|
6694
6694
|
P === "browser" ? O = {
|
|
6695
6695
|
service: "browser",
|
|
@@ -6700,8 +6700,8 @@ const ze = ye(({
|
|
|
6700
6700
|
service: "elevenlabs",
|
|
6701
6701
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
6702
6702
|
apiKey: o || S.apiKey,
|
|
6703
|
-
defaultVoice: s || S.defaultVoice ||
|
|
6704
|
-
voices: S.voices ||
|
|
6703
|
+
defaultVoice: s || S.defaultVoice || ae.defaultVoice,
|
|
6704
|
+
voices: S.voices || ae.voices
|
|
6705
6705
|
} : P === "deepgram" ? O = {
|
|
6706
6706
|
service: "deepgram",
|
|
6707
6707
|
endpoint: "https://api.deepgram.com/v1/speak",
|
|
@@ -6713,7 +6713,7 @@ const ze = ye(({
|
|
|
6713
6713
|
// Override API key if provided via props
|
|
6714
6714
|
apiKey: o !== null ? o : S.apiKey
|
|
6715
6715
|
};
|
|
6716
|
-
const
|
|
6716
|
+
const W = {
|
|
6717
6717
|
url: N,
|
|
6718
6718
|
body: t,
|
|
6719
6719
|
avatarMood: e,
|
|
@@ -6723,84 +6723,84 @@ const ze = ye(({
|
|
|
6723
6723
|
showFullAvatar: a,
|
|
6724
6724
|
bodyMovement: r,
|
|
6725
6725
|
movementIntensity: u
|
|
6726
|
-
},
|
|
6726
|
+
}, _ = {
|
|
6727
6727
|
ttsEndpoint: O.endpoint,
|
|
6728
6728
|
ttsApikey: O.apiKey,
|
|
6729
6729
|
ttsService: P,
|
|
6730
6730
|
lipsyncModules: ["en"],
|
|
6731
6731
|
cameraView: h
|
|
6732
|
-
},
|
|
6732
|
+
}, K = M(async () => {
|
|
6733
6733
|
if (!(!F.current || p.current))
|
|
6734
6734
|
try {
|
|
6735
|
-
if (
|
|
6736
|
-
if (
|
|
6737
|
-
const T = Math.min(100, Math.round(
|
|
6738
|
-
|
|
6735
|
+
if (I(!0), D(null), p.current = new we(F.current, _), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(W, (H) => {
|
|
6736
|
+
if (H.lengthComputable) {
|
|
6737
|
+
const T = Math.min(100, Math.round(H.loaded / H.total * 100));
|
|
6738
|
+
d(T);
|
|
6739
6739
|
}
|
|
6740
|
-
}), await new Promise((
|
|
6740
|
+
}), await new Promise((H) => {
|
|
6741
6741
|
const T = () => {
|
|
6742
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ?
|
|
6742
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? H() : setTimeout(T, 100);
|
|
6743
6743
|
};
|
|
6744
6744
|
T();
|
|
6745
6745
|
}), p.current && p.current.setShowFullAvatar)
|
|
6746
6746
|
try {
|
|
6747
6747
|
p.current.setShowFullAvatar(a);
|
|
6748
|
-
} catch (
|
|
6749
|
-
console.warn("Error setting full body mode on initialization:",
|
|
6748
|
+
} catch (H) {
|
|
6749
|
+
console.warn("Error setting full body mode on initialization:", H);
|
|
6750
6750
|
}
|
|
6751
|
-
p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()),
|
|
6752
|
-
const
|
|
6751
|
+
p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), I(!1), oe(!0), l(p.current);
|
|
6752
|
+
const k = () => {
|
|
6753
6753
|
document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
|
|
6754
6754
|
};
|
|
6755
|
-
return document.addEventListener("visibilitychange",
|
|
6756
|
-
document.removeEventListener("visibilitychange",
|
|
6755
|
+
return document.addEventListener("visibilitychange", k), () => {
|
|
6756
|
+
document.removeEventListener("visibilitychange", k);
|
|
6757
6757
|
};
|
|
6758
|
-
} catch (
|
|
6759
|
-
console.error("Error initializing TalkingHead:",
|
|
6758
|
+
} catch (R) {
|
|
6759
|
+
console.error("Error initializing TalkingHead:", R), D(R.message || "Failed to initialize avatar"), I(!1), c(R);
|
|
6760
6760
|
}
|
|
6761
6761
|
}, [N, t, e, i, n, s, o, a, r, u, h]);
|
|
6762
|
-
|
|
6762
|
+
le(() => (K(), () => {
|
|
6763
6763
|
p.current && (p.current.stop(), p.current.dispose(), p.current = null);
|
|
6764
|
-
}), [
|
|
6764
|
+
}), [K]), le(() => {
|
|
6765
6765
|
if (!F.current || !p.current) return;
|
|
6766
|
-
const
|
|
6767
|
-
for (const T of
|
|
6766
|
+
const R = new ResizeObserver((H) => {
|
|
6767
|
+
for (const T of H)
|
|
6768
6768
|
p.current && p.current.onResize && p.current.onResize();
|
|
6769
6769
|
});
|
|
6770
|
-
|
|
6771
|
-
const
|
|
6770
|
+
R.observe(F.current);
|
|
6771
|
+
const k = () => {
|
|
6772
6772
|
p.current && p.current.onResize && p.current.onResize();
|
|
6773
6773
|
};
|
|
6774
|
-
return window.addEventListener("resize",
|
|
6775
|
-
|
|
6774
|
+
return window.addEventListener("resize", k), () => {
|
|
6775
|
+
R.disconnect(), window.removeEventListener("resize", k);
|
|
6776
6776
|
};
|
|
6777
|
-
}, [
|
|
6778
|
-
const
|
|
6777
|
+
}, [X]);
|
|
6778
|
+
const se = M(async () => {
|
|
6779
6779
|
if (p.current && p.current.audioCtx)
|
|
6780
6780
|
try {
|
|
6781
6781
|
(p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
|
|
6782
|
-
} catch (
|
|
6783
|
-
console.warn("Failed to resume audio context:",
|
|
6782
|
+
} catch (R) {
|
|
6783
|
+
console.warn("Failed to resume audio context:", R);
|
|
6784
6784
|
}
|
|
6785
|
-
}, []),
|
|
6786
|
-
if (p.current &&
|
|
6785
|
+
}, []), pe = M(async (R, k = {}) => {
|
|
6786
|
+
if (p.current && X)
|
|
6787
6787
|
try {
|
|
6788
|
-
await
|
|
6789
|
-
const
|
|
6790
|
-
...
|
|
6791
|
-
lipsyncLang:
|
|
6788
|
+
await se();
|
|
6789
|
+
const H = {
|
|
6790
|
+
...k,
|
|
6791
|
+
lipsyncLang: k.lipsyncLang || W.lipsyncLang || "en"
|
|
6792
6792
|
};
|
|
6793
|
-
if (
|
|
6793
|
+
if (k.onSpeechEnd && p.current) {
|
|
6794
6794
|
const T = p.current;
|
|
6795
|
-
let
|
|
6796
|
-
const
|
|
6797
|
-
let
|
|
6798
|
-
|
|
6799
|
-
if (
|
|
6800
|
-
if (
|
|
6801
|
-
|
|
6795
|
+
let Y = null, te = 0;
|
|
6796
|
+
const ye = 1200;
|
|
6797
|
+
let he = !1;
|
|
6798
|
+
Y = setInterval(() => {
|
|
6799
|
+
if (te++, te > ye) {
|
|
6800
|
+
if (Y && (clearInterval(Y), Y = null), !he) {
|
|
6801
|
+
he = !0;
|
|
6802
6802
|
try {
|
|
6803
|
-
|
|
6803
|
+
k.onSpeechEnd();
|
|
6804
6804
|
} catch (Re) {
|
|
6805
6805
|
console.error("Error in onSpeechEnd callback (timeout):", Re);
|
|
6806
6806
|
}
|
|
@@ -6808,11 +6808,11 @@ const ze = ye(({
|
|
|
6808
6808
|
return;
|
|
6809
6809
|
}
|
|
6810
6810
|
const He = !T.speechQueue || T.speechQueue.length === 0, Te = !T.audioPlaylist || T.audioPlaylist.length === 0;
|
|
6811
|
-
T && T.isSpeaking === !1 && He && Te && T.isAudioPlaying === !1 && !
|
|
6812
|
-
if (T && T.isSpeaking === !1 && (!T.speechQueue || T.speechQueue.length === 0) && (!T.audioPlaylist || T.audioPlaylist.length === 0) && T.isAudioPlaying === !1 && !
|
|
6813
|
-
|
|
6811
|
+
T && T.isSpeaking === !1 && He && Te && T.isAudioPlaying === !1 && !he && setTimeout(() => {
|
|
6812
|
+
if (T && T.isSpeaking === !1 && (!T.speechQueue || T.speechQueue.length === 0) && (!T.audioPlaylist || T.audioPlaylist.length === 0) && T.isAudioPlaying === !1 && !he) {
|
|
6813
|
+
he = !0, Y && (clearInterval(Y), Y = null);
|
|
6814
6814
|
try {
|
|
6815
|
-
|
|
6815
|
+
k.onSpeechEnd();
|
|
6816
6816
|
} catch (Me) {
|
|
6817
6817
|
console.error("Error in onSpeechEnd callback:", Me);
|
|
6818
6818
|
}
|
|
@@ -6820,124 +6820,124 @@ const ze = ye(({
|
|
|
6820
6820
|
}, 100);
|
|
6821
6821
|
}, 100);
|
|
6822
6822
|
}
|
|
6823
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(
|
|
6824
|
-
await
|
|
6823
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(R, H)) : setTimeout(async () => {
|
|
6824
|
+
await se(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(R, H));
|
|
6825
6825
|
}, 100);
|
|
6826
|
-
} catch (
|
|
6827
|
-
console.error("Error speaking text:",
|
|
6826
|
+
} catch (H) {
|
|
6827
|
+
console.error("Error speaking text:", H), D(H.message || "Failed to speak text");
|
|
6828
6828
|
}
|
|
6829
|
-
}, [
|
|
6829
|
+
}, [X, se, W.lipsyncLang]), ue = M(() => {
|
|
6830
6830
|
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1));
|
|
6831
|
-
}, []),
|
|
6832
|
-
p.current && p.current.setMood(
|
|
6833
|
-
}, []),
|
|
6834
|
-
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(
|
|
6835
|
-
}, []),
|
|
6831
|
+
}, []), ge = M((R) => {
|
|
6832
|
+
p.current && p.current.setMood(R);
|
|
6833
|
+
}, []), Q = M((R) => {
|
|
6834
|
+
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(R);
|
|
6835
|
+
}, []), b = M((R, k = !1) => {
|
|
6836
6836
|
if (p.current && p.current.playAnimation) {
|
|
6837
|
-
if (x && x[
|
|
6837
|
+
if (x && x[R] && (R = x[R]), p.current.setShowFullAvatar)
|
|
6838
6838
|
try {
|
|
6839
6839
|
p.current.setShowFullAvatar(z.current);
|
|
6840
6840
|
} catch (T) {
|
|
6841
6841
|
console.warn("Error setting full body mode:", T);
|
|
6842
6842
|
}
|
|
6843
|
-
if (
|
|
6843
|
+
if (R.includes("."))
|
|
6844
6844
|
try {
|
|
6845
|
-
p.current.playAnimation(
|
|
6845
|
+
p.current.playAnimation(R, null, 10, 0, 0.01, k);
|
|
6846
6846
|
} catch (T) {
|
|
6847
|
-
console.warn(`Failed to play ${
|
|
6847
|
+
console.warn(`Failed to play ${R}:`, T);
|
|
6848
6848
|
try {
|
|
6849
6849
|
p.current.setBodyMovement("idle");
|
|
6850
|
-
} catch (
|
|
6851
|
-
console.warn("Fallback animation also failed:",
|
|
6850
|
+
} catch (Y) {
|
|
6851
|
+
console.warn("Fallback animation also failed:", Y);
|
|
6852
6852
|
}
|
|
6853
6853
|
}
|
|
6854
6854
|
else {
|
|
6855
6855
|
const T = [".fbx", ".glb", ".gltf"];
|
|
6856
|
-
let
|
|
6857
|
-
for (const
|
|
6856
|
+
let Y = !1;
|
|
6857
|
+
for (const te of T)
|
|
6858
6858
|
try {
|
|
6859
|
-
p.current.playAnimation(
|
|
6859
|
+
p.current.playAnimation(R + te, null, 10, 0, 0.01, k), Y = !0;
|
|
6860
6860
|
break;
|
|
6861
6861
|
} catch {
|
|
6862
6862
|
}
|
|
6863
|
-
if (!
|
|
6864
|
-
console.warn("Animation not found:",
|
|
6863
|
+
if (!Y) {
|
|
6864
|
+
console.warn("Animation not found:", R);
|
|
6865
6865
|
try {
|
|
6866
6866
|
p.current.setBodyMovement("idle");
|
|
6867
|
-
} catch (
|
|
6868
|
-
console.warn("Fallback animation also failed:",
|
|
6867
|
+
} catch (te) {
|
|
6868
|
+
console.warn("Fallback animation also failed:", te);
|
|
6869
6869
|
}
|
|
6870
6870
|
}
|
|
6871
6871
|
}
|
|
6872
6872
|
}
|
|
6873
|
-
}, [x]),
|
|
6873
|
+
}, [x]), v = M(() => {
|
|
6874
6874
|
p.current && p.current.onResize && p.current.onResize();
|
|
6875
6875
|
}, []);
|
|
6876
|
-
return
|
|
6877
|
-
speakText:
|
|
6878
|
-
stopSpeaking:
|
|
6879
|
-
resumeAudioContext:
|
|
6880
|
-
setMood:
|
|
6881
|
-
setTimingAdjustment:
|
|
6882
|
-
playAnimation:
|
|
6883
|
-
isReady:
|
|
6876
|
+
return xe(L, () => ({
|
|
6877
|
+
speakText: pe,
|
|
6878
|
+
stopSpeaking: ue,
|
|
6879
|
+
resumeAudioContext: se,
|
|
6880
|
+
setMood: ge,
|
|
6881
|
+
setTimingAdjustment: Q,
|
|
6882
|
+
playAnimation: b,
|
|
6883
|
+
isReady: X,
|
|
6884
6884
|
talkingHead: p.current,
|
|
6885
|
-
handleResize:
|
|
6886
|
-
setBodyMovement: (
|
|
6885
|
+
handleResize: v,
|
|
6886
|
+
setBodyMovement: (R) => {
|
|
6887
6887
|
if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
|
|
6888
6888
|
try {
|
|
6889
|
-
p.current.setShowFullAvatar(z.current), p.current.setBodyMovement(
|
|
6890
|
-
} catch (
|
|
6891
|
-
console.warn("Error setting body movement:",
|
|
6889
|
+
p.current.setShowFullAvatar(z.current), p.current.setBodyMovement(R);
|
|
6890
|
+
} catch (k) {
|
|
6891
|
+
console.warn("Error setting body movement:", k);
|
|
6892
6892
|
}
|
|
6893
6893
|
},
|
|
6894
|
-
setMovementIntensity: (
|
|
6894
|
+
setMovementIntensity: (R) => p.current?.setMovementIntensity(R),
|
|
6895
6895
|
playRandomDance: () => {
|
|
6896
6896
|
if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
|
|
6897
6897
|
try {
|
|
6898
6898
|
p.current.setShowFullAvatar(z.current), p.current.playRandomDance();
|
|
6899
|
-
} catch (
|
|
6900
|
-
console.warn("Error playing random dance:",
|
|
6899
|
+
} catch (R) {
|
|
6900
|
+
console.warn("Error playing random dance:", R);
|
|
6901
6901
|
}
|
|
6902
6902
|
},
|
|
6903
|
-
playReaction: (
|
|
6903
|
+
playReaction: (R) => {
|
|
6904
6904
|
if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
|
|
6905
6905
|
try {
|
|
6906
|
-
p.current.setShowFullAvatar(z.current), p.current.playReaction(
|
|
6907
|
-
} catch (
|
|
6908
|
-
console.warn("Error playing reaction:",
|
|
6906
|
+
p.current.setShowFullAvatar(z.current), p.current.playReaction(R);
|
|
6907
|
+
} catch (k) {
|
|
6908
|
+
console.warn("Error playing reaction:", k);
|
|
6909
6909
|
}
|
|
6910
6910
|
},
|
|
6911
6911
|
playCelebration: () => {
|
|
6912
6912
|
if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
|
|
6913
6913
|
try {
|
|
6914
6914
|
p.current.setShowFullAvatar(z.current), p.current.playCelebration();
|
|
6915
|
-
} catch (
|
|
6916
|
-
console.warn("Error playing celebration:",
|
|
6915
|
+
} catch (R) {
|
|
6916
|
+
console.warn("Error playing celebration:", R);
|
|
6917
6917
|
}
|
|
6918
6918
|
},
|
|
6919
|
-
setShowFullAvatar: (
|
|
6919
|
+
setShowFullAvatar: (R) => {
|
|
6920
6920
|
if (p.current && p.current.setShowFullAvatar)
|
|
6921
6921
|
try {
|
|
6922
|
-
z.current =
|
|
6923
|
-
} catch (
|
|
6924
|
-
console.warn("Error setting showFullAvatar:",
|
|
6922
|
+
z.current = R, p.current.setShowFullAvatar(R);
|
|
6923
|
+
} catch (k) {
|
|
6924
|
+
console.warn("Error setting showFullAvatar:", k);
|
|
6925
6925
|
}
|
|
6926
6926
|
},
|
|
6927
6927
|
lockAvatarPosition: () => {
|
|
6928
6928
|
if (p.current && p.current.lockAvatarPosition)
|
|
6929
6929
|
try {
|
|
6930
6930
|
p.current.lockAvatarPosition();
|
|
6931
|
-
} catch (
|
|
6932
|
-
console.warn("Error locking avatar position:",
|
|
6931
|
+
} catch (R) {
|
|
6932
|
+
console.warn("Error locking avatar position:", R);
|
|
6933
6933
|
}
|
|
6934
6934
|
},
|
|
6935
6935
|
unlockAvatarPosition: () => {
|
|
6936
6936
|
if (p.current && p.current.unlockAvatarPosition)
|
|
6937
6937
|
try {
|
|
6938
6938
|
p.current.unlockAvatarPosition();
|
|
6939
|
-
} catch (
|
|
6940
|
-
console.warn("Error unlocking avatar position:",
|
|
6939
|
+
} catch (R) {
|
|
6940
|
+
console.warn("Error unlocking avatar position:", R);
|
|
6941
6941
|
}
|
|
6942
6942
|
}
|
|
6943
6943
|
})), /* @__PURE__ */ ke(
|
|
@@ -6951,7 +6951,7 @@ const ze = ye(({
|
|
|
6951
6951
|
...y
|
|
6952
6952
|
},
|
|
6953
6953
|
children: [
|
|
6954
|
-
/* @__PURE__ */
|
|
6954
|
+
/* @__PURE__ */ ne(
|
|
6955
6955
|
"div",
|
|
6956
6956
|
{
|
|
6957
6957
|
ref: F,
|
|
@@ -6963,7 +6963,7 @@ const ze = ye(({
|
|
|
6963
6963
|
}
|
|
6964
6964
|
}
|
|
6965
6965
|
),
|
|
6966
|
-
C && /* @__PURE__ */
|
|
6966
|
+
C && /* @__PURE__ */ ne("div", { className: "loading-overlay", style: {
|
|
6967
6967
|
position: "absolute",
|
|
6968
6968
|
top: "50%",
|
|
6969
6969
|
left: "50%",
|
|
@@ -6972,7 +6972,7 @@ const ze = ye(({
|
|
|
6972
6972
|
fontSize: "18px",
|
|
6973
6973
|
zIndex: 10
|
|
6974
6974
|
}, children: "Loading avatar..." }),
|
|
6975
|
-
|
|
6975
|
+
B && /* @__PURE__ */ ne("div", { className: "error-overlay", style: {
|
|
6976
6976
|
position: "absolute",
|
|
6977
6977
|
top: "50%",
|
|
6978
6978
|
left: "50%",
|
|
@@ -6983,13 +6983,13 @@ const ze = ye(({
|
|
|
6983
6983
|
zIndex: 10,
|
|
6984
6984
|
padding: "20px",
|
|
6985
6985
|
borderRadius: "8px"
|
|
6986
|
-
}, children:
|
|
6986
|
+
}, children: B })
|
|
6987
6987
|
]
|
|
6988
6988
|
}
|
|
6989
6989
|
);
|
|
6990
6990
|
});
|
|
6991
6991
|
ze.displayName = "TalkingHeadAvatar";
|
|
6992
|
-
const it =
|
|
6992
|
+
const it = fe(({
|
|
6993
6993
|
text: N = "Hello! I'm a talking avatar. How are you today?",
|
|
6994
6994
|
onLoading: t = () => {
|
|
6995
6995
|
},
|
|
@@ -7001,7 +7001,7 @@ const it = ye(({
|
|
|
7001
7001
|
style: s = {},
|
|
7002
7002
|
avatarConfig: o = {}
|
|
7003
7003
|
}, r) => {
|
|
7004
|
-
const u =
|
|
7004
|
+
const u = V(null), a = V(null), [h, l] = re(!0), [d, c] = re(null), [g, y] = re(!1), x = be(), L = o.ttsService || x.service, F = L === "browser" ? {
|
|
7005
7005
|
endpoint: "",
|
|
7006
7006
|
apiKey: null,
|
|
7007
7007
|
defaultVoice: "Google US English"
|
|
@@ -7010,13 +7010,13 @@ const it = ye(({
|
|
|
7010
7010
|
// Override API key if provided via avatarConfig
|
|
7011
7011
|
apiKey: o.ttsApiKey !== void 0 && o.ttsApiKey !== null ? o.ttsApiKey : x.apiKey,
|
|
7012
7012
|
// Override endpoint for ElevenLabs if service is explicitly set
|
|
7013
|
-
endpoint:
|
|
7013
|
+
endpoint: L === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : x.endpoint
|
|
7014
7014
|
}, p = {
|
|
7015
7015
|
url: "/avatars/brunette.glb",
|
|
7016
7016
|
// Use brunette avatar (working glTF file)
|
|
7017
7017
|
body: "F",
|
|
7018
7018
|
avatarMood: "neutral",
|
|
7019
|
-
ttsLang:
|
|
7019
|
+
ttsLang: L === "browser" ? "en-US" : "en",
|
|
7020
7020
|
ttsVoice: o.ttsVoice || F.defaultVoice,
|
|
7021
7021
|
lipsyncLang: "en",
|
|
7022
7022
|
// English lip-sync
|
|
@@ -7028,28 +7028,28 @@ const it = ye(({
|
|
|
7028
7028
|
}, z = {
|
|
7029
7029
|
ttsEndpoint: F.endpoint,
|
|
7030
7030
|
ttsApikey: F.apiKey,
|
|
7031
|
-
ttsService:
|
|
7031
|
+
ttsService: L,
|
|
7032
7032
|
lipsyncModules: ["en"],
|
|
7033
7033
|
cameraView: "upper"
|
|
7034
|
-
}, C =
|
|
7034
|
+
}, C = M(async () => {
|
|
7035
7035
|
if (!(!u.current || a.current))
|
|
7036
7036
|
try {
|
|
7037
|
-
if (l(!0),
|
|
7037
|
+
if (l(!0), c(null), a.current = new we(u.current, z), await a.current.showAvatar(p, (O) => {
|
|
7038
7038
|
if (O.lengthComputable) {
|
|
7039
|
-
const
|
|
7040
|
-
t(
|
|
7039
|
+
const W = Math.min(100, Math.round(O.loaded / O.total * 100));
|
|
7040
|
+
t(W);
|
|
7041
7041
|
}
|
|
7042
7042
|
}), a.current.morphs && a.current.morphs.length > 0) {
|
|
7043
7043
|
const O = a.current.morphs[0].morphTargetDictionary;
|
|
7044
7044
|
console.log("Available morph targets:", Object.keys(O));
|
|
7045
|
-
const
|
|
7046
|
-
console.log("Viseme morph targets found:",
|
|
7045
|
+
const W = Object.keys(O).filter((_) => _.startsWith("viseme_"));
|
|
7046
|
+
console.log("Viseme morph targets found:", W), W.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"));
|
|
7047
7047
|
}
|
|
7048
7048
|
if (await new Promise((O) => {
|
|
7049
|
-
const
|
|
7050
|
-
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), O()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(
|
|
7049
|
+
const W = () => {
|
|
7050
|
+
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), O()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(W, 100));
|
|
7051
7051
|
};
|
|
7052
|
-
|
|
7052
|
+
W();
|
|
7053
7053
|
}), a.current && a.current.setShowFullAvatar)
|
|
7054
7054
|
try {
|
|
7055
7055
|
a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
|
|
@@ -7064,76 +7064,76 @@ const it = ye(({
|
|
|
7064
7064
|
document.removeEventListener("visibilitychange", P);
|
|
7065
7065
|
};
|
|
7066
7066
|
} catch (S) {
|
|
7067
|
-
console.error("Error initializing TalkingHead:", S),
|
|
7067
|
+
console.error("Error initializing TalkingHead:", S), c(S.message || "Failed to initialize avatar"), l(!1), e(S);
|
|
7068
7068
|
}
|
|
7069
7069
|
}, []);
|
|
7070
|
-
|
|
7070
|
+
le(() => (C(), () => {
|
|
7071
7071
|
a.current && (a.current.stop(), a.current.dispose(), a.current = null);
|
|
7072
7072
|
}), [C]);
|
|
7073
|
-
const
|
|
7073
|
+
const I = M((S) => {
|
|
7074
7074
|
if (a.current && g)
|
|
7075
7075
|
try {
|
|
7076
7076
|
console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", a.current), a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
|
|
7077
7077
|
a.current && a.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
|
|
7078
7078
|
}, 500));
|
|
7079
7079
|
} catch (P) {
|
|
7080
|
-
console.error("Error speaking text:", P),
|
|
7080
|
+
console.error("Error speaking text:", P), c(P.message || "Failed to speak text");
|
|
7081
7081
|
}
|
|
7082
7082
|
else
|
|
7083
7083
|
console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
|
|
7084
|
-
}, [g, p]),
|
|
7084
|
+
}, [g, p]), B = M(() => {
|
|
7085
7085
|
a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
|
|
7086
|
-
}, []), D =
|
|
7086
|
+
}, []), D = M((S) => {
|
|
7087
7087
|
a.current && a.current.setMood(S);
|
|
7088
|
-
}, []),
|
|
7088
|
+
}, []), X = M((S) => {
|
|
7089
7089
|
a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
|
|
7090
|
-
}, []),
|
|
7090
|
+
}, []), oe = M((S, P = !1) => {
|
|
7091
7091
|
if (a.current && a.current.playAnimation) {
|
|
7092
7092
|
if (a.current.setShowFullAvatar)
|
|
7093
7093
|
try {
|
|
7094
7094
|
a.current.setShowFullAvatar(!0);
|
|
7095
|
-
} catch (
|
|
7096
|
-
console.warn("Error setting full body mode:",
|
|
7095
|
+
} catch (W) {
|
|
7096
|
+
console.warn("Error setting full body mode:", W);
|
|
7097
7097
|
}
|
|
7098
7098
|
if (S.includes("."))
|
|
7099
7099
|
try {
|
|
7100
7100
|
a.current.playAnimation(S, null, 10, 0, 0.01, P), console.log("Playing animation:", S);
|
|
7101
|
-
} catch (
|
|
7102
|
-
console.log(`Failed to play ${S}:`,
|
|
7101
|
+
} catch (W) {
|
|
7102
|
+
console.log(`Failed to play ${S}:`, W);
|
|
7103
7103
|
try {
|
|
7104
7104
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7105
|
-
} catch (
|
|
7106
|
-
console.warn("Fallback animation also failed:",
|
|
7105
|
+
} catch (_) {
|
|
7106
|
+
console.warn("Fallback animation also failed:", _);
|
|
7107
7107
|
}
|
|
7108
7108
|
}
|
|
7109
7109
|
else {
|
|
7110
|
-
const
|
|
7111
|
-
let
|
|
7112
|
-
for (const
|
|
7110
|
+
const W = [".fbx", ".glb", ".gltf"];
|
|
7111
|
+
let _ = !1;
|
|
7112
|
+
for (const K of W)
|
|
7113
7113
|
try {
|
|
7114
|
-
a.current.playAnimation(S +
|
|
7114
|
+
a.current.playAnimation(S + K, null, 10, 0, 0.01, P), console.log("Playing animation:", S + K), _ = !0;
|
|
7115
7115
|
break;
|
|
7116
7116
|
} catch {
|
|
7117
|
-
console.log(`Failed to play ${S}${
|
|
7117
|
+
console.log(`Failed to play ${S}${K}, trying next format...`);
|
|
7118
7118
|
}
|
|
7119
|
-
if (!
|
|
7119
|
+
if (!_) {
|
|
7120
7120
|
console.warn("Animation system not available or animation not found:", S);
|
|
7121
7121
|
try {
|
|
7122
7122
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7123
|
-
} catch (
|
|
7124
|
-
console.warn("Fallback animation also failed:",
|
|
7123
|
+
} catch (K) {
|
|
7124
|
+
console.warn("Fallback animation also failed:", K);
|
|
7125
7125
|
}
|
|
7126
7126
|
}
|
|
7127
7127
|
}
|
|
7128
7128
|
} else
|
|
7129
7129
|
console.warn("Animation system not available or animation not found:", S);
|
|
7130
7130
|
}, []);
|
|
7131
|
-
return
|
|
7132
|
-
speakText:
|
|
7133
|
-
stopSpeaking:
|
|
7131
|
+
return xe(r, () => ({
|
|
7132
|
+
speakText: I,
|
|
7133
|
+
stopSpeaking: B,
|
|
7134
7134
|
setMood: D,
|
|
7135
|
-
setTimingAdjustment:
|
|
7136
|
-
playAnimation:
|
|
7135
|
+
setTimingAdjustment: X,
|
|
7136
|
+
playAnimation: oe,
|
|
7137
7137
|
isReady: g,
|
|
7138
7138
|
talkingHead: a.current,
|
|
7139
7139
|
setBodyMovement: (S) => {
|
|
@@ -7194,7 +7194,7 @@ const it = ye(({
|
|
|
7194
7194
|
}
|
|
7195
7195
|
}
|
|
7196
7196
|
})), /* @__PURE__ */ ke("div", { className: `talking-head-container ${n}`, style: s, children: [
|
|
7197
|
-
/* @__PURE__ */
|
|
7197
|
+
/* @__PURE__ */ ne(
|
|
7198
7198
|
"div",
|
|
7199
7199
|
{
|
|
7200
7200
|
ref: u,
|
|
@@ -7206,7 +7206,7 @@ const it = ye(({
|
|
|
7206
7206
|
}
|
|
7207
7207
|
}
|
|
7208
7208
|
),
|
|
7209
|
-
h && /* @__PURE__ */
|
|
7209
|
+
h && /* @__PURE__ */ ne("div", { className: "loading-overlay", style: {
|
|
7210
7210
|
position: "absolute",
|
|
7211
7211
|
top: "50%",
|
|
7212
7212
|
left: "50%",
|
|
@@ -7215,7 +7215,7 @@ const it = ye(({
|
|
|
7215
7215
|
fontSize: "18px",
|
|
7216
7216
|
zIndex: 10
|
|
7217
7217
|
}, children: "Loading avatar..." }),
|
|
7218
|
-
|
|
7218
|
+
d && /* @__PURE__ */ ne("div", { className: "error-overlay", style: {
|
|
7219
7219
|
position: "absolute",
|
|
7220
7220
|
top: "50%",
|
|
7221
7221
|
left: "50%",
|
|
@@ -7226,11 +7226,11 @@ const it = ye(({
|
|
|
7226
7226
|
zIndex: 10,
|
|
7227
7227
|
padding: "20px",
|
|
7228
7228
|
borderRadius: "8px"
|
|
7229
|
-
}, children:
|
|
7229
|
+
}, children: d })
|
|
7230
7230
|
] });
|
|
7231
7231
|
});
|
|
7232
7232
|
it.displayName = "TalkingHeadComponent";
|
|
7233
|
-
const nt =
|
|
7233
|
+
const nt = fe(({
|
|
7234
7234
|
curriculumData: N = null,
|
|
7235
7235
|
avatarConfig: t = {},
|
|
7236
7236
|
animations: e = {},
|
|
@@ -7246,7 +7246,7 @@ const nt = ye(({
|
|
|
7246
7246
|
},
|
|
7247
7247
|
autoStart: u = !1
|
|
7248
7248
|
}, a) => {
|
|
7249
|
-
const h =
|
|
7249
|
+
const h = V(null), l = V({
|
|
7250
7250
|
currentModuleIndex: 0,
|
|
7251
7251
|
currentLessonIndex: 0,
|
|
7252
7252
|
currentQuestionIndex: 0,
|
|
@@ -7256,18 +7256,18 @@ const nt = ye(({
|
|
|
7256
7256
|
curriculumCompleted: !1,
|
|
7257
7257
|
score: 0,
|
|
7258
7258
|
totalQuestions: 0
|
|
7259
|
-
}),
|
|
7259
|
+
}), d = V({
|
|
7260
7260
|
onLessonStart: i,
|
|
7261
7261
|
onLessonComplete: n,
|
|
7262
7262
|
onQuestionAnswer: s,
|
|
7263
7263
|
onCurriculumComplete: o,
|
|
7264
7264
|
onCustomAction: r
|
|
7265
|
-
}),
|
|
7265
|
+
}), c = V(null), g = V(null), y = V(null), x = V(null), L = V(null), F = V(null), p = V(null), z = V(N?.curriculum || {
|
|
7266
7266
|
title: "Default Curriculum",
|
|
7267
7267
|
description: "No curriculum data provided",
|
|
7268
7268
|
language: "en",
|
|
7269
7269
|
modules: []
|
|
7270
|
-
}), C =
|
|
7270
|
+
}), C = V({
|
|
7271
7271
|
avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
|
|
7272
7272
|
avatarBody: t.avatarBody || "F",
|
|
7273
7273
|
mood: t.mood || "happy",
|
|
@@ -7281,15 +7281,15 @@ const nt = ye(({
|
|
|
7281
7281
|
animations: e,
|
|
7282
7282
|
lipsyncLang: "en"
|
|
7283
7283
|
});
|
|
7284
|
-
|
|
7285
|
-
|
|
7284
|
+
le(() => {
|
|
7285
|
+
d.current = {
|
|
7286
7286
|
onLessonStart: i,
|
|
7287
7287
|
onLessonComplete: n,
|
|
7288
7288
|
onQuestionAnswer: s,
|
|
7289
7289
|
onCurriculumComplete: o,
|
|
7290
7290
|
onCustomAction: r
|
|
7291
7291
|
};
|
|
7292
|
-
}, [i, n, s, o, r]),
|
|
7292
|
+
}, [i, n, s, o, r]), le(() => {
|
|
7293
7293
|
z.current = N?.curriculum || {
|
|
7294
7294
|
title: "Default Curriculum",
|
|
7295
7295
|
description: "No curriculum data provided",
|
|
@@ -7310,23 +7310,23 @@ const nt = ye(({
|
|
|
7310
7310
|
lipsyncLang: "en"
|
|
7311
7311
|
};
|
|
7312
7312
|
}, [N, t, e]);
|
|
7313
|
-
const
|
|
7313
|
+
const I = M(() => (z.current || { modules: [] }).modules[l.current.currentModuleIndex]?.lessons[l.current.currentLessonIndex], []), B = M(() => I()?.questions[l.current.currentQuestionIndex], [I]), D = M((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), X = M(() => {
|
|
7314
7314
|
l.current.lessonCompleted = !0, l.current.isQuestionMode = !1;
|
|
7315
|
-
const
|
|
7316
|
-
let
|
|
7317
|
-
if (l.current.totalQuestions > 0 ?
|
|
7315
|
+
const b = l.current.totalQuestions > 0 ? Math.round(l.current.score / l.current.totalQuestions * 100) : 100;
|
|
7316
|
+
let v = "Congratulations! You've completed this lesson";
|
|
7317
|
+
if (l.current.totalQuestions > 0 ? v += ` with a score of ${l.current.score} out of ${l.current.totalQuestions} (${b}%). ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", d.current.onLessonComplete({
|
|
7318
7318
|
moduleIndex: l.current.currentModuleIndex,
|
|
7319
7319
|
lessonIndex: l.current.currentLessonIndex,
|
|
7320
7320
|
score: l.current.score,
|
|
7321
7321
|
totalQuestions: l.current.totalQuestions,
|
|
7322
|
-
percentage:
|
|
7323
|
-
}),
|
|
7322
|
+
percentage: b
|
|
7323
|
+
}), d.current.onCustomAction({
|
|
7324
7324
|
type: "lessonComplete",
|
|
7325
7325
|
moduleIndex: l.current.currentModuleIndex,
|
|
7326
7326
|
lessonIndex: l.current.currentLessonIndex,
|
|
7327
7327
|
score: l.current.score,
|
|
7328
7328
|
totalQuestions: l.current.totalQuestions,
|
|
7329
|
-
percentage:
|
|
7329
|
+
percentage: b
|
|
7330
7330
|
}), h.current) {
|
|
7331
7331
|
if (h.current.setMood("happy"), e.lessonComplete)
|
|
7332
7332
|
try {
|
|
@@ -7334,28 +7334,28 @@ const nt = ye(({
|
|
|
7334
7334
|
} catch {
|
|
7335
7335
|
h.current.playCelebration();
|
|
7336
7336
|
}
|
|
7337
|
-
const
|
|
7338
|
-
h.current.speakText(
|
|
7339
|
-
lipsyncLang:
|
|
7337
|
+
const R = z.current || { modules: [] }, k = R.modules[l.current.currentModuleIndex], H = l.current.currentLessonIndex < (k?.lessons?.length || 0) - 1, T = l.current.currentModuleIndex < (R.modules?.length || 0) - 1, Y = H || T, te = C.current || { lipsyncLang: "en" };
|
|
7338
|
+
h.current.speakText(v, {
|
|
7339
|
+
lipsyncLang: te.lipsyncLang,
|
|
7340
7340
|
onSpeechEnd: () => {
|
|
7341
|
-
|
|
7341
|
+
d.current.onCustomAction({
|
|
7342
7342
|
type: "lessonCompleteFeedbackDone",
|
|
7343
7343
|
moduleIndex: l.current.currentModuleIndex,
|
|
7344
7344
|
lessonIndex: l.current.currentLessonIndex,
|
|
7345
7345
|
score: l.current.score,
|
|
7346
7346
|
totalQuestions: l.current.totalQuestions,
|
|
7347
|
-
percentage:
|
|
7348
|
-
hasNextLesson:
|
|
7347
|
+
percentage: b,
|
|
7348
|
+
hasNextLesson: Y
|
|
7349
7349
|
});
|
|
7350
7350
|
}
|
|
7351
7351
|
});
|
|
7352
7352
|
}
|
|
7353
|
-
}, [e.lessonComplete]),
|
|
7353
|
+
}, [e.lessonComplete]), oe = M(() => {
|
|
7354
7354
|
l.current.curriculumCompleted = !0;
|
|
7355
|
-
const
|
|
7356
|
-
if (
|
|
7357
|
-
modules:
|
|
7358
|
-
totalLessons:
|
|
7355
|
+
const b = z.current || { modules: [] };
|
|
7356
|
+
if (d.current.onCurriculumComplete({
|
|
7357
|
+
modules: b.modules.length,
|
|
7358
|
+
totalLessons: b.modules.reduce((v, R) => v + R.lessons.length, 0)
|
|
7359
7359
|
}), h.current) {
|
|
7360
7360
|
if (h.current.setMood("celebrating"), e.curriculumComplete)
|
|
7361
7361
|
try {
|
|
@@ -7363,166 +7363,166 @@ const nt = ye(({
|
|
|
7363
7363
|
} catch {
|
|
7364
7364
|
h.current.playCelebration();
|
|
7365
7365
|
}
|
|
7366
|
-
const
|
|
7367
|
-
h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang:
|
|
7366
|
+
const v = C.current || { lipsyncLang: "en" };
|
|
7367
|
+
h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: v.lipsyncLang });
|
|
7368
7368
|
}
|
|
7369
|
-
}, [e.curriculumComplete]), S =
|
|
7370
|
-
const
|
|
7371
|
-
l.current.isQuestionMode = !0, l.current.currentQuestionIndex = 0, l.current.totalQuestions =
|
|
7372
|
-
const
|
|
7373
|
-
|
|
7369
|
+
}, [e.curriculumComplete]), S = M(() => {
|
|
7370
|
+
const b = I();
|
|
7371
|
+
l.current.isQuestionMode = !0, l.current.currentQuestionIndex = 0, l.current.totalQuestions = b?.questions?.length || 0;
|
|
7372
|
+
const v = B();
|
|
7373
|
+
v && d.current.onCustomAction({
|
|
7374
7374
|
type: "questionStart",
|
|
7375
7375
|
moduleIndex: l.current.currentModuleIndex,
|
|
7376
7376
|
lessonIndex: l.current.currentLessonIndex,
|
|
7377
7377
|
questionIndex: l.current.currentQuestionIndex,
|
|
7378
7378
|
totalQuestions: l.current.totalQuestions,
|
|
7379
|
-
question:
|
|
7379
|
+
question: v
|
|
7380
7380
|
});
|
|
7381
|
-
const
|
|
7382
|
-
if (!h.current || !
|
|
7383
|
-
if (h.current.setMood("
|
|
7381
|
+
const R = () => {
|
|
7382
|
+
if (!h.current || !v) return;
|
|
7383
|
+
if (h.current.setMood("happy"), e.questionStart)
|
|
7384
7384
|
try {
|
|
7385
7385
|
h.current.playAnimation(e.questionStart, !0);
|
|
7386
|
-
} catch (
|
|
7387
|
-
console.warn("Failed to play questionStart animation:",
|
|
7386
|
+
} catch (H) {
|
|
7387
|
+
console.warn("Failed to play questionStart animation:", H);
|
|
7388
7388
|
}
|
|
7389
|
-
const
|
|
7390
|
-
|
|
7389
|
+
const k = C.current || { lipsyncLang: "en" };
|
|
7390
|
+
v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: k.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: k.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: k.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: k.lipsyncLang });
|
|
7391
7391
|
};
|
|
7392
|
-
if (h.current && h.current.isReady &&
|
|
7393
|
-
|
|
7392
|
+
if (h.current && h.current.isReady && v)
|
|
7393
|
+
R();
|
|
7394
7394
|
else if (h.current && h.current.isReady) {
|
|
7395
|
-
const
|
|
7396
|
-
h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang:
|
|
7395
|
+
const k = C.current || { lipsyncLang: "en" };
|
|
7396
|
+
h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: k.lipsyncLang });
|
|
7397
7397
|
} else {
|
|
7398
|
-
const
|
|
7399
|
-
h.current && h.current.isReady && (clearInterval(
|
|
7398
|
+
const k = setInterval(() => {
|
|
7399
|
+
h.current && h.current.isReady && (clearInterval(k), v && R());
|
|
7400
7400
|
}, 100);
|
|
7401
7401
|
setTimeout(() => {
|
|
7402
|
-
clearInterval(
|
|
7402
|
+
clearInterval(k);
|
|
7403
7403
|
}, 5e3);
|
|
7404
7404
|
}
|
|
7405
|
-
}, [e.questionStart,
|
|
7406
|
-
const
|
|
7407
|
-
if (l.current.currentQuestionIndex < (
|
|
7405
|
+
}, [e.questionStart, I, B]), P = M(() => {
|
|
7406
|
+
const b = I();
|
|
7407
|
+
if (l.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
|
|
7408
7408
|
l.current.currentQuestionIndex += 1;
|
|
7409
|
-
const
|
|
7410
|
-
|
|
7409
|
+
const v = B();
|
|
7410
|
+
v && d.current.onCustomAction({
|
|
7411
7411
|
type: "nextQuestion",
|
|
7412
7412
|
moduleIndex: l.current.currentModuleIndex,
|
|
7413
7413
|
lessonIndex: l.current.currentLessonIndex,
|
|
7414
7414
|
questionIndex: l.current.currentQuestionIndex,
|
|
7415
7415
|
totalQuestions: l.current.totalQuestions,
|
|
7416
|
-
question:
|
|
7416
|
+
question: v
|
|
7417
7417
|
});
|
|
7418
|
-
const
|
|
7419
|
-
if (!h.current || !
|
|
7418
|
+
const R = () => {
|
|
7419
|
+
if (!h.current || !v) return;
|
|
7420
7420
|
if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
|
|
7421
7421
|
try {
|
|
7422
7422
|
h.current.playAnimation(e.nextQuestion, !0);
|
|
7423
|
-
} catch (
|
|
7424
|
-
console.warn("Failed to play nextQuestion animation:",
|
|
7423
|
+
} catch (H) {
|
|
7424
|
+
console.warn("Failed to play nextQuestion animation:", H);
|
|
7425
7425
|
}
|
|
7426
|
-
const
|
|
7427
|
-
|
|
7428
|
-
lipsyncLang:
|
|
7429
|
-
}) :
|
|
7430
|
-
lipsyncLang:
|
|
7431
|
-
}) :
|
|
7432
|
-
lipsyncLang:
|
|
7433
|
-
}) : h.current.speakText(`Here's the next question: ${
|
|
7434
|
-
lipsyncLang:
|
|
7426
|
+
const k = C.current || { lipsyncLang: "en" };
|
|
7427
|
+
v.type === "code_test" ? h.current.speakText(`Great! Now let's move on to your next coding challenge: ${v.question}`, {
|
|
7428
|
+
lipsyncLang: k.lipsyncLang
|
|
7429
|
+
}) : v.type === "multiple_choice" ? h.current.speakText(`Alright! Here's your next question: ${v.question}`, {
|
|
7430
|
+
lipsyncLang: k.lipsyncLang
|
|
7431
|
+
}) : v.type === "true_false" ? h.current.speakText(`Now let's try this one: ${v.question}`, {
|
|
7432
|
+
lipsyncLang: k.lipsyncLang
|
|
7433
|
+
}) : h.current.speakText(`Here's the next question: ${v.question}`, {
|
|
7434
|
+
lipsyncLang: k.lipsyncLang
|
|
7435
7435
|
});
|
|
7436
7436
|
};
|
|
7437
|
-
if (h.current && h.current.isReady &&
|
|
7438
|
-
|
|
7439
|
-
else if (
|
|
7440
|
-
const
|
|
7441
|
-
h.current && h.current.isReady && (clearInterval(
|
|
7437
|
+
if (h.current && h.current.isReady && v)
|
|
7438
|
+
R();
|
|
7439
|
+
else if (v) {
|
|
7440
|
+
const k = setInterval(() => {
|
|
7441
|
+
h.current && h.current.isReady && (clearInterval(k), R());
|
|
7442
7442
|
}, 100);
|
|
7443
7443
|
setTimeout(() => {
|
|
7444
|
-
clearInterval(
|
|
7444
|
+
clearInterval(k);
|
|
7445
7445
|
}, 5e3);
|
|
7446
7446
|
}
|
|
7447
7447
|
} else
|
|
7448
|
-
|
|
7448
|
+
d.current.onCustomAction({
|
|
7449
7449
|
type: "allQuestionsComplete",
|
|
7450
7450
|
moduleIndex: l.current.currentModuleIndex,
|
|
7451
7451
|
lessonIndex: l.current.currentLessonIndex,
|
|
7452
7452
|
totalQuestions: l.current.totalQuestions,
|
|
7453
7453
|
score: l.current.score
|
|
7454
7454
|
});
|
|
7455
|
-
}, [e.nextQuestion,
|
|
7456
|
-
const
|
|
7457
|
-
l.current.currentLessonIndex < (
|
|
7455
|
+
}, [e.nextQuestion, I, B]), O = M(() => {
|
|
7456
|
+
const b = z.current || { modules: [] }, v = b.modules[l.current.currentModuleIndex];
|
|
7457
|
+
l.current.currentLessonIndex < (v?.lessons?.length || 0) - 1 ? (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({
|
|
7458
7458
|
type: "lessonStart",
|
|
7459
7459
|
moduleIndex: l.current.currentModuleIndex,
|
|
7460
7460
|
lessonIndex: l.current.currentLessonIndex
|
|
7461
|
-
}),
|
|
7461
|
+
}), d.current.onLessonStart({
|
|
7462
7462
|
moduleIndex: l.current.currentModuleIndex,
|
|
7463
7463
|
lessonIndex: l.current.currentLessonIndex,
|
|
7464
|
-
lesson:
|
|
7465
|
-
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"))) : l.current.currentModuleIndex < (
|
|
7464
|
+
lesson: I()
|
|
7465
|
+
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"))) : l.current.currentModuleIndex < (b.modules?.length || 0) - 1 ? (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, d.current.onCustomAction({
|
|
7466
7466
|
type: "lessonStart",
|
|
7467
7467
|
moduleIndex: l.current.currentModuleIndex,
|
|
7468
7468
|
lessonIndex: l.current.currentLessonIndex
|
|
7469
|
-
}),
|
|
7469
|
+
}), d.current.onLessonStart({
|
|
7470
7470
|
moduleIndex: l.current.currentModuleIndex,
|
|
7471
7471
|
lessonIndex: l.current.currentLessonIndex,
|
|
7472
|
-
lesson:
|
|
7473
|
-
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"))) :
|
|
7474
|
-
}, []),
|
|
7475
|
-
const
|
|
7476
|
-
let
|
|
7477
|
-
if (
|
|
7478
|
-
const
|
|
7479
|
-
|
|
7472
|
+
lesson: I()
|
|
7473
|
+
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"))) : L.current && L.current();
|
|
7474
|
+
}, []), W = M(() => {
|
|
7475
|
+
const b = I();
|
|
7476
|
+
let v = null;
|
|
7477
|
+
if (b?.avatar_script && b?.body) {
|
|
7478
|
+
const R = b.avatar_script.trim(), k = b.body.trim(), H = R.match(/[.!?]$/) ? " " : ". ";
|
|
7479
|
+
v = `${R}${H}${k}`;
|
|
7480
7480
|
} else
|
|
7481
|
-
|
|
7482
|
-
if (h.current && h.current.isReady &&
|
|
7481
|
+
v = b?.avatar_script || b?.body || null;
|
|
7482
|
+
if (h.current && h.current.isReady && v) {
|
|
7483
7483
|
l.current.isTeaching = !0, l.current.isQuestionMode = !1, h.current.setMood("happy");
|
|
7484
|
-
let
|
|
7484
|
+
let R = !1;
|
|
7485
7485
|
if (e.teaching)
|
|
7486
7486
|
try {
|
|
7487
|
-
h.current.playAnimation(e.teaching, !0),
|
|
7488
|
-
} catch (
|
|
7489
|
-
console.warn("Failed to play teaching animation:",
|
|
7487
|
+
h.current.playAnimation(e.teaching, !0), R = !0;
|
|
7488
|
+
} catch (H) {
|
|
7489
|
+
console.warn("Failed to play teaching animation:", H);
|
|
7490
7490
|
}
|
|
7491
|
-
|
|
7492
|
-
const
|
|
7493
|
-
|
|
7491
|
+
R || h.current.setBodyMovement("gesturing");
|
|
7492
|
+
const k = C.current || { lipsyncLang: "en" };
|
|
7493
|
+
d.current.onLessonStart({
|
|
7494
7494
|
moduleIndex: l.current.currentModuleIndex,
|
|
7495
7495
|
lessonIndex: l.current.currentLessonIndex,
|
|
7496
|
-
lesson:
|
|
7497
|
-
}),
|
|
7496
|
+
lesson: b
|
|
7497
|
+
}), d.current.onCustomAction({
|
|
7498
7498
|
type: "teachingStart",
|
|
7499
7499
|
moduleIndex: l.current.currentModuleIndex,
|
|
7500
7500
|
lessonIndex: l.current.currentLessonIndex,
|
|
7501
|
-
lesson:
|
|
7502
|
-
}), h.current.speakText(
|
|
7503
|
-
lipsyncLang:
|
|
7501
|
+
lesson: b
|
|
7502
|
+
}), h.current.speakText(v, {
|
|
7503
|
+
lipsyncLang: k.lipsyncLang,
|
|
7504
7504
|
onSpeechEnd: () => {
|
|
7505
|
-
l.current.isTeaching = !1,
|
|
7505
|
+
l.current.isTeaching = !1, d.current.onCustomAction({
|
|
7506
7506
|
type: "teachingComplete",
|
|
7507
7507
|
moduleIndex: l.current.currentModuleIndex,
|
|
7508
7508
|
lessonIndex: l.current.currentLessonIndex,
|
|
7509
|
-
lesson:
|
|
7510
|
-
hasQuestions:
|
|
7509
|
+
lesson: b,
|
|
7510
|
+
hasQuestions: b.questions && b.questions.length > 0
|
|
7511
7511
|
});
|
|
7512
7512
|
}
|
|
7513
7513
|
});
|
|
7514
7514
|
}
|
|
7515
|
-
}, [e.teaching,
|
|
7516
|
-
const
|
|
7517
|
-
if (
|
|
7515
|
+
}, [e.teaching, I]), _ = M((b) => {
|
|
7516
|
+
const v = B(), R = D(b, v);
|
|
7517
|
+
if (R && (l.current.score += 1), d.current.onQuestionAnswer({
|
|
7518
7518
|
moduleIndex: l.current.currentModuleIndex,
|
|
7519
7519
|
lessonIndex: l.current.currentLessonIndex,
|
|
7520
7520
|
questionIndex: l.current.currentQuestionIndex,
|
|
7521
|
-
answer:
|
|
7522
|
-
isCorrect:
|
|
7523
|
-
question:
|
|
7521
|
+
answer: b,
|
|
7522
|
+
isCorrect: R,
|
|
7523
|
+
question: v
|
|
7524
7524
|
}), h.current)
|
|
7525
|
-
if (
|
|
7525
|
+
if (R) {
|
|
7526
7526
|
if (h.current.setMood("happy"), e.correct)
|
|
7527
7527
|
try {
|
|
7528
7528
|
h.current.playReaction("happy");
|
|
@@ -7530,17 +7530,17 @@ const nt = ye(({
|
|
|
7530
7530
|
h.current.setBodyMovement("happy");
|
|
7531
7531
|
}
|
|
7532
7532
|
h.current.setBodyMovement("gesturing");
|
|
7533
|
-
const
|
|
7534
|
-
h.current.speakText(
|
|
7535
|
-
lipsyncLang:
|
|
7533
|
+
const k = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, H = C.current || { lipsyncLang: "en" };
|
|
7534
|
+
h.current.speakText(k, {
|
|
7535
|
+
lipsyncLang: H.lipsyncLang,
|
|
7536
7536
|
onSpeechEnd: () => {
|
|
7537
|
-
|
|
7537
|
+
d.current.onCustomAction({
|
|
7538
7538
|
type: "answerFeedbackComplete",
|
|
7539
7539
|
moduleIndex: l.current.currentModuleIndex,
|
|
7540
7540
|
lessonIndex: l.current.currentLessonIndex,
|
|
7541
7541
|
questionIndex: l.current.currentQuestionIndex,
|
|
7542
7542
|
isCorrect: !0,
|
|
7543
|
-
hasNextQuestion: l.current.currentQuestionIndex < (
|
|
7543
|
+
hasNextQuestion: l.current.currentQuestionIndex < (I()?.questions?.length || 0) - 1
|
|
7544
7544
|
});
|
|
7545
7545
|
}
|
|
7546
7546
|
});
|
|
@@ -7552,124 +7552,183 @@ const nt = ye(({
|
|
|
7552
7552
|
h.current.setBodyMovement("idle");
|
|
7553
7553
|
}
|
|
7554
7554
|
h.current.setBodyMovement("gesturing");
|
|
7555
|
-
const
|
|
7556
|
-
h.current.speakText(
|
|
7557
|
-
lipsyncLang:
|
|
7555
|
+
const k = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""} Let's move on to the next question.`, H = C.current || { lipsyncLang: "en" };
|
|
7556
|
+
h.current.speakText(k, {
|
|
7557
|
+
lipsyncLang: H.lipsyncLang,
|
|
7558
7558
|
onSpeechEnd: () => {
|
|
7559
|
-
|
|
7559
|
+
d.current.onCustomAction({
|
|
7560
7560
|
type: "answerFeedbackComplete",
|
|
7561
7561
|
moduleIndex: l.current.currentModuleIndex,
|
|
7562
7562
|
lessonIndex: l.current.currentLessonIndex,
|
|
7563
7563
|
questionIndex: l.current.currentQuestionIndex,
|
|
7564
7564
|
isCorrect: !1,
|
|
7565
|
-
hasNextQuestion: l.current.currentQuestionIndex < (
|
|
7565
|
+
hasNextQuestion: l.current.currentQuestionIndex < (I()?.questions?.length || 0) - 1
|
|
7566
7566
|
});
|
|
7567
7567
|
}
|
|
7568
7568
|
});
|
|
7569
7569
|
}
|
|
7570
7570
|
else
|
|
7571
|
-
|
|
7571
|
+
d.current.onCustomAction({
|
|
7572
7572
|
type: "answerFeedbackComplete",
|
|
7573
7573
|
moduleIndex: l.current.currentModuleIndex,
|
|
7574
7574
|
lessonIndex: l.current.currentLessonIndex,
|
|
7575
7575
|
questionIndex: l.current.currentQuestionIndex,
|
|
7576
|
-
isCorrect:
|
|
7577
|
-
hasNextQuestion: l.current.currentQuestionIndex < (
|
|
7576
|
+
isCorrect: R,
|
|
7577
|
+
hasNextQuestion: l.current.currentQuestionIndex < (I()?.questions?.length || 0) - 1,
|
|
7578
7578
|
avatarNotReady: !0
|
|
7579
7579
|
});
|
|
7580
|
-
}, [e.correct, e.incorrect,
|
|
7581
|
-
const
|
|
7582
|
-
if (!
|
|
7580
|
+
}, [e.correct, e.incorrect, B, I, D]), K = M((b) => {
|
|
7581
|
+
const v = B();
|
|
7582
|
+
if (!b || typeof b != "object") {
|
|
7583
7583
|
console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
|
|
7584
7584
|
return;
|
|
7585
7585
|
}
|
|
7586
|
-
if (
|
|
7586
|
+
if (v?.type !== "code_test") {
|
|
7587
7587
|
console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
|
|
7588
7588
|
return;
|
|
7589
7589
|
}
|
|
7590
|
-
const
|
|
7591
|
-
passed:
|
|
7592
|
-
results:
|
|
7593
|
-
output:
|
|
7594
|
-
error:
|
|
7595
|
-
executionTime:
|
|
7596
|
-
testCount:
|
|
7597
|
-
passedCount:
|
|
7598
|
-
failedCount:
|
|
7590
|
+
const R = {
|
|
7591
|
+
passed: b.passed === !0,
|
|
7592
|
+
results: b.results || [],
|
|
7593
|
+
output: b.output || "",
|
|
7594
|
+
error: b.error || null,
|
|
7595
|
+
executionTime: b.executionTime || null,
|
|
7596
|
+
testCount: b.testCount || 0,
|
|
7597
|
+
passedCount: b.passedCount || 0,
|
|
7598
|
+
failedCount: b.failedCount || 0
|
|
7599
7599
|
};
|
|
7600
|
-
|
|
7600
|
+
d.current.onCustomAction({
|
|
7601
7601
|
type: "codeTestSubmitted",
|
|
7602
7602
|
moduleIndex: l.current.currentModuleIndex,
|
|
7603
7603
|
lessonIndex: l.current.currentLessonIndex,
|
|
7604
7604
|
questionIndex: l.current.currentQuestionIndex,
|
|
7605
|
-
testResult:
|
|
7606
|
-
question:
|
|
7607
|
-
}), p.current && p.current(
|
|
7608
|
-
}, [
|
|
7605
|
+
testResult: R,
|
|
7606
|
+
question: v
|
|
7607
|
+
}), p.current && p.current(R);
|
|
7608
|
+
}, [B, D]), se = M(() => {
|
|
7609
|
+
if (l.current.currentQuestionIndex > 0) {
|
|
7610
|
+
l.current.currentQuestionIndex -= 1;
|
|
7611
|
+
const b = B();
|
|
7612
|
+
b && d.current.onCustomAction({
|
|
7613
|
+
type: "questionStart",
|
|
7614
|
+
moduleIndex: l.current.currentModuleIndex,
|
|
7615
|
+
lessonIndex: l.current.currentLessonIndex,
|
|
7616
|
+
questionIndex: l.current.currentQuestionIndex,
|
|
7617
|
+
totalQuestions: l.current.totalQuestions,
|
|
7618
|
+
question: b
|
|
7619
|
+
});
|
|
7620
|
+
const v = () => {
|
|
7621
|
+
if (!h.current || !b) return;
|
|
7622
|
+
h.current.setMood("happy"), h.current.setBodyMovement("idle");
|
|
7623
|
+
const R = C.current || { lipsyncLang: "en" };
|
|
7624
|
+
b.type === "code_test" ? h.current.speakText(`Let's go back to this coding challenge: ${b.question}`, {
|
|
7625
|
+
lipsyncLang: R.lipsyncLang
|
|
7626
|
+
}) : h.current.speakText(`Going back to: ${b.question}`, {
|
|
7627
|
+
lipsyncLang: R.lipsyncLang
|
|
7628
|
+
});
|
|
7629
|
+
};
|
|
7630
|
+
if (h.current && h.current.isReady && b)
|
|
7631
|
+
v();
|
|
7632
|
+
else if (b) {
|
|
7633
|
+
const R = setInterval(() => {
|
|
7634
|
+
h.current && h.current.isReady && (clearInterval(R), v());
|
|
7635
|
+
}, 100);
|
|
7636
|
+
setTimeout(() => {
|
|
7637
|
+
clearInterval(R);
|
|
7638
|
+
}, 5e3);
|
|
7639
|
+
}
|
|
7640
|
+
}
|
|
7641
|
+
}, [B]), pe = M(() => {
|
|
7642
|
+
const b = z.current || { modules: [] };
|
|
7643
|
+
if (b.modules[l.current.currentModuleIndex], l.current.currentLessonIndex > 0)
|
|
7644
|
+
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({
|
|
7645
|
+
type: "lessonStart",
|
|
7646
|
+
moduleIndex: l.current.currentModuleIndex,
|
|
7647
|
+
lessonIndex: l.current.currentLessonIndex
|
|
7648
|
+
}), d.current.onLessonStart({
|
|
7649
|
+
moduleIndex: l.current.currentModuleIndex,
|
|
7650
|
+
lessonIndex: l.current.currentLessonIndex,
|
|
7651
|
+
lesson: I()
|
|
7652
|
+
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7653
|
+
else if (l.current.currentModuleIndex > 0) {
|
|
7654
|
+
const k = b.modules[l.current.currentModuleIndex - 1];
|
|
7655
|
+
l.current.currentModuleIndex -= 1, l.current.currentLessonIndex = (k?.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({
|
|
7656
|
+
type: "lessonStart",
|
|
7657
|
+
moduleIndex: l.current.currentModuleIndex,
|
|
7658
|
+
lessonIndex: l.current.currentLessonIndex
|
|
7659
|
+
}), d.current.onLessonStart({
|
|
7660
|
+
moduleIndex: l.current.currentModuleIndex,
|
|
7661
|
+
lessonIndex: l.current.currentLessonIndex,
|
|
7662
|
+
lesson: I()
|
|
7663
|
+
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7664
|
+
}
|
|
7665
|
+
}, [I]), ue = M(() => {
|
|
7609
7666
|
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;
|
|
7610
|
-
}, []), ge =
|
|
7611
|
-
console.log("Avatar is ready!",
|
|
7612
|
-
const
|
|
7613
|
-
u &&
|
|
7614
|
-
|
|
7667
|
+
}, []), ge = M((b) => {
|
|
7668
|
+
console.log("Avatar is ready!", b);
|
|
7669
|
+
const v = I(), R = v?.avatar_script || v?.body;
|
|
7670
|
+
u && R && setTimeout(() => {
|
|
7671
|
+
c.current && c.current();
|
|
7615
7672
|
}, 10);
|
|
7616
|
-
}, [u,
|
|
7673
|
+
}, [u, I]);
|
|
7617
7674
|
Ee(() => {
|
|
7618
|
-
|
|
7619
|
-
}),
|
|
7675
|
+
c.current = W, g.current = O, y.current = X, x.current = P, L.current = oe, F.current = S, p.current = _;
|
|
7676
|
+
}), xe(a, () => ({
|
|
7620
7677
|
// Curriculum control methods
|
|
7621
|
-
startTeaching:
|
|
7678
|
+
startTeaching: W,
|
|
7622
7679
|
startQuestions: S,
|
|
7623
|
-
handleAnswerSelect:
|
|
7624
|
-
handleCodeTestResult:
|
|
7680
|
+
handleAnswerSelect: _,
|
|
7681
|
+
handleCodeTestResult: K,
|
|
7625
7682
|
nextQuestion: P,
|
|
7683
|
+
previousQuestion: se,
|
|
7626
7684
|
nextLesson: O,
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7685
|
+
previousLesson: pe,
|
|
7686
|
+
completeLesson: X,
|
|
7687
|
+
completeCurriculum: oe,
|
|
7688
|
+
resetCurriculum: ue,
|
|
7630
7689
|
getState: () => ({ ...l.current }),
|
|
7631
|
-
getCurrentQuestion: () =>
|
|
7632
|
-
getCurrentLesson: () =>
|
|
7690
|
+
getCurrentQuestion: () => B(),
|
|
7691
|
+
getCurrentLesson: () => I(),
|
|
7633
7692
|
// Direct access to avatar ref (always returns current value)
|
|
7634
7693
|
getAvatarRef: () => h.current,
|
|
7635
7694
|
// Convenience methods that delegate to avatar (always check current ref)
|
|
7636
|
-
speakText: async (
|
|
7695
|
+
speakText: async (b, v = {}) => {
|
|
7637
7696
|
await h.current?.resumeAudioContext?.();
|
|
7638
|
-
const
|
|
7639
|
-
h.current?.speakText(
|
|
7697
|
+
const R = C.current || { lipsyncLang: "en" };
|
|
7698
|
+
h.current?.speakText(b, { ...v, lipsyncLang: v.lipsyncLang || R.lipsyncLang });
|
|
7640
7699
|
},
|
|
7641
7700
|
resumeAudioContext: async () => {
|
|
7642
7701
|
if (h.current?.resumeAudioContext)
|
|
7643
7702
|
return await h.current.resumeAudioContext();
|
|
7644
|
-
const
|
|
7645
|
-
if (
|
|
7646
|
-
const
|
|
7647
|
-
if (
|
|
7703
|
+
const b = h.current?.talkingHead;
|
|
7704
|
+
if (b?.audioCtx) {
|
|
7705
|
+
const v = b.audioCtx;
|
|
7706
|
+
if (v.state === "suspended" || v.state === "interrupted")
|
|
7648
7707
|
try {
|
|
7649
|
-
await
|
|
7650
|
-
} catch (
|
|
7651
|
-
console.warn("Failed to resume audio context:",
|
|
7708
|
+
await v.resume(), console.log("Audio context resumed via talkingHead");
|
|
7709
|
+
} catch (R) {
|
|
7710
|
+
console.warn("Failed to resume audio context:", R);
|
|
7652
7711
|
}
|
|
7653
7712
|
} else
|
|
7654
7713
|
console.warn("Audio context not available yet");
|
|
7655
7714
|
},
|
|
7656
7715
|
stopSpeaking: () => h.current?.stopSpeaking(),
|
|
7657
|
-
setMood: (
|
|
7658
|
-
playAnimation: (
|
|
7659
|
-
setBodyMovement: (
|
|
7660
|
-
setMovementIntensity: (
|
|
7716
|
+
setMood: (b) => h.current?.setMood(b),
|
|
7717
|
+
playAnimation: (b, v) => h.current?.playAnimation(b, v),
|
|
7718
|
+
setBodyMovement: (b) => h.current?.setBodyMovement(b),
|
|
7719
|
+
setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
|
|
7661
7720
|
playRandomDance: () => h.current?.playRandomDance(),
|
|
7662
|
-
playReaction: (
|
|
7721
|
+
playReaction: (b) => h.current?.playReaction(b),
|
|
7663
7722
|
playCelebration: () => h.current?.playCelebration(),
|
|
7664
|
-
setShowFullAvatar: (
|
|
7665
|
-
setTimingAdjustment: (
|
|
7723
|
+
setShowFullAvatar: (b) => h.current?.setShowFullAvatar(b),
|
|
7724
|
+
setTimingAdjustment: (b) => h.current?.setTimingAdjustment(b),
|
|
7666
7725
|
lockAvatarPosition: () => h.current?.lockAvatarPosition(),
|
|
7667
7726
|
unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
|
|
7668
7727
|
// Custom action trigger
|
|
7669
|
-
triggerCustomAction: (
|
|
7670
|
-
|
|
7671
|
-
type:
|
|
7672
|
-
...
|
|
7728
|
+
triggerCustomAction: (b, v) => {
|
|
7729
|
+
d.current.onCustomAction({
|
|
7730
|
+
type: b,
|
|
7731
|
+
...v,
|
|
7673
7732
|
state: { ...l.current }
|
|
7674
7733
|
});
|
|
7675
7734
|
},
|
|
@@ -7677,8 +7736,8 @@ const nt = ye(({
|
|
|
7677
7736
|
handleResize: () => h.current?.handleResize(),
|
|
7678
7737
|
// Avatar readiness check (always returns current value)
|
|
7679
7738
|
isAvatarReady: () => h.current?.isReady || !1
|
|
7680
|
-
}), [
|
|
7681
|
-
const
|
|
7739
|
+
}), [W, S, _, K, P, O, X, oe, ue, B, I]);
|
|
7740
|
+
const Q = C.current || {
|
|
7682
7741
|
avatarUrl: "/avatars/brunette.glb",
|
|
7683
7742
|
avatarBody: "F",
|
|
7684
7743
|
mood: "happy",
|
|
@@ -7691,27 +7750,27 @@ const nt = ye(({
|
|
|
7691
7750
|
showFullAvatar: !1,
|
|
7692
7751
|
animations: e
|
|
7693
7752
|
};
|
|
7694
|
-
return /* @__PURE__ */
|
|
7753
|
+
return /* @__PURE__ */ ne("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ ne(
|
|
7695
7754
|
ze,
|
|
7696
7755
|
{
|
|
7697
7756
|
ref: h,
|
|
7698
|
-
avatarUrl:
|
|
7699
|
-
avatarBody:
|
|
7700
|
-
mood:
|
|
7701
|
-
ttsLang:
|
|
7702
|
-
ttsService:
|
|
7703
|
-
ttsVoice:
|
|
7704
|
-
ttsApiKey:
|
|
7705
|
-
bodyMovement:
|
|
7706
|
-
movementIntensity:
|
|
7707
|
-
showFullAvatar:
|
|
7757
|
+
avatarUrl: Q.avatarUrl,
|
|
7758
|
+
avatarBody: Q.avatarBody,
|
|
7759
|
+
mood: Q.mood,
|
|
7760
|
+
ttsLang: Q.ttsLang,
|
|
7761
|
+
ttsService: Q.ttsService,
|
|
7762
|
+
ttsVoice: Q.ttsVoice,
|
|
7763
|
+
ttsApiKey: Q.ttsApiKey,
|
|
7764
|
+
bodyMovement: Q.bodyMovement,
|
|
7765
|
+
movementIntensity: Q.movementIntensity,
|
|
7766
|
+
showFullAvatar: Q.showFullAvatar,
|
|
7708
7767
|
cameraView: "upper",
|
|
7709
|
-
animations:
|
|
7768
|
+
animations: Q.animations,
|
|
7710
7769
|
onReady: ge,
|
|
7711
7770
|
onLoading: () => {
|
|
7712
7771
|
},
|
|
7713
|
-
onError: (
|
|
7714
|
-
console.error("Avatar error:",
|
|
7772
|
+
onError: (b) => {
|
|
7773
|
+
console.error("Avatar error:", b);
|
|
7715
7774
|
}
|
|
7716
7775
|
}
|
|
7717
7776
|
) });
|
|
@@ -7826,7 +7885,7 @@ export {
|
|
|
7826
7885
|
ze as TalkingHeadAvatar,
|
|
7827
7886
|
it as TalkingHeadComponent,
|
|
7828
7887
|
Ce as animations,
|
|
7829
|
-
|
|
7888
|
+
be as getActiveTTSConfig,
|
|
7830
7889
|
pt as getAnimation,
|
|
7831
7890
|
mt as getVoiceOptions,
|
|
7832
7891
|
gt as hasAnimation
|