Interactive General Relativity and gravitational physics visualizations built with React, Three.js, React Three Fiber, Tailwind CSS, and Vite+.
The app focuses on visually explaining spacetime curvature, gravitational waves, and Mercury's relativistic perihelion precession while keeping the underlying equations tested.
- Spacetime curvature around a central mass using a Schwarzschild-radius visualization.
- Binary massive-body curvature wells and gravitational-wave surface distortion.
- Mercury perihelion precession with a simulation-unit system calibrated for stable, visible orbits.
- Physics tests for Newtonian gravity, Schwarzschild radius, escape velocity, gravitational-wave strain, Kepler frequency, spacetime helpers, and Mercury's real ~43 arcsec/century precession.
- Unified Vite+ workflow for install, check, test, dev, build, and preview commands.
This project uses Vite+ through the vp CLI. Use vp commands instead of calling the package manager or Vite/Vitest directly.
Useful commands:
vp installinstalls dependencies.vp devstarts the development server.vp checkformats, lints, and type checks.vp testruns the test suite.vp buildcreates a production build.vp previewpreviews the production build.vp run <script>runs a package script through Vite+.
- Vite+ CLI available as
vp. - Node.js managed by Vite+ or your local environment.
Check your environment with:
vp env doctorInstall dependencies:
vp installStart the local dev server:
vp devOpen the local URL printed by Vite+.
Routes:
/home page./simulations/mass-effectspacetime curvature around mass./simulations/gravitational-wavesbinary system and wave distortion./simulations/mercury-precessionrelativistic orbital precession.
Run the full check loop:
vp check
vp test
vp buildThe current test suite includes 29 physics tests.
Build the app:
vp buildPreview the generated dist/ output:
vp previewCore equations covered by tests include:
- Newtonian gravity:
F = G m1 m2 / r^2. - Gravitational acceleration:
a = F / m. - Orbital velocity:
v = sqrt(GM/r). - Escape velocity:
v_esc = sqrt(2GM/r). - Schwarzschild radius:
r_s = 2GM/c^2. - Schwarzschild precession:
Delta omega = 6 pi GM / (c^2 a (1-e^2)). - Binary Kepler frequency:
f = sqrt(G(m1+m2)/a^3) / (2 pi). - Leading-order gravitational-wave strain:
h = 4 (G M_c / c^2)^(5/3) (pi f / c)^(2/3) / r. - Chirp mass:
M_c = (m1 m2)^(3/5) / (m1 + m2)^(1/5).
The Mercury simulation intentionally uses dimensionless simulation units for the rendered orbit. Real SI constants at a = 8 render units would produce superluminal, numerically unstable motion. The info panel still validates real Mercury precession using SI units and the real solar mass.
src/physics/pure physics services and equations.src/simulations/React Three Fiber simulation scenes.src/components/app-level layout, renderer, controls, and panels.src/ui/shared UI primitives used by the app.src/styles/globals.cssTailwind v4 theme and dark-mode variant.vite.config.tsVite+ config for build, lint, formatting, staged hooks, and Vite plugins.
The project has been migrated to Vite+:
- Vite config imports use
vite-plus. - Tests import from
vite-plus/test. - Standalone
viteandvitestdev dependencies were removed; Vite+ provides them. - Validation runs through
vp install,vp check,vp test, andvp build.
If tooling behaves unexpectedly, run:
vp env doctorIf dependencies are out of sync, run:
vp install