@antv/l7-layers 2.16.0 → 2.16.2
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/core/BaseLayer.d.ts +3 -0
- package/es/core/BaseLayer.js +76 -80
- package/es/core/BaseModel.d.ts +9 -71
- package/es/core/BaseModel.js +75 -357
- package/es/core/CommonStyleAttribute.d.ts +2 -0
- package/es/core/CommonStyleAttribute.js +66 -0
- package/es/core/interface.d.ts +13 -3
- package/es/core/shape/extrude.js +18 -6
- package/es/core/triangulation.d.ts +12 -0
- package/es/core/triangulation.js +70 -0
- package/es/heatmap/models/grid.js +1 -1
- package/es/heatmap/models/grid3d.js +1 -1
- package/es/heatmap/models/heatmap.d.ts +1 -0
- package/es/heatmap/models/heatmap.js +17 -13
- package/es/heatmap/models/hexagon.js +1 -1
- package/es/heatmap/shaders/grid_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/es/line/index.d.ts +1 -0
- package/es/line/index.js +3 -2
- package/es/line/models/arc.js +9 -45
- package/es/line/models/arc_3d.js +12 -45
- package/es/line/models/earthArc_3d.js +6 -40
- package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
- package/es/line/models/flow.js +167 -0
- package/es/line/models/great_circle.js +4 -38
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +3 -3
- package/es/line/models/line.js +7 -41
- package/es/line/models/linearline.js +4 -38
- package/es/line/models/simpleLine.d.ts +0 -1
- package/es/line/models/simpleLine.js +4 -43
- package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/es/line/shaders/line_arc_frag.glsl +7 -11
- package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/es/line/shaders/line_arc_vert.glsl +9 -45
- package/es/line/shaders/line_frag.glsl +15 -17
- package/es/line/shaders/line_vert.glsl +3 -34
- package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/es/plugins/DataMappingPlugin.js +20 -34
- package/es/plugins/LayerModelPlugin.js +13 -1
- package/es/plugins/ShaderUniformPlugin.js +3 -3
- package/es/point/index.d.ts +1 -0
- package/es/point/index.js +1 -0
- package/es/point/models/earthExtrude.d.ts +0 -3
- package/es/point/models/earthExtrude.js +2 -40
- package/es/point/models/earthFill.d.ts +0 -1
- package/es/point/models/earthFill.js +9 -60
- package/es/point/models/extrude.d.ts +0 -3
- package/es/point/models/extrude.js +3 -42
- package/es/point/models/fill.d.ts +0 -1
- package/es/point/models/fill.js +15 -76
- package/es/point/models/fillmage.js +6 -43
- package/es/point/models/image.js +7 -41
- package/es/point/models/normal.js +2 -2
- package/es/point/models/radar.d.ts +0 -1
- package/es/point/models/radar.js +4 -13
- package/es/point/models/simplePoint.d.ts +0 -1
- package/es/point/models/simplePoint.js +8 -49
- package/es/point/models/text.js +17 -47
- package/es/point/shaders/animate/wave_frag.glsl +1 -11
- package/es/point/shaders/earth/extrude_frag.glsl +5 -17
- package/es/point/shaders/earth/extrude_vert.glsl +14 -29
- package/es/point/shaders/earth/fill_frag.glsl +5 -14
- package/es/point/shaders/earth/fill_vert.glsl +1 -75
- package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/es/point/shaders/fill_frag.glsl +9 -20
- package/es/point/shaders/fill_vert.glsl +16 -101
- package/es/point/shaders/image/fillImage_frag.glsl +2 -5
- package/es/point/shaders/image/fillImage_vert.glsl +4 -47
- package/es/point/shaders/image_frag.glsl +1 -5
- package/es/point/shaders/image_vert.glsl +1 -44
- package/es/point/shaders/normal_frag.glsl +0 -2
- package/es/point/shaders/normal_vert.glsl +2 -1
- package/es/point/shaders/radar/radar_vert.glsl +2 -2
- package/es/point/shaders/simplePoint_frag.glsl +0 -7
- package/es/point/shaders/simplePoint_vert.glsl +3 -45
- package/es/point/shaders/text_frag.glsl +6 -19
- package/es/point/shaders/text_vert.glsl +5 -66
- package/es/polygon/index.d.ts +1 -0
- package/es/polygon/index.js +1 -0
- package/es/polygon/models/extrude.d.ts +0 -3
- package/es/polygon/models/extrude.js +86 -82
- package/es/polygon/models/fill.d.ts +0 -4
- package/es/polygon/models/fill.js +8 -47
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/es/polygon/shaders/polygon_frag.glsl +0 -5
- package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/es/polygon/shaders/polygon_vert.glsl +1 -27
- package/es/utils/layerData.js +2 -2
- package/lib/core/BaseLayer.js +74 -78
- package/lib/core/BaseModel.js +74 -356
- package/lib/core/CommonStyleAttribute.js +72 -0
- package/lib/core/shape/extrude.js +18 -6
- package/lib/core/triangulation.js +72 -0
- package/lib/heatmap/models/grid.js +1 -1
- package/lib/heatmap/models/grid3d.js +1 -1
- package/lib/heatmap/models/heatmap.js +17 -13
- package/lib/heatmap/models/hexagon.js +1 -1
- package/lib/heatmap/shaders/grid_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/lib/line/index.js +3 -2
- package/lib/line/models/arc.js +9 -45
- package/lib/line/models/arc_3d.js +12 -45
- package/lib/line/models/earthArc_3d.js +6 -40
- package/lib/line/models/flow.js +174 -0
- package/lib/line/models/great_circle.js +4 -38
- package/lib/line/models/index.js +3 -3
- package/lib/line/models/line.js +7 -41
- package/lib/line/models/linearline.js +4 -38
- package/lib/line/models/simpleLine.js +4 -43
- package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/lib/line/shaders/line_arc_frag.glsl +7 -11
- package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/lib/line/shaders/line_arc_vert.glsl +9 -45
- package/lib/line/shaders/line_frag.glsl +15 -17
- package/lib/line/shaders/line_vert.glsl +3 -34
- package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/lib/plugins/DataMappingPlugin.js +20 -34
- package/lib/plugins/LayerModelPlugin.js +13 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -3
- package/lib/point/index.js +1 -0
- package/lib/point/models/earthExtrude.js +2 -40
- package/lib/point/models/earthFill.js +9 -60
- package/lib/point/models/extrude.js +3 -42
- package/lib/point/models/fill.js +15 -76
- package/lib/point/models/fillmage.js +6 -43
- package/lib/point/models/image.js +7 -41
- package/lib/point/models/normal.js +2 -2
- package/lib/point/models/radar.js +4 -13
- package/lib/point/models/simplePoint.js +8 -49
- package/lib/point/models/text.js +15 -45
- package/lib/point/shaders/animate/wave_frag.glsl +1 -11
- package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
- package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
- package/lib/point/shaders/earth/fill_frag.glsl +5 -14
- package/lib/point/shaders/earth/fill_vert.glsl +1 -75
- package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/lib/point/shaders/fill_frag.glsl +9 -20
- package/lib/point/shaders/fill_vert.glsl +16 -101
- package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
- package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
- package/lib/point/shaders/image_frag.glsl +1 -5
- package/lib/point/shaders/image_vert.glsl +1 -44
- package/lib/point/shaders/normal_frag.glsl +0 -2
- package/lib/point/shaders/normal_vert.glsl +2 -1
- package/lib/point/shaders/radar/radar_vert.glsl +2 -2
- package/lib/point/shaders/simplePoint_frag.glsl +0 -7
- package/lib/point/shaders/simplePoint_vert.glsl +3 -45
- package/lib/point/shaders/text_frag.glsl +6 -19
- package/lib/point/shaders/text_vert.glsl +5 -66
- package/lib/polygon/index.js +1 -0
- package/lib/polygon/models/extrude.js +86 -82
- package/lib/polygon/models/fill.js +8 -47
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/lib/polygon/shaders/polygon_frag.glsl +0 -5
- package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/lib/polygon/shaders/polygon_vert.glsl +1 -27
- package/lib/utils/layerData.js +2 -2
- package/package.json +7 -7
- package/es/line/models/half.js +0 -267
- package/es/line/shaders/half/line_half_frag.glsl +0 -53
- package/es/line/shaders/half/line_half_vert.glsl +0 -169
- package/es/utils/dataMappingStyle.d.ts +0 -31
- package/es/utils/dataMappingStyle.js +0 -137
- package/lib/line/models/half.js +0 -274
- package/lib/line/shaders/half/line_half_frag.glsl +0 -53
- package/lib/line/shaders/half/line_half_vert.glsl +0 -169
- package/lib/utils/dataMappingStyle.js +0 -140
|
@@ -4,36 +4,27 @@ 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 int
|
|
9
|
+
uniform int u_size_unit;
|
|
12
10
|
|
|
13
11
|
varying vec4 v_data;
|
|
14
12
|
varying vec4 v_color;
|
|
15
13
|
varying float v_radius;
|
|
14
|
+
varying vec4 v_stroke;
|
|
16
15
|
|
|
17
|
-
uniform float u_opacity : 1;
|
|
18
|
-
uniform float
|
|
19
|
-
uniform
|
|
20
|
-
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
21
|
-
uniform vec2 u_offsets;
|
|
22
|
-
|
|
23
|
-
uniform float u_blur : 0.0;
|
|
24
|
-
uniform float u_raisingHeight: 0.0;
|
|
25
|
-
uniform float u_heightfixed: 0.0;
|
|
16
|
+
// uniform float u_opacity : 1;
|
|
17
|
+
uniform float u_stroke_width: 2;
|
|
18
|
+
uniform vec3 u_blur_height_fixed: [0, 0, 0];
|
|
26
19
|
|
|
27
|
-
#pragma include "styleMapping"
|
|
28
|
-
#pragma include "styleMappingCalOpacity"
|
|
29
|
-
#pragma include "styleMappingCalStrokeOpacity"
|
|
30
|
-
#pragma include "styleMappingCalStrokeWidth"
|
|
31
20
|
|
|
32
21
|
#pragma include "projection"
|
|
33
22
|
#pragma include "picking"
|
|
34
23
|
|
|
35
24
|
|
|
36
25
|
void main() {
|
|
26
|
+
// 透明度计算
|
|
27
|
+
v_stroke = stroke;
|
|
37
28
|
vec3 extrude = a_Extrude;
|
|
38
29
|
float shape_type = a_Shape;
|
|
39
30
|
/*
|
|
@@ -43,88 +34,12 @@ void main() {
|
|
|
43
34
|
float newSize = setPickingSize(a_Size);
|
|
44
35
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
45
36
|
|
|
46
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
47
|
-
styleMappingMat = mat4(
|
|
48
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
49
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
50
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
51
|
-
0.0, 0.0, 0.0, 0.0
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
55
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
56
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
57
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
58
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
59
|
-
float id = a_vertexId; // 第n个顶点
|
|
60
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
61
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
62
|
-
|
|
63
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
64
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
65
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
66
|
-
|
|
67
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
68
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
69
|
-
textureOffset = opacityAndOffset.g;
|
|
70
|
-
|
|
71
|
-
vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
72
|
-
styleMappingMat[0][1] = strokeOpacityAndOffset.r;
|
|
73
|
-
textureOffset = strokeOpacityAndOffset.g;
|
|
74
|
-
|
|
75
|
-
vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
76
|
-
styleMappingMat[0][2] = strokeWidthAndOffset.r;
|
|
77
|
-
textureOffset = strokeWidthAndOffset.g;
|
|
78
|
-
|
|
79
|
-
vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);
|
|
80
|
-
if(hasStroke()) {
|
|
81
|
-
vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
82
|
-
styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R
|
|
83
|
-
textureOffset += 1.0;
|
|
84
|
-
|
|
85
|
-
vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
86
|
-
styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G
|
|
87
|
-
textureOffset += 1.0;
|
|
88
|
-
|
|
89
|
-
vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
90
|
-
styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B
|
|
91
|
-
textureOffset += 1.0;
|
|
92
|
-
|
|
93
|
-
vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
94
|
-
styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A
|
|
95
|
-
textureOffset += 1.0;
|
|
96
|
-
} else {
|
|
97
|
-
if(u_stroke_color == vec4(0.0)) {
|
|
98
|
-
styleMappingMat[1][0] = v_color.r;
|
|
99
|
-
styleMappingMat[1][1] = v_color.g;
|
|
100
|
-
styleMappingMat[1][2] = v_color.b;
|
|
101
|
-
styleMappingMat[1][3] = v_color.a;
|
|
102
|
-
} else {
|
|
103
|
-
styleMappingMat[1][0] = u_stroke_color.r;
|
|
104
|
-
styleMappingMat[1][1] = u_stroke_color.g;
|
|
105
|
-
styleMappingMat[1][2] = u_stroke_color.b;
|
|
106
|
-
styleMappingMat[1][3] = u_stroke_color.a;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
37
|
|
|
110
|
-
vec2 textrueOffsets = vec2(0.0, 0.0);
|
|
111
|
-
if(hasOffsets()) {
|
|
112
|
-
vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
113
|
-
textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
|
|
114
|
-
textureOffset += 1.0;
|
|
115
|
-
|
|
116
|
-
vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
117
|
-
textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
|
|
118
|
-
textureOffset += 1.0;
|
|
119
|
-
} else {
|
|
120
|
-
textrueOffsets = u_offsets;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// cal style mapping
|
|
124
38
|
|
|
125
39
|
// unpack color(vec2)
|
|
126
|
-
v_color = a_Color;
|
|
127
|
-
|
|
40
|
+
v_color = vec4(a_Color.xyz, a_Color.w * opacity);
|
|
41
|
+
|
|
42
|
+
if(u_size_unit == 1) {
|
|
128
43
|
newSize = newSize * u_PixelsPerMeter.z;
|
|
129
44
|
}
|
|
130
45
|
|
|
@@ -132,9 +47,9 @@ if(u_Size_Unit == 1) {
|
|
|
132
47
|
|
|
133
48
|
// anti-alias
|
|
134
49
|
// float antialiased_blur = -max(u_blur, antialiasblur);
|
|
135
|
-
float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize,
|
|
50
|
+
float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);
|
|
136
51
|
|
|
137
|
-
vec2 offset = (extrude.xy * (newSize + u_stroke_width) +
|
|
52
|
+
vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);
|
|
138
53
|
vec3 aPosition = a_Position;
|
|
139
54
|
|
|
140
55
|
offset = project_pixel(offset);
|
|
@@ -147,14 +62,14 @@ if(u_Size_Unit == 1) {
|
|
|
147
62
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
148
63
|
// gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
|
|
149
64
|
|
|
150
|
-
float raisingHeight =
|
|
65
|
+
float raisingHeight = u_blur_height_fixed.y;
|
|
151
66
|
|
|
152
|
-
if(
|
|
153
|
-
raisingHeight = project_pixel(
|
|
67
|
+
if(u_blur_height_fixed.z < 1.0) { // false
|
|
68
|
+
raisingHeight = project_pixel(u_blur_height_fixed.y);
|
|
154
69
|
} else {
|
|
155
70
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
156
71
|
float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
|
|
157
|
-
raisingHeight =
|
|
72
|
+
raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;
|
|
158
73
|
}
|
|
159
74
|
}
|
|
160
75
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
uniform sampler2D u_texture;
|
|
2
2
|
uniform vec2 u_textSize;
|
|
3
|
-
|
|
4
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
3
|
+
uniform float u_opacity : 1;
|
|
5
4
|
|
|
6
5
|
#pragma include "sdf_2d"
|
|
7
6
|
#pragma include "picking"
|
|
@@ -10,11 +9,9 @@ varying vec2 v_Iconuv;
|
|
|
10
9
|
|
|
11
10
|
void main() {
|
|
12
11
|
|
|
13
|
-
float opacity = styleMappingMat[0][0];
|
|
14
|
-
|
|
15
12
|
vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;
|
|
16
13
|
gl_FragColor = texture2D(u_texture, pos);
|
|
17
|
-
gl_FragColor.a *=
|
|
14
|
+
gl_FragColor.a *= u_opacity;
|
|
18
15
|
|
|
19
16
|
gl_FragColor = filterColor(gl_FragColor);
|
|
20
17
|
}
|
|
@@ -5,12 +5,10 @@ attribute float a_Size;
|
|
|
5
5
|
attribute vec2 a_Uv;
|
|
6
6
|
attribute float a_Rotate;
|
|
7
7
|
|
|
8
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
9
|
-
|
|
10
8
|
uniform mat4 u_ModelMatrix;
|
|
11
9
|
uniform mat4 u_Mvp;
|
|
12
10
|
uniform mat2 u_RotateMatrix;
|
|
13
|
-
uniform int
|
|
11
|
+
uniform int u_size_unit;
|
|
14
12
|
|
|
15
13
|
varying vec2 v_uv; // 本身的 uv 坐标
|
|
16
14
|
varying vec2 v_Iconuv; // icon 贴图的 uv 坐标
|
|
@@ -20,69 +18,28 @@ uniform float u_heightfixed: 0.0;
|
|
|
20
18
|
uniform float u_opacity : 1;
|
|
21
19
|
uniform vec2 u_offsets;
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
#pragma include "styleMappingCalOpacity"
|
|
21
|
+
|
|
25
22
|
|
|
26
23
|
#pragma include "projection"
|
|
27
24
|
#pragma include "picking"
|
|
28
25
|
|
|
29
26
|
void main() {
|
|
30
27
|
vec3 extrude = a_Extrude;
|
|
31
|
-
|
|
32
28
|
v_uv = (a_Extrude.xy + 1.0)/2.0;
|
|
33
29
|
v_uv.y = 1.0 - v_uv.y;
|
|
34
30
|
v_Iconuv = a_Uv;
|
|
35
31
|
|
|
36
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
37
|
-
styleMappingMat = mat4(
|
|
38
|
-
0.0, 0.0, 0.0, 0.0, // opacity - empty - empty - empty
|
|
39
|
-
0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty
|
|
40
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
41
|
-
0.0, 0.0, 0.0, 0.0
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
45
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
46
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
47
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
48
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
49
|
-
float id = a_vertexId; // 第n个顶点
|
|
50
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
51
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
52
|
-
|
|
53
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
54
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
55
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
56
|
-
|
|
57
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
58
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
59
|
-
textureOffset = opacityAndOffset.g;
|
|
60
|
-
|
|
61
|
-
vec2 textrueOffsets = vec2(0.0, 0.0);
|
|
62
|
-
if(hasOffsets()) {
|
|
63
|
-
vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
64
|
-
textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
|
|
65
|
-
textureOffset += 1.0;
|
|
66
|
-
|
|
67
|
-
vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
68
|
-
textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
|
|
69
|
-
textureOffset += 1.0;
|
|
70
|
-
} else {
|
|
71
|
-
textrueOffsets = u_offsets;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// cal style mapping
|
|
75
32
|
|
|
76
33
|
highp float angle_sin = sin(a_Rotate);
|
|
77
34
|
highp float angle_cos = cos(a_Rotate);
|
|
78
35
|
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
|
79
36
|
float newSize = a_Size;
|
|
80
|
-
if(
|
|
37
|
+
if(u_size_unit == 1) {
|
|
81
38
|
newSize = newSize * u_PixelsPerMeter.z;
|
|
82
39
|
}
|
|
83
40
|
|
|
84
41
|
// vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
|
|
85
|
-
vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) +
|
|
42
|
+
vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);
|
|
86
43
|
vec3 aPosition = a_Position;
|
|
87
44
|
|
|
88
45
|
offset = project_pixel(offset);
|
|
@@ -5,13 +5,9 @@ varying vec2 v_uv;
|
|
|
5
5
|
uniform vec2 u_textSize;
|
|
6
6
|
uniform float u_opacity : 1;
|
|
7
7
|
|
|
8
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
9
|
-
|
|
10
8
|
#pragma include "picking"
|
|
11
9
|
|
|
12
10
|
void main(){
|
|
13
|
-
float opacity = styleMappingMat[0][0];
|
|
14
|
-
float size = styleMappingMat[1][0];
|
|
15
11
|
vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;
|
|
16
12
|
vec4 textureColor;
|
|
17
13
|
|
|
@@ -34,7 +30,7 @@ void main(){
|
|
|
34
30
|
gl_FragColor= step(0.01, textureColor.z) * v_color;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
gl_FragColor.a = gl_FragColor.a *
|
|
33
|
+
gl_FragColor.a = gl_FragColor.a * u_opacity;
|
|
38
34
|
|
|
39
35
|
if (gl_FragColor.a < 0.01) {
|
|
40
36
|
discard;
|
|
@@ -13,61 +13,18 @@ uniform float u_opacity : 1;
|
|
|
13
13
|
uniform float u_raisingHeight: 0.0;
|
|
14
14
|
uniform float u_heightfixed: 0.0;
|
|
15
15
|
|
|
16
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
17
|
-
|
|
18
|
-
#pragma include "styleMapping"
|
|
19
|
-
#pragma include "styleMappingCalOpacity"
|
|
20
16
|
|
|
21
17
|
#pragma include "projection"
|
|
22
18
|
#pragma include "picking"
|
|
23
19
|
|
|
24
20
|
void main() {
|
|
25
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
26
|
-
styleMappingMat = mat4(
|
|
27
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
28
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
29
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
30
|
-
0.0, 0.0, 0.0, 0.0
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
34
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
35
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
36
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
37
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
38
|
-
float id = a_vertexId; // 第n个顶点
|
|
39
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
40
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
41
|
-
|
|
42
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
43
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
44
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
45
|
-
|
|
46
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
47
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
48
|
-
textureOffset = opacityAndOffset.g;
|
|
49
|
-
|
|
50
|
-
styleMappingMat[1][0] = a_Size;
|
|
51
|
-
|
|
52
|
-
vec2 textrueOffsets = vec2(0.0, 0.0);
|
|
53
|
-
if(hasOffsets()) {
|
|
54
|
-
vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
55
|
-
textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
|
|
56
|
-
textureOffset += 1.0;
|
|
57
|
-
|
|
58
|
-
vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
59
|
-
textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
|
|
60
|
-
textureOffset += 1.0;
|
|
61
|
-
} else {
|
|
62
|
-
textrueOffsets = u_offsets;
|
|
63
|
-
}
|
|
64
21
|
|
|
65
22
|
// cal style mapping - 数据纹理映射部分的计算
|
|
66
23
|
v_color = a_Color;
|
|
67
24
|
v_uv = a_Uv;
|
|
68
25
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
69
26
|
|
|
70
|
-
vec2 offset = project_pixel(
|
|
27
|
+
vec2 offset = project_pixel(u_offsets);
|
|
71
28
|
|
|
72
29
|
float raisingHeight = u_raisingHeight;
|
|
73
30
|
if(u_heightfixed < 1.0) { // false
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
attribute vec3 a_Position;
|
|
3
3
|
uniform mat4 u_ModelMatrix;
|
|
4
|
+
uniform float u_opacity : 1;
|
|
4
5
|
uniform mat4 u_Mvp;
|
|
5
6
|
attribute float a_Size;
|
|
6
7
|
attribute vec4 a_Color;
|
|
@@ -11,7 +12,7 @@ varying vec4 v_color;
|
|
|
11
12
|
#pragma include "project"
|
|
12
13
|
|
|
13
14
|
void main() {
|
|
14
|
-
v_color = a_Color;
|
|
15
|
+
v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
|
|
15
16
|
|
|
16
17
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
17
18
|
gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);
|
|
@@ -7,7 +7,7 @@ uniform float u_time;
|
|
|
7
7
|
|
|
8
8
|
uniform mat4 u_ModelMatrix;
|
|
9
9
|
uniform mat4 u_Mvp;
|
|
10
|
-
uniform int
|
|
10
|
+
uniform int u_size_unit;
|
|
11
11
|
|
|
12
12
|
varying vec4 v_data;
|
|
13
13
|
varying vec4 v_color;
|
|
@@ -37,7 +37,7 @@ void main() {
|
|
|
37
37
|
float blur = 0.0;
|
|
38
38
|
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
|
|
39
39
|
|
|
40
|
-
if(
|
|
40
|
+
if(u_size_unit == 1) {
|
|
41
41
|
newSize = newSize * u_PixelsPerMeter.z;
|
|
42
42
|
}
|
|
43
43
|
// radius(16-bit)
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
uniform float u_opacity : 1;
|
|
3
|
-
uniform vec2 u_offsets;
|
|
4
2
|
uniform float u_additive;
|
|
5
|
-
|
|
6
3
|
uniform float u_stroke_opacity : 1;
|
|
7
4
|
|
|
8
5
|
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
9
6
|
|
|
10
7
|
varying vec4 v_color;
|
|
11
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
12
8
|
varying float v_blur;
|
|
13
9
|
varying float v_innerRadius;
|
|
14
10
|
|
|
@@ -16,7 +12,6 @@ varying float v_innerRadius;
|
|
|
16
12
|
void main() {
|
|
17
13
|
vec2 center = vec2(0.5);
|
|
18
14
|
|
|
19
|
-
float opacity = styleMappingMat[0][0];
|
|
20
15
|
// Tip: 片元到中心点的距离 0 - 1
|
|
21
16
|
float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;
|
|
22
17
|
// Tip: 片元的剪切成圆形
|
|
@@ -40,8 +35,6 @@ void main() {
|
|
|
40
35
|
gl_FragColor = v_color;
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
gl_FragColor.a *= opacity;
|
|
44
|
-
|
|
45
38
|
gl_FragColor = filterColor(gl_FragColor);
|
|
46
39
|
|
|
47
40
|
if(u_additive > 0.0) {
|
|
@@ -10,62 +10,20 @@ uniform float u_opacity : 1;
|
|
|
10
10
|
uniform vec2 u_offsets;
|
|
11
11
|
uniform float u_stroke_width;
|
|
12
12
|
|
|
13
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
14
13
|
varying float v_blur;
|
|
15
14
|
varying float v_innerRadius;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
#pragma include "styleMappingCalOpacity"
|
|
16
|
+
|
|
19
17
|
|
|
20
18
|
#pragma include "projection"
|
|
21
19
|
#pragma include "picking"
|
|
22
20
|
#pragma include "project"
|
|
23
21
|
void main() {
|
|
24
|
-
v_color = a_Color;
|
|
22
|
+
v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
|
|
25
23
|
v_blur = 1.0 - max(2.0/a_Size, 0.05);
|
|
26
24
|
v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);
|
|
27
|
-
|
|
28
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
29
|
-
styleMappingMat = mat4(
|
|
30
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
31
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
32
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
33
|
-
0.0, 0.0, 0.0, 0.0
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
37
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
38
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
39
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
40
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
41
|
-
float id = a_vertexId; // 第n个顶点
|
|
42
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
43
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
44
|
-
|
|
45
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
46
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
47
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
48
|
-
|
|
49
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
50
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
51
|
-
textureOffset = opacityAndOffset.g;
|
|
52
|
-
|
|
53
|
-
vec2 textrueOffsets = vec2(0.0, 0.0);
|
|
54
|
-
if(hasOffsets()) {
|
|
55
|
-
vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
56
|
-
textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
|
|
57
|
-
textureOffset += 1.0;
|
|
58
|
-
|
|
59
|
-
vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
60
|
-
textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
|
|
61
|
-
textureOffset += 1.0;
|
|
62
|
-
} else {
|
|
63
|
-
textrueOffsets = u_offsets;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// cal style mapping
|
|
67
25
|
|
|
68
|
-
vec2 offset = project_pixel(
|
|
26
|
+
vec2 offset = project_pixel(u_offsets);
|
|
69
27
|
|
|
70
28
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
71
29
|
gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);
|
|
@@ -3,47 +3,34 @@
|
|
|
3
3
|
#define FONT_SIZE 48.0
|
|
4
4
|
uniform sampler2D u_sdf_map;
|
|
5
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
6
|
uniform float u_stroke_width : 2.0;
|
|
10
7
|
uniform float u_halo_blur : 0.5;
|
|
11
8
|
uniform float u_DevicePixelRatio;
|
|
12
9
|
|
|
13
10
|
varying vec4 v_color;
|
|
11
|
+
varying vec4 v_stroke_color;
|
|
14
12
|
varying vec2 v_uv;
|
|
15
13
|
varying float v_gamma_scale;
|
|
16
14
|
varying float v_fontScale;
|
|
17
15
|
|
|
18
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
19
16
|
|
|
20
17
|
#pragma include "picking"
|
|
21
18
|
void main() {
|
|
22
19
|
// get style data mapping
|
|
23
|
-
float opacity = styleMappingMat[0][0];
|
|
24
|
-
float strokeWidth = styleMappingMat[0][2];
|
|
25
|
-
vec4 textrueStroke = vec4(
|
|
26
|
-
styleMappingMat[1][0],
|
|
27
|
-
styleMappingMat[1][1],
|
|
28
|
-
styleMappingMat[1][2],
|
|
29
|
-
styleMappingMat[1][3]
|
|
30
|
-
);
|
|
31
20
|
|
|
32
21
|
// get sdf from atlas
|
|
33
22
|
float dist = texture2D(u_sdf_map, v_uv).a;
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;
|
|
38
|
-
lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;
|
|
24
|
+
lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;
|
|
39
25
|
highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;
|
|
40
26
|
|
|
41
27
|
highp float gamma_scaled = gamma * v_gamma_scale;
|
|
42
28
|
|
|
43
29
|
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
|
44
|
-
|
|
45
|
-
gl_FragColor = mix(
|
|
46
|
-
|
|
30
|
+
|
|
31
|
+
gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));
|
|
32
|
+
|
|
33
|
+
gl_FragColor.a *= alpha;
|
|
47
34
|
// 作为 mask 模板时需要丢弃透明的像素
|
|
48
35
|
if (gl_FragColor.a < 0.01) {
|
|
49
36
|
discard;
|
|
@@ -16,86 +16,25 @@ uniform float u_raisingHeight: 0.0;
|
|
|
16
16
|
varying vec2 v_uv;
|
|
17
17
|
varying float v_gamma_scale;
|
|
18
18
|
varying vec4 v_color;
|
|
19
|
+
varying vec4 v_stroke_color;
|
|
19
20
|
varying float v_fontScale;
|
|
20
|
-
|
|
21
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
22
|
-
|
|
23
|
-
uniform float u_opacity : 1;
|
|
21
|
+
// uniform float u_opacity : 1;
|
|
24
22
|
uniform float u_stroke_width : 2;
|
|
25
23
|
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
26
24
|
|
|
27
|
-
#pragma include "styleMapping"
|
|
28
|
-
#pragma include "styleMappingCalOpacity"
|
|
29
|
-
#pragma include "styleMappingCalStrokeWidth"
|
|
30
25
|
|
|
31
26
|
#pragma include "projection"
|
|
32
27
|
#pragma include "picking"
|
|
33
28
|
|
|
34
29
|
void main() {
|
|
35
30
|
// cal style mapping - 数据纹理映射部分的计算
|
|
36
|
-
styleMappingMat = mat4(
|
|
37
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
38
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
39
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
40
|
-
0.0, 0.0, 0.0, 0.0
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
44
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
45
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
46
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
47
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
48
|
-
float id = a_vertexId; // 第n个顶点
|
|
49
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
50
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
51
31
|
|
|
52
|
-
|
|
53
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
54
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
55
|
-
|
|
56
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
57
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
58
|
-
textureOffset = opacityAndOffset.g;
|
|
59
|
-
|
|
60
|
-
vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
61
|
-
styleMappingMat[0][2] = strokeWidthAndOffset.r;
|
|
62
|
-
textureOffset = strokeWidthAndOffset.g;
|
|
63
|
-
|
|
64
|
-
vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);
|
|
65
|
-
if(hasStroke()) {
|
|
66
|
-
vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
67
|
-
styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R
|
|
68
|
-
textureOffset += 1.0;
|
|
69
|
-
|
|
70
|
-
vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
71
|
-
styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G
|
|
72
|
-
textureOffset += 1.0;
|
|
32
|
+
v_uv = a_tex / u_sdf_map_size;
|
|
73
33
|
|
|
74
|
-
vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
75
|
-
styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B
|
|
76
|
-
textureOffset += 1.0;
|
|
77
34
|
|
|
78
|
-
vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
79
|
-
styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A
|
|
80
|
-
textureOffset += 1.0;
|
|
81
|
-
} else {
|
|
82
|
-
if(u_stroke_color == vec4(0.0)) {
|
|
83
|
-
styleMappingMat[1][0] = v_color.r;
|
|
84
|
-
styleMappingMat[1][1] = v_color.g;
|
|
85
|
-
styleMappingMat[1][2] = v_color.b;
|
|
86
|
-
styleMappingMat[1][3] = v_color.a;
|
|
87
|
-
} else {
|
|
88
|
-
styleMappingMat[1][0] = u_stroke_color.r;
|
|
89
|
-
styleMappingMat[1][1] = u_stroke_color.g;
|
|
90
|
-
styleMappingMat[1][2] = u_stroke_color.b;
|
|
91
|
-
styleMappingMat[1][3] = u_stroke_color.a;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
96
35
|
|
|
97
|
-
v_color = a_Color;
|
|
98
|
-
|
|
36
|
+
v_color = vec4(a_Color.xyz, a_Color.w * opacity);
|
|
37
|
+
v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);
|
|
99
38
|
|
|
100
39
|
// 文本缩放比例
|
|
101
40
|
float fontScale = a_Size / FONT_SIZE;
|
package/es/polygon/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IPolygonLayerStyleOptions } from '../core/interface';
|
|
|
3
3
|
import { PolygonModelType } from './models/';
|
|
4
4
|
export default class PolygonLayer extends BaseLayer<IPolygonLayerStyleOptions> {
|
|
5
5
|
type: string;
|
|
6
|
+
enableEncodeStyles: string[];
|
|
6
7
|
defaultSourceConfig: {
|
|
7
8
|
data: [];
|
|
8
9
|
options: {
|
package/es/polygon/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var PolygonLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
22
22
|
}
|
|
23
23
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
24
|
_defineProperty(_assertThisInitialized(_this), "type", 'PolygonLayer');
|
|
25
|
+
_defineProperty(_assertThisInitialized(_this), "enableEncodeStyles", ['opacity']);
|
|
25
26
|
return _this;
|
|
26
27
|
}
|
|
27
28
|
_createClass(PolygonLayer, [{
|