ClippingPlanes not working with a Polygon

Hi,

I’m trying to set a clippingPlanes on the globe based on this sample :

It works properly with a box

but when I try it with a polygon instead, it doesn’t work.
image

The polygonEntity.computeModelMatrix(Cesium.JulianDate.now()) returns undefined, while it returns an object for the Box

I’m not sure to understand well and the reason why, but the clippingPlane doesn’t seem to work with the polygon. Can anybody help me with this issue?

//Working fine
boxEntity = viewer.entities.add({
position: cartesianPosition,
box: {
dimensions: new Cesium.Cartesian3(1400.0, 1400.0, 2800.0),
material: Cesium.Color.WHITE.withAlpha(0.3),
},
});
globe.clippingPlanes = new Cesium.ClippingPlaneCollection({
modelMatrix: entity.computeModelMatrix(Cesium.JulianDate.now()),
planes: [
new Cesium.ClippingPlane(new Cesium.Cartesian3(1.0, 0.0, 0.0),-700.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0.0),-700.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 1.0, 0.0),-700.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, -1.0, 0.0),-700.0),
],
edgeWidth: 0,
edgeColor: Cesium.Color.WHITE,
enabled: true,
});

//Not working
polygonEntity = viewer.entities.add({
polygon: {
hierarchy: polygon.positions,
material: Cesium.Color.WHITE.withAlpha(0.3),
extrudedHeight:1000,
},
});
globe.clippingPlanes = new Cesium.ClippingPlaneCollection({
modelMatrix: polygonEntity.computeModelMatrix(Cesium.JulianDate.now()),
planes: polygonPlanes,
edgeWidth: 0,
edgeColor: Cesium.Color.WHITE,
enabled: true,
});

Thank you in advance for your help.

My main question is: How can I use a polygon entity instead of a box entity to calculate the planes and cut a specific region of the globe using ClippingPlanes?

1 Like