http://lodev.org/cgtutor/raycasting.html - js implementation