FERRETGame engine over Babylon.js
Ferret

Springs, ropes, cloth, soft bodies

Skill ferret-physics-stretch · download all skills · SKILL.md

When to use#

A rope bridge, a bungee, a curtain, a flag, a jelly.

The model#

Springs and ropes are links with E, area, damping, rest length, yieldStrain (permanent set) and breakStrain (snap); strength held still is breakStrain × E × area. Cloth and soft bodies are not kernel bodies: particles advanced by their own solver with a fixed step and a fixed number of passes, so replays are identical. They meet the world through colliders you give them and read gravity and wind from the host.

Steps#

  1. Enable stretch; build with cap.rope({...}), Cloth, SoftBody.
  2. Pin the top row for a curtain (pinned: 'top'); add colliders (sphere, plane, box, rigid bodies) to cloth.colliders.
  3. Name links you care about; events stretch:yield, stretch:break.
  4. Keep cloth to a handful on screen; check cap.particles() against the budget.

Check afterwards#

A rope hangs F L / E A longer than rest; a curtain hangs about its length with the strain limit held; a load over the rating parts the rope.

What usually goes wrong#

  • Cloth does not move: over the particle budget, capability off, or hand-stepped without calling step.
  • Rubber cloth: raise stiffness, lower strainLimit (1.05).
  • Passes through a body: not in cloth.colliders, or thickness smaller than a step's travel: raise substeps.
  • A rope does not sag: rope: false, or too stiff for the load.
  • Results differ between runs: variable dt.

Files#

  • reference/stretch.md — Springs, ropes that sag and snap, cloth and flags, soft jelly bodies: everything that gives way instead of staying rigid.
  • reference/api-physics-stretch.md — every export of @ferret/physics-stretch with signature and doc comment
  • reference/commands.md — 2 commands of these packages with their arguments
  • recipes/structures-and-ropes.md — Six recipes: a rope that holds a load or snaps, a shear pin that protects the rest, a crate that breaks only at speed, a bungee that springs back, a wall that breaks under a blast, a curtain that hangs.