Skip to content

Commit

Permalink
Merge pull request #5796 from AnalyticalGraphicsInc/tweak-terrain-sam…
Browse files Browse the repository at this point in the history
…pling

Use terrainProvider.readyPromise in preference to setTimeout()
  • Loading branch information
pjcozzi authored Sep 6, 2017
2 parents 411944b + 49a3112 commit 3646fef
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions Source/Core/sampleTerrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,7 @@ define([
Check.defined('positions', positions);
//>>includeEnd('debug');

var deferred = when.defer();

function doSamplingWhenReady() {
if (terrainProvider.ready) {
when(doSampling(terrainProvider, level, positions), function(updatedPositions) {
deferred.resolve(updatedPositions);
});
} else {
setTimeout(doSamplingWhenReady, 10);
}
}

doSamplingWhenReady();

return deferred.promise;
return terrainProvider.readyPromise.then(function() { return doSampling(terrainProvider, level, positions); });
}

function doSampling(terrainProvider, level, positions) {
Expand Down

0 comments on commit 3646fef

Please sign in to comment.