# Baseball

The ball as a sphere with a real seam: the figure-eight is a closed curve lying exactly on the surface, so spin carries it round the back instead of sliding it across the front.

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

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

## Notes

- Solved: the seam, which lies exactly on the sphere and is culled by its own normal; the silhouette; and the flight, which is gravity plus `(S/m)(ω × v)`. The dashed line is the same pitch with the spin set to zero, so the break is measured rather than typed.
- Illustrated: nothing about the ball, and everything about the air. There is no drag and no spin decay, and the Magnus term is held at its release value — which makes the whole flight one quadratic. Over the sixty feet this is drawn at, that is smaller than the seam it is drawn with.
- `front` is the batter's view, and the one worth looking at: a curveball's dive and a slider's sideways break only separate from a fastball when the flight is coming at you.

## Usage

```tsx
import { RobotBaseball } from "@/components/ui/robot-baseball"

// Each pitch is a spin rate and an axis, and the break follows.
<RobotBaseball behavior="curveball" view="front" />

// Or walk it down the flight yourself, which stops the loop.
<RobotBaseball along={0.6} onAlongChange={setAlong} interactive />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `along` | `number` | — | Where the ball is, 0 at release and 1 at the plate. Supplying it stops the loop. |
| `onAlongChange` | `(along: number) => void` | — | Fires while it is dragged or keyed, so interaction works in controlled mode too. |
| `behavior` | `"fastball" | "curveball" | "slider" | "sinker" | "knuckler" | "spin" | "static"` | `"fastball"` | Which pitch it throws with nobody driving it. Each one is a spin rate and an axis; everything else follows. |
| `interactive` | `boolean` | `false` | Hand it to a person: drag across to walk the ball down the flight, or focus it and use the arrow keys. |
| `showPath` | `boolean` | `true` | Draw the solved flight, and the same pitch with the spin taken out. The gap between them is the break. |
| `seam` | `boolean` | `true` | Draw the figure-eight seam, culled to the half the camera can see. |
| `showGround` | `boolean` | `true` | Draw the ground line, home plate and the contact shadow. |
| `label` | `string` | — | Optional technical caption under the drawing. |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"profile"` | Where the camera stands. One ball, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `speed` | `number` | `0.5` | Pitches 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. |
| `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/robot-baseball.tsx`
