Build a 3D Website or Game with AI and Three.js
Spinning products, 3D portfolios, small browser games: most 3D on the web is built with one free library, Three.js. You don't need to be a graphics expert to start. Your AI can do the heavy lifting if you give it the right instructions.
Video not loading? Watch the reel on Facebook.
Three.js is a free, open-source (MIT) JavaScript library for 3D graphics in the browser. It handles the hard math of drawing 3D shapes on a flat screen, so you can think in terms of objects, cameras and lights.
How a 3D scene works, in five pieces
- Scene: the empty world you put things in.
- Camera: where you're looking from.
- Renderer: draws what the camera sees onto your web page.
- Mesh: an object, made of a shape (like a cube) and a material (its color and surface).
- Animation loop: redraws the scene many times a second, so things can move.
Every Three.js project, from a spinning cube to a full game, is built from these. Knowing the five words is enough to talk to your AI about it.
The fastest way to start
The official manual recommends npm with Vite. With Node.js installed, in a new folder:
npm install --save three
npm install --save-dev vite
npx vite
Or skip the setup entirely: ask your AI for "a single HTML file with a Three.js scene, loading Three.js from a CDN with an import map". Open the file in your browser and it runs.
Getting AI to write good Three.js code
AI models often write outdated Three.js code, because the library changes fast and their training data is older. The Three.js team publishes guidance written specifically for AI: https://threejs.org/docs/llms.txt. Tell your agent to read it first:
"Read https://threejs.org/docs/llms.txt first and follow it. Then build a single-page Three.js scene: a slowly rotating low-poly planet with soft lighting, which the user can drag to rotate. Use import maps, not old script tags."
Then improve it one step at a time: "add stars in the background", "make it work on phones", "add a click that shows the country name". Small steps make it much easier to see what broke.
Ideas to try
- A 3D product viewer for an online shop, where customers can rotate the item.
- A portfolio header with a floating 3D object that follows the mouse.
- A tiny browser game: a ball rolling through a maze, or an endless runner.
- A data visualization, like sales as 3D bars.
For more inspiration, browse the official examples. Each one has its source code, which you can hand to your AI as a starting point.
Tips
- Keep it light. 3D can be heavy on phones. Ask the AI to keep models simple and test on a phone early.
- Use React? React Three Fiber lets you build Three.js scenes as React components.
- When it looks wrong, take a screenshot and show it to your AI. See Fix Your Website with a Screenshot.
Start here: threejs.org · Examples · GitHub
Follow my Facebook page for more things you can build with AI.