Skip to main content
skill CX Codex

threejs · mengto — Claude Code skill: build Three.js 3D scenes

Guides your agent through building and debugging interactive Three.js scenes: scene, camera, lights, glTF loading, controls and performance.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add MengTo/Skills --skill threejs -a claude-code
Open on GitHub

What threejs does

The skill kicks in when a page needs real 3D rather than background effects: a spinning product, an interactive hero scene, shader work, 3D data viz. It keeps the agent on the core Three.js model — Scene, Camera, WebGLRenderer, a Mesh built from geometry plus material, lights when the material is not unlit — and the render loop driven by requestAnimationFrame.

Recipes are included. The minimal spinning cube sets up a renderer with antialias and alpha, a perspective camera, MeshStandardMaterial, an AmbientLight and a DirectionalLight, plus a resize handler using setPixelRatio(Math.min(window.devicePixelRatio, 2)) and updateProjectionMatrix(). A separate note tells the agent to honour prefers-reduced-motion: reduce and draw a still frame instead of running the loop.

Resource leaks get their own section. In a single-page app you call geometry.dispose(), material.dispose(), texture.dispose() and renderer.dispose() after a route change, remove listeners and cancel the RAF. Skip that and the tab crashes. The skill also warns against a high pixel ratio on phones and against oversized textures, since both slow the first paint. Before writing code the agent asks whether the scene is decorative or a functional viewer, which devices matter, and what asset formats and file-size limits you have.

What it helps with

  • stand up an interactive 3D scene without digging through the docs
  • fix stretched rendering after a window resize
  • track down leaked WebGL resources across route changes in an SPA
  • load a glTF model and wire up OrbitControls
  • stay inside a performance budget on mobile GPUs

Example prompts for the agent

  • Build a spinning cube with Three.js in canvas #c, with resize handling and prefers-reduced-motion
  • Load the model with GLTFLoader, add OrbitControls, and dispose everything on unmount
  • Why does the tab crash after a route change? Check dispose on geometries, materials and the renderer

How to install threejs

1Skills CLI (Vercel)

npx skills add MengTo/Skills --skill threejs -a claude-code

2Manually: put the files in place

~/.claude/skills/threejs/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/threejs/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about threejs

How do I install threejs in Claude?

Run npx skills add MengTo/Skills --skill threejs -a claude-code. The skill lands in ~/.claude/skills/threejs/SKILL.md.

What does the threejs skill do?

It tells the agent how to build and debug Three.js scenes: scene, camera, renderer, lights and materials, glTF loading, controls, and cleanup of WebGL resources.

Which platforms support the threejs skill?

Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each has its own install line, for example npx skills add MengTo/Skills --skill threejs -a cursor.

Source text

SKILL.md · MIT
---
name: threejs
description: Use when building or debugging interactive 3D scenes on the web with Three.js (scene/camera/renderer, lights/materials, GLTF loading, controls, performance). Helpful for designers shipping 3D UI moments.
---

# Three.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
```js
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

© MengTo · MIT · MengTo/Skills

Similar skills

Everything for Frontend and UI →

threejs by other authors comes first.

threejs nexu-io Guides the agent in building browser 3D scenes, materials, interactive controls, and post-processing with Three.js. CX Codex +1 3,400installs threejs mrgoonie A coding-agent skill that walks you through Three.js scenes, shaders and VR work. Useful when a project needs WebGL or WebGPU and you want the agent to know the API. CX Codex +1 1,200installs threejs secondsky A skill with reference files and working examples for Three.js: scenes, materials, lighting, shaders, GLTF loading. Useful when you build 3D in the browser. CX Codex +1 460installs threejs-loaders CloudAI-X Teaches your AI agent to load glTF models, textures, and HDR maps in three.js r186. Useful when wiring loading progress, color spaces, or WebGPU environments. CX Codex +1 12,900installs threejs-webgl freshtechbro Configures coding agents to build Three.js scenes, set up WebGL or WebGPU renderers, adjust lighting, and load glTF models for web 3D apps. CX Codex +1 4,600installs threejs-gltf-loading gamedev-skills Loads glTF/GLB models into three.js and plays their baked or skinned clips, with patterns for DRACO, Meshopt and KTX2. For the case where the file imports but nothing shows up on screen. CX Codex +1 5,600installs threejs-animation iart-ai A coding-agent skill for Three.js and React Three Fiber motion: scenes, GLTF clips, scroll-linked cameras, instancing and GPU cleanup. CX Codex +1 1,400installs threejs-asset-pipeline CloudAI-X A skill for compressing and validating glTF models before loading them in three.js: gltf-transform commands, Draco, meshopt, KTX2 and gltfjsx. CX Codex +1 1,300installs threejs-materials-lighting gamedev-skills Picks the right three.js material, adds lights and shadow maps, and wires an HDR environment so a model stops rendering black or flat. CX Codex +1 5,500installs

From the same set148

build-awwwards-quality-sites Provides art direction and implementation rules for motion-led, interactive websites. Guides the AI agent through GSAP choreography, smooth scrolling, and WebGL safeguards. CX Codex +1 3,100installs cinematic-gsap-lenis-motion-system Builds cinematic web animation systems using GSAP, ScrollTrigger, and Lenis. Ideal for luxury editorial layouts, creative portfolios, and smooth reveals. CX Codex +1 2,400installs beautiful-shadows A skill that hands your agent three exact Tailwind arbitrary shadow classes for cards, panels and popovers. Useful when default shadow-sm and shadow-lg look blunt. CX Codex +1 2,200installs cinematic-scroll-storytelling Generates scroll-driven landing page animations using Lenis and GSAP ScrollTrigger. It helps structure editorial storytelling, sticky card stacks, and masked typography reveals. CX Codex +1 2,100installs landing-page Skill for planning and copywriting single-offer landing pages for web apps or services. Sets up section order, benefit-driven copy formulas, and objection handling. CX Codex +1 2,000installs animation-on-scroll A skill that wires up scroll-reveal with IntersectionObserver, plus Tailwind animation classes and keyframes. CX Codex +1 2,000installs animation-systems Motion design guide for clean, product-grade web animations like Stripe, Linear, and Apple. Useful when building UI transitions, hover states, and modals. CX Codex +1 1,900installs gsap A skill that helps your coding agent write and debug GSAP web animations: timelines, ScrollTrigger, stagger, transforms. CX Codex +1 1,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor