Expandable SPS with invisible particles draws unexisting particles after rebuilding the SPS

I think there is a problem with SPS when it’s expandable and we have some invisible particles on it.

Here are the steps:

  • Create a SPS
  • Add a particle, and set isVisible = false on it
  • Build the SPS
  • Add another particle
  • Build the SPS

It is expected for the SPS to show just one particle (the visible one), but instead, it is showing the second particle, and another particle that appears to be the original mesh shape of the first particle.

Below a playground showing the error:
https://playground.babylonjs.com/#BKX11Q#5

Note that the white sphere shown in the scene was not supposed to be shown. It is expected to show just the blue box.

Is this a bug or I’m missing something?

Best regards,
Rafael Cerávolo

It is odd, i totally agree. But can I ask something. Why are you building the SPS twice?

Why not do this:

Problem with expandalble SPS and invisible particles | Babylon.js Playground (babylonjs.com)

Hi there!

It’s becase I’m using an expandable SPS, so when new particles are added/removed after the first build, it’s required do buildMesh() again for the SPS to draw the new particles.

In the example in the playground it’s ok to just call buildMesh() just once at the end, but in my real app, the particles are added/removed/hidden at different moments while the user interacts with the scene, so I need to rebuild the mesh after those interactions.

The playground is just to reproduce the issue!

1 Like