ParticleStorage class Particles
Structure-of-arrays storage for one emitter's live particles, with an O(1) free pool.
Each particle property is its own tightly packed Float32List column
(posX, velX, ...) rather than a List<Particle> of objects, so the
per-frame update loop sweeps contiguous memory and never allocates or
pressures the GC. Live particles always occupy the dense prefix
[0, aliveCount); spawn appends at the end and kill fills the freed
slot with the last live particle (swap-with-last compaction), so the live
set stays packed at the cost of not preserving order (rendering re-sorts
anyway).
Color is stored as four floats per particle (matching the billboard
instance buffer's float32x4 color attribute and the over-life color
math). A packed RGBA8 column is a later memory optimization.
Constructors
- ParticleStorage(int capacity)
-
Allocates storage for up to
capacitysimultaneous particles.
Properties
- age → Float32List
-
Seconds since the particle was spawned.
final
- aliveCount → int
-
The number of live particles. They occupy columns
[0, aliveCount).no setter - angularVelocity → Float32List
-
In-plane rotation (radians) and its rate of change (radians/second).
final
- axisX → Float32List
-
Unit 3D rotation axis, set to a uniformly random direction at spawn.
Billboards ignore it (their rotation is in-plane); mesh particles
tumble around it by rotation.
final
- axisY → Float32List
-
Unit 3D rotation axis, set to a uniformly random direction at spawn.
Billboards ignore it (their rotation is in-plane); mesh particles
tumble around it by rotation.
final
- axisZ → Float32List
-
Unit 3D rotation axis, set to a uniformly random direction at spawn.
Billboards ignore it (their rotation is in-plane); mesh particles
tumble around it by rotation.
final
- baseSize → Float32List
-
Current rendered size (world units) and the size set at spawn, which
size-over-life scales.
final
- capacity → int
-
The maximum number of simultaneous particles.
final
- colorA → Float32List
-
Current linear RGBA color (premultiplication happens in the shader).
final
- colorB → Float32List
-
Current linear RGBA color (premultiplication happens in the shader).
final
- colorG → Float32List
-
Current linear RGBA color (premultiplication happens in the shader).
final
- colorR → Float32List
-
Current linear RGBA color (premultiplication happens in the shader).
final
- frame → Float32List
-
Flipbook frame index (fractional values round to the nearest cell). Left
at zero unless a module (or spawn code) writes it.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFull → bool
-
Whether the pool is at capacity.
no setter
- lifetime → Float32List
-
Total lifetime in seconds; the particle dies once age exceeds it.
final
- posX → Float32List
-
World-space position (in the emitter node's local space).
final
- posY → Float32List
-
World-space position (in the emitter node's local space).
final
- posZ → Float32List
-
World-space position (in the emitter node's local space).
final
- random01 → Float32List
-
Per-particle random in
[0, 1), written at spawn. Distributions sample against it (directly, or via randomFor for an independent stream) so a particle's randomized properties are stable for its whole life.final - rotation → Float32List
-
In-plane rotation (radians) and its rate of change (radians/second).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → Float32List
-
Current rendered size (world units) and the size set at spawn, which
size-over-life scales.
final
- velX → Float32List
-
Linear velocity, world units per second.
final
- velY → Float32List
-
Linear velocity, world units per second.
final
- velZ → Float32List
-
Linear velocity, world units per second.
final
Methods
-
clear(
) → void - Removes every particle.
-
kill(
int index) → void -
Removes the particle at
indexby moving the last live particle into its slot and shrinking the live set. The moved particle's index changes, so a reverse iteration (for (var i = aliveCount - 1; i >= 0; i--)) visits every particle exactly once even while killing. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
randomFor(
int index, int salt) → double -
Derives an independent random in
[0, 1)for particleindexfrom its stored random01 and asalt, so different randomized properties (size, rotation, color) do not all share one stream and correlate. -
spawn(
) → int -
Reserves a slot for a new particle and returns its index, or
-1when the pool is full. The caller initializes the columns at that index (including random01). -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited