Implementing unique object labels

We previously mentioned that picking based on the diffuse property could be difficult if two or more objects in the scene share the same diffuse color. If that were the case and you selected one of them, how would you know which one is picked based on its color? In the next Time for Action section, we will implement unique object labels. The objects will be rendered in the offscreen framebuffer using these color labels instead of the diffuse colors. The scene will still be rendered on screen using the non-unique diffuse colors.

Get WebGL Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.