import {resolveEasing} from "../vfx-utils.mjs";

const vfxDrawBackAnimation = {
  setup: (state, params) => {
    params.ease = resolveEasing(params.easing ?? "outBack", params.easingParams ?? 0.8);
    if ( !params.object ) {
      const container = state.projectile?.container;
      if ( container ) {
        container.alpha = 1.0;
        params.object = container.sprites.mesh;
      }
    }
  },
  animate: (t, state, params) => {
    const mesh = params.object;
    if (!mesh) return;
    mesh.anchor.x = Math.mix(0.5, 1.25, params.ease(t));
    mesh.alpha = Math.min(t * 4, 1);
  }
};
export default vfxDrawBackAnimation;
