Skip to content
sudoaanishPublic

About

Interactive 3D solar-system visualizer with a corrected Keplerian orbital model, compressed visual scaling, and educational astronomy tools.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

COSMOS orbital logo

COSMOS

COSMOS is an interactive 3D solar-system visualizer built with JavaScript, Three.js, WebGL, and a corrected Keplerian planetary model.

Live Demo Version 0.2.0 GitHub Pages deployment Tests: 15 passing JavaScript Three.js WebGL Public repository

COSMOS solar-system scene with orbital paths, planets, and the Milky Way

Live Demo

Open the deployed visualizer at sudoaanish.github.io/COSMOS.

Overview

COSMOS presents an explorable solar system in the browser. Planetary positions come from immutable physical orbital records and a complete elliptic Keplerian pipeline. Physical heliocentric coordinates remain in astronomical units (AU); a separate visual transform compresses the outer solar system into a scene that can be navigated comfortably.

COSMOS is a corrected Keplerian visualizer, not an ephemeris engine.

Highlights

  • Interactive Three.js solar-system scene with camera orbit, zoom, inspection, labels, follow targets, and guided tour controls
  • Corrected Keplerian planetary propagation using physically sourced elements
  • Argument of periapsis, inclination, and longitude of ascending node applied to every catalog orbit
  • Physical AU-space calculations separated from compressed render coordinates
  • Body positions and orbit paths generated by the same orbital functions
  • UTC current-date synchronization and direct simulation-date navigation
  • Approximate heliocentric alignment finder with navigable event rows
  • Model-derived physical distance measurements in AU and kilometres
  • Simplified parent-relative moons and an educational Moon-phase display
  • Custom orbiting bodies with unique identities and rendered-Sun clearance checks
  • Procedural asteroid belt, layered planetary rings, comet tail, and irregular small-body geometry
  • Deterministic Milky Way backdrop and depth-occluded point-star layers
  • Local major-planet textures with documented attribution and fallbacks
  • Static, responsive browser deployment with no application build framework

Orbital Model

Each major orbiting body has a physical record containing its central body, semi-major axis, eccentricity, inclination, ascending node, argument of periapsis, mean anomaly at epoch, epoch, orbital period, rotation period, radius, and mass where available. Physical records and visual metadata are deeply immutable and stored separately.

The former scene-distance-derived planetary periods are no longer active. Outer planets therefore advance according to their documented orbital periods, not according to the compressed distance at which they are drawn.

Mathematics And Coordinate Pipeline

For each simulation timestamp COSMOS:

  1. Advances mean anomaly from the element epoch.
  2. Solves Kepler's equation: M = E - e sin(E).
  3. Converts eccentric anomaly to true anomaly.
  4. Computes orbital radius and orbital-plane coordinates.
  5. Rotates by argument of periapsis, inclination, and longitude of ascending node.
  6. Produces heliocentric Cartesian coordinates in AU.
  7. Passes the physical position through a separate radial visual-compression transform.
  8. Maps the result to Three.js, where XZ is the ecliptic plane and Y is vertical.

Orbit-line samples use the same element-to-position functions as the moving bodies, preventing the path and body formulas from diverging.

Accuracy And Limitations

  • Major planets use approximate NASA/JPL J2000 mean elements.
  • Pluto, selected dwarf planets and asteroids, and 1P/Halley use fixed JPL Small-Body Database osculating elements at documented epochs.
  • Planetary perturbations, runtime secular element changes, light-time, aberration, precession, and observer-dependent apparent positions are not fully modeled.
  • Moon motion remains simplified, parent-relative, and visually scaled.
  • Approx. Alignments compare physical heliocentric directions; they are not apparent geocentric conjunction predictions.
  • Relative Size Mode is a presentation mode. It preserves the established 8x planet-distance and 3x moon-distance visual treatments.
  • Custom bodies retain an approximate scene-unit orbit model.
  • No public N-body mode is provided.

The offline regression suite includes fixed JPL Horizons vectors. Declared vector tolerances range from 0.0002 AU for selected terrestrial checks to 0.04 AU for Halley near perihelion. These tolerances characterize the fixed-element model; they do not claim JPL-grade accuracy.

Features

Area Capability
Time Adjustable speed, pause, current UTC date, and explicit date selection
Orbits Full elliptic orientation, path toggle, and compressed presentation
Exploration Body inspection, follow camera, guided tour, drag rotation, and zoom
Measurements Model-derived physical AU/km distance for catalog bodies
Events Approximate physical heliocentric alignments with date navigation
Scene Moons, Moon phase, asteroid belt, rings, comet tail, ecliptic grid, and labels
Sandbox Approximate custom bodies with eccentricity, inclination, and safety validation
Visuals Local planet maps, procedural fallbacks, irregular bodies, and Milky Way backdrop

Controls

  • Drag: rotate the camera
  • Scroll: zoom
  • Speed slider: pause or accelerate simulation time
  • Set to Current Date: synchronize to the current UTC time
  • Set Simulation Date: jump to a selected date
  • Follow Target: track a planet, dwarf planet, asteroid, comet, or moon
  • Relative Size Mode: apply the established presentation scaling
  • 1-9: focus major bodies
  • H: open keyboard-bind help
  • Space: pause or resume

Architecture

index.html / style.css
        |
      app.js
        |
        +-- js/data/
        |     +-- orbital-elements.js   immutable physical catalog
        |     +-- bodies.js             visual metadata
        |     +-- moons.js              approximate moon catalog
        |     +-- catalog.js            runtime catalog assembly
        |
        +-- js/orbital/
        |     +-- constants.js
        |     +-- kepler.js             pure orbital mathematics
        |     +-- transforms.js         AU-to-scene compression
        |
        +-- js/simulation/time.js       UTC navigation helpers

The runtime remains a static ES-module application. Three.js, OrbitControls, GSAP, and web fonts are loaded from CDNs; orbital validation does not require a live internet service.

Running Locally

git clone https://github.com/sudoaanish/COSMOS.git
cd COSMOS
python -m http.server 8768

Open http://127.0.0.1:8768.

Opening index.html directly can be unreliable because browser security rules restrict ES-module loading from file:// URLs.

Tests

COSMOS uses Node's built-in test runner and has no runtime test-service dependency.

npm test
npm run check

The 15 tests cover catalog immutability, Kepler residuals, radius extrema, orientation transforms, path/position agreement, radial compression, real period preservation, UTC navigation, physical distance calculations, and offline Horizons snapshots.

Data Sources

  • Orbital data sources and model tolerances
  • NASA/JPL approximate J2000 planetary elements
  • JPL Small-Body Database elements for selected small bodies
  • Offline JPL Horizons heliocentric vectors used as test fixtures

No live ephemeris API is called by the application or tests.

Visual Assets And Attribution

Procedural textures and geometry are visual approximations and are not presented as sourced surface or shape models.

Repository Structure

assets/
  branding/       logo, icon, favicons, and README hero
  textures/       local runtime textures and attribution
docs/             orbital data-source documentation
js/               immutable data, orbital math, transforms, and time helpers
test/             Node test suite
test-fixtures/    offline Horizons vectors
.github/workflows/pages.yml
app.js
index.html
style.css
VERSION

GitHub Pages deploys only the runtime files (index.html, style.css, app.js, VERSION, js/, and assets/) through a Pages artifact. Development documents, tests, and repository metadata are not part of the deployed site.

Roadmap

  • Time-varying orbital elements or an optional ephemeris-backed mode
  • Observer-frame apparent conjunction calculations
  • More complete lunar orbit models
  • Additional offline reference dates and validation bodies
  • Continued accessibility and label-layout improvements

Version History

  • v0.2.0: corrected Keplerian planetary model, immutable physical catalog, AU/render separation, synchronized orbit paths, physical distance readouts, offline Horizons fixtures, and official branding
  • v0.1.3: visual assets, local textures, irregular small-body geometry, and Milky Way presentation
  • v0.1.2: custom-body safety, deterministic asteroid belt, ring-system differentiation, and small-body visual improvements

Author

Developed by Aanish Farrukh (sudoaanish).

About

Interactive 3D solar-system visualizer with a corrected Keplerian orbital model, compressed visual scaling, and educational astronomy tools.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages