Normal vector for clipping plane is not vertical from the ground

Hi,

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.

image

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.

https://sandcastle.cesium.com/#c=5Vlrb9u2Gv4rPPkkYy6tmy9Ks56TJu4aoE18EnfFNheDItE2MZoUSCpp1vm/jxR1l7z4FNsBhiWFXV6f573yJRMxKiR4wOgRcfAtoOgRXCCB0x38PuuzVidR1r5gVIaYIr46GYIvKwqARJyrngVnDzhG/LRYGHEUSvSRcRIvzRRrMFzR/eDlikYZnIgQRQrNwMKsqQZXFK+B9a+sCSMS7pIle4vwZivv0iRhXKJ4YKAfMY3ZIwwJ4tLSHQCsTpZbLMA9Z49CiRIzJABlCsssBY393jMhL5GSh6AYrk70DprdXnMwFKUaEkgqkoZOwvEOS/yABAzjOMOs6cp8eZdLs8r6YjilnJRauWL0FgmW8gjBNWe7c6EmXsWWb88mE60fAPaDFR1keshVEO4QD6Gap21hNo2RkJiGEjN62mAQKvUIHFIv14fjOhPfcaA99WfTaeBO/KEZeOFPvYnneNBRQ9PxzMv7FRHHGwdw7Ljj8cSZun6mlmyUcYyU+Tuob1EYY7pZYBltbxkhObYPXS8I3LFje+PJzJvMCmgb+oHjuIE38/yZ7Sr4fGQC3Wkw8wM3cO3ZbDypYSMaL3lIxZrxXanN96Hk+LMPry7n18ur5Q+Ff63oXUjjKBSSIG2oJWPkPuSvUykZVb58p5yAILDNvEBoV16nNNJyASv3LZFNMX4irMwt9Ee3W/+WqxXWgoQUzanE8smKCnM4Q1D+3x0WbvVzjkWUhxEVVN+jSHlax5RQpPeSh5G06nvU9+73gIGmB3r2o0qHIcG/IitHVWHGKFLxWdAwggFgogARghPBcHydLaw4zosB+PG7u5kPN4jFSOLoLuXrMEJmunUkU41XYSZajWaDS8yRUW+fciLOhCgEGba5PqObDlYvRKWvPlbPQDTFUjloyxb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/VF9nZquX4Jtv8KDw5/wau16bRzkMRsDsAl6AvEYENbSf8KfeYpMgnpTe1+MytRq09KIMs2weuC2YYUNkb9SSPeKZfnjw9bGqekW+B5RbdS2unqWypSi+qOZVMX6k8vRPX0Zp5IpaKLURlTYbYV7e2VvpBgAexhgfepi0oasPSfMxaNVpB3LO7fyyMXFfa+0Lu5cqP0LQhJEn/WbUol5IL3rEbxAIebR8SlBJ89y04fXN9bwx8dEUhO6BzFrPkTmlm1Tqr/f5nAVnCeIqzbd0HPWUlCY1NzXV1HCMErl9o3zu/ddQaDL40i6xj6SU2am/4q/sWlq16Gg/rXa80/407PHZTo8KfrqR2xfOp/IdtoDa56//J8OTMyGfCHpVgP8H77I/H6ScWBCOJFKHg1KOGN2n0S9IwkiIYpOzUX3pWYwfAI6/7fn7iSYrhBpZp4Tc4V/R6uTV2UjN7ywlLHtfv1F3cBI+6Wlb59U70wkhPBupZv9KaR6+Wzv/Dg

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