@sage-rsc/talking-head-react 1.0.64 → 1.0.66
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 +292 -280
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +35 -10
- package/src/components/TalkingHeadAvatar.jsx +10 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as Ee, jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as Ee, jsx as de } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Le, useRef as Z, useState as ge, useEffect as ye, useCallback as E, useImperativeHandle as Ae, useLayoutEffect as We } from "react";
|
|
3
3
|
import * as f from "three";
|
|
4
4
|
import { OrbitControls as Ve } from "three/addons/controls/OrbitControls.js";
|
|
5
5
|
import { GLTFLoader as Ge } from "three/addons/loaders/GLTFLoader.js";
|
|
@@ -7,12 +7,12 @@ import { DRACOLoader as Ze } from "three/addons/loaders/DRACOLoader.js";
|
|
|
7
7
|
import { FBXLoader as ze } from "three/addons/loaders/FBXLoader.js";
|
|
8
8
|
import { RoomEnvironment as Xe } from "three/addons/environments/RoomEnvironment.js";
|
|
9
9
|
import Ye from "three/addons/libs/stats.module.js";
|
|
10
|
-
let m,
|
|
11
|
-
const A = [0, 0, 0, 0], k = new f.Vector3(), be = new f.Vector3(),
|
|
10
|
+
let m, $, ne;
|
|
11
|
+
const A = [0, 0, 0, 0], k = new f.Vector3(), be = new f.Vector3(), _ = new f.Vector3(), ve = new f.Vector3();
|
|
12
12
|
new f.Plane();
|
|
13
13
|
new f.Ray();
|
|
14
14
|
new f.Euler();
|
|
15
|
-
const
|
|
15
|
+
const K = new f.Quaternion(), Ce = new f.Quaternion(), re = new f.Matrix4(), le = new f.Matrix4();
|
|
16
16
|
new f.Vector3();
|
|
17
17
|
const Re = new f.Vector3(0, 0, 1), je = new f.Vector3(1, 0, 0), Qe = new f.Vector3(0, 1, 0), qe = new f.Vector3(0, 0, 1);
|
|
18
18
|
class _e {
|
|
@@ -338,7 +338,7 @@ class _e {
|
|
|
338
338
|
ea: [0, 0, 0, 0]
|
|
339
339
|
// External acceleration [m/s^2]
|
|
340
340
|
};
|
|
341
|
-
h.boneParent.matrixWorld.decompose(k,
|
|
341
|
+
h.boneParent.matrixWorld.decompose(k, K, _), k.copy(Re).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), h.qWorldInverseYaw = K.clone().normalize(), this.data.push(h), this.dict[u] = h;
|
|
342
342
|
try {
|
|
343
343
|
this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
|
|
344
344
|
} catch (r) {
|
|
@@ -356,22 +356,22 @@ class _e {
|
|
|
356
356
|
for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, i = this.objectsUpdate.length; e < i; e++)
|
|
357
357
|
o = this.objectsUpdate[e], o.updateMatrix(), o.parent === null ? o.matrixWorld.copy(o.matrix) : o.matrixWorld.multiplyMatrices(o.parent.matrixWorld, o.matrix), o.matrixWorldNeedsUpdate = !1;
|
|
358
358
|
for (e = 0, i = this.data.length; e < i; e++) {
|
|
359
|
-
if (o = this.data[e], k.copy(o.vWorld),
|
|
359
|
+
if (o = this.data[e], k.copy(o.vWorld), re.copy(o.boneParent.matrixWorld), le.copy(re).invert(), o.vWorld.setFromMatrixPosition(re), k.applyMatrix4(le), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
|
|
360
360
|
for (n = 0, s = o.children.length; n < s; n++)
|
|
361
361
|
m = o.children[n], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
|
|
362
362
|
if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, k.set(
|
|
363
363
|
o.vBasis.x + A[0],
|
|
364
364
|
o.vBasis.y + A[1],
|
|
365
365
|
o.vBasis.z + A[2]
|
|
366
|
-
), k.applyMatrix4(
|
|
366
|
+
), k.applyMatrix4(re), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(le), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
|
|
367
367
|
o.bone.position.set(
|
|
368
368
|
o.vBasis.x + A[0],
|
|
369
369
|
o.vBasis.y + A[1],
|
|
370
370
|
o.vBasis.z - A[2]
|
|
371
371
|
);
|
|
372
|
-
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k,
|
|
372
|
+
else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, K, _), k.copy(Re).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle(qe, -m), o.boneParent.quaternion.multiply(K)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), K.setFromAxisAngle(je, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Qe, -m), o.boneParent.quaternion.multiply(K)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
|
|
373
373
|
for (n = 0, s = o.excludes.length; n < s; n++)
|
|
374
|
-
m = o.excludes[n],
|
|
374
|
+
m = o.excludes[n], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), le.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(le), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), $ = _.length(), !($ > m.radius + ne) && ($ < Math.abs(m.radius - ne) || ($ = ($ * $ + ne * ne - m.radiusSq) / (2 * $), _.normalize(), ve.copy(_).multiplyScalar($), $ = Math.sqrt(ne * ne - $ * $), k.subVectors(k, ve).projectOnPlane(_).normalize().multiplyScalar($), be.subVectors(o.vBasis, ve).projectOnPlane(_).normalize(), ne = be.dot(k), ne < 0 && (ne = Math.sqrt($ * $ - ne * ne), be.multiplyScalar(ne), k.add(be)), k.add(ve).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
|
|
375
375
|
}
|
|
376
376
|
this.helpers.isActive && this.updateHelpers();
|
|
377
377
|
}
|
|
@@ -442,17 +442,17 @@ class _e {
|
|
|
442
442
|
*/
|
|
443
443
|
updateHelpers() {
|
|
444
444
|
if (m = this.helpers.points, m.bones.length) {
|
|
445
|
-
|
|
445
|
+
le.copy(this.armature.matrixWorld).invert();
|
|
446
446
|
const t = m.object.geometry.getAttribute("position");
|
|
447
447
|
for (let e = 0, n = m.bones.length; e < n; e++)
|
|
448
|
-
|
|
448
|
+
re.multiplyMatrices(le, m.bones[e].matrixWorld), k.setFromMatrixPosition(re), t.setXYZ(e, k.x, k.y, k.z);
|
|
449
449
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
450
450
|
}
|
|
451
451
|
if (m = this.helpers.lines, m.bones.length) {
|
|
452
|
-
|
|
452
|
+
le.copy(this.armature.matrixWorld).invert();
|
|
453
453
|
const t = m.object.geometry.getAttribute("position");
|
|
454
454
|
for (let e = 0, n = 0, i = m.bones.length; e < i; e++, n += 2)
|
|
455
|
-
|
|
455
|
+
re.multiplyMatrices(le, m.bones[e].matrixWorld), k.setFromMatrixPosition(re), t.setXYZ(n, k.x, k.y, k.z), re.multiplyMatrices(le, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(re), t.setXYZ(n + 1, k.x, k.y, k.z);
|
|
456
456
|
t.needsUpdate = !0, m.object.updateMatrixWorld();
|
|
457
457
|
}
|
|
458
458
|
}
|
|
@@ -2629,7 +2629,7 @@ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2629
2629
|
fr: it,
|
|
2630
2630
|
fi: st,
|
|
2631
2631
|
lt: rt
|
|
2632
|
-
},
|
|
2632
|
+
}, V = new f.Quaternion(), F = new f.Euler(), ue = new f.Vector3(), ce = new f.Vector3(), Te = new f.Box3();
|
|
2633
2633
|
new f.Matrix4();
|
|
2634
2634
|
new f.Matrix4();
|
|
2635
2635
|
new f.Vector3();
|
|
@@ -4376,7 +4376,7 @@ class Fe {
|
|
|
4376
4376
|
if (e.x === 0 && e.y === 0 && e.z === 0) continue;
|
|
4377
4377
|
F.set(e.x, e.y, e.z);
|
|
4378
4378
|
const n = this.poseAvatar.props[t];
|
|
4379
|
-
n.isQuaternion ? (
|
|
4379
|
+
n.isQuaternion ? (V.setFromEuler(F), n.multiply(V)) : n.isVector3 && n.add(F);
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
4382
|
/**
|
|
@@ -5180,7 +5180,7 @@ class Fe {
|
|
|
5180
5180
|
eyeLookOutRight: [null, 0],
|
|
5181
5181
|
eyeContact: [0]
|
|
5182
5182
|
}
|
|
5183
|
-
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (
|
|
5183
|
+
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (V.setFromAxisAngle(ht, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(V)), Te.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ue), ue.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectHips.position.y -= Te.min.y / 2, this.objectHips.position.x -= (ue.x + ce.x) / 4, this.objectHips.position.z -= (ue.z + ce.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
|
|
5184
5184
|
this.stats && this.stats.end();
|
|
5185
5185
|
else {
|
|
5186
5186
|
if (this.cameraClock !== null && this.cameraClock < 1e3) {
|
|
@@ -5253,8 +5253,8 @@ class Fe {
|
|
|
5253
5253
|
for (let x = 0; x < y.length; x++) {
|
|
5254
5254
|
const I = x === y.length - 1, D = y[x].match(l);
|
|
5255
5255
|
let p = y[x].match(s);
|
|
5256
|
-
const
|
|
5257
|
-
if (p && !I && !
|
|
5256
|
+
const C = y[x].match(u), z = y[x].match(o);
|
|
5257
|
+
if (p && !I && !C && y[x + 1].match(s) && (p = !1), n && (h += y[x]), D && (!i || i.every((R) => x < R[0] || x > R[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
|
|
5258
5258
|
mark: c,
|
|
5259
5259
|
word: r
|
|
5260
5260
|
})), h.length && (g.push({
|
|
@@ -5287,7 +5287,7 @@ class Fe {
|
|
|
5287
5287
|
};
|
|
5288
5288
|
n && (R.onSubtitles = n), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], r = "", c = 0, g = [];
|
|
5289
5289
|
}
|
|
5290
|
-
if (
|
|
5290
|
+
if (C) {
|
|
5291
5291
|
let R = this.animEmojis[y[x]];
|
|
5292
5292
|
R && R.link && (R = this.animEmojis[R.link]), R && this.speechQueue.push({ emoji: R });
|
|
5293
5293
|
}
|
|
@@ -5470,7 +5470,7 @@ class Fe {
|
|
|
5470
5470
|
s.lang = o, s.rate = Math.max(0.1, Math.min(10, l)), s.pitch = Math.max(0, Math.min(2, u)), s.volume = Math.max(0, Math.min(1, a));
|
|
5471
5471
|
const h = speechSynthesis.getVoices(), r = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
|
|
5472
5472
|
if (r && h.length > 0) {
|
|
5473
|
-
const p = h.find((
|
|
5473
|
+
const p = h.find((C) => C.name.includes(r) || C.lang === o);
|
|
5474
5474
|
p && (s.voice = p);
|
|
5475
5475
|
}
|
|
5476
5476
|
const c = i.length * 100 / s.rate, d = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (c / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", y = this.lipsyncPreProcessText(i, g), x = this.lipsyncWordsToVisemes(y, g);
|
|
@@ -5485,11 +5485,11 @@ class Fe {
|
|
|
5485
5485
|
const I = [];
|
|
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
|
-
for (let
|
|
5489
|
-
const z = x.visemes[
|
|
5488
|
+
for (let C = 0; C < x.visemes.length; C++) {
|
|
5489
|
+
const z = x.visemes[C], R = x.times[C] / p, T = x.durations[C] / p, P = R * c, ie = T * c;
|
|
5490
5490
|
I.push({
|
|
5491
5491
|
template: { name: "viseme" },
|
|
5492
|
-
ts: [P - Math.min(60, 2 *
|
|
5492
|
+
ts: [P - Math.min(60, 2 * ie / 3), P + Math.min(25, ie / 2), P + ie + Math.min(60, ie / 2)],
|
|
5493
5493
|
vs: {
|
|
5494
5494
|
["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
|
|
5495
5495
|
}
|
|
@@ -6133,7 +6133,7 @@ class Fe {
|
|
|
6133
6133
|
*/
|
|
6134
6134
|
lookAtCamera(t) {
|
|
6135
6135
|
let e;
|
|
6136
|
-
if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0),
|
|
6136
|
+
if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ue.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), ce.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ue, ce).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
|
|
6137
6137
|
if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
|
|
6138
6138
|
if (this.avatar.avatarIgnoreCamera) {
|
|
6139
6139
|
this.lookAhead(t);
|
|
@@ -6146,10 +6146,10 @@ class Fe {
|
|
|
6146
6146
|
this.lookAt(null, null, t);
|
|
6147
6147
|
return;
|
|
6148
6148
|
}
|
|
6149
|
-
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0),
|
|
6150
|
-
const n = new f.Vector3().subVectors(e,
|
|
6149
|
+
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ue.setFromMatrixPosition(this.objectLeftEye.matrixWorld), ce.setFromMatrixPosition(this.objectRightEye.matrixWorld), ue.add(ce).divideScalar(2), V.copy(this.armature.quaternion), V.multiply(this.poseTarget.props["Hips.quaternion"]), V.multiply(this.poseTarget.props["Spine.quaternion"]), V.multiply(this.poseTarget.props["Spine1.quaternion"]), V.multiply(this.poseTarget.props["Spine2.quaternion"]), V.multiply(this.poseTarget.props["Neck.quaternion"]), V.multiply(this.poseTarget.props["Head.quaternion"]);
|
|
6150
|
+
const n = new f.Vector3().subVectors(e, ue).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
|
|
6151
6151
|
F.set(s, i, 0, "YXZ");
|
|
6152
|
-
const l = new f.Quaternion().setFromEuler(F), u = new f.Quaternion().copy(l).multiply(
|
|
6152
|
+
const l = new f.Quaternion().setFromEuler(F), u = new f.Quaternion().copy(l).multiply(V.clone().invert());
|
|
6153
6153
|
F.setFromQuaternion(u, "YXZ");
|
|
6154
6154
|
let a = F.x / (40 / 24) + 0.2, h = F.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, a)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
|
|
6155
6155
|
if (t) {
|
|
@@ -6186,13 +6186,13 @@ class Fe {
|
|
|
6186
6186
|
const s = new f.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new f.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), l = new f.Vector3().addVectors(s, o).divideScalar(2);
|
|
6187
6187
|
l.project(this.camera);
|
|
6188
6188
|
let u = (l.x + 1) / 2 * i.width + i.left, a = -(l.y - 1) / 2 * i.height + i.top;
|
|
6189
|
-
t === null && (t = u), e === null && (e = a),
|
|
6189
|
+
t === null && (t = u), e === null && (e = a), V.copy(this.armature.quaternion), V.multiply(this.poseTarget.props["Hips.quaternion"]), V.multiply(this.poseTarget.props["Spine.quaternion"]), V.multiply(this.poseTarget.props["Spine1.quaternion"]), V.multiply(this.poseTarget.props["Spine2.quaternion"]), V.multiply(this.poseTarget.props["Neck.quaternion"]), V.multiply(this.poseTarget.props["Head.quaternion"]), F.setFromQuaternion(V);
|
|
6190
6190
|
let h = F.x / (40 / 24), r = F.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - r + d;
|
|
6191
6191
|
x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
|
|
6192
6192
|
let D = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
|
|
6193
6193
|
if (n) {
|
|
6194
|
-
let
|
|
6195
|
-
|
|
6194
|
+
let C = this.animQueue.findIndex((R) => R.template.name === "lookat");
|
|
6195
|
+
C !== -1 && this.animQueue.splice(C, 1);
|
|
6196
6196
|
const z = {
|
|
6197
6197
|
name: "lookat",
|
|
6198
6198
|
dt: [750, n],
|
|
@@ -6578,11 +6578,11 @@ class Fe {
|
|
|
6578
6578
|
if (e)
|
|
6579
6579
|
for (let I = 0; I < x; I++) {
|
|
6580
6580
|
let D = !1;
|
|
6581
|
-
for (let p = 0,
|
|
6581
|
+
for (let p = 0, C = y.length; p < C; p++) {
|
|
6582
6582
|
const z = y[p].bone;
|
|
6583
6583
|
z.matrixWorld.decompose(u, a, h), a.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(a), l.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
|
|
6584
6584
|
let R = s.dot(l);
|
|
6585
|
-
R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), r.crossVectors(l, s), r.normalize(),
|
|
6585
|
+
R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), V.setFromAxisAngle(r, R), z.quaternion.multiply(V), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
|
|
6586
6586
|
y[p].minx !== void 0 ? y[p].minx : -1 / 0,
|
|
6587
6587
|
y[p].miny !== void 0 ? y[p].miny : -1 / 0,
|
|
6588
6588
|
y[p].minz !== void 0 ? y[p].minz : -1 / 0
|
|
@@ -6605,7 +6605,7 @@ class Fe {
|
|
|
6605
6605
|
this.isRunning = !1, this.stop(), this.stopSpeaking(), this.streamStop(), this.isAvatarOnly ? this.armature && (this.armature.parent && this.armature.parent.remove(this.armature), this.clearThree(this.armature)) : (this.clearThree(this.scene), this.resizeobserver.disconnect(), this.renderer && (this.renderer.dispose(), this.renderer.domElement && this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement), this.renderer = null)), this.clearThree(this.ikMesh), this.dynamicbones.dispose();
|
|
6606
6606
|
}
|
|
6607
6607
|
}
|
|
6608
|
-
const
|
|
6608
|
+
const fe = {
|
|
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 ye = {
|
|
|
6645
6645
|
// Male, English - Powerful
|
|
6646
6646
|
}
|
|
6647
6647
|
};
|
|
6648
|
-
function
|
|
6648
|
+
function Se() {
|
|
6649
6649
|
return {
|
|
6650
6650
|
service: "elevenlabs",
|
|
6651
|
-
endpoint:
|
|
6652
|
-
apiKey:
|
|
6653
|
-
defaultVoice:
|
|
6654
|
-
voices:
|
|
6651
|
+
endpoint: fe.endpoint,
|
|
6652
|
+
apiKey: fe.apiKey,
|
|
6653
|
+
defaultVoice: fe.defaultVoice,
|
|
6654
|
+
voices: fe.voices
|
|
6655
6655
|
};
|
|
6656
6656
|
}
|
|
6657
6657
|
function Rt() {
|
|
6658
|
-
const O =
|
|
6658
|
+
const O = Se(), t = [];
|
|
6659
6659
|
return Object.entries(O.voices).forEach(([e, n]) => {
|
|
6660
6660
|
t.push({
|
|
6661
6661
|
value: n,
|
|
@@ -6663,7 +6663,7 @@ function Rt() {
|
|
|
6663
6663
|
});
|
|
6664
6664
|
}), t;
|
|
6665
6665
|
}
|
|
6666
|
-
const Pe =
|
|
6666
|
+
const Pe = Le(({
|
|
6667
6667
|
avatarUrl: O = "/avatars/brunette.glb",
|
|
6668
6668
|
avatarBody: t = "F",
|
|
6669
6669
|
mood: e = "neutral",
|
|
@@ -6685,72 +6685,72 @@ const Pe = Ie(({
|
|
|
6685
6685
|
style: y = {},
|
|
6686
6686
|
animations: x = {}
|
|
6687
6687
|
}, I) => {
|
|
6688
|
-
const D =
|
|
6689
|
-
|
|
6690
|
-
T.current =
|
|
6691
|
-
}, [
|
|
6692
|
-
|
|
6688
|
+
const D = Z(null), p = Z(null), C = Z(a), z = Z(null), R = Z(null), T = Z(!1), P = Z({ remainingText: null, originalText: null, options: null }), [ie, he] = ge(!0), [S, N] = ge(null), [X, Y] = ge(!1), [Q, J] = ge(!1);
|
|
6689
|
+
ye(() => {
|
|
6690
|
+
T.current = Q;
|
|
6691
|
+
}, [Q]), ye(() => {
|
|
6692
|
+
C.current = a;
|
|
6693
6693
|
}, [a]);
|
|
6694
|
-
const
|
|
6695
|
-
let
|
|
6696
|
-
|
|
6694
|
+
const oe = Se(), me = i || oe.service;
|
|
6695
|
+
let se;
|
|
6696
|
+
me === "browser" ? se = {
|
|
6697
6697
|
service: "browser",
|
|
6698
6698
|
endpoint: "",
|
|
6699
6699
|
apiKey: null,
|
|
6700
6700
|
defaultVoice: "Google US English"
|
|
6701
|
-
} :
|
|
6701
|
+
} : me === "elevenlabs" ? se = {
|
|
6702
6702
|
service: "elevenlabs",
|
|
6703
6703
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
6704
|
-
apiKey: o ||
|
|
6705
|
-
defaultVoice: s ||
|
|
6706
|
-
voices:
|
|
6707
|
-
} :
|
|
6704
|
+
apiKey: o || oe.apiKey,
|
|
6705
|
+
defaultVoice: s || oe.defaultVoice || fe.defaultVoice,
|
|
6706
|
+
voices: oe.voices || fe.voices
|
|
6707
|
+
} : me === "deepgram" ? se = {
|
|
6708
6708
|
service: "deepgram",
|
|
6709
6709
|
endpoint: "https://api.deepgram.com/v1/speak",
|
|
6710
|
-
apiKey: o ||
|
|
6711
|
-
defaultVoice: s ||
|
|
6712
|
-
voices:
|
|
6713
|
-
} :
|
|
6714
|
-
...
|
|
6710
|
+
apiKey: o || oe.apiKey,
|
|
6711
|
+
defaultVoice: s || oe.defaultVoice || Me.defaultVoice,
|
|
6712
|
+
voices: oe.voices || Me.voices
|
|
6713
|
+
} : se = {
|
|
6714
|
+
...oe,
|
|
6715
6715
|
// Override API key if provided via props
|
|
6716
|
-
apiKey: o !== null ? o :
|
|
6716
|
+
apiKey: o !== null ? o : oe.apiKey
|
|
6717
6717
|
};
|
|
6718
|
-
const
|
|
6718
|
+
const pe = {
|
|
6719
6719
|
url: O,
|
|
6720
6720
|
body: t,
|
|
6721
6721
|
avatarMood: e,
|
|
6722
|
-
ttsLang:
|
|
6723
|
-
ttsVoice: s ||
|
|
6722
|
+
ttsLang: me === "browser" ? "en-US" : n,
|
|
6723
|
+
ttsVoice: s || se.defaultVoice,
|
|
6724
6724
|
lipsyncLang: "en",
|
|
6725
6725
|
showFullAvatar: a,
|
|
6726
6726
|
bodyMovement: l,
|
|
6727
6727
|
movementIntensity: u
|
|
6728
|
-
},
|
|
6729
|
-
ttsEndpoint:
|
|
6730
|
-
ttsApikey:
|
|
6731
|
-
ttsService:
|
|
6728
|
+
}, ee = {
|
|
6729
|
+
ttsEndpoint: se.endpoint,
|
|
6730
|
+
ttsApikey: se.apiKey,
|
|
6731
|
+
ttsService: me,
|
|
6732
6732
|
lipsyncModules: ["en"],
|
|
6733
6733
|
cameraView: h
|
|
6734
6734
|
}, b = E(async () => {
|
|
6735
6735
|
if (!(!D.current || p.current))
|
|
6736
6736
|
try {
|
|
6737
|
-
if (
|
|
6738
|
-
if (
|
|
6739
|
-
const M = Math.min(100, Math.round(
|
|
6737
|
+
if (he(!0), N(null), p.current = new Fe(D.current, ee), 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(pe, (G) => {
|
|
6738
|
+
if (G.lengthComputable) {
|
|
6739
|
+
const M = Math.min(100, Math.round(G.loaded / G.total * 100));
|
|
6740
6740
|
c(M);
|
|
6741
6741
|
}
|
|
6742
|
-
}), await new Promise((
|
|
6742
|
+
}), await new Promise((G) => {
|
|
6743
6743
|
const M = () => {
|
|
6744
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ?
|
|
6744
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? G() : setTimeout(M, 100);
|
|
6745
6745
|
};
|
|
6746
6746
|
M();
|
|
6747
6747
|
}), p.current && p.current.setShowFullAvatar)
|
|
6748
6748
|
try {
|
|
6749
6749
|
p.current.setShowFullAvatar(a);
|
|
6750
|
-
} catch (
|
|
6751
|
-
console.warn("Error setting full body mode on initialization:",
|
|
6750
|
+
} catch (G) {
|
|
6751
|
+
console.warn("Error setting full body mode on initialization:", G);
|
|
6752
6752
|
}
|
|
6753
|
-
p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()),
|
|
6753
|
+
p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), he(!1), Y(!0), r(p.current);
|
|
6754
6754
|
const B = () => {
|
|
6755
6755
|
document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
|
|
6756
6756
|
};
|
|
@@ -6758,15 +6758,15 @@ const Pe = Ie(({
|
|
|
6758
6758
|
document.removeEventListener("visibilitychange", B);
|
|
6759
6759
|
};
|
|
6760
6760
|
} catch (L) {
|
|
6761
|
-
console.error("Error initializing TalkingHead:", L), N(L.message || "Failed to initialize avatar"),
|
|
6761
|
+
console.error("Error initializing TalkingHead:", L), N(L.message || "Failed to initialize avatar"), he(!1), d(L);
|
|
6762
6762
|
}
|
|
6763
6763
|
}, [O, t, e, n, i, s, o, a, l, u, h]);
|
|
6764
|
-
|
|
6764
|
+
ye(() => (b(), () => {
|
|
6765
6765
|
p.current && (p.current.stop(), p.current.dispose(), p.current = null);
|
|
6766
|
-
}), [b]),
|
|
6766
|
+
}), [b]), ye(() => {
|
|
6767
6767
|
if (!D.current || !p.current) return;
|
|
6768
|
-
const L = new ResizeObserver((
|
|
6769
|
-
for (const M of
|
|
6768
|
+
const L = new ResizeObserver((G) => {
|
|
6769
|
+
for (const M of G)
|
|
6770
6770
|
p.current && p.current.onResize && p.current.onResize();
|
|
6771
6771
|
});
|
|
6772
6772
|
L.observe(D.current);
|
|
@@ -6776,7 +6776,7 @@ const Pe = Ie(({
|
|
|
6776
6776
|
return window.addEventListener("resize", B), () => {
|
|
6777
6777
|
L.disconnect(), window.removeEventListener("resize", B);
|
|
6778
6778
|
};
|
|
6779
|
-
}, [
|
|
6779
|
+
}, [X]);
|
|
6780
6780
|
const v = E(async () => {
|
|
6781
6781
|
if (p.current && p.current.audioCtx)
|
|
6782
6782
|
try {
|
|
@@ -6785,23 +6785,23 @@ const Pe = Ie(({
|
|
|
6785
6785
|
console.warn("Failed to resume audio context:", L);
|
|
6786
6786
|
}
|
|
6787
6787
|
}, []), w = E(async (L, B = {}) => {
|
|
6788
|
-
if (p.current &&
|
|
6788
|
+
if (p.current && X)
|
|
6789
6789
|
try {
|
|
6790
|
-
R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: B }, P.current = { remainingText: null, originalText: null, options: null },
|
|
6791
|
-
const
|
|
6790
|
+
R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: B }, P.current = { remainingText: null, originalText: null, options: null }, J(!1), T.current = !1, await v();
|
|
6791
|
+
const G = {
|
|
6792
6792
|
...B,
|
|
6793
|
-
lipsyncLang: B.lipsyncLang ||
|
|
6793
|
+
lipsyncLang: B.lipsyncLang || pe.lipsyncLang || "en"
|
|
6794
6794
|
};
|
|
6795
6795
|
if (B.onSpeechEnd && p.current) {
|
|
6796
6796
|
const M = p.current;
|
|
6797
|
-
let
|
|
6797
|
+
let W = null, ae = 0;
|
|
6798
6798
|
const ke = 1200;
|
|
6799
6799
|
let xe = !1;
|
|
6800
|
-
|
|
6801
|
-
if (
|
|
6800
|
+
W = setInterval(() => {
|
|
6801
|
+
if (ae++, T.current)
|
|
6802
6802
|
return;
|
|
6803
|
-
if (
|
|
6804
|
-
if (
|
|
6803
|
+
if (ae > ke) {
|
|
6804
|
+
if (W && (clearInterval(W), W = null, R.current = null), !xe && !T.current) {
|
|
6805
6805
|
xe = !0;
|
|
6806
6806
|
try {
|
|
6807
6807
|
B.onSpeechEnd();
|
|
@@ -6814,7 +6814,7 @@ const Pe = Ie(({
|
|
|
6814
6814
|
const Oe = !M.speechQueue || M.speechQueue.length === 0, Ne = !M.audioPlaylist || M.audioPlaylist.length === 0;
|
|
6815
6815
|
M && M.isSpeaking === !1 && Oe && Ne && M.isAudioPlaying === !1 && !xe && !T.current && setTimeout(() => {
|
|
6816
6816
|
if (M && !T.current && M.isSpeaking === !1 && (!M.speechQueue || M.speechQueue.length === 0) && (!M.audioPlaylist || M.audioPlaylist.length === 0) && M.isAudioPlaying === !1 && !xe && !T.current) {
|
|
6817
|
-
xe = !0,
|
|
6817
|
+
xe = !0, W && (clearInterval(W), W = null, R.current = null);
|
|
6818
6818
|
try {
|
|
6819
6819
|
B.onSpeechEnd();
|
|
6820
6820
|
} catch (Ue) {
|
|
@@ -6822,35 +6822,35 @@ const Pe = Ie(({
|
|
|
6822
6822
|
}
|
|
6823
6823
|
}
|
|
6824
6824
|
}, 100);
|
|
6825
|
-
}, 100), R.current =
|
|
6825
|
+
}, 100), R.current = W;
|
|
6826
6826
|
}
|
|
6827
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L,
|
|
6828
|
-
await v(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L,
|
|
6827
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, G)) : setTimeout(async () => {
|
|
6828
|
+
await v(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, G));
|
|
6829
6829
|
}, 100);
|
|
6830
|
-
} catch (
|
|
6831
|
-
console.error("Error speaking text:",
|
|
6830
|
+
} catch (G) {
|
|
6831
|
+
console.error("Error speaking text:", G), N(G.message || "Failed to speak text");
|
|
6832
6832
|
}
|
|
6833
|
-
}, [
|
|
6834
|
-
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null,
|
|
6835
|
-
}, []),
|
|
6833
|
+
}, [X, v, pe.lipsyncLang]), H = E(() => {
|
|
6834
|
+
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, J(!1));
|
|
6835
|
+
}, []), U = E(() => {
|
|
6836
6836
|
if (p.current && p.current.pauseSpeaking) {
|
|
6837
6837
|
const L = p.current;
|
|
6838
6838
|
if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
|
|
6839
6839
|
R.current && (clearInterval(R.current), R.current = null);
|
|
6840
|
-
let
|
|
6840
|
+
let G = "";
|
|
6841
6841
|
if (L.speechQueue && L.speechQueue.length > 0 && z.current) {
|
|
6842
|
-
const M = L.speechQueue.filter((
|
|
6843
|
-
M && M.trim() && (
|
|
6842
|
+
const M = L.speechQueue.filter((W) => W && W.text && Array.isArray(W.text) && W.text.length > 0).map((W) => W.text.map((ae) => ae.word || "").filter((ae) => ae.length > 0).join(" ")).filter((W) => W.length > 0).join(" ");
|
|
6843
|
+
M && M.trim() && (G = M.trim());
|
|
6844
6844
|
}
|
|
6845
6845
|
z.current && (P.current = {
|
|
6846
|
-
remainingText:
|
|
6846
|
+
remainingText: G || null,
|
|
6847
6847
|
originalText: z.current.text,
|
|
6848
6848
|
options: z.current.options
|
|
6849
|
-
}), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0,
|
|
6849
|
+
}), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, J(!0);
|
|
6850
6850
|
}
|
|
6851
6851
|
}
|
|
6852
|
-
}, []),
|
|
6853
|
-
if (!p.current || !
|
|
6852
|
+
}, []), te = E(async () => {
|
|
6853
|
+
if (!p.current || !Q)
|
|
6854
6854
|
return;
|
|
6855
6855
|
let L = "", B = {};
|
|
6856
6856
|
if (P.current && P.current.remainingText)
|
|
@@ -6858,28 +6858,28 @@ const Pe = Ie(({
|
|
|
6858
6858
|
else if (z.current && z.current.text)
|
|
6859
6859
|
L = z.current.text, B = z.current.options || {};
|
|
6860
6860
|
else {
|
|
6861
|
-
console.warn("Resume called but no paused speech found"),
|
|
6861
|
+
console.warn("Resume called but no paused speech found"), J(!1), T.current = !1;
|
|
6862
6862
|
return;
|
|
6863
6863
|
}
|
|
6864
|
-
|
|
6865
|
-
const
|
|
6864
|
+
J(!1), T.current = !1, await v();
|
|
6865
|
+
const G = {
|
|
6866
6866
|
...B,
|
|
6867
|
-
lipsyncLang: B.lipsyncLang ||
|
|
6867
|
+
lipsyncLang: B.lipsyncLang || pe.lipsyncLang || "en"
|
|
6868
6868
|
};
|
|
6869
6869
|
try {
|
|
6870
|
-
await w(L,
|
|
6870
|
+
await w(L, G);
|
|
6871
6871
|
} catch (M) {
|
|
6872
|
-
console.error("Error resuming speech:", M),
|
|
6872
|
+
console.error("Error resuming speech:", M), J(!1), T.current = !1;
|
|
6873
6873
|
}
|
|
6874
|
-
}, [v,
|
|
6874
|
+
}, [v, Q, w, pe]), q = E((L) => {
|
|
6875
6875
|
p.current && p.current.setMood(L);
|
|
6876
|
-
}, []),
|
|
6876
|
+
}, []), j = E((L) => {
|
|
6877
6877
|
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
|
|
6878
|
-
}, []),
|
|
6878
|
+
}, []), Ie = E((L, B = !1) => {
|
|
6879
6879
|
if (p.current && p.current.playAnimation) {
|
|
6880
6880
|
if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
|
|
6881
6881
|
try {
|
|
6882
|
-
p.current.setShowFullAvatar(
|
|
6882
|
+
p.current.setShowFullAvatar(C.current);
|
|
6883
6883
|
} catch (M) {
|
|
6884
6884
|
console.warn("Error setting full body mode:", M);
|
|
6885
6885
|
}
|
|
@@ -6890,25 +6890,25 @@ const Pe = Ie(({
|
|
|
6890
6890
|
console.warn(`Failed to play ${L}:`, M);
|
|
6891
6891
|
try {
|
|
6892
6892
|
p.current.setBodyMovement("idle");
|
|
6893
|
-
} catch (
|
|
6894
|
-
console.warn("Fallback animation also failed:",
|
|
6893
|
+
} catch (W) {
|
|
6894
|
+
console.warn("Fallback animation also failed:", W);
|
|
6895
6895
|
}
|
|
6896
6896
|
}
|
|
6897
6897
|
else {
|
|
6898
6898
|
const M = [".fbx", ".glb", ".gltf"];
|
|
6899
|
-
let
|
|
6900
|
-
for (const
|
|
6899
|
+
let W = !1;
|
|
6900
|
+
for (const ae of M)
|
|
6901
6901
|
try {
|
|
6902
|
-
p.current.playAnimation(L +
|
|
6902
|
+
p.current.playAnimation(L + ae, null, 10, 0, 0.01, B), W = !0;
|
|
6903
6903
|
break;
|
|
6904
6904
|
} catch {
|
|
6905
6905
|
}
|
|
6906
|
-
if (!
|
|
6906
|
+
if (!W) {
|
|
6907
6907
|
console.warn("Animation not found:", L);
|
|
6908
6908
|
try {
|
|
6909
6909
|
p.current.setBodyMovement("idle");
|
|
6910
|
-
} catch (
|
|
6911
|
-
console.warn("Fallback animation also failed:",
|
|
6910
|
+
} catch (ae) {
|
|
6911
|
+
console.warn("Fallback animation also failed:", ae);
|
|
6912
6912
|
}
|
|
6913
6913
|
}
|
|
6914
6914
|
}
|
|
@@ -6916,23 +6916,23 @@ const Pe = Ie(({
|
|
|
6916
6916
|
}, [x]), De = E(() => {
|
|
6917
6917
|
p.current && p.current.onResize && p.current.onResize();
|
|
6918
6918
|
}, []);
|
|
6919
|
-
return
|
|
6919
|
+
return Ae(I, () => ({
|
|
6920
6920
|
speakText: w,
|
|
6921
|
-
stopSpeaking:
|
|
6922
|
-
pauseSpeaking:
|
|
6923
|
-
resumeSpeaking:
|
|
6921
|
+
stopSpeaking: H,
|
|
6922
|
+
pauseSpeaking: U,
|
|
6923
|
+
resumeSpeaking: te,
|
|
6924
6924
|
resumeAudioContext: v,
|
|
6925
|
-
setMood:
|
|
6926
|
-
setTimingAdjustment:
|
|
6927
|
-
playAnimation:
|
|
6928
|
-
isReady:
|
|
6929
|
-
isPaused:
|
|
6925
|
+
setMood: q,
|
|
6926
|
+
setTimingAdjustment: j,
|
|
6927
|
+
playAnimation: Ie,
|
|
6928
|
+
isReady: X,
|
|
6929
|
+
isPaused: Q,
|
|
6930
6930
|
talkingHead: p.current,
|
|
6931
6931
|
handleResize: De,
|
|
6932
6932
|
setBodyMovement: (L) => {
|
|
6933
6933
|
if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
|
|
6934
6934
|
try {
|
|
6935
|
-
p.current.setShowFullAvatar(
|
|
6935
|
+
p.current.setShowFullAvatar(C.current), p.current.setBodyMovement(L);
|
|
6936
6936
|
} catch (B) {
|
|
6937
6937
|
console.warn("Error setting body movement:", B);
|
|
6938
6938
|
}
|
|
@@ -6941,7 +6941,7 @@ const Pe = Ie(({
|
|
|
6941
6941
|
playRandomDance: () => {
|
|
6942
6942
|
if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
|
|
6943
6943
|
try {
|
|
6944
|
-
p.current.setShowFullAvatar(
|
|
6944
|
+
p.current.setShowFullAvatar(C.current), p.current.playRandomDance();
|
|
6945
6945
|
} catch (L) {
|
|
6946
6946
|
console.warn("Error playing random dance:", L);
|
|
6947
6947
|
}
|
|
@@ -6949,7 +6949,7 @@ const Pe = Ie(({
|
|
|
6949
6949
|
playReaction: (L) => {
|
|
6950
6950
|
if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
|
|
6951
6951
|
try {
|
|
6952
|
-
p.current.setShowFullAvatar(
|
|
6952
|
+
p.current.setShowFullAvatar(C.current), p.current.playReaction(L);
|
|
6953
6953
|
} catch (B) {
|
|
6954
6954
|
console.warn("Error playing reaction:", B);
|
|
6955
6955
|
}
|
|
@@ -6957,7 +6957,7 @@ const Pe = Ie(({
|
|
|
6957
6957
|
playCelebration: () => {
|
|
6958
6958
|
if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
|
|
6959
6959
|
try {
|
|
6960
|
-
p.current.setShowFullAvatar(
|
|
6960
|
+
p.current.setShowFullAvatar(C.current), p.current.playCelebration();
|
|
6961
6961
|
} catch (L) {
|
|
6962
6962
|
console.warn("Error playing celebration:", L);
|
|
6963
6963
|
}
|
|
@@ -6965,7 +6965,7 @@ const Pe = Ie(({
|
|
|
6965
6965
|
setShowFullAvatar: (L) => {
|
|
6966
6966
|
if (p.current && p.current.setShowFullAvatar)
|
|
6967
6967
|
try {
|
|
6968
|
-
|
|
6968
|
+
C.current = L, p.current.setShowFullAvatar(L);
|
|
6969
6969
|
} catch (B) {
|
|
6970
6970
|
console.warn("Error setting showFullAvatar:", B);
|
|
6971
6971
|
}
|
|
@@ -6997,7 +6997,7 @@ const Pe = Ie(({
|
|
|
6997
6997
|
...y
|
|
6998
6998
|
},
|
|
6999
6999
|
children: [
|
|
7000
|
-
/* @__PURE__ */
|
|
7000
|
+
/* @__PURE__ */ de(
|
|
7001
7001
|
"div",
|
|
7002
7002
|
{
|
|
7003
7003
|
ref: D,
|
|
@@ -7009,7 +7009,7 @@ const Pe = Ie(({
|
|
|
7009
7009
|
}
|
|
7010
7010
|
}
|
|
7011
7011
|
),
|
|
7012
|
-
|
|
7012
|
+
ie && /* @__PURE__ */ de("div", { className: "loading-overlay", style: {
|
|
7013
7013
|
position: "absolute",
|
|
7014
7014
|
top: "50%",
|
|
7015
7015
|
left: "50%",
|
|
@@ -7018,7 +7018,7 @@ const Pe = Ie(({
|
|
|
7018
7018
|
fontSize: "18px",
|
|
7019
7019
|
zIndex: 10
|
|
7020
7020
|
}, children: "Loading avatar..." }),
|
|
7021
|
-
S && /* @__PURE__ */
|
|
7021
|
+
S && /* @__PURE__ */ de("div", { className: "error-overlay", style: {
|
|
7022
7022
|
position: "absolute",
|
|
7023
7023
|
top: "50%",
|
|
7024
7024
|
left: "50%",
|
|
@@ -7035,7 +7035,7 @@ const Pe = Ie(({
|
|
|
7035
7035
|
);
|
|
7036
7036
|
});
|
|
7037
7037
|
Pe.displayName = "TalkingHeadAvatar";
|
|
7038
|
-
const ut =
|
|
7038
|
+
const ut = Le(({
|
|
7039
7039
|
text: O = "Hello! I'm a talking avatar. How are you today?",
|
|
7040
7040
|
onLoading: t = () => {
|
|
7041
7041
|
},
|
|
@@ -7047,7 +7047,7 @@ const ut = Ie(({
|
|
|
7047
7047
|
style: s = {},
|
|
7048
7048
|
avatarConfig: o = {}
|
|
7049
7049
|
}, l) => {
|
|
7050
|
-
const u =
|
|
7050
|
+
const u = Z(null), a = Z(null), [h, r] = ge(!0), [c, d] = ge(null), [g, y] = ge(!1), x = Se(), I = o.ttsService || x.service, D = I === "browser" ? {
|
|
7051
7051
|
endpoint: "",
|
|
7052
7052
|
apiKey: null,
|
|
7053
7053
|
defaultVoice: "Google US English"
|
|
@@ -7071,7 +7071,7 @@ const ut = Ie(({
|
|
|
7071
7071
|
bodyMovement: "idle",
|
|
7072
7072
|
movementIntensity: 0.5,
|
|
7073
7073
|
...o
|
|
7074
|
-
},
|
|
7074
|
+
}, C = {
|
|
7075
7075
|
ttsEndpoint: D.endpoint,
|
|
7076
7076
|
ttsApikey: D.apiKey,
|
|
7077
7077
|
ttsService: I,
|
|
@@ -7080,27 +7080,27 @@ const ut = Ie(({
|
|
|
7080
7080
|
}, z = E(async () => {
|
|
7081
7081
|
if (!(!u.current || a.current))
|
|
7082
7082
|
try {
|
|
7083
|
-
if (r(!0), d(null), a.current = new Fe(u.current,
|
|
7084
|
-
if (
|
|
7085
|
-
const
|
|
7086
|
-
t(
|
|
7083
|
+
if (r(!0), d(null), a.current = new Fe(u.current, C), await a.current.showAvatar(p, (X) => {
|
|
7084
|
+
if (X.lengthComputable) {
|
|
7085
|
+
const Y = Math.min(100, Math.round(X.loaded / X.total * 100));
|
|
7086
|
+
t(Y);
|
|
7087
7087
|
}
|
|
7088
7088
|
}), a.current.morphs && a.current.morphs.length > 0) {
|
|
7089
|
-
const
|
|
7090
|
-
console.log("Available morph targets:", Object.keys(
|
|
7091
|
-
const
|
|
7092
|
-
console.log("Viseme morph targets found:",
|
|
7089
|
+
const X = a.current.morphs[0].morphTargetDictionary;
|
|
7090
|
+
console.log("Available morph targets:", Object.keys(X));
|
|
7091
|
+
const Y = Object.keys(X).filter((Q) => Q.startsWith("viseme_"));
|
|
7092
|
+
console.log("Viseme morph targets found:", Y), Y.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
|
|
7093
7093
|
}
|
|
7094
|
-
if (await new Promise((
|
|
7095
|
-
const
|
|
7096
|
-
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)),
|
|
7094
|
+
if (await new Promise((X) => {
|
|
7095
|
+
const Y = () => {
|
|
7096
|
+
a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), X()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Y, 100));
|
|
7097
7097
|
};
|
|
7098
|
-
|
|
7098
|
+
Y();
|
|
7099
7099
|
}), a.current && a.current.setShowFullAvatar)
|
|
7100
7100
|
try {
|
|
7101
7101
|
a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
|
|
7102
|
-
} catch (
|
|
7103
|
-
console.warn("Error setting full body mode on initialization:",
|
|
7102
|
+
} catch (X) {
|
|
7103
|
+
console.warn("Error setting full body mode on initialization:", X);
|
|
7104
7104
|
}
|
|
7105
7105
|
r(!1), y(!0), n(a.current);
|
|
7106
7106
|
const N = () => {
|
|
@@ -7113,7 +7113,7 @@ const ut = Ie(({
|
|
|
7113
7113
|
console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), r(!1), e(S);
|
|
7114
7114
|
}
|
|
7115
7115
|
}, []);
|
|
7116
|
-
|
|
7116
|
+
ye(() => (z(), () => {
|
|
7117
7117
|
a.current && (a.current.stop(), a.current.dispose(), a.current = null);
|
|
7118
7118
|
}), [z]);
|
|
7119
7119
|
const R = E((S) => {
|
|
@@ -7131,55 +7131,55 @@ const ut = Ie(({
|
|
|
7131
7131
|
a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
|
|
7132
7132
|
}, []), P = E((S) => {
|
|
7133
7133
|
a.current && a.current.setMood(S);
|
|
7134
|
-
}, []),
|
|
7134
|
+
}, []), ie = E((S) => {
|
|
7135
7135
|
a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
|
|
7136
|
-
}, []),
|
|
7136
|
+
}, []), he = E((S, N = !1) => {
|
|
7137
7137
|
if (a.current && a.current.playAnimation) {
|
|
7138
7138
|
if (a.current.setShowFullAvatar)
|
|
7139
7139
|
try {
|
|
7140
7140
|
a.current.setShowFullAvatar(!0);
|
|
7141
|
-
} catch (
|
|
7142
|
-
console.warn("Error setting full body mode:",
|
|
7141
|
+
} catch (Y) {
|
|
7142
|
+
console.warn("Error setting full body mode:", Y);
|
|
7143
7143
|
}
|
|
7144
7144
|
if (S.includes("."))
|
|
7145
7145
|
try {
|
|
7146
7146
|
a.current.playAnimation(S, null, 10, 0, 0.01, N), console.log("Playing animation:", S);
|
|
7147
|
-
} catch (
|
|
7148
|
-
console.log(`Failed to play ${S}:`,
|
|
7147
|
+
} catch (Y) {
|
|
7148
|
+
console.log(`Failed to play ${S}:`, Y);
|
|
7149
7149
|
try {
|
|
7150
7150
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7151
|
-
} catch (
|
|
7152
|
-
console.warn("Fallback animation also failed:",
|
|
7151
|
+
} catch (Q) {
|
|
7152
|
+
console.warn("Fallback animation also failed:", Q);
|
|
7153
7153
|
}
|
|
7154
7154
|
}
|
|
7155
7155
|
else {
|
|
7156
|
-
const
|
|
7157
|
-
let
|
|
7158
|
-
for (const
|
|
7156
|
+
const Y = [".fbx", ".glb", ".gltf"];
|
|
7157
|
+
let Q = !1;
|
|
7158
|
+
for (const J of Y)
|
|
7159
7159
|
try {
|
|
7160
|
-
a.current.playAnimation(S +
|
|
7160
|
+
a.current.playAnimation(S + J, null, 10, 0, 0.01, N), console.log("Playing animation:", S + J), Q = !0;
|
|
7161
7161
|
break;
|
|
7162
7162
|
} catch {
|
|
7163
|
-
console.log(`Failed to play ${S}${
|
|
7163
|
+
console.log(`Failed to play ${S}${J}, trying next format...`);
|
|
7164
7164
|
}
|
|
7165
|
-
if (!
|
|
7165
|
+
if (!Q) {
|
|
7166
7166
|
console.warn("Animation system not available or animation not found:", S);
|
|
7167
7167
|
try {
|
|
7168
7168
|
a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
|
|
7169
|
-
} catch (
|
|
7170
|
-
console.warn("Fallback animation also failed:",
|
|
7169
|
+
} catch (J) {
|
|
7170
|
+
console.warn("Fallback animation also failed:", J);
|
|
7171
7171
|
}
|
|
7172
7172
|
}
|
|
7173
7173
|
}
|
|
7174
7174
|
} else
|
|
7175
7175
|
console.warn("Animation system not available or animation not found:", S);
|
|
7176
7176
|
}, []);
|
|
7177
|
-
return
|
|
7177
|
+
return Ae(l, () => ({
|
|
7178
7178
|
speakText: R,
|
|
7179
7179
|
stopSpeaking: T,
|
|
7180
7180
|
setMood: P,
|
|
7181
|
-
setTimingAdjustment:
|
|
7182
|
-
playAnimation:
|
|
7181
|
+
setTimingAdjustment: ie,
|
|
7182
|
+
playAnimation: he,
|
|
7183
7183
|
isReady: g,
|
|
7184
7184
|
talkingHead: a.current,
|
|
7185
7185
|
setBodyMovement: (S) => {
|
|
@@ -7240,7 +7240,7 @@ const ut = Ie(({
|
|
|
7240
7240
|
}
|
|
7241
7241
|
}
|
|
7242
7242
|
})), /* @__PURE__ */ Ee("div", { className: `talking-head-container ${i}`, style: s, children: [
|
|
7243
|
-
/* @__PURE__ */
|
|
7243
|
+
/* @__PURE__ */ de(
|
|
7244
7244
|
"div",
|
|
7245
7245
|
{
|
|
7246
7246
|
ref: u,
|
|
@@ -7252,7 +7252,7 @@ const ut = Ie(({
|
|
|
7252
7252
|
}
|
|
7253
7253
|
}
|
|
7254
7254
|
),
|
|
7255
|
-
h && /* @__PURE__ */
|
|
7255
|
+
h && /* @__PURE__ */ de("div", { className: "loading-overlay", style: {
|
|
7256
7256
|
position: "absolute",
|
|
7257
7257
|
top: "50%",
|
|
7258
7258
|
left: "50%",
|
|
@@ -7261,7 +7261,7 @@ const ut = Ie(({
|
|
|
7261
7261
|
fontSize: "18px",
|
|
7262
7262
|
zIndex: 10
|
|
7263
7263
|
}, children: "Loading avatar..." }),
|
|
7264
|
-
c && /* @__PURE__ */
|
|
7264
|
+
c && /* @__PURE__ */ de("div", { className: "error-overlay", style: {
|
|
7265
7265
|
position: "absolute",
|
|
7266
7266
|
top: "50%",
|
|
7267
7267
|
left: "50%",
|
|
@@ -7276,7 +7276,7 @@ const ut = Ie(({
|
|
|
7276
7276
|
] });
|
|
7277
7277
|
});
|
|
7278
7278
|
ut.displayName = "TalkingHeadComponent";
|
|
7279
|
-
const ct =
|
|
7279
|
+
const ct = Le(({
|
|
7280
7280
|
curriculumData: O = null,
|
|
7281
7281
|
avatarConfig: t = {},
|
|
7282
7282
|
animations: e = {},
|
|
@@ -7292,7 +7292,7 @@ const ct = Ie(({
|
|
|
7292
7292
|
},
|
|
7293
7293
|
autoStart: u = !1
|
|
7294
7294
|
}, a) => {
|
|
7295
|
-
const h =
|
|
7295
|
+
const h = Z(null), r = Z({
|
|
7296
7296
|
currentModuleIndex: 0,
|
|
7297
7297
|
currentLessonIndex: 0,
|
|
7298
7298
|
currentQuestionIndex: 0,
|
|
@@ -7302,18 +7302,18 @@ const ct = Ie(({
|
|
|
7302
7302
|
curriculumCompleted: !1,
|
|
7303
7303
|
score: 0,
|
|
7304
7304
|
totalQuestions: 0
|
|
7305
|
-
}), c =
|
|
7305
|
+
}), c = Z({
|
|
7306
7306
|
onLessonStart: n,
|
|
7307
7307
|
onLessonComplete: i,
|
|
7308
7308
|
onQuestionAnswer: s,
|
|
7309
7309
|
onCurriculumComplete: o,
|
|
7310
7310
|
onCustomAction: l
|
|
7311
|
-
}), d =
|
|
7311
|
+
}), d = Z(null), g = Z(null), y = Z(null), x = Z(null), I = Z(null), D = Z(null), p = Z(null), C = Z(O?.curriculum || {
|
|
7312
7312
|
title: "Default Curriculum",
|
|
7313
7313
|
description: "No curriculum data provided",
|
|
7314
7314
|
language: "en",
|
|
7315
7315
|
modules: []
|
|
7316
|
-
}), z =
|
|
7316
|
+
}), z = Z({
|
|
7317
7317
|
avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
|
|
7318
7318
|
avatarBody: t.avatarBody || "F",
|
|
7319
7319
|
mood: t.mood || "happy",
|
|
@@ -7327,7 +7327,7 @@ const ct = Ie(({
|
|
|
7327
7327
|
animations: e,
|
|
7328
7328
|
lipsyncLang: "en"
|
|
7329
7329
|
});
|
|
7330
|
-
|
|
7330
|
+
ye(() => {
|
|
7331
7331
|
c.current = {
|
|
7332
7332
|
onLessonStart: n,
|
|
7333
7333
|
onLessonComplete: i,
|
|
@@ -7335,8 +7335,8 @@ const ct = Ie(({
|
|
|
7335
7335
|
onCurriculumComplete: o,
|
|
7336
7336
|
onCustomAction: l
|
|
7337
7337
|
};
|
|
7338
|
-
}, [n, i, s, o, l]),
|
|
7339
|
-
|
|
7338
|
+
}, [n, i, s, o, l]), ye(() => {
|
|
7339
|
+
C.current = O?.curriculum || {
|
|
7340
7340
|
title: "Default Curriculum",
|
|
7341
7341
|
description: "No curriculum data provided",
|
|
7342
7342
|
language: "en",
|
|
@@ -7356,7 +7356,7 @@ const ct = Ie(({
|
|
|
7356
7356
|
lipsyncLang: "en"
|
|
7357
7357
|
};
|
|
7358
7358
|
}, [O, t, e]);
|
|
7359
|
-
const R = E(() => (
|
|
7359
|
+
const R = E(() => (C.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), T = E(() => R()?.questions[r.current.currentQuestionIndex], [R]), P = E((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), ie = E(() => {
|
|
7360
7360
|
r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
|
|
7361
7361
|
const b = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
|
|
7362
7362
|
let v = "Congratulations! You've completed this lesson";
|
|
@@ -7380,9 +7380,9 @@ const ct = Ie(({
|
|
|
7380
7380
|
} catch {
|
|
7381
7381
|
h.current.playCelebration();
|
|
7382
7382
|
}
|
|
7383
|
-
const w =
|
|
7383
|
+
const w = C.current || { modules: [] }, H = w.modules[r.current.currentModuleIndex], U = r.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = U || te, j = z.current || { lipsyncLang: "en" };
|
|
7384
7384
|
h.current.speakText(v, {
|
|
7385
|
-
lipsyncLang:
|
|
7385
|
+
lipsyncLang: j.lipsyncLang,
|
|
7386
7386
|
onSpeechEnd: () => {
|
|
7387
7387
|
c.current.onCustomAction({
|
|
7388
7388
|
type: "lessonCompleteFeedbackDone",
|
|
@@ -7391,14 +7391,14 @@ const ct = Ie(({
|
|
|
7391
7391
|
score: r.current.score,
|
|
7392
7392
|
totalQuestions: r.current.totalQuestions,
|
|
7393
7393
|
percentage: b,
|
|
7394
|
-
hasNextLesson:
|
|
7394
|
+
hasNextLesson: q
|
|
7395
7395
|
});
|
|
7396
7396
|
}
|
|
7397
7397
|
});
|
|
7398
7398
|
}
|
|
7399
|
-
}, [e.lessonComplete]),
|
|
7399
|
+
}, [e.lessonComplete]), he = E(() => {
|
|
7400
7400
|
r.current.curriculumCompleted = !0;
|
|
7401
|
-
const b =
|
|
7401
|
+
const b = C.current || { modules: [] };
|
|
7402
7402
|
if (c.current.onCurriculumComplete({
|
|
7403
7403
|
modules: b.modules.length,
|
|
7404
7404
|
totalLessons: b.modules.reduce((v, w) => v + w.lessons.length, 0)
|
|
@@ -7430,23 +7430,23 @@ const ct = Ie(({
|
|
|
7430
7430
|
if (h.current.setMood("happy"), e.questionStart)
|
|
7431
7431
|
try {
|
|
7432
7432
|
h.current.playAnimation(e.questionStart, !0);
|
|
7433
|
-
} catch (
|
|
7434
|
-
console.warn("Failed to play questionStart animation:",
|
|
7433
|
+
} catch (U) {
|
|
7434
|
+
console.warn("Failed to play questionStart animation:", U);
|
|
7435
7435
|
}
|
|
7436
|
-
const
|
|
7437
|
-
v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang:
|
|
7436
|
+
const H = z.current || { lipsyncLang: "en" };
|
|
7437
|
+
v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: H.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: H.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: H.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: H.lipsyncLang });
|
|
7438
7438
|
};
|
|
7439
7439
|
if (h.current && h.current.isReady && v)
|
|
7440
7440
|
w();
|
|
7441
7441
|
else if (h.current && h.current.isReady) {
|
|
7442
|
-
const
|
|
7443
|
-
h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang:
|
|
7442
|
+
const H = z.current || { lipsyncLang: "en" };
|
|
7443
|
+
h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: H.lipsyncLang });
|
|
7444
7444
|
} else {
|
|
7445
|
-
const
|
|
7446
|
-
h.current && h.current.isReady && (clearInterval(
|
|
7445
|
+
const H = setInterval(() => {
|
|
7446
|
+
h.current && h.current.isReady && (clearInterval(H), v && w());
|
|
7447
7447
|
}, 100);
|
|
7448
7448
|
setTimeout(() => {
|
|
7449
|
-
clearInterval(
|
|
7449
|
+
clearInterval(H);
|
|
7450
7450
|
}, 5e3);
|
|
7451
7451
|
}
|
|
7452
7452
|
}, [e.questionStart, R, T]), N = E(() => {
|
|
@@ -7468,28 +7468,40 @@ const ct = Ie(({
|
|
|
7468
7468
|
if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
|
|
7469
7469
|
try {
|
|
7470
7470
|
h.current.playAnimation(e.nextQuestion, !0);
|
|
7471
|
-
} catch (
|
|
7472
|
-
console.warn("Failed to play nextQuestion animation:",
|
|
7471
|
+
} catch (j) {
|
|
7472
|
+
console.warn("Failed to play nextQuestion animation:", j);
|
|
7473
7473
|
}
|
|
7474
|
-
const
|
|
7475
|
-
v.type === "code_test"
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7474
|
+
const H = z.current || { lipsyncLang: "en" }, te = R()?.questions?.length || 0, q = r.current.currentQuestionIndex >= te - 1;
|
|
7475
|
+
if (v.type === "code_test") {
|
|
7476
|
+
const j = q ? `Great! Here's your final coding challenge: ${v.question}` : `Great! Now let's move on to your next coding challenge: ${v.question}`;
|
|
7477
|
+
h.current.speakText(j, {
|
|
7478
|
+
lipsyncLang: H.lipsyncLang
|
|
7479
|
+
});
|
|
7480
|
+
} else if (v.type === "multiple_choice") {
|
|
7481
|
+
const j = q ? `Alright! Here's your final question: ${v.question}` : `Alright! Here's your next question: ${v.question}`;
|
|
7482
|
+
h.current.speakText(j, {
|
|
7483
|
+
lipsyncLang: H.lipsyncLang
|
|
7484
|
+
});
|
|
7485
|
+
} else if (v.type === "true_false") {
|
|
7486
|
+
const j = q ? `Now let's try this final one: ${v.question}` : `Now let's try this one: ${v.question}`;
|
|
7487
|
+
h.current.speakText(j, {
|
|
7488
|
+
lipsyncLang: H.lipsyncLang
|
|
7489
|
+
});
|
|
7490
|
+
} else {
|
|
7491
|
+
const j = q ? `Here's your final question: ${v.question}` : `Here's the next question: ${v.question}`;
|
|
7492
|
+
h.current.speakText(j, {
|
|
7493
|
+
lipsyncLang: H.lipsyncLang
|
|
7494
|
+
});
|
|
7495
|
+
}
|
|
7484
7496
|
};
|
|
7485
7497
|
if (h.current && h.current.isReady && v)
|
|
7486
7498
|
w();
|
|
7487
7499
|
else if (v) {
|
|
7488
|
-
const
|
|
7489
|
-
h.current && h.current.isReady && (clearInterval(
|
|
7500
|
+
const H = setInterval(() => {
|
|
7501
|
+
h.current && h.current.isReady && (clearInterval(H), w());
|
|
7490
7502
|
}, 100);
|
|
7491
7503
|
setTimeout(() => {
|
|
7492
|
-
clearInterval(
|
|
7504
|
+
clearInterval(H);
|
|
7493
7505
|
}, 5e3);
|
|
7494
7506
|
}
|
|
7495
7507
|
} else
|
|
@@ -7500,16 +7512,16 @@ const ct = Ie(({
|
|
|
7500
7512
|
totalQuestions: r.current.totalQuestions,
|
|
7501
7513
|
score: r.current.score
|
|
7502
7514
|
});
|
|
7503
|
-
}, [e.nextQuestion, R, T]),
|
|
7504
|
-
const b =
|
|
7515
|
+
}, [e.nextQuestion, R, T]), X = E(() => {
|
|
7516
|
+
const b = C.current || { modules: [] }, v = b.modules[r.current.currentModuleIndex];
|
|
7505
7517
|
if (r.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
|
|
7506
7518
|
r.current.currentLessonIndex += 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
|
|
7507
|
-
const
|
|
7519
|
+
const H = b.modules[r.current.currentModuleIndex], U = r.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = U || te;
|
|
7508
7520
|
c.current.onCustomAction({
|
|
7509
7521
|
type: "lessonStart",
|
|
7510
7522
|
moduleIndex: r.current.currentModuleIndex,
|
|
7511
7523
|
lessonIndex: r.current.currentLessonIndex,
|
|
7512
|
-
hasNextLesson:
|
|
7524
|
+
hasNextLesson: q
|
|
7513
7525
|
}), c.current.onLessonStart({
|
|
7514
7526
|
moduleIndex: r.current.currentModuleIndex,
|
|
7515
7527
|
lessonIndex: r.current.currentLessonIndex,
|
|
@@ -7517,12 +7529,12 @@ const ct = Ie(({
|
|
|
7517
7529
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7518
7530
|
} else if (r.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
|
|
7519
7531
|
r.current.currentModuleIndex += 1, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
|
|
7520
|
-
const
|
|
7532
|
+
const U = b.modules[r.current.currentModuleIndex], te = r.current.currentLessonIndex < (U?.lessons?.length || 0) - 1, q = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, j = te || q;
|
|
7521
7533
|
c.current.onCustomAction({
|
|
7522
7534
|
type: "lessonStart",
|
|
7523
7535
|
moduleIndex: r.current.currentModuleIndex,
|
|
7524
7536
|
lessonIndex: r.current.currentLessonIndex,
|
|
7525
|
-
hasNextLesson:
|
|
7537
|
+
hasNextLesson: j
|
|
7526
7538
|
}), c.current.onLessonStart({
|
|
7527
7539
|
moduleIndex: r.current.currentModuleIndex,
|
|
7528
7540
|
lessonIndex: r.current.currentLessonIndex,
|
|
@@ -7530,12 +7542,12 @@ const ct = Ie(({
|
|
|
7530
7542
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7531
7543
|
} else
|
|
7532
7544
|
I.current && I.current();
|
|
7533
|
-
}, []),
|
|
7545
|
+
}, []), Y = E(() => {
|
|
7534
7546
|
const b = R();
|
|
7535
7547
|
let v = null;
|
|
7536
7548
|
if (b?.avatar_script && b?.body) {
|
|
7537
|
-
const w = b.avatar_script.trim(),
|
|
7538
|
-
v = `${w}${
|
|
7549
|
+
const w = b.avatar_script.trim(), H = b.body.trim(), U = w.match(/[.!?]$/) ? " " : ". ";
|
|
7550
|
+
v = `${w}${U}${H}`;
|
|
7539
7551
|
} else
|
|
7540
7552
|
v = b?.avatar_script || b?.body || null;
|
|
7541
7553
|
if (h.current && h.current.isReady && v) {
|
|
@@ -7544,11 +7556,11 @@ const ct = Ie(({
|
|
|
7544
7556
|
if (e.teaching)
|
|
7545
7557
|
try {
|
|
7546
7558
|
h.current.playAnimation(e.teaching, !0), w = !0;
|
|
7547
|
-
} catch (
|
|
7548
|
-
console.warn("Failed to play teaching animation:",
|
|
7559
|
+
} catch (U) {
|
|
7560
|
+
console.warn("Failed to play teaching animation:", U);
|
|
7549
7561
|
}
|
|
7550
7562
|
w || h.current.setBodyMovement("gesturing");
|
|
7551
|
-
const
|
|
7563
|
+
const H = z.current || { lipsyncLang: "en" };
|
|
7552
7564
|
c.current.onLessonStart({
|
|
7553
7565
|
moduleIndex: r.current.currentModuleIndex,
|
|
7554
7566
|
lessonIndex: r.current.currentLessonIndex,
|
|
@@ -7559,7 +7571,7 @@ const ct = Ie(({
|
|
|
7559
7571
|
lessonIndex: r.current.currentLessonIndex,
|
|
7560
7572
|
lesson: b
|
|
7561
7573
|
}), h.current.speakText(v, {
|
|
7562
|
-
lipsyncLang:
|
|
7574
|
+
lipsyncLang: H.lipsyncLang,
|
|
7563
7575
|
onSpeechEnd: () => {
|
|
7564
7576
|
r.current.isTeaching = !1, c.current.onCustomAction({
|
|
7565
7577
|
type: "teachingComplete",
|
|
@@ -7571,7 +7583,7 @@ const ct = Ie(({
|
|
|
7571
7583
|
}
|
|
7572
7584
|
});
|
|
7573
7585
|
}
|
|
7574
|
-
}, [e.teaching, R]),
|
|
7586
|
+
}, [e.teaching, R]), Q = E((b) => {
|
|
7575
7587
|
const v = T(), w = P(b, v);
|
|
7576
7588
|
if (w && (r.current.score += 1), c.current.onQuestionAnswer({
|
|
7577
7589
|
moduleIndex: r.current.currentModuleIndex,
|
|
@@ -7589,18 +7601,19 @@ const ct = Ie(({
|
|
|
7589
7601
|
h.current.setBodyMovement("happy");
|
|
7590
7602
|
}
|
|
7591
7603
|
h.current.setBodyMovement("gesturing");
|
|
7592
|
-
const
|
|
7593
|
-
|
|
7594
|
-
|
|
7604
|
+
const U = R()?.questions?.length || 0;
|
|
7605
|
+
r.current.currentQuestionIndex >= U - 1;
|
|
7606
|
+
const te = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, q = z.current || { lipsyncLang: "en" };
|
|
7607
|
+
h.current.speakText(te, {
|
|
7608
|
+
lipsyncLang: q.lipsyncLang,
|
|
7595
7609
|
onSpeechEnd: () => {
|
|
7596
|
-
const ie = R()?.questions?.length || 0;
|
|
7597
7610
|
c.current.onCustomAction({
|
|
7598
7611
|
type: "answerFeedbackComplete",
|
|
7599
7612
|
moduleIndex: r.current.currentModuleIndex,
|
|
7600
7613
|
lessonIndex: r.current.currentLessonIndex,
|
|
7601
7614
|
questionIndex: r.current.currentQuestionIndex,
|
|
7602
7615
|
isCorrect: !0,
|
|
7603
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7616
|
+
hasNextQuestion: r.current.currentQuestionIndex < U - 1,
|
|
7604
7617
|
score: r.current.score,
|
|
7605
7618
|
totalQuestions: r.current.totalQuestions
|
|
7606
7619
|
});
|
|
@@ -7614,18 +7627,17 @@ const ct = Ie(({
|
|
|
7614
7627
|
h.current.setBodyMovement("idle");
|
|
7615
7628
|
}
|
|
7616
7629
|
h.current.setBodyMovement("gesturing");
|
|
7617
|
-
const
|
|
7618
|
-
h.current.speakText(
|
|
7619
|
-
lipsyncLang:
|
|
7630
|
+
const U = R()?.questions?.length || 0, te = r.current.currentQuestionIndex >= U - 1, q = 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 || ""}${te ? "" : " Let's move on to the next question."}`, j = z.current || { lipsyncLang: "en" };
|
|
7631
|
+
h.current.speakText(q, {
|
|
7632
|
+
lipsyncLang: j.lipsyncLang,
|
|
7620
7633
|
onSpeechEnd: () => {
|
|
7621
|
-
const ie = R()?.questions?.length || 0;
|
|
7622
7634
|
c.current.onCustomAction({
|
|
7623
7635
|
type: "answerFeedbackComplete",
|
|
7624
7636
|
moduleIndex: r.current.currentModuleIndex,
|
|
7625
7637
|
lessonIndex: r.current.currentLessonIndex,
|
|
7626
7638
|
questionIndex: r.current.currentQuestionIndex,
|
|
7627
7639
|
isCorrect: !1,
|
|
7628
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7640
|
+
hasNextQuestion: r.current.currentQuestionIndex < U - 1,
|
|
7629
7641
|
score: r.current.score,
|
|
7630
7642
|
totalQuestions: r.current.totalQuestions
|
|
7631
7643
|
});
|
|
@@ -7633,20 +7645,20 @@ const ct = Ie(({
|
|
|
7633
7645
|
});
|
|
7634
7646
|
}
|
|
7635
7647
|
else {
|
|
7636
|
-
const
|
|
7648
|
+
const U = R()?.questions?.length || 0;
|
|
7637
7649
|
c.current.onCustomAction({
|
|
7638
7650
|
type: "answerFeedbackComplete",
|
|
7639
7651
|
moduleIndex: r.current.currentModuleIndex,
|
|
7640
7652
|
lessonIndex: r.current.currentLessonIndex,
|
|
7641
7653
|
questionIndex: r.current.currentQuestionIndex,
|
|
7642
7654
|
isCorrect: w,
|
|
7643
|
-
hasNextQuestion: r.current.currentQuestionIndex <
|
|
7655
|
+
hasNextQuestion: r.current.currentQuestionIndex < U - 1,
|
|
7644
7656
|
score: r.current.score,
|
|
7645
7657
|
totalQuestions: r.current.totalQuestions,
|
|
7646
7658
|
avatarNotReady: !0
|
|
7647
7659
|
});
|
|
7648
7660
|
}
|
|
7649
|
-
}, [e.correct, e.incorrect, T, R, P]),
|
|
7661
|
+
}, [e.correct, e.incorrect, T, R, P]), J = E((b) => {
|
|
7650
7662
|
const v = T();
|
|
7651
7663
|
if (!b || typeof b != "object") {
|
|
7652
7664
|
console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
|
|
@@ -7674,7 +7686,7 @@ const ct = Ie(({
|
|
|
7674
7686
|
testResult: w,
|
|
7675
7687
|
question: v
|
|
7676
7688
|
}), p.current && p.current(w);
|
|
7677
|
-
}, [T, P]),
|
|
7689
|
+
}, [T, P]), oe = E(() => {
|
|
7678
7690
|
if (r.current.currentQuestionIndex > 0) {
|
|
7679
7691
|
r.current.currentQuestionIndex -= 1;
|
|
7680
7692
|
const b = T();
|
|
@@ -7708,8 +7720,8 @@ const ct = Ie(({
|
|
|
7708
7720
|
}, 5e3);
|
|
7709
7721
|
}
|
|
7710
7722
|
}
|
|
7711
|
-
}, [T]),
|
|
7712
|
-
const b =
|
|
7723
|
+
}, [T]), me = E(() => {
|
|
7724
|
+
const b = C.current || { modules: [] };
|
|
7713
7725
|
if (b.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
|
|
7714
7726
|
r.current.currentLessonIndex -= 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
|
|
7715
7727
|
type: "lessonStart",
|
|
@@ -7721,8 +7733,8 @@ const ct = Ie(({
|
|
|
7721
7733
|
lesson: R()
|
|
7722
7734
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7723
7735
|
else if (r.current.currentModuleIndex > 0) {
|
|
7724
|
-
const
|
|
7725
|
-
r.current.currentModuleIndex -= 1, r.current.currentLessonIndex = (
|
|
7736
|
+
const H = b.modules[r.current.currentModuleIndex - 1];
|
|
7737
|
+
r.current.currentModuleIndex -= 1, r.current.currentLessonIndex = (H?.lessons?.length || 1) - 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
|
|
7726
7738
|
type: "lessonStart",
|
|
7727
7739
|
moduleIndex: r.current.currentModuleIndex,
|
|
7728
7740
|
lessonIndex: r.current.currentLessonIndex
|
|
@@ -7732,9 +7744,9 @@ const ct = Ie(({
|
|
|
7732
7744
|
lesson: R()
|
|
7733
7745
|
}), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
|
|
7734
7746
|
}
|
|
7735
|
-
}, [R]),
|
|
7747
|
+
}, [R]), se = E(() => {
|
|
7736
7748
|
r.current.currentModuleIndex = 0, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.isTeaching = !1, r.current.isQuestionMode = !1, r.current.lessonCompleted = !1, r.current.curriculumCompleted = !1, r.current.score = 0, r.current.totalQuestions = 0;
|
|
7737
|
-
}, []),
|
|
7749
|
+
}, []), pe = E((b) => {
|
|
7738
7750
|
console.log("Avatar is ready!", b);
|
|
7739
7751
|
const v = R(), w = v?.avatar_script || v?.body;
|
|
7740
7752
|
u && w && setTimeout(() => {
|
|
@@ -7742,20 +7754,20 @@ const ct = Ie(({
|
|
|
7742
7754
|
}, 10);
|
|
7743
7755
|
}, [u, R]);
|
|
7744
7756
|
We(() => {
|
|
7745
|
-
d.current =
|
|
7746
|
-
}),
|
|
7757
|
+
d.current = Y, g.current = X, y.current = ie, x.current = N, I.current = he, D.current = S, p.current = Q;
|
|
7758
|
+
}), Ae(a, () => ({
|
|
7747
7759
|
// Curriculum control methods
|
|
7748
|
-
startTeaching:
|
|
7760
|
+
startTeaching: Y,
|
|
7749
7761
|
startQuestions: S,
|
|
7750
|
-
handleAnswerSelect:
|
|
7751
|
-
handleCodeTestResult:
|
|
7762
|
+
handleAnswerSelect: Q,
|
|
7763
|
+
handleCodeTestResult: J,
|
|
7752
7764
|
nextQuestion: N,
|
|
7753
|
-
previousQuestion:
|
|
7754
|
-
nextLesson:
|
|
7755
|
-
previousLesson:
|
|
7756
|
-
completeLesson:
|
|
7757
|
-
completeCurriculum:
|
|
7758
|
-
resetCurriculum:
|
|
7765
|
+
previousQuestion: oe,
|
|
7766
|
+
nextLesson: X,
|
|
7767
|
+
previousLesson: me,
|
|
7768
|
+
completeLesson: ie,
|
|
7769
|
+
completeCurriculum: he,
|
|
7770
|
+
resetCurriculum: se,
|
|
7759
7771
|
getState: () => ({ ...r.current }),
|
|
7760
7772
|
getCurrentQuestion: () => T(),
|
|
7761
7773
|
getCurrentLesson: () => R(),
|
|
@@ -7809,8 +7821,8 @@ const ct = Ie(({
|
|
|
7809
7821
|
handleResize: () => h.current?.handleResize(),
|
|
7810
7822
|
// Avatar readiness check (always returns current value)
|
|
7811
7823
|
isAvatarReady: () => h.current?.isReady || !1
|
|
7812
|
-
}), [
|
|
7813
|
-
const
|
|
7824
|
+
}), [Y, S, Q, J, N, X, ie, he, se, T, R]);
|
|
7825
|
+
const ee = z.current || {
|
|
7814
7826
|
avatarUrl: "/avatars/brunette.glb",
|
|
7815
7827
|
avatarBody: "F",
|
|
7816
7828
|
mood: "happy",
|
|
@@ -7823,23 +7835,23 @@ const ct = Ie(({
|
|
|
7823
7835
|
showFullAvatar: !1,
|
|
7824
7836
|
animations: e
|
|
7825
7837
|
};
|
|
7826
|
-
return /* @__PURE__ */
|
|
7838
|
+
return /* @__PURE__ */ de("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ de(
|
|
7827
7839
|
Pe,
|
|
7828
7840
|
{
|
|
7829
7841
|
ref: h,
|
|
7830
|
-
avatarUrl:
|
|
7831
|
-
avatarBody:
|
|
7832
|
-
mood:
|
|
7833
|
-
ttsLang:
|
|
7834
|
-
ttsService:
|
|
7835
|
-
ttsVoice:
|
|
7836
|
-
ttsApiKey:
|
|
7837
|
-
bodyMovement:
|
|
7838
|
-
movementIntensity:
|
|
7839
|
-
showFullAvatar:
|
|
7842
|
+
avatarUrl: ee.avatarUrl,
|
|
7843
|
+
avatarBody: ee.avatarBody,
|
|
7844
|
+
mood: ee.mood,
|
|
7845
|
+
ttsLang: ee.ttsLang,
|
|
7846
|
+
ttsService: ee.ttsService,
|
|
7847
|
+
ttsVoice: ee.ttsVoice,
|
|
7848
|
+
ttsApiKey: ee.ttsApiKey,
|
|
7849
|
+
bodyMovement: ee.bodyMovement,
|
|
7850
|
+
movementIntensity: ee.movementIntensity,
|
|
7851
|
+
showFullAvatar: ee.showFullAvatar,
|
|
7840
7852
|
cameraView: "upper",
|
|
7841
|
-
animations:
|
|
7842
|
-
onReady:
|
|
7853
|
+
animations: ee.animations,
|
|
7854
|
+
onReady: pe,
|
|
7843
7855
|
onLoading: () => {
|
|
7844
7856
|
},
|
|
7845
7857
|
onError: (b) => {
|
|
@@ -7958,7 +7970,7 @@ export {
|
|
|
7958
7970
|
Pe as TalkingHeadAvatar,
|
|
7959
7971
|
ut as TalkingHeadComponent,
|
|
7960
7972
|
Be as animations,
|
|
7961
|
-
|
|
7973
|
+
Se as getActiveTTSConfig,
|
|
7962
7974
|
It as getAnimation,
|
|
7963
7975
|
Rt as getVoiceOptions,
|
|
7964
7976
|
Lt as hasAnimation
|