Files
star-map/README.md
T
Claude efa9e4084a Draw the whole catalogue, and build the aggregation the rest would need
Two things, one verified and one that cannot be.

The render budget is now the whole catalogue: 68388 stars, one instanced
draw call, which is what a GPU should be asked to do. The budget itself
stays, because the catalogue is meant to grow past what any machine should
draw at once — Gaia alone could contribute a million — and at that point
the selection is what keeps the field legible rather than a grey wash. A
`?stars=` override handles the machines that cannot, including the
software rasterizer the end-to-end suite runs against, whose frame rate is
two orders of magnitude below a real GPU's and which was measuring the
rasterizer rather than the app.

The aggregation is the second thing, and none of it has run. Every ESA,
NOIRLab, SDSS and Euclid endpoint is unreachable from here — only GitHub
raw is, which is why HYG and OpenNGC are the current sources. So this is
infrastructure and a Gaia query written against the published DR3 schema,
not data.

What the framework encodes is that these surveys are not interchangeable.
The distinction is not size but whether a catalogue knows how far away its
objects are, because a 3D map cannot place a star it only has a direction
for. Gaia is the only one of the five that can add stars here, because it
is the only one that measures parallaxes. DECaPS2 has fifty times Gaia's
object count and photometry alone — not one of its 3.32 billion objects
can be placed in depth. Euclid's bulge is 8 kpc away, where a parallax is
microarcseconds; its contribution would be imagery. SDSS-V and SAGA are
keyed to stars something else already places, so they enrich rather than
extend. Those roles are recorded as data the ETL prints, not as prose that
can drift.

Overlapping catalogues are reconciled on direction rather than on 3D
proximity, which is the one non-obvious part. Two surveys agree on a
star's direction to within an arcsecond and disagree on its distance by
tens of per cent, so a star at 200 pc is 50 pc from itself between
catalogues while being unmistakably the same object. Matching in 3D would
need a tolerance so loose it swallowed real neighbours. The better
parallax wins where both reach; where only one does, the star stays.

Names become dense-with-holes with a source dictionary, because a survey
catalogue has no proper names — writing "Gaia DR3 4472832130942575872"
once per star would cost 25 MB per million to repeat what two adjacent
fields already say. An empty entry costs three bytes and is regenerated on
load. The Sun needed its own case in the merge: it sits at the origin, has
no direction to compare, and appears in every catalogue.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaySiNst4HhDXBHnMy8p5G
2026-08-05 08:51:54 +00:00

315 lines
19 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# star-map
An interactive 3D star map in the spirit of Star Citizen's in-game starmap, but populated with
real astronomical data instead of fictional systems. Browse the solar neighbourhood, fly into a
star's system to see its planets on their real orbits, and drill into a single body for the
NASA figures behind it.
This repo also hosts a small Claude Code plugin marketplace — see [Plugins](#plugins) below.
## Running it
```bash
npm install
npm start # dev server on http://localhost:4200
npm run build # production bundle into dist/
```
Requires the Node version in `package.json`'s Angular toolchain range (Node 22.22.3+ or 24.15+).
```bash
npm test # unit/component tests (Vitest, jsdom)
npm run e2e # end-to-end tests (Playwright + Chromium) — see e2e/README.md
npm run etl # refresh the astronomical datasets — see below
npm run etl:typecheck # type-check the ETL scripts (they build separately from the app)
npm run e2e:typecheck
```
## What's in it
**Galaxy view** — the HYG catalogue out to 250 parsecs, 68 388 stars, as instanced
camera-facing billboards positioned from real RA/Dec/parallax, coloured by spectral index and
sized by magnitude. The field draws a budget of the most visible of them rather than all — see
"On how many stars" below. A polar grid in the galactic plane runs under them with a drop line
from each of the brightest, and names label the most prominent stars near whatever the camera is
looking at.
Behind them sits a backdrop of notable deep-sky objects and a Milky Way panorama.
**Galactic view** — keep pulling back and the neighbourhood becomes a point inside the Milky
Way: the bar and bulge, five spiral arms, the disc and a thin halo, with the arms and the
galactic centre named. It is the same parsec-scale space as the galaxy view, crossfaded by
camera distance rather than switched, so the Sun stays where it really is — 8.18 kpc out, on the
Orion Spur, between the Sagittarius and Perseus arms. See "On the Galaxy model" below for what
in it is measured and what is not.
**System view** — selecting a star flies the camera continuously into its system rather than
cutting to a new scene. The Sun gets the real solar-system bodies from JPL Horizons; other
stars get their confirmed exoplanets. Orbits are drawn as ellipses and bodies are propagated
along them by a Kepler solver against the current epoch. Under them, a dashed grid marks out
round distances in AU — 5 AU rings for the solar system, 0.01 AU rings for TRAPPIST-1 — with a
drop line from each body, so eccentricity and inclination read against a circular reference
instead of having to be inferred from a shape in space. The camera frames that grid rather than
the orbits, from the field of view it actually has, so the outermost ring sits inside the frame
with room around it at any system scale and any window shape.
The star at the centre is sized against the system's *innermost* orbit, so it can never swallow
its closest planet, while the camera is placed to frame the *outermost* ring — and in the solar
system those differ by a factor of a hundred. At the distance that fits Pluto in view, a disc
that stays clear of Mercury is about a pixel across, and no radius satisfies both. So the disc
stays honest to the orbits and the star's halo carries its visibility, floored against the framed
radius: light is not a surface, and a glow reaching past the innermost orbit says the star is
bright rather than that it is large. That floor is bounded from both sides — large enough that
the star reads at a glance, small enough that Venus's and Earth's orbits stay legible as rings
around it. Mercury's, three pixels wide at that range, does not survive either way.
**Body detail** — a dedicated close-up scene and info panel for one planet, moon or exoplanet,
with real photography where NASA/ESA/USGS imagery exists, and a surface derived from the body's
own measurements where it does not. See "On surfaces that were never photographed" below.
**Search** — name search across stars, solar-system bodies and exoplanets, navigating to the
same place an in-scene click would.
### Architecture notes
- **Rendering** runs on Three.js `WebGPURenderer`, which falls back to a WebGL2 backend
automatically. The render loop runs outside Angular's change detection.
- **Stars are billboards, not points.** The WebGPU backend caps point primitives at a single
pixel, so a points cloud renders every star as an identical dot regardless of magnitude. The
star field is instanced quads on a `SpriteNodeMaterial` instead, which behaves the same on
both backends. Their size is angular rather than world-space — real stars are unresolvable
point sources, so apparent size should follow brightness, not distance.
- **One reference frame, from three sources.** HYG gives star positions in equatorial J2000.
JPL Horizons reports orbital elements against the ecliptic, tilted 23.4° away. The Exoplanet
Archive measures inclination from the *plane of the sky* — perpendicular to our line of sight
to each host star, which is why transiting planets cluster at 90°. Each set of elements is
rotated from its own reference plane into the scene's equatorial frame, so a direction means
the same thing everywhere. Systems are still presented face-on — by placing the camera
relative to whichever plane that system's elements were measured in, rather than by rotating
the world into a convenient pose. That plane is per-system, not global: one fixed viewing
direction is face-on for the solar system and edge-on for an exoplanet system whose host star
lies elsewhere on the sky. It is also the plane the system's reference grid lies in.
- **Two coordinate scales.** The galaxy view works in parsecs and the system view in AU —
about eight orders of magnitude apart, which wrecks float precision if rendered in one unit
space. The camera rig recentres the active star to the origin ("floating origin") and swaps
the unit scale and near/far planes at the transition point.
- **The galactic scale is not a third space.** It is the same parsec space as the galaxy view,
four orders of magnitude further out, so no swap is needed — the Milky Way model and the
catalogued star field crossfade against camera distance and the depth range scales with it.
One fixed near/far pair cannot serve both ends: flying into a star needs a near plane a
hundredth of a parsec out, and holding the Galaxy needs a far plane a hundred thousand
parsecs out, and a projection spanning both has no precision left to separate one arm from
the next.
- **No backend.** Every dataset is baked at build time into `src/assets/data/` and served as a
static asset. Nothing queries an astronomy API at runtime.
### On surfaces that were never photographed
Fifteen bodies here have a real photograph. Everything else does not, and never will on current
instruments: no exoplanet's surface has ever been imaged, and a few of the solar system's own
moons have no usable map in this asset set either.
Those bodies get a surface reasoned from what *has* been measured, in a chain that is worth
following because every link is standard:
1. The host star's **luminosity** comes from its catalogued apparent magnitude and its
parallax distance — that pair is exactly an absolute magnitude — plus a bolometric correction
for its spectral class. The correction is not optional: an M dwarf radiates most of its light
in the infrared, so its visual magnitude understates it by more than tenfold, and M dwarfs are
what most nearby planet hosts are. Good to about a factor of two, which matters less than it
sounds: temperature goes as the fourth root.
2. Luminosity and the planet's semi-major axis give its **equilibrium temperature**, the standard
blackbody balance. Checked against the solar system it lands on Earth 255 K, Jupiter 112 K,
Neptune 46 K — all within a kelvin or two of published values — and puts 51 Pegasi b at
1227 K against a published 1200.
3. Published mass and radius give **bulk density**, which is the difference between a ball of
iron, of rock, of water and of hydrogen.
4. Size fixes the family, temperature the state within it, and density overrides both at the
extremes. That yields a class — molten, scorched, iron-rich, rocky, temperate, ice, sub-
Neptune, ice giant, gas giant, hot gas giant — each with a palette reasoned from its chemistry.
Methane absorbs red light, which is why the ice giants are blue; ammonia cloud tops are cream
and ochre; silicate cloud decks over a glowing interior are why hot Jupiters are drawn deep red.
5. The surface is then painted from that class: **zonal bands** for a body with a fluid envelope,
because a rapidly rotating atmosphere organises into them, and fractal **terrain** for one
with a solid surface. Polar caps grow and shrink with the derived temperature.
The generator samples three-dimensional noise along the sphere rather than a flat field, so
there is no seam to stitch at the antimeridian and no pinching at the poles, and it writes into
a plain byte array rather than a canvas — which makes it a pure function with no DOM to depend on.
Each body's surface is seeded from its own id, so it looks the same on every visit.
The limits are worth stating. Equilibrium temperature ignores greenhouse warming and internal
heat, which is why Venus comes out at 300 K against a real surface of 737 K, and why Io — kept
molten by tidal heating — classifies as ice. Luminosity classes are often missing from the star
catalogue, so a red giant read as a dwarf will come out too bright. And the surfaces are
illustrations throughout: the info panel says so on every body that has one, next to the
measurements it was reasoned from.
### On the Galaxy model
Every other dataset here is measured. The Galaxy is the exception, and not for want of trying:
we sit inside its disc, and dust blocks the view across it, so no catalogue holds the positions
of its stars. Every rendering of the Milky Way seen face-on — including NASA's — is a model.
What *is* measured is the skeleton, and that is what `shared/astro/galaxy.ts` contains: the
directions of the galactic centre and the north galactic pole, which fix the disc's 63° tilt
against the celestial equator; the 8.18 kpc from the Sun to the centre, from the orbit of the
star S2 around Sgr A*; and a reference radius, azimuth and pitch angle per spiral arm,
approximating the maser-parallax fits. The Sun's placement on the Orion Spur and the arms either
side of it follow from those numbers rather than being posed by hand.
The particles scattered around that skeleton are illustrative — a seeded, reproducible cloud, not
observations. The galactic view says so on screen, and the model fades out entirely before the
camera reaches the catalogued 50 pc the real stars occupy.
## Data pipeline
`npm run etl` runs `tools/etl/build.ts`, which fetches each source, writes the static assets,
then validates the combined output. Raw responses are cached under `tools/etl/.cache/`, so
re-runs are cheap and offline-friendly; set `ETL_FORCE_REFRESH=1` to bypass the cache.
| Script | Source | Output |
| --- | --- | --- |
| `fetchStars.ts` | HYG database, plus any other positional catalogue wired in (see below) | `stars.bin`, `stars-meta.bin`, `stars-index.json` |
| `fetchSolarSystem.ts` | JPL Horizons / SSD | `bodies.json` |
| `fetchExoplanets.ts` | NASA Exoplanet Archive (TAP) | `exoplanets.json` |
| `fetchDeepSky.ts` | OpenNGC | `deepsky.json` |
The star catalogue ships as two binary column stores plus a small JSON file, not as an array of
objects. At 68 388 stars the old encoding — one JSON object per star, its eight key names
repeated each time — would have been about 17 MB to download and parse before the first frame.
Splitting it puts the numbers in `stars.bin` (positions, handed to the GPU verbatim) and
`stars-meta.bin` (id, magnitude, colour index, spectral-type index), and leaves `stars-index.json`
holding only the strings, with the ~2 600 distinct spectral classifications collapsed into a
dictionary. The result is 2.6 MB for 7.8× the stars. `star-catalog.ts` defines the layout once
and both the ETL and the app use it, so the writer and the reader cannot drift apart.
`ETL_STAR_DISTANCE_PC` (default `250`) sets the star-field distance cutoff.
### On aggregating other surveys
`tools/etl/sources/registry.ts` lists every catalogue the pipeline knows about, and `npm run etl`
prints it. Sources are wired in by role, because the roles are not interchangeable:
| Source | Role | What it adds |
| --- | --- | --- |
| HYG | positional | The named, spectrally classified bright-star spine — 68 388 stars within 250 pc. |
| Gaia DR3 | positional | Parallaxes fifty times more precise, for 1.8 billion sources. |
| DECaPS2 | backdrop | 3.32 billion objects across the southern galactic plane. |
| SDSS-V Milky Way Mapper | enrichment | Spectroscopic temperatures, gravities, metallicities, radial velocities. |
| Euclid Bulge Survey (Q2) | backdrop | High-resolution imagery and astrometry of the inner bulge. |
| SAGA | enrichment | Compiled elemental abundances for metal-poor stars. |
The distinction that matters is not size — it is whether a catalogue knows how **far away** its
objects are, because a 3D map cannot place a star it only has a direction for. **Gaia is the only
one of these that can add stars to this map**, because it is the only one that measures
parallaxes. DECaPS2 has fifty times Gaia's object count and photometry alone: not one of its
3.32 billion objects can be placed in depth, so it can only ever be a direction-only backdrop
beside the deep-sky shell. Euclid's bulge sits 8 kpc away, where a parallax is microarcseconds —
its natural contribution here is imagery, not positions. SDSS-V and SAGA are keyed to stars
another catalogue already places; they enrich what is there and cannot extend it.
Where two positional catalogues overlap they are reconciled by `star-merge.ts`, which matches on
**direction** rather than on 3D proximity. Two surveys agree on a star's direction to within an
arcsecond and disagree on its distance by tens of per cent — so a star at 200 pc can be 50 pc
from itself between catalogues while being unmistakably the same object. Where both have a star,
the one with the better parallax wins; where only one reaches, the star is still there.
Only HYG has ever run. Every ESA, NOIRLab, SDSS and Euclid endpoint is unreachable from the
environment this was developed in, so the Gaia query is written against the published DR3 schema
and has not been executed against it. A source that cannot be reached is reported and skipped
rather than failing the build.
### On how many stars
Not many, against the Galaxy. It holds 100–400 billion stars and this map ships 68 388 of them —
about 0.00003%. That gap is not this project's to close: Gaia DR3, the largest stellar catalogue
ever assembled, has ~1.8 billion sources, roughly 1% of the Galaxy, and is itself blocked by dust
and blind to most red dwarfs beyond a few hundred parsecs. It is the same reason the galactic
view is a model.
The 250 pc cutoff is where HYG's own measurements stop. 98.6% of its rows carry a Hipparcos
identifier, and Hipparcos parallaxes are good to about a milliarcsecond — so at 250 pc a
distance is uncertain by some tens of per cent and beyond it the catalogue would be plotting
noise. Only the *radial* placement blurs; a star's direction on the sky stays exact at any
distance. Note also that beyond about 50 pc the sample is magnitude-limited rather than
volume-complete: it thins to the intrinsically bright, which is the same selection the naked eye
makes.
Drawing and knowing are separate. The field draws `STAR_RENDER_BUDGET` stars — every one inside
25 pc, then the brightest of the rest — while search, navigation and the planet cross-reference
all see the full catalogue. A real GPU would draw all 68 388 without noticing; the budget exists
for the machines that would not, and is a single constant to raise.
### On deep-sky distances
OpenNGC publishes no distance column, so distance has to be inferred — and the inference fails
for precisely the best-known objects. M31, M33 and M42 are Local Group members whose redshift
is negative or absent, and the catalogue's parallax for a galaxy comes from a cross-matched
foreground star (it lists 6 mas for M31, implying 167 pc for something 780,000 pc away).
So deep-sky records store a **unit direction** on the celestial sphere rather than a position:
the line of sight is always known precisely, and the objects are drawn as a fixed-radius
backdrop shell where true distance would be unusable anyway. `distancePc` is optional metadata,
derived from parallax for galactic objects or the Hubble law for genuinely distant galaxies,
and left `null` — with its `distanceMethod` — whenever neither is trustworthy. Roughly 330 of
the 463 cataloged objects get a distance; the rest honestly report none.
## Layout
```
src/app/
core/engine/ Three.js renderer, render loop, resize
core/data/ static-asset loading and caching
features/galaxy-system/ shared galactic+galaxy+system scene, camera rig, star field,
Milky Way model, grid planes, deep-sky backdrop, orbits,
labels, HUD
features/body-detail/ close-up scene and info panel
features/search/ name search across every dataset
shared/astro/ coordinates, Kepler propagator, deep-sky classification,
Milky Way structure
shared/models/ record contracts shared by the app and the ETL
shared/rendering/ skybox, glow sprites, texture catalog
shared/state/ navigation store (Angular signals)
tools/etl/ build-time data pipeline
e2e/ Playwright end-to-end tests
```
The design document behind all of this is `.junie/plans/nasa-star-map.md`.
## Plugins
This repo doubles as a Claude Code plugin marketplace. Adding it and installing a plugin
defaults to **user scope**, meaning the plugin becomes available in *every* project on your
machine, not just the one you happen to be in:
```bash
/plugin marketplace add avalon-vanguard/star-map
/plugin install caveman@star-map
```
Scope can be overridden at install time if you want it tied to a single repo instead:
```bash
# Shared with collaborators via that repo's .claude/settings.json
/plugin install caveman@star-map --scope project
# Just for you, in that one repo only (gitignored)
/plugin install caveman@star-map --scope local
```
See [Claude Code plugin installation scopes](https://code.claude.com/docs/en/plugins-reference)
for details on `user` / `project` / `local` scope.
- **caveman** — `/cs:caveman` ultra-compressed communication mode.
- Command: [`commands/cs/caveman.md`](commands/cs/caveman.md)
- Agent: [`agents/cs-caveman-mode.md`](agents/cs-caveman-mode.md)
- Skill: [`skills/caveman/SKILL.md`](skills/caveman/SKILL.md)
## Data credits
Star catalogue: [HYG database](https://github.com/astronexus/HYG-Database) (Hipparcos, Yale
Bright Star, Gliese) — 68 388 stars within 250 pc. Solar-system ephemerides: NASA/JPL Horizons. Exoplanets: NASA Exoplanet
Archive. Deep-sky objects: [OpenNGC](https://github.com/mattiaverga/OpenNGC). Body and skybox
imagery: NASA/JPL/USGS public domain and Solar System Scope (CC BY 4.0) — per-file provenance
is recorded in `src/app/shared/rendering/texture-catalog.ts`.