This is not a something like simulation of a galaxy, since in a galaxy all bodies interact with each other. The simulation roughly visualizes how ultralight bodies would interact with one supermassive body.
The advantage of this type of simulation is the simplicity of calculations: O(N). Because only one body actually attracts all the particles we can simulate hundreds of thousands of particles in the browser in real time.
For a real N-Body simulation, it would be necessary to calculate the interaction of each particle with each other. For 1000 particles this would require 1,000,000 operations.
But with some optimization it is achievable! See implementation of N-Body simulation.
1-Body Visualization frame with 1,000,000 particles
Demo: https://dra1ex.github.io/JS_ParticleSystem/
- particle_count - Count of particles to simulate (default: 100000 for mobile, 200000 for desktop)
- fps - Refresh rate in frames per second (default: 60)
- dpr - Enable drawing according to Device Pixel Ratio (default: 0)
- g - Attraction force of mouse pointer (default: 9)
- resistance - Resistance of environment, 1 - means no resistance (default: 0.99)
