几个关键点:
material..morphTargets = true; //开启顶点动画
// http://catchvar.com/threejs-animating-blender-models
//动画的基本控制参数
var animOffset = 0, // starting frame of animation
walking = false,
duration = 1000, // milliseconds to complete animation
keyframes = 20, // total number of animation frames 设定了多少个关键帧
interpolation = duration / keyframes, // milliseconds per frame
lastKeyframe = 0, // previous keyframe
currentKeyframe = 0;
//渲染方法
function render()
{
if ( android ) // exists / is loaded
{
// Alternate morph targets
time = new Date().getTime() % duration;
keyframe = Math.floor( time / interpolation ) + animOffset;
if ( keyframe != currentKeyframe )
{
android.morphTargetInfluences[ lastKeyframe ] = 0;
android.morphTargetInfluences[ currentKeyframe ] = 1;
android.morphTargetInfluences[ keyframe ] = 0;
lastKeyframe = currentKeyframe;
currentKeyframe = keyframe;
}
android.morphTargetInfluences[ keyframe ] =
( time % interpolation ) / interpolation;
android.morphTargetInfluences[ lastKeyframe ] =
1 - android.morphTargetInfluences[ keyframe ];
}
renderer.render( scene, camera );
}
Mesh中的解释,就是通过这个取各个关键帧的数据
.morphTargetInfluences : Array
An array of weights typically from 0-1 that specify how much of the morph is applied. Undefined by default, but reset to a blank array by updateMorphTargets.
FYI:https://stemkoski.github.io/Three.js/Model-Animation.html
//加入控制
https://stemkoski.github.io/Three.js/Model-Animation-Control.html