In the 3DTiles Feature styling example of Cesium Sandcastle,distance is measured in what way?

Can somebody give me a detailed explanation of the below code?

Does it calculate based on earth's curvature also and to what precision?

function colorByDistance() {
    tileset.style = new Cesium.Cesium3DTileStyle({
        defines : {
            distance : "distance(vec2(radians(\{longitude\}\), radians\({latitude})), vec2(-1.291777521, 0.7105706624))"
        },
        color : {
            conditions : [
                ["\{distance\} &gt; 0\.0012&quot;,&quot;color\(&#39;gray&#39;\)&quot;\], &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\[&quot;{distance} > 0.0008", "mix(color('yellow'), color('red'), (\{distance\} \- 0\.008\) / 0\.0004\)&quot;\], &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\[&quot;{distance} > 0.0004", "mix(color('green'), color('yellow'), (\{distance\} \- 0\.0004\) / 0\.0004\)&quot;\], &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\[&quot;{distance} < 0.00001", "color('white')"],
                ["true", "mix(color('blue'), color('green'), ${distance} / 0.0004)"]
            ]
        }
    });
}

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you're using, your operating system and browser.

1.47, win7, chrome

Hi!

The function colorByDistance colors the buildings based on their distance from a specific spot, in this case, the World Trade Center, whose position is denoted by the length 2 vector (-1.291777521, 0.7105706624). The first value is the longitude in radians and the second value is the latitude in radians. There is no height, so that point would be on the ground of the earth.

Regarding your question of whether the distance takes into consideration the curvature of the earth, it does not seem to be according to the documentation. The distance function computes vector math and just calculates length(u - v) where u and v are the vectors.

Thus, for every building in this set of 3D Tiles, this function first calculates the vector distance between the (lon, lat) of the building with the target position (-1.291777521, 0.7105706624). It then colors based on the result of this calculation.

thanks Jane.

so the result is in terms of what?
meters/kilometers?

so the result is in terms of what?
meters/kilometers?

and the conditions are taken in terms of distance, that is from where is the starting point taken while coloring?

Since the vectors are both in radians, the distance calculated would also have units in radians, not kilometers or meters.

And the conditions do depend on the distance that is evaluated for every building. Every building thus gets colored by how far they are from the World Trade Center.