0

我目前正在为我的动画项目使用three.js。我正在使用 morphtargets 并想问为什么我的帧经常被跳过?我的动画有 7 个变形目标,它围绕着它们展开。它从 0 到 6 (output:console.log('frame: ' + lastKeyframe) ) 开始,但有时我的帧从 0 跳到 3 或从 1 跳到 4.. 这里真的发生了什么?顺便说一句,动画代码运行良好

[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);

}]
4

1 回答 1

0

我认为这是因为您是根据阅读挂钟来选择新帧。所以如果您的帧速率下降,那么您可能会丢失一帧

于 2013-10-15T14:57:33.720 回答