7 lessons · 72 min Intermediate

Three.js through maths: 3D on the web is just maths

I taught maths and physics before I wrote code. Here, every high-school notion becomes a piece of 3D scene you can play with: a vector turns a head, a sine wave makes a cat breathe, a dot product lights a lamp.

FR EN
Progress 0/7
1

Scene, camera and coordinate frame

Three axes, a camera, a field of view. Why up is y, what the fov changes, and why near and far exist. Your first scene to drive with sliders.

10 min
2

Vectors: position, direction, distance

Adding, measuring, normalising, and the dot product that answers "is it looking at me?". A cat head that follows your pointer.

10 min
3

Translate, rotate, scale: matrices

The 4x4 matrix that holds position, rotation and size. Why order matters, and how a cat tail follows its body through the hierarchy.

11 min
4

Sine and cosine: orbits and oscillations

Amplitude, period, phase: three numbers to make a cat breathe, swing Christmas baubles and orbit a firefly. Plus lerp and easing.

10 min
5

Gravity, bounce, friction

Euler's method in three lines, the restitution coefficient, exponential friction and rolling without slipping. And why a large dt blows everything up.

11 min
6

Light and materials: Lambert, shadows, bloom

Lambert is a dot product: n·l. Emissive, tone mapping and the bloom that makes a fire or ice cat glow.

10 min
7

Colour is a vector: k-means

A pixel is a point in an RGB cube. Distance, mean, and the k-means algorithm that guesses a cat's coat from its photo.

10 min

What you will learn

Place an object and a camera in a coordinate frame, and set fov, near and far without guessing

Use vectors, lengths and the dot product to aim, measure and detect a gaze

Combine translations, rotations and scales, and animate with sin, cos and lerp

Simulate gravity and bounces, light with Lambert, and extract colours with k-means

Prerequisites: JavaScript basics (variables, functions, objects). On the maths side, nothing beyond high school, and every formula is explained again. The demos run in your browser with WebGL, and they only load when you click them.

Curious where this maths leads? The 3D Lab shows the two complete scenes used as examples throughout the course.

Start lesson 1

Free · No signup · 10 minutes