I’m trying to implement offline routing in 3D map inside ThreeJS scene. I want user to click a point and then navigate a cube to this point. Navigation works correctly but clicked point isn’t accurate. Flat map is a plane in XZ coordinates with Y axis up. In the scene I’ve got Orbit Controls which when orbiting change the position argument of camera, thus raycasting is not accurate with the way I’m doing it. I need to get correct XZ coords in whatever orbit state. I’m getting correct coords for traditional raycasting in 3D but as I said this is not what I need. I tried basic method from ThreeJS docs for raycaster, answer from this question and unprojecting mouse click with Vector3.unproject() without any success.
Here is jsfiddle to illustrate what I mean. There are some important explanation comments.