---
name: "threejs-webgl-scene-camera-rig"
description: "Construct performant, responsive 3D WebGL scenes with custom lighting and camera rigs in Three.js."
metadata:
  author: "Mr.doob"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "initialize three.js scene"
  - "setup perspective camera threejs"
  - "configure webglrenderer shadow map"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Three.js WebGL Scene & Camera Rig

Sets up Three.js WebGLRenderer with physically correct lighting, shadow maps, perspective camera frustums, orbit controls, and window resize listeners without canvas distortion.

## When to Invoke
Invoke this skill whenever you need to:
- initialize three.js scene
- setup perspective camera threejs
- configure webglrenderer shadow map

## Execution SOP & Rules
1. Always set renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)) to prevent mobile GPU thermal throttling.
2. Update camera.aspect = width / height and call camera.updateProjectionMatrix() inside resize handlers.
3. Enable renderer.shadowMap.enabled = true and choose PCFSoftShadowMap for smooth shadow boundaries.
4. Dispose of unused geometries, materials, and textures explicitly to prevent WebGL memory leaks.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
