@antv/l7-layers 2.17.4 → 2.17.5

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 (250) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.js +325 -483
  10. package/es/core/BaseModel.js +51 -80
  11. package/es/core/CommonStyleAttribute.js +2 -5
  12. package/es/core/LayerPickService.js +21 -32
  13. package/es/core/TextureService.js +0 -13
  14. package/es/core/interface.js +17 -24
  15. package/es/core/shape/Path.js +13 -20
  16. package/es/core/shape/extrude.js +27 -39
  17. package/es/core/triangulation.js +99 -136
  18. package/es/earth/index.js +9 -33
  19. package/es/earth/models/atmosphere.js +30 -54
  20. package/es/earth/models/base.js +47 -85
  21. package/es/earth/models/bloomsphere.js +30 -54
  22. package/es/earth/utils.js +9 -13
  23. package/es/heatmap/index.js +10 -40
  24. package/es/heatmap/models/grid.js +28 -52
  25. package/es/heatmap/models/grid3d.js +28 -52
  26. package/es/heatmap/models/heatmap.js +92 -149
  27. package/es/heatmap/models/hexagon.js +28 -52
  28. package/es/heatmap/triangulation.js +0 -4
  29. package/es/image/index.js +9 -28
  30. package/es/image/models/image.js +66 -100
  31. package/es/index.js +9 -17
  32. package/es/line/index.js +9 -35
  33. package/es/line/models/arc.js +63 -112
  34. package/es/line/models/arc_3d.js +58 -102
  35. package/es/line/models/earthArc_3d.js +60 -105
  36. package/es/line/models/flow.js +36 -60
  37. package/es/line/models/great_circle.js +53 -94
  38. package/es/line/models/line.js +92 -144
  39. package/es/line/models/linearline.js +42 -74
  40. package/es/line/models/simpleLine.js +38 -67
  41. package/es/line/models/wall.js +52 -92
  42. package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
  43. package/es/line/shaders/line_frag.glsl +1 -3
  44. package/es/line/shaders/line_vert.glsl +2 -0
  45. package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
  46. package/es/mask/index.js +9 -28
  47. package/es/mask/models/fill.js +29 -54
  48. package/es/plugins/DataMappingPlugin.js +78 -114
  49. package/es/plugins/DataSourcePlugin.js +45 -68
  50. package/es/plugins/FeatureScalePlugin.js +67 -122
  51. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  52. package/es/plugins/LayerMaskPlugin.js +3 -11
  53. package/es/plugins/LayerModelPlugin.js +69 -118
  54. package/es/plugins/LayerStylePlugin.js +4 -9
  55. package/es/plugins/LightingPlugin.js +12 -18
  56. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  57. package/es/plugins/PixelPickingPlugin.js +12 -21
  58. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  59. package/es/plugins/ShaderUniformPlugin.js +13 -27
  60. package/es/plugins/UpdateModelPlugin.js +0 -5
  61. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  62. package/es/point/index.js +26 -78
  63. package/es/point/models/earthExtrude.js +58 -95
  64. package/es/point/models/earthFill.js +52 -80
  65. package/es/point/models/extrude.js +57 -94
  66. package/es/point/models/fill.js +56 -81
  67. package/es/point/models/fillmage.js +60 -100
  68. package/es/point/models/image.js +47 -83
  69. package/es/point/models/index.js +2 -2
  70. package/es/point/models/normal.js +30 -54
  71. package/es/point/models/radar.js +38 -63
  72. package/es/point/models/simplePoint.js +38 -62
  73. package/es/point/models/text.js +199 -296
  74. package/es/point/shape/extrude.js +4 -13
  75. package/es/polygon/index.js +11 -41
  76. package/es/polygon/models/extrude.js +87 -135
  77. package/es/polygon/models/fill.js +50 -79
  78. package/es/polygon/models/index.js +3 -2
  79. package/es/polygon/models/ocean.js +42 -76
  80. package/es/polygon/models/water.js +37 -71
  81. package/es/raster/buffers/triangulation.js +2 -4
  82. package/es/raster/index.js +9 -32
  83. package/es/raster/models/raster.js +80 -116
  84. package/es/raster/models/rasterRgb.js +84 -127
  85. package/es/raster/models/rasterTerrainRgb.js +56 -84
  86. package/es/tile/interaction/getRasterData.js +14 -20
  87. package/es/tile/interaction/utils.js +7 -9
  88. package/es/tile/manager/base.js +63 -96
  89. package/es/tile/service/TileLayerService.js +33 -55
  90. package/es/tile/service/TilePickService.js +26 -40
  91. package/es/tile/service/TileSourceService.js +3 -7
  92. package/es/tile/tileFactory/DebugTile.js +29 -46
  93. package/es/tile/tileFactory/ImageTile.js +20 -38
  94. package/es/tile/tileFactory/MaskTile.js +22 -43
  95. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  96. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  97. package/es/tile/tileFactory/RasterTile.js +30 -53
  98. package/es/tile/tileFactory/Tile.js +63 -97
  99. package/es/tile/tileFactory/VectorTile.js +41 -68
  100. package/es/tile/tileFactory/index.js +0 -11
  101. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  102. package/es/tile/tileFactory/util.js +0 -3
  103. package/es/tile/tileLayer/BaseLayer.js +105 -146
  104. package/es/tile/utils.js +1 -1
  105. package/es/utils/blend.js +0 -2
  106. package/es/utils/collision-index.js +9 -16
  107. package/es/utils/extrude_polyline.js +101 -149
  108. package/es/utils/grid-index.js +2 -27
  109. package/es/utils/identityScale.js +0 -8
  110. package/es/utils/layerData.js +30 -44
  111. package/es/utils/multiPassRender.js +11 -13
  112. package/es/utils/polylineNormal.js +31 -37
  113. package/es/utils/simpleLine.js +2 -16
  114. package/es/utils/stencil.js +2 -3
  115. package/es/utils/symbol-layout.js +27 -53
  116. package/es/wind/index.js +9 -29
  117. package/es/wind/models/utils.js +26 -51
  118. package/es/wind/models/wind.js +101 -147
  119. package/es/wind/models/windRender.js +53 -66
  120. package/lib/Geometry/index.js +9 -38
  121. package/lib/Geometry/models/billboard.js +51 -97
  122. package/lib/Geometry/models/index.js +0 -5
  123. package/lib/Geometry/models/plane.js +79 -151
  124. package/lib/Geometry/models/sprite.js +60 -127
  125. package/lib/canvas/index.js +10 -40
  126. package/lib/canvas/models/canvas.js +41 -101
  127. package/lib/canvas/models/index.js +0 -3
  128. package/lib/citybuliding/building.js +8 -35
  129. package/lib/citybuliding/models/build.js +57 -92
  130. package/lib/core/BaseLayer.js +325 -474
  131. package/lib/core/BaseModel.js +51 -90
  132. package/lib/core/CommonStyleAttribute.js +2 -7
  133. package/lib/core/LayerPickService.js +21 -37
  134. package/lib/core/TextureService.js +0 -16
  135. package/lib/core/interface.js +21 -31
  136. package/lib/core/schema.js +0 -1
  137. package/lib/core/shape/Path.js +14 -31
  138. package/lib/core/shape/extrude.js +27 -62
  139. package/lib/core/triangulation.js +98 -177
  140. package/lib/earth/index.js +9 -43
  141. package/lib/earth/models/atmosphere.js +30 -63
  142. package/lib/earth/models/base.js +47 -90
  143. package/lib/earth/models/bloomsphere.js +30 -63
  144. package/lib/earth/utils.js +7 -31
  145. package/lib/heatmap/index.js +10 -48
  146. package/lib/heatmap/models/grid.js +28 -60
  147. package/lib/heatmap/models/grid3d.js +28 -60
  148. package/lib/heatmap/models/heatmap.js +92 -166
  149. package/lib/heatmap/models/hexagon.js +28 -60
  150. package/lib/heatmap/models/index.js +0 -6
  151. package/lib/heatmap/triangulation.js +0 -5
  152. package/lib/image/index.js +9 -36
  153. package/lib/image/models/image.js +66 -109
  154. package/lib/image/models/index.js +0 -3
  155. package/lib/index.js +7 -61
  156. package/lib/line/index.js +9 -40
  157. package/lib/line/models/arc.js +61 -122
  158. package/lib/line/models/arc_3d.js +56 -113
  159. package/lib/line/models/earthArc_3d.js +58 -115
  160. package/lib/line/models/flow.js +36 -70
  161. package/lib/line/models/great_circle.js +53 -104
  162. package/lib/line/models/index.js +0 -11
  163. package/lib/line/models/line.js +90 -152
  164. package/lib/line/models/linearline.js +42 -86
  165. package/lib/line/models/simpleLine.js +38 -77
  166. package/lib/line/models/wall.js +52 -103
  167. package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
  168. package/lib/line/shaders/line_frag.glsl +1 -3
  169. package/lib/line/shaders/line_vert.glsl +2 -0
  170. package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
  171. package/lib/mask/index.js +9 -36
  172. package/lib/mask/models/fill.js +29 -63
  173. package/lib/mask/models/index.js +0 -3
  174. package/lib/plugins/DataMappingPlugin.js +78 -125
  175. package/lib/plugins/DataSourcePlugin.js +45 -76
  176. package/lib/plugins/FeatureScalePlugin.js +67 -138
  177. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  178. package/lib/plugins/LayerMaskPlugin.js +4 -17
  179. package/lib/plugins/LayerModelPlugin.js +70 -127
  180. package/lib/plugins/LayerStylePlugin.js +5 -14
  181. package/lib/plugins/LightingPlugin.js +12 -25
  182. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  183. package/lib/plugins/PixelPickingPlugin.js +12 -27
  184. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  185. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  186. package/lib/plugins/UpdateModelPlugin.js +1 -10
  187. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  188. package/lib/point/index.js +26 -83
  189. package/lib/point/models/earthExtrude.js +58 -106
  190. package/lib/point/models/earthFill.js +52 -110
  191. package/lib/point/models/extrude.js +57 -103
  192. package/lib/point/models/fill.js +54 -90
  193. package/lib/point/models/fillmage.js +58 -107
  194. package/lib/point/models/image.js +47 -92
  195. package/lib/point/models/index.js +1 -12
  196. package/lib/point/models/normal.js +30 -64
  197. package/lib/point/models/radar.js +38 -72
  198. package/lib/point/models/simplePoint.js +38 -72
  199. package/lib/point/models/text.js +199 -305
  200. package/lib/point/shape/extrude.js +4 -20
  201. package/lib/polygon/index.js +11 -48
  202. package/lib/polygon/models/extrude.js +87 -146
  203. package/lib/polygon/models/fill.js +50 -89
  204. package/lib/polygon/models/index.js +2 -14
  205. package/lib/polygon/models/ocean.js +42 -88
  206. package/lib/polygon/models/water.js +37 -82
  207. package/lib/raster/buffers/triangulation.js +3 -7
  208. package/lib/raster/index.js +9 -40
  209. package/lib/raster/models/index.js +0 -5
  210. package/lib/raster/models/raster.js +80 -125
  211. package/lib/raster/models/rasterRgb.js +84 -139
  212. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  213. package/lib/tile/interaction/getRasterData.js +14 -25
  214. package/lib/tile/interaction/utils.js +7 -19
  215. package/lib/tile/manager/base.js +63 -104
  216. package/lib/tile/service/TileLayerService.js +33 -60
  217. package/lib/tile/service/TilePickService.js +26 -48
  218. package/lib/tile/service/TileSourceService.js +2 -16
  219. package/lib/tile/style/utils.js +0 -3
  220. package/lib/tile/tileFactory/DebugTile.js +29 -54
  221. package/lib/tile/tileFactory/ImageTile.js +20 -46
  222. package/lib/tile/tileFactory/MaskTile.js +22 -51
  223. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  224. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  225. package/lib/tile/tileFactory/RasterTile.js +30 -63
  226. package/lib/tile/tileFactory/Tile.js +63 -102
  227. package/lib/tile/tileFactory/VectorTile.js +41 -76
  228. package/lib/tile/tileFactory/index.js +0 -25
  229. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  230. package/lib/tile/tileFactory/util.js +0 -9
  231. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  232. package/lib/tile/utils.js +1 -5
  233. package/lib/utils/blend.js +0 -5
  234. package/lib/utils/collision-index.js +9 -25
  235. package/lib/utils/extrude_polyline.js +101 -181
  236. package/lib/utils/grid-index.js +2 -28
  237. package/lib/utils/identityScale.js +0 -9
  238. package/lib/utils/layerData.js +30 -49
  239. package/lib/utils/multiPassRender.js +11 -16
  240. package/lib/utils/polylineNormal.js +31 -66
  241. package/lib/utils/simpleLine.js +2 -21
  242. package/lib/utils/stencil.js +0 -4
  243. package/lib/utils/symbol-layout.js +27 -55
  244. package/lib/wind/index.js +9 -37
  245. package/lib/wind/models/index.js +0 -3
  246. package/lib/wind/models/utils.js +26 -62
  247. package/lib/wind/models/wind.js +101 -157
  248. package/lib/wind/models/windRender.js +53 -71
  249. package/lib/wind/models/windShader.js +0 -1
  250. package/package.json +7 -7
@@ -1,70 +1,43 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.TextTrianglation = TextTrianglation;
9
8
  exports.default = void 0;
10
-
11
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
-
13
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
14
-
15
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
-
17
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
18
-
19
13
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
20
-
21
14
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
22
-
23
15
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
24
-
25
16
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
26
-
27
17
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
28
-
29
18
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
30
-
31
19
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
32
-
33
20
  var _l7Core = require("@antv/l7-core");
34
-
35
21
  var _l7Utils = require("@antv/l7-utils");
36
-
37
22
  var _lodash = require("lodash");
38
-
39
23
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
40
-
41
24
  var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
42
-
43
25
  var _symbolLayout = require("../../utils/symbol-layout");
44
-
45
26
  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
-
47
27
  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); }
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
-
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; }
51
29
  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
-
53
30
  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
-
55
31
  /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
56
32
  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
-
58
33
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
59
34
  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
-
61
35
  function TextTrianglation(feature) {
62
36
  // @ts-ignore
63
37
  var that = this;
64
38
  var id = feature.id;
65
39
  var vertices = [];
66
40
  var indices = [];
67
-
68
41
  if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
69
42
  return {
70
43
  vertices: [],
@@ -73,9 +46,7 @@ function TextTrianglation(feature) {
73
46
  size: 7
74
47
  };
75
48
  }
76
-
77
49
  var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
78
-
79
50
  var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
80
51
  that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
81
52
  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]));
@@ -88,21 +59,15 @@ function TextTrianglation(feature) {
88
59
  size: 7
89
60
  };
90
61
  }
91
-
92
62
  var TextModel = /*#__PURE__*/function (_BaseModel) {
93
63
  (0, _inherits2.default)(TextModel, _BaseModel);
94
-
95
64
  var _super = _createSuper(TextModel);
96
-
97
65
  function TextModel() {
98
66
  var _this;
99
-
100
67
  (0, _classCallCheck2.default)(this, TextModel);
101
-
102
68
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
103
69
  args[_key] = arguments[_key];
104
70
  }
105
-
106
71
  _this = _super.call.apply(_super, [this].concat(args));
107
72
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "glyphInfoMap", {});
108
73
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "currentZoom", -1);
@@ -111,52 +76,42 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
111
76
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preTextStyle", {});
112
77
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapping", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
113
78
  return _regenerator.default.wrap(function _callee$(_context) {
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
- }
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();
129
88
  }
130
89
  }, _callee);
131
90
  })));
132
91
  return _this;
133
92
  }
134
-
135
93
  (0, _createClass2.default)(TextModel, [{
136
94
  key: "getUninforms",
137
95
  value: function getUninforms() {
138
96
  var _ref2 = this.layer.getLayerConfig(),
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
-
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;
152
109
  var mapping = this.getFontServiceMapping();
153
110
  var canvas = this.getFontServiceCanvas();
154
-
155
111
  if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
156
112
  this.updateTexture();
157
113
  this.textCount = Object.keys(mapping).length;
158
114
  }
159
-
160
115
  this.preTextStyle = this.getTextStyle();
161
116
  return (0, _objectSpread2.default)({
162
117
  u_raisingHeight: Number(raisingHeight),
@@ -174,28 +129,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
174
129
  value: function () {
175
130
  var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
176
131
  return _regenerator.default.wrap(function _callee2$(_context2) {
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
- }
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();
191
143
  }
192
144
  }, _callee2, this);
193
145
  }));
194
-
195
146
  function initModels() {
196
147
  return _initModels.apply(this, arguments);
197
148
  }
198
-
199
149
  return initModels;
200
150
  }()
201
151
  }, {
@@ -203,49 +153,38 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
203
153
  value: function () {
204
154
  var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
205
155
  var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
206
-
207
156
  return _regenerator.default.wrap(function _callee3$(_context3) {
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();
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
219
174
  }
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
- }
175
+ });
176
+ case 6:
177
+ model = _context3.sent;
178
+ return _context3.abrupt("return", [model]);
179
+ case 8:
180
+ case "end":
181
+ return _context3.stop();
241
182
  }
242
183
  }, _callee3, this);
243
184
  }));
244
-
245
185
  function buildModels() {
246
186
  return _buildModels.apply(this, arguments);
247
187
  }
248
-
249
188
  return buildModels;
250
189
  }() // 需要更新的场景
251
190
  // 1. 文本偏移量发生改变
@@ -253,79 +192,61 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
253
192
  // 3. 文本允许重叠发生改变
254
193
  // 4. 文本字体发生改变
255
194
  // 5. 文本字体粗细发生改变
256
-
257
195
  }, {
258
196
  key: "needUpdate",
259
197
  value: function () {
260
198
  var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
261
199
  var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
262
-
263
200
  return _regenerator.default.wrap(function _callee4$(_context4) {
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
- }
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();
312
236
  }
313
237
  }, _callee4, this);
314
238
  }));
315
-
316
239
  function needUpdate() {
317
240
  return _needUpdate.apply(this, arguments);
318
241
  }
319
-
320
242
  return needUpdate;
321
243
  }()
322
244
  }, {
323
245
  key: "clearModels",
324
246
  value: function clearModels() {
325
247
  var _this$texture;
326
-
327
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy(); // TODO this.mapping
328
-
248
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
249
+ // TODO this.mapping
329
250
  this.layer.off('remapping', this.mapping);
330
251
  }
331
252
  }, {
@@ -344,7 +265,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
344
265
  size: 1,
345
266
  update: function update(feature) {
346
267
  var _feature$rotate = feature.rotate,
347
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
268
+ rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
348
269
  return Array.isArray(rotate) ? [rotate[0]] : [rotate];
349
270
  }
350
271
  }
@@ -366,8 +287,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
366
287
  return [vertex[5], vertex[6]];
367
288
  }
368
289
  }
369
- }); // point layer size;
290
+ });
370
291
 
292
+ // point layer size;
371
293
  this.styleAttributeService.registerStyleAttribute({
372
294
  name: 'size',
373
295
  type: _l7Core.AttributeType.Attribute,
@@ -382,7 +304,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
382
304
  size: 1,
383
305
  update: function update(feature) {
384
306
  var _feature$size = feature.size,
385
- size = _feature$size === void 0 ? 12 : _feature$size;
307
+ size = _feature$size === void 0 ? 12 : _feature$size;
386
308
  return Array.isArray(size) ? [size[0]] : [size];
387
309
  }
388
310
  }
@@ -421,28 +343,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
421
343
  /**
422
344
  * 生成文字纹理(生成文字纹理字典)
423
345
  */
424
-
425
346
  }, {
426
347
  key: "initTextFont",
427
348
  value: function initTextFont() {
428
349
  var _this$getTextStyle = this.getTextStyle(),
429
- fontWeight = _this$getTextStyle.fontWeight,
430
- fontFamily = _this$getTextStyle.fontFamily;
431
-
350
+ fontWeight = _this$getTextStyle.fontWeight,
351
+ fontFamily = _this$getTextStyle.fontFamily;
432
352
  var data = this.rawEncodeData;
433
353
  var characterSet = [];
434
354
  data.forEach(function (item) {
435
355
  var _item$shape = item.shape,
436
- shape = _item$shape === void 0 ? '' : _item$shape;
356
+ shape = _item$shape === void 0 ? '' : _item$shape;
437
357
  shape = shape.toString();
438
-
439
358
  var _iterator = _createForOfIteratorHelper(shape),
440
- _step;
441
-
359
+ _step;
442
360
  try {
443
361
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
444
362
  var char = _step.value;
445
-
446
363
  // 去重
447
364
  if (characterSet.indexOf(char) === -1) {
448
365
  characterSet.push(char);
@@ -461,24 +378,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
461
378
  iconfont: false
462
379
  });
463
380
  }
381
+
464
382
  /**
465
383
  * 生成 iconfont 纹理字典
466
384
  */
467
-
468
385
  }, {
469
386
  key: "initIconFontTex",
470
387
  value: function initIconFontTex() {
471
388
  var _this$getTextStyle2 = this.getTextStyle(),
472
- fontWeight = _this$getTextStyle2.fontWeight,
473
- fontFamily = _this$getTextStyle2.fontFamily;
474
-
389
+ fontWeight = _this$getTextStyle2.fontWeight,
390
+ fontFamily = _this$getTextStyle2.fontFamily;
475
391
  var data = this.rawEncodeData;
476
392
  var characterSet = [];
477
393
  data.forEach(function (item) {
478
394
  var _item$shape2 = item.shape,
479
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
395
+ shape = _item$shape2 === void 0 ? '' : _item$shape2;
480
396
  shape = "".concat(shape);
481
-
482
397
  if (characterSet.indexOf(shape) === -1) {
483
398
  characterSet.push(shape);
484
399
  }
@@ -494,27 +409,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
494
409
  key: "getTextStyle",
495
410
  value: function getTextStyle() {
496
411
  var _ref5 = this.layer.getLayerConfig(),
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
-
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;
518
432
  return {
519
433
  fontWeight: fontWeight,
520
434
  fontFamily: fontFamily,
@@ -528,40 +442,41 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
528
442
  stroke: stroke
529
443
  };
530
444
  }
445
+
531
446
  /**
532
447
  * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
533
448
  */
534
-
535
449
  }, {
536
450
  key: "generateGlyphLayout",
537
451
  value: function generateGlyphLayout(iconfont) {
538
452
  var _this2 = this;
539
-
540
453
  var mapping = this.getFontServiceMapping();
541
-
542
454
  var _ref6 = this.layer.getLayerConfig(),
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
-
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;
549
460
  var data = this.rawEncodeData;
550
461
  this.glyphInfo = data.map(function (feature) {
551
462
  var _feature$shape = feature.shape,
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 计算
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 计算
558
471
  iconfont);
559
472
  var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
560
473
  feature.shaping = shaping;
561
- feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
474
+ feature.glyphQuads = glyphQuads;
475
+ // feature.centroid = calculteCentroid(coordinates);
562
476
 
563
- feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid
477
+ feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
564
478
 
479
+ // 此时地图高德2.0 originCentroid == centroid
565
480
  feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
566
481
  _this2.glyphInfoMap[id] = {
567
482
  shaping: shaping,
@@ -575,76 +490,66 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
575
490
  key: "getFontServiceMapping",
576
491
  value: function getFontServiceMapping() {
577
492
  var _ref7 = this.layer.getLayerConfig(),
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
-
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;
583
497
  return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
584
498
  }
585
499
  }, {
586
500
  key: "getFontServiceCanvas",
587
501
  value: function getFontServiceCanvas() {
588
502
  var _ref8 = this.layer.getLayerConfig(),
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
-
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
+ // 更新文字布局
595
508
  return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
596
509
  }
510
+
597
511
  /**
598
512
  * 文字避让 depend on originCentorid
599
513
  */
600
-
601
514
  }, {
602
515
  key: "filterGlyphs",
603
516
  value: function filterGlyphs() {
604
517
  var _this3 = this;
605
-
606
518
  var _ref9 = this.layer.getLayerConfig(),
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
-
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;
612
523
  if (textAllowOverlap) {
613
524
  // 如果允许文本覆盖
614
525
  return;
615
526
  }
616
-
617
527
  this.glyphInfoMap = {};
618
528
  this.currentZoom = this.mapService.getZoom();
619
529
  this.extent = this.textExtent();
620
-
621
530
  var _this$rendererService = this.rendererService.getViewportSize(),
622
- width = _this$rendererService.width,
623
- height = _this$rendererService.height;
624
-
531
+ width = _this$rendererService.width,
532
+ height = _this$rendererService.height;
625
533
  var collisionIndex = new _collisionIndex.default(width, height);
626
534
  var filterData = this.glyphInfo.filter(function (feature) {
627
535
  var shaping = feature.shaping,
628
- _feature$id = feature.id,
629
- id = _feature$id === void 0 ? 0 : _feature$id; // const centroid = feature.centroid as [number, number];
536
+ _feature$id = feature.id,
537
+ id = _feature$id === void 0 ? 0 : _feature$id;
538
+ // const centroid = feature.centroid as [number, number];
630
539
  // const centroid = feature.originCentroid as [number, number];
631
-
632
540
  var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
633
541
  var size = feature.size;
634
542
  var fontScale = size / 16;
635
-
636
543
  var pixels = _this3.mapService.lngLatToContainer(centroid);
637
-
638
544
  var _collisionIndex$place = collisionIndex.placeCollisionBox({
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
-
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;
648
553
  if (box && box.length) {
649
554
  collisionIndex.insertCollisionBox(box, id);
650
555
  return true;
@@ -655,39 +560,35 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
655
560
  filterData.forEach(function (item) {
656
561
  // @ts-ignore
657
562
  _this3.glyphInfoMap[item.id] = item;
658
- }); // this.layer.setEncodedData(filterData);
563
+ });
564
+ // this.layer.setEncodedData(filterData);
659
565
  }
660
566
  /**
661
567
  * 初始化文字布局
662
568
  */
663
-
664
569
  }, {
665
570
  key: "initGlyph",
666
571
  value: function initGlyph() {
667
572
  var _this$layer$getLayerC = this.layer.getLayerConfig(),
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
-
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.生成文字布局
674
578
  this.generateGlyphLayout(iconfont);
675
579
  }
676
580
  /**
677
581
  * 更新文字纹理
678
582
  */
679
-
680
583
  }, {
681
584
  key: "updateTexture",
682
585
  value: function updateTexture() {
683
586
  var createTexture2D = this.rendererService.createTexture2D;
684
587
  var canvas = this.getFontServiceCanvas();
685
588
  this.textureHeight = canvas.height;
686
-
687
589
  if (this.texture) {
688
590
  this.texture.destroy();
689
591
  }
690
-
691
592
  this.texture = createTexture2D({
692
593
  data: canvas,
693
594
  mag: _l7Core.gl.LINEAR,
@@ -702,43 +603,36 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
702
603
  var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
703
604
  var model;
704
605
  return _regenerator.default.wrap(function _callee5$(_context5) {
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
- }
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();
730
627
  }
731
628
  }, _callee5, this);
732
629
  }));
733
-
734
630
  function reBuildModel() {
735
631
  return _reBuildModel.apply(this, arguments);
736
632
  }
737
-
738
633
  return reBuildModel;
739
634
  }()
740
635
  }]);
741
636
  return TextModel;
742
637
  }(_BaseModel2.default);
743
-
744
638
  exports.default = TextModel;