agentleFS
JbmanllrJbmanllr/agent-skills/skills/three-js/SKILL.md

three-js

Skill2 starsChanged 10 months agoMITView on GitHub

This skill should be used when the user asks to "create a 3D scene", "add a mesh", "implement OrbitControls", "load a GLTF model", "add bloom post-processing", "write a custom shader", "create particle effects", "optimize Three.js performance", "use WebGPU", "add shadows", "animate a model", or mentions Three.js, threejs, WebGL, WebGPU, GLTF, raycaster, shader material, PBR material, or post-processing effects.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. Mindrally/skills★ 275same name
    2. sivaguru-2113/Agent-persona★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository8 other files it gives its agents.

The file

Files
SKILL.md

Three.js Complete Reference (Vanilla)

React Three Fiber users: This reference is for vanilla Three.js. For R3F/Drei patterns, use the r3f-best-practices skill. However, understanding Three.js concepts here helps when working with R3F since R3F is a React renderer for Three.js.

Quick Start

import * as THREE from 'three';

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);

const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);

scene.add(new THREE.AmbientLight(0xffffff, 0.5));
const light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(5, 5, 5);
scene.add(light);

camera.position.z = 5;

function animate() {
  requestAnimationFrame(animate);
  cube.rotation.x += 0.01;
  cube.rotation.y += 0.01;
  renderer.render(scene, camera);
}
animate();

Reference Index

Load the appropriate reference file based on task:

Core Foundation

ReferenceUse When
references/01-fundamentals.mdScene setup, renderer config, Object3D hierarchy, coordinate systems
references/02-geometry.mdCreating shapes, BufferGeometry, instancing, points, lines
references/06-cameras.mdCamera types, frustum, viewport, projection
references/13-math.mdVector3, Matrix4, Quaternion, Euler, Color, MathUtils

Visual Appearance

ReferenceUse When
references/03-materials.mdPBR materials, shader materials, all material types
references/04-textures.mdTexture loading, UV mapping, render targets, environment maps
references/05-lighting.mdLight types, shadows, IBL, light probes
references/11-shaders.mdCustom GLSL shaders, uniforms, varyings, shader patterns

Motion & Interaction

ReferenceUse When
references/08-animation.mdKeyframe animation, skeletal, morph targets, procedural motion
references/09-interaction.mdRaycasting, selection, drag, coordinate conversion
references/10-controls.mdOrbitControls, FlyControls, PointerLockControls, etc.

Assets

ReferenceUse When
references/07-loaders.mdGLTF, FBX, textures, HDR, Draco compression, async patterns

Effects

ReferenceUse When
references/12-postprocessing.mdBloom, DOF, SSAO, custom effects, EffectComposer

Advanced

ReferenceUse When
references/14-performance.mdOptimization, profiling, LOD, culling, batching
references/15-node-materials.mdTSL (Three Shading Language), node-based materials
references/16-physics-vr.mdPhysics engines, WebXR, VR/AR integration
references/17-webgpu.mdWebGPU renderer, compute shaders, WGSL
references/18-patterns.mdArchitecture patterns, asset management, cleanup, state

Common Patterns Quick Reference

Resize Handler

window.addEventListener('resize', () => {
  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(window.innerWidth, window.innerHeight);
});

Cleanup/Dispose

function dispose(obj) {
  obj.traverse(child => {
    if (child.geometry) child.geometry.dispose();
    if (child.material) {
      if (Array.isArray(child.material)) {
        child.material.forEach(m => m.dispose());
      } else {
        child.material.dispose();
      }
    }
  });
}

Animation Loop with Clock

const clock = new THREE.Clock();

function animate() {
  const delta = clock.getDelta();
  const elapsed = clock.getElapsedTime();

  // Use delta for frame-rate independent animation
  mixer?.update(delta);

  requestAnimationFrame(animate);
  renderer.render(scene, camera);
}

Import Patterns

// Core
import * as THREE from 'three';

// Addons (controls, loaders, effects)
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';

// Compression support
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';

Version Notes

This reference targets Three.js r150+ with notes for:

  • WebGPU support (r150+)
  • Node materials / TSL
  • Modern ES module imports

For version-specific APIs, check the Three.js migration guide.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.