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:
@@ -0,0 +1,69 @@
|
||||
import * as THREE from 'three/webgpu';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { GALACTIC_LANDMARKS } from '../../shared/astro/galaxy';
|
||||
import { GALAXY_FADE_FAR_PC, GALAXY_FADE_NEAR_PC, MilkyWayRenderer } from './milky-way-renderer';
|
||||
|
||||
const SMALL_COUNTS = { arms: 400, disc: 200, bulge: 200, halo: 50 };
|
||||
|
||||
describe('MilkyWayRenderer', () => {
|
||||
it('draws one instance per particle the model placed', () => {
|
||||
const renderer = new MilkyWayRenderer(5, SMALL_COUNTS);
|
||||
expect(renderer.particleCount).toBeGreaterThan(0);
|
||||
expect((renderer.object.geometry as THREE.InstancedBufferGeometry).instanceCount).toBe(renderer.particleCount);
|
||||
renderer.dispose();
|
||||
});
|
||||
|
||||
it('stays hidden until the camera has pulled back, so the local view pays nothing for it', () => {
|
||||
const renderer = new MilkyWayRenderer(5, SMALL_COUNTS);
|
||||
expect(renderer.object.visible).toBe(false);
|
||||
|
||||
expect(renderer.setViewerDistancePc(50)).toBe(0);
|
||||
expect(renderer.object.visible).toBe(false);
|
||||
|
||||
renderer.dispose();
|
||||
});
|
||||
|
||||
it('fades in across the crossfade band and holds at full strength beyond it', () => {
|
||||
const renderer = new MilkyWayRenderer(5, SMALL_COUNTS);
|
||||
|
||||
expect(renderer.setViewerDistancePc(GALAXY_FADE_NEAR_PC)).toBe(0);
|
||||
expect(renderer.setViewerDistancePc((GALAXY_FADE_NEAR_PC + GALAXY_FADE_FAR_PC) / 2)).toBeCloseTo(0.5, 6);
|
||||
expect(renderer.setViewerDistancePc(GALAXY_FADE_FAR_PC)).toBe(1);
|
||||
expect(renderer.setViewerDistancePc(80000)).toBe(1);
|
||||
expect(renderer.object.visible).toBe(true);
|
||||
expect(renderer.strength).toBe(1);
|
||||
|
||||
renderer.dispose();
|
||||
});
|
||||
|
||||
it('never culls itself, since its instances are nowhere near the geometry it was built from', () => {
|
||||
// The billboard quad sits at the origin and the particles are placed in the vertex shader,
|
||||
// so the mesh's own bounds say nothing about where it is drawn.
|
||||
const renderer = new MilkyWayRenderer(5, SMALL_COUNTS);
|
||||
expect(renderer.object.frustumCulled).toBe(false);
|
||||
renderer.dispose();
|
||||
});
|
||||
|
||||
it('offers a label anchor for every structural landmark, namespaced away from the star ids', () => {
|
||||
const renderer = new MilkyWayRenderer(5, SMALL_COUNTS);
|
||||
const labels = renderer.labelPoints();
|
||||
|
||||
expect(labels).toHaveLength(GALACTIC_LANDMARKS.length);
|
||||
expect(labels.map((label) => label.name)).toContain('Sagittarius A*');
|
||||
for (const label of labels) {
|
||||
expect(String(label.id).startsWith('galactic:')).toBe(true);
|
||||
expect(Number.isFinite(label.x + label.y + label.z)).toBe(true);
|
||||
}
|
||||
|
||||
renderer.dispose();
|
||||
});
|
||||
|
||||
it('detaches itself on dispose, so a torn-down scene does not keep it alive', () => {
|
||||
const renderer = new MilkyWayRenderer(5, SMALL_COUNTS);
|
||||
new THREE.Group().add(renderer.object);
|
||||
|
||||
renderer.dispose();
|
||||
expect(renderer.object.parent).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user