// 创建一个关键帧动画
let frameRate = 10
// 动画名称 绑定的动画属性 帧率数
let animationRotate = new BABYLON.Animation(
"cameraRotation",
"alpha",
frameRate,
BABYLON.Animation.ANIMATIONTYPE_VECTOR3,
BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE
);
let start_alpha = camera1.alpha
// 定义动画的关键帧
var keysRotation = [
{
frame: 0,
value: start_alpha
},
{
frame: frameRate,
value: start_alpha+camera_rotation_Speed
}
];
// 将关键帧添加到动画中
animationRotate.setKeys(keysRotation);
// 将动画应用到相机的 rotation 属性上
camera1.animations.push(animationRotate);
const easingFunction = new BABYLON.SineEase();
easingFunction.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
animationRotate.setEasingFunction(easingFunction);
// 启动动画
scene.beginAnimation(camera1, 0, frameRate, false);