Skip to content

Commit

Permalink
Add Vertical Perspective projection (#5023)
Browse files Browse the repository at this point in the history
* Support Vertical Projection

* changelog

* unit test fix

* remove typo
  • Loading branch information
birkskyum authored Nov 9, 2024
1 parent b6e3b55 commit 72aeed0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## main

### ✨ Features and improvements
- Support Vertical Perspective projection ([#5023](https://github.com/maplibre/maplibre-gl-js/pull/5023))
- _...Add new stuff here..._

### 🐞 Bug fixes
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@mapbox/unitbezier": "^0.0.1",
"@mapbox/vector-tile": "^1.3.1",
"@mapbox/whoots-js": "^3.1.0",
"@maplibre/maplibre-gl-style-spec": "^21.1.0",
"@maplibre/maplibre-gl-style-spec": "^21.2.0",
"@types/geojson": "^7946.0.14",
"@types/geojson-vt": "3.2.5",
"@types/mapbox__point-geometry": "^0.1.4",
Expand Down
8 changes: 6 additions & 2 deletions src/geo/projection/globe_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,11 @@ export class GlobeTransform implements ITransform {
private _farZ: number;

private _coveringTilesDetailsProvider: GlobeCoveringTilesDetailsProvider;
private _adaptive: boolean;

public constructor(globeProjection: GlobeProjection, globeProjectionEnabled: boolean = true, adaptive:boolean = true) {
this._adaptive = adaptive;

public constructor(globeProjection: GlobeProjection, globeProjectionEnabled: boolean = true) {
this._helper = new TransformHelper({
calcMatrices: () => { this._calcMatrices(); },
getConstrained: (center, zoom) => { return this.getConstrained(center, zoom); }
Expand Down Expand Up @@ -372,7 +375,8 @@ export class GlobeTransform implements ITransform {
newFrameUpdate(): TransformUpdateResult {
this._lastUpdateTimeSeconds = browser.now() / 1000.0;
const oldGlobeRendering = this.isGlobeRendering;
this._globeness = this._computeGlobenessAnimation();

this._globeness = (!this._adaptive && this._globeProjectionAllowed) ? 1 : this._computeGlobenessAnimation();
// Everything below this comment must happen AFTER globeness update
this._updateErrorCorrectionValue();
this._calcMatrices();
Expand Down
11 changes: 10 additions & 1 deletion src/geo/projection/projection_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ export function createProjectionFromName(name: ProjectionSpecification['type']):
const proj = new GlobeProjection();
return {
projection: proj,
transform: new GlobeTransform(proj),
transform: new GlobeTransform(proj, true),
cameraHelper: new GlobeCameraHelper(proj),
};
}
case 'vertical-perspective':
{
const proj = new GlobeProjection();
return {
projection: proj,
transform: new GlobeTransform(proj, true, false),
cameraHelper: new GlobeCameraHelper(proj),
};
}
Expand Down

0 comments on commit 72aeed0

Please sign in to comment.