Want to use Polygon as ClassificationPrimitive

202 views
Skip to first unread message

swapn...@gmail.com

unread,
Apr 26, 2018, 7:44:17 AM4/26/18
to cesium-dev
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(
Cesium.Cartesian3.fromDegreesArray([
-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);
/*Cesium.BoxGeometry.fromDimensions({
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
}));

Gabby Getz

unread,
Apr 27, 2018, 9:51:33 AM4/27/18
to cesium-dev
Hi there,

The documentation for ClassificationPrimitive lists the supported geometry types:

Valid geometries are BoxGeometryCylinderGeometryEllipsoidGeometryPolylineVolumeGeometry, and SphereGeometry.

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

Thanks!
Gabby

swapn...@gmail.com

unread,
Apr 29, 2018, 10:38:29 AM4/29/18
to cesium-dev
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.

Gabby Getz

unread,
May 1, 2018, 1:27:40 PM5/1/18
to cesium-dev
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)],

swapn...@gmail.com

unread,
May 24, 2018, 10:10:41 AM5/24/18
to cesium-dev
Hi Gabby Getz
Do you have any sample where any other geometry is being used in ClassificationPrimitive?

Gabby Getz

unread,
May 25, 2018, 9:39:33 AM5/25/18
to cesium-dev
Example with boxes, ellipsoids, and spheres.


Additionally, you can search for "classification" in Sandcastle to get all the examples that use it.
Reply all
Reply to author
Forward
0 new messages