Vector
A mathematical quantity with magnitude and direction, commonly used for positions, directions, and velocities.
Every glowing point, every impossible surface, every world inside your browser begins with mathematics. Explore the invisible machinery that turns code into three-dimensional experiences.
A 3D scene begins with a coordinate system. Every point has an X, Y, and Z position. These three values describe where an object exists, but not how it appears on your screen.
The origin is the reference point. Translation moves an object, rotation changes its orientation, and scale changes its dimensions. Combine these transformations and you can position almost anything in a virtual world.
// Create a position in 3D space
mesh.position.set(2, 1, -3);
mesh.rotation.y = Math.PI / 4;
mesh.scale.set(1, 2, 1);A mesh is generally a combination of geometry and material. Geometry describes a shape; a material describes how its surface responds to light. Together, they form one of the basic building blocks of a 3D scene.
Complex objects can be assembled from triangles. Each triangle has three vertices, and each vertex can store position, normal, color, texture coordinates, and other attributes.
// Geometry + material = mesh
const geometry =
new THREE.IcosahedronGeometry(1, 2);
const material =
new THREE.MeshStandardMaterial({
color: 0x78f6ff,
roughness: 0.3,
metalness: 0.5
});
const mesh = new THREE.Mesh(
geometry, material
);
scene.add(mesh);A camera transforms a 3D world into a view. A perspective camera makes distant objects appear smaller, creating the familiar sense of depth. An orthographic camera keeps apparent object size independent of distance.
The camera's field of view, aspect ratio, near plane, and far plane determine how the scene is projected. The view matrix positions the world relative to the camera, while the projection matrix maps it into clip space.
// Perspective projection
const camera =
new THREE.PerspectiveCamera(
55,
innerWidth / innerHeight,
0.1,
100
);
camera.position.set(0, 2, 7);
camera.lookAt(0, 0, 0);Materials determine how a surface interacts with illumination. Roughness controls how broad or concentrated its highlights appear. Metalness influences how metallic surfaces reflect their surroundings.
Realistic rendering often combines direct lighting, environment lighting, surface normals, shadows, and physically based material models. The final result depends on both the lighting and the material.
// A physically based surface
const material =
new THREE.MeshStandardMaterial({
color: 0xa68aff,
metalness: 0.75,
roughness: 0.22
});
const light =
new THREE.PointLight(
0x78f6ff, 80, 30
);
light.position.set(3, 4, 2);Rendering is a sequence of transformations. Application code updates scene data, the camera defines the view, and the graphics pipeline processes geometry and shaders before producing pixels.
The exact pipeline depends on the renderer and its configuration. Modern engines may include shadow maps, depth testing, post-processing, temporal techniques, and multiple rendering passes.
// The core rendering loop
function animate() {
requestAnimationFrame(animate);
mesh.rotation.y += 0.005;
renderer.render(scene, camera);
}
animate();Shaders are programs executed as part of the graphics pipeline. Vertex shaders process vertex data; fragment shaders determine the output for fragments that may contribute to pixels.
With custom shaders, developers can build procedural patterns, distort surfaces, animate noise, generate holographic effects, and manipulate color directly on the GPU.
// Fragment shader concept
uniform float uTime;
varying vec2 vUv;
void main() {
float wave = sin(
vUv.x * 18.0 + uTime
);
vec3 color = mix(
vec3(0.04, 0.1, 0.3),
vec3(0.2, 0.95, 1.0),
wave * 0.5 + 0.5
);
gl_FragColor = vec4(color, 1.0);
}Animation is the process of changing scene properties over time. Position, rotation, color, scale, camera movement, and shader uniforms can all be animated.
Use elapsed time rather than frame count whenever possible. Delta time makes motion more consistent across devices running at different frame rates. Interpolation and easing can make transitions feel intentional.
// Time-based motion
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
mesh.position.y =
Math.sin(time) * 0.5;
mesh.rotation.x = time * 0.2;
renderer.render(scene, camera);
}A scroll-driven experience can treat document position as an input to a 3D scene. As the reader moves through chapters, the camera can travel, particle systems can reorganize, and objects can transform.
This creates a connection between explanation and demonstration: the scene becomes part of the story instead of serving as a decorative background. Keep motion smooth and provide alternatives for reduced-motion preferences.
// Map scroll progress to scene state
const progress =
scrollY / (
document.body.scrollHeight -
innerHeight
);
camera.position.z =
THREE.MathUtils.lerp(8, 2, progress);
mesh.rotation.y = progress * Math.PI * 2;Real-time graphics must finish their work within a frame budget. At 60 frames per second, a frame takes about 16.7 milliseconds. That time must accommodate application logic, rendering, browser work, and other tasks.
Reduce unnecessary draw calls, reuse geometry and materials, limit expensive effects, control pixel ratio, and avoid allocating new objects in every frame. Profile on representative devices rather than relying on guesses.
Change the parameters and watch a live particle system respond. This small laboratory uses the same principles introduced throughout the documentary.
A compact glossary of foundational concepts used throughout real-time graphics.
A mathematical quantity with magnitude and direction, commonly used for positions, directions, and velocities.
A structured set of numbers used to represent transformations and map coordinates between spaces.
A collection of vertices and geometric primitives, typically combined with a material to create a visible object.
A direction perpendicular to a surface, used in lighting calculations and other geometric operations.
Two-dimensional coordinates that associate points on a surface with locations in a texture.
The process of determining which screen-space fragments are covered by geometric primitives.
A GPU program that processes graphics data, such as vertex positions or fragment colors.
A rendering destination that stores output such as color and depth for a frame or rendering pass.
A family of techniques that trace rays through a scene to estimate visibility, reflections, and illumination.
Rendering methods that use material and lighting models designed to behave consistently with physical principles.
Rendering many copies of geometry efficiently by sharing underlying resources and varying per-instance data.
Image operations applied after a scene is rendered, such as bloom, color grading, and depth-based effects.
Three-dimensional web graphics bring mathematics, programming, design, and storytelling into a single interactive medium. Learn the fundamentals, experiment with the parameters, inspect the rendering pipeline, and then build something that could not exist as a static page.