repro: https://playground.babylonjs.com/#217750#263
If you have thin instances on a mesh added to the gpu picking list and then matrix buffer is emptied, ie, all thin instances gone, console throws TypeError: Cannot read properties of undefined (reading 'r')
. uncommenting line 50 clears the error.
I guess a user warn, doc update?
@Deltakosh , can this be a bug in the GPUPicker implementation?
Yes probably doc update again (quite swamped right now, do you want to help on this one pretty please ? :))
I’ll update doc when I have a better grasp of what is going on.
Another repro for instances this time: Babylon.js Playground
Beginning to see the pattern that
a) any instances/thin instances added/removed needs a picker.setPickingList([...list])
update to refresh the gpu. for instances, do it after instance.dispose();
b) root meshes used for normal instances must be enabled and also in the list for gpu picking to work, even if they are not meant to be seen.
c) root meshes for thin instances need a gpu refresh for any matrix buffer
changes.
d) spawning the first thin instance of a mesh gives thinInstanceIndex
of undefined
on pickAsync
until the gpu pick list is refreshed.
e) renderOverlay
or any shader/plugin with similar behaviors doesn’t work with gpu picking, this happens for stock, clones, meshes with no instances/thin instances.
Maybe I should just shut up and go read the source… 
I thought I knew what was going on, but now I know I don’t, hrmm…
Repro: https://playground.babylonjs.com/#NNC5Y2#1
The sphere farthest away in view is instance0
, the nearest is instance9
. Dispose instance1
and updated the gpu pick list, now the pick results are borked. Nearest is now instance8
, instance2
is now instance9
?
If you reverse the dispose and update order to
picker.setPickingList([...list]);
scene.getMeshByName("instance1").dispose();
You get a different result…hrm… Does anyone else see what I’m seeing?