use rdpe::prelude::*;
#[derive(rdpe::Particle, Clone)]
struct Particle {
position: Vec3,
velocity: Vec3,
}
fn main() {
let count = 30_000;
Simulation::<Particle>::new()
.with_particle_count(count)
.with_bounds(1.5)
.with_particle_size(0.012)
.with_spawner(|ctx| {
let phi = ctx.progress() * std::f32::consts::PI * 2.0 * 100.0;
let theta = ((ctx.index as f32 * 0.618_034) % 1.0) * std::f32::consts::PI;
let r = 0.3 + (ctx.index as f32 * 0.381966) % 0.4;
let x = r * theta.sin() * phi.cos();
let y = r * theta.cos();
let z = r * theta.sin() * phi.sin();
Particle {
position: Vec3::new(x, y, z),
velocity: Vec3::ZERO,
}
})
.with_visuals(|v| {
v.palette(Palette::Ocean, ColorMapping::Distance { max_dist: 1.5 });
v.blend_mode(BlendMode::Additive);
v.trails(10);
})
.with_rule(Rule::Shockwave {
origin: Vec3::ZERO,
speed: 0.8,
width: 0.25,
strength: 4.0,
repeat: 3.0,
})
.with_rule(Rule::Pulse {
point: Vec3::ZERO,
strength: 0.5,
frequency: 0.3,
radius: 0.0, })
.with_rule(Rule::Radial {
point: Vec3::ZERO,
strength: -0.8, radius: 2.0,
falloff: Falloff::Linear,
})
.with_rule(Rule::Drag(1.5))
.with_rule(Rule::SpeedLimit { min: 0.0, max: 1.5 })
.with_rule(Rule::BounceWalls { restitution: 1.0 })
.run().expect("Simulation failed");
}