Template prompt: Three.js Game
Paste everything below into a new Bash.tv space.
Make a starter template: Three.js Game.
- Technology: Three.js with Vite
- Sample gameplay: A small 3D collect sample: a capsule player on a flat arena with a few boxes, a follow camera, 8 glowing spheres to collect.
- Project docs: full
Must haves
- Simple shapes and materials made in code (no model files).
- Renderer pixel ratio capped at 2, resize on window and orientation changes,
renderer.setAnimationLoop. - Touch: left thumb stick to move, drag on the right half to turn the camera.
- Handle
webglcontextlostandwebglcontextrestored. - Register
window.bash.preview.onCaptureso the Bash preview can capture the canvas (see the bash-js-sdk skill). - Check it in the viewer’s preview or with
check_gpu_render, not the sandbox browser.
Rules for every template
- Read the
apps-and-gamesandbash-js-sdkskills first. Load Bash.js inindex.html. Don’t use alert, confirm or prompt. - This is a template: a small, clean, working starting point for new games, not a finished game. Build only what this prompt asks for. No extra modes, levels, pages or demos.
- The sample gameplay is short and clearly marked as the part to replace. Keep tunable numbers in
src/config.js. - No generated art or music. Draw shapes in code. Leave sound wired up through the Audio Manager with no sound files, and say in the README where to add them.
- Keyboard, mouse and touch all work (and gamepad where the Input Manager is used). The game pauses when the tab is hidden.
- Title, play, pause and game over screens, and restarting without reloading the page.
- Set the test hook:
window.__game = { state, pause, resume, restart, gameOver }(details in the quality gates guide). - Wrap the game loop with the Error Handler’s
guard()so one error doesn’t freeze the game.
The toolkit
Download the toolkit once and use its parts instead of writing them again:
curl -fsSL https://bash.l00.pw/toolkit/toolkit.zip -o /tmp/toolkit.zip
python3 -c "import zipfile; zipfile.ZipFile('/tmp/toolkit.zip').extractall('/tmp')"
- Components: copy these from
/tmp/toolkit/components/<name>/<name>.jsintosrc/components/unchanged:input-manager,touch-controller,audio-manager,settings-manager,timer-manager,performance-monitor,error-handler. Each one’s README (/tmp/toolkit/components/<name>/README.md, or https://bash.l00.pw/toolkit/components/) shows how to use it. If a component needs a change, don’t edit it in place; note it in the template’sdocs/TECHNICAL_DEBT.md. - Project docs:
python3 /tmp/toolkit/project-docs/new-project.py . --name "Three.js Game template", then fill every file in for this template. No template text may be left. - Quality gates:
python3 scripts/run-gates.py . --root dist --build "npm run build"(guide: https://bash.l00.pw/toolkit/quality-gates/).
Proving it works
- Run the quality gates and keep the report (
.project/VALIDATION_REPORT.md). Each gate must be PASS, FAIL, NOT TESTED or NOT APPLICABLE, with evidence. Never mark something PASS because the code looks right. - Fix every FAIL. Anything still NOT TESTED needs a reason in the report.
- This template uses the GPU. Never load it in the sandbox browser. Check it in the viewer’s preview (
look_at_preview) or withcheck_gpu_render, and record what you checked by hand in the evidence file (.project/evidence.json). - Check the phone layout with the viewer’s preview at phone size, and restore their setting afterwards.
README for people using the template
The template’s README.md must say: what’s included, how to run it, the controls, which files to change first to make a new game from it, which toolkit components it uses, and the latest quality gates summary.
Done when
- The sample plays from title to game over and back, on desktop and on a phone.
- All the must-haves above are in.
- Project docs filled in, with no template text left.
- Quality gates: no FAIL, and every NOT TESTED explained.
- Committed with a clear message.
When it’s done, tell me in plain words what the template includes, what to change first to start a new game, and anything that is still NOT TESTED.