import { getTween } from '.';
/**
 * Make something flap or wiggle
 * @example
 * ```ts
  // Basic flapping
  let spr: HNode = getPrefab({ id: 'sphere_01', p: [3, 1, 10], r: [0, 0, 40] });
  spr = getFlapping(spr);
  world.add(spr);

  // Create a wing of a meringue
  const flapWrap = getGroup({
    children: [getPrefab({ id: 'meringue_01', r: [30, 180, 180], p: [0, 2, 0], s: [0.1, 1, 1] })],
    p: [0, 0, 5],
    r: [0, 0, 20],
  });
  addTo(world, getFlapping(flapWrap, { angle: 20, axis: 'x', duration: 0.5 }));
 * ```
 * ![flapping](https://user-images.githubusercontent.com/1092077/214518839-3786371d-9acf-44bb-b128-da56f7653157.gif)
 */
export const getFlapping = (target, options = {}) => {
    const { autoWrap = true, p = undefined, r = undefined, s = undefined, angle = 10, axis = 'x', duration = 1, progress = 0, } = options;
    let angVec = [0, 0, angle];
    if (axis === 'z')
        angVec = [angle, 0, 0];
    if (axis === 'y')
        angVec = [0, angle, 0];
    // Create key frames
    const kf = [
        { ts: 0, r },
        { ts: 1, r: [angVec[0] * -1, angVec[1] * -1, angVec[2] * -1] },
    ];
    return getTween(target, kf, { duration, progress, autoWrap, p, r, s });
};
//# sourceMappingURL=getFlapping.js.map