# Evolving Art Garden

A generative-art garden built with Three.js and contained in one file. Nine procedural plant-sculptures stand on pedestals. You pick the ones you like, breed them, and the next generation grows in with an animation.

Open `index.html` in any WebGL browser. You can open it straight from disk or serve it (e.g. `python3 -m http.server`). There is no build step and nothing to fetch, because Three.js r180 and OrbitControls are bundled inside the file.

## Controls

| Action | Mouse / UI | Key |
|---|---|---|
| Pick / unpick a favourite (also opens its family tree) | Click a sculpture | `1`–`9` (back row left→right, then front row) |
| Breed the next generation from your favourites | **Breed next generation** | `Space` |
| Toggle auto-play | **Auto-play** | `A` |
| Export the garden view as a PNG | **Export PNG** | `P` |
| Clear favourites | **Clear picks** | `C` |
| Start a new random garden (generation 0) | **New garden** | `R` |
| Orbit / zoom the camera | Drag / mouse wheel | |
| Collapse / expand the family-tree panel | ▾ button | `T` |
| Hide all UI (clean view) | | `H` |

- **Mutation** slider: how strongly children are mutated (per-gene probability and step size).
- **Keep favourites as elites**: when on, the parents stay on their pedestals and only the other slots get children. When off, the whole garden is replaced.

## Auto-play / idle mode

Every 8 seconds auto-play does the following:
1. It picks 2–3 favourites using a light "taste" score (blooms, glow, colour, complexity, plus randomness, with a penalty for old elites).
2. It highlights them.
3. It breeds them.

While it runs, the camera sways slowly and a countdown bar shows at the bottom. If nobody touches anything for 40 seconds, the garden switches to **IDLE AUTO-PLAY** by itself. Any click, key or scroll hands control back to you.

## Family-tree panel

The panel shows the selected sculpture, its parents, grandparents and great-grandparents as a pedigree chart with rendered thumbnails. A green dot marks a sculpture that is still in the garden, and ↑ means there are more ancestors further up. Below the chart you'll find:
- the sculpture's offspring
- its colour palette
- the genome in readable form (the L-system rules X → …, F → …, angles, bloom type and shader parameters)
- a "gene barcode" with one stripe per numeric gene

Click any node or offspring thumbnail to move through the lineage.

## How it works

- **Genome**:
  - two L-system rewrite rules (`X`, `F`)
  - 32 numeric genes:
    - shape: iterations, branch angles, roll, phyllotaxis, length decay, pipe-model thickness, tropism, jitter
    - leaves and blooms: density and size, bloom shape (orb / flower / crystal / lantern)
    - colour palette: hue, spread, saturation, lightness
    - shader: noise frequency, amplitude and speed, surface pattern, glow, rim, iridescence, wind sway
- **Crossover**: each numeric gene is taken from one parent or blended between both (hues blend around the colour circle). Rules are spliced at bracket-balanced points.
- **Mutation**: genes take Gaussian steps. Rules can gain or lose turns or branches, or have units duplicated or swapped. Each generation, one "wildcard" child gets a much stronger mutation to keep variety alive.
- **Geometry**:
  - A 3D turtle builds a skeleton.
  - Branch thickness comes from a pipe model, so each branch's radius depends on how many tips it carries.
  - The whole sculpture is merged into one mesh.
  - Every vertex stores when it is "born", so a custom shader can grow the plant from the root outward (and shrink it back when it dies) with a single uniform.
