@antv/l7-layers 2.19.8 → 2.19.10

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 (75) hide show
  1. package/es/core/BaseLayer.d.ts +0 -2
  2. package/es/core/BaseLayer.js +15 -34
  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 +2 -0
  8. package/es/geometry/models/plane.js +1 -2
  9. package/es/geometry/models/sprite.js +1 -2
  10. package/es/line/index.js +1 -1
  11. package/es/line/models/arc.js +10 -13
  12. package/es/line/models/arc_3d.js +2 -2
  13. package/es/line/models/earthArc_3d.js +2 -2
  14. package/es/line/models/great_circle.js +6 -7
  15. package/es/line/models/line.js +7 -10
  16. package/es/line/models/linearline.js +5 -4
  17. package/es/line/models/simpleLine.js +6 -5
  18. package/es/line/models/wall.js +4 -5
  19. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -4
  20. package/es/line/shaders/dash/arc_dash_vert.glsl +1 -3
  21. package/es/line/shaders/dash/line_dash_frag.glsl +0 -1
  22. package/es/line/shaders/line_arc_3d_frag.glsl +2 -4
  23. package/es/line/shaders/line_arc_3d_vert.glsl +2 -1
  24. package/es/line/shaders/line_arc_frag.glsl +1 -4
  25. package/es/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  26. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  27. package/es/line/shaders/line_arc_vert.glsl +3 -5
  28. package/es/line/shaders/line_frag.glsl +12 -12
  29. package/es/line/shaders/line_vert.glsl +2 -0
  30. package/es/line/shaders/linear/arc_linear_vert.glsl +1 -2
  31. package/es/line/shaders/linear/line_linear_frag.glsl +0 -1
  32. package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  33. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  34. package/es/line/shaders/simple/simpleline_vert.glsl +1 -2
  35. package/es/plugins/DataMappingPlugin.js +3 -4
  36. package/es/polygon/models/ocean.js +1 -2
  37. package/es/polygon/models/water.js +1 -2
  38. package/lib/core/BaseLayer.js +15 -34
  39. package/lib/core/BaseModel.js +4 -19
  40. package/lib/core/CommonStyleAttribute.js +20 -0
  41. package/lib/core/constant.js +27 -0
  42. package/lib/geometry/models/plane.js +1 -2
  43. package/lib/geometry/models/sprite.js +1 -2
  44. package/lib/line/index.js +1 -1
  45. package/lib/line/models/arc.js +10 -13
  46. package/lib/line/models/arc_3d.js +2 -2
  47. package/lib/line/models/earthArc_3d.js +2 -2
  48. package/lib/line/models/great_circle.js +6 -7
  49. package/lib/line/models/line.js +7 -10
  50. package/lib/line/models/linearline.js +5 -4
  51. package/lib/line/models/simpleLine.js +6 -5
  52. package/lib/line/models/wall.js +4 -5
  53. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -4
  54. package/lib/line/shaders/dash/arc_dash_vert.glsl +1 -3
  55. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -1
  56. package/lib/line/shaders/line_arc_3d_frag.glsl +2 -4
  57. package/lib/line/shaders/line_arc_3d_vert.glsl +2 -1
  58. package/lib/line/shaders/line_arc_frag.glsl +1 -4
  59. package/lib/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  60. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  61. package/lib/line/shaders/line_arc_vert.glsl +3 -5
  62. package/lib/line/shaders/line_frag.glsl +12 -12
  63. package/lib/line/shaders/line_vert.glsl +2 -0
  64. package/lib/line/shaders/linear/arc_linear_vert.glsl +1 -2
  65. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -1
  66. package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  67. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  68. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -2
  69. package/lib/plugins/DataMappingPlugin.js +3 -4
  70. package/lib/polygon/models/ocean.js +1 -2
  71. package/lib/polygon/models/water.js +1 -2
  72. package/package.json +7 -7
  73. package/es/utils/layerData.d.ts +0 -2
  74. package/es/utils/layerData.js +0 -159
  75. package/lib/utils/layerData.js +0 -166
@@ -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";
@@ -14,9 +15,9 @@ import { rgb2arr } from '@antv/l7-utils';
14
15
  import BaseModel from "../../core/BaseModel";
15
16
  import { LineArcTriangulation } from "../../core/triangulation";
16
17
  /* babel-plugin-inline-import '../shaders/line_arc_great_circle_frag.glsl' */
17
- var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nvarying vec4 v_line_data;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n float opacity = u_opacity;\n float animateSpeed = 0.0;\n float d_segmentIndex = v_line_data.g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float dashLength = mod(v_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\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\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 // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_animate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
18
+ var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nvarying vec4 v_line_data;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n\n float animateSpeed = 0.0;\n float d_segmentIndex = v_line_data.g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\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 // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n if(u_line_type == LineTypeDash) {\n float dashLength = mod(v_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\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\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 // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_animate.x == Animate) {\n u = gl_FragColor.a/v_color.a;\n }\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(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 = filterColor(pattern);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
18
19
  /* babel-plugin-inline-import '../shaders/line_arc_great_circle_vert.glsl' */
19
- var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_line_data;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return index / (segmentNumber - 1.);\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n }else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\n}\n\nvoid main() {\n \n\n v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*16.0; // total_Distance*16.0 \u8C03\u6574\u9ED8\u8BA4\u7684\u6548\u679C\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n }\n\n if(u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\nv_line_data.g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\nv_line_data.b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\nv_line_data.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n";
20
+ var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_line_data;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return index / (segmentNumber - 1.);\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n }else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\n}\n\nvoid main() {\n v_color = a_Color;\n v_color.a = v_color.a * opacity;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*16.0; // total_Distance*16.0 \u8C03\u6574\u9ED8\u8BA4\u7684\u6548\u679C\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n }\n\n if(u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\nv_line_data.g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\nv_line_data.b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\nv_line_data.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n";
20
21
  var lineStyleObj = {
21
22
  solid: 0.0,
22
23
  dash: 1.0
@@ -55,8 +56,6 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
55
56
  key: "getUninforms",
56
57
  value: function getUninforms() {
57
58
  var _ref = this.layer.getLayerConfig(),
58
- _ref$opacity = _ref.opacity,
59
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
60
59
  sourceColor = _ref.sourceColor,
61
60
  targetColor = _ref.targetColor,
62
61
  _ref$textureBlend = _ref.textureBlend,
@@ -87,8 +86,7 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
87
86
  targetColorArr = rgb2arr(targetColor);
88
87
  useLinearColor = 1;
89
88
  }
90
- return {
91
- u_opacity: opacity,
89
+ return _objectSpread({
92
90
  u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
93
91
  segmentNumber: segmentNumber,
94
92
  u_line_type: lineStyleObj[lineType] || 0.0,
@@ -104,7 +102,7 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
104
102
  u_linearColor: useLinearColor,
105
103
  u_sourceColor: sourceColorArr,
106
104
  u_targetColor: targetColorArr
107
- };
105
+ }, this.getStyleAttribute());
108
106
  }
109
107
  }, {
110
108
  key: "getAnimateUniforms",
@@ -158,6 +156,7 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
158
156
  vertexShader: line_arc2d_vert,
159
157
  fragmentShader: line_arc_frag,
160
158
  triangulation: LineArcTriangulation,
159
+ inject: this.getInject(),
161
160
  depth: {
162
161
  enable: false
163
162
  }
@@ -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,
@@ -136,8 +134,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
136
134
  u_icon_step: iconStep,
137
135
  u_textSize: [1024, this.iconService.canvasHeight || 128],
138
136
  // line border 参数
139
- u_borderWidth: borderWidth,
140
- u_borderColor: rgb2arr(borderColor),
137
+ u_strokeWidth: strokeWidth,
141
138
  // 渐变色支持参数
142
139
  u_linearDir: linearDir === LinearDir.VERTICAL ? 1.0 : 0.0,
143
140
  u_linearColor: useLinearColor,
@@ -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)) {
@@ -16,8 +16,6 @@ varying float v_distance_ratio;
16
16
 
17
17
  uniform float u_thetaOffset: 0.314;
18
18
 
19
- uniform float u_opacity: 1.0;
20
-
21
19
  #pragma include "projection"
22
20
  #pragma include "project"
23
21
  #pragma include "picking"
@@ -72,7 +70,7 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
72
70
  }
73
71
 
74
72
  void main() {
75
- v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
73
+ v_color = vec4(a_Color.xyz, a_Color.w * opacity);
76
74
 
77
75
  vec2 source = a_Instance.rg; // 起始点
78
76
  vec2 target = a_Instance.ba; // 终点
@@ -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
  // 实线部分
@@ -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