Search code examples
cesiumjs

Drawing text at different heights in CesiumJS


I'm trying to draw some text at a particular height (so it's drawn at the same height as some other primitive) in Cesium. Text-wise, I can't seem to be able to draw anything but labels clamps to the ground (in the example below, the first little circle is at ground level). As such:

var entity = viewer.entities.add({
            position: Cesium.Cartesian3.fromDegrees(parseFloat(terrain[5]), parseFloat(terrain[4])),
            ellipse : {
              semiMinorAxis : 10000,
              semiMajorAxis : 10000,
              height : 1000,
              fill : true,           
              outline: true,
              material : Cesium.Color.fromCssColorString(someColour).withAlpha(0.5),
              outlineWidth : 2
            },
            label: {
                id: 'my label',
                text: "Blabla",
                scale: .5,
                height: 1000
              }
         });

enter image description here

Is there any way to draw text at a specific height in Cesium?


Solution

  • The text height needs to be part of entity.position. Try adding it as a 3rd parameter to Cartesian3.fromDegrees on the 2nd line there.