how to draw figure at right position by mouse when 3d, terrainProvider and groundPrimitive

I can't obtain the correct coordinates by mouse.

    In 2d scene mode, It could get the rigth coordinates on mouse pointer, but when 3D or 2.5D, and have terrainProvider, the coordinates on mouse pointer have some offset, earth window center's point coordinate is rigth, and the point more farther center the offset is bigger. so I think maybe the terrain influence, the same window screen location(x, y) have diffirent coordinate.

    Could we get the same and right coordinate by mouse on 3d or 2.5d and overlay terrainProvider? because this is very important when draw mark, polyline, polygon, rectangle when clam to gound(use groundPrimitive).

Hello,

If you are using camera.pickEllipsoid, this could give unexpected results with terrain enabled.

Instead, try using viewer.camera.getPickRay and viewer.scene.globe.pick. Here is an example that gets the position on the terrain:

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas, false);
handler.setInputAction(
function(click) {
var ray = viewer.camera.getPickRay(click.position);
var position = viewer.scene.globe.pick(ray, viewer.scene);
if (Cesium.defined(position)) {
// Make the height of the position = 0 so it works with groundPrimitive
var positionCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(position);
positionCartographic.height = 0;
position = viewer.scenne.globe.ellipsoid.cartographicToCartesian(positionCartographic);
}
},
Cesium.ScreenSpaceEventType.LEFT_CLICK
);

``

Best,

Hannah

Thank you very much, I have resolved my problem by your code.