ParticleSystem class Particles

A self-contained, CPU-driven particle simulation: storage plus the config, shape, spawner, and module stack that fill and advance it.

The system is pure Dart with no scene-graph or GPU dependency, so it can be driven by a component, a headless test, or a future alternative backend. step advances the simulation with a fixed-timestep accumulator (so the result is independent of frame rate) using semi-implicit Euler integration; after stepping, a renderer reads the live columns out of storage.

Spawning is gated by looping/duration: a looping system emits forever, while a non-looping one stops emitting once its run passes duration (already-live particles still finish their lives). All randomness derives from seed, so a given seed and step sequence reproduce exactly (the basis for byte-for-byte tests and editor scrubbing).

Constructors

ParticleSystem({int maxParticles = 1024, required EmitterShape shape, required Spawner spawner, List<ParticleModule> modules = const <ParticleModule>[], FloatDistribution lifetime = const ConstantFloat(1.0), FloatDistribution startSpeed = const ConstantFloat(0.0), FloatDistribution startSize = const ConstantFloat(1.0), FloatDistribution startRotation = const ConstantFloat(0.0), FloatDistribution startAngularVelocity = const ConstantFloat(0.0), ColorDistribution? startColor, Vector3? gravity, bool looping = true, double duration = 5.0, double fixedStep = 1.0 / 60.0, double maxFrameTime = 0.25, int seed = 0, double prewarm = 0.0})
Creates a particle system. The distributions, shape, spawner, gravity, looping behaviour, fixed-step size, and seed are all configurable; only shape and spawner are required.

Properties

duration double
The length of one run in seconds (the emit cutoff for a non-looping system).
getter/setter pair
fixedStep double
The fixed simulation timestep in seconds.
final
gravity → Vector3
Constant acceleration applied to every particle during integration.
final
hashCode int
The hash code for this object.
no setterinherited
lifetime FloatDistribution
Per-particle spawn properties sampled (with independent randoms) at birth.
getter/setter pair
looping bool
Whether the system emits forever; when false it stops emitting past duration.
getter/setter pair
maxFrameTime double
The largest frame delta honored by step; longer frames are clamped so a hitch cannot spiral the accumulator.
final
modules List<ParticleModule>
The ordered behaviour stack (forces and over-life evaluators).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
seed int
The seed for all spawn randomness.
final
shape EmitterShape
Where particles spawn and which way they initially head.
getter/setter pair
spawner Spawner
How many particles to emit each step.
final
startAngularVelocity FloatDistribution
Per-particle spawn properties sampled (with independent randoms) at birth.
getter/setter pair
startColor ColorDistribution
The color assigned at spawn (a color-over-life module may overwrite it).
getter/setter pair
startRotation FloatDistribution
Per-particle spawn properties sampled (with independent randoms) at birth.
getter/setter pair
startSize FloatDistribution
Per-particle spawn properties sampled (with independent randoms) at birth.
getter/setter pair
startSpeed FloatDistribution
Per-particle spawn properties sampled (with independent randoms) at birth.
getter/setter pair
storage ParticleStorage
The backing structure-of-arrays storage; a renderer reads its live prefix.
final
time double
Seconds the system has been running (advances by whole fixed steps).
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Removes every live particle and rewinds the clock (the seed stream and fractional spawn accumulator reset, so a restart replays identically).
step(double dt) → void
Advances the simulation by dt seconds in fixed-size steps, draining a clamped accumulator so the outcome is frame-rate independent.
toString() String
A string representation of this object.
inherited

Operators

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