暂时不支持凹多边形、多个裁切的
Q1 Multiple ClippingPlaneCollections for concave clipping polygons
https://community.cesium.com/t/multiple-clippingplanecollections-for-concave-clipping-polygons/6479
Hi everyone
I find that clipping planes for globe and models can only cut a convex area.
What if I have a concave shape to clip?
My solution is to apply multiple clippingPlaneCollections.
So that I can triangulate the concave shape into triangles first, and then clip the area triangle by triangle with multiple clippingPlaneCollections.
However, modifying the source code is a little bit hard for me.
Can any help me with the idea?
Thanks
Chris
A1 Currently its not possible to have multiple clippingPlane 1Collections.
Hi,
Currently its not possible to have multiple multiple clippingPlane Collections. We have started some work on clipping volumes, which you would be able to have multiples of per tileset, and either use a concave ro convex mode. Keep and eye out for that feature.
You can also try setting clippingPlaneCollection.unionClippingRegions 8 to false, which will clip all regions outside any clipping plane.
Thanks,
Gabby
Q2 How to clipping multiple Polygon on the Cesium3DTileset?
https://community.cesium.com/t/how-to-clipping-multiple-polygon-on-the-cesium3dtileset/9182
- A concise explanation of the problem you’re experiencing.
I want to clipping multiple Polygon on Cesium3DTileset, but now I can only clipping one. - A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: tiles.url,
clippingPlanes: [
new Cesium.ClippingPlaneCollection({ // clipping one Polygon
planes: [
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 1.0, 0.0), 1.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, -1.0, 0.0), -1.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), 1.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), -1.0)
],
unionClippingRegions: false,
}),
new Cesium.ClippingPlaneCollection({ // clipping two Polygon
planes: [
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 1.0, 0.0), 2.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, -1.0, 0.0), -2.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), 2.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), -2.0)
],
unionClippingRegions: false,
})
]
}));
- Context. Why do you need to do this? We might know a better way to accomplish your goal.
I want to clip multiple polygons in Cesium3DTileset,Used to display the pipeline model below. - The Cesium version you’re using, your operating system and browser.
1.66
A2 It isn’t currently possible to add multiple clipping planes to one tileset
It isn’t currently possible to add multiple clipping planes to one tileset, but we’ve got a feature request for this here: https://github.com/CesiumGS/cesium/issues/8751 35.
Q3 Add support for concave /convex clipping planes + holes in CesiumJS
https://github.com/CesiumGS/cesium/issues/8751
https://community.cesium.com/t/multiple-clippingplanes/11809
The user should be able to define a 2D clipping polygon with zero or more holes.
We should support:
Multiple clipping planes
Multiple holes in each clipping plane
Overlapping holes
We should disallow:
Self-intersecting polygons / holes
Holes that extend beyond the region of their parent clipping plane.
A3 I urgently need multiple clipping on the globe!. Here is a simple effect I achieved.
These files are modified: GlobeSurfaceShaderSet.js, GlobeSurfaceTileProvieder.js, Globe.js, GlobeVS.glsl.
New files are created: MultiClippingPlaneCollection.js, getMultiClippingFunction.js.
files.zip
You can now clip multiple polygons on the globe by passing an instance of MultiClippingPlaneCollection which manages a list of ClippingPlaneCollection to the multiClippingPlanes property new added to the globe.
For example:
var clippingPlanecollection1 = new Cesium.ClippingPlaneCollection({
planes: [
new Cesium.ClippingPlane(new Cesium.Cartesian3(1.0, 0.0, 0.0), 0.0),
new Cesium.ClippingPlane(
new Cesium.Cartesian3(-1.0, 0.0, 0.0),
-500.0
),
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 1.0, 0.0), -15.0),
new Cesium.ClippingPlane(
new Cesium.Cartesian3(0.0, -1.0, 0.0),
-15.0
),
],
});
var clippingPlanecollection2 = new Cesium.ClippingPlaneCollection({
planes: [
new Cesium.ClippingPlane(new Cesium.Cartesian3(1.0, 0.0, 0.0), 1000),
new Cesium.ClippingPlane(
new Cesium.Cartesian3(-1.0, 0.0, 0.0),
-2000.0
),
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 1.0, 0.0), -15.0),
new Cesium.ClippingPlane(
new Cesium.Cartesian3(0.0, -1.0, 0.0),
-15.0
),
],
});
globe.multiClippingPlanes = new Cesium.MultiClippingPlaneCollection({
collections: [clippingPlanecollection1, clippingPlanecollection2],
modelMatrix: entity.computeModelMatrix(Cesium.JulianDate.now()),
edgeWidth: 1,
edgeColor: Cesium.Color.WHITE,
});
The key point is to rewrite the orginal getClippingFunction.js to getMultiClippingFunction.js to make the fragment shader able to handle multiple clipping plane collections. The shader also needs to know the length of every collection so it can get the correct clipping plane.
This is only a temporary solution on multi-clipping on terrain, more problems to be solved:
-
Different styles and model matrix on each ClippingPlaneCollection
are not supportive. They’re set on the ClippingPlaneCollection and
are the same for each collection. -
It dosen’t support concave polygon
directly. But you could try decomposing the polygon into convex
polygons. The star below is actually two triangles. -
It only works on the globe terrain with every ClippingPlaneCollection’s
unionClippingRegions set to false. -
I didn’t rewrite the union function. Clipping on 3dtiles and models is out of scope, but I
think the concept is similar. -
There might be bugs. : P
Hope this feautre will come out soon!