首次播放不掉帧

This commit is contained in:
yinsx
2026-01-04 14:06:14 +08:00
parent 2bd183463d
commit f98ff21394
7 changed files with 4856 additions and 33 deletions

View File

@ -12,6 +12,7 @@ class BlendShapeAnimator {
this.idleAnimations = {};
this.blendShapeScale = config.blendShapeScale || 1.0;
this.dataFps = config.dataFps || 30;
this.playbackSpeed = config.playbackSpeed || 1.0; // 播放倍速0.5=慢速, 1.0=正常, 2.0=快速
this.isStreaming = false;
this.streamingComplete = true;
this.streamingWaitStart = null;
@ -333,7 +334,7 @@ class BlendShapeAnimator {
}
const frameDuration = 1000 / this.dataFps;
const elapsed = now - this.animationStartTime - this.streamingStallMs;
const elapsed = (now - this.animationStartTime - this.streamingStallMs) * this.playbackSpeed;
const exactFrame = elapsed / frameDuration;
const targetFrameIndex = Math.floor(exactFrame);
const frameProgress = exactFrame - targetFrameIndex;
@ -710,6 +711,8 @@ class BlendShapeAnimator {
updateConfig(key, value) {
if (key === 'blendShapeScale') {
this.blendShapeScale = value;
} else if (key === 'playbackSpeed') {
this.playbackSpeed = value;
} else if (this[key]) {
this[key] = value;
}