let box=BABYLON.MeshBuilder.CreateBox('box',{width:5,height:3,depth:2},scene)
const framerate=10
const anim=new BABYLON.Animation('animation','position.y',framerate,
BABYLON.Animation.ANIMATIONTYPE_FLOAT,
BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE)
const keysFrames=[]
keysFrames.push({
frame:0,
value:0
})
keysFrames.push({
frame:2*framerate,
value:10
})
keysFrames.push({
frame:4*framerate,
value:0
})
anim.setKeys(keysFrames)
box.animations.push(anim)
scene.beginAnimation(box,0,4*framerate,true)
beginAnimation 方法的第二个和第三个参数是 keyFrames 列表中的起始帧和结束帧。如果你反转这两个值,动画将反向播放!
const myAnim = new BABYLON.Animation(name, property,
frames_per_second, property_type, loop_mode)
参数说明: