Physics · class

ClothControl

A skinned cloth's schedule, over one device.

Explained in Your first game, Rigid bodies.

class ClothControl
import { 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.

ParameterTypeDescription
setupSkinnedClothSetup
deviceClothDevice
particlesOnCpu?boolean

Properties

NameTypeDescription
parametersreadonlyResolvedClothParameters
targetsreadonlyClothTargets

Accessors

NameTypeDescription
alphagetnumberHow far the time handed to advance reaches into the next step, 0 to 1.

Methods

setPose

setPose(globals: Float32Array, model: Float32Array): void

The 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.

ParameterTypeDescription
globalsFloat32Array
modelFloat32Array

reset

reset(): void

Every 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): number

Advance 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.

ParameterTypeDescription
dtnumber

step

step(): void

One fixed step, all the way to the latest pose: for a caller in the engine's fixed-step loop.