Spring-Mass / Verlet
First appeared 1967 — The numerical core — Verlet integration — originates in Loup Verlet's 1967 molecular-dynamics work on classical fluids (the scheme had earlier precedents and was rediscovered several times). Its use for interactive cloth, rope and soft-body line work was popularized by Thomas Jakobsen's 2001 GDC talk "Advanced Character Physics." The year marks the integration method, not a single artwork. · timeline ↗
community / folk Name — A descriptive category label, not a coined or eponymous name; no single coiner of the term is attested.
In one line A physics simulation of point masses connected by springs (often integrated with Verlet). Used for cloth, rope, soft bodies and constraint-driven dynamic line work.
The code
The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.
spring-mass/index.html
const SEED = Math.floor(Math.random()*1e9);
// Verlet cloth: a grid of point masses linked by distance constraints,
// pinned along the top, settling under gravity. Constraints relaxed
// iteratively (Jakobsen 2001).
let pts = [], cons = [], COLS, ROWS, S;
function setup() {
randomSeed(SEED);
S = Math.min(windowWidth, windowHeight);
createCanvas(S, S);
COLS = 18; ROWS = 18;
const gap = S * 0.045, ox = (S - gap*(COLS-1))/2, oy = S*0.1;
for (let j = 0; j < ROWS; j++)
for (let i = 0; i < COLS; i++) {
const x = ox + i*gap, y = oy + j*gap;
pts.push({ x, y, px: x, py: y, pin: j === 0 && i % 3 === 0 });
}
const idx = (i,j) => j*COLS+i;
for (let j = 0; j < ROWS; j++)
for (let i = 0; i < COLS; i++) {
if (i < COLS-1) cons.push([idx(i,j), idx(i+1,j), gap]);
if (j < ROWS-1) cons.push([idx(i,j), idx(i,j+1), gap]);
}
stroke(120, 200, 255); strokeWeight(S*0.0015); noFill();
}
function draw() {
background(10, 12, 18);
// integrate
const g = S * 0.0006;
for (const p of pts) {
if (p.pin) continue;
const vx = (p.x - p.px) * 0.99, vy = (p.y - p.py) * 0.99;
p.px = p.x; p.py = p.y;
p.x += vx; p.y += vy + g;
}
// relax constraints
for (let k = 0; k < 8; k++) {
for (const [a, b, len] of cons) {
const pa = pts[a], pb = pts[b];
const dx = pb.x - pa.x, dy = pb.y - pa.y;
const d = Math.hypot(dx, dy) || 1e-4;
const diff = (len - d) / d * 0.5;
const ox = dx*diff, oy = dy*diff;
if (!pa.pin) { pa.x -= ox; pa.y -= oy; }
if (!pb.pin) { pb.x += ox; pb.y += oy; }
}
}
// draw mesh
for (const [a, b] of cons) line(pts[a].x, pts[a].y, pts[b].x, pts[b].y);
}How it works
Model the object as particles (masses) joined by springs with a rest length. Each step: 1. Force/spring solve: for every spring, compute the restoring force from how far it is stretched or compressed (Hooke's law, F = −k·Δx), plus damping; add external forces like gravity and wind to each mass. 2. Integrate: advance each particle. Verlet integration is popular — x_next = x + (x − x_prev) + a·dt² — because it is stable and stores velocity implicitly in the previous position. 3. Constraint relaxation: instead of stiff springs, many cloth solvers just push particle pairs back toward rest length a few iterations per frame (position-based dynamics), which is robust at large steps. Pinning some particles and tuning stiffness/damping yields cloth, hanging ropes and wobbling structures.
Parameters
stiffness: number — Spring constant k; higher values make the connections more rigid.damping: number — Velocity damping that bleeds energy so the system settles.restLength: number — The natural length each spring relaxes toward.timestep: number — Integration step (Verlet/Euler); smaller is more stable.
Lineage
Frequently combined with
- Fragment Shader (GLSL) · 3 works
- Perlin / Simplex Noise · 3 works
- Boids / Flocking · 2 works
- Quadtree / Recursive Quad Split · 2 works
- Plotter-style Hatching · 2 works
- Particle System · 2 works
- Voronoi Diagram · 1 work
- Marching Squares / Contours · 1 work
- Delaunay Triangulation · 1 work
- Raymarching with SDFs · 1 work
- Flow Field / Vector Field · 1 work
- Bezier / Catmull-Rom Splines · 1 work
Works using this algorithm (5)
Last updated 2026-07-16