Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix: Update import path for FaceExpression module in embodiment-stage.js

udvk3ed85d5bbe9e
diff --git a/apps-sdk/embodiment/embodiment-stage.js b/apps-sdk/embodiment/embodiment-stage.js
index 34aa8b318..4bd26e0d9 100644
--- a/apps-sdk/embodiment/embodiment-stage.js
+++ b/apps-sdk/embodiment/embodiment-stage.js
@@ -40,7 +40,7 @@ import { A2FPlayer } from '../../src/voice/a2f-player.js';
import { inspectRig, decideRigMode } from '../../src/embodiment/rig-mode.js';
import { expressionForText, expressionFor } from '../../src/embodiment/emotion.js';
import { TextVisemeEnvelope, estimateSpeechDuration } from '../../src/embodiment/text-visemes.js';
-import { FaceExpression } from './face-expression.js';
+import { FaceExpression } from '../../src/embodiment/face-expression.js';
const REDUCED_MOTION =
typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
diff --git a/apps-sdk/embodiment/face-expression.js b/apps-sdk/embodiment/face-expression.js
index cd661a4cd..d3b9e4749 100644
--- a/apps-sdk/embodiment/face-expression.js
+++ b/apps-sdk/embodiment/face-expression.js
@@ -1,98 +1,4 @@
-/**
- * Emotion → face, the blendshape half of an embodied reply.
- *
- * Lip-sync (AvatarMouthTarget / A2FPlayer) owns the MOUTH while the body speaks;
- * this owns the EXPRESSION — the brows, eyes, cheeks, nose and smile/frown that
- * carry joy, sadness, anger, surprise. It indexes a rig's ARKit-52 morph targets
- * (the shared vocabulary in src/voice/arkit-blendshapes.js) and eases the current
- * weights toward a target set every frame, so an emotion fades in and out instead
- * of snapping.
- *
- * It deliberately does NOT drive jawOpen or the raw viseme channels — those belong
- * to the lip-sync driver, and writing them here would fight the mouth. A rig with
- * no facial morphs is fine: this becomes a no-op and the emotion still reads
- * through the body gesture the stage plays. That graceful degradation is the
- * point — emotion is never lost, it just moves from the face to the body.
- */
-
-import { indexARKitMorphs, canonicalARKitName } from '../../src/voice/arkit-blendshapes.js';
-
-// Channels the lip-sync driver owns — never written by the expression layer.
-const MOUTH_RESERVED = new Set(['jawOpen', 'jawForward', 'jawLeft', 'jawRight']);
-
-export class FaceExpression {
- constructor() {
- /** @type {Array<{mesh:object, index:Map<string,number>}>} */
- this._meshes = [];
- this._current = new Map(); // canonical ARKit name → current weight
- this._target = new Map(); // canonical ARKit name → target weight
- }
-
- /** Bind to a loaded model: collect every mesh that carries ARKit morphs. */
- attach(root) {
- this._meshes = [];
- this._current.clear();
- this._target.clear();
- root?.traverse?.((node) => {
- if (node.isMesh && node.morphTargetDictionary && node.morphTargetInfluences) {
- const index = indexARKitMorphs(node.morphTargetDictionary);
- if (index.size) this._meshes.push({ mesh: node, index });
- }
- });
- return this;
- }
-
- /** True if any expression morph is available on this rig. */
- hasMorphs() {
- return this._meshes.length > 0;
- }
-
- /**
- * Set the emotion face. Accepts a map of ARKit name → weight (0..1); unknown
- * names are normalized, mouth-reserved channels are dropped. Pass {} to relax
- * back to a neutral face.
- * @param {Record<string, number>} arkitWeights
- */
- setTarget(arkitWeights = {}) {
- const next = new Map();
- for (const [name, w] of Object.entries(arkitWeights)) {
- const canon = canonicalARKitName(name);
- if (!canon || MOUTH_RESERVED.has(canon)) continue;
- next.set(canon, Math.max(0, Math.min(1, Number(w) || 0)));
- }
- this._target = next;
- }
-
- /**
- * Ease current weights toward target and write them to every bound mesh.
- * @param {number} dt seconds since last frame
- */
- update(dt) {
- if (!this._meshes.length) return;
- // Time-constant ease (~180ms to most of the way), framerate-independent.
- const k = 1 - Math.exp(-dt / 0.18);
- const names = new Set([...this._current.keys(), ...this._target.keys()]);
- for (const name of names) {
- const cur = this._current.get(name) || 0;
- const tgt = this._target.get(name) || 0;
- const val = cur + (tgt - cur) * k;
- if (val < 0.001 && tgt === 0) this._current.delete(name);
- else this._current.set(name, val);
- }
- for (const { mesh, index } of this._meshes) {
- for (const [name, val] of this._current) {
- const i = index.get(name);
- if (i != null) mesh.morphTargetInfluences[i] = val;
- }
- }
- }
-
- /** Snap everything to neutral immediately (e.g. on persona swap). */
- reset() {
- this._target = new Map();
- for (const { mesh, index } of this._meshes) {
- for (const i of index.values()) mesh.morphTargetInfluences[i] = 0;
- }
- this._current.clear();
- }
-}
+// Re-export from the canonical implementation in src/embodiment so there is one
+// FaceExpression class in the codebase, not two. Any file that used to import
+// from this path continues to work unchanged.
+export { FaceExpression } from '../../src/embodiment/face-expression.js';