# Planetary gearbox

A reduction stage with its face off: a sun driving planets inside a held ring, with real meshing teeth. The reduction is read off the tooth counts rather than typed in.

> 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/planetary-gearbox.json
```

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

## Notes

- The teeth are geometry. Every member's phase comes from the mesh relation in transmission-geometry, so the planets counter-rotate at −sun/planet and the ring provably does not move at all with the sun — which is what makes the carrier the output and the reduction exactly 1 + ring/sun.
- Tooth counts you ask for are not always the counts you get: the ring is sun + 2 × planet, and (sun + ring) has to divide by the planet count or the planets cannot all mesh at once. The planet count is raised until it does, and the readout shows what was built.
- Geometry only — no torque, no backlash, no friction, no efficiency. It will happily turn a ratio that would strip itself.

## Usage

```tsx
import { PlanetaryGearbox } from "@/components/ui/planetary-gearbox"

<PlanetaryGearbox sunTeeth={18} planetTeeth={12} planets={3} />

// Controlled, or a shaft you can wind.
<PlanetaryGearbox angle={140} />
<PlanetaryGearbox interactive onAngleChange={setAngle} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"front"` | Where the camera stands. One gearbox, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `angle` | `number` | — | Controlled input shaft angle in degrees. Omit it and the shaft runs behavior. |
| `behavior` | `"run" | "jog" | "static"` | `"run"` | Turn continuously, or index in half-turn steps with a dwell between. |
| `speed` | `number` | `0.3` | Input turns per second running, or half-turn steps per second jogging. |
| `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 round the centre to wind the input shaft, or arrow-key it 10° at a time. |
| `onAngleChange` | `(angle: number) => void` | — | Input angle, wrapped to 0–360, whenever a person moves it. |
| `sunTeeth` | `number` | `16` | Teeth on the sun, rounded and clamped to 8–40. |
| `planetTeeth` | `number` | `12` | Teeth on each planet. Raised to the nearest count that assembles, and capped so neighbours cannot overlap. |
| `planets` | `number` | `3` | Equally spaced planets, rounded and clamped to 3–5. |
| `showHousing` | `boolean` | `true` | Draw the case and its bolt circle around the train. |
| `showRatio` | `boolean` | `true` | Print the tooth counts and the reduction under the drawing. |
| `label` | `string` | — | Caption below the ratio readout. |
| `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. |
| `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/planetary-gearbox.tsx`
