You need to share some code. It shows your attempt, your coding level and it makes helping you easier.
Check these links, one is a previous discussion and the second one is mPicker, a p5.js lib made exactly for this:
- https://github.com/physicsdavid/mPicker/tree/master/example
- https://forum.processing.org/two/discussion/25255/mouse-click-event-in-3d-webgl
Kf