fix bug: when switching talkinghead off, set character expression

This commit is contained in:
Juha Jeronen 2024-02-05 00:47:14 +02:00
parent 2a39db799a
commit ad48d6666a
1 changed files with 8 additions and 2 deletions

View File

@ -562,8 +562,14 @@ function handleImageChange() {
}
}
} else {
imgElement.src = ''; //remove incase char doesnt have expressions
setExpression(getContext().name2, FALLBACK_EXPRESSION, true);
imgElement.src = ''; // remove in case char doesn't have expressions
// When switching Talkinghead off, force-set the character to the last known expression, if any.
// This preserves the same expression Talkinghead had at the moment it was switched off.
const charName = getContext().name2;
const last = lastExpression[charName];
const targetExpression = last ? last : FALLBACK_EXPRESSION;
setExpression(charName, targetExpression, true);
}
}