Physics · interface

SkinnedClothParameters

What the solver runs at. Every field has a default; the defaults are a garment's, not a sheet's.

Explained in Your first game, Rigid bodies.

interface SkinnedClothParameters
import type { SkinnedClothParameters } from '@driftengine/physics';

Properties

NameTypeDescription
stepreadonlyoptionalnumberThe fixed step, in seconds. The solver runs whole steps whatever the frame. Default 1/60.
maxStepsreadonlyoptionalnumberThe most whole steps one advance runs; the time past them is dropped, not owed to the next frame. Default none, so advance(1) is a second of cloth. A caller handing it each frame's time wants two to four: unbounded, a slow frame's steps make the next frame slower, which hands it more time again. What it gives up: past the cap the cloth runs slower than the clock.
substepsreadonlyoptionalnumberSubsteps a step. Default 1.
iterationsreadonlyoptionalnumberConstraint passes a substep. Default 4.
gravityreadonlyoptionalreadonly [number, number, number]Metres a second squared, world space. Default [0, −9.81, 0].
dampingreadonlyoptionalnumberThe log of the velocity kept after a second: ln 0.25 keeps a quarter. Zero is none; it is applied as exp(damping · h) a substep, so it means one thing at every step length.
dragreadonlyoptionalnumberThe same, of the velocity relative to the wind: how fast the air takes the cloth with it.
pullreadonlyoptionalnumberHow hard each particle is drawn back toward where skinning puts it, as a stiffness: metres a second squared toward its skinned position for every metre it is away from it. Zero, the default, is none. A particle at rest under gravity alone sits 9.81 / pull metres below its skinned place, whatever the step.
More

For a garment made to hold a shape gravity would undo: styled hair held by a few pinned particles at its roots keeps the shape it was made in at rest and swings out of it only as the body moves, then settles back. The hard limits cannot do that: a max distance is a sphere a particle may fall anywhere inside, so hair falls to its edge and hangs.

A stiffness, not a share of the offset kept a second as damping is. Applied first among the limits, after the constraints, each substep keeping 1 / (1 + pull · h²) of the offset: a compliant constraint's step, so the shape it holds against gravity is one length at every step. A share scaled by the step as damping is would hold a sag proportional to the step: hair authored to keep 0.7 of its offset a 1/60 step sags 6.36, 3.49 and 1.83 mm at 1/60, 1/120 and 1/240 that way, where this holds 6.36 mm at all three. A share k kept a step at a step s is (1 / k − 1) / s² here, and keeps exactly k at that step. SkinnedClothSetup.pullWeights weighs it particle by particle, so a strap can be held at its root and hang free at its tip. What it gives up: it is a pull rather than a limit, so a hard blow still takes a particle out of shape for a moment; and with no damping a stiff one rings, at a rate a coarse step damps more than a fine one does.

windreadonlyoptionalreadonly [number, number, number]Metres a second, world space: the air the cloth starts in. Default still air. A garment in a scene follows the scene's wind a frame at a time, through setWind.
linearInertiareadonlyoptionalnumberHow much of the character's own movement and turning the cloth keeps as its own, 0 to 1: 1 is simulated wholly in the world, so a dash leaves the hem behind; 0 moves it with the character. Default 1.
angularInertiareadonlyoptionalnumber
maxDistanceScalereadonlyoptionalnumberScales every max distance, for a garment worn looser or tighter than cooked. Default 1.
marginreadonlyoptionalnumberMetres added to every collider's radius, beyond a particle's own thickness. Default 0.
teleportDistancereadonlyoptionalnumberA move of the character's origin past this, between two poses, resets the cloth. Default none.
teleportAnglereadonlyoptionalnumberA turn past this many radians between two poses resets it too. Default none.
settleStepsreadonlyoptionalnumberSteps run at once when the cloth is reset, so it starts hanging rather than falling.
blendStepsreadonlyoptionalnumberSteps over which a reset cloth blends from its skinned pose into its simulation.