ol 7.3.1-dev.1680098251703 → 7.3.1-dev.1680173927805
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/Map.d.ts.map +1 -1
- package/Map.js +1 -0
- package/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/package.json +1 -1
- package/render/webgl/BatchRenderer.d.ts +11 -8
- package/render/webgl/BatchRenderer.d.ts.map +1 -1
- package/render/webgl/BatchRenderer.js +20 -27
- package/render/webgl/MixedGeometryBatch.d.ts +36 -48
- package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
- package/render/webgl/MixedGeometryBatch.js +229 -110
- package/renderer/webgl/VectorLayer.d.ts +17 -0
- package/renderer/webgl/VectorLayer.d.ts.map +1 -1
- package/renderer/webgl/VectorLayer.js +55 -18
- package/renderer/webgl/VectorTileLayer.d.ts +160 -0
- package/renderer/webgl/VectorTileLayer.d.ts.map +1 -0
- package/renderer/webgl/VectorTileLayer.js +335 -0
- package/renderer/webgl/shaders.d.ts.map +1 -1
- package/renderer/webgl/shaders.js +68 -3
- package/util.js +1 -1
- package/webgl/Helper.d.ts +2 -2
- package/webgl/Helper.d.ts.map +1 -1
- package/webgl/Helper.js +4 -6
- package/webgl/TileGeometry.d.ts +37 -0
- package/webgl/TileGeometry.d.ts.map +1 -0
- package/webgl/TileGeometry.js +106 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export default WebGLVectorTileLayerRenderer;
|
|
2
|
+
/**
|
|
3
|
+
* A callback computing
|
|
4
|
+
* the value of a custom attribute (different for each feature) to be passed on to the GPU.
|
|
5
|
+
* Properties are available as 2nd arg for quicker access.
|
|
6
|
+
*/
|
|
7
|
+
export type CustomAttributeCallback = (arg0: import("../../Feature").default, arg1: {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}) => number;
|
|
10
|
+
/**
|
|
11
|
+
* An object containing both shaders (vertex and fragment) as well as the required attributes
|
|
12
|
+
*/
|
|
13
|
+
export type ShaderProgram = {
|
|
14
|
+
/**
|
|
15
|
+
* Vertex shader source (using the default one if unspecified).
|
|
16
|
+
*/
|
|
17
|
+
vertexShader?: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Fragment shader source (using the default one if unspecified).
|
|
20
|
+
*/
|
|
21
|
+
fragmentShader?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Custom attributes made available in the vertex shader.
|
|
24
|
+
* Keys are the names of the attributes which are then accessible in the vertex shader using the `a_` prefix, e.g.: `a_opacity`.
|
|
25
|
+
* Default shaders rely on the attributes in {@link module :ol/render/webgl/shaders~DefaultAttributes}.
|
|
26
|
+
*/
|
|
27
|
+
attributes: any;
|
|
28
|
+
};
|
|
29
|
+
export type Options = {
|
|
30
|
+
/**
|
|
31
|
+
* Attributes and shaders for filling polygons.
|
|
32
|
+
*/
|
|
33
|
+
fill?: ShaderProgram | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Attributes and shaders for line strings and polygon strokes.
|
|
36
|
+
*/
|
|
37
|
+
stroke?: ShaderProgram | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Attributes and shaders for points.
|
|
40
|
+
*/
|
|
41
|
+
point?: ShaderProgram | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Additional uniforms
|
|
44
|
+
* made available to shaders.
|
|
45
|
+
*/
|
|
46
|
+
uniforms?: {
|
|
47
|
+
[x: string]: import("../../webgl/Helper").UniformValue;
|
|
48
|
+
} | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The vector tile cache size.
|
|
51
|
+
*/
|
|
52
|
+
cacheSize?: number | undefined;
|
|
53
|
+
};
|
|
54
|
+
export type LayerType = import("../../layer/BaseTile.js").default<any, any>;
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {function(import("../../Feature").default, Object<string, *>):number} CustomAttributeCallback A callback computing
|
|
57
|
+
* the value of a custom attribute (different for each feature) to be passed on to the GPU.
|
|
58
|
+
* Properties are available as 2nd arg for quicker access.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* @typedef {Object} ShaderProgram An object containing both shaders (vertex and fragment) as well as the required attributes
|
|
62
|
+
* @property {string} [vertexShader] Vertex shader source (using the default one if unspecified).
|
|
63
|
+
* @property {string} [fragmentShader] Fragment shader source (using the default one if unspecified).
|
|
64
|
+
* @property {Object<import("./shaders.js").DefaultAttributes,CustomAttributeCallback>} attributes Custom attributes made available in the vertex shader.
|
|
65
|
+
* Keys are the names of the attributes which are then accessible in the vertex shader using the `a_` prefix, e.g.: `a_opacity`.
|
|
66
|
+
* Default shaders rely on the attributes in {@link module:ol/render/webgl/shaders~DefaultAttributes}.
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* @typedef {Object} Options
|
|
70
|
+
* @property {ShaderProgram} [fill] Attributes and shaders for filling polygons.
|
|
71
|
+
* @property {ShaderProgram} [stroke] Attributes and shaders for line strings and polygon strokes.
|
|
72
|
+
* @property {ShaderProgram} [point] Attributes and shaders for points.
|
|
73
|
+
* @property {Object<string, import("../../webgl/Helper").UniformValue>} [uniforms] Additional uniforms
|
|
74
|
+
* made available to shaders.
|
|
75
|
+
* @property {number} [cacheSize=512] The vector tile cache size.
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {import("../../layer/BaseTile.js").default} LayerType
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* @classdesc
|
|
82
|
+
* WebGL renderer for vector tile layers. Experimental.
|
|
83
|
+
* @extends {WebGLBaseTileLayerRenderer<LayerType>}
|
|
84
|
+
*/
|
|
85
|
+
declare class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer<import("../../layer/BaseTile.js").default<any, any>, any, any> {
|
|
86
|
+
/**
|
|
87
|
+
* @param {LayerType} tileLayer Tile layer.
|
|
88
|
+
* @param {Options} options Options.
|
|
89
|
+
*/
|
|
90
|
+
constructor(tileLayer: import("../../layer/BaseTile.js").default<any, any>, options: Options);
|
|
91
|
+
/**
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
private worker_;
|
|
95
|
+
/**
|
|
96
|
+
* @type {PolygonBatchRenderer}
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
private polygonRenderer_;
|
|
100
|
+
/**
|
|
101
|
+
* @type {PointBatchRenderer}
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
private pointRenderer_;
|
|
105
|
+
/**
|
|
106
|
+
* @type {LineStringBatchRenderer}
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
private lineStringRenderer_;
|
|
110
|
+
/**
|
|
111
|
+
* This transform is updated on every frame and is the composition of:
|
|
112
|
+
* - invert of the world->screen transform that was used when rebuilding buffers (see `this.renderTransform_`)
|
|
113
|
+
* - current world->screen transform
|
|
114
|
+
* @type {import("../../transform.js").Transform}
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private currentFrameStateTransform_;
|
|
118
|
+
tmpTransform_: number[];
|
|
119
|
+
tmpMat4_: number[];
|
|
120
|
+
/**
|
|
121
|
+
* @param {Options} options Options.
|
|
122
|
+
*/
|
|
123
|
+
reset(options: Options): void;
|
|
124
|
+
/**
|
|
125
|
+
* @param {Options} options Options.
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
private applyOptions_;
|
|
129
|
+
fillVertexShader_: string | undefined;
|
|
130
|
+
fillFragmentShader_: string | undefined;
|
|
131
|
+
fillAttributes_: import("../../render/webgl/BatchRenderer").CustomAttribute[] | undefined;
|
|
132
|
+
strokeVertexShader_: string | undefined;
|
|
133
|
+
strokeFragmentShader_: string | undefined;
|
|
134
|
+
strokeAttributes_: import("../../render/webgl/BatchRenderer").CustomAttribute[] | undefined;
|
|
135
|
+
pointVertexShader_: string | undefined;
|
|
136
|
+
pointFragmentShader_: string | undefined;
|
|
137
|
+
pointAttributes_: import("../../render/webgl/BatchRenderer").CustomAttribute[] | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private createRenderers_;
|
|
142
|
+
createTileRepresentation(options: any): TileGeometry;
|
|
143
|
+
beforeTilesRender(frameState: any, tilesWithAlpha: any): void;
|
|
144
|
+
/**
|
|
145
|
+
* @param {number} alpha Alpha value of the tile
|
|
146
|
+
* @param {import("../../extent.js").Extent} renderExtent Which extent to restrict drawing to
|
|
147
|
+
* @param {import("../../transform.js").Transform} batchInvertTransform Inverse of the transformation in which tile geometries are expressed
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
private applyUniforms_;
|
|
151
|
+
renderTile(tileRepresentation: any, tileTransform: any, frameState: any, renderExtent: any, tileResolution: any, tileSize: any, tileOrigin: any, tileExtent: any, depth: any, gutter: any, alpha: any): void;
|
|
152
|
+
/**
|
|
153
|
+
* Render declutter items for this layer
|
|
154
|
+
* @param {import("../../Map.js").FrameState} frameState Frame state.
|
|
155
|
+
*/
|
|
156
|
+
renderDeclutter(frameState: import("../../Map.js").FrameState): void;
|
|
157
|
+
}
|
|
158
|
+
import WebGLBaseTileLayerRenderer from './TileLayerBase.js';
|
|
159
|
+
import TileGeometry from '../../webgl/TileGeometry.js';
|
|
160
|
+
//# sourceMappingURL=VectorTileLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorTileLayer.d.ts","sourceRoot":"","sources":["VectorTileLayer.js"],"names":[],"mappings":";;;;;;6CAwCsB,OAAO,eAAe,EAAE,OAAO;QAAS,MAAM;MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AADhF;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,qFAFW,OAAO,EAuCjB;IAlCC;;OAEG;IACH,gBAAkC;IAElC;;;OAGG;IACH,yBAA4B;IAC5B;;;OAGG;IACH,uBAA0B;IAC1B;;;OAGG;IACH,4BAA+B;IAE/B;;;;;;OAMG;IACH,oCAAoD;IAEpD,wBAAsC;IACtC,mBAA4B;IAK9B;;OAEG;IACH,eAFW,OAAO,QASjB;IAED;;;OAGG;IACH,sBAoDC;IAlBC,sCACmE;IACnE,wCACuE;IACvE,0FAAwD;IAExD,wCACyE;IACzE,0CAEwB;IACxB,4FAA4D;IAE5D,uCACsE;IACtE,yCAC0E;IAC1E,2FAA0D;IAG5D;;OAEG;IACH,yBAsBC;IAMD,qDAgBC;IAED,8DAMC;IAED;;;;;OAKG;IACH,uBAkBC;IAED,6MA+CC;IAED;;;OAGG;IACH,4BAFW,OAAO,cAAc,EAAE,UAAU,QAEd;CAS/B;uCApUkD,oBAAoB;yBAD9C,6BAA6B"}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ol/renderer/webgl/VectorTileLayer
|
|
3
|
+
*/
|
|
4
|
+
import EventType from '../../events/EventType.js';
|
|
5
|
+
import LineStringBatchRenderer from '../../render/webgl/LineStringBatchRenderer.js';
|
|
6
|
+
import PointBatchRenderer from '../../render/webgl/PointBatchRenderer.js';
|
|
7
|
+
import PolygonBatchRenderer from '../../render/webgl/PolygonBatchRenderer.js';
|
|
8
|
+
import TileGeometry from '../../webgl/TileGeometry.js';
|
|
9
|
+
import WebGLBaseTileLayerRenderer, {Uniforms} from './TileLayerBase.js';
|
|
10
|
+
import {
|
|
11
|
+
FILL_FRAGMENT_SHADER,
|
|
12
|
+
FILL_VERTEX_SHADER,
|
|
13
|
+
POINT_FRAGMENT_SHADER,
|
|
14
|
+
POINT_VERTEX_SHADER,
|
|
15
|
+
STROKE_FRAGMENT_SHADER,
|
|
16
|
+
STROKE_VERTEX_SHADER,
|
|
17
|
+
packColor,
|
|
18
|
+
} from './shaders.js';
|
|
19
|
+
import {
|
|
20
|
+
create as createMat4,
|
|
21
|
+
fromTransform as mat4FromTransform,
|
|
22
|
+
} from '../../vec/mat4.js';
|
|
23
|
+
import {
|
|
24
|
+
create as createTransform,
|
|
25
|
+
makeInverse as makeInverseTransform,
|
|
26
|
+
multiply as multiplyTransform,
|
|
27
|
+
setFromArray as setFromTransform,
|
|
28
|
+
} from '../../transform.js';
|
|
29
|
+
import {create as createWebGLWorker} from '../../worker/webgl.js';
|
|
30
|
+
import {getIntersection} from '../../extent.js';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {Object<import("./shaders.js").DefaultAttributes,CustomAttributeCallback>} obj Lookup of attribute getters.
|
|
34
|
+
* @return {Array<import("../../render/webgl/BatchRenderer").CustomAttribute>} An array of attribute descriptors.
|
|
35
|
+
*/
|
|
36
|
+
function toAttributesArray(obj) {
|
|
37
|
+
return Object.keys(obj).map((key) => ({name: key, callback: obj[key]}));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {function(import("../../Feature").default, Object<string, *>):number} CustomAttributeCallback A callback computing
|
|
42
|
+
* the value of a custom attribute (different for each feature) to be passed on to the GPU.
|
|
43
|
+
* Properties are available as 2nd arg for quicker access.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {Object} ShaderProgram An object containing both shaders (vertex and fragment) as well as the required attributes
|
|
48
|
+
* @property {string} [vertexShader] Vertex shader source (using the default one if unspecified).
|
|
49
|
+
* @property {string} [fragmentShader] Fragment shader source (using the default one if unspecified).
|
|
50
|
+
* @property {Object<import("./shaders.js").DefaultAttributes,CustomAttributeCallback>} attributes Custom attributes made available in the vertex shader.
|
|
51
|
+
* Keys are the names of the attributes which are then accessible in the vertex shader using the `a_` prefix, e.g.: `a_opacity`.
|
|
52
|
+
* Default shaders rely on the attributes in {@link module:ol/render/webgl/shaders~DefaultAttributes}.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {Object} Options
|
|
57
|
+
* @property {ShaderProgram} [fill] Attributes and shaders for filling polygons.
|
|
58
|
+
* @property {ShaderProgram} [stroke] Attributes and shaders for line strings and polygon strokes.
|
|
59
|
+
* @property {ShaderProgram} [point] Attributes and shaders for points.
|
|
60
|
+
* @property {Object<string, import("../../webgl/Helper").UniformValue>} [uniforms] Additional uniforms
|
|
61
|
+
* made available to shaders.
|
|
62
|
+
* @property {number} [cacheSize=512] The vector tile cache size.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {import("../../layer/BaseTile.js").default} LayerType
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @classdesc
|
|
71
|
+
* WebGL renderer for vector tile layers. Experimental.
|
|
72
|
+
* @extends {WebGLBaseTileLayerRenderer<LayerType>}
|
|
73
|
+
*/
|
|
74
|
+
class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer {
|
|
75
|
+
/**
|
|
76
|
+
* @param {LayerType} tileLayer Tile layer.
|
|
77
|
+
* @param {Options} options Options.
|
|
78
|
+
*/
|
|
79
|
+
constructor(tileLayer, options) {
|
|
80
|
+
super(tileLayer, options);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
this.worker_ = createWebGLWorker();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @type {PolygonBatchRenderer}
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
this.polygonRenderer_ = null;
|
|
92
|
+
/**
|
|
93
|
+
* @type {PointBatchRenderer}
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
this.pointRenderer_ = null;
|
|
97
|
+
/**
|
|
98
|
+
* @type {LineStringBatchRenderer}
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
this.lineStringRenderer_ = null;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* This transform is updated on every frame and is the composition of:
|
|
105
|
+
* - invert of the world->screen transform that was used when rebuilding buffers (see `this.renderTransform_`)
|
|
106
|
+
* - current world->screen transform
|
|
107
|
+
* @type {import("../../transform.js").Transform}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
this.currentFrameStateTransform_ = createTransform();
|
|
111
|
+
|
|
112
|
+
this.tmpTransform_ = createTransform();
|
|
113
|
+
this.tmpMat4_ = createMat4();
|
|
114
|
+
|
|
115
|
+
this.applyOptions_(options);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param {Options} options Options.
|
|
120
|
+
*/
|
|
121
|
+
reset(options) {
|
|
122
|
+
super.reset(options);
|
|
123
|
+
|
|
124
|
+
this.applyOptions_(options);
|
|
125
|
+
if (this.helper) {
|
|
126
|
+
this.createRenderers_();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {Options} options Options.
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
applyOptions_(options) {
|
|
135
|
+
const fillAttributes = {
|
|
136
|
+
color: function () {
|
|
137
|
+
return packColor('#ddd');
|
|
138
|
+
},
|
|
139
|
+
opacity: function () {
|
|
140
|
+
return 1;
|
|
141
|
+
},
|
|
142
|
+
...(options.fill && options.fill.attributes),
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const strokeAttributes = {
|
|
146
|
+
color: function () {
|
|
147
|
+
return packColor('#eee');
|
|
148
|
+
},
|
|
149
|
+
opacity: function () {
|
|
150
|
+
return 1;
|
|
151
|
+
},
|
|
152
|
+
width: function () {
|
|
153
|
+
return 1.5;
|
|
154
|
+
},
|
|
155
|
+
...(options.stroke && options.stroke.attributes),
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const pointAttributes = {
|
|
159
|
+
color: function () {
|
|
160
|
+
return packColor('#eee');
|
|
161
|
+
},
|
|
162
|
+
opacity: function () {
|
|
163
|
+
return 1;
|
|
164
|
+
},
|
|
165
|
+
...(options.point && options.point.attributes),
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
this.fillVertexShader_ =
|
|
169
|
+
(options.fill && options.fill.vertexShader) || FILL_VERTEX_SHADER;
|
|
170
|
+
this.fillFragmentShader_ =
|
|
171
|
+
(options.fill && options.fill.fragmentShader) || FILL_FRAGMENT_SHADER;
|
|
172
|
+
this.fillAttributes_ = toAttributesArray(fillAttributes);
|
|
173
|
+
|
|
174
|
+
this.strokeVertexShader_ =
|
|
175
|
+
(options.stroke && options.stroke.vertexShader) || STROKE_VERTEX_SHADER;
|
|
176
|
+
this.strokeFragmentShader_ =
|
|
177
|
+
(options.stroke && options.stroke.fragmentShader) ||
|
|
178
|
+
STROKE_FRAGMENT_SHADER;
|
|
179
|
+
this.strokeAttributes_ = toAttributesArray(strokeAttributes);
|
|
180
|
+
|
|
181
|
+
this.pointVertexShader_ =
|
|
182
|
+
(options.point && options.point.vertexShader) || POINT_VERTEX_SHADER;
|
|
183
|
+
this.pointFragmentShader_ =
|
|
184
|
+
(options.point && options.point.fragmentShader) || POINT_FRAGMENT_SHADER;
|
|
185
|
+
this.pointAttributes_ = toAttributesArray(pointAttributes);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
191
|
+
createRenderers_() {
|
|
192
|
+
this.polygonRenderer_ = new PolygonBatchRenderer(
|
|
193
|
+
this.helper,
|
|
194
|
+
this.worker_,
|
|
195
|
+
this.fillVertexShader_,
|
|
196
|
+
this.fillFragmentShader_,
|
|
197
|
+
this.fillAttributes_
|
|
198
|
+
);
|
|
199
|
+
this.pointRenderer_ = new PointBatchRenderer(
|
|
200
|
+
this.helper,
|
|
201
|
+
this.worker_,
|
|
202
|
+
this.pointVertexShader_,
|
|
203
|
+
this.pointFragmentShader_,
|
|
204
|
+
this.pointAttributes_
|
|
205
|
+
);
|
|
206
|
+
this.lineStringRenderer_ = new LineStringBatchRenderer(
|
|
207
|
+
this.helper,
|
|
208
|
+
this.worker_,
|
|
209
|
+
this.strokeVertexShader_,
|
|
210
|
+
this.strokeFragmentShader_,
|
|
211
|
+
this.strokeAttributes_
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
afterHelperCreated() {
|
|
216
|
+
this.createRenderers_();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
createTileRepresentation(options) {
|
|
220
|
+
const tileRep = new TileGeometry(
|
|
221
|
+
options,
|
|
222
|
+
this.polygonRenderer_,
|
|
223
|
+
this.lineStringRenderer_,
|
|
224
|
+
this.pointRenderer_
|
|
225
|
+
);
|
|
226
|
+
// redraw the layer when the tile is ready
|
|
227
|
+
const listener = () => {
|
|
228
|
+
if (tileRep.ready) {
|
|
229
|
+
this.getLayer().changed();
|
|
230
|
+
tileRep.removeEventListener(EventType.CHANGE, listener);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
tileRep.addEventListener(EventType.CHANGE, listener);
|
|
234
|
+
return tileRep;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
beforeTilesRender(frameState, tilesWithAlpha) {
|
|
238
|
+
super.beforeTilesRender(frameState, true); // always consider that tiles need alpha blending
|
|
239
|
+
this.helper.makeProjectionTransform(
|
|
240
|
+
frameState,
|
|
241
|
+
this.currentFrameStateTransform_
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @param {number} alpha Alpha value of the tile
|
|
247
|
+
* @param {import("../../extent.js").Extent} renderExtent Which extent to restrict drawing to
|
|
248
|
+
* @param {import("../../transform.js").Transform} batchInvertTransform Inverse of the transformation in which tile geometries are expressed
|
|
249
|
+
* @private
|
|
250
|
+
*/
|
|
251
|
+
applyUniforms_(alpha, renderExtent, batchInvertTransform) {
|
|
252
|
+
// world to screen matrix
|
|
253
|
+
setFromTransform(this.tmpTransform_, this.currentFrameStateTransform_);
|
|
254
|
+
multiplyTransform(this.tmpTransform_, batchInvertTransform);
|
|
255
|
+
this.helper.setUniformMatrixValue(
|
|
256
|
+
Uniforms.PROJECTION_MATRIX,
|
|
257
|
+
mat4FromTransform(this.tmpMat4_, this.tmpTransform_)
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// screen to world matrix
|
|
261
|
+
makeInverseTransform(this.tmpTransform_, this.currentFrameStateTransform_);
|
|
262
|
+
this.helper.setUniformMatrixValue(
|
|
263
|
+
Uniforms.SCREEN_TO_WORLD_MATRIX,
|
|
264
|
+
mat4FromTransform(this.tmpMat4_, this.tmpTransform_)
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
this.helper.setUniformFloatValue(Uniforms.GLOBAL_ALPHA, alpha);
|
|
268
|
+
this.helper.setUniformFloatVec4(Uniforms.RENDER_EXTENT, renderExtent);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
renderTile(
|
|
272
|
+
tileRepresentation,
|
|
273
|
+
tileTransform,
|
|
274
|
+
frameState,
|
|
275
|
+
renderExtent,
|
|
276
|
+
tileResolution,
|
|
277
|
+
tileSize,
|
|
278
|
+
tileOrigin,
|
|
279
|
+
tileExtent,
|
|
280
|
+
depth,
|
|
281
|
+
gutter,
|
|
282
|
+
alpha
|
|
283
|
+
) {
|
|
284
|
+
const gutterExtent = getIntersection(tileExtent, renderExtent, tileExtent);
|
|
285
|
+
|
|
286
|
+
this.polygonRenderer_.preRender(
|
|
287
|
+
tileRepresentation.batch.polygonBatch,
|
|
288
|
+
this.frameState
|
|
289
|
+
);
|
|
290
|
+
this.applyUniforms_(
|
|
291
|
+
alpha,
|
|
292
|
+
gutterExtent,
|
|
293
|
+
tileRepresentation.batch.polygonBatch.invertVerticesBufferTransform
|
|
294
|
+
);
|
|
295
|
+
this.polygonRenderer_.render(tileRepresentation.batch.polygonBatch);
|
|
296
|
+
|
|
297
|
+
this.lineStringRenderer_.preRender(
|
|
298
|
+
tileRepresentation.batch.lineStringBatch,
|
|
299
|
+
this.frameState
|
|
300
|
+
);
|
|
301
|
+
this.applyUniforms_(
|
|
302
|
+
alpha,
|
|
303
|
+
gutterExtent,
|
|
304
|
+
tileRepresentation.batch.lineStringBatch.invertVerticesBufferTransform
|
|
305
|
+
);
|
|
306
|
+
this.lineStringRenderer_.render(tileRepresentation.batch.lineStringBatch);
|
|
307
|
+
|
|
308
|
+
this.pointRenderer_.preRender(
|
|
309
|
+
tileRepresentation.batch.pointBatch,
|
|
310
|
+
this.frameState
|
|
311
|
+
);
|
|
312
|
+
this.applyUniforms_(
|
|
313
|
+
alpha,
|
|
314
|
+
gutterExtent,
|
|
315
|
+
tileRepresentation.batch.pointBatch.invertVerticesBufferTransform
|
|
316
|
+
);
|
|
317
|
+
this.pointRenderer_.render(tileRepresentation.batch.pointBatch);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Render declutter items for this layer
|
|
322
|
+
* @param {import("../../Map.js").FrameState} frameState Frame state.
|
|
323
|
+
*/
|
|
324
|
+
renderDeclutter(frameState) {}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Clean up.
|
|
328
|
+
*/
|
|
329
|
+
disposeInternal() {
|
|
330
|
+
this.worker_.terminate();
|
|
331
|
+
super.disposeInternal();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export default WebGLVectorTileLayerRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaders.d.ts","sourceRoot":"","sources":["shaders.js"],"names":[],"mappings":"AAKA,6DAA6D;AAE7D;;;;;GAKG;AACH,iCAHW,OAAO,gBAAgB,EAAE,KAAK,GAAC,MAAM,GACpC,MAAM,CAQjB;AAQD;;;;GAIG;AACH,iCAFU,MAAM,
|
|
1
|
+
{"version":3,"file":"shaders.d.ts","sourceRoot":"","sources":["shaders.js"],"names":[],"mappings":"AAKA,6DAA6D;AAE7D;;;;;GAKG;AACH,iCAHW,OAAO,gBAAgB,EAAE,KAAK,GAAC,MAAM,GACpC,MAAM,CAQjB;AAQD;;;;GAIG;AACH,iCAFU,MAAM,CAmBX;AAEL;;;GAGG;AACH,mCAFU,MAAM,CAqCX;AAEL;;;;GAIG;AACH,mCAFU,MAAM,CAiEX;AAEL;;;GAGG;AACH,qCAFU,MAAM,CAoDX;AAEL;;;;GAIG;AACH,kCAFU,MAAM,CA0BX;AAEL;;;GAGG;AACH,oCAFU,MAAM,CAWX;gCAjQS,OAAO,GAAC,SAAS,GAAC,OAAO"}
|
|
@@ -31,7 +31,11 @@ const DECODE_COLOR_EXPRESSION = `vec3(
|
|
|
31
31
|
* @type {string}
|
|
32
32
|
*/
|
|
33
33
|
export const FILL_VERTEX_SHADER = `
|
|
34
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
35
|
+
precision highp float;
|
|
36
|
+
#else
|
|
34
37
|
precision mediump float;
|
|
38
|
+
#endif
|
|
35
39
|
uniform mat4 u_projectionMatrix;
|
|
36
40
|
attribute vec2 a_position;
|
|
37
41
|
attribute float a_color;
|
|
@@ -50,12 +54,40 @@ export const FILL_VERTEX_SHADER = `
|
|
|
50
54
|
* @type {string}
|
|
51
55
|
*/
|
|
52
56
|
export const FILL_FRAGMENT_SHADER = `
|
|
57
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
58
|
+
precision highp float;
|
|
59
|
+
#else
|
|
53
60
|
precision mediump float;
|
|
61
|
+
#endif
|
|
62
|
+
uniform float u_globalAlpha;
|
|
63
|
+
uniform mat4 u_projectionMatrix;
|
|
64
|
+
uniform mat4 u_screenToWorldMatrix;
|
|
65
|
+
uniform vec2 u_sizePx;
|
|
66
|
+
uniform float u_pixelRatio;
|
|
67
|
+
uniform vec4 u_renderExtent;
|
|
54
68
|
varying vec3 v_color;
|
|
55
69
|
varying float v_opacity;
|
|
56
70
|
|
|
71
|
+
vec2 pxToWorld(vec2 pxPos) {
|
|
72
|
+
vec2 screenPos = 2.0 * pxPos / u_sizePx - 1.0;
|
|
73
|
+
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
|
74
|
+
}
|
|
75
|
+
|
|
57
76
|
void main(void) {
|
|
58
|
-
|
|
77
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
78
|
+
vec2 v_worldPos = pxToWorld(gl_FragCoord.xy / u_pixelRatio);
|
|
79
|
+
if (
|
|
80
|
+
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
|
81
|
+
v_worldPos[0] < u_renderExtent[0] ||
|
|
82
|
+
v_worldPos[1] < u_renderExtent[1] ||
|
|
83
|
+
v_worldPos[0] > u_renderExtent[2] ||
|
|
84
|
+
v_worldPos[1] > u_renderExtent[3]
|
|
85
|
+
)
|
|
86
|
+
) {
|
|
87
|
+
discard;
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
90
|
+
gl_FragColor = vec4(v_color, 1.0) * v_opacity * u_globalAlpha;
|
|
59
91
|
}`;
|
|
60
92
|
|
|
61
93
|
/**
|
|
@@ -64,7 +96,11 @@ export const FILL_FRAGMENT_SHADER = `
|
|
|
64
96
|
* @type {string}
|
|
65
97
|
*/
|
|
66
98
|
export const STROKE_VERTEX_SHADER = `
|
|
99
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
100
|
+
precision highp float;
|
|
101
|
+
#else
|
|
67
102
|
precision mediump float;
|
|
103
|
+
#endif
|
|
68
104
|
uniform mat4 u_projectionMatrix;
|
|
69
105
|
uniform vec2 u_sizePx;
|
|
70
106
|
attribute vec2 a_segmentStart;
|
|
@@ -129,8 +165,17 @@ export const STROKE_VERTEX_SHADER = `
|
|
|
129
165
|
* @type {string}
|
|
130
166
|
*/
|
|
131
167
|
export const STROKE_FRAGMENT_SHADER = `
|
|
168
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
169
|
+
precision highp float;
|
|
170
|
+
#else
|
|
132
171
|
precision mediump float;
|
|
172
|
+
#endif
|
|
173
|
+
uniform mat4 u_projectionMatrix;
|
|
174
|
+
uniform mat4 u_screenToWorldMatrix;
|
|
175
|
+
uniform vec2 u_sizePx;
|
|
133
176
|
uniform float u_pixelRatio;
|
|
177
|
+
uniform float u_globalAlpha;
|
|
178
|
+
uniform vec4 u_renderExtent;
|
|
134
179
|
varying vec2 v_segmentStart;
|
|
135
180
|
varying vec2 v_segmentEnd;
|
|
136
181
|
varying float v_angleStart;
|
|
@@ -139,6 +184,11 @@ export const STROKE_FRAGMENT_SHADER = `
|
|
|
139
184
|
varying float v_opacity;
|
|
140
185
|
varying float v_width;
|
|
141
186
|
|
|
187
|
+
vec2 pxToWorld(vec2 pxPos) {
|
|
188
|
+
vec2 screenPos = 2.0 * pxPos / u_sizePx - 1.0;
|
|
189
|
+
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
|
190
|
+
}
|
|
191
|
+
|
|
142
192
|
float segmentDistanceField(vec2 point, vec2 start, vec2 end, float radius) {
|
|
143
193
|
vec2 startToPoint = point - start;
|
|
144
194
|
vec2 startToEnd = end - start;
|
|
@@ -149,7 +199,20 @@ export const STROKE_FRAGMENT_SHADER = `
|
|
|
149
199
|
|
|
150
200
|
void main(void) {
|
|
151
201
|
vec2 v_currentPoint = gl_FragCoord.xy / u_pixelRatio;
|
|
152
|
-
|
|
202
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
203
|
+
vec2 v_worldPos = pxToWorld(v_currentPoint);
|
|
204
|
+
if (
|
|
205
|
+
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
|
206
|
+
v_worldPos[0] < u_renderExtent[0] ||
|
|
207
|
+
v_worldPos[1] < u_renderExtent[1] ||
|
|
208
|
+
v_worldPos[0] > u_renderExtent[2] ||
|
|
209
|
+
v_worldPos[1] > u_renderExtent[3]
|
|
210
|
+
)
|
|
211
|
+
) {
|
|
212
|
+
discard;
|
|
213
|
+
}
|
|
214
|
+
#endif
|
|
215
|
+
gl_FragColor = vec4(v_color, 1.0) * v_opacity * u_globalAlpha;
|
|
153
216
|
gl_FragColor *= segmentDistanceField(v_currentPoint, v_segmentStart, v_segmentEnd, v_width);
|
|
154
217
|
}`;
|
|
155
218
|
|
|
@@ -190,9 +253,11 @@ export const POINT_VERTEX_SHADER = `
|
|
|
190
253
|
*/
|
|
191
254
|
export const POINT_FRAGMENT_SHADER = `
|
|
192
255
|
precision mediump float;
|
|
256
|
+
uniform float u_globalAlpha;
|
|
257
|
+
uniform vec4 u_renderExtent;
|
|
193
258
|
varying vec3 v_color;
|
|
194
259
|
varying float v_opacity;
|
|
195
260
|
|
|
196
261
|
void main(void) {
|
|
197
|
-
gl_FragColor = vec4(v_color, 1.0) * v_opacity;
|
|
262
|
+
gl_FragColor = vec4(v_color, 1.0) * v_opacity * u_globalAlpha;
|
|
198
263
|
}`;
|
package/util.js
CHANGED
package/webgl/Helper.d.ts
CHANGED
|
@@ -478,8 +478,8 @@ declare class WebGLHelper extends Disposable {
|
|
|
478
478
|
*/
|
|
479
479
|
getAttributeLocation(name: string): number;
|
|
480
480
|
/**
|
|
481
|
-
*
|
|
482
|
-
* The resulting transform can be used to convert world space coordinates to view coordinates.
|
|
481
|
+
* Sets the given transform to apply the rotation/translation/scaling of the given frame state.
|
|
482
|
+
* The resulting transform can be used to convert world space coordinates to view coordinates in the [-1, 1] range.
|
|
483
483
|
* @param {import("../Map.js").FrameState} frameState Frame state.
|
|
484
484
|
* @param {import("../transform").Transform} transform Transform to update.
|
|
485
485
|
* @return {import("../transform").Transform} The updated transform object.
|
package/webgl/Helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["Helper.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["Helper.js"],"names":[],"mappings":"AA+iCA;;;;GAIG;AACH,oDAHW,MAAM,oBAAoB,CAAC,GAC1B,MAAM,CASjB;;;;yBA3hCS,MAAM;;;;;;;;;6BAUN,MAAM;;;;;;;;;;;;;;;4BAgBN,MAAM;;;;;;;;;;;;YAhCF,OAAO,aA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