Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Creates simple Three.js web apps with scene setup, lighting, geometries, materials, animations, and responsive rendering. Use for: "Create a threejs scene/app/showcase" or when user wants 3D web content. Supports ES modules, modern Three.js r150+ APIs.
.claude/skills/aiskillstore-threejs-builder/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 48% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 358% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 162% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 60% | 0% |
A focused skill for creating simple, performant Three.js web applications using modern ES module patterns.
Three.js is built on the scene graph—a hierarchical tree of objects where parent transformations affect children. Understanding this mental model is key to effective 3D web development.
Before creating a Three.js app, ask:
Core principles:
scene renders. Use Group for hierarchical transforms.requestAnimationFrame or renderer.setAnimationLoop.html<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Three.js App</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { overflow: hidden; background: #000; } canvas { display: block; } </style> </head> <body> <script type="module"> import * as THREE from 'https://unpkg.com/three@0.160.0/build/three.module.js'; // Scene setup const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); document.body.appendChild(renderer.domElement); // Your 3D content here // ... camera.position.z = 5; // Animation loop renderer.setAnimationLoop((time) => { renderer.render(scene, camera); }); // Handle resize window.addEventListener('resize', () => { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); }); </script> </body> </html>
Built-in primitives cover most simple app needs. Use BufferGeometry only for custom shapes.
Common primitives:
BoxGeometry(width, height, depth) - cubes, boxesSphereGeometry(radius, widthSegments, heightSegments) - balls, planetsCylinderGeometry(radiusTop, radiusBottom, height) - tubes, cylindersTorusGeometry(radius, tube) - donuts, ringsPlaneGeometry(width, height) - floors, walls, backgroundsConeGeometry(radius, height) - spikes, conesIcosahedronGeometry(radius, detail) - low-poly spheres (detail=0)Usage:
javascriptconst geometry = new THREE.BoxGeometry(1, 1, 1); const material = new THREE.MeshStandardMaterial({ color: 0x44aa88 }); const mesh = new THREE.Mesh(geometry, material); scene.add(mesh);
Choose material based on lighting needs and visual style.
Material selection guide:
MeshBasicMaterial - No lighting, flat colors. Use for: UI, wireframes, unlit effectsMeshStandardMaterial - PBR lighting. Default for realistic surfacesMeshPhysicalMaterial - Advanced PBR with clearcoat, transmission. Glass, waterMeshNormalMaterial - Debug, rainbow colors based on normalsMeshPhongMaterial - Legacy, shininess control. Faster than StandardCommon material properties:
javascript{ color: 0x44aa88, // Hex color roughness: 0.5, // 0=glossy, 1=matte (Standard/Physical) metalness: 0.0, // 0=non-metal, 1=metal (Standard/Physical) emissive: 0x000000, // Self-illumination color wireframe: false, // Show edges only transparent: false, // Enable transparency opacity: 1.0, // 0=invisible, 1=opaque (needs transparent:true) side: THREE.FrontSide // FrontSide, BackSide, DoubleSide }
No light = black screen (except BasicMaterial/NormalMaterial).
Light types:
AmbientLight(intensity) - Base illumination everywhere. Use 0.3-0.5DirectionalLight(color, intensity) - Sun-like, parallel rays. Cast shadowsPointLight(color, intensity, distance) - Light bulb, emits in all directionsSpotLight(color, intensity, angle, penumbra) - Flashlight, cone of lightTypical lighting setup:
javascriptconst ambientLight = new THREE.AmbientLight(0xffffff, 0.4); scene.add(ambientLight); const mainLight = new THREE.DirectionalLight(0xffffff, 1); mainLight.position.set(5, 10, 7); scene.add(mainLight); const fillLight = new THREE.DirectionalLight(0x88ccff, 0.5); fillLight.position.set(-5, 0, -5); scene.add(fillLight);
Shadows (advanced, use when needed):
javascriptrenderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; mainLight.castShadow = true; mainLight.shadow.mapSize.width = 2048; mainLight.shadow.mapSize.height = 2048; mesh.castShadow = true; mesh.receiveShadow = true;
Transform objects over time using the animation loop.
Animation patterns:
javascriptrenderer.setAnimationLoop((time) => { mesh.rotation.x = time * 0.001; mesh.rotation.y = time * 0.0005; renderer.render(scene, camera); });
javascriptrenderer.setAnimationLoop((time) => { mesh.position.y = Math.sin(time * 0.002) * 0.5; renderer.render(scene, camera); });
javascriptconst mouse = new THREE.Vector2(); window.addEventListener('mousemove', (event) => { mouse.x = (event.clientX / window.innerWidth) * 2 - 1; mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; }); renderer.setAnimationLoop(() => { mesh.rotation.x = mouse.y * 0.5; mesh.rotation.y = mouse.x * 0.5; renderer.render(scene, camera); });
Import OrbitControls from examples for interactive camera movement:
html<script type="module"> import * as THREE from 'https://unpkg.com/three@0.160.0/build/three.module.js'; import { OrbitControls } from 'https://unpkg.com/three@0.160.0/examples/jsm/controls/OrbitControls.js'; // ... scene setup ... const controls = new OrbitControls(camera, renderer.domElement); controls.enableDamping = true; controls.dampingFactor = 0.05; renderer.setAnimationLoop(() => { controls.update(); renderer.render(scene, camera); }); </script>
javascriptconst geometry = new THREE.BoxGeometry(1, 1, 1); const material = new THREE.MeshStandardMaterial({ color: 0x00ff88 }); const cube = new THREE.Mesh(geometry, material); scene.add(cube); renderer.setAnimationLoop((time) => { cube.rotation.x = time * 0.001; cube.rotation.y = time * 0.001; renderer.render(scene, camera); });
javascriptconst particleCount = 1000; const geometry = new THREE.BufferGeometry(); const positions = new Float32Array(particleCount * 3); for (let i = 0; i < particleCount * 3; i += 3) { positions[i] = (Math.random() - 0.5) * 50; positions[i + 1] = (Math.random() - 0.5) * 50; positions[i + 2] = (Math.random() - 0.5) * 50; } geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3)); const material = new THREE.PointsMaterial({ color: 0xffffff, size: 0.1 }); const particles = new THREE.Points(geometry, material); scene.add(particles);
javascript// Background grid const gridHelper = new THREE.GridHelper(50, 50, 0x444444, 0x222222); scene.add(gridHelper); // Foreground object const mainGeometry = new THREE.IcosahedronGeometry(1, 0); const mainMaterial = new THREE.MeshStandardMaterial({ color: 0xff6600, flatShading: true }); const mainMesh = new THREE.Mesh(mainGeometry, mainMaterial); scene.add(mainMesh);
Three.js uses hexadecimal color format: 0xRRGGBB
Common hex colors:
0x000000, White: 0xffffff0xff0000, Green: 0x00ff00, Blue: 0x0000ff0x00ffff, Magenta: 0xff00ff, Yellow: 0xffff000xff8800, Purple: 0x8800ff, Pink: 0xff0088❌ Not importing OrbitControls from correct path Why bad: Controls won't load, THREE.OrbitControls is undefined in modern Three.js Better: Use import { OrbitControls } from 'three/addons/controls/OrbitControls.js' or unpkg examples/jsm path
❌ Forgetting to add object to scene Why bad: Object won't render, silent failure Better: Always call scene.add(object) after creating meshes/lights
❌ Using old requestAnimationFrame pattern instead of setAnimationLoop Why bad: More verbose, doesn't handle XR/WebXR automatically Better: renderer.setAnimationLoop((time) => { ... })
❌ Creating new geometries in animation loop Why bad: Massive memory allocation, frame rate collapse Better: Create geometry once, reuse it. Transform only position/rotation/scale
❌ Using too many segments on primitives Why bad: Unnecessary vertices, GPU overhead Better: Default segments are usually fine. SphereGeometry(1, 32, 16) not SphereGeometry(1, 128, 64)
❌ Not setting pixelRatio cap Why bad: 4K/5K displays run at full resolution, poor performance Better: Math.min(window.devicePixelRatio, 2)
❌ Everything in one giant function Why bad: Hard to modify, hard to debug Better: Separate setup into functions: createScene(), createLights(), createMeshes()
❌ Hardcoding all values Why bad: Difficult to tweak and experiment Better: Define constants at top: const CONFIG = { color: 0x00ff88, speed: 0.001 }
IMPORTANT: Each Three.js app should feel unique and context-appropriate.
Vary by scenario:
Vary visual elements:
Avoid converging on:
Three.js is a tool for interactive 3D on the web.
Effective Three.js apps:
Modern Three.js (r150+) uses ES modules from three package or CDN. CommonJS patterns and global THREE variable are legacy.
For advanced topics (GLTF models, shaders, post-processing), see references/advanced-topics.md.
Claude is capable of creating elegant, performant 3D web experiences. These patterns guide the way—they don't limit the result.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 35,231 | 51,603 | +46% | 1 | 1 | 0% | 7,030 | 11,263 | +60% | 0 | 0 | — |
case-02 | fail→fail | 46,873 | 45,116 | -4% | 1 | 1 | 0% | 8,264 | 11,693 | +41% | 0 | 0 | — |
case-03 | pass→pass | 59,480 | 31,073 | -48% | 1 | 1 | 0% | 6,178 | 9,134 | +48% | 0 | 0 | — |
case-04 | pass→pass | 12,196 | 17,328 | +42% | 1 | 1 | 0% | 1,297 | 5,942 | +358% | 0 | 0 | — |
case-05 | pass→pass | 21,362 | 35,619 | +67% | 1 | 1 | 0% | 3,382 | 8,865 | +162% | 0 | 0 | — |
case-06 | pass→pass | 22,178 | 24,397 | +10% | 1 | 1 | 0% | 4,729 | 7,573 | +60% | 0 | 0 | — |
case-07 | pass→pass | 20,047 | 8,564 | -57% | 1 | 1 | 0% | 2,907 | 5,049 | +74% | 0 | 0 | — |
case-08 | pass→pass | 11,637 | 15,501 | +33% | 1 | 1 | 0% | 2,397 | 5,920 | +147% | 0 | 0 | — |
case-09 | pass→pass | 18,257 | 16,724 | -8% | 1 | 1 | 0% | 3,352 | 6,545 | +95% | 0 | 0 | — |
case-10 | pass→pass | 17,316 | 13,436 | -22% | 1 | 1 | 0% | 3,262 | 4,784 | +47% | 0 | 0 | — |
case-11 | pass→pass | 13,764 | 4,423 | -68% | 1 | 1 | 0% | 1,543 | 4,196 | +172% | 0 | 0 | — |
case-12 | pass→pass | 23,757 | 14,611 | -38% | 1 | 1 | 0% | 3,345 | 5,960 | +78% | 0 | 0 | — |
case-13 | pass→pass | 17,185 | 15,711 | -9% | 1 | 1 | 0% | 2,425 | 5,836 | +141% | 0 | 0 | — |
case-14 | pass→pass | 20,500 | 11,481 | -44% | 1 | 1 | 0% | 2,937 | 5,613 | +91% | 0 | 0 | — |
case-15 | pass→pass | 19,841 | 16,834 | -15% | 1 | 1 | 0% | 2,998 | 5,798 | +93% | 0 | 0 | — |
case-16 | pass→pass | 26,578 | 10,454 | -61% | 1 | 1 | 0% | 4,313 | 5,371 | +25% | 0 | 0 | — |
case-17 | pass→pass | 12,142 | 5,334 | -56% | 1 | 1 | 0% | 1,544 | 4,372 | +183% | 0 | 0 | — |
case-18 | pass→pass | 9,455 | 4,596 | -51% | 1 | 1 | 0% | 744 | 4,199 | +464% | 0 | 0 | — |
case-19 | fail→fail | 17,506 | 14,667 | -16% | 1 | 1 | 0% | 2,094 | 5,136 | +145% | 0 | 0 | — |
case-20 | pass→pass | 13,656 | 9,807 | -28% | 1 | 1 | 0% | 1,669 | 4,262 | +155% | 0 | 0 | — |
case-21 | pass→pass | 18,893 | 11,730 | -38% | 1 | 1 | 0% | 2,384 | 4,633 | +94% | 0 | 0 | — |
case-22 | pass→pass | 6,899 | 12,083 | +75% | 1 | 1 | 0% | 1,390 | 4,809 | +246% | 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 +5 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.