Functions And Solids
Creating and using functions is such a life saver that you must learn it as soon as possible
In this lecture we will discuss how functions work and how to use them. We will explain the concepts of inputs and outputs. We will also create a small boxy robot model that you can configure further.
The Code
This is the code that you should copy and paste into the editor. You can also type it in yourself. The code is explained in the video.
type Point3 = Bit.Inputs.Base.Point3;
const start = async () => {
bitbybit.draw.drawGridMesh(new Bit.Inputs.Draw.SceneDrawGridMeshDto());
const robot1 = await createRobot([0, 0, 0], 0.7);
const robot2 = await createRobot([0, 0, 4], 1);
const robot3 = await createRobot([0, 0, 8], 0.3);
const robot4 = await createRobot([0, 0, -4], 0.4);
const robot5 = await createRobot([0, 0, -8], 1.5);
const robot6 = await createRobot([0, 0, 12], 0.9);
const drawOptions = new Bit.Inputs.Draw.DrawOcctShapeOptions();
drawOptions.edgeWidth = 1;
drawOptions.faceColour = "#ff00ff";
const compoundedRobots = await bitbybit.occt.shapes.compound.makeCompound({
shapes: [robot1, robot2, robot3, robot4, robot5, robot6]
});
bitbybit.draw.drawAnyAsync({
entity: compoundedRobots,
options: drawOptions
});
}
const createRobot = async (centerInput: Point3, headHeight: number) => {
const robotBody = await bitbybit.occt.shapes.solid.createBox({
width: 1,
length: 1,
height: 2,
center: [centerInput[0], 2 + centerInput[1], centerInput[2]]
});
const robotHead = await bitbybit.occt.shapes.solid.createBox({
width: 0.5,
length: 0.5,
height: headHeight,
center: [centerInput[0], 3 + (headHeight / 2) + centerInput[1], centerInput[2]]
});
const robotLeg1 = await bitbybit.occt.shapes.solid.createBox({
width: 0.25,
length: 0.25,
height: 1,
center: [0.2 + centerInput[0], 0.5 + centerInput[1], centerInput[2]]
});
const robotLeg2 = await bitbybit.occt.shapes.solid.createBox({
width: 0.25,
length: 0.25,
height: 1,
center: [-0.2 + centerInput[0], 0.5 + centerInput[1], centerInput[2]]
});
const robotArms = await bitbybit.occt.shapes.solid.createBox({
width: 3,
length: 0.25,
height: 0.25,
center: [centerInput[0], 2.55 + centerInput[1], centerInput[2]]
});
const robotUnion = await bitbybit.occt.booleans.union({
shapes: [robotBody, robotHead, robotLeg1, robotLeg2, robotArms],
keepEdges: false
});
const robot = await bitbybit.occt.fillets.filletEdges({
shape: robotUnion,
radius: 0.07
});
return robot;
}
start();
Course Lectures
Navigate freely between lectures by clicking on them. Approximate time required: 171 minutes.

Hello World
10 minIn this lecture we will show how to create a very simple program that outputs Hello World in 3D letters.

Why TypeScript
11 minIn this lecture we will discuss why we chose TypeScript as our main programming language.

Some Inspiration
17 minBefore diving into details of programming in TypeScript lets first discuss what the possibilities are and go through some more advanced examples of 3D objects used in our website. Do not worry if they are not making too much sense now, they will later.

Variables And Vectors
17 minWe will begin our journey by discussing some of the basic concepts of programming. Understanding variables and vectors is crucial for creating parametric geometry.

Iterations And Loops
15 minIterating code in loops is one of the most important concepts in programming, lets learn how they work!

Functions And Solids
35 minCreating and using functions is such a life saver that you must learn it as soon as possible

JavaScript Objects
16 minShort introduction to JavaScript objects and few examples showing how they can be used in the real project.

Classes
50 minReal world objects and their behaviours often get represented by their classes. This concept is very important in programming and we will discuss it in this lecture.


