Skip to main content

Module particles

Module particles 

Source
Expand description

Particle emitters: fire, smoke, sparks, rain, snow, magic dust.

A ParticleEmitter simulates its particles on the CPU and draws them as camera-facing quads in one DynamicMesh (one draw call per emitter). Particles live in world space, so they trail behind a moving emitter. Colours and fading are done by the built-in particle shader.

use kvas_engine::{prelude::*, scene::Scene, runtime::Runtime};
let mut scene = Scene::default();
let fire = scene.spawn("Campfire");
scene.world.insert(fire, ParticleEmitter::preset("fire"));
let mut runtime = Runtime::new(scene, None);
for _ in 0..30 { runtime.tick(1.0 / 30.0); }
assert!(runtime.scene.world.get::<ParticleEmitter>(fire).unwrap().alive() > 0);

Structs§

ParticleEmitter
A particle emitter.

Enums§

EmitterShape
Where new particles appear.

Functions§

update
Simulates every emitter and refreshes its mesh and material. simulate is false in the editor outside Play: emitters then animate from wall-clock time so they can be previewed.