Skip to main content

ParticleEmitterDef

Struct ParticleEmitterDef 

Source
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: SpriteModelId

The 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: EmitterShape

Spawn-position distribution around pos (PS.2; default EmitterShape::Point).

§spawn: SpawnMode

Spawn 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: VelocityDef

Initial velocity distribution.

§gravity: [f32; 3]

Constant acceleration, world units/s² — gravity is positive z (default [0, 0, 22], a decent arcade fall).

§drag: f32

Linear drag coefficient, 1/s: each step removes drag · vel · dt. 0.0 = ballistic; smoke wants ~1-3.

§collision: CollisionMode

Voxel-collision reaction (PS.3; default CollisionMode::None). Only the _with_scene update/tick variants test it.

§scale: f32

Uniform 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: f32

Fraction 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: f32

Fraction 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: Rgb

Per-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: u8

Voxel-material id for every particle (TV palette; 0 opaque). Smoke wants an alpha/volumetric material, sparks additive.

§lighting: BillboardLighting

Shading-normal mode (default BillboardLighting::FaceNormal; glowing effects want BillboardLighting::FullBright).

§shadows: ShadowFlags

Shadow 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

Source

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

Source§

fn clone(&self) -> ParticleEmitterDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParticleEmitterDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more