FabricSimulation class

Constructors

FabricSimulation({required double width, required double height, required int cols, required int rows, double tearRatio = 3.2, double pinBreakRatio = 2.0, FabricElasticity elasticity = const FabricElasticity()})

Properties

cols → int
final
elasticity → FabricElasticity
Stretchiness / stiffness / damping - see FabricElasticity.
final
gravityOn ↔ bool
Becomes true once anything tears / any pin lets go. From then on the cloth is affected by gravity and never returns to the flat state.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
height → double
final
isGrabbing → bool
no setter
maxOffset ↔ double
Largest distance of any visible node from its resting place.
getter/setter pair
motion ↔ double
Average per-node movement of the last step (used to detect rest).
getter/setter pair
nodes → List<PointMass>
final
onPinBreak ↔ void Function()?
Fired every time a pin lets go of the wall (good hook for a "pop"/ "snap" sound).
getter/setter pair
onTear ↔ void Function()?
Fired the first time a spring gives way (good hook for a "rip" sound).
getter/setter pair
pinBreakRatio → double
A pin lets go when a spring attached to it is stretched beyond this.
final
pinNodes → List<PointMass>
The border nodes that start pinned to the "wall".
no setter
pinsBrokenCount ↔ int
How many pins have let go of the wall so far.
getter/setter pair
random → Random
Shared random source (seeded, so effects are repeatable).
no setter
rows → int
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
springs → List<Spring>
final
tearRatio → double
A spring tears when stretched beyond this multiple of its rest length.
final
topologyVersion ↔ int
Increments whenever a spring tears (painter rebuilds its triangles).
getter/setter pair
tornCount ↔ int
How many springs have torn so far.
getter/setter pair
width → double
final

Methods

addForce(SimulationForce force) → void
Adds a SimulationForce that acts until its SimulationForce.isActive turns false.
beginGrab(double x, double y, {required double radius, required double pushDepth}) → bool
Grabs every free node around (x, y) with a smooth falloff. Returns false if nothing could be grabbed.
buildIndices() → Uint16List
Triangle indices; triangles that touch a torn spring are left out, which is what opens the holes / rips.
endGrab() → void
moveGrab(double x, double y) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
step() → void
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

timeStep → const double
Fixed physics step (the widget runs this with an accumulator, so the feel is identical on 60 Hz and 120 Hz screens).