@antv/l7-layers 2.9.27-alpha.2 → 2.9.27-alpha.3
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/es/Geometry/index.js +6 -2
- package/es/Geometry/models/billboard.js +1 -2
- package/es/Geometry/models/plane.js +2 -4
- package/es/Geometry/models/sprite.js +2 -4
- package/es/canvas/index.d.ts +4 -0
- package/es/canvas/index.js +38 -2
- package/es/citybuliding/building.js +6 -2
- package/es/citybuliding/models/build.js +2 -3
- package/es/core/BaseLayer.d.ts +15 -6
- package/es/core/BaseLayer.js +51 -69
- package/es/core/BaseModel.d.ts +1 -1
- package/es/core/BaseModel.js +7 -3
- package/es/core/interface.d.ts +18 -0
- package/es/core/triangulation.d.ts +6 -0
- package/es/core/triangulation.js +64 -2
- package/es/earth/index.js +3 -1
- package/es/earth/models/base.js +2 -4
- package/es/earth/shaders/atmosphere_frag.glsl +1 -1
- package/es/earth/shaders/bloomsphere_frag.glsl +1 -1
- package/es/heatmap/index.js +6 -2
- package/es/heatmap/models/heatmap.js +5 -3
- package/es/image/index.js +6 -2
- package/es/image/models/dataImage.js +4 -7
- package/es/image/models/image.js +4 -7
- package/es/line/index.d.ts +1 -0
- package/es/line/index.js +8 -2
- package/es/line/models/arc.js +6 -5
- package/es/line/models/half.js +3 -4
- package/es/line/models/line.js +9 -8
- package/es/line/models/simpleLine.js +2 -1
- package/es/line/models/simpleTileLine.d.ts +9 -0
- package/es/line/models/simpleTileLine.js +100 -0
- package/es/line/models/tile.d.ts +1 -4
- package/es/line/models/tile.js +49 -222
- package/es/line/models/wall.js +10 -46
- package/es/line/shaders/dash/arc_dash_vert.glsl +2 -0
- package/es/line/shaders/dash/line_dash_frag.glsl +1 -1
- package/es/line/shaders/line_arc2d_vert.glsl +1 -1
- package/es/line/shaders/line_arc_3d_frag.glsl +1 -1
- package/es/line/shaders/line_arc_3d_vert.glsl +3 -3
- package/es/line/shaders/line_arc_frag.glsl +1 -1
- package/es/line/shaders/line_arc_great_circle_frag.glsl +1 -1
- package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/line_bezier_vert.glsl +1 -1
- package/es/line/shaders/line_frag.glsl +1 -2
- package/es/line/shaders/line_vert.glsl +1 -1
- package/es/line/shaders/linear/arc3d_linear_frag.glsl +1 -1
- package/es/line/shaders/linear/arc3d_linear_vert.glsl +3 -3
- package/es/line/shaders/linear/arc_linear_frag.glsl +1 -1
- package/es/line/shaders/tile/line_tile_map_vert.glsl +25 -0
- package/es/line/shaders/tile/line_tile_vert.glsl +19 -177
- package/es/line/shaders/tile/simpleline_map_vert.glsl +15 -0
- package/es/line/shaders/tile/simpleline_vert.glsl +21 -0
- package/es/line/shaders/{wall_frag.glsl → wall/wall_frag.glsl} +17 -21
- package/es/line/shaders/wall/wall_vert.glsl +77 -0
- package/es/mask/index.d.ts +1 -0
- package/es/mask/index.js +80 -5
- package/es/mask/models/fill.d.ts +2 -1
- package/es/mask/models/fill.js +13 -10
- package/es/mask/shaders/mask_vert.glsl +0 -6
- package/es/plugins/DataMappingPlugin.d.ts +4 -3
- package/es/plugins/DataMappingPlugin.js +129 -58
- package/es/plugins/DataSourcePlugin.js +3 -2
- package/es/plugins/FeatureScalePlugin.d.ts +0 -2
- package/es/plugins/FeatureScalePlugin.js +8 -51
- package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -2
- package/es/plugins/LayerAnimateStylePlugin.js +7 -27
- package/es/plugins/LayerModelPlugin.js +2 -6
- package/es/plugins/LightingPlugin.js +1 -7
- package/es/plugins/MultiPassRendererPlugin.d.ts +0 -1
- package/es/plugins/MultiPassRendererPlugin.js +4 -16
- package/es/plugins/PixelPickingPlugin.d.ts +1 -1
- package/es/plugins/PixelPickingPlugin.js +8 -28
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +4 -0
- package/es/plugins/RegisterStyleAttributePlugin.js +56 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +2 -9
- package/es/point/index.js +6 -2
- package/es/point/models/fill.js +2 -2
- package/es/point/models/fillmage.js +1 -1
- package/es/point/models/image.js +1 -1
- package/es/point/models/normal.d.ts +0 -1
- package/es/point/models/normal.js +9 -60
- package/es/point/models/radar.js +4 -69
- package/es/point/models/simplePoint.d.ts +0 -1
- package/es/point/models/simplePoint.js +2 -11
- package/es/point/models/text.js +6 -7
- package/es/point/models/tile.d.ts +0 -7
- package/es/point/models/tile.js +22 -155
- package/es/point/models/tileText.d.ts +0 -4
- package/es/point/models/tileText.js +98 -185
- package/es/point/shaders/animate/wave_frag.glsl +3 -3
- package/es/point/shaders/earth/fill_vert.glsl +0 -1
- package/es/point/shaders/fill_vert.glsl +0 -1
- package/es/point/shaders/normal_frag.glsl +1 -10
- package/es/point/shaders/normal_vert.glsl +5 -60
- package/es/point/shaders/radar/radar_frag.glsl +4 -15
- package/es/point/shaders/radar/radar_vert.glsl +4 -54
- package/es/point/shaders/tile/fill_tile_frag.glsl +10 -17
- package/es/point/shaders/tile/fill_tile_vert.glsl +20 -123
- package/es/point/shaders/tile/text_frag.glsl +33 -0
- package/es/point/shaders/tile/text_map_frag.glsl +31 -0
- package/es/point/shaders/tile/text_map_vert.glsl +38 -0
- package/es/point/shaders/tile/text_vert.glsl +48 -0
- package/es/polygon/index.js +6 -2
- package/es/polygon/models/extrude.js +1 -3
- package/es/polygon/models/fill.js +3 -4
- package/es/polygon/models/ocean.d.ts +0 -2
- package/es/polygon/models/ocean.js +13 -47
- package/es/polygon/models/tile.d.ts +1 -4
- package/es/polygon/models/tile.js +25 -57
- package/es/polygon/models/water.d.ts +0 -2
- package/es/polygon/models/water.js +13 -47
- package/es/polygon/shaders/polygon_frag.glsl +2 -2
- package/es/polygon/shaders/polygon_vert.glsl +2 -2
- package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +16 -0
- package/es/polygon/shaders/tile/polygon_tile_vert.glsl +20 -60
- package/es/polygon/shaders/water/polygon_ocean_frag.glsl +1 -2
- package/es/polygon/shaders/water/polygon_ocean_vert.glsl +0 -31
- package/es/polygon/shaders/water/polygon_water_frag.glsl +1 -3
- package/es/polygon/shaders/water/polygon_water_vert.glsl +0 -29
- package/es/raster/buffers/triangulation.js +1 -4
- package/es/raster/index.js +6 -2
- package/es/raster/models/raster.js +3 -2
- package/es/shader/minify_frag.glsl +7 -0
- package/es/shader/minify_picking_frag.glsl +10 -0
- package/es/tile/manager/baseMapTileLayerManager.d.ts +29 -0
- package/es/tile/manager/baseMapTileLayerManager.js +207 -0
- package/es/tile/manager/tileLayerManager.d.ts +2 -2
- package/es/tile/manager/tileLayerManager.js +2 -2
- package/es/tile/manager/tilePickerManager.d.ts +2 -3
- package/es/tile/manager/tilePickerManager.js +1 -2
- package/es/tile/models/tileModel.d.ts +1 -0
- package/es/tile/models/tileModel.js +18 -2
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +58 -33
- package/es/tile/tileFactory/line.js +3 -0
- package/es/tile/tileFactory/point.js +3 -0
- package/es/tile/tileFactory/polygon.js +3 -0
- package/es/tile/tileFactory/raster.js +3 -0
- package/es/tile/tileFactory/rasterData.js +3 -0
- package/es/tile/tileFactory/rasterDataLayer.js +6 -2
- package/es/tile/tileFactory/test.js +26 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +4 -1
- package/es/tile/tileFactory/vectorLayer.js +110 -7
- package/es/tile/tileLayer/baseMapTileLayer.d.ts +29 -0
- package/es/tile/tileLayer/baseMapTileLayer.js +188 -0
- package/es/tile/tileLayer/baseTileLayer.d.ts +4 -4
- package/es/tile/tileLayer/baseTileLayer.js +46 -75
- package/es/tile/tileTest.d.ts +1 -0
- package/es/tile/tileTest.js +3 -2
- package/es/tile/tmsMapTileLayer.d.ts +9 -0
- package/es/tile/tmsMapTileLayer.js +119 -0
- package/es/tile/tmsTileLayer.d.ts +2 -0
- package/es/tile/tmsTileLayer.js +24 -2
- package/es/tile/utils.d.ts +4 -0
- package/es/tile/utils.js +30 -0
- package/es/utils/dataMappingStyle.js +3 -0
- package/es/utils/layerData.js +2 -2
- package/es/utils/updateShape.js +2 -2
- package/es/wind/index.js +6 -2
- package/es/wind/models/wind.js +8 -8
- package/es/wind/shaders/wind_vert.glsl +1 -1
- package/lib/Geometry/index.js +6 -2
- package/lib/Geometry/models/billboard.js +1 -2
- package/lib/Geometry/models/plane.js +2 -4
- package/lib/Geometry/models/sprite.js +2 -4
- package/lib/canvas/index.js +37 -2
- package/lib/citybuliding/building.js +6 -2
- package/lib/citybuliding/models/build.js +2 -3
- package/lib/core/BaseLayer.js +51 -69
- package/lib/core/BaseModel.js +7 -3
- package/lib/core/triangulation.js +66 -2
- package/lib/earth/index.js +3 -1
- package/lib/earth/models/base.js +2 -4
- package/lib/earth/shaders/atmosphere_frag.glsl +1 -1
- package/lib/earth/shaders/bloomsphere_frag.glsl +1 -1
- package/lib/heatmap/index.js +6 -2
- package/lib/heatmap/models/heatmap.js +5 -3
- package/lib/image/index.js +6 -2
- package/lib/image/models/dataImage.js +4 -7
- package/lib/image/models/image.js +4 -7
- package/lib/line/index.js +7 -2
- package/lib/line/models/arc.js +6 -5
- package/lib/line/models/half.js +3 -4
- package/lib/line/models/line.js +9 -8
- package/lib/line/models/simpleLine.js +2 -1
- package/lib/line/models/simpleTileLine.js +115 -0
- package/lib/line/models/tile.js +49 -223
- package/lib/line/models/wall.js +10 -46
- package/lib/line/shaders/dash/arc_dash_vert.glsl +2 -0
- package/lib/line/shaders/dash/line_dash_frag.glsl +1 -1
- package/lib/line/shaders/line_arc2d_vert.glsl +1 -1
- package/lib/line/shaders/line_arc_3d_frag.glsl +1 -1
- package/lib/line/shaders/line_arc_3d_vert.glsl +3 -3
- package/lib/line/shaders/line_arc_frag.glsl +1 -1
- package/lib/line/shaders/line_arc_great_circle_frag.glsl +1 -1
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -1
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/line_bezier_vert.glsl +1 -1
- package/lib/line/shaders/line_frag.glsl +1 -2
- package/lib/line/shaders/line_vert.glsl +1 -1
- package/lib/line/shaders/linear/arc3d_linear_frag.glsl +1 -1
- package/lib/line/shaders/linear/arc3d_linear_vert.glsl +3 -3
- package/lib/line/shaders/linear/arc_linear_frag.glsl +1 -1
- package/lib/line/shaders/tile/line_tile_map_vert.glsl +25 -0
- package/lib/line/shaders/tile/line_tile_vert.glsl +19 -177
- package/lib/line/shaders/tile/simpleline_map_vert.glsl +15 -0
- package/lib/line/shaders/tile/simpleline_vert.glsl +21 -0
- package/lib/line/shaders/{wall_frag.glsl → wall/wall_frag.glsl} +17 -21
- package/lib/line/shaders/wall/wall_vert.glsl +77 -0
- package/lib/mask/index.js +82 -5
- package/lib/mask/models/fill.js +14 -10
- package/lib/mask/shaders/mask_vert.glsl +0 -6
- package/lib/plugins/DataMappingPlugin.js +127 -57
- package/lib/plugins/DataSourcePlugin.js +3 -2
- package/lib/plugins/FeatureScalePlugin.js +6 -50
- package/lib/plugins/LayerAnimateStylePlugin.js +6 -29
- package/lib/plugins/LayerModelPlugin.js +2 -6
- package/lib/plugins/LightingPlugin.js +1 -7
- package/lib/plugins/MultiPassRendererPlugin.js +3 -19
- package/lib/plugins/PixelPickingPlugin.js +8 -28
- package/lib/plugins/RegisterStyleAttributePlugin.js +56 -5
- package/lib/plugins/UpdateStyleAttributePlugin.js +2 -9
- package/lib/point/index.js +6 -2
- package/lib/point/models/fill.js +2 -2
- package/lib/point/models/fillmage.js +1 -1
- package/lib/point/models/image.js +1 -1
- package/lib/point/models/normal.js +8 -59
- package/lib/point/models/radar.js +4 -69
- package/lib/point/models/simplePoint.js +1 -10
- package/lib/point/models/text.js +6 -7
- package/lib/point/models/tile.js +21 -156
- package/lib/point/models/tileText.js +97 -184
- package/lib/point/shaders/animate/wave_frag.glsl +3 -3
- package/lib/point/shaders/earth/fill_vert.glsl +0 -1
- package/lib/point/shaders/fill_vert.glsl +0 -1
- package/lib/point/shaders/normal_frag.glsl +1 -10
- package/lib/point/shaders/normal_vert.glsl +5 -60
- package/lib/point/shaders/radar/radar_frag.glsl +4 -15
- package/lib/point/shaders/radar/radar_vert.glsl +4 -54
- package/lib/point/shaders/tile/fill_tile_frag.glsl +10 -17
- package/lib/point/shaders/tile/fill_tile_vert.glsl +20 -123
- package/lib/point/shaders/tile/text_frag.glsl +33 -0
- package/lib/point/shaders/tile/text_map_frag.glsl +31 -0
- package/lib/point/shaders/tile/text_map_vert.glsl +38 -0
- package/lib/point/shaders/tile/text_vert.glsl +48 -0
- package/lib/polygon/index.js +6 -2
- package/lib/polygon/models/extrude.js +1 -3
- package/lib/polygon/models/fill.js +3 -4
- package/lib/polygon/models/ocean.js +14 -47
- package/lib/polygon/models/tile.js +24 -57
- package/lib/polygon/models/water.js +14 -47
- package/lib/polygon/shaders/polygon_frag.glsl +2 -2
- package/lib/polygon/shaders/polygon_vert.glsl +2 -2
- package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +16 -0
- package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +20 -60
- package/lib/polygon/shaders/water/polygon_ocean_frag.glsl +1 -2
- package/lib/polygon/shaders/water/polygon_ocean_vert.glsl +0 -31
- package/lib/polygon/shaders/water/polygon_water_frag.glsl +1 -3
- package/lib/polygon/shaders/water/polygon_water_vert.glsl +0 -29
- package/lib/raster/buffers/triangulation.js +1 -4
- package/lib/raster/index.js +6 -2
- package/lib/raster/models/raster.js +3 -2
- package/lib/shader/minify_frag.glsl +7 -0
- package/lib/shader/minify_picking_frag.glsl +10 -0
- package/lib/tile/manager/baseMapTileLayerManager.js +222 -0
- package/lib/tile/manager/tileLayerManager.js +2 -2
- package/lib/tile/manager/tilePickerManager.js +1 -2
- package/lib/tile/models/tileModel.js +19 -2
- package/lib/tile/tileFactory/base.js +60 -33
- package/lib/tile/tileFactory/line.js +3 -0
- package/lib/tile/tileFactory/point.js +3 -0
- package/lib/tile/tileFactory/polygon.js +3 -0
- package/lib/tile/tileFactory/raster.js +3 -0
- package/lib/tile/tileFactory/rasterData.js +3 -0
- package/lib/tile/tileFactory/rasterDataLayer.js +6 -2
- package/lib/tile/tileFactory/test.js +26 -5
- package/lib/tile/tileFactory/vectorLayer.js +112 -8
- package/lib/tile/tileLayer/baseMapTileLayer.js +195 -0
- package/lib/tile/tileLayer/baseTileLayer.js +46 -75
- package/lib/tile/tileTest.js +3 -2
- package/lib/tile/tmsMapTileLayer.js +136 -0
- package/lib/tile/tmsTileLayer.js +25 -2
- package/lib/tile/utils.js +38 -0
- package/lib/utils/dataMappingStyle.js +3 -0
- package/lib/utils/layerData.js +2 -2
- package/lib/utils/updateShape.js +2 -2
- package/lib/wind/index.js +6 -2
- package/lib/wind/models/wind.js +7 -7
- package/lib/wind/shaders/wind_vert.glsl +1 -1
- package/package.json +8 -7
- package/es/line/shaders/tile/line_tile_frag.glsl +0 -79
- package/es/line/shaders/wall_vert.glsl +0 -111
- package/es/mask/shaders/mask_frag.glsl +0 -7
- package/es/polygon/shaders/tile/polygon_tile_frag.glsl +0 -12
- package/lib/line/shaders/tile/line_tile_frag.glsl +0 -79
- package/lib/line/shaders/wall_vert.glsl +0 -111
- package/lib/mask/shaders/mask_frag.glsl +0 -7
- package/lib/polygon/shaders/tile/polygon_tile_frag.glsl +0 -12
|
@@ -2,12 +2,9 @@ attribute vec4 a_Color;
|
|
|
2
2
|
attribute vec3 a_Position;
|
|
3
3
|
attribute vec3 a_Extrude;
|
|
4
4
|
attribute float a_Size;
|
|
5
|
-
attribute float a_Shape;
|
|
6
5
|
uniform float u_speed: 1.0;
|
|
7
6
|
uniform float u_time;
|
|
8
7
|
|
|
9
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
10
|
-
|
|
11
8
|
uniform mat4 u_ModelMatrix;
|
|
12
9
|
uniform mat4 u_Mvp;
|
|
13
10
|
uniform float u_isMeter;
|
|
@@ -15,68 +12,21 @@ uniform float u_isMeter;
|
|
|
15
12
|
varying vec4 v_data;
|
|
16
13
|
varying vec4 v_color;
|
|
17
14
|
varying float v_radius;
|
|
18
|
-
|
|
19
|
-
uniform float u_opacity : 1;
|
|
20
|
-
uniform vec2 u_offsets;
|
|
21
|
-
|
|
22
|
-
#pragma include "styleMapping"
|
|
23
|
-
#pragma include "styleMappingCalOpacity"
|
|
15
|
+
varying vec2 v_exteude;
|
|
24
16
|
|
|
25
17
|
#pragma include "projection"
|
|
26
18
|
#pragma include "picking"
|
|
27
19
|
|
|
28
20
|
void main() {
|
|
29
21
|
vec3 extrude = a_Extrude;
|
|
30
|
-
float shape_type = a_Shape;
|
|
31
22
|
float newSize = setPickingSize(a_Size);
|
|
32
23
|
|
|
33
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
34
|
-
styleMappingMat = mat4(
|
|
35
|
-
0.0, 0.0, 0.0, 0.0, // opacity - empty - empty - empty
|
|
36
|
-
0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty
|
|
37
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - a_Extrude.x - a_Extrude.y
|
|
38
|
-
0.0, 0.0, 0.0, 0.0 //
|
|
39
|
-
);
|
|
40
|
-
|
|
41
24
|
float time = u_time * u_speed;
|
|
42
25
|
mat2 rotateMatrix = mat2(
|
|
43
26
|
cos(time), sin(time),
|
|
44
27
|
-sin(time), cos(time)
|
|
45
28
|
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
49
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
50
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
51
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
52
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
53
|
-
float id = a_vertexId; // 第n个顶点
|
|
54
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
55
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
56
|
-
|
|
57
|
-
// cell 固定顺序 opacity -> strokeOpacity -> empty -> empty ...
|
|
58
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
59
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
60
|
-
|
|
61
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
62
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
63
|
-
textureOffset = opacityAndOffset.g;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
vec2 textrueOffsets = vec2(0.0, 0.0);
|
|
67
|
-
if(hasOffsets()) {
|
|
68
|
-
vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
69
|
-
textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
|
|
70
|
-
textureOffset += 1.0;
|
|
71
|
-
|
|
72
|
-
vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
73
|
-
textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
|
|
74
|
-
textureOffset += 1.0;
|
|
75
|
-
} else {
|
|
76
|
-
textrueOffsets = u_offsets;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// cal style mapping
|
|
29
|
+
v_exteude = rotateMatrix * a_Extrude.xy;
|
|
80
30
|
|
|
81
31
|
// unpack color(vec2)
|
|
82
32
|
v_color = a_Color;
|
|
@@ -88,7 +38,7 @@ void main() {
|
|
|
88
38
|
float blur = 0.0;
|
|
89
39
|
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
|
|
90
40
|
|
|
91
|
-
vec2 offset = (extrude.xy * (newSize)
|
|
41
|
+
vec2 offset = (extrude.xy * (newSize));
|
|
92
42
|
vec3 aPosition = a_Position;
|
|
93
43
|
if(u_isMeter < 1.0) {
|
|
94
44
|
// 不以米为实际单位
|
|
@@ -106,7 +56,7 @@ void main() {
|
|
|
106
56
|
}
|
|
107
57
|
}
|
|
108
58
|
|
|
109
|
-
v_data = vec4(extrude.x, extrude.y, antialiasblur,
|
|
59
|
+
v_data = vec4(extrude.x, extrude.y, antialiasblur, -1.0);
|
|
110
60
|
|
|
111
61
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
112
62
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
uniform float u_additive;
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
uniform float u_opacity : 1;
|
|
4
|
+
uniform float u_stroke_opacity : 1;
|
|
5
|
+
uniform float u_stroke_width : 2;
|
|
6
|
+
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
3
7
|
|
|
4
8
|
varying vec4 v_data;
|
|
5
9
|
varying vec4 v_color;
|
|
@@ -11,20 +15,9 @@ varying float v_radius;
|
|
|
11
15
|
void main() {
|
|
12
16
|
int shape = int(floor(v_data.w + 0.5));
|
|
13
17
|
|
|
14
|
-
vec4 textrueStroke = vec4(
|
|
15
|
-
styleMappingMat[1][0],
|
|
16
|
-
styleMappingMat[1][1],
|
|
17
|
-
styleMappingMat[1][2],
|
|
18
|
-
styleMappingMat[1][3]
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
float opacity = styleMappingMat[0][0];
|
|
22
|
-
float stroke_opacity = styleMappingMat[0][1];
|
|
23
|
-
float strokeWidth = styleMappingMat[0][2];
|
|
24
|
-
vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;
|
|
25
18
|
|
|
26
19
|
lowp float antialiasblur = v_data.z;
|
|
27
|
-
float r = v_radius / (v_radius +
|
|
20
|
+
float r = v_radius / (v_radius + u_stroke_width);
|
|
28
21
|
|
|
29
22
|
float outer_df;
|
|
30
23
|
float inner_df;
|
|
@@ -61,16 +54,16 @@ void main() {
|
|
|
61
54
|
|
|
62
55
|
float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
|
|
63
56
|
|
|
64
|
-
float color_t =
|
|
57
|
+
float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(
|
|
65
58
|
antialiasblur,
|
|
66
59
|
0.0,
|
|
67
60
|
inner_df
|
|
68
61
|
);
|
|
69
62
|
|
|
70
|
-
if(
|
|
71
|
-
gl_FragColor = vec4(v_color.rgb, v_color.a *
|
|
63
|
+
if(u_stroke_width < 0.01) {
|
|
64
|
+
gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);
|
|
72
65
|
} else {
|
|
73
|
-
gl_FragColor = mix(vec4(v_color.rgb, v_color.a *
|
|
66
|
+
gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), u_stroke_color * u_stroke_opacity, color_t);
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
if(u_additive > 0.0) {
|
|
@@ -4,14 +4,11 @@ attribute vec3 a_Extrude;
|
|
|
4
4
|
attribute float a_Size;
|
|
5
5
|
attribute float a_Shape;
|
|
6
6
|
|
|
7
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
8
|
-
|
|
9
7
|
uniform mat4 u_ModelMatrix;
|
|
10
8
|
uniform mat4 u_Mvp;
|
|
11
|
-
uniform float u_isMeter;
|
|
12
9
|
|
|
13
|
-
uniform vec2 u_tileOrigin;
|
|
14
|
-
uniform float u_coord;
|
|
10
|
+
// uniform vec2 u_tileOrigin;
|
|
11
|
+
// uniform float u_coord;
|
|
15
12
|
|
|
16
13
|
varying vec4 v_data;
|
|
17
14
|
varying vec4 v_color;
|
|
@@ -21,14 +18,6 @@ uniform float u_opacity : 1;
|
|
|
21
18
|
uniform float u_stroke_opacity : 1;
|
|
22
19
|
uniform float u_stroke_width : 2;
|
|
23
20
|
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
24
|
-
uniform vec2 u_offsets;
|
|
25
|
-
|
|
26
|
-
uniform float u_blur : 0.0;
|
|
27
|
-
|
|
28
|
-
#pragma include "styleMapping"
|
|
29
|
-
#pragma include "styleMappingCalOpacity"
|
|
30
|
-
#pragma include "styleMappingCalStrokeOpacity"
|
|
31
|
-
#pragma include "styleMappingCalStrokeWidth"
|
|
32
21
|
|
|
33
22
|
#pragma include "projection"
|
|
34
23
|
#pragma include "picking"
|
|
@@ -38,83 +27,6 @@ void main() {
|
|
|
38
27
|
float shape_type = a_Shape;
|
|
39
28
|
float newSize = setPickingSize(a_Size);
|
|
40
29
|
|
|
41
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
42
|
-
styleMappingMat = mat4(
|
|
43
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
44
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
45
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
46
|
-
0.0, 0.0, 0.0, 0.0
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
50
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
51
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
52
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
53
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
54
|
-
float id = a_vertexId; // 第n个顶点
|
|
55
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
56
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
57
|
-
|
|
58
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
59
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
60
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
61
|
-
|
|
62
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
63
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
64
|
-
textureOffset = opacityAndOffset.g;
|
|
65
|
-
|
|
66
|
-
vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
67
|
-
styleMappingMat[0][1] = strokeOpacityAndOffset.r;
|
|
68
|
-
textureOffset = strokeOpacityAndOffset.g;
|
|
69
|
-
|
|
70
|
-
vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
71
|
-
styleMappingMat[0][2] = strokeWidthAndOffset.r;
|
|
72
|
-
textureOffset = strokeWidthAndOffset.g;
|
|
73
|
-
|
|
74
|
-
vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);
|
|
75
|
-
if(hasStroke()) {
|
|
76
|
-
vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
77
|
-
styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R
|
|
78
|
-
textureOffset += 1.0;
|
|
79
|
-
|
|
80
|
-
vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
81
|
-
styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G
|
|
82
|
-
textureOffset += 1.0;
|
|
83
|
-
|
|
84
|
-
vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
85
|
-
styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B
|
|
86
|
-
textureOffset += 1.0;
|
|
87
|
-
|
|
88
|
-
vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
89
|
-
styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A
|
|
90
|
-
textureOffset += 1.0;
|
|
91
|
-
} else {
|
|
92
|
-
if(u_stroke_color == vec4(0.0)) {
|
|
93
|
-
styleMappingMat[1][0] = v_color.r;
|
|
94
|
-
styleMappingMat[1][1] = v_color.g;
|
|
95
|
-
styleMappingMat[1][2] = v_color.b;
|
|
96
|
-
styleMappingMat[1][3] = v_color.a;
|
|
97
|
-
} else {
|
|
98
|
-
styleMappingMat[1][0] = u_stroke_color.r;
|
|
99
|
-
styleMappingMat[1][1] = u_stroke_color.g;
|
|
100
|
-
styleMappingMat[1][2] = u_stroke_color.b;
|
|
101
|
-
styleMappingMat[1][3] = u_stroke_color.a;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
vec2 textrueOffsets = vec2(0.0, 0.0);
|
|
106
|
-
if(hasOffsets()) {
|
|
107
|
-
vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
108
|
-
textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
|
|
109
|
-
textureOffset += 1.0;
|
|
110
|
-
|
|
111
|
-
vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
112
|
-
textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
|
|
113
|
-
textureOffset += 1.0;
|
|
114
|
-
} else {
|
|
115
|
-
textrueOffsets = u_offsets;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
30
|
// cal style mapping
|
|
119
31
|
|
|
120
32
|
v_color = a_Color;
|
|
@@ -122,57 +34,42 @@ void main() {
|
|
|
122
34
|
|
|
123
35
|
// anti-alias
|
|
124
36
|
// float antialiased_blur = -max(u_blur, antialiasblur);
|
|
125
|
-
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size,
|
|
37
|
+
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, 0.0);
|
|
126
38
|
|
|
127
|
-
vec2 offset = (extrude.xy * (newSize + u_stroke_width)
|
|
128
|
-
|
|
129
|
-
if(u_isMeter < 1.0) {
|
|
130
|
-
// 不以米为实际单位
|
|
131
|
-
offset = project_pixel(offset);
|
|
132
|
-
} else {
|
|
133
|
-
// 以米为实际单位
|
|
134
|
-
antialiasblur *= pow(19.0 - u_Zoom, 2.0);
|
|
135
|
-
antialiasblur = max(antialiasblur, -0.01);
|
|
136
|
-
// offset *= 0.5;
|
|
137
|
-
|
|
138
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
139
|
-
aPosition.xy += offset;
|
|
140
|
-
offset.x = 0.0;
|
|
141
|
-
offset.y = 0.0;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
39
|
+
vec2 offset = (extrude.xy * (newSize + u_stroke_width));
|
|
40
|
+
offset = project_pixel(offset);
|
|
144
41
|
|
|
145
42
|
v_data = vec4(extrude.x, extrude.y, antialiasblur,shape_type);
|
|
146
43
|
|
|
147
|
-
vec4 project_pos = project_position(vec4(
|
|
44
|
+
vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
|
|
148
45
|
|
|
149
46
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
150
47
|
float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
|
|
151
48
|
}
|
|
152
49
|
|
|
153
|
-
if(u_coord > 0.0) {
|
|
50
|
+
// if(u_coord > 0.0) {
|
|
154
51
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
155
52
|
gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);
|
|
156
53
|
} else {
|
|
157
54
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
|
|
158
55
|
}
|
|
159
|
-
} else {
|
|
160
|
-
|
|
161
|
-
vec2 pointPos = a_Position.xy;
|
|
162
|
-
vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
|
|
56
|
+
// } else {
|
|
57
|
+
|
|
58
|
+
// vec2 pointPos = a_Position.xy;
|
|
59
|
+
// vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
|
|
163
60
|
|
|
164
|
-
vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
|
|
61
|
+
// vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
|
|
165
62
|
|
|
166
|
-
world.xy += offset;
|
|
167
|
-
world.xy += pointOffset;
|
|
63
|
+
// world.xy += offset;
|
|
64
|
+
// world.xy += pointOffset;
|
|
168
65
|
|
|
169
|
-
if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
66
|
+
// if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
67
|
+
// // Needs to be divided with project_uCommonUnitsPerMeter
|
|
68
|
+
// world.w *= u_PixelsPerMeter.z;
|
|
69
|
+
// }
|
|
173
70
|
|
|
174
|
-
gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
|
|
175
|
-
}
|
|
71
|
+
// gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
|
|
72
|
+
// }
|
|
176
73
|
|
|
177
74
|
|
|
178
75
|
setPickingColor(a_PickingColor);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#define SDF_PX 8.0
|
|
2
|
+
#define EDGE_GAMMA 0.105
|
|
3
|
+
#define FONT_SIZE 48.0
|
|
4
|
+
uniform sampler2D u_sdf_map;
|
|
5
|
+
uniform float u_gamma_scale : 0.5;
|
|
6
|
+
// uniform float u_font_size : 24.0;
|
|
7
|
+
uniform float u_opacity : 1.0;
|
|
8
|
+
uniform vec4 u_stroke_color : [0, 0, 0, 1];
|
|
9
|
+
uniform float u_stroke_width : 2.0;
|
|
10
|
+
uniform float u_halo_blur : 0.5;
|
|
11
|
+
uniform float u_DevicePixelRatio;
|
|
12
|
+
|
|
13
|
+
varying vec4 v_color;
|
|
14
|
+
varying vec2 v_uv;
|
|
15
|
+
varying float v_gamma_scale;
|
|
16
|
+
varying float v_fontScale;
|
|
17
|
+
|
|
18
|
+
#pragma include "picking"
|
|
19
|
+
void main() {
|
|
20
|
+
// get sdf from atlas
|
|
21
|
+
float dist = texture2D(u_sdf_map, v_uv).a;
|
|
22
|
+
|
|
23
|
+
lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;
|
|
24
|
+
highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;
|
|
25
|
+
|
|
26
|
+
highp float gamma_scaled = gamma * v_gamma_scale;
|
|
27
|
+
|
|
28
|
+
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
|
29
|
+
|
|
30
|
+
gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));
|
|
31
|
+
gl_FragColor.a= gl_FragColor.a * alpha;
|
|
32
|
+
gl_FragColor = filterColor(gl_FragColor);
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#define SDF_PX 8.0
|
|
2
|
+
#define EDGE_GAMMA 0.105
|
|
3
|
+
#define FONT_SIZE 48.0
|
|
4
|
+
uniform sampler2D u_sdf_map;
|
|
5
|
+
uniform float u_gamma_scale : 0.5;
|
|
6
|
+
|
|
7
|
+
uniform float u_opacity : 1.0;
|
|
8
|
+
uniform vec4 u_stroke_color : [0, 0, 0, 1];
|
|
9
|
+
uniform float u_stroke_width : 2.0;
|
|
10
|
+
uniform float u_halo_blur : 0.5;
|
|
11
|
+
uniform float u_DevicePixelRatio;
|
|
12
|
+
|
|
13
|
+
varying vec2 v_uv;
|
|
14
|
+
varying float v_gamma_scale;
|
|
15
|
+
varying float v_fontScale;
|
|
16
|
+
uniform vec4 u_color;
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
// get sdf from atlas
|
|
20
|
+
float dist = texture2D(u_sdf_map, v_uv).a;
|
|
21
|
+
|
|
22
|
+
lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;
|
|
23
|
+
highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;
|
|
24
|
+
|
|
25
|
+
highp float gamma_scaled = gamma * v_gamma_scale;
|
|
26
|
+
|
|
27
|
+
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
|
28
|
+
|
|
29
|
+
gl_FragColor = mix(vec4(u_color.rgb, u_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));
|
|
30
|
+
gl_FragColor.a= gl_FragColor.a * alpha;
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#define FONT_SIZE 24.0
|
|
2
|
+
attribute vec3 a_Position;
|
|
3
|
+
attribute vec2 a_tex;
|
|
4
|
+
attribute vec2 a_textOffsets;
|
|
5
|
+
|
|
6
|
+
uniform vec2 u_sdf_map_size;
|
|
7
|
+
uniform mat4 u_ModelMatrix;
|
|
8
|
+
uniform mat4 u_Mvp;
|
|
9
|
+
|
|
10
|
+
uniform float u_size;
|
|
11
|
+
|
|
12
|
+
varying vec2 v_uv;
|
|
13
|
+
varying float v_gamma_scale;
|
|
14
|
+
varying float v_fontScale;
|
|
15
|
+
|
|
16
|
+
#pragma include "projection"
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
v_uv = a_tex / u_sdf_map_size;
|
|
20
|
+
|
|
21
|
+
// 文本缩放比例
|
|
22
|
+
float fontScale = u_size / FONT_SIZE;
|
|
23
|
+
v_fontScale = fontScale;
|
|
24
|
+
|
|
25
|
+
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
26
|
+
|
|
27
|
+
vec4 projected_position;
|
|
28
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
29
|
+
projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));
|
|
30
|
+
} else { // else
|
|
31
|
+
projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
gl_Position = vec4(
|
|
35
|
+
projected_position.xy / projected_position.w + a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
|
|
36
|
+
v_gamma_scale = gl_Position.w;
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#define SDF_PX 8.0
|
|
2
|
+
#define EDGE_GAMMA 0.105
|
|
3
|
+
#define FONT_SIZE 24.0
|
|
4
|
+
attribute vec3 a_Position;
|
|
5
|
+
attribute vec2 a_tex;
|
|
6
|
+
attribute vec2 a_textOffsets;
|
|
7
|
+
attribute vec4 a_Color;
|
|
8
|
+
attribute float a_Size;
|
|
9
|
+
|
|
10
|
+
uniform vec2 u_sdf_map_size;
|
|
11
|
+
uniform mat4 u_ModelMatrix;
|
|
12
|
+
uniform mat4 u_Mvp;
|
|
13
|
+
|
|
14
|
+
varying vec2 v_uv;
|
|
15
|
+
varying float v_gamma_scale;
|
|
16
|
+
varying vec4 v_color;
|
|
17
|
+
varying float v_fontScale;
|
|
18
|
+
|
|
19
|
+
uniform float u_opacity : 1;
|
|
20
|
+
uniform float u_stroke_width : 2;
|
|
21
|
+
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
22
|
+
|
|
23
|
+
#pragma include "projection"
|
|
24
|
+
#pragma include "picking"
|
|
25
|
+
|
|
26
|
+
void main() {
|
|
27
|
+
v_color = a_Color;
|
|
28
|
+
v_uv = a_tex / u_sdf_map_size;
|
|
29
|
+
|
|
30
|
+
// 文本缩放比例
|
|
31
|
+
float fontScale = a_Size / FONT_SIZE;
|
|
32
|
+
v_fontScale = fontScale;
|
|
33
|
+
|
|
34
|
+
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
35
|
+
|
|
36
|
+
vec4 projected_position;
|
|
37
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
38
|
+
projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));
|
|
39
|
+
} else { // else
|
|
40
|
+
projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
gl_Position = vec4(
|
|
44
|
+
projected_position.xy / projected_position.w + a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
|
|
45
|
+
v_gamma_scale = gl_Position.w;
|
|
46
|
+
setPickingColor(a_PickingColor);
|
|
47
|
+
|
|
48
|
+
}
|
package/lib/polygon/index.js
CHANGED
|
@@ -60,7 +60,9 @@ var PolygonLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
60
60
|
this.layerModel.initModels(function (models) {
|
|
61
61
|
_this2.models = models;
|
|
62
62
|
|
|
63
|
-
_this2.
|
|
63
|
+
_this2.emit('modelLoaded', null);
|
|
64
|
+
|
|
65
|
+
_this2.layerService.throttleRenderLayers();
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
}, {
|
|
@@ -69,7 +71,9 @@ var PolygonLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
69
71
|
var _this3 = this;
|
|
70
72
|
|
|
71
73
|
this.layerModel.buildModels(function (models) {
|
|
72
|
-
|
|
74
|
+
_this3.models = models;
|
|
75
|
+
|
|
76
|
+
_this3.emit('modelLoaded', null);
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
79
|
}, {
|
|
@@ -32,7 +32,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
32
32
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
33
|
|
|
34
34
|
/* babel-plugin-inline-import '../shaders/polygon_frag.glsl' */
|
|
35
|
-
var polygon_frag = "uniform float u_opacity: 1.0;\nvarying vec4
|
|
35
|
+
var polygon_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
36
36
|
|
|
37
37
|
/* babel-plugin-inline-import '../shaders/polygon_linear_frag.glsl' */
|
|
38
38
|
var polygon_linear_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nuniform float u_opacitylinear: 0.0;\nuniform float u_dir: 1.0;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n \n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
@@ -41,7 +41,7 @@ var polygon_linear_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\
|
|
|
41
41
|
var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_opacity: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nuniform float u_opacitylinear: 0.0;\n\nattribute vec3 a_linear;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}";
|
|
42
42
|
|
|
43
43
|
/* babel-plugin-inline-import '../shaders/polygon_vert.glsl' */
|
|
44
|
-
var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_opacity: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4
|
|
44
|
+
var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_opacity: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
45
45
|
|
|
46
46
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
47
47
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
@@ -186,8 +186,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
186
186
|
type: _l7Core.gl.FLOAT
|
|
187
187
|
},
|
|
188
188
|
size: 3,
|
|
189
|
-
update: function update(feature, featureIdx, vertex
|
|
190
|
-
// center[0] center[1] radius
|
|
189
|
+
update: function update(feature, featureIdx, vertex) {
|
|
191
190
|
return [vertex[3], vertex[4], vertex[5]];
|
|
192
191
|
}
|
|
193
192
|
}
|