Highlighting Top part of 3D tile only

I was trying to highlight top of the 3D tile, e.g. top part of the tree.
But Polygon Highlight doesn't work, it creates a box around it when I provide Height and Extruded Height.

However, When I use Primitive for highlighting using Geometry Instance. Like below. It works fine, but then when I wanted to change its color using LEFT_CLICK event, I can't access the primitive. It doesn't come up in PrimitiveCollection or Cesium.Primitive. Not sure how to access.

1. Is there any sample which use Viewer Entities for highlighting top of 3D tileset.
2. How to alter Attributes with Primitive in such cases.

scene.primitives.add(new Cesium.ClassificationPrimitive({
  geometryInstances : new Cesium.GeometryInstance({
    geometry : new Cesium.PolygonGeometry({
      polygonHierarchy : new Cesium.PolygonHierarchy(
      height : 10,
      extrudedHeight : 7
    attributes : {
      color : customColor,//Cesium.Color.RED,
      show : new Cesium.ShowGeometryInstanceAttribute(true)
    id : "OuterID"
  classificationType : Cesium.ClassificationType.CESIUM_3D_TILE

I think if you export your classification volume as a glTF, you can use it as an entity to classify by creating it as a model.

For your primitive issue, I’m having a hard time understanding the exact problem. Can you create a complete Sandcastle (https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/) example I can run? Just click “Share” and then paste the link you get here when you’ve got it.

I'll try to create a sample for Primitive.
Like we access entities, viewer.entities.getById(), We can alter Material property too.
But with ClassificationPrimitive, I tried to getGeometryInstance, but I was not able to change color attribute.


This thread tells to use ReadyPromise.

Oh, then it just might be a matter of waiting for it to load. Have you tried it with the readyPromise?

Here is the sample I created for highlighting. It works fine. But if I just want to highlight bottom floor or top floor, I'll have to provide height and extruded height, it doesn't work. Not sure why. Can you please help me in this.

I'll try readyPromise and let you know for my other doubt.

@Omar, Please take a look at sandcastle sample I created for Highlighting top part of the 3Dtile.


Yeah I see what you’re trying to do. I think the problem is classification types aren’t supported on all entities:


For this case, you need classification for an entity that is not clamped to ground, like a box geometry. This can be done with the lower level Primitive API:

You could try that, but it’s a lot more verbose. It might be easier to export like a polygon/box of the right size from Blender as a glTF, which you can then load and use as a classification volume.

Let me know which of these approaches works better for you. I’ve been trying to work on better examples for classification so that would help.