Source: swcad-js-component-spec/src/tile/index.js

"use strict"

/**
 * ...
 * @memberof componentSpec
 * @namespace tile
 */

const tileInit = ({ jscad, swcadJs }) => {

    const { cuboid } = jscad.primitives
    const { math } = swcadJs.calcs
    const { functions } = swcadJs.data

    const tileStandards = {
        TILE_THICKNESS_LG: math.inchesToMm(9 / 32), // 7.14375 mm
        TILE_THICKNESS_MD: math.inchesToMm(1 / 4), // 6.35 mm
        TILE_THICKNESS_SM: math.inchesToMm(7 / 32), // 5.55625 mm
        TILE_SIZE_MOSAIC: 10,
        TILE_SIZE_SM: math.inchesToMm(3),
        TILE_SIZE_MD: math.inchesToMm(4),
        TILE_SIZE_LG: math.inchesToMm(5),
    }

    const thicknesses = {
        thin: tileStandards.TILE_THICKNESS_SM,
        medium: tileStandards.TILE_THICKNESS_MD,
        thick: tileStandards.TILE_THICKNESS_LG,
    }

    const sizes = {
        mosaic: tileStandards.TILE_SIZE_MOSAIC,
        small: tileStandards.TILE_SIZE_SM,
        medium: tileStandards.TILE_SIZE_MD,
        large: tileStandards.TILE_SIZE_LG,
    }

    const tileModels = {}

    Object.entries(thicknesses).forEach(([thKey, thVal], thIdx) => {
        Object.entries(sizes).forEach(([sKey, sVal], sIdx) => {
            const thicknessLabel = thKey === 'medium' ? '' : ` ${thKey}`;
            const modelName = functions.camelCase(`${sKey}${thicknessLabel}`)
            const modelSize = [sVal, sVal, thVal]

            tileModels[modelName] = {
                name: modelName,
                size: modelSize,
                length: sKey,
                lengthDim: sVal,
                thickness: thKey,
                thicknessDim: thVal,
                geom: cuboid({ size: modelSize }),
            }
        })
    })

    return tileModels
}

module.exports = { init: tileInit }