Physics · class
ClothControl
A skinned cloth's schedule, over one device.
Explained in Your first game, Rigid bodies.
class ClothControlimport { ClothControl } from '@driftengine/physics';Constructor
new
constructor(setup: SkinnedClothSetup, device: ClothDevice, particlesOnCpu?: boolean)particlesOnCpu false leaves the skinned particle positions to the device: the targets keep
the model matrices, the skin matrices and the colliders, which is all a GPU needs from them.
| Parameter | Type | Description |
|---|---|---|
setup | SkinnedClothSetup | |
device | ClothDevice | |
particlesOnCpu? | boolean |
Properties
| Name | Type | Description |
|---|---|---|
parametersreadonly | ResolvedClothParameters | |
targetsreadonly | ClothTargets |
Accessors
| Name | Type | Description |
|---|---|---|
alphaget | number | How far the time handed to advance reaches into the next step, 0 to 1. |
Methods
setPose
setPose(globals: Float32Array, model: Float32Array): voidThe skeleton's pose for the steps to come: each joint's global matrix, model space, sixteen
floats a joint, and the model matrix. The first pose, and one past the teleport thresholds,
resets the cloth to it; any other is reached across the steps of the next advance.
| Parameter | Type | Description |
|---|---|---|
globals | Float32Array | |
model | Float32Array |
reset
reset(): voidEvery particle at its skinned position, at rest; then the set-up's settle steps at once, and its blend steps from the skinned pose into the simulation over the steps that follow.
advance
advance(dt: number): numberAdvance by dt seconds of the caller's time, in whole fixed steps; how many ran. The remainder
is kept for the next call, and alpha says how far into the next step it reaches. At most
maxSteps run, reaching the latest pose all the same; the whole steps past them are dropped.
| Parameter | Type | Description |
|---|---|---|
dt | number |
step
step(): voidOne fixed step, all the way to the latest pose: for a caller in the engine's fixed-step loop.