agentleFS
alton47alton47/threejs-skills/skills/threejs-materials/SKILL.md

threejs-materials

Skill13 starsChanged 7 months agoMITView on GitHub

Configures Three.js materials — MeshStandardMaterial, MeshPhysicalMaterial, PBR pipeline, texture maps (color, normal, roughness, metalness, AO, emissive, environment). Use when the user asks about materials, textures, PBR, shading, opacity, transparency, or material properties. Trigger keywords: material, texture, PBR, roughness, metalness, normal map, emissive, transparent, MeshStandardMaterial.

Files
SKILL.md

Three.js Materials

MeshStandardMaterial (default PBR material)

const mat = new THREE.MeshStandardMaterial({
  color: 0xffffff, // base color (hex or THREE.Color)
  roughness: 0.5, // 0 = mirror, 1 = fully diffuse
  metalness: 0.0, // 0 = dielectric, 1 = metal
  envMapIntensity: 1.0, // environment map strength
});

See MAPS.md for complete texture map reference.

MeshPhysicalMaterial (extended PBR)

const mat = new THREE.MeshPhysicalMaterial({
  roughness: 0.1,
  metalness: 0.0,
  transmission: 1.0, // glass / transparency (0–1)
  thickness: 0.5, // refraction thickness
  ior: 1.5, // index of refraction (glass = 1.5)
  reflectivity: 0.5,
  iridescence: 1.0, // soap bubble iridescence
  iridescenceIOR: 1.3,
  sheen: 1.0, // fabric-like sheen
  sheenColor: 0xffffff,
  clearcoat: 1.0, // car paint clear coat
  clearcoatRoughness: 0.1,
});
// Note: transmission requires renderer.physicallyCorrectLights or specific setup

Loading Textures

const loader = new THREE.TextureLoader();
const texture = loader.load("/textures/diffuse.jpg", (tex) => {
  tex.colorSpace = THREE.SRGBColorSpace; // for color/albedo maps
});

// For non-color maps (normal, roughness, metalness, AO) — linear space
const normalMap = loader.load("/textures/normal.jpg");
// normalMap.colorSpace stays LinearSRGBColorSpace (default) — do NOT set sRGB

const mat = new THREE.MeshStandardMaterial({
  map: texture, // albedo / color
  normalMap: normalMap,
  roughnessMap: loader.load("/textures/roughness.jpg"),
  metalnessMap: loader.load("/textures/metalness.jpg"),
  aoMap: loader.load("/textures/ao.jpg"), // requires uv2
  aoMapIntensity: 1.0,
  emissiveMap: loader.load("/textures/emissive.jpg"),
  emissive: new THREE.Color(0xffffff),
  emissiveIntensity: 1.0,
});

Texture Settings

texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(4, 4); // tile 4x in each direction
texture.offset.set(0.5, 0); // offset UV
texture.rotation = Math.PI / 4;
texture.center.set(0.5, 0.5); // rotation pivot

// Filter — affects sharpness
texture.minFilter = THREE.LinearMipmapLinearFilter; // default, best quality
texture.magFilter = THREE.LinearFilter;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy(); // max sharpness at angle
texture.generateMipmaps = true; // default true

Environment Map

import { RGBELoader } from "three/addons/loaders/RGBELoader.js";
import { PMREMGenerator } from "three";

const pmrem = new PMREMGenerator(renderer);
pmrem.compileEquirectangularShader();

new RGBELoader().load("/env/studio.hdr", (hdr) => {
  const envMap = pmrem.fromEquirectangular(hdr).texture;
  scene.background = envMap;
  scene.environment = envMap; // applies to ALL PBR materials
  hdr.dispose();
  pmrem.dispose();
});

Transparency & Blending

// Alpha via texture
mat.alphaMap = loader.load("/textures/alpha.jpg");
mat.transparent = true;
mat.alphaTest = 0.5; // discard below threshold (no depth sorting needed)

// Full transparency with blending
mat.transparent = true;
mat.opacity = 0.5;
mat.depthWrite = false; // prevents z-fighting for transparent objects
mat.side = THREE.DoubleSide; // render front and back

// Blending modes
mat.blending = THREE.NormalBlending;
mat.blending = THREE.AdditiveBlending; // glow, particles
mat.blending = THREE.MultiplyBlending;

Other Materials

new THREE.MeshBasicMaterial({ color: 0xff0000 }); // unlit, no shadows
new THREE.MeshLambertMaterial({ color: 0xff0000 }); // flat shading, fast
new THREE.MeshPhongMaterial({ color: 0xff0000, shininess: 100 }); // specular
new THREE.MeshToonMaterial({ color: 0xff0000 }); // cel shading
new THREE.MeshNormalMaterial(); // debug normals
new THREE.MeshDepthMaterial(); // debug depth
new THREE.LineBasicMaterial({ color: 0xffffff });
new THREE.LineDashedMaterial({ color: 0xffffff, dashSize: 0.1, gapSize: 0.05 });
new THREE.PointsMaterial({ size: 0.05, sizeAttenuation: true });
new THREE.SpriteMaterial({ map: texture });

Material Disposal

mat.dispose(); // always dispose when removing from scene
// dispose all textures separately:
mat.map?.dispose();
mat.normalMap?.dispose();

Common Gotchas

  • aoMap requires a second UV set: geo.setAttribute('uv2', geo.attributes.uv) or uv1 in r152+
  • Color/albedo textures: set colorSpace = THREE.SRGBColorSpace
  • Non-color textures (normal, rough, metal, AO): leave as LinearSRGBColorSpace
  • transparent: true triggers alpha sorting — use alphaTest instead for hard cutouts
  • MeshPhysicalMaterial with transmission requires a background or scene.environment
  • envMapIntensity only works on MeshStandardMaterial and MeshPhysicalMaterial

Download now (ZIP)

  • Other versions20 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 1

    1. FkennedyFox/claude-skills★ 0100% same

    Wrote their own version · 19

    1. calesthio/OpenMontage★ 72ksame name
    2. CloudAI-X/threejs-skills★ 3.7ksame name
    3. educlopez/thegridcn-ui★ 390same name
    4. quiet-node/gesture-lab★ 185same name
    5. kumaran-is/claude-code-onboarding★ 35same name
    6. ruloCode/hermes-os★ 15same name
    7. LinHao-city/StoryMind★ 10same name
    8. full-stack-skills/threejs-skills★ 9same name
    9. chadixearth/graphyloop★ 3same name
    10. codetesla51/skills★ 3same name

    9 more not listed

    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.

  • Used alongsideProjects with it also use pose-library-design, video-toolkit and 7 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • LinHao-citySkill

      pose-library-design

      Design reusable 2D character pose libraries, action cycles, and expression states for data-driven animation.

      Also in 3 projects that use this

    • LinHao-citySkill

      video-toolkit

      Create professional videos autonomously using claude-code-video-toolkit — AI voiceovers, image generation, music, talking heads, and Remotion rendering.

      Also in 3 projects that use this

    • jaron-goh-centrSkill

      website-to-video

      Capture a general website/URL and turn it into a video OF the site — tour, showcase, or social clip built from captured screenshots and the site's own brand assets. Use for portfolio / blog / docs / landing-page showcases. Not a product launch or promo, even from a URL (/product-launch-video). Unclear → /hyperframes.

      Also in 4 projects that use this

    • dAAAbSkill

      heygen

      Also in 3 projects that use this

    • chrisvoncsefalvaySkill

      d3-viz

      Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.

      Also in 4 projects that use this

    • +4 more from LinHao-city
  • In this repository15 other files it gives its agents.

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.