Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>VS Code Space SimNew to Visual Studio Code? Get it now.
VS Code Space Sim

VS Code Space Sim

Keshav Madhav

|
3 installs
| (0) | Free
Interactive N-Body gravity simulation with Barnes-Hut algorithm right in your VS Code explorer. Watch celestial bodies orbit, collide, and merge in real-time!
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VSCode Space 🌌

Visual Studio Marketplace Version License: MIT GitHub Stars

An interactive N-Body gravity simulation right in your VS Code explorer. Watch celestial bodies orbit, collide, and merge in real-time using the Barnes-Hut algorithm!

VSCode Space Preview

✨ Features

🚀 Real-Time Physics Simulation

  • Barnes-Hut Algorithm — Efficient O(n log n) gravitational calculations
  • Collision Detection — Bodies merge on contact with momentum conservation
  • Stable Orbits — Leapfrog integration for accurate orbital mechanics

🎨 Visual Effects

  • Smooth Trails — Gradient trails that fade from oldest to newest points
  • Starfield Background — Thousands of background stars (performance optimized)
  • Color-Coded Bodies — Visual distinction based on mass and type

🌍 Built-in Presets

Preset Description
Solar System Stable 8-planet system with realistic orbits
Binary Stars Two massive stars in gravitational dance
Three Body Classic chaotic three-body problem
Galaxy Spiral galaxy with rotation effect
Collision High-energy collision scenarios
Ring Saturn-like ring formation
Cluster 1000-body galaxy simulation

🎮 Interactive Controls

Toolbar

  • ◀️ Slow Down — Decrease time scale (-1x)
  • ⏸️/▶️ Pause/Play — Toggle simulation
  • ▶️ Speed Up — Increase time scale (+1x)
  • ➕ Spawn — Add new celestial bodies

Mouse

  • Click + Drag — Pan the camera
  • Scroll Wheel — Zoom in/out
  • Click (with body selected) — Spawn body at position

Body Types

Spawn different celestial objects via the + menu: | Type | Description | |------|-------------| | 🪨 Asteroid | Tiny, minimal gravitational effect | | 🪐 Planet | Small, orbiting body | | ⭐ Star | Medium mass, bright coloring | | 🔴 Giant | Large, heavy body | | ⚫ Black Hole | Massive, with signature red border |

📦 Installation

From VS Code Marketplace

  1. Open VS Code
  2. Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
  3. Search for "VSCode Space"
  4. Click Install

From VSIX

  1. Download the .vsix file from Releases
  2. In VS Code, open Command Palette (Cmd+Shift+P / Ctrl+Shift+P)
  3. Run "Extensions: Install from VSIX..."
  4. Select the downloaded file

🚀 Usage

  1. Open Explorer — The simulation appears in a panel in the Explorer sidebar
  2. Choose a Preset — Click the ⋯ menu and select a preset
  3. Watch & Interact — Pan, zoom, and spawn new bodies!

Commands

All commands are available via Command Palette (Cmd+Shift+P / Ctrl+Shift+P):

Command Description
Space: Pause Pause the simulation
Space: Play Resume the simulation
Space: Reset Simulation Reset to initial state
Space: Speed Up (+1x) Increase time scale
Space: Slow Down (-1x) Decrease time scale
Space: Preset: Solar System Load solar system preset
Space: Preset: Binary Stars Load binary stars preset
Space: Preset: Three Body Load three-body preset
Space: Preset: Galaxy Load galaxy preset
Space: Preset: Collision Load collision preset
Space: Preset: Ring Load ring preset
Space: Preset: Cluster Load 1000-body cluster
Space: Spawn Body Open spawn menu

🔧 Technical Details

Physics Engine

  • Algorithm: Barnes-Hut with θ = 0.5 for force approximation
  • Integration: Leapfrog method for energy conservation
  • Collision: Inelastic merging with mass and momentum conservation

Performance Optimizations

  • QuadTree spatial partitioning
  • Circular buffer for trail storage
  • View frustum culling for off-screen bodies
  • Adaptive trail point decimation
  • Separate canvas layers (static stars, dynamic simulation)
  • Background stars update only on camera movement

Requirements

  • VS Code 1.85.0 or higher
  • No additional dependencies required

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  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

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.

👨‍💻 Author

Keshav Madhav

  • GitHub: @Keshav-Madhav

🔗 Related Projects

🌐 Space Simulator (Browser Version)

Want a more expansive, full-featured gravitational sandbox? Check out the companion browser-based simulator:

Live Demo GitHub Repo

Feature VSCode Space Browser Simulator
Body Count Ideally 100 Ideally 20,000+
Custom Spawning Preset types Full radius/density/color control
Camera Pan & zoom Follow body, center-of-mass tracking
Controls Mouse + toolbar Mouse + 15+ keyboard shortcuts
Physics Tweaks Time scale Time scale, collision toggle, velocity units
Visualizations Trails, starfield Trails, velocity vectors, labels, FPS overlay
Presets 7 presets 6+ presets including deterministic tests
Performance Optimized for sidebar Designed for large-N scaling

Browser Simulator Highlights:

  • 🔬 Scientific sandbox — Experiment with orbital mechanics, three-body chaos, and galaxy formation
  • ⚡ Performance-focused — Roadmap includes Barnes-Hut, Web Workers, and WebGL acceleration
  • 🎛️ Deep customization — Adjust density, radius, color for each body type
  • 📊 Real-time metrics — Velocity vectors, FPS display, unit switching (m/s ↔ km/s)
  • 🎹 Keyboard shortcuts — WASD pan, C follow camera, T/K/G spawn presets, and more

Perfect for when you want to dive deeper into gravitational physics without leaving your browser!

🙏 Acknowledgments

  • Inspired by Space-Simulation-HTML-CSS-JS
  • Barnes-Hut algorithm for efficient N-body simulation
  • VS Code Extension API for seamless integration

Enjoy exploring the cosmos from your code editor! 🌟

⭐ Star this repo if you find it useful!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft