Cesium - using scaleByDistance for a billboard created through CZML

I am trying to show a badge in the form of a billboard and scale it by distance. I can handle it well, but as soon as I load the billboard via CZML and not directly into JS, I cannot resize the billboard.

In my JS file, I have:

var czmlDataSource = new Cesium.CzmlDataSource();
czmlDataSource.loadUrl('airports.czml');
viewer.dataSources.add(czmlDataSource);

My CZML file shows:

[
  {
    "id":"document",
    "version":"1.0"
  },
  {
    "id":"test",
    "billboard":{
      "image":"airport.png",
      "verticalOrigin":"BOTTOM",
      "show":true
    },
    "position":{
      "cartographicDegrees":[
        0.055278, 51.505278, 0
      ]
    }
  }
]

Before using this:

entity.billboard.scaleByDistance = new Cesium.ConstantProperty(new Cesium.NearFarScalar(1.5e3, 0.3, 3.5e5, 0.0));

Obviously this is not working right now. But I cannot find a way how to possibly get the billboard identifier and use scaleByDistance.

+5
source share
2 answers

CZML scaleByDistance. , , .

, loadUrl , . :

var czmlDataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(czmlDataSource);
czmlDataSource.loadUrl('airports.czml').then(function() {
    var entity = czmlDataSource.entities.getById('test');
    entity.billboard.scaleByDistance = new Cesium.ConstantProperty(
            new Cesium.NearFarScalar(1.5e3, 0.3, 3.5e5, 0.0));
});
+4

. Cesium ( new Cesium.NearFarScalar, CZML, JSON):

"scaleByDistance": { "nearFarScalar": [ 1.0, 2.0, 10000.0, 3.0 ] }

.

:

+1
source

All Articles