cesium
cesium copied to clipboard
subsequent pickPosition returns wrong value (depth?)
Firstly, this issue is hard to reproduce, that's why I provide images below.
In my application, when the user clicks a point cloud point, we want to find the point closest to the camera within a certain screen environment (env
currently set to 4). So this is not about hitting any point cloud point within that screen rect, but the closest one. This function we named pickPoint
calls Cesium's viewer.scene.pickPosition()
.
However, sometimes*, pickPoint
returns a position that is too close to the camera, where actually no point cloud is.
The sandcastle implements 2 kinds of picking:
- "massive pick" (see toolbar) that invokes
pickPoint
all over the screen for every 20 pixel. Might take a minute or longer. - "diagonal pick" (double left click) that picks at the clicked position and then goes down-right for the next 100 pixel and invokes
pickPoint
there. Might take a few seconds.
In pickPoint
, some point entites are created at the positions that were successfully picked. A yellow point means that this position was picked at the very first; a blue point means this position was picked subsequently in the loop to pick around the given screen environment env
.
When the bug happens:
- "massive pick": you will see that the yellow point is always at the correct position, and the blue points never are. The blue points are closer to the camera, it seems that all by the same amount. See the images below, it's like the point cloud would exist a second time.
- "diagonal pick": The very first pick seems to be correct, and there are also some blue points at the correct position, but all other picks are wrong in the diagonal line, doesn't matter if yellow or blue, see the image and GIF below.
What I think could be wrong:
Since the first pick seems to be right and subsequent picks that are close to the first one aren't, I think this could be something about the picking cache, or maybe the depth buffer gets interpreted wrongly (logarithmic vs. linear). But this is just my intuition, I have no idea about the Cesium code. Since it's unreliable to reproduce, it might also be a race condition somewhere.
* sometimes: Happens very often on certain point clouds, sometimes on meshes, and almost never on certain other point clouds. We cannot find any difference in the point clouds that would make them special to this bug. The point cloud which has this bug quite often is also used in the sandcastle, and it also sometimes shows this error in the sandcastle, too. First I thought that attenuation
might play a role, or the density of the point cloud, or that the point cloud is still loading, or that the globe is still loading, or just overall "busyness" of the browser. But nothing could reliably increase the chance of causing this bug.
Images: massive pick
It's as if the point cloud exists twice, but closer to the camera position. Easy to spot at the wall ("line") and the tree structures.
(the red and green circles on some images were picked using debugPickPosition
on the point cloud when the inspector widget was initialized)
Initial position after massive pick:
Shown from above:
Even the globe gets picked wrongly:
From the ground:
Images: diagonal pick
Showing the same diagonal pick from different angles.
Inital Position:
Zooming in:
You can clearly see that the diagonal line is in shape as the vegetation in front of the wall, but only the first few picks are correctly on the wall.
Sandcastle example:
https://sandcastle.cesium.com/#c=rVj7c9o4EP5XdPnhalpi/OCZR3sJIS1pQnIJbS+dzHSELYLASJwtB9y7/O+3sjDYxqT07pgMsVe7K+1D3ydRqaD3PmYCtUlAw+nFHcKOQ4IACY4iHvqIcoZwEBARPDClo3c5010yxKEnTmLlPp8Qho7Rwx6JLkaD9w69phfdT9+7Zo92gy67rTntbr07mf3xuX3R0kHpT/f9BJS6Rm96O7kad7/fU2NxP72yL/u346/TK3Hd/0y/UsP+Ov48ufp+Tnvjk2qv36GX7YvZV3DWG39a9PonQXfqjVx4v+rfR9f9x1rvbGL1mKF7xox3vnytPy2i749R+/fJxaR6s39PeUP8fiPm9kd/UL87N/f/GHcf9g4f2ANzOAsEeqJkTnyIhZH5Mif651imPew58XubM4EpI/7DXulQ2XGP6B5/1JS1HjiExQLsUzGaUueMzMToNBwOif+iyYw6kz6UI/BCeBexWSleXaWCTlx3uSLUZcGMOIL78cDSBVkIwlxtuWglVC/2WZ96JFhZXdEFZcrvMGSOkDX2CdS4jafEx1oJ/fXAEHyWnp1YrM94QGPdTHba2BfwhJmt1e1G06zW9FatYdXrZtUuI0tvNpq1WqNqNhrNar1qWWXU0M160zYNyzIaDdtqWHIpm9O51CfOi/PtG7pRByeGVTdaZgOcVsvI0Ks1y4ZZ7VqrZRg2TF5GoNlstuq1JvxVa2at0TKLJw1nW2cz9FaraTTMRtOyq5ZptWpyMsNqmnbNrjbqLbsBM7fiyYxaDQKzm9VG1a6ZMGnxbD59HIkXJjTkx6yaraYF8TVrzVbVqNZVOC3Thuw1m6ZlN1rNWiyswqx1s2VYZrUJybDlrM+yzHeYuQ4OBDQddt0+594A+6ehEJxpcmGvfDLlTwRB00GJSfCqLKWp5pCjneXgRn8kVrrSO/E8TcULc6s222F+aD+k0qImTzVk4m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AUL+gULiBKCTCA+pxNYR0lyX7gMO6H1UynOCCAv5COkRCz4KBSgfw6Ezhh+UOPz3WHTysxP0G4QcWWx9xWxeN8Bli9T9k+3lcLVA4lty5ibl2/R7l3N6/gSo198zAHAnjRBTkEgF7L7zTLozzNS2V4evMms2My+1GX06p9C49v0OJwm2K0VoxAMcrUdYkgRbCROMjDR/HVoZRGwxgWNs4hUJ4h9ZeAJbtBSBaWyUdz6nloQFBEPKhSGWF4DcJBIM8STKyGB15I8ofTTRSxdoGRl6EkBydQmmMoDnqH6ugAWeVigyzArG0ssDFftllCztomAyn3ncvL6y8oBzSnl586W7z+PC79L9hUhE87YlQpD3P5s+mPAcjKmmTNc534uqiL4rb8Cf7M+kio8Cco8L9S4W59nOvlanm7WraDrR9rFlHl+9tOp/eC6b9rzv+tQbc16e5kujuJbiHTnyfVjctYQrEFA7IRFzGQROjvv+XzEUDKr78iJdyPSkvx27TYBPlGc0q2OgaGy60iprx9N8qLI0Vw2cvj+iWSF8iM1SKWLNLHZvkFdL7ahHCPYXczuGd1niBPHzBzPSmHex2bheIkvjloqysEZ2c8hBZpy9NCfEmKzw2x7cN68604lynOZZAi05APOcpNXZ2zscJlbe159ftDzMQs1wBRsWqUU01fyJ93uleDxa6f1S/pd7mE9qMZ0S875/1vZ9efTi8739qX3fZH6X2vvHcUiMgjb5M1/kan8uojr9yarlcEmcIFGLZHZRDCCVPoThAkARxV0qZHLn1C1D0u+D0bUoODAEaGoRcD1MPe26MK6G+YehzD8fDxGk5yHo6k2sh8e6mEuq4fVeC12FKoH+1ynv8B
Browser: Chrome, Firefox
Operating System: Windows 10, Ubuntu