Every constructor option, its exact default, and whether it can change at runtime.
createFlagCloth() accepts a FlagClothOptions object. The React component accepts the same options except container, because it creates that element for you. Nested groups are partial: pass only the values you want to change.
import type { FlagClothOptions } from 'flag-cloth';
Horizontal cell count. There are x + 1 particle columns.
segments.y
number
20
Vertical cell count. There are y + 1 particle rows.
attachment
Attachment
'left'
Edge, corner, partial edge, custom grid points, or 'none'.
autoStart
boolean
true
Marks the instance as started immediately and schedules its owned animation loop.
Changing width, height, or segments rebuilds the simulation topology but keeps the same canvas, WebGL2 context, renderer instance, observers, and event controllers. Changing attachment only rebuilds the pin mask. See Attachments for every accepted shape.
World-space acceleration. Gravity is disabled by default for a conventional flag.
fixedTimeStep
number
1 / 60
Stable accumulator step in seconds.
maxFrameDelta
number
0.1
Maximum display-frame gap accepted by the accumulator, in seconds.
substeps
number
2
Integration subdivisions per fixed step. Values are floored and clamped to at least 1.
constraintIterations
number
6
Structural, shear, and bend solve passes per substep.
structuralStiffness
number
1
Horizontal and vertical distance retention.
shearStiffness
number
0.9
Diagonal distance retention.
bendStiffness
number
0.4
Two-cell distance retention.
maxCorrection
number
0.25
Per-constraint correction cap. Set 0 to disable the cap.
mass
number
1
Total cloth mass, independent of grid density.
Stiffness values are clamped from 0 to 1 by the solver and converted to an iteration-independent correction. See Cloth simulation before raising grid resolution or solver work.
The table shows the default quality profile. Selecting performance changes maxPixelRatio to 1, shadows to false, and shadingUpdateInterval to 2. Explicit values passed alongside a preset win.
Property
Type
Default
Meaning
preset
'quality' | 'performance'
'quality'
Selects a tested rendering profile.
alpha
boolean
true
Requests an alpha-enabled WebGL2 context. Construction-time only.
Requests a desynchronized context when supported. Construction-time only.
powerPreference
WebGLPowerPreference
'high-performance'
GPU preference used during context creation. Construction-time only.
maxPixelRatio
number
1.5
Caps backing-store resolution; values below 0.5 are clamped.
textureFiltering
'linear' | 'nearest'
'linear'
Image texture sampling mode.
transparent
boolean
true
Clears with alpha instead of backgroundColor.
backgroundColor
string
'transparent'
CSS color used when transparent is false.
shadows
boolean
true
Enables the nine-sample soft silhouette shadow.
shadingUpdateInterval
number
1
Recalculates normals every N rendered frames.
alpha, antialias, desynchronized, and powerPreference are intentionally absent from FlagClothUpdateOptions.renderer; changing a WebGL context attribute requires creating a new instance.
setOptions() is asynchronous because it can load a new texture. Wind, pinning, simulation, interaction, renderer, material, lighting, camera, visibility, and debug changes do not recreate the WebGL2 context.