Examle in TypeScript

Examle in TypeScript script details
Type
Typescript logo image
typescript
App Version
0.13.0
Visibility
public
Date Created
Mar 19, 2021, 10:05:46 AM
Last Edit Date
Dec 5, 2023, 6:00:36 PM

Script Details

The Code
const Inputs = Bit.Inputs; let start = async () => { const isocurveSegments = 70; const isocurveSubdivisions = 41; const verticalIsocurveRadius = 0.1; const downloadStl = false; const profiles = [ bitbybit.verb.curve.ellipse.createEllipse({ center: [0, 0, 0], xAxis: [2, -0.5, 2], yAxis: [0, -0.5, 2], }), bitbybit.verb.curve.ellipse.createEllipse({ center: [0, 3, 0], xAxis: [2, 0, 0], yAxis: [0, 0, 4], }), bitbybit.verb.curve.ellipse.createEllipse({ center: [0, 6, 0], xAxis: [4, 0, 0], yAxis: [0, 0, 2], }), bitbybit.verb.curve.ellipse.createEllipse({ center: [0, 12, 0], xAxis: [1, 0, 0], yAxis: [0, 0, 2], }), bitbybit.verb.curve.ellipse.createEllipse({ center: [0, 16, 0], xAxis: [2, 0.5, 0], yAxis: [0, 0.5, 2], }), ]; const surface = bitbybit.verb.surface.createSurfaceByLoftingCurves({ curves: profiles, degreeV: 3, }); const allIsocurves = bitbybit.verb.surface.isocurvesSubdivision({ surface, isocurveSegments, includeFirst: true, includeLast: true, useV: false, }); const hullSolids = await Promise.all(allIsocurves.map(async (curve) => { const centers = bitbybit.verb.curve.divideByEqualArcLengthToPoints({ curve, subdivision: isocurveSubdivisions, }); const spheres = await bitbybit.jscad.shapes.spheresOnCenterPoints({ centers, radius: verticalIsocurveRadius, segments: 4, }); return bitbybit.jscad.hulls.hullChain({ meshes: spheres, }); })); const drawSolidsInput = new Inputs.Draw.DrawBasicGeometryOptions(); drawSolidsInput.colours = '#ffffff'; await bitbybit.draw.drawAnyAsync({ entity: hullSolids, options: drawSolidsInput }); if (downloadStl) { await bitbybit.jscad.downloadSolidsSTL({ meshes: hullSolids, fileName: 'bitbybit-model', }); } } start();