Physics · class
ClothBody
Explained in Your first game, Rigid bodies.
class ClothBodyimport { ClothBody } from '@driftengine/physics';Constructor
new
constructor(positions: Float32Array, links: Int32Array, bendLinks: Int32Array, options?: ClothOptions)| Parameter | Type | Description |
|---|---|---|
positions | Float32Array | |
links | Int32Array | |
bendLinks | Int32Array | |
options? | ClothOptions |
Properties
| Name | Type | Description |
|---|---|---|
positionreadonly | Float32Array | xyz-packed particle positions. |
velocityreadonly | Float32Array | xyz-packed velocities. |
invMassreadonly | Float32Array | Inverse mass per particle. Zero pins it. |
countreadonly | number | |
iterationsreadonly | number | |
dampingreadonly | number | |
thicknessreadonly | number | |
couplingreadonly | number | See ClothOptions.coupling. 0 is one-way, which is the default. |
particleMassreadonly | number | See ClothOptions.particleMass. Kilograms, read only by the coupling. |
selfDistancereadonly | number | See ClothOptions.selfDistance. 0 is off, which is the default. |
gravityX | number | |
gravityY | number | |
gravityZ | number |
Methods
pin
pin(index: number, pinned?: boolean): voidPin a particle where it is, or release it.
| Parameter | Type | Description |
|---|---|---|
index | number | |
pinned? | boolean |
step
step(world: PhysicsWorld | null, dt: number): voidAdvance one fixed tick.
| Parameter | Type | Description |
|---|---|---|
world | PhysicsWorld | null | |
dt | number |
More
Integrate, project every constraint iterations times, then derive velocity from how far each
particle actually moved — which is what makes it position-based: a constraint that moves a
particle also, by construction, changes its velocity, so nothing has to reconcile the two.