@sage-rsc/talking-head-react 1.0.73 → 1.0.75

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.js CHANGED
@@ -8,7 +8,7 @@ import { FBXLoader as Oe } from "three/addons/loaders/FBXLoader.js";
8
8
  import { RoomEnvironment as qe } from "three/addons/environments/RoomEnvironment.js";
9
9
  import Ke from "three/addons/libs/stats.module.js";
10
10
  let m, re, ue;
11
- const A = [0, 0, 0, 0], k = new x.Vector3(), ze = new x.Vector3(), ne = new x.Vector3(), Ce = new x.Vector3();
11
+ const A = [0, 0, 0, 0], w = new x.Vector3(), ze = new x.Vector3(), ne = new x.Vector3(), Ce = new x.Vector3();
12
12
  new x.Plane();
13
13
  new x.Ray();
14
14
  new x.Euler();
@@ -321,7 +321,7 @@ class et {
321
321
  /// Bone's parent object
322
322
  vBasis: r.position.clone(),
323
323
  // Original local position
324
- vWorld: r.parent.getWorldPosition(k).clone(),
324
+ vWorld: r.parent.getWorldPosition(w).clone(),
325
325
  // World position, parent
326
326
  qBasis: r.parent.quaternion.clone(),
327
327
  // Original quaternion, parent
@@ -338,7 +338,7 @@ class et {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- u.boneParent.matrixWorld.decompose(k, ie, ne), k.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, k).invert()).normalize(), u.qWorldInverseYaw = ie.clone().normalize(), this.data.push(u), this.dict[h] = u;
341
+ u.boneParent.matrixWorld.decompose(w, ie, ne), w.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, w).invert()).normalize(), u.qWorldInverseYaw = ie.clone().normalize(), this.data.push(u), this.dict[h] = u;
342
342
  try {
343
343
  this.setValue(h, "type", s.type), this.setValue(h, "stiffness", s.stiffness), this.setValue(h, "damping", s.damping), this.setValue(h, "external", s.external), this.setValue(h, "limits", s.limits), this.setValue(h, "excludes", s.excludes), this.setValue(h, "deltaLocal", s.deltaLocal), this.setValue(h, "deltaWorld", s.deltaWorld), this.setValue(h, "pivot", s.pivot), this.setValue(h, "helper", s.helper);
344
344
  } catch (a) {
@@ -356,22 +356,22 @@ class et {
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), fe.copy(o.boneParent.matrixWorld), xe.copy(fe).invert(), o.vWorld.setFromMatrixPosition(fe), k.applyMatrix4(xe), 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)
359
+ if (o = this.data[e], w.copy(o.vWorld), fe.copy(o.boneParent.matrixWorld), xe.copy(fe).invert(), o.vWorld.setFromMatrixPosition(fe), w.applyMatrix4(xe), 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 (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
- 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(
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
- ), k.applyMatrix4(fe), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(xe), 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)
366
+ ), w.applyMatrix4(fe), w.x += m[0], w.y += m[1], w.z += m[2], w.applyMatrix4(xe), 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(k, ie, ne), k.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, k).invert()).normalize(), o.boneParent.quaternion.multiply(ie.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), ie.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(ie)), 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), ie.setFromAxisAngle(_e, -m), o.boneParent.quaternion.multiply(ie)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), ie.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(ie)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
372
+ else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(w, ie, ne), w.copy(He).applyQuaternion(ie).setY(0).normalize(), ie.premultiply(Ne.setFromUnitVectors(He, w).invert()).normalize(), o.boneParent.quaternion.multiply(ie.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), ie.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(ie)), 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), ie.setFromAxisAngle(_e, -m), o.boneParent.quaternion.multiply(ie)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), ie.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(ie)), 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], ne.set(0, 0, 0), m.deltaLocal && (ne.x += m.deltaLocal[0], ne.y += m.deltaLocal[1], ne.z += m.deltaLocal[2]), ne.applyMatrix4(m.bone.matrixWorld), xe.copy(o.boneParent.matrixWorld).invert(), ne.applyMatrix4(xe), k.copy(o.bone.position), !(k.distanceToSquared(ne) >= m.radiusSq) && (ue = k.length(), re = ne.length(), !(re > m.radius + ue) && (re < Math.abs(m.radius - ue) || (re = (re * re + ue * ue - m.radiusSq) / (2 * re), ne.normalize(), Ce.copy(ne).multiplyScalar(re), re = Math.sqrt(ue * ue - re * re), k.subVectors(k, Ce).projectOnPlane(ne).normalize().multiplyScalar(re), ze.subVectors(o.vBasis, Ce).projectOnPlane(ne).normalize(), ue = ze.dot(k), ue < 0 && (ue = Math.sqrt(re * re - ue * ue), ze.multiplyScalar(ue), k.add(ze)), k.add(Ce).normalize(), ne.copy(o.bone.position).normalize(), ie.setFromUnitVectors(ne, k), o.boneParent.quaternion.premultiply(ie), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[n], ne.set(0, 0, 0), m.deltaLocal && (ne.x += m.deltaLocal[0], ne.y += m.deltaLocal[1], ne.z += m.deltaLocal[2]), ne.applyMatrix4(m.bone.matrixWorld), xe.copy(o.boneParent.matrixWorld).invert(), ne.applyMatrix4(xe), w.copy(o.bone.position), !(w.distanceToSquared(ne) >= m.radiusSq) && (ue = w.length(), re = ne.length(), !(re > m.radius + ue) && (re < Math.abs(m.radius - ue) || (re = (re * re + ue * ue - m.radiusSq) / (2 * re), ne.normalize(), Ce.copy(ne).multiplyScalar(re), re = Math.sqrt(ue * ue - re * re), w.subVectors(w, Ce).projectOnPlane(ne).normalize().multiplyScalar(re), ze.subVectors(o.vBasis, Ce).projectOnPlane(ne).normalize(), ue = ze.dot(w), ue < 0 && (ue = Math.sqrt(re * re - ue * ue), ze.multiplyScalar(ue), w.add(ze)), w.add(Ce).normalize(), ne.copy(o.bone.position).normalize(), ie.setFromUnitVectors(ne, w), o.boneParent.quaternion.premultiply(ie), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -445,14 +445,14 @@ class et {
445
445
  xe.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
- fe.multiplyMatrices(xe, m.bones[e].matrixWorld), k.setFromMatrixPosition(fe), t.setXYZ(e, k.x, k.y, k.z);
448
+ fe.multiplyMatrices(xe, m.bones[e].matrixWorld), w.setFromMatrixPosition(fe), 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
  xe.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
- fe.multiplyMatrices(xe, m.bones[e].matrixWorld), k.setFromMatrixPosition(fe), t.setXYZ(n, k.x, k.y, k.z), fe.multiplyMatrices(xe, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(fe), t.setXYZ(n + 1, k.x, k.y, k.z);
455
+ fe.multiplyMatrices(xe, m.bones[e].matrixWorld), w.setFromMatrixPosition(fe), t.setXYZ(n, w.x, w.y, w.z), fe.multiplyMatrices(xe, m.bones[e].parent.matrixWorld), w.setFromMatrixPosition(fe), t.setXYZ(n + 1, w.x, w.y, w.z);
456
456
  t.needsUpdate = !0, m.object.updateMatrixWorld();
457
457
  }
458
458
  }
@@ -4984,6 +4984,7 @@ class Be {
4984
4984
  }
4985
4985
  }
4986
4986
  l = r;
4987
+ continue;
4987
4988
  } else
4988
4989
  break;
4989
4990
  let h = this.valueFn(l.delay) || 0;
@@ -5253,8 +5254,8 @@ class Be {
5253
5254
  for (let b = 0; b < y.length; b++) {
5254
5255
  const I = b === y.length - 1, V = y[b].match(l);
5255
5256
  let p = y[b].match(s);
5256
- const M = y[b].match(h), w = y[b].match(o);
5257
- if (p && !I && !M && y[b + 1].match(s) && (p = !1), n && (u += y[b]), V && (!i || i.every((f) => b < f[0] || b > f[1])) && (a += y[b]), (w || p || I) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5257
+ const M = y[b].match(h), z = y[b].match(o);
5258
+ if (p && !I && !M && y[b + 1].match(s) && (p = !1), n && (u += y[b]), V && (!i || i.every((f) => b < f[0] || b > f[1])) && (a += y[b]), (z || p || I) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5258
5259
  mark: c,
5259
5260
  word: a
5260
5261
  })), u.length && (g.push({
@@ -5486,12 +5487,12 @@ class Be {
5486
5487
  if (b && b.visemes && b.visemes.length > 0) {
5487
5488
  const p = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
5488
5489
  for (let M = 0; M < b.visemes.length; M++) {
5489
- const w = b.visemes[M], f = b.times[M] / p, E = b.durations[M] / p, P = f * c, U = E * c;
5490
+ const z = b.visemes[M], f = b.times[M] / p, E = b.durations[M] / p, P = f * c, U = E * c;
5490
5491
  I.push({
5491
5492
  template: { name: "viseme" },
5492
5493
  ts: [P - Math.min(60, 2 * U / 3), P + Math.min(25, U / 2), P + U + Math.min(60, U / 2)],
5493
5494
  vs: {
5494
- ["viseme_" + w]: [null, w === "PP" || w === "FF" ? 0.9 : 0.6, 0]
5495
+ ["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
5495
5496
  }
5496
5497
  });
5497
5498
  }
@@ -6193,7 +6194,7 @@ class Be {
6193
6194
  if (n) {
6194
6195
  let M = this.animQueue.findIndex((f) => f.template.name === "lookat");
6195
6196
  M !== -1 && this.animQueue.splice(M, 1);
6196
- const w = {
6197
+ const z = {
6197
6198
  name: "lookat",
6198
6199
  dt: [750, n],
6199
6200
  vs: {
@@ -6208,7 +6209,7 @@ class Be {
6208
6209
  headMove: [0]
6209
6210
  }
6210
6211
  };
6211
- this.animQueue.push(this.animFactory(w));
6212
+ this.animQueue.push(this.animFactory(z));
6212
6213
  }
6213
6214
  }
6214
6215
  /**
@@ -6579,10 +6580,10 @@ class Be {
6579
6580
  for (let I = 0; I < b; I++) {
6580
6581
  let V = !1;
6581
6582
  for (let p = 0, M = y.length; p < M; p++) {
6582
- const w = y[p].bone;
6583
- w.matrixWorld.decompose(h, r, u), r.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, h), l.applyQuaternion(r), l.normalize(), s.subVectors(e, h), s.applyQuaternion(r), s.normalize();
6583
+ const z = y[p].bone;
6584
+ z.matrixWorld.decompose(h, r, u), r.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, h), l.applyQuaternion(r), l.normalize(), s.subVectors(e, h), s.applyQuaternion(r), s.normalize();
6584
6585
  let f = s.dot(l);
6585
- f > 1 ? f = 1 : f < -1 && (f = -1), f = Math.acos(f), !(f < 1e-5) && (y[p].minAngle !== void 0 && f < y[p].minAngle && (f = y[p].minAngle), y[p].maxAngle !== void 0 && f > y[p].maxAngle && (f = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), Q.setFromAxisAngle(a, f), w.quaternion.multiply(Q), w.rotation.setFromVector3(c.setFromEuler(w.rotation).clamp(new x.Vector3(
6586
+ f > 1 ? f = 1 : f < -1 && (f = -1), f = Math.acos(f), !(f < 1e-5) && (y[p].minAngle !== void 0 && f < y[p].minAngle && (f = y[p].minAngle), y[p].maxAngle !== void 0 && f > y[p].maxAngle && (f = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), Q.setFromAxisAngle(a, f), z.quaternion.multiply(Q), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new x.Vector3(
6586
6587
  y[p].minx !== void 0 ? y[p].minx : -1 / 0,
6587
6588
  y[p].miny !== void 0 ? y[p].miny : -1 / 0,
6588
6589
  y[p].minz !== void 0 ? y[p].minz : -1 / 0
@@ -6590,7 +6591,7 @@ class Be {
6590
6591
  y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
6591
6592
  y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
6592
6593
  y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
6593
- ))), w.updateMatrixWorld(!0), V = !0);
6594
+ ))), z.updateMatrixWorld(!0), V = !0);
6594
6595
  }
6595
6596
  if (!V) break;
6596
6597
  }
@@ -6685,7 +6686,7 @@ const Ve = Me(({
6685
6686
  style: y = {},
6686
6687
  animations: b = {}
6687
6688
  }, I) => {
6688
- const V = D(null), p = D(null), M = D(r), w = D(null), f = D(null), E = D(!1), P = D({ remainingText: null, originalText: null, options: null }), U = D([]), oe = D(0), [S, Z] = ce(!0), [K, X] = ce(null), [$, se] = ce(!1), [ae, pe] = ce(!1);
6689
+ const V = D(null), p = D(null), M = D(r), z = D(null), f = D(null), E = D(!1), P = D({ remainingText: null, originalText: null, options: null }), U = D([]), oe = D(0), [S, Z] = ce(!0), [K, X] = ce(null), [$, se] = ce(!1), [ae, pe] = ce(!1);
6689
6690
  de(() => {
6690
6691
  E.current = ae;
6691
6692
  }, [ae]), de(() => {
@@ -6731,7 +6732,7 @@ const Ve = Me(({
6731
6732
  ttsService: le,
6732
6733
  lipsyncModules: ["en"],
6733
6734
  cameraView: u
6734
- }, z = T(async () => {
6735
+ }, k = T(async () => {
6735
6736
  if (!(!V.current || p.current))
6736
6737
  try {
6737
6738
  if (Z(!0), X(null), p.current = new Be(V.current, R), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), b && Object.keys(b).length > 0 && (p.current.customAnimations = b), await p.current.showAvatar(v, (B) => {
@@ -6761,9 +6762,9 @@ const Ve = Me(({
6761
6762
  console.error("Error initializing TalkingHead:", L), X(L.message || "Failed to initialize avatar"), Z(!1), d(L);
6762
6763
  }
6763
6764
  }, [G, t, e, n, i, s, o, r, l, h, u]);
6764
- de(() => (z(), () => {
6765
+ de(() => (k(), () => {
6765
6766
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6766
- }), [z]), de(() => {
6767
+ }), [k]), de(() => {
6767
6768
  if (!V.current || !p.current) return;
6768
6769
  const L = new ResizeObserver((B) => {
6769
6770
  for (const J of B)
@@ -6787,7 +6788,7 @@ const Ve = Me(({
6787
6788
  }, []), N = T(async (L, F = {}) => {
6788
6789
  if (p.current && $)
6789
6790
  try {
6790
- f.current && (clearInterval(f.current), f.current = null), w.current = { text: L, options: F }, P.current = { remainingText: null, originalText: null, options: null };
6791
+ f.current && (clearInterval(f.current), f.current = null), z.current = { text: L, options: F }, P.current = { remainingText: null, originalText: null, options: null };
6791
6792
  const B = /[!\.\?\n\p{Extended_Pictographic}]/ug, J = L.split(B).map((Y) => Y.trim()).filter((Y) => Y.length > 0);
6792
6793
  U.current = J, oe.current = 0, pe(!1), E.current = !1, await H();
6793
6794
  const ge = {
@@ -6833,24 +6834,24 @@ const Ve = Me(({
6833
6834
  console.error("Error speaking text:", B), X(B.message || "Failed to speak text");
6834
6835
  }
6835
6836
  }, [$, H, v.lipsyncLang]), _ = T(() => {
6836
- p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), w.current = null, pe(!1));
6837
+ p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, pe(!1));
6837
6838
  }, []), j = T(() => {
6838
6839
  if (p.current && p.current.pauseSpeaking) {
6839
6840
  const L = p.current;
6840
6841
  if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
6841
6842
  f.current && (clearInterval(f.current), f.current = null);
6842
6843
  let B = "";
6843
- if (w.current && U.current.length > 0) {
6844
+ if (z.current && U.current.length > 0) {
6844
6845
  const J = U.current.length, ge = L.speechQueue ? L.speechQueue.filter((Ae) => Ae && Ae.text && Array.isArray(Ae.text) && Ae.text.length > 0).length : 0, Y = L.audioPlaylist && L.audioPlaylist.length > 0, he = ge + (Y ? 1 : 0), Se = J - he;
6845
6846
  if (he > 0 && Se < J && (B = U.current.slice(Se).join(". ").trim(), !B && ge > 0 && L.speechQueue)) {
6846
6847
  const be = L.speechQueue.filter((ye) => ye && ye.text && Array.isArray(ye.text) && ye.text.length > 0).map((ye) => ye.text.map((ke) => ke.word || "").filter((ke) => ke.length > 0).join(" ")).filter((ye) => ye.length > 0).join(" ");
6847
6848
  be && be.trim() && (B = be.trim());
6848
6849
  }
6849
6850
  }
6850
- w.current && (P.current = {
6851
+ z.current && (P.current = {
6851
6852
  remainingText: B || null,
6852
- originalText: w.current.text,
6853
- options: w.current.options
6853
+ originalText: z.current.text,
6854
+ options: z.current.options
6854
6855
  }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), E.current = !0, pe(!0);
6855
6856
  }
6856
6857
  }
@@ -6860,8 +6861,8 @@ const Ve = Me(({
6860
6861
  let L = "", F = {};
6861
6862
  if (P.current && P.current.remainingText)
6862
6863
  L = P.current.remainingText, F = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
6863
- else if (w.current && w.current.text)
6864
- L = w.current.text, F = w.current.options || {};
6864
+ else if (z.current && z.current.text)
6865
+ L = z.current.text, F = z.current.options || {};
6865
6866
  else {
6866
6867
  console.warn("Resume called but no paused speech found"), pe(!1), E.current = !1;
6867
6868
  return;
@@ -7082,7 +7083,7 @@ const pt = Me(({
7082
7083
  ttsService: I,
7083
7084
  lipsyncModules: ["en"],
7084
7085
  cameraView: "upper"
7085
- }, w = T(async () => {
7086
+ }, z = T(async () => {
7086
7087
  if (!(!h.current || r.current))
7087
7088
  try {
7088
7089
  if (a(!0), d(null), r.current = new Be(h.current, M), await r.current.showAvatar(p, (K) => {
@@ -7118,9 +7119,9 @@ const pt = Me(({
7118
7119
  console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), a(!1), e(S);
7119
7120
  }
7120
7121
  }, []);
7121
- de(() => (w(), () => {
7122
+ de(() => (z(), () => {
7122
7123
  r.current && (r.current.stop(), r.current.dispose(), r.current = null);
7123
- }), [w]);
7124
+ }), [z]);
7124
7125
  const f = T((S) => {
7125
7126
  if (r.current && g)
7126
7127
  try {
@@ -7307,7 +7308,7 @@ const gt = Me(({
7307
7308
  animations: V = {},
7308
7309
  autoSpeak: p = !1
7309
7310
  }, M) => {
7310
- const w = D(null), f = D(null), E = D(u), P = D(null), U = D(null), oe = D(!1), S = D({ remainingText: null, originalText: null, options: null }), Z = D([]), [K, X] = ce(!0), [$, se] = ce(null), [ae, pe] = ce(!1), [ee, le] = ce(!1);
7311
+ const z = D(null), f = D(null), E = D(u), P = D(null), U = D(null), oe = D(!1), S = D({ remainingText: null, originalText: null, options: null }), Z = D([]), [K, X] = ce(!0), [$, se] = ce(null), [ae, pe] = ce(!1), [ee, le] = ce(!1);
7311
7312
  de(() => {
7312
7313
  oe.current = ee;
7313
7314
  }, [ee]), de(() => {
@@ -7336,7 +7337,7 @@ const gt = Me(({
7336
7337
  ...O,
7337
7338
  apiKey: l !== null ? l : O.apiKey
7338
7339
  };
7339
- const z = {
7340
+ const k = {
7340
7341
  url: t,
7341
7342
  body: e,
7342
7343
  avatarMood: n,
@@ -7353,14 +7354,18 @@ const gt = Me(({
7353
7354
  lipsyncModules: ["en"],
7354
7355
  cameraView: a
7355
7356
  }, N = T(async () => {
7356
- if (!(!w.current || f.current))
7357
+ if (!(!z.current || f.current))
7357
7358
  try {
7358
- X(!0), se(null), f.current = new Be(w.current, H), await f.current.showAvatar(z, (te) => {
7359
+ X(!0), se(null), f.current = new Be(z.current, H), console.log("Avatar config being passed:", {
7360
+ url: k.url,
7361
+ body: k.body,
7362
+ avatarMood: k.avatarMood
7363
+ }), await f.current.showAvatar(k, (te) => {
7359
7364
  if (te.lengthComputable) {
7360
7365
  const L = Math.min(100, Math.round(te.loaded / te.total * 100));
7361
7366
  d(L);
7362
7367
  }
7363
- }), X(!1), pe(!0), c(f.current);
7368
+ }), f.current?.avatar && console.log("Avatar body after initialization:", f.current.avatar.body), X(!1), pe(!0), c(f.current);
7364
7369
  const C = () => {
7365
7370
  document.visibilityState === "visible" ? f.current?.start() : f.current?.stop();
7366
7371
  };
@@ -7462,7 +7467,7 @@ const gt = Me(({
7462
7467
  /* @__PURE__ */ me(
7463
7468
  "div",
7464
7469
  {
7465
- ref: w,
7470
+ ref: z,
7466
7471
  className: "talking-head-viewer",
7467
7472
  style: {
7468
7473
  width: "100%",
@@ -7532,7 +7537,7 @@ const yt = Me(({
7532
7537
  description: "No curriculum data provided",
7533
7538
  language: "en",
7534
7539
  modules: []
7535
- }), w = D({
7540
+ }), z = D({
7536
7541
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7537
7542
  avatarBody: t.avatarBody || "F",
7538
7543
  mood: t.mood || "happy",
@@ -7560,7 +7565,7 @@ const yt = Me(({
7560
7565
  description: "No curriculum data provided",
7561
7566
  language: "en",
7562
7567
  modules: []
7563
- }, w.current = {
7568
+ }, z.current = {
7564
7569
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7565
7570
  avatarBody: t.avatarBody || "F",
7566
7571
  mood: t.mood || "happy",
@@ -7599,7 +7604,7 @@ const yt = Me(({
7599
7604
  } catch {
7600
7605
  u.current.playCelebration();
7601
7606
  }
7602
- const z = M.current || { modules: [] }, H = z.modules[a.current.currentModuleIndex], N = a.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, _ = a.current.currentModuleIndex < (z.modules?.length || 0) - 1, j = N || _, q = w.current || { lipsyncLang: "en" };
7607
+ const k = M.current || { modules: [] }, H = k.modules[a.current.currentModuleIndex], N = a.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, _ = a.current.currentModuleIndex < (k.modules?.length || 0) - 1, j = N || _, q = z.current || { lipsyncLang: "en" };
7603
7608
  u.current.speakText(R, {
7604
7609
  lipsyncLang: q.lipsyncLang,
7605
7610
  onSpeechEnd: () => {
@@ -7620,7 +7625,7 @@ const yt = Me(({
7620
7625
  const v = M.current || { modules: [] };
7621
7626
  if (c.current.onCurriculumComplete({
7622
7627
  modules: v.modules.length,
7623
- totalLessons: v.modules.reduce((R, z) => R + z.lessons.length, 0)
7628
+ totalLessons: v.modules.reduce((R, k) => R + k.lessons.length, 0)
7624
7629
  }), u.current) {
7625
7630
  if (u.current.setMood("celebrating"), e.curriculumComplete)
7626
7631
  try {
@@ -7628,7 +7633,7 @@ const yt = Me(({
7628
7633
  } catch {
7629
7634
  u.current.playCelebration();
7630
7635
  }
7631
- const R = w.current || { lipsyncLang: "en" };
7636
+ const R = z.current || { lipsyncLang: "en" };
7632
7637
  u.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: R.lipsyncLang });
7633
7638
  }
7634
7639
  }, [e.curriculumComplete]), S = T(() => {
@@ -7644,7 +7649,7 @@ const yt = Me(({
7644
7649
  question: R,
7645
7650
  score: a.current.score
7646
7651
  });
7647
- const z = () => {
7652
+ const k = () => {
7648
7653
  if (!u.current || !R) return;
7649
7654
  if (u.current.setMood("happy"), e.questionStart)
7650
7655
  try {
@@ -7652,17 +7657,17 @@ const yt = Me(({
7652
7657
  } catch (N) {
7653
7658
  console.warn("Failed to play questionStart animation:", N);
7654
7659
  }
7655
- const H = w.current || { lipsyncLang: "en" };
7660
+ const H = z.current || { lipsyncLang: "en" };
7656
7661
  R.type === "code_test" ? u.current.speakText(`Let's test your coding skills! Here's your first challenge: ${R.question}`, { lipsyncLang: H.lipsyncLang }) : R.type === "multiple_choice" ? u.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: H.lipsyncLang }) : R.type === "true_false" ? u.current.speakText(`Let's start with some true or false questions. First question: ${R.question}`, { lipsyncLang: H.lipsyncLang }) : u.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: H.lipsyncLang });
7657
7662
  };
7658
7663
  if (u.current && u.current.isReady && R)
7659
- z();
7664
+ k();
7660
7665
  else if (u.current && u.current.isReady) {
7661
- const H = w.current || { lipsyncLang: "en" };
7666
+ const H = z.current || { lipsyncLang: "en" };
7662
7667
  u.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: H.lipsyncLang });
7663
7668
  } else {
7664
7669
  const H = setInterval(() => {
7665
- u.current && u.current.isReady && (clearInterval(H), R && z());
7670
+ u.current && u.current.isReady && (clearInterval(H), R && k());
7666
7671
  }, 100);
7667
7672
  setTimeout(() => {
7668
7673
  clearInterval(H);
@@ -7682,7 +7687,7 @@ const yt = Me(({
7682
7687
  question: R,
7683
7688
  score: a.current.score
7684
7689
  });
7685
- const z = () => {
7690
+ const k = () => {
7686
7691
  if (!u.current || !R) return;
7687
7692
  if (u.current.setMood("happy"), u.current.setBodyMovement("idle"), e.nextQuestion)
7688
7693
  try {
@@ -7690,7 +7695,7 @@ const yt = Me(({
7690
7695
  } catch (q) {
7691
7696
  console.warn("Failed to play nextQuestion animation:", q);
7692
7697
  }
7693
- const H = w.current || { lipsyncLang: "en" }, _ = f()?.questions?.length || 0, j = a.current.currentQuestionIndex >= _ - 1;
7698
+ const H = z.current || { lipsyncLang: "en" }, _ = f()?.questions?.length || 0, j = a.current.currentQuestionIndex >= _ - 1;
7694
7699
  if (R.type === "code_test") {
7695
7700
  const q = j ? `Great! Here's your final coding challenge: ${R.question}` : `Great! Now let's move on to your next coding challenge: ${R.question}`;
7696
7701
  u.current.speakText(q, {
@@ -7714,10 +7719,10 @@ const yt = Me(({
7714
7719
  }
7715
7720
  };
7716
7721
  if (u.current && u.current.isReady && R)
7717
- z();
7722
+ k();
7718
7723
  else if (R) {
7719
7724
  const H = setInterval(() => {
7720
- u.current && u.current.isReady && (clearInterval(H), z());
7725
+ u.current && u.current.isReady && (clearInterval(H), k());
7721
7726
  }, 100);
7722
7727
  setTimeout(() => {
7723
7728
  clearInterval(H);
@@ -7765,21 +7770,21 @@ const yt = Me(({
7765
7770
  const v = f();
7766
7771
  let R = null;
7767
7772
  if (v?.avatar_script && v?.body) {
7768
- const z = v.avatar_script.trim(), H = v.body.trim(), N = z.match(/[.!?]$/) ? " " : ". ";
7769
- R = `${z}${N}${H}`;
7773
+ const k = v.avatar_script.trim(), H = v.body.trim(), N = k.match(/[.!?]$/) ? " " : ". ";
7774
+ R = `${k}${N}${H}`;
7770
7775
  } else
7771
7776
  R = v?.avatar_script || v?.body || null;
7772
7777
  if (u.current && u.current.isReady && R) {
7773
7778
  a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, u.current.setMood("happy");
7774
- let z = !1;
7779
+ let k = !1;
7775
7780
  if (e.teaching)
7776
7781
  try {
7777
- u.current.playAnimation(e.teaching, !0), z = !0;
7782
+ u.current.playAnimation(e.teaching, !0), k = !0;
7778
7783
  } catch (N) {
7779
7784
  console.warn("Failed to play teaching animation:", N);
7780
7785
  }
7781
- z || u.current.setBodyMovement("gesturing");
7782
- const H = w.current || { lipsyncLang: "en" };
7786
+ k || u.current.setBodyMovement("gesturing");
7787
+ const H = z.current || { lipsyncLang: "en" };
7783
7788
  c.current.onLessonStart({
7784
7789
  moduleIndex: a.current.currentModuleIndex,
7785
7790
  lessonIndex: a.current.currentLessonIndex,
@@ -7809,16 +7814,16 @@ const yt = Me(({
7809
7814
  });
7810
7815
  }
7811
7816
  }, [e.teaching, f]), $ = T((v) => {
7812
- const R = E(), z = P(v, R);
7813
- if (z && (a.current.score += 1), c.current.onQuestionAnswer({
7817
+ const R = E(), k = P(v, R);
7818
+ if (k && (a.current.score += 1), c.current.onQuestionAnswer({
7814
7819
  moduleIndex: a.current.currentModuleIndex,
7815
7820
  lessonIndex: a.current.currentLessonIndex,
7816
7821
  questionIndex: a.current.currentQuestionIndex,
7817
7822
  answer: v,
7818
- isCorrect: z,
7823
+ isCorrect: k,
7819
7824
  question: R
7820
7825
  }), u.current)
7821
- if (z) {
7826
+ if (k) {
7822
7827
  if (u.current.setMood("happy"), e.correct)
7823
7828
  try {
7824
7829
  u.current.playReaction("happy");
@@ -7830,7 +7835,7 @@ const yt = Me(({
7830
7835
  a.current.currentQuestionIndex >= N - 1;
7831
7836
  const _ = a.current.currentQuestionIndex < N - 1;
7832
7837
  console.log("[CurriculumLearning] Answer feedback - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", N, "hasNextQuestion:", _);
7833
- const j = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, q = w.current || { lipsyncLang: "en" };
7838
+ const j = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, q = z.current || { lipsyncLang: "en" };
7834
7839
  u.current.speakText(j, {
7835
7840
  lipsyncLang: q.lipsyncLang,
7836
7841
  onSpeechEnd: () => {
@@ -7856,7 +7861,7 @@ const yt = Me(({
7856
7861
  u.current.setBodyMovement("gesturing");
7857
7862
  const N = f()?.questions?.length || 0, _ = a.current.currentQuestionIndex >= N - 1, j = a.current.currentQuestionIndex < N - 1;
7858
7863
  console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", N, "hasNextQuestion:", j);
7859
- const q = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""}${_ ? "" : " Let's move on to the next question."}`, Le = w.current || { lipsyncLang: "en" };
7864
+ const q = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""}${_ ? "" : " Let's move on to the next question."}`, Le = z.current || { lipsyncLang: "en" };
7860
7865
  u.current.speakText(q, {
7861
7866
  lipsyncLang: Le.lipsyncLang,
7862
7867
  onSpeechEnd: () => {
@@ -7880,7 +7885,7 @@ const yt = Me(({
7880
7885
  moduleIndex: a.current.currentModuleIndex,
7881
7886
  lessonIndex: a.current.currentLessonIndex,
7882
7887
  questionIndex: a.current.currentQuestionIndex,
7883
- isCorrect: z,
7888
+ isCorrect: k,
7884
7889
  hasNextQuestion: a.current.currentQuestionIndex < N - 1,
7885
7890
  score: a.current.score,
7886
7891
  totalQuestions: a.current.totalQuestions,
@@ -7897,7 +7902,7 @@ const yt = Me(({
7897
7902
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
7898
7903
  return;
7899
7904
  }
7900
- const z = {
7905
+ const k = {
7901
7906
  passed: v.passed === !0,
7902
7907
  results: v.results || [],
7903
7908
  output: v.output || "",
@@ -7912,9 +7917,9 @@ const yt = Me(({
7912
7917
  moduleIndex: a.current.currentModuleIndex,
7913
7918
  lessonIndex: a.current.currentLessonIndex,
7914
7919
  questionIndex: a.current.currentQuestionIndex,
7915
- testResult: z,
7920
+ testResult: k,
7916
7921
  question: R
7917
- }), p.current && p.current(z);
7922
+ }), p.current && p.current(k);
7918
7923
  }, [E, P]), ae = T(() => {
7919
7924
  if (a.current.currentQuestionIndex > 0) {
7920
7925
  a.current.currentQuestionIndex -= 1;
@@ -7931,21 +7936,21 @@ const yt = Me(({
7931
7936
  const R = () => {
7932
7937
  if (!u.current || !v) return;
7933
7938
  u.current.setMood("happy"), u.current.setBodyMovement("idle");
7934
- const z = w.current || { lipsyncLang: "en" };
7939
+ const k = z.current || { lipsyncLang: "en" };
7935
7940
  v.type === "code_test" ? u.current.speakText(`Let's go back to this coding challenge: ${v.question}`, {
7936
- lipsyncLang: z.lipsyncLang
7941
+ lipsyncLang: k.lipsyncLang
7937
7942
  }) : u.current.speakText(`Going back to: ${v.question}`, {
7938
- lipsyncLang: z.lipsyncLang
7943
+ lipsyncLang: k.lipsyncLang
7939
7944
  });
7940
7945
  };
7941
7946
  if (u.current && u.current.isReady && v)
7942
7947
  R();
7943
7948
  else if (v) {
7944
- const z = setInterval(() => {
7945
- u.current && u.current.isReady && (clearInterval(z), R());
7949
+ const k = setInterval(() => {
7950
+ u.current && u.current.isReady && (clearInterval(k), R());
7946
7951
  }, 100);
7947
7952
  setTimeout(() => {
7948
- clearInterval(z);
7953
+ clearInterval(k);
7949
7954
  }, 5e3);
7950
7955
  }
7951
7956
  }
@@ -7977,8 +7982,8 @@ const yt = Me(({
7977
7982
  a.current.currentModuleIndex = 0, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.isTeaching = !1, a.current.isQuestionMode = !1, a.current.lessonCompleted = !1, a.current.curriculumCompleted = !1, a.current.score = 0, a.current.totalQuestions = 0;
7978
7983
  }, []), le = T((v) => {
7979
7984
  console.log("Avatar is ready!", v);
7980
- const R = f(), z = R?.avatar_script || R?.body;
7981
- h && z && setTimeout(() => {
7985
+ const R = f(), k = R?.avatar_script || R?.body;
7986
+ h && k && setTimeout(() => {
7982
7987
  d.current && d.current();
7983
7988
  }, 10);
7984
7989
  }, [h, f]);
@@ -8005,8 +8010,8 @@ const yt = Me(({
8005
8010
  // Convenience methods that delegate to avatar (always check current ref)
8006
8011
  speakText: async (v, R = {}) => {
8007
8012
  await u.current?.resumeAudioContext?.();
8008
- const z = w.current || { lipsyncLang: "en" };
8009
- u.current?.speakText(v, { ...R, lipsyncLang: R.lipsyncLang || z.lipsyncLang });
8013
+ const k = z.current || { lipsyncLang: "en" };
8014
+ u.current?.speakText(v, { ...R, lipsyncLang: R.lipsyncLang || k.lipsyncLang });
8010
8015
  },
8011
8016
  resumeAudioContext: async () => {
8012
8017
  if (u.current?.resumeAudioContext)
@@ -8017,8 +8022,8 @@ const yt = Me(({
8017
8022
  if (R.state === "suspended" || R.state === "interrupted")
8018
8023
  try {
8019
8024
  await R.resume(), console.log("Audio context resumed via talkingHead");
8020
- } catch (z) {
8021
- console.warn("Failed to resume audio context:", z);
8025
+ } catch (k) {
8026
+ console.warn("Failed to resume audio context:", k);
8022
8027
  }
8023
8028
  } else
8024
8029
  console.warn("Audio context not available yet");
@@ -8051,7 +8056,7 @@ const yt = Me(({
8051
8056
  // Avatar readiness check (always returns current value)
8052
8057
  isAvatarReady: () => u.current?.isReady || !1
8053
8058
  }), [X, S, $, se, Z, K, U, oe, ee, E, f]);
8054
- const O = w.current || {
8059
+ const O = z.current || {
8055
8060
  avatarUrl: "/avatars/brunette.glb",
8056
8061
  avatarBody: "F",
8057
8062
  mood: "happy",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "description": "A reusable React component for 3D talking avatars with lip-sync and text-to-speech",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -146,6 +146,13 @@ const SimpleTalkingAvatar = forwardRef(({
146
146
 
147
147
  talkingHeadRef.current = new TalkingHead(containerRef.current, defaultOptions);
148
148
 
149
+ // Debug: Log avatar config to verify body type is passed
150
+ console.log('Avatar config being passed:', {
151
+ url: defaultAvatarConfig.url,
152
+ body: defaultAvatarConfig.body,
153
+ avatarMood: defaultAvatarConfig.avatarMood
154
+ });
155
+
149
156
  await talkingHeadRef.current.showAvatar(defaultAvatarConfig, (ev) => {
150
157
  if (ev.lengthComputable) {
151
158
  const progress = Math.min(100, Math.round(ev.loaded / ev.total * 100));
@@ -153,6 +160,11 @@ const SimpleTalkingAvatar = forwardRef(({
153
160
  }
154
161
  });
155
162
 
163
+ // Debug: Verify avatar body was set correctly
164
+ if (talkingHeadRef.current?.avatar) {
165
+ console.log('Avatar body after initialization:', talkingHeadRef.current.avatar.body);
166
+ }
167
+
156
168
  setIsLoading(false);
157
169
  setIsReady(true);
158
170
  onReady(talkingHeadRef.current);
@@ -2677,6 +2677,8 @@ class TalkingHead {
2677
2677
  }
2678
2678
  }
2679
2679
  a = b;
2680
+ // Continue loop to check for gender-specific override after selecting alternative
2681
+ continue;
2680
2682
 
2681
2683
  } else {
2682
2684
  break;