# Asteroid

An irregular body whose radius is a deterministic sum of cosine lobes, so its silhouette genuinely changes as it turns — and it tumbles about an axis that is itself going round.

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

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

## Notes

- The outline is not a hull. A hull would bridge every hollow the lobes make, which is the whole subject — so the surface is sampled densely, projected, and the farthest sample in each angular bin about the centre is kept. That is the true silhouette of a body star-shaped about its own centre, concavities included.
- It tumbles rather than spins: the body turns about its pole while the pole itself goes round at a fraction of that rate which is not a whole number, so no two frames of the cycle repeat.
- The day-night line is taken analytically — the great circle of directions square to the light, with the body's own radius along each one — so the shadow's inner edge is smooth and its outer edge is the body's own rim.
- Solved: the radius field, the silhouette, the terminator, the shadow region, the crater foreshortening, the companion's orbit and its occlusion. Illustrated: the crater rims and the regolith shading.
- No collisional history, no rotation dynamics, no mass. The tumble is a shaped number rather than a solved free precession.

## Usage

```tsx
import { CelestialAsteroid } from "@/components/ui/celestial-asteroid"

<CelestialAsteroid body="contact" seed={4} craters={22} moonlet />
<CelestialAsteroid tumble={140} interactive onTumbleChange={setTumble} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"front"` | Where the camera stands. One body, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `tumble` | `number` | — | Controlled rotation in degrees. The pole follows it. Supplying it stops the loop. |
| `behavior` | `"tumble" | "spin" | "drift" | "static"` | `"tumble"` | Tumble and spin turn it at different rates; drift barely turns it, the way a body nobody has hit in a long time turns. |
| `speed` | `number` | `0.08` | Revolutions 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 it to turn it; arrows 10 degrees, shift 30, Home and End park it. |
| `onTumbleChange` | `(tumble: number) => void` | — | Fires on every drag and key press, in controlled mode too. |
| `body` | `"rubble" | "monolith" | "contact"` | `"rubble"` | Sets the lobe count and how deep they cut: a rubble pile is many shallow lobes, a contact body is two deep ones. |
| `seed` | `number` | `9` | Any integer. The same seed is the same rock, every render — on the server and in the browser alike. |
| `craters` | `number` | `18` | Craters on the surface, clamped to 0..80. |
| `sun` | `number` | `34` | Where the light is, in degrees round the body; 0 is behind the viewer. |
| `moonlet` | `boolean` | `false` | A companion on its own orbit, which passes behind the rock. |
| `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/celestial-asteroid.tsx`
