Skip to content

Commit

Permalink
Make sampleTerrain behaviour consistent with the rejectOnTileFail flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseyay committed May 22, 2024
1 parent 11dd728 commit 987ffe7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fixed a bug where `TaskProcessor` worker loading would check the worker module ID rather than the absolute URL when determining if it is cross-origin. [#11833](https://github.com/CesiumGS/cesium/pull/11833)
- Fixed a bug where cross-origin workers would error when loaded with the CommonJS `importScripts` shim instead of an ESM `import`. [#11833](https://github.com/CesiumGS/cesium/pull/11833)
- Corrected the Typescript types for `Billboard.id` and `Label.id` to be `any` [#11973](https://github.com/CesiumGS/cesium/issues/11973)
- Fixes a bug where `sampleTerrain` did not respect the `rejectOnTileFail` flag for failed requests other than the first.

### 1.117 - 2024-05-01

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Tony Luk](https://github.com/impactblue573)
- [Daniel Cooper](https://github.com/moodragon46)
- [Harry Morris](https://github.com/harrythemorris)
- [Jesse Gibbs](https://github.com/jesseyay)
- [GeoFS](https://www.geo-fs.com)
- [Xavier Tassin](https://github.com/xtassin/)
- [Esri](https://www.esri.com)
Expand Down
6 changes: 3 additions & 3 deletions packages/engine/Source/Core/sampleTerrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import defined from "./defined.js";
* @param {TerrainProvider} terrainProvider The terrain provider from which to query heights.
* @param {number} level The terrain level-of-detail from which to query terrain heights.
* @param {Cartographic[]} positions The positions to update with terrain heights.
* @param {boolean} [rejectOnTileFail=false] If true, for a failed terrain tile request the promise will be rejected. If false, returned heights will be undefined.
* @param {boolean} [rejectOnTileFail=false] If true, for any failed terrain tile requests, the promise will be rejected. If false, returned heights will be undefined.
* @returns {Promise<Cartographic[]>} A promise that resolves to the provided list of positions when terrain the query has completed.
*
* @see sampleTerrainMostDetailed
Expand Down Expand Up @@ -139,12 +139,12 @@ function drainTileRequestQueue(tileRequests, results, rejectOnTileFail) {
rejectOnTileFail
);
if (success) {
return drainTileRequestQueue(tileRequests, results);
return drainTileRequestQueue(tileRequests, results, rejectOnTileFail);
}

// wait a small fixed amount of time first, before retrying the same request again
return delay(100).then(() => {
return drainTileRequestQueue(tileRequests, results);
return drainTileRequestQueue(tileRequests, results, rejectOnTileFail);
});
}

Expand Down
10 changes: 10 additions & 0 deletions packages/engine/Specs/Core/sampleTerrainSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ describe("Core/sampleTerrain", function () {
).toBeRejected();
});

it("rejects if terrain data is not available for the second position and rejectOnTileFail is true", function () {
const positionWithData = Cartographic.fromDegrees(86.925145, 27.988257);
const positionWithoutData = Cartographic.fromDegrees(0.0, 0.0, 0.0);

const positions = [positionWithData, positionWithoutData];
return expectAsync(
sampleTerrain(worldTerrain, 12, positions, true)
).toBeRejected();
});

it("fills in what it can when given a mix of positions with and without valid tiles", function () {
const positions = [
Cartographic.fromDegrees(86.925145, 27.988257),
Expand Down

0 comments on commit 987ffe7

Please sign in to comment.