How is 3D Tiles distanceToCamera property computed?

1. A concise explanation of the problem you're experiencing.

Hi, I have a large number of 3D Tiles tilesets, each with only one tile containing a few features. I want to process and modify them based on the distance to the camera, and I was wondering how the tile._distanceToCamera property was computed. Is it based on the bounding volume of the tile? Or is it a point at the tile center?

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

for(var i = 0; i < tileset.length; i++){
    tileset[i].tileVisible.addEventListener(function(tile) {
      //console.log(isInArray(tile, visibleTiles));
      if ( isInArray(tile, visibleTiles) < 0 ){
        visibleTiles.push([tile, tile._distanceToCamera]);

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

I need to apply modifications (such as color changing) sequentially by distance, so the user should see the closest tiles being changed first, then further, and further.

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

v1.39, Google Chrome


Hi Aditya,

It’s based on the tileBoundingVolume (See, which can be a box, oriented box, or sphere each of which have their own implementation. However generally it’s computed based on the closest point on the outside of the bounding volume.

Thanks, hope that helps!


Thanks Gabby! One quick follow up, is there a way to check bounding boxes for individual features? I’ve tried a number of properties in both feature.content and feature.primitive, but they all seem to relate to the tile and not the feature itself.



feature.content is a private function and subject to change, but you can get the tile it is a part of:





Just to clarify, do any of the objects (feature, tile, tileset) contain bounding volumes for individual features? Primarily I am trying to compute the distance of individual features to the camera.



Cesium does not contain bounding volumes for individual features, however a common approach is to encode positional or bounding volume information in the tiles themselves via batch table properties. For example, a lot of the sample tilesets encode longitude, latitude, and height properties which can be converted to Cartesian coordinates pretty easily for distance checks. Check out the code in

If you have these properties in the batch table it is also a lot easier to write a style that colors by distance rather than looping over the feature’s yourself. Check out the Color By Distance mode in Alternatively, you can style with a custom function. Check out the second example here: This way probably makes more sense since it is based on the camera’s position.

If you are writing your own tileset generation tool it shouldn’t be too hard to add those properties. But if not, I’m afraid there isn’t a great way of getting feature bounding volume information.