Spring joint with AmmoJS


I’m currently trying to simulate muscles and ligaments. I think the best thing for that are springs.
In my project, I have a lot of compound bodies with some primary colliders. So I have to use AmmoJS because it’s currently the only engine that can properly handle them.

Ir didn’t find any joint in AmmoJSPlugin where I can change stiffness or damping to create a spring. But the Bullet physics engine has a btGeneric6DofSpringConstraint wich I think I could use.(Bullet Collision Detection & Physics Library: btGeneric6DofSpringConstraint Class Reference)

I’m not very good in C++ or mixing different frameworks but I find a way to create a spring.

In https://www.babylonjs-playground.com/#W2KED8#15 , I created a spring joint (line 78) wich seems to be fine at first glance. The two bodies have a constraint. If I move one, the other one follow immediatly.
But If I want to change the stiffness or the damping of the spring, nothing change. It’s like the constraint is not affected. Changing the mass of the green box or the gravity changes nothing.

Right now, I don’t know where to look to make this work. I also don’t understand the use of indexes in some functions like “springJoint.enableSpring(index,bool)”.

If someone has an idea or see my mistakes ? :).

Thanks for help.

Okey, that was fast, I found xD…

We have to remove the restrictions with


The indexes are for the axes. “1” is for y-axis.


1 Like