click a point on the terrainprovider ?

Hi,

viewer.camera.pickEllipsoid(click.position)
returns a cartesian3 of the ellipsoid, but I'm using a terrainprovider and I would like to click a point on that surface, is that possible ?
I can construct a ray from the camera, but I can't seem to find a reference to the terrain mesh/model to intersect with.

Help is appreciated.

Sander

Hello Sander,

You can use globe.pick to get the intersection with the terrain. Here is an example:

    var ray = viewer.camera.getPickRay(movement.endPosition);
    var position = viewer.scene.globe.pick(ray, viewer.scene);

``

Just keep in mind that this value may vary depending on the level of detail for the terrain tile that is currently loaded. For a consistent result, you may want to use the sampleTerrain function to query the terrain for the height of the position at a given cartographic coordinate.

Best,

Hannah