Back to portfolio
Physics · Live Demo

Cloth Simulation

A real-time cloth built from a grid of point masses linked by distance constraints. It uses Verlet integration — positions carry their own velocity — and relaxes the constraints several times per frame so the fabric holds together while still swinging and stretching under gravity.

  • Verlet integrationVelocity is implicit in the previous position — stable and simple.
  • Constraint relaxationEach thread is solved a few times per frame to keep the weave taut.
  • Drag & tearPull the cloth around, or switch to Cut mode to slice through the threads.
JavaScriptCanvasVerletPhysicsSimulation
View source on GitHub

Click & drag the cloth to pull it around.