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
{
"id": "rete-v2-json",
"nodes": {
"ellipseWire": {
"id": "ellipseWire",
"name": "bitbybit.occt.shapes.wire.createEllipseWire",
"customName": "ellipse wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"radiusMinor": 4,
"radiusMajor": 8
},
"inputs": {},
"position": [
410,
135
]
},
"ellipseWire2": {
"id": "ellipseWire2",
"name": "bitbybit.occt.shapes.wire.createEllipseWire",
"customName": "ellipse wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"radiusMinor": 1,
"radiusMajor": 4
},
"inputs": {
"center": {
"connections": [
{
"node": "vectorXyz",
"output": "result",
"data": {}
}
]
}
},
"position": [
411,
550
]
},
"vectorXyz": {
"id": "vectorXyz",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 0,
"y": 3,
"z": 0
},
"inputs": {},
"position": [
-14,
588
]
},
"ellipseWire3": {
"id": "ellipseWire3",
"name": "bitbybit.occt.shapes.wire.createEllipseWire",
"customName": "ellipse wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"radiusMinor": 2,
"radiusMajor": 6
},
"inputs": {
"center": {
"connections": [
{
"node": "vectorXyz2",
"output": "result",
"data": {}
}
]
}
},
"position": [
414,
963
]
},
"vectorXyz2": {
"id": "vectorXyz2",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 0,
"y": 7,
"z": 0
},
"inputs": {},
"position": [
-18,
985
]
},
"loft": {
"id": "loft",
"name": "bitbybit.occt.operations.loft",
"customName": "loft",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"makeSolid": false
},
"inputs": {
"shapes": {
"connections": [
{
"node": "createList",
"output": "list",
"data": {}
}
]
}
},
"position": [
1346,
575
]
},
"createList": {
"id": "createList",
"name": "bitbybit.lists.createList",
"customName": "create list",
"async": false,
"drawable": false,
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "ellipseWire",
"output": "result",
"data": {}
},
{
"node": "ellipseWire2",
"output": "result",
"data": {}
},
{
"node": "ellipseWire3",
"output": "result",
"data": {}
}
]
}
},
"position": [
939,
627
]
},
"drawAnyAsync": {
"id": "drawAnyAsync",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "loft",
"output": "result",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "optionsOcctShapeSimple",
"output": "result",
"data": {}
}
]
}
},
"position": [
1833,
751
]
},
"optionsOcctShapeSimple": {
"id": "optionsOcctShapeSimple",
"name": "bitbybit.draw.optionsOcctShapeSimple",
"customName": "options occt shape simple",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"precision": 0.001,
"drawFaces": true,
"faceColour": "#8000ff",
"drawEdges": true,
"edgeColour": "#ffffff",
"edgeWidth": 2,
"drawTwoSided": true,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1
},
"inputs": {},
"position": [
1349,
915
]
}
},
"modules": {}
}
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="ellipse1">ellipse1</variable><variable id="ellipse2">ellipse2</variable><variable id="ellipse3">ellipse3</variable><variable id="ellipses">ellipses</variable><variable id="loft">loft</variable></variables><block type="variables_set" x="-397" y="-446"><field name="VAR" id="ellipse1">ellipse1</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createEllipseWire"><value name="Center"><block type="bitbybit.point.pointXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="RadiusMinor"><block type="math_number"><field name="NUM">4</field></block></value><value name="RadiusMajor"><block type="math_number"><field name="NUM">8</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="ellipse2">ellipse2</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createEllipseWire"><value name="Center"><block type="bitbybit.point.pointXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">3</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="RadiusMinor"><block type="math_number"><field name="NUM">1</field></block></value><value name="RadiusMajor"><block type="math_number"><field name="NUM">4</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="ellipse3">ellipse3</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createEllipseWire"><value name="Center"><block type="bitbybit.point.pointXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">7</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="RadiusMinor"><block type="math_number"><field name="NUM">2</field></block></value><value name="RadiusMajor"><block type="math_number"><field name="NUM">6</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="ellipses">ellipses</field><value name="VALUE"><block type="lists_create_with"><mutation items="3"></mutation><value name="ADD0"><block type="variables_get"><field name="VAR" id="ellipse1">ellipse1</field></block></value><value name="ADD1"><block type="variables_get"><field name="VAR" id="ellipse2">ellipse2</field></block></value><value name="ADD2"><block type="variables_get"><field name="VAR" id="ellipse3">ellipse3</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="loft">loft</field><value name="VALUE"><block type="bitbybit.occt.operations.loft"><value name="Shapes"><block type="variables_get"><field name="VAR" id="ellipses">ellipses</field></block></value><value name="MakeSolid"><block type="logic_boolean"><field name="BOOL">FALSE</field></block></value></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn"><value name="Entity"><block type="variables_get"><field name="VAR" id="loft">loft</field></block></value><value name="Options"><block type="bitbybit.draw.optionsOcctShapeSimple"><value name="Precision"><block type="math_number"><field name="NUM">0.001</field></block></value><value name="DrawFaces"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></value><value name="FaceColour"><block type="colour_picker"><field name="COLOUR">#6600cc</field></block></value><value name="DrawEdges"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></value><value name="EdgeColour"><block type="colour_picker"><field name="COLOUR">#ffffff</field></block></value><value name="EdgeWidth"><block type="math_number"><field name="NUM">2</field></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></xml>
// 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!



