@antv/l7-layers 2.9.25-alpha.0 → 2.9.26-alpha.1

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 (126) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/tileFactory/base.d.ts +1 -1
  3. package/es/tile/utils.js +1 -1
  4. package/lib/Geometry/index.js +114 -77
  5. package/lib/Geometry/models/billboard.js +232 -181
  6. package/lib/Geometry/models/index.js +18 -34
  7. package/lib/Geometry/models/plane.js +407 -278
  8. package/lib/Geometry/models/sprite.js +291 -189
  9. package/lib/canvas/index.js +101 -66
  10. package/lib/canvas/models/canvas.js +207 -140
  11. package/lib/canvas/models/index.js +12 -30
  12. package/lib/citybuliding/building.js +98 -63
  13. package/lib/citybuliding/models/build.js +192 -146
  14. package/lib/core/BaseLayer.js +1331 -814
  15. package/lib/core/BaseModel.js +457 -279
  16. package/lib/core/interface.js +40 -53
  17. package/lib/core/schema.js +21 -39
  18. package/lib/core/shape/Path.js +67 -79
  19. package/lib/core/shape/extrude.js +132 -91
  20. package/lib/core/triangulation.js +378 -196
  21. package/lib/earth/index.js +100 -62
  22. package/lib/earth/models/atmosphere.js +146 -112
  23. package/lib/earth/models/base.js +210 -150
  24. package/lib/earth/models/bloomsphere.js +146 -112
  25. package/lib/earth/utils.js +111 -91
  26. package/lib/heatmap/index.js +149 -92
  27. package/lib/heatmap/models/grid.js +118 -91
  28. package/lib/heatmap/models/grid3d.js +155 -123
  29. package/lib/heatmap/models/heatmap.js +475 -338
  30. package/lib/heatmap/models/hexagon.js +121 -92
  31. package/lib/heatmap/models/index.js +22 -37
  32. package/lib/heatmap/triangulation.js +31 -47
  33. package/lib/image/index.js +111 -74
  34. package/lib/image/models/dataImage.js +232 -174
  35. package/lib/image/models/image.js +175 -128
  36. package/lib/image/models/index.js +15 -32
  37. package/lib/index.js +263 -97
  38. package/lib/line/index.js +131 -85
  39. package/lib/line/models/arc.js +352 -237
  40. package/lib/line/models/arc_3d.js +334 -228
  41. package/lib/line/models/earthArc_3d.js +336 -228
  42. package/lib/line/models/great_circle.js +291 -200
  43. package/lib/line/models/half.js +286 -201
  44. package/lib/line/models/index.js +42 -50
  45. package/lib/line/models/line.js +428 -299
  46. package/lib/line/models/linearline.js +277 -203
  47. package/lib/line/models/simpleLine.js +239 -175
  48. package/lib/line/models/tile.js +348 -237
  49. package/lib/line/models/wall.js +327 -235
  50. package/lib/mask/index.js +92 -59
  51. package/lib/mask/models/fill.js +134 -82
  52. package/lib/mask/models/index.js +12 -30
  53. package/lib/plugins/DataMappingPlugin.js +342 -224
  54. package/lib/plugins/DataSourcePlugin.js +102 -87
  55. package/lib/plugins/FeatureScalePlugin.js +330 -240
  56. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  57. package/lib/plugins/LayerModelPlugin.js +80 -73
  58. package/lib/plugins/LayerStylePlugin.js +48 -51
  59. package/lib/plugins/LightingPlugin.js +80 -68
  60. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  61. package/lib/plugins/PixelPickingPlugin.js +150 -109
  62. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  63. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  64. package/lib/plugins/UpdateModelPlugin.js +40 -47
  65. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  66. package/lib/point/index.js +226 -150
  67. package/lib/point/models/earthExtrude.js +279 -201
  68. package/lib/point/models/earthFill.js +287 -202
  69. package/lib/point/models/extrude.js +299 -203
  70. package/lib/point/models/fill.js +406 -275
  71. package/lib/point/models/fillmage.js +365 -256
  72. package/lib/point/models/image.js +241 -168
  73. package/lib/point/models/index.js +46 -52
  74. package/lib/point/models/normal.js +183 -134
  75. package/lib/point/models/radar.js +304 -211
  76. package/lib/point/models/simplePoint.js +194 -142
  77. package/lib/point/models/text.js +608 -385
  78. package/lib/point/models/tile.js +314 -223
  79. package/lib/point/shape/extrude.js +56 -52
  80. package/lib/polygon/index.js +154 -102
  81. package/lib/polygon/models/extrude.js +311 -223
  82. package/lib/polygon/models/fill.js +215 -153
  83. package/lib/polygon/models/index.js +46 -52
  84. package/lib/polygon/models/ocean.js +244 -173
  85. package/lib/polygon/models/tile.js +144 -100
  86. package/lib/polygon/models/water.js +222 -153
  87. package/lib/raster/buffers/triangulation.js +27 -40
  88. package/lib/raster/index.js +115 -75
  89. package/lib/raster/models/index.js +16 -33
  90. package/lib/raster/models/raster.js +178 -135
  91. package/lib/raster/raster.js +187 -132
  92. package/lib/tile/interface.js +4 -16
  93. package/lib/tile/manager/tileConfigManager.js +125 -86
  94. package/lib/tile/manager/tileLayerManager.js +313 -229
  95. package/lib/tile/manager/tilePickerManager.js +192 -123
  96. package/lib/tile/models/tileModel.js +71 -52
  97. package/lib/tile/tileFactory/base.js +432 -309
  98. package/lib/tile/tileFactory/index.js +51 -49
  99. package/lib/tile/tileFactory/line.js +65 -50
  100. package/lib/tile/tileFactory/point.js +65 -50
  101. package/lib/tile/tileFactory/polygon.js +65 -50
  102. package/lib/tile/tileFactory/raster.js +66 -54
  103. package/lib/tile/tileFactory/rasterData.js +88 -76
  104. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  105. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  106. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  107. package/lib/tile/tmsTileLayer.js +110 -67
  108. package/lib/tile/utils.js +110 -92
  109. package/lib/utils/blend.js +59 -79
  110. package/lib/utils/collision-index.js +107 -64
  111. package/lib/utils/dataMappingStyle.js +105 -60
  112. package/lib/utils/extrude_polyline.js +600 -398
  113. package/lib/utils/grid-index.js +163 -111
  114. package/lib/utils/layerData.js +130 -99
  115. package/lib/utils/multiPassRender.js +49 -41
  116. package/lib/utils/polylineNormal.js +148 -96
  117. package/lib/utils/simpleLine.js +100 -85
  118. package/lib/utils/symbol-layout.js +219 -116
  119. package/lib/utils/updateShape.js +15 -41
  120. package/lib/wind/index.js +109 -71
  121. package/lib/wind/models/index.js +12 -30
  122. package/lib/wind/models/utils.js +144 -105
  123. package/lib/wind/models/wind.js +333 -224
  124. package/lib/wind/models/windRender.js +329 -218
  125. package/lib/wind/models/windShader.js +23 -181
  126. package/package.json +6 -6
@@ -1,258 +1,373 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
21
4
 
22
- // src/line/models/arc.ts
23
- var arc_exports = {};
24
- __export(arc_exports, {
25
- default: () => ArcModel
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(arc_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_l7_utils = require("@antv/l7-utils");
30
- var import_lodash = require("lodash");
31
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
32
- var import_triangulation = require("../../core/triangulation");
33
- var import_arc_dash_frag = __toESM(require("../shaders/dash/arc_dash_frag.glsl"));
34
- var import_arc_dash_vert = __toESM(require("../shaders/dash/arc_dash_vert.glsl"));
35
- var import_line_arc_frag = __toESM(require("../shaders/line_arc_frag.glsl"));
36
- var import_line_arc_vert = __toESM(require("../shaders/line_arc_vert.glsl"));
37
- var import_arc_linear_frag = __toESM(require("../shaders/linear/arc_linear_frag.glsl"));
38
- var import_arc_linear_vert = __toESM(require("../shaders/linear/arc_linear_vert.glsl"));
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _l7Core = require("@antv/l7-core");
25
+
26
+ var _l7Utils = require("@antv/l7-utils");
27
+
28
+ var _lodash = require("lodash");
29
+
30
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
31
+
32
+ var _triangulation = require("../../core/triangulation");
33
+
34
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
35
+
36
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
37
+
38
+ /* babel-plugin-inline-import '../shaders/dash/arc_dash_frag.glsl' */
39
+ // arc dash line
40
+ var arc_dash_frag = "\nuniform float u_opacity;\n\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float segmentNumber;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].b; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u6BD4\u4F8B\n\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity;\n\n float flag = 0.;\n float dashLength = mod(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 flag = 1.;\n };\n gl_FragColor.a *=flag;\n \n gl_FragColor = filterColor(gl_FragColor);\n}";
41
+
42
+ /* babel-plugin-inline-import '../shaders/dash/arc_dash_vert.glsl' */
43
+ var arc_dash_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nvarying vec4 v_color;\n\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_lineDir: 1.0;\nvarying vec4 v_dash_array;\n\nuniform float u_thetaOffset: 0.314;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalThetaOffset\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\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}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\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 if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\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}\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}\n\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // dataset \u6570\u636E\u96C6\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke -> thetaOffset... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 thetaOffsetAndOffset = calThetaOffsetAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = thetaOffsetAndOffset.r;\n textureOffset = thetaOffsetAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\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 v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n\n styleMappingMat[3].b = segmentIndex / segmentNumber;\n\n // styleMappingMat[0][1] - arcThetaOffset\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, styleMappingMat[0][1]), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, styleMappingMat[0][1]), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n gl_PointSize = 5.0;\n setPickingColor(a_PickingColor);\n}\n"; // arc normal line
44
+
45
+ /* babel-plugin-inline-import '../shaders/line_arc_frag.glsl' */
46
+ var arc_line_frag = "\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 vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float segmentNumber;\nvarying vec2 v_iconMapUV;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_segmentIndex = styleMappingMat[3].r; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n float d_distance_ratio = styleMappingMat[3].b; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u6BD4\u4F8B\n\n gl_FragColor = v_color;\n \n gl_FragColor.a *= opacity;\n\n if(u_aimate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = styleMappingMat[3].g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_aimate.x == Animate) {\n time = u_time / u_aimate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = styleMappingMat[3].a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_aimate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_aimate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\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 \n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n // gl_FragColor = filterColor(gl_FragColor);\n}";
47
+
48
+ /* babel-plugin-inline-import '../shaders/line_arc_vert.glsl' */
49
+ var arc_line_vert = "#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;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nuniform float u_lineDir: 1.0;\n\nuniform float u_thetaOffset: 0.314;\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalThetaOffset\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\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}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\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 if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\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}\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}\n\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // dataset \u6570\u636E\u96C6\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke -> thetaOffset... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 thetaOffsetAndOffset = calThetaOffsetAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = thetaOffsetAndOffset.r;\n textureOffset = thetaOffsetAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n \n if(u_aimate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n styleMappingMat[3].b = d_distance_ratio;\n\n // styleMappingMat[0][1] - arcThetaOffset\n float arcThetaOffset = styleMappingMat[0][1];\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, arcThetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, arcThetaOffset), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n styleMappingMat[3].r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n styleMappingMat[3].g = texCount;\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\n styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n"; // arc linear line
50
+
51
+ /* babel-plugin-inline-import '../shaders/linear/arc_linear_frag.glsl' */
52
+ var arc_linear_frag = "#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 vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float segmentNumber;\nvarying vec2 v_iconMapUV;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_segmentIndex = styleMappingMat[3].r; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}";
53
+
54
+ /* babel-plugin-inline-import '../shaders/linear/arc_linear_vert.glsl' */
55
+ var arc_linear_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nvarying vec4 v_color;\n\nuniform float u_lineDir: 1.0;\n\nuniform float u_thetaOffset: 0.314;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalThetaOffset\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\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}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\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 if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\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}\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}\n\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // dataset \u6570\u636E\u96C6\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke -> thetaOffset... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 thetaOffsetAndOffset = calThetaOffsetAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = thetaOffsetAndOffset.r;\n textureOffset = thetaOffsetAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n\n styleMappingMat[3].b = d_distance_ratio;\n\n // styleMappingMat[0][1] - arcThetaOffset\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, styleMappingMat[0][1]), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, styleMappingMat[0][1]), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n styleMappingMat[3].r = d_segmentIndex;\n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n";
39
56
  var lineStyleObj = {
40
- solid: 0,
41
- dash: 1
57
+ solid: 0.0,
58
+ dash: 1.0
42
59
  };
43
- var ArcModel = class extends import_BaseModel.default {
44
- constructor() {
45
- super(...arguments);
46
- this.updateTexture = () => {
47
- const { createTexture2D } = this.rendererService;
48
- if (this.texture) {
49
- this.texture.update({
50
- data: this.iconService.getCanvas()
60
+
61
+ var ArcModel = /*#__PURE__*/function (_BaseModel) {
62
+ (0, _inherits2.default)(ArcModel, _BaseModel);
63
+
64
+ var _super = _createSuper(ArcModel);
65
+
66
+ function ArcModel() {
67
+ var _this;
68
+
69
+ (0, _classCallCheck2.default)(this, ArcModel);
70
+
71
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
72
+ args[_key] = arguments[_key];
73
+ }
74
+
75
+ _this = _super.call.apply(_super, [this].concat(args));
76
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
77
+ var createTexture2D = _this.rendererService.createTexture2D;
78
+
79
+ if (_this.texture) {
80
+ _this.texture.update({
81
+ data: _this.iconService.getCanvas()
51
82
  });
52
- this.layer.render();
83
+
84
+ _this.layer.render();
85
+
53
86
  return;
54
87
  }
55
- this.texture = createTexture2D({
56
- data: this.iconService.getCanvas(),
57
- mag: import_l7_core.gl.NEAREST,
58
- min: import_l7_core.gl.NEAREST,
88
+
89
+ _this.texture = createTexture2D({
90
+ data: _this.iconService.getCanvas(),
91
+ mag: _l7Core.gl.NEAREST,
92
+ min: _l7Core.gl.NEAREST,
59
93
  premultiplyAlpha: false,
60
94
  width: 1024,
61
- height: this.iconService.canvasHeight || 128
95
+ height: _this.iconService.canvasHeight || 128
62
96
  });
63
- };
64
- }
65
- getUninforms() {
66
- const {
67
- opacity = 1,
68
- sourceColor,
69
- targetColor,
70
- textureBlend = "normal",
71
- lineType = "solid",
72
- dashArray = [10, 5],
73
- forward = true,
74
- lineTexture = false,
75
- iconStep = 100,
76
- segmentNumber = 30,
77
- thetaOffset = 0.314
78
- } = this.layer.getLayerConfig();
79
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity, thetaOffset })) {
80
- this.judgeStyleAttributes({ opacity, thetaOffset });
81
- const encodeData = this.layer.getEncodedData();
82
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
83
- this.rowCount = height;
84
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
85
- flipY: true,
86
- data,
87
- format: import_l7_core.gl.LUMINANCE,
88
- type: import_l7_core.gl.FLOAT,
89
- width,
90
- height
91
- }) : this.createTexture2D({
92
- flipY: true,
93
- data: [1],
94
- format: import_l7_core.gl.LUMINANCE,
95
- type: import_l7_core.gl.FLOAT,
96
- width: 1,
97
- height: 1
98
- });
99
- }
100
- if (dashArray.length === 2) {
101
- dashArray.push(0, 0);
102
- }
103
- let useLinearColor = 0;
104
- let sourceColorArr = [0, 0, 0, 0];
105
- let targetColorArr = [0, 0, 0, 0];
106
- if (sourceColor && targetColor) {
107
- sourceColorArr = (0, import_l7_utils.rgb2arr)(sourceColor);
108
- targetColorArr = (0, import_l7_utils.rgb2arr)(targetColor);
109
- useLinearColor = 1;
110
- }
111
- if (this.rendererService.getDirty()) {
112
- this.texture.bind();
113
- }
114
- return {
115
- u_dataTexture: this.dataTexture,
116
- u_cellTypeLayout: this.getCellTypeLayout(),
117
- u_thetaOffset: (0, import_lodash.isNumber)(thetaOffset) ? thetaOffset : 0,
118
- u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
119
- u_textureBlend: textureBlend === "normal" ? 0 : 1,
120
- segmentNumber,
121
- u_line_type: lineStyleObj[lineType || "solid"],
122
- u_dash_array: dashArray,
123
- u_blur: 0.9,
124
- u_lineDir: forward ? 1 : -1,
125
- u_texture: this.texture,
126
- u_line_texture: lineTexture ? 1 : 0,
127
- u_icon_step: iconStep,
128
- u_textSize: [1024, this.iconService.canvasHeight || 128],
129
- u_linearColor: useLinearColor,
130
- u_sourceColor: sourceColorArr,
131
- u_targetColor: targetColorArr
132
- };
133
- }
134
- getAnimateUniforms() {
135
- const { animateOption } = this.layer.getLayerConfig();
136
- return {
137
- u_aimate: this.animateOption2Array(animateOption),
138
- u_time: this.layer.getLayerAnimateTime()
139
- };
140
- }
141
- initModels(callbackModel) {
142
- this.updateTexture();
143
- this.iconService.on("imageUpdate", this.updateTexture);
144
- this.buildModels(callbackModel);
145
- }
146
- clearModels() {
147
- var _a, _b;
148
- (_a = this.texture) == null ? void 0 : _a.destroy();
149
- (_b = this.dataTexture) == null ? void 0 : _b.destroy();
150
- this.iconService.off("imageUpdate", this.updateTexture);
97
+ });
98
+ return _this;
151
99
  }
152
- getShaders() {
153
- const {
154
- sourceColor,
155
- targetColor,
156
- lineType
157
- } = this.layer.getLayerConfig();
158
- if (lineType === "dash") {
100
+
101
+ (0, _createClass2.default)(ArcModel, [{
102
+ key: "getUninforms",
103
+ value: function getUninforms() {
104
+ var _ref = this.layer.getLayerConfig(),
105
+ _ref$opacity = _ref.opacity,
106
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
107
+ sourceColor = _ref.sourceColor,
108
+ targetColor = _ref.targetColor,
109
+ _ref$textureBlend = _ref.textureBlend,
110
+ textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
111
+ _ref$lineType = _ref.lineType,
112
+ lineType = _ref$lineType === void 0 ? 'solid' : _ref$lineType,
113
+ _ref$dashArray = _ref.dashArray,
114
+ dashArray = _ref$dashArray === void 0 ? [10, 5] : _ref$dashArray,
115
+ _ref$forward = _ref.forward,
116
+ forward = _ref$forward === void 0 ? true : _ref$forward,
117
+ _ref$lineTexture = _ref.lineTexture,
118
+ lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
119
+ _ref$iconStep = _ref.iconStep,
120
+ iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
121
+ _ref$segmentNumber = _ref.segmentNumber,
122
+ segmentNumber = _ref$segmentNumber === void 0 ? 30 : _ref$segmentNumber,
123
+ _ref$thetaOffset = _ref.thetaOffset,
124
+ thetaOffset = _ref$thetaOffset === void 0 ? 0.314 : _ref$thetaOffset;
125
+
126
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
127
+ opacity: opacity,
128
+ thetaOffset: thetaOffset
129
+ })) {
130
+ this.judgeStyleAttributes({
131
+ opacity: opacity,
132
+ thetaOffset: thetaOffset
133
+ });
134
+ var encodeData = this.layer.getEncodedData();
135
+
136
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
137
+ data = _this$calDataFrame.data,
138
+ width = _this$calDataFrame.width,
139
+ height = _this$calDataFrame.height;
140
+
141
+ this.rowCount = height; // 当前数据纹理有多少行
142
+
143
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
144
+ flipY: true,
145
+ data: data,
146
+ format: _l7Core.gl.LUMINANCE,
147
+ type: _l7Core.gl.FLOAT,
148
+ width: width,
149
+ height: height
150
+ }) : this.createTexture2D({
151
+ flipY: true,
152
+ data: [1],
153
+ format: _l7Core.gl.LUMINANCE,
154
+ type: _l7Core.gl.FLOAT,
155
+ width: 1,
156
+ height: 1
157
+ });
158
+ }
159
+
160
+ if (dashArray.length === 2) {
161
+ dashArray.push(0, 0);
162
+ } // 转化渐变色
163
+
164
+
165
+ var useLinearColor = 0; // 默认不生效
166
+
167
+ var sourceColorArr = [0, 0, 0, 0];
168
+ var targetColorArr = [0, 0, 0, 0];
169
+
170
+ if (sourceColor && targetColor) {
171
+ sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
172
+ targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
173
+ useLinearColor = 1;
174
+ }
175
+
176
+ if (this.rendererService.getDirty()) {
177
+ this.texture.bind();
178
+ }
179
+
159
180
  return {
160
- frag: import_arc_dash_frag.default,
161
- vert: import_arc_dash_vert.default,
162
- type: "Dash"
181
+ u_dataTexture: this.dataTexture,
182
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
183
+ u_cellTypeLayout: this.getCellTypeLayout(),
184
+ u_thetaOffset: (0, _lodash.isNumber)(thetaOffset) ? thetaOffset : 0.0,
185
+ // u_thetaOffset: 0.0,
186
+ u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
187
+ u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
188
+ segmentNumber: segmentNumber,
189
+ u_line_type: lineStyleObj[lineType || 'solid'],
190
+ u_dash_array: dashArray,
191
+ u_blur: 0.9,
192
+ u_lineDir: forward ? 1 : -1,
193
+ // 纹理支持参数
194
+ u_texture: this.texture,
195
+ // 贴图
196
+ u_line_texture: lineTexture ? 1.0 : 0.0,
197
+ // 传入线的标识
198
+ u_icon_step: iconStep,
199
+ u_textSize: [1024, this.iconService.canvasHeight || 128],
200
+ // 渐变色支持参数
201
+ u_linearColor: useLinearColor,
202
+ u_sourceColor: sourceColorArr,
203
+ u_targetColor: targetColorArr
163
204
  };
164
205
  }
165
- if (sourceColor && targetColor) {
166
- return {
167
- frag: import_arc_linear_frag.default,
168
- vert: import_arc_linear_vert.default,
169
- type: "Linear"
170
- };
171
- } else {
206
+ }, {
207
+ key: "getAnimateUniforms",
208
+ value: function getAnimateUniforms() {
209
+ var _ref2 = this.layer.getLayerConfig(),
210
+ animateOption = _ref2.animateOption;
211
+
172
212
  return {
173
- frag: import_line_arc_frag.default,
174
- vert: import_line_arc_vert.default,
175
- type: ""
213
+ u_aimate: this.animateOption2Array(animateOption),
214
+ u_time: this.layer.getLayerAnimateTime()
176
215
  };
177
216
  }
178
- }
179
- buildModels(callbackModel) {
180
- const {
181
- segmentNumber = 30,
182
- mask = false,
183
- maskInside = true
184
- } = this.layer.getLayerConfig();
185
- const { frag, vert, type } = this.getShaders();
186
- this.layer.buildLayerModel({
187
- moduleName: "lineArc2d" + type,
188
- vertexShader: vert,
189
- fragmentShader: frag,
190
- triangulation: import_triangulation.LineArcTriangulation,
191
- depth: { enable: false },
192
- blend: this.getBlend(),
193
- segmentNumber,
194
- stencil: (0, import_l7_utils.getMask)(mask, maskInside)
195
- }).then((model) => {
196
- callbackModel([model]);
197
- }).catch((err) => {
198
- console.warn(err);
199
- callbackModel([]);
200
- });
201
- }
202
- registerBuiltinAttributes() {
203
- this.styleAttributeService.registerStyleAttribute({
204
- name: "size",
205
- type: import_l7_core.AttributeType.Attribute,
206
- descriptor: {
207
- name: "a_Size",
208
- buffer: {
209
- usage: import_l7_core.gl.DYNAMIC_DRAW,
210
- data: [],
211
- type: import_l7_core.gl.FLOAT
212
- },
213
- size: 1,
214
- update: (feature, featureIdx, vertex, attributeIdx) => {
215
- const { size = 1 } = feature;
216
- return Array.isArray(size) ? [size[0]] : [size];
217
- }
217
+ }, {
218
+ key: "initModels",
219
+ value: function initModels(callbackModel) {
220
+ this.updateTexture();
221
+ this.iconService.on('imageUpdate', this.updateTexture);
222
+ this.buildModels(callbackModel);
223
+ }
224
+ }, {
225
+ key: "clearModels",
226
+ value: function clearModels() {
227
+ var _this$texture, _this$dataTexture;
228
+
229
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
230
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
231
+ this.iconService.off('imageUpdate', this.updateTexture);
232
+ }
233
+ }, {
234
+ key: "getShaders",
235
+ value: function getShaders() {
236
+ var _ref3 = this.layer.getLayerConfig(),
237
+ sourceColor = _ref3.sourceColor,
238
+ targetColor = _ref3.targetColor,
239
+ lineType = _ref3.lineType;
240
+
241
+ if (lineType === 'dash') {
242
+ return {
243
+ frag: arc_dash_frag,
244
+ vert: arc_dash_vert,
245
+ type: 'Dash'
246
+ };
218
247
  }
219
- });
220
- this.styleAttributeService.registerStyleAttribute({
221
- name: "instance",
222
- type: import_l7_core.AttributeType.Attribute,
223
- descriptor: {
224
- name: "a_Instance",
225
- buffer: {
226
- usage: import_l7_core.gl.STATIC_DRAW,
227
- data: [],
228
- type: import_l7_core.gl.FLOAT
229
- },
230
- size: 4,
231
- update: (feature, featureIdx, vertex, attributeIdx) => {
232
- return [vertex[3], vertex[4], vertex[5], vertex[6]];
233
- }
248
+
249
+ if (sourceColor && targetColor) {
250
+ // 分离 linear 功能
251
+ return {
252
+ frag: arc_linear_frag,
253
+ vert: arc_linear_vert,
254
+ type: 'Linear'
255
+ };
256
+ } else {
257
+ return {
258
+ frag: arc_line_frag,
259
+ vert: arc_line_vert,
260
+ type: ''
261
+ };
234
262
  }
235
- });
236
- this.styleAttributeService.registerStyleAttribute({
237
- name: "uv",
238
- type: import_l7_core.AttributeType.Attribute,
239
- descriptor: {
240
- name: "a_iconMapUV",
241
- buffer: {
242
- usage: import_l7_core.gl.DYNAMIC_DRAW,
243
- data: [],
244
- type: import_l7_core.gl.FLOAT
263
+ }
264
+ }, {
265
+ key: "buildModels",
266
+ value: function buildModels(callbackModel) {
267
+ var _ref4 = this.layer.getLayerConfig(),
268
+ _ref4$segmentNumber = _ref4.segmentNumber,
269
+ segmentNumber = _ref4$segmentNumber === void 0 ? 30 : _ref4$segmentNumber,
270
+ _ref4$mask = _ref4.mask,
271
+ mask = _ref4$mask === void 0 ? false : _ref4$mask,
272
+ _ref4$maskInside = _ref4.maskInside,
273
+ maskInside = _ref4$maskInside === void 0 ? true : _ref4$maskInside;
274
+
275
+ var _this$getShaders = this.getShaders(),
276
+ frag = _this$getShaders.frag,
277
+ vert = _this$getShaders.vert,
278
+ type = _this$getShaders.type;
279
+
280
+ this.layer.buildLayerModel({
281
+ moduleName: 'lineArc2d' + type,
282
+ vertexShader: vert,
283
+ fragmentShader: frag,
284
+ triangulation: _triangulation.LineArcTriangulation,
285
+ depth: {
286
+ enable: false
245
287
  },
246
- size: 2,
247
- update: (feature, featureIdx, vertex, attributeIdx) => {
248
- const iconMap = this.iconService.getIconMap();
249
- const { texture } = feature;
250
- const { x, y } = iconMap[texture] || { x: 0, y: 0 };
251
- return [x, y];
288
+ blend: this.getBlend(),
289
+ segmentNumber: segmentNumber,
290
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
291
+ }).then(function (model) {
292
+ callbackModel([model]);
293
+ }).catch(function (err) {
294
+ console.warn(err);
295
+ callbackModel([]);
296
+ });
297
+ }
298
+ }, {
299
+ key: "registerBuiltinAttributes",
300
+ value: function registerBuiltinAttributes() {
301
+ var _this2 = this;
302
+
303
+ // point layer size;
304
+ this.styleAttributeService.registerStyleAttribute({
305
+ name: 'size',
306
+ type: _l7Core.AttributeType.Attribute,
307
+ descriptor: {
308
+ name: 'a_Size',
309
+ buffer: {
310
+ // give the WebGL driver a hint that this buffer may change
311
+ usage: _l7Core.gl.DYNAMIC_DRAW,
312
+ data: [],
313
+ type: _l7Core.gl.FLOAT
314
+ },
315
+ size: 1,
316
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
317
+ var _feature$size = feature.size,
318
+ size = _feature$size === void 0 ? 1 : _feature$size;
319
+ return Array.isArray(size) ? [size[0]] : [size];
320
+ }
252
321
  }
253
- }
254
- });
255
- }
256
- };
257
- // Annotate the CommonJS export names for ESM import in node:
258
- 0 && (module.exports = {});
322
+ });
323
+ this.styleAttributeService.registerStyleAttribute({
324
+ name: 'instance',
325
+ // 弧线起始点信息
326
+ type: _l7Core.AttributeType.Attribute,
327
+ descriptor: {
328
+ name: 'a_Instance',
329
+ buffer: {
330
+ usage: _l7Core.gl.STATIC_DRAW,
331
+ data: [],
332
+ type: _l7Core.gl.FLOAT
333
+ },
334
+ size: 4,
335
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
336
+ return [vertex[3], vertex[4], vertex[5], vertex[6]];
337
+ }
338
+ }
339
+ });
340
+ this.styleAttributeService.registerStyleAttribute({
341
+ name: 'uv',
342
+ type: _l7Core.AttributeType.Attribute,
343
+ descriptor: {
344
+ name: 'a_iconMapUV',
345
+ buffer: {
346
+ // give the WebGL driver a hint that this buffer may change
347
+ usage: _l7Core.gl.DYNAMIC_DRAW,
348
+ data: [],
349
+ type: _l7Core.gl.FLOAT
350
+ },
351
+ size: 2,
352
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
353
+ var iconMap = _this2.iconService.getIconMap();
354
+
355
+ var texture = feature.texture;
356
+
357
+ var _ref5 = iconMap[texture] || {
358
+ x: 0,
359
+ y: 0
360
+ },
361
+ x = _ref5.x,
362
+ y = _ref5.y;
363
+
364
+ return [x, y];
365
+ }
366
+ }
367
+ });
368
+ }
369
+ }]);
370
+ return ArcModel;
371
+ }(_BaseModel2.default);
372
+
373
+ exports.default = ArcModel;