Learn Three.js
local graph
Learn Three.js
Section titled “Learn Three.js”chapter_01
Section titled “chapter_01”node-book_learn-three-js_chapter-01-creating-your-first-3d-scene-with-three-js — Creating Your First 3D Scene with Three.js
chapter_02
Section titled “chapter_02”node-book_learn-three-js_chapter-02-the-basic-components-that-make-up-a-three-js-application — The Basic Components that Make up a Three.js Application
chapter_03
Section titled “chapter_03”node-book_learn-three-js_chapter-03-working-with-light-sources-in-three-js — Working with Light Sources in Three.js
chapter_04
Section titled “chapter_04”node-book_learn-three-js_chapter-04-working-with-three-js-materials — Working with Three.js Materials
chapter_05
Section titled “chapter_05”node-book_learn-three-js_chapter-05-learning-to-work-with-geometries — Learning to Work with Geometries
chapter_06
Section titled “chapter_06”node-book_learn-three-js_chapter-06-exploring-advanced-geometries — Exploring Advanced Geometries
chapter_07
Section titled “chapter_07”node-book_learn-three-js_chapter-07-points-and-sprites — Points and Sprites
chapter_08
Section titled “chapter_08”node-book_learn-three-js_chapter-08-creating-and-loading-advanced-meshes-and-geometries — Creating and Loading Advanced Meshes and Geometries
chapter_09
Section titled “chapter_09”node-book_learn-three-js_chapter-09-animations-and-moving-the-camera — Animations and Moving the Camera
chapter_10
Section titled “chapter_10”node-book_learn-three-js_chapter-10-loading-and-working-with-textures — Loading and Working with Textures
chapter_11
Section titled “chapter_11”node-book_learn-three-js_chapter-11-render-postprocessing — Render Postprocessing
chapter_12
Section titled “chapter_12”node-book_learn-three-js_chapter-12-adding-physics-and-sounds-to-your-scene — Adding Physics and Sounds to Your Scene
chapter_13
Section titled “chapter_13”node-book_learn-three-js_chapter-13-working-with-blender-and-three-js — Working with Blender and Three.js
chapter_14
Section titled “chapter_14”node-book_learn-three-js_chapter-14-three-js-together-with-react-typescript-and-web-xr — Three.js Together with React, TypeScript, and Web-XR
Preface
Section titled “Preface”Three.js has become the standard way of creating stunning 3D WebGL content over the last couple of years. In this edition, we’ll look at all the features of Three.js and provide additional content on how to integrate Three.js with Blender, React, TypeScript, and the newest physics engine.
In this book, you’ll learn how to create and animate immersive 3D scenes directly in your browser using the full potential of WebGL and modern browsers.
The book starts with the basic concepts and building blocks used in Three.js and helps you explore these essential topics in detail through extensive examples and code samples. You’ll also learn how to create realistic-looking 3D objects using textures and materials. Besides creating these objects manually, we’ll also explain how to load existing models from an external source. Next, you’ll understand how to easily control the camera using the Three.js built-in camera controls, which will enable you to fly or walk around the 3D scene you’ve created. Later chapters will then show you how to use the HTML5 video and canvas elements as materials for your 3D objects and animate your models. You will learn how to use morph and skeleton-based animation, before understanding how to add physics, such as gravity and collision detection, to your scene. Finally, we’ll explain how to combine Blender with Three.js, how to integrate Three.js with React and TypeScript, and how you can use Three.js to create VR and AR scenes.
By the end of this book, you’ll have gained the skills you need to create 3D-animated graphics using Three.js.
Who this book is for
Section titled “Who this book is for”This book is for JavaScript developers who are looking to learn how to use the Three.js library confidently.
What this book covers
Section titled “What this book covers”Chapter 1, Creating Your First 3D Scene with Three.js, introduces the Three.js library, explains how to set up your development environment, and shows how to create your first application.
Chapter 2, The Basic Components that Make up a Three.js Application, explains the core concepts behind Three.js and introduces the basic components you’ll need for each Three.js application.
Chapter 3, Working with Light Sources in Three.js, goes through all the available light sources you can use in Three.js to add lights to your Three.js scenes.
Chapter 4, Working with Three.js Materials, shows an overview of the different materials you can use when creating the objects you’re visualizing with Three.js.
Chapter 5, Learning to Work with Geometries, explains which basic geometries are provided with Three.js and how you can use and customize them.
Chapter 6, Exploring Advanced Geometries, goes into detail explaining the advanced geometries provided by Three.js.
Chapter 7, Points and Sprites, describes how you can create and manipulate a large number of points and sprites on the screen, and how to change what these points look like.
Chapter 8, Creating and Loading Advanced Meshes and Geometries, gives examples and instructions on how to group and merge objects together, and how to load existing models from external sources.
Chapter 9, Animations and Moving the Camera, talks about the different camera controls provided by Three.js, and explains how animations work in Three.js and how to load animations from external sources.
Chapter 10, Loading and Working with Textures, gives an overview of the different types of textures that are available in Three.js, and how you can use them to configure the Three.js materials.
Chapter 11, Render Postprocessing, describes how you can add post-rendering effects such as blur, bloom, and colorify to your scene.
Chapter 12, Adding Physics and Sounds to Your Scene, introduces the Rapier physics library, which allows you to have objects interact with each other simulating the real world. This chapter also shows how you can add positional sound to your scenes.
Chapter 13, Working with Blender and Three.js, provides information on how you can integrate Blender with Three.js, exchange models, and use Blender to bake specific textures.
Chapter 14, Three.js Together with React, TypeScript, and Web-XR, shows how you can combine Three.js with React and TypeScript, and gives an overview of the support Three.js has for the Web-XR standard to create VR and AR scenes.
To get the most out of this book
Section titled “To get the most out of this book”You don’t need to know much before starting with this book. The only requirement is that you have some basic knowledge of JavaScript. This book provides instructions on how to set up your development environment, install any additional tools and libraries, and run the examples.
| Software covered in the book | Operating system requirements |
|---|---|
| Three.js r147 | Windows, macOS, or Linux |
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Conventions used
Section titled “Conventions used”There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “You can do these steps yourself, or look in the three-ts folder and just run yarn install there to skip this setup.”
A block of code is set as follows:
import './style.css'import { initThreeJsScene } from './threeCanvas'const mainElement = document.querySelector<HTMLDivElement>('#app')if (mainElement) { initThreeJsScene(mainElement)}Any command-line input or output is written as follows:
$ git --versiongit version 2.30.1 (Apple Git-130)Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “For this, we need to create a new debug configuration from the Run | Edit Configurations menu.”
Tips or important notes
Appear like this.
Source: