pub struct SubEmitter {
pub parent_type: u32,
pub child_type: u32,
pub count: u32,
pub speed_min: f32,
pub speed_max: f32,
pub spread: f32,
pub inherit_velocity: f32,
pub child_lifetime: Option<f32>,
pub child_color: Option<Vec3>,
pub spawn_radius: f32,
pub trigger: SpawnTrigger,
}Expand description
Configuration for a sub-emitter that spawns children when triggered.
§Example
SubEmitter::new(ParentType, ChildType)
.count(20) // Spawn 20 children per death
.speed(1.0..2.0) // Random speed in range
.spread(PI / 4.0) // 45-degree cone
.inherit_velocity(0.5) // 50% of parent velocity
.child_lifetime(1.5) // Children live 1.5 seconds
.child_color(Vec3::new(1.0, 0.5, 0.0)) // Orange childrenFields§
§parent_type: u32Parent particle type that triggers sub-emission.
child_type: u32Child particle type to spawn.
count: u32Number of children to spawn per trigger event.
speed_min: f32Speed range for children (random within range).
speed_max: f32§spread: f32Spread angle in radians (0 = laser, PI = hemisphere, TAU = full sphere).
inherit_velocity: f32How much of parent’s velocity children inherit (0.0 - 1.0).
child_lifetime: Option<f32>Optional fixed lifetime for children (overrides any lifecycle rules).
child_color: Option<Vec3>Optional fixed color for children.
spawn_radius: f32Spawn radius around parent position.
trigger: SpawnTriggerWhat triggers this sub-emitter (death, condition, etc.).
Implementations§
Source§impl SubEmitter
impl SubEmitter
Sourcepub fn new(parent_type: u32, child_type: u32) -> Self
pub fn new(parent_type: u32, child_type: u32) -> Self
Create a new sub-emitter configuration.
By default, triggers on parent death. Use .on_condition() to trigger
on a custom WGSL condition instead.
§Arguments
parent_type- Type of particle that triggers sub-emissionchild_type- Type of particle to spawn as children
§Example
// Classic death-triggered spawning (fireworks)
SubEmitter::new(Firework::Rocket.into(), Firework::Spark.into())
// Condition-triggered spawning (cell division)
SubEmitter::new(Cell::Parent.into(), Cell::Child.into())
.on_condition("p.energy > 1.5")
.count(2)Sourcepub fn on_condition(self, condition: impl Into<String>) -> Self
pub fn on_condition(self, condition: impl Into<String>) -> Self
Set the trigger to a custom WGSL condition.
The condition is a WGSL boolean expression with access to:
p- The current particleuniforms.time- Total elapsed timeuniforms.delta_time- Frame delta time
When the condition evaluates to true, spawn events are recorded and children are spawned in a secondary pass.
§Example
// Spawn when energy exceeds threshold
SubEmitter::new(Parent, Child)
.on_condition("p.energy > 0.9")
.count(3)
// Periodic spawning (approximately every second)
SubEmitter::new(Parent, Child)
.on_condition("fract(p.age) < uniforms.delta_time")
.count(1)
// Spawn near the origin
SubEmitter::new(Parent, Child)
.on_condition("length(p.position) < 0.2")
.count(2)Sourcepub fn trigger(self, trigger: SpawnTrigger) -> Self
pub fn trigger(self, trigger: SpawnTrigger) -> Self
Sourcepub fn inherit_velocity(self, factor: f32) -> Self
pub fn inherit_velocity(self, factor: f32) -> Self
Sourcepub fn child_lifetime(self, seconds: f32) -> Self
pub fn child_lifetime(self, seconds: f32) -> Self
Sourcepub fn child_color(self, color: Vec3) -> Self
pub fn child_color(self, color: Vec3) -> Self
Sourcepub fn spawn_radius(self, radius: f32) -> Self
pub fn spawn_radius(self, radius: f32) -> Self
Trait Implementations§
Source§impl Clone for SubEmitter
impl Clone for SubEmitter
Source§fn clone(&self) -> SubEmitter
fn clone(&self) -> SubEmitter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SubEmitter
impl RefUnwindSafe for SubEmitter
impl Send for SubEmitter
impl Sync for SubEmitter
impl Unpin for SubEmitter
impl UnwindSafe for SubEmitter
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.