Rendering 3D Objects in Bitbybit Editors
This guide demonstrates how to use the core "Draw" functionalities across Bitbybit's different editor environments: Rete, Blockly, and TypeScript. The objective is to render a 3D object-specifically, a cube with rounded edges-and customize its appearance.
A filleted cube with its own colours
The script builds a cube, rounds its edges with a fillet, and draws the result with options of its own: blue faces, light red edges, and its vertices drawn as points.
Each editor draws it the same way:
- Rete: the draw any async component, in the palette's
drawcategory under itsdraw asyncheading. - Blockly: the draw any async no return block, in the toolbox under
draw>draw async. The blocks are nested directly, without variables in between. - TypeScript:
bitbybit.draw.drawAnyAsync, with aBit.Inputs.Draw.DrawOcctShapeOptionsfor the options.
- Rete
- Blockly
- TypeScript
Script Source (typescript)
const cubeOptions = new Bit.Inputs.OCCT.CubeDto();
cubeOptions.size = 5;
const cube = await bitbybit.occt.shapes.solid.createCube(cubeOptions);
const filletOptions = new Bit.Inputs.OCCT.FilletDto<Bit.Inputs.OCCT.TopoDSShapePointer>()
filletOptions.shape = cube;
filletOptions.radius = 1;
const roundedCube = await bitbybit.occt.fillets.filletEdges(filletOptions);
const drawOcctOptions = new Bit.Inputs.Draw.DrawOcctShapeOptions();
drawOcctOptions.faceColour = "#0000ff";
drawOcctOptions.edgeColour = "#ff5555";
drawOcctOptions.drawVertices = true;
drawOcctOptions.vertexSize = 0.3;
// The rest of options remain default (initialized inside the instance)
const drawnMesh = await bitbybit.draw.drawAnyAsync({ entity: roundedCube, options: drawOcctOptions })
// drawnMesh is a BabylonJS Mesh when the BabylonJS engine is used; in ThreeJS it is a Group.
