Confused on altitude/height

Hi, I’m giving up on my own research trying to figure out things. Basically, I want to use CesiumJS to display a marker at a specific latitude/longitude. I’ve got that working, but depending on the terrain height at the location, the marker may or may not be properly visible.

If needed, I have the elevation for locations, plus access to geodesy software to calculate any needed ellipsoid values. I’m just am a noob when it comes to what all this does.

So… how to do take coordinates and create a destination with Cesium that is around 100’ above the terrain at any world location?

Thanks, but that went way over my head, LOL. I’m a noob in all this remember. I want to know the time, not how to build a clock.

All I’m looking for is using a latitude/longitude with a corresponding elevation to properly place a Cesium model in 3D space so that entity doesn’t collide with the terrain mesh when viewing via CesiumJS. I would have thought this is a common need that had some prebuilt Cesium functions available to do just that.

Hi @ryust,

Are you using the Entity API to place a marker?

If so, it should be straightforward to clamp it to the ground. There is also a RELATIVE_TO_GROUND value which will allow you to offset by a value, say 100 meters like in your example.

Thanks Gabby.

Yes, I am using an Entity and I’ve tried both RELATIVE and CLAMPED. Regardless, unless the appropriate height is given for the entity, the model could be obscured by the terrain or worst go “underground” into the black hole.

I am looking for an easy way to take a lat/lng with elevation location and correctly derived an entity so that it is positioned in a way it accounts for the terrain mesh below it that may be different than GPS elevation.

I think this would be a very common need where prebuilt Cesium function would handle that without the user needing to know/understand the complexities involved.

Regardless, unless the appropriate height is given for the entity, the model could be obscured by the terrain or worst go “underground” into the black hole.

That shouldn’t be the case. Do you have a minimal code example which can duplicate what you’re seeing? Sandcastle is a useful tool to do so.

Here you go:

const viewer = new Cesium.Viewer(“cesiumContainer”);
const destination = new Cesium.Cartesian3.fromDegrees(-94.5132, 37.0842, 0);
const entity = new Cesium.Entity({
position: destination,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
//heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
label: {text: ‘test label’},
viewer.entities.add(entity);{destination: destination});

  1. To ensure the camera is not looking underground, try flying to the entity with viewer.flyTo(entity); instead of setting the camera position to be the destination itself.
  2. Try setting the verticalOrigin to ensure the label renders above the destination and pixelOffset to adjust the offset as needed; and/or disableDepthTestDistance to disable depth testing with terrain completely.
        label: {
          verticalOrigin: Cesium.VerticalOrigin.BASELINE,
          pixelOffset: new Cesium.Cartesian2(0, -25),
          disableDepthTestDistance: Number.POSITIVE_INFINITY,

I’ve tried to flyTo(entity) before, but I get this error: DeveloperError: destination is required.

Did you try the sample you gave me with your changes? I get the same black hole result using your additions.

I would love to see a Sandcastle sample that works so I can use it as a base for my code.