A JavaScript 3D n-body particle simulator using a simplified model of Physics.
Try to simulate 3 forces on point-like particles:
- Gravity
- Electromagnetic
- Nuclear force
BTC: 187JHUUqszdB9fC6Nn52CpP7UsEeD8GsNh
Github Sponsor: https://github.com/sponsors/andrenepomuceno
Big thanks to three.js guys who made this amazing WebGL library, making the entire process a lot easier and fun.
To run the test server on localhost:8080
git clone https://github.com/andrenepomuceno/particle.js.git
cd particle.js
npm install
npm run test
To build the production package:
npm run build
- Real time simulation
- Runs on GPU.
- Supports 2D and 3D modes.
- Can export and import simulations.
- Adjustable parameters during runtime.
- Vector field visualization.
- Interactive simulation and particles. Almost everything is editable!
- Sandbox Mode
- And much more...
Main considerations:
- Each particle is a point (no volume) in space.
- Particles have vectorial properties like position and velocity.
- Particles have scalar properties like mass, charge and "nuclear charge".
- Particles interact and collide with each other every simulation step.
- Uses Coulomb's Law for electromagnetism and Newton's Law for gravity.
- Uses an approximate nuclear force, trying to imitate the Strong Force.
For each particle
where
and
For this project, the default is
Function
So, the velocity of the particle is described by
And the position
A collision occurs when the distance between two particles is less than a minimal allowed distance
In the case of a collision between
Where
So, the force exerted by a collision is (a lot of omitted calculus here...)
Simplified diagram, first layer only.
