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

RD-313: Terrain animation + easeTo glitch #109

Merged
merged 6 commits into from
Sep 3, 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
## NEXT
### Bug Fixes
- Updating from MapLibre v4.4.1 to v4.6.0. See Maplibre changelogs for [v4.5.0](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#450), [v4.5.1](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#451), [v4.5.2](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#452), and [v4.6.0](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#460)
- Fixed the elevation shift glitch happening with terrain animation after calling `.easeTo()` (https://github.com/maptiler/maptiler-sdk-js/pull/110)
### New Features
- Updating from MapLibre v4.4.1 to v4.5.2, adding the following features. See Maplibre changelogs for for [v4.5.0](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#450), [v4.5.1](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#451), [v4.5.2](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#452), and [v4.6.0](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md#460)
### Others
- Updating from MapLibre v4.4.1 to v4.5.2
- Updating `MapTilerGeolocateControl` to match latest Maplibre update
- Updating `MapTilerGeolocateControl` to match latest Maplibre update (https://github.com/maptiler/maptiler-sdk-js/pull/104)

## 2.2.2
### Bug Fixes
Expand Down
7 changes: 7 additions & 0 deletions src/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ export class Map extends maplibregl.Map {
this.terrain.exaggeration = exaggeration;
}

// When growing the terrain, this is only necessary before rendering
this._elevationFreeze = false;
this.triggerRepaint();
};

Expand Down Expand Up @@ -1162,6 +1164,10 @@ export class Map extends maplibregl.Map {
// normalized value in interval [0, 1] of where we are currently in the animation loop
const positionInLoop = (performance.now() - startTime) / animationLoopDuration;

// At disabling, this should be togled fo both the setTerrain() (at the end of the animation)
// and also just before triggerRepain(), this is why we moved it this high
this._elevationFreeze = false;

// The animation goes on until we reached 99% of the growing sequence duration
if (positionInLoop < 0.99) {
const exaggerationFactor = (1 - positionInLoop) ** 4;
Expand All @@ -1172,6 +1178,7 @@ export class Map extends maplibregl.Map {
this.terrain.exaggeration = 0;
this.terrainGrowing = false;
this.terrainFlattening = false;

// @ts-expect-error - https://github.com/maplibre/maplibre-gl-js/issues/2992
this.setTerrain();
if (this.getSource(defaults.terrainSourceId)) {
Expand Down
Loading