Repolode
qunabu

qunabu/Gravity

An interactive TypeScript and Three.js solar system simulator that shows how gravity shapes orbits, with a guided tour and real astronomical data.

Stars
220
Forks
17
Open issues
0
Last commit
29 days ago

What is it?

Gravity is a browser-based solar system simulator built with TypeScript, Three.js and Vite. It uses real astronomical data for body sizes, masses and J2000.0 orbital elements, so planets, Pluto and the major moons follow their actual orbits. The only thing that is scaled is the rendering, and a toggle lets you switch between true scale and a visual scale that keeps the Sun and tiny Mercury visible at once.

The project opens with a 43-step guided tour that explains why orbits exist, starting from Newton's laws and moving through the Earth-Moon system, Lagrange points, tides, and general relativity. Each step has a deep link, and the text can be switched between English and Polish. After the tour, a free-explore mode lets you work with the simulation directly.

Two physics models can be toggled: an analytic Keplerian model, and an N-body model that integrates all-pairs Newtonian gravity with a leapfrog integrator and displays live energy drift. Textures are generated procedurally on a canvas, so the app runs offline without image files.

Key features

  • 01Real planetary sizes, masses and J2000 orbital elements for the Sun, planets, Pluto and major moons.
  • 02Toggle between true scale and a visual scale that keeps small bodies visible.
  • 03Switch between analytic Keplerian orbits and a live N-body gravity simulation.
  • 04Guided 43-step tour with deep links and English/Polish text.
  • 05Procedurally generated planet and moon textures that work offline.

Use cases

  • Teaching orbital mechanics and Newton's laws to students.
  • Exploring how Lagrange points, tides and orbital resonance work visually.
  • Using the TypeScript and Three.js codebase as a reference for a 3D scientific visualization.

Quick start

  1. 1

    Install dependencies

    npm install
  2. 2

    Start the dev server at localhost:5173

    npm run dev

Things to know

  • Moon orbital node, argument and phase values are approximate; only semi-major axis, eccentricity, inclination and period are real.
  • Visual scale uses a non-linear remap, so orbit ellipses are only near-ellipses in that mode.
  • N-body mode with moons enabled needs a finer timestep and can lose accuracy at very high time multipliers.

Topics

FAQ

What is Gravity?
An interactive TypeScript and Three.js solar system simulator that shows how gravity shapes orbits, with a guided tour and real astronomical data. Gravity is a browser-based solar system simulator built with TypeScript, Three.js and Vite. It uses real astronomical data for body sizes, masses and J2000.0 orbital elements, so planets, Pluto and the major moons follow their actual orbits. The only thing that is scaled is the rendering, and a toggle lets you switch between true scale and a visual scale that keeps the Sun and tiny Mercury visible at once.
Is Gravity free to use? What license does it have?
Gravity is open source under the GPL-3.0 license. Check the license terms before using it in commercial products.
Is Gravity still maintained?
Actively maintained. The last commit to Gravity was on Sep 21, 2026.
What can I use Gravity for?
Teaching orbital mechanics and Newton's laws to students. Exploring how Lagrange points, tides and orbital resonance work visually. Using the TypeScript and Three.js codebase as a reference for a 3D scientific visualization.
How do I install Gravity?
Install dependencies: npm install Start the dev server at localhost:5173: npm run dev
Where can I get Gravity?
The source code and installation instructions are on GitHub: https://github.com/qunabu/Gravity

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects