Put a reference grid under the system view

A system was a handful of ellipses floating in the dark. You could see
that one orbit was bigger than another, but not how big, and not that a
planet sat above or below the plane the others share.

Adds the same plane-and-tether reading aid the outer scales got: a polar
grid in the system's own reference plane, with a drop line from each body
onto it.

Ring radii snap to a 1-2-5 ladder rather than dividing the system evenly,
because the point is to put a number on a distance — 5, 10, 15 AU can be
read at a glance and 4.34, 8.68, 13.02 cannot. That holds across the four
orders of magnitude real systems span: the solar system gets 5 AU rings,
TRAPPIST-1 gets 0.01 AU ones. The outermost ring encloses the outermost
orbit rather than falling just inside it.

The rings are dashed. Solid ones would sit in the same plane as the orbit
ellipses, which are themselves rings, and at a glance a reference circle
and a circular orbit are the same picture. Dashes are cut by dropping
whole segments rather than by a dashed material: the ring is already built
from independent segment pairs, so a material's dash pattern would restart
at every one.

Drawing the grid exposed a framing bug it made unmissable. The camera
settled along one fixed direction derived from the ecliptic, which is
face-on only for the one system whose elements are ecliptic. Every
exoplanet system — measured against the plane of the sky, perpendicular to
the line of sight to its own host star — was being presented nearly
edge-on, a smear of overlapping ellipses. The settle direction is now
taken relative to whichever plane the system was measured in, so all of
them read as discs. The solar system is unmoved, which a test pins.

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 20:32:31 +00:00
parent 2e525fb5c3
commit a84e2d3a69
9 changed files with 437 additions and 55 deletions
@@ -30,7 +30,7 @@ describe('galacticFrameQuaternion', () => {
describe('PolarGridPlane', () => {
const rings = [10, 20, 50];
const spokes = 8;
const grid = new PolarGridPlane({ ringRadiiPc: rings, spokeCount: spokes, emphasisRadiiPc: [50] });
const grid = new PolarGridPlane({ ringRadii: rings, spokeCount: spokes, emphasisRadii: [50] });
it('draws every ring segment and every spoke', () => {
expect(grid.object.geometry.getAttribute('position').count).toBe(rings.length * SEGMENTS_PER_RING * 2 + spokes * 2);
@@ -72,9 +72,9 @@ describe('PolarGridPlane', () => {
it('sits on the galactic centre when given it, still in the plane', () => {
const centre = galacticCentrePositionPc();
const galacticGrid = new PolarGridPlane({
ringRadiiPc: [2500, 8178],
ringRadii: [2500, 8178],
spokeCount: 4,
centrePc: new THREE.Vector3(centre.x, centre.y, centre.z)
centre: new THREE.Vector3(centre.x, centre.y, centre.z)
});
galacticGrid.object.updateMatrixWorld(true);
@@ -86,6 +86,31 @@ describe('PolarGridPlane', () => {
galacticGrid.dispose();
});
it('lies in whatever plane it is oriented into, for a system read against its own', () => {
// The system view passes the frame its orbital elements were measured in, which has nothing
// to do with the Galaxy's plane.
const orientation = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1, 0, 0), Math.PI / 2);
const systemGrid = new PolarGridPlane({ ringRadii: [1, 2, 3], spokeCount: 6, orientation });
systemGrid.object.updateMatrixWorld(true);
const normal = new THREE.Vector3(0, 0, 1).applyQuaternion(orientation);
for (const index of [0, 200, systemGrid.object.geometry.getAttribute('position').count - 1]) {
const world = vertexAt(systemGrid.object.geometry, index).applyMatrix4(systemGrid.object.matrixWorld);
expect(world.dot(normal)).toBeCloseTo(0, 6);
}
// ...and it is genuinely a different plane from the default.
expect(Math.abs(normal.dot(galacticNormal()))).toBeLessThan(0.99);
systemGrid.dispose();
});
it('honours an explicit peak opacity, for a grid that has to sit under other rings', () => {
const quiet = new PolarGridPlane({ ringRadii: [1, 2], spokeCount: 4, opacity: 0.2 });
quiet.setStrength(1);
expect((quiet.object.material as THREE.LineBasicMaterial).opacity).toBeCloseTo(0.2, 6);
quiet.dispose();
});
it('keeps the emphasised ring brighter than the rest', () => {
const colors = grid.object.geometry.getAttribute('color');
// Vertices are written ring by ring, in the order they were listed: 10 pc first, 50 pc last.
@@ -148,6 +173,27 @@ describe('TetherField', () => {
field.dispose();
});
it('drops down whatever normal it was built with, not always the galactic one', () => {
const normal = new THREE.Vector3(0, 1, 0);
const field = new TetherField(2, { normal });
field.setTargets([new THREE.Vector3(3, 7, 5)]);
const foot = vertexAt(field.object.geometry, 1);
// The foot keeps the in-plane components and loses only the height along the normal.
expect(foot.x).toBeCloseTo(3, 6);
expect(foot.y).toBeCloseTo(0, 6);
expect(foot.z).toBeCloseTo(5, 6);
field.dispose();
});
it('normalises the normal it is given, so an unnormalised frame axis still lands on the plane', () => {
const field = new TetherField(2, { normal: new THREE.Vector3(0, 0, 4) });
field.setTargets([new THREE.Vector3(1, 1, 9)]);
expect(vertexAt(field.object.geometry, 1).z).toBeCloseTo(0, 6);
field.dispose();
});
it('stays hidden until it is given a strength', () => {
const field = new TetherField(2);
expect(field.object.visible).toBe(false);