0

I want the Force converge to a point of the scene. So the Force will not be the same on each point of the scene (like Y vector) but change direction in the space. It is like gravity converge to the center of the Planet or Star.

How would you do this with Ammo.js ?

Best regards

PS1 : Firstly, I want exactly to rewrite this example with Ammo.js : http://lo-th.github.io/Oimo.js/#planet

PS2 : My final intention is to rewrite this example of gravity in 3D with Three.js and Ammo.js : https://bruno-m-.github.io/gravity/ I want planets and satellits turn around this point with only their initial velocity, direction, Mass and this Force, like reality.

PS3 : it isn't exactly the same question of this problem : BulletPhysics (ammo.js) - How would you go about applying force to an object? (where the direction of the force didn't change)

  • Assuming you have a scene set up in ammo.. On each frame, you would need to loop through each rigidBody, compute the direction vector and distance from the gravitational object, then use applyCentralImpulse(impulse) on each body with that impulse. This won't be 100% accurate since the impulse won't neccesarily be applied at each timestep.. so you may want to make sure you step your simulation at a fixed delta time, with a substep of 1, and just make repeated calls to .step the simulation so that your force is applied at every step. – manthrax Mar 08 '18 at 23:35
  • PS : it is not likely the same of this question : https://stackoverflow.com/questions/26573039/bulletphysics-ammo-js-how-would-you-go-about-applying-force-to-an-object/49184155?noredirect=1#comment85374159_49184155 The direction of the Force change for all point of the scene – Géo-IT Solutions Mar 08 '18 at 23:37
  • Thanks a lot @manthrax for your answer. But have you an example of code for applying this force to a object with Ammo ? My final intention is to rewrite this example of gravity in 3D with Three.js and Ammo.js : https://bruno-m-.github.io/gravity/ I want planets and satellits turn around this point with only their initial velocity, direction, mass and this Force, like reality. Il the velocity is too much important the sattelit will leave the orbit, and vice versa crash to the planet if not enough.. – Géo-IT Solutions Mar 09 '18 at 08:53

0 Answers0