# clipping plan on 3dtileset problem

When you click two point on viewer, the globe will be dug a hole. In my case, I want to dig a hole on 3dtileset, too. But in the follow code, 3dtileset didn’t work, how should I do?

code url

This is because clipping planes are relative to the root tile’s transform. This is described on the documentation page:

https://cesiumjs.org/Cesium/Build/Documentation/ClippingPlaneCollection.html?classFilter=Clippin

So for example, if you set the the clipping plane at (0,0,0), with a normal facing in the positive X axis, it would clip half the tileset (wheras the same plane would clip half the globe). The easiest way to get a plane to clip a tileset and the globe in the same location is to add a modelMatrix to the ClippingPlaneCollection on the tileset to reverse this transformation to make its coordinate relative to the center of the earth:

tileset.clippingPlanes = new Cesium.ClippingPlaneCollection({
planes : clippingPlanes,
edgeColor: Cesium.Color.WHITE,
modelMatrix: Cesium.Matrix4.inverse(tileset.root.computedTransform, new Cesium.Matrix4())
});

``

You might also want to use viewer.camera.pickEllipsoid instead of pickPosition to get more accurate results when not using terrain.

Hello,

I have been trying to adapt this sandcastle so that the user can draw the hole as a polygon and therefore cut the 3Dtileset in any shape he wants, but I can't get it to work. I've only changed the "hole" function.

Is this because clipping planes are not supported (except for rectangles and triangles) ?

Many thanks for your response, I'm really stucked on this one!

Hello World.html (4.04 KB)

I think it just might be that that original example was computing the planes based on the assumption that it will always describe a rectangle. You can certainly have a combination of many clipping planes to describe more arbitrary shapes. Here’s a Sandcastle example showing this:

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=development%2FMany%20Clipping%20Planes.html&label=Development

You might also find this thread useful which was doing a similar thing, clipping planes made out of arbitrary polygons: