GPU multi picking

You’re right.

I just woke up and a solution has popped out of my mind. It seems that my brain is more rested because I could think of it right away :slight_smile:

Basically you can ask for a multiPick with two coordinates. Left upper corner and right bottom corner - a region. All you have do then is read the gpuPicker._readBuffer’s data. It’s an Uint8Array with Color4 data. Each color represents a meshId - index + 1 in the pickingList.

Move the meshes into the magenta region.

The example reads only one color byte, so you’re limited to 255 meshes.

@Deltakosh maybe we could expose the _readBuffer or it would be more elegant to make the private _getColorIdFromReadBuffer(offset: number):IColor3Like function public.

EDIT:
Drag to create region and pick meshes in the region. Picks only visible meshes but can be easily updated to pick ocluded meshes as well.

The same but also picks the meshes onmousemove:

Code is not optimized yet.

2 Likes