Raycaster patch modified from @jpweeks's suggestion.