Various implementations of WebGL picking (hit testing)
You will find two various methods for WebGL picking (hit testing) by encoding index or color values. Here's a simple DEMO showcasing the encoding of the geometry index into the alpha channel.
Go ahead and give it a try: WebGL Picking
git clone https://github.com/FarhadG/webgl-picking.git
cd webgl-picking
Open
or serve
up the index.html
file. All of the logic happens inside of either indexEncoding.js
or 'colorEncoding.js'.
MIT