gamedev-skills/awesome-gamedev-agent-skills/threejs-scene-setup
Claude Code and agent skill by gamedev-skills/awesome-gamedev-agent-skills
- community
- ext:[{"type":"plugin","description":"Custom plugin integration"}]
Checking that the SKILL.md file is still in the repository.
Sets up and debugs a plain three.js r187 game or 3D scene: import maps, Scene, PerspectiveCamera and WebGLRenderer, setAnimationLoop with Timer, resize, OrbitControls and WebGPURenderer. Use on "Failed to resolve module specifier three", a black canvas or nothing animating. Not for GLB loading (`threejs-gltf-loading`), materials (`threejs-materials-lighting`) or React Three Fiber.
Install
npx vskill@latest install gamedev-skills/awesome-gamedev-agent-skills/threejs-scene-setupSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as gamedev-skills/awesome-gamedev-agent-skills/threejs-scene-setup.
three.js scene setup
Builds the base every three.js game needs: module loading, the scene, camera and renderer, one render loop, resize handling, and a resolution budget. Patterns target r187. Read the installed three version first; addons, defaults and deprecations move every release.
When to use
- Bootstrapping a three.js scene, fixing a black or blank canvas, making the canvas
responsive, setting up the loop, adding OrbitControls, or choosing between WebGLRenderer and WebGPURenderer.
package.jsondepends onthree, or code doesimport * as THREE from 'three'.- Not for models and animation (
threejs-gltf-loading), surface look, lights and shadows
(threejs-materials-lighting), or React Three Fiber (@react-three/fiber) components, whose <Canvas> owns the renderer and loop. For 2D, use pixijs-rendering or Phaser.
Workflow
- Read `three` from `package.json` or the import map. An existing project keeps its
release unless the user asks to upgrade.
- Resolve `three` and `three/addons/` with a bundler or an import map; addons live under
three/addons/....
- Create the scene, camera and renderer, with the camera moved back from the origin and
the pixel ratio capped (Pattern 2).
- Prove the pipeline with an unlit mesh first (
MeshNormalMaterial). Only then switch
to lit materials and add lights.
- Drive everything from `renderer.setAnimationLoop` with a
Timerand a clamped delta.
Keep game state in plain objects and copy it onto meshes each frame. Meshes then stay a view, and state can be saved and tested without a GPU.
- Handle resize (aspect, projection matrix, renderer size) and add
OrbitControls
while developing.
- Verify with Verify.
Patterns
1. Import map (no bundler)
With Vite or webpack, npm i three and the same imports resolve without a map.
2. Scene, camera and renderer
3. Render loop with Timer
Call update() with no argument when the timer is connected. Visibility reset samples performance.now(), so passing the loop's timestamp can produce a negative delta right after a hidden tab returns. The clamp also protects a fixed-step accumulator; the 0.1 s upper bound drops time after a stall on purpose, so tune it to the game's catch-up policy.
4. Resize
5. OrbitControls
6. WebGPURenderer, only when needed
Stay on WebGLRenderer by default. Switch when the project needs TSL node materials or compute shaders; WebGPURenderer falls back to a WebGL 2 backend where WebGPU is missing.
Scenes, cameras, built-in Mesh*Materials and most addons carry over. Custom GLSL (ShaderMaterial, onBeforeCompile) does not.
Verify
npm run build(ornpx tsc --noEmitwith@types/threematching thethreeversion)
passes.
- Smoke-test in a headless browser. With the dev server running and
window.renderer
exposed (Pattern 2), run node smoke.mjs <url> after npm i -D playwright and npx playwright install chromium. Without browser automation, ask the user to open the page, then report the console output and whether the cube is visible and turning.
Expect drawCalls above 0, a canvas size other than 0 × 0, and no errors. Open both screenshots: the second must still show the scene, or something holds GPU objects that the restore did not rebuild.
Gotchas
- `Failed to resolve module specifier "three"` → no import map or bundler. Map both
"three" and "three/addons/"; the addons entry must end with /.
- Black canvas, no errors → the camera sits inside or behind the object, or a lit
material has no light. Move the camera back and test with MeshNormalMaterial.
- Stretched view after resize → the renderer was resized but
camera.aspectand
updateProjectionMatrix() were not updated.
- Slow or hot on HiDPI and phones → a pixel ratio of 2 draws four times the pixels of 1,
so a cap of 2 does nothing on a 2× screen. Start at 1.25 to 1.5 and offer a resolution setting; adaptive resolution is in the reference.
- Simulation freezes after the tab returns → in r186 and r187 a loop timestamp passed to
timer.update(time) can precede the visibility reset and give a negative delta. Call update() with no argument and clamp as in Pattern 3.
- `THREE.Clock: This module has been deprecated` → since r183; use
THREE.Timer. - Old tutorials use `<script src="three.min.js">` or `examples/js/...` →
examples/jswas
removed in r148 and build/three.min.js in r161. Use modules and an import map.
- OrbitControls feel dead → with
enableDampingon,controls.update()must run every
frame.
- Canvas goes black after a GPU reset or many tabs → the WebGL context was lost.
WebGLRenderer handles webglcontextlost and rebuilds its own state on restore; code that keeps raw GL objects or skips the loop while lost does not recover. Test with forceContextLoss() / forceContextRestore() as in Verify.
- `.render() called before the backend is initialized` (WebGPURenderer) → `await
renderer.init() before a direct render()/compute(), or render only from setAnimationLoop`, which initialises first.
- `Material "ShaderMaterial" is not compatible`, or `onBeforeCompile` is ignored
(WebGPURenderer) → it renders node materials only. Port the effect to TSL or stay on WebGLRenderer.
References
- Read `references/scene-graph.md` for coordinate conventions,
parenting with Group, OrthographicCamera for 2.5D, disposing geometries, materials and textures between levels, stopping the loop, render-on-demand, and adaptive resolution.
Related skills
threejs-materials-lighting: lights, shadows, PBR and environment maps.threejs-gltf-loading: loading models and playing their animations.camera-systems: follow, orbit and first-person camera design.fps-shooter: a 3D genre that builds on these skills.
Version notes
Last verified: 2026-11-11 against three r187 (npm three@0.187.0, published 2026-10-30; @types/three@0.187.0).
Timer.update()is unchanged between r186 and r187, so the negative-delta note holds.- The r187 WebGPU examples still map
threeandthree/webgputobuild/three.webgpu.js. - Sources: r187 release notes,
Migration Guide, r187 Timer.js, r187 responsive rendering manual, WebGLRenderer.js context handling.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/web-engines/threejs-scene-setup/SKILL.md
Popularity
- Repository stars
- 1,071
- Repository forks
- 87
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
pluginCustom plugin integration
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/gamedev-skills/awesome-gamedev-agent-skills/threejs-scene-setup)