We made this course for people interested in creating parametric geometry and 3D models in TypeScript programming language. Follow these lecture series to understand how things work and how to achieve your goals.
schoolMade For Beginners
money_offFree
TypeScript
JavaScript Objects
Short introduction to JavaScript objects and few examples showing how they can be used in the real project.
In this lecture we will discuss how JavaScript Objects can be used to structure and simplify your code. This will be a good introduction to discussing classes.
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.
const start = async () => {
function createText() {
return `${this.name} ${this.surname} born ${this.yearOfBirth}`;
}
const person1 = {
name: "Matas",
surname: "Johnson",
yearOfBirth: 1950,
height: 190,
createText
}
const person2 = {
name: "Steve",
surname: "Johnstone",
yearOfBirth: 1970,
height: 180,
createText
}
const person3 = {
name: "Danielle",
surname: "Goldsmith",
yearOfBirth: 1976,
height: 165,
createText
}
const persons = [person1, person2, person3];
const textOptions = new Bit.Advanced.Text3D.Text3DDto();
let index = 0;
for (const person of persons) {
textOptions.text = person.createText();
textOptions.height = person.height / 50;
textOptions.origin = [0, 0, index * 2];
const text = await bitbybit.advanced.text3d.create(textOptions);
bitbybit.draw.drawAnyAsync({
entity: text
});
index++;
}
}
start();