import { addTo } from './addTo';
import { getClone } from './getClone';
import { getWrapper } from './getWrapper';
/**
 * Place prefab or a group next to each other like tiles.
 * @example
 * ```ts
  const floor = getPrefab({
    id: 'greek_floor_01' as Prefab,
  });
  addTo(root, getTiles(floor, { dim: 4, reps: 5 }));
 * ```
 */
export const getTiles = (toStack, options = {}) => {
    let { repeatsX = 3, repeatsZ = 3, dim = 2 } = options;
    if (options.reps) {
        repeatsX = options.reps;
        repeatsZ = options.reps;
    }
    const wrapper = getWrapper(toStack);
    const offset = repeatsX * dim * 0.5 - dim * 0.5;
    for (let indeX = 0; indeX < repeatsX; indeX++) {
        for (let indeZ = 0; indeZ < repeatsZ; indeZ++) {
            const p = [dim * indeX - offset, 0, dim * indeZ - offset];
            const object = getClone(toStack, { p });
            addTo(wrapper, object);
        }
    }
    return wrapper;
};
//# sourceMappingURL=getTiles.js.map