Animation Three.js和帧动画跳过
我目前正在使用three.js进行动画项目。我正在使用变形目标,想问一下为什么我的帧经常被跳过?我的动画有7个变形目标,它围绕着它们。它从0到6开始(输出:console.log('frame:'+lastKeyframe)),但有时我的帧从0跳到3或从1跳到4。。这里到底发生了什么?顺便说一句,动画代码运行良好Animation Three.js和帧动画跳过,animation,three.js,frame,Animation,Three.js,Frame,我目前正在使用three.js进行动画项目。我正在使用变形目标,想问一下为什么我的帧经常被跳过?我的动画有7个变形目标,它围绕着它们。它从0到6开始(输出:console.log('frame:'+lastKeyframe)),但有时我的帧从0跳到3或从1跳到4。。这里到底发生了什么?顺便说一句,动画代码运行良好 [if ( Mesh && playBack ) // exists / is loaded { time = new Date().getTime()
[if ( Mesh && playBack ) // exists / is loaded
{
time = new Date().getTime() % duration; //arba Date.now()
keyframe = Math.floor( time / interpolation ) + animOffset;
if ( keyframe != currentKeyframe )
{
Mesh.morphTargetInfluences[ lastKeyframe ] = 0;
Mesh.morphTargetInfluences[ currentKeyframe ] = 1;
Mesh.morphTargetInfluences[ keyframe ] = 0;
//console.log(Mesh.morphTargetInfluences[ 0 ]);
lastKeyframe = currentKeyframe;
currentKeyframe = keyframe;
}
//The two lines after the if statement interpolate between frames.
//The value at currentKeyFrame starts decreasing from 1, and the value at keyFrame starts increasing.
Mesh.morphTargetInfluences[ keyframe ] = ( time % interpolation ) / interpolation;
Mesh.morphTargetInfluences[ lastKeyframe ] = 1 - Mesh.morphTargetInfluences[ keyframe ];
//console.log('current: ' + Mesh.morphTargetInfluences[ keyframe ]);
console.log('frame: ' + lastKeyframe);
}]
我想这是因为你是在读挂钟的基础上选择新的框架的。。因此,如果帧速率下降,则可能会丢失一帧