# Tree Leaves Physics — Reproducible Prompt

## Task
Build a single-file seasonal tree-canopy physics benchmark in `index.html` using Three.js (via CDN) and vanilla JavaScript. No external images. Hostable on CodePen, Vercel, or Cloudflare Pages.

## Theme
A single rooted harbour plane tree (Platanus) cycles through a full seasonal loop: spring budburst → summer full canopy → autumn colour shift → winter bare branches with leaf detachment → regrowth. The scene must feel alive, windy, and emotionally resonant.

## Visual Requirements
- **Trunk & branches**: Procedurally generated via recursive branching with tapering thickness. Bark-brown material with slight roughness. The tree must be rooted to a visible ground plane.
- **Canopy**: Thousands of individual leaves attached to branch tips. Each leaf is a small, flat, lobed shape (plane-tree leaf silhouette) using vertex colors or instance colors.
- **Seasonal colour palette**:
  - Spring: soft lime green (#a8e063) → fresh green (#56ab2f)
  - Summer: deep verdant green (#2d6a4f) → emerald (#1b4332)
  - Autumn: amber (#f4a261) → burnt sienna (#e76f51) → rust (#9b2226)
  - Winter: bare branches only; fallen leaves on ground as muted brown points
- **Lighting**: Directional sun + hemisphere ambient + subtle fog for depth. Shadows enabled with PCFSoftShadowMap.
- **Ground**: Earth-toned plane with subtle noise-based colour variation. Scattered fallen leaves in autumn/winter.
- **Sky**: Soft gradient background (CSS or shader) transitioning with season — pale spring blue, warm summer white, amber-grey autumn, cold slate winter.

## Physics & Behaviour
- **Wind**: A time-varying vector field using layered sine waves at multiple frequencies and phases. Wind affects both branch sway (rotation oscillation) and leaf flutter (position jitter + normal perturbation).
- **Branch sway**: Branches rotate around their parent joint via spring-damper-like angular displacement driven by wind force scaled by branch length (longer = more sway).
- **Leaf detachment**: During late autumn and winter, leaves detach stochastically based on wind gust strength and season progress. Detached leaves become physics objects affected by gravity, wind drag, and tumbling rotation. They fall to the ground and settle.
- **Budburst / regrowth**: In early spring, buds appear at branch tips, expand, and leaf colour transitions from bud-pink to lime green over several seconds of simulation time.
- **Season cycle**: Continuous loop. Normalized season parameter `t ∈ [0,1)` where:
  - `0.00–0.20` Spring (budburst, rapid greening)
  - `0.20–0.45` Summer (full canopy, deepest green)
  - `0.45–0.65` Autumn (colour shift toward amber then rust)
  - `0.65–0.85` Winter (mass leaf fall, bare branches, gusty wind)
  - `0.85–1.00` Late winter → early spring (regrowth buds form)
- **Wind intensity mapping**: Gentle in spring/summer, gusting strongly in autumn, strongest and coldest in winter.

## Technical Constraints
- Single `index.html` file.
- Three.js loaded from `https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js` or equivalent stable CDN.
- No external images. Procedurally generate all geometry and textures.
- Use `InstancedMesh` for leaves to maintain high leaf count (target ≥ 3,000) at 60fps.
- Use `requestAnimationFrame` loop.
- Camera: OrbitControls from Three.js examples CDN, initial framing showing full tree.
- Window resize must be handled.
- Code must be self-contained and run without a build step.

## Code Architecture (suggested)
1. **Scene setup**: Renderer, camera, lights, fog, controls.
2. **Ground**: ShaderMaterial or vertex-colored plane.
3. **TreeGenerator**: Recursive function building a hierarchy of `THREE.Group` nodes representing trunk and branches. Store branch length, radius, and depth at each node.
4. **LeafSystem**: Instanced mesh. Store per-instance data: attachment branch index, local offset, scale, phase offset, detachment state (attached/falling/settled), velocity, angular velocity.
5. **WindSystem`: Compute wind vector per frame from layered sines.
6. **SeasonSystem**: Maintain `seasonT`, expose colour/leaf-density/wind-strength interpolators.
7. **Update loop**:
   - Update seasonT slowly (full cycle ~60 seconds real time).
   - Compute wind.
   - Update branch transforms (sway).
   - Update leaf instances: flutter if attached, integrate physics if falling, fade settled.
   - Spawn buds/regrow leaves near season transition 0.85→0.05.
8. **UI overlay**: Minimal top-left text showing current season name. No other UI.

## Output Files
- `index.html` — complete artifact
- `PROMPT.md` — this file
- `artifact.json` — route metadata
