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

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 (125) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/utils.js +1 -1
  3. package/lib/Geometry/index.js +114 -77
  4. package/lib/Geometry/models/billboard.js +232 -181
  5. package/lib/Geometry/models/index.js +18 -34
  6. package/lib/Geometry/models/plane.js +407 -278
  7. package/lib/Geometry/models/sprite.js +291 -189
  8. package/lib/canvas/index.js +101 -66
  9. package/lib/canvas/models/canvas.js +207 -140
  10. package/lib/canvas/models/index.js +12 -30
  11. package/lib/citybuliding/building.js +98 -63
  12. package/lib/citybuliding/models/build.js +192 -146
  13. package/lib/core/BaseLayer.js +1331 -814
  14. package/lib/core/BaseModel.js +457 -279
  15. package/lib/core/interface.js +40 -53
  16. package/lib/core/schema.js +21 -39
  17. package/lib/core/shape/Path.js +67 -79
  18. package/lib/core/shape/extrude.js +132 -91
  19. package/lib/core/triangulation.js +378 -196
  20. package/lib/earth/index.js +100 -62
  21. package/lib/earth/models/atmosphere.js +146 -112
  22. package/lib/earth/models/base.js +210 -150
  23. package/lib/earth/models/bloomsphere.js +146 -112
  24. package/lib/earth/utils.js +111 -91
  25. package/lib/heatmap/index.js +149 -92
  26. package/lib/heatmap/models/grid.js +118 -91
  27. package/lib/heatmap/models/grid3d.js +155 -123
  28. package/lib/heatmap/models/heatmap.js +475 -338
  29. package/lib/heatmap/models/hexagon.js +121 -92
  30. package/lib/heatmap/models/index.js +22 -37
  31. package/lib/heatmap/triangulation.js +31 -47
  32. package/lib/image/index.js +111 -74
  33. package/lib/image/models/dataImage.js +232 -174
  34. package/lib/image/models/image.js +175 -128
  35. package/lib/image/models/index.js +15 -32
  36. package/lib/index.js +263 -97
  37. package/lib/line/index.js +131 -85
  38. package/lib/line/models/arc.js +352 -237
  39. package/lib/line/models/arc_3d.js +334 -228
  40. package/lib/line/models/earthArc_3d.js +336 -228
  41. package/lib/line/models/great_circle.js +291 -200
  42. package/lib/line/models/half.js +286 -201
  43. package/lib/line/models/index.js +42 -50
  44. package/lib/line/models/line.js +428 -299
  45. package/lib/line/models/linearline.js +277 -203
  46. package/lib/line/models/simpleLine.js +239 -175
  47. package/lib/line/models/tile.js +348 -237
  48. package/lib/line/models/wall.js +327 -235
  49. package/lib/mask/index.js +92 -59
  50. package/lib/mask/models/fill.js +134 -82
  51. package/lib/mask/models/index.js +12 -30
  52. package/lib/plugins/DataMappingPlugin.js +342 -224
  53. package/lib/plugins/DataSourcePlugin.js +102 -87
  54. package/lib/plugins/FeatureScalePlugin.js +330 -240
  55. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  56. package/lib/plugins/LayerModelPlugin.js +80 -73
  57. package/lib/plugins/LayerStylePlugin.js +48 -51
  58. package/lib/plugins/LightingPlugin.js +80 -68
  59. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  60. package/lib/plugins/PixelPickingPlugin.js +150 -109
  61. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  62. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  63. package/lib/plugins/UpdateModelPlugin.js +40 -47
  64. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  65. package/lib/point/index.js +226 -150
  66. package/lib/point/models/earthExtrude.js +279 -201
  67. package/lib/point/models/earthFill.js +287 -202
  68. package/lib/point/models/extrude.js +299 -203
  69. package/lib/point/models/fill.js +406 -275
  70. package/lib/point/models/fillmage.js +365 -256
  71. package/lib/point/models/image.js +241 -168
  72. package/lib/point/models/index.js +46 -52
  73. package/lib/point/models/normal.js +183 -134
  74. package/lib/point/models/radar.js +304 -211
  75. package/lib/point/models/simplePoint.js +194 -142
  76. package/lib/point/models/text.js +608 -385
  77. package/lib/point/models/tile.js +314 -223
  78. package/lib/point/shape/extrude.js +56 -52
  79. package/lib/polygon/index.js +154 -102
  80. package/lib/polygon/models/extrude.js +311 -223
  81. package/lib/polygon/models/fill.js +215 -153
  82. package/lib/polygon/models/index.js +46 -52
  83. package/lib/polygon/models/ocean.js +244 -173
  84. package/lib/polygon/models/tile.js +144 -100
  85. package/lib/polygon/models/water.js +222 -153
  86. package/lib/raster/buffers/triangulation.js +27 -40
  87. package/lib/raster/index.js +115 -75
  88. package/lib/raster/models/index.js +16 -33
  89. package/lib/raster/models/raster.js +178 -135
  90. package/lib/raster/raster.js +187 -132
  91. package/lib/tile/interface.js +4 -16
  92. package/lib/tile/manager/tileConfigManager.js +125 -86
  93. package/lib/tile/manager/tileLayerManager.js +313 -229
  94. package/lib/tile/manager/tilePickerManager.js +192 -123
  95. package/lib/tile/models/tileModel.js +71 -52
  96. package/lib/tile/tileFactory/base.js +432 -309
  97. package/lib/tile/tileFactory/index.js +51 -49
  98. package/lib/tile/tileFactory/line.js +65 -50
  99. package/lib/tile/tileFactory/point.js +65 -50
  100. package/lib/tile/tileFactory/polygon.js +65 -50
  101. package/lib/tile/tileFactory/raster.js +66 -54
  102. package/lib/tile/tileFactory/rasterData.js +88 -76
  103. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  104. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  105. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  106. package/lib/tile/tmsTileLayer.js +110 -67
  107. package/lib/tile/utils.js +110 -92
  108. package/lib/utils/blend.js +59 -79
  109. package/lib/utils/collision-index.js +107 -64
  110. package/lib/utils/dataMappingStyle.js +105 -60
  111. package/lib/utils/extrude_polyline.js +600 -398
  112. package/lib/utils/grid-index.js +163 -111
  113. package/lib/utils/layerData.js +130 -99
  114. package/lib/utils/multiPassRender.js +49 -41
  115. package/lib/utils/polylineNormal.js +148 -96
  116. package/lib/utils/simpleLine.js +100 -85
  117. package/lib/utils/symbol-layout.js +219 -116
  118. package/lib/utils/updateShape.js +15 -41
  119. package/lib/wind/index.js +109 -71
  120. package/lib/wind/models/index.js +12 -30
  121. package/lib/wind/models/utils.js +144 -105
  122. package/lib/wind/models/wind.js +333 -224
  123. package/lib/wind/models/windRender.js +329 -218
  124. package/lib/wind/models/windShader.js +23 -181
  125. package/package.json +6 -6
@@ -1,214 +1,299 @@
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);
21
-
22
- // src/line/models/half.ts
23
- var half_exports = {};
24
- __export(half_exports, {
25
- default: () => LineModel
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(half_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_line_half_frag = __toESM(require("../shaders/half/line_half_frag.glsl"));
34
- var import_line_half_vert = __toESM(require("../shaders/half/line_half_vert.glsl"));
35
- var LineModel = class extends import_BaseModel.default {
36
- getUninforms() {
37
- const {
38
- opacity = 1,
39
- sourceColor,
40
- targetColor,
41
- arrow = {
8
+ exports.default = void 0;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
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/half/line_half_frag.glsl' */
39
+ var line_half_frag = "#define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0 // amap\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\n#define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0\nuniform float u_CoordinateSystem;\nvarying vec4 v_color;\nuniform float u_arrow: 0.0;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat;\nvoid main() {\n float distanceAndIndex = styleMappingMat[0][3];\n float miter = styleMappingMat[0][2];\n\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n\n if(u_arrow > 0.0 && distanceAndIndex < 2.0) { // arrow\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) { \n if(cross(vec3(styleMappingMat[1].rg, 0.0), vec3(styleMappingMat[1].ba, 0.0)).z < 0.0) { // amap\n discard;\n }\n } else { // amap2 mapbox map\n if(cross(vec3(styleMappingMat[1].rg, 0.0), vec3(styleMappingMat[1].ba, 0.0)).z > 0.0) { \n discard;\n }\n }\n } else { // line body\n if(miter < 0.0) {\n discard;\n }\n }\n\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
40
+
41
+ /* babel-plugin-inline-import '../shaders/half/line_half_vert.glsl' */
42
+ var line_half_vert = "attribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute vec4 a_dirPoints;\nattribute vec3 a_DistanceAndIndex;\n\nuniform vec4 u_lineDir;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\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\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\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 styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - a_Miter - a_DistanceAndIndex\n 0.0, 0.0, 0.0, 0.0, // originX - originY - vectorX - vectorY\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n styleMappingMat[0][3] = a_DistanceAndIndex.y;\n styleMappingMat[0][2] = a_Miter;\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n\n v_color = a_Color;\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 // styleMappingMat[1].rg = a_Position.xy + offset;\n\n vec2 copyOffset = vec2(offset.x, offset.y);\n\n float lineDistance = a_DistanceAndIndex.x;\n float total_Distance = a_DistanceAndIndex.z;\n float currentLinePointRatio = lineDistance / 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\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = lineDistance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\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); // \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 gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));\n }\n \n if(u_arrow > 0.0 && a_DistanceAndIndex.y < 2.0) {\n vec2 startPoint = a_dirPoints.rg;\n vec2 endPoint = a_dirPoints.ba;\n vec4 t1 = project_position(vec4(startPoint, 0, 1.0));\n vec4 t2 = project_position(vec4(endPoint, 0, 1.0));\n // TODO\uFF1A \u540E\u7EED\u4F18\u5316\u53EF\u4EE5\u628A\u4F4D\u7F6E\u8BA1\u7B97\u653E\u5728 cpu \u4E2D\u5B8C\u6210\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 p1 = (u_Mvp * vec4(t1.xy, 0.0, 1.0)).xy;\n vec2 p2 = (u_Mvp * vec4(t2.xy, 0.0, 1.0)).xy;\n styleMappingMat[1].rg = normalize(p1 - p2);\n styleMappingMat[1].ba = normalize(gl_Position.xy - p2);\n } else {\n vec2 p1 = project_common_position_to_clipspace(vec4(t1.xy, 0.0, 1.0)).xy;\n vec2 p2 = project_common_position_to_clipspace(vec4(t2.xy, 0.0, 1.0)).xy;\n styleMappingMat[1].rg = normalize(p1 - p2);\n styleMappingMat[1].ba = normalize(gl_Position.xy - p2);\n }\n }\n\n setPickingColor(a_PickingColor);\n}\n";
43
+
44
+ var LineModel = /*#__PURE__*/function (_BaseModel) {
45
+ (0, _inherits2.default)(LineModel, _BaseModel);
46
+
47
+ var _super = _createSuper(LineModel);
48
+
49
+ function LineModel() {
50
+ (0, _classCallCheck2.default)(this, LineModel);
51
+ return _super.apply(this, arguments);
52
+ }
53
+
54
+ (0, _createClass2.default)(LineModel, [{
55
+ key: "getUninforms",
56
+ value: function getUninforms() {
57
+ var _ref = this.layer.getLayerConfig(),
58
+ _ref$opacity = _ref.opacity,
59
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
60
+ sourceColor = _ref.sourceColor,
61
+ targetColor = _ref.targetColor,
62
+ _ref$arrow = _ref.arrow,
63
+ arrow = _ref$arrow === void 0 ? {
42
64
  enable: false,
43
65
  arrowWidth: 2,
44
66
  arrowHeight: 3,
45
67
  tailWidth: 1
68
+ } : _ref$arrow; // 转化渐变色
69
+
70
+
71
+ var useLinearColor = 0; // 默认不生效
72
+
73
+ var sourceColorArr = [0, 0, 0, 0];
74
+ var targetColorArr = [0, 0, 0, 0];
75
+
76
+ if (sourceColor && targetColor) {
77
+ sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
78
+ targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
79
+ useLinearColor = 1;
80
+ }
81
+
82
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
83
+ opacity: opacity
84
+ })) {
85
+ this.judgeStyleAttributes({
86
+ opacity: opacity
87
+ });
88
+ var encodeData = this.layer.getEncodedData();
89
+
90
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
91
+ data = _this$calDataFrame.data,
92
+ width = _this$calDataFrame.width,
93
+ height = _this$calDataFrame.height;
94
+
95
+ this.rowCount = height; // 当前数据纹理有多少行
96
+
97
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
98
+ flipY: true,
99
+ data: data,
100
+ format: _l7Core.gl.LUMINANCE,
101
+ type: _l7Core.gl.FLOAT,
102
+ width: width,
103
+ height: height
104
+ }) : this.createTexture2D({
105
+ flipY: true,
106
+ data: [1],
107
+ format: _l7Core.gl.LUMINANCE,
108
+ type: _l7Core.gl.FLOAT,
109
+ width: 1,
110
+ height: 1
111
+ });
46
112
  }
47
- } = this.layer.getLayerConfig();
48
- let useLinearColor = 0;
49
- let sourceColorArr = [0, 0, 0, 0];
50
- let targetColorArr = [0, 0, 0, 0];
51
- if (sourceColor && targetColor) {
52
- sourceColorArr = (0, import_l7_utils.rgb2arr)(sourceColor);
53
- targetColorArr = (0, import_l7_utils.rgb2arr)(targetColor);
54
- useLinearColor = 1;
113
+
114
+ return {
115
+ u_dataTexture: this.dataTexture,
116
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
117
+ u_cellTypeLayout: this.getCellTypeLayout(),
118
+ u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
119
+ // 渐变色支持参数
120
+ u_linearColor: useLinearColor,
121
+ u_sourceColor: sourceColorArr,
122
+ u_targetColor: targetColorArr,
123
+ // arrow
124
+ u_arrow: Number(arrow.enable),
125
+ u_arrowHeight: arrow.arrowHeight || 3,
126
+ u_arrowWidth: arrow.arrowWidth || 2,
127
+ u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
128
+ };
55
129
  }
56
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
57
- this.judgeStyleAttributes({ opacity });
58
- const encodeData = this.layer.getEncodedData();
59
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
60
- this.rowCount = height;
61
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
62
- flipY: true,
63
- data,
64
- format: import_l7_core.gl.LUMINANCE,
65
- type: import_l7_core.gl.FLOAT,
66
- width,
67
- height
68
- }) : this.createTexture2D({
69
- flipY: true,
70
- data: [1],
71
- format: import_l7_core.gl.LUMINANCE,
72
- type: import_l7_core.gl.FLOAT,
73
- width: 1,
74
- height: 1
75
- });
130
+ }, {
131
+ key: "initModels",
132
+ value: function initModels(callbackModel) {
133
+ this.buildModels(callbackModel);
76
134
  }
77
- return {
78
- u_dataTexture: this.dataTexture,
79
- u_cellTypeLayout: this.getCellTypeLayout(),
80
- u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
81
- u_linearColor: useLinearColor,
82
- u_sourceColor: sourceColorArr,
83
- u_targetColor: targetColorArr,
84
- u_arrow: Number(arrow.enable),
85
- u_arrowHeight: arrow.arrowHeight || 3,
86
- u_arrowWidth: arrow.arrowWidth || 2,
87
- u_tailWidth: arrow.tailWidth === void 0 ? 1 : arrow.tailWidth
88
- };
89
- }
90
- initModels(callbackModel) {
91
- this.buildModels(callbackModel);
92
- }
93
- clearModels() {
94
- var _a;
95
- (_a = this.dataTexture) == null ? void 0 : _a.destroy();
96
- }
97
- async buildModels(callbackModel) {
98
- const {
99
- mask = false,
100
- maskInside = true,
101
- depth = false
102
- } = this.layer.getLayerConfig();
103
- const { frag, vert } = this.getShaders();
104
- this.layer.triangulation = import_triangulation.LineTriangulation;
105
- this.layer.buildLayerModel({
106
- moduleName: "lineHalf",
107
- vertexShader: vert,
108
- fragmentShader: frag,
109
- triangulation: import_triangulation.LineTriangulation,
110
- depth: { enable: depth },
111
- blend: this.getBlend(),
112
- stencil: (0, import_l7_utils.getMask)(mask, maskInside)
113
- }).then((model) => {
114
- callbackModel([model]);
115
- }).catch((err) => {
116
- console.warn(err);
117
- callbackModel([]);
118
- });
119
- }
120
- getShaders() {
121
- return {
122
- frag: import_line_half_frag.default,
123
- vert: import_line_half_vert.default,
124
- type: "normal"
125
- };
126
- }
127
- registerBuiltinAttributes() {
128
- this.styleAttributeService.registerStyleAttribute({
129
- name: "distanceAndIndex",
130
- type: import_l7_core.AttributeType.Attribute,
131
- descriptor: {
132
- name: "a_DistanceAndIndex",
133
- buffer: {
134
- usage: import_l7_core.gl.STATIC_DRAW,
135
- data: [],
136
- type: import_l7_core.gl.FLOAT
137
- },
138
- size: 3,
139
- update: (feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) => {
140
- return vertexIndex === void 0 ? [vertex[3], 10, vertex[5]] : [vertex[3], vertexIndex, vertex[5]];
141
- }
135
+ }, {
136
+ key: "clearModels",
137
+ value: function clearModels() {
138
+ var _this$dataTexture;
139
+
140
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
141
+ }
142
+ }, {
143
+ key: "buildModels",
144
+ value: function () {
145
+ var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(callbackModel) {
146
+ var _ref2, _ref2$mask, mask, _ref2$maskInside, maskInside, _ref2$depth, depth, _this$getShaders, frag, vert;
147
+
148
+ return _regenerator.default.wrap(function _callee$(_context) {
149
+ while (1) {
150
+ switch (_context.prev = _context.next) {
151
+ case 0:
152
+ _ref2 = this.layer.getLayerConfig(), _ref2$mask = _ref2.mask, mask = _ref2$mask === void 0 ? false : _ref2$mask, _ref2$maskInside = _ref2.maskInside, maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside, _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? false : _ref2$depth;
153
+ _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert;
154
+ this.layer.triangulation = _triangulation.LineTriangulation;
155
+ this.layer.buildLayerModel({
156
+ moduleName: 'lineHalf',
157
+ vertexShader: vert,
158
+ fragmentShader: frag,
159
+ triangulation: _triangulation.LineTriangulation,
160
+ depth: {
161
+ enable: depth
162
+ },
163
+ blend: this.getBlend(),
164
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
165
+ }).then(function (model) {
166
+ callbackModel([model]);
167
+ }).catch(function (err) {
168
+ console.warn(err);
169
+ callbackModel([]);
170
+ });
171
+
172
+ case 4:
173
+ case "end":
174
+ return _context.stop();
175
+ }
176
+ }
177
+ }, _callee, this);
178
+ }));
179
+
180
+ function buildModels(_x) {
181
+ return _buildModels.apply(this, arguments);
142
182
  }
143
- });
144
- this.styleAttributeService.registerStyleAttribute({
145
- name: "dirPoints",
146
- type: import_l7_core.AttributeType.Attribute,
147
- descriptor: {
148
- name: "a_dirPoints",
149
- buffer: {
150
- usage: import_l7_core.gl.STATIC_DRAW,
151
- data: [],
152
- type: import_l7_core.gl.FLOAT
153
- },
154
- size: 4,
155
- update: (feature, featureIdx, vertex, attributeIdx) => {
156
- const startPoint = feature.coordinates[0] || [0, 0];
157
- const endPoint = feature.coordinates[3] || [0, 0];
158
- return [startPoint[0], startPoint[1], endPoint[0], endPoint[1]];
183
+
184
+ return buildModels;
185
+ }()
186
+ /**
187
+ * 根据参数获取不同的 shader 代码
188
+ * @returns
189
+ */
190
+
191
+ }, {
192
+ key: "getShaders",
193
+ value: function getShaders() {
194
+ return {
195
+ frag: line_half_frag,
196
+ vert: line_half_vert,
197
+ type: 'normal'
198
+ };
199
+ }
200
+ }, {
201
+ key: "registerBuiltinAttributes",
202
+ value: function registerBuiltinAttributes() {
203
+ this.styleAttributeService.registerStyleAttribute({
204
+ name: 'distanceAndIndex',
205
+ type: _l7Core.AttributeType.Attribute,
206
+ descriptor: {
207
+ name: 'a_DistanceAndIndex',
208
+ buffer: {
209
+ // give the WebGL driver a hint that this buffer may change
210
+ usage: _l7Core.gl.STATIC_DRAW,
211
+ data: [],
212
+ type: _l7Core.gl.FLOAT
213
+ },
214
+ size: 3,
215
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
216
+ return vertexIndex === undefined ? [vertex[3], 10, vertex[5]] : [vertex[3], vertexIndex, vertex[5]];
217
+ }
159
218
  }
160
- }
161
- });
162
- this.styleAttributeService.registerStyleAttribute({
163
- name: "size",
164
- type: import_l7_core.AttributeType.Attribute,
165
- descriptor: {
166
- name: "a_Size",
167
- buffer: {
168
- usage: import_l7_core.gl.DYNAMIC_DRAW,
169
- data: [],
170
- type: import_l7_core.gl.FLOAT
171
- },
172
- size: 2,
173
- update: (feature, featureIdx, vertex, attributeIdx) => {
174
- const { size = 1 } = feature;
175
- return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
219
+ });
220
+ this.styleAttributeService.registerStyleAttribute({
221
+ name: 'dirPoints',
222
+ type: _l7Core.AttributeType.Attribute,
223
+ descriptor: {
224
+ name: 'a_dirPoints',
225
+ buffer: {
226
+ // give the WebGL driver a hint that this buffer may change
227
+ usage: _l7Core.gl.STATIC_DRAW,
228
+ data: [],
229
+ type: _l7Core.gl.FLOAT
230
+ },
231
+ size: 4,
232
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
233
+ // console.log(feature)
234
+ var startPoint = feature.coordinates[0] || [0, 0];
235
+ var endPoint = feature.coordinates[3] || [0, 0];
236
+ return [startPoint[0], startPoint[1], endPoint[0], endPoint[1]];
237
+ }
176
238
  }
177
- }
178
- });
179
- this.styleAttributeService.registerStyleAttribute({
180
- name: "normal",
181
- type: import_l7_core.AttributeType.Attribute,
182
- descriptor: {
183
- name: "a_Normal",
184
- buffer: {
185
- usage: import_l7_core.gl.STATIC_DRAW,
186
- data: [],
187
- type: import_l7_core.gl.FLOAT
188
- },
189
- size: 3,
190
- update: (feature, featureIdx, vertex, attributeIdx, normal) => {
191
- return normal;
239
+ });
240
+ this.styleAttributeService.registerStyleAttribute({
241
+ name: 'size',
242
+ type: _l7Core.AttributeType.Attribute,
243
+ descriptor: {
244
+ name: 'a_Size',
245
+ buffer: {
246
+ // give the WebGL driver a hint that this buffer may change
247
+ usage: _l7Core.gl.DYNAMIC_DRAW,
248
+ data: [],
249
+ type: _l7Core.gl.FLOAT
250
+ },
251
+ size: 2,
252
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
253
+ var _feature$size = feature.size,
254
+ size = _feature$size === void 0 ? 1 : _feature$size;
255
+ return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
256
+ }
192
257
  }
193
- }
194
- });
195
- this.styleAttributeService.registerStyleAttribute({
196
- name: "miter",
197
- type: import_l7_core.AttributeType.Attribute,
198
- descriptor: {
199
- name: "a_Miter",
200
- buffer: {
201
- usage: import_l7_core.gl.STATIC_DRAW,
202
- data: [],
203
- type: import_l7_core.gl.FLOAT
204
- },
205
- size: 1,
206
- update: (feature, featureIdx, vertex, attributeIdx) => {
207
- return [vertex[4]];
258
+ }); // point layer size;
259
+
260
+ this.styleAttributeService.registerStyleAttribute({
261
+ name: 'normal',
262
+ type: _l7Core.AttributeType.Attribute,
263
+ descriptor: {
264
+ name: 'a_Normal',
265
+ buffer: {
266
+ // give the WebGL driver a hint that this buffer may change
267
+ usage: _l7Core.gl.STATIC_DRAW,
268
+ data: [],
269
+ type: _l7Core.gl.FLOAT
270
+ },
271
+ size: 3,
272
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
273
+ return normal;
274
+ }
208
275
  }
209
- }
210
- });
211
- }
212
- };
213
- // Annotate the CommonJS export names for ESM import in node:
214
- 0 && (module.exports = {});
276
+ });
277
+ this.styleAttributeService.registerStyleAttribute({
278
+ name: 'miter',
279
+ type: _l7Core.AttributeType.Attribute,
280
+ descriptor: {
281
+ name: 'a_Miter',
282
+ buffer: {
283
+ // give the WebGL driver a hint that this buffer may change
284
+ usage: _l7Core.gl.STATIC_DRAW,
285
+ data: [],
286
+ type: _l7Core.gl.FLOAT
287
+ },
288
+ size: 1,
289
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
290
+ return [vertex[4]];
291
+ }
292
+ }
293
+ });
294
+ }
295
+ }]);
296
+ return LineModel;
297
+ }(_BaseModel2.default);
298
+
299
+ exports.default = LineModel;
@@ -1,54 +1,46 @@
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";
21
2
 
22
- // src/line/models/index.ts
23
- var models_exports = {};
24
- __export(models_exports, {
25
- default: () => models_default
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(models_exports);
28
- var import_tileModel = __toESM(require("../../tile/models/tileModel"));
29
- var import_arc = __toESM(require("./arc"));
30
- var import_arc_3d = __toESM(require("./arc_3d"));
31
- var import_earthArc_3d = __toESM(require("./earthArc_3d"));
32
- var import_great_circle = __toESM(require("./great_circle"));
33
- var import_half = __toESM(require("./half"));
34
- var import_line = __toESM(require("./line"));
35
- var import_linearline = __toESM(require("./linearline"));
36
- var import_simpleLine = __toESM(require("./simpleLine"));
37
- var import_tile = __toESM(require("./tile"));
38
- var import_wall = __toESM(require("./wall"));
8
+ exports.default = void 0;
9
+
10
+ var _tileModel = _interopRequireDefault(require("../../tile/models/tileModel"));
11
+
12
+ var _arc = _interopRequireDefault(require("./arc"));
13
+
14
+ var _arc_3d = _interopRequireDefault(require("./arc_3d"));
15
+
16
+ var _earthArc_3d = _interopRequireDefault(require("./earthArc_3d"));
17
+
18
+ var _great_circle = _interopRequireDefault(require("./great_circle"));
19
+
20
+ var _half = _interopRequireDefault(require("./half"));
21
+
22
+ var _line = _interopRequireDefault(require("./line"));
23
+
24
+ var _linearline = _interopRequireDefault(require("./linearline"));
25
+
26
+ var _simpleLine = _interopRequireDefault(require("./simpleLine"));
27
+
28
+ var _tile = _interopRequireDefault(require("./tile"));
29
+
30
+ var _wall = _interopRequireDefault(require("./wall"));
31
+
39
32
  var LineModels = {
40
- arc: import_arc.default,
41
- arc3d: import_arc_3d.default,
42
- greatcircle: import_great_circle.default,
43
- wall: import_wall.default,
44
- line: import_line.default,
45
- halfLine: import_half.default,
46
- simple: import_simpleLine.default,
47
- linearline: import_linearline.default,
48
- vectorline: import_tileModel.default,
49
- tileLine: import_tile.default,
50
- earthArc3d: import_earthArc_3d.default
33
+ arc: _arc.default,
34
+ arc3d: _arc_3d.default,
35
+ greatcircle: _great_circle.default,
36
+ wall: _wall.default,
37
+ line: _line.default,
38
+ halfLine: _half.default,
39
+ simple: _simpleLine.default,
40
+ linearline: _linearline.default,
41
+ vectorline: _tileModel.default,
42
+ tileLine: _tile.default,
43
+ earthArc3d: _earthArc_3d.default
51
44
  };
52
- var models_default = LineModels;
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {});
45
+ var _default = LineModels;
46
+ exports.default = _default;