threejs-materials-lighting
БесплатноБез исполняемых скриптовНе проверенLights and shades three.js r187 scenes: standard, physical and unlit materials, lights, shadows, HDR environment lighting and tone mapping. Use when a mesh…
от gamedev-skills★ 12 656 звёзд на GitHubОб этом скилле
three.js materials and lighting
Makes three.js surfaces read correctly: the right material, a light rig, working shadows and image-based lighting (IBL). Patterns target r187. Lighting has been physically based since r155, so intensities from older tutorials look far too dark.
When to use
- A mesh renders black or flat, a material choice is needed, lights or shadows are being added, or environment reflections (IBL) are being set up.
- Code constructs
MeshStandardMaterial,DirectionalLightand similar, or setsrenderer.shadowMap.enabled,scene.environmentorrenderer.toneMapping. - Not for the renderer, camera and loop (
threejs-scene-setup), loading models (threejs-gltf-loading), or custom GLSL and node shaders (shader-programmingfor the technique).
Workflow
- Rule out geometry first. Swap the material for
MeshNormalMaterial. If the mesh is still missing, the problem is the camera, scale or loading, not lighting. - Default to
MeshStandardMaterial. It reacts to lights andscene.environmentand matches glTF's PBR model. UseMeshPhysicalMaterialonly for clearcoat, transmission or sheen, andMeshBasicMaterialfor unlit UI, sprites and flat colour. - Light the scene: an environment map or a hemisphere fill, plus one directional key light. Start the key at about 2 to 3.
- Turn on shadows in three places: the renderer, the light, and each mesh's
castShadow/receiveShadow. Then fit the light's shadow camera to the play area. - Tag colour textures sRGB and leave data maps (normal, roughness, metalness) linear.
- Choose a tone mapping curve once, and finish any post-processing chain with
OutputPass. - Verify with Verify.
Patterns
1. PBR material under a key and fill
import * as THREE from 'three';
const material = new THREE.MeshStandardMaterial({
color: 0xcc4444,
roughness: 0.5, // 0 = mirror, 1 = matte
metalness: 0.0, // 0 = plastic, wood, skin; 1 = bare metal
});
scene.add(new THREE.Mesh(new THREE.SphereGeometry(1, 32, 16), material));
scene.add(new THREE.HemisphereLight(0xbbddff, 0x443322, 1.0)); // sky, ground, intensity
const key = new THREE.DirectionalLight(0xffffff, 2.5);
key.position.set(5, 10, 7);
scene.add(key);
2. Unlit material with a colour texture
const tex = new THREE.TextureLoader().load('assets/logo.png');
tex.colorSpace = THREE.SRGBColorSpace; // colour maps are sRGB
const logo = new THREE.MeshBasicMaterial({ map: tex, transparent: true }); // ignores lights
3. Shadows with a fitted shadow camera
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowMap; // soft since r182
const sun = new THREE.DirectionalLight(0xffffff, 3);
sun.position.set(8, 12, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048); // default 512
const cam = sun.shadow.camera; // orthographic for a DirectionalLight
cam.near = 1; cam.far = 40;
cam.left = -15; cam.right = 15; cam.top = 15; cam.bottom = -15;
scene.add(sun);
// scene.add(new THREE.CameraHelper(cam)); // draw the frustum while tuning
mesh.castShadow = true;
ground.receiveShadow = true;
For a level larger than the shadow frustum, move the light and its target with the player
each frame instead of growing the frustum, which spreads the same map over more ground. Add
the target to the scene (scene.add(sun.target)) so its world matrix updates.
4. PBR texture set
const loader = new THREE.TextureLoader();
const colorMap = loader.load('assets/brick_color.jpg');
colorMap.colorSpace = THREE.SRGBColorSpace;
const brick = new THREE.MeshStandardMaterial({
map: colorMap,
normalMap: loader.load('assets/brick_normal.jpg'), // data maps stay linear
roughnessMap: loader.load('assets/brick_rough.jpg'),
metalness: 0,
});
5. Image-based lighting from an HDR file
import { HDRLoader } from 'three/addons/loaders/HDRLoader.js'; // RGBELoader before r180
new HDRLoader().load('assets/studio.hdr', (hdr) => {
hdr.mapping = THREE.EquirectangularReflectionMapping;
scene.environment = hdr; // lights and reflects every PBR material
scene.background = hdr; // optional backdrop
});
renderer.toneMapping = THREE.ACESFilmicToneMapping; // default is NoToneMapping
renderer.toneMappingExposure = 1.0;
No HDR file? The reference shows RoomEnvironment through PMREMGenerator.
Verify
npm run build(ornpx tsc --noEmit) passes.- Probe the lighting state in the running page. Expose
rendererandsceneonwindow(Object.assign(window, { renderer, scene })). Then pass this expression to Playwright'spage.evaluateas a string, so it runs in the page and not in Node (the smoke script inthreejs-scene-setupworks), or ask the user to paste it into the browser console and report the output:
(() => {
const lights = [], casters = [], srgbMissing = [];
windo
Установить threejs-materials-lighting в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл threejs-materials-lighting?
Lights and shades three.js r187 scenes: standard, physical and unlit materials, lights, shadows, HDR environment lighting and tone mapping. Use when a mesh renders black or washed out, shadows are missing or full of acne, or EffectComposer darkens the image. Not for renderer setup (`threejs-scene-setup`), model loading (`threejs-gltf-loading`) or custom shaders (`shader-programming`).
Как установить скилл threejs-materials-lighting?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл threejs-materials-lighting запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic