@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
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
#define Animate 0.0
|
|
2
|
-
#define LineTexture 1.0
|
|
3
|
-
|
|
4
|
-
uniform float u_opacity;
|
|
5
|
-
uniform float u_textureBlend;
|
|
6
|
-
uniform float u_blur : 0.9;
|
|
7
|
-
uniform float u_line_type: 0.0;
|
|
8
|
-
// varying vec2 v_normal;
|
|
9
|
-
varying vec4 v_dash_array;
|
|
10
1
|
varying vec4 v_color;
|
|
11
2
|
|
|
12
|
-
uniform float u_time;
|
|
13
|
-
uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
|
|
14
|
-
|
|
15
|
-
uniform float u_line_texture;
|
|
16
|
-
uniform sampler2D u_texture;
|
|
17
|
-
uniform vec2 u_textSize;
|
|
18
|
-
|
|
19
|
-
uniform float segmentNumber;
|
|
20
|
-
varying vec2 v_iconMapUV;
|
|
21
|
-
|
|
22
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
23
|
-
|
|
24
|
-
uniform float u_linearColor: 0;
|
|
25
|
-
uniform vec4 u_sourceColor;
|
|
26
|
-
uniform vec4 u_targetColor;
|
|
27
|
-
|
|
28
3
|
#pragma include "picking"
|
|
29
4
|
|
|
30
5
|
void main() {
|
|
31
|
-
|
|
32
|
-
float d_segmentIndex = styleMappingMat[3].r; // 当前顶点在弧线中所处的分段位置
|
|
6
|
+
// 当前顶点在弧线中所处的分段位置
|
|
33
7
|
|
|
34
|
-
|
|
35
|
-
gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
|
|
36
|
-
gl_FragColor.a *= opacity;
|
|
8
|
+
gl_FragColor = v_Color;
|
|
37
9
|
gl_FragColor = filterColor(gl_FragColor);
|
|
38
10
|
}
|
|
@@ -7,17 +7,16 @@ uniform mat4 u_ModelMatrix;
|
|
|
7
7
|
uniform mat4 u_Mvp;
|
|
8
8
|
uniform float segmentNumber;
|
|
9
9
|
varying vec4 v_color;
|
|
10
|
+
varying float v_segmentIndex;
|
|
10
11
|
|
|
11
12
|
uniform float u_lineDir: 1.0;
|
|
12
13
|
|
|
13
14
|
uniform float u_thetaOffset: 0.314;
|
|
15
|
+
uniform vec4 u_sourceColor;
|
|
16
|
+
uniform vec4 u_targetColor;
|
|
17
|
+
|
|
14
18
|
|
|
15
|
-
uniform float u_opacity: 1.0;
|
|
16
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
17
19
|
|
|
18
|
-
#pragma include "styleMapping"
|
|
19
|
-
#pragma include "styleMappingCalOpacity"
|
|
20
|
-
#pragma include "styleMappingCalThetaOffset"
|
|
21
20
|
|
|
22
21
|
#pragma include "projection"
|
|
23
22
|
#pragma include "project"
|
|
@@ -73,37 +72,6 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
|
|
|
73
72
|
void main() {
|
|
74
73
|
v_color = a_Color;
|
|
75
74
|
|
|
76
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
77
|
-
styleMappingMat = mat4(
|
|
78
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
79
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
80
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
81
|
-
0.0, 0.0, 0.0, 0.0 // dataset 数据集
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
85
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
86
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
87
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
88
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
89
|
-
float id = a_vertexId; // 第n个顶点
|
|
90
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
91
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
92
|
-
|
|
93
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke -> thetaOffset...
|
|
94
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
95
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
96
|
-
|
|
97
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
98
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
99
|
-
textureOffset = opacityAndOffset.g;
|
|
100
|
-
|
|
101
|
-
vec2 thetaOffsetAndOffset = calThetaOffsetAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
102
|
-
styleMappingMat[0][1] = thetaOffsetAndOffset.r;
|
|
103
|
-
textureOffset = thetaOffsetAndOffset.g;
|
|
104
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
105
|
-
|
|
106
|
-
|
|
107
75
|
vec2 source = a_Instance.rg; // 起始点
|
|
108
76
|
vec2 target = a_Instance.ba; // 终点
|
|
109
77
|
float segmentIndex = a_Position.x;
|
|
@@ -112,12 +80,8 @@ void main() {
|
|
|
112
80
|
float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
|
|
113
81
|
float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
|
|
114
82
|
float d_distance_ratio;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// styleMappingMat[0][1] - arcThetaOffset
|
|
119
|
-
vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, styleMappingMat[0][1]), 0.0, 1.0));
|
|
120
|
-
vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, styleMappingMat[0][1]), 0.0, 1.0));
|
|
83
|
+
vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset, 0.0, 1.0));
|
|
84
|
+
vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
|
|
121
85
|
// v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
|
|
122
86
|
//unProjCustomCoord
|
|
123
87
|
|
|
@@ -125,11 +89,11 @@ void main() {
|
|
|
125
89
|
|
|
126
90
|
|
|
127
91
|
float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
|
|
128
|
-
styleMappingMat[3].r = d_segmentIndex;
|
|
129
92
|
|
|
130
|
-
|
|
93
|
+
v_Color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
|
|
94
|
+
v_Color.a *= u_opacity;
|
|
95
|
+
|
|
131
96
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
132
|
-
// gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));
|
|
133
97
|
gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));
|
|
134
98
|
} else {
|
|
135
99
|
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
varying vec4 v_color;
|
|
2
|
+
varying vec4 v_texture_data;
|
|
2
3
|
uniform float u_linearDir: 1.0;
|
|
3
4
|
uniform float u_linearColor: 0;
|
|
4
5
|
uniform vec4 u_sourceColor;
|
|
5
6
|
uniform vec4 u_targetColor;
|
|
7
|
+
uniform float u_opacity: 1.0;
|
|
6
8
|
|
|
7
9
|
#pragma include "picking"
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
varying mat4 styleMappingMat;
|
|
11
|
-
|
|
12
12
|
void main() {
|
|
13
|
-
float
|
|
14
|
-
float linearRadio = styleMappingMat[3][0]; // 当前点位距离占线总长的比例
|
|
13
|
+
float linearRadio = v_texture_data.r; // 当前点位距离占线总长的比例
|
|
15
14
|
if(u_linearDir < 1.0) {
|
|
16
|
-
linearRadio =
|
|
15
|
+
linearRadio = v_texture_data.a;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
@@ -22,6 +21,6 @@ void main() {
|
|
|
22
21
|
gl_FragColor = v_color;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
gl_FragColor.a *=
|
|
24
|
+
gl_FragColor.a *= u_opacity; // 全局透明度
|
|
26
25
|
gl_FragColor = filterColor(gl_FragColor);
|
|
27
26
|
}
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
uniform float u_opacity : 1.0;
|
|
2
|
-
uniform sampler2D u_texture;
|
|
3
|
-
uniform float u_linearDir: 1.0;
|
|
4
1
|
|
|
2
|
+
varying vec4 v_Color;
|
|
5
3
|
#pragma include "picking"
|
|
6
|
-
|
|
7
|
-
varying mat4 styleMappingMat;
|
|
8
|
-
|
|
9
4
|
void main() {
|
|
10
|
-
float opacity = styleMappingMat[0][0];
|
|
11
|
-
float linearRadio = styleMappingMat[3].r; // 当前点位距离占线总长的比例
|
|
12
|
-
if(u_linearDir < 1.0) {
|
|
13
|
-
linearRadio = styleMappingMat[3][3];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
gl_FragColor = texture2D(u_texture, vec2(linearRadio, 0.5));
|
|
17
5
|
|
|
18
|
-
gl_FragColor
|
|
6
|
+
gl_FragColor = v_Color; // 全局透明度
|
|
19
7
|
gl_FragColor = filterColor(gl_FragColor);
|
|
20
8
|
}
|
|
@@ -14,43 +14,18 @@ uniform mat4 u_Mvp;
|
|
|
14
14
|
uniform float u_heightfixed: 0.0;
|
|
15
15
|
uniform float u_vertexScale: 1.0;
|
|
16
16
|
uniform float u_raisingHeight: 0.0;
|
|
17
|
+
uniform float u_opacity : 1.0;
|
|
18
|
+
uniform sampler2D u_texture;
|
|
19
|
+
uniform float u_linearDir: 1.0;
|
|
20
|
+
varying vec4 v_Color;
|
|
17
21
|
|
|
18
|
-
uniform float u_opacity: 1.0;
|
|
19
22
|
|
|
20
23
|
#pragma include "projection"
|
|
21
24
|
#pragma include "picking"
|
|
22
25
|
|
|
23
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
24
|
-
|
|
25
|
-
#pragma include "styleMapping"
|
|
26
|
-
#pragma include "styleMappingCalOpacity"
|
|
27
26
|
|
|
28
27
|
void main() {
|
|
29
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
30
|
-
styleMappingMat = mat4(
|
|
31
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
32
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
33
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
34
|
-
0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
38
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
39
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
40
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
41
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
42
|
-
float id = a_vertexId; // 第n个顶点
|
|
43
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
44
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
45
|
-
|
|
46
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
47
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
48
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
49
28
|
|
|
50
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
51
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
52
|
-
textureOffset = opacityAndOffset.g;
|
|
53
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
54
29
|
|
|
55
30
|
vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
|
|
56
31
|
|
|
@@ -64,9 +39,16 @@ void main() {
|
|
|
64
39
|
float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
|
|
65
40
|
float texV = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
|
|
66
41
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
42
|
+
float linearRadio =currentLinePointRatio; // 当前点位距离占线总长的比例
|
|
43
|
+
if(u_linearDir < 1.0) {
|
|
44
|
+
linearRadio = texV;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
v_Color = texture2D(u_texture, vec2(linearRadio, 0.5));
|
|
48
|
+
|
|
49
|
+
v_Color.a *= u_opacity; // 全局透明度
|
|
50
|
+
|
|
51
|
+
|
|
70
52
|
|
|
71
53
|
vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
|
|
72
54
|
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
uniform vec4 u_sourceColor;
|
|
2
2
|
uniform vec4 u_targetColor;
|
|
3
|
-
|
|
4
|
-
varying mat4 styleMappingMat;
|
|
3
|
+
uniform float opacity;
|
|
5
4
|
void main() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// styleMappingMat[3][0] 当前点位距离占线总长的比例
|
|
9
|
-
gl_FragColor = mix(u_sourceColor, u_targetColor, styleMappingMat[3][0]);
|
|
5
|
+
gl_FragColor = mix(u_sourceColor, u_targetColor, v_distanceScale);
|
|
10
6
|
gl_FragColor.a *= opacity; // 全局透明度
|
|
11
7
|
}
|
|
@@ -10,47 +10,21 @@ uniform mat4 u_Mvp;
|
|
|
10
10
|
|
|
11
11
|
uniform float u_opacity: 1.0;
|
|
12
12
|
uniform float u_vertexScale: 1.0;
|
|
13
|
+
uniform vec4 u_sourceColor;
|
|
14
|
+
uniform vec4 u_targetColor;
|
|
13
15
|
|
|
14
|
-
#pragma include "projection"
|
|
15
16
|
|
|
16
|
-
varying vec4 v_color;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
#pragma include "projection"
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
varying vec4 v_color;
|
|
21
|
+
varying float v_distanceScale;
|
|
22
22
|
|
|
23
23
|
void main() {
|
|
24
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
25
|
-
styleMappingMat = mat4(
|
|
26
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
27
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
28
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
29
|
-
0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV
|
|
30
|
-
);
|
|
31
24
|
|
|
32
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
33
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
34
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
35
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
36
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
37
|
-
float id = a_vertexId; // 第n个顶点
|
|
38
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
39
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
40
|
-
|
|
41
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
42
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
43
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
44
|
-
|
|
45
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
46
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
47
|
-
textureOffset = opacityAndOffset.g;
|
|
48
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
49
|
-
|
|
50
|
-
|
|
51
25
|
v_color = a_Color;
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
v_distanceScale = a_Distance / a_Total_Distance;
|
|
27
|
+
v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
|
|
54
28
|
vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
|
|
55
29
|
|
|
56
30
|
float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况
|
|
@@ -105,7 +105,9 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
105
105
|
}
|
|
106
106
|
if (attributesToRemapping.length) {
|
|
107
107
|
// 过滤数据
|
|
108
|
-
var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData()
|
|
108
|
+
var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData() // TODO 优化
|
|
109
|
+
);
|
|
110
|
+
|
|
109
111
|
layer.setEncodedData(encodeData);
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -132,7 +134,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
132
134
|
// 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
|
|
133
135
|
// 在各个 layer 中继承
|
|
134
136
|
|
|
135
|
-
filterData = layer.processData(filterData);
|
|
137
|
+
filterData = layer.processData(filterData); // 目前只有简单线需要处理
|
|
136
138
|
var encodeData = this.mapping(layer, attributes, filterData, undefined);
|
|
137
139
|
layer.setEncodedData(encodeData);
|
|
138
140
|
if (dataArray.length === 0 && layer.encodeDataLength === 0) {
|
|
@@ -164,8 +166,8 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
164
166
|
}, preRecord);
|
|
165
167
|
usedAttributes.forEach(function (attribute) {
|
|
166
168
|
var values = _this3.applyAttributeMapping(attribute, record);
|
|
167
|
-
// TODO: 支持每个属性配置 postprocess
|
|
168
|
-
if (attribute.name === 'color') {
|
|
169
|
+
// TODO: 支持每个属性配置 postprocess}
|
|
170
|
+
if (attribute.name === 'color' || attribute.name === 'stroke') {
|
|
169
171
|
values = values.map(function (c) {
|
|
170
172
|
return (0, _l7Utils.rgb2arr)(c);
|
|
171
173
|
});
|
|
@@ -178,7 +180,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
178
180
|
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
179
181
|
}
|
|
180
182
|
});
|
|
181
|
-
if (arrow.enable &&
|
|
183
|
+
if (arrow.enable && encodeRecord.shape === 'line') {
|
|
182
184
|
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
183
185
|
var coords = encodeRecord.coordinates;
|
|
184
186
|
// @ts-ignore
|
|
@@ -209,36 +211,20 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
209
211
|
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
210
212
|
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version['GAODE2.x']) {
|
|
211
213
|
var layerCenter = layer.coordCenter || layer.getSource().center;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
// 单个的点数据
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
mappedData
|
|
217
|
+
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
218
|
+
.filter(function (d) {
|
|
219
|
+
return !d.originCoordinates;
|
|
220
|
+
}).map(function (d) {
|
|
221
|
+
d.version = _l7Maps.Version['GAODE2.x'];
|
|
214
222
|
// @ts-ignore
|
|
215
|
-
|
|
216
|
-
//
|
|
217
|
-
.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
d.version = _l7Maps.Version['GAODE2.x'];
|
|
221
|
-
// @ts-ignore
|
|
222
|
-
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
223
|
-
// @ts-ignore
|
|
224
|
-
// d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
|
|
225
|
-
d.coordinates = _this4.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
// 连续的线、面数据
|
|
229
|
-
mappedData
|
|
230
|
-
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
231
|
-
.filter(function (d) {
|
|
232
|
-
return !d.originCoordinates;
|
|
233
|
-
}).map(function (d) {
|
|
234
|
-
d.version = _l7Maps.Version['GAODE2.x'];
|
|
235
|
-
// @ts-ignore
|
|
236
|
-
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
237
|
-
// @ts-ignore
|
|
238
|
-
// d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
|
|
239
|
-
d.coordinates = _this4.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
223
|
+
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
224
|
+
// @ts-ignore
|
|
225
|
+
// d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
|
|
226
|
+
d.coordinates = _this4.mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
|
|
227
|
+
});
|
|
242
228
|
}
|
|
243
229
|
}
|
|
244
230
|
}, {
|
|
@@ -28,7 +28,7 @@ var LayerModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
|
|
|
28
28
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
29
29
|
while (1) switch (_context.prev = _context.next) {
|
|
30
30
|
case 0:
|
|
31
|
-
// 更新Model 配置项
|
|
31
|
+
// 更新Model 配置项 style options
|
|
32
32
|
layer.prepareBuildModel();
|
|
33
33
|
// 初始化 Model
|
|
34
34
|
_context.next = 3;
|
|
@@ -76,6 +76,8 @@ var LayerModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
|
|
|
76
76
|
_context3.next = 2;
|
|
77
77
|
return this.build(layer);
|
|
78
78
|
case 2:
|
|
79
|
+
layer.styleNeedUpdate = false;
|
|
80
|
+
case 3:
|
|
79
81
|
case "end":
|
|
80
82
|
return _context3.stop();
|
|
81
83
|
}
|
|
@@ -147,6 +149,16 @@ var LayerModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
|
|
|
147
149
|
return _ref2.apply(this, arguments);
|
|
148
150
|
};
|
|
149
151
|
}());
|
|
152
|
+
layer.hooks.beforeRender.tap('LayerModelPlugin', function () {
|
|
153
|
+
// 判断数据映射是否需要更新
|
|
154
|
+
if (layer.styleNeedUpdate) {
|
|
155
|
+
_this.prepareLayerModel(layer).then(function () {
|
|
156
|
+
layer.styleNeedUpdate = false;
|
|
157
|
+
layer.renderLayers();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
layer.styleNeedUpdate = false;
|
|
161
|
+
});
|
|
150
162
|
}
|
|
151
163
|
}]);
|
|
152
164
|
return LayerModelPlugin;
|
|
@@ -37,7 +37,7 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
37
37
|
var _this = this;
|
|
38
38
|
var version = this.mapService.version;
|
|
39
39
|
var mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
|
|
40
|
-
var
|
|
40
|
+
var sceneCenterMercator = [0, 0];
|
|
41
41
|
layer.hooks.beforeRender.tap('ShaderUniformPlugin', function () {
|
|
42
42
|
// @ts-ignore
|
|
43
43
|
var offset = layer.getLayerConfig().tileOrigin;
|
|
@@ -49,14 +49,14 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
49
49
|
mvp = _this.mapService.map.customCoords.getMVPMatrix();
|
|
50
50
|
// mvp = amapCustomCoords.getMVPMatrix()
|
|
51
51
|
// @ts-ignore
|
|
52
|
-
|
|
52
|
+
sceneCenterMercator = _this.mapService.getCustomCoordCenter();
|
|
53
53
|
}
|
|
54
54
|
var _this$rendererService = _this.rendererService.getViewportSize(),
|
|
55
55
|
width = _this$rendererService.width,
|
|
56
56
|
height = _this$rendererService.height;
|
|
57
57
|
layer.models.forEach(function (model) {
|
|
58
58
|
var _model$addUniforms;
|
|
59
|
-
model.addUniforms((_model$addUniforms = {}, (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.Zoom, _this.cameraService.getZoom()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.Mvp, mvp), (0, _defineProperty2.default)(_model$addUniforms, "
|
|
59
|
+
model.addUniforms((_model$addUniforms = {}, (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.Zoom, _this.cameraService.getZoom()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.Mvp, mvp), (0, _defineProperty2.default)(_model$addUniforms, "u_sceneCenterMercator", sceneCenterMercator), (0, _defineProperty2.default)(_model$addUniforms, "u_ViewportSize", [width, height]), (0, _defineProperty2.default)(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), (0, _defineProperty2.default)(_model$addUniforms, "u_DevicePixelRatio", _l7Utils.$window.devicePixelRatio), (0, _defineProperty2.default)(_model$addUniforms, "u_PickingBuffer", layer.getLayerConfig().pickingBuffer || 0), (0, _defineProperty2.default)(_model$addUniforms, "u_shaderPick", Number(layer.getShaderPickStat())), _model$addUniforms));
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// TODO:脏检查,决定是否需要渲染
|
package/lib/point/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
32
32
|
}
|
|
33
33
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
34
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'PointLayer');
|
|
35
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableEncodeStyles", ['opacity', 'offsets', 'stroke']);
|
|
35
36
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultSourceConfig", {
|
|
36
37
|
data: [],
|
|
37
38
|
options: {
|
|
@@ -23,9 +23,9 @@ var _utils = require("../../earth/utils");
|
|
|
23
23
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
24
24
|
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; } }
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/earth/extrude_frag.glsl' */
|
|
26
|
-
var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\nuniform float u_pickLight: 0.0;\n\n#pragma include \"picking\"\n\
|
|
26
|
+
var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\nuniform float u_pickLight: 0.0;\n\n#pragma include \"picking\"\n\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_opacitylinear: 0.0;\nuniform float u_opacitylinear_dir: 1.0;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\nvoid main() {\n\n gl_FragColor = v_color;\n\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - v_barLinearZ): v_barLinearZ;\n }\n\n // picking\n if(u_pickLight > 0.0) {\n gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/earth/extrude_vert.glsl' */
|
|
28
|
-
var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_globel;\nuniform float u_r;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\
|
|
28
|
+
var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_globel;\nuniform float u_r;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\n// \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n \n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n // a_Position.z \u662F\u5728\u6784\u5EFA\u7F51\u683C\u7684\u65F6\u5019\u4F20\u5165\u7684\u6807\u51C6\u503C 0 - 1\uFF0C\u5728\u63D2\u503C\u5668\u63D2\u503C\u53EF\u4EE5\u83B7\u53D6 0\uFF5E1 \u7EBF\u6027\u6E10\u53D8\u7684\u503C\n v_barLinearZ = a_Position.z;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n v_lightWeight = lightWeight;\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, barLinearZ);\n v_color.rgb *= lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n v_color = a_Color;\n }\n v_color.a *= u_opacity;\n\n \n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0, \n 0,xcos,-xsin,0, \n 0,xsin,xcos,0, \n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0, \n 0,1,0,0, \n ysin,0,ycos,0, \n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n \n\n setPickingColor(a_PickingColor);\n}\n";
|
|
29
29
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
30
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
31
31
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -65,35 +65,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
65
65
|
} : _ref$opacityLinear,
|
|
66
66
|
_ref$lightEnable = _ref.lightEnable,
|
|
67
67
|
lightEnable = _ref$lightEnable === void 0 ? true : _ref$lightEnable;
|
|
68
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
69
|
-
opacity: opacity
|
|
70
|
-
})) {
|
|
71
|
-
this.judgeStyleAttributes({
|
|
72
|
-
opacity: opacity
|
|
73
|
-
});
|
|
74
|
-
var encodeData = this.layer.getEncodedData();
|
|
75
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
76
|
-
data = _this$calDataFrame.data,
|
|
77
|
-
width = _this$calDataFrame.width,
|
|
78
|
-
height = _this$calDataFrame.height;
|
|
79
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
80
|
-
|
|
81
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
82
|
-
flipY: true,
|
|
83
|
-
data: data,
|
|
84
|
-
format: _l7Core.gl.LUMINANCE,
|
|
85
|
-
type: _l7Core.gl.FLOAT,
|
|
86
|
-
width: width,
|
|
87
|
-
height: height
|
|
88
|
-
}) : this.createTexture2D({
|
|
89
|
-
flipY: true,
|
|
90
|
-
data: [1],
|
|
91
|
-
format: _l7Core.gl.LUMINANCE,
|
|
92
|
-
type: _l7Core.gl.FLOAT,
|
|
93
|
-
width: 1,
|
|
94
|
-
height: 1
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
68
|
|
|
98
69
|
// 转化渐变色
|
|
99
70
|
var useLinearColor = 0; // 默认不生效
|
|
@@ -125,9 +96,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
125
96
|
// 圆柱体是否固定高度
|
|
126
97
|
u_heightfixed: Number(heightfixed),
|
|
127
98
|
u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
|
|
128
|
-
u_dataTexture: this.dataTexture,
|
|
129
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
130
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
131
99
|
u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
|
|
132
100
|
// 渐变色支持参数
|
|
133
101
|
u_linearColor: useLinearColor,
|
|
@@ -199,12 +167,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
199
167
|
}
|
|
200
168
|
return buildModels;
|
|
201
169
|
}()
|
|
202
|
-
}, {
|
|
203
|
-
key: "clearModels",
|
|
204
|
-
value: function clearModels() {
|
|
205
|
-
var _this$dataTexture;
|
|
206
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
207
|
-
}
|
|
208
170
|
}, {
|
|
209
171
|
key: "registerBuiltinAttributes",
|
|
210
172
|
value: function registerBuiltinAttributes() {
|