@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.
Files changed (218) hide show
  1. package/es/core/BaseLayer.d.ts +3 -0
  2. package/es/core/BaseLayer.js +76 -80
  3. package/es/core/BaseModel.d.ts +9 -71
  4. package/es/core/BaseModel.js +75 -357
  5. package/es/core/CommonStyleAttribute.d.ts +2 -0
  6. package/es/core/CommonStyleAttribute.js +66 -0
  7. package/es/core/interface.d.ts +13 -3
  8. package/es/core/shape/extrude.js +18 -6
  9. package/es/core/triangulation.d.ts +12 -0
  10. package/es/core/triangulation.js +70 -0
  11. package/es/heatmap/models/grid.js +1 -1
  12. package/es/heatmap/models/grid3d.js +1 -1
  13. package/es/heatmap/models/heatmap.d.ts +1 -0
  14. package/es/heatmap/models/heatmap.js +17 -13
  15. package/es/heatmap/models/hexagon.js +1 -1
  16. package/es/heatmap/shaders/grid_vert.glsl +2 -2
  17. package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  18. package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
  19. package/es/line/index.d.ts +1 -0
  20. package/es/line/index.js +3 -2
  21. package/es/line/models/arc.js +9 -45
  22. package/es/line/models/arc_3d.js +12 -45
  23. package/es/line/models/earthArc_3d.js +6 -40
  24. package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
  25. package/es/line/models/flow.js +167 -0
  26. package/es/line/models/great_circle.js +4 -38
  27. package/es/line/models/index.d.ts +1 -1
  28. package/es/line/models/index.js +3 -3
  29. package/es/line/models/line.js +7 -41
  30. package/es/line/models/linearline.js +4 -38
  31. package/es/line/models/simpleLine.d.ts +0 -1
  32. package/es/line/models/simpleLine.js +4 -43
  33. package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
  34. package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
  35. package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
  36. package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
  37. package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
  38. package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
  39. package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
  40. package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
  41. package/es/line/shaders/line_arc_frag.glsl +7 -11
  42. package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  43. package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  44. package/es/line/shaders/line_arc_vert.glsl +9 -45
  45. package/es/line/shaders/line_frag.glsl +15 -17
  46. package/es/line/shaders/line_vert.glsl +3 -34
  47. package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  48. package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  49. package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
  50. package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
  51. package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
  52. package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  53. package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  54. package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
  55. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  56. package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
  57. package/es/plugins/DataMappingPlugin.js +20 -34
  58. package/es/plugins/LayerModelPlugin.js +13 -1
  59. package/es/plugins/ShaderUniformPlugin.js +3 -3
  60. package/es/point/index.d.ts +1 -0
  61. package/es/point/index.js +1 -0
  62. package/es/point/models/earthExtrude.d.ts +0 -3
  63. package/es/point/models/earthExtrude.js +2 -40
  64. package/es/point/models/earthFill.d.ts +0 -1
  65. package/es/point/models/earthFill.js +9 -60
  66. package/es/point/models/extrude.d.ts +0 -3
  67. package/es/point/models/extrude.js +3 -42
  68. package/es/point/models/fill.d.ts +0 -1
  69. package/es/point/models/fill.js +15 -76
  70. package/es/point/models/fillmage.js +6 -43
  71. package/es/point/models/image.js +7 -41
  72. package/es/point/models/normal.js +2 -2
  73. package/es/point/models/radar.d.ts +0 -1
  74. package/es/point/models/radar.js +4 -13
  75. package/es/point/models/simplePoint.d.ts +0 -1
  76. package/es/point/models/simplePoint.js +8 -49
  77. package/es/point/models/text.js +17 -47
  78. package/es/point/shaders/animate/wave_frag.glsl +1 -11
  79. package/es/point/shaders/earth/extrude_frag.glsl +5 -17
  80. package/es/point/shaders/earth/extrude_vert.glsl +14 -29
  81. package/es/point/shaders/earth/fill_frag.glsl +5 -14
  82. package/es/point/shaders/earth/fill_vert.glsl +1 -75
  83. package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
  84. package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
  85. package/es/point/shaders/fill_frag.glsl +9 -20
  86. package/es/point/shaders/fill_vert.glsl +16 -101
  87. package/es/point/shaders/image/fillImage_frag.glsl +2 -5
  88. package/es/point/shaders/image/fillImage_vert.glsl +4 -47
  89. package/es/point/shaders/image_frag.glsl +1 -5
  90. package/es/point/shaders/image_vert.glsl +1 -44
  91. package/es/point/shaders/normal_frag.glsl +0 -2
  92. package/es/point/shaders/normal_vert.glsl +2 -1
  93. package/es/point/shaders/radar/radar_vert.glsl +2 -2
  94. package/es/point/shaders/simplePoint_frag.glsl +0 -7
  95. package/es/point/shaders/simplePoint_vert.glsl +3 -45
  96. package/es/point/shaders/text_frag.glsl +6 -19
  97. package/es/point/shaders/text_vert.glsl +5 -66
  98. package/es/polygon/index.d.ts +1 -0
  99. package/es/polygon/index.js +1 -0
  100. package/es/polygon/models/extrude.d.ts +0 -3
  101. package/es/polygon/models/extrude.js +86 -82
  102. package/es/polygon/models/fill.d.ts +0 -4
  103. package/es/polygon/models/fill.js +8 -47
  104. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  105. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  106. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  107. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  108. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  109. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  110. package/es/polygon/shaders/polygon_frag.glsl +0 -5
  111. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
  112. package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
  113. package/es/polygon/shaders/polygon_vert.glsl +1 -27
  114. package/es/utils/layerData.js +2 -2
  115. package/lib/core/BaseLayer.js +74 -78
  116. package/lib/core/BaseModel.js +74 -356
  117. package/lib/core/CommonStyleAttribute.js +72 -0
  118. package/lib/core/shape/extrude.js +18 -6
  119. package/lib/core/triangulation.js +72 -0
  120. package/lib/heatmap/models/grid.js +1 -1
  121. package/lib/heatmap/models/grid3d.js +1 -1
  122. package/lib/heatmap/models/heatmap.js +17 -13
  123. package/lib/heatmap/models/hexagon.js +1 -1
  124. package/lib/heatmap/shaders/grid_vert.glsl +2 -2
  125. package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  126. package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
  127. package/lib/line/index.js +3 -2
  128. package/lib/line/models/arc.js +9 -45
  129. package/lib/line/models/arc_3d.js +12 -45
  130. package/lib/line/models/earthArc_3d.js +6 -40
  131. package/lib/line/models/flow.js +174 -0
  132. package/lib/line/models/great_circle.js +4 -38
  133. package/lib/line/models/index.js +3 -3
  134. package/lib/line/models/line.js +7 -41
  135. package/lib/line/models/linearline.js +4 -38
  136. package/lib/line/models/simpleLine.js +4 -43
  137. package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
  138. package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
  139. package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
  140. package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
  141. package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
  142. package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
  143. package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
  144. package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
  145. package/lib/line/shaders/line_arc_frag.glsl +7 -11
  146. package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  147. package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  148. package/lib/line/shaders/line_arc_vert.glsl +9 -45
  149. package/lib/line/shaders/line_frag.glsl +15 -17
  150. package/lib/line/shaders/line_vert.glsl +3 -34
  151. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  152. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  153. package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
  154. package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
  155. package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
  156. package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  157. package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  158. package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
  159. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  160. package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
  161. package/lib/plugins/DataMappingPlugin.js +20 -34
  162. package/lib/plugins/LayerModelPlugin.js +13 -1
  163. package/lib/plugins/ShaderUniformPlugin.js +3 -3
  164. package/lib/point/index.js +1 -0
  165. package/lib/point/models/earthExtrude.js +2 -40
  166. package/lib/point/models/earthFill.js +9 -60
  167. package/lib/point/models/extrude.js +3 -42
  168. package/lib/point/models/fill.js +15 -76
  169. package/lib/point/models/fillmage.js +6 -43
  170. package/lib/point/models/image.js +7 -41
  171. package/lib/point/models/normal.js +2 -2
  172. package/lib/point/models/radar.js +4 -13
  173. package/lib/point/models/simplePoint.js +8 -49
  174. package/lib/point/models/text.js +15 -45
  175. package/lib/point/shaders/animate/wave_frag.glsl +1 -11
  176. package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
  177. package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
  178. package/lib/point/shaders/earth/fill_frag.glsl +5 -14
  179. package/lib/point/shaders/earth/fill_vert.glsl +1 -75
  180. package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
  181. package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
  182. package/lib/point/shaders/fill_frag.glsl +9 -20
  183. package/lib/point/shaders/fill_vert.glsl +16 -101
  184. package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
  185. package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
  186. package/lib/point/shaders/image_frag.glsl +1 -5
  187. package/lib/point/shaders/image_vert.glsl +1 -44
  188. package/lib/point/shaders/normal_frag.glsl +0 -2
  189. package/lib/point/shaders/normal_vert.glsl +2 -1
  190. package/lib/point/shaders/radar/radar_vert.glsl +2 -2
  191. package/lib/point/shaders/simplePoint_frag.glsl +0 -7
  192. package/lib/point/shaders/simplePoint_vert.glsl +3 -45
  193. package/lib/point/shaders/text_frag.glsl +6 -19
  194. package/lib/point/shaders/text_vert.glsl +5 -66
  195. package/lib/polygon/index.js +1 -0
  196. package/lib/polygon/models/extrude.js +86 -82
  197. package/lib/polygon/models/fill.js +8 -47
  198. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  199. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  200. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  201. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  202. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  203. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  204. package/lib/polygon/shaders/polygon_frag.glsl +0 -5
  205. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
  206. package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
  207. package/lib/polygon/shaders/polygon_vert.glsl +1 -27
  208. package/lib/utils/layerData.js +2 -2
  209. package/package.json +7 -7
  210. package/es/line/models/half.js +0 -267
  211. package/es/line/shaders/half/line_half_frag.glsl +0 -53
  212. package/es/line/shaders/half/line_half_vert.glsl +0 -169
  213. package/es/utils/dataMappingStyle.d.ts +0 -31
  214. package/es/utils/dataMappingStyle.js +0 -137
  215. package/lib/line/models/half.js +0 -274
  216. package/lib/line/shaders/half/line_half_frag.glsl +0 -53
  217. package/lib/line/shaders/half/line_half_vert.glsl +0 -169
  218. 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 u_Size_Unit;
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(u_Size_Unit == 1) {
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
- #pragma include "styleMapping"
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(textrueOffsets);
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
- // float fontScale = u_font_size / FONT_SIZE;
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
- // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));
45
- gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));
46
- gl_FragColor.a= gl_FragColor.a * alpha;
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
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
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
- v_uv = a_tex / u_sdf_map_size;
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;
@@ -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 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 mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0]; \n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\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 gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
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;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n 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\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 // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\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_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
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 mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float lightWeight = styleMappingMat[3][1];\n float topU = styleMappingMat[2][2];\n float topV = styleMappingMat[2][3];\n\n float sidey = styleMappingMat[3][0];\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 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 }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; // texture
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 u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n v_Color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - a_Position.z(judge side by a_Position.z)\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - u - v\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n \n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[2][2] = a_uvs[0];\n styleMappingMat[2][3] = 1.0 - a_uvs[1];\n styleMappingMat[3][0] = a_uvs[2];\n\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n 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\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 // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\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 styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
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 mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\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";
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\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n 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_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\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
- this.loadTexture();
122
- return _context.abrupt("return", this.buildModels());
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$dataTexture, _this$texture;
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 _bbox = (0, _slicedToArray2.default)(bbox, 4),
203
- minLng = _bbox[0],
204
- minLat = _bbox[1],
205
- maxLng = _bbox[2],
206
- maxLat = _bbox[3];
207
- var lngLen = maxLng - minLng;
208
- var latLen = maxLat - minLat;
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
- return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];
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 loadTexture() {
267
- var _this = this;
268
- var _ref3 = this.layer.getLayerConfig(),
269
- mapTexture = _ref3.mapTexture;
270
- var createTexture2D = this.rendererService.createTexture2D;
271
- this.texture = createTexture2D({
272
- height: 0,
273
- width: 0
274
- });
275
- if (mapTexture) {
276
- var image = new Image();
277
- image.crossOrigin = '';
278
- image.src = mapTexture;
279
- image.onload = function () {
280
- _this.texture = createTexture2D({
281
- data: image,
282
- width: image.width,
283
- height: image.height,
284
- wrapS: _l7Core.gl.CLAMP_TO_EDGE,
285
- wrapT: _l7Core.gl.CLAMP_TO_EDGE,
286
- min: _l7Core.gl.LINEAR,
287
- mag: _l7Core.gl.LINEAR
288
- });
289
- _this.layerService.reRender();
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);