Its been 3 years since I started learning Javascript in earnest and along the way I have shared some of my efforts. Before that I mostly programmed with C++ and Java using the object orientated paradigm and this can be seen in my early Javascript examples.
One of those examples was a 3D shape picker using a colour buffer algorithm. It met my requirements at the time but it needed modifying to make it compatible with p5js V2 and I now have a need for a 2D version.
So I have created a new shape picker that
- performs both 2D and 3D automatically detecting the rendering mode (P2D or WEBGL) of the sketch.
- is compatible with both p5js V1 and V2. Codes changes might be needed to load images etc. but the picker doesn’t.
- requires a single line of code to show the shape buffer in the web page (useful for debugging)
The two sketches below demonstrate 2D and 3D shape picking (using the mouse) and are available to copy and experiment with from my p5js sketch editor account.