Skip to content

Commit 0de1b51

Browse files
NathanMOlsonbirkskyumHarelM
authored
Fix enabling terrain while transitioning (#6266)
* Fix adding terrain while transitioning * cleanup * changelog * add browser test * increase timeout for windows * replace non-functional integration test with working unit test for setting terrain during easeTo() * Fix changelog (merge error) --------- Co-authored-by: Birk Skyum <[email protected]> Co-authored-by: Harel M <[email protected]>
1 parent 1e02d77 commit 0de1b51

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### 🐞 Bug fixes
1111
- Prevent original input style JSON from being mutated by `Style.set*` methods ([#6216](https://github.com/maplibre/maplibre-gl-js/pull/6216))
1212
- Fix evaluating `global-state` in paint properties with other subexpressions ([#6048](https://github.com/maplibre/maplibre-gl-js/issues/6048))
13+
- Fix enabling terrain while transitioning [#6011](https://github.com/maplibre/maplibre-gl-js/issues/6011)
1314

1415
## 5.6.2
1516

src/ui/camera.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,27 @@ describe('easeTo', () => {
12581258

12591259
expect(spy.mock.calls.find(c => 'done' in c[0])).toBeTruthy();
12601260
});
1261+
1262+
test('terrain set during easeTo', () => {
1263+
const camera = createCamera();
1264+
const stubNow = vi.spyOn(browser, 'now');
1265+
1266+
stubNow.mockImplementation(() => 0);
1267+
1268+
camera.easeTo({bearing: 97, duration: 500});
1269+
1270+
stubNow.mockImplementation(() => 100);
1271+
camera.simulateFrame();
1272+
1273+
const terrain = {getMinTileElevationForLngLatZoom: () => 0,
1274+
getElevationForLngLatZoom: () => 0};
1275+
camera.terrain = terrain as any;
1276+
1277+
stubNow.mockImplementation(() => 500);
1278+
camera.simulateFrame();
1279+
1280+
expect(camera.getBearing()).toEqual(97);
1281+
});
12611282
});
12621283

12631284
describe('flyTo', () => {

src/ui/camera.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,11 @@ export abstract class Camera extends Evented {
11871187
}
11881188

11891189
_updateElevation(k: number) {
1190+
1191+
if (this._elevationStart === undefined || this._elevationCenter === undefined) {
1192+
this._prepareElevation(this.transform.center);
1193+
}
1194+
11901195
this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom));
11911196
const elevation = this.terrain.getElevationForLngLatZoom(this._elevationCenter, this.transform.tileZoom);
11921197
// target terrain updated during flight, slowly move camera to new height

0 commit comments

Comments
 (0)