pub struct ParticleEmitterDef {Show 19 fields
pub model: SpriteModelId,
pub pos: [f32; 3],
pub shape: EmitterShape,
pub spawn: SpawnMode,
pub lifetime: Range<f32>,
pub velocity: VelocityDef,
pub gravity: [f32; 3],
pub drag: f32,
pub collision: CollisionMode,
pub scale: f32,
pub scale_end: Option<f32>,
pub spin: Range<f32>,
pub fade_in_frac: f32,
pub fade_out_frac: f32,
pub tint: Rgb,
pub tint_end: Option<Rgb>,
pub material: u8,
pub lighting: BillboardLighting,
pub shadows: ShadowFlags,
}Expand description
Recipe for add_emitter. Construct
with ParticleEmitterDef::new and override what the effect needs;
there is no Default because a def is meaningless without a live
SpriteModelId.
Fields§
§model: SpriteModelIdThe kv6 sprite model every particle instantiates (a puff, a
spark, a shard) — from
add_sprite_model.
pos: [f32; 3]Emitter position, world space. Movable later via
set_emitter_pos.
shape: EmitterShapeSpawn-position distribution around pos (PS.2; default
EmitterShape::Point).
spawn: SpawnModeSpawn behaviour (default SpawnMode::Manual).
lifetime: Range<f32>Per-particle lifetime, seconds, sampled uniformly. A degenerate
range (end <= start) collapses to start. Clamped to ≥ 1 ms.
velocity: VelocityDefInitial velocity distribution.
gravity: [f32; 3]Constant acceleration, world units/s² — gravity is positive
z (default [0, 0, 22], a decent arcade fall).
drag: f32Linear drag coefficient, 1/s: each step removes
drag · vel · dt. 0.0 = ballistic; smoke wants ~1-3.
collision: CollisionModeVoxel-collision reaction (PS.3; default CollisionMode::None).
Only the _with_scene update/tick variants test it.
scale: f32Uniform base scale applied to the instance basis (1.0 =
authored model size). The rendered scale clamps to ≥ 0.05 —
a degenerate basis silently skips drawing.
scale_end: Option<f32>End-of-life scale (PS.2): the particle lerps scale → scale_end over its lifetime — growing smoke, shrinking sparks.
None (default) = constant.
spin: Range<f32>Spin rate about the world vertical, radians/second, sampled
uniformly per particle (PS.2) — a symmetric range like
-3.0..3.0 spins debris both ways. Default 0.0..0.0 = no
spin.
fade_in_frac: f32Fraction of the lifetime over which alpha ramps 0 → 255 at the
start (PS.2) — smoke that condenses in rather than pops.
0.0 (default) = born fully opaque.
fade_out_frac: f32Fraction of the lifetime over which alpha fades 255 → 0 at the
end (0.25 = the last quarter). 0.0 = no fade, particles
vanish at full opacity.
tint: RgbPer-particle RGB tint, packed 0x00RRGGBB (white = no-op).
tint_end: Option<Rgb>End-of-life tint (PS.2): lerped per channel from tint over
the lifetime — white-hot → red → dark ember. None (default) =
constant.
material: u8Voxel-material id for every particle (TV palette; 0 opaque).
Smoke wants an alpha/volumetric material, sparks additive.
lighting: BillboardLightingShading-normal mode (default BillboardLighting::FaceNormal;
glowing effects want BillboardLighting::FullBright).
shadows: ShadowFlagsShadow participation. Defaults to neither cast nor receive — hundreds of shadow-casting particles are a perf trap; opt back in per effect.
Implementations§
Source§impl ParticleEmitterDef
impl ParticleEmitterDef
Sourcepub fn new(model: SpriteModelId) -> Self
pub fn new(model: SpriteModelId) -> Self
A def with every field at its documented default: manual spawn at a point at the origin, 1-2 s lifetime, no initial velocity, arcade gravity, no drag, constant unit scale, no spin, fade out over the last quarter, constant no-op tint, opaque material, face-normal lighting, shadows off.
Trait Implementations§
Source§impl Clone for ParticleEmitterDef
impl Clone for ParticleEmitterDef
Source§fn clone(&self) -> ParticleEmitterDef
fn clone(&self) -> ParticleEmitterDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ParticleEmitterDef
impl RefUnwindSafe for ParticleEmitterDef
impl Send for ParticleEmitterDef
impl Sync for ParticleEmitterDef
impl Unpin for ParticleEmitterDef
impl UnsafeUnpin for ParticleEmitterDef
impl UnwindSafe for ParticleEmitterDef
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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