@sage-rsc/talking-head-react 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.js +411 -407
- package/package.json +1 -1
- package/src/components/SimpleTalkingAvatar.jsx +33 -4
- package/src/lib/talkinghead.mjs +2 -3
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsxs as ke, jsx as $ } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Ze, useRef as W, useState as ae, useEffect as fe, useCallback as
|
|
3
|
-
import * as
|
|
4
|
-
import { OrbitControls as
|
|
5
|
-
import { GLTFLoader as
|
|
6
|
-
import { DRACOLoader as
|
|
2
|
+
import { forwardRef as Ze, useRef as W, useState as ae, useEffect as fe, useCallback as N, useImperativeHandle as Xe, useLayoutEffect as ot } from "react";
|
|
3
|
+
import * as x from "three";
|
|
4
|
+
import { OrbitControls as st } from "three/addons/controls/OrbitControls.js";
|
|
5
|
+
import { GLTFLoader as rt } from "three/addons/loaders/GLTFLoader.js";
|
|
6
|
+
import { DRACOLoader as at } from "three/addons/loaders/DRACOLoader.js";
|
|
7
7
|
import { FBXLoader as qe } from "three/addons/loaders/FBXLoader.js";
|
|
8
|
-
import { RoomEnvironment as
|
|
9
|
-
import
|
|
10
|
-
let m, ye,
|
|
11
|
-
const z = [0, 0, 0, 0], O = new
|
|
12
|
-
new
|
|
13
|
-
new
|
|
14
|
-
new
|
|
15
|
-
const de = new
|
|
16
|
-
new
|
|
17
|
-
const Ve = new
|
|
18
|
-
class
|
|
8
|
+
import { RoomEnvironment as lt } from "three/addons/environments/RoomEnvironment.js";
|
|
9
|
+
import ut from "three/addons/libs/stats.module.js";
|
|
10
|
+
let m, ye, ve;
|
|
11
|
+
const z = [0, 0, 0, 0], O = new x.Vector3(), Ue = new x.Vector3(), he = new x.Vector3(), We = new x.Vector3();
|
|
12
|
+
new x.Plane();
|
|
13
|
+
new x.Ray();
|
|
14
|
+
new x.Euler();
|
|
15
|
+
const de = new x.Quaternion(), _e = new x.Quaternion(), we = new x.Matrix4(), Ce = new x.Matrix4();
|
|
16
|
+
new x.Vector3();
|
|
17
|
+
const Ve = new x.Vector3(0, 0, 1), ct = new x.Vector3(1, 0, 0), ht = new x.Vector3(0, 1, 0), dt = new x.Vector3(0, 0, 1);
|
|
18
|
+
class mt {
|
|
19
19
|
constructor(t = null) {
|
|
20
20
|
this.opt = Object.assign({
|
|
21
21
|
warmupMs: 2e3,
|
|
@@ -369,9 +369,9 @@ class dt {
|
|
|
369
369
|
i.vBasis.y + z[1],
|
|
370
370
|
i.vBasis.z - z[2]
|
|
371
371
|
);
|
|
372
|
-
else if (i.boneParent.quaternion.copy(i.qBasis), i.pivot && this.opt.isPivots && (i.boneParent.updateWorldMatrix(!1, !1), i.boneParent.matrixWorld.decompose(O, de, he), O.copy(Ve).applyQuaternion(de).setY(0).normalize(), de.premultiply(_e.setFromUnitVectors(Ve, O).invert()).normalize(), i.boneParent.quaternion.multiply(de.invert()), i.boneParent.quaternion.multiply(i.qWorldInverseYaw)), i.isZ && (m = Math.atan(z[0] / i.l), de.setFromAxisAngle(
|
|
372
|
+
else if (i.boneParent.quaternion.copy(i.qBasis), i.pivot && this.opt.isPivots && (i.boneParent.updateWorldMatrix(!1, !1), i.boneParent.matrixWorld.decompose(O, de, he), O.copy(Ve).applyQuaternion(de).setY(0).normalize(), de.premultiply(_e.setFromUnitVectors(Ve, O).invert()).normalize(), i.boneParent.quaternion.multiply(de.invert()), i.boneParent.quaternion.multiply(i.qWorldInverseYaw)), i.isZ && (m = Math.atan(z[0] / i.l), de.setFromAxisAngle(dt, -m), i.boneParent.quaternion.multiply(de)), i.isY && (m = i.l / 3, m = m * Math.tanh(z[1] / m), i.bone.position.setLength(i.l + m)), i.isX && (m = Math.atan(z[2] / i.l), de.setFromAxisAngle(ct, -m), i.boneParent.quaternion.multiply(de)), i.isT && (m = 1.5 * Math.tanh(z[3] * 1.5), de.setFromAxisAngle(ht, -m), i.boneParent.quaternion.multiply(de)), i.boneParent.updateWorldMatrix(!1, !0), i.excludes && this.opt.isExcludes)
|
|
373
373
|
for (n = 0, s = i.excludes.length; n < s; n++)
|
|
374
|
-
m = i.excludes[n], he.set(0, 0, 0), m.deltaLocal && (he.x += m.deltaLocal[0], he.y += m.deltaLocal[1], he.z += m.deltaLocal[2]), he.applyMatrix4(m.bone.matrixWorld), Ce.copy(i.boneParent.matrixWorld).invert(), he.applyMatrix4(Ce), O.copy(i.bone.position), !(O.distanceToSquared(he) >= m.radiusSq) && (
|
|
374
|
+
m = i.excludes[n], he.set(0, 0, 0), m.deltaLocal && (he.x += m.deltaLocal[0], he.y += m.deltaLocal[1], he.z += m.deltaLocal[2]), he.applyMatrix4(m.bone.matrixWorld), Ce.copy(i.boneParent.matrixWorld).invert(), he.applyMatrix4(Ce), O.copy(i.bone.position), !(O.distanceToSquared(he) >= m.radiusSq) && (ve = O.length(), ye = he.length(), !(ye > m.radius + ve) && (ye < Math.abs(m.radius - ve) || (ye = (ye * ye + ve * ve - m.radiusSq) / (2 * ye), he.normalize(), We.copy(he).multiplyScalar(ye), ye = Math.sqrt(ve * ve - ye * ye), O.subVectors(O, We).projectOnPlane(he).normalize().multiplyScalar(ye), Ue.subVectors(i.vBasis, We).projectOnPlane(he).normalize(), ve = Ue.dot(O), ve < 0 && (ve = Math.sqrt(ye * ye - ve * ve), Ue.multiplyScalar(ve), O.add(Ue)), O.add(We).normalize(), he.copy(i.bone.position).normalize(), de.setFromUnitVectors(he, O), i.boneParent.quaternion.premultiply(de), i.boneParent.updateWorldMatrix(!1, !0))));
|
|
375
375
|
}
|
|
376
376
|
this.helpers.isActive && this.updateHelpers();
|
|
377
377
|
}
|
|
@@ -393,7 +393,7 @@ class dt {
|
|
|
393
393
|
o || (m.excludes.bones.push(n.bone), m.excludes.radii.push(n.radius), m.excludes.deltaLocals.push(n.deltaLocal ? [...n.deltaLocal] : null), m.excludes.objects.push(null));
|
|
394
394
|
}));
|
|
395
395
|
}), m = this.helpers.excludes, this.opt.isExcludes && m.bones.length && m.bones.forEach((e, n) => {
|
|
396
|
-
const o = new
|
|
396
|
+
const o = new x.SphereGeometry(m.radii[n], 6, 6), s = new x.MeshBasicMaterial({
|
|
397
397
|
depthTest: !1,
|
|
398
398
|
depthWrite: !1,
|
|
399
399
|
toneMapped: !1,
|
|
@@ -401,18 +401,18 @@ class dt {
|
|
|
401
401
|
wireframe: !0,
|
|
402
402
|
color: this.opt.helperExcludesColor
|
|
403
403
|
});
|
|
404
|
-
m.objects[n] = new
|
|
404
|
+
m.objects[n] = new x.Mesh(o, s), m.objects[n].renderOrder = 997, e.add(m.objects[n]), m.deltaLocals[n] && m.objects[n].position.set(
|
|
405
405
|
m.deltaLocals[n][0],
|
|
406
406
|
m.deltaLocals[n][1],
|
|
407
407
|
m.deltaLocals[n][2]
|
|
408
408
|
);
|
|
409
409
|
}), m = this.helpers.points, m.bones.length) {
|
|
410
410
|
this.helpers.isActive = !0;
|
|
411
|
-
const e = new
|
|
412
|
-
e.setAttribute("position", new
|
|
413
|
-
const o = new
|
|
414
|
-
e.setAttribute("color", new
|
|
415
|
-
const a = new
|
|
411
|
+
const e = new x.BufferGeometry(), n = m.bones.map((c) => [0, 0, 0]).flat();
|
|
412
|
+
e.setAttribute("position", new x.Float32BufferAttribute(n, 3));
|
|
413
|
+
const o = new x.Color(this.opt.helperBoneColor1), s = new x.Color(this.opt.helperBoneColor2), i = m.pivots.map((c) => c && this.opt.isPivots ? [s.r, s.g, s.b] : [o.r, o.g, o.b]).flat();
|
|
414
|
+
e.setAttribute("color", new x.Float32BufferAttribute(i, 3));
|
|
415
|
+
const a = new x.PointsMaterial({
|
|
416
416
|
depthTest: !1,
|
|
417
417
|
depthWrite: !1,
|
|
418
418
|
toneMapped: !1,
|
|
@@ -420,21 +420,21 @@ class dt {
|
|
|
420
420
|
size: 0.2,
|
|
421
421
|
vertexColors: !0
|
|
422
422
|
});
|
|
423
|
-
m.object = new
|
|
423
|
+
m.object = new x.Points(e, a), m.object.renderOrder = 998, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
|
|
424
424
|
}
|
|
425
425
|
if (m = this.helpers.lines, m.bones.length) {
|
|
426
|
-
const e = new
|
|
427
|
-
e.setAttribute("position", new
|
|
428
|
-
const o = new
|
|
429
|
-
e.setAttribute("color", new
|
|
430
|
-
const a = new
|
|
426
|
+
const e = new x.BufferGeometry(), n = m.bones.map((c) => [0, 0, 0, 0, 0, 0]).flat();
|
|
427
|
+
e.setAttribute("position", new x.Float32BufferAttribute(n, 3));
|
|
428
|
+
const o = new x.Color(this.opt.helperLinkColor1), s = new x.Color(this.opt.helperLinkColor2), i = m.bones.map((c) => [o.r, o.g, o.b, s.r, s.g, s.b]).flat();
|
|
429
|
+
e.setAttribute("color", new x.Float32BufferAttribute(i, 3));
|
|
430
|
+
const a = new x.LineBasicMaterial({
|
|
431
431
|
vertexColors: !0,
|
|
432
432
|
depthTest: !1,
|
|
433
433
|
depthWrite: !1,
|
|
434
434
|
toneMapped: !1,
|
|
435
435
|
transparent: !0
|
|
436
436
|
});
|
|
437
|
-
m.object = new
|
|
437
|
+
m.object = new x.LineSegments(e, a), m.object.renderOrder = 999, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
@@ -489,7 +489,7 @@ class dt {
|
|
|
489
489
|
this.stop(), this.scene = null, this.armature = null, this.config = [], this.data = [], this.dict = {}, this.objectsUpdate = [], this.timerMs = 0;
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
class
|
|
492
|
+
class pt {
|
|
493
493
|
constructor(t) {
|
|
494
494
|
this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
|
|
495
495
|
}
|
|
@@ -814,7 +814,7 @@ class mt {
|
|
|
814
814
|
return o * s;
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
-
class
|
|
817
|
+
class gt {
|
|
818
818
|
/**
|
|
819
819
|
* @constructor
|
|
820
820
|
*/
|
|
@@ -1396,11 +1396,11 @@ class pt {
|
|
|
1396
1396
|
return e;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
const
|
|
1399
|
+
const yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1400
1400
|
__proto__: null,
|
|
1401
|
-
LipsyncEn:
|
|
1401
|
+
LipsyncEn: gt
|
|
1402
1402
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1403
|
-
class
|
|
1403
|
+
class ft {
|
|
1404
1404
|
/**
|
|
1405
1405
|
* @constructor
|
|
1406
1406
|
*/
|
|
@@ -1754,11 +1754,11 @@ class yt {
|
|
|
1754
1754
|
return e;
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
|
-
const
|
|
1757
|
+
const xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1758
1758
|
__proto__: null,
|
|
1759
|
-
LipsyncDe:
|
|
1759
|
+
LipsyncDe: ft
|
|
1760
1760
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1761
|
-
class
|
|
1761
|
+
class bt {
|
|
1762
1762
|
/**
|
|
1763
1763
|
* @constructor
|
|
1764
1764
|
*/
|
|
@@ -2289,11 +2289,11 @@ class xt {
|
|
|
2289
2289
|
return e;
|
|
2290
2290
|
}
|
|
2291
2291
|
}
|
|
2292
|
-
const
|
|
2292
|
+
const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2293
2293
|
__proto__: null,
|
|
2294
|
-
LipsyncFr:
|
|
2294
|
+
LipsyncFr: bt
|
|
2295
2295
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2296
|
-
class
|
|
2296
|
+
class vt {
|
|
2297
2297
|
/**
|
|
2298
2298
|
* @constructor
|
|
2299
2299
|
*/
|
|
@@ -2436,11 +2436,11 @@ class Rt {
|
|
|
2436
2436
|
return e;
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
const
|
|
2439
|
+
const It = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2440
2440
|
__proto__: null,
|
|
2441
|
-
LipsyncFi:
|
|
2441
|
+
LipsyncFi: vt
|
|
2442
2442
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2443
|
-
class
|
|
2443
|
+
class At {
|
|
2444
2444
|
/**
|
|
2445
2445
|
* @constructor
|
|
2446
2446
|
*/
|
|
@@ -2620,23 +2620,23 @@ class It {
|
|
|
2620
2620
|
return e;
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
2623
|
-
const
|
|
2623
|
+
const Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2624
2624
|
__proto__: null,
|
|
2625
|
-
LipsyncLt:
|
|
2626
|
-
}, Symbol.toStringTag, { value: "Module" })), Lt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkIC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YgKHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aCA+IDApIHsKICAgICAgICAgIHRoaXMuX2N1cnJlbnRDaHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKHRoaXMuX2N1cnJlbnRDaHVuaykg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nJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Ke = {
|
|
2627
|
-
en:
|
|
2628
|
-
de:
|
|
2629
|
-
fr:
|
|
2630
|
-
fi:
|
|
2631
|
-
lt:
|
|
2632
|
-
}, ie = new
|
|
2633
|
-
new
|
|
2634
|
-
new
|
|
2635
|
-
new
|
|
2636
|
-
new
|
|
2637
|
-
const
|
|
2638
|
-
new
|
|
2639
|
-
new
|
|
2625
|
+
LipsyncLt: At
|
|
2626
|
+
}, Symbol.toStringTag, { value: "Module" })), St = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMR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ICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciB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url), Ke = {
|
|
2627
|
+
en: yt,
|
|
2628
|
+
de: xt,
|
|
2629
|
+
fr: Rt,
|
|
2630
|
+
fi: It,
|
|
2631
|
+
lt: Lt
|
|
2632
|
+
}, ie = new x.Quaternion(), _ = new x.Euler(), Te = new x.Vector3(), Ee = new x.Vector3(), Je = new x.Box3();
|
|
2633
|
+
new x.Matrix4();
|
|
2634
|
+
new x.Matrix4();
|
|
2635
|
+
new x.Vector3();
|
|
2636
|
+
new x.Vector3(0, 0, 1);
|
|
2637
|
+
const kt = new x.Vector3(1, 0, 0);
|
|
2638
|
+
new x.Vector3(0, 1, 0);
|
|
2639
|
+
new x.Vector3(0, 0, 1);
|
|
2640
2640
|
class Qe {
|
|
2641
2641
|
/**
|
|
2642
2642
|
* Avatar.
|
|
@@ -2763,7 +2763,7 @@ class Qe {
|
|
|
2763
2763
|
avatarOnlyCamera: null,
|
|
2764
2764
|
statsNode: null,
|
|
2765
2765
|
statsStyle: null
|
|
2766
|
-
}, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new
|
|
2766
|
+
}, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new ut(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
|
|
2767
2767
|
side: {
|
|
2768
2768
|
standing: !0,
|
|
2769
2769
|
props: {
|
|
@@ -4073,22 +4073,22 @@ class Qe {
|
|
|
4073
4073
|
if (this.isAvatarOnly = this.opt.avatarOnly, this.isAvatarOnly)
|
|
4074
4074
|
this.scene = this.opt.avatarOnlyScene, this.camera = this.opt.avatarOnlyCamera;
|
|
4075
4075
|
else {
|
|
4076
|
-
this.renderer = new
|
|
4077
|
-
new
|
|
4076
|
+
this.renderer = new x.WebGLRenderer({ antialias: !0, alpha: !0 }), this.renderer.setPixelRatio(this.opt.modelPixelRatio * window.devicePixelRatio), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), this.renderer.outputColorSpace = x.SRGBColorSpace, this.renderer.toneMapping = x.ACESFilmicToneMapping, this.renderer.shadowMap.enabled = !1, this.nodeAvatar.appendChild(this.renderer.domElement), this.camera = new x.PerspectiveCamera(10, this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight, 0.1, 2e3), this.scene = new x.Scene(), this.lightAmbient = new x.AmbientLight(
|
|
4077
|
+
new x.Color(this.opt.lightAmbientColor),
|
|
4078
4078
|
this.opt.lightAmbientIntensity
|
|
4079
|
-
), this.lightDirect = new
|
|
4080
|
-
new
|
|
4079
|
+
), this.lightDirect = new x.DirectionalLight(
|
|
4080
|
+
new x.Color(this.opt.lightDirectColor),
|
|
4081
4081
|
this.opt.lightDirectIntensity
|
|
4082
|
-
), this.lightSpot = new
|
|
4083
|
-
new
|
|
4082
|
+
), this.lightSpot = new x.SpotLight(
|
|
4083
|
+
new x.Color(this.opt.lightSpotColor),
|
|
4084
4084
|
this.opt.lightSpotIntensity,
|
|
4085
4085
|
0,
|
|
4086
4086
|
this.opt.lightSpotDispersion
|
|
4087
4087
|
), this.setLighting(this.opt);
|
|
4088
|
-
const a = new
|
|
4089
|
-
a.compileEquirectangularShader(), this.scene.environment = a.fromScene(new
|
|
4088
|
+
const a = new x.PMREMGenerator(this.renderer);
|
|
4089
|
+
a.compileEquirectangularShader(), this.scene.environment = a.fromScene(new lt()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new st(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
|
|
4090
4090
|
}
|
|
4091
|
-
this.ikMesh = new
|
|
4091
|
+
this.ikMesh = new x.SkinnedMesh();
|
|
4092
4092
|
const s = {
|
|
4093
4093
|
LeftShoulder: null,
|
|
4094
4094
|
LeftArm: "LeftShoulder",
|
|
@@ -4102,16 +4102,16 @@ class Qe {
|
|
|
4102
4102
|
RightHandMiddle1: "RightHand"
|
|
4103
4103
|
}, i = [];
|
|
4104
4104
|
Object.entries(s).forEach((a, c) => {
|
|
4105
|
-
const l = new
|
|
4105
|
+
const l = new x.Bone();
|
|
4106
4106
|
l.name = a[0], a[1] ? this.ikMesh.getObjectByName(a[1]).add(l) : this.ikMesh.add(l), i.push(l);
|
|
4107
|
-
}), this.ikMesh.bind(new
|
|
4107
|
+
}), this.ikMesh.bind(new x.Skeleton(i)), this.dynamicbones = new mt(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
|
|
4108
4108
|
}
|
|
4109
4109
|
/**
|
|
4110
4110
|
* Helper that re/creates the audio context and the other nodes.
|
|
4111
4111
|
* @param {number} sampleRate
|
|
4112
4112
|
*/
|
|
4113
4113
|
initAudioGraph(t = null) {
|
|
4114
|
-
if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new
|
|
4114
|
+
if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new pt(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
|
|
4115
4115
|
this.opt.mixerGainSpeech,
|
|
4116
4116
|
this.opt.mixerGainBackground
|
|
4117
4117
|
), this.workletLoaded = !1, this.streamWorkletNode) {
|
|
@@ -4194,7 +4194,7 @@ class Qe {
|
|
|
4194
4194
|
for (let [n, o] of Object.entries(t)) {
|
|
4195
4195
|
const s = n.split(".");
|
|
4196
4196
|
let i = Array.isArray(o.x) ? this.gaussianRandom(...o.x) : o.x, a = Array.isArray(o.y) ? this.gaussianRandom(...o.y) : o.y, c = Array.isArray(o.z) ? this.gaussianRandom(...o.z) : o.z;
|
|
4197
|
-
s[1] === "position" || s[1] === "scale" ? e[n] = new
|
|
4197
|
+
s[1] === "position" || s[1] === "scale" ? e[n] = new x.Vector3(i, a, c) : s[1] === "rotation" ? (n = s[0] + ".quaternion", e[n] = new x.Quaternion().setFromEuler(new x.Euler(i, a, c, "XYZ")).normalize()) : s[1] === "quaternion" && (e[n] = new x.Quaternion(i, a, c, o.w).normalize());
|
|
4198
4198
|
}
|
|
4199
4199
|
return e;
|
|
4200
4200
|
}
|
|
@@ -4226,7 +4226,7 @@ class Qe {
|
|
|
4226
4226
|
for (const [l, u] of Object.entries(n))
|
|
4227
4227
|
if (s.morphTargetDictionary.hasOwnProperty(l)) {
|
|
4228
4228
|
const r = s.morphTargetDictionary[l], d = i.morphAttributes.position[r], h = i.morphAttributes.normal?.[r];
|
|
4229
|
-
a || (a = new
|
|
4229
|
+
a || (a = new x.Float32BufferAttribute(d.count * 3, 3), h && (c = new x.Float32BufferAttribute(d.count * 3, 3)));
|
|
4230
4230
|
for (let g = 0; g < d.count; g++) {
|
|
4231
4231
|
const R = a.getX(g) + d.getX(g) * u, b = a.getY(g) + d.getY(g) * u, L = a.getZ(g) + d.getZ(g) * u;
|
|
4232
4232
|
a.setXYZ(g, R, b, L);
|
|
@@ -4252,9 +4252,9 @@ class Qe {
|
|
|
4252
4252
|
async showAvatar(t, e = null) {
|
|
4253
4253
|
if (!t || !t.hasOwnProperty("url"))
|
|
4254
4254
|
throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
|
|
4255
|
-
const n = new
|
|
4255
|
+
const n = new rt();
|
|
4256
4256
|
if (this.dracoEnabled) {
|
|
4257
|
-
const l = new
|
|
4257
|
+
const l = new at();
|
|
4258
4258
|
l.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(l);
|
|
4259
4259
|
}
|
|
4260
4260
|
let o = await n.loadAsync(t.url, e);
|
|
@@ -4314,7 +4314,7 @@ class Qe {
|
|
|
4314
4314
|
console.error("Dynamic bones setup failed: " + l);
|
|
4315
4315
|
}
|
|
4316
4316
|
this.objectLeftToeBase = this.armature.getObjectByName("LeftToeBase"), this.objectRightToeBase = this.armature.getObjectByName("RightToeBase"), this.objectLeftEye = this.armature.getObjectByName("LeftEye"), this.objectRightEye = this.armature.getObjectByName("RightEye"), this.objectLeftArm = this.armature.getObjectByName("LeftArm"), this.objectRightArm = this.armature.getObjectByName("RightArm"), this.objectHips = this.armature.getObjectByName("Hips"), this.objectHead = this.armature.getObjectByName("Head"), this.objectNeck = this.armature.getObjectByName("Neck");
|
|
4317
|
-
const c = new
|
|
4317
|
+
const c = new x.Vector3();
|
|
4318
4318
|
this.objectLeftEye.getWorldPosition(c), this.avatarHeight = c.y + 0.2, this.viewName || this.setView(this.opt.cameraView), this.setMood(this.avatar.avatarMood || this.moodName || this.opt.avatarMood), this.avatar.body === "M" && this.poseTemplates.wide && (this.poseName = "wide", this.setPoseFromTemplate(this.poseTemplates.wide, 0)), this.initializeFBXAnimationLoader(), this.bodyMovement && this.bodyMovement !== "idle" && this.applyBodyMovementAnimation(), this.start();
|
|
4319
4319
|
}
|
|
4320
4320
|
/**
|
|
@@ -4358,14 +4358,14 @@ class Qe {
|
|
|
4358
4358
|
default:
|
|
4359
4359
|
r += 12, u = u * r;
|
|
4360
4360
|
}
|
|
4361
|
-
l = l * r, this.controlsEnd = new
|
|
4361
|
+
l = l * r, this.controlsEnd = new x.Vector3(l, u, 0), this.cameraEnd = new x.Vector3(l, u, r).applyEuler(new x.Euler(i, a, 0)), this.cameraClock === null && (this.controls.target.copy(this.controlsEnd), this.camera.position.copy(this.cameraEnd)), this.controlsStart = this.controls.target.clone(), this.cameraStart = this.camera.position.clone(), this.cameraClock = 0;
|
|
4362
4362
|
}
|
|
4363
4363
|
/**
|
|
4364
4364
|
* Change light colors and intensities.
|
|
4365
4365
|
* @param {Object} opt Options
|
|
4366
4366
|
*/
|
|
4367
4367
|
setLighting(t) {
|
|
4368
|
-
this.isAvatarOnly || (t = t || {}, t.hasOwnProperty("lightAmbientColor") && this.lightAmbient.color.set(new
|
|
4368
|
+
this.isAvatarOnly || (t = t || {}, t.hasOwnProperty("lightAmbientColor") && this.lightAmbient.color.set(new x.Color(t.lightAmbientColor)), t.hasOwnProperty("lightAmbientIntensity") && (this.lightAmbient.intensity = t.lightAmbientIntensity, this.lightAmbient.visible = t.lightAmbientIntensity !== 0), t.hasOwnProperty("lightDirectColor") && this.lightDirect.color.set(new x.Color(t.lightDirectColor)), t.hasOwnProperty("lightDirectIntensity") && (this.lightDirect.intensity = t.lightDirectIntensity, this.lightDirect.visible = t.lightDirectIntensity !== 0), t.hasOwnProperty("lightDirectPhi") && t.hasOwnProperty("lightDirectTheta") && this.lightDirect.position.setFromSphericalCoords(2, t.lightDirectPhi, t.lightDirectTheta), t.hasOwnProperty("lightSpotColor") && this.lightSpot.color.set(new x.Color(t.lightSpotColor)), t.hasOwnProperty("lightSpotIntensity") && (this.lightSpot.intensity = t.lightSpotIntensity, this.lightSpot.visible = t.lightSpotIntensity !== 0), t.hasOwnProperty("lightSpotPhi") && t.hasOwnProperty("lightSpotTheta") && (this.lightSpot.position.setFromSphericalCoords(2, t.lightSpotPhi, t.lightSpotTheta), this.lightSpot.position.add(new x.Vector3(0, 1.5, 0))), t.hasOwnProperty("lightSpotDispersion") && (this.lightSpot.angle = t.lightSpotDispersion));
|
|
4369
4369
|
}
|
|
4370
4370
|
/**
|
|
4371
4371
|
* Render scene.
|
|
@@ -4412,9 +4412,9 @@ class Qe {
|
|
|
4412
4412
|
updatePoseDelta() {
|
|
4413
4413
|
for (const [t, e] of Object.entries(this.poseDelta.props)) {
|
|
4414
4414
|
if (e.x === 0 && e.y === 0 && e.z === 0) continue;
|
|
4415
|
-
|
|
4415
|
+
_.set(e.x, e.y, e.z);
|
|
4416
4416
|
const n = this.poseAvatar.props[t];
|
|
4417
|
-
n.isQuaternion ? (ie.setFromEuler(
|
|
4417
|
+
n.isQuaternion ? (ie.setFromEuler(_), n.multiply(ie)) : n.isVector3 && n.add(_);
|
|
4418
4418
|
}
|
|
4419
4419
|
}
|
|
4420
4420
|
/**
|
|
@@ -4494,7 +4494,7 @@ class Qe {
|
|
|
4494
4494
|
return Object.entries(t).forEach((o, s) => {
|
|
4495
4495
|
const i = o[0].split(".");
|
|
4496
4496
|
if (i[1] === "position" || i[1] === "rotation" || i[1] === "quaternion") {
|
|
4497
|
-
const a = i[1] === "quaternion" ? i[0] + ".rotation" : o[0], c = o[1].isQuaternion ? new
|
|
4497
|
+
const a = i[1] === "quaternion" ? i[0] + ".rotation" : o[0], c = o[1].isQuaternion ? new x.Euler().setFromQuaternion(o[1]) : o[1];
|
|
4498
4498
|
n += (s ? ", " : "") + "'" + a + "':{", n += "x:" + Math.round(c.x * e) / e, n += ", y:" + Math.round(c.y * e) / e, n += ", z:" + Math.round(c.z * e) / e, n += "}";
|
|
4499
4499
|
}
|
|
4500
4500
|
}), n += "}", n;
|
|
@@ -5164,7 +5164,7 @@ class Qe {
|
|
|
5164
5164
|
{ link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
|
|
5165
5165
|
{ link: "LeftArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
|
|
5166
5166
|
]
|
|
5167
|
-
}, o.x ? new
|
|
5167
|
+
}, o.x ? new x.Vector3(o.x, o.y, o.z) : null, !0, o.d);
|
|
5168
5168
|
break;
|
|
5169
5169
|
case "handRight":
|
|
5170
5170
|
this.ikSolve({
|
|
@@ -5176,10 +5176,10 @@ class Qe {
|
|
|
5176
5176
|
{ link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5, maxAngle: 0.2 },
|
|
5177
5177
|
{ link: "RightArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
|
|
5178
5178
|
]
|
|
5179
|
-
}, o.x ? new
|
|
5179
|
+
}, o.x ? new x.Vector3(o.x, o.y, o.z) : null, !0, o.d);
|
|
5180
5180
|
break;
|
|
5181
5181
|
}
|
|
5182
|
-
if ((c || l) && (
|
|
5182
|
+
if ((c || l) && (_.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), _.x = Math.max(-0.9, Math.min(0.9, 2 * _.x - 0.5)), _.y = Math.max(-0.9, Math.min(0.9, -2.5 * _.y)), c ? (Object.assign(this.mtAvatar.eyesLookDown, { system: _.x < 0 ? -_.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: _.x < 0 ? 0 : _.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: _.y < 0 ? -_.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: _.y < 0 ? 0 : _.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: _.y < 0 ? 0 : _.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: _.y < 0 ? -_.y : 0, needsUpdate: !0 }), l && (n = -this.mtAvatar.bodyRotateY.value, o = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
|
|
5183
5183
|
name: "headmove",
|
|
5184
5184
|
dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
|
|
5185
5185
|
vs: {
|
|
@@ -5200,12 +5200,12 @@ class Qe {
|
|
|
5200
5200
|
eyeLookOutRight: [null, 0],
|
|
5201
5201
|
eyeContact: [0]
|
|
5202
5202
|
}
|
|
5203
|
-
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], o = this.mtAvatar[n], o.needsUpdate || Object.assign(o, { base: (this.mood.baseline[n] || 0) + (1 + a / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(),
|
|
5203
|
+
})))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], o = this.mtAvatar[n], o.needsUpdate || Object.assign(o, { base: (this.mood.baseline[n] || 0) + (1 + a / 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) && c ? a > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = a) : (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, o = Math.abs(n), o > 1e-4 && (i = o * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / o) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(o, i)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (ie.setFromAxisAngle(kt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(ie)), Je.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(Te), Te.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(Ee), Ee.sub(this.armature.position), this.objectHips.position.y -= Je.min.y / 2, this.objectHips.position.x -= (Te.x + Ee.x) / 4, this.objectHips.position.z -= (Te.z + Ee.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
|
|
5204
5204
|
this.stats && this.stats.end();
|
|
5205
5205
|
else {
|
|
5206
5206
|
if (this.cameraClock !== null && this.cameraClock < 1e3) {
|
|
5207
5207
|
this.cameraClock += e, this.cameraClock > 1e3 && (this.cameraClock = 1e3);
|
|
5208
|
-
let r = new
|
|
5208
|
+
let r = new x.Spherical().setFromVector3(this.cameraStart), d = new x.Spherical().setFromVector3(this.cameraEnd);
|
|
5209
5209
|
r.phi += this.easing(this.cameraClock / 1e3) * (d.phi - r.phi), r.theta += this.easing(this.cameraClock / 1e3) * (d.theta - r.theta), r.radius += this.easing(this.cameraClock / 1e3) * (d.radius - r.radius), r.makeSafe(), this.camera.position.setFromSpherical(r), this.controlsStart.x !== this.controlsEnd.x ? this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd, this.easing(this.cameraClock / 1e3))) : (r.setFromVector3(this.controlsStart), d.setFromVector3(this.controlsEnd), r.phi += this.easing(this.cameraClock / 1e3) * (d.phi - r.phi), r.theta += this.easing(this.cameraClock / 1e3) * (d.theta - r.theta), r.radius += this.easing(this.cameraClock / 1e3) * (d.radius - r.radius), r.makeSafe(), this.controls.target.setFromSpherical(r)), this.controls.update();
|
|
5210
5210
|
}
|
|
5211
5211
|
this.controls.autoRotate && this.controls.update(), this.stats && this.stats.end(), this.render();
|
|
@@ -5288,13 +5288,13 @@ class Qe {
|
|
|
5288
5288
|
const y = this.lipsyncWordsToVisemes(r, l);
|
|
5289
5289
|
if (y && y.visemes && y.visemes.length) {
|
|
5290
5290
|
const F = y.times[y.visemes.length - 1] + y.durations[y.visemes.length - 1];
|
|
5291
|
-
for (let
|
|
5291
|
+
for (let f = 0; f < y.visemes.length; f++)
|
|
5292
5292
|
g.push({
|
|
5293
5293
|
mark: d,
|
|
5294
5294
|
template: { name: "viseme" },
|
|
5295
|
-
ts: [(y.times[
|
|
5295
|
+
ts: [(y.times[f] - 0.6) / F, (y.times[f] + 0.5) / F, (y.times[f] + y.durations[f] + 0.5) / F],
|
|
5296
5296
|
vs: {
|
|
5297
|
-
["viseme_" + y.visemes[
|
|
5297
|
+
["viseme_" + y.visemes[f]]: [null, y.visemes[f] === "PP" || y.visemes[f] === "FF" ? 0.9 : 0.6, 0]
|
|
5298
5298
|
}
|
|
5299
5299
|
});
|
|
5300
5300
|
}
|
|
@@ -5497,10 +5497,10 @@ class Qe {
|
|
|
5497
5497
|
if (b && b.visemes && b.visemes.length > 0) {
|
|
5498
5498
|
const p = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
|
|
5499
5499
|
for (let P = 0; P < b.visemes.length; P++) {
|
|
5500
|
-
const E = b.visemes[P], y = b.times[P] / p, F = b.durations[P] / p,
|
|
5500
|
+
const E = b.visemes[P], y = b.times[P] / p, F = b.durations[P] / p, f = y * d, S = F * d;
|
|
5501
5501
|
L.push({
|
|
5502
5502
|
template: { name: "viseme" },
|
|
5503
|
-
ts: [
|
|
5503
|
+
ts: [f - Math.min(60, 2 * S / 3), f + Math.min(25, S / 2), f + S + Math.min(60, S / 2)],
|
|
5504
5504
|
vs: {
|
|
5505
5505
|
["viseme_" + E]: [null, E === "PP" || E === "FF" ? 0.9 : 0.6, 0]
|
|
5506
5506
|
}
|
|
@@ -5861,7 +5861,7 @@ class Qe {
|
|
|
5861
5861
|
}
|
|
5862
5862
|
if (!this.workletLoaded)
|
|
5863
5863
|
try {
|
|
5864
|
-
const a = this.audioCtx.audioWorklet.addModule(
|
|
5864
|
+
const a = this.audioCtx.audioWorklet.addModule(St.href), c = new Promise(
|
|
5865
5865
|
(l, u) => setTimeout(() => u(new Error("Worklet loading timed out")), 5e3)
|
|
5866
5866
|
);
|
|
5867
5867
|
await Promise.race([a, c]), this.workletLoaded = !0;
|
|
@@ -6099,7 +6099,7 @@ class Qe {
|
|
|
6099
6099
|
*/
|
|
6100
6100
|
lookAtCamera(t) {
|
|
6101
6101
|
let e;
|
|
6102
|
-
if (this.speakTo && (e = new
|
|
6102
|
+
if (this.speakTo && (e = new x.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), Te.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), Ee.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(Te, Ee).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) {
|
|
6103
6103
|
if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
|
|
6104
6104
|
if (this.avatar.avatarIgnoreCamera) {
|
|
6105
6105
|
this.lookAhead(t);
|
|
@@ -6113,11 +6113,11 @@ class Qe {
|
|
|
6113
6113
|
return;
|
|
6114
6114
|
}
|
|
6115
6115
|
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), Te.setFromMatrixPosition(this.objectLeftEye.matrixWorld), Ee.setFromMatrixPosition(this.objectRightEye.matrixWorld), Te.add(Ee).divideScalar(2), ie.copy(this.armature.quaternion), ie.multiply(this.poseTarget.props["Hips.quaternion"]), ie.multiply(this.poseTarget.props["Spine.quaternion"]), ie.multiply(this.poseTarget.props["Spine1.quaternion"]), ie.multiply(this.poseTarget.props["Spine2.quaternion"]), ie.multiply(this.poseTarget.props["Neck.quaternion"]), ie.multiply(this.poseTarget.props["Head.quaternion"]);
|
|
6116
|
-
const n = new
|
|
6117
|
-
|
|
6118
|
-
const a = new
|
|
6119
|
-
|
|
6120
|
-
let l =
|
|
6116
|
+
const n = new x.Vector3().subVectors(e, Te).normalize(), o = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
|
|
6117
|
+
_.set(s, o, 0, "YXZ");
|
|
6118
|
+
const a = new x.Quaternion().setFromEuler(_), c = new x.Quaternion().copy(a).multiply(ie.clone().invert());
|
|
6119
|
+
_.setFromQuaternion(c, "YXZ");
|
|
6120
|
+
let l = _.x / (40 / 24) + 0.2, u = _.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, l)), d = Math.min(0.8, Math.max(-0.8, u)), h = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
|
|
6121
6121
|
if (t) {
|
|
6122
6122
|
let R = this.animQueue.findIndex((L) => L.template.name === "lookat");
|
|
6123
6123
|
R !== -1 && this.animQueue.splice(R, 1);
|
|
@@ -6149,11 +6149,11 @@ class Qe {
|
|
|
6149
6149
|
if (!this.camera) return;
|
|
6150
6150
|
const o = this.nodeAvatar.getBoundingClientRect();
|
|
6151
6151
|
this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0);
|
|
6152
|
-
const s = new
|
|
6152
|
+
const s = new x.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), i = new x.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), a = new x.Vector3().addVectors(s, i).divideScalar(2);
|
|
6153
6153
|
a.project(this.camera);
|
|
6154
6154
|
let c = (a.x + 1) / 2 * o.width + o.left, l = -(a.y - 1) / 2 * o.height + o.top;
|
|
6155
|
-
t === null && (t = c), e === null && (e = l), ie.copy(this.armature.quaternion), ie.multiply(this.poseTarget.props["Hips.quaternion"]), ie.multiply(this.poseTarget.props["Spine.quaternion"]), ie.multiply(this.poseTarget.props["Spine1.quaternion"]), ie.multiply(this.poseTarget.props["Spine2.quaternion"]), ie.multiply(this.poseTarget.props["Neck.quaternion"]), ie.multiply(this.poseTarget.props["Head.quaternion"]),
|
|
6156
|
-
let u =
|
|
6155
|
+
t === null && (t = c), e === null && (e = l), ie.copy(this.armature.quaternion), ie.multiply(this.poseTarget.props["Hips.quaternion"]), ie.multiply(this.poseTarget.props["Spine.quaternion"]), ie.multiply(this.poseTarget.props["Spine1.quaternion"]), ie.multiply(this.poseTarget.props["Spine2.quaternion"]), ie.multiply(this.poseTarget.props["Neck.quaternion"]), ie.multiply(this.poseTarget.props["Head.quaternion"]), _.setFromQuaternion(ie);
|
|
6156
|
+
let u = _.x / (40 / 24), r = _.y / (9 / 4), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), h = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - c, c), R = Math.max(window.innerHeight - l, l), b = this.convertRange(e, [l - R, l + R], [-0.3, 0.6]) - u + d, L = this.convertRange(t, [c - g, c + g], [-0.8, 0.8]) - r + h;
|
|
6157
6157
|
b = Math.min(0.6, Math.max(-0.3, b)), L = Math.min(0.8, Math.max(-0.8, L));
|
|
6158
6158
|
let T = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
|
|
6159
6159
|
if (n) {
|
|
@@ -6185,14 +6185,14 @@ class Qe {
|
|
|
6185
6185
|
*/
|
|
6186
6186
|
touchAt(t, e) {
|
|
6187
6187
|
if (!this.camera) return;
|
|
6188
|
-
const n = this.nodeAvatar.getBoundingClientRect(), o = new
|
|
6188
|
+
const n = this.nodeAvatar.getBoundingClientRect(), o = new x.Vector2(
|
|
6189
6189
|
(t - n.left) / n.width * 2 - 1,
|
|
6190
6190
|
-((e - n.top) / n.height) * 2 + 1
|
|
6191
|
-
), s = new
|
|
6191
|
+
), s = new x.Raycaster();
|
|
6192
6192
|
s.setFromCamera(o, this.camera);
|
|
6193
6193
|
const i = s.intersectObject(this.armature);
|
|
6194
6194
|
if (i.length > 0) {
|
|
6195
|
-
const a = i[0].point, c = new
|
|
6195
|
+
const a = i[0].point, c = new x.Vector3(), l = new x.Vector3();
|
|
6196
6196
|
this.objectLeftArm.getWorldPosition(c), this.objectRightArm.getWorldPosition(l);
|
|
6197
6197
|
const u = c.distanceToSquared(a), r = l.distanceToSquared(a);
|
|
6198
6198
|
u < r ? (this.ikSolve({
|
|
@@ -6236,7 +6236,7 @@ class Qe {
|
|
|
6236
6236
|
{ link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
|
|
6237
6237
|
{ link: "LeftArm", minx: -1.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -1, maxz: 3 }
|
|
6238
6238
|
]
|
|
6239
|
-
}, new
|
|
6239
|
+
}, new x.Vector3(
|
|
6240
6240
|
this.gaussianRandom(0, 0.5),
|
|
6241
6241
|
this.gaussianRandom(-0.8, -0.2),
|
|
6242
6242
|
this.gaussianRandom(0, 0.5)
|
|
@@ -6248,15 +6248,15 @@ class Qe {
|
|
|
6248
6248
|
{ link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5 },
|
|
6249
6249
|
{ link: "RightArm" }
|
|
6250
6250
|
]
|
|
6251
|
-
}, new
|
|
6251
|
+
}, new x.Vector3(
|
|
6252
6252
|
this.gaussianRandom(-0.5, 0),
|
|
6253
6253
|
this.gaussianRandom(-0.8, -0.2),
|
|
6254
6254
|
this.gaussianRandom(0, 0.5)
|
|
6255
6255
|
), !0);
|
|
6256
6256
|
const n = [], o = [];
|
|
6257
6257
|
n.push(100 + Math.round(Math.random() * 500)), o.push({ duration: 1e3, props: {
|
|
6258
|
-
"LeftHand.quaternion": new
|
|
6259
|
-
"RightHand.quaternion": new
|
|
6258
|
+
"LeftHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, -1 - Math.random(), 0)),
|
|
6259
|
+
"RightHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, 1 + Math.random(), 0))
|
|
6260
6260
|
} }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm"].forEach((i) => {
|
|
6261
6261
|
o[0].props[i + ".quaternion"] = this.ikMesh.getObjectByName(i).quaternion.clone();
|
|
6262
6262
|
}), n.push(1e3 + Math.round(Math.random() * 500)), o.push({ duration: 2e3, props: {} }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm", "LeftHand", "RightHand"].forEach((i) => {
|
|
@@ -6341,7 +6341,7 @@ class Qe {
|
|
|
6341
6341
|
let l = this.animQueue.find((h) => h.template.name === "pose");
|
|
6342
6342
|
l && (l.ts[0] = 1 / 0), Object.entries(c.pose.props).forEach((h) => {
|
|
6343
6343
|
this.poseBase.props[h[0]] = h[1].clone(), this.poseTarget.props[h[0]] = h[1].clone(), this.poseTarget.props[h[0]].t = 0, this.poseTarget.props[h[0]].d = 1e3;
|
|
6344
|
-
}), this.mixer || (this.mixer = new
|
|
6344
|
+
}), this.mixer || (this.mixer = new x.AnimationMixer(this.armature)), this.animationFinishedCallback = a;
|
|
6345
6345
|
const u = () => {
|
|
6346
6346
|
this.animationFinishedCallback && (this.animationFinishedCallback(), this.animationFinishedCallback = null), this.stopAnimation();
|
|
6347
6347
|
};
|
|
@@ -6349,7 +6349,7 @@ class Qe {
|
|
|
6349
6349
|
let r = 1;
|
|
6350
6350
|
n > 0 && (r = Math.ceil(n / c.clip.duration));
|
|
6351
6351
|
const d = this.mixer.clipAction(c.clip);
|
|
6352
|
-
if (d.setLoop(
|
|
6352
|
+
if (d.setLoop(x.LoopRepeat, r), d.clampWhenFinished = !0, this.currentFBXAction && this.currentFBXAction.isRunning()) {
|
|
6353
6353
|
this.currentFBXAction.fadeOut(0.3), setTimeout(() => {
|
|
6354
6354
|
this.currentFBXAction = d;
|
|
6355
6355
|
try {
|
|
@@ -6421,28 +6421,28 @@ class Qe {
|
|
|
6421
6421
|
let F = y.replace(/^mixamorig/i, "").replace(/^CC_Base_/i, "").replace(/^RPM_/i, "");
|
|
6422
6422
|
if (g.has(F))
|
|
6423
6423
|
return F;
|
|
6424
|
-
const
|
|
6425
|
-
if (
|
|
6426
|
-
if (
|
|
6424
|
+
const f = F.toLowerCase();
|
|
6425
|
+
if (f.includes("left") && f.includes("arm")) {
|
|
6426
|
+
if (f.includes("fore") || f.includes("lower")) {
|
|
6427
6427
|
if (g.has("LeftForeArm")) return "LeftForeArm";
|
|
6428
6428
|
if (g.has("LeftForearm")) return "LeftForearm";
|
|
6429
|
-
} else if (!
|
|
6429
|
+
} else if (!f.includes("fore") && !f.includes("hand") && g.has("LeftArm"))
|
|
6430
6430
|
return "LeftArm";
|
|
6431
6431
|
}
|
|
6432
|
-
if (
|
|
6433
|
-
if (
|
|
6432
|
+
if (f.includes("right") && f.includes("arm")) {
|
|
6433
|
+
if (f.includes("fore") || f.includes("lower")) {
|
|
6434
6434
|
if (g.has("RightForeArm")) return "RightForeArm";
|
|
6435
6435
|
if (g.has("RightForearm")) return "RightForearm";
|
|
6436
|
-
} else if (!
|
|
6436
|
+
} else if (!f.includes("fore") && !f.includes("hand") && g.has("RightArm"))
|
|
6437
6437
|
return "RightArm";
|
|
6438
6438
|
}
|
|
6439
|
-
if (
|
|
6439
|
+
if (f.includes("left") && f.includes("hand") && !f.includes("index") && !f.includes("thumb") && !f.includes("middle") && !f.includes("ring") && !f.includes("pinky") && g.has("LeftHand"))
|
|
6440
6440
|
return "LeftHand";
|
|
6441
|
-
if (
|
|
6441
|
+
if (f.includes("right") && f.includes("hand") && !f.includes("index") && !f.includes("thumb") && !f.includes("middle") && !f.includes("ring") && !f.includes("pinky") && g.has("RightHand"))
|
|
6442
6442
|
return "RightHand";
|
|
6443
|
-
if (
|
|
6443
|
+
if (f.includes("left") && (f.includes("shoulder") || f.includes("clavicle")) && g.has("LeftShoulder"))
|
|
6444
6444
|
return "LeftShoulder";
|
|
6445
|
-
if (
|
|
6445
|
+
if (f.includes("right") && (f.includes("shoulder") || f.includes("clavicle")) && g.has("RightShoulder"))
|
|
6446
6446
|
return "RightShoulder";
|
|
6447
6447
|
const S = {
|
|
6448
6448
|
// Arm bones - exact matches
|
|
@@ -6490,11 +6490,11 @@ class Qe {
|
|
|
6490
6490
|
return H;
|
|
6491
6491
|
}
|
|
6492
6492
|
for (const H of g)
|
|
6493
|
-
if (H.toLowerCase() ===
|
|
6493
|
+
if (H.toLowerCase() === f)
|
|
6494
6494
|
return H;
|
|
6495
6495
|
for (const H of g) {
|
|
6496
6496
|
const I = H.toLowerCase();
|
|
6497
|
-
if ((
|
|
6497
|
+
if ((f.includes("left") && I.includes("left") || f.includes("right") && I.includes("right")) && (f.includes("arm") && I.includes("arm") && !I.includes("fore") || f.includes("forearm") && I.includes("forearm") || f.includes("hand") && I.includes("hand") && !I.includes("index") && !I.includes("thumb") || f.includes("shoulder") && I.includes("shoulder")))
|
|
6498
6498
|
return H;
|
|
6499
6499
|
}
|
|
6500
6500
|
return null;
|
|
@@ -6509,23 +6509,23 @@ class Qe {
|
|
|
6509
6509
|
);
|
|
6510
6510
|
const T = [], p = /* @__PURE__ */ new Set();
|
|
6511
6511
|
h.tracks.forEach((y) => {
|
|
6512
|
-
const
|
|
6512
|
+
const f = y.name.replaceAll("mixamorig", "").split("."), S = f[0], H = f[1], I = b(S);
|
|
6513
6513
|
if (!(I && (I === "LeftShoulder" || I === "RightShoulder") && (H === "quaternion" || H === "rotation")))
|
|
6514
6514
|
if (I && H) {
|
|
6515
6515
|
const U = `${I}.${H}`, G = y.clone();
|
|
6516
6516
|
G.name = U, T.push(G), S !== I && R.set(S, I);
|
|
6517
6517
|
} else
|
|
6518
6518
|
p.add(S), (S.toLowerCase().includes("arm") || S.toLowerCase().includes("hand") || S.toLowerCase().includes("shoulder")) && console.warn(`⚠️ Arm bone "${S}" could not be mapped to avatar skeleton`);
|
|
6519
|
-
}), T.length > 0 ? h = new
|
|
6519
|
+
}), T.length > 0 ? h = new x.AnimationClip(h.name, h.duration, T) : console.error("No tracks could be mapped! Animation may not work correctly.");
|
|
6520
6520
|
const P = {};
|
|
6521
6521
|
h.tracks.forEach((y) => {
|
|
6522
6522
|
y.name = y.name.replaceAll("mixamorig", "");
|
|
6523
6523
|
const F = y.name.split(".");
|
|
6524
6524
|
if (F[1] === "position") {
|
|
6525
|
-
for (let
|
|
6526
|
-
y.values[
|
|
6527
|
-
P[y.name] = new
|
|
6528
|
-
} else F[1] === "quaternion" ? P[y.name] = new
|
|
6525
|
+
for (let f = 0; f < y.values.length; f++)
|
|
6526
|
+
y.values[f] = y.values[f] * s;
|
|
6527
|
+
P[y.name] = new x.Vector3(y.values[0], y.values[1], y.values[2]);
|
|
6528
|
+
} else F[1] === "quaternion" ? P[y.name] = new x.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : F[1] === "rotation" && (P[F[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
|
|
6529
6529
|
});
|
|
6530
6530
|
const E = { props: P };
|
|
6531
6531
|
P["Hips.position"] && (P["Hips.position"].y < 0.5 ? E.lying = !0 : E.standing = !0), this.animClips.push({
|
|
@@ -6576,7 +6576,7 @@ class Qe {
|
|
|
6576
6576
|
l.tracks.forEach((d) => {
|
|
6577
6577
|
d.name = d.name.replaceAll("mixamorig", "");
|
|
6578
6578
|
const h = d.name.split(".");
|
|
6579
|
-
h[1] === "position" ? u[d.name] = new
|
|
6579
|
+
h[1] === "position" ? u[d.name] = new x.Vector3(d.values[0] * s, d.values[1] * s, d.values[2] * s) : h[1] === "quaternion" ? u[d.name] = new x.Quaternion(d.values[0], d.values[1], d.values[2], d.values[3]) : h[1] === "rotation" && (u[h[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(d.values[0], d.values[1], d.values[2], "XYZ")).normalize());
|
|
6580
6580
|
});
|
|
6581
6581
|
const r = { props: u };
|
|
6582
6582
|
u["Hips.position"] && (u["Hips.position"].y < 0.5 ? r.lying = !0 : r.standing = !0), this.animPoses.push({
|
|
@@ -6609,7 +6609,7 @@ class Qe {
|
|
|
6609
6609
|
if (s) {
|
|
6610
6610
|
this.gestureTimeout && (clearTimeout(this.gestureTimeout), this.gestureTimeout = null);
|
|
6611
6611
|
let a = this.animQueue.findIndex((c) => c.template.name === "talkinghands");
|
|
6612
|
-
a !== -1 && (this.animQueue[a].ts = this.animQueue[a].ts.map((c) => 0)), this.gesture = this.propsToThreeObjects(s), n && (this.gesture = this.mirrorPose(this.gesture)), t === "namaste" && this.avatar.body === "M" && (this.gesture["RightArm.quaternion"].rotateTowards(new
|
|
6612
|
+
a !== -1 && (this.animQueue[a].ts = this.animQueue[a].ts.map((c) => 0)), this.gesture = this.propsToThreeObjects(s), n && (this.gesture = this.mirrorPose(this.gesture)), t === "namaste" && this.avatar.body === "M" && (this.gesture["RightArm.quaternion"].rotateTowards(new x.Quaternion(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new x.Quaternion(0, 1, 0, 0), -0.25));
|
|
6613
6613
|
for (let [c, l] of Object.entries(this.gesture))
|
|
6614
6614
|
l.t = this.animClock, l.d = o, this.poseTarget.props.hasOwnProperty(c) && (this.poseTarget.props[c].copy(l), this.poseTarget.props[c].t = this.animClock, this.poseTarget.props[c].d = o);
|
|
6615
6615
|
e && Number.isFinite(e) && (this.gestureTimeout = setTimeout(this.stopGesture.bind(this, o), 1e3 * e));
|
|
@@ -6657,7 +6657,7 @@ class Qe {
|
|
|
6657
6657
|
* @param {numeric} [d=null] If set, apply in d milliseconds
|
|
6658
6658
|
*/
|
|
6659
6659
|
ikSolve(t, e = null, n = !1, o = null) {
|
|
6660
|
-
const s = new
|
|
6660
|
+
const s = new x.Vector3(), i = new x.Vector3(), a = new x.Vector3(), c = new x.Vector3(), l = new x.Quaternion(), u = new x.Vector3(), r = new x.Vector3(), d = new x.Vector3(), h = this.ikMesh.getObjectByName(t.root);
|
|
6661
6661
|
h.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), h.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(h.position);
|
|
6662
6662
|
const g = this.ikMesh.getObjectByName(t.effector), R = t.links;
|
|
6663
6663
|
R.forEach((L) => {
|
|
@@ -6671,11 +6671,11 @@ class Qe {
|
|
|
6671
6671
|
const E = R[p].bone;
|
|
6672
6672
|
E.matrixWorld.decompose(c, l, u), l.invert(), i.setFromMatrixPosition(g.matrixWorld), a.subVectors(i, c), a.applyQuaternion(l), a.normalize(), s.subVectors(e, c), s.applyQuaternion(l), s.normalize();
|
|
6673
6673
|
let y = s.dot(a);
|
|
6674
|
-
y > 1 ? y = 1 : y < -1 && (y = -1), y = Math.acos(y), !(y < 1e-5) && (R[p].minAngle !== void 0 && y < R[p].minAngle && (y = R[p].minAngle), R[p].maxAngle !== void 0 && y > R[p].maxAngle && (y = R[p].maxAngle), r.crossVectors(a, s), r.normalize(), ie.setFromAxisAngle(r, y), E.quaternion.multiply(ie), E.rotation.setFromVector3(d.setFromEuler(E.rotation).clamp(new
|
|
6674
|
+
y > 1 ? y = 1 : y < -1 && (y = -1), y = Math.acos(y), !(y < 1e-5) && (R[p].minAngle !== void 0 && y < R[p].minAngle && (y = R[p].minAngle), R[p].maxAngle !== void 0 && y > R[p].maxAngle && (y = R[p].maxAngle), r.crossVectors(a, s), r.normalize(), ie.setFromAxisAngle(r, y), E.quaternion.multiply(ie), E.rotation.setFromVector3(d.setFromEuler(E.rotation).clamp(new x.Vector3(
|
|
6675
6675
|
R[p].minx !== void 0 ? R[p].minx : -1 / 0,
|
|
6676
6676
|
R[p].miny !== void 0 ? R[p].miny : -1 / 0,
|
|
6677
6677
|
R[p].minz !== void 0 ? R[p].minz : -1 / 0
|
|
6678
|
-
), new
|
|
6678
|
+
), new x.Vector3(
|
|
6679
6679
|
R[p].maxx !== void 0 ? R[p].maxx : 1 / 0,
|
|
6680
6680
|
R[p].maxy !== void 0 ? R[p].maxy : 1 / 0,
|
|
6681
6681
|
R[p].maxz !== void 0 ? R[p].maxz : 1 / 0
|
|
@@ -6774,13 +6774,13 @@ const et = Ze(({
|
|
|
6774
6774
|
style: R = {},
|
|
6775
6775
|
animations: b = {}
|
|
6776
6776
|
}, L) => {
|
|
6777
|
-
const T = W(null), p = W(null), P = W(l), E = W(null), y = W(null), F = W(!1),
|
|
6777
|
+
const T = W(null), p = W(null), P = W(l), E = W(null), y = W(null), F = W(!1), f = W({ remainingText: null, originalText: null, options: null }), S = W([]), H = W(0), [I, U] = ae(!0), [G, j] = ae(null), [Y, ue] = ae(!1), [le, Ie] = ae(!1);
|
|
6778
6778
|
fe(() => {
|
|
6779
6779
|
F.current = le;
|
|
6780
6780
|
}, [le]), fe(() => {
|
|
6781
6781
|
P.current = l;
|
|
6782
6782
|
}, [l]);
|
|
6783
|
-
const
|
|
6783
|
+
const re = je(), ze = o || re.service;
|
|
6784
6784
|
let ee;
|
|
6785
6785
|
ze === "browser" ? ee = {
|
|
6786
6786
|
service: "browser",
|
|
@@ -6790,19 +6790,19 @@ const et = Ze(({
|
|
|
6790
6790
|
} : ze === "elevenlabs" ? ee = {
|
|
6791
6791
|
service: "elevenlabs",
|
|
6792
6792
|
endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
|
|
6793
|
-
apiKey: i ||
|
|
6794
|
-
defaultVoice: s ||
|
|
6795
|
-
voices:
|
|
6793
|
+
apiKey: i || re.apiKey,
|
|
6794
|
+
defaultVoice: s || re.defaultVoice || Pe.defaultVoice,
|
|
6795
|
+
voices: re.voices || Pe.voices
|
|
6796
6796
|
} : ze === "deepgram" ? ee = {
|
|
6797
6797
|
service: "deepgram",
|
|
6798
6798
|
endpoint: "https://api.deepgram.com/v1/speak",
|
|
6799
|
-
apiKey: i ||
|
|
6800
|
-
defaultVoice: s ||
|
|
6801
|
-
voices:
|
|
6799
|
+
apiKey: i || re.apiKey,
|
|
6800
|
+
defaultVoice: s || re.defaultVoice || Ge.defaultVoice,
|
|
6801
|
+
voices: re.voices || Ge.voices
|
|
6802
6802
|
} : ee = {
|
|
6803
|
-
...
|
|
6803
|
+
...re,
|
|
6804
6804
|
// Override API key if provided via props
|
|
6805
|
-
apiKey: i !== null ? i :
|
|
6805
|
+
apiKey: i !== null ? i : re.apiKey
|
|
6806
6806
|
};
|
|
6807
6807
|
const v = {
|
|
6808
6808
|
url: V,
|
|
@@ -6820,19 +6820,19 @@ const et = Ze(({
|
|
|
6820
6820
|
ttsService: ze,
|
|
6821
6821
|
lipsyncModules: ["en"],
|
|
6822
6822
|
cameraView: u
|
|
6823
|
-
}, M =
|
|
6823
|
+
}, M = N(async () => {
|
|
6824
6824
|
if (!(!T.current || p.current))
|
|
6825
6825
|
try {
|
|
6826
6826
|
if (U(!0), j(null), p.current = new Qe(T.current, A), 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, (Q) => {
|
|
6827
6827
|
if (Q.lengthComputable) {
|
|
6828
|
-
const
|
|
6829
|
-
d(
|
|
6828
|
+
const se = Math.min(100, Math.round(Q.loaded / Q.total * 100));
|
|
6829
|
+
d(se);
|
|
6830
6830
|
}
|
|
6831
6831
|
}), await new Promise((Q) => {
|
|
6832
|
-
const
|
|
6833
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? Q() : setTimeout(
|
|
6832
|
+
const se = () => {
|
|
6833
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? Q() : setTimeout(se, 100);
|
|
6834
6834
|
};
|
|
6835
|
-
|
|
6835
|
+
se();
|
|
6836
6836
|
}), p.current && p.current.setShowFullAvatar)
|
|
6837
6837
|
try {
|
|
6838
6838
|
p.current.setShowFullAvatar(l);
|
|
@@ -6846,142 +6846,142 @@ const et = Ze(({
|
|
|
6846
6846
|
return document.addEventListener("visibilitychange", X), () => {
|
|
6847
6847
|
document.removeEventListener("visibilitychange", X);
|
|
6848
6848
|
};
|
|
6849
|
-
} catch (
|
|
6850
|
-
console.error("Error initializing TalkingHead:",
|
|
6849
|
+
} catch (C) {
|
|
6850
|
+
console.error("Error initializing TalkingHead:", C), j(C.message || "Failed to initialize avatar"), U(!1), h(C);
|
|
6851
6851
|
}
|
|
6852
6852
|
}, [V, t, e, n, o, s, i, l, a, c, u]);
|
|
6853
6853
|
fe(() => (M(), () => {
|
|
6854
6854
|
p.current && (p.current.stop(), p.current.dispose(), p.current = null);
|
|
6855
6855
|
}), [M]), fe(() => {
|
|
6856
6856
|
if (!T.current || !p.current) return;
|
|
6857
|
-
const
|
|
6858
|
-
for (const
|
|
6857
|
+
const C = new ResizeObserver((Q) => {
|
|
6858
|
+
for (const se of Q)
|
|
6859
6859
|
p.current && p.current.onResize && p.current.onResize();
|
|
6860
6860
|
});
|
|
6861
|
-
|
|
6861
|
+
C.observe(T.current);
|
|
6862
6862
|
const X = () => {
|
|
6863
6863
|
p.current && p.current.onResize && p.current.onResize();
|
|
6864
6864
|
};
|
|
6865
6865
|
return window.addEventListener("resize", X), () => {
|
|
6866
|
-
|
|
6866
|
+
C.disconnect(), window.removeEventListener("resize", X);
|
|
6867
6867
|
};
|
|
6868
6868
|
}, [Y]);
|
|
6869
|
-
const B =
|
|
6869
|
+
const B = N(async () => {
|
|
6870
6870
|
if (p.current && p.current.audioCtx)
|
|
6871
6871
|
try {
|
|
6872
6872
|
(p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
|
|
6873
|
-
} catch (
|
|
6874
|
-
console.warn("Failed to resume audio context:",
|
|
6873
|
+
} catch (C) {
|
|
6874
|
+
console.warn("Failed to resume audio context:", C);
|
|
6875
6875
|
}
|
|
6876
|
-
}, []), Z =
|
|
6876
|
+
}, []), Z = N(async (C, X = {}) => {
|
|
6877
6877
|
if (p.current && Y)
|
|
6878
6878
|
try {
|
|
6879
|
-
y.current && (clearInterval(y.current), y.current = null), E.current = { text:
|
|
6880
|
-
const Q = /[!\.\?\n\p{Extended_Pictographic}]/ug,
|
|
6881
|
-
S.current =
|
|
6879
|
+
y.current && (clearInterval(y.current), y.current = null), E.current = { text: C, options: X }, f.current = { remainingText: null, originalText: null, options: null };
|
|
6880
|
+
const Q = /[!\.\?\n\p{Extended_Pictographic}]/ug, se = C.split(Q).map((J) => J.trim()).filter((J) => J.length > 0);
|
|
6881
|
+
S.current = se, H.current = 0, Ie(!1), F.current = !1, await B();
|
|
6882
6882
|
const xe = {
|
|
6883
6883
|
...X,
|
|
6884
6884
|
lipsyncLang: X.lipsyncLang || v.lipsyncLang || "en"
|
|
6885
6885
|
};
|
|
6886
6886
|
if (X.onSpeechEnd && p.current) {
|
|
6887
|
-
const
|
|
6888
|
-
let pe = null,
|
|
6889
|
-
const
|
|
6887
|
+
const J = p.current;
|
|
6888
|
+
let pe = null, be = 0;
|
|
6889
|
+
const Re = 1200;
|
|
6890
6890
|
let Le = !1;
|
|
6891
6891
|
pe = setInterval(() => {
|
|
6892
|
-
if (
|
|
6892
|
+
if (be++, F.current)
|
|
6893
6893
|
return;
|
|
6894
|
-
if (
|
|
6894
|
+
if (be > Re) {
|
|
6895
6895
|
if (pe && (clearInterval(pe), pe = null, y.current = null), !Le && !F.current) {
|
|
6896
6896
|
Le = !0;
|
|
6897
6897
|
try {
|
|
6898
6898
|
X.onSpeechEnd();
|
|
6899
|
-
} catch (
|
|
6900
|
-
console.error("Error in onSpeechEnd callback (timeout):",
|
|
6899
|
+
} catch (w) {
|
|
6900
|
+
console.error("Error in onSpeechEnd callback (timeout):", w);
|
|
6901
6901
|
}
|
|
6902
6902
|
}
|
|
6903
6903
|
return;
|
|
6904
6904
|
}
|
|
6905
|
-
const Ae = !
|
|
6906
|
-
|
|
6907
|
-
if (
|
|
6905
|
+
const Ae = !J.speechQueue || J.speechQueue.length === 0, Oe = !J.audioPlaylist || J.audioPlaylist.length === 0;
|
|
6906
|
+
J && J.isSpeaking === !1 && Ae && Oe && J.isAudioPlaying === !1 && !Le && !F.current && setTimeout(() => {
|
|
6907
|
+
if (J && !F.current && J.isSpeaking === !1 && (!J.speechQueue || J.speechQueue.length === 0) && (!J.audioPlaylist || J.audioPlaylist.length === 0) && J.isAudioPlaying === !1 && !Le && !F.current) {
|
|
6908
6908
|
Le = !0, pe && (clearInterval(pe), pe = null, y.current = null);
|
|
6909
6909
|
try {
|
|
6910
6910
|
X.onSpeechEnd();
|
|
6911
|
-
} catch (
|
|
6912
|
-
console.error("Error in onSpeechEnd callback:",
|
|
6911
|
+
} catch (D) {
|
|
6912
|
+
console.error("Error in onSpeechEnd callback:", D);
|
|
6913
6913
|
}
|
|
6914
6914
|
}
|
|
6915
6915
|
}, 100);
|
|
6916
6916
|
}, 100), y.current = pe;
|
|
6917
6917
|
}
|
|
6918
|
-
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(
|
|
6919
|
-
await B(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(
|
|
6918
|
+
p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(C, xe)) : setTimeout(async () => {
|
|
6919
|
+
await B(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(C, xe));
|
|
6920
6920
|
}, 100);
|
|
6921
6921
|
} catch (Q) {
|
|
6922
6922
|
console.error("Error speaking text:", Q), j(Q.message || "Failed to speak text");
|
|
6923
6923
|
}
|
|
6924
|
-
}, [Y, B, v.lipsyncLang]),
|
|
6925
|
-
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), E.current = null,
|
|
6926
|
-
}, []), ne =
|
|
6924
|
+
}, [Y, B, v.lipsyncLang]), oe = N(() => {
|
|
6925
|
+
p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), E.current = null, Ie(!1));
|
|
6926
|
+
}, []), ne = N(() => {
|
|
6927
6927
|
if (p.current && p.current.pauseSpeaking) {
|
|
6928
|
-
const
|
|
6929
|
-
if (
|
|
6928
|
+
const C = p.current;
|
|
6929
|
+
if (C.isSpeaking || C.audioPlaylist && C.audioPlaylist.length > 0 || C.speechQueue && C.speechQueue.length > 0) {
|
|
6930
6930
|
y.current && (clearInterval(y.current), y.current = null);
|
|
6931
6931
|
let Q = "";
|
|
6932
6932
|
if (E.current && S.current.length > 0) {
|
|
6933
|
-
const
|
|
6934
|
-
if (pe > 0 &&
|
|
6935
|
-
const Le =
|
|
6933
|
+
const se = S.current.length, xe = C.speechQueue ? C.speechQueue.filter((Re) => Re && Re.text && Array.isArray(Re.text) && Re.text.length > 0).length : 0, J = C.audioPlaylist && C.audioPlaylist.length > 0, pe = xe + (J ? 1 : 0), be = se - pe;
|
|
6934
|
+
if (pe > 0 && be < se && (Q = S.current.slice(be).join(". ").trim(), !Q && xe > 0 && C.speechQueue)) {
|
|
6935
|
+
const Le = C.speechQueue.filter((Ae) => Ae && Ae.text && Array.isArray(Ae.text) && Ae.text.length > 0).map((Ae) => Ae.text.map((Oe) => Oe.word || "").filter((Oe) => Oe.length > 0).join(" ")).filter((Ae) => Ae.length > 0).join(" ");
|
|
6936
6936
|
Le && Le.trim() && (Q = Le.trim());
|
|
6937
6937
|
}
|
|
6938
6938
|
}
|
|
6939
|
-
E.current && (
|
|
6939
|
+
E.current && (f.current = {
|
|
6940
6940
|
remainingText: Q || null,
|
|
6941
6941
|
originalText: E.current.text,
|
|
6942
6942
|
options: E.current.options
|
|
6943
|
-
}),
|
|
6943
|
+
}), C.speechQueue && (C.speechQueue.length = 0), p.current.pauseSpeaking(), F.current = !0, Ie(!0);
|
|
6944
6944
|
}
|
|
6945
6945
|
}
|
|
6946
|
-
}, []),
|
|
6946
|
+
}, []), K = N(async () => {
|
|
6947
6947
|
if (!p.current || !le)
|
|
6948
6948
|
return;
|
|
6949
|
-
let
|
|
6950
|
-
if (
|
|
6951
|
-
|
|
6949
|
+
let C = "", X = {};
|
|
6950
|
+
if (f.current && f.current.remainingText)
|
|
6951
|
+
C = f.current.remainingText, X = f.current.options || {}, f.current = { remainingText: null, originalText: null, options: null };
|
|
6952
6952
|
else if (E.current && E.current.text)
|
|
6953
|
-
|
|
6953
|
+
C = E.current.text, X = E.current.options || {};
|
|
6954
6954
|
else {
|
|
6955
|
-
console.warn("Resume called but no paused speech found"),
|
|
6955
|
+
console.warn("Resume called but no paused speech found"), Ie(!1), F.current = !1;
|
|
6956
6956
|
return;
|
|
6957
6957
|
}
|
|
6958
|
-
|
|
6958
|
+
Ie(!1), F.current = !1, await B();
|
|
6959
6959
|
const Q = {
|
|
6960
6960
|
...X,
|
|
6961
6961
|
lipsyncLang: X.lipsyncLang || v.lipsyncLang || "en"
|
|
6962
6962
|
};
|
|
6963
6963
|
try {
|
|
6964
|
-
await Z(
|
|
6965
|
-
} catch (
|
|
6966
|
-
console.error("Error resuming speech:",
|
|
6964
|
+
await Z(C, Q);
|
|
6965
|
+
} catch (se) {
|
|
6966
|
+
console.error("Error resuming speech:", se), Ie(!1), F.current = !1;
|
|
6967
6967
|
}
|
|
6968
|
-
}, [B, le, Z, v]), me =
|
|
6969
|
-
p.current && p.current.setMood(
|
|
6970
|
-
}, []), Me =
|
|
6971
|
-
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(
|
|
6972
|
-
}, []), He =
|
|
6968
|
+
}, [B, le, Z, v]), me = N((C) => {
|
|
6969
|
+
p.current && p.current.setMood(C);
|
|
6970
|
+
}, []), Me = N((C) => {
|
|
6971
|
+
p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(C);
|
|
6972
|
+
}, []), He = N((C, X = !1) => {
|
|
6973
6973
|
if (p.current && p.current.playAnimation) {
|
|
6974
|
-
if (b && b[
|
|
6974
|
+
if (b && b[C] && (C = b[C]), p.current.setShowFullAvatar)
|
|
6975
6975
|
try {
|
|
6976
6976
|
p.current.setShowFullAvatar(P.current);
|
|
6977
|
-
} catch (
|
|
6978
|
-
console.warn("Error setting full body mode:",
|
|
6977
|
+
} catch (se) {
|
|
6978
|
+
console.warn("Error setting full body mode:", se);
|
|
6979
6979
|
}
|
|
6980
|
-
if (
|
|
6980
|
+
if (C.includes("."))
|
|
6981
6981
|
try {
|
|
6982
|
-
p.current.playAnimation(
|
|
6983
|
-
} catch (
|
|
6984
|
-
console.warn(`Failed to play ${
|
|
6982
|
+
p.current.playAnimation(C, null, 10, 0, 0.01, X);
|
|
6983
|
+
} catch (se) {
|
|
6984
|
+
console.warn(`Failed to play ${C}:`, se);
|
|
6985
6985
|
try {
|
|
6986
6986
|
p.current.setBodyMovement("idle");
|
|
6987
6987
|
} catch (xe) {
|
|
@@ -6989,32 +6989,32 @@ const et = Ze(({
|
|
|
6989
6989
|
}
|
|
6990
6990
|
}
|
|
6991
6991
|
else {
|
|
6992
|
-
const
|
|
6992
|
+
const se = [".fbx", ".glb", ".gltf"];
|
|
6993
6993
|
let xe = !1;
|
|
6994
|
-
for (const
|
|
6994
|
+
for (const J of se)
|
|
6995
6995
|
try {
|
|
6996
|
-
p.current.playAnimation(
|
|
6996
|
+
p.current.playAnimation(C + J, null, 10, 0, 0.01, X), xe = !0;
|
|
6997
6997
|
break;
|
|
6998
6998
|
} catch {
|
|
6999
6999
|
}
|
|
7000
7000
|
if (!xe) {
|
|
7001
|
-
console.warn("Animation not found:",
|
|
7001
|
+
console.warn("Animation not found:", C);
|
|
7002
7002
|
try {
|
|
7003
7003
|
p.current.setBodyMovement("idle");
|
|
7004
|
-
} catch (
|
|
7005
|
-
console.warn("Fallback animation also failed:",
|
|
7004
|
+
} catch (J) {
|
|
7005
|
+
console.warn("Fallback animation also failed:", J);
|
|
7006
7006
|
}
|
|
7007
7007
|
}
|
|
7008
7008
|
}
|
|
7009
7009
|
}
|
|
7010
|
-
}, [b]), Ye =
|
|
7010
|
+
}, [b]), Ye = N(() => {
|
|
7011
7011
|
p.current && p.current.onResize && p.current.onResize();
|
|
7012
7012
|
}, []);
|
|
7013
7013
|
return Xe(L, () => ({
|
|
7014
7014
|
speakText: Z,
|
|
7015
|
-
stopSpeaking:
|
|
7015
|
+
stopSpeaking: oe,
|
|
7016
7016
|
pauseSpeaking: ne,
|
|
7017
|
-
resumeSpeaking:
|
|
7017
|
+
resumeSpeaking: K,
|
|
7018
7018
|
resumeAudioContext: B,
|
|
7019
7019
|
setMood: me,
|
|
7020
7020
|
setTimingAdjustment: Me,
|
|
@@ -7023,27 +7023,27 @@ const et = Ze(({
|
|
|
7023
7023
|
isPaused: le,
|
|
7024
7024
|
talkingHead: p.current,
|
|
7025
7025
|
handleResize: Ye,
|
|
7026
|
-
setBodyMovement: (
|
|
7026
|
+
setBodyMovement: (C) => {
|
|
7027
7027
|
if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
|
|
7028
7028
|
try {
|
|
7029
|
-
p.current.setShowFullAvatar(P.current), p.current.setBodyMovement(
|
|
7029
|
+
p.current.setShowFullAvatar(P.current), p.current.setBodyMovement(C);
|
|
7030
7030
|
} catch (X) {
|
|
7031
7031
|
console.warn("Error setting body movement:", X);
|
|
7032
7032
|
}
|
|
7033
7033
|
},
|
|
7034
|
-
setMovementIntensity: (
|
|
7034
|
+
setMovementIntensity: (C) => p.current?.setMovementIntensity(C),
|
|
7035
7035
|
playRandomDance: () => {
|
|
7036
7036
|
if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
|
|
7037
7037
|
try {
|
|
7038
7038
|
p.current.setShowFullAvatar(P.current), p.current.playRandomDance();
|
|
7039
|
-
} catch (
|
|
7040
|
-
console.warn("Error playing random dance:",
|
|
7039
|
+
} catch (C) {
|
|
7040
|
+
console.warn("Error playing random dance:", C);
|
|
7041
7041
|
}
|
|
7042
7042
|
},
|
|
7043
|
-
playReaction: (
|
|
7043
|
+
playReaction: (C) => {
|
|
7044
7044
|
if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
|
|
7045
7045
|
try {
|
|
7046
|
-
p.current.setShowFullAvatar(P.current), p.current.playReaction(
|
|
7046
|
+
p.current.setShowFullAvatar(P.current), p.current.playReaction(C);
|
|
7047
7047
|
} catch (X) {
|
|
7048
7048
|
console.warn("Error playing reaction:", X);
|
|
7049
7049
|
}
|
|
@@ -7052,14 +7052,14 @@ const et = Ze(({
|
|
|
7052
7052
|
if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
|
|
7053
7053
|
try {
|
|
7054
7054
|
p.current.setShowFullAvatar(P.current), p.current.playCelebration();
|
|
7055
|
-
} catch (
|
|
7056
|
-
console.warn("Error playing celebration:",
|
|
7055
|
+
} catch (C) {
|
|
7056
|
+
console.warn("Error playing celebration:", C);
|
|
7057
7057
|
}
|
|
7058
7058
|
},
|
|
7059
|
-
setShowFullAvatar: (
|
|
7059
|
+
setShowFullAvatar: (C) => {
|
|
7060
7060
|
if (p.current && p.current.setShowFullAvatar)
|
|
7061
7061
|
try {
|
|
7062
|
-
P.current =
|
|
7062
|
+
P.current = C, p.current.setShowFullAvatar(C);
|
|
7063
7063
|
} catch (X) {
|
|
7064
7064
|
console.warn("Error setting showFullAvatar:", X);
|
|
7065
7065
|
}
|
|
@@ -7068,16 +7068,16 @@ const et = Ze(({
|
|
|
7068
7068
|
if (p.current && p.current.lockAvatarPosition)
|
|
7069
7069
|
try {
|
|
7070
7070
|
p.current.lockAvatarPosition();
|
|
7071
|
-
} catch (
|
|
7072
|
-
console.warn("Error locking avatar position:",
|
|
7071
|
+
} catch (C) {
|
|
7072
|
+
console.warn("Error locking avatar position:", C);
|
|
7073
7073
|
}
|
|
7074
7074
|
},
|
|
7075
7075
|
unlockAvatarPosition: () => {
|
|
7076
7076
|
if (p.current && p.current.unlockAvatarPosition)
|
|
7077
7077
|
try {
|
|
7078
7078
|
p.current.unlockAvatarPosition();
|
|
7079
|
-
} catch (
|
|
7080
|
-
console.warn("Error unlocking avatar position:",
|
|
7079
|
+
} catch (C) {
|
|
7080
|
+
console.warn("Error unlocking avatar position:", C);
|
|
7081
7081
|
}
|
|
7082
7082
|
}
|
|
7083
7083
|
})), /* @__PURE__ */ ke(
|
|
@@ -7129,7 +7129,7 @@ const et = Ze(({
|
|
|
7129
7129
|
);
|
|
7130
7130
|
});
|
|
7131
7131
|
et.displayName = "TalkingHeadAvatar";
|
|
7132
|
-
const
|
|
7132
|
+
const wt = Ze(({
|
|
7133
7133
|
text: V = "Hello! I'm a talking avatar. How are you today?",
|
|
7134
7134
|
onLoading: t = () => {
|
|
7135
7135
|
},
|
|
@@ -7171,7 +7171,7 @@ const kt = Ze(({
|
|
|
7171
7171
|
ttsService: L,
|
|
7172
7172
|
lipsyncModules: ["en"],
|
|
7173
7173
|
cameraView: "upper"
|
|
7174
|
-
}, E =
|
|
7174
|
+
}, E = N(async () => {
|
|
7175
7175
|
if (!(!c.current || l.current))
|
|
7176
7176
|
try {
|
|
7177
7177
|
if (r(!0), h(null), l.current = new Qe(c.current, P), await l.current.showAvatar(p, (G) => {
|
|
@@ -7210,7 +7210,7 @@ const kt = Ze(({
|
|
|
7210
7210
|
fe(() => (E(), () => {
|
|
7211
7211
|
l.current && (l.current.stop(), l.current.dispose(), l.current = null);
|
|
7212
7212
|
}), [E]);
|
|
7213
|
-
const y =
|
|
7213
|
+
const y = N((I) => {
|
|
7214
7214
|
if (l.current && g)
|
|
7215
7215
|
try {
|
|
7216
7216
|
console.log("Speaking text:", I), console.log("Avatar config:", p), console.log("TalkingHead instance:", l.current), l.current.lipsync && Object.keys(l.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(l.current.lipsync)), l.current.setSlowdownRate && (l.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), l.current.speakText(I)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
|
|
@@ -7221,13 +7221,13 @@ const kt = Ze(({
|
|
|
7221
7221
|
}
|
|
7222
7222
|
else
|
|
7223
7223
|
console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!l.current);
|
|
7224
|
-
}, [g, p]), F =
|
|
7224
|
+
}, [g, p]), F = N(() => {
|
|
7225
7225
|
l.current && (l.current.stopSpeaking(), l.current.setSlowdownRate && (l.current.setSlowdownRate(1), console.log("Reset timing to normal")));
|
|
7226
|
-
}, []),
|
|
7226
|
+
}, []), f = N((I) => {
|
|
7227
7227
|
l.current && l.current.setMood(I);
|
|
7228
|
-
}, []), S =
|
|
7228
|
+
}, []), S = N((I) => {
|
|
7229
7229
|
l.current && l.current.setSlowdownRate && (l.current.setSlowdownRate(I), console.log("Timing adjustment set to:", I));
|
|
7230
|
-
}, []), H =
|
|
7230
|
+
}, []), H = N((I, U = !1) => {
|
|
7231
7231
|
if (l.current && l.current.playAnimation) {
|
|
7232
7232
|
if (l.current.setShowFullAvatar)
|
|
7233
7233
|
try {
|
|
@@ -7271,7 +7271,7 @@ const kt = Ze(({
|
|
|
7271
7271
|
return Xe(a, () => ({
|
|
7272
7272
|
speakText: y,
|
|
7273
7273
|
stopSpeaking: F,
|
|
7274
|
-
setMood:
|
|
7274
|
+
setMood: f,
|
|
7275
7275
|
setTimingAdjustment: S,
|
|
7276
7276
|
playAnimation: H,
|
|
7277
7277
|
isReady: g,
|
|
@@ -7369,7 +7369,7 @@ const kt = Ze(({
|
|
|
7369
7369
|
}, children: d })
|
|
7370
7370
|
] });
|
|
7371
7371
|
});
|
|
7372
|
-
|
|
7372
|
+
wt.displayName = "TalkingHeadComponent";
|
|
7373
7373
|
async function De(V) {
|
|
7374
7374
|
try {
|
|
7375
7375
|
const t = await fetch(V);
|
|
@@ -7380,7 +7380,7 @@ async function De(V) {
|
|
|
7380
7380
|
return console.error("Failed to load animation manifest:", t), {};
|
|
7381
7381
|
}
|
|
7382
7382
|
}
|
|
7383
|
-
async function
|
|
7383
|
+
async function Ct(V, t = "F") {
|
|
7384
7384
|
const e = [], n = V.replace(/\/$/, "");
|
|
7385
7385
|
try {
|
|
7386
7386
|
const s = [
|
|
@@ -7423,14 +7423,14 @@ async function $e(V, t = "F") {
|
|
|
7423
7423
|
const e = {};
|
|
7424
7424
|
for (const [n, o] of Object.entries(V))
|
|
7425
7425
|
try {
|
|
7426
|
-
const s = await
|
|
7426
|
+
const s = await Ct(o, t);
|
|
7427
7427
|
s.length > 0 && (e[n] = s);
|
|
7428
7428
|
} catch (s) {
|
|
7429
7429
|
console.error(`❌ Failed to auto-load animations from ${o}:`, s);
|
|
7430
7430
|
}
|
|
7431
7431
|
return e;
|
|
7432
7432
|
}
|
|
7433
|
-
const
|
|
7433
|
+
const zt = Ze(({
|
|
7434
7434
|
text: V = null,
|
|
7435
7435
|
avatarUrl: t = "/avatars/brunette.glb",
|
|
7436
7436
|
avatarBody: e = "F",
|
|
@@ -7460,72 +7460,72 @@ const Ct = Ze(({
|
|
|
7460
7460
|
// e.g., "idle" - will randomly select from this group when idle
|
|
7461
7461
|
autoSpeak: E = !1
|
|
7462
7462
|
}, y) => {
|
|
7463
|
-
const F = W(null),
|
|
7463
|
+
const F = W(null), f = W(null), S = W(u), H = W(null), I = W(null), U = W(!1), G = W({ remainingText: null, originalText: null, options: null }), j = W([]), [Y, ue] = ae(!0), [le, Ie] = ae(null), [re, ze] = ae(!1), [ee, v] = ae(!1), [A, M] = ae(T), B = W(null), Z = W(!1), oe = W(null), ne = W([]), K = W([]);
|
|
7464
7464
|
fe(() => {
|
|
7465
7465
|
U.current = ee;
|
|
7466
7466
|
}, [ee]), fe(() => {
|
|
7467
7467
|
(async () => {
|
|
7468
7468
|
if (T.manifest && T.auto)
|
|
7469
7469
|
try {
|
|
7470
|
-
const
|
|
7471
|
-
M(
|
|
7470
|
+
const w = await De(T.manifest);
|
|
7471
|
+
M(w);
|
|
7472
7472
|
return;
|
|
7473
7473
|
} catch {
|
|
7474
7474
|
}
|
|
7475
7475
|
if (T.manifest && !T.auto)
|
|
7476
7476
|
try {
|
|
7477
|
-
const
|
|
7478
|
-
M(
|
|
7479
|
-
} catch (
|
|
7480
|
-
console.error("Failed to load animation manifest:",
|
|
7477
|
+
const w = await De(T.manifest);
|
|
7478
|
+
M(w);
|
|
7479
|
+
} catch (w) {
|
|
7480
|
+
console.error("Failed to load animation manifest:", w), M(T);
|
|
7481
7481
|
}
|
|
7482
7482
|
else if (T.auto)
|
|
7483
7483
|
try {
|
|
7484
|
-
let
|
|
7484
|
+
let w = null;
|
|
7485
7485
|
if (T.manifest)
|
|
7486
7486
|
try {
|
|
7487
|
-
|
|
7487
|
+
w = await De(T.manifest);
|
|
7488
7488
|
} catch {
|
|
7489
7489
|
}
|
|
7490
7490
|
if (typeof T.auto == "string") {
|
|
7491
|
-
const
|
|
7492
|
-
talking: `${
|
|
7493
|
-
idle: `${
|
|
7494
|
-
},
|
|
7495
|
-
te[`${
|
|
7491
|
+
const D = T.auto, te = {
|
|
7492
|
+
talking: `${D}/talking`,
|
|
7493
|
+
idle: `${D}/idle`
|
|
7494
|
+
}, q = e === "M" ? "male" : "female";
|
|
7495
|
+
te[`${q}_talking`] = `${D}/${q}/talking`, te[`${q}_idle`] = `${D}/${q}/idle`, te.shared_talking = `${D}/shared/talking`, te.shared_idle = `${D}/shared/idle`;
|
|
7496
7496
|
const Se = await $e(te, e);
|
|
7497
|
-
if (!Object.values(Se).some((ce) => Array.isArray(ce) && ce.length > 0) &&
|
|
7498
|
-
M(
|
|
7497
|
+
if (!Object.values(Se).some((ce) => Array.isArray(ce) && ce.length > 0) && w) {
|
|
7498
|
+
M(w);
|
|
7499
7499
|
return;
|
|
7500
7500
|
}
|
|
7501
7501
|
const ge = {
|
|
7502
7502
|
_genderSpecific: {
|
|
7503
|
-
[
|
|
7503
|
+
[q]: {},
|
|
7504
7504
|
shared: {}
|
|
7505
7505
|
}
|
|
7506
7506
|
};
|
|
7507
7507
|
Object.entries(Se).forEach(([ce, Fe]) => {
|
|
7508
7508
|
if (ce.includes("_")) {
|
|
7509
|
-
const [Ne, ...
|
|
7510
|
-
Ne === "shared" ? (ge._genderSpecific.shared[Be] || (ge._genderSpecific.shared[Be] = []), ge._genderSpecific.shared[Be].push(...Fe)) : Ne ===
|
|
7509
|
+
const [Ne, ...it] = ce.split("_"), Be = it.join("_");
|
|
7510
|
+
Ne === "shared" ? (ge._genderSpecific.shared[Be] || (ge._genderSpecific.shared[Be] = []), ge._genderSpecific.shared[Be].push(...Fe)) : Ne === q && (ge._genderSpecific[q][Be] || (ge._genderSpecific[q][Be] = []), ge._genderSpecific[q][Be].push(...Fe));
|
|
7511
7511
|
} else
|
|
7512
7512
|
ge[ce] = Fe;
|
|
7513
|
-
}),
|
|
7514
|
-
ge._genderSpecific[ce] || (ge._genderSpecific[ce] = {}), Object.entries(
|
|
7513
|
+
}), w && (w._genderSpecific && Object.keys(w._genderSpecific).forEach((ce) => {
|
|
7514
|
+
ge._genderSpecific[ce] || (ge._genderSpecific[ce] = {}), Object.entries(w._genderSpecific[ce]).forEach(([Fe, Ne]) => {
|
|
7515
7515
|
ge._genderSpecific[ce][Fe] || (ge._genderSpecific[ce][Fe] = Ne);
|
|
7516
7516
|
});
|
|
7517
|
-
}), Object.entries(
|
|
7517
|
+
}), Object.entries(w).forEach(([ce, Fe]) => {
|
|
7518
7518
|
ce !== "_genderSpecific" && !ge[ce] && (ge[ce] = Fe);
|
|
7519
7519
|
})), M(ge);
|
|
7520
7520
|
} else if (typeof T.auto == "object") {
|
|
7521
|
-
const
|
|
7522
|
-
M(!te &&
|
|
7521
|
+
const D = await $e(T.auto, e), te = Object.values(D).some((q) => Array.isArray(q) && q.length > 0);
|
|
7522
|
+
M(!te && w ? w : D);
|
|
7523
7523
|
}
|
|
7524
|
-
} catch (
|
|
7525
|
-
if (console.error("Failed to auto-discover animations:",
|
|
7524
|
+
} catch (w) {
|
|
7525
|
+
if (console.error("Failed to auto-discover animations:", w), T.manifest)
|
|
7526
7526
|
try {
|
|
7527
|
-
const
|
|
7528
|
-
M(
|
|
7527
|
+
const D = await De(T.manifest);
|
|
7528
|
+
M(D);
|
|
7529
7529
|
} catch {
|
|
7530
7530
|
M(T);
|
|
7531
7531
|
}
|
|
@@ -7571,171 +7571,175 @@ const Ct = Ze(({
|
|
|
7571
7571
|
showFullAvatar: u,
|
|
7572
7572
|
bodyMovement: c,
|
|
7573
7573
|
movementIntensity: l
|
|
7574
|
-
},
|
|
7574
|
+
}, C = {
|
|
7575
7575
|
ttsEndpoint: He.endpoint,
|
|
7576
7576
|
ttsApikey: He.apiKey,
|
|
7577
7577
|
ttsService: Me,
|
|
7578
7578
|
lipsyncModules: ["en"],
|
|
7579
7579
|
cameraView: r
|
|
7580
|
-
}, X =
|
|
7581
|
-
if (!(!F.current ||
|
|
7580
|
+
}, X = N(async () => {
|
|
7581
|
+
if (!(!F.current || f.current))
|
|
7582
7582
|
try {
|
|
7583
|
-
ue(!0),
|
|
7584
|
-
if (
|
|
7585
|
-
const
|
|
7586
|
-
h(
|
|
7583
|
+
ue(!0), Ie(null), f.current = new Qe(F.current, C), await f.current.showAvatar(Ye, (w) => {
|
|
7584
|
+
if (w.lengthComputable) {
|
|
7585
|
+
const D = Math.min(100, Math.round(w.loaded / w.total * 100));
|
|
7586
|
+
h(D);
|
|
7587
7587
|
}
|
|
7588
|
-
}), ue(!1), ze(!0), d(
|
|
7588
|
+
}), ue(!1), ze(!0), d(f.current);
|
|
7589
7589
|
const k = () => {
|
|
7590
|
-
document.visibilityState === "visible" ?
|
|
7590
|
+
document.visibilityState === "visible" ? f.current?.start() : f.current?.stop();
|
|
7591
7591
|
};
|
|
7592
7592
|
return document.addEventListener("visibilitychange", k), () => {
|
|
7593
7593
|
document.removeEventListener("visibilitychange", k);
|
|
7594
7594
|
};
|
|
7595
7595
|
} catch (k) {
|
|
7596
|
-
console.error("Error initializing TalkingHead:", k),
|
|
7596
|
+
console.error("Error initializing TalkingHead:", k), Ie(k.message || "Failed to initialize avatar"), ue(!1), g(k);
|
|
7597
7597
|
}
|
|
7598
7598
|
}, []);
|
|
7599
7599
|
fe(() => (X(), () => {
|
|
7600
|
-
|
|
7600
|
+
f.current && (f.current.stop(), f.current.dispose(), f.current = null);
|
|
7601
7601
|
}), [X]);
|
|
7602
|
-
const Q =
|
|
7603
|
-
if (
|
|
7602
|
+
const Q = N(async () => {
|
|
7603
|
+
if (f.current)
|
|
7604
7604
|
try {
|
|
7605
|
-
const k =
|
|
7605
|
+
const k = f.current.audioCtx || f.current.audioContext;
|
|
7606
7606
|
k && (k.state === "suspended" || k.state === "interrupted") && await k.resume();
|
|
7607
7607
|
} catch (k) {
|
|
7608
7608
|
console.warn("Failed to resume audio context:", k);
|
|
7609
7609
|
}
|
|
7610
|
-
}, []),
|
|
7610
|
+
}, []), se = N((k) => {
|
|
7611
7611
|
if (!A)
|
|
7612
7612
|
return [];
|
|
7613
|
-
let
|
|
7613
|
+
let w = null;
|
|
7614
7614
|
if (A._genderSpecific) {
|
|
7615
|
-
const te = (e?.toUpperCase() || "F") === "M" ? "male" : "female",
|
|
7616
|
-
|
|
7615
|
+
const te = (e?.toUpperCase() || "F") === "M" ? "male" : "female", q = A._genderSpecific[te];
|
|
7616
|
+
q && q[k] ? w = q[k] : A._genderSpecific.shared && A._genderSpecific.shared[k] && (w = A._genderSpecific.shared[k]);
|
|
7617
7617
|
}
|
|
7618
|
-
return !
|
|
7619
|
-
}, [A, e]), xe =
|
|
7620
|
-
const
|
|
7621
|
-
for (let
|
|
7622
|
-
const te = Math.floor(Math.random() * (
|
|
7623
|
-
[
|
|
7618
|
+
return !w && A[k] && (w = A[k]), w ? Array.isArray(w) ? [...w] : typeof w == "string" ? [w] : [] : [];
|
|
7619
|
+
}, [A, e]), xe = N((k) => {
|
|
7620
|
+
const w = [...k];
|
|
7621
|
+
for (let D = w.length - 1; D > 0; D--) {
|
|
7622
|
+
const te = Math.floor(Math.random() * (D + 1));
|
|
7623
|
+
[w[D], w[te]] = [w[te], w[D]];
|
|
7624
7624
|
}
|
|
7625
|
-
return
|
|
7626
|
-
}, []),
|
|
7627
|
-
if (
|
|
7628
|
-
const
|
|
7629
|
-
if (
|
|
7625
|
+
return w;
|
|
7626
|
+
}, []), J = N((k) => {
|
|
7627
|
+
if (K.current.length === 0) {
|
|
7628
|
+
const D = se(k);
|
|
7629
|
+
if (D.length === 0)
|
|
7630
7630
|
return null;
|
|
7631
|
-
|
|
7631
|
+
K.current = xe(D), ne.current = [];
|
|
7632
7632
|
}
|
|
7633
|
-
const
|
|
7634
|
-
return
|
|
7635
|
-
}, [
|
|
7636
|
-
if (!
|
|
7633
|
+
const w = K.current.shift();
|
|
7634
|
+
return w && ne.current.push(w), w;
|
|
7635
|
+
}, [se, xe]), pe = N((k) => k ? k.split("/").pop().replace(".fbx", "").replace(/[-_]/g, " ") : "Unknown", []), be = N((k, w = !1, D = null) => {
|
|
7636
|
+
if (!f.current)
|
|
7637
7637
|
return null;
|
|
7638
|
-
const te =
|
|
7638
|
+
const te = J(k);
|
|
7639
7639
|
if (te)
|
|
7640
7640
|
try {
|
|
7641
|
-
const
|
|
7642
|
-
console.log(`🎬 Playing animation: "${
|
|
7641
|
+
const q = pe(te);
|
|
7642
|
+
console.log(`🎬 Playing animation: "${q}"`);
|
|
7643
7643
|
const Se = () => {
|
|
7644
|
-
Z.current &&
|
|
7645
|
-
|
|
7646
|
-
}, 100) :
|
|
7644
|
+
Z.current && oe.current === k && f.current && (f.current.isSpeaking || f.current.audioPlaylist && f.current.audioPlaylist.length > 0 || f.current.speechQueue && f.current.speechQueue.length > 0) ? setTimeout(() => {
|
|
7645
|
+
be(k, w, D);
|
|
7646
|
+
}, 100) : (Z.current = !1, oe.current = null, D && D());
|
|
7647
7647
|
};
|
|
7648
|
-
return
|
|
7649
|
-
} catch (
|
|
7650
|
-
return console.error("Failed to play animation:",
|
|
7648
|
+
return f.current.playAnimation(te, null, 0, 0, 0.01, w, Se), te;
|
|
7649
|
+
} catch (q) {
|
|
7650
|
+
return console.error("Failed to play animation:", q), null;
|
|
7651
7651
|
}
|
|
7652
|
+
else
|
|
7653
|
+
Z.current && oe.current === k && f.current && (f.current.isSpeaking || f.current.audioPlaylist && f.current.audioPlaylist.length > 0 || f.current.speechQueue && f.current.speechQueue.length > 0) && (K.current = [], ne.current = [], setTimeout(() => {
|
|
7654
|
+
be(k, w, D);
|
|
7655
|
+
}, 100));
|
|
7652
7656
|
return null;
|
|
7653
|
-
}, [
|
|
7654
|
-
if (!
|
|
7657
|
+
}, [J, pe]), Re = N(async (k, w = {}) => {
|
|
7658
|
+
if (!f.current || !re || !k || k.trim() === "")
|
|
7655
7659
|
return;
|
|
7656
7660
|
await Q();
|
|
7657
|
-
const
|
|
7658
|
-
|
|
7661
|
+
const D = w.animationGroup || p;
|
|
7662
|
+
D && !w.skipAnimation && (Z.current = !0, oe.current = D, K.current = [], ne.current = [], be(D)), G.current = { remainingText: null, originalText: null, options: null }, j.current = [], H.current = { text: k, options: w }, I.current && (clearInterval(I.current), I.current = null), v(!1), U.current = !1;
|
|
7659
7663
|
const te = k.split(/[.!?]+/).filter((Se) => Se.trim().length > 0);
|
|
7660
7664
|
j.current = te;
|
|
7661
|
-
const
|
|
7662
|
-
lipsyncLang:
|
|
7665
|
+
const q = {
|
|
7666
|
+
lipsyncLang: w.lipsyncLang || "en",
|
|
7663
7667
|
onSpeechEnd: () => {
|
|
7664
|
-
I.current && (clearInterval(I.current), I.current = null), Z.current = !1,
|
|
7668
|
+
I.current && (clearInterval(I.current), I.current = null), Z.current = !1, oe.current = null, K.current = [], ne.current = [], w.onSpeechEnd && w.onSpeechEnd(), R();
|
|
7665
7669
|
}
|
|
7666
7670
|
};
|
|
7667
7671
|
try {
|
|
7668
|
-
|
|
7672
|
+
f.current.speakText(k, q);
|
|
7669
7673
|
} catch (Se) {
|
|
7670
|
-
console.error("Error speaking text:", Se),
|
|
7674
|
+
console.error("Error speaking text:", Se), Ie(Se.message || "Failed to speak text");
|
|
7671
7675
|
}
|
|
7672
|
-
}, [
|
|
7676
|
+
}, [re, R, Q, p, be]);
|
|
7673
7677
|
fe(() => {
|
|
7674
|
-
if (!
|
|
7678
|
+
if (!re || !P || !f.current)
|
|
7675
7679
|
return;
|
|
7676
7680
|
B.current && clearInterval(B.current);
|
|
7677
7681
|
const k = () => {
|
|
7678
|
-
|
|
7682
|
+
f.current && !U.current && be(P);
|
|
7679
7683
|
};
|
|
7680
7684
|
return k(), B.current = setInterval(() => {
|
|
7681
7685
|
k();
|
|
7682
7686
|
}, 12e3 + Math.random() * 3e3), () => {
|
|
7683
7687
|
B.current && (clearInterval(B.current), B.current = null);
|
|
7684
7688
|
};
|
|
7685
|
-
}, [
|
|
7686
|
-
|
|
7687
|
-
}, [
|
|
7688
|
-
const Le =
|
|
7689
|
-
if (
|
|
7689
|
+
}, [re, P, be]), fe(() => {
|
|
7690
|
+
re && V && E && f.current && Re(V);
|
|
7691
|
+
}, [re, V, E, Re]);
|
|
7692
|
+
const Le = N(() => {
|
|
7693
|
+
if (f.current)
|
|
7690
7694
|
try {
|
|
7691
|
-
const k =
|
|
7692
|
-
if (k ||
|
|
7695
|
+
const k = f.current.isSpeaking || !1, w = f.current.audioPlaylist || [], D = f.current.speechQueue || [];
|
|
7696
|
+
if (k || w.length > 0 || D.length > 0) {
|
|
7693
7697
|
I.current && (clearInterval(I.current), I.current = null);
|
|
7694
7698
|
let te = "";
|
|
7695
|
-
|
|
7699
|
+
D.length > 0 && (te = D.map((q) => q.text && Array.isArray(q.text) ? q.text.map((Se) => Se.word).join(" ") : q.text || "").join(" ")), G.current = {
|
|
7696
7700
|
remainingText: te || null,
|
|
7697
7701
|
originalText: H.current?.text || null,
|
|
7698
7702
|
options: H.current?.options || null
|
|
7699
|
-
},
|
|
7703
|
+
}, f.current.speechQueue.length = 0, f.current.pauseSpeaking(), v(!0), U.current = !0;
|
|
7700
7704
|
}
|
|
7701
7705
|
} catch (k) {
|
|
7702
7706
|
console.warn("Error pausing speech:", k);
|
|
7703
7707
|
}
|
|
7704
|
-
}, []), Ae =
|
|
7705
|
-
if (!(!
|
|
7708
|
+
}, []), Ae = N(async () => {
|
|
7709
|
+
if (!(!f.current || !ee))
|
|
7706
7710
|
try {
|
|
7707
7711
|
await Q(), v(!1), U.current = !1;
|
|
7708
|
-
const k = G.current?.remainingText,
|
|
7709
|
-
te &&
|
|
7712
|
+
const k = G.current?.remainingText, w = G.current?.originalText || H.current?.text, D = G.current?.options || H.current?.options || {}, te = k || w;
|
|
7713
|
+
te && Re(te, D);
|
|
7710
7714
|
} catch (k) {
|
|
7711
7715
|
console.warn("Error resuming speech:", k), v(!1), U.current = !1;
|
|
7712
7716
|
}
|
|
7713
|
-
}, [ee,
|
|
7714
|
-
|
|
7717
|
+
}, [ee, Re, Q]), Oe = N(() => {
|
|
7718
|
+
f.current && (f.current.stopSpeaking(), I.current && (clearInterval(I.current), I.current = null), Z.current = !1, oe.current = null, K.current = [], ne.current = [], v(!1), U.current = !1);
|
|
7715
7719
|
}, []);
|
|
7716
7720
|
return Xe(y, () => ({
|
|
7717
|
-
speakText:
|
|
7721
|
+
speakText: Re,
|
|
7718
7722
|
pauseSpeaking: Le,
|
|
7719
7723
|
resumeSpeaking: Ae,
|
|
7720
7724
|
stopSpeaking: Oe,
|
|
7721
7725
|
resumeAudioContext: Q,
|
|
7722
7726
|
isPaused: () => ee,
|
|
7723
|
-
setMood: (k) =>
|
|
7727
|
+
setMood: (k) => f.current?.setMood(k),
|
|
7724
7728
|
setBodyMovement: (k) => {
|
|
7725
|
-
|
|
7729
|
+
f.current && f.current.setBodyMovement(k);
|
|
7726
7730
|
},
|
|
7727
|
-
playAnimation: (k,
|
|
7728
|
-
|
|
7731
|
+
playAnimation: (k, w = !1) => {
|
|
7732
|
+
f.current && f.current.playAnimation && f.current.playAnimation(k, null, 10, 0, 0.01, w);
|
|
7729
7733
|
},
|
|
7730
|
-
playRandomAnimation: (k,
|
|
7734
|
+
playRandomAnimation: (k, w = !1) => be(k, w),
|
|
7731
7735
|
getRandomAnimation: (k) => getRandomAnimation(k),
|
|
7732
|
-
playReaction: (k) =>
|
|
7733
|
-
playCelebration: () =>
|
|
7736
|
+
playReaction: (k) => f.current?.playReaction(k),
|
|
7737
|
+
playCelebration: () => f.current?.playCelebration(),
|
|
7734
7738
|
setShowFullAvatar: (k) => {
|
|
7735
|
-
|
|
7739
|
+
f.current && (S.current = k, f.current.setShowFullAvatar(k));
|
|
7736
7740
|
},
|
|
7737
|
-
isReady:
|
|
7738
|
-
talkingHead:
|
|
7741
|
+
isReady: re,
|
|
7742
|
+
talkingHead: f.current
|
|
7739
7743
|
})), /* @__PURE__ */ ke("div", { className: `simple-talking-avatar-container ${b}`, style: L, children: [
|
|
7740
7744
|
/* @__PURE__ */ $(
|
|
7741
7745
|
"div",
|
|
@@ -7772,8 +7776,8 @@ const Ct = Ze(({
|
|
|
7772
7776
|
}, children: le })
|
|
7773
7777
|
] });
|
|
7774
7778
|
});
|
|
7775
|
-
|
|
7776
|
-
const
|
|
7779
|
+
zt.displayName = "SimpleTalkingAvatar";
|
|
7780
|
+
const Ht = Ze(({
|
|
7777
7781
|
curriculumData: V = null,
|
|
7778
7782
|
avatarConfig: t = {},
|
|
7779
7783
|
animations: e = {},
|
|
@@ -7853,7 +7857,7 @@ const zt = Ze(({
|
|
|
7853
7857
|
lipsyncLang: "en"
|
|
7854
7858
|
};
|
|
7855
7859
|
}, [V, t, e]);
|
|
7856
|
-
const y =
|
|
7860
|
+
const y = N(() => (P.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), F = N(() => y()?.questions[r.current.currentQuestionIndex], [y]), f = N((v, A) => A.type === "multiple_choice" || A.type === "true_false" ? v === A.answer : A.type === "code_test" && typeof v == "object" && v !== null ? v.passed === !0 : !1, []), S = N(() => {
|
|
7857
7861
|
r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
|
|
7858
7862
|
const v = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
|
|
7859
7863
|
let A = "Congratulations! You've completed this lesson";
|
|
@@ -7877,9 +7881,9 @@ const zt = Ze(({
|
|
|
7877
7881
|
} catch {
|
|
7878
7882
|
u.current.playCelebration();
|
|
7879
7883
|
}
|
|
7880
|
-
const M = P.current || { modules: [] }, B = M.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (B?.lessons?.length || 0) - 1,
|
|
7884
|
+
const M = P.current || { modules: [] }, B = M.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (B?.lessons?.length || 0) - 1, oe = r.current.currentModuleIndex < (M.modules?.length || 0) - 1, ne = Z || oe, K = E.current || { lipsyncLang: "en" };
|
|
7881
7885
|
u.current.speakText(A, {
|
|
7882
|
-
lipsyncLang:
|
|
7886
|
+
lipsyncLang: K.lipsyncLang,
|
|
7883
7887
|
onSpeechEnd: () => {
|
|
7884
7888
|
d.current.onCustomAction({
|
|
7885
7889
|
type: "lessonCompleteFeedbackDone",
|
|
@@ -7893,7 +7897,7 @@ const zt = Ze(({
|
|
|
7893
7897
|
}
|
|
7894
7898
|
});
|
|
7895
7899
|
}
|
|
7896
|
-
}, [e.lessonComplete]), H =
|
|
7900
|
+
}, [e.lessonComplete]), H = N(() => {
|
|
7897
7901
|
r.current.curriculumCompleted = !0;
|
|
7898
7902
|
const v = P.current || { modules: [] };
|
|
7899
7903
|
if (d.current.onCurriculumComplete({
|
|
@@ -7909,7 +7913,7 @@ const zt = Ze(({
|
|
|
7909
7913
|
const A = E.current || { lipsyncLang: "en" };
|
|
7910
7914
|
u.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: A.lipsyncLang });
|
|
7911
7915
|
}
|
|
7912
|
-
}, [e.curriculumComplete]), I =
|
|
7916
|
+
}, [e.curriculumComplete]), I = N(() => {
|
|
7913
7917
|
const v = y();
|
|
7914
7918
|
r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = v?.questions?.length || 0, r.current.score = 0;
|
|
7915
7919
|
const A = F();
|
|
@@ -7946,7 +7950,7 @@ const zt = Ze(({
|
|
|
7946
7950
|
clearInterval(B);
|
|
7947
7951
|
}, 5e3);
|
|
7948
7952
|
}
|
|
7949
|
-
}, [e.questionStart, y, F]), U =
|
|
7953
|
+
}, [e.questionStart, y, F]), U = N(() => {
|
|
7950
7954
|
const v = y();
|
|
7951
7955
|
if (r.current.currentQuestionIndex < (v?.questions?.length || 0) - 1) {
|
|
7952
7956
|
u.current && u.current.stopSpeaking && u.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
|
|
@@ -7965,28 +7969,28 @@ const zt = Ze(({
|
|
|
7965
7969
|
if (u.current.setMood("happy"), u.current.setBodyMovement("idle"), e.nextQuestion)
|
|
7966
7970
|
try {
|
|
7967
7971
|
u.current.playAnimation(e.nextQuestion, !0);
|
|
7968
|
-
} catch (
|
|
7969
|
-
console.warn("Failed to play nextQuestion animation:",
|
|
7972
|
+
} catch (K) {
|
|
7973
|
+
console.warn("Failed to play nextQuestion animation:", K);
|
|
7970
7974
|
}
|
|
7971
|
-
const B = E.current || { lipsyncLang: "en" },
|
|
7975
|
+
const B = E.current || { lipsyncLang: "en" }, oe = y()?.questions?.length || 0, ne = r.current.currentQuestionIndex >= oe - 1;
|
|
7972
7976
|
if (A.type === "code_test") {
|
|
7973
|
-
const
|
|
7974
|
-
u.current.speakText(
|
|
7977
|
+
const K = ne ? `Great! Here's your final coding challenge: ${A.question}` : `Great! Now let's move on to your next coding challenge: ${A.question}`;
|
|
7978
|
+
u.current.speakText(K, {
|
|
7975
7979
|
lipsyncLang: B.lipsyncLang
|
|
7976
7980
|
});
|
|
7977
7981
|
} else if (A.type === "multiple_choice") {
|
|
7978
|
-
const
|
|
7979
|
-
u.current.speakText(
|
|
7982
|
+
const K = ne ? `Alright! Here's your final question: ${A.question}` : `Alright! Here's your next question: ${A.question}`;
|
|
7983
|
+
u.current.speakText(K, {
|
|
7980
7984
|
lipsyncLang: B.lipsyncLang
|
|
7981
7985
|
});
|
|
7982
7986
|
} else if (A.type === "true_false") {
|
|
7983
|
-
const
|
|
7984
|
-
u.current.speakText(
|
|
7987
|
+
const K = ne ? `Now let's try this final one: ${A.question}` : `Now let's try this one: ${A.question}`;
|
|
7988
|
+
u.current.speakText(K, {
|
|
7985
7989
|
lipsyncLang: B.lipsyncLang
|
|
7986
7990
|
});
|
|
7987
7991
|
} else {
|
|
7988
|
-
const
|
|
7989
|
-
u.current.speakText(
|
|
7992
|
+
const K = ne ? `Here's your final question: ${A.question}` : `Here's the next question: ${A.question}`;
|
|
7993
|
+
u.current.speakText(K, {
|
|
7990
7994
|
lipsyncLang: B.lipsyncLang
|
|
7991
7995
|
});
|
|
7992
7996
|
}
|
|
@@ -8009,11 +8013,11 @@ const zt = Ze(({
|
|
|
8009
8013
|
totalQuestions: r.current.totalQuestions,
|
|
8010
8014
|
score: r.current.score
|
|
8011
8015
|
});
|
|
8012
|
-
}, [e.nextQuestion, y, F]), G =
|
|
8016
|
+
}, [e.nextQuestion, y, F]), G = N(() => {
|
|
8013
8017
|
const v = P.current || { modules: [] }, A = v.modules[r.current.currentModuleIndex];
|
|
8014
8018
|
if (r.current.currentLessonIndex < (A?.lessons?.length || 0) - 1) {
|
|
8015
8019
|
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;
|
|
8016
|
-
const B = v.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (B?.lessons?.length || 0) - 1,
|
|
8020
|
+
const B = v.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (B?.lessons?.length || 0) - 1, oe = r.current.currentModuleIndex < (v.modules?.length || 0) - 1, ne = Z || oe;
|
|
8017
8021
|
d.current.onCustomAction({
|
|
8018
8022
|
type: "lessonStart",
|
|
8019
8023
|
moduleIndex: r.current.currentModuleIndex,
|
|
@@ -8026,12 +8030,12 @@ const zt = Ze(({
|
|
|
8026
8030
|
}), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
|
|
8027
8031
|
} else if (r.current.currentModuleIndex < (v.modules?.length || 0) - 1) {
|
|
8028
8032
|
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;
|
|
8029
|
-
const Z = v.modules[r.current.currentModuleIndex],
|
|
8033
|
+
const Z = v.modules[r.current.currentModuleIndex], oe = r.current.currentLessonIndex < (Z?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (v.modules?.length || 0) - 1, K = oe || ne;
|
|
8030
8034
|
d.current.onCustomAction({
|
|
8031
8035
|
type: "lessonStart",
|
|
8032
8036
|
moduleIndex: r.current.currentModuleIndex,
|
|
8033
8037
|
lessonIndex: r.current.currentLessonIndex,
|
|
8034
|
-
hasNextLesson:
|
|
8038
|
+
hasNextLesson: K
|
|
8035
8039
|
}), d.current.onLessonStart({
|
|
8036
8040
|
moduleIndex: r.current.currentModuleIndex,
|
|
8037
8041
|
lessonIndex: r.current.currentLessonIndex,
|
|
@@ -8039,7 +8043,7 @@ const zt = Ze(({
|
|
|
8039
8043
|
}), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
|
|
8040
8044
|
} else
|
|
8041
8045
|
L.current && L.current();
|
|
8042
|
-
}, []), j =
|
|
8046
|
+
}, []), j = N(() => {
|
|
8043
8047
|
const v = y();
|
|
8044
8048
|
let A = null;
|
|
8045
8049
|
if (v?.avatar_script && v?.body) {
|
|
@@ -8086,8 +8090,8 @@ const zt = Ze(({
|
|
|
8086
8090
|
}
|
|
8087
8091
|
});
|
|
8088
8092
|
}
|
|
8089
|
-
}, [e.teaching, y]), Y =
|
|
8090
|
-
const A = F(), M =
|
|
8093
|
+
}, [e.teaching, y]), Y = N((v) => {
|
|
8094
|
+
const A = F(), M = f(v, A);
|
|
8091
8095
|
if (M && (r.current.score += 1), d.current.onQuestionAnswer({
|
|
8092
8096
|
moduleIndex: r.current.currentModuleIndex,
|
|
8093
8097
|
lessonIndex: r.current.currentLessonIndex,
|
|
@@ -8106,11 +8110,11 @@ const zt = Ze(({
|
|
|
8106
8110
|
u.current.setBodyMovement("gesturing");
|
|
8107
8111
|
const Z = y()?.questions?.length || 0;
|
|
8108
8112
|
r.current.currentQuestionIndex >= Z - 1;
|
|
8109
|
-
const
|
|
8110
|
-
console.log("[CurriculumLearning] Answer feedback - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:",
|
|
8111
|
-
const ne = A.type === "code_test" ? `Great job! Your code passed all the tests! ${A.explanation || ""}` : `Excellent! That's correct! ${A.explanation || ""}`,
|
|
8113
|
+
const oe = r.current.currentQuestionIndex < Z - 1;
|
|
8114
|
+
console.log("[CurriculumLearning] Answer feedback - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:", oe);
|
|
8115
|
+
const ne = A.type === "code_test" ? `Great job! Your code passed all the tests! ${A.explanation || ""}` : `Excellent! That's correct! ${A.explanation || ""}`, K = E.current || { lipsyncLang: "en" };
|
|
8112
8116
|
u.current.speakText(ne, {
|
|
8113
|
-
lipsyncLang:
|
|
8117
|
+
lipsyncLang: K.lipsyncLang,
|
|
8114
8118
|
onSpeechEnd: () => {
|
|
8115
8119
|
d.current.onCustomAction({
|
|
8116
8120
|
type: "answerFeedbackComplete",
|
|
@@ -8118,7 +8122,7 @@ const zt = Ze(({
|
|
|
8118
8122
|
lessonIndex: r.current.currentLessonIndex,
|
|
8119
8123
|
questionIndex: r.current.currentQuestionIndex,
|
|
8120
8124
|
isCorrect: !0,
|
|
8121
|
-
hasNextQuestion:
|
|
8125
|
+
hasNextQuestion: oe,
|
|
8122
8126
|
score: r.current.score,
|
|
8123
8127
|
totalQuestions: r.current.totalQuestions
|
|
8124
8128
|
});
|
|
@@ -8132,10 +8136,10 @@ const zt = Ze(({
|
|
|
8132
8136
|
u.current.setBodyMovement("idle");
|
|
8133
8137
|
}
|
|
8134
8138
|
u.current.setBodyMovement("gesturing");
|
|
8135
|
-
const Z = y()?.questions?.length || 0,
|
|
8139
|
+
const Z = y()?.questions?.length || 0, oe = r.current.currentQuestionIndex >= Z - 1, ne = r.current.currentQuestionIndex < Z - 1;
|
|
8136
8140
|
console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:", ne);
|
|
8137
|
-
const
|
|
8138
|
-
u.current.speakText(
|
|
8141
|
+
const K = A.type === "code_test" ? `Your code didn't pass all the tests. ${A.explanation || "Try again!"}` : `Not quite right, but don't worry! ${A.explanation || ""}${oe ? "" : " Let's move on to the next question."}`, me = E.current || { lipsyncLang: "en" };
|
|
8142
|
+
u.current.speakText(K, {
|
|
8139
8143
|
lipsyncLang: me.lipsyncLang,
|
|
8140
8144
|
onSpeechEnd: () => {
|
|
8141
8145
|
d.current.onCustomAction({
|
|
@@ -8165,7 +8169,7 @@ const zt = Ze(({
|
|
|
8165
8169
|
avatarNotReady: !0
|
|
8166
8170
|
});
|
|
8167
8171
|
}
|
|
8168
|
-
}, [e.correct, e.incorrect, F, y,
|
|
8172
|
+
}, [e.correct, e.incorrect, F, y, f]), ue = N((v) => {
|
|
8169
8173
|
const A = F();
|
|
8170
8174
|
if (!v || typeof v != "object") {
|
|
8171
8175
|
console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
|
|
@@ -8193,7 +8197,7 @@ const zt = Ze(({
|
|
|
8193
8197
|
testResult: M,
|
|
8194
8198
|
question: A
|
|
8195
8199
|
}), p.current && p.current(M);
|
|
8196
|
-
}, [F,
|
|
8200
|
+
}, [F, f]), le = N(() => {
|
|
8197
8201
|
if (r.current.currentQuestionIndex > 0) {
|
|
8198
8202
|
r.current.currentQuestionIndex -= 1;
|
|
8199
8203
|
const v = F();
|
|
@@ -8227,7 +8231,7 @@ const zt = Ze(({
|
|
|
8227
8231
|
}, 5e3);
|
|
8228
8232
|
}
|
|
8229
8233
|
}
|
|
8230
|
-
}, [F]),
|
|
8234
|
+
}, [F]), Ie = N(() => {
|
|
8231
8235
|
const v = P.current || { modules: [] };
|
|
8232
8236
|
if (v.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
|
|
8233
8237
|
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, d.current.onCustomAction({
|
|
@@ -8251,16 +8255,16 @@ const zt = Ze(({
|
|
|
8251
8255
|
lesson: y()
|
|
8252
8256
|
}), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
|
|
8253
8257
|
}
|
|
8254
|
-
}, [y]),
|
|
8258
|
+
}, [y]), re = N(() => {
|
|
8255
8259
|
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;
|
|
8256
|
-
}, []), ze =
|
|
8260
|
+
}, []), ze = N((v) => {
|
|
8257
8261
|
console.log("Avatar is ready!", v);
|
|
8258
8262
|
const A = y(), M = A?.avatar_script || A?.body;
|
|
8259
8263
|
c && M && setTimeout(() => {
|
|
8260
8264
|
h.current && h.current();
|
|
8261
8265
|
}, 10);
|
|
8262
8266
|
}, [c, y]);
|
|
8263
|
-
|
|
8267
|
+
ot(() => {
|
|
8264
8268
|
h.current = j, g.current = G, R.current = S, b.current = U, L.current = H, T.current = I, p.current = Y;
|
|
8265
8269
|
}), Xe(l, () => ({
|
|
8266
8270
|
// Curriculum control methods
|
|
@@ -8271,10 +8275,10 @@ const zt = Ze(({
|
|
|
8271
8275
|
nextQuestion: U,
|
|
8272
8276
|
previousQuestion: le,
|
|
8273
8277
|
nextLesson: G,
|
|
8274
|
-
previousLesson:
|
|
8278
|
+
previousLesson: Ie,
|
|
8275
8279
|
completeLesson: S,
|
|
8276
8280
|
completeCurriculum: H,
|
|
8277
|
-
resetCurriculum:
|
|
8281
|
+
resetCurriculum: re,
|
|
8278
8282
|
getState: () => ({ ...r.current }),
|
|
8279
8283
|
getCurrentQuestion: () => F(),
|
|
8280
8284
|
getCurrentLesson: () => y(),
|
|
@@ -8328,7 +8332,7 @@ const zt = Ze(({
|
|
|
8328
8332
|
handleResize: () => u.current?.handleResize(),
|
|
8329
8333
|
// Avatar readiness check (always returns current value)
|
|
8330
8334
|
isAvatarReady: () => u.current?.isReady || !1
|
|
8331
|
-
}), [j, I, Y, ue, U, G, S, H,
|
|
8335
|
+
}), [j, I, Y, ue, U, G, S, H, re, F, y]);
|
|
8332
8336
|
const ee = E.current || {
|
|
8333
8337
|
avatarUrl: "/avatars/brunette.glb",
|
|
8334
8338
|
avatarBody: "F",
|
|
@@ -8367,7 +8371,7 @@ const zt = Ze(({
|
|
|
8367
8371
|
}
|
|
8368
8372
|
) });
|
|
8369
8373
|
});
|
|
8370
|
-
|
|
8374
|
+
Ht.displayName = "CurriculumLearning";
|
|
8371
8375
|
function Ut({
|
|
8372
8376
|
manifestPath: V = "/animations/manifest.json",
|
|
8373
8377
|
avatarBody: t = "F",
|
|
@@ -8447,7 +8451,7 @@ This will delete:
|
|
|
8447
8451
|
${H.slice(0, 5).join(`
|
|
8448
8452
|
`)}${H.length > 5 ? `
|
|
8449
8453
|
...` : ""}`) && (o && o(H), a(i.filter((I) => c.has(I.path))), l(/* @__PURE__ */ new Set()));
|
|
8450
|
-
},
|
|
8454
|
+
}, f = (S) => {
|
|
8451
8455
|
e && e(S);
|
|
8452
8456
|
};
|
|
8453
8457
|
return u ? /* @__PURE__ */ $("div", { style: { padding: "20px", textAlign: "center", ...s }, children: /* @__PURE__ */ $("p", { children: "Loading animations..." }) }) : d ? /* @__PURE__ */ $("div", { style: { padding: "20px", color: "red", ...s }, children: /* @__PURE__ */ ke("p", { children: [
|
|
@@ -8624,7 +8628,7 @@ ${H.slice(0, 5).join(`
|
|
|
8624
8628
|
"button",
|
|
8625
8629
|
{
|
|
8626
8630
|
onClick: (U) => {
|
|
8627
|
-
U.stopPropagation(),
|
|
8631
|
+
U.stopPropagation(), f(S.path);
|
|
8628
8632
|
},
|
|
8629
8633
|
style: {
|
|
8630
8634
|
width: "100%",
|
|
@@ -8757,10 +8761,10 @@ const tt = {
|
|
|
8757
8761
|
}, Wt = (V) => tt[V] || null, Vt = (V) => tt.hasOwnProperty(V);
|
|
8758
8762
|
export {
|
|
8759
8763
|
Ut as AnimationSelector,
|
|
8760
|
-
|
|
8761
|
-
|
|
8764
|
+
Ht as CurriculumLearning,
|
|
8765
|
+
zt as SimpleTalkingAvatar,
|
|
8762
8766
|
et as TalkingHeadAvatar,
|
|
8763
|
-
|
|
8767
|
+
wt as TalkingHeadComponent,
|
|
8764
8768
|
tt as animations,
|
|
8765
8769
|
je as getActiveTTSConfig,
|
|
8766
8770
|
Wt as getAnimation,
|