diff --git a/src/app/features/galaxy-system/system-orbits-renderer.spec.ts b/src/app/features/galaxy-system/system-orbits-renderer.spec.ts index 5dc6f5a..08857db 100644 --- a/src/app/features/galaxy-system/system-orbits-renderer.spec.ts +++ b/src/app/features/galaxy-system/system-orbits-renderer.spec.ts @@ -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); + } } }); diff --git a/src/app/features/galaxy-system/system-orbits-renderer.ts b/src/app/features/galaxy-system/system-orbits-renderer.ts index 4b33abe..b854d8b 100644 --- a/src/app/features/galaxy-system/system-orbits-renderer.ts +++ b/src/app/features/galaxy-system/system-orbits-renderer.ts @@ -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;