@antv/l7-layers 2.19.9 → 2.19.11

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 (89) hide show
  1. package/es/core/BaseLayer.d.ts +0 -2
  2. package/es/core/BaseLayer.js +19 -38
  3. package/es/core/BaseModel.js +4 -19
  4. package/es/core/CommonStyleAttribute.js +20 -0
  5. package/es/core/constant.d.ts +6 -0
  6. package/es/core/constant.js +19 -0
  7. package/es/core/interface.d.ts +15 -9
  8. package/es/core/line_trangluation.d.ts +19 -0
  9. package/es/core/line_trangluation.js +91 -0
  10. package/es/core/shape/arrow.d.ts +25 -0
  11. package/es/core/shape/arrow.js +160 -0
  12. package/es/core/triangulation.d.ts +2 -8
  13. package/es/core/triangulation.js +6 -34
  14. package/es/geometry/models/plane.js +1 -2
  15. package/es/geometry/models/sprite.js +1 -2
  16. package/es/line/index.js +3 -2
  17. package/es/line/models/arc.js +13 -14
  18. package/es/line/models/arc_3d.js +5 -3
  19. package/es/line/models/earthArc_3d.js +5 -3
  20. package/es/line/models/flow.js +4 -5
  21. package/es/line/models/great_circle.js +6 -7
  22. package/es/line/models/line.js +9 -24
  23. package/es/line/models/linearline.js +5 -4
  24. package/es/line/models/simpleLine.js +6 -5
  25. package/es/line/models/wall.js +4 -5
  26. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -4
  27. package/es/line/shaders/dash/arc_dash_vert.glsl +3 -8
  28. package/es/line/shaders/dash/line_dash_frag.glsl +0 -1
  29. package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
  30. package/es/line/shaders/line_arc_3d_frag.glsl +2 -4
  31. package/es/line/shaders/line_arc_3d_vert.glsl +2 -1
  32. package/es/line/shaders/line_arc_frag.glsl +1 -4
  33. package/es/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  34. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  35. package/es/line/shaders/line_arc_vert.glsl +3 -5
  36. package/es/line/shaders/line_frag.glsl +12 -12
  37. package/es/line/shaders/line_vert.glsl +2 -0
  38. package/es/line/shaders/linear/arc_linear_vert.glsl +3 -5
  39. package/es/line/shaders/linear/line_linear_frag.glsl +0 -1
  40. package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  41. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  42. package/es/line/shaders/simple/simpleline_vert.glsl +1 -2
  43. package/es/plugins/DataMappingPlugin.js +5 -23
  44. package/es/polygon/models/ocean.js +1 -2
  45. package/es/polygon/models/water.js +1 -2
  46. package/es/tile/tile/Tile.d.ts +0 -1
  47. package/lib/core/BaseLayer.js +19 -38
  48. package/lib/core/BaseModel.js +4 -19
  49. package/lib/core/CommonStyleAttribute.js +20 -0
  50. package/lib/core/constant.js +27 -0
  51. package/lib/core/line_trangluation.js +99 -0
  52. package/lib/core/shape/arrow.js +174 -0
  53. package/lib/core/triangulation.js +6 -35
  54. package/lib/geometry/models/plane.js +1 -2
  55. package/lib/geometry/models/sprite.js +1 -2
  56. package/lib/line/index.js +3 -2
  57. package/lib/line/models/arc.js +13 -14
  58. package/lib/line/models/arc_3d.js +5 -3
  59. package/lib/line/models/earthArc_3d.js +5 -3
  60. package/lib/line/models/flow.js +4 -5
  61. package/lib/line/models/great_circle.js +6 -7
  62. package/lib/line/models/line.js +9 -24
  63. package/lib/line/models/linearline.js +5 -4
  64. package/lib/line/models/simpleLine.js +6 -5
  65. package/lib/line/models/wall.js +4 -5
  66. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -4
  67. package/lib/line/shaders/dash/arc_dash_vert.glsl +3 -8
  68. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -1
  69. package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
  70. package/lib/line/shaders/line_arc_3d_frag.glsl +2 -4
  71. package/lib/line/shaders/line_arc_3d_vert.glsl +2 -1
  72. package/lib/line/shaders/line_arc_frag.glsl +1 -4
  73. package/lib/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  74. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  75. package/lib/line/shaders/line_arc_vert.glsl +3 -5
  76. package/lib/line/shaders/line_frag.glsl +12 -12
  77. package/lib/line/shaders/line_vert.glsl +2 -0
  78. package/lib/line/shaders/linear/arc_linear_vert.glsl +3 -5
  79. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -1
  80. package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  81. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  82. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -2
  83. package/lib/plugins/DataMappingPlugin.js +5 -23
  84. package/lib/polygon/models/ocean.js +1 -2
  85. package/lib/polygon/models/water.js +1 -2
  86. package/package.json +7 -7
  87. package/es/utils/layerData.d.ts +0 -2
  88. package/es/utils/layerData.js +0 -159
  89. package/lib/utils/layerData.js +0 -166
@@ -17,15 +17,15 @@ import { LinearDir, TextureBlend } from "../../core/interface";
17
17
  // import { LineTriangulation } from '../../core/triangulation';
18
18
  // dash line shader
19
19
  /* babel-plugin-inline-import '../shaders/dash/line_dash_frag.glsl' */
20
- var line_dash_frag = "#define LineTypeSolid 0.0\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n\n gl_FragColor = v_color;\n\n \n float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
+ var line_dash_frag = "#define LineTypeSolid 0.0\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n\n gl_FragColor = v_color;\n\n float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
21
21
  /* babel-plugin-inline-import '../shaders/dash/line_dash_vert.glsl' */
22
22
  var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n\nvoid main() {\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n \n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // basic line shader
23
23
  /* babel-plugin-inline-import '../shaders/line_frag.glsl' */
24
- var line_frag = "#extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\n\nuniform vec3 u_blur;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_texture_data;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n// [animate, duration, interval, trailLength],\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_texture_data.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_texture_data.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_texture_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth / 2.0;\n\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = v_texture_data.a;\n if(blurV < 0.5) {\n gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n}\n";
24
+ var line_frag = "#extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\n\nuniform float u_strokeWidth: 0.0;\n\nuniform vec3 u_blur;\nvarying vec4 v_color;\nvarying vec4 v_stroke;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_texture_data;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n// [animate, duration, interval, trailLength],\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_texture_data.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_texture_data.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_texture_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float strokeWidth = min(0.5, u_strokeWidth);\n // \u7ED8\u5236 border\n if(strokeWidth > 0.01) {\n float borderOuterWidth = strokeWidth / 2.0;\n\n\n if(v >= 1.0 - strokeWidth || v <= strokeWidth) {\n if(v > strokeWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, v_stroke.rgb, linear);\n } else if(v <= strokeWidth) {\n float linear = smoothstep(0.0, 1.0, v/strokeWidth);\n gl_FragColor.rgb = mix(v_stroke.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = v_texture_data.a;\n if(blurV < 0.5) {\n gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n}\n";
25
25
  /* babel-plugin-inline-import '../shaders/line_vert.glsl' */
26
- var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\nvarying vec4 v_texture_data;\n\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n \n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // other function shaders
26
+ var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_stroke;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\nvarying vec4 v_texture_data;\n\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n v_color.a *= opacity;\n v_stroke = stroke;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n \n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // other function shaders
27
27
  /* babel-plugin-inline-import '../shaders/linear/line_linear_frag.glsl' */
28
- var linear_line_frag = "varying vec4 v_color;\nvarying vec4 v_texture_data;\nuniform float u_linearDir: 1.0;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_opacity: 1.0;\n\n#pragma include \"picking\"\n\n\nvoid main() {\n float linearRadio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = v_texture_data.a;\n }\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, linearRadio);\n gl_FragColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
28
+ var linear_line_frag = "varying vec4 v_color;\nvarying vec4 v_texture_data;\nuniform float u_linearDir: 1.0;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\n\nvoid main() {\n float linearRadio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = v_texture_data.a;\n }\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, linearRadio);\n gl_FragColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
29
29
  var lineStyleObj = {
30
30
  solid: 0.0,
31
31
  dash: 1.0
@@ -87,10 +87,8 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
87
87
  iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
88
88
  _ref$vertexHeightScal = _ref.vertexHeightScale,
89
89
  vertexHeightScale = _ref$vertexHeightScal === void 0 ? 20.0 : _ref$vertexHeightScal,
90
- _ref$borderWidth = _ref.borderWidth,
91
- borderWidth = _ref$borderWidth === void 0 ? 0.0 : _ref$borderWidth,
92
- _ref$borderColor = _ref.borderColor,
93
- borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
90
+ _ref$strokeWidth = _ref.strokeWidth,
91
+ strokeWidth = _ref$strokeWidth === void 0 ? 0.0 : _ref$strokeWidth,
94
92
  _ref$raisingHeight = _ref.raisingHeight,
95
93
  raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
96
94
  _ref$heightfixed = _ref.heightfixed,
@@ -98,14 +96,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
98
96
  _ref$linearDir = _ref.linearDir,
99
97
  linearDir = _ref$linearDir === void 0 ? LinearDir.VERTICAL : _ref$linearDir,
100
98
  _ref$blur = _ref.blur,
101
- blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur,
102
- _ref$arrow = _ref.arrow,
103
- arrow = _ref$arrow === void 0 ? {
104
- enable: false,
105
- arrowWidth: 2,
106
- arrowHeight: 3,
107
- tailWidth: 1
108
- } : _ref$arrow;
99
+ blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur;
109
100
  if (dashArray.length === 2) {
110
101
  dashArray.push(0, 0);
111
102
  }
@@ -136,8 +127,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
136
127
  u_icon_step: iconStep,
137
128
  u_textSize: [1024, this.iconService.canvasHeight || 128],
138
129
  // line border 参数
139
- u_borderWidth: borderWidth,
140
- u_borderColor: rgb2arr(borderColor),
130
+ u_strokeWidth: strokeWidth,
141
131
  // 渐变色支持参数
142
132
  u_linearDir: linearDir === LinearDir.VERTICAL ? 1.0 : 0.0,
143
133
  u_linearColor: useLinearColor,
@@ -147,12 +137,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
147
137
  u_heightfixed: Number(heightfixed),
148
138
  // 顶点高度 scale
149
139
  u_vertexScale: vertexHeightScale,
150
- u_raisingHeight: Number(raisingHeight),
151
- // arrow
152
- u_arrow: Number(arrow.enable),
153
- u_arrowHeight: arrow.arrowHeight || 3,
154
- u_arrowWidth: arrow.arrowWidth || 2,
155
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
140
+ u_raisingHeight: Number(raisingHeight)
156
141
  }, this.getStyleAttribute());
157
142
  }
158
143
  }, {
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -17,7 +18,7 @@ import { LineTriangulation } from "../../core/triangulation";
17
18
  /* babel-plugin-inline-import '../shaders/linearLine/line_linear_frag.glsl' */
18
19
  var linear_line_frag = "\nvarying vec4 v_Color;\n#pragma include \"picking\"\nvoid main() {\n\n gl_FragColor = v_Color; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
19
20
  /* babel-plugin-inline-import '../shaders/linearLine/line_linear_vert.glsl' */
20
- var linear_line_vert = "\nattribute float a_Miter;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity : 1.0;\nuniform sampler2D u_texture;\nuniform float u_linearDir: 1.0;\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n float linearRadio =currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = texV;\n }\n\n v_Color = texture2D(u_texture, vec2(linearRadio, 0.5));\n\n v_Color.a *= u_opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
21
+ var linear_line_vert = "\nattribute float a_Miter;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\nuniform sampler2D u_texture;\nuniform float u_linearDir: 1.0;\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n float linearRadio =currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = texV;\n }\n\n v_Color = texture2D(u_texture, vec2(linearRadio, 0.5));\n\n v_Color.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
21
22
  var isNumber = lodashUtil.isNumber;
22
23
  var LinearLineModel = /*#__PURE__*/function (_BaseModel) {
23
24
  _inherits(LinearLineModel, _BaseModel);
@@ -67,9 +68,8 @@ var LinearLineModel = /*#__PURE__*/function (_BaseModel) {
67
68
  if (this.rendererService.getDirty()) {
68
69
  this.colorTexture.bind();
69
70
  }
70
- return {
71
+ return _objectSpread({
71
72
  u_linearDir: linearDir === LinearDir.VERTICAL ? 1.0 : 0.0,
72
- u_opacity: isNumber(opacity) ? opacity : 1,
73
73
  // 纹理支持参数
74
74
  u_texture: this.colorTexture,
75
75
  // 贴图
@@ -79,7 +79,7 @@ var LinearLineModel = /*#__PURE__*/function (_BaseModel) {
79
79
  // 顶点高度 scale
80
80
  u_vertexScale: vertexHeightScale,
81
81
  u_raisingHeight: Number(raisingHeight)
82
- };
82
+ }, this.getStyleAttribute());
83
83
  }
84
84
  }, {
85
85
  key: "initModels",
@@ -123,6 +123,7 @@ var LinearLineModel = /*#__PURE__*/function (_BaseModel) {
123
123
  vertexShader: linear_line_vert,
124
124
  fragmentShader: linear_line_frag,
125
125
  triangulation: LineTriangulation,
126
+ inject: this.getInject(),
126
127
  depth: {
127
128
  enable: depth
128
129
  }
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
@@ -14,9 +15,9 @@ import { SimpleLineTriangulation } from "../../core/triangulation";
14
15
  /* babel-plugin-inline-import '../shaders/simple/simpleline_frag.glsl' */
15
16
  var simple_line_frag = "\nvarying vec4 v_color;\nvoid main() {\n gl_FragColor = v_color;\n\n}\n"; // linear simple line shader
16
17
  /* babel-plugin-inline-import '../shaders/simple/simpleline_linear_frag.glsl' */
17
- var simle_linear_frag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nvarying float v_distanceScale;\nuniform float u_opacity: 1.0;\nvoid main() {\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_distanceScale);\n gl_FragColor.a *= u_opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n}\n";
18
+ var simle_linear_frag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nvarying float v_distanceScale;\nvarying vec4 v_color;\nvoid main() {\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_distanceScale);\n gl_FragColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n}\n";
18
19
  /* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
19
- var simple_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Position;\n\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_opacity: 1.0;\nuniform float u_vertexScale: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n\n\n#pragma include \"projection\"\n\nvarying vec4 v_color;\nvarying float v_distanceScale;\n\nvoid main() {\n\n v_color = a_Color; \n v_distanceScale = a_Distance / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity); \n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n }\n}\n";
20
+ var simple_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Position;\n\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_vertexScale: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n\n\n#pragma include \"projection\"\n\nvarying vec4 v_color;\nvarying float v_distanceScale;\n\nvoid main() {\n\n v_color = a_Color; \n v_distanceScale = a_Distance / a_Total_Distance;\n v_color.a = v_color.a * opacity;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n }\n}\n";
20
21
  var isNumber = lodashUtil.isNumber;
21
22
  var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
22
23
  _inherits(SimpleLineModel, _BaseModel);
@@ -45,15 +46,14 @@ var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
45
46
  targetColorArr = rgb2arr(targetColor);
46
47
  useLinearColor = 1;
47
48
  }
48
- return {
49
- u_opacity: isNumber(opacity) ? opacity : 1,
49
+ return _objectSpread({
50
50
  // 渐变色支持参数
51
51
  u_linearColor: useLinearColor,
52
52
  u_sourceColor: sourceColorArr,
53
53
  u_targetColor: targetColorArr,
54
54
  // 顶点高度 scale
55
55
  u_vertexScale: vertexHeightScale
56
- };
56
+ }, this.getStyleAttribute());
57
57
  }
58
58
  }, {
59
59
  key: "initModels",
@@ -110,6 +110,7 @@ var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
110
110
  vertexShader: vert,
111
111
  fragmentShader: frag,
112
112
  triangulation: SimpleLineTriangulation,
113
+ inject: this.getInject(),
113
114
  primitive: gl.LINES,
114
115
  depth: {
115
116
  enable: false
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -52,8 +53,6 @@ var LineWallModel = /*#__PURE__*/function (_BaseModel) {
52
53
  key: "getUninforms",
53
54
  value: function getUninforms() {
54
55
  var _ref = this.layer.getLayerConfig(),
55
- _ref$opacity = _ref.opacity,
56
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
57
56
  sourceColor = _ref.sourceColor,
58
57
  targetColor = _ref.targetColor,
59
58
  _ref$textureBlend = _ref.textureBlend,
@@ -79,9 +78,8 @@ var LineWallModel = /*#__PURE__*/function (_BaseModel) {
79
78
  targetColorArr = rgb2arr(targetColor);
80
79
  useLinearColor = 1;
81
80
  }
82
- return {
81
+ return _objectSpread({
83
82
  u_heightfixed: Number(heightfixed),
84
- u_opacity: isNumber(opacity) ? opacity : 1.0,
85
83
  u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
86
84
  // 纹理支持参数
87
85
  u_texture: this.texture,
@@ -95,7 +93,7 @@ var LineWallModel = /*#__PURE__*/function (_BaseModel) {
95
93
  u_linearColor: useLinearColor,
96
94
  u_sourceColor: sourceColorArr,
97
95
  u_targetColor: targetColorArr
98
- };
96
+ }, this.getStyleAttribute());
99
97
  }
100
98
  }, {
101
99
  key: "getAnimateUniforms",
@@ -149,6 +147,7 @@ var LineWallModel = /*#__PURE__*/function (_BaseModel) {
149
147
  vertexShader: line_vert,
150
148
  fragmentShader: line_frag,
151
149
  triangulation: LineTriangulation,
150
+ inject: this.getInject(),
152
151
  depth: {
153
152
  enable: false
154
153
  },
@@ -1,6 +1,3 @@
1
-
2
- uniform float u_opacity;
3
-
4
1
  varying vec4 v_dash_array;
5
2
  varying vec4 v_color;
6
3
  varying float v_distance_ratio;
@@ -13,7 +10,6 @@ uniform float segmentNumber;
13
10
  void main() {
14
11
  gl_FragColor = v_color;
15
12
 
16
-
17
13
  float flag = 0.;
18
14
  float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
19
15
  if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {
@@ -13,11 +13,6 @@ uniform vec4 u_dash_array: [10.0, 5., 0, 0];
13
13
  uniform float u_lineDir: 1.0;
14
14
  varying vec4 v_dash_array;
15
15
  varying float v_distance_ratio;
16
-
17
- uniform float u_thetaOffset: 0.314;
18
-
19
- uniform float u_opacity: 1.0;
20
-
21
16
  #pragma include "projection"
22
17
  #pragma include "project"
23
18
  #pragma include "picking"
@@ -72,7 +67,7 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
72
67
  }
73
68
 
74
69
  void main() {
75
- v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
70
+ v_color = vec4(a_Color.xyz, a_Color.w * opacity);
76
71
 
77
72
  vec2 source = a_Instance.rg; // 起始点
78
73
  vec2 target = a_Instance.ba; // 终点
@@ -94,8 +89,8 @@ void main() {
94
89
 
95
90
  v_distance_ratio = segmentIndex / segmentNumber;
96
91
 
97
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
98
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
92
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
93
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
99
94
 
100
95
 
101
96
  vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
@@ -15,7 +15,6 @@ void main() {
15
15
 
16
16
  gl_FragColor = v_color;
17
17
 
18
-
19
18
  float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
20
19
  if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {
21
20
  // 实线部分
@@ -8,29 +8,59 @@ uniform mat4 u_ModelMatrix;
8
8
 
9
9
 
10
10
  #pragma include "projection"
11
+ #pragma include "project"
11
12
  #pragma include "picking"
12
13
  varying vec4 v_color;
13
14
  uniform float u_gap_width: 1.0;
14
15
  uniform float u_stroke_width: 1.0;
15
16
  uniform float u_stroke_opacity: 1.0;
16
17
 
18
+ vec2 project_pixel_offset(vec2 offsets) {
19
+
20
+ vec2 data = project_pixel(offsets);
21
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
22
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
23
+ return data;
24
+ }
25
+
26
+ return vec2(data.x, -data.y);;
27
+ }
28
+
29
+ vec2 line_dir(vec2 target, vec2 source) {
30
+
31
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
32
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
33
+ return normalize(target - source);
34
+ }
35
+ return normalize(ProjectFlat(target) - ProjectFlat(source));
36
+ }
37
+
38
+ float flag_gap() {
39
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
40
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
41
+ return 1.;
42
+ }
43
+ return -1.;
44
+
45
+ }
46
+
17
47
 
18
48
  void main() {
19
49
 
20
50
  // 透明度计算
21
51
  vec2 source = a_Instance.rg; // 起始点
22
52
  vec2 target = a_Instance.ba; // 终点
23
- vec2 flowlineDir = normalize(target - source);
24
- vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);
53
+ vec2 flowlineDir = line_dir(target,source);
54
+ vec2 perpendicularDir = vec2(flowlineDir.y, flowlineDir.x); // mapbox || 高德
25
55
 
26
56
 
27
57
  vec2 position = mix(source, target, a_Position.x);
28
58
 
29
59
  float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); //
30
- vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);
60
+ vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || 高德
31
61
  vec2 limitedOffsetDistances = clamp(
32
62
  offsetDistances,
33
- project_pixel(-lengthCommon*.8), project_pixel(lengthCommon*.8)
63
+ project_pixel(-lengthCommon*.2), project_pixel(lengthCommon*.2)
34
64
  );
35
65
 
36
66
 
@@ -42,9 +72,9 @@ void main() {
42
72
  a_Position.x
43
73
  );
44
74
 
45
- vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);
75
+ vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || 高德
46
76
 
47
- float gapCommon = project_pixel(u_gap_width);
77
+ float gapCommon = flag_gap() * project_pixel(u_gap_width);
48
78
  vec3 offsetCommon = vec3(
49
79
  flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -
50
80
  perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),
@@ -16,7 +16,7 @@ uniform sampler2D u_texture;
16
16
  uniform vec2 u_textSize;
17
17
  varying float v_segmentIndex;
18
18
  uniform float segmentNumber;
19
- uniform float u_opacity;
19
+
20
20
 
21
21
  varying vec2 v_iconMapUV;
22
22
 
@@ -27,12 +27,10 @@ uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
27
27
  #pragma include "picking"
28
28
 
29
29
  void main() {
30
- float opacity = u_opacity;
31
30
  float animateSpeed = 0.0; // 运动速度
32
31
  float d_distance_ratio = v_line_data.g; // 当前点位距离占线总长的比例
33
32
  gl_FragColor = v_color;
34
33
 
35
- gl_FragColor.a *= opacity;
36
34
  if(u_line_type == LineTypeDash) {
37
35
  float flag = 0.;
38
36
  float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
@@ -88,7 +86,7 @@ void main() {
88
86
  pattern.a = 0.0;
89
87
  gl_FragColor = filterColor(gl_FragColor + pattern);
90
88
  } else { // replace
91
- pattern.a *= opacity;
89
+ pattern.a *= v_color.a;
92
90
  if(gl_FragColor.a <= 0.0) {
93
91
  pattern.a = 0.0;
94
92
  discard;
@@ -96,6 +96,7 @@ vec3 lglt2xyz(vec2 lnglat) {
96
96
  void main() {
97
97
 
98
98
  v_color = a_Color;
99
+ v_color.a = v_color.a * opacity;
99
100
  vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;
100
101
  vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;
101
102
  float segmentIndex = a_Position.x;
@@ -143,7 +144,7 @@ void main() {
143
144
  }
144
145
 
145
146
 
146
- gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
147
+ gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 1.0));
147
148
 
148
149
  // 地球模式
149
150
  if(u_globel > 0.0) {
@@ -1,8 +1,6 @@
1
1
 
2
2
  #define Animate 0.0
3
3
  #define LineTexture 1.0
4
-
5
- uniform float u_opacity;
6
4
  uniform float u_textureBlend;
7
5
  uniform float u_blur : 0.9;
8
6
  uniform float u_line_type: 0.0;
@@ -28,7 +26,6 @@ void main() {
28
26
  float animateSpeed = 0.0; // 运动速度
29
27
  gl_FragColor = v_color;
30
28
 
31
- gl_FragColor.a *= u_opacity;
32
29
 
33
30
  if(u_animate.x == Animate && u_line_texture != LineTexture) {
34
31
  animateSpeed = u_time / u_animate.y;
@@ -71,7 +68,7 @@ void main() {
71
68
  pattern.a = 0.0;
72
69
  gl_FragColor = filterColor(gl_FragColor + pattern);
73
70
  } else { // replace
74
- pattern.a *= u_opacity;
71
+ pattern.a *= v_color.a;
75
72
  if(gl_FragColor.a <= 0.0) {
76
73
  pattern.a = 0.0;
77
74
  }
@@ -3,7 +3,6 @@
3
3
  #define Animate 0.0
4
4
  #define LineTexture 1.0
5
5
 
6
- uniform float u_opacity;
7
6
  uniform float u_textureBlend;
8
7
  uniform float u_blur : 0.9;
9
8
  uniform float u_line_type: 0.0;
@@ -32,20 +31,20 @@ varying vec4 v_line_data;
32
31
  #pragma include "projection"
33
32
 
34
33
  void main() {
35
- float opacity = u_opacity;
34
+
36
35
  float animateSpeed = 0.0;
37
36
  float d_segmentIndex = v_line_data.g;
38
37
 
39
38
  // 设置弧线的底色
40
39
  if(u_linearColor == 1.0) { // 使用渐变颜色
41
40
  gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
41
+ gl_FragColor.a *= v_color.a;
42
42
  } else { // 使用 color 方法传入的颜色
43
43
  gl_FragColor = v_color;
44
44
  }
45
45
 
46
46
  // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));
47
47
  // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));
48
- gl_FragColor.a *= opacity;
49
48
  if(u_line_type == LineTypeDash) {
50
49
  float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
51
50
  if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {
@@ -73,7 +72,7 @@ void main() {
73
72
  float u = fract(arcRadio * count - animateSpeed * count);
74
73
  // float u = fract(arcRadio * count - animateSpeed);
75
74
  if(u_animate.x == Animate) {
76
- u = gl_FragColor.a/opacity;
75
+ u = gl_FragColor.a/v_color.a;
77
76
  }
78
77
 
79
78
  float v = v_line_data.a; // 线图层贴图部分的 v 坐标值
@@ -86,7 +85,7 @@ void main() {
86
85
  pattern.a = 0.0;
87
86
  gl_FragColor = filterColor(gl_FragColor + pattern);
88
87
  } else { // replace
89
- pattern.a *= opacity;
88
+ pattern.a *= v_color.a;
90
89
  if(gl_FragColor.a <= 0.0) {
91
90
  pattern.a = 0.0;
92
91
  }
@@ -119,9 +119,8 @@ vec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {
119
119
  }
120
120
 
121
121
  void main() {
122
-
123
-
124
122
  v_color = a_Color;
123
+ v_color.a = v_color.a * opacity;
125
124
  vec2 source = radians(a_Instance.rg);
126
125
  vec2 target = radians(a_Instance.ba);
127
126
  float angularDist = getAngularDist(source, target);
@@ -13,7 +13,6 @@ varying vec4 v_color;
13
13
 
14
14
  uniform float u_lineDir: 1.0;
15
15
 
16
- uniform float u_thetaOffset: 0.314;
17
16
  uniform float u_icon_step: 100;
18
17
  uniform float u_line_texture: 0.0;
19
18
  attribute vec2 a_iconMapUV;
@@ -21,8 +20,6 @@ varying vec2 v_iconMapUV;
21
20
  varying vec4 v_lineData;
22
21
  varying vec2 v_distance_ratio;
23
22
 
24
- uniform float u_opacity: 1.0;
25
-
26
23
 
27
24
  #pragma include "projection"
28
25
  #pragma include "project"
@@ -80,6 +77,7 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
80
77
 
81
78
  void main() {
82
79
  v_color = a_Color;
80
+ v_color.a = v_color.a * opacity;
83
81
 
84
82
  vec2 source = a_Instance.rg; // 起始点
85
83
  vec2 target = a_Instance.ba; // 终点
@@ -99,8 +97,8 @@ void main() {
99
97
 
100
98
  v_lineData.b = d_distance_ratio;
101
99
 
102
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
103
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
100
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
101
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
104
102
 
105
103
 
106
104
  vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
@@ -3,11 +3,11 @@
3
3
  #define LineTexture 1.0
4
4
  uniform float u_textureBlend;
5
5
 
6
- uniform float u_borderWidth: 0.0;
6
+ uniform float u_strokeWidth: 0.0;
7
7
 
8
8
  uniform vec3 u_blur;
9
- uniform vec4 u_borderColor;
10
9
  varying vec4 v_color;
10
+ varying vec4 v_stroke;
11
11
 
12
12
  // line texture
13
13
  uniform float u_line_texture;
@@ -59,20 +59,20 @@ void main() {
59
59
  }
60
60
 
61
61
  float v = v_texture_data.a;
62
- float borderWidth = min(0.5, u_borderWidth);
62
+ float strokeWidth = min(0.5, u_strokeWidth);
63
63
  // 绘制 border
64
- if(borderWidth > 0.01) {
65
- float borderOuterWidth = borderWidth / 2.0;
64
+ if(strokeWidth > 0.01) {
65
+ float borderOuterWidth = strokeWidth / 2.0;
66
66
 
67
67
 
68
- if(v >= 1.0 - borderWidth || v <= borderWidth) {
69
- if(v > borderWidth) { // 外侧
70
- float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);
68
+ if(v >= 1.0 - strokeWidth || v <= strokeWidth) {
69
+ if(v > strokeWidth) { // 外侧
70
+ float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);
71
71
  // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);
72
- gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);
73
- } else if(v <= borderWidth) {
74
- float linear = smoothstep(0.0, 1.0, v/borderWidth);
75
- gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);
72
+ gl_FragColor.rgb = mix(gl_FragColor.rgb, v_stroke.rgb, linear);
73
+ } else if(v <= strokeWidth) {
74
+ float linear = smoothstep(0.0, 1.0, v/strokeWidth);
75
+ gl_FragColor.rgb = mix(v_stroke.rgb, gl_FragColor.rgb, linear);
76
76
  }
77
77
  }
78
78
 
@@ -26,6 +26,7 @@ uniform float u_raisingHeight: 0.0;
26
26
  #pragma include "picking"
27
27
 
28
28
  varying vec4 v_color;
29
+ varying vec4 v_stroke;
29
30
 
30
31
  // texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
31
32
  varying vec2 v_iconMapUV;
@@ -95,6 +96,7 @@ void main() {
95
96
 
96
97
  v_color = a_Color;
97
98
  v_color.a *= opacity;
99
+ v_stroke = stroke;
98
100
 
99
101
  vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
100
102