import AnimationTrack from "../../../../animation/keyed2/AnimationTrack.js";
import TransitionFunctions from "../../../../animation/TransitionFunctions.js";
import { playAnimation } from "./playAnimation.js";
import { updateAnimationState } from "./updateAnimationState.js";

//build up animation track
const ANIMATION_TRACK_APPEAR = new AnimationTrack(["alpha", "scale"]);
ANIMATION_TRACK_APPEAR.addKey(0, [0.2, 0.95]);
ANIMATION_TRACK_APPEAR.addKey(0.1, [1, 1]);

ANIMATION_TRACK_APPEAR.addTransition(0, TransitionFunctions.EaseIn);

/**
 *
 * @param {View} view
 * @param {EntityComponentDataset} ecd
 * @returns {Promise<View>}
 */
export function animateAppearance(view, ecd) {
    return playAnimation(ANIMATION_TRACK_APPEAR, view, updateAnimationState, ecd);
}