Time for Action: Fountain of Sparks

Let's see how we can use point sprites to create a fountain of sparks:

  1. Open the ch10_02_point-sprites.html file in your browser:
  1. This example showcases a simple fountain of sparks effect with point sprites. You can adjust the size and lifetime of the particles by using the sliders.
  2. The particle simulation is performed by maintaining a list of particles that are comprised of position, velocity, and lifespan. In every frame, we iterate through the list and move the particles according to the velocity; we also apply gravity and reduce the remaining lifespan. Once a particle's lifespan has reached 0, it's ...

Get Real-Time 3D Graphics with WebGL 2 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.