Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Stand up a three.js scene: import maps and the three/addons path, the Scene/PerspectiveCamera/WebGLRenderer trio, the setAnimationLoop render loop, responsive resize, and OrbitControls. Use when starting or debugging a three.js app — when the user mentions three.js, THREE.Scene, WebGLRenderer, PerspectiveCamera, the render loop, resizing, or OrbitControls. For models use threejs-gltf-loading; for materials/lights use threejs-materials-lighting.
.claude/skills/gamedev-skills-threejs-scene-setup/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 32% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 197% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 67% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 23% | 0% |
Create the foundation of a three.js app: module loading, the scene/camera/renderer trio, the render loop, responsive resizing, and camera controls. Patterns target r184. Read the installed three version before changing an existing project because examples and addons move across releases.
canvas responsive, setting up the animation loop, or adding OrbitControls.
package.json depends on three and code does import as THREE from'three'.
When not to use: loading .gltf/.glb models or skinned animation → threejs-gltf-loading. Materials, lights, shadows, environment maps → threejs-materials-lighting. 2D rendering → pixijs-rendering.
specifier 'three' and 'three/addons/' must be mapped (in HTML or by a bundler). Addons (controls, loaders) live under three/addons/....
Scene (root of the graph), a PerspectiveCamera(fov,aspect, near, far) moved back from the origin, and a WebGLRenderer whose domElement is in the DOM. Set size and pixelRatio.
new Mesh(geometry, material) and scene.add(mesh). With alit material you also need a light (see threejs-materials-lighting).
renderer.setAnimationLoop(fn). It's the modern,WebXR-/WebGPU-safe replacement for hand-rolled requestAnimationFrame. Use a Clock for delta time.
camera.aspect, call updateProjectionMatrix(), and renderer.setSize(...).
OrbitControls for orbit/pan/zoom while developing. Confirm somethingactually renders (a lit cube, the controls responding) before assuming success.
html<canvas id="c"></canvas> <script type="importmap"> { "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.184.0/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.184.0/examples/jsm/" } } </script> <script type="module" src="./main.js"></script>
With a bundler (Vite/webpack), skip the import map and just npm i three; the same import statements resolve.
js// main.js import * as THREE from 'three'; const canvas = document.querySelector('#c'); const renderer = new THREE.WebGLRenderer({ canvas, antialias: true }); renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); // cap for perf renderer.setSize(window.innerWidth, window.innerHeight); const scene = new THREE.Scene(); scene.background = new THREE.Color(0x101018); const camera = new THREE.PerspectiveCamera( 60, // vertical field of view (degrees) window.innerWidth / window.innerHeight, // aspect 0.1, // near 100 // far ); camera.position.set(3, 2, 5); camera.lookAt(0, 0, 0); const cube = new THREE.Mesh( new THREE.BoxGeometry(1, 1, 1), new THREE.MeshNormalMaterial() // unlit; shows orientation without a light ); scene.add(cube);
jsconst clock = new THREE.Clock(); renderer.setAnimationLoop(() => { const dt = clock.getDelta(); // seconds since last frame cube.rotation.x += dt; // frame-rate independent cube.rotation.y += dt * 0.7; renderer.render(scene, camera); }); // renderer.setAnimationLoop(null); // stop the loop
jsfunction onResize() { const w = window.innerWidth, h = window.innerHeight; camera.aspect = w / h; camera.updateProjectionMatrix(); // required after changing aspect renderer.setSize(w, h); } window.addEventListener('resize', onResize);
jsimport { OrbitControls } from 'three/addons/controls/OrbitControls.js'; const controls = new OrbitControls(camera, renderer.domElement); controls.enableDamping = true; // inertial feel controls.target.set(0, 0, 0); renderer.setAnimationLoop(() => { controls.update(); // needed every frame when damping is on renderer.render(scene, camera); });
Failed to resolve module specifier "three" → missing import map (or bundlerconfig). Map both "three" and "three/addons/"; addon paths must end with /.
or you used a lit material (MeshStandardMaterial) with no light. Move the camera back; use MeshNormalMaterial/MeshBasicMaterial to verify geometry first.
renderer.render inside the loop, or youcall setAnimationLoop but render outside it.
update camera.aspect + updateProjectionMatrix().
renderer.setPixelRatio(...); cap it (≈2) so4K/retina screens don't tank performance.
enableDamping = true you must callcontrols.update() every frame.
<script src="three.min.js"> → since r147 three.js shipsES modules only; use type="module" + import maps.
Group, parent/child transforms,Object3D add/remove), OrthographicCamera for 2.5D, and disposing of geometries/materials/textures to avoid leaks, read references/scene-graph.md.
threejs-materials-lighting — give surfaces a lit look (lights, shadows, PBR).threejs-gltf-loading — load 3D models and play their animations.pixijs-rendering — 2D rendering in the browser.fps-shooter — a 3D genre template that composes three.js skills.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 11,556 | 15,830 | +37% | 1 | 1 | 0% | 2,512 | 4,025 | +60% | 0 | 0 | — |
case-02 | fail→pass | 17,696 | 14,366 | -19% | 1 | 1 | 0% | 2,703 | 3,558 | +32% | 0 | 0 | — |
case-03 | fail→fail | 115,419 | 15,808 | -86% | 1 | 1 | 0% | 3,944 | 4,194 | +6% | 0 | 0 | — |
case-04 | pass→pass | 12,215 | 16,194 | +33% | 1 | 1 | 0% | 2,270 | 3,796 | +67% | 0 | 0 | — |
case-05 | pass→pass | 18,138 | 18,927 | +4% | 1 | 1 | 0% | 3,561 | 4,370 | +23% | 0 | 0 | — |
case-06 | pass→pass | 17,186 | 14,886 | -13% | 1 | 1 | 0% | 3,620 | 4,240 | +17% | 0 | 0 | — |
case-11 | pass→pass | 4,677 | 3,551 | -24% | 1 | 1 | 0% | 911 | 2,258 | +148% | 0 | 0 | — |
case-07 | pass→pass | 11,427 | 6,617 | -42% | 1 | 1 | 0% | 2,252 | 2,962 | +32% | 0 | 0 | — |
case-08 | pass→pass | 17,866 | 17,890 | +0% | 1 | 1 | 0% | 2,954 | 3,896 | +32% | 0 | 0 | — |
case-09 | pass→pass | 14,049 | 8,750 | -38% | 1 | 1 | 0% | 1,425 | 2,556 | +79% | 0 | 0 | — |
case-10 | pass→pass | 4,621 | 3,004 | -35% | 1 | 1 | 0% | 796 | 2,276 | +186% | 0 | 0 | — |
case-12 | pass→pass | 12,030 | 8,106 | -33% | 1 | 1 | 0% | 2,389 | 3,555 | +49% | 0 | 0 | — |
case-13 | pass→pass | 7,817 | 7,045 | -10% | 1 | 1 | 0% | 1,369 | 2,932 | +114% | 0 | 0 | — |
case-14 | pass→pass | 11,773 | 16,999 | +44% | 1 | 1 | 0% | 2,092 | 3,669 | +75% | 0 | 0 | — |
case-15 | pass→pass | 3,893 | 5,131 | +32% | 1 | 1 | 0% | 618 | 2,616 | +323% | 0 | 0 | — |
case-20 | pass→pass | 15,840 | 8,677 | -45% | 1 | 1 | 0% | 2,421 | 3,207 | +32% | 0 | 0 | — |
case-16 | pass→pass | 9,712 | 3,275 | -66% | 1 | 1 | 0% | 1,609 | 2,282 | +42% | 0 | 0 | — |
case-17 | fail→pass | 4,758 | 4,128 | -13% | 1 | 1 | 0% | 815 | 2,417 | +197% | 0 | 0 | — |
case-18 | pass→pass | 6,983 | 4,329 | -38% | 1 | 1 | 0% | 1,206 | 2,442 | +102% | 0 | 0 | — |
case-19 | pass→pass | 14,415 | 10,001 | -31% | 1 | 1 | 0% | 2,429 | 3,324 | +37% | 0 | 0 | — |
case-21 | pass→pass | 4,274 | 2,852 | -33% | 1 | 1 | 0% | 751 | 2,194 | +192% | 0 | 0 | — |
case-22 | pass→pass | 16,730 | 8,435 | -50% | 1 | 1 | 0% | 2,352 | 3,225 | +37% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.