As I needed to find a quick fix for this for my work, I came up with a solution by creating my own indices to particle lookup rather than using .pickedParticles.
This playground shows it working. The relevant comments start with // ***
[EDIT] done. Now, the fixing will work even with MultiMaterials by using the new method sps.pickedParticle(pickingInfo) returning {idx: number, faceId: number}
idx being the particle index
faceId being the picked face index within the particle geometry
If you click the center black portion you’ll get the correct index always, but if you click the grey sides you sometimes will get the correct index, but usually get a different one than then one you clicked.
Indeed your example shows a behavior different from the one you expect.
That said, it’s quite a complicated example because it uses several processes of your own, like testing the inclusion of the particle index in an array, filtering and managing this array, etc.
Don’t you have please a simpler example without all the added process (I mean with only things related to the SPS and Multimaterial and no extra custom particle management) ?
From this PG, I just can’t check if there’s a bug in the SPS or in your particle management… sorry
If not, maybe someone could replicate the fix (only some lines of code) in the main repro, please.
I have no time to code for BJS unfortunatelly and I don’t have the dev platform on my current computer