Fix: TalkingHead2.animate crash - null morph target access in animate()

#5
by bep40 - opened

Fix: TalklingHead2.animate crash "Cannot read properties of undefined (reading 'value')"

Root cause

In @met4citizen/talkinghead/dist/talkinghead.mjs, the animate() method crashes at line ~2620 when:

  • this.mtRandomized contains morph target keys not present in this.mtAvatar for the loaded GLB
  • j = this.mtAvatar[i] returns undefined โ†’ !j.needsUpdate throws

Fix (3 layers)

  1. Null check in animate โ€” add if (!j) continue; before null access
  2. Guard direct .value accesses โ€” wrap this.mtAvatar['key'].value in (this.mtAvatar['key'] || {}).value || 0
  3. Wrap animate in try/catch โ€” safety net for any other crashes

Patch is applied at Docker build-time via patch_talkinghead.py run after bun install.

Publish this branch
This branch is in draft mode, publish it to be able to merge.

Sign up or log in to comment