/Threejs-Projects

Threejs Library Projects

Primary LanguageJavaScript

Three.js - Template

Get started with Three.js to render 3d Web Experience.

Setup

Download Node.js. Run this followed commands:

# Install dependencies (only the first time)
npm install

# Run the local server at localhost:8080
npm run dev

# Run the local server at locat ip
npm run host

# Build for production in the dist/ directory
npm run build

Credits

🤨 What is WebGL?

WebGL is a JavaScript API that renders triangles in a canvas at a remarkable speed. It's compatible with most modern browsers, and it's fast because it uses the Graphic Processing Unit (GPU) of the visitor.

WebGL can draw more than triangles and can also be used to create 2D experiences, but we will focus on 3D experiences using triangles for the course's sake.

The GPU can do thousands of parallel calculations. Imagine that you want to render a 3D model and this model is constituted of 1000 triangles—which, come to think about it, is not that many. Each triangle includes 3 points. When we want to render our model, the GPU will have to calculate the position of these 3000 points. Because the GPU can do parallel calculations, it will handle all the triangles points in one raw.

Once the model's points are well placed, the GPU needs to draw each visible pixel of those triangles. Yet again, the GPU will handle the thousands and thousands of pixels calculations in one go.

The instructions to place the points and draw the pixels are written in what we call shaders. And let me tell you, shaders are hard to master. We also need to provide data to these shaders. For example: how to place the points according to the model transformations and the camera's properties. These are called matrices. We also need to provide data to help colorize the pixels. If there is a light and the triangle is facing that light, it should be brighter than if the triangle isn't.

And this is why native WebGL is so hard. Drawing a single triangle on the canvas would take at least 100 lines of code. Good luck if you want to add perspective, lights, models, and animate everything in that case.

But native WebGL benefits from existing at a low level, very close to the GPU. This enables excellent optimizations and more control.

🤨 What is three.js ?

Three.js is a cross-browser JavaScript library and application programming interface used to create and display animated 3D computer graphics in a web browser using WebGL. The source code is hosted in a repository on GitHub.

See also

Three.js is the most popular JavaScript framework for displaying three-dimensional content on the web. Three.js eliminates the need for a high-end gaming PC or console to display photorealistic 3D graphics. You don't even need to instal any software. With only a smartphone and a web browser, anyone can now experience stunning 3D applications in the palm of their hand.

This incredible library, as well as the vibrant community that surrounds it, are all you need to create games, music videos, scientific and data visualisations, and pretty much anything else you can think of, right in your browser on your laptop, tablet, or smartphone!

three.js

💖 List of my favourite Three.js projects:

(1) bruno-simons Bruno Simon's Portfolio Website
(2) img Coastal World
(3) lusion lusion.co
(4) alt Medal of honor
(5) img Heraclos Game
(6) MIDWAM MIDWAM Company
(7) img Knguru
(8) MIDWAM Enough

Made with 💜 by SahilK-027