/**
 * Distribute objects around a point.
 * @param  radius optional distance from center, default = 5
 * @param  numberOfItems, optional number of items to distribute
 * @param  faceCenter optional if the items should rotate to face the center
 * @param  fn optional function to call on each item
 * @param  degToRotate optional degrees to rotate, can be anything, ex: 180 or 720, default 360
 * @example
 * ```
  placeInCircle({
    radius: 4,
    numberOfItems: 10,
    onEach: (data: IPlaceInCircleForEachOptions) => {
      const prefab = getPrefab({
        p: data.p,
        r: data.r,
      });
      addTo(root, prefab);
    },
  });
 * ```
 */
export const placeInCircle = (opt) => {
    const { radius = 5, numberOfItems = 5, faceCenter = true, onEach = ({}) => { }, degToRotate = 360, offset = 0, itemOffset = 0, ellipseX = 1, ellipseZ = 1, } = opt;
    const a = radius * ellipseX;
    const b = radius * ellipseZ;
    const res = [];
    for (let i = 0; i < numberOfItems; i++) {
        const angle = (degToRotate * i) / numberOfItems + offset;
        const radians = angle * (Math.PI / 180);
        const x = a * Math.cos(radians);
        const z = b * Math.sin(radians);
        const progress = i / (numberOfItems - 1);
        const degrees = faceCenter ? radians * (-180 / Math.PI) : 0;
        const data = {
            p: [x, 0, z],
            r: [0, degrees - itemOffset, 0],
            progress,
            index: i,
        };
        res.push(data);
        onEach(data);
    }
    return res;
};
//# sourceMappingURL=placeInCircle.js.map