tutorial· 10 min read

How to Build a Three.js Browser Game in VULK

Step-by-step tutorial on building 3D browser games with Three.js in VULK. Covers physics, controls, lighting, performance, deployment, and tested prompts for platformers, runners, shooters, and puzzles.

João CastroJoão Castro
How to Build a Three.js Browser Game in VULK

Updated July 17, 2026 — refreshed with verified platform data, tested prompt patterns, and current deploy details.

How do you build a Three.js browser game in VULK?

The complete answer in one paragraph: describe the game — mechanics, controls, camera, win/lose conditions — in a single prompt, and VULK detects it is a game and generates a full Vite + Three.js project: renderer and scene setup, a fixed-timestep physics world (Cannon.js), player controls, lighting with shadows, a requestAnimationFrame game loop with delta time, and an HTML HUD overlay. The game runs immediately in the live preview; you then iterate with follow-up prompts ("add double jump", "add sound", "add mobile touch controls") and deploy it to Cloudflare Pages with one click. You never write WebGL boilerplate by hand.

This is not a niche workflow. Games and puzzles are the #2 category of AI-generated apps at 5.4% of all projects, behind only dashboards (VULK platform data, July 2026, N = 10,994 active projects) — and the median builder ships a first working app 47 seconds after signing up. The rest of this guide covers what gets generated, tested prompts per game genre, performance patterns, and the path to a public URL.

Why Three.js for browser games?

Three.js is the standard library for 3D rendering in the browser. It abstracts WebGL into a scene graph model -- cameras, meshes, lights, materials -- that makes building interactive 3D experiences practical without writing raw shader code. Combined with physics engines like Cannon.js or Rapier, you get collision detection, gravity, and rigid body dynamics. Combined with VULK, you get a complete game project generated from a single prompt.

VULK auto-detects when your prompt describes a game. When it does, the generation pipeline switches to a Three.js template that includes a render loop, scene setup, camera controls, and physics integration out of the box. You do not need to specify "use Three.js" -- just describe the game you want.

What does VULK generate for a game prompt?

When VULK detects a game prompt, the generated project includes a specific set of files and systems:

System What you get
Scene setup Renderer with antialiasing, pixel-ratio handling, resize listener; scene + camera initialization
Physics world Cannon.js world at a fixed 1/60s timestep; each visual mesh paired with a physics body, synced every frame
Player controls WASD + pointer lock for first-person, orbit controls for third-person, spacebar jump on ground contact
Lighting Ambient fill + directional sun with shadow maps, plus point lights for specific areas
Game loop requestAnimationFrame loop with delta time — consistent speed across refresh rates
HUD overlay HTML/CSS overlay for score, health, timer, or other game state on top of the canvas

Which prompts work for each game genre?

The specificity of your prompt directly controls the complexity and quality of the output. Here are examples for common game types.

Platformer: "Build a 3D platformer game. The player is a sphere that rolls across floating platforms. Platforms are rectangular with different colors at varying heights. Include a score counter that increases when the player reaches a new platform. If the player falls below y=-10, reset to the start. Add WASD controls and spacebar for jump. Camera follows the player from behind."

This prompt triggers platform generation with randomized layouts, a follow camera, fall detection, and score tracking. The physics system handles the rolling ball naturally.

Endless runner: "Create an endless runner game. The player runs forward automatically on a 3-lane road. Arrow keys switch lanes. Obstacles appear randomly and the player must dodge them. Speed increases over time. Show distance traveled as the score. Game over on collision."

VULK generates an object pooling system for obstacles, lane-switching logic with smooth transitions, progressive difficulty, and collision detection between the player and obstacle meshes.

Shooter: "Build a first-person shooter with pointer lock controls. The player moves with WASD in a rectangular arena. Enemies are red cubes that move toward the player. Click to shoot projectiles. Enemies take 3 hits to destroy. Show health bar and kill count. Enemies spawn every 5 seconds, increasing over time."

This generates pointer lock integration, raycasting or projectile physics for shooting, enemy AI with pathfinding toward the player, a health system, and spawn management.

Puzzle game: "Create a 3D puzzle game where the player pushes boxes onto marked tiles. Sokoban-style. Grid-based movement, 5 levels with increasing difficulty. Show move count and level number. Undo button to reverse last move."

Grid-based movement is handled by snapping positions to integer coordinates after each input. Level data is stored as 2D arrays that define walls, boxes, targets, and player start position.

How do you customize the generated game?

The generated game is a standard Vite + Three.js project. Every file is editable. Common customizations you can make through follow-up prompts:

Change the visual style: "Make the platforms look like stone blocks with a texture. Add a skybox with a sunset gradient." VULK will add texture loading and a cube texture or shader-based skybox.

Add sound: "Add a jump sound effect, a coin collection sound, and background music. Use the Web Audio API." The generation adds an audio manager that preloads and plays sound files at the right moments.

Add mobile controls: "Add touch controls -- a virtual joystick on the left side and a jump button on the right." This generates an HTML overlay with touch event listeners that feed into the same input system as keyboard controls.

Improve physics: "Make the ball bounce off walls instead of stopping. Add friction to the ground so the ball slows down when not moving." These translate to Cannon.js material properties -- restitution for bounce, friction coefficients for surfaces.

This iterative loop is how good games actually get built on the platform: the median build conversation is 4 messages, while the most invested projects run past 25 (VULK platform data, July 2026). Start with the core mechanic, then layer on polish.

How do you keep a browser game fast?

Browser games run in the main thread alongside DOM operations, so performance matters. VULK's generated games include several optimizations by default:

  • Geometry reuse -- Identical meshes share geometry and material instances instead of creating new ones for each object.
  • Frustum culling -- Three.js culls objects outside the camera's view automatically, but VULK also disables rendering on objects that are too far from the player.
  • Fixed physics timestep -- Physics runs at a consistent rate regardless of render framerate, preventing tunneling at low FPS and instability at high FPS.
  • Object pooling -- For games with many spawning/despawning objects (bullets, enemies, particles), objects are recycled from a pool instead of being created and garbage collected.

If you notice frame drops, a good follow-up prompt is: "Optimize the game for mobile performance. Reduce shadow map resolution, lower the draw distance, and simplify geometries." VULK will adjust the renderer settings and scene complexity accordingly.

How do you deploy and share your game?

Once you are satisfied with the game in VULK's real-time preview, click Deploy. The game is built and deployed to Cloudflare Pages, giving you a public URL you can share. The deployed game is static -- just HTML, JS, and assets -- so it loads fast and works on any modern browser.

For games with leaderboards or persistent state, you can ask VULK to generate a backend: "Add a leaderboard. Store the top 100 scores with player name and date. Show the leaderboard on the game over screen." This triggers VULK's backend generation, adding a PostgreSQL database and API endpoints alongside the game. This is common across the platform — 62% of all generated apps include a SQL database schema (VULK platform data, July 2026).

What makes game prompts work best?

Three.js games in VULK work best when you describe the mechanics clearly. Abstract descriptions like "make a fun game" produce generic results. Specific mechanics like "the player double-jumps, wall-slides, and dashes" produce games with those exact systems implemented.

Start with the core mechanic. Get it working in the preview. Then iterate -- add enemies, scoring, levels, sound, and visual polish through follow-up prompts. Each iteration builds on the existing code, so you accumulate complexity without starting over.

The combination of Three.js for rendering, Cannon.js for physics, and VULK's generation pipeline means you go from idea to playable prototype in minutes instead of days. From there, refinement through prompts or manual code editing gets you to a polished game you can ship.


FAQ

Do I need to know how to code to build a Three.js game in VULK?

No. The prompt describes mechanics in plain language and the pipeline generates the full project. That said, the output is standard TypeScript/JavaScript in a Vite project — if you can code, you can open any file and edit it directly alongside the AI.

Which physics engine does VULK use for generated games?

Cannon.js by default, running a fixed 1/60s timestep world synced to the render loop. If you prefer Rapier, name it in your prompt. Simple games (grid puzzles, lane runners) may skip a physics engine entirely in favor of direct position math — that is intentional and faster.

Can generated games work on phones?

Yes. Ask for touch controls ("virtual joystick on the left, jump button on the right") and mobile performance optimizations (lower shadow resolution, reduced draw distance). The deployed game is a static site, so it runs in any modern mobile browser.

Can I add a leaderboard or save player progress?

Yes — ask for it in a follow-up prompt. VULK generates a PostgreSQL-backed API with endpoints for scores or save states, wired into the game over screen. Backend deployment is included from the Builder plan up.

How much does it cost to build a game with VULK?

VULK is paid-only (no free tier). Plans start at Builder $19.99/mo, with a 3-day full-access intro from $3.99 that is credited to your first month if you continue. 3D Studio features start on Pro ($39.99/mo).

Who owns the game code?

You do. Export the complete source as a ZIP (Builder+) or sync to GitHub (Pro+). It is a standard Vite + Three.js project with no proprietary dependencies — it builds anywhere npm run build works.

Published by João Castro · 10 min read

Keep reading

All articles
VULK Support

Online

Hi! How can I help you today?

Popular topics

AI support • support.vulk.dev