You will have to code it, study some tutorials or example project that implement raycast on how it works.
Here are some:
https://developer.playcanvas.com/en/tutorials/?tags=raycast