import addLineToScene from '../../builder/geomentries/lines/addLineToScene';
import * as CONSTANTS from '../../../types/world/worldConstants';
import * as Types from "../../../types/world/worldTypes";

function loadInitialLine(
    floorPlanGroupLine: Types.RefGroup,
    lines: Types.RefLines
): void {

    if (!floorPlanGroupLine.current) return

    //////////  Load the Lines initially if there are any  //////////

    floorPlanGroupLine.current.children = [];
    lines.current.forEach((line) => {
        let colour;
        if (line[0][3] && line[1][3] === CONSTANTS.lineConfig.wallName) {
            colour = CONSTANTS.lineConfig.wallColor;
        } else if (line[0][3] && line[1][3] === CONSTANTS.lineConfig.floorName) {
            colour = CONSTANTS.lineConfig.floorColor;
        } else if (line[0][3] && line[1][3] === CONSTANTS.lineConfig.aisleName) {
            colour = CONSTANTS.lineConfig.aisleColor;
        }
        if (colour) {
            addLineToScene(line[0][0], line[1][0], colour, line, floorPlanGroupLine);
        }
    });
}

export default loadInitialLine;
