threejs-impl-shadows

Configure and debug shadow maps in Three.js scenes across light types.

1|Updated Aug 20, 2023
One-click install
npx skills add https://github.com/imanlangaran/mini-projects --skill threejs-impl-shadows-imanlangaran
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-impl-shadows
Source: https://github.com/imanlangaran/mini-projects/tree/main/react/three-gsap/.claude/skills/threejs-impl-shadows
Command: npx skills add https://github.com/imanlangaran/mini-projects --skill threejs-impl-shadows-imanlangaran

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Shadows in Three.js fail silently when any of the three opt-in steps (renderer, light, mesh) is missed, and artifacts like shadow acne, peter panning, and clipped frustums are hard to diagnose without guidance. This Skill provides the exact configuration steps, bias tuning values, and debugging workflows to get correct shadows on the first attempt. ## Core Features & Use Cases - Three-Step Shadow Setup: Enforces the renderer, light, and mesh opt-in flags plus correct shadow map type selection (Basic, PCF, PCFSoft, VSM). - Per-Light Configuration: Covers DirectionalLight orthographic frustum sizing, SpotLight auto-configured perspective shadows, and the 6x cost of PointLight cubemap shadows. - Artifact Diagnosis: Provides a flowchart for fixing shadow acne, peter panning, shadow swimming, VSM light bleeding, and transparent material shadows via customDepthMaterial. - Use Case: You add a DirectionalLight to your scene but see no shadows. The Skill walks you through enabling renderer.shadowMap, setting castShadow/receiveShadow flags, sizing the shadow camera frustum with CameraHelper, and tuning bias and normalBias to remove acne. ## Quick Start Ask the AI to enable PCFSoft shadows for a DirectionalLight in your Three.js scene and fix any shadow acne on the ground plane.

Frequently Asked Questions about threejs-impl-shadows

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable shadows in Three.js?

Enable shadows with three opt-in steps: set renderer.shadowMap.enabled to true, set light.castShadow to true, and set castShadow or receiveShadow on each mesh. Missing any one step produces no shadows with no error message.

Why are my Three.js shadows not showing?

Shadows fail silently when the renderer, light, or mesh flags are missing, or when the shadow camera frustum does not cover the scene. Use a CameraHelper on light.shadow.camera to visualize the frustum and verify far plane distance.

How do I fix shadow acne in Three.js?

Fix shadow acne by setting shadow.bias to a small negative value like -0.0001 and shadow.normalBias around 0.02 for curved surfaces. Increasing shadow.mapSize also improves depth precision and reduces striping artifacts.

What is the difference between PCFSoftShadowMap and VSMShadowMap?

PCFSoftShadowMap uses a variable kernel for soft penumbra and ignores shadow.radius, while VSMShadowMap supports radius and blurSamples for Gaussian blur. VSM can cause light bleeding through thin geometry, so PCFSoft is the safer general choice.

How many PointLight shadows can a Three.js scene handle?

Use at most one shadow-casting PointLight because each renders six cubemap faces per frame. Prefer SpotLight shadows, which cost one render pass each, and keep shadow map sizes at 512 or 1024 for PointLights.

How do I make transparent objects cast correct shadows in Three.js?

Assign a customDepthMaterial to the mesh with a MeshDepthMaterial that matches the visible material's alphaMap and alphaTest values. Fully transparent objects without alphaTest cannot cast correct real-time shadows and need baked or contact shadows.