How to achieve simple cloth-like physics simulation

Has anyone made effect like that (attention on car’s antenna)?
I have absolutely no idea how to do this.
May be someone has an experience in that kind of features?

I don’t even know how this behaviors named so i can’t even google it :frowning:

Hi Pashtet,

Sounds like you might be looking for how to use a physics engine, and specifically how to use spring joints (they’re mentioned on that doc page). There’s also a Playground demonstrating the use of Cannon’s built-in spring physics joint.

You might have to play around with it a bit if you’re going for a particular look/feel to the physics, but I think that’s a good place to start. If you end up wanting more precise control, it’s also not too difficult to write a custom “toy” spring mechanism to achieve a certain look (here’s a quick one that doesn’t bother much with physical accuracy, but looks kind of fun). Hope this helps!


Thank you so much! I’ll try it:)

Old, but might help -

(Shameless self-promotion! :slight_smile: )


Thank you! I have already red your article, it awesome) But I a bit confused with that method, I can’t use this method when I’m using 3d model more complex than plane. At times, it seems to me that Skeloton and Bones are right way to solve my problem. But I haven’t found how to apply physics to Bone at the moment .

Physics on bones will work very similar to the way the cloth is working - you add particles to the bone’s position, connect them with any join you think fits (distance joint exists in all engines, spring joint is available in cannon) and update the bone’s position every frame based on what the physics engine delivers back. So:

  1. Add a particle per bone position (I would disable the bidirectional transformation to have better performance - it is a flag in the impostor options)
  2. Set each particles transformation according to the absolute position of the bone
  3. Connect those particles using joints
  4. On a before-render function, get the (updated) positions of the bone impostors and update the bone positions accordingly.

If you limit the joint’s allowed angles you can get the effect you wanted

On a different note, you can achieve this effect without a physics engine (at least not on the antenna). Create the mesh, and update its movement according to the change in acceleration in the (local) Z axis of the car. You know the car is moving in a specific speed - move the upper pat of the antenna a bit to the back if it goes forward. When the can breaks (acceleration delta is negative) start moving the antenna forward. I dont see why it can’t look realistic without a physics engine.

1 Like

I have tried to implement this feature, but faced with problem with gravity (Distance and Spring joints doesn’t have “lock” features). I have tried to implement with LockJoint and I’ve got some results - Babylon.js Playground

I keep trying :slight_smile:

Hi guys.

Seeing we have AmmoJS nearby, we also have ropeImpostors nearby.

Just begun. Started with someone elses PG. That whole PG series is packed-with Ammo soft-body demos, I believe.

Forced-positioning in line 35… never a good idea for a mesh with a physicsImpostor, so might be troubles there. Plus, I dunno if a rope impostor is SUPPOSED TO work… “standing”. I don’t know how to set its restitution, mass, inertia, etc, either. New stuff for Mr. Wingnut.

Are we seeing SOME “bend” as this thing cycles laterally? Not sure. It seems opposite bend-direction from what it should be. Could be eye-foolery. :slight_smile: - Classic chain of hinge joints in Cannon… MIGHT be able to be made “stiff” by moving connectedPivots on joints… up or down. Not sure. Might be difficult to replace spheres with tube-sections. All sorts of obstacles to “smooth linear bend” there, too. Essentially, this is one “column” of cloth… using larger sphereImpostors instead of particleImpostors or Ammo’s method.

1 Like

How about using a point-to-point joint?


Thank you, Master :slight_smile:

I changed bones position synchronisation to rotation, now it looks almost as I wish.

Now I’ll try to make it more solid (elastic)



With your permission, I am going to make it a WebXR boxing scene :slight_smile: . Seems like a perfect way to test physics on the controllers

Of course! I will only be happy :slight_smile:

1 Like

Meh Ammo… It can do everything, but it so difficult for me. I think Cannon.js is my limit:)

1 Like