Icosahedron

Following examples show how to create a parametric Icosahedron shape.
function build() {

    let sideLength = 10; // params.sideLength;

    return icosahedron(sideLength);

};

function icosahedron(sideLength){

    //for convenience
    const Vertex = cadlib.Vertex;
    const Edge = cadlib.Edge;
    const Face = cadlib.Face;
    const Wire = cadlib.Wire;
    var gr = (Math.sqrt(5)+1)/2;  //golden ratio
 
    //create an icosahedron with edge length 2 to be scaled up
    //create vertices
    let vxyRect1 = new Vertex(gr, -1, 0);
    let vxyRect2 = new Vertex(gr, 1, 0);
    let vxyRect3 = new Vertex(-gr, 1, 0);
    let vxyRect4 = new Vertex(-gr, -1, 0);
    let vxzRect1 = new Vertex(1, 0, gr);
    let vxzRect2 = new Vertex(1, 0, -gr);
    let vxzRect3 = new Vertex(-1, 0, -gr);
    let vxzRect4 = new Vertex(-1, 0, gr);
    let vyzRect1 = new Vertex(0, -gr, -1);
    let vyzRect2 = new Vertex(0, gr, -1);
    let vyzRect3 = new Vertex(0, gr, 1);
    let vyzRect4 = new Vertex(0, -gr, 1);
 
    //create edges
    let eTopPenta1 = new Edge().createLine(vxyRect2, vxzRect2);
    let eTopPenta2 = new Edge().createLine(vxzRect2, vxzRect3);
    let eTopPenta3 = new Edge().createLine(vxzRect3, vxyRect3);
    let eTopPenta4 = new Edge().createLine(vxyRect3, vyzRect3);
    let eTopPenta5 = new Edge().createLine(vyzRect3, vxyRect2);
    let ePeak1 = new Edge().createLine(vxyRect2, vyzRect2);
    let ePeak2 = new Edge().createLine(vxzRect2, vyzRect2);
    let ePeak3 = new Edge().createLine(vxzRect3, vyzRect2);
    let ePeak4 = new Edge().createLine(vxyRect3, vyzRect2);
    let ePeak5 = new Edge().createLine(vyzRect3, vyzRect2);
 
    let eMid1To5 = new Edge().createLine(vxzRect1, vxyRect2);
    let eMid1To1 = new Edge().createLine(vxyRect2, vxyRect1);
    let eBotPenta1 = new Edge().createLine(vxzRect1, vxyRect1);
    let eMid2To1 = new Edge().createLine(vxzRect2, vxyRect1);
    let eMid2To2 = new Edge().createLine(vxzRect2, vyzRect1);
    let eBotPenta2 = new Edge().createLine(vxyRect1, vyzRect1);
    let eMid3To2 = new Edge().createLine(vxzRect3, vyzRect1);
    let eMid3To3 = new Edge().createLine(vxzRect3, vxyRect4);
    let eBotPenta3 = new Edge().createLine(vyzRect1, vxyRect4);
    let eMid4To3 = new Edge().createLine(vxyRect3, vxyRect4);
    let eMid4To4 = new Edge().createLine(vxzRect4, vxyRect3);
    let eBotPenta4 = new Edge().createLine(vxyRect4, vxzRect4);
    let eMid5To4 = new Edge().createLine(vyzRect3, vxzRect4);
    let eBotPenta5 = new Edge().createLine(vxzRect4, vxzRect1);
    let eMid5To5 = new Edge().createLine(vxzRect1, vyzRect3);
 
    let eTrough1 = new Edge().createLine(vxyRect1, vyzRect4);
    let eTrough2 = new Edge().createLine(vyzRect1, vyzRect4);
    let eTrough3 = new Edge().createLine(vxyRect4, vyzRect4);
    let eTrough4 = new Edge().createLine(vxzRect4, vyzRect4);
    let eTrough5 = new Edge().createLine(vxzRect1, vyzRect4);
 
    //create faces and wires
    let fPeak1 = new Face([new Wire([eTopPenta1, ePeak1, ePeak2])]);
    let fPeak2 = new Face([new Wire([eTopPenta2, ePeak2, ePeak3])]);
    let fPeak3 = new Face([new Wire([eTopPenta3, ePeak3, ePeak4])]);
    let fPeak4 = new Face([new Wire([eTopPenta4, ePeak4, ePeak5])]);
    let fPeak5 = new Face([new Wire([eTopPenta5, ePeak5, ePeak1])]);
 
    let fMidBot1 = new Face([new Wire([eBotPenta1, eMid1To5, eMid1To1])]);
    let fMidTop1 = new Face([new Wire([eTopPenta1, eMid1To1, eMid2To1])]);
    let fMidBot2 = new Face([new Wire([eBotPenta2, eMid2To1, eMid2To2])]);
    let fMidTop2 = new Face([new Wire([eMid3To2, eMid2To2, eTopPenta2])]);
    let fMidBot3 = new Face([new Wire([eBotPenta3, eMid3To2, eMid3To3])]);
    let fMidTop3 = new Face([new Wire([eMid4To3, eMid3To3, eTopPenta3])]);
    let fMidBot4 = new Face([new Wire([eMid4To4, eMid4To3, eBotPenta4])]);
    let fMidTop4 = new Face([new Wire([eTopPenta4, eMid4To4, eMid5To4])]);
    let fMidBot5 = new Face([new Wire([eMid5To5, eMid5To4, eBotPenta5])]);
    let fMidTop5 = new Face([new Wire([eTopPenta5, eMid5To5, eMid1To5])]);
 
    let fTrough1 = new Face([new Wire([eBotPenta1, eTrough5, eTrough1])]);
    let fTrough2 = new Face([new Wire([eBotPenta2, eTrough1, eTrough2])]);
    let fTrough3 = new Face([new Wire([eBotPenta3,eTrough2, eTrough3])]);
    let fTrough4 = new Face([new Wire([eBotPenta4, eTrough3, eTrough4])]);
    let fTrough5 = new Face([new Wire([eBotPenta5, eTrough4, eTrough5])]);
 
    //create shell and solid
    let topShell = cadlib.makeShell([fPeak1, fPeak2, fPeak3, fPeak4,fPeak5, fMidBot1, fMidTop1, fMidBot2, fMidTop2, fMidBot3, fMidTop3, fMidBot4, fMidTop4, fMidBot5, fMidTop5, fTrough1, fTrough2, fTrough3, fTrough4, fTrough5]);
    let solid = cadlib.makeSolidFromShells([topShell]);
    solid = cadlib.fixShape(solid);
 
    //scale to parameter side length
    let scFactor = sideLength/2;
    //let scaleTransf = cadlib.createScaleTransform(scFactor, {x:0, y:0, z:0});
    //solid.transform(scaleTransf, false);
    solid = cadlib.scale(solid, scFactor, {x:0, y:0, z:0});
    return solid;
    
}