# Pumpjack

A beam pump with its four-bar actually solved. The crank turns, the pitman closes the loop, and the polished-rod stroke is what the link lengths produce — not a number anyone typed.

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

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

## Notes

- The four-bar, the beam angle and the rod stroke are solved; the horsehead's arc is centred on the saddle bearing, which is why the rod stays vertical and travels exactly radius × beam angle.
- No dynamics: no fluid, rod load, torque, counterbalance calculation or production rate is computed.
- The teardown is `assembly-geometry`'s schedule, and the angle it parks at is scanned out of the four-bar rather than typed — `beam level` is an inverse problem the loop does not solve directly.
- The handed pairs come off sideways, which reads in `iso` and `front`; in `profile` a lateral move is foreshortened to almost nothing, and in `plan` a part lifted straight up does not move on screen at all. Both are the projection being honest — a real side elevation cannot show a lateral move either. The wellhead is the well, not the pump, so it stays put.

## Usage

```tsx
import { Pumpjack } from "@/components/ui/pumpjack"

<Pumpjack behavior="pump" balance="crank" />
<Pumpjack crankAngle={120} balance="beam" interactive onCrankAngleChange={setAngle} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `crankAngle` | `number` | — | Controlled crank angle in degrees. Supplying it stops the loop. |
| `behavior` | `"pump" | "slow" | "service" | "static"` | `"pump"` | Continuous pumping, a pump-off duty cycle of two revolutions then a rest, or `service`: parked level and taken apart and back together. |
| `balance` | `"crank" | "beam" | "air"` | `"crank"` | Where the counterbalance mass is carried. It moves the mass, not the linkage. |
| `explode` | `number` | — | How far apart it is, 0 assembled to 1 fully exploded. Anything above 0 parks the linkage at the service angle and stops the loop. |
| `explodeOverlap` | `number` | `0.45` | How much the parts' travel windows overlap: 0 takes one stage off at a time, 1 moves everything at once. |
| `showLeaders` | `boolean` | `true` | Dashed leaders from each displaced part back to its seat. Nothing is drawn while the machine is together. |
| `control` | `"crank" | "explode"` | `"crank"` | Which axis dragging and the arrow keys drive. |
| `showWell` | `boolean` | `true` | The stuffing box, wellhead and flow line under the polished rod. |
| `interactive / onCrankAngleChange / onExplodeChange` | `boolean / (angle: number) => void / (explode: number) => void` | — | Turn the gearbox by hand — the pointer's bearing about the crank centre is the crank angle — or pull the machine apart, depending on `control`. |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"profile"` | Where the camera stands. One beam pump, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `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. |
| `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/pumpjack.tsx`
