Challenge with picking on terrain. Unpredictable results

Hi all,

I am developing an application that involves plotting paths. The mouse is used to select a start and end point on the surface of the globe, and a path is drawn between them. When I am picking on the WGS84 ellipsoid things seem to be ok and the line is drawn between the two points I would expect. When I add a terrain provider things start to get very unpredictable (just as an aside, the terrain support is amazing btw! love it). The picked points are often floating in the air, and almost never where I would expect them to be. I am aware of the sampleTerrain function, and I have used it to lower the picked points to be at terrain height, but height aside, the points are in the wrong location. I am using globe.pick(). My interpretation of the API documentation is that this function should pick on the terrain and not the reference ellipsoid, is that correct? My feeling is that it might be an issue with the intersection calculation between the pick ray and the terrain.

The geographical region that I am testing in is, I believe, below the surface of the ellipsoid, so I do wonder if this might be significant?

I have created a jsfiddle to demonstrate this issue -

To use it, you'll want to zoom in a little further, and rotate the view to an isometric one. Picking seems to work ok from the nadir view. Right click on two different points on the scene, and then rotate around again to see where the line has been drawn.

I've also got some images showing the issue. The first image shows a line created by click on two points on the terrain. The subsequent images are the same line, with the view rotated.

Thanks for any help you can give me!

There was a recent issue causing unpredictable results when requestVertexNormals was set to true (which you seem to be using based on the images).

So try setting requestVertexNormals to false or working from master rather than 1.2.


Yup, disabling vertex normals seems to have fixed it :slight_smile: Thanks for the tip!

I might hold out for the next point release which presumably is imminent?Shadows aren't essential at the moment (though they do look very nice :slight_smile: ).


The fix is in the 1.3 release, which came out today. So you should be able to use vertex normals again, assuming you want them.