Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
86ed382
Camera Roll (#4780)
NathanMOlson Oct 17, 2024
a215357
Bump cspell from 8.15.3 to 8.15.4 (#4857)
dependabot[bot] Oct 18, 2024
904d372
Bump @types/node from 22.7.6 to 22.7.7 (#4865)
dependabot[bot] Oct 21, 2024
a2f1450
Support for RTL text plugin 0.3.0 (#4860)
HarelM Oct 21, 2024
cdc50e2
Clean up console log in unit tests (#4866)
HarelM Oct 21, 2024
92b86d5
Bump version to v5.0.0-pre.3 (#4867)
github-actions[bot] Oct 21, 2024
6c99b6d
Globe custom layers: draw globe into depth buffer (#4838)
kubapelc Oct 21, 2024
0ffa890
Upgrade eslint to version 9 (#4869)
HarelM Oct 21, 2024
de41d3d
Bump @typescript-eslint/eslint-plugin from 8.10.0 to 8.11.0 (#4872)
dependabot[bot] Oct 22, 2024
deedc71
Bump @types/node from 22.7.7 to 22.7.8 (#4875)
dependabot[bot] Oct 22, 2024
cf816c9
Bump @typescript-eslint/parser from 8.10.0 to 8.11.0 (#4873)
dependabot[bot] Oct 22, 2024
3f526e2
Bump devtools-protocol from 0.0.1368592 to 0.0.1371839 (#4874)
dependabot[bot] Oct 22, 2024
f24dfe6
Update package to support multi features (#4877)
HarelM Oct 22, 2024
f34aaa3
squashed changes to support pitch > 90
NathanMOlson Oct 19, 2024
10b38e7
fix merge conflicts
NathanMOlson Oct 17, 2024
83c9f32
fix changelog screwup
NathanMOlson Oct 17, 2024
f9dda9f
fix lint and adjust build size
NathanMOlson Oct 17, 2024
4843479
better naming
NathanMOlson Oct 18, 2024
4698d69
remove jumpToLLA (it can be made a plugin)
NathanMOlson Oct 18, 2024
4e3f107
fix render tests by breaking camera-centric behavior
NathanMOlson Oct 18, 2024
02ecf12
better naming
NathanMOlson Oct 18, 2024
2b0929c
add setRoll operation
NathanMOlson Oct 18, 2024
3ef2ad6
fix pitch95 render test
NathanMOlson Oct 18, 2024
1da2ea3
add pitch=90 roll=135 render test
NathanMOlson Oct 18, 2024
aed96e5
add render test for pitch95 with terrain
NathanMOlson Oct 18, 2024
39e7b23
test getMercatorHorizon() at high pitch
NathanMOlson Oct 18, 2024
d5bf672
add test for recalculateZoomAndCenter without terrain
NathanMOlson Oct 18, 2024
6054901
documentation
NathanMOlson Oct 18, 2024
17ef87e
<89 -> <=89
NathanMOlson Oct 18, 2024
589d0c8
LLA -> LngLatAlt
NathanMOlson Oct 18, 2024
9c05c31
fix lint
NathanMOlson Oct 18, 2024
39dec29
Merc -> Mercator
NathanMOlson Oct 18, 2024
8d5ff83
add public API function setCenterElevation(), and remove render test …
NathanMOlson Oct 18, 2024
845e32f
don't let camera distances go negative
NathanMOlson Oct 19, 2024
72aca37
change the mercator horizon heuristic to be continuous, and update re…
NathanMOlson Oct 19, 2024
7ec73ab
function to only set elevation if center point is below horizon
NathanMOlson Oct 19, 2024
3eb4a0a
update sky render tests
NathanMOlson Oct 19, 2024
9b29a53
update changelog
NathanMOlson Oct 19, 2024
d2dae37
revert unintended package changes.
NathanMOlson Oct 20, 2024
0bfdc8f
revert unnecessarry shader change
NathanMOlson Oct 20, 2024
9173573
updated maxPitch docs
NathanMOlson Oct 20, 2024
9e9c950
fix spelling
NathanMOlson Oct 20, 2024
06a0e22
add named constant maxMercatorHorizonAngle
NathanMOlson Oct 20, 2024
f514d75
use roll and pitch spec definitions in sky render tests
NathanMOlson Oct 20, 2024
a1b1fc0
move __setElevationIfCenterPointBelowHorizon() from Transform to Map
NathanMOlson Oct 20, 2024
52156b2
change mercator horizon limit from 89 to 89.25, so that horizon heuri…
NathanMOlson Oct 20, 2024
9cd34d6
update comment
NathanMOlson Oct 20, 2024
09cce24
fix lint
NathanMOlson Oct 20, 2024
339a0c3
update unit tests for new horizon heuristic
NathanMOlson Oct 20, 2024
1d76a42
revert unchanged render test results
NathanMOlson Oct 20, 2024
ea54dfa
add switch to control "centerClampedToGround" behavior
NathanMOlson Oct 21, 2024
b224639
fix render tests
NathanMOlson Oct 21, 2024
9c957f0
Update src/geo/projection/mercator_utils.ts
HarelM Oct 21, 2024
9ec4fa2
Apply suggestions from code review
HarelM Oct 21, 2024
365615d
Update src/geo/transform_interface.ts
HarelM Oct 21, 2024
3ded9f2
Don't update center point if there is nothing to do (this was causing…
NathanMOlson Oct 21, 2024
f045bd1
Add an example showing center point at the top of a building and pitc…
NathanMOlson Oct 21, 2024
c614f78
remove warnings about pitch angles > 60.
NathanMOlson Oct 21, 2024
98a6bd8
move cameraMercatorCoordinateFromCenterAndRotation() to mercator_utils
NathanMOlson Oct 21, 2024
f1fff70
Restore old setLocationAtPoint(). This fixes unit tests but breaks `c…
NathanMOlson Oct 21, 2024
692e788
better unit test coverage and documentation for calculateCenterFromCa…
NathanMOlson Oct 21, 2024
8fd3c93
add @internal
NathanMOlson Oct 21, 2024
bbfb97e
code cleanup
NathanMOlson Oct 21, 2024
fa33e02
Add calculateCameraOptionsFromCameraLngLatAltRotation() and unit tests
NathanMOlson Oct 21, 2024
418231f
add developer guide describing center point.
NathanMOlson Oct 21, 2024
b059f53
move high-pitch render tests to high-pitch folder
NathanMOlson Oct 21, 2024
56b7b6d
fix build
NathanMOlson Oct 21, 2024
1d40a3e
update high pitch + terrain render test to remove setPitch() call
NathanMOlson Oct 21, 2024
8b86f8e
use transform's elevation in setLocationAtPoint()
NathanMOlson Oct 22, 2024
818de68
fix jumps when using the mouse to rotate past 90 degrees pitch
NathanMOlson Oct 22, 2024
33779dd
further safety against numerical issues near the horizon
NathanMOlson Oct 22, 2024
95dab2f
fix spelling
NathanMOlson Oct 22, 2024
b730093
make centerClampedToGround get/set symmetric
NathanMOlson Oct 22, 2024
ee0e474
split recalculateZoomAndCenter unit tests.
NathanMOlson Oct 22, 2024
c8c8322
simplify center-point example
NathanMOlson Oct 22, 2024
0ae6699
add examples for calculateCameraOptionsFromTo() and calculateCameraOp…
NathanMOlson Oct 22, 2024
38aeaaf
origPixelPerMeter -> originalPixelPerMeter
NathanMOlson Oct 22, 2024
7389a0a
whitespace
NathanMOlson Oct 22, 2024
461487a
simplify center-point example
NathanMOlson Oct 22, 2024
f00d9a4
set minZoom in example so we don't lose the map
NathanMOlson Oct 22, 2024
11c0dde
remove unnecessary limit on _farZ
NathanMOlson Oct 22, 2024
e661375
change pseudocode to Typescript
NathanMOlson Oct 22, 2024
02d44fd
add unit tests to cover various code paths in _updateMapTransform()
NathanMOlson Oct 22, 2024
564b710
update build size
NathanMOlson Oct 22, 2024
54cf54e
fix: order of normalizeSpriteURL and transformRequest in load sprite…
Kai-W Oct 22, 2024
49231ab
Bump eslint-plugin-react from 7.37.1 to 7.37.2 (#4880)
dependabot[bot] Oct 23, 2024
86d4522
Bump @types/cssnano from 5.1.0 to 5.1.3 (#4882)
dependabot[bot] Oct 23, 2024
6900f99
Bump @types/node from 22.7.8 to 22.7.9 (#4881)
dependabot[bot] Oct 23, 2024
471b786
Bump @types/react from 18.3.11 to 18.3.12 (#4884)
dependabot[bot] Oct 23, 2024
aa596e6
Bump @types/jest from 29.5.13 to 29.5.14 (#4883)
dependabot[bot] Oct 23, 2024
612b070
Update developer-guides/center-point.md
HarelM Oct 23, 2024
6000c53
use local variables
NathanMOlson Oct 23, 2024
a3e89e9
Add example of Three.js model with shadow (#4885)
birkskyum Oct 24, 2024
7e759ad
pmtiles example: bump library version, fix link to OpenStreetMap. (#4…
bdon Oct 24, 2024
491ac04
Use ESM and latest three.js 0.169.0 (#4888)
birkskyum Oct 24, 2024
4b860ba
Bump st from 3.0.0 to 3.0.1 (#4893)
dependabot[bot] Oct 25, 2024
dd17405
Bump devtools-protocol from 0.0.1371839 to 0.0.1373723 (#4894)
dependabot[bot] Oct 25, 2024
941037b
move "underground" check to _elevateCameraIfInsideTerrain()
NathanMOlson Oct 25, 2024
2ce4343
fix high-pitch render tests, which were having their pitch angle modi…
NathanMOlson Oct 25, 2024
4682db8
return early in case of no terrain and pitch < 90
NathanMOlson Oct 25, 2024
3346fbd
Remove unminified prod build (Revert #4265) (#4906)
birkskyum Oct 27, 2024
95cfbdb
docs: update measure example to turf v7 (#4907)
twelch Oct 27, 2024
d42e0da
Allow raster source tile updates to re-trigger tile request that fail…
wagewarbler Oct 27, 2024
8554314
Bump rollup from 4.24.0 to 4.24.2 (#4910)
dependabot[bot] Oct 28, 2024
20ce115
Bump @types/node from 22.7.9 to 22.8.1 (#4911)
dependabot[bot] Oct 28, 2024
53e5f0e
Merge branch 'main' into camera-centric
HarelM Oct 28, 2024
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
107 changes: 0 additions & 107 deletions .eslintrc.json

This file was deleted.

18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
## main

### ✨ Features and improvements
- ⚠️ Changed `geometry-type` to identify "Multi-" features ([#4877](https://github.com/maplibre/maplibre-gl-js/pull/4877))
- Add support for pitch > 90 degrees ([#4717](https://github.com/maplibre/maplibre-gl-js/issues/4717))
- _...Add new stuff here..._

### 🐞 Bug fixes
- ⚠️ Fix order of normalizeSpriteURL and transformRequest in loadSprite ([#3897](https://github.com/maplibre/maplibre-gl-js/issues/3897))
- ⚠️ Remove unminified prod build ([#4906](https://github.com/maplibre/maplibre-gl-js/pull/4906))
- Fix issue where raster tile source won't fetch updates following request error ([#4890](https://github.com/maplibre/maplibre-gl-js/pull/4890))
- _...Add new stuff here..._

## v5.0.0-pre.3

### ✨ Features and improvements

- Add support for camera roll angle ([#4717](https://github.com/maplibre/maplibre-gl-js/issues/4717))

### 🐞 Bug fixes

- Fix text not being hidden behind the globe when overlap mode was set to `always` ([#4802](https://github.com/maplibre/maplibre-gl-js/issues/4802))
- Fix 3D models in custom layers not being properly occluded by the globe ([#4817](https://github.com/maplibre/maplibre-gl-js/issues/4817))
- Fix a single white frame being displayed when the map internally transitions from mercator to globe projection ([#4816](https://github.com/maplibre/maplibre-gl-js/issues/4816))
- _...Add new stuff here..._
- Fix loading of RTL plugin version 0.3.0 ([#4860](https://github.com/maplibre/maplibre-gl-js/pull/4860))

## 5.0.0-pre.2

Expand Down
2 changes: 1 addition & 1 deletion build/generate-doc-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function createImage(exampleName) {
const waitTime = (exampleName.includes('3d-model') || exampleName.includes('globe')) ? 5000 : 1500;
console.log(`waiting for ${waitTime} ms`);
await new Promise(resolve => setTimeout(resolve, waitTime));
} catch (err) {
} catch {
// map.loaded() does not evaluate to true within 3 seconds, it's probably an animated example.
// In this case we take the screenshot immediately.
console.log(`Timed out waiting for map load on ${exampleName}.`);
Expand Down
2 changes: 1 addition & 1 deletion build/generate-struct-arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export class ${structArrayClass} extends ${structArrayLayoutClass} {`);
output.push(
` /**
* Return the ${structTypeClass} at the given location in the array.
* @param index The index of the element.
* @param index - The index of the element.
*/
get(index: number): ${structTypeClass} {
return new ${structTypeClass}(this, index);
Expand Down
5 changes: 2 additions & 3 deletions build/rollup_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const nodeResolve = resolve({
preferBuiltins: false
});

export const plugins = (production: boolean, minified: boolean): Plugin[] => [
export const plugins = (production: boolean): Plugin[] => [
json(),
// https://github.com/zaach/jison/issues/351
replace({
Expand All @@ -31,9 +31,8 @@ export const plugins = (production: boolean, minified: boolean): Plugin[] => [
sourceMap: true,
functions: ['PerformanceUtils.*']
}),
minified && terser({
terser({
compress: {
// eslint-disable-next-line camelcase
pure_getters: true,
passes: 3
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added developer-guides/assets/center-point_nominal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions developer-guides/center-point.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# How Camera position is calculated

This guide describes how camera position is calculated from the center point, zoom, and camera rotation.
The `Transform` variables `center`, `elevation`, `zoom`, `pitch`, `bearing`, and `fov` control the location of the camera indirectly.

`elevation` sets the height of the "center point" above sea level. In the typical use case (`centerClampedToGround = true`), the library modifies `elevation` in an attempt to keep the center point always on the terrain (or 0 MSL if no terrain is enabled). When `centerClampedToGround = false`, the user provides the elevation of the center point.

`zoom` sets the distance from the center point to the camera (in conjunction with `fovInRadians`, which is currently hardcoded).

Together, `zoom`, `elevation`, and `pitch` set the altitude of the camera:

See `MercatorTransform::getCameraAltitude()`:
```typescript
getCameraAltitude(): number {
const altitude = Math.cos(this.pitchInRadians) * this._cameraToCenterDistance / this._helper._pixelPerMeter;
return altitude + this.elevation;
}
```

![image](assets/center-point_nominal.png)

To allow pitch > 90, the "center point" must be placed off of the ground. This will allow the camera to stay above the ground when it pitches above 90. This requires setting `centerClampedToGround = false`.

![image](assets/center-point_high-pitch.png)

The same math applies whether the center point is on terrain or not, and whether the camera is above or below the ground:

![image](assets/center-point_straight-up.png)
![image](assets/center-point_underground.png)


To help users position the camera, `Camera` exports the function `calculateCameraOptionsFromCameraLngLatAltRotation()`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/examples/center-point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
157 changes: 157 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import stylisticTs from '@stylistic/eslint-plugin-ts'
import tsdoc from 'eslint-plugin-tsdoc';
import jest from 'eslint-plugin-jest';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import react from 'eslint-plugin-react';
import html from 'eslint-plugin-html';

export default [
{
ignores: ['build/*.js', 'staging/**', 'coverage/**', 'node_modules/**', 'docs/**', 'dist/**']
},
{
ignores: ['test/bench/**'],
files: ['**/*.ts', '**/*.js'],
plugins: {
'@typescript-eslint': typescriptEslint,
'@stylistic': stylisticTs,
tsdoc,
jest,
},

linterOptions: {
reportUnusedDisableDirectives: true,
},

languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
performance: true,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
createDefaultProgram: true,
},
},

rules: {
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': ['error'],

'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
}],

'@stylistic/member-delimiter-style': ['error'],
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': ['error'],
'no-undef': 'off',
'no-use-before-define': 'off',
'no-duplicate-imports': 'off',
'implicit-arrow-linebreak': 'off',
'arrow-parens': 'off',
'arrow-body-style': 'off',
'no-confusing-arrow': 'off',
'no-control-regex': 'off',
'no-invalid-this': 'off',
'no-buffer-constructor': 'off',
'array-bracket-spacing': 'error',
'consistent-return': 'off',
'global-require': 'off',
'key-spacing': 'error',
'no-eq-null': 'off',
'no-lonely-if': 'off',
'no-new': 'off',

'no-restricted-properties': [2, {
object: 'Object',
property: 'assign',
}],

'no-unused-vars': 'off',
'no-warning-comments': 'error',
'object-curly-spacing': ['error', 'never'],
'prefer-arrow-callback': 'error',

'prefer-const': ['error', {
destructuring: 'all',
}],

'prefer-template': 'error',
'prefer-spread': 'off',
quotes: 'off',
'@stylistic/quotes': ['error', 'single'],
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': ['error'],
'space-before-function-paren': 'off',
'template-curly-spacing': 'error',
'no-useless-escape': 'off',
indent: 'off',
'@stylistic/indent': ['error'],

'no-multiple-empty-lines': ['error', {
max: 1,
}],

'tsdoc/syntax': 'warn',
'jest/no-commented-out-tests': 'error',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/prefer-to-contain': 'warn',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'jest/prefer-to-be': 'warn',
'jest/no-alias-methods': 'warn',
'jest/no-interpolation-in-snapshots': 'warn',

'jest/no-large-snapshots': ['warn', {
maxSize: 50,
inlineMaxSize: 20,
}],

'jest/no-deprecated-functions': 'warn',
},
},
{
files: ['**/*.html'],
plugins: {
html
},
rules: {
'no-restricted-properties': 'off',
'new-cap': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
},
{
files: ['test/bench/**/*.jsx', 'test/bench/**/*.js', 'test/bench/**/*.ts'],
plugins: {
react
},
rules: {
'react/jsx-uses-vars': [2],
'no-restricted-properties': 'off'
},
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
performance: true,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
createDefaultProgram: true,
},
},
},

];
Loading