Physics · Live Demo

Cloth Simulation

A JS port of my Python cloth simulation. Includes a 32×24 grid of point masses linked by sticks. It uses Verlet integration (velocity is implicit in the previous position) and relaxes the constraints five times per frame, so the fabric holds together while swinging and stretching under gravity. Every other node on the top row is pinned.

  • Verlet integration. Velocity is implicit in the previous position.
  • Constraint relaxation. Each stick is solved five times per frame to keep the weave taut.
  • Slice it. Drag your mouse across the cloth and any thread you cross is cut.
PythonJavaScriptCanvasVerletPhysicsSimulation
View source on GitHub

Click and drag across the cloth to slice through the threads.