优化,增加表情幅度

This commit is contained in:
yinsx
2025-12-27 09:22:31 +08:00
parent ea4bc6502d
commit 6e61fd81b3
4 changed files with 29 additions and 8 deletions

View File

@ -36,7 +36,8 @@ class BlendShapeAnimator {
this.expressionParams = config.expressionParams || {
intervalMin: 3000,
intervalMax: 8000,
speed: 400
speed: 400,
strength: 1.0
};
this.enabledExpressions = new Set();
@ -269,12 +270,20 @@ class BlendShapeAnimator {
// 设置空闲动画
setIdleAnimation(name, target, duration = 200, easing = 'easeOutQuad') {
const currentValue = this.morphTargetAdapter
? this.morphTargetAdapter.getInfluence(name) || 0
: (this.idleAnimations[name]?.target || 0);
const anim = this.idleAnimations[name] || {};
const unchanged = Math.abs(currentValue - target) < 1e-4 && Math.abs((anim.target ?? 0) - target) < 1e-4;
this.idleAnimations[name] = {
target: target,
duration: duration,
easing: easing,
startTime: null,
startValue: this.idleAnimations[name]?.target || 0
// 如果目标基本不变,保持当前起点,避免反复重新插值导致抖动
startTime: unchanged ? performance.now() : null,
startValue: currentValue
};
}
@ -305,7 +314,9 @@ class BlendShapeAnimator {
if (anim.target === 0) {
delete this.idleAnimations[name];
} else {
anim.startTime = null;
// 目标保持不变,锁定在当前值,避免反复重新插值造成抖动
anim.startValue = anim.target;
anim.startTime = now;
}
}
}