
Threejs Lighting
Configure Three.js lights, shadows, and IBL in a WebGL scene when your solo 3D product needs readable materials without guessing light types.
Install
npx skills add https://github.com/cloudai-x/threejs-skills --skill threejs-lightingWhat is this skill?
- Quick-start AmbientLight plus DirectionalLight scene wiring
- Comparison table of 6 light types with shadow support and relative GPU cost
- Patterns for HemisphereLight, PointLight, SpotLight, and RectAreaLight
- Guidance when adding lights, configuring shadows, IBL, and perf tuning
- Runtime color and intensity adjustments on existing light instances
Adoption & trust: 3.3k installs on skills.sh; 2.3k GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Frontend Designanthropics/skills
Vercel React Best Practicesvercel-labs/agent-skills
Remotion Best Practicesremotion-dev/skills
Vercel Composition Patternsvercel-labs/agent-skills
Develop Userscriptsxixu-me/skills
Next Best Practicesvercel-labs/next-skills
Journey fit
Primary fit
3D lighting is frontend product work during Build when scenes, heroes, or configurators are assembled in the browser. Frontend is canonical: the skill is Three.js scene API usage (Ambient, Directional, shadows, IBL), not backend or DevOps.
Common Questions / FAQ
Is Threejs Lighting safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Threejs Lighting
# Three.js Lighting ## Quick Start ```javascript import * as THREE from "three"; // Basic lighting setup const ambientLight = new THREE.AmbientLight(0xffffff, 0.5); scene.add(ambientLight); const directionalLight = new THREE.DirectionalLight(0xffffff, 1); directionalLight.position.set(5, 5, 5); scene.add(directionalLight); ``` ## Light Types Overview | Light | Description | Shadow Support | Cost | | ---------------- | ---------------------- | -------------- | -------- | | AmbientLight | Uniform everywhere | No | Very Low | | HemisphereLight | Sky/ground gradient | No | Very Low | | DirectionalLight | Parallel rays (sun) | Yes | Low | | PointLight | Omnidirectional (bulb) | Yes | Medium | | SpotLight | Cone-shaped | Yes | Medium | | RectAreaLight | Area light (window) | No\* | High | \*RectAreaLight shadows require custom solutions ## AmbientLight Illuminates all objects equally. No direction, no shadows. ```javascript // AmbientLight(color, intensity) const ambient = new THREE.AmbientLight(0xffffff, 0.5); scene.add(ambient); // Modify at runtime ambient.color.set(0xffffcc); ambient.intensity = 0.3; ``` ## HemisphereLight Gradient from sky to ground color. Good for outdoor scenes. ```javascript // HemisphereLight(skyColor, groundColor, intensity) const hemi = new THREE.HemisphereLight(0x87ceeb, 0x8b4513, 0.6); hemi.position.set(0, 50, 0); scene.add(hemi); // Properties hemi.color; // Sky color hemi.groundColor; // Ground color hemi.intensity; ``` ## DirectionalLight Parallel light rays. Simulates distant light source (sun). ```javascript // DirectionalLight(color, intensity) const dirLight = new THREE.DirectionalLight(0xffffff, 1); dirLight.position.set(5, 10, 5); // Light points at target (default: 0, 0, 0) dirLight.target.position.set(0, 0, 0); scene.add(dirLight.target); scene.add(dirLight); ``` ### DirectionalLight Shadows ```javascript dirLight.castShadow = true; // Shadow map size (higher = sharper, more expensive) dirLight.shadow.mapSize.width = 2048; dirLight.shadow.mapSize.height = 2048; // Shadow camera (orthographic) dirLight.shadow.camera.near = 0.5; dirLight.shadow.camera.far = 50; dirLight.shadow.camera.left = -10; dirLight.shadow.camera.right = 10; dirLight.shadow.camera.top = 10; dirLight.shadow.camera.bottom = -10; // Shadow softness dirLight.shadow.radius = 4; // Blur radius (PCFSoftShadowMap only) // Shadow bias (fixes shadow acne) dirLight.shadow.bias = -0.0001; dirLight.shadow.normalBias = 0.02; // Helper to visualize shadow camera const helper = new THREE.CameraHelper(dirLight.shadow.camera); scene.add(helper); ``` ## PointLight Emits light in all directions from a point. Like a light bulb. ```javascript // PointLight(color, intensity, distance, decay) const pointLight = new THREE.PointLight(0xffffff, 1, 100, 2); pointLight.position.set(0, 5, 0); scene.add(pointLight); // Properties pointLight.distance; // Maximum range (0 = infinite) pointLight.decay; // Light falloff (physically correct = 2) ``` ### PointLight Shadows ```javascript pointLight.castShadow = true; pointLight.shadow.mapSize.width = 1024; pointLight.shadow.mapSize.height = 1024; // Shadow camera (perspective - 6 directions for cube map) pointLight.shadow.camera.near = 0.5; pointLight.shadow.camera.far = 50; pointLight.shadow.bias = -0.005; ``` ## SpotLight Cone-shaped light. Like a flashlight or stage light. ```javascript // SpotLight(color, intensity, distance, angle, penumbra, decay) const spotLight = new THREE.SpotLight(0xffffff, 1, 100, Math.PI / 6, 0.5, 2); spotLight.position.set(0, 10, 0); // Target (light points at this) spotLight.target.position.