Physics · class

SkinnedCloth

A garment's particles, constraints and solver state, stepped at the set-up's fixed step. Read positions after a step, or interpolate between the last two for a frame's alpha. The schedule — poses, steps, resets, the blend — is ClothControl's; this is its CPU device.

Explained in Your first game, Rigid bodies.

class SkinnedCloth
import { SkinnedCloth } from '@driftengine/physics';

Constructor

new

constructor(setup: SkinnedClothSetup)
ParameterTypeDescription
setupSkinnedClothSetup

Properties

NameTypeDescription
countreadonlynumberHow many particles.
positionsreadonlyFloat32ArrayWhere each particle is now, three floats a particle.
velocitiesreadonlyFloat32ArrayMetres a second, three floats a particle.
inverseMassreadonlyFloat32Array
parametersreadonlyResolvedClothParametersThe parameters with their defaults filled in.

Accessors

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

Methods

setWind

setWind(x: number, y: number, z: number): void

The air the steps to come drag the cloth toward, world space, metres a second: the frame's sample of the scene's one wind, so a garment moves with the smoke and the grass rather than with a second wind of its own. See AGENTS.md, "One wind, sampled once".

ParameterTypeDescription
xnumber
ynumber
znumber

setPose

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

See ClothControl.setPose.

ParameterTypeDescription
globalsFloat32Array
modelFloat32Array

reset

reset(): void

See ClothControl.reset.

advance

advance(dt: number): number

See ClothControl.advance.

ParameterTypeDescription
dtnumber

interpolate

interpolate(alpha: number, out: Float32Array): void

Each particle between the start and the end of the last step, at alpha, into out.

ParameterTypeDescription
alphanumber
outFloat32Array

step

step(): void

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