drawcall / Proton

Javascript particle animation library
https://drawcall.github.io/Proton/
MIT License
2.41k stars 275 forks source link

refactor: removeParticle API #68

Closed cha0s closed 4 years ago

cha0s commented 4 years ago

I need to be able to remove a specific particle from an emitter, so I created two API functions: removeParticle which will remove a particle from the emitter and removeParticleAtIndex which does the same thing but uses a numeric index (for speed to avoid indexOf calls if possible).

A couple of other light changes to consume the API.

drawcall commented 4 years ago

Good advice, but after I submit a new version, consider merging it

cha0s commented 4 years ago

No problem, I'll be watching. :)

I need the ability to remove specific particles because in my engine it's possible to associate a particle with an entity. If that entity is destroyed (can happen out-of-band/async) then the associated particle must also be destroyed (to avoid 876128376 "does entity still exist" checks in PARTICLE_UPDATE).

As long as whatever you propose allows me to do that, I'll use your branch. If my use case is too specific, I can simply maintain my fork for my own purposes.

drawcall commented 4 years ago

This is indeed a good suggestion, I hope you can help write a proton promotion article. Haha