Normal vector for clipping plane is not vertical from the ground


I have a problem on giving the modelMatrix to the clipping plane.
It should be clipped along with the green line but it is tilted as shown below.


I have a sandcastle replicated the issue but not completely as I cannot share the dataset.

In sandcastle, it does not seem tilted because it is 3d model tileset but when you do it on point cloud tileset, you should the issue.

This topic is related to this.

I also noticed that when trying to come up with the answer in the other thread. Here is a sandcastle where I inserted the relevant coordinate system axes (red, green and blue) for debugging:

It can be seen that the alignment is just a little off:

But I haven’t found the reason (or a solution) for that yet.

Maybe someone from the CesiumJS core team can have a look or has an idea here. For those who want to take a look: Here is a simplified sandcastle

It has comments, sensible variable names, and focusses on the actual question, which might make it easier to find a solution.

1 Like

Thanks for simplifying the problem. I hope CesiumJS core team can help us as well.

Thanks @sean_lilley for the solution: The computation of the angle between the (local) y-Axis of the plane and the UNIT_Z axis was wrong. It should have been the angle between the y-Axis and the projection of the UNIT_Z axis on the plane.

Here is the simplified sandcastle, with this change being applied:

The result is indeed the plane being properly aligned with the horizon:

The computation of the orientation is commented, and it should be possible to apply that more or less directly to the Sandcastle that you posted, near the line

const angle1 = Cesium.Cartesian3.angleBetween(ellipsoidNormal, Cesium.Cartesian3.UNIT_Z);

I did a quick check by inserting this solution in your Sandcastle here:

but there are some computations that could be omitted now, or simplified, or optimized, or moved into own function - this is only to show that this should solve the issue in general.

1 Like