# Orrery

A geared model of a system: bodies carried on radial arms whose length is the orbital radius, running fast at periapsis and slow at apoapsis on real Kepler ellipses with the hub at a focus.

> For the complete index, see [llms.txt](https://robocn.dev/llms.txt). A Markdown version of any page is available by appending `.md` to its URL or by sending an `Accept: text/markdown` header.

## Install

```bash
bunx --bun shadcn@latest add https://robocn.dev/r/orrery.json
```

Registry item: `orrery` · [`https://robocn.dev/r/orrery.json`](https://robocn.dev/r/orrery.json)

## Notes

- The arm's length is the orbital radius, so it really does telescope in and out over a year — and the body runs at periapsis and loiters at apoapsis because `orbitalState` solves Kepler's equation rather than sliding an angle round at a constant rate.
- The hub is at a focus of every ellipse, not at the centre. That is the difference between a drawing of an orrery and one.
- The periods are not free either: they come from the third law, `T ∝ a^{3/2}`, so an outer body is slow because it is far out.
- Drawn from above, where the ellipses read true. Tipping the camera brings out the column and the plinth, which are the parts that only exist off the plan axis.
- Solved: Kepler's equation, the orbits and their foci, the periods, the arms, and the hub train as real horizontal circles. Illustrated: the gear teeth are not drawn and nothing is geared to anything — there is no gravity here and the bodies do not pull on each other.

## Usage

```tsx
import { Orrery } from "@/components/ui/orrery"

<Orrery bodies={5} eccentricity={0.6} inclination={12} />
<Orrery epoch={3.2} interactive onEpochChange={setYear} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"plan"` | Where the camera stands. One machine, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `epoch` | `number` | — | Controlled time, in years. Supplying it stops the loop. |
| `behavior` | `"run" | "jog" | "static"` | `"run"` | Run winds time on continuously; jog indexes a year at a time and dwells between them, the way a geared model is wound on. |
| `speed` | `number` | `0.14` | Turns of the innermost body per second. |
| `animate` | `boolean` | `true` | Off parks the machine at phase and stops rendering. A reduced-motion preference does the same. |
| `paused` | `boolean` | `false` | Freeze where it stands. |
| `phase` | `number` | `0` | Seconds of offset, so a row of machines breaks step. |
| `interactive` | `boolean` | `false` | Drag across the frame to wind time on — the full width is twenty-four years; arrows a quarter of a year, shift a whole one. |
| `onEpochChange` | `(epoch: number) => void` | — | Fires on every drag and key press, in controlled mode too. |
| `bodies` | `number` | `4` | Bodies on the train, clamped to 1..6. Each gets an orbit, an arm, a gear and a body. |
| `eccentricity` | `number` | `0.45` | How eccentric the orbits are, 0 circular to 1 as far as the set goes. Every orbit gets a different share of it. |
| `inclination` | `number` | `7` | Degrees the outermost orbit is tilted out of the plane; the inner ones get a share, so the train reads as a stack of planes. |
| `showOrbits` | `boolean` | `true` | Draw the ellipses the bodies run on. |
| `showGears` | `boolean` | `true` | Draw the hub train the arms are geared to. |
| `variant` | `"solid" | "outline" | "blueprint" | "wire"` | `"solid"` | How the machine is painted. Geometry never changes between variants. |
| `size` | `"xs" | "sm" | "md" | "lg" | "xl" | number` | `"md"` | Rendered width in pixels, or a step on the scale. |
| `signal` | `"idle" | "ready" | "warning"` | — | Status-lamp state using neutral, accent, or shell colour; each component documents its visual default in the demo. |
| `label` | `string` | — | Optional technical caption under the drawing. |
| `color` | `string` | `var(--robot-shell)` | Body panels — the colour the machine reads as. |
| `accent` | `string` | `var(--robot-accent)` | Status colour: tip light, live tool, readouts. |
| `metal` | `string` | `var(--robot-metal)` | Bare machined parts: collars, bolts, tool bodies. |
| `dark` | `string` | `var(--robot-dark)` | Cast joints, base, shadow side. |
| `palette` | `Partial<RobotPalette>` | — | Override any subset of roles at once, including glow and grid. |

## Source

- `src/components/ui/orrery.tsx`
