From 648b10a79124b4c81634a64ef2da47c93b2347b8 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 2 Jan 2020 11:56:09 -0500 Subject: [PATCH] globe.getHeight traverses to deepest tile with a rendered mesh --- Source/Scene/Globe.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index eb17e1ac979c..30cff1b60dd3 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -618,19 +618,26 @@ import TileSelectionResult from './TileSelectionResult.js'; return undefined; } + var tileWithMesh = tile; + while (tile._lastSelectionResult === TileSelectionResult.REFINED) { tile = tileIfContainsCartographic(tile.southwestChild, cartographic) || tileIfContainsCartographic(tile.southeastChild, cartographic) || tileIfContainsCartographic(tile.northwestChild, cartographic) || tile.northeastChild; + if (defined(tile.data) && defined(tile.data.renderedMesh)) { + tileWithMesh = tile; + } } + tile = tileWithMesh; + // This tile was either rendered or culled. // It is sometimes useful to get a height from a culled tile, // e.g. when we're getting a height in order to place a billboard // on terrain, and the camera is looking at that same billboard. // The culled tile must have a valid mesh, though. - if (!defined(tile.data) || !defined(tile.data.renderedMesh)) { + if (!defined(tile)) { // Tile was not rendered (culled). return undefined; }