Picking on terrain

Hey there,

I´m trying to get the position of a mouseclick including the terrain height. So imagine this. The camera is close to the ground and pointed towards a mountain. If I click on the mountain I want to get the mosition on the mountain. I was able to get this working but with one problem.

If the click position (so, for example a mountain top) has the ellipsoid behind it its all working fine. I get the height and the correct position. But if I rotate the camera enough so that behind the mountain top there is the horizon (or rather space) I get an error even though I am still clicking on terrain. Hope this was clear enough.

Heres the gist for a sandcastle example
: https://gist.github.com/AlexZeller/1452287607b0d1fad642bc3111bc531d

Thanks for your ideas

It sound like you are picking the ellipsoid and not the terrain itself, that’s why you are getting undefined when you are picking the space behind the mountain and not on the ellipsoid.

Try using Scene.pickPosition instead of Scene.globe.pick, as it uses the depth buffer to select the position.



That was it.

Thank you!