This commit is contained in:
yinsx
2025-12-26 15:51:59 +08:00
parent 43ffe4486a
commit ea4bc6502d
3 changed files with 36 additions and 8 deletions

View File

@ -26,8 +26,8 @@ const ExpressionLibrary = {
smirk: {
name: '冷笑',
blendShapes: {
eyeblinkleft: 0.41,
eyeblinkright: 0.41,
eyesquintleft: 0.35,
eyesquintright: 0.35,
mouthsmileleft: 0.3
},
duration: 2000
@ -94,9 +94,7 @@ const ExpressionLibrary = {
blendShapes: {
eyesquintleft: 0.3,
eyesquintright: 0.3,
mouthpucker: 0.4,
eyelookupleft: 0.3,
eyelookupright: 0.3
mouthpucker: 0.4
},
duration: 3000
},
@ -130,8 +128,10 @@ const ExpressionLibrary = {
randomPlayer: {
enabled: false,
timeout: null,
durationTimeout: null,
currentExpression: null,
lastExpressionKey: null,
pausedEyeLook: false,
intervalMin: 3000,
intervalMax: 8000,
@ -146,12 +146,21 @@ const ExpressionLibrary = {
clearTimeout(this.timeout);
this.timeout = null;
}
if (this.durationTimeout) {
clearTimeout(this.durationTimeout);
this.durationTimeout = null;
}
this.reset();
},
scheduleNext: function() {
if (!this.enabled) return;
// 清除之前的定时器(如果存在)
if (this.timeout) {
clearTimeout(this.timeout);
}
const delay = this.intervalMin + Math.random() * (this.intervalMax - this.intervalMin);
this.timeout = setTimeout(() => {
this.playRandom();
@ -186,6 +195,12 @@ const ExpressionLibrary = {
key => ExpressionLibrary.expressions[key] === expression
);
// 暂停眼球移动(避免与表情冲突)
if (window.animator && window.animator.isEyeLookEnabled) {
window.animator._stopRandomEyeLook();
this.pausedEyeLook = true;
}
// 从主页面获取动画速度参数
const speed = window.expressionParams?.speed || 400;
@ -200,7 +215,13 @@ const ExpressionLibrary = {
const duration = (window.expressionDurations && window.expressionDurations[this.lastExpressionKey])
|| expression.duration;
setTimeout(() => {
// 清除之前的持续时间定时器(如果存在)
if (this.durationTimeout) {
clearTimeout(this.durationTimeout);
}
this.durationTimeout = setTimeout(() => {
this.durationTimeout = null;
this.reset();
if (!this.enabled) return;
this.scheduleNext();
@ -221,6 +242,12 @@ const ExpressionLibrary = {
}
this.currentExpression = null;
// 恢复眼球移动
if (this.pausedEyeLook && window.animator && window.animator.isEyeLookEnabled) {
window.animator._startRandomEyeLook();
this.pausedEyeLook = false;
}
}
},