Discover Three.js: Intro and Study Guide
Tags: beginners, learning, webdev, threejs
Published: 2023-10-18 10:07:43


There are many ways to approach learning Three.js. You can start by reading the documentation, watching tutorials, or taking online courses. However, it can be challenging to find the right resources and know where to begin. This study guide provides a basic roadmap for beginners to start learning Three.js. It covers essential concepts, topics, and actionable steps for effective learning. Make sure to follow the provided resources for detailed explanations and practical examples.

## What is Three.js?

It is a JavaScript library and API that works seamlessly across different web browsers. It's primarily used for creating and showcasing interactive 3D graphics using WebGL.

Three.js enables you to apply textures and materials to your objects. It also provides various light sources to illuminate your scene, advanced postprocessing effects, custom shaders, etc.

Here are some examples of what you can build with Three.js and its ecosystem:

- [Three.js Examples](https://threejs.org/examples/) - Official examples from the Three.js repository.
- [Three.js Journey](https://threejs-journey.xyz/) - A course by Bruno Simon that teaches you how to build 3D scenes using Three.js.
- [Three.js Official Website](https://threejs.org/) - The official website of Three.js.
- [ShaderToy](https://www.shadertoy.com/) - A site to showcase some of the best shaders.
- [Hadaka.jp](https://hadaka.jp/) - Company website that uses Three.js to create a 3D experience.
- [Elysium](https://elysium.thebenezer.com/) - A 3D experience that uses Three.js and WebGL.
- [Lost for You](https://lostforyou.com/) - A 3D experience that uses Three.js and WebGL.
- [Akella's YouTube Streams](https://www.youtube.com/@akella_/streams) - A YouTube channel that showcases some of the best Three.js projects.

## What is React Three Fiber?

Im sure that if you have some level of interest in Three.js  you have heard about (R3F) React Three Fiber (or you will eventually) and you are wondering what is it and why would you use it.  I will try to explain it in a simple way.

React-three-fiber, often referred to as R3F, It's a JavaScript library that builds on top of React and leverages the power of WebGL and Three.js. It's a powerful tool for both web and React Native development.

So, why should you consider React Three Fiber? It makes building dynamic 3D scenes much easier by allowing you to create declarative, reusable components. This approach brings clean and reactive coding practices to 3D graphics and opens up opportunities for integrating various packages for state management, animation, and gestures.

React Three Fiber acts as a bridge between React and Three.js, making it easy to build interactive 3D web applications without getting bogged down in Three.js's specifics. It remains compatible with different versions of Three.js, providing consistency in behavior.

If you're already familiar with React, you'll find it easy to get started with React Three Fiber. It's a great way to learn Three.js and WebGL while building interactive 3D scenes. and if you want to dive deeper into the world of 3D graphics, you can always use Three.js directly.
to learn a bit more about React Three Fiber, check out the following resources: [React Three Fiber Documentation](https://docs.pmnd.rs/react-three-fiber/getting-started/introduction) and [I Wish I Knew This Before Using React Three Fiber](https://www.youtube.com/watch?v=DPl34H2ISsk)

## How to get started with Three.js?

With the basic info out of the way, let's get started with Three.js. The following sections provide a step-by-step guide for learning Three.js. It covers the essential concepts, topics, and actionable steps for effective learning. Make sure to follow the provided resources for detailed explanations and practical examples.

| Key Concepts     | Important Topics         | Actionable Steps for Effective Learning                                                                                                                                                                          |
|------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1. WebGL         | WebGL rendering pipeline | - Familiarize yourself with the basics of WebGL and its rendering pipeline.                                                                                                                                     |
|                  |                          | - Learn about vertex and fragment shaders and how they contribute to the rendering process.                                                                                                                     |
|                  |                          | - Understand how to create and manipulate WebGL contexts and buffers.                                                                                                                                           |
|                  |                          | - Practice rendering simple shapes using WebGL.                                                                                                                                                                 |
|                  |                          | - Resources:                                                                                                                                      |
|                  |                          |   - [WebGL Fundamentals](https://webglfundamentals.org/)                                                                                        |
|                  |                          |   - [MDN WebGL tutorial](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial)                                                                                                                |
|                  |                          |   - [Awesome WebGL GitHub Repository](https://github.com/sjfricke/awesome-webgl)                                                                                                           |
|                  |                          |   - [The Book of Shaders](https://thebookofshaders.com/)                                                                                                           |
| 2. Three.js      | Basics of Three.js       | - Learn the fundamental concepts of Three.js, such as scenes, cameras, and renderers.                                                                                                                         |
|                  |                          | - Understand how to create and manipulate geometries, materials, and textures in Three.js.                                                                                                                     |
|                  |                          | - Explore different types of lights and shadows in Three.js.                                                                                                                                                   |
|                  |                          | - Practice creating and animating 3D objects using Three.js.                                                                                                                                                   |
|                  |                          | - Resources:                                                                                                                                      |
|                  |                          |   - [Three.js Documentation](https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene)                                                                                                    |
|                  |                          |   - [Awesome Three.js GitHub Repository](https://github.com/AxiomeCG/awesome-threejs)                                                                                                    |
|                  |                          |   - [Discover Three.js](https://discoverthreejs.com/)                                                                                                    |
|                  |                          |   - [Three.js Fundamentals](https://threejs.org/manual/#en/fundamentals)                                                                                    |
| 3. Interaction   | User input and controls  | - Learn how to handle user interactions, such as mouse and keyboard events, in Three.js.                                                                                                                      |
|                  |                          | - Explore different types of controls, such as OrbitControls and TrackballControls, for navigating and manipulating the scene.                                                                                 |
|                  |                          | - Understand how to implement picking and raycasting for object selection and interaction.                                                                                                                     |
|                  |                          | - Practice adding interactivity to your Three.js applications.                                                                                                                                                 |
|                  |                          | - Resources:                                                                                                                                      |
|                  |                          |   - [Interactive 3D Graphics course](https://www.udacity.com/course/interactive-3d-graphics--cs291) (Note: Some parts may require WebGL knowledge)                                                          |
| 4. Optimization  | Performance and best     | - Learn techniques for optimizing rendering performance in Three.js, such as efficient rendering, reducing draw calls, and implementing level of detail (LOD) techniques.                                    |
|                  | practices                 | - Understand how to use shaders for advanced visual effects and performance improvements.                                                                                                                       |
|                  |                          | - Explore tools like the Chrome DevTools for profiling and debugging Three.js applications.                                                                                                                     |
|                  |                          | - Practice optimizing your Three.js projects for better performance.                                                                                                                                            |
|                  |                          | - Resources:                                                                                                                                      |
|                  |                          |   - [Optimizing WebGL Performance](https://www.soft8soft.com/docs/manual/en/introduction/Optimizing-WebGL-performance.html)                                                                                         |
|                  |                          |   - [Three.js Performance Tips](https://discoverthreejs.com/tips-and-tricks/)                                                                    |

Note: This study guide is not meant to be exhaustive. It provides a basic roadmap for beginners to start learning Three.js. You can always explore other topics and resources to expand your knowledge.