Bug: ray picking fails in Columbus View

1. A concise explanation of the problem you’re experiencing.

I am using ray picking to locate the clicked location on the map and placing a marker there. This works in 3D view but fails in Columbus View, where the marker is placed in an unexpected location.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

Use this sandcastle:

  1. In default 3D mode, left-click points on the Earth and see markers added there. This works with terrain on or off.

  2. Switch to 2D mode and left-clicking also works since pickEllipsoid is used in this case.

  3. Switch to CV mode and left-clicking places markers in unexpected places.

Thanks,

Jacob

Hi Jacob,

Since Columbus View uses a projected map like in 2D mode, you should buse the same pick functionality as you do for 2D mode. I changed this line:

var sceneModeIs2D = viewer.scene.mode === Cesium.SceneMode.SCENE2D || viewer.scene.mode === Cesium.SceneMode.COLUMBUS_VIEW;

``

and it seems to work as expected.

Thank,

Gabby

Hi Gabby,

Thanks for taking a look! I tried out your suggestion and it works in CV when using the ellipsoid terrain, but not so well when using “Cesium World Terrain”. In particular, I’d like to be able to zoom to a mountain and place the marker on the mountain. I think I need getPickRay to get that click location, and this works well in 3D mode.

Thanks,

Jacob

What do you mean by not working so well?

If you want to set the billboard to be at the height of the terrain, set Billboard.heightReference to Cesium.HeightReference.CLAMP_TO_GROUND.

Hi Gabby,

I should have clarified that the marker appears in an undesired location when I use CV mode with terrain. What I want is for the location to appear on the terrain under the mouse, which is what getPickRay gives me in 3D mode. However, using pickEllipsoid in CV mode with terrain puts the marker further towards the horizon than where I want. Here is an updated sandcastle to help illustrate, using pickEllipsoid in CV mode and CLAMP_TO_GROUND for markers:

By default, markers are placed where expected. However, select “Cesium World Terrain” and go to a mountain and rotate the view. For example:

Now click on the mountain side and you do not get a marker placed there. Instead, if you zoom out you can see the marker was placed behind the mountain:

Thanks,

Jacob

If you set

viewer.scene.globe.depthTestAgainstTerrain = true;

``

You can use

cartesian = viewer.scene.pickPosition(click.position);

``

For all three modes, plus it works on terrain.

Thanks,

Gabby