The clippingPlanes problem

697 views
Skip to first unread message

MR.Klien

unread,
Apr 12, 2018, 6:00:00 AM4/12/18
to cesium-dev


os:win10(64)
chrome: 65.0.3325.181(64)
cesium:1.44

I used five planes 
 new Cesium.Plane(new Cesium.Cartesian3(1.0, 0.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(0.0, 1.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(0.0, -1.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(0.0, 0.0, -1.0), 0)

When I dug a hole in the tileset.The effect looks like this.



And then zoom in




The cut came out again.And I tried the new version of the ClippingPlane, used with ClippingPlane objects instead of Plane.But there will be new problems,The dynamic change of distance or normal ,tileset  doesn't change



Gabby Getz

unread,
Apr 12, 2018, 10:27:42 AM4/12/18
to cesium-dev
Hi there,

Can you provide your full code for setting up the clippingPlaneCollection? There's not enough info here to see what the problem is, and I think it has to do with the reference frame.

Thanks,
Gabby

MR.Klien

unread,
Apr 12, 2018, 9:01:10 PM4/12/18
to cesium-dev




 
var allClippingPlanes = [
                new Cesium.Plane(new Cesium.Cartesian3(1.0, 0.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(0.0, 1.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(0.0, -1.0, 0.0), 0),
                new Cesium.Plane(new Cesium.Cartesian3(0.0, 0.0, -1.0), 0)
            ];

var
midPoint = self.viewer.entities.add({
                        position
: midPosition,
                        point
: {
                            pixelSize
: 0
                       
}
                   
}); 
tileset.clippingPlanes = new Cesium.ClippingPlaneCollection({
                        modelMatrix : midPoint.computeModelMatrix(Cesium.JulianDate.now()),
                        planes : allClippingPlanes,
                        edgeWidth : 1.0,
                        edgeColor : Color.WHITE
                    });



在 2018年4月12日星期四 UTC+8下午10:27:42,Gabby Getz写道:

Gabby Getz

unread,
Apr 13, 2018, 4:35:25 PM4/13/18
to cesium-dev
Yes, I think the issue here is modelMatrix. You are providing a the transformation matrix relative to world space. 

If you remove it entirely, it should place the clipping planes relative to the tileset origin.

Otherwise, try Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center).

MR.Klien

unread,
Apr 15, 2018, 11:04:31 PM4/15/18
to cesium-dev
It's already used eastNorthUpToFixedFrame when I compute the plane's normal.The result of the graphic is correct

I guess if it is a problem with Multistage rendering?

The tileset is Tilt photography.There's a problem when I zoom in.However, it's good when I'm zooming out

在 2018年4月14日星期六 UTC+8上午4:35:25,Gabby Getz写道:
Message has been deleted

MR.Klien

unread,
Apr 16, 2018, 4:58:54 AM4/16/18
to cesium-dev



在 2018年4月16日星期一 UTC+8上午11:04:31,MR.Klien写道:

Gabby Getz

unread,
Apr 17, 2018, 9:37:49 AM4/17/18
to cesium-dev
Got it, thanks for the gif, that's a lot clearer. Looks like the clipping planes are not being correctly applied to the higher LOD tiles. Would you be able to post the tileset for us to take a look at?

MR.Klien

unread,
Apr 17, 2018, 10:49:22 PM4/17/18
to cesium-dev


The source file is too large, I cut part of it to upload.

tilesets demo







在 2018年4月17日星期二 UTC+8下午9:37:49,Gabby Getz写道:

MR.Klien

unread,
Apr 20, 2018, 3:45:45 AM4/20/18
to cesium-dev


Sometimes this happens





在 2018年4月18日星期三 UTC+8上午10:49:22,MR.Klien写道:

Sean Lilley

unread,
Apr 22, 2018, 4:18:02 PM4/22/18
to cesium-dev
I started to look into this but could use some help in recreating the problem. Do you have the latest clipping planes code from your gif above? I also want to make sure the tileset you sent is the correct area. I attached a screenshot of what I see.
snippet.PNG

MR.Klien

unread,
Apr 22, 2018, 10:07:42 PM4/22/18
to cesium-dev
var scratchPlane = new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0);
function createPlaneUpdateFunction(plane, transform) {
   
return function () {
        plane
.distance = targetY;
       
return Cesium.Plane.transform(plane, transform, scratchPlane);
   
};
}


var tileset;
function loadTileset(url) {
   
var clippingPlanes = [
       
new Cesium.Plane(new Cesium.Cartesian3(0.0, -1,0.0), -10.0)
   
];


    tileset
= viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
        url
: "../../../data/Tileset/Tileset1/tileset.json",
        clippingPlanes
: new Cesium.ClippingPlaneCollection({
            planes
: clippingPlanes,
            edgeWidth
: viewModel.edgeStylingEnabled ? 1.0 : 0.0
       
})
   
}));


    tileset
.debugShowBoundingVolume = viewModel.debugBoundingVolumesEnabled;
   
return tileset.readyPromise.then(function() {
       
var boundingSphere = tileset.boundingSphere;
       
var radius = boundingSphere.radius;


       
// viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.5, -0.2, radius * 4.0));
          tileset
.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(boundingSphere.center);
          tileset
.readyPromise.then(function() {
                   
var boundingSphere = tileset.boundingSphere;
                    viewer
.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius * 2));
                    viewer
.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
           
});
       


       
for (var i = 0; i < clippingPlanes.length; ++i) {
           
var plane = clippingPlanes[i];
           
var planeEntity = viewer.entities.add({
                position
: boundingSphere.center,
                plane
: {
                    dimensions
: new Cesium.Cartesian2(radius * 2.5, radius * 2.5),
                    material
: Cesium.Color.WHITE.withAlpha(0.1),
                    plane
: new Cesium.CallbackProperty(createPlaneUpdateFunction(plane, tileset.modelMatrix), false),
                    outline
: true,
                    outlineColor
: Cesium.Color.WHITE
               
}
           
});


            planeEntities
.push(planeEntity);
       
}
       
return tileset;
   
}).otherwise(function(error) {
        console
.log(error);
   
});
}


The Plane situation


Then I replace Plane with clippingPlane


You need to pull far and try several times



在 2018年4月23日星期一 UTC+8上午4:18:02,Sean Lilley写道:

Sean Lilley

unread,
Apr 23, 2018, 9:01:22 PM4/23/18
to cesium-dev
Thanks - I was able to confirm this is a bug. I opened an issue here: https://github.com/AnalyticalGraphicsInc/cesium/issues/6484.

Sean Lilley

unread,
Apr 24, 2018, 8:09:42 PM4/24/18
to cesium-dev
Thanks again, this was fixed in https://github.com/AnalyticalGraphicsInc/cesium/pull/6486 and will be shipped with Cesium 1.45 on May 1st.

MR.Klien

unread,
May 4, 2018, 5:17:30 AM5/4/18
to cesium-dev

Thanks,I updated the code, the problem with the cutting function is OK,But sometimes still this error occurs





在 2018年4月25日星期三 UTC+8上午8:09:42,Sean Lilley写道:

Sean Lilley

unread,
May 5, 2018, 8:15:30 PM5/5/18
to cesium-dev
Ah sorry we didn't catch that one - I opened an issue on Github for fixing it: https://github.com/AnalyticalGraphicsInc/cesium/issues/6566.

Sean Lilley

unread,
May 9, 2018, 12:53:51 PM5/9/18
to cesium-dev
MR.Klien - would you be able to test our fix? The changes are in https://github.com/AnalyticalGraphicsInc/cesium/pull/6576 and I've uploaded a Cesium build here: https://drive.google.com/open?id=1ieZ3NlgIA6OMGwXZWZCoWfHNhsj0k1z5.

MR.Klien

unread,
May 15, 2018, 1:53:50 AM5/15/18
to cesium-dev



I used this zip, but there is another problem……




在 2018年5月10日星期四 UTC+8上午12:53:51,Sean Lilley写道:

Sean Lilley

unread,
May 17, 2018, 1:47:53 PM5/17/18
to cesium-dev
Thanks, we'll look into it.

Kangning Li

unread,
May 17, 2018, 3:02:23 PM5/17/18
to cesium-dev
MR.Klein - does the crash happen immediately when the app loads or only after zooming in/out and moving the clipping planes around?

Also, are you able to reproduce this crash with any of the tilesets that we have in Sandcastle? Or are you able to share any other tilesets that have this problem?

Thanks!

MR.Klien

unread,
May 23, 2018, 5:40:16 AM5/23/18
to cesium-dev
you can use http://localhost:8081/Apps/Sandcastle/index.html?src=3D%20Tiles%20Photogrammetry.html&label=All

js code:
var viewer = new Cesium.Viewer('cesiumContainer');


var tileset = new Cesium.Cesium3DTileset({
    url
: Cesium.IonResource.fromAssetId(3836)
});


viewer
.scene.primitives.add(tileset);
viewer
.zoomTo(tileset);


tileset
.readyPromise.then(function(tileset) {
     
var clippingPlanes = [
               
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, -1.0, 0), -100.0)
           
];
       tileset
.clippingPlanes =  new Cesium.ClippingPlaneCollection({
            planes
: clippingPlanes,
            edgeWidth
:1
       
});
});


document
.getElementById("removeClip").addEventListener('click',function(){
    tileset
.clippingPlanes.removeAll();
});
document
.getElementById("addClip").addEventListener('click',function(){
     
var clippingPlanes = [
               
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, -1.0, 0), -100.0)
           
];
       tileset
.clippingPlanes =  new Cesium.ClippingPlaneCollection({
            planes
: clippingPlanes,
            edgeWidth
:1
       
});
});


html code:


<style>
   
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"> <button id="removeClip" style="position:'absolute';top:140px;left:40px;">remove</button>
<button id="addClip"  style="position:'absolute';top:140px;left:60px;">add</button></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>





first remove,and then add.

This problem arises when you zoom in and out






在 2018年5月18日星期五 UTC+8上午3:02:23,Kangning Li写道:

Kangning Li

unread,
May 23, 2018, 12:13:36 PM5/23/18
to cesium-dev
Awesome, got the same error. Thanks MR.Klein, this is super helpful!

Kangning Li

unread,
May 23, 2018, 1:13:24 PM5/23/18
to cesium-dev
Hi MR.Klein,

I'm working on a bugfix now that I know what's happening, but in the meantime you might be able to work around the behavior in your app.
Instead of creating a new ClippingPlaneCollection when you need to add planes you can also use "tileset.clippingPlanes.add."
There's also a "remove" function that might be helpful. Check out the documentation here: https://cesiumjs.org/Cesium/Build/Documentation/ClippingPlaneCollection.html

MR.Klien

unread,
May 24, 2018, 4:27:21 AM5/24/18
to cesium-dev
When I use Plane of 1.44 instead of ClippingPlane,The effect I expect is good


But after I used ClippingPlane of 1.45, the result is wrong





在 2018年5月24日星期四 UTC+8上午1:13:24,Kangning Li写道:

Kangning Li

unread,
May 24, 2018, 10:43:10 AM5/24/18
to cesium-dev
Ah right sorry... 1.45 is also missing some other bugfixes for clipping planes. This problem should be fixed in master, and the crash problem should be fixed soon too.

MR.Klien

unread,
May 24, 2018, 8:59:30 PM5/24/18
to cesium-dev
Thank you for your reply. I will try again when the new version is released 

在 2018年5月24日星期四 UTC+8下午10:43:10,Kangning Li写道:

Sean Lilley

unread,
May 25, 2018, 2:16:02 PM5/25/18
to cesium-dev
The clipping plane crash fix was just merged, and will be in Cesium 1.46.

I wonder if clipping problem you just posted is related to https://github.com/AnalyticalGraphicsInc/cesium/issues/6600.

If you are able to upload that tileset as well it will be helpful for debugging.
Reply all
Reply to author
Forward
0 new messages