Skip to content

Commit

Permalink
RD-313: Terrain animation + easeTo glitch (#109)
Browse files Browse the repository at this point in the history
* Update Maplibre to v4.6.0

* Fix the easeTo terrain glitch

* changelog

* changelog

---------

Co-authored-by: Petr Sloup <[email protected]>
  • Loading branch information
jonathanlurie and petrsloup authored Sep 3, 2024
1 parent 6a4958d commit 7f4af0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 7f4af0f

Please sign in to comment.