# globe.pick returning undefined

**URL:** <https://community.cesium.com/t/globe-pick-returning-undefined/6616>\
**Category:** CesiumJS\
**Created:** [March 1, 2018, 8:32pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616 "2018-03-01T20:32:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![i\_question](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@i\_question](https://community.cesium.com/u/i_question)\
**Post date:** [March 1, 2018, 8:32pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/1 "2018-03-01T20:32:47Z")

</div>

1. A concise explanation of the problem you're experiencing.  
I'm trying to use globe.pick to find a point directly below another point, but while IntersectionTests.rayEllipsoid does find an intersection, globe.pick is returning undefined. To test this, I decided to place a "satellite" directly above Kansas and see if it worked; it did not.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.  
let viewer = new Cesium.Viewer('cesiumContainer');  
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({url: '[//assets.agi.com/stk-terrain/world](https://assets.agi.com/stk-terrain/world)'});

// The Earth  
let globe = viewer.scene.globe;  
let ellipsoid = globe.ellipsoid;

// Place "satellite"  
let scratch = new Cesium.Cartesian3();  
let kansas = Cesium.Cartesian3.fromDegrees(-101.2921054, 39.4166685);  
let aboveKansas = Cesium.Cartesian3.multiplyByScalar(kansas, 1.5, scratch);  
viewer.entities.add({  
&nbsp;&nbsp;&nbsp;&nbsp;id: "satellite",  
&nbsp;&nbsp;&nbsp;&nbsp;name: "satellite",  
&nbsp;&nbsp;&nbsp;&nbsp;position: aboveKansas,  
&nbsp;&nbsp;&nbsp;&nbsp;point: {pixelSize: 10, color: Cesium.Color.YELLOW}  
});  
let satellite = viewer.entities.getById("satellite");  
let satPos = satellite.position.getValue(viewer.clock.currentTime);

// Place ray on "satellite" pointing down  
let ray = new Cesium.Ray();  
ray.origin = satPos;  
ray.direction = Cesium.Cartesian3.negate(satPos, scratch);

// Intersection with ellipsoid  
let ellipsoidIntersect = Cesium.IntersectionTests.rayEllipsoid(ray, ellipsoid);  
if ((ellipsoidIntersect !== undefined) && (ellipsoidIntersect !== null)) {  
&nbsp;&nbsp;&nbsp;&nbsp;// rayEllipsoid returns an interval, where on the ray is the interval?  
&nbsp;&nbsp;&nbsp;&nbsp;let intersectPosition = Cesium.Ray.getPoint(ray, ellipsoidIntersect.start);  
&nbsp;&nbsp;&nbsp;&nbsp;console.log("ellipsoidIntersectPosition");  
&nbsp;&nbsp;&nbsp;&nbsp;console.log(intersectPosition);  
} else if (ellipsoidIntersect === undefined) {  
&nbsp;&nbsp;&nbsp;&nbsp;console.log("ellipsoidIntersect undefined")  
} else if (ellipsoidIntersect === null) {  
&nbsp;&nbsp;&nbsp;&nbsp;console.log("ellipsoidIntersect null")  
}

// Intersection with terrain  
let terrainIntersect = viewer.scene.globe.pick(ray, globe);  
if ((terrainIntersect !== undefined) && (terrainIntersect !== null)) {  
&nbsp;&nbsp;&nbsp;&nbsp;// globe.pick returns a Cartesian3, so it's fine as it is  
&nbsp;&nbsp;&nbsp;&nbsp;console.log("terrainIntersectPosition");  
&nbsp;&nbsp;&nbsp;&nbsp;console.log(terrainIntersect);  
} else if (terrainIntersect === undefined) {  
&nbsp;&nbsp;&nbsp;&nbsp;console.log("terrainIntersect undefined")  
} else if (terrainIntersect === null) {  
&nbsp;&nbsp;&nbsp;&nbsp;console.log("terrainIntersect null")  
}

The console output from this is:  
ellipsoidIntersectPosition  
a {x: -966148.3627938608, y: -4838569.813304188, z: 4028160.31341576}  
terrainIntersect undefined

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.  
I'm trying to figure out how to properly determine a ray's intersection point with terrain.

4. The Cesium version you're using, your operating system and browser.  
Cesium 1.41.0  
Windows 10 and Chrome 64.0.3282.186  
or  
CentOS7 and Firefox 52.2.0

---

<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 6, 2018, 2:50pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/2 "2018-03-06T14:50:14Z")

</div>

Thanks for pointing this out! I believe this may be a regression after [#6115](https://github.com/AnalyticalGraphicsInc/cesium/pull/6115) and has to do with the order of when the globe tiles load and the pick is performed. I’ve opened [#6312](https://github.com/AnalyticalGraphicsInc/cesium/issues/6312) to track.

In the meantime, I do get values returned (albeit inconsistently) when performing Globe.pick in a listener function subscribed to [Globe.tileLoadProgressEvent](https://cesiumjs.org/Cesium/Build/Documentation/Globe.html#tileLoadProgressEvent), and checking [Globe.tilesLoaded](https://cesiumjs.org/Cesium/Build/Documentation/Globe.html#tilesLoaded).

Thanks,

Gabby

---

<div class="post-metadata">

**Author:** ![i\_question](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@i\_question](https://community.cesium.com/u/i_question)\
**Post date:** [March 8, 2018, 8:14pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/3 "2018-03-08T20:14:31Z")

</div>

Thanks, I look forward to the resolution.

---

<div class="post-metadata">

**Author:** ![rileyhowley](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/rileyhowley/32/32179_2.png) [@rileyhowley](https://community.cesium.com/u/rileyhowley)\
**Post date:** [December 3, 2025, 2:28am UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/4 "2025-12-03T02:28:50Z")

</div>

Re-raising this as I have recently come across this and it has broken one of our workflows.

Does anyone have a workaround for this that they can share?

> **[Sandcastle | CesiumJS](https://sandcastle.cesium.com/#c=fVPdb5swEP9XbjzBxIyqvS0ErYqQVmkdUdL1CSl1zCWxamxkm1RZlf99Nh8VdNUeEHB3vw/fnXndKG3hM1ADKzS8reGgVQ1lwLq/MliUspRMSWPhzPEFNSxB4stQTR67WDjWr5S0lEvUZRBNkPlmU2x26+Lu18McvqLaui8qv4ZfbmLonx7ZqxHDNKLcNpRhfkZpf1BZCR9Heyeb1t4yy5UMQ/TJCJYZvJYSoNd9BUZr1DSGo1B7hKtTf+NFiZ0QgNWXHjXihGLU07ryjpegrNbKcB9bQJLArTFtzeURniaZJ+AG7AmhVq1BaIbwlFjTi+PsTZEj2jVnzxt6CUdBf/SxWgkkQh1db11FGcQeHA2OAfgBwk8+Ahptq+W0x29FvSi6Jp9Gk06+6wVpnHToCOJZRz42kE8ZvJUZ5TtTw2grPLhFqMJ56X/tDqkZovNzdS2z7AThDrVWOppOy7vsot6nf4M/mZ/NOIBv3vGAXMyU5iacTimv8bib23eb93BpkNwXv7f57r54zKNFEAepsReBmcd+5/1darUICUks1o2gbrmTfcue0RJmjFdPkxGSVvwMvFp+cHeACWqMyxxaIbb8D5ZBliaufgYTilbunMUZtfAbkqWnm+xnHySEpIn7/RdllRJ7qieMfwE)**

Reproduce steps:

- Load Sandcastle example
- Transform map in 2D
- Mouse over United states
- Identify the `undefined` in the terminal response

Thanks all

cheers

---

<div class="post-metadata">

**Author:** ![mzschwartz5](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mzschwartz5/32/30089_2.png) [@mzschwartz5](https://community.cesium.com/u/mzschwartz5)\
**Post date:** [December 4, 2025, 9:56pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/5 "2025-12-04T21:56:58Z")

</div>

Hi @rileyhowley,

This actually appears to be a new issue you’re encountering - a regression due to [this PR](https://github.com/CesiumGS/cesium/pull/9961) (mea culpa!). I _believe_ I know where the issue stems from, but I’m still investigating. I’ll open an issue and follow up here once I have more information, and we’ll see if it’s possible to fix in the next release.

Best,  
Matt

---

<div class="post-metadata">

**Author:** ![rileyhowley](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/rileyhowley/32/32179_2.png) [@rileyhowley](https://community.cesium.com/u/rileyhowley)\
**Post date:** [December 4, 2025, 10:27pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/6 "2025-12-04T22:27:21Z")

</div>

Appreciate it!

---

<div class="post-metadata">

**Author:** ![mzschwartz5](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mzschwartz5/32/30089_2.png) [@mzschwartz5](https://community.cesium.com/u/mzschwartz5)\
**Post date:** [December 4, 2025, 10:43pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/7 "2025-12-04T22:43:22Z")

</div>

[Issue here](https://github.com/CesiumGS/cesium/issues/13083). I feel like I’m just shy of understanding what’s going wrong, but will pick back up tomorrow.

---

<div class="post-metadata">

**Author:** ![mzschwartz5](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mzschwartz5/32/30089_2.png) [@mzschwartz5](https://community.cesium.com/u/mzschwartz5)\
**Post date:** [December 8, 2025, 3:17pm UTC](https://community.cesium.com/t/globe-pick-returning-undefined/6616/8 "2025-12-08T15:17:06Z")

</div>

Still working on it, progress in issue. One thing I’ll say (for you or for others with the same issue) - if you only need an ellipsoid height and not a terrain height, you can use `Camera.pickEllipsoid` (which will also be much more performant).
