Clipping polygons precision on Terrain and 3D Tiles
What happened?
In this clipping example on cesium sandcastle, try to draw a polygon in parking lot for a vehicle. The cut area is far away from the actual drawn feature.
Reproduction steps
- Go to https://sandcastle.cesium.com/?src=Clipping%20Regions.html
- Zoom in parking area, Draw a polygon for vehicle space in parking area
- the area getting clipped is a different area than the actual drawn polygon.
Sandcastle example
No response
Environment
Browser: Chrome CesiumJS Version: 1.123 Operating System: Windows 11
this is happening to me using point cloud 3D tiles as well. The actual clipped area is quite a bit smaller than the polygon (rectangle) that is being applied and has inconsistent and jagged edges. It seems to be more chaotic / less accurate if the clipping polygons are smaller. Clipping polygons with larger areas tend to be more accurate.
Browser: Chrome CesiumJS Version: 1.123.1 Operating System: Mac OS
Thanks for the input @saadatali48 and @jjrise. Clipping polygons were designed around global tilesets such as Google Photorealistic 3D Tiles. As such, they are computed in coordinate system suitable for a global reference frame. I think the solution here would be to localize the coordinate system to the tileset for better accuracy.
Hi @ggetz, The above image is from clipping example on cesium sandcastle on terrain and Google 3D Tileset. When we draw a polygon for clipping, the coordinates are cartesian using default 4326 Ellispoid. How can we improve the accuracy of cut area in this case.
I have noticed if polygon is small, then accuracy is really distorted, for relatively larger polygons it becomes a bit better, but still we can clearly see that the corners are not getting cut as per the polygon, some part of the basemap image is coming inside the cut area. as shown in attached image.
@saadatali48 figure anything out here? I'm still wrestling with the same thing...
Also reported in https://github.com/CesiumGS/cesium/issues/12416.
Also reported in https://github.com/CesiumGS/cesium/issues/12096.
Also reported in https://github.com/CesiumGS/cesium/issues/12174.
Also reported in #12649.
@saadatali48 Try adjusting the polygon points WGS height to the terrain - it is not perfect but it improves the precision quiet a bit. EG.: sandcastle-with-adjusted-clipping changed code:
const positionsCarto = [
[-105.0077102972673, 39.75198671798765],
...
].map(p => new Cesium.Cartographic(
Cesium.Math.toRadians(p[0]), Cesium.Math.toRadians(p[1]), 0
));
const { WGS84 } = Cesium.Ellipsoid;
const positionsAdjustedToTerrain = await Cesium.sampleTerrainMostDetailed(
scene.terrainProvider, positionsCarto
);
// Add a clipping region covering total lot
const polygons = [
new Cesium.ClippingPolygon({
positions: WGS84.cartographicArrayToCartesianArray(positionsAdjustedToTerrain)
}),
];
Also @ggetz another issue we noticed, that I suspect is related to this - when having multiple clippings far apart the distortion (especially in the corners) gets much worse. sandcastle
one clipping:
two clippings:
Also reported in https://github.com/CesiumGS/cesium/issues/12649.
- From https://sandcastle.cesium.com/?src=AEC%20Clipping.html:
