import { getSpinning, rsd } from '.';
import { getWrapper } from './getWrapper';
/**
 * Helper to animated an objects rotation similar to an asteroid.
 * @example
 * ```
  let rock: HNode = getPrefab({ id: 'rock_01_t3', p: [0, 8, 5] });
  rock = getAsteroidSpin(rock, { seed: 2 });
  rock = getMoving(rock);
  rock = getOrbiting(rock, { duration: 16 });
  world.add(rock);
 * ```
 */
export const getAsteroidSpin = (target, options) => {
    const { seed = undefined, p = undefined, r = undefined, s = undefined } = options || {};
    const minDur = 8;
    const maxDur = 64;
    let asteroid = getWrapper(target, { p, r, s });
    asteroid = getSpinning(asteroid, {
        axis: 'y',
        direction: rsd(seed).randomFromArray([1, -1]),
        duration: rsd(seed).range(minDur, maxDur),
        ...options,
    });
    asteroid = getSpinning(asteroid, {
        axis: 'x',
        direction: rsd(seed).randomFromArray([1, -1]),
        duration: rsd(seed).range(minDur, maxDur),
        ...options,
    });
    asteroid = getSpinning(asteroid, {
        axis: 'z',
        direction: rsd(seed).randomFromArray([1, -1]),
        duration: rsd(seed).range(minDur, maxDur),
        ...options,
    });
    return asteroid;
};
//# sourceMappingURL=getAsteroidSpin.js.map