Check that a redrawn orbit line reaches the GPU, and hold Saturn to the chords' own sag
The redraw test read the reshaped line's points on the CPU, which reshapeOrbitLine rewrites
whether or not it then sets needsUpdate. three uploads a buffer again only when its version
rises, which only that setter does, so a renderer that dropped the line left J2000's ellipse on
screen and passed the whole suite (857/857). The test now takes Saturn's position version after
drawing J2000 and expects it higher once the clock is at AD 1.
Its Saturn bounds, 0.002 AU at AD 1 and 0.0015 at J2000, sat inside the 128 chords' own sag, which
reaches 0.0032 AU near aphelion, where points spaced evenly in true anomaly lie furthest apart:
the test passed only because Saturn falls near a vertex on those two dates, and a line correct by
construction failed it (Saturn without its a, e and i rates: 0.00229 AU). Both are now 0.0035,
which still catches the line left unreshaped (0.054 AU at AD 1). The renderer's comment put the
sag at 0.003 for Saturn and 0.0005 for Mars; it now says 0.0032 and 0.00055, and where.
Guarded mutants (full suite):
- position.needsUpdate dropped: only the redraw test fails ("expected 0 to be greater than 0");
- the reshapeOrbitLine call dropped: only the redraw test fails;
- Saturn's a, e and i rates removed from bodies.json, line and marker on one ellipse: the
distance bound now passes (0.00229 < 0.0035); the redraw test still fails, on the version, as
it should with nothing to redraw, and so does Saturn's AD 3000 Horizons test (0.41 degrees).
Unit suite 858/858, tsc -p tsconfig.app.json and etl:typecheck clean.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -718,12 +718,21 @@ describe('solar-system bodies against Horizons', () => {
|
||||
}
|
||||
|
||||
it('redraws a planet’s orbit as its axis and eccentricity drift, so Saturn and Mars stay on their lines at AD 1', () => {
|
||||
// What is left is the 128 chords' own sag from the true ellipse: measured 0.0017 AU for Saturn and
|
||||
// 0.0005 for Mars at AD 1, and 0.0011 for Saturn at J2000. Drawn at J2000's shape at AD 1, the
|
||||
// lines were 0.054 AU from Saturn and 0.0022 from Mars.
|
||||
for (const [id, days, maxAu] of [['saturn', -730000, 0.002], ['mars', -730000, 0.0006], ['saturn', 0, 0.0015]] as const) {
|
||||
// What is left is the 128 chords' own sag from the true ellipse, which depends on where the
|
||||
// planet falls between two points: at most 0.0032 AU for Saturn, near aphelion, and 0.00055 for
|
||||
// Mars. Measured 0.0017 AU for Saturn and 0.0005 for Mars at AD 1, and 0.0011 for Saturn at
|
||||
// J2000. Drawn at J2000's shape at AD 1, the lines were 0.054 AU from Saturn and 0.0022 from Mars.
|
||||
const saturnLine = renderer.object.children[renderer.object.children.indexOf(renderer.members.find((member) => member.id === 'saturn')!.marker) - 1] as THREE.Line;
|
||||
renderer.update(DEFAULT_EPOCH_JD);
|
||||
const drawnVersion = (saturnLine.geometry.getAttribute('position') as THREE.BufferAttribute).version;
|
||||
for (const [id, days, maxAu] of [['saturn', -730000, 0.0035], ['mars', -730000, 0.0006], ['saturn', 0, 0.0035]] as const) {
|
||||
renderer.update(DEFAULT_EPOCH_JD + days);
|
||||
expect(offLineAu(id)).toBeLessThan(maxAu);
|
||||
if (days !== 0) {
|
||||
// Handed to the GPU again, which uploads a buffer only when its version rises: the points
|
||||
// rewritten on the CPU alone leave J2000's ellipse on screen.
|
||||
expect((saturnLine.geometry.getAttribute('position') as THREE.BufferAttribute).version).toBeGreaterThan(drawnVersion);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -162,7 +162,8 @@ function ellipseInItsPlane(elements: OrbitalElements, positions: Float32Array):
|
||||
|
||||
/**
|
||||
* How far, in AU, an orbit's drawn ellipse may be from its current one before it is drawn again:
|
||||
* well under the 128 chords' own sag from the true curve, 0.0005 AU for Mars and 0.003 for Saturn.
|
||||
* well under the 128 chords' own sag from the true curve, at most 0.00055 AU for Mars and 0.0032
|
||||
* for Saturn, near aphelion, where points spaced evenly in true anomaly lie furthest apart.
|
||||
*/
|
||||
const ORBIT_RESHAPE_AU = 1e-4;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user