GAME DEVELOPMENT
WITH THREE.JS
Isaac Sukin's Kindle guide (Packt) to building real 3D games in the browser with JavaScript and Three.js: scenes, controls, physics, particle effects, first-person shooter mechanics and imported 3D models, from first scene to playable game. Get it on Amazon Kindle.
Book by Isaac Sukin · Updated November 2, 2026 · Book guide · about 6 minute read
LIVE DEMO
The book on the right of this page is a live Three.js scene with its real cover as a texture. Launch it full screen to drag to turn it and scroll to zoom. Launch asks for a free Google sign-in first. Press Esc or Exit to return.
Free Google sign-in · Orbit: drag · Zoom: scroll · Esc to exit
About This Book
WebGL and Three.js changed what a web page can do: full 3D games that start the moment someone clicks a link. This book teaches you to build them with plain JavaScript and Three.js.
It goes from a first scene to advanced physics, particle systems and a full first-person shooter, building real games step by step instead of isolated snippets.
Buy on Amazon Kindle →As an Amazon Associate I earn from qualifying purchases, at no extra cost to you.
Who This Book Is For
Developers with basic JavaScript knowledge who want to make 3D browser games. No previous Three.js experience is required. If you can write a function and a loop, you can follow along.
What You Will Learn
- Creating 3D scenes, cameras, lighting and physics
- Mouse and keyboard controls and interactivity
- Advanced particle systems and special effects
- First-person shooter mechanics and Capture the Flag
- Importing 3D models and animations
- Post-processing, shaders and performance optimization
What You'll Build
Try Before You Buy
Want a taste of the style first? These free tutorials cover the same building blocks: creating and animating simple 3D objects, the FPS game starter and animating GLTF models.
More Three.js Programming Books

Learn Three.js Programming
Create stunning 3D animations and visualizations using JavaScript and Three.js.

Three.js Cookbook
A comprehensive guide to creating 3D graphics and visualizations using Three.js.

Using WebXR API
Dive into immersive frame-based AR and VR development with WebXR.

Real-Time 3D Graphics with WebGL 2
Build interactive 3D applications with JavaScript and WebGL 2.

Learn Three.js: Programming 3D animations
Learn Three.js: Programming 3D animations and visualizations for the web.
Step-by-Step Code Breakdown
Bonus mini lesson: this is how the floating 3D book at the top of the page is built. Every excerpt is copied exactly from the full code below.
1. Scene, camera and renderer
In plain words: a dark scene, a camera a few steps in front of the book, and a renderer. Tone mapping keeps the bright cover colors from washing out under the lights.
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07090f);
const camera = new THREE.PerspectiveCamera(40, innerWidth / innerHeight, 0.1, 100);
camera.position.set(0, 0.3, 9);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.outputColorSpace = THREE.SRGBColorSpace;
document.body.appendChild(renderer.domElement);
2. Light it like a product shot
In plain words: photographers light products with a soft key light from the front side and a colored rim light from behind that outlines the edges. We do the same with two directional lights plus a little ambient fill.
scene.add(new THREE.AmbientLight(0xffffff, 0.6));
const key = new THREE.DirectionalLight(0xffffff, 2.2);
key.position.set(3, 4, 6);
scene.add(key);
const rim = new THREE.DirectionalLight(0x2ad1d6, 3);
rim.position.set(-5, 2, -4);
scene.add(rim);
3. Load the cover as a texture
In plain words: TextureLoader downloads the cover picture and turns it into a texture the graphics card can paint onto 3D shapes. setCrossOrigin('anonymous') is needed because the image lives on another website. Setting the color space to sRGB keeps the colors true to the original picture.
const loader = new THREE.TextureLoader();
loader.setCrossOrigin('anonymous');
const coverTex = loader.load('https://m.media-amazon.com/images/I/51-bumnFteL._SY466_.jpg');
coverTex.colorSpace = THREE.SRGBColorSpace;
coverTex.anisotropy = renderer.capabilities.getMaxAnisotropy();
4. Build the book from a box with six materials
In plain words: a book is just a thin box. BoxGeometry accepts an array of six materials, one per face, in this order: right, left, top, bottom, front, back. The front gets the cover, the left side becomes the colored spine, and the other edges get a cream paper color so it reads as pages.
const paper = new THREE.MeshStandardMaterial({ color: 0xf1ead8, roughness: 0.9 });
const spineMat = new THREE.MeshStandardMaterial({ color: 0x1b2a4a, roughness: 0.5 });
const front = new THREE.MeshStandardMaterial({ map: coverTex, roughness: 0.45 });
const back = new THREE.MeshStandardMaterial({ color: 0x1b2a4a, roughness: 0.6 });
const book = new THREE.Mesh(
new THREE.BoxGeometry(3, 4.6, 0.5),
[paper, spineMat, paper, paper, front, back] // right, left, top, bottom, front, back
);
scene.add(book);
5. Float the book and add drifting sparks
In plain words: a few hundred tiny points drift around the book like dust in a sunbeam. In the loop the book sways side to side with Math.sin, so you see the cover, the spine and the page edges catch the light.
const sparkPos = new Float32Array(400 * 3);
for (let i = 0; i < sparkPos.length; i++) sparkPos[i] = (Math.random() - 0.5) * 14;
const sparkGeo = new THREE.BufferGeometry();
sparkGeo.setAttribute('position', new THREE.BufferAttribute(sparkPos, 3));
const sparks = new THREE.Points(sparkGeo, new THREE.PointsMaterial({ color: 0x2ad1d6, size: 0.05, transparent: true, opacity: 0.8 }));
scene.add(sparks);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const t = clock.getElapsedTime();
book.rotation.y = Math.sin(t * 0.5) * 0.6;
book.rotation.x = Math.sin(t * 0.3) * 0.08;
book.position.y = Math.sin(t * 0.8) * 0.12;
sparks.rotation.y = t * 0.03;
controls.update();
renderer.render(scene, camera);
}
animate();
Live Scene: The Full Code
Paste this into a file named index.html. It loads the cover image from Amazon, which allows cross-origin use, so it runs from anywhere. Launch Full Code opens this exact code as a standalone page in a new window.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Three.js 3D Book Cover Scene</title>
<style>
body { margin: 0; overflow: hidden; background: #000; font-family: system-ui, sans-serif; }
</style>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
}
}
</script>
</head>
<body>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
// --- 1. Scene, camera and renderer ---
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07090f);
const camera = new THREE.PerspectiveCamera(40, innerWidth / innerHeight, 0.1, 100);
camera.position.set(0, 0.3, 9);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.outputColorSpace = THREE.SRGBColorSpace;
document.body.appendChild(renderer.domElement);
// Orbit controls: drag (mouse or touch) to orbit. Zoom is off on the page so
// vertical swipes still scroll on phones; the full-screen demo turns zoom on.
const controls = new OrbitControls(camera, renderer.domElement);
controls.target.set(0, 0, 0);
controls.enableDamping = true;
controls.enableZoom = false;
controls.enablePan = false;
controls.autoRotate = false;
controls.autoRotateSpeed = 0;
renderer.domElement.style.touchAction = 'pan-y';
// --- 2. Light it like a product shot ---
scene.add(new THREE.AmbientLight(0xffffff, 0.6));
const key = new THREE.DirectionalLight(0xffffff, 2.2);
key.position.set(3, 4, 6);
scene.add(key);
const rim = new THREE.DirectionalLight(0x2ad1d6, 3);
rim.position.set(-5, 2, -4);
scene.add(rim);
// --- 3. Load the cover as a texture ---
const loader = new THREE.TextureLoader();
loader.setCrossOrigin('anonymous');
const coverTex = loader.load('https://m.media-amazon.com/images/I/51-bumnFteL._SY466_.jpg');
coverTex.colorSpace = THREE.SRGBColorSpace;
coverTex.anisotropy = renderer.capabilities.getMaxAnisotropy();
// --- 4. Build the book from a box with six materials ---
const paper = new THREE.MeshStandardMaterial({ color: 0xf1ead8, roughness: 0.9 });
const spineMat = new THREE.MeshStandardMaterial({ color: 0x1b2a4a, roughness: 0.5 });
const front = new THREE.MeshStandardMaterial({ map: coverTex, roughness: 0.45 });
const back = new THREE.MeshStandardMaterial({ color: 0x1b2a4a, roughness: 0.6 });
const book = new THREE.Mesh(
new THREE.BoxGeometry(3, 4.6, 0.5),
[paper, spineMat, paper, paper, front, back] // right, left, top, bottom, front, back
);
scene.add(book);
// --- 5. Float the book and add drifting sparks ---
const sparkPos = new Float32Array(400 * 3);
for (let i = 0; i < sparkPos.length; i++) sparkPos[i] = (Math.random() - 0.5) * 14;
const sparkGeo = new THREE.BufferGeometry();
sparkGeo.setAttribute('position', new THREE.BufferAttribute(sparkPos, 3));
const sparks = new THREE.Points(sparkGeo, new THREE.PointsMaterial({ color: 0x2ad1d6, size: 0.05, transparent: true, opacity: 0.8 }));
scene.add(sparks);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const t = clock.getElapsedTime();
book.rotation.y = Math.sin(t * 0.5) * 0.6;
book.rotation.x = Math.sin(t * 0.3) * 0.08;
book.position.y = Math.sin(t * 0.8) * 0.12;
sparks.rotation.y = t * 0.03;
controls.update();
renderer.render(scene, camera);
}
animate();
addEventListener('resize', () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
</script>
</body>
</html>
What To Try Next
- Swap in your own cover: change the URL in step 3 to any image on a server that allows cross-origin loading.
- Add a back cover: load a second texture and use it for the last material in the array instead of the plain color.
- Make it open: split the cover into its own thin box with its pivot on the spine and rotate it on click.
- Start the book's first project for free with the FPS game starter.
Frequently Asked Questions
What is Game Development with Three.js about?
It teaches how to build 3D games that run in a web browser using JavaScript and the Three.js library, covering scenes, lighting, controls, physics, particle effects, first-person shooter mechanics and imported 3D models.
Do I need Three.js experience to read this book?
No. Basic JavaScript is enough. The book starts with a first scene and builds up to complete games.
Who wrote Game Development with Three.js?
Isaac Sukin wrote Game Development with Three.js, published by Packt. It is one of the first books focused on making browser games with Three.js.
Is Game Development with Three.js up to date?
It was written for an older Three.js release, so some code needs updating, for example THREE.Geometry is now BufferGeometry and addons are imported as ES modules. The game design ideas and techniques still apply, and the free tutorials on this site use the current pinned Three.js 0.160.0.
Where can I buy Game Development with Three.js?
It is available as a Kindle edition on Amazon. The Buy on Amazon Kindle button on this page links straight to it.
Can I read a Kindle book without a Kindle device?
Yes. The free Kindle app runs on phones, tablets and computers, and Kindle books can also be read in a web browser with Kindle Cloud Reader.
Is the 3D book scene code on this page free?
Yes. The live 3D book scene code is free to copy and Launch Full Code opens it in a new window. Only the full-screen live demo asks for a free Google sign-in.











