COSMOS is an interactive 3D solar-system visualizer built with JavaScript, Three.js, WebGL, and a corrected Keplerian planetary model.
Open the deployed visualizer at sudoaanish.github.io/COSMOS.
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.
- 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
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.
For each simulation timestamp COSMOS:
- Advances mean anomaly from the element epoch.
- Solves Kepler's equation:
M = E - e sin(E). - Converts eccentric anomaly to true anomaly.
- Computes orbital radius and orbital-plane coordinates.
- Rotates by argument of periapsis, inclination, and longitude of ascending node.
- Produces heliocentric Cartesian coordinates in AU.
- Passes the physical position through a separate radial visual-compression transform.
- 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.
- 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.
| 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 |
- 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
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.
git clone https://github.com/sudoaanish/COSMOS.git
cd COSMOS
python -m http.server 8768Open http://127.0.0.1:8768.
Opening index.html directly can be unreliable because browser security rules
restrict ES-module loading from file:// URLs.
COSMOS uses Node's built-in test runner and has no runtime test-service dependency.
npm test
npm run checkThe 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.
- 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.
- Human-readable texture attribution
- Machine-readable texture manifest
- Solar System Scope texture licensing where identified in the attribution record
- NASA Scientific Visualization Studio Moon asset
- Official COSMOS logo and icon: original project branding
Procedural textures and geometry are visual approximations and are not presented as sourced surface or shape models.
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.
- 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
- 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
Developed by Aanish Farrukh (sudoaanish).

