In three.js is better to use classes or functional programming?

Hello to all! I’m new to the forum :raised_hands: I’m learning with the Bruno Simon Three Journey, I’m already in the shaders module.

I’m wondering that Bruno uses javascript classes. Despite of r3f, I want to learn really well Three.js first, I am a front end develop (next, react, typescript) with 5 years of exp, and I’m wondering why Bruno uses javascript classes in Three.js, we can make a Three.js project using functional component, or OOP instead of classes?

And also, what do you recommend right now to make a portfolio, using Three.js or r3f?

Thanks you so much!

Whichever you’re feeling more familiar with - in vanilla javascript, OOP gives a slight feeling of having a someway structured code (although the structure is still arbitrary and chaotic most of the time.) With R3F you have the component-based structure enforced by the framework, so that problem is solved out of the box.

Three.js doesn’t require you to use or not use OOP - you’re free to write top-down code with just a bunch of functions, you can use classes, or any other paradigm you enjoy coding in.

4 Likes

Thank you @mjurczyk for the reply! It is helpful!