Viewer Event Position breaks after enabling, then disabling World Terrain model

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:

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:

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:

This does not happen with event.endPosition, but that can’t be used in every circumstance.

Is this an engine bug? Or some implementation error that I can get around?

@dzung should this be reported as an engine bug on github?

This is now reported on github as a bug.

Have you tried scene.pickPosition (Scene - Cesium Documentation) for terrain and camera.pickEllipsoid (Camera - Cesium Documentation) for the ellipsoid? It might be an issue with picking terrain versus picking the ellipsoid.

@dzung I can try, but surely if I’m using the first function for both ellipsoid and terrain, and I switch from ellipsoid to terrain and then back to ellipsoid, it shouldn’t have made any lasting changes?

Or are you saying that the change to the world terrain model changes the scene.pickPosition function permanently, because it’s now interacted with a terrain model over an ellipsoid model?

EDIT: Just gave this a try by making a function to return a position dependent on what terrain model the Viewer is using - I still ran into the same issue.

This might be a potential bug. Are you able to share a Sandcastle example of the code?

@dzung There’s one in the github issue report - it’s a sandcastle that’s not specifically about that bug but shows that it it exists.

The sandcastle I linked to is Cesium Sandcastle - switch between the world terrain and back and see that coordinates for a specific location will change.

1 Like