Photons
Photons copied to clipboard
Restarting a particle system should be more automated
trafficstars
It is common to reuse particle systems for things like impact puffs from a gunshots hitting something. There should be an easy way (maybe 1 line of code) way to do this.
Here's how I'm currently accomplishing this:
function onMouseDown() {
// Restarting particles is very clunky...
if ( smokeSystem.isActive ) {
smokeSystem.liveParticleArray.forEach( function( particle ) {
smokeSystem.resetParticle( particle );
} );
smokeSystem.emitting = false;
}
if ( !smokeSystem.emitting || !smokeSystem.isActive ) {
smokeSystem.emitting = true;
smokeSystem.age = 0;
smokeSystem.timeSinceLastEmit = 0;
smokeSystem.activate();
}
}
Is there a better way that I'm missing? one-shot-replay.zip
Actually there is not a better way (right now), and there definitely should be. I haven't actually had a chance to do much experimenting with release-at-once systems, so there's definitely room for improvement. I suppose we need a way to to specify whether or not we want a single release, or repeated release, and an easier way to reset the system.