What Three.js does
Three.js is a powerful library for creating and managing 3D graphics in the browser using WebGL. This skill is designed for developers and designers who want to build interactive 3D scenes, whether for product displays, data visualizations, or immersive user interfaces. It provides a structured approach to setting up a 3D environment with essential components like scenes, cameras, and renderers, while also addressing common challenges such as performance tuning and asset management.
The core mental model of Three.js revolves around creating a scene graph, where you define a Scene as the root, add a Camera for perspective, and use a Renderer to display your graphics. You can create Mesh objects by combining geometries and materials, and add lighting to enhance visual effects. The skill also covers important aspects of rendering, including the use of requestAnimationFrame for smooth animations and how to properly dispose of resources to prevent memory leaks.
This skill is particularly useful when you need full control over the 3D experience, such as when implementing product spins or interactive hero scenes. It also guides you in using common APIs for loading assets, handling user inputs through controls, and optimizing performance for various devices. With practical examples, including a minimal spinning cube, users can quickly grasp the foundational concepts and start building their own 3D applications.
However, it's important to recognize potential pitfalls, such as improper handling of window resizing or failing to dispose of WebGL resources, which can lead to crashes or performance issues. This skill provides the necessary guidance to avoid these common mistakes, making it an essential resource for anyone looking to create robust 3D web applications.
When to use it
Use this skill when building interactive 3D scenes that require detailed control over rendering and asset management.
When not to use it
This skill may not be suitable for simple 2D applications or when you require a quick solution without the need for performance tuning.
What you can build with it
Creating a Product Viewer
Use Three.js to build an interactive 3D model viewer for showcasing products, allowing users to rotate and zoom in on details.
Developing Data Visualizations
Implement Three.js to create engaging 3D data visualizations that enhance the user's understanding of complex datasets.
Building an Interactive Hero Scene
Design a captivating hero section for a website with animated 3D elements that respond to user interactions.
How to install Three.js
View source1. Install with the skills CLI
npx skills add mengto/skills/threejs --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mengtoThree.js — WebGL 3D Scenes Skill
When to use
- Real 3D: product spins, interactive hero scenes, shaders/material effects, 3D data viz
- You need full control beyond “background effects”
- You can budget time for asset pipeline + performance tuning
Core mental model
- Create:
Scene(root graph)Camera(Perspective/Orthographic)Renderer(WebGLRenderer)Mesh=Geometry+Material- Lights (if using non-unlit materials)
- Render loop:
requestAnimationFrame(animate)- Update time-based animations, controls, mixers, then
renderer.render(scene, camera)
Key APIs/patterns
- Setup:
const renderer = new THREE.WebGLRenderer({ canvas, antialias, alpha })renderer.setSize(width, height, false)renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
- Camera:
camera.aspect = width / height; camera.updateProjectionMatrix()
- Scene graph:
scene.add(object)/object.position/rotation/scale
- Loading assets:
GLTFLoader(models),TextureLoader(images),DRACOLoader(compressed glTF)
- Controls (common):
OrbitControls(debug/product),PointerLockControls(FPS), custom pointer handlers
- Cleanup (important in SPAs):
geometry.dispose(),material.dispose(),texture.dispose(),renderer.dispose()- Remove event listeners; cancel RAF.
Common pitfalls
- Not handling resize → stretched/cropped rendering
- Too high devicePixelRatio → mobile GPU meltdown
- Leaking WebGL resources (not disposing) → crashes after route changes
- Loading huge textures/models → slow start; use compressed textures, Draco/KTX2, smaller maps
- Using too many lights/shadows → expensive; fake lighting with baked textures when possible
Quick recipes
1) Minimal spinning cube
import * as THREE from "three";
const canvas = document.querySelector("#c");
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, 1, 0.1, 100);
camera.position.set(0, 0, 4);
const geom = new THREE.BoxGeometry(1, 1, 1);
const mat = new THREE.MeshStandardMaterial({ color: 0x7c3aed });
const mesh = new THREE.Mesh(geom, mat);
scene.add(mesh);
scene.add(new THREE.AmbientLight(0xffffff, 0.8));
const dir = new THREE.DirectionalLight(0xffffff, 0.8);
dir.position.set(2, 2, 2);
scene.add(dir);
function resize() {
const w = canvas.clientWidth;
const h = canvas.clientHeight;
renderer.setSize(w, h, false);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
camera.aspect = w / h;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
function animate(t) {
mesh.rotation.y = t * 0.0006;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
2) Respect reduced motion
- If
prefers-reduced-motion: reduce, render a still frame (no RAF) or slow updates.
What to ask the user
- Is this decorative (hero) or functional 3D (product viewer)?
- Target devices: mobile? older iPhones?
- Asset format availability (glTF, HDRI, textures) and file size constraints
- Accessibility/reduced motion requirements
Frequently asked questions about Three.js
Similar skills
Playwright Component Testing
Test React and Vue components in isolation with Playwright.
Fluent UI Blazor
Integrate Fluent UI components in Blazor applications effortlessly.
Build MCP App
Create interactive UI widgets for MCP servers.
Web Design Reviewer
Identify and fix design issues in websites efficiently.
Markstream Install
Seamlessly integrate Markstream for Markdown rendering.
GSAP & Framer Scroll Animation
Create advanced scroll animations effortlessly.

