@antv/l7-layers 2.17.2 → 2.17.4

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 (242) hide show
  1. package/es/Geometry/index.js +31 -9
  2. package/es/Geometry/models/billboard.js +89 -51
  3. package/es/Geometry/models/plane.js +143 -81
  4. package/es/Geometry/models/sprite.js +118 -60
  5. package/es/canvas/index.js +33 -10
  6. package/es/canvas/models/canvas.js +97 -41
  7. package/es/citybuliding/building.js +27 -8
  8. package/es/citybuliding/models/build.js +82 -57
  9. package/es/core/BaseLayer.js +478 -313
  10. package/es/core/BaseModel.js +80 -51
  11. package/es/core/CommonStyleAttribute.js +5 -2
  12. package/es/core/LayerPickService.js +32 -21
  13. package/es/core/TextureService.js +13 -0
  14. package/es/core/interface.js +24 -17
  15. package/es/core/shape/Path.js +20 -13
  16. package/es/core/shape/extrude.js +39 -27
  17. package/es/core/triangulation.js +136 -99
  18. package/es/earth/index.js +33 -9
  19. package/es/earth/models/atmosphere.js +54 -30
  20. package/es/earth/models/base.js +85 -47
  21. package/es/earth/models/bloomsphere.js +54 -30
  22. package/es/earth/utils.js +13 -9
  23. package/es/heatmap/index.js +40 -10
  24. package/es/heatmap/models/grid.js +52 -28
  25. package/es/heatmap/models/grid3d.js +52 -28
  26. package/es/heatmap/models/heatmap.js +149 -92
  27. package/es/heatmap/models/hexagon.js +52 -28
  28. package/es/heatmap/triangulation.js +4 -0
  29. package/es/image/index.js +28 -9
  30. package/es/image/models/image.js +100 -66
  31. package/es/index.js +17 -9
  32. package/es/line/index.js +35 -9
  33. package/es/line/models/arc.js +114 -64
  34. package/es/line/models/arc_3d.js +102 -58
  35. package/es/line/models/earthArc_3d.js +105 -60
  36. package/es/line/models/flow.js +60 -36
  37. package/es/line/models/great_circle.js +94 -53
  38. package/es/line/models/line.js +138 -86
  39. package/es/line/models/linearline.js +76 -43
  40. package/es/line/models/simpleLine.js +69 -39
  41. package/es/line/models/wall.js +92 -52
  42. package/es/mask/index.js +28 -9
  43. package/es/mask/models/fill.js +54 -29
  44. package/es/plugins/DataMappingPlugin.js +114 -78
  45. package/es/plugins/DataSourcePlugin.js +68 -45
  46. package/es/plugins/FeatureScalePlugin.js +122 -67
  47. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  48. package/es/plugins/LayerMaskPlugin.js +11 -3
  49. package/es/plugins/LayerModelPlugin.js +108 -69
  50. package/es/plugins/LayerStylePlugin.js +9 -3
  51. package/es/plugins/LightingPlugin.js +18 -12
  52. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  53. package/es/plugins/PixelPickingPlugin.js +21 -12
  54. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  55. package/es/plugins/ShaderUniformPlugin.js +27 -13
  56. package/es/plugins/UpdateModelPlugin.js +5 -0
  57. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  58. package/es/point/index.js +78 -26
  59. package/es/point/models/earthExtrude.js +95 -58
  60. package/es/point/models/earthFill.js +80 -52
  61. package/es/point/models/extrude.js +94 -57
  62. package/es/point/models/fill.js +81 -56
  63. package/es/point/models/fillmage.js +100 -60
  64. package/es/point/models/image.js +83 -47
  65. package/es/point/models/index.js +2 -2
  66. package/es/point/models/normal.js +54 -30
  67. package/es/point/models/radar.js +63 -38
  68. package/es/point/models/simplePoint.js +62 -38
  69. package/es/point/models/text.js +296 -199
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +41 -11
  72. package/es/polygon/models/extrude.js +135 -87
  73. package/es/polygon/models/fill.js +79 -50
  74. package/es/polygon/models/index.js +2 -3
  75. package/es/polygon/models/ocean.js +76 -42
  76. package/es/polygon/models/water.js +71 -37
  77. package/es/raster/buffers/triangulation.js +4 -2
  78. package/es/raster/index.js +32 -9
  79. package/es/raster/models/raster.js +116 -80
  80. package/es/raster/models/rasterRgb.js +127 -84
  81. package/es/raster/models/rasterTerrainRgb.js +84 -56
  82. package/es/tile/interaction/getRasterData.js +20 -14
  83. package/es/tile/interaction/utils.js +9 -7
  84. package/es/tile/manager/base.js +96 -63
  85. package/es/tile/service/TileLayerService.js +55 -33
  86. package/es/tile/service/TilePickService.js +40 -26
  87. package/es/tile/service/TileSourceService.js +7 -3
  88. package/es/tile/tileFactory/DebugTile.js +46 -29
  89. package/es/tile/tileFactory/ImageTile.js +38 -20
  90. package/es/tile/tileFactory/MaskTile.js +43 -22
  91. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  93. package/es/tile/tileFactory/RasterTile.js +53 -30
  94. package/es/tile/tileFactory/Tile.js +97 -63
  95. package/es/tile/tileFactory/VectorTile.js +68 -41
  96. package/es/tile/tileFactory/index.js +11 -0
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  98. package/es/tile/tileFactory/util.js +3 -0
  99. package/es/tile/tileLayer/BaseLayer.js +146 -105
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +2 -0
  102. package/es/utils/collision-index.js +16 -9
  103. package/es/utils/extrude_polyline.js +149 -101
  104. package/es/utils/grid-index.js +27 -2
  105. package/es/utils/identityScale.js +8 -0
  106. package/es/utils/layerData.js +44 -30
  107. package/es/utils/multiPassRender.js +13 -11
  108. package/es/utils/polylineNormal.js +37 -31
  109. package/es/utils/simpleLine.js +16 -2
  110. package/es/utils/stencil.js +3 -2
  111. package/es/utils/symbol-layout.js +53 -27
  112. package/es/wind/index.js +29 -9
  113. package/es/wind/models/utils.js +51 -26
  114. package/es/wind/models/wind.js +147 -101
  115. package/es/wind/models/windRender.js +66 -53
  116. package/lib/Geometry/index.js +38 -9
  117. package/lib/Geometry/models/billboard.js +97 -51
  118. package/lib/Geometry/models/index.js +5 -0
  119. package/lib/Geometry/models/plane.js +151 -79
  120. package/lib/Geometry/models/sprite.js +127 -60
  121. package/lib/canvas/index.js +40 -10
  122. package/lib/canvas/models/canvas.js +101 -41
  123. package/lib/canvas/models/index.js +3 -0
  124. package/lib/citybuliding/building.js +35 -8
  125. package/lib/citybuliding/models/build.js +92 -57
  126. package/lib/core/BaseLayer.js +469 -313
  127. package/lib/core/BaseModel.js +90 -51
  128. package/lib/core/CommonStyleAttribute.js +7 -2
  129. package/lib/core/LayerPickService.js +37 -21
  130. package/lib/core/TextureService.js +16 -0
  131. package/lib/core/interface.js +31 -21
  132. package/lib/core/schema.js +1 -0
  133. package/lib/core/shape/Path.js +31 -14
  134. package/lib/core/shape/extrude.js +62 -27
  135. package/lib/core/triangulation.js +177 -98
  136. package/lib/earth/index.js +43 -9
  137. package/lib/earth/models/atmosphere.js +63 -30
  138. package/lib/earth/models/base.js +90 -47
  139. package/lib/earth/models/bloomsphere.js +63 -30
  140. package/lib/earth/utils.js +31 -7
  141. package/lib/heatmap/index.js +48 -10
  142. package/lib/heatmap/models/grid.js +60 -28
  143. package/lib/heatmap/models/grid3d.js +60 -28
  144. package/lib/heatmap/models/heatmap.js +166 -92
  145. package/lib/heatmap/models/hexagon.js +60 -28
  146. package/lib/heatmap/models/index.js +6 -0
  147. package/lib/heatmap/triangulation.js +5 -0
  148. package/lib/image/index.js +36 -9
  149. package/lib/image/models/image.js +109 -66
  150. package/lib/image/models/index.js +3 -0
  151. package/lib/index.js +61 -7
  152. package/lib/line/index.js +40 -9
  153. package/lib/line/models/arc.js +124 -62
  154. package/lib/line/models/arc_3d.js +113 -56
  155. package/lib/line/models/earthArc_3d.js +115 -58
  156. package/lib/line/models/flow.js +70 -36
  157. package/lib/line/models/great_circle.js +104 -53
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +146 -84
  160. package/lib/line/models/linearline.js +88 -43
  161. package/lib/line/models/simpleLine.js +79 -39
  162. package/lib/line/models/wall.js +103 -52
  163. package/lib/mask/index.js +36 -9
  164. package/lib/mask/models/fill.js +63 -29
  165. package/lib/mask/models/index.js +3 -0
  166. package/lib/plugins/DataMappingPlugin.js +125 -78
  167. package/lib/plugins/DataSourcePlugin.js +76 -45
  168. package/lib/plugins/FeatureScalePlugin.js +138 -67
  169. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  170. package/lib/plugins/LayerMaskPlugin.js +17 -4
  171. package/lib/plugins/LayerModelPlugin.js +117 -70
  172. package/lib/plugins/LayerStylePlugin.js +14 -4
  173. package/lib/plugins/LightingPlugin.js +25 -12
  174. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  175. package/lib/plugins/PixelPickingPlugin.js +27 -12
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  177. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  178. package/lib/plugins/UpdateModelPlugin.js +10 -1
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  180. package/lib/point/index.js +83 -26
  181. package/lib/point/models/earthExtrude.js +106 -58
  182. package/lib/point/models/earthFill.js +110 -52
  183. package/lib/point/models/extrude.js +103 -57
  184. package/lib/point/models/fill.js +90 -54
  185. package/lib/point/models/fillmage.js +107 -58
  186. package/lib/point/models/image.js +92 -47
  187. package/lib/point/models/index.js +12 -1
  188. package/lib/point/models/normal.js +64 -30
  189. package/lib/point/models/radar.js +72 -38
  190. package/lib/point/models/simplePoint.js +72 -38
  191. package/lib/point/models/text.js +305 -199
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +146 -87
  195. package/lib/polygon/models/fill.js +89 -50
  196. package/lib/polygon/models/index.js +14 -2
  197. package/lib/polygon/models/ocean.js +88 -42
  198. package/lib/polygon/models/water.js +82 -37
  199. package/lib/raster/buffers/triangulation.js +7 -3
  200. package/lib/raster/index.js +40 -9
  201. package/lib/raster/models/index.js +5 -0
  202. package/lib/raster/models/raster.js +125 -80
  203. package/lib/raster/models/rasterRgb.js +139 -84
  204. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  205. package/lib/tile/interaction/getRasterData.js +25 -14
  206. package/lib/tile/interaction/utils.js +19 -7
  207. package/lib/tile/manager/base.js +104 -63
  208. package/lib/tile/service/TileLayerService.js +60 -33
  209. package/lib/tile/service/TilePickService.js +48 -26
  210. package/lib/tile/service/TileSourceService.js +16 -2
  211. package/lib/tile/style/utils.js +3 -0
  212. package/lib/tile/tileFactory/DebugTile.js +54 -29
  213. package/lib/tile/tileFactory/ImageTile.js +46 -20
  214. package/lib/tile/tileFactory/MaskTile.js +51 -22
  215. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  217. package/lib/tile/tileFactory/RasterTile.js +63 -30
  218. package/lib/tile/tileFactory/Tile.js +102 -63
  219. package/lib/tile/tileFactory/VectorTile.js +76 -41
  220. package/lib/tile/tileFactory/index.js +25 -0
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  222. package/lib/tile/tileFactory/util.js +9 -0
  223. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  224. package/lib/tile/utils.js +5 -1
  225. package/lib/utils/blend.js +5 -0
  226. package/lib/utils/collision-index.js +25 -9
  227. package/lib/utils/extrude_polyline.js +181 -101
  228. package/lib/utils/grid-index.js +28 -2
  229. package/lib/utils/identityScale.js +9 -0
  230. package/lib/utils/layerData.js +49 -30
  231. package/lib/utils/multiPassRender.js +16 -11
  232. package/lib/utils/polylineNormal.js +66 -31
  233. package/lib/utils/simpleLine.js +21 -2
  234. package/lib/utils/stencil.js +4 -0
  235. package/lib/utils/symbol-layout.js +55 -27
  236. package/lib/wind/index.js +37 -9
  237. package/lib/wind/models/index.js +3 -0
  238. package/lib/wind/models/utils.js +62 -26
  239. package/lib/wind/models/wind.js +157 -101
  240. package/lib/wind/models/windRender.js +71 -53
  241. package/lib/wind/models/windShader.js +1 -0
  242. package/package.json +7 -7
@@ -1,43 +1,70 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.TextTrianglation = TextTrianglation;
8
9
  exports.default = void 0;
10
+
9
11
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
+
10
13
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
14
+
11
15
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
+
12
17
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
18
+
13
19
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
20
+
14
21
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
22
+
15
23
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
24
+
16
25
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
26
+
17
27
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
28
+
18
29
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
30
+
19
31
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
32
+
20
33
  var _l7Core = require("@antv/l7-core");
34
+
21
35
  var _l7Utils = require("@antv/l7-utils");
36
+
22
37
  var _lodash = require("lodash");
38
+
23
39
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
40
+
24
41
  var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
42
+
25
43
  var _symbolLayout = require("../../utils/symbol-layout");
44
+
26
45
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
46
+
27
47
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
48
+
49
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
50
+
29
51
  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); }; }
52
+
30
53
  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; } }
54
+
31
55
  /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
32
56
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
57
+
33
58
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
34
59
  var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\n// uniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
60
+
35
61
  function TextTrianglation(feature) {
36
62
  // @ts-ignore
37
63
  var that = this;
38
64
  var id = feature.id;
39
65
  var vertices = [];
40
66
  var indices = [];
67
+
41
68
  if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
42
69
  return {
43
70
  vertices: [],
@@ -46,7 +73,9 @@ function TextTrianglation(feature) {
46
73
  size: 7
47
74
  };
48
75
  }
76
+
49
77
  var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
78
+
50
79
  var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
51
80
  that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
52
81
  vertices.push.apply(vertices, (0, _toConsumableArray2.default)(coord).concat([quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y]));
@@ -59,15 +88,21 @@ function TextTrianglation(feature) {
59
88
  size: 7
60
89
  };
61
90
  }
91
+
62
92
  var TextModel = /*#__PURE__*/function (_BaseModel) {
63
93
  (0, _inherits2.default)(TextModel, _BaseModel);
94
+
64
95
  var _super = _createSuper(TextModel);
96
+
65
97
  function TextModel() {
66
98
  var _this;
99
+
67
100
  (0, _classCallCheck2.default)(this, TextModel);
101
+
68
102
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
69
103
  args[_key] = arguments[_key];
70
104
  }
105
+
71
106
  _this = _super.call.apply(_super, [this].concat(args));
72
107
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "glyphInfoMap", {});
73
108
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "currentZoom", -1);
@@ -76,42 +111,52 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
76
111
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preTextStyle", {});
77
112
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapping", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
78
113
  return _regenerator.default.wrap(function _callee$(_context) {
79
- while (1) switch (_context.prev = _context.next) {
80
- case 0:
81
- _this.initGlyph(); //
82
- _this.updateTexture();
83
- _context.next = 4;
84
- return _this.reBuildModel();
85
- case 4:
86
- case "end":
87
- return _context.stop();
114
+ while (1) {
115
+ switch (_context.prev = _context.next) {
116
+ case 0:
117
+ _this.initGlyph(); //
118
+
119
+
120
+ _this.updateTexture();
121
+
122
+ _context.next = 4;
123
+ return _this.reBuildModel();
124
+
125
+ case 4:
126
+ case "end":
127
+ return _context.stop();
128
+ }
88
129
  }
89
130
  }, _callee);
90
131
  })));
91
132
  return _this;
92
133
  }
134
+
93
135
  (0, _createClass2.default)(TextModel, [{
94
136
  key: "getUninforms",
95
137
  value: function getUninforms() {
96
138
  var _ref2 = this.layer.getLayerConfig(),
97
- _ref2$opacity = _ref2.opacity,
98
- opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
99
- _ref2$stroke = _ref2.stroke,
100
- stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
101
- _ref2$strokeWidth = _ref2.strokeWidth,
102
- strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
103
- _ref2$halo = _ref2.halo,
104
- halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
105
- _ref2$gamma = _ref2.gamma,
106
- gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
107
- _ref2$raisingHeight = _ref2.raisingHeight,
108
- raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
139
+ _ref2$opacity = _ref2.opacity,
140
+ opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
141
+ _ref2$stroke = _ref2.stroke,
142
+ stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
143
+ _ref2$strokeWidth = _ref2.strokeWidth,
144
+ strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
145
+ _ref2$halo = _ref2.halo,
146
+ halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
147
+ _ref2$gamma = _ref2.gamma,
148
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
149
+ _ref2$raisingHeight = _ref2.raisingHeight,
150
+ raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
151
+
109
152
  var mapping = this.getFontServiceMapping();
110
153
  var canvas = this.getFontServiceCanvas();
154
+
111
155
  if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
112
156
  this.updateTexture();
113
157
  this.textCount = Object.keys(mapping).length;
114
158
  }
159
+
115
160
  this.preTextStyle = this.getTextStyle();
116
161
  return (0, _objectSpread2.default)({
117
162
  u_raisingHeight: Number(raisingHeight),
@@ -129,23 +174,28 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
129
174
  value: function () {
130
175
  var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
131
176
  return _regenerator.default.wrap(function _callee2$(_context2) {
132
- while (1) switch (_context2.prev = _context2.next) {
133
- case 0:
134
- // 绑定事件
135
- this.bindEvent();
136
- this.extent = this.textExtent();
137
- this.rawEncodeData = this.layer.getEncodedData();
138
- this.preTextStyle = this.getTextStyle();
139
- return _context2.abrupt("return", this.buildModels());
140
- case 5:
141
- case "end":
142
- return _context2.stop();
177
+ while (1) {
178
+ switch (_context2.prev = _context2.next) {
179
+ case 0:
180
+ // 绑定事件
181
+ this.bindEvent();
182
+ this.extent = this.textExtent();
183
+ this.rawEncodeData = this.layer.getEncodedData();
184
+ this.preTextStyle = this.getTextStyle();
185
+ return _context2.abrupt("return", this.buildModels());
186
+
187
+ case 5:
188
+ case "end":
189
+ return _context2.stop();
190
+ }
143
191
  }
144
192
  }, _callee2, this);
145
193
  }));
194
+
146
195
  function initModels() {
147
196
  return _initModels.apply(this, arguments);
148
197
  }
198
+
149
199
  return initModels;
150
200
  }()
151
201
  }, {
@@ -153,38 +203,49 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
153
203
  value: function () {
154
204
  var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
155
205
  var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
206
+
156
207
  return _regenerator.default.wrap(function _callee3$(_context3) {
157
- while (1) switch (_context3.prev = _context3.next) {
158
- case 0:
159
- _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
160
- this.initGlyph(); //
161
- this.updateTexture();
162
- if (!textAllowOverlap) {
163
- this.filterGlyphs();
164
- }
165
- _context3.next = 6;
166
- return this.layer.buildLayerModel({
167
- moduleName: 'pointText',
168
- vertexShader: textVert,
169
- fragmentShader: textFrag,
170
- inject: this.getInject(),
171
- triangulation: TextTrianglation.bind(this),
172
- depth: {
173
- enable: false
208
+ while (1) {
209
+ switch (_context3.prev = _context3.next) {
210
+ case 0:
211
+ _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
212
+
213
+ this.initGlyph(); //
214
+
215
+ this.updateTexture();
216
+
217
+ if (!textAllowOverlap) {
218
+ this.filterGlyphs();
174
219
  }
175
- });
176
- case 6:
177
- model = _context3.sent;
178
- return _context3.abrupt("return", [model]);
179
- case 8:
180
- case "end":
181
- return _context3.stop();
220
+
221
+ _context3.next = 6;
222
+ return this.layer.buildLayerModel({
223
+ moduleName: 'pointText',
224
+ vertexShader: textVert,
225
+ fragmentShader: textFrag,
226
+ inject: this.getInject(),
227
+ triangulation: TextTrianglation.bind(this),
228
+ depth: {
229
+ enable: false
230
+ }
231
+ });
232
+
233
+ case 6:
234
+ model = _context3.sent;
235
+ return _context3.abrupt("return", [model]);
236
+
237
+ case 8:
238
+ case "end":
239
+ return _context3.stop();
240
+ }
182
241
  }
183
242
  }, _callee3, this);
184
243
  }));
244
+
185
245
  function buildModels() {
186
246
  return _buildModels.apply(this, arguments);
187
247
  }
248
+
188
249
  return buildModels;
189
250
  }() // 需要更新的场景
190
251
  // 1. 文本偏移量发生改变
@@ -192,61 +253,79 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
192
253
  // 3. 文本允许重叠发生改变
193
254
  // 4. 文本字体发生改变
194
255
  // 5. 文本字体粗细发生改变
256
+
195
257
  }, {
196
258
  key: "needUpdate",
197
259
  value: function () {
198
260
  var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
199
261
  var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
262
+
200
263
  return _regenerator.default.wrap(function _callee4$(_context4) {
201
- while (1) switch (_context4.prev = _context4.next) {
202
- case 0:
203
- _ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
204
- if (!(!(0, _lodash.isEqual)(padding, this.preTextStyle.padding) || !(0, _lodash.isEqual)(textOffset, this.preTextStyle.textOffset) || !(0, _lodash.isEqual)(textAnchor, this.preTextStyle.textAnchor) || !(0, _lodash.isEqual)(fontFamily, this.preTextStyle.fontFamily) || !(0, _lodash.isEqual)(fontWeight, this.preTextStyle.fontWeight))) {
205
- _context4.next = 5;
206
- break;
207
- }
208
- _context4.next = 4;
209
- return this.mapping();
210
- case 4:
211
- return _context4.abrupt("return", true);
212
- case 5:
213
- if (!textAllowOverlap) {
214
- _context4.next = 7;
215
- break;
216
- }
217
- return _context4.abrupt("return", false);
218
- case 7:
219
- // textAllowOverlap 发生改变
220
- zoom = this.mapService.getZoom();
221
- extent = this.mapService.getBounds();
222
- flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
223
- if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
224
- _context4.next = 14;
225
- break;
226
- }
227
- _context4.next = 13;
228
- return this.reBuildModel();
229
- case 13:
230
- return _context4.abrupt("return", true);
231
- case 14:
232
- return _context4.abrupt("return", false);
233
- case 15:
234
- case "end":
235
- return _context4.stop();
264
+ while (1) {
265
+ switch (_context4.prev = _context4.next) {
266
+ case 0:
267
+ _ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
268
+
269
+ if (!(!(0, _lodash.isEqual)(padding, this.preTextStyle.padding) || !(0, _lodash.isEqual)(textOffset, this.preTextStyle.textOffset) || !(0, _lodash.isEqual)(textAnchor, this.preTextStyle.textAnchor) || !(0, _lodash.isEqual)(fontFamily, this.preTextStyle.fontFamily) || !(0, _lodash.isEqual)(fontWeight, this.preTextStyle.fontWeight))) {
270
+ _context4.next = 5;
271
+ break;
272
+ }
273
+
274
+ _context4.next = 4;
275
+ return this.mapping();
276
+
277
+ case 4:
278
+ return _context4.abrupt("return", true);
279
+
280
+ case 5:
281
+ if (!textAllowOverlap) {
282
+ _context4.next = 7;
283
+ break;
284
+ }
285
+
286
+ return _context4.abrupt("return", false);
287
+
288
+ case 7:
289
+ // textAllowOverlap 发生改变
290
+ zoom = this.mapService.getZoom();
291
+ extent = this.mapService.getBounds();
292
+ flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
293
+
294
+ if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
295
+ _context4.next = 14;
296
+ break;
297
+ }
298
+
299
+ _context4.next = 13;
300
+ return this.reBuildModel();
301
+
302
+ case 13:
303
+ return _context4.abrupt("return", true);
304
+
305
+ case 14:
306
+ return _context4.abrupt("return", false);
307
+
308
+ case 15:
309
+ case "end":
310
+ return _context4.stop();
311
+ }
236
312
  }
237
313
  }, _callee4, this);
238
314
  }));
315
+
239
316
  function needUpdate() {
240
317
  return _needUpdate.apply(this, arguments);
241
318
  }
319
+
242
320
  return needUpdate;
243
321
  }()
244
322
  }, {
245
323
  key: "clearModels",
246
324
  value: function clearModels() {
247
325
  var _this$texture;
248
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
249
- // TODO this.mapping
326
+
327
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy(); // TODO this.mapping
328
+
250
329
  this.layer.off('remapping', this.mapping);
251
330
  }
252
331
  }, {
@@ -265,7 +344,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
265
344
  size: 1,
266
345
  update: function update(feature) {
267
346
  var _feature$rotate = feature.rotate,
268
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
347
+ rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
269
348
  return Array.isArray(rotate) ? [rotate[0]] : [rotate];
270
349
  }
271
350
  }
@@ -287,9 +366,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
287
366
  return [vertex[5], vertex[6]];
288
367
  }
289
368
  }
290
- });
369
+ }); // point layer size;
291
370
 
292
- // point layer size;
293
371
  this.styleAttributeService.registerStyleAttribute({
294
372
  name: 'size',
295
373
  type: _l7Core.AttributeType.Attribute,
@@ -304,7 +382,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
304
382
  size: 1,
305
383
  update: function update(feature) {
306
384
  var _feature$size = feature.size,
307
- size = _feature$size === void 0 ? 12 : _feature$size;
385
+ size = _feature$size === void 0 ? 12 : _feature$size;
308
386
  return Array.isArray(size) ? [size[0]] : [size];
309
387
  }
310
388
  }
@@ -343,23 +421,28 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
343
421
  /**
344
422
  * 生成文字纹理(生成文字纹理字典)
345
423
  */
424
+
346
425
  }, {
347
426
  key: "initTextFont",
348
427
  value: function initTextFont() {
349
428
  var _this$getTextStyle = this.getTextStyle(),
350
- fontWeight = _this$getTextStyle.fontWeight,
351
- fontFamily = _this$getTextStyle.fontFamily;
429
+ fontWeight = _this$getTextStyle.fontWeight,
430
+ fontFamily = _this$getTextStyle.fontFamily;
431
+
352
432
  var data = this.rawEncodeData;
353
433
  var characterSet = [];
354
434
  data.forEach(function (item) {
355
435
  var _item$shape = item.shape,
356
- shape = _item$shape === void 0 ? '' : _item$shape;
436
+ shape = _item$shape === void 0 ? '' : _item$shape;
357
437
  shape = shape.toString();
438
+
358
439
  var _iterator = _createForOfIteratorHelper(shape),
359
- _step;
440
+ _step;
441
+
360
442
  try {
361
443
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
362
444
  var char = _step.value;
445
+
363
446
  // 去重
364
447
  if (characterSet.indexOf(char) === -1) {
365
448
  characterSet.push(char);
@@ -378,22 +461,24 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
378
461
  iconfont: false
379
462
  });
380
463
  }
381
-
382
464
  /**
383
465
  * 生成 iconfont 纹理字典
384
466
  */
467
+
385
468
  }, {
386
469
  key: "initIconFontTex",
387
470
  value: function initIconFontTex() {
388
471
  var _this$getTextStyle2 = this.getTextStyle(),
389
- fontWeight = _this$getTextStyle2.fontWeight,
390
- fontFamily = _this$getTextStyle2.fontFamily;
472
+ fontWeight = _this$getTextStyle2.fontWeight,
473
+ fontFamily = _this$getTextStyle2.fontFamily;
474
+
391
475
  var data = this.rawEncodeData;
392
476
  var characterSet = [];
393
477
  data.forEach(function (item) {
394
478
  var _item$shape2 = item.shape,
395
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
479
+ shape = _item$shape2 === void 0 ? '' : _item$shape2;
396
480
  shape = "".concat(shape);
481
+
397
482
  if (characterSet.indexOf(shape) === -1) {
398
483
  characterSet.push(shape);
399
484
  }
@@ -409,26 +494,27 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
409
494
  key: "getTextStyle",
410
495
  value: function getTextStyle() {
411
496
  var _ref5 = this.layer.getLayerConfig(),
412
- _ref5$fontWeight = _ref5.fontWeight,
413
- fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
414
- _ref5$fontFamily = _ref5.fontFamily,
415
- fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
416
- _ref5$textAllowOverla = _ref5.textAllowOverlap,
417
- textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
418
- _ref5$padding = _ref5.padding,
419
- padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
420
- _ref5$textAnchor = _ref5.textAnchor,
421
- textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
422
- _ref5$textOffset = _ref5.textOffset,
423
- textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
424
- _ref5$opacity = _ref5.opacity,
425
- opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
426
- _ref5$strokeOpacity = _ref5.strokeOpacity,
427
- strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
428
- _ref5$strokeWidth = _ref5.strokeWidth,
429
- strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
430
- _ref5$stroke = _ref5.stroke,
431
- stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
497
+ _ref5$fontWeight = _ref5.fontWeight,
498
+ fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
499
+ _ref5$fontFamily = _ref5.fontFamily,
500
+ fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
501
+ _ref5$textAllowOverla = _ref5.textAllowOverlap,
502
+ textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
503
+ _ref5$padding = _ref5.padding,
504
+ padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
505
+ _ref5$textAnchor = _ref5.textAnchor,
506
+ textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
507
+ _ref5$textOffset = _ref5.textOffset,
508
+ textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
509
+ _ref5$opacity = _ref5.opacity,
510
+ opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
511
+ _ref5$strokeOpacity = _ref5.strokeOpacity,
512
+ strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
513
+ _ref5$strokeWidth = _ref5.strokeWidth,
514
+ strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
515
+ _ref5$stroke = _ref5.stroke,
516
+ stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
517
+
432
518
  return {
433
519
  fontWeight: fontWeight,
434
520
  fontFamily: fontFamily,
@@ -442,41 +528,40 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
442
528
  stroke: stroke
443
529
  };
444
530
  }
445
-
446
531
  /**
447
532
  * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
448
533
  */
534
+
449
535
  }, {
450
536
  key: "generateGlyphLayout",
451
537
  value: function generateGlyphLayout(iconfont) {
452
538
  var _this2 = this;
539
+
453
540
  var mapping = this.getFontServiceMapping();
541
+
454
542
  var _ref6 = this.layer.getLayerConfig(),
455
- _ref6$spacing = _ref6.spacing,
456
- spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
457
- _ref6$textAnchor = _ref6.textAnchor,
458
- textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
459
- textOffset = _ref6.textOffset;
543
+ _ref6$spacing = _ref6.spacing,
544
+ spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
545
+ _ref6$textAnchor = _ref6.textAnchor,
546
+ textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
547
+ textOffset = _ref6.textOffset;
548
+
460
549
  var data = this.rawEncodeData;
461
550
  this.glyphInfo = data.map(function (feature) {
462
551
  var _feature$shape = feature.shape,
463
- shape = _feature$shape === void 0 ? '' : _feature$shape,
464
- id = feature.id,
465
- _feature$size2 = feature.size,
466
- size = _feature$size2 === void 0 ? 1 : _feature$size2;
467
- var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
468
- // @ts-ignore
469
- size, textAnchor, 'left', spacing, textOffset,
470
- // || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
552
+ shape = _feature$shape === void 0 ? '' : _feature$shape,
553
+ id = feature.id,
554
+ _feature$size2 = feature.size,
555
+ size = _feature$size2 === void 0 ? 1 : _feature$size2;
556
+ var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping, // @ts-ignore
557
+ size, textAnchor, 'left', spacing, textOffset, // || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
471
558
  iconfont);
472
559
  var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
473
560
  feature.shaping = shaping;
474
- feature.glyphQuads = glyphQuads;
475
- // feature.centroid = calculteCentroid(coordinates);
561
+ feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
476
562
 
477
- feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
563
+ feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid
478
564
 
479
- // 此时地图高德2.0 originCentroid == centroid
480
565
  feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
481
566
  _this2.glyphInfoMap[id] = {
482
567
  shaping: shaping,
@@ -490,66 +575,76 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
490
575
  key: "getFontServiceMapping",
491
576
  value: function getFontServiceMapping() {
492
577
  var _ref7 = this.layer.getLayerConfig(),
493
- _ref7$fontWeight = _ref7.fontWeight,
494
- fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
495
- _ref7$fontFamily = _ref7.fontFamily,
496
- fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
578
+ _ref7$fontWeight = _ref7.fontWeight,
579
+ fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
580
+ _ref7$fontFamily = _ref7.fontFamily,
581
+ fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
582
+
497
583
  return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
498
584
  }
499
585
  }, {
500
586
  key: "getFontServiceCanvas",
501
587
  value: function getFontServiceCanvas() {
502
588
  var _ref8 = this.layer.getLayerConfig(),
503
- _ref8$fontWeight = _ref8.fontWeight,
504
- fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
505
- _ref8$fontFamily = _ref8.fontFamily,
506
- fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily;
507
- // 更新文字布局
589
+ _ref8$fontWeight = _ref8.fontWeight,
590
+ fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
591
+ _ref8$fontFamily = _ref8.fontFamily,
592
+ fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily; // 更新文字布局
593
+
594
+
508
595
  return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
509
596
  }
510
-
511
597
  /**
512
598
  * 文字避让 depend on originCentorid
513
599
  */
600
+
514
601
  }, {
515
602
  key: "filterGlyphs",
516
603
  value: function filterGlyphs() {
517
604
  var _this3 = this;
605
+
518
606
  var _ref9 = this.layer.getLayerConfig(),
519
- _ref9$padding = _ref9.padding,
520
- padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
521
- _ref9$textAllowOverla = _ref9.textAllowOverlap,
522
- textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
607
+ _ref9$padding = _ref9.padding,
608
+ padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
609
+ _ref9$textAllowOverla = _ref9.textAllowOverlap,
610
+ textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
611
+
523
612
  if (textAllowOverlap) {
524
613
  // 如果允许文本覆盖
525
614
  return;
526
615
  }
616
+
527
617
  this.glyphInfoMap = {};
528
618
  this.currentZoom = this.mapService.getZoom();
529
619
  this.extent = this.textExtent();
620
+
530
621
  var _this$rendererService = this.rendererService.getViewportSize(),
531
- width = _this$rendererService.width,
532
- height = _this$rendererService.height;
622
+ width = _this$rendererService.width,
623
+ height = _this$rendererService.height;
624
+
533
625
  var collisionIndex = new _collisionIndex.default(width, height);
534
626
  var filterData = this.glyphInfo.filter(function (feature) {
535
627
  var shaping = feature.shaping,
536
- _feature$id = feature.id,
537
- id = _feature$id === void 0 ? 0 : _feature$id;
538
- // const centroid = feature.centroid as [number, number];
628
+ _feature$id = feature.id,
629
+ id = _feature$id === void 0 ? 0 : _feature$id; // const centroid = feature.centroid as [number, number];
539
630
  // const centroid = feature.originCentroid as [number, number];
631
+
540
632
  var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
541
633
  var size = feature.size;
542
634
  var fontScale = size / 16;
635
+
543
636
  var pixels = _this3.mapService.lngLatToContainer(centroid);
637
+
544
638
  var _collisionIndex$place = collisionIndex.placeCollisionBox({
545
- x1: shaping.left * fontScale - padding[0],
546
- x2: shaping.right * fontScale + padding[0],
547
- y1: shaping.top * fontScale - padding[1],
548
- y2: shaping.bottom * fontScale + padding[1],
549
- anchorPointX: pixels.x,
550
- anchorPointY: pixels.y
551
- }),
552
- box = _collisionIndex$place.box;
639
+ x1: shaping.left * fontScale - padding[0],
640
+ x2: shaping.right * fontScale + padding[0],
641
+ y1: shaping.top * fontScale - padding[1],
642
+ y2: shaping.bottom * fontScale + padding[1],
643
+ anchorPointX: pixels.x,
644
+ anchorPointY: pixels.y
645
+ }),
646
+ box = _collisionIndex$place.box;
647
+
553
648
  if (box && box.length) {
554
649
  collisionIndex.insertCollisionBox(box, id);
555
650
  return true;
@@ -560,35 +655,39 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
560
655
  filterData.forEach(function (item) {
561
656
  // @ts-ignore
562
657
  _this3.glyphInfoMap[item.id] = item;
563
- });
564
- // this.layer.setEncodedData(filterData);
658
+ }); // this.layer.setEncodedData(filterData);
565
659
  }
566
660
  /**
567
661
  * 初始化文字布局
568
662
  */
663
+
569
664
  }, {
570
665
  key: "initGlyph",
571
666
  value: function initGlyph() {
572
667
  var _this$layer$getLayerC = this.layer.getLayerConfig(),
573
- _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
574
- iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2;
575
- // 1.生成文字纹理(或是生成 iconfont)
576
- iconfont ? this.initIconFontTex() : this.initTextFont();
577
- // 2.生成文字布局
668
+ _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
669
+ iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
670
+
671
+
672
+ iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
673
+
578
674
  this.generateGlyphLayout(iconfont);
579
675
  }
580
676
  /**
581
677
  * 更新文字纹理
582
678
  */
679
+
583
680
  }, {
584
681
  key: "updateTexture",
585
682
  value: function updateTexture() {
586
683
  var createTexture2D = this.rendererService.createTexture2D;
587
684
  var canvas = this.getFontServiceCanvas();
588
685
  this.textureHeight = canvas.height;
686
+
589
687
  if (this.texture) {
590
688
  this.texture.destroy();
591
689
  }
690
+
592
691
  this.texture = createTexture2D({
593
692
  data: canvas,
594
693
  mag: _l7Core.gl.LINEAR,
@@ -603,36 +702,43 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
603
702
  var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
604
703
  var model;
605
704
  return _regenerator.default.wrap(function _callee5$(_context5) {
606
- while (1) switch (_context5.prev = _context5.next) {
607
- case 0:
608
- this.filterGlyphs();
609
- _context5.next = 3;
610
- return this.layer.buildLayerModel({
611
- moduleName: 'pointText',
612
- vertexShader: textVert,
613
- fragmentShader: textFrag,
614
- triangulation: TextTrianglation.bind(this),
615
- inject: this.getInject(),
616
- depth: {
617
- enable: false
618
- }
619
- });
620
- case 3:
621
- model = _context5.sent;
622
- // TODO 渲染流程待修改
623
- this.layer.models = [model];
624
- case 5:
625
- case "end":
626
- return _context5.stop();
705
+ while (1) {
706
+ switch (_context5.prev = _context5.next) {
707
+ case 0:
708
+ this.filterGlyphs();
709
+ _context5.next = 3;
710
+ return this.layer.buildLayerModel({
711
+ moduleName: 'pointText',
712
+ vertexShader: textVert,
713
+ fragmentShader: textFrag,
714
+ triangulation: TextTrianglation.bind(this),
715
+ inject: this.getInject(),
716
+ depth: {
717
+ enable: false
718
+ }
719
+ });
720
+
721
+ case 3:
722
+ model = _context5.sent;
723
+ // TODO 渲染流程待修改
724
+ this.layer.models = [model];
725
+
726
+ case 5:
727
+ case "end":
728
+ return _context5.stop();
729
+ }
627
730
  }
628
731
  }, _callee5, this);
629
732
  }));
733
+
630
734
  function reBuildModel() {
631
735
  return _reBuildModel.apply(this, arguments);
632
736
  }
737
+
633
738
  return reBuildModel;
634
739
  }()
635
740
  }]);
636
741
  return TextModel;
637
742
  }(_BaseModel2.default);
743
+
638
744
  exports.default = TextModel;