Scaling

In this example we will clone the original solid to which transformation is applied. Combining original object and its clone helps in visualizing the scaling operation.

function build() {


    //create cylinder lying on the X-Z plane. 

    let s1 = cadlib.cylinder({radius:5, height:1});

    //Move the shape on +Y axis by 30. 
    //Scaling factor is set to 4. 

	let xform = {
        position: new Vec3(0, 30, 0),
        scale: {factor:4}
    };
    
    //create transformation object
    let t = cadlib.createTransformation(xform);
    
    //return clonned object
    let s2 = s1.transform(t, true);
    
    //return fused solid
    return cadlib.fuse([s1, s2]);
    
}