Would this idea work for you (no raycasting): https://codepen.io/boytchev/pen/QWJOBrL
The full discussion is here: