Implemented ray casting.