Got another issue with BABYLON.Animation.
I create an animation using 3 keyframes for a value of 0 to 1.
But when playing the animation, by this time is get to end of animation the values is never 1… as a matter of fact if stops way short of 1.
this is my code for create a Tween Style animation for a float value
public static CreateTweenAnimation(name:string, targetProperty:string, startValue:number, endValue:number, frameRate:number = 30, loopMode:number = BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT):BABYLON.Animation {
const keyFrames:any[] = [];
keyFrames.push({
frame: 0,
value: startValue,
});
keyFrames.push({
frame: frameRate,
value: (startValue > endValue) ? (startValue * 0.5) : (endValue * 0.5),
});
keyFrames.push({
frame: (2 * frameRate),
value: endValue,
});
const result = new BABYLON.Animation(name, targetProperty, frameRate, BABYLON.Animation.ANIMATIONTYPE_FLOAT, loopMode);
result.setKeys(keyFrames);
return result;
}
And i call like this
const tweenAnim:BABYLON.Animation = PROJECT.PortalManager.CreateTweenAnimation("TestTween", "opacity", 0, 1);
const scene:BABYLON.Scene = BABYLON.SceneManager.GetLastCreatedScene();
scene.beginDirectAnimation(blanket.style, [tweenAnim], 0, tweenAnim.getKeys().length, false, speed, ()=>{
console.warn("*** FINISHED FADE TO BLANKET ANIMATION: " + tweenAnim.name);
console.log(blanket.style.opacity);
});
Here is console log shot… It never get to the full 1 value
Is there some kind of quirk when animation a flat value ???