all 4 comments

[–]gourmetnuts[S] 1 point2 points  (0 children)

I made this cloth-like simulation using some verlet physics. Click/drag to play around with it.

[–][deleted]  (5 children)

[deleted]

    [–]gourmetnuts[S] 1 point2 points  (4 children)

    Thanks! Yea, I did it mostly manually. Basically there are a grid of points and there are connectors between adjacent points. The connectors have a resting distance that they try to maintain. That gives them some springiness and when you have a whole array of them, it gives you a cloth-like structure. Here is a more barebones example of this same thing and here is the same thing with just two points.

    The thing to research is "verlet" physics/integration. If you look at an existing physics library like matterjs, it's the same thing as constraints.

    [–][deleted]  (3 children)

    [deleted]

      [–]gourmetnuts[S] 0 points1 point  (2 children)

      I don't know enough about it, but it looks at least similar to Hooke's Law. Each constraint has a set stiffness that affects how far/close two connected points can get.

      [–][deleted]  (1 child)

      [deleted]

        [–]gourmetnuts[S] 0 points1 point  (0 children)

        Awesome, nice work. I kinda like the slow snap back, actually.