Html overlays in 3d terrain

Hello , i have the collection of html overlays with huge logic , which I display on map.
When I use terrain provider arcGis or Cesium , and trying to press ctrl and turn over the view of map, my overlays are moving , but there position is same… , height of each overlay = 0

example

Can I suggest something to fix this ?

Hi there,

It looks like the overlays are a an ellipsoid height of 0, meaning they are actually under terrain, causing the discrepancy in the visuals.

To display the overlays at the height which corresponds to terrain, I would suggest using picking in the event listener callback.

but then I will have to change the entire logic of the widget, which is very labor-intensive, is there any option to determine the correct height for the html-overlay?

such problem exists only with using html-overlays ?

Hi @PetukhovArt,

I don’t think this should be a major overhaul, but I probably lack the context of the overall widget design. Could you explain a bit more?

For clarity, an HTML overlay is more or less standard DOM manipulation outside CesiumJS. The CesiumJS portion involves mapping the in-world 3D position to a 2D screenspace position that the DOM element can map to.

From the code you posted, it looks like you are using Cartesian3 instances to represent the in-world 3D position. These instances are simply X/Y/Z coordinates and don’t “know” anything about the terrain. In order to incorporate terrain height, you’ll need to sample it somehow. Picking, as I suggested above, is a common method. But there are alternatives such as asynchronously making network request to sample the exact height of terrain.