Viewer Event Position breaks after enabling, then disabling World Terrain model (or any new terrain model in that menu)
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Browser: Chrome
OS: Kubuntu 20.04
Sandcastle Link: [Bug occurs in any cesium application that uses the position. In this example, go to any position and take the lat long of it; then switch world terrain on/off and check the position again (it will have changed)](https://sandcastle.cesium.com/index.html#c=lVVtb9s2EP4rB3+RnLqU7RVoIdnBuiTDBiTosHqvMDDQ1NkiQpECSdlxiv73HWVLfqsHTJ9I3j13z70qSeA3hyCUrCqpV1AprtGBN+BQofByjWoLhcwRKm69A7MEXyCslFkguNouuUA213O95hbWEjdoYQoaN3CHTtYl+715iyPRXO+M9lxqtNEAvsw10Oeetx99aVxVoMUUllw5HOxFhalV/lHLknuEFLytW5FHa8nQL9asiZxNW3fCIun+YazKZzuVuD/XX/tZ4EgsGzbs1ZhyZuL9DbWXXqILSmdPjOd5vCcq8xSi0tTRnoLiC1RpG0b4kgQq4whoNHSM7ihvdOJ6zP5++PXTAA76FN/mJKqve6p7Fk6gRiY4Jbdh8rAmXo/SeXqmlBIXh6VZIyVzWWsR/MbYbxmFijRxbKki53Gt0P+w/TlvjETBZYdQ1AvOyPwA2tFoSs468R5CIT8FGkA07FFrNB2EzYOgBJiV5VUhxSE/B4+iTdDBo+AlWs4qKZ4fWofxUVN1Of0upvwoSWH9OYD2+Fd/cAijjU0uIe489Y+r1nLoOE4PaNZBZubuSOfIVHZqSRm9kr7O8bO3YaKmLecn7gvmzT2uLKKLjz2yDtQnjR/lC+bxaHhhmfv/b3iPuWZ31x+sq8r0UI1LrabhWWha0gtde01lSVP+j/NbhaT44d01tVw6vlB4j5UvZuj8PXU21yKARmz8/t14OPoANzAaws0NvM+O5+yM9/TKsGVwxbXHF09uojiCNxclewM0UI3gNOP03o/OimLR1SqYujCfhdnYhPbXpBVGxBfSHdC5EXVJqDCKDwrDsZnIeS+noZ73+kxqGvOfZk+P3zS/3xjUq2T6y38Xq1mq2emOmeveoDdpqnS7k3wvy8pYD7VVMWOJx5J+B5TOZFGLZ/RMuGZFTpIWNMnlmtbitKUMjWAavb6VOseXFMbD4TDrZj4FvnBG1R4zKFCuCp+OhsPqJYONzH2RjncX20io7OGyMN6bMoXmEuJ+K4wytO83hfQY3U4S4nBC5exHQ6yE4s6RZFkr9Vm+4rz3DZgyPKcif6I1pvg2qBSj28fdI2NsktD1EuWNUQtujyz+Cw)
This is in accordance with https://community.cesium.com/t/viewer-event-position-breaks-after-enabling-then-disabling-world-terrain-model/12732.
It’s possible to get the position of a mouse click on the world via `event.position` so that an entity can be placed there. For example, here I’m drawing a line from one corner of this octagon to another:
[Image Link - working WGS84](https://aws1.discourse-cdn.com/business4/uploads/cesium/original/2X/0/07f027bee77ce4efbed0e4f8b8c1de21b5eca830.jpeg)
This was taken using the default WGS84 ellipsoid. If I switch to the Cesium World terrain, I can do the same thing again without incident:
[Image Link 2 - working properly with terrain enabled](https://aws1.discourse-cdn.com/business4/uploads/cesium/original/2X/5/5ea50944c821be6648a9cea3984721d05925524b.jpeg)
But then if I switch back to the WGS84 ellipsoid, the location reported by event.position breaks and it starts reporting incorrect values. Note that in this image I clicked on the same two corners as before:
[Image Link 3 - the bug occuring after switching back to WGS84](https://aws1.discourse-cdn.com/business4/uploads/cesium/original/2X/4/4f588c7ce7d65b850814ac163f73d8be60f99e21.jpeg)
This does not happen with `event.endPosition`, but that can’t be used in every circumstance.
Strangely enough, this occurs when switching between any terrain model present in that menu:
[The menu in question](https://aws1.discourse-cdn.com/business4/uploads/cesium/original/2X/0/08f6986313cdc510ca923440bfb7d492cc46b953.png)
If I remove the world terrain option and replace it with my own terrain model, the same bug will occur.
Contributor guide
Research direction
Start by reproducing the issue in the linked Sandcastle example, focusing on Viewer event.position while switching between terrain models. Trace the terrain-switch and event.position handling, then verify that the reported coordinates remain correct after enabling and disabling terrain; event.endPosition is noted as unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100