How can I access the height value in 3d tiles data?

I want to display point cloud data in color by height.
(.las data converted to 3d tiles)

classificationTileset.style = new Cesium.Cesium3DTileStyle({
  color: {
    conditions: [
      ["${id} ==='roof1'", "color('#004FFF', 0.5)"],
      ["${id} ==='towerBottom1'", "color('#33BB66', 0.5)"],
      ["${id} ==='towerTop1'", "color('#0099AA', 0.5)"],
      ["${id} ==='roof2'", "color('#004FFF', 0.5)"],
      ["${id} ==='tower3'", "color('#FF8833', 0.5)"],
      ["${id} ==='tower4'", "color('#FFAA22', 0.5)"],
      ["true", "color('#FFFF00', 0.5)"],
    ],
  },
});

In the sandcastle example above, it seems that colors were given according to the value of ${id}, and if I change ${id} to height, my point cloud data can be displayed as color by height.

But, I can’t find where the id value in the sandcastle example data or the height value in my point cloud data is.

So my question is how can I access the height value in 3d tiles data?

Thank you

Couple of things here;

First is that it’s not a given that a point cloud has a height property, it really depends if the pointcloud was tiled with that property in it. The reason is because all points/tiles are in Cartesian3 coordinate system (each point is a 3D vector distance from the center of the earth) out of the box, not in world coordinates (lat, long, height), so you have to add them (especially the Height property) when you create your pointcloud (with whatever tool you use for it; I don’t know which models in Cesium Ion have what).

Secondly, you can’t test for what properties the pointcloud has upfront (at least not in the current Cesium), so the rendering either breaks (if the property isn’t there), or you have to write a rule that checks for it (first rule);

["${height} ===undefined || ${height} === null || isNaN(${height}) ", "true"]

If you know it’s got height there’s no issue. I’ve tried a number of tricks with meta variables and all sorts of detection, but this one is a bit tricky. It also doesn’t help that the engine for pointclouds is slightly different than rendering other 3D tilesets (and some brain-cells in the back of the head informs me that I can’t check for ‘undefined’ in pointclouds, only in other 3D tiles, but I might be misremembering).

You can read more about all this here;

Cheers,

Alex

3 Likes

This is true because styling for point clouds is evaluated in the GPU via a shader vs styling for 3D buildings for example is done by evaluated on the CPU.

Thanks for linking to the Styling & Filtering article Alex! The style pointclouds section in particular has a link to a Sandcastle that shows you how to styling using the absolute position of a point if you created your point cloud with Cesium ion. See the heatmap Sandcastle.

1 Like

Thank you so much for answering.