@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,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/lib/polygon/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var PolygonLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
29
29
|
}
|
|
30
30
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
31
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'PolygonLayer');
|
|
32
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableEncodeStyles", ['opacity']);
|
|
32
33
|
return _this;
|
|
33
34
|
}
|
|
34
35
|
(0, _createClass2.default)(PolygonLayer, [{
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
14
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
@@ -15,23 +16,22 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
15
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
17
|
var _l7Core = require("@antv/l7-core");
|
|
17
18
|
var _l7Utils = require("@antv/l7-utils");
|
|
18
|
-
var _lodash = require("lodash");
|
|
19
19
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
20
|
var _triangulation = require("../../core/triangulation");
|
|
21
21
|
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); }; }
|
|
22
22
|
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; } }
|
|
23
23
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
|
|
24
|
-
var polygonExtrudeFrag = "uniform
|
|
24
|
+
var polygonExtrudeFrag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\n\n#pragma include \"picking\"\n\nvoid main() {\n\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = v_Color;\n \n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
|
|
26
|
-
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\
|
|
26
|
+
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n float isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
|
|
28
|
-
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying
|
|
28
|
+
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying vec3 v_uvs;\nvarying vec2 v_texture_data;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n } else {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = texture2D(u_texture, vec2(topU, topV));\n // gl_FragColor = vec4(1.0, 0., 0., 1.0);\n }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; // texture
|
|
29
29
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
|
|
30
|
-
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float
|
|
30
|
+
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform sampler2D u_texture;\n\n\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_linearColor: 0.0;\n\nvarying vec2 v_texture_data;\nvarying vec3 v_uvs;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_uvs = a_uvs;\n\n v_texture_data = vec2(a_Position.z, lightWeight);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
|
|
31
31
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
|
|
32
|
-
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying
|
|
32
|
+
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying vec3 v_uvs;\nvarying vec2 v_texture_data;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n // side notuse linear\n gl_FragColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n}\n";
|
|
33
33
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
|
|
34
|
-
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\
|
|
34
|
+
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_texture_data;\nvarying vec3 v_uvs;\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n\n\n v_uvs = a_uvs;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n v_texture_data = vec2(a_Position.z,lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
35
35
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
36
36
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
37
37
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -43,8 +43,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
43
43
|
key: "getUninforms",
|
|
44
44
|
value: function getUninforms() {
|
|
45
45
|
var _ref = this.layer.getLayerConfig(),
|
|
46
|
-
_ref$opacity = _ref.opacity,
|
|
47
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
48
46
|
_ref$heightfixed = _ref.heightfixed,
|
|
49
47
|
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
50
48
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
@@ -55,35 +53,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
55
53
|
sidesurface = _ref$sidesurface === void 0 ? true : _ref$sidesurface,
|
|
56
54
|
sourceColor = _ref.sourceColor,
|
|
57
55
|
targetColor = _ref.targetColor;
|
|
58
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
59
|
-
opacity: opacity
|
|
60
|
-
})) {
|
|
61
|
-
this.judgeStyleAttributes({
|
|
62
|
-
opacity: opacity
|
|
63
|
-
});
|
|
64
|
-
var encodeData = this.layer.getEncodedData();
|
|
65
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
66
|
-
data = _this$calDataFrame.data,
|
|
67
|
-
width = _this$calDataFrame.width,
|
|
68
|
-
height = _this$calDataFrame.height;
|
|
69
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
70
|
-
|
|
71
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
72
|
-
flipY: true,
|
|
73
|
-
data: data,
|
|
74
|
-
format: _l7Core.gl.LUMINANCE,
|
|
75
|
-
type: _l7Core.gl.FLOAT,
|
|
76
|
-
width: width,
|
|
77
|
-
height: height
|
|
78
|
-
}) : this.createTexture2D({
|
|
79
|
-
flipY: true,
|
|
80
|
-
data: [1],
|
|
81
|
-
format: _l7Core.gl.LUMINANCE,
|
|
82
|
-
type: _l7Core.gl.FLOAT,
|
|
83
|
-
width: 1,
|
|
84
|
-
height: 1
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
56
|
|
|
88
57
|
// 转化渐变色
|
|
89
58
|
var useLinearColor = 0; // 默认不生效
|
|
@@ -94,22 +63,18 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
94
63
|
targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
|
|
95
64
|
useLinearColor = 1;
|
|
96
65
|
}
|
|
97
|
-
return {
|
|
66
|
+
return (0, _objectSpread2.default)({
|
|
98
67
|
// 控制侧面和顶面的显示隐藏
|
|
99
68
|
u_topsurface: Number(topsurface),
|
|
100
69
|
u_sidesurface: Number(sidesurface),
|
|
101
70
|
u_heightfixed: Number(heightfixed),
|
|
102
|
-
u_dataTexture: this.dataTexture,
|
|
103
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
104
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
105
71
|
u_raisingHeight: Number(raisingHeight),
|
|
106
|
-
u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
|
|
107
72
|
// 渐变色支持参数
|
|
108
73
|
u_linearColor: useLinearColor,
|
|
109
74
|
u_sourceColor: sourceColorArr,
|
|
110
75
|
u_targetColor: targetColorArr,
|
|
111
76
|
u_texture: this.texture
|
|
112
|
-
};
|
|
77
|
+
}, this.getStyleAttribute());
|
|
113
78
|
}
|
|
114
79
|
}, {
|
|
115
80
|
key: "initModels",
|
|
@@ -118,9 +83,11 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
118
83
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
119
84
|
while (1) switch (_context.prev = _context.next) {
|
|
120
85
|
case 0:
|
|
121
|
-
|
|
122
|
-
return
|
|
86
|
+
_context.next = 2;
|
|
87
|
+
return this.loadTexture();
|
|
123
88
|
case 2:
|
|
89
|
+
return _context.abrupt("return", this.buildModels());
|
|
90
|
+
case 3:
|
|
124
91
|
case "end":
|
|
125
92
|
return _context.stop();
|
|
126
93
|
}
|
|
@@ -145,6 +112,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
145
112
|
moduleName: type,
|
|
146
113
|
vertexShader: vert,
|
|
147
114
|
fragmentShader: frag,
|
|
115
|
+
inject: this.getInject(),
|
|
148
116
|
triangulation: _triangulation.PolygonExtrudeTriangulation
|
|
149
117
|
});
|
|
150
118
|
case 3:
|
|
@@ -191,21 +159,32 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
191
159
|
}, {
|
|
192
160
|
key: "clearModels",
|
|
193
161
|
value: function clearModels() {
|
|
194
|
-
var _this$
|
|
195
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
162
|
+
var _this$texture;
|
|
196
163
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
197
164
|
}
|
|
198
165
|
}, {
|
|
199
166
|
key: "registerBuiltinAttributes",
|
|
200
167
|
value: function registerBuiltinAttributes() {
|
|
201
168
|
var bbox = this.layer.getSource().extent;
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
169
|
+
var bounds = bbox;
|
|
170
|
+
var layerCenter = this.layer.coordCenter || this.layer.getSource().center;
|
|
171
|
+
var lngLen = bounds[2] - bounds[0];
|
|
172
|
+
var latLen = bounds[3] - bounds[1];
|
|
173
|
+
if (this.mapService.version === 'GAODE2.x') {
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
var _this$mapService$coor = this.mapService.coordToAMap2RelativeCoordinates([bbox[0], bbox[1]], layerCenter),
|
|
176
|
+
_this$mapService$coor2 = (0, _slicedToArray2.default)(_this$mapService$coor, 2),
|
|
177
|
+
minX = _this$mapService$coor2[0],
|
|
178
|
+
minY = _this$mapService$coor2[1];
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
var _this$mapService$coor3 = this.mapService.coordToAMap2RelativeCoordinates([bbox[2], bbox[3]], layerCenter),
|
|
181
|
+
_this$mapService$coor4 = (0, _slicedToArray2.default)(_this$mapService$coor3, 2),
|
|
182
|
+
maxX = _this$mapService$coor4[0],
|
|
183
|
+
maxY = _this$mapService$coor4[1];
|
|
184
|
+
lngLen = maxX - minX;
|
|
185
|
+
latLen = maxY - minY;
|
|
186
|
+
bounds = [minX, minY, maxX, maxY];
|
|
187
|
+
}
|
|
209
188
|
this.styleAttributeService.registerStyleAttribute({
|
|
210
189
|
name: 'uvs',
|
|
211
190
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -221,7 +200,9 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
221
200
|
update: function update(feature, featureIdx, vertex) {
|
|
222
201
|
var lng = vertex[0];
|
|
223
202
|
var lat = vertex[1];
|
|
224
|
-
|
|
203
|
+
// console.log((lng - bounds[0]) / lngLen, (lat - bounds[1]) / latLen, vertex[4])
|
|
204
|
+
// 临时 兼容高德V2
|
|
205
|
+
return [(lng - bounds[0]) / lngLen, (lat - bounds[1]) / latLen, vertex[4]];
|
|
225
206
|
}
|
|
226
207
|
}
|
|
227
208
|
});
|
|
@@ -263,33 +244,56 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
263
244
|
}
|
|
264
245
|
}, {
|
|
265
246
|
key: "loadTexture",
|
|
266
|
-
value: function
|
|
267
|
-
var
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
247
|
+
value: function () {
|
|
248
|
+
var _loadTexture = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
249
|
+
var _this = this;
|
|
250
|
+
var _ref3, mapTexture, createTexture2D;
|
|
251
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
252
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
253
|
+
case 0:
|
|
254
|
+
_ref3 = this.layer.getLayerConfig(), mapTexture = _ref3.mapTexture;
|
|
255
|
+
createTexture2D = this.rendererService.createTexture2D;
|
|
256
|
+
this.texture = createTexture2D({
|
|
257
|
+
height: 0,
|
|
258
|
+
width: 0
|
|
259
|
+
});
|
|
260
|
+
if (!mapTexture) {
|
|
261
|
+
_context3.next = 5;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
return _context3.abrupt("return", new Promise(function (resolve, reject) {
|
|
265
|
+
var image = new Image();
|
|
266
|
+
image.crossOrigin = 'anonymous';
|
|
267
|
+
image.src = mapTexture;
|
|
268
|
+
image.onload = function () {
|
|
269
|
+
_this.texture = createTexture2D({
|
|
270
|
+
data: image,
|
|
271
|
+
width: image.width,
|
|
272
|
+
height: image.height,
|
|
273
|
+
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
274
|
+
wrapT: _l7Core.gl.CLAMP_TO_EDGE,
|
|
275
|
+
min: _l7Core.gl.LINEAR,
|
|
276
|
+
mag: _l7Core.gl.LINEAR
|
|
277
|
+
});
|
|
278
|
+
return resolve(null);
|
|
279
|
+
// this.layerService.reRender();
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
image.onerror = function () {
|
|
283
|
+
reject(new Error('image load error'));
|
|
284
|
+
};
|
|
285
|
+
}));
|
|
286
|
+
case 5:
|
|
287
|
+
case "end":
|
|
288
|
+
return _context3.stop();
|
|
289
|
+
}
|
|
290
|
+
}, _callee3, this);
|
|
291
|
+
}));
|
|
292
|
+
function loadTexture() {
|
|
293
|
+
return _loadTexture.apply(this, arguments);
|
|
291
294
|
}
|
|
292
|
-
|
|
295
|
+
return loadTexture;
|
|
296
|
+
}()
|
|
293
297
|
}]);
|
|
294
298
|
return ExtrudeModel;
|
|
295
299
|
}(_BaseModel2.default);
|