Add partial support of ray casting with uv computation.

And fix a lot of small bugs on ray casting.