Hi, I’m interested in learning about cloth physics in three.js. I have a gltf and would like to apply cloth physics, what are the general steps that I need to take? It does not have to be specific, I just want to know what I need to research.
Cloth rendering is a very specific area of 3D rendering so it will be hard to find beginner friendly tutorials. The scientific papers about cloth rendering mostly assume prior knowledge in this area and computer graphics in general. You have to be really brave when diving into this topic^^.
You’re right… it does appear very complicated. I notice that the 2nd demo you provided is made with help from ammo.js. Using ammo.js, it should be simple for beginners like me who have no experience with physics but want to achieve physics? If so, I think I will start there…
Hello, I’m the author of the Three.js Ammo examples. You have all what you need in the webgl_physics_volume demo:
The function createSoftVolume( bufferGeom, mass, pressure ) will create a soft body with the given BufferGeometry, the mass, and an internal air pressure value. A soft body is the type of body wich can deform, as opposed to the rigid bodies.
Of course you want to keep all the other functions related to physics in the example.
You can give the function a BufferGeometry loaded from gltf.
The mass is up to you (the best is to use meters, seconds and kilograms for all the length, time and mass units)
Finally, for simulating cloth you can use 0 as the pressure. If you give a positive pressure the cloth will inflate like a balloon even if it is a not closed mesh. (Edit: To clarify, the cloth can be an open, double-sided rendered mesh)
Then, you can also stick the cloth to the person model at some vertices, with the so called anchor points. See the webgl_physics_cloth example, where the function softBody.appendAnchor() is used to glue the cloth to the crane arm. You can add anchors to a soft body, linked to a rigidBody or fixed in thin air.
@yombo Thanks for your explanations! In this forum, we always try to recommend reading materials for the interested developer or student. Do you know any good books or publications in context of cloth rendering/physics? If so, it would be great to add these resources to the three.js bookshelf
I have been banging my head against this all afternoon trying to figure out how to get the BufferGeometry from the GLTF file to parse into the createSoftVolume( bufferGeom, mass, pressure) function.
Trying to create custom soft body meshes as well. Any help would be much appreciated!
Oh cool! ty for posting that! I will give that a try. I am wondering if the performance is good enough to have a few of those going at once. I am looking for a solution for moving hair, skirts, etc on avatars.
It was a silly error - it is actually surprising easy to use the function to create geometry from a gltf model. I was just not allowing the model to load before calling the function - all is working well now.
@donmccurdy I have posted it before, but no one discussed it.So I had to look in the comments to find out, the clothes in the FBX character model didn’t know how to fit the fabric pattern
It is a very broad question, with not enough information to answer it. To me it sounds like you may want to be using modeling software like Blender instead? That is a much better way to do most changes to existing 3D models.