# Bug: ray picking fails in Columbus View

**URL:** <https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643>\
**Category:** CesiumJS\
**Created:** [March 7, 2018, 6:42pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643 "2018-03-07T18:42:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@Jacob](https://community.cesium.com/u/Jacob)\
**Post date:** [March 7, 2018, 6:42pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643/1 "2018-03-07T18:42:07Z")

</div>

**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:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Hello%20World.html&label=Showcases&gist=448b80aef6e84cf5abde32bdd745c723)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

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

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [March 12, 2018, 9:54pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643/2 "2018-03-12T21:54:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jacob](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@Jacob](https://community.cesium.com/u/Jacob)\
**Post date:** [March 14, 2018, 6:57pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643/3 "2018-03-14T18:57:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [March 14, 2018, 8:56pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643/4 "2018-03-14T20:56:22Z")

</div>

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](https://cesiumjs.org/Cesium/Build/Documentation/Billboard.html#heightReference) to Cesium.HeightReference.CLAMP\_TO\_GROUND.

---

<div class="post-metadata">

**Author:** ![Jacob](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@Jacob](https://community.cesium.com/u/Jacob)\
**Post date:** [March 15, 2018, 5:15pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643/5 "2018-03-15T17:15:14Z")

</div>

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:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Hello%20World.html&label=Showcases&gist=f3e68ebe96ecda8cfeed079be495d6b5)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

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

[![](https://lh3.googleusercontent.com/-vK5JmWCmD5w/WqqojciFFHI/AAAAAAAAA1k/AO1MvyAPofEj37NZ7K2_7ekEdHyeYRq9ACLcBGAs/s400/CesiumCVClickTerrain1.jpg)](https://lh3.googleusercontent.com/-vK5JmWCmD5w/WqqojciFFHI/AAAAAAAAA1k/AO1MvyAPofEj37NZ7K2_7ekEdHyeYRq9ACLcBGAs/s1600/CesiumCVClickTerrain1.jpg)

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:

[![](https://lh3.googleusercontent.com/-QTtxz2JpD_o/Wqqo9fb8btI/AAAAAAAAA1o/UbcvXu7BXW0zDKfBT7cVRcfwC5mgJUTrwCLcBGAs/s400/CesiumCVClickTerrain2.jpg)](https://lh3.googleusercontent.com/-QTtxz2JpD_o/Wqqo9fb8btI/AAAAAAAAA1o/UbcvXu7BXW0zDKfBT7cVRcfwC5mgJUTrwCLcBGAs/s1600/CesiumCVClickTerrain2.jpg)

Thanks,

Jacob

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [March 16, 2018, 9:19pm UTC](https://community.cesium.com/t/bug-ray-picking-fails-in-columbus-view/6643/6 "2018-03-16T21:19:58Z")

</div>

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
