import { addTo } from './addTo';
import { getGroup } from './getGroup';
import { getPrefab } from './getPrefab';
import { getWall } from './getWall';
export const getRoom = (opt = {}) => {
    const val = {
        height: 5,
        dim: 5,
        floorThickness: 0.2,
        roof: true,
        wallThickness: 0.1,
        doorWidth: 1.5,
        doorHeight: 2.5,
        windowWidth: 1.5,
        windowHeight: 2.5,
        windowUp: 0.5,
        wallPrefab: 'cube_01',
        wallMaterial: 'palette_01_white',
        floorPrefab: 'cube_01',
        floorMaterial: 'palette_02_silver',
        wallTypes: ['DOOR', 'WINDOW', 'DOOR', 'PLAIN'],
        p: [0, 0, 0],
        r: [0, 0, 0],
        s: [1, 1, 1],
        ...opt,
    };
    const wrapper = getGroup(val);
    const width = val.dim;
    const depth = val.dim;
    const floor = getPrefab({
        name: 'floor',
        material: val.floorMaterial,
        id: val.floorPrefab,
        s: [width + val.wallThickness, val.floorThickness, depth + val.wallThickness],
        p: [0, val.floorThickness * -2, 0],
    });
    addTo(wrapper, floor);
    const wallSettings = {
        blockPrefab: val.wallPrefab,
        thickness: val.wallThickness,
        height: val.height,
        doorWidth: val.doorWidth,
        doorHeight: val.doorHeight,
        windowUp: val.windowUp,
        windowWidth: val.windowWidth,
        windowHeight: val.windowHeight,
        parent: wrapper,
        width: width,
        material: val.wallMaterial,
    };
    if (wallSettings.height < wallSettings.windowHeight + wallSettings.windowUp ||
        wallSettings.height < wallSettings.doorHeight) {
        const extra = 1;
        wallSettings.height =
            wallSettings.windowHeight + wallSettings.windowUp < wallSettings.doorHeight
                ? wallSettings.doorHeight + extra
                : wallSettings.windowHeight + wallSettings.windowUp + extra;
        console.warn("Room 'Height' to low, Height is lower than height of windows and/or doors. Height is recalculated based on window and door heights to: " +
            wallSettings.height +
            '.');
    }
    if (val.roof) {
        const roof = getPrefab({
            name: 'roof',
            material: val.wallMaterial,
            id: val.wallPrefab,
            s: [width + val.wallThickness, val.wallThickness, depth + val.wallThickness],
            p: [0, wallSettings.height * 2, 0],
        });
        addTo(wrapper, roof);
    }
    const wall_N = getWall({
        ...{
            name: 'wallNorth',
            wallType: val.wallTypes[0],
            p: [0, 0, depth],
        },
        ...wallSettings,
    });
    addTo(wrapper, wall_N);
    const wall_E = getWall({
        ...{
            name: 'wallEast',
            wallType: val.wallTypes[1],
            r: [0, -90, 0],
            p: [depth * -1, 0, 0],
        },
        ...wallSettings,
    });
    addTo(wrapper, wall_E);
    const wall_S = getWall({
        ...{
            name: 'wallSouth',
            wallType: val.wallTypes[2],
            r: [0, 180, 0],
            p: [0, 0, depth * -1],
        },
        ...wallSettings,
    });
    addTo(wrapper, wall_S);
    const wall_W = getWall({
        ...{
            name: 'wallWest',
            wallType: val.wallTypes[3],
            r: [0, 90, 0],
            p: [depth, 0, 0],
        },
        ...wallSettings,
    });
    addTo(wrapper, wall_W);
    return wrapper;
};
//# sourceMappingURL=getRoom.js.map