pub struct ParticleEmitter {
pub position: [f32; 3],
pub emission_rate: f32,
pub initial_velocity: [f32; 3],
pub velocity_spread: f32,
pub lifetime: f32,
pub color: [f32; 4],
pub size: f32,
pub accumulator: f32,
}Expand description
Emits particles from a point with configurable velocity distribution and lifetime.
Fields§
§position: [f32; 3]World-space emission origin.
emission_rate: f32Number of particles emitted per second.
initial_velocity: [f32; 3]Base initial velocity [vx, vy, vz].
velocity_spread: f32Random spread (half-range) added to each velocity component.
lifetime: f32Initial particle lifetime in seconds.
color: [f32; 4]Initial particle color.
size: f32Initial particle size.
accumulator: f32Accumulated fractional particles not yet emitted.
Implementations§
Source§impl ParticleEmitter
impl ParticleEmitter
Sourcepub fn new(
position: [f32; 3],
emission_rate: f32,
initial_velocity: [f32; 3],
velocity_spread: f32,
lifetime: f32,
) -> Self
pub fn new( position: [f32; 3], emission_rate: f32, initial_velocity: [f32; 3], velocity_spread: f32, lifetime: f32, ) -> Self
Create a new emitter.
Sourcepub fn particles_to_emit(&mut self, dt: f32) -> usize
pub fn particles_to_emit(&mut self, dt: f32) -> usize
Advance the accumulator and return how many particles to emit this step.
Sourcepub fn spawn(&self, rng: &mut Lcg) -> GpuParticle
pub fn spawn(&self, rng: &mut Lcg) -> GpuParticle
Build a fresh particle, adding random velocity spread via the given RNG.
Trait Implementations§
Source§impl Clone for ParticleEmitter
impl Clone for ParticleEmitter
Source§fn clone(&self) -> ParticleEmitter
fn clone(&self) -> ParticleEmitter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ParticleEmitter
impl RefUnwindSafe for ParticleEmitter
impl Send for ParticleEmitter
impl Sync for ParticleEmitter
impl Unpin for ParticleEmitter
impl UnsafeUnpin for ParticleEmitter
impl UnwindSafe for ParticleEmitter
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more