CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.01k stars 3.51k forks source link

`scene.pickPosition` cannot accurately pick the correct position in underground mode. #12268

Open wumanho opened 3 weeks ago

wumanho commented 3 weeks ago

What happened?

When I try to enable underground mode based on a Sandcastle example, I find that using pickPosition in events such as Cesium.ScreenSpaceEventType.MOUSE_MOVE and Cesium.ScreenSpaceEventType.LEFT_CLICK does not return the correct latitude and longitude coordinates.

And if set the option viewer.scene.pickTranslucentDepth = true, pickPosition seems to work correctly, but rotating the camera view results in a render error. image

Please refer to the Sandcastle example I provide below for the reproduction. Thank you.

Reproduction steps

  1. set scene.globe.translucency.enabled = true
  2. create a mouse event handler like Cesium.ScreenSpaceEventType.MOUSE_MOVE

Sandcastle example

https://sandcastle.cesium.com/index.html#c=tVj7c9vGEf5XWPUHUzPU6XAP3B2tOLVlpfbUsjyR4kym6nRAAhIxBgEOAEpmM/7f++3hQRJU0jhN/BgC99j3fruLeZFX9eghTR6TcvTNKE8eR+dJla6X7KNfG98ezf37eZHXUZon5e3RZPTzbT4a1UlZYmXaXbhp3tldWSx/LMosbhfGx5Pb/Mvx89v8Nj89bXmxap7kCVul8083ZZRX2Rrv9etkVS8gRl2uk9t87mVbRHmcDYW7npdJkl+vonly8YCLb5pD4z3i8yh/iKrj27wlwaqkfpuv1vXLeZ0W+XicHH/zwqvScFoVVUobYHUg5Id2b5ywJI+7t+Pt5fsyWi3SOe62Ip5HZV20q94mtICtKB+vDq9nUb29ehnVC1YXr5N7aFmNOyI4k9brONm9lt//72tFfj+8t0jS+wVx7A41C92BIktw7X7crE6eNb/PQODL5Bc8cLNZJezy6ofri39fXn28OCZvN7y8EQc2fd5t3mfFjDYbS/s3HyjNe7Vlch4tkzKiKCyLjJyZ5NEsS87xklaw5eukTuat9+6irCIynhyr+/iab8gRef0d6L3MVovo1eZ1WtVRPk/2w+t9EpXfReX1PMoipACsojhnfEJP3a/tVwL/2wR465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FbN/VhunPctydg8TnteO3MiozDfo7If9893u77fcBhO7jzrGQ2+R9EnDPoKRd/WGhyJk6pO86gZjHdAaNtGtrOpxJCkQs1Qy1AN0G11CH2CPgTFB1MH4FSFONbhpqa2wRqGgqtD9HgN6jWQUpQpMu6Q7xuM+0itD2k9X3xfZFnHnaF1xJjItaZybXTXe50ABmgYo08cyqCyhx3mhkxgGDPohKhlEO0g1HBP8th/9UOmLqc7QVamnxV7+/ri/c3bm5+20PaUFe+yzU3x9TZETwWJNfV/6OG2JtTooNFko+CjiaCWpTMhumBlGKYozFKYff8fE6I2K0ENHo2HmIm3JhTUyaFi0byMcdyIXRsa3yWicbdK7rCP12XLu/kOBVuNjiZHZ1W9yZIXXaH5W7pcFaX/6DNm7LROlqsM4VmdztbzT0nN5lXVIAP9+WsHzz9vh7wZkPy+LTvl/SwaK3TB3X/O7PY2EgWDEjSfjtTq887yrCjjpDwpYZZ1tb/55YB1Sh9odwV4ACZjiMtOoiy9h7bLNI6z5JDrSV2sUGL3OHdbs6Kui+X+7iFrtoDnkj3t7wBAJ49+bptCjyweXj873bX3WZw+jNL4myc+mjejKnbu1ll2nf4nuT16cXaK8wdXs8LHzxUUz6INHVsEL941i4yxs1O8Pn2zr5y9+89qqhIvtgqd1bMi3uws0FK5904r8YubHSAetcXo7BQbh0f3V7DW+LDGyE2WWCTzT7PiM0wAYIxOZije3XLTixwUtR0FWopDxlgof4MS38Gfo9lmFLdF4U9RYFB3/ijZr6nYPPji4vn+KbLvF7A/THZfr3+XwAiGe9gQWZ7jDchGz9FnPAf+uaqTld8IBio9UD/Q1vjJyL/94CvxdPTMc3h2oN2Qd518rokFkhNv+lcYfLWh8LqXd3jfSczdbP4v

Environment

Browser: Chrome 120.0.6099.200 & Edge 118.0.2088.76 CesiumJS Version: 1.95.0 & 1.122.0 Operating System: Windows 11

ggetz commented 3 weeks ago

Hi @wumanho, what are you attempting to pick in this example? The terrain or the pipes beneath it? What values are you expecting see?

wumanho commented 3 weeks ago

Hi @wumanho, what are you attempting to pick in this example? The terrain or the pipes beneath it? What values are you expecting see?

Hi @ggetz , sorry, I didn't explain it clearly before.

I am trying to pick the latitude, longitude, and height of the terrain.

When I set the alpha value of the right panel to 1, I can get the expected terrain position, and the console logs numbers around 200, representing the terrain height.

However, if the alpha value is less than 1, the position I get is not what I expect, and the console shows height values like -10000.

The other problem I got is enabling viewer.scene.pickTranslucentDepth = true can lead to crashes. Please refer to this example for the reproduction. After performing a few rotate or zoom operations on the map, the problem will appear.

Thank you very much for your help.

https://sandcastle.cesium.com/index.html#c=tVhpc9tGEv0rWO0HU1XUaDAHBkMrzvqQ1661LFekOJVabW2BBCSiDAIsAJTMdfm/7+vBQRBUsnE28VEE5njd08fraSyKvKq9+zR5SErvOy9PHryXSZVuVuyjG5vcHC3c+8sir6M0T8qbo6n35Sb3vDopS4zMug3XzTu7LYvVT0WZxe3A5Hh6k389fnqT3+SNIFYtkjxh63Tx6bqM8irb4L1+lazrJXSoy01yk5+eLpxqyyiPs7FuV4sySfKrdbRIzu+x9U2zaLIHv4jy+6g6JqgWhFVJ/TZfb+rnizot8skkOf7u2Rda4HmNtHVRpTQFcQeqfmjnJglL8rh7Ox5uvyuj9TJdYHer6MuorIt21BmGBjAV5ZP1YwBZVO82X0T1ktXFq+QOp60mHQzWpPUmTvY35nf/e2OR3x3uXCbp3ZKkdsuagd2SIkuw9W7SjE+fNL9PHMjX6S945Hq7TtjF5Y9X5/++uPx4fkzOb+Q5g47s+7SbvMuKOU02VndvLm6a92on5GW0SsqIgrIsMnJtkkfzLHmJl7SCVV8ldbJoPXkbZRXBODhW9xG32JJL8vo18J5n62X0YvsqreooXyT74fY+icrXUXm1iLIIGYHYV5wzPqWn7jfsR3z328R765zO8IA9kSwU2g/7I3fuxJyWzPeN2M31vjGC7UYHQToIMxdV0gVZ5/he7rSXMm0xj3u0TZkB6OaIsdOraLXOkldRHZ2uijjJqtMPUbl4l0TxBTJ/7wW+md8cDc4In6f1dudX954mFYvieOL4IofLZ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neHqiDaRa03l2uju7nUCGqBmjD5xKIPKHnScGzCBZszgJkRXBtE2Qo30JI/dd0Bk6mo2CLIy/azY21fn76/fXv/8Cx8RWyveZtvr4tttiDsVNNZ0/8MdbmdCjRs0Ltko+LhE0JWlMyFuwcowdFHopdD7/j8mRG1Wgi541B6iJ96ZUNBNDhWL+mW040YMbWjcLREX91DJgfh4U7aym+9QsJV3ND06q+ptljzrCs3f0tW6KN1Hnwljp3WyWmcIz+p0vll8Smq2qKqGGejPXzt6/rJr8uZg8ru27JR382iicAvu/nMW7nYjUdAo4eQzT60/D4bnRRkn5UkJs2yq/cmvB6JT+lw7VOAenIwmLjuJsvQOp12lcZwlh1JP6mKNErsnuZuaF3VdrPZnD0WzJTyX7J3+FgR08uD6thnOkcXj7WenQ3ufxem9l8bfPfINvWlVMXO7ybKr9D/JzdGzs1OsP9iaFS5+LnHwLNrSsqX/7F0zyBg7O8Xr4zv7ytm7/6ymKvFsd6Czel7E28EADZV77zQSP7seELHXFqOzU0wcLt0fwVjjwxotN1limSw+zYvPMAGIMTqZo3h3w81d5KCoDQ7QIo4FY6D8DYd4DX96860Xt0XhTznAqO78UbpfUbG5d8XFyf1TdN8vYH+Y7q5e/y6FEQx3sCGyPMcbmI2eo8949t1zVSdrN+GPjnRP94G2xk899/ajq8Qz74mT8OTgdGPZdfK5JhFITrzpXxHwzYbC617e4X2QmMNs/i8

ggetz commented 2 weeks ago

Thanks for the explanation!

Ah yes, you will need to set viewer.scene.pickTranslucentDepth = true to pick translucent terrain.

It seems that I am not able to reproduce the crash on my end. I have ensured viewer.scene.pickTranslucentDepth = true, and have rotated and moved the camera throughout the scene.

@wumanho Would you be able to:

  1. Copy and paste the full error text
  2. Visit webglreport.com and take a screenshot of your results
wumanho commented 1 week ago

Of course! :slightly_smiling_face:

Full error text in case 1

Sandcastle example

DeveloperError: This object was destroyed, i.e., destroy() was called.

Error at new DeveloperError (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:10067:13) at Imagery.throwOnDestroyed (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:22327:13) at ComputeCommand.postExecute (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:210268:19) at ComputeEngine.execute (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:176739:22) at ComputeCommand.execute (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:82765:19) at executeComputeCommands (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:240446:22) at executeCommandsInViewport (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:240711:7) at Scene4.updateAndExecuteCommands (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:240530:7) at renderTranslucentDepthForPick (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:226936:11) at Picking.pickPositionWorldCoordinates (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:226970:7)

Full error text in case 2

Sandcastle example

TypeError: Cannot destructure property 'pass' of 'command' as it is undefined.

TypeError: Cannot destructure property 'pass' of 'command' as it is undefined. at View.createPotentiallyVisibleSet (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:226520:15) at executeCommandsInViewport (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:240709:10) at Scene4.updateAndExecuteCommands (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:240530:7) at renderTranslucentDepthForPick (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:226936:11) at Picking.pickPositionWorldCoordinates (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:226970:7) at Scene4.pickPositionWorldCoordinates (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:241441:26) at pickPosition (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:233343:33) at zoom3D2 (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:234295:22) at maintainInertia (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:232789:9) at reactToInput (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:232833:11)

Screenshots

image image

Thank you!