Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sampleTerrain behaviour consistent with the rejectOnTileFail flag #11998

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- 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)
- Fixed a normalization error in image-based lighting [#11994](https://github.com/CesiumGS/cesium/issues/11994)
- Fixes a bug where `sampleTerrain` did not respect the `rejectOnTileFail` flag for failed requests other than the first. [#11998](https://github.com/CesiumGS/cesium/pull/11998)

### 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