Derive a surface for every body that was never photographed

Fifteen bodies here have a real photograph. Every exoplanet does not, and
never will on current instruments — none has ever been imaged — and nor do
several of the solar system's own moons. Those all shared one crude
stand-in: a few noisy bands tinted by category, cached per colour, so
every exoplanet in the app was literally the same picture.

They now get a surface reasoned from what has actually been measured.

The chain is standard at every link. A 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 more
than tenfold, and M dwarfs are what most nearby planet hosts are.
Luminosity and the semi-major axis then give an equilibrium temperature,
mass and radius give a bulk density, and size, temperature and density
together give a class of world.

Checked against the solar system the temperatures land on Earth 255 K,
Jupiter 112 K, Neptune 46 K, all within a kelvin or two of published
values, and 51 Pegasi b comes out at 1227 K against a published 1200.

Each class carries a palette reasoned from its chemistry — methane absorbs
red light, which is why the ice giants are blue — and a structure: 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, which is
the clearest visible consequence of the whole chain.

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 byte array rather than a
canvas — a pure function, testable, with no 2D context to be unavailable.

Two things the derivation cannot do, both stated on screen next to the
measurements it rests on. Equilibrium temperature ignores greenhouse
warming and internal heat, so Venus comes out at 300 K against a real
surface of 737 K and Io, kept molten by tides, classifies as ice. And
these are illustrations: reasoned, but not observations.

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-05 06:52:22 +00:00
parent a84e2d3a69
commit ac296f5133
17 changed files with 1566 additions and 92 deletions
+6 -61
View File
@@ -2,9 +2,12 @@ import * as THREE from 'three/webgpu';
/**
* Real NASA/ESA/USGS photography baked into `src/assets/textures/bodies/` at build time,
* keyed by the same ids used in `bodies.json`. Bodies without an entry here (most exoplanets,
* a few moons whose photo wasn't sourced this round, and any future body) fall back to
* `proceduralBodyTexture()` below rather than a flat color.
* keyed by the same ids used in `bodies.json`.
*
* This map is the whole of what has actually been photographed. Everything else — every
* exoplanet, since not one has ever been imaged, and the moons no probe returned a usable map
* of — falls through to `procedural-planet-texture.ts`, which derives a surface from the body's
* own measured size, mass, orbit and host star instead.
*
* Provenance (all public domain NASA/JPL or CC BY 4.0 Solar System Scope, via Wikimedia
* Commons — see each file's Commons page for the original credit line):
@@ -80,61 +83,3 @@ export function loadCachedTexture(path: string): THREE.Texture {
loadedTextures.set(path, texture);
return texture;
}
const proceduralTextureCache = new Map<string, THREE.CanvasTexture>();
/**
* Generates a simple procedural surface for bodies with no real photograph available — mainly
* exoplanets, whose actual surfaces have never been directly imaged. This is an honest artistic
* stand-in (mottled bands tinted by the body's classification color), not a fabricated "real"
* texture, and is cached per color so repeated exoplanets of the same kind share one canvas.
* Returns `undefined` if 2D canvas rendering isn't available (e.g. under a test/jsdom
* environment with no canvas backend); callers should fall back to a flat material color.
*/
export function proceduralBodyTexture(baseColor: THREE.ColorRepresentation): THREE.CanvasTexture | undefined {
const key = new THREE.Color(baseColor).getHexString();
const cached = proceduralTextureCache.get(key);
if (cached) {
return cached;
}
const size = 256;
const canvas = document.createElement('canvas');
canvas.width = size;
canvas.height = size;
const context = canvas.getContext('2d');
if (!context) {
return undefined;
}
const base = new THREE.Color(baseColor);
const light = base.clone().offsetHSL(0, -0.15, 0.14);
const dark = base.clone().offsetHSL(0, 0.05, -0.16);
context.fillStyle = `#${base.getHexString()}`;
context.fillRect(0, 0, size, size);
// A handful of horizontal-ish noisy bands, reminiscent of banded gas giants / mottled rock,
// without claiming to depict any specific real surface feature.
let seed = key.split('').reduce((sum, char) => sum + char.charCodeAt(0), 0) || 1;
const random = () => {
seed = (seed * 1103515245 + 12345) & 0x7fffffff;
return seed / 0x7fffffff;
};
const bandCount = 10;
for (let i = 0; i < bandCount; i++) {
const y = (i / bandCount) * size + random() * (size / bandCount) * 0.4;
const height = size / bandCount * (0.5 + random() * 0.6);
context.fillStyle = `#${(random() > 0.5 ? light : dark).getHexString()}`;
context.globalAlpha = 0.35 + random() * 0.25;
context.fillRect(0, y, size, height);
}
context.globalAlpha = 1;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
proceduralTextureCache.set(key, texture);
return texture;
}