@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
|
@@ -3,9 +3,6 @@ attribute vec3 a_Position;
|
|
|
3
3
|
attribute vec3 a_Extrude;
|
|
4
4
|
attribute float a_Size;
|
|
5
5
|
attribute float a_Shape;
|
|
6
|
-
|
|
7
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
8
|
-
|
|
9
6
|
uniform mat4 u_ModelMatrix;
|
|
10
7
|
uniform mat4 u_Mvp;
|
|
11
8
|
|
|
@@ -21,11 +18,6 @@ uniform vec2 u_offsets;
|
|
|
21
18
|
|
|
22
19
|
uniform float u_blur : 0.0;
|
|
23
20
|
|
|
24
|
-
#pragma include "styleMapping"
|
|
25
|
-
#pragma include "styleMappingCalOpacity"
|
|
26
|
-
#pragma include "styleMappingCalStrokeOpacity"
|
|
27
|
-
#pragma include "styleMappingCalStrokeWidth"
|
|
28
|
-
|
|
29
21
|
#pragma include "projection"
|
|
30
22
|
#pragma include "picking"
|
|
31
23
|
|
|
@@ -39,72 +31,6 @@ void main() {
|
|
|
39
31
|
float newSize = setPickingSize(a_Size);
|
|
40
32
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
41
33
|
|
|
42
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
43
|
-
styleMappingMat = mat4(
|
|
44
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
45
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
46
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
47
|
-
0.0, 0.0, 0.0, 0.0
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
51
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
52
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
53
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
54
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
55
|
-
float id = a_vertexId; // 第n个顶点
|
|
56
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
57
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
58
|
-
|
|
59
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
60
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
61
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
62
|
-
|
|
63
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
64
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
65
|
-
textureOffset = opacityAndOffset.g;
|
|
66
|
-
|
|
67
|
-
vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
68
|
-
styleMappingMat[0][1] = strokeOpacityAndOffset.r;
|
|
69
|
-
textureOffset = strokeOpacityAndOffset.g;
|
|
70
|
-
|
|
71
|
-
vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
72
|
-
styleMappingMat[0][2] = strokeWidthAndOffset.r;
|
|
73
|
-
textureOffset = strokeWidthAndOffset.g;
|
|
74
|
-
|
|
75
|
-
vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);
|
|
76
|
-
if(hasStroke()) {
|
|
77
|
-
vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
78
|
-
styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R
|
|
79
|
-
textureOffset += 1.0;
|
|
80
|
-
|
|
81
|
-
vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
82
|
-
styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G
|
|
83
|
-
textureOffset += 1.0;
|
|
84
|
-
|
|
85
|
-
vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
86
|
-
styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B
|
|
87
|
-
textureOffset += 1.0;
|
|
88
|
-
|
|
89
|
-
vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
90
|
-
styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A
|
|
91
|
-
textureOffset += 1.0;
|
|
92
|
-
} else {
|
|
93
|
-
if(u_stroke_color == vec4(0.0)) {
|
|
94
|
-
styleMappingMat[1][0] = v_color.r;
|
|
95
|
-
styleMappingMat[1][1] = v_color.g;
|
|
96
|
-
styleMappingMat[1][2] = v_color.b;
|
|
97
|
-
styleMappingMat[1][3] = v_color.a;
|
|
98
|
-
} else {
|
|
99
|
-
styleMappingMat[1][0] = u_stroke_color.r;
|
|
100
|
-
styleMappingMat[1][1] = u_stroke_color.g;
|
|
101
|
-
styleMappingMat[1][2] = u_stroke_color.b;
|
|
102
|
-
styleMappingMat[1][3] = u_stroke_color.a;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// cal style mapping
|
|
107
|
-
|
|
108
34
|
// unpack color(vec2)
|
|
109
35
|
v_color = a_Color;
|
|
110
36
|
|
|
@@ -119,7 +45,7 @@ void main() {
|
|
|
119
45
|
v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
|
|
120
46
|
|
|
121
47
|
|
|
122
|
-
gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);
|
|
48
|
+
gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + u_offsets, 1.0);
|
|
123
49
|
|
|
124
50
|
setPickingColor(a_PickingColor);
|
|
125
51
|
}
|
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
varying vec4 v_color;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
varying float v_lightWeight;
|
|
4
3
|
uniform float u_pickLight: 0.0;
|
|
5
4
|
|
|
6
5
|
#pragma include "picking"
|
|
7
6
|
|
|
8
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
9
|
-
|
|
10
|
-
uniform float u_linearColor: 0;
|
|
11
|
-
uniform vec4 u_sourceColor;
|
|
12
|
-
uniform vec4 u_targetColor;
|
|
13
|
-
|
|
14
|
-
uniform float u_opacitylinear: 0.0;
|
|
15
|
-
uniform float u_opacitylinear_dir: 1.0;
|
|
16
7
|
|
|
17
8
|
void main() {
|
|
18
|
-
float opacity = styleMappingMat[0][0];
|
|
19
|
-
float lightWeight = styleMappingMat[1][3];
|
|
20
|
-
float barLinearZ = styleMappingMat[2][3];
|
|
21
|
-
|
|
22
|
-
// 设置圆柱的底色
|
|
23
|
-
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
24
|
-
gl_FragColor = mix(u_sourceColor, u_targetColor, barLinearZ);
|
|
25
|
-
gl_FragColor.rgb *= lightWeight;
|
|
26
|
-
} else { // 使用 color 方法传入的颜色
|
|
27
|
-
gl_FragColor = v_color;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 应用透明度
|
|
31
|
-
gl_FragColor.a *= opacity;
|
|
32
9
|
|
|
10
|
+
gl_FragColor = v_color;
|
|
33
11
|
// 开启透明度渐变
|
|
34
|
-
if(u_opacitylinear > 0.0) {
|
|
35
|
-
gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - barLinearZ): barLinearZ;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
12
|
// picking
|
|
39
13
|
if(u_pickLight > 0.0) {
|
|
40
|
-
gl_FragColor = filterColorAlpha(gl_FragColor,
|
|
14
|
+
gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);
|
|
41
15
|
} else {
|
|
42
16
|
gl_FragColor = filterColor(gl_FragColor);
|
|
43
17
|
}
|
|
@@ -16,14 +16,17 @@ uniform float u_r;
|
|
|
16
16
|
uniform mat4 u_ModelMatrix;
|
|
17
17
|
uniform mat4 u_Mvp;
|
|
18
18
|
varying vec4 v_color;
|
|
19
|
+
varying float v_lightWeight;
|
|
20
|
+
varying float v_barLinearZ;
|
|
19
21
|
|
|
20
22
|
uniform float u_opacity : 1;
|
|
21
23
|
uniform float u_lightEnable: 1;
|
|
24
|
+
uniform float u_opacitylinear: 0.0;
|
|
25
|
+
uniform vec4 u_sourceColor;
|
|
26
|
+
uniform vec4 u_targetColor;
|
|
27
|
+
uniform float u_opacitylinear_dir: 1.0;
|
|
28
|
+
uniform float u_linearColor: 0.0;
|
|
22
29
|
|
|
23
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
24
|
-
|
|
25
|
-
#pragma include "styleMapping"
|
|
26
|
-
#pragma include "styleMappingCalOpacity"
|
|
27
30
|
|
|
28
31
|
#pragma include "projection"
|
|
29
32
|
#pragma include "light"
|
|
@@ -47,37 +50,11 @@ float getXRadian(float y, float r) {
|
|
|
47
50
|
|
|
48
51
|
void main() {
|
|
49
52
|
|
|
50
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
51
|
-
styleMappingMat = mat4(
|
|
52
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
53
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA - lightWeight
|
|
54
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - linearZ(垂直方向 0 - 1 的值)
|
|
55
|
-
0.0, 0.0, 0.0, 0.0
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
59
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
60
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
61
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
62
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
63
|
-
float id = a_vertexId; // 第n个顶点
|
|
64
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
65
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
66
|
-
|
|
67
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
68
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
69
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
70
|
-
|
|
71
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
72
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
73
|
-
textureOffset = opacityAndOffset.g;
|
|
74
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
75
|
-
vec3 size = a_Size * a_Position;
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
styleMappingMat[2][3] = a_Position.z;
|
|
54
|
+
vec3 size = a_Size * a_Position;
|
|
79
55
|
|
|
80
56
|
vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
|
|
57
|
+
|
|
81
58
|
if(u_heightfixed < 1.0) { // 圆柱体不固定高度
|
|
82
59
|
|
|
83
60
|
if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
|
|
@@ -100,14 +77,29 @@ void main() {
|
|
|
100
77
|
// u_r 控制圆柱的生长
|
|
101
78
|
vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
|
|
102
79
|
|
|
103
|
-
// 圆柱光照效果
|
|
80
|
+
// // 圆柱光照效果
|
|
104
81
|
float lightWeight = 1.0;
|
|
82
|
+
|
|
105
83
|
if(u_lightEnable > 0.0) { // 取消三元表达式,增强健壮性
|
|
106
84
|
lightWeight = calc_lighting(pos);
|
|
107
85
|
}
|
|
108
|
-
styleMappingMat[1][3] = lightWeight;
|
|
109
86
|
|
|
110
|
-
|
|
87
|
+
v_lightWeight = lightWeight;
|
|
88
|
+
|
|
89
|
+
v_color = a_Color;
|
|
90
|
+
|
|
91
|
+
// 设置圆柱的底色
|
|
92
|
+
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
93
|
+
v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
|
|
94
|
+
v_color.a = v_color.a * u_opacity;
|
|
95
|
+
} else {
|
|
96
|
+
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * u_opacity);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if(u_opacitylinear > 0.0) {
|
|
100
|
+
v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;
|
|
101
|
+
}
|
|
102
|
+
|
|
111
103
|
|
|
112
104
|
// gl_Position = project_common_position_to_clipspace(pos);
|
|
113
105
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
uniform float u_additive;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
uniform float u_stroke_opacity : 1;
|
|
3
|
+
uniform float u_stroke_width : 2;
|
|
4
4
|
|
|
5
5
|
varying vec4 v_data;
|
|
6
6
|
varying vec4 v_color;
|
|
7
7
|
varying float v_radius;
|
|
8
|
+
varying vec4 v_stroke;
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
#pragma include "sdf_2d"
|
|
10
12
|
#pragma include "picking"
|
|
@@ -12,21 +14,8 @@ varying float v_radius;
|
|
|
12
14
|
|
|
13
15
|
void main() {
|
|
14
16
|
int shape = int(floor(v_data.w + 0.5));
|
|
15
|
-
|
|
16
|
-
vec4 textrueStroke = vec4(
|
|
17
|
-
styleMappingMat[1][0],
|
|
18
|
-
styleMappingMat[1][1],
|
|
19
|
-
styleMappingMat[1][2],
|
|
20
|
-
styleMappingMat[1][3]
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
float opacity = styleMappingMat[0][0];
|
|
24
|
-
float stroke_opacity = styleMappingMat[0][1];
|
|
25
|
-
float strokeWidth = styleMappingMat[0][2];
|
|
26
|
-
vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;
|
|
27
|
-
|
|
28
17
|
lowp float antialiasblur = v_data.z;
|
|
29
|
-
float r = v_radius / (v_radius +
|
|
18
|
+
float r = v_radius / (v_radius + u_stroke_width);
|
|
30
19
|
|
|
31
20
|
float outer_df;
|
|
32
21
|
float inner_df;
|
|
@@ -62,16 +51,16 @@ void main() {
|
|
|
62
51
|
|
|
63
52
|
float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
|
|
64
53
|
|
|
65
|
-
float color_t =
|
|
54
|
+
float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(
|
|
66
55
|
antialiasblur,
|
|
67
56
|
0.0,
|
|
68
57
|
inner_df
|
|
69
58
|
);
|
|
70
59
|
|
|
71
|
-
if(
|
|
72
|
-
gl_FragColor =
|
|
60
|
+
if(u_stroke_width < 0.01) {
|
|
61
|
+
gl_FragColor = v_color;
|
|
73
62
|
} else {
|
|
74
|
-
gl_FragColor = mix(
|
|
63
|
+
gl_FragColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);
|
|
75
64
|
}
|
|
76
65
|
|
|
77
66
|
if(u_additive > 0.0) {
|
|
@@ -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
|