Colour by Distance - point cloud

I am using Cesium 1.35 on linux, with Firefox.

I am interested to visualise point clouds by the point distance to another object, like a landmark, or vector line. The Cesium Sandcastle Gallery example called “3D Tiles Feature Styling” has a function colorByDistance which allows to colour by distance from landmark, for which the snipit is shown below.


1 does anyone know the format and how it works, because the point with latitude longitude -1.291777521, 0.7105706624 is not relevant in absolute values to the example of Manhattan. Perhaps it is relative to an origin?

2 does anyone have any idea if it possible to take that further and use the function colorByDistance for not just a point , but at vector polyline. Eg a corridor type analysis

3 will this work for point cloud, as opposed to 3D tile?

// Color buildings by distance from a landmark.

function colorByDistance() { = new Cesium.Cesium3DTileStyle({

    defines : {

        distance : "distance(vec2(${longitude}, ${latitude}), vec2(-1.291777521, 0.7105706624))"


    color : {

        conditions : [

            ["${distance} > 0.0002", "color('gray')"],

            ["true", "mix(color('yellow'), color('green'), ${distance} / 0.0002)"]





Here are my thoughts right now for point cloud styling by distance:

  1. The NYC colorByDistance style assumes each building has longitude/latitude metadata. The math itself does not give a precise distance in meters, just an estimate of distance.

For point clouds you may want to write the distance define to work with Cartesian coordinates since it is unlikely the points have longitude and latitude properties. Something like:

distance(${POSITION_ABSOLUTE} , vec3(6378137, 0, 0)) // Distance from lat/long of 0,0


Where POSITION_ABSOLUTE is a built-in property for all point clouds - described here:

  1. We aren’t quite far enough along on the vector tile styling to truly know, but at first the style will likely apply a single color to the line/corridor rather than a gradient based on distance.

  2. Different tile formats may need different tweaks for a colorByDistance type styles, but it should be doable throughout 3D Tiles. Right now styling is on a per-feature basis. Eventually we want to take this further to create color gradients like this prototype video: