I am using Three.js to simulate and visualize a robot. I need to allow this robot to detect obstacles; specifically it needs to return the distance to the closest obstacle straight in front of it. How could said functionality be implemented in Three.js? I need to essentially "look" along a given ray and find the closest object that intersects it.
You can use the raycaster built into Three.js: https://threejs.org/docs/#api/en/core/Raycaster