(I'm still learning so forgive me if this is a beginner question.) I'm currently working on fitting a cloth material to a character model in Three.JS. What would be the most effective approach for this? Should I create a complete garment as cloth geometry, place it on the model, and then apply a physics library? Or is it better to define a set of constraints where the cloth is "pinned" to the model while letting the rest flow freely?
For guidance, I looked into the code for Three's cloth example. However, I could only find references to pin variables in the code, without clear implementation outside of their assignment functions:
/* testing cloth simulation */
var pinsFormation = [];
var pins = [6];
pinsFormation.push(pins);
pins = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
pinsFormation.push(pins);
pins = [0];
pinsFormation.push(pins);
pins = []; // cut the rope ;)
pinsFormation.push(pins);
pins = [0, cloth.w]; // classic 2 pins
pinsFormation.push(pins);
pins = pinsFormation[1];
function togglePins() {
pins = pinsFormation[~~(Math.random() * pinsFormation.length)];
}
Has anyone encountered similar challenges in their work before?
I came across this question, but the answer was quite basic ("collision detection") and didn't clarify the example code that confused me.
I'm still a beginner in this field, so I appreciate any guidance available. Thank you!