import { addTo, getGroup, getPrefab, getSlice3 } from '.';
export const getWall = (opt = {}) => {
    const val = {
        id: 'cube_01',
        material: 'palette_01_white',
        height: 3,
        width: 3,
        thickness: 0.2,
        wallType: 'PLAIN',
        doorWidth: 1,
        doorHeight: 2,
        windowWidth: 1,
        windowHeight: 2,
        windowUp: 0.6,
        p: [0, 0, 0],
        r: [0, 0, 0],
        s: [1, 1, 1],
        ...opt,
    };
    const wrapper = getGroup(val);
    const type = val.wallType;
    if (type === 'DOOR' || type === 'WINDOW') {
        const doorWidth = val.doorWidth > val.width ? val.width * 0.99 : val.doorWidth;
        const windowHeight = val.windowHeight > val.width ? val.width * 0.99 : val.windowHeight;
        const doorHeight = val.doorHeight > val.height ? val.height * 0.99 : val.doorHeight;
        const bottomScale = type === 'DOOR' ? 0 : val.windowUp / val.height;
        const topScale = type === 'DOOR' ? 1 - doorHeight / val.height : 1 - windowHeight / val.height;
        const centerPartScale = type === 'DOOR' ? doorWidth / val.width : val.windowWidth / val.width;
        const leftPartScale = (1 - centerPartScale) * 0.5;
        const rightPartScale = leftPartScale;
        const leftPart = getSlice3({
            name: 'Left Part',
            p: [val.width - val.width * leftPartScale + val.thickness * 0.5, 0, 0],
            s: [val.width * leftPartScale + val.thickness * 0.5, val.height, val.thickness],
            topScale: 0,
            bottomScale: 1,
            topPrefab: val.id,
            bottomPrefab: val.id,
            material: val.material,
        });
        addTo(wrapper, leftPart);
        const centerPart = getSlice3({
            name: 'Center Part',
            p: [0, 0, 0],
            s: [val.width * centerPartScale, val.height, val.thickness],
            topScale: topScale,
            bottomScale: bottomScale,
            topPrefab: val.id,
            bottomPrefab: val.id,
            material: val.material,
        });
        addTo(wrapper, centerPart);
        const rightPart = getSlice3({
            name: 'Right Part',
            p: [(val.width - val.width * rightPartScale + val.thickness * 0.5) * -1, 0, 0],
            s: [val.width * rightPartScale + val.thickness * 0.5, val.height, val.thickness],
            topScale: 0,
            bottomScale: 1,
            topPrefab: val.id,
            bottomPrefab: val.id,
            material: val.material,
        });
        addTo(wrapper, rightPart);
    }
    else if (type === 'PLAIN') {
        addTo(wrapper, getPrefab({
            id: val.id,
            s: [val.width, val.height, val.thickness],
            material: val.material,
        }));
    }
    return wrapper;
};
//# sourceMappingURL=getWall.js.map