Note: I use p5.js as an editor, not a library
See the updated post in the pingback below
My current JavaScript project is to represent gravity in three-dimensions using a 3D library called three.js. This is however a difficult task at first and now I have got the engine I am having problems with sudden accelerations. The more physicist of you will notice I am accelerating them towards each other based on their distance and mass, so if I place two of them very close together, they will literally fly off each other at 10px/s (I have an emergency slow down mechanism). I am thinking of installing some sort of method that doesn’t affect their acceleration if they are close, but tell me your ideas in the comments! The engine is able to cope with as many particles as you like with as many different masses. If you want to add or remove particles, see line 109 and change in this order: cubegen(mass,colour,position,initialVelocity)
int mass
Sets the mass of the object. This will affect its acceleration rate and size.
col colour
Sets the colour of the object on screen.
int[] position
Sets the initial position of the object.
BETA int[] initialVelocity
Sets the initial velocity of the object

One thought on “Gravity simulator 3D”