three.js is a free, MIT-licensed JavaScript library that draws 3D graphics in the browser. It sits on top of WebGL 2 and WebGPU so you don’t have to write either by hand. The current release is r187 (30 October 2026). This guide starts with a single HTML file and takes you to a generative sketch, using code written for that version.
Sketch notes
- Every three.js scene needs a Scene, a Camera, a Renderer, at least one Mesh (Geometry plus Material), and usually lights.
- You can start without npm: an import map pinned to [email protected] on jsDelivr is enough.
- WebGPURenderer comes from ‘three/webgpu’ and falls back to WebGL 2 on its own. Compute features don’t survive that fallback.
- Most broken tutorials fail because of version changes: examples/js went in r148, and the build/three.js and build/three.min.js files went in r160.
- React Three Fiber is a React renderer built on three.js. It is not part of three.js, so learning plain JavaScript first pays off.
Fact-checked
We checked these key facts against the sources named, on December 02, 2026:
- Ricardo Cabello, known online as mrdoob, created it, and it has been developed in the open on GitHub since 2010 (source: github.com)
- Camera: 60° field of view, window aspect, near 0.1, far 100 const camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 0.1, 100); camera.position.set(0, 1.5, 4); // 3 (source: threejs.org)
- Read the installation, fundamentals and responsive pages first (source: threejs.org)
What is three.js? The 30-second answer
three.js is a JavaScript 3D library that turns objects like “a box, lit from the left, seen through a camera” into GPU draw calls through WebGL 2 or WebGPU. Ricardo Cabello, known online as mrdoob, created it, and it has been developed in the open on GitHub since 2010. The project ships a new numbered release roughly every month, and the latest is r187.
According to the project’s GitHub README, current builds include two renderers, WebGL and WebGPU. SVG and CSS3D renderers are available as addons. Older descriptions that mention a “Canvas 2D renderer”, like the boilerplate on download mirrors, are years out of date.
Is three.js part of React? Does it use WebGPU?
No, three.js has nothing to do with React. It is plain JavaScript and runs in any page, framework or no framework. React Three Fiber, from the pmndrs collective, is a separate library that lets React render three.js objects.
Yes, three.js now has a WebGPU path. WebGPURenderer, imported from ‘three/webgpu’, uses WebGPU when the browser supports it and switches to a WebGL 2 backend automatically when it doesn’t.
Why not write WebGL or WebGPU by hand?
Raw WebGL takes around a hundred lines before one shaded triangle appears: buffers, shader compilation, attribute pointers, matrices. Raw WebGPU takes even more setup. three.js packs all of that into a few objects, and it still lets you drop down to custom shaders when you need to. If you know p5.js, the trade-off will feel familiar. You give up some control and get speed of expression back, and its WEBGL mode is a gentle step towards what three.js does at a larger scale.
Who uses it
Agencies build award-site experiences with it. Brands use it for product configurators. Indie developers make browser games, and artists use it for generative and audiovisual work. Awwwards keeps a curated three.js collection, which held 119 sites as of December 2026. Bruno Simon’s drivable portfolio at bruno-simon.com remains one of the most widely shared examples of the library.
Did you know?
The official three.js homepage features browser ports of Quake, Doom and Descent made by Mr.doob himself, all running on three.js.
The mental model: six objects behind every scene
Every three.js scene, from a spinning cube to an award-winning site, is built from the same six things: a Scene, a Camera, a Renderer, Meshes (Geometry plus Material), Lights and an animation loop. Once these click, the docs stop feeling like a wall of class names.
| Object | What it does | Typical class |
|---|---|---|
| Scene | The container that holds everything you want drawn | THREE.Scene |
| Camera | The viewpoint: field of view, aspect ratio, near and far clipping planes | THREE.PerspectiveCamera(fov, aspect, near, far) |
| Renderer | Turns the scene and camera into pixels on a <canvas> element |
THREE.WebGLRenderer or WebGPURenderer |
| Geometry | The shape: vertices, normals, UVs | BoxGeometry, SphereGeometry, BufferGeometry |
| Material | The surface: colour, roughness, how it reacts to light | MeshStandardMaterial, MeshBasicMaterial |
| Mesh | Geometry plus Material, placed in the scene | THREE.Mesh(geometry, material) |
| Lights | Illumination for materials that need it | AmbientLight, DirectionalLight, PointLight |
| Loop | Updates and re-renders every frame | renderer.setAnimationLoop(fn) |
The scene graph and transforms
Every object has position, rotation and scale, and any object can hold children. If you add a moon to a planet mesh and then rotate the planet, the moon orbits with it. That parent-child tree is the scene graph, and it is how you build anything that moves in parts: an arm, a solar system, a swarm of instances in a group.
Cameras are objects too. camera.lookAt(0, 0, 0) points the camera at a target, and the lookAt matrix together with the view frustum decides what ends up on screen.
Materials that need light vs ones that don’t
MeshBasicMaterial and MeshNormalMaterial ignore lights and always show up. MeshStandardMaterial and MeshPhysicalMaterial are physically based, so with no light in the scene they render black. That one fact explains most “my scene is black” posts on the forum.
Units, coordinates and the right-handed Y-up world
three.js uses a right-handed coordinate system: +X to the right, +Y up, and +Z towards you out of the screen. Units have no fixed meaning, but glTF models and physically based lights assume 1 unit = 1 metre, so sticking to metres saves you scaling headaches later. A new camera sits at the origin looking down −Z. If you never move it, it sits inside anything else you place at the origin.
Your first scene in one HTML file, no build tools

The fastest way to start is one index.html that loads three.js from jsDelivr through an import map. That follows the official installation manual’s CDN route. Copy this, serve it locally and you get a lit, orbitable cube.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>First three.js scene</title>
<style>body { margin: 0; } canvas { display: block; }</style>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}
}
</script>
</head>
<body>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
// 1. Scene
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x111111);
// 2. Camera: 60° field of view, window aspect, near 0.1, far 100
const camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 0.1, 100);
camera.position.set(0, 1.5, 4);
// 3. Renderer
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
// 4. Mesh = Geometry + Material
const cube = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
new THREE.MeshStandardMaterial({ color: 0xff6a3d, roughness: 0.4 })
);
scene.add(cube);
// 5. Lights: soft fill plus a key light
scene.add(new THREE.AmbientLight(0xffffff, 0.4));
const sun = new THREE.DirectionalLight(0xffffff, 2);
sun.position.set(3, 4, 5);
scene.add(sun);
// Drag to orbit
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
// 6. Animation loop (time is in milliseconds)
renderer.setAnimationLoop((time) => {
cube.rotation.x = time / 2000;
cube.rotation.y = time / 1000;
controls.update();
renderer.render(scene, camera);
});
// Keep the canvas sharp and undistorted on resize
addEventListener('resize', () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
</script>
</body>
</html>
Studio tip
Run a local server instead of double-clicking the file: npx vite in the folder, or the Live Server extension in VS Code. Opening index.html through file:// makes module imports and texture loads fail because of CORS rules.
The import map, line by line
Browsers only understand module imports that are full URLs or relative paths. The bare word 'three' means nothing to them. The <script type="importmap"> block tells the browser that 'three' means the r187 module build on jsDelivr. Any import that starts with 'three/addons/' resolves inside the examples/jsm/ folder of that same version. The trailing slash on "three/addons/" matters, because it is what makes the entry work as a folder prefix.
This answers a question that comes up on discourse.threejs.org all the time: “Why does three.js require an import map?” It doesn’t strictly need one. The addon files contain import ... from 'three', though, and the import map is what lets those internal imports resolve without a bundler.
Studio tip
Pin one exact version, such as [email protected], in both import map lines, and load both from the same CDN. If you mix versions or CDNs, the browser loads two copies of three.js. That produces strange bugs, such as instanceof checks failing and the console warning about multiple instances.
Adding OrbitControls and GLTFLoader from three/addons
Anything in the repo’s examples/jsm folder is an addon. You import it by path:
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
That is the complete answer to “How do I import addons like OrbitControls without npm?” No separate script tags and no global THREE.OrbitControls.
Handling window resize and devicePixelRatio
There are three steps on resize: update camera.aspect, call camera.updateProjectionMatrix(), and call renderer.setSize(). Capping the pixel ratio at 2 stops a phone with a 3× screen from rendering more than twice the pixels you need for little visible gain. setAnimationLoop is preferable to a hand-written requestAnimationFrame. The official examples use it, and WebXR sessions need it.
Setting up a real project with npm and Vite
For anything bigger than a sketch, use npm and Vite. You get hot reload, tree-shaking and a production build. The setup takes about two minutes.
Quick steps: a three.js project with Vite
- Run
npm create vite@latest my-scene -- --template vanilla. - Run
cd my-sceneand thennpm install three --save-exact, which installs the current published version. - Replace main.js with the module code from the HTML example.
- Run
npm run devand open the local URL. - Run
npm run buildwhen you’re ready to deploy.
With a bundler, the import paths stay the same as in the CDN version: import * as THREE from 'three' and import { OrbitControls } from 'three/addons/controls/OrbitControls.js'. The package’s export map handles the resolution, so code moves between the two setups unchanged.
How release numbers map to npm versions
three.js versions follow the pattern rNNN, and the npm package mirrors that as 0.NNN.x. So r187 corresponds to the 0.187.x line, but check npm for the versions actually published. The leading zero does not mean the library is unfinished. It reflects the fact that any monthly release can contain breaking changes, which is why pinning an exact version beats relying on a caret range.
TypeScript types (@types/three)
Types ship separately: npm install -D @types/three. The three-types project releases them in step with each three.js version, so keep the two version numbers matched.
Loading assets from /public
Vite serves anything in /public from the site root. A model at public/models/robot.glb loads as loader.load('/models/robot.glb', ...) in development and in the production build.
WebGL or WebGPU? Choosing a renderer in December 2026

For a first project today, WebGLRenderer is still the simplest and most predictable choice. Choose WebGPURenderer when you want TSL materials, compute shaders or the new drawing pipelines, because that is where the project’s effort is going.
| Aspect | WebGLRenderer | WebGPURenderer |
|---|---|---|
| Import | 'three' |
'three/webgpu' |
| Startup | Synchronous | Async init (await renderer.init()) |
| Shaders | GLSL, ShaderMaterial, onBeforeCompile |
TSL node materials (compiled to WGSL or GLSL) |
| Fallback | None needed | Automatic WebGL 2 backend |
| Compute shaders | No | Yes (WebGPU backend only) |
| r187 additions | Maintenance | StandardDrawingPipeline, MeshletDrawingPipeline, VisibilityBufferDrawingPipeline |
| Maturity | Proven over many years | Fast-moving; APIs still being renamed |
Switching takes three changes: the import, the constructor and an async init.
import * as THREE from 'three/webgpu';
const renderer = new THREE.WebGPURenderer({ antialias: true });
await renderer.init(); // set up WebGPU, or the WebGL 2 fallback
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
In an import map for a WebGPU project, map "three" and "three/webgpu" to the same file, build/three.webgpu.js, and map "three/tsl" to build/three.tsl.js. The official WebGPU examples do this so that addons importing 'three' don’t load a second copy of the library.
Did you know?
According to an analysis of the r187 diff by the Japanese studio Sirocco, about 79% of changed core lines (14,242) went to the WebGPU renderer and TSL. The number of three/tsl exports grew from 682 to 819.
forceWebGL vs plain WebGLRenderer
new THREE.WebGPURenderer({ forceWebGL: true }) makes the WebGPU renderer use its WebGL 2 backend, which is useful for testing the fallback. A three.js maintainer has explained on the forum that this backend is a separate implementation and does not use WebGLRenderer internally. It is not a drop-in equivalent. A forum benchmark on r181 measured the forced-WebGL path at roughly 50 fps against about 350 fps for plain WebGLRenderer, with 5,000 cubes. Test your own scene before relying on the fallback for heavy work.
Heads up
If you need the WebGL 2 fallback, avoid WebGPU-only features such as compute shaders. They don’t carry over, which is why some WebGPU examples run in one browser and fail in another.
Browser support matrix
web.dev reported in November 2025 that WebGPU had shipped in all major browser engines, with gaps remaining by platform:
| Browser | Platform | WebGPU status | What three.js does |
|---|---|---|---|
| Chrome / Edge 113+ | Windows, macOS, ChromeOS | Shipped | Uses WebGPU |
| Chrome | Android (recent devices) | Shipped on supported GPUs | WebGPU, else WebGL 2 |
| Safari 26 | macOS, iOS, iPadOS, visionOS | Shipped | Uses WebGPU |
| Firefox 141 | Windows | Shipped | Uses WebGPU |
| Firefox 145 | Apple Silicon macOS | Shipped | Uses WebGPU |
| Firefox | Linux, Android, Intel Macs | In progress | Falls back to WebGL 2 |
When to stay on WebGLRenderer
Stay on WebGLRenderer if your project depends on raw GLSL ShaderMaterial code, on older addons that haven’t been ported, or on tutorials written before 2025. Stay on it too if you need identical behaviour on every device right now. A learner loses nothing by starting there, because Scene, Camera, Mesh and the loop work the same way in both renderers.
Meet TSL: shaders written in JavaScript
TSL, the Three.js Shading Language, is a set of JavaScript functions (color, time, sin, mix, positionLocal and hundreds more) that build a shader graph. The renderer compiles that graph to WGSL for WebGPU or GLSL for the WebGL 2 fallback. You write one material and it runs on both backends. That replaces the old habit of string-patching GLSL in onBeforeCompile, which broke on almost every release.
Three.js vs React Three Fiber (and other options)
If you’re asking whether to learn React Three Fiber or plain three.js first, learn plain three.js first. R3F maps JSX onto three.js objects one to one, so every R3F problem turns out to be a three.js problem in the end. React Three Fiber v9 targets React 19, and v8 targets React 18.
| Option | Style | Best for | Notes |
|---|---|---|---|
| three.js (vanilla) | Imperative JavaScript | Art, sketches, any site or framework | Free, MIT, the base layer for the others |
| React Three Fiber | Declarative JSX | React apps, UI-heavy 3D | pmndrs; Drei adds helpers |
| Babylon.js | Imperative, engine-style | Games, physics, built-in inspector | Free, Microsoft-backed, more batteries included |
| PlayCanvas | Engine plus visual editor | Team game production | Open-source engine; hosted editor plans |
| Raw WebGPU | Low-level API | Custom engines, research | Most control, most code |
Same scene, two ways
Here is the cube from earlier written in R3F:
import { Canvas, useFrame } from '@react-three/fiber';
import { useRef } from 'react';
function Cube() {
const ref = useRef();
useFrame((_, delta) => { ref.current.rotation.y += delta; });
return (
<mesh ref={ref}>
<boxGeometry />
<meshStandardMaterial color="#ff6a3d" />
</mesh>
);
}
export default function App() {
return (
<Canvas camera={{ position: [0, 1.5, 4] }}>
<ambientLight intensity={0.4} />
<directionalLight position={[3, 4, 5]} intensity={2} />
<Cube />
</Canvas>
);
}
<mesh> is new THREE.Mesh(), <boxGeometry /> is new THREE.BoxGeometry(), and useFrame hooks into the render loop. If you already work in React, this is shorter. If you don’t, it adds a framework between you and the GPU.
Drei and the ecosystem
Drei, also from pmndrs, is a large set of ready-made R3F components: controls, environment maps, text and loaders. The fair point in R3F’s favour is that for a React product team, Drei and React state management save weeks. The case against it for artists is that a generative sketch has no UI state to manage.
From cube to artwork: a three-step creative coding workshop
This is where three.js turns into a creative tool: thousands of objects in one draw call, particle fields, and shaders that react to time. Each sketch below swaps into the first-scene file. Replace the cube and the loop, and keep the scene, camera, renderer and lights.
Sketch 1: InstancedMesh and noise
InstancedMesh draws thousands of copies of one geometry in a single draw call. Here, 1,600 columns rise and fall on Perlin noise from the ImprovedNoise addon.
import { ImprovedNoise } from 'three/addons/math/ImprovedNoise.js';
const perlin = new ImprovedNoise();
const COUNT = 40;
const grid = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.9, 1, 0.9),
new THREE.MeshStandardMaterial({ color: 0x88ccff, roughness: 0.5 }),
COUNT * COUNT
);
scene.add(grid);
camera.position.set(30, 28, 30);
camera.lookAt(0, 0, 0);
const dummy = new THREE.Object3D();
renderer.setAnimationLoop((time) => {
let i = 0;
for (let x = 0; x < COUNT; x++) {
for (let z = 0; z < COUNT; z++) {
const h = perlin.noise(x * 0.1, z * 0.1, time * 0.0003) + 0.5;
dummy.position.set(x - COUNT / 2, h * 2, z - COUNT / 2);
dummy.scale.set(1, 0.2 + h * 4, 1);
dummy.updateMatrix();
grid.setMatrixAt(i++, dummy.matrix);
}
}
grid.instanceMatrix.needsUpdate = true;
renderer.render(scene, camera);
});
Try changing this: raise the noise scale from 0.1 to 0.03 for rolling hills, or swap BoxGeometry for CylinderGeometry(0.4, 0.4, 1, 6) for a hexagonal city.
Sketch 2: Points and BufferGeometry
BufferGeometry lets you write vertex positions straight into a Float32Array. Pair it with Points and you get 20,000 glowing particles in a sphere.
const N = 20000;
const positions = new Float32Array(N * 3);
for (let i = 0; i < N; i++) {
const r = 5 * Math.cbrt(Math.random()); // even spread through the volume
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
positions[i * 3] = r * Math.sin(phi) * Math.cos(theta);
positions[i * 3 + 1] = r * Math.sin(phi) * Math.sin(theta);
positions[i * 3 + 2] = r * Math.cos(phi);
}
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
const cloud = new THREE.Points(geo, new THREE.PointsMaterial({
size: 0.03, color: 0xffd6a5, transparent: true, opacity: 0.8,
depthWrite: false, blending: THREE.AdditiveBlending
}));
scene.add(cloud);
renderer.setAnimationLoop((time) => {
cloud.rotation.y = time * 0.0001;
cloud.rotation.x = Math.sin(time * 0.0002) * 0.3;
renderer.render(scene, camera);
});
Try changing this: replace Math.cbrt(Math.random()) with 1 to put every point on the surface, then compare the two.
Sketch 3: A TSL shader that breathes
This one needs WebGPURenderer, so use the WebGPU import map described above. The colour pulses over time, the surface swells along its normals, and the pointer shifts the palette.
import * as THREE from 'three/webgpu';
import { color, mix, sin, time, positionLocal, normalLocal, uniform } from 'three/tsl';
const pointer = uniform(new THREE.Vector2(0, 0));
const pulse = sin(time.mul(2)).mul(0.5).add(0.5); // 0..1, over and over
const material = new THREE.MeshStandardNodeMaterial({ roughness: 0.3 });
const warmth = pointer.x.add(1).mul(0.5); // pointer x mapped to 0..1
material.colorNode = mix(color(0x1b1f3b), color(0xff6a3d), pulse.mul(warmth));
material.positionNode = positionLocal.add(normalLocal.mul(pulse.mul(0.15)));
const blob = new THREE.Mesh(new THREE.IcosahedronGeometry(1, 32), material);
scene.add(blob);
addEventListener('pointermove', (e) => {
pointer.value.set((e.clientX / innerWidth) * 2 - 1, -(e.clientY / innerHeight) * 2 + 1);
});
Try changing this: replace normalLocal.mul(pulse.mul(0.15)) with normalLocal.mul(sin(positionLocal.y.mul(8).add(time)).mul(0.1)) to send ripples up the surface. If you’d rather drive the uniform with your hand than a mouse, browser hand tracking with ml5.js can feed the same pointer.value.
Loading 3D models and textures
Use glTF, ideally the binary GLB form, for anything you didn’t build in code. It is the format three.js is designed around, and GLTFLoader handles meshes, PBR materials, animations and cameras in one file.
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
new GLTFLoader().load('/models/robot.glb', (gltf) => {
scene.add(gltf.scene);
});
The free three.js editor on threejs.org lets you drag in a GLB and check its scale, materials and animations before writing any code.
Exporting from Blender
Blender’s built-in glTF 2.0 exporter writes GLB directly. Apply transforms first, keep 1 unit = 1 metre, and use the Principled BSDF node, which maps cleanly onto MeshStandardMaterial.
Compressing assets
Draco compresses mesh geometry (DRACOLoader), and KTX2 with Basis Universal compresses textures so they stay compressed in GPU memory (KTX2Loader). Both need decoder files hosted alongside your site. For colour, three.js has managed sRGB output by default since r152, so set texture.colorSpace = THREE.SRGBColorSpace on colour maps you load by hand. Textures that look smeared at steep angles usually need anisotropic filtering, set through texture.anisotropy.
Why your scene is black (and other errors everyone hits)
Most first-scene failures come from one of four causes: a missing light, a camera inside the object, an import that doesn’t resolve, or code written for an older release. Open the browser console first. three.js prints clear warnings.
| Symptom | Likely cause | Fix |
|---|---|---|
| Black mesh | MeshStandardMaterial with no lights |
Add AmbientLight plus DirectionalLight, or debug with MeshNormalMaterial |
| Blank canvas | Camera at the origin, inside the mesh | camera.position.z = 5 |
| Object vanishes when zooming | Near/far planes too tight | Widen them, e.g. 0.1 and 1000 |
THREE is not defined |
Old global-script tutorial | Use <script type="module"> with import * as THREE from 'three' |
Failed to resolve module specifier "three" |
No import map | Add the import map before your module script |
| Console warns about multiple instances | Mixed versions or CDNs | Pin one version on one CDN |
| CORS error on load | Page opened via file:// | Run a local server |
Version changes explain the rest. These are the traps that break older tutorials most often:
| Release | What changed | Symptom | Fix |
|---|---|---|---|
| r148 | examples/js (UMD globals) removed |
THREE.OrbitControls is not a constructor, 404s |
Import from three/addons/ (examples/jsm) |
| r152 | Colour management on, outputEncoding replaced |
Washed-out or too-dark colours | Use outputColorSpace and SRGBColorSpace |
| r155 | Physically correct lighting by default | Old scenes look dim | Raise light intensities |
| r160 | build/three.js and build/three.min.js removed |
404 on three.min.js |
Use three.module.js; minify in your own build |
| r186 | PCFSoftShadowMap removed |
Shadow type error | Use PCFShadowMap or VSMShadowMap |
| r186-r187 | rangeFog, viewportResolution TSL exports removed |
TSL import errors | fog(color, rangeFogFactor(near, far)); screenSize |
| r187 | ProxyNodeMaterial renamed |
Import error | Use NodeMaterialInstance |
Performance basics for smooth 60 fps
Draw calls usually cost more than triangle count. Each separate mesh is roughly one draw call, so 1,000 individual cubes can stutter where a single InstancedMesh of 1,000 cubes runs smoothly.
- Instance repeated objects. Use
InstancedMeshfor grids, forests, crowds and particles made of meshes. - Dispose what you remove.
geometry.dispose(),material.dispose()andtexture.dispose()free GPU memory. Removing an object from the scene does not. - Cap the pixel ratio at 2, as in the starter.
- Precompile shaders.
renderer.compileAsync(scene, camera)precompiles materials for the objects already in the scene when you call it. It does not cover objects added later, so call it again for newly added objects before rendering them to reduce shader-compilation stalls. In r187 the WebGPU renderer compiles those pipelines in parallel. - Inspect. The three.js devtools extension and the Needle Inspector show the live scene graph, so you can spot duplicate materials and runaway object counts.
Is three.js widely used? Numbers that matter
Yes, and the figures are concrete. As of December 2026, the mrdoob/three.js repository has about 120,000 GitHub stars and 48,752 commits under the MIT licence. A full-history clone downloads about 2 GB, so git clone --depth=1 is the sensible way to fetch it.
| Metric | Figure | Source and date |
|---|---|---|
| GitHub stars | ~120.0k | mrdoob/three.js, Dec 2026 |
| Commits | 48,752 | mrdoob/three.js, Dec 2026 |
npm weekly downloads, three |
~33.0M | npm trends, late 2026 |
npm weekly downloads, @react-three/fiber |
~8.79M (v9.8.2) | npm, late 2026 |
| Awwwards three.js collection | 119 sites | Awwwards, Dec 2026 |
Treat download counts as a range. Trackers disagree: javascripts.com showed about 12.2M weekly downloads of three for the last week of September 2026, against npm trends’ 33.0M. Even the lower figure puts three.js among the most installed graphics packages on npm. It also explains why R3F’s downloads count towards three.js as well, since every R3F install pulls three in.
Where to learn next
A common complaint is “I find the docs hard to start with, where do I actually begin?” The docs are a reference, not a course. Use them in this order:
- The official manual. It is free and assumes you already know JavaScript and the DOM. Read the installation, fundamentals and responsive pages first.
- The official examples. They are free, and every one has a “view source” button. Find one close to your idea and take it apart.
- Three.js Journey by Bruno Simon. A paid course, the most complete structured path, covering shaders, Blender and physics.
- SimonDev. Free YouTube videos plus paid courses, strong on shaders and game-style techniques.
- discourse.threejs.org and the official Discord. Free. Post a minimal live example and you’ll usually get an answer fast.
For designers asking what they need first: comfortable JavaScript (functions, modules, arrays), basic vectors, and patience with the coordinate system. Matrices and linear algebra can wait until you write shaders. Showcases like Codevember, where artists post one creative-coding piece per day in November, are worth studying for scope. Most of the entries are small, single-idea sketches, which is the right size for learning.
FAQ
What exactly is three.js?
A free, open-source JavaScript library for 3D graphics in the browser. It wraps WebGL 2 and WebGPU behind objects like Scene, Camera, Mesh and Light, so you describe a scene instead of programming the GPU directly.
Is three.js part of React?
No. three.js is framework-free JavaScript. React Three Fiber is a separate pmndrs library that renders three.js objects from React components.
Is three.js using WebGPU?
Yes, through WebGPURenderer, imported from ‘three/webgpu’. It falls back to WebGL 2 automatically. The classic WebGLRenderer is still available and stable.
Is three.js widely used?
Very. It has around 120,000 GitHub stars and tens of millions of weekly npm downloads, depending on the tracker, and powers a large share of award-winning 3D websites.
Is three.js free to use commercially?
Yes. The MIT licence allows commercial use, modification and redistribution. You just keep the copyright notice in the source.
Do I need to know math or WebGL to learn three.js?
You don’t need WebGL. Basic vectors help from day one. Trigonometry (sine for oscillation) and matrices matter once you animate procedurally or write shaders.
How do I use three.js from a CDN without npm?
Add an import map that maps “three” to https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js and “three/addons/” to the matching examples/jsm/ folder. Then import inside a <script type="module">.
What is the latest version of three.js?
r187, released 30 October 2026. Check npm for the current published version number before installing.
Three.js vs Babylon.js: which should I learn?
For creative coding, web design and custom visuals, learn three.js. It is lighter and has the bigger community. For games that need built-in physics, an inspector and a more complete engine, Babylon.js fits better.
Can you make games with three.js?
Yes. Mr.doob’s Quake, Doom and Descent ports show it can. three.js is a rendering library, though, not an engine. You add physics (Rapier, cannon-es), audio and game logic yourself.
Try it live
This p5.js sketch is a cousin of Sketch 1. It uses p5’s WEBGL mode, with a perspective camera, two lights and a noise-driven grid of boxes, so you can play with the same ideas without leaving the page. Drag to orbit and press any key for new terrain. Then rebuild it in three.js with InstancedMesh and compare: 400 separate box() calls here against a single draw call there. That difference is the main reason people move from sketches to three.js.
// A p5.js cousin of the three.js InstancedMesh sketch:
// a grid of boxes whose heights follow Perlin noise.
// Drag to orbit (like OrbitControls). Press any key for new terrain.
const COUNT = 20; // boxes per side (20 x 20 = 400 boxes)
const SPACING = 22; // distance between box centres
let t = 0; // moves through the noise field over time
function setup() {
createCanvas(720, 480, WEBGL);
// Like a PerspectiveCamera: field of view, aspect, near, far
perspective(PI / 3, width / height, 1, 5000);
noStroke();
}
function draw() {
background(17);
orbitControl();
// Lights: a soft fill plus a warm directional key light
ambientLight(70);
directionalLight(255, 230, 210, -0.5, 1, -0.6);
// Tilt the world so you look down at the grid, then spin slowly
rotateX(-PI / 6);
rotateY(frameCount * 0.002);
const half = ((COUNT - 1) * SPACING) / 2;
const low = color(40, 60, 140);
const high = color(255, 120, 60);
for (let x = 0; x < COUNT; x++) {
for (let z = 0; z < COUNT; z++) {
// Noise gives a smooth value between 0 and 1
const n = noise(x * 0.12, z * 0.12, t);
const h = 10 + n * 160;
push();
// In p5, negative y is up, so lift each box by half its height
translate(x * SPACING - half, -h / 2, z * SPACING - half);
// Colour follows height: deep blue valleys, orange peaks
fill(lerpColor(low, high, n));
box(SPACING * 0.8, h, SPACING * 0.8);
pop();
}
}
t += 0.01;
}
function keyPressed() {
// A new seed gives a completely new landscape
noiseSeed(floor(random(100000)));
}
On this article
- Facts were checked against the sources below before publication.
- Published
Sources (8)
- mrdoob/three.js: JavaScript 3D Library (GitHub) (github.com)
- Releases: mrdoob/three.js (github.com)
- Releases: three-types/three-ts-types (github.com)
- three.js manual: WebGPURenderer (threejs.org)
- WebGPURenderer(forceWebGL=true) vs WebGLRenderer, three.js forum (discourse.threejs.org)
- R3F WebGPU, WebGL2 Fallback, Tree Shaking, three.js forum (discourse.threejs.org)
- WebGPU is now supported in major browsers (web.dev) (web.dev)
- three.js manual: Installation (threejs.org)


