Implement Rigidbody throghout Morph Target Transformation

I have a gltf model with morph targets which is working as expected .
I had a sphere 3d object which by using dat.gui controls value change morph to a suzanne.
as far now , the scene displays a ball which is rigid and collides with other components .

when I do

threeObject.morphInfluences[0]=value ;

In the rigidbody function it doesn’t morph to its target.
When I change the influence of the morph . Nothing changes

What I want to acheive is
When the sphere changes to suzanne it should also have rigidbody along its morphinfluence and react along each morph .

Can it be done .

1 Like

Your problem is not three.js, it’s Ammo, or Bullet even.

My guess is - constructed 3d shapes can not be modified at run time, that’s one. So you may have to rebuild the physics object each time morph influences change. You can check on that, I suggest reading Bullet documentation on this, it might be possible to mutate the shape, but there’s probably some kind of special process for that.

Second, you have to compute actual vertex positions after morphing yourself, and provide those to Ammo.js, Ammo.js has no awareness of skinning, morph targets, skeletons, animations etc. All it knows are: Shapes, Bodies and Constraints - that’s literally all.

In short:

  1. update morphing (influences, target etc.)
  2. compute new vertex positions for your mesh (on CPU)
  3. give those computed vertex positions to Ammo.js (here you might have to rebuild your body/shape as well depending on what Bullet/Ammo allow)
2 Likes