
typescriptThis example demonstrates how parametric 3D model can be produced by using NURBS framework and CAD features of BitByBit platform. Parametric lamp model can also be saved to STL format and 3D printed.
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();
Editor plans for 3D development, API keys for server-side CAD algorithms
Cloud storage, private projects & 3D algorithms for Bitbybit editors
Run CAD algorithms on managed cloud servers from your own backend applications
Custom software development, dedicated servers & CAD automation at scale.