Want to use Polygon as ClassificationPrimitive

In Sandcastle examples, Classification 3D tile, we can use boxgeometry as highlighting boundry. I want to use Polygon as highlighting boundry. I tried following example, it didn't throw any error, but didn't work either.

var extrudedPolygon = new Cesium.PolygonGeometry({
      polygonHierarchy : new Cesium.PolygonHierarchy(
          -72.0, 40.0,
                                  -70.0, 35.0,
                                  -75.0, 30.0,
                                  -70.0, 30.0,
                                  -68.0, 40.0
      extrudedHeight: 200

    //var geometry = Cesium.PolygonGeometry.createGeometry(polygon);
    var geometry1 = Cesium.PolygonGeometry.createGeometry(extrudedPolygon);
      vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
      dimensions : new Cesium.Cartesian3(building.structures[index].dx, building.structures[index].dy, building.structures[index].dz)
    var buildingHighlight = viewer.scene.primitives.add(new Cesium.ClassificationPrimitive({
      geometryInstances : new Cesium.GeometryInstance({
        geometry : geometry1,
        modelMatrix : modelMatrix,
        attributes : {
          color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5)),
          show : new Cesium.ShowGeometryInstanceAttribute(true)
        id : 'volume'
      classificationType : Cesium.ClassificationType.BOTH

Hi there,

The documentation for ClassificationPrimitive lists the supported geometry types:

Valid geometries are BoxGeometry, CylinderGeometry, EllipsoidGeometry, PolylineVolumeGeometry, and SphereGeometry.

So you’ll need to use one of those geometries.



I tried to implement PolylineVolumeGeometry, but couldn't succeed on using as ClassificationPrimitive. I was able to generate polygeometry with Round volume from samples for PolylineVolumeGeometry.

I'm able to generate polygon outline, but not able to generate its vertical volume. e.g.

var greenBox = viewer.entities.add({
    name : 'Green box with beveled corners and outline',
    polylineVolume : {
        positions : Cesium.Cartesian3.fromDegreesArray([
      -74.41453200422134, 40.93542704749751,
      -73.36827859024918, 40.9611033533233,
      -73.16152373946669, 41.38956253083078,
      -74.29436811233255, 41.54438381912347
        //shape : computeStar(7, 70, 50),
    shape :[
      new Cesium.Cartesian2(Cesium.Math.toDegrees(-74.41453200422134), Cesium.Math.toDegrees(40.93542704749751)),
      new Cesium.Cartesian2(Cesium.Math.toDegrees(-73.36827859024918), Cesium.Math.toDegrees(40.9611033533233)),
      new Cesium.Cartesian2(Cesium.Math.toDegrees(-73.16152373946669), Cesium.Math.toDegrees(41.38956253083078)),
      new Cesium.Cartesian2(Cesium.Math.toDegrees(-74.29436811233255), Cesium.Math.toDegrees(41.54438381912347))],
        material : Cesium.Color.GREEN.withAlpha(0.5),
        outline : true,
        outlineColor : Cesium.Color.BLACK

I'm sure I'm making some mistake in shape parameter.

Don’t use Cesium.Math.toDegrees. The Cartesian2 is an offset from the center potion from which to draw the shape.

shape : [new Cesium.Cartesian2(-50000, -50000),

new Cesium.Cartesian2(50000, -50000),

new Cesium.Cartesian2(50000, 50000),

new Cesium.Cartesian2(-50000, 50000)],


Hi Gabby Getz
Do you have any sample where any other geometry is being used in ClassificationPrimitive?

Example with boxes, ellipsoids, and spheres.

Example with polygons.

Additionally, you can search for “classification” in Sandcastle to get all the examples that use it.