I’m trying to figure out how to select/pick the nearest to camera mesh when looking at it by means of a Universal Camera. That is, picking such a mesh when is shown at the center of the screen.
I supposed that this would be a very common scenario and so there were some documentation or even several PGs on it, but couldn’t find any.
As I understand, In order to set the ray cast we’re going to use to pick the meshes, an origin point and direction vector are both needed.
For my case of use, camera.position is of course the origin, and I’m using camera.getDirection in order to retrieve the direction.
This said, sadly the call to getDirection throws a “TypeError: can’t access property “_x”, e is undefined”.
You can take a look at all that through this PG, which of course shows only a very initial stage of the intended full behavior, namely, how to pick the nearest mesh when looking at it.