Physics · function
makeClothGrid
A rectangular sheet: positions, its stretch links, and the bend links across them.
Explained in Your first game, Rigid bodies.
function makeClothGrid(columns: number, rows: number, spacing: number):import { makeClothGrid } from '@driftengine/physics';Parameters
| Parameter | Type | Description |
|---|---|---|
columns | number | |
rows | number | |
spacing | number |
In depth
Bend links skip a particle rather than joining diagonals, because a diagonal resists shear and a skip resists bowing, and a sheet that cannot shear drapes like cardboard.
A skip-one distance constraint resists curvature and not orientation, which is worth knowing before tuning it: three collinear particles satisfy it at any angle, so a flat sheet and a sheet hanging straight down are equally happy. Measured — a cantilever pinned along one edge settles at exactly vertical whether the bend compliance is 1e-8 or 1e6. What it does buy is 12.5 millimetres less bow on a strip pinned at both ends with slack.
What would make it wrong is a consumer wanting a cloak to stand out from a shoulder, and the answer then is a dihedral-angle constraint over the two triangles either side of an edge, which knows a rest angle and therefore knows the difference between flat and folded.