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();