Updated July 18, 2026 — refreshed with current platform data on browser-game generation and AI-assisted 3D workflows.
What is Three.js and why does it matter for browser games?
Three.js is the most widely used JavaScript 3D library. It abstracts the complexity of raw WebGL into a developer-friendly API that handles scene graphs, cameras, lighting, materials, and rendering — so a game that would take thousands of lines of raw WebGL takes hundreds of lines of Three.js. Combined with a physics engine like cannon-es, it powers interactive 3D experiences — from product configurators to full browser games — that run in any modern browser without plugins or installations.
Understanding these core concepts matters whether you write Three.js by hand or work with AI-generated game code. Games and interactive experiences are the #2 most-generated app category on VULK at 5.4% of all projects, and the platform has logged 2,438 user requests mentioning 3D or WebGL (VULK platform data, July 2026, N = 11,355 projects) — so a lot of people are reading and modifying Three.js code they did not write from scratch. This guide gives you the mental model to do that confidently.
What are the core building blocks of a Three.js application?
Every Three.js application is built around three fundamental objects — and a loop that ties them together:
| Concept | Role | Key detail |
|---|---|---|
| Scene | Container for all 3D objects, lights, effects | The root of the scene graph |
| Camera | The viewpoint the scene is observed from | Usually PerspectiveCamera for games |
| Renderer | Draws scene + camera to a <canvas> |
WebGL under the hood |
| Render loop | Runs ~60×/second | Updates positions, physics, then renders |
| Mesh | A visible object | Geometry (shape) + Material (appearance) |
| Lights | Make materials visible and scenes feel real | Ambient, directional, point, spot, hemisphere |
The render loop is the heartbeat of every Three.js application: it updates object positions, applies physics calculations, and tells the renderer to draw the current frame. Keeping it efficient is the key to smooth performance.
How do meshes, materials, and geometry work?
Visible objects in Three.js are called Meshes, and each Mesh is a combination of Geometry (the shape) and Material (the appearance). Geometry defines the vertices, faces, and normals that make up a 3D shape. Material defines how light interacts with that shape — its color, reflectivity, roughness, and transparency.
Three.js provides both basic materials (MeshBasicMaterial, which ignores lighting) and physically-based rendering (PBR) materials (MeshStandardMaterial, MeshPhysicalMaterial) that simulate realistic light interaction. PBR materials use metalness and roughness maps to create convincing surfaces like brushed metal, worn concrete, or polished glass.
How does lighting work in Three.js?
Lighting is what makes 3D scenes feel real. Three.js offers several light types: AmbientLight for base illumination, DirectionalLight for sun-like parallel rays, PointLight for omnidirectional sources like light bulbs, SpotLight for focused beams, and HemisphereLight for outdoor sky-ground color blending. Most scenes use a combination of ambient and directional lighting as a baseline, with point lights and spotlights for specific effects.
Shadows add another layer of realism but come with a performance cost. Each shadow-casting light requires an additional render pass. For browser games, limiting shadow-casting lights to one or two directional lights is a common optimization.
How do you add physics with cannon-es?
Three.js handles rendering, but it does not simulate physics. For realistic movement, collisions, and gravity, most browser games pair Three.js with cannon-es (a maintained fork of cannon.js). The physics engine runs its own simulation loop, and you synchronize the physics body positions with the Three.js mesh positions each frame.
Key concepts in cannon-es include Bodies (objects with mass and shape), Shapes (spheres, boxes, cylinders, convex hulls), and the World (the physics simulation container with gravity and collision detection). For vehicle physics, cannon-es provides a RaycastVehicle class that simulates suspension, steering, and wheel friction.
How do you load 3D models?
While simple shapes can be created with built-in geometry, complex objects like characters, vehicles, and buildings are typically created in 3D modeling software and loaded as GLB or GLTF files. The GLTFLoader in Three.js handles this, parsing the file and returning a scene graph that you can add to your Three.js scene.
GLTF (GL Transmission Format) has become the standard for web 3D because it supports meshes, materials, textures, animations, and scene hierarchy in a single, efficient binary format. Model optimization — reducing polygon count, compressing textures, and using efficient UV layouts — is important for browser performance.

Which performance optimizations matter most in the browser?
Browser games face stricter performance constraints than native applications. Key optimization strategies include:
- Instanced rendering: Drawing many copies of the same geometry (trees, buildings, particles) in a single draw call
- Level of detail (LOD): Showing simpler models for distant objects and detailed models for close ones
- Frustum culling: Skipping rendering for objects outside the camera's view (Three.js handles this automatically)
- Texture atlases: Combining multiple textures into a single image to reduce draw calls
- Object pooling: Reusing objects instead of creating and destroying them to reduce garbage collection
How do you structure a game loop?
A typical game loop in Three.js follows this pattern: read input (keyboard, mouse, gamepad), update game state (player position, NPC behavior, physics step), sync physics bodies with meshes, update the camera, and render the frame. Keeping each step efficient ensures the game runs smoothly at 60fps.
For complex games, separating game logic into modules — an Engine class for rendering and loops, a World class for level geometry, a Character class for player control, a Vehicle class for driving mechanics — keeps the codebase organized and maintainable.
Do you still need to learn all this by hand?
Increasingly, no — but the concepts still matter. AI code generation now produces complete Three.js games from natural-language descriptions: on VULK, a prompt like "build a 3D endless runner with obstacles and a score counter" generates the scene setup, game loop, physics integration, and input handling as real, editable code, rendered in a live preview within seconds. The generation is verified — VULK's render gate loads the scene in a real browser and fails the generation if the canvas renders blank.
What the concepts in this guide give you is the ability to iterate intelligently: knowing that shadows cost render passes, that instancing collapses draw calls, and that physics bodies sync to meshes each frame lets you direct the AI precisely — and edit the generated code when you need something non-standard.
FAQ
Is Three.js good enough for real games, or do I need Unity or Unreal?
For browser-delivered 3D games — arcade games, runners, puzzle games, product-adjacent experiences — Three.js is the standard and delivers 60fps on modern hardware. For AAA-scale titles with massive worlds and console targets, native engines still win. The advantage of Three.js is zero-install distribution: your game is a URL.
What is the fastest way to get a working Three.js game?
Describe it to an AI generator. On VULK, game prompts trigger a Three.js-specific pipeline that generates the scene, game loop, physics, and input handling as a Vite project with a live preview. Games and interactive experiences are the #2 category on the platform at 5.4% of all generations (VULK platform data, July 2026). You then iterate conversationally and deploy to Cloudflare Pages in one click.
Do I need a physics engine for every game?
No. Many successful browser games use simple math (bounding-box checks, manual velocity) instead of a full physics simulation. Add cannon-es when you need realistic gravity, stacking, collisions between many bodies, or vehicle dynamics.
How large can a Three.js game be before performance suffers?
There is no fixed limit — it depends on draw calls, polygon counts, and texture memory. With instancing, LOD, and texture atlases, scenes with tens of thousands of objects run smoothly. The usual bottleneck is draw calls: keep them in the low hundreds for mobile.
Can I export and self-host a game generated with VULK?
Yes. Generated games are standard Vite + Three.js projects. You can export the full source as a ZIP or push to GitHub, then host the static build anywhere. VULK is paid-only (no free tier): plans start at Builder $19.99/mo, with a 3-day full-access intro from $3.99 credited to your first month if you continue.
Whether you are building a product visualizer, an educational simulation, or a full browser game, Three.js provides the foundation — and with AI generation producing verified Three.js scenes from plain English, the barrier to entry has never been lower. Start at vulk.dev.



