Open the map out to the whole Milky Way

The map stopped at the catalogued 50 pc around the Sun — 0.33% of the
Galaxy's width — and looked like a point cloud with a search box.

Adds the galactic scale above it and the heads-up display the reference
map is built from.

The Galaxy is not a third coordinate space. It is the same parsec space
four orders of magnitude further out, so the model and the star field
crossfade against camera distance instead of switching, and the Sun stays
where it really is: 8.18 kpc out, on the Orion Spur, between the
Sagittarius and Perseus arms. The depth range scales with that distance —
one fixed near/far pair cannot both fly into a star and hold the Galaxy.

The structure in shared/astro/galaxy.ts is measured: the directions of the
centre and the north galactic pole, which fix the disc's 63 degree tilt
against the celestial equator; the Sun's galactocentric distance; and a
radius, azimuth and pitch angle per arm. The particles scattered around it
are not, and cannot be — dust hides the disc, so no catalogue holds the
Galaxy's stars. The view says so, and the model fades out before the
camera reaches the 50 pc where the real stars are.

The rest is the look: polar grids lying in the galactic plane with drop
lines from the Sun's neighbours, a scale ladder, a readout panel, range,
reticle and frame brackets. Two things had to give way for it. The
deep-sky shell is the sky as seen from here, so it dissolves rather than
letting the camera fly through a wall of nebulae, and so does the skybox,
which is a photograph taken from inside the thing now being viewed from
outside. Labels are picked by screen separation rather than distance
alone: the Sun's fifteen nearest neighbours are all inside four parsecs
and printed as one unreadable clump.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaySiNst4HhDXBHnMy8p5G
This commit is contained in:
Claude
2026-08-04 19:59:01 +00:00
parent 2f45fa7fef
commit 2e525fb5c3
19 changed files with 2166 additions and 46 deletions
@@ -0,0 +1,91 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { beforeEach, describe, expect, it } from 'vitest';
import { ViewLevel } from '../../shared/state/navigation.store';
import { StarmapHudComponent } from './starmap-hud.component';
describe('StarmapHudComponent', () => {
let fixture: ComponentFixture<StarmapHudComponent>;
function render(level: ViewLevel): HTMLElement {
fixture.componentRef.setInput('level', level);
fixture.detectChanges();
return fixture.nativeElement as HTMLElement;
}
function buttonLabels(host: HTMLElement): string[] {
return [...host.querySelectorAll('nav button')].map((button) => button.textContent?.trim() ?? '');
}
beforeEach(async () => {
await TestBed.configureTestingModule({ imports: [StarmapHudComponent] }).compileComponents();
fixture = TestBed.createComponent(StarmapHudComponent);
});
it('offers the way back down from the outermost scale', () => {
// The two outer scales share one space, so the ladder goes both ways between them.
expect(buttonLabels(render('galactic'))).toEqual(['Solar Neighbourhood']);
});
it('offers the Milky Way from the solar neighbourhood', () => {
expect(buttonLabels(render('galaxy'))).toEqual(['Milky Way']);
});
it('offers both wider scales from inside a system', () => {
expect(buttonLabels(render('system'))).toEqual(['Milky Way', 'Solar Neighbourhood']);
});
it('never offers the system scale, which needs a star picked first', () => {
for (const level of ['galactic', 'galaxy', 'system'] as const) {
expect(buttonLabels(render(level))).not.toContain('System');
}
});
it('marks the current scale rather than making it a button that goes nowhere', () => {
// Load-bearing beyond tidiness: this marker is how the end-to-end tests tell which scale the
// view has actually settled at.
const host = render('galaxy');
const current = host.querySelector('[data-testid="hud-current-level"]');
expect(current?.textContent?.trim()).toBe('Solar Neighbourhood');
expect(current?.getAttribute('aria-current')).toBe('step');
expect(buttonLabels(host)).not.toContain('Solar Neighbourhood');
});
it('marks exactly one scale as current', () => {
for (const level of ['galactic', 'galaxy', 'system'] as const) {
expect(render(level).querySelectorAll('[data-testid="hud-current-level"]')).toHaveLength(1);
}
});
it('emits the scale that was asked for', () => {
const host = render('system');
const emitted: ViewLevel[] = [];
fixture.componentInstance.levelSelected.subscribe((level) => emitted.push(level));
host.querySelectorAll('nav button').forEach((button) => (button as HTMLButtonElement).click());
expect(emitted).toEqual(['galactic', 'galaxy']);
});
it('renders the readout panel from its inputs', () => {
fixture.componentRef.setInput('level', 'galactic');
fixture.componentRef.setInput('eyebrow', 'Galactic Scale');
fixture.componentRef.setInput('title', 'Milky Way');
fixture.componentRef.setInput('subtitle', 'Barred spiral');
fixture.componentRef.setInput('readouts', [{ label: 'Arms', value: '5' }]);
fixture.componentRef.setInput('note', 'Illustrative model.');
fixture.componentRef.setInput('range', '21.5 kpc');
fixture.detectChanges();
const text = (fixture.nativeElement as HTMLElement).textContent ?? '';
for (const expected of ['Galactic Scale', 'Milky Way', 'Barred spiral', 'Arms', '5', 'Illustrative model.', '21.5 kpc']) {
expect(text).toContain(expected);
}
});
it('leaves out the optional lines it was given nothing for', () => {
const host = render('galaxy');
expect(host.querySelector('dl')).toBeNull();
expect(host.textContent).not.toContain('undefined');
});
});