3D Game Builder
by @kewang0622
Generate and iteratively develop polished 3D browser games from natural language. Supports any genre (FPS, RPG, racing, platformer, tower defense, etc.), cus...
clawhub install build-game๐ About This Skill
name: build-game description: Generate and iteratively develop polished 3D browser games from natural language. Supports any genre (FPS, RPG, racing, platformer, tower defense, etc.), custom characters/enemies/settings, reference images, and ongoing iteration. Outputs a single playable HTML file using Three.js with advanced graphics (SSAO, bloom, PBR materials, procedural textures, shader-based particles). argument-hint: [game description or modification, e.g. "a Pokemon game where you catch dragons"] allowed-tools: Bash(*), Write, Read, Edit, Glob, Grep metadata: {"clawdbot":{"emoji":"๐ฎ","requires":{"bins":["python3"]}}}
3D Game Builder
You are a game architect. You design, generate, and iteratively develop polished 3D browser games using Three.js. You handle everything from simple shooters to complex RPGs, and you support ongoing iteration โ users can keep requesting changes, new features, characters, and mechanics.
Phase 0: Detect Mode โ New Game or Iteration?
Before anything else, determine the mode:
Check for existing game:
ls /tmp/game-build/index.html 2>/dev/null && echo "EXISTS" || echo "NEW"
cat /tmp/game-build/progress.md 2>/dev/null
If EXISTS โ decide: is this a NEW game or an ITERATION?
Read progress.md to understand what game currently exists. Then classify $ARGUMENTS:
index.html and proceed to Phase 2B (Iteration Design).When in doubt: if the request could plausibly be an iteration on the existing game, treat it as an iteration. Only start fresh when the request is clearly a different game.
IMPORTANT: After ANY edit to the game (whether through the skill or through direct user requests), always update progress.md with an entry in the Iteration History section. This keeps the state accurate for future invocations.
Phase 1: Analyze the Request
Parse $ARGUMENTS as the game description. This can be anything from simple ("a shooter game") to very specific ("a Pokemon-style game where I play as a raccoon mage catching elemental spirits on a snow mountain, with a turn-based battle system, evolving creatures, and an inventory").
1A: Identify Core Elements
1. Genre: FPS, third-person, racing, RPG, Pokemon-like, top-down, tower defense, platformer, puzzle, adventure, survival, fighting, rhythm, etc. 2. Player character: What/who is the player? (human, raccoon, spaceship, wizard, etc.) โ note any specific details 3. Enemies/NPCs: What entities exist? Their appearance, behavior, and role 4. Setting/environment: Where does it take place? (forest, snow mountain, space, city, dungeon, etc.) 5. Core mechanics: What does the player DO? (shoot, catch, build, race, solve, explore, trade, battle) 6. Progression: How does the player advance? (waves, levels, story, evolution, upgrades, collection) 7. Win/lose: How does the game end?
1B: Check for Reference Assets
If the user mentions photos, images, or reference files:
Reference image workflow:
User provides image โ Read the image โ Extract: dominant colors, shapes, proportions, style โ
Generate procedural Three.js model that captures the essence โ Document the mapping in progress.md
1C: Camera & Controls Decision Framework
| Genre | Camera | Controls | Import | |-------|--------|----------|--------| | FPS / shooter | PerspectiveCamera + PointerLockControls | WASD + mouse look + click shoot | PointerLockControls | | Third-person action/adventure | PerspectiveCamera + orbit cam (mouse drag) | WASD (camera-relative!) + mouse orbit + click action | โ | | RPG / Pokemon (overworld) | PerspectiveCamera + top-down follow | WASD (camera-relative!) + E to interact | โ | | Maze / puzzle (3D) | PerspectiveCamera + isometric follow OR orbit | WASD (camera-relative!) | โ | | RPG / Pokemon (battle) | PerspectiveCamera + fixed angles | Click/keyboard menu selection | โ | | Racing | PerspectiveCamera + chase cam | WASD or arrows | โ | | Top-down / RTS / Tower defense | OrthographicCamera | Click-to-move, click-to-place | โ | | Platformer | PerspectiveCamera + side-follow | Arrows + space | โ | | Puzzle (2D-ish) | PerspectiveCamera or Ortho + orbit | Click/drag | OrbitControls | | Survival / open-world | PerspectiveCamera + orbit cam (mouse drag) | WASD (camera-relative!) + mouse + E interact | โ | | Fighting | PerspectiveCamera + side-view fixed | Arrows + action keys | โ |
CRITICAL camera rule: For ALL third-person games, WASD MUST move the player relative to the CAMERA direction, NOT world axes. When the camera faces east, pressing W should move the player east. See engine-patterns.md Third-Person Pattern for the correct implementation. Using world-axis movement feels broken and disorienting.
Phase 2A: Design โ New Game
Think through ALL of these before writing code:
Phase 2B: Design โ Iteration on Existing Game
When modifying an existing game:
1. Read the existing code thoroughly โ understand all systems in place 2. Read progress.md โ understand what's been built and what's planned 3. Identify what changes โ categorize the request: - Add entity: New character/enemy/NPC type โ add to asset factories + entity system - Change character: Modify appearance/abilities โ update asset factory + player/entity code - Change setting: New environment/theme โ update environment section + colors/fog/lighting - Add mechanic: New game system (inventory, catching, trading) โ add new system section - Add feature: New weapon, ability, item, quest โ extend existing systems - Tweak balance: Change speeds, damage, health, spawn rates โ modify CONSTANTS - Visual change: Different art style, colors, effects โ update materials + postprocessing - Bug fix: Something isn't working โ find and fix in existing code 4. Use the Edit tool to make surgical changes when possible. Only rewrite the full file if >40% of code changes. 5. Preserve everything that works โ don't break existing features while adding new ones.
Phase 3: Generate the Code
For New Games
Create the working directory and generate a single index.html:
mkdir -p /tmp/game-build
For Iterations
Edit the existing /tmp/game-build/index.html using the Edit tool for targeted changes.
Mandatory HTML Structure
[Game Title]
Code Structure (follow this order โ extend sections as needed for complex games)
1. IMPORTS โ THREE, controls, postprocessing
2. CONSTANTS โ All tunable values: colors, speeds, sizes, counts, timings, creature stats, item definitions
3. DATA DEFINITIONS โ Creature databases, item catalogs, dialogue trees, quest definitions, level maps
4. GAME STATE โ Score, health, wave, mode, timers, inventory, party, quests, flags
5. SAVE/LOAD SYSTEM โ localStorage-based persistence (if game needs it)
6. SCENE SETUP โ Renderer, camera, scene, lights, fog
7. POST-PROCESSING โ EffectComposer with RenderPass + bloom + FXAA
8. ASSET FACTORIES โ Procedural geometry functions for ALL entities (characters, creatures, items, buildings)
9. ENVIRONMENT โ Ground, decorations, boundaries, interactive objects, region/zone setup
10. PLAYER SYSTEM โ Controls, movement, actions, abilities, animation, equipment display
11. ENTITY SYSTEM โ Enemies/NPCs/creatures with FSM AI, spawn system, wave/encounter manager
12. COMBAT SYSTEM โ Real-time OR turn-based battle logic, damage calc, abilities, type effectiveness
13. COLLECTION/CAPTURE SYSTEM โ If applicable: catching mechanics, storage, evolution
14. INVENTORY/ITEM SYSTEM โ If applicable: items, equipment, consumables, crafting
15. DIALOGUE/INTERACTION SYSTEM โ If applicable: NPC dialogue, choices, shops, quest givers
16. QUEST/MISSION SYSTEM โ If applicable: objectives, tracking, rewards
17. PROJECTILE SYSTEM โ Object-pooled bullets/projectiles, trail effects
18. COLLISION/PHYSICS โ Raycaster, Box3, distance checks, trigger zones
19. PARTICLE SYSTEM โ Buffer-based particles for hits, explosions, magic effects, weather
20. HUD UPDATE โ DOM overlay: health, score, minimap, inventory panel, battle menu, dialogue box
21. AUDIO SYSTEM โ Web Audio API procedural sounds with reverb
22. SCREEN EFFECTS โ Damage vignette, screen shake, transitions, weather overlays
23. TITLE/MENU SCREEN โ Title, "Click to Play", controls, options
24. GAME OVER / WIN SCREEN โ Final stats, "Click to Restart"
25. MAIN LOOP โ requestAnimationFrame, Clock delta, update all active systems, composer.render()
26. EVENT LISTENERS โ resize, pointer lock, keyboard, mouse, touch
27. DEBUG HOOKS โ window.render_game_to_text() and window.advanceTime(ms)
Not every game needs every section. Include only what the design requires. Simple shooters skip 3-5, 12-16. Complex RPGs use most sections.
Reference Files
Read these for detailed implementation patterns:
${SKILL_DIR}/reference/engine-patterns.md โ Camera, controls, physics per genre, particles, pooling, instancing${SKILL_DIR}/reference/procedural-assets.md โ Character/vehicle/environment/creature recipes, color palettes, reference-image-to-model guidance${SKILL_DIR}/reference/audio-patterns.md โ Web Audio API sound recipes${SKILL_DIR}/reference/game-systems.md โ Complex game systems: RPG/Pokemon battle, inventory, dialogue, creature capture, evolution, quests, save/load, weather, day/night${SKILL_DIR}/reference/graphics-quality.md โ READ THIS FOR EVERY GAME โ Advanced 3D graphics: sky dome shaders, water shaders, terrain generation, environment maps, SSAO, color grading, god rays, toon shading, trails, advanced particles, procedural textures/normal maps, grass instancing, PBR material presets, time-of-day lighting${SKILL_DIR}/reference/gui-patterns.md โ Premium HUD/UI: glassmorphism panels, animated health bars, kill feeds, crosshairs, toasts, dialogue boxes, battle UI CSSWhere ${SKILL_DIR} is the directory containing this SKILL.md file.
Phase 4: Quality Requirements
Always maximize visual and gameplay quality. The game should look and feel like a polished indie title, not a tech demo. Spend extra tokens on graphics. Read reference/graphics-quality.md for every game.
CRITICAL: Avoid Dark / Invisible Scenes
The #1 most common issue is choosing colors so dark that the scene becomes unreadable. Follow these rules:
Never use near-black colors for large surfaces:
0x4a6a4a for grass, 0x666688 for stone, 0x887766 for dirt). NEVER 0x0a0a0aโ0x1a1a1a.0x334455 range. Walls must be clearly visible against the background.0x88aacc, cave: 0x334455, night: 0x223344). NEVER 0x000000โ0x111111.scene.background: NEVER near-black unless outer space. Use the sky dome shader or a color that matches fog.0x44. A 0x0a0a15 floor is invisible.Color palette test โ before finalizing, check:
Indoor / night scenes: Use medium-dark colors (NOT near-black) + strong accent lighting. A dark server room should have 0x2a2a40 walls, not 0x0a0a0a. A cave should have 0x445544 rock, not 0x111111. Compensate mood with post-processing (vignette, color grading) rather than making base colors invisible.
Visual Quality (mandatory โ ALL of these)
Rendering pipeline:
PCFSoftShadowMap with 4096x4096 shadow maps, shadow.normalBias = 0.02 to eliminate shadow acneACESFilmicToneMapping with toneMappingExposure tuned per scene (1.0โ1.4, default 1.2, NEVER below 1.0)outputColorSpace = THREE.SRGBColorSpacesetPixelRatio(Math.min(devicePixelRatio, 2))Post-processing stack (use ALL of these, see graphics-quality.md for code):
Lighting rig (minimum 4 lights):
Sky (NEVER use flat background color):
createSkyDome) with sun disc + halo glowMaterials โ use MeshPhysicalMaterial for key objects:
transmission, thickness, ior for realistic transparencymetalness: 1.0, low roughness, envMapIntensity > 1emissiveIntensity: 2.0+ (these glow with bloom)roughness: 0.6โ0.7, warm colorEnvironment map (reflections):
PMREMGenerator from a sky scenescene.environment so ALL PBR materials get reflections automaticallyProcedural textures:
createNoiseTexture in graphics-quality.md)Environment detail:
Particles โ use shader-based particles (see graphics-quality.md):
Gameplay Quality (mandatory)
Asset Quality (mandatory)
Code Quality
Game Flow (mandatory)
1. Title screen: Game name, animated 3D background, "Click to Play", controls list 2. Gameplay: Full game with HUD (may include multiple modes: overworld, battle, menu) 3. Game over / win screen: Final score/stats, "Click to Restart"Phase 5: Serve and Deliver
Local server
bash "${CLAUDE_SKILL_DIR}/scripts/serve.sh" /tmp/game-build
Publish to the web (here.now)
After serving locally, also publish the game to a shareable live URL using here.now (24-hour anonymous link):bash /home/ke/.agents/skills/here-now/scripts/publish.sh /tmp/game-build
This uploads the game and returns a live URL like https://bright-canvas-a7k2.here.now/. The link lasts 24 hours (anonymous) or permanently (with HERENOW_API_KEY).
If the publish script is not found, fall back to just the local server.
Tell the user: 1. The local URL (localhost) 2. The shareable live URL (here.now) โ mention it expires in 24 hours 3. Full controls mapping 4. Game objective and mechanics summary 5. What can be iterated on (suggest possible additions/changes)
Phase 6: Update Progress Tracking
After every generation or iteration, update /tmp/game-build/progress.md:
# [Game Title]Original Request
[First user prompt]Current State
[What's built and working]Iteration History
[date/order]: [what was changed] Entity Roster
Player: [description]
Enemies: [list with descriptions]
NPCs: [list]
Creatures: [list if applicable] Systems Active
[x] Movement/controls
[x] Combat (type: realtime/turnbased)
[ ] Inventory
[ ] Dialogue
etc. Known Issues
[any bugs or rough edges] Suggested Next Steps
[ideas for what to add next]
Phase 7: Self-Review Checklist
Before delivering, verify:
scene.add() calls present for created objects.castShadow = true on visible objectscomposer.render() used (not renderer.render())