flutter3d_particles library
Particles for flutter3d: a pooled simulation, and one draw call.
An extension rather than part of the engine. Nothing in flutter3d names a
particle now — the last thread was two shader handles Renderer.create
required and no code read, so an application that draws no particles could
not start a renderer.
No Flutter. The two contributors draw through flutter3d_core's
PassContributor, not through a widget, so the whole package runs under
dart test — and flutter3d_model_core's BakeParticleSystemJobRequest
bakes a system into a cache on the Dart VM through it, the same way it
bakes a rigid body through flutter3d_physics.
The shaders stay in flutter3d_shaders. That package is already the
shared GLSL every backend compiles from — Impeller into a bundle, WebGL by
translation, and the CPU backend as Dart transcriptions — so particle.vert
living there while the simulation lives here is the arrangement that package
exists for, not a layering violation. Moving them is a five-package change
with no user-visible benefit and belongs to whenever a second extension
wants a shader of its own.
What is here
ParticleSystem is one pool for the whole application, not one per effect: a system per effect is a draw call per effect, and on this engine a pipeline change is the most expensive state change there is. Emission, ageing and ParticleAffectors advance every particle in it.
ParticleGlow and LightEmitter are the part worth having. A fire is its particles, so the light it casts is measured from them rather than produced by a second wobble running alongside — two generators of one quantity disagree eventually, and the disagreement looks like a flame burning brightly while the light it casts has gone out.
Classes
- BoxEmitter
- Anywhere inside a box. Rain over an area, dust in a shaft of light, embers rising off the whole width of a fire rather than out of one point.
- ConeEmitter
- A cone around a direction. Muzzle flashes, sparks off a wall, blood.
- CurveKey
- One point on a ParticleCurve.
- DriftEmitter
- Straight up, slowly. Smoke and dust.
- Emission
- A standing emission: what, where, how fast, and for how long.
- Flipbook
- A grid of frames, played across a particle's life.
- FlipbookCell
- One cell of the sheet, in texture space.
- GradientKey
- One point on a ParticleGradient.
- KeyEase
- How a value travels from one key to the next.
- LightEmitter
- Something whose particles are a light source.
- MeshParticleContributor
- Particle
- One particle, reused for the life of the system.
- ParticleAffector
- One thing that happens to a particle while it is alive.
- ParticleColorGradient
- Drives a particle's colour from a gradient.
- ParticleColorOverLife
- Moves the colour from one to another across the particle's life.
- ParticleContributor
- ParticleCurve
- A scalar over a particle's life.
- ParticleDrag
- Bleeds off speed, so a burst slows into a drift instead of flying away.
- ParticleEffect
- A recipe for a burst: what is emitted, and what happens to it.
- ParticleEmitter
- Decides where a particle starts and which way it is going.
- ParticleFade
- Fades a particle out towards the end of its life.
- ParticleGlow
- What a source's particles add up to: how much light they are, and where.
- ParticleGradient
- A colour over a particle's life.
- ParticleGravity
- Pulls particles down. Sparks and debris; not smoke.
- ParticleRandom
- A reusable, re-seedable generator.
- ParticleSalt
- Which stream a draw comes from.
- ParticleSizeCurve
- Drives a particle's size from a curve, as a multiple of its birth size.
- ParticleSizeOverLife
- Scales a particle across its life.
- ParticleSpin
- Turns a billboard over its life.
- ParticleSystem
- Every particle in the world, and the one buffer they are drawn from.
- ParticleTurbulence
- Swirls particles through a standing flow field, so a column of smoke curls instead of rising in a straight line.
- ParticleWind
- Pushes everything one way, for a draught or the wake of an explosion.
- Range
- A range a value is drawn from when a particle is born.
- Shown
- One burst, where it happens, and which way it goes.
- SphereEmitter
- Outwards in every direction. Explosions, and anything that bursts.