pub enum Emitter {
Point {
position: Vec3,
rate: f32,
speed: f32,
},
Burst {
position: Vec3,
count: u32,
speed: f32,
},
Cone {
position: Vec3,
direction: Vec3,
speed: f32,
spread: f32,
rate: f32,
},
Sphere {
center: Vec3,
radius: f32,
speed: f32,
rate: f32,
},
Box {
min: Vec3,
max: Vec3,
velocity: Vec3,
rate: f32,
},
}Expand description
Particle emitter configuration.
Emitters respawn dead particles at a configurable rate. They run as part of the compute shader, finding dead particle slots and reinitializing them.
§Example
Simulation::<Spark>::new()
.with_particle_count(10_000)
.with_emitter(Emitter::Point {
position: Vec3::ZERO,
rate: 500.0,
})
.with_rule(Rule::Age)
.with_rule(Rule::Lifetime(2.0))
.with_rule(Rule::Gravity(9.8))
.run();Variants§
Point
Emit particles from a single point with random directions.
Simple omnidirectional emitter - particles fly out in all directions.
§Fields
position- Spawn locationrate- Particles per secondspeed- Initial speed of particles (default behavior if 0: random 0-0.5)
Fields
Burst
One-time burst of particles (explosion effect).
Spawns count particles in a single frame, then stops.
Useful for explosions, impacts, or other instantaneous effects.
§Fields
position- Explosion centercount- Number of particles to spawnspeed- Initial outward speedtriggered- Set totrueto fire (resets after burst)
Fields
Cone
Directional cone emitter.
Emits particles in a cone shape, useful for fountains, jets, thrusters.
§Fields
position- Spawn locationdirection- Primary emission direction (will be normalized)speed- Initial particle speedspread- Cone half-angle in radians (0 = laser, PI/2 = hemisphere)rate- Particles per second
Fields
Sphere
Spawn particles on a sphere surface.
Particles spawn on the surface and move outward (or inward if speed < 0).
§Fields
center- Sphere centerradius- Sphere radiusspeed- Outward speed (negative = inward)rate- Particles per second
Fields
Box
Spawn particles within a box volume.
Particles spawn at random positions within the box with optional initial velocity.
§Fields
min- Minimum corner of the boxmax- Maximum corner of the boxvelocity- Initial velocity for all spawned particlesrate- Particles per second
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Emitter
impl RefUnwindSafe for Emitter
impl Send for Emitter
impl Sync for Emitter
impl Unpin for Emitter
impl UnwindSafe for Emitter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.