use-ammojs icon indicating copy to clipboard operation
use-ammojs copied to clipboard

Cloth simulation

Open DrRonne opened this issue 3 years ago • 2 comments

Hi, first of all, this looks like an amazing project and would very much like to use it. As the title suggests, I'd like to use it for some cloth simulation. I saw an example of Ammo.js with some cloth and it looks very nice: https://threejs.org/examples/?q=cloth#physics_ammo_cloth I would like to create something similar in react, but I'm unsure if this project is already fit for such purpose. A nudge in the right direction here would be immensily appreciated!

Thanks in advance!

DrRonne avatar Jan 18 '22 20:01 DrRonne

Hi @DrRonne ,

this should already be possible. The cloth in the example is implemented as a "SoftBody" in ammojs. The three example uses a specific helper ("CreatePatch") to create the mesh, which use-ammmojs doesn't expose directly yet. Instead arbitrary Meshes can be passed (example) and the result should be identical if you pass in a subdivided plane yourself.

Only caveat is that Textures don't work yet. There's some work to be done to match and map the UV coordinates correctly into the physics buffers in the worker thread.

Attachment points are also demonstrated here.

Hope that helps

notrabs avatar Jan 20 '22 15:01 notrabs

Hi, I'm sorry for being late to respond. I did manage to get it working. I would like to have some textures on it as well though. Is there already a plan on implementing this? If needed/wanted, I could perhaps try this as well. Not yet very familiar with the source code here though.

DrRonne avatar Mar 01 '22 20:03 DrRonne