Three.js examples & lessons

Learn one 3D concept at a time. Read the scene, run it, and change something you can see. Each lesson includes editable code, an explanation, and a concrete challenge.

Your first five scenes

From one mesh to a scene with hierarchy, camera controls, and real shadows.

Start with a cube
  1. 1.Rotating Cube
  2. 2.Position, Rotation & Scale
  3. 3.Solar System
  4. 4.Perspective & Orbit Controls
  5. 5.Lighting & Real Shadows

15 of 15 lessons

Rotating Cube: rendered Three.js scene
Beginner

Foundations

Rotating Cube

Build your first mesh and animate its rotation with elapsed time.

Open lesson
Position, Rotation & Scale: rendered Three.js scene
Beginner

Foundations

Position, Rotation & Scale

Compare three meshes that share geometry but use different local transforms.

Open lesson
Solar System: rendered Three.js scene
Beginner

Foundations

Solar System

Use nested groups to separate a planet's orbit from a moon's local orbit.

Open lesson
Perspective & Orbit Controls: rendered Three.js scene
Beginner

Foundations

Perspective & Orbit Controls

Frame a subject and constrain orbit controls without moving the scene.

Open lesson
Lighting & Real Shadows: rendered Three.js scene
Beginner

Light & surfaces

Lighting & Real Shadows

Connect a shadow-casting light, a casting mesh, and a receiving floor.

Open lesson
Material Gallery: rendered Three.js scene
Intermediate

Light & surfaces

Material Gallery

Isolate roughness and metalness using identical spheres under identical lighting.

Open lesson
Textures & Color Space: rendered Three.js scene
Intermediate

Light & surfaces

Textures & Color Space

Paint a local canvas texture and label its colors correctly for rendering.

Open lesson
Procedural Environment: rendered Three.js scene
Intermediate

Light & surfaces

Procedural Environment

Light a reflective object with six generated cube-map faces instead of an external HDR image.

Open lesson
Frame-Rate Independent Motion: rendered Three.js scene
Intermediate

Animation & interaction

Frame-Rate Independent Motion

Move an object in units per second, not units per frame.

Open lesson
Raycast Picking: rendered Three.js scene
Intermediate

Animation & interaction

Raycast Picking

Turn a pointer position into a camera ray and identify the nearest mesh.

Open lesson
Load a Local glTF Model: rendered Three.js scene
Intermediate

Assets & scale

Multi-file

Load a Local glTF Model

Load a real project asset with GLTFLoader and organize module code across files.

Open lesson
Instanced Mesh Grid: rendered Three.js scene
Advanced

Assets & scale

Instanced Mesh Grid

Draw hundreds of repeated objects with one geometry and one material.

Open lesson
Particle Field: rendered Three.js scene
Advanced

Assets & scale

Particle Field

Store many colored particles in BufferGeometry instead of creating a mesh per particle.

Open lesson
Write a Wave Shader: rendered Three.js scene
Advanced

Shaders & effects

Write a Wave Shader

Displace vertices on the GPU and pass a height value to a fragment shader.

Open lesson
Postprocessing with Bloom: rendered Three.js scene
Advanced

Shaders & effects

Multi-file

Postprocessing with Bloom

Render a scene through an effect pipeline and resize its offscreen targets with the viewport.

Open lesson

All starter assets are generated or included locally. Rendering needs a browser with WebGL 2; particle counts, shadows, and effects can cost more on mobile GPUs.