How can I get rid of color arrays in SPS?

I was measuring the memory consumption of my app and I noticed that solid particle system (SPS) takes up a lot. This is understandable, because we use it a lot.

But I noticed that there’s a _color32 array, and I don’t even use colors.
=> is there a way to get rid of it? I already use the _computeParticleColor flag, but that doesn’t seem to do the trick.

For example if there aren’t any UVs on the underlying mesh, the SPS will not create any _uvs32.
But this isn’t the case for colors.
Here’s the code:


cc @Evgeni_Popov to see if he has an idea ?

You’re right, we should not create the array if not needed. Here’s the PR:

In fact, it’s not possible to remove the color array because the color can be set in a custom recycleParticle callback, and the code can’t know in advance that you’ll be using such functions/changing the particle color in that function (which is probably why the code was as it was).

I think the best solution for now is to call spsMesh.removeVerticesData("color") to remove the color attribute. If you want to save even more memory, you can do sps._colors32 = new Float32Array().

1 Like

Ok, thanks for the clarification :+1: