Paint polygon with click

Someone has an idea why when I paint a polygon with clicks, if it gets me long and lat correctly, but when I add a terrainProvider to CesiumViewer I no longer paint the polygon correctly it makes it far from the point where I click on the map

Can you please provide a Sandcastle example ( showing the issue? You can click “share” and paste the link you get here.