How Sparkles sequences and mixes work
mainSparkles use a system of Sequences and Mixes to control particle behavior over time or space.
Sequences (:sequence-* props)
Sequences define how a property (like color, alpha, or size) changes as a particle "progresses". They use a Gradient<T> type, which can be:
- A single value:
T(e.g.,'red') - An even distribution:
[T, T, ...](e.g.,['red', 'blue', 'green']) - An uneven distribution with stops:
[[number, T], ...]wherenumberis a stop from0to1(e.g.,[[0.1, 'red'], [0.5, 'blue']])
Mixes (:mix-* props)
Mixes determine what drives the "progress" through a sequence. A :mix-X prop controls the corresponding :sequence-X prop by interpolating between two factors:
- Light Factor (0.0): Progress is determined by how much the vertex normal faces the
directionalLight(calculated via the dot product of the inverted light position and the vertex normal). - Lifetime Factor (1.0): Progress is determined by the particle's remaining lifetime.
Example: Setting :mix-alpha="0.5" means the particle's opacity sequence is halfway between being driven by light and being driven by its age.
// Example of a sequence and a mix
<Sparkles
:sequence-color="['red', 'blue', 'green']"
:mix-color="1.0" // Progress is driven entirely by particle lifetime
/>