Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Animation Three.js和帧动画跳过_Animation_Three.js_Frame - Fatal编程技术网

Animation Three.js和帧动画跳过

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()

我目前正在使用three.js进行动画项目。我正在使用变形目标,想问一下为什么我的帧经常被跳过?我的动画有7个变形目标,它围绕着它们。它从0到6开始(输出: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);

}]

我想这是因为你是在读挂钟的基础上选择新的框架的。。因此,如果帧速率下降,则可能会丢失一帧