maplibre-gl 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/build/generate-shaders.ts +39 -6
- package/build/readme.md +0 -5
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +185 -142
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +44 -40
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +33 -32
- package/src/geo/lng_lat.ts +2 -2
- package/src/gl/context.ts +27 -10
- package/src/gl/types.ts +14 -14
- package/src/gl/value.ts +11 -3
- package/src/gl/vertex_buffer.ts +2 -2
- package/src/gl/webgl2.ts +12 -0
- package/src/render/draw_heatmap.ts +1 -0
- package/src/render/painter.ts +1 -1
- package/src/render/program.ts +1 -4
- package/src/render/texture.ts +4 -4
- package/src/render/uniform_binding.ts +1 -1
- package/src/shaders/README.md +2 -2
- package/src/shaders/_prelude.fragment.glsl.g.ts +1 -1
- package/src/shaders/_prelude.vertex.glsl.g.ts +1 -1
- package/src/shaders/background.fragment.glsl.g.ts +1 -1
- package/src/shaders/background.vertex.glsl.g.ts +1 -1
- package/src/shaders/background_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/background_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/circle.fragment.glsl.g.ts +1 -1
- package/src/shaders/circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +1 -1
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +1 -1
- package/src/shaders/collision_box.fragment.glsl.g.ts +1 -1
- package/src/shaders/collision_box.vertex.glsl.g.ts +1 -1
- package/src/shaders/collision_circle.fragment.glsl.g.ts +1 -1
- package/src/shaders/collision_circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/debug.fragment.glsl.g.ts +1 -1
- package/src/shaders/debug.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_outline.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_outline.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/heatmap.fragment.glsl.g.ts +1 -1
- package/src/shaders/heatmap.vertex.glsl.g.ts +1 -1
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +1 -1
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +1 -1
- package/src/shaders/hillshade.fragment.glsl.g.ts +1 -1
- package/src/shaders/hillshade.vertex.glsl.g.ts +1 -1
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +1 -1
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +1 -1
- package/src/shaders/line.fragment.glsl.g.ts +1 -1
- package/src/shaders/line.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_gradient.fragment.glsl.g.ts +1 -1
- package/src/shaders/line_gradient.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/line_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_sdf.fragment.glsl.g.ts +1 -1
- package/src/shaders/line_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/raster.fragment.glsl.g.ts +1 -1
- package/src/shaders/raster.vertex.glsl.g.ts +1 -1
- package/src/shaders/shaders.ts +5 -5
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +1 -1
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +1 -1
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +1 -1
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/terrain.fragment.glsl.g.ts +1 -1
- package/src/shaders/terrain.vertex.glsl.g.ts +1 -1
- package/src/shaders/terrain_coords.fragment.glsl.g.ts +1 -1
- package/src/shaders/terrain_depth.fragment.glsl.g.ts +1 -1
- package/src/source/raster_dem_tile_source.ts +4 -3
- package/src/source/source_cache.ts +8 -3
- package/src/source/vector_tile_source.test.ts +11 -11
- package/src/source/vector_tile_worker_source.ts +1 -1
- package/src/style/style_layer/custom_style_layer.ts +6 -6
- package/src/ui/control/attribution_control.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +1 -1
- package/src/ui/control/geolocate_control.ts +6 -6
- package/src/ui/control/navigation_control.ts +4 -4
- package/src/ui/control/scale_control.ts +1 -1
- package/src/ui/control/terrain_control.ts +4 -5
- package/src/ui/map.test.ts +11 -0
- package/src/ui/map.ts +19 -12
- package/src/ui/marker.ts +2 -2
- package/src/ui/popup.ts +2 -2
- package/src/util/browser.ts +2 -2
- package/src/util/config.ts +2 -0
- package/src/util/test/mock_webgl.ts +4 -1
- package/src/util/webp_supported.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplibre-gl",
|
|
3
3
|
"description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",
|
|
4
|
-
"version": "3.0
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"main": "dist/maplibre-gl.js",
|
|
6
6
|
"style": "dist/maplibre-gl.css",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
@@ -41,22 +41,22 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
|
|
43
43
|
"@mapbox/mvt-fixtures": "^3.10.0",
|
|
44
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
44
|
+
"@rollup/plugin-commonjs": "^25.0.1",
|
|
45
45
|
"@rollup/plugin-json": "^6.0.0",
|
|
46
|
-
"@rollup/plugin-node-resolve": "^15.0
|
|
46
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
47
47
|
"@rollup/plugin-replace": "^5.0.2",
|
|
48
48
|
"@rollup/plugin-strip": "^3.0.2",
|
|
49
|
-
"@rollup/plugin-terser": "^0.4.
|
|
49
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
50
50
|
"@rollup/plugin-typescript": "^11.1.1",
|
|
51
51
|
"@types/benchmark": "^2.1.2",
|
|
52
52
|
"@types/cssnano": "^5.0.0",
|
|
53
53
|
"@types/d3": "^7.4.0",
|
|
54
54
|
"@types/diff": "^5.0.3",
|
|
55
55
|
"@types/earcut": "^2.1.1",
|
|
56
|
-
"@types/eslint": "^8.
|
|
56
|
+
"@types/eslint": "^8.40.0",
|
|
57
57
|
"@types/gl": "^6.0.2",
|
|
58
58
|
"@types/glob": "^8.1.0",
|
|
59
|
-
"@types/jest": "^29.5.
|
|
59
|
+
"@types/jest": "^29.5.2",
|
|
60
60
|
"@types/jsdom": "^21.1.1",
|
|
61
61
|
"@types/minimist": "^1.2.2",
|
|
62
62
|
"@types/murmurhash-js": "^1.0.4",
|
|
@@ -65,39 +65,39 @@
|
|
|
65
65
|
"@types/offscreencanvas": "^2019.7.0",
|
|
66
66
|
"@types/pixelmatch": "^5.2.4",
|
|
67
67
|
"@types/pngjs": "^6.0.1",
|
|
68
|
-
"@types/react": "^18.2.
|
|
68
|
+
"@types/react": "^18.2.11",
|
|
69
69
|
"@types/react-dom": "^18.2.4",
|
|
70
70
|
"@types/request": "^2.48.8",
|
|
71
71
|
"@types/shuffle-seed": "^1.1.0",
|
|
72
72
|
"@types/supercluster": "^7.1.0",
|
|
73
73
|
"@types/window-or-global": "^1.0.4",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
75
|
-
"@typescript-eslint/parser": "^5.59.
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
75
|
+
"@typescript-eslint/parser": "^5.59.11",
|
|
76
76
|
"address": "^1.2.2",
|
|
77
77
|
"benchmark": "^2.1.4",
|
|
78
78
|
"canvas": "^2.11.2",
|
|
79
79
|
"cssnano": "^6.0.1",
|
|
80
|
-
"d3": "^7.8.
|
|
80
|
+
"d3": "^7.8.5",
|
|
81
81
|
"d3-queue": "^3.0.7",
|
|
82
|
-
"devtools-protocol": "^0.0.
|
|
82
|
+
"devtools-protocol": "^0.0.1155872",
|
|
83
83
|
"diff": "^5.1.0",
|
|
84
|
-
"documentation": "14.0.
|
|
84
|
+
"documentation": "14.0.2",
|
|
85
85
|
"dts-bundle-generator": "^8.0.1",
|
|
86
|
-
"eslint": "^8.
|
|
86
|
+
"eslint": "^8.42.0",
|
|
87
87
|
"eslint-config-mourner": "^3.0.0",
|
|
88
88
|
"eslint-plugin-html": "^7.1.0",
|
|
89
89
|
"eslint-plugin-import": "^2.27.5",
|
|
90
90
|
"eslint-plugin-jest": "^27.2.1",
|
|
91
|
-
"eslint-plugin-jsdoc": "^
|
|
91
|
+
"eslint-plugin-jsdoc": "^46.2.6",
|
|
92
92
|
"eslint-plugin-react": "^7.32.2",
|
|
93
93
|
"expect": "^29.5.0",
|
|
94
94
|
"gl": "^6.0.2",
|
|
95
|
-
"glob": "^10.2.
|
|
95
|
+
"glob": "^10.2.7",
|
|
96
96
|
"is-builtin-module": "^3.2.1",
|
|
97
97
|
"jest": "^29.5.0",
|
|
98
|
-
"jest-canvas-mock": "^2.5.
|
|
98
|
+
"jest-canvas-mock": "^2.5.1",
|
|
99
99
|
"jest-environment-jsdom": "^29.5.0",
|
|
100
|
-
"jsdom": "^22.
|
|
100
|
+
"jsdom": "^22.1.0",
|
|
101
101
|
"json-stringify-pretty-compact": "^4.0.0",
|
|
102
102
|
"minimist": "^1.2.8",
|
|
103
103
|
"mock-geolocation": "^1.0.11",
|
|
@@ -108,26 +108,26 @@
|
|
|
108
108
|
"pdf-merger-js": "^4.3.0",
|
|
109
109
|
"pixelmatch": "^5.3.0",
|
|
110
110
|
"pngjs": "^7.0.0",
|
|
111
|
-
"postcss": "^8.4.
|
|
111
|
+
"postcss": "^8.4.24",
|
|
112
112
|
"postcss-cli": "^10.1.0",
|
|
113
113
|
"postcss-inline-svg": "^6.0.0",
|
|
114
114
|
"pretty-bytes": "^6.1.0",
|
|
115
|
-
"puppeteer": "^20.
|
|
115
|
+
"puppeteer": "^20.7.1",
|
|
116
116
|
"react": "^18.2.0",
|
|
117
117
|
"react-dom": "^18.2.0",
|
|
118
|
-
"rollup": "^3.
|
|
118
|
+
"rollup": "^3.25.1",
|
|
119
119
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
120
120
|
"rw": "^1.3.3",
|
|
121
121
|
"semver": "^7.5.1",
|
|
122
122
|
"shuffle-seed": "^1.1.6",
|
|
123
123
|
"source-map-explorer": "^2.5.3",
|
|
124
124
|
"st": "^3.0.0",
|
|
125
|
-
"stylelint": "^15.
|
|
125
|
+
"stylelint": "^15.7.0",
|
|
126
126
|
"stylelint-config-standard": "^33.0.0",
|
|
127
127
|
"ts-jest": "^29.1.0",
|
|
128
128
|
"ts-node": "^10.9.1",
|
|
129
|
-
"tslib": "^2.5.
|
|
130
|
-
"typescript": "^5.
|
|
129
|
+
"tslib": "^2.5.2",
|
|
130
|
+
"typescript": "^5.1.3"
|
|
131
131
|
},
|
|
132
132
|
"overrides": {
|
|
133
133
|
"postcss-inline-svg": {
|
|
@@ -138,11 +138,11 @@
|
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
"scripts": {
|
|
141
|
-
"generate-dist-package": "
|
|
142
|
-
"generate-shaders": "
|
|
143
|
-
"generate-struct-arrays": "
|
|
144
|
-
"generate-style-code": "
|
|
145
|
-
"generate-typings": "
|
|
141
|
+
"generate-dist-package": "npm run tsnode build/generate-dist-package.js",
|
|
142
|
+
"generate-shaders": "npm run tsnode build/generate-shaders.ts",
|
|
143
|
+
"generate-struct-arrays": "npm run tsnode build/generate-struct-arrays.ts",
|
|
144
|
+
"generate-style-code": "npm run tsnode build/generate-style-code.ts",
|
|
145
|
+
"generate-typings": "npm run tsnode build/generate-typings.ts",
|
|
146
146
|
"build-dist": "run-p --print-label generate-typings build-dev build-prod build-csp build-csp-dev build-css",
|
|
147
147
|
"build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev",
|
|
148
148
|
"watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch",
|
|
@@ -165,14 +165,15 @@
|
|
|
165
165
|
"jest-ci": "jest --reporters=github-actions --reporters=summary",
|
|
166
166
|
"test-build": "jest --selectProjects=build",
|
|
167
167
|
"test-integration": "jest --selectProjects=integration",
|
|
168
|
-
"test-render": "
|
|
168
|
+
"test-render": "npm run tsnode test/integration/render/run_render_tests.ts",
|
|
169
169
|
"test-unit": "jest --selectProjects=unit",
|
|
170
170
|
"test-watch-roots": "jest --watch",
|
|
171
171
|
"codegen": "run-p generate-dist-package generate-style-code generate-struct-arrays generate-shaders",
|
|
172
|
-
"benchmark": "
|
|
173
|
-
"gl-stats": "
|
|
172
|
+
"benchmark": "npm run tsnode test/bench/run-benchmarks.ts",
|
|
173
|
+
"gl-stats": "npm run tsnode test/bench/gl-stats.ts",
|
|
174
174
|
"prepare": "npm run codegen",
|
|
175
|
-
"typecheck": "tsc --noEmit"
|
|
175
|
+
"typecheck": "tsc --noEmit && tsc --project tsconfig.dist.json",
|
|
176
|
+
"tsnode": "node --experimental-loader=ts-node/esm --no-warnings"
|
|
176
177
|
},
|
|
177
178
|
"files": [
|
|
178
179
|
"build/",
|
package/src/geo/lng_lat.ts
CHANGED
|
@@ -11,10 +11,10 @@ export const earthRadius = 6371008.8;
|
|
|
11
11
|
* A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
|
|
12
12
|
* These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
|
|
13
13
|
*
|
|
14
|
-
* MapLibre GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
|
|
14
|
+
* MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
|
|
15
15
|
* [GeoJSON specification](https://tools.ietf.org/html/rfc7946).
|
|
16
16
|
*
|
|
17
|
-
* Note that any MapLibre GL method that accepts a `LngLat` object as an argument or option
|
|
17
|
+
* Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option
|
|
18
18
|
* can also accept an `Array` of two numbers and will perform an implicit conversion.
|
|
19
19
|
* This flexible type is documented as {@link LngLatLike}.
|
|
20
20
|
*
|
package/src/gl/context.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
StructArrayMember
|
|
16
16
|
} from '../util/struct_array';
|
|
17
17
|
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
+
import {isWebGL2} from './webgl2';
|
|
18
19
|
|
|
19
20
|
type ClearArgs = {
|
|
20
21
|
color?: Color;
|
|
@@ -23,7 +24,7 @@ type ClearArgs = {
|
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
class Context {
|
|
26
|
-
gl: WebGL2RenderingContext;
|
|
27
|
+
gl: WebGLRenderingContext | WebGL2RenderingContext;
|
|
27
28
|
|
|
28
29
|
currentNumAttributes: number;
|
|
29
30
|
maxTextureSize: number;
|
|
@@ -67,7 +68,7 @@ class Context {
|
|
|
67
68
|
RGBA16F?: GLenum;
|
|
68
69
|
RGB16F?: GLenum;
|
|
69
70
|
|
|
70
|
-
constructor(gl: WebGL2RenderingContext) {
|
|
71
|
+
constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) {
|
|
71
72
|
this.gl = gl;
|
|
72
73
|
this.clearColor = new ClearColor(this);
|
|
73
74
|
this.clearDepth = new ClearDepth(this);
|
|
@@ -101,18 +102,30 @@ class Context {
|
|
|
101
102
|
this.pixelStoreUnpackPremultiplyAlpha = new PixelStoreUnpackPremultiplyAlpha(this);
|
|
102
103
|
this.pixelStoreUnpackFlipY = new PixelStoreUnpackFlipY(this);
|
|
103
104
|
|
|
104
|
-
this.extTextureFilterAnisotropic =
|
|
105
|
+
this.extTextureFilterAnisotropic = (
|
|
106
|
+
gl.getExtension('EXT_texture_filter_anisotropic') ||
|
|
107
|
+
gl.getExtension('MOZ_EXT_texture_filter_anisotropic') ||
|
|
108
|
+
gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')
|
|
109
|
+
);
|
|
110
|
+
|
|
105
111
|
if (this.extTextureFilterAnisotropic) {
|
|
106
112
|
this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
|
|
110
|
-
this.HALF_FLOAT = gl.HALF_FLOAT;
|
|
111
116
|
|
|
112
|
-
gl
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
if (isWebGL2(gl)) {
|
|
118
|
+
this.HALF_FLOAT = gl.HALF_FLOAT;
|
|
119
|
+
const extColorBufferHalfFloat = gl.getExtension('EXT_color_buffer_half_float');
|
|
120
|
+
this.RGBA16F = gl.RGBA16F ?? extColorBufferHalfFloat?.RGBA16F_EXT;
|
|
121
|
+
this.RGB16F = gl.RGB16F ?? extColorBufferHalfFloat?.RGB16F_EXT;
|
|
122
|
+
gl.getExtension('EXT_color_buffer_float');
|
|
123
|
+
} else {
|
|
124
|
+
gl.getExtension('EXT_color_buffer_half_float');
|
|
125
|
+
gl.getExtension('OES_texture_half_float_linear');
|
|
126
|
+
const extTextureHalfFloat = gl.getExtension('OES_texture_half_float');
|
|
127
|
+
this.HALF_FLOAT = extTextureHalfFloat?.HALF_FLOAT_OES;
|
|
128
|
+
}
|
|
116
129
|
}
|
|
117
130
|
|
|
118
131
|
setDefault() {
|
|
@@ -285,11 +298,15 @@ class Context {
|
|
|
285
298
|
}
|
|
286
299
|
|
|
287
300
|
createVertexArray(): WebGLVertexArrayObject | undefined {
|
|
288
|
-
|
|
301
|
+
if (isWebGL2(this.gl))
|
|
302
|
+
return this.gl.createVertexArray();
|
|
303
|
+
return this.gl.getExtension('OES_vertex_array_object')?.createVertexArrayOES();
|
|
289
304
|
}
|
|
290
305
|
|
|
291
306
|
deleteVertexArray(x: WebGLVertexArrayObject | undefined) {
|
|
292
|
-
|
|
307
|
+
if (isWebGL2(this.gl))
|
|
308
|
+
return this.gl.deleteVertexArray(x);
|
|
309
|
+
return this.gl.getExtension('OES_vertex_array_object')?.deleteVertexArrayOES(x);
|
|
293
310
|
}
|
|
294
311
|
|
|
295
312
|
unbindVAO() {
|
package/src/gl/types.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
type BlendFuncConstant =
|
|
1
|
+
type BlendFuncConstant = WebGLRenderingContextBase['ZERO'] | WebGLRenderingContextBase['ONE'] | WebGLRenderingContextBase['SRC_COLOR'] | WebGLRenderingContextBase['ONE_MINUS_SRC_COLOR'] | WebGLRenderingContextBase['DST_COLOR'] | WebGLRenderingContextBase['ONE_MINUS_DST_COLOR'] | WebGLRenderingContextBase['SRC_ALPHA'] | WebGLRenderingContextBase['ONE_MINUS_SRC_ALPHA'] | WebGLRenderingContextBase['DST_ALPHA'] | WebGLRenderingContextBase['ONE_MINUS_DST_ALPHA'] | WebGLRenderingContextBase['CONSTANT_COLOR'] | WebGLRenderingContextBase['ONE_MINUS_CONSTANT_COLOR'] | WebGLRenderingContextBase['CONSTANT_ALPHA'] | WebGLRenderingContextBase['ONE_MINUS_CONSTANT_ALPHA'] | WebGLRenderingContextBase['BLEND_COLOR'];
|
|
2
2
|
|
|
3
3
|
export type BlendFuncType = [BlendFuncConstant, BlendFuncConstant];
|
|
4
4
|
|
|
5
|
-
export type BlendEquationType =
|
|
5
|
+
export type BlendEquationType = WebGLRenderingContextBase['FUNC_ADD'] | WebGLRenderingContextBase['FUNC_SUBTRACT'] | WebGLRenderingContextBase['FUNC_REVERSE_SUBTRACT'];
|
|
6
6
|
|
|
7
7
|
export type ColorMaskType = [boolean, boolean, boolean, boolean];
|
|
8
8
|
|
|
9
|
-
export type CompareFuncType =
|
|
9
|
+
export type CompareFuncType = WebGLRenderingContextBase['NEVER'] | WebGLRenderingContextBase['LESS'] | WebGLRenderingContextBase['EQUAL'] | WebGLRenderingContextBase['LEQUAL'] | WebGLRenderingContextBase['GREATER'] | WebGLRenderingContextBase['NOTEQUAL'] | WebGLRenderingContextBase['GEQUAL'] | WebGLRenderingContextBase['ALWAYS'];
|
|
10
10
|
|
|
11
11
|
export type DepthMaskType = boolean;
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ export type StencilFuncType = {
|
|
|
20
20
|
mask: number;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export type StencilOpConstant =
|
|
23
|
+
export type StencilOpConstant = WebGLRenderingContextBase['KEEP'] | WebGLRenderingContextBase['ZERO'] | WebGLRenderingContextBase['REPLACE'] | WebGLRenderingContextBase['INCR'] | WebGLRenderingContextBase['INCR_WRAP'] | WebGLRenderingContextBase['DECR'] | WebGLRenderingContextBase['DECR_WRAP'] | WebGLRenderingContextBase['INVERT'];
|
|
24
24
|
|
|
25
25
|
export type StencilOpType = [StencilOpConstant, StencilOpConstant, StencilOpConstant];
|
|
26
26
|
|
|
@@ -29,31 +29,31 @@ export type TextureUnitType = number;
|
|
|
29
29
|
export type ViewportType = [number, number, number, number];
|
|
30
30
|
|
|
31
31
|
export type StencilTestGL = {
|
|
32
|
-
func:
|
|
32
|
+
func: WebGLRenderingContextBase['NEVER'];
|
|
33
33
|
mask: 0;
|
|
34
34
|
} | {
|
|
35
|
-
func:
|
|
35
|
+
func: WebGLRenderingContextBase['LESS'];
|
|
36
36
|
mask: number;
|
|
37
37
|
} | {
|
|
38
|
-
func:
|
|
38
|
+
func: WebGLRenderingContextBase['EQUAL'];
|
|
39
39
|
mask: number;
|
|
40
40
|
} | {
|
|
41
|
-
func:
|
|
41
|
+
func: WebGLRenderingContextBase['LEQUAL'];
|
|
42
42
|
mask: number;
|
|
43
43
|
} | {
|
|
44
|
-
func:
|
|
44
|
+
func: WebGLRenderingContextBase['GREATER'];
|
|
45
45
|
mask: number;
|
|
46
46
|
} | {
|
|
47
|
-
func:
|
|
47
|
+
func: WebGLRenderingContextBase['NOTEQUAL'];
|
|
48
48
|
mask: number;
|
|
49
49
|
} | {
|
|
50
|
-
func:
|
|
50
|
+
func: WebGLRenderingContextBase['GEQUAL'];
|
|
51
51
|
mask: number;
|
|
52
52
|
} | {
|
|
53
|
-
func:
|
|
53
|
+
func: WebGLRenderingContextBase['ALWAYS'];
|
|
54
54
|
mask: 0;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export type CullFaceModeType =
|
|
57
|
+
export type CullFaceModeType = WebGLRenderingContextBase['FRONT'] | WebGLRenderingContextBase['BACK'] | WebGLRenderingContextBase['FRONT_AND_BACK'];
|
|
58
58
|
|
|
59
|
-
export type FrontFaceType =
|
|
59
|
+
export type FrontFaceType = WebGLRenderingContextBase['CW'] | WebGLRenderingContextBase['CCW'];
|
package/src/gl/value.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
+
import {isWebGL2} from './webgl2';
|
|
2
3
|
|
|
3
4
|
import type Context from './context';
|
|
4
5
|
import type {
|
|
@@ -26,7 +27,7 @@ export interface IValue<T> {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
class BaseValue<T> implements IValue<T> {
|
|
29
|
-
gl: WebGL2RenderingContext;
|
|
30
|
+
gl: WebGLRenderingContext|WebGL2RenderingContext;
|
|
30
31
|
current: T;
|
|
31
32
|
default: T;
|
|
32
33
|
dirty: boolean;
|
|
@@ -417,14 +418,20 @@ export class BindElementBuffer extends BaseValue<WebGLBuffer> {
|
|
|
417
418
|
}
|
|
418
419
|
}
|
|
419
420
|
|
|
420
|
-
export class BindVertexArray extends BaseValue<WebGLVertexArrayObject> {
|
|
421
|
+
export class BindVertexArray extends BaseValue<WebGLVertexArrayObject | null> {
|
|
421
422
|
getDefault(): WebGLVertexArrayObject | null {
|
|
422
423
|
return null;
|
|
423
424
|
}
|
|
424
425
|
set(v: WebGLVertexArrayObject | null) {
|
|
425
426
|
if (v === this.current && !this.dirty) return;
|
|
426
427
|
const gl = this.gl;
|
|
427
|
-
|
|
428
|
+
|
|
429
|
+
if (isWebGL2(gl)) {
|
|
430
|
+
gl.bindVertexArray(v);
|
|
431
|
+
} else {
|
|
432
|
+
gl.getExtension('OES_vertex_array_object')?.bindVertexArrayOES(v);
|
|
433
|
+
}
|
|
434
|
+
|
|
428
435
|
this.current = v;
|
|
429
436
|
this.dirty = false;
|
|
430
437
|
}
|
|
@@ -494,6 +501,7 @@ export class ColorAttachment extends FramebufferAttachment<WebGLTexture> {
|
|
|
494
501
|
// attachment point, but thus far MBGL only uses textures for color
|
|
495
502
|
const gl = this.gl;
|
|
496
503
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, v, 0);
|
|
504
|
+
|
|
497
505
|
this.current = v;
|
|
498
506
|
this.dirty = false;
|
|
499
507
|
}
|
package/src/gl/vertex_buffer.ts
CHANGED
|
@@ -67,7 +67,7 @@ class VertexBuffer {
|
|
|
67
67
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
enableAttributes(gl: WebGL2RenderingContext, program: Program<any>) {
|
|
70
|
+
enableAttributes(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program<any>) {
|
|
71
71
|
for (let j = 0; j < this.attributes.length; j++) {
|
|
72
72
|
const member = this.attributes[j];
|
|
73
73
|
const attribIndex: number | void = program.attributes[member.name];
|
|
@@ -83,7 +83,7 @@ class VertexBuffer {
|
|
|
83
83
|
* @param program The active WebGL program
|
|
84
84
|
* @param vertexOffset Index of the starting vertex of the segment
|
|
85
85
|
*/
|
|
86
|
-
setVertexAttribPointers(gl: WebGL2RenderingContext, program: Program<any>, vertexOffset?: number | null) {
|
|
86
|
+
setVertexAttribPointers(gl: WebGLRenderingContext|WebGL2RenderingContext, program: Program<any>, vertexOffset?: number | null) {
|
|
87
87
|
for (let j = 0; j < this.attributes.length; j++) {
|
|
88
88
|
const member = this.attributes[j];
|
|
89
89
|
const attribIndex: number | void = program.attributes[member.name];
|
package/src/gl/webgl2.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const cache = new WeakMap();
|
|
2
|
+
export function isWebGL2(
|
|
3
|
+
gl: WebGLRenderingContext | WebGL2RenderingContext
|
|
4
|
+
): gl is WebGL2RenderingContext {
|
|
5
|
+
if (cache.has(gl)) {
|
|
6
|
+
return cache.get(gl);
|
|
7
|
+
} else {
|
|
8
|
+
const value = gl.getParameter(gl.VERSION).startsWith('WebGL 2.0');
|
|
9
|
+
cache.set(gl, value);
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -100,6 +100,7 @@ function bindTextureToFramebuffer(context: Context, painter: Painter, texture: W
|
|
|
100
100
|
const gl = context.gl;
|
|
101
101
|
// Use the higher precision half-float texture where available (producing much smoother looking heatmaps);
|
|
102
102
|
// Otherwise, fall back to a low precision texture
|
|
103
|
+
|
|
103
104
|
const numType = context.HALF_FLOAT ?? gl.UNSIGNED_BYTE;
|
|
104
105
|
const internalFormat = context.RGBA16F ?? gl.RGBA;
|
|
105
106
|
|
package/src/render/painter.ts
CHANGED
|
@@ -128,7 +128,7 @@ class Painter {
|
|
|
128
128
|
// every time the camera-matrix changes the terrain-facilitators will be redrawn.
|
|
129
129
|
terrainFacilitator: {dirty: boolean; matrix: mat4; renderTime: number};
|
|
130
130
|
|
|
131
|
-
constructor(gl: WebGL2RenderingContext, transform: Transform) {
|
|
131
|
+
constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, transform: Transform) {
|
|
132
132
|
this.context = new Context(gl);
|
|
133
133
|
this.transform = transform;
|
|
134
134
|
this._tileTextures = {};
|
package/src/render/program.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {terrainPreludeUniforms, TerrainPreludeUniformsType} from './program/terr
|
|
|
16
16
|
import type {TerrainData} from '../render/terrain';
|
|
17
17
|
import Terrain from '../render/terrain';
|
|
18
18
|
|
|
19
|
-
export type DrawMode =
|
|
19
|
+
export type DrawMode = WebGLRenderingContextBase['LINES'] | WebGLRenderingContextBase['TRIANGLES'] | WebGL2RenderingContext['LINE_STRIP'];
|
|
20
20
|
|
|
21
21
|
function getTokenizedAttributesAndUniforms(array: Array<string>): Array<string> {
|
|
22
22
|
const result = [];
|
|
@@ -75,8 +75,6 @@ class Program<Us extends UniformBindings> {
|
|
|
75
75
|
defines.push('#define TERRAIN3D;');
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
defines.unshift('#version 300 es');
|
|
79
|
-
|
|
80
78
|
const fragmentSource = defines.concat(shaders.prelude.fragmentSource, source.fragmentSource).join('\n');
|
|
81
79
|
const vertexSource = defines.concat(shaders.prelude.vertexSource, source.vertexSource).join('\n');
|
|
82
80
|
|
|
@@ -111,7 +109,6 @@ class Program<Us extends UniformBindings> {
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
gl.linkProgram(this.program);
|
|
114
|
-
|
|
115
112
|
gl.deleteShader(vertexShader);
|
|
116
113
|
gl.deleteShader(fragmentShader);
|
|
117
114
|
|
package/src/render/texture.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type Context from '../gl/context';
|
|
|
2
2
|
import type {RGBAImage, AlphaImage} from '../util/image';
|
|
3
3
|
import {isImageBitmap} from '../util/util';
|
|
4
4
|
|
|
5
|
-
export type TextureFormat =
|
|
6
|
-
export type TextureFilter =
|
|
7
|
-
export type TextureWrap =
|
|
5
|
+
export type TextureFormat = WebGLRenderingContextBase['RGBA'] | WebGLRenderingContextBase['ALPHA'];
|
|
6
|
+
export type TextureFilter = WebGLRenderingContextBase['LINEAR'] | WebGLRenderingContextBase['LINEAR_MIPMAP_NEAREST'] | WebGLRenderingContextBase['NEAREST'];
|
|
7
|
+
export type TextureWrap = WebGLRenderingContextBase['REPEAT'] | WebGLRenderingContextBase['CLAMP_TO_EDGE'] | WebGLRenderingContextBase['MIRRORED_REPEAT'];
|
|
8
8
|
|
|
9
9
|
type EmptyImage = {
|
|
10
10
|
width: number;
|
|
@@ -41,7 +41,7 @@ class Texture {
|
|
|
41
41
|
x: number;
|
|
42
42
|
y: number;
|
|
43
43
|
}) {
|
|
44
|
-
const {width, height} = image;
|
|
44
|
+
const {width, height} = image as {width: number; height: number};
|
|
45
45
|
const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position;
|
|
46
46
|
const {context} = this;
|
|
47
47
|
const {gl} = context;
|
|
@@ -11,7 +11,7 @@ export type UniformValues<Us extends {}> = $ObjMap<Us, <V>(u: Uniform<V>) => V>;
|
|
|
11
11
|
export type UniformLocations = {[_: string]: WebGLUniformLocation};
|
|
12
12
|
|
|
13
13
|
abstract class Uniform<T> {
|
|
14
|
-
gl: WebGL2RenderingContext;
|
|
14
|
+
gl: WebGLRenderingContext|WebGL2RenderingContext;
|
|
15
15
|
location: WebGLUniformLocation;
|
|
16
16
|
current: T;
|
|
17
17
|
|
package/src/shaders/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# MapLibre GL Shaders
|
|
1
|
+
# MapLibre GL JS Shaders
|
|
2
2
|
|
|
3
|
-
This repository contains
|
|
3
|
+
This repository contains the GLSL shaders
|
|
4
4
|
|
|
5
5
|
## Pragmas
|
|
6
6
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\
|
|
2
|
+
export default '#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(
|
|
2
|
+
export default '#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default 'uniform vec4 u_color;uniform float u_opacity;void main() {
|
|
2
|
+
export default 'uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;
|
|
2
|
+
export default 'uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;
|
|
2
|
+
export default 'uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;
|
|
2
|
+
export default 'uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default 'void main() {
|
|
2
|
+
export default 'void main() {gl_FragColor=vec4(1.0);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default 'uniform highp vec4 u_color;uniform sampler2D u_overlay;
|
|
2
|
+
export default 'uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
-
export default '
|
|
2
|
+
export default 'attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}';
|