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.

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.

More optionsFewer options

Gravity

Heavy cloth hangs straighter and falls faster.

Detail

More points make finer folds; phones start at Low.

Marks each point; pinned ones are red.

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.

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 GitHub

What it is

The full explanation is in README.md.

Good for

  • Flags and banners
  • Playful pages
  • Fashion and textiles

Avoid on

  • Behind text
  • Serious content