Threejs
Meng ToCommunityCreated by Meng To
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to implementing 3D scenes on the web using Three.js. It covers the core architectural components like scenes, cameras, and renderers, while emphasizing performance optimization, asset management, and proper resource disposal to prevent memory leaks in single-page applications.
What it does
- Explains the core Three.js scene graph and render loop architecture.
- Provides patterns for loading 3D assets like glTF models and textures.
- Offers best practices for performance tuning and mobile optimization.
- Details essential cleanup procedures to avoid WebGL memory leaks.
- Includes boilerplate code for setting up responsive 3D canvases.
When to use it
- When creating interactive product viewers or 3D hero scenes.
- When implementing custom shaders or complex material effects.
- When building 3D data visualizations on the web.
- When you need full control over the 3D rendering pipeline.
Advantages
- Reduces common pitfalls like stretched rendering or GPU performance issues.
- Ensures robust resource management for long-running web applications.
- Provides clear guidance on asset optimization for faster load times.
- Helps maintain accessibility by supporting reduced motion preferences.
Usage examples
- “How do I set up a basic Three.js scene with a spinning cube?”
- The agent provides a complete, responsive code snippet including the renderer, camera, scene, and animation loop.
- “My Three.js app crashes after navigating between pages, what is wrong?”
- The agent identifies potential memory leaks and provides instructions on how to properly dispose of geometries, materials, and textures.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/mengto/threejs/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip threejs.zip -d .agents/skills
Documentation by Meng To
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+MaterialLights (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
Files
- ATTRIBUTION.mdAdded by AutoGineer836 B
- LICENSELicence file added by AutoGineer1.0 KiB
- REFERENCES.md49 B
- SKILL.md3.4 KiB
- demo/PROMPT.md1.9 KiB
- demo/index.html15.9 KiB
- demo/preview.jpg38.7 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Meng To
- Publisher
- Meng To (Community)
- Source
- MengTo/Skills · agent-skills/web-design/threejs · commit 5ea1661
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Meng To or Meng To.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download threejs.zip