Skip to content

Interactive 3D visualization of binary black hole mergers with realistic physics, gravitational lensing, and wave effects. Built with Three.js and WebGL.

License

Notifications You must be signed in to change notification settings

sai-educ/Interactive-3D-Black-Hole-Merger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŒ Black Hole Merger Simulation

๐Ÿ‘‰ Go here for interactive simulation

An interactive, scientifically-inspired 3D visualization of binary black hole mergers featuring realistic gravitational physics, stunning visual effects, and real-time rendering.

Black Hole Merger Simulation License WebGL Status

Created by Sai Gattupalli, Ph.D. - STEM Education Technology Expert, Researcher, and Writer
Developed using innovative "vibe coding" techniques

๐ŸŽฏ Overview

This project simulates one of the most violent and energetic events in the universe - the merger of two black holes. Inspired by LIGO's groundbreaking gravitational wave detections, this simulation combines accurate physics with stunning visual effects to create an educational and mesmerizing experience.

โœจ Key Features

  • ๐Ÿ”ฌ Realistic Physics Engine

    • Newtonian gravitational attraction
    • Energy loss through gravitational wave radiation
    • Conservation of momentum and mass-energy
    • Schwarzschild radius calculations
    • Keplerian orbital mechanics
  • ๐ŸŽจ Advanced Visual Effects

    • Real-time gravitational lensing that warps spacetime
    • Dynamic gravitational wave visualization
    • 70,000+ particle star field
    • Accretion disk with 20,000 particles per black hole
    • Particle-based merger flare effect
    • Bloom and post-processing effects
  • ๐ŸŽฎ Interactive Controls

    • Adjustable mass ratio between black holes
    • Variable initial separation distance
    • Time scale control (0.1x to 3.0x speed)
    • Toggle individual visual effects
    • Orbit camera with smooth damping
    • Real-time parameter adjustments
  • ๐Ÿ“Š Three Simulation Phases

    1. Inspiral: Black holes orbit each other, slowly losing energy
    2. Merger: The violent collision and coalescence
    3. Ringdown: The merged black hole settles into equilibrium

๐Ÿš€ Live Demo

Go here for interactive simulation

Best experienced on desktop with a modern browser

๐Ÿ› ๏ธ Technology Stack

  • Three.js (r163) - 3D graphics library
  • WebGL - Hardware-accelerated graphics rendering
  • GLSL Shaders - Custom gravitational lensing and wave effects
  • ES6 Modules - Modern JavaScript architecture
  • Tailwind CSS - Utility-first CSS framework
  • Vanilla JavaScript - No framework dependencies

The following section is for educators and learners with programming experience.

๐Ÿ“ฆ Installation

Quick Start

  1. Clone the repository

    git clone https://github.com/yourusername/black-hole-merger-simulation.git
    cd black-hole-merger-simulation
  2. Serve the files locally

    Using Python:

    python -m http.server 8000

    Using Node.js:

    npx serve

    Using VS Code:

    • Install the "Live Server" extension
    • Right-click on index.html and select "Open with Live Server"
  3. Open in browser

    http://localhost:8000
    

Deployment (3 choices to choose from)

Vercel (Recommended)

  1. Fork this repository
  2. Import to Vercel
  3. Deploy (no configuration needed)

GitHub Pages

  1. Go to Settings โ†’ Pages
  2. Select source: "Deploy from a branch"
  3. Choose branch: main, folder: / (root)
  4. Save and wait for deployment

Netlify

  1. Drag and drop the project folder to Netlify Drop
  2. Instant deployment with a unique URL

๐ŸŽฎ Controls & Usage

Mouse Controls

  • Left Click + Drag: Rotate camera around the black holes
  • Scroll Wheel: Zoom in/out
  • Right Click + Drag: Pan camera (disabled by default)

Keyboard Shortcuts

Key Action
Space Play/Pause simulation
R Reset simulation
L Toggle gravitational lensing
W Toggle gravitational waves
D Toggle accretion disks
I Show information panel
Esc Close information panel

Control Panel

  • Mass Ratio: Adjust the relative masses (Mโ‚‚/Mโ‚) from 0.1 to 1.0
  • Initial Separation: Set starting distance (25-80 Schwarzschild radii)
  • Simulation Speed: Control time scale (0.1x to 3.0x)
  • Visual Effects: Toggle individual effects on/off

๐Ÿ”ฌ Physics Implementation

Gravitational Dynamics

The simulation implements classical Newtonian gravity with relativistic corrections:

F = G * m1 * m2 / rยฒ

Energy Loss via Gravitational Waves

Based on the Peters-Mathews formula for orbital decay:

dE/dt = -(32/5) * (Gโด/cโต) * (m1ยฒ * m2ยฒ * (m1+m2)) / rโต

Mass-Energy Conversion

During merger, approximately 5% of the total mass is converted to gravitational wave energy, following Einstein's mass-energy equivalence.

Schwarzschild Radius

The event horizon radius is calculated as:

Rs = 2GM/cยฒ

๐Ÿ“Š Performance Optimization

  • Particle Systems: Efficient buffer geometry for 90,000+ particles
  • Level-of-Detail: Dynamic quality adjustments based on performance
  • Frustum Culling: Automatic Three.js optimization
  • GPU Acceleration: WebGL shaders for complex calculations
  • Adaptive Quality: Pixel ratio capped at 2x for high-DPI displays

๐ŸŽจ Visual Effects Details

Gravitational Lensing

Custom GLSL shader that bends light around massive objects, creating realistic spacetime distortion.

Gravitational Waves

Quadrupole wave pattern shader visualizing spacetime ripples emanating from the system.

Accretion Disks

20,000 particles per black hole with:

  • Keplerian orbital mechanics
  • Tidal disruption effects
  • Temperature-based color gradients
  • Particle life cycles

Bloom Post-Processing

UnrealBloomPass for enhanced glow effects during merger events.

๐Ÿ“ Project Structure

black-hole-merger-simulation/
โ”œโ”€โ”€ index.html          # Main HTML structure
โ”œโ”€โ”€ style.css           # Styles and animations
โ”œโ”€โ”€ script.js           # Core simulation logic
โ”œโ”€โ”€ README.md           # Documentation
โ””โ”€โ”€ preview.png         # Social media preview image (optional)

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Maintain consistent code style
  • Add comments for complex physics calculations
  • Test on multiple browsers (Chrome, Firefox, Safari, Edge)
  • Ensure mobile responsiveness
  • Optimize performance for low-end devices

๐Ÿ“š Educational Resources

Learn More About Black Holes

Three.js Resources

๐Ÿ› Known Issues & Limitations

  • Performance may vary on integrated graphics cards
  • Mobile devices may experience reduced particle counts
  • Safari may have minor shader compatibility issues
  • Maximum recommended particle count: 100,000 total

๐Ÿ—บ๏ธ Roadmap

  • Add sound effects and gravitational wave audio
  • Implement spinning black holes (Kerr metric)
  • Add more preset scenarios (different mass ratios)
  • VR/AR support for immersive experience
  • Neutron star merger variant
  • Educational mode with annotations
  • Record and export simulation videos
  • Multi-body simulations (3+ black holes)

๐Ÿ™ Acknowledgments

  • Inspired by LIGO's detection of gravitational waves from GW150914
  • Three.js community for the excellent documentation and examples
  • NASA for public domain space imagery and educational resources
  • The scientific community for making complex physics accessible

๐Ÿ“ง Contact

๐Ÿ“ธ Screenshots (This section is updated continuously)

Inspiral Phase

Two black holes orbiting each other, slowly losing energy to gravitational waves

Merger Event

The violent collision creating intense gravitational waves and energy release

Gravitational Lensing

Spacetime distortion bending light from background stars


Made with โค๏ธ and physics

โญ Star this repository if you find it interesting!

About

Interactive 3D visualization of binary black hole mergers with realistic physics, gravitational lensing, and wave effects. Built with Three.js and WebGL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published