diff --git a/examples/instancing.rs b/examples/instancing.rs index 3cceab5c..e2c1b73a 100644 --- a/examples/instancing.rs +++ b/examples/instancing.rs @@ -209,6 +209,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, mut my_effect: ResMut, + loader: Res, ) { info!("Usage: Press the SPACE key to spawn more instances, and the DELETE key to remove an existing instance."); @@ -272,10 +273,11 @@ fn setup( gradient.add_key(0.0, Vec4::new(1., 0., 0., 0.)); gradient.add_key(0.1, Vec4::new(1., 0., 0., 1.)); gradient.add_key(1.0, Vec4::new(1., 0., 0., 0.)); + let texture = loader.load("circle.png"); let writer = ExprWriter::new(); - let lifetime = writer.lit(2.).expr(); + let lifetime = writer.lit(5.).expr(); let init_lifetime = SetAttributeModifier::new(Attribute::LIFETIME, lifetime); let init_pos = SetPositionSphereModifier { @@ -290,12 +292,21 @@ fn setup( speed: writer.lit(4.).expr(), }; + let radial_accel = + RadialAccelModifier::new(writer.lit(Vec3::ZERO).expr(), writer.lit(-3).expr()); + let alt_effect = effects.add( - EffectAsset::new(vec![512], Spawner::rate(256.0.into()), writer.finish()) + EffectAsset::new(vec![512], Spawner::rate(102.0.into()), writer.finish()) + .with_simulation_space(SimulationSpace::Local) .with_name("alternate instancing") .init(init_pos) .init(init_vel) .init(init_lifetime) + .update(radial_accel) + .render(ParticleTextureModifier { + texture, + ..default() + }) .render(ColorOverLifetimeModifier { gradient }), );