Creating a Simple Loft
A loft operation is a fundamental technique in 3D modeling that allows you to create complex surfaces by defining a series of 2D profiles (cross-sections) in space. The software then generates a smooth transitional surface that connects these profiles. This is incredibly useful for modeling organic shapes, aerodynamic bodies, or any object with a varying cross-section.
In this tutorial, we'll walk through the process of creating a simple lofted shape. We will define three distinct elliptical wires at different positions and then use the loft operation to generate a surface that smoothly interpolates between them. We'll demonstrate how to achieve this using Rete, Blockly, and TypeScript, providing a clear understanding of the underlying logic and its implementation in different environments.
The power of lofting comes from its versatility. You can:
- Use different shapes: Combine circles, rectangles, polygons, or even more complex custom curves.
- Vary the number of profiles: More profiles can lead to more detailed and controlled surfaces.
- Adjust profile orientation and scale: Tilting or resizing profiles can dramatically alter the resulting shape.
- Create solids: By setting the
makeSolidoption totrue(where applicable), you can create volumetric bodies instead of just surfaces. - Nr of wire edges: For loft to work correctly in most situations you must ensure that you loft wires that contain the same amount of edges to form topologically coherent faces.
- Order of wires matter: If you reverse the order of wires in the list your loft faces will point to different direction.
- Wire direction matters: If you reverse directions of wires and their edges, your loft faces will point to different direction.

- Rete
- Blockly
- TypeScript
// Import necessary modules from the bitbybit library.
// 'operations' and 'shapes' are for OpenCascade Technology (OCCT) functionalities like lofting and creating wires.
const { operations, shapes } = bitbybit.occt;
// 'draw' module is used for rendering shapes on the canvas.
const { draw } = bitbybit;
// Import Data Transfer Objects (DTOs) for defining OCCT inputs.
// 'EllipseDto' for creating ellipses, 'LoftDto' for loft operation parameters.
const { EllipseDto, LoftDto } = Bit.Inputs.OCCT;
// Import DTO for drawing options.
const { DrawOcctShapeSimpleOptions } = Bit.Inputs.Draw;
// Define a type alias for OCCT shape pointers for better readability.
type TopoDSShapePointer = Bit.Inputs.OCCT.TopoDSShapePointer;
// Create an instance of EllipseDto to define the properties of the first ellipse.
const ellipseOpt = new EllipseDto();
// Set the minor radius of the ellipse.
ellipseOpt.radiusMinor = 4;
// Set the major radius of the ellipse.
ellipseOpt.radiusMajor = 8;
// Create the first elliptical wire. The center defaults to [0,0,0] and direction to [0,1,0] if not specified.
// 'await' is used because shape creation is an asynchronous operation.
const ellipse1 = await shapes.wire.createEllipseWire(ellipseOpt);
// Modify the ellipseOpt for the second ellipse.
// Set the center of the second ellipse.
ellipseOpt.center = [0, 3, 0];
// Set the minor radius for the second ellipse.
ellipseOpt.radiusMinor = 1;
// Set the major radius for the second ellipse.
ellipseOpt.radiusMajor = 4;
// Create the second elliptical wire with the updated options.
const ellipse2 = await shapes.wire.createEllipseWire(ellipseOpt);
// Modify the ellipseOpt for the third ellipse.
// Set the center of the third ellipse.
ellipseOpt.center = [0, 7, 0];
// Set the minor radius for the third ellipse.
ellipseOpt.radiusMinor = 2;
// Set the major radius for the third ellipse.
ellipseOpt.radiusMajor = 6;
// Create the third elliptical wire with the updated options.
const ellipse3 = await shapes.wire.createEllipseWire(ellipseOpt);
// Create an instance of LoftDto to define the parameters for the loft operation.
// The generic type TopoDSShapePointer indicates the type of shapes to be lofted.
const loftOpt = new LoftDto<TopoDSShapePointer>();
// Assign an array of the created ellipse wires to the 'shapes' property of loftOpt.
// These are the profiles that will be connected by the loft.
loftOpt.shapes = [ellipse1, ellipse2, ellipse3];
// Perform the loft operation using the defined options.
// This will create a surface (or shell) connecting the three ellipses.
// 'makeSolid' defaults to false, creating a shell.
const loft = await operations.loft(loftOpt);
// Create an instance of DrawOcctShapeSimpleOptions to define how the lofted shape will be displayed.
const drawOpt = new DrawOcctShapeSimpleOptions();
// Set the precision for drawing the shape. This affects the tessellation quality.
drawOpt.precision = 0.001;
// Set the color of the faces of the lofted shape.
drawOpt.faceColour = "#ff00ff"; // Magenta
// Draw the lofted shape asynchronously using the specified entity and drawing options.
draw.drawAnyAsync({ entity: loft, options: drawOpt });
With these examples, you've learned the basics of creating a lofted surface from a series of wire profiles.
Experiment with these parameters to explore the wide range of forms you can achieve with the loft operation. Happy modeling!
