Skip to content

omerarslan0/geodesic

Repository files navigation

Geodesic

Bend light through gravity wells and turn it into art.

Try it live →

Geodesic — gravitational lensing art

What is this?

Geodesic lets you drop masses onto a canvas and watch thousands of light rays warp around them in real time. The patterns that emerge — caustics, interference, lensing arcs — look like something out of a telescope, but you made them by clicking.

It's a toy, an art tool, and a physics playground rolled into one. Every frame is exportable as a PNG.

Features

  • Real-time ray tracing — 1000+ rays bent through curved spacetime, computed in Rust/WASM
  • 3D spacetime mesh — Optional wireframe showing how mass curves the fabric of space
  • 5 color schemes — Infrared, Ocean, Aurora, Mono, Plasma
  • Smart shuffle — Generates aesthetically composed scenes with one click
  • Particle trajectories — Launch test particles and watch them orbit, spiral, or get captured
  • Time dilation overlay — See where time slows down near massive objects
  • Art Shot export — One-click export from the optimal camera angle
  • Gallery presets — Curated starting points: black holes, binary systems, gravitational lenses
  • Auto-rotation — Scene slowly orbits when idle, screensaver style
  • Undo — Ctrl+Z works like you'd expect

Controls

Action What it does
Click Drop a new mass
Drag Move a mass around
Scroll on a mass Make it heavier / lighter
Right-click a mass Delete it
Long press (mobile) Delete
R Shuffle — new random scene
Ctrl+Z Undo
E Export PNG
F Fullscreen
M Toggle spacetime mesh
T Toggle time dilation
G Open gallery
P Switch mass/particle mode
Space Pause/resume

Tech

Physics Rust → WASM via wasm-bindgen. RK4 integrator with GR correction: a = -M/r² · (1 + 3Mv²/r²)
Rendering React Three Fiber + Three.js. Single draw call, additive blending, per-vertex curvature coloring
Post-processing Bloom + vignette + chromatic aberration
Mesh deformation GPU-side vertex shader, 40k vertices displaced in real time
Frontend Next.js 16, TypeScript, Tailwind CSS

The WASM binary is ~16KB gzipped. It traces 1000 rays × 2000 steps in about 5ms on a modern machine.

Run locally

git clone https://github.com/omerarslan0/geodesic.git
cd geodesic
npm install
npm run dev

WASM is pre-built in public/wasm/. If you want to recompile the Rust physics engine:

# needs rust + wasm-pack
npm run build:wasm

How the physics works

Each ray is a null geodesic traced through a Schwarzschild-like field. Multiple masses are superimposed — not physically rigorous for multi-body GR, but it produces gorgeous caustic patterns, which is the whole point.

The particle sim uses velocity Verlet integration with the same GR-corrected acceleration. ISCO (innermost stable circular orbit) is shown at r = 3M for each mass.

License

MIT

About

Bend light through gravity wells. Interactive generative art tool powered by Rust/WASM and Three.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors