06.15 · 3D & Advanced
Cloth / Soft-Body Simulation
A cloth sways in the wind, and you can drag it around. Best for playful pages.
Watch it
It moves by itself. Drag the cloth to pull it, or pause it to look closely.
Inside, the cloth is points joined by links: wind and gravity push every point, then each link pulls its two points back to its length (gold where stretched). Red points are pinned.
No links: the same points, pushed by the same wind and gravity, fall away from their pins, since nothing holds them; With links: the cloth hangs and folds. Press Reset to hang both again.
Try it
Change a setting and see the difference as it moves.
Hangs from
Where the cloth is pinned; Nothing lets it fall.
Wind
How hard the wind blows; it rises and falls.
Stiffness
Stretchy sags and bounces; stiff keeps its shape.
Copy the prompt
Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.
Add a cloth simulation to [the flag, banner or fabric you want to show]. Model the cloth as a grid of points joined to their neighbors by links of fixed length. In fixed 1/60 s steps, as many as the time since the last frame needs, move every point by its own momentum plus gravity and wind, then pull linked points back toward their proper distance a few times over, so the cloth moves at the same speed on every screen. Pin some points so the cloth hangs, and let the visitor grab and drag the nearest point with the pointer or a finger. Use a coarser grid on phones. If the visitor has reduced motion turned on, show the cloth hanging still. Match the settings listed below.
Your settings
Replace the words in brackets with your own element. Your settings are added at the end.
Free and open source. If this helped, a star on GitHub helps other people find it.
Star on GitHubWhat it is
The full explanation is in README.md.