Hi guys, so what I’m trying to do is like
I’m trying to build an animation for arcRotateCamera so it can rotate smoothly, i.e. from start position to end position, and with the exact correct upVector as well.
After I tried in playground, I found that only position and upVector property worked in animation(which means the camera actually move during animation).
Other properties, such as rotationQuaternion, alpha, beta(does not move), or absoluteRotation(error report: can not … [object,object]…), do not work when I build animation with them.
The problem is that i’m not so satisfied with the current position and upVector animation, they seem to make camera rotate in a very strange way, espectially upVector property.
Here is the playgroud code:
var createScene = function () {
var scene = new BABYLON.Scene(engine);
scene.beginDirectAnimation()
var light = new BABYLON.PointLight(“Omni”, new BABYLON.Vector3(0, 100, 100), scene);
var camera = new BABYLON.ArcRotateCamera(“Camera”,1.57,0,200, new BABYLON.Vector3(0,0,0), scene);
//camera.setPosition(new BABYLON.Vector3(1, 2, 50));
// camera.attachControl(canvas, true);
//Boxes
var box1 = BABYLON.Mesh.CreateBox("Box1", 10.0, scene);
box1.position.x = -20;
var materialBox = new BABYLON.StandardMaterial("texture1", scene);
materialBox.diffuseColor = new BABYLON.Color3(0, 1, 0);//Green
//Applying materials
box1.material = materialBox;
var animCamPosition = new BABYLON.Animation("animCam", "rotationQuaternion", 24,
// BABYLON.Animation.ANIMATIONTYPE_VECTOR3,)
BABYLON.Animation.ANIMATIONTYPE_QUATERNION);
var keysPosition = [];
keysPosition.push({
frame: 0,
value: new BABYLON.Quaternion(-1,0,0,0)
});
keysPosition.push({
frame: 100,
value: new BABYLON.Quaternion(0,0,0,1)
});
animCamPosition.setKeys(keysPosition);
camera.animations.push(animCamPosition);
scene.beginAnimation(camera, 0, 100, true);
return scene;
}