Replace the SVG core and backdrop with one shader that traces each pixel through Schwarzschild spacetime. The shadow, the arch of the far side of the disk, the second image and the Einstein ring come from the physics rather than artwork. The disk is a thin disk seen from a low angle, about five times the shadow's radius, with Doppler beaming and a filtered, cloud-like texture. - Sky: a procedural galaxy baked once into a cubemap. Point sources are small, few and brightness-capped so they never rival the orbit markers, which now carry a dark backing disc and outline. - Quality: tiers from high to still, a startup calibration cached per canvas size, an fps cap, and an idle sleep. A locked realistic map draws nothing. - Integration: the canvas follows the galaxy frame through Big Screen, draws in Motion's post-render step, takes the disk clock and capture absorption from the galaxy loop, and falls back to the SVG core without WebGL2. - Radar view: a toolbar toggle switches to a radar look that spreads outward from the hole as a wave, with a sweep on its own clock. The choice is remembered per browser; reduced motion switches at once and holds the sweep. - Tests for the geodesics, quality governor, look spring and layout, plus a standalone preview page (web/blackhole-proto.html) for tuning the look. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { CRITICAL_IMPACT, HORIZON, deflection, traceImpact, traceRay } from "../src/lib/blackhole/geodesic.ts";
|
|
|
|
test("a ray inside the critical impact parameter is captured and one outside escapes", () => {
|
|
assert.equal(traceImpact(CRITICAL_IMPACT * 0.94).outcome, "captured");
|
|
assert.equal(traceImpact(CRITICAL_IMPACT * 1.06).outcome, "escaped");
|
|
});
|
|
|
|
test("the shadow edge sits at the analytic 3√3 within the step error", () => {
|
|
let captured = 0;
|
|
let escaped = 10;
|
|
for (let i = 0; i < 24; i++) {
|
|
const mid = (captured + escaped) / 2;
|
|
const { outcome } = traceImpact(mid, 48, { maxSteps: 900 });
|
|
if (outcome === "escaped") escaped = mid;
|
|
else captured = mid;
|
|
}
|
|
assert.ok(Math.abs(escaped - CRITICAL_IMPACT) / CRITICAL_IMPACT < 0.03, `edge at ${escaped}`);
|
|
});
|
|
|
|
test("weak-field deflection follows 4M/b plus the second-order term", () => {
|
|
const b = 20;
|
|
const expected = 4 / b + (15 * Math.PI) / 4 / (b * b);
|
|
const angle = deflection(traceImpact(b, 400, { maxSteps: 600 }));
|
|
assert.ok(Math.abs(angle - expected) / expected < 0.1, `${angle} vs ${expected}`);
|
|
});
|
|
|
|
test("a ray that falls radially is captured at the horizon", () => {
|
|
const trace = traceRay([0, 0, 30], [0, 0, -1]);
|
|
assert.equal(trace.outcome, "captured");
|
|
assert.ok(trace.minRadius < HORIZON);
|
|
});
|
|
|
|
test("a ray in the disk plane never crosses it and a skewed ray crosses it once", () => {
|
|
assert.equal(traceImpact(9).crossings.length, 0);
|
|
const skew = traceRay([9, 14, 40], [0, -0.3, -0.95]);
|
|
assert.equal(skew.crossings.length, 1);
|
|
assert.equal(skew.crossings[0].point[1], 0);
|
|
});
|