globe.pick returning undefined

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'});

// 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({
    id: "satellite",
    name: "satellite",
    position: aboveKansas,
    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)) {
    // rayEllipsoid returns an interval, where on the ray is the interval?
    let intersectPosition = Cesium.Ray.getPoint(ray, ellipsoidIntersect.start);
    console.log("ellipsoidIntersectPosition");
    console.log(intersectPosition);
} else if (ellipsoidIntersect === undefined) {
    console.log("ellipsoidIntersect undefined")
} else if (ellipsoidIntersect === null) {
    console.log("ellipsoidIntersect null")
}

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

Thanks for pointing this out! I believe this may be a regression after #6115 and has to do with the order of when the globe tiles load and the pick is performed. I’ve opened #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, and checking Globe.tilesLoaded.

Thanks,

Gabby

Thanks, I look forward to the resolution.