feat!: Replace the particle system with a data-oriented particle system - #3948
Open
spydon wants to merge 3 commits into
Open
feat!: Replace the particle system with a data-oriented particle system#3948spydon wants to merge 3 commits into
spydon wants to merge 3 commits into
Conversation
spydon
force-pushed
the
new-particle-system
branch
from
July 19, 2026 15:45
a85c897 to
39cb748
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Completely removes the old particle system and replaces it with a new data-oriented one built for large particle counts and a declarative developer experience.
Stacked on top of #3947, since flame_oxygen (removed there) depended on the old particle API.
Removed:
Particleand all 15 subclasses (AcceleratedParticle,CircleParticle,ComponentParticle,ComposedParticle,ComputedParticle,CurvedParticle,ImageParticle,MovingParticle,PaintParticle,RotatingParticle,ScaledParticle,ScalingParticle,SpriteAnimationParticle,SpriteParticle,TranslatedParticle), theSingleChildParticlemixin, andParticleSystemComponent.Added (in
package:flame/particles.dart):ParticleEmitter: a declarative, reusable preset describing emission (continuousrate, timedEmitterBursts,duration/loop), spawnshape(point, circle, rectangle, or a customEmitterShape), polar initial velocity (speed,direction,spread), forces (gravity,drag), rotation (rotation,spin,rotateToVelocity), and over-life behavior (scaleOverLife,opacityOverLife,colorOverLife). Per-particle variation is expressed as(min, max)records (ParticleRange).ParticleCurveandColorRamp: over-life curves and gradients, baked into lookup tables at construction so per-particle per-frame evaluation is an array read.ParticleBuffer: struct-of-arrays storage overFloat32List/Int32List, preallocated atmaxParticles, with constant-time swap-removal. A running effect performs no allocations.ParticleRendererwith batched built-ins:CircleParticleRenderer(one-time rasterized circle texture with asoftnessknob) andSpriteParticleRendererrender all particles of an emitter in a singleCanvas.drawRawAtlascall with per-particle transform and tint;CallbackParticleRenderergives direct canvas access.ParticleEmitterComponent: aPositionComponenttying it together, withstart()/stop(), immediateemit(n),removeOnFinishfor fire-and-forget one-shots, a seedableRandomfor determinism, andworldSpace: trueto leave live particles behind while the emitter moves (trails, exhaust).The particles documentation page has been rewritten, both particle example stories have been rebuilt on the new API, and the new system is covered by 49 tests.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Migration instructions
The old
Particlehierarchy andParticleSystemComponentare gone; effects are now described declaratively instead of composed from per-particle object trees. An old-style effect like:becomes:
Rough mapping from the old API:
ParticleSystemComponent+Particle.generate:ParticleEmitterComponentwith anEmitterBurst(orratefor continuous emission).MovingParticle/AcceleratedParticle:speed,direction,spread,gravity,dragonParticleEmitter.CircleParticle:CircleParticleRenderer;SpriteParticle/ImageParticle:SpriteParticleRenderer.ScalingParticle/ScaledParticle:sizeplusscaleOverLife.RotatingParticle:rotationandspinranges, orrotateToVelocity.PaintParticlecolor effects:colorOverLife(ColorRamp) andopacityOverLife.ComputedParticle/ComposedParticle/ComponentParticle:CallbackParticleRendereror a customParticleRenderer/EmitterShape; compose severalParticleEmitterComponents for layered effects.Related Issues