@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
@@ -8,29 +8,20 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
10
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
11
-
12
11
  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; } } }; }
13
-
14
12
  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); }
15
-
16
- 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; }
17
-
13
+ 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; }
18
14
  import _regeneratorRuntime from "@babel/runtime/regenerator";
19
-
20
15
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
-
22
16
  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; } }
23
-
24
17
  import { AttributeType, gl } from '@antv/l7-core';
25
18
  import { boundsContains, calculateCentroid, padBounds, rgb2arr } from '@antv/l7-utils';
26
19
  import { isEqual } from 'lodash';
27
20
  import BaseModel from "../../core/BaseModel";
28
21
  import CollisionIndex from "../../utils/collision-index";
29
22
  import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
30
-
31
23
  /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
32
24
  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";
33
-
34
25
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
35
26
  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";
36
27
  export function TextTrianglation(feature) {
@@ -39,7 +30,6 @@ export function TextTrianglation(feature) {
39
30
  var id = feature.id;
40
31
  var vertices = [];
41
32
  var indices = [];
42
-
43
33
  if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
44
34
  return {
45
35
  vertices: [],
@@ -48,9 +38,7 @@ export function TextTrianglation(feature) {
48
38
  size: 7
49
39
  };
50
40
  }
51
-
52
41
  var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
53
-
54
42
  var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
55
43
  that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
56
44
  vertices.push.apply(vertices, _toConsumableArray(coord).concat([quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y], _toConsumableArray(coord), [quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y], _toConsumableArray(coord), [quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y], _toConsumableArray(coord), [quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y]));
@@ -63,82 +51,59 @@ export function TextTrianglation(feature) {
63
51
  size: 7
64
52
  };
65
53
  }
66
-
67
54
  var TextModel = /*#__PURE__*/function (_BaseModel) {
68
55
  _inherits(TextModel, _BaseModel);
69
-
70
56
  var _super = _createSuper(TextModel);
71
-
72
57
  function TextModel() {
73
58
  var _this;
74
-
75
59
  _classCallCheck(this, TextModel);
76
-
77
60
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
78
61
  args[_key] = arguments[_key];
79
62
  }
80
-
81
63
  _this = _super.call.apply(_super, [this].concat(args));
82
-
83
64
  _defineProperty(_assertThisInitialized(_this), "glyphInfoMap", {});
84
-
85
65
  _defineProperty(_assertThisInitialized(_this), "currentZoom", -1);
86
-
87
66
  _defineProperty(_assertThisInitialized(_this), "textureHeight", 0);
88
-
89
67
  _defineProperty(_assertThisInitialized(_this), "textCount", 0);
90
-
91
68
  _defineProperty(_assertThisInitialized(_this), "preTextStyle", {});
92
-
93
69
  _defineProperty(_assertThisInitialized(_this), "mapping", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
94
70
  return _regeneratorRuntime.wrap(function _callee$(_context) {
95
- while (1) {
96
- switch (_context.prev = _context.next) {
97
- case 0:
98
- _this.initGlyph(); //
99
-
100
-
101
- _this.updateTexture();
102
-
103
- _context.next = 4;
104
- return _this.reBuildModel();
105
-
106
- case 4:
107
- case "end":
108
- return _context.stop();
109
- }
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ _this.initGlyph(); //
74
+ _this.updateTexture();
75
+ _context.next = 4;
76
+ return _this.reBuildModel();
77
+ case 4:
78
+ case "end":
79
+ return _context.stop();
110
80
  }
111
81
  }, _callee);
112
82
  })));
113
-
114
83
  return _this;
115
84
  }
116
-
117
85
  _createClass(TextModel, [{
118
86
  key: "getUninforms",
119
87
  value: function getUninforms() {
120
88
  var _ref2 = this.layer.getLayerConfig(),
121
- _ref2$opacity = _ref2.opacity,
122
- opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
123
- _ref2$stroke = _ref2.stroke,
124
- stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
125
- _ref2$strokeWidth = _ref2.strokeWidth,
126
- strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
127
- _ref2$halo = _ref2.halo,
128
- halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
129
- _ref2$gamma = _ref2.gamma,
130
- gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
131
- _ref2$raisingHeight = _ref2.raisingHeight,
132
- raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
133
-
89
+ _ref2$opacity = _ref2.opacity,
90
+ opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
91
+ _ref2$stroke = _ref2.stroke,
92
+ stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
93
+ _ref2$strokeWidth = _ref2.strokeWidth,
94
+ strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
95
+ _ref2$halo = _ref2.halo,
96
+ halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
97
+ _ref2$gamma = _ref2.gamma,
98
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
99
+ _ref2$raisingHeight = _ref2.raisingHeight,
100
+ raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
134
101
  var mapping = this.getFontServiceMapping();
135
102
  var canvas = this.getFontServiceCanvas();
136
-
137
103
  if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
138
104
  this.updateTexture();
139
105
  this.textCount = Object.keys(mapping).length;
140
106
  }
141
-
142
107
  this.preTextStyle = this.getTextStyle();
143
108
  return _objectSpread({
144
109
  u_raisingHeight: Number(raisingHeight),
@@ -156,28 +121,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
156
121
  value: function () {
157
122
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
158
123
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
159
- while (1) {
160
- switch (_context2.prev = _context2.next) {
161
- case 0:
162
- // 绑定事件
163
- this.bindEvent();
164
- this.extent = this.textExtent();
165
- this.rawEncodeData = this.layer.getEncodedData();
166
- this.preTextStyle = this.getTextStyle();
167
- return _context2.abrupt("return", this.buildModels());
168
-
169
- case 5:
170
- case "end":
171
- return _context2.stop();
172
- }
124
+ while (1) switch (_context2.prev = _context2.next) {
125
+ case 0:
126
+ // 绑定事件
127
+ this.bindEvent();
128
+ this.extent = this.textExtent();
129
+ this.rawEncodeData = this.layer.getEncodedData();
130
+ this.preTextStyle = this.getTextStyle();
131
+ return _context2.abrupt("return", this.buildModels());
132
+ case 5:
133
+ case "end":
134
+ return _context2.stop();
173
135
  }
174
136
  }, _callee2, this);
175
137
  }));
176
-
177
138
  function initModels() {
178
139
  return _initModels.apply(this, arguments);
179
140
  }
180
-
181
141
  return initModels;
182
142
  }()
183
143
  }, {
@@ -185,49 +145,38 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
185
145
  value: function () {
186
146
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
187
147
  var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
188
-
189
148
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
190
- while (1) {
191
- switch (_context3.prev = _context3.next) {
192
- case 0:
193
- _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
194
-
195
- this.initGlyph(); //
196
-
197
- this.updateTexture();
198
-
199
- if (!textAllowOverlap) {
200
- this.filterGlyphs();
149
+ while (1) switch (_context3.prev = _context3.next) {
150
+ case 0:
151
+ _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
152
+ this.initGlyph(); //
153
+ this.updateTexture();
154
+ if (!textAllowOverlap) {
155
+ this.filterGlyphs();
156
+ }
157
+ _context3.next = 6;
158
+ return this.layer.buildLayerModel({
159
+ moduleName: 'pointText',
160
+ vertexShader: textVert,
161
+ fragmentShader: textFrag,
162
+ inject: this.getInject(),
163
+ triangulation: TextTrianglation.bind(this),
164
+ depth: {
165
+ enable: false
201
166
  }
202
-
203
- _context3.next = 6;
204
- return this.layer.buildLayerModel({
205
- moduleName: 'pointText',
206
- vertexShader: textVert,
207
- fragmentShader: textFrag,
208
- inject: this.getInject(),
209
- triangulation: TextTrianglation.bind(this),
210
- depth: {
211
- enable: false
212
- }
213
- });
214
-
215
- case 6:
216
- model = _context3.sent;
217
- return _context3.abrupt("return", [model]);
218
-
219
- case 8:
220
- case "end":
221
- return _context3.stop();
222
- }
167
+ });
168
+ case 6:
169
+ model = _context3.sent;
170
+ return _context3.abrupt("return", [model]);
171
+ case 8:
172
+ case "end":
173
+ return _context3.stop();
223
174
  }
224
175
  }, _callee3, this);
225
176
  }));
226
-
227
177
  function buildModels() {
228
178
  return _buildModels.apply(this, arguments);
229
179
  }
230
-
231
180
  return buildModels;
232
181
  }() // 需要更新的场景
233
182
  // 1. 文本偏移量发生改变
@@ -235,79 +184,61 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
235
184
  // 3. 文本允许重叠发生改变
236
185
  // 4. 文本字体发生改变
237
186
  // 5. 文本字体粗细发生改变
238
-
239
187
  }, {
240
188
  key: "needUpdate",
241
189
  value: function () {
242
190
  var _needUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
243
191
  var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
244
-
245
192
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
246
- while (1) {
247
- switch (_context4.prev = _context4.next) {
248
- case 0:
249
- _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;
250
-
251
- if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
252
- _context4.next = 5;
253
- break;
254
- }
255
-
256
- _context4.next = 4;
257
- return this.mapping();
258
-
259
- case 4:
260
- return _context4.abrupt("return", true);
261
-
262
- case 5:
263
- if (!textAllowOverlap) {
264
- _context4.next = 7;
265
- break;
266
- }
267
-
268
- return _context4.abrupt("return", false);
269
-
270
- case 7:
271
- // textAllowOverlap 发生改变
272
- zoom = this.mapService.getZoom();
273
- extent = this.mapService.getBounds();
274
- flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
275
-
276
- if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
277
- _context4.next = 14;
278
- break;
279
- }
280
-
281
- _context4.next = 13;
282
- return this.reBuildModel();
283
-
284
- case 13:
285
- return _context4.abrupt("return", true);
286
-
287
- case 14:
288
- return _context4.abrupt("return", false);
289
-
290
- case 15:
291
- case "end":
292
- return _context4.stop();
293
- }
193
+ while (1) switch (_context4.prev = _context4.next) {
194
+ case 0:
195
+ _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;
196
+ if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
197
+ _context4.next = 5;
198
+ break;
199
+ }
200
+ _context4.next = 4;
201
+ return this.mapping();
202
+ case 4:
203
+ return _context4.abrupt("return", true);
204
+ case 5:
205
+ if (!textAllowOverlap) {
206
+ _context4.next = 7;
207
+ break;
208
+ }
209
+ return _context4.abrupt("return", false);
210
+ case 7:
211
+ // textAllowOverlap 发生改变
212
+ zoom = this.mapService.getZoom();
213
+ extent = this.mapService.getBounds();
214
+ flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
215
+ if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
216
+ _context4.next = 14;
217
+ break;
218
+ }
219
+ _context4.next = 13;
220
+ return this.reBuildModel();
221
+ case 13:
222
+ return _context4.abrupt("return", true);
223
+ case 14:
224
+ return _context4.abrupt("return", false);
225
+ case 15:
226
+ case "end":
227
+ return _context4.stop();
294
228
  }
295
229
  }, _callee4, this);
296
230
  }));
297
-
298
231
  function needUpdate() {
299
232
  return _needUpdate.apply(this, arguments);
300
233
  }
301
-
302
234
  return needUpdate;
303
235
  }()
304
236
  }, {
305
237
  key: "clearModels",
306
238
  value: function clearModels() {
307
239
  var _this$texture;
308
-
309
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy(); // TODO this.mapping
310
-
240
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
241
+ // TODO this.mapping
311
242
  this.layer.off('remapping', this.mapping);
312
243
  }
313
244
  }, {
@@ -326,7 +257,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
326
257
  size: 1,
327
258
  update: function update(feature) {
328
259
  var _feature$rotate = feature.rotate,
329
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
260
+ rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
330
261
  return Array.isArray(rotate) ? [rotate[0]] : [rotate];
331
262
  }
332
263
  }
@@ -348,8 +279,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
348
279
  return [vertex[5], vertex[6]];
349
280
  }
350
281
  }
351
- }); // point layer size;
282
+ });
352
283
 
284
+ // point layer size;
353
285
  this.styleAttributeService.registerStyleAttribute({
354
286
  name: 'size',
355
287
  type: AttributeType.Attribute,
@@ -364,7 +296,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
364
296
  size: 1,
365
297
  update: function update(feature) {
366
298
  var _feature$size = feature.size,
367
- size = _feature$size === void 0 ? 12 : _feature$size;
299
+ size = _feature$size === void 0 ? 12 : _feature$size;
368
300
  return Array.isArray(size) ? [size[0]] : [size];
369
301
  }
370
302
  }
@@ -403,28 +335,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
403
335
  /**
404
336
  * 生成文字纹理(生成文字纹理字典)
405
337
  */
406
-
407
338
  }, {
408
339
  key: "initTextFont",
409
340
  value: function initTextFont() {
410
341
  var _this$getTextStyle = this.getTextStyle(),
411
- fontWeight = _this$getTextStyle.fontWeight,
412
- fontFamily = _this$getTextStyle.fontFamily;
413
-
342
+ fontWeight = _this$getTextStyle.fontWeight,
343
+ fontFamily = _this$getTextStyle.fontFamily;
414
344
  var data = this.rawEncodeData;
415
345
  var characterSet = [];
416
346
  data.forEach(function (item) {
417
347
  var _item$shape = item.shape,
418
- shape = _item$shape === void 0 ? '' : _item$shape;
348
+ shape = _item$shape === void 0 ? '' : _item$shape;
419
349
  shape = shape.toString();
420
-
421
350
  var _iterator = _createForOfIteratorHelper(shape),
422
- _step;
423
-
351
+ _step;
424
352
  try {
425
353
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
426
354
  var char = _step.value;
427
-
428
355
  // 去重
429
356
  if (characterSet.indexOf(char) === -1) {
430
357
  characterSet.push(char);
@@ -443,24 +370,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
443
370
  iconfont: false
444
371
  });
445
372
  }
373
+
446
374
  /**
447
375
  * 生成 iconfont 纹理字典
448
376
  */
449
-
450
377
  }, {
451
378
  key: "initIconFontTex",
452
379
  value: function initIconFontTex() {
453
380
  var _this$getTextStyle2 = this.getTextStyle(),
454
- fontWeight = _this$getTextStyle2.fontWeight,
455
- fontFamily = _this$getTextStyle2.fontFamily;
456
-
381
+ fontWeight = _this$getTextStyle2.fontWeight,
382
+ fontFamily = _this$getTextStyle2.fontFamily;
457
383
  var data = this.rawEncodeData;
458
384
  var characterSet = [];
459
385
  data.forEach(function (item) {
460
386
  var _item$shape2 = item.shape,
461
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
387
+ shape = _item$shape2 === void 0 ? '' : _item$shape2;
462
388
  shape = "".concat(shape);
463
-
464
389
  if (characterSet.indexOf(shape) === -1) {
465
390
  characterSet.push(shape);
466
391
  }
@@ -476,27 +401,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
476
401
  key: "getTextStyle",
477
402
  value: function getTextStyle() {
478
403
  var _ref5 = this.layer.getLayerConfig(),
479
- _ref5$fontWeight = _ref5.fontWeight,
480
- fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
481
- _ref5$fontFamily = _ref5.fontFamily,
482
- fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
483
- _ref5$textAllowOverla = _ref5.textAllowOverlap,
484
- textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
485
- _ref5$padding = _ref5.padding,
486
- padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
487
- _ref5$textAnchor = _ref5.textAnchor,
488
- textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
489
- _ref5$textOffset = _ref5.textOffset,
490
- textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
491
- _ref5$opacity = _ref5.opacity,
492
- opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
493
- _ref5$strokeOpacity = _ref5.strokeOpacity,
494
- strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
495
- _ref5$strokeWidth = _ref5.strokeWidth,
496
- strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
497
- _ref5$stroke = _ref5.stroke,
498
- stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
499
-
404
+ _ref5$fontWeight = _ref5.fontWeight,
405
+ fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
406
+ _ref5$fontFamily = _ref5.fontFamily,
407
+ fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
408
+ _ref5$textAllowOverla = _ref5.textAllowOverlap,
409
+ textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
410
+ _ref5$padding = _ref5.padding,
411
+ padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
412
+ _ref5$textAnchor = _ref5.textAnchor,
413
+ textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
414
+ _ref5$textOffset = _ref5.textOffset,
415
+ textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
416
+ _ref5$opacity = _ref5.opacity,
417
+ opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
418
+ _ref5$strokeOpacity = _ref5.strokeOpacity,
419
+ strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
420
+ _ref5$strokeWidth = _ref5.strokeWidth,
421
+ strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
422
+ _ref5$stroke = _ref5.stroke,
423
+ stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
500
424
  return {
501
425
  fontWeight: fontWeight,
502
426
  fontFamily: fontFamily,
@@ -510,40 +434,41 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
510
434
  stroke: stroke
511
435
  };
512
436
  }
437
+
513
438
  /**
514
439
  * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
515
440
  */
516
-
517
441
  }, {
518
442
  key: "generateGlyphLayout",
519
443
  value: function generateGlyphLayout(iconfont) {
520
444
  var _this2 = this;
521
-
522
445
  var mapping = this.getFontServiceMapping();
523
-
524
446
  var _ref6 = this.layer.getLayerConfig(),
525
- _ref6$spacing = _ref6.spacing,
526
- spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
527
- _ref6$textAnchor = _ref6.textAnchor,
528
- textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
529
- textOffset = _ref6.textOffset;
530
-
447
+ _ref6$spacing = _ref6.spacing,
448
+ spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
449
+ _ref6$textAnchor = _ref6.textAnchor,
450
+ textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
451
+ textOffset = _ref6.textOffset;
531
452
  var data = this.rawEncodeData;
532
453
  this.glyphInfo = data.map(function (feature) {
533
454
  var _feature$shape = feature.shape,
534
- shape = _feature$shape === void 0 ? '' : _feature$shape,
535
- id = feature.id,
536
- _feature$size2 = feature.size,
537
- size = _feature$size2 === void 0 ? 1 : _feature$size2;
538
- var shaping = shapeText(shape.toString(), mapping, // @ts-ignore
539
- size, textAnchor, 'left', spacing, textOffset, // || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
455
+ shape = _feature$shape === void 0 ? '' : _feature$shape,
456
+ id = feature.id,
457
+ _feature$size2 = feature.size,
458
+ size = _feature$size2 === void 0 ? 1 : _feature$size2;
459
+ var shaping = shapeText(shape.toString(), mapping,
460
+ // @ts-ignore
461
+ size, textAnchor, 'left', spacing, textOffset,
462
+ // || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
540
463
  iconfont);
541
464
  var glyphQuads = getGlyphQuads(shaping, textOffset, false);
542
465
  feature.shaping = shaping;
543
- feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
466
+ feature.glyphQuads = glyphQuads;
467
+ // feature.centroid = calculteCentroid(coordinates);
544
468
 
545
- feature.centroid = calculateCentroid(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid
469
+ feature.centroid = calculateCentroid(feature.coordinates);
546
470
 
471
+ // 此时地图高德2.0 originCentroid == centroid
547
472
  feature.originCentroid = feature.version === 'GAODE2.x' ? calculateCentroid(feature.originCoordinates) : feature.originCentroid = feature.centroid;
548
473
  _this2.glyphInfoMap[id] = {
549
474
  shaping: shaping,
@@ -557,76 +482,66 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
557
482
  key: "getFontServiceMapping",
558
483
  value: function getFontServiceMapping() {
559
484
  var _ref7 = this.layer.getLayerConfig(),
560
- _ref7$fontWeight = _ref7.fontWeight,
561
- fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
562
- _ref7$fontFamily = _ref7.fontFamily,
563
- fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
564
-
485
+ _ref7$fontWeight = _ref7.fontWeight,
486
+ fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
487
+ _ref7$fontFamily = _ref7.fontFamily,
488
+ fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
565
489
  return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
566
490
  }
567
491
  }, {
568
492
  key: "getFontServiceCanvas",
569
493
  value: function getFontServiceCanvas() {
570
494
  var _ref8 = this.layer.getLayerConfig(),
571
- _ref8$fontWeight = _ref8.fontWeight,
572
- fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
573
- _ref8$fontFamily = _ref8.fontFamily,
574
- fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily; // 更新文字布局
575
-
576
-
495
+ _ref8$fontWeight = _ref8.fontWeight,
496
+ fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
497
+ _ref8$fontFamily = _ref8.fontFamily,
498
+ fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily;
499
+ // 更新文字布局
577
500
  return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
578
501
  }
502
+
579
503
  /**
580
504
  * 文字避让 depend on originCentorid
581
505
  */
582
-
583
506
  }, {
584
507
  key: "filterGlyphs",
585
508
  value: function filterGlyphs() {
586
509
  var _this3 = this;
587
-
588
510
  var _ref9 = this.layer.getLayerConfig(),
589
- _ref9$padding = _ref9.padding,
590
- padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
591
- _ref9$textAllowOverla = _ref9.textAllowOverlap,
592
- textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
593
-
511
+ _ref9$padding = _ref9.padding,
512
+ padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
513
+ _ref9$textAllowOverla = _ref9.textAllowOverlap,
514
+ textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
594
515
  if (textAllowOverlap) {
595
516
  // 如果允许文本覆盖
596
517
  return;
597
518
  }
598
-
599
519
  this.glyphInfoMap = {};
600
520
  this.currentZoom = this.mapService.getZoom();
601
521
  this.extent = this.textExtent();
602
-
603
522
  var _this$rendererService = this.rendererService.getViewportSize(),
604
- width = _this$rendererService.width,
605
- height = _this$rendererService.height;
606
-
523
+ width = _this$rendererService.width,
524
+ height = _this$rendererService.height;
607
525
  var collisionIndex = new CollisionIndex(width, height);
608
526
  var filterData = this.glyphInfo.filter(function (feature) {
609
527
  var shaping = feature.shaping,
610
- _feature$id = feature.id,
611
- id = _feature$id === void 0 ? 0 : _feature$id; // const centroid = feature.centroid as [number, number];
528
+ _feature$id = feature.id,
529
+ id = _feature$id === void 0 ? 0 : _feature$id;
530
+ // const centroid = feature.centroid as [number, number];
612
531
  // const centroid = feature.originCentroid as [number, number];
613
-
614
532
  var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
615
533
  var size = feature.size;
616
534
  var fontScale = size / 16;
617
-
618
535
  var pixels = _this3.mapService.lngLatToContainer(centroid);
619
-
620
536
  var _collisionIndex$place = collisionIndex.placeCollisionBox({
621
- x1: shaping.left * fontScale - padding[0],
622
- x2: shaping.right * fontScale + padding[0],
623
- y1: shaping.top * fontScale - padding[1],
624
- y2: shaping.bottom * fontScale + padding[1],
625
- anchorPointX: pixels.x,
626
- anchorPointY: pixels.y
627
- }),
628
- box = _collisionIndex$place.box;
629
-
537
+ x1: shaping.left * fontScale - padding[0],
538
+ x2: shaping.right * fontScale + padding[0],
539
+ y1: shaping.top * fontScale - padding[1],
540
+ y2: shaping.bottom * fontScale + padding[1],
541
+ anchorPointX: pixels.x,
542
+ anchorPointY: pixels.y
543
+ }),
544
+ box = _collisionIndex$place.box;
630
545
  if (box && box.length) {
631
546
  collisionIndex.insertCollisionBox(box, id);
632
547
  return true;
@@ -637,39 +552,35 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
637
552
  filterData.forEach(function (item) {
638
553
  // @ts-ignore
639
554
  _this3.glyphInfoMap[item.id] = item;
640
- }); // this.layer.setEncodedData(filterData);
555
+ });
556
+ // this.layer.setEncodedData(filterData);
641
557
  }
642
558
  /**
643
559
  * 初始化文字布局
644
560
  */
645
-
646
561
  }, {
647
562
  key: "initGlyph",
648
563
  value: function initGlyph() {
649
564
  var _this$layer$getLayerC = this.layer.getLayerConfig(),
650
- _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
651
- iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
652
-
653
-
654
- iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
655
-
565
+ _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
566
+ iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2;
567
+ // 1.生成文字纹理(或是生成 iconfont)
568
+ iconfont ? this.initIconFontTex() : this.initTextFont();
569
+ // 2.生成文字布局
656
570
  this.generateGlyphLayout(iconfont);
657
571
  }
658
572
  /**
659
573
  * 更新文字纹理
660
574
  */
661
-
662
575
  }, {
663
576
  key: "updateTexture",
664
577
  value: function updateTexture() {
665
578
  var createTexture2D = this.rendererService.createTexture2D;
666
579
  var canvas = this.getFontServiceCanvas();
667
580
  this.textureHeight = canvas.height;
668
-
669
581
  if (this.texture) {
670
582
  this.texture.destroy();
671
583
  }
672
-
673
584
  this.texture = createTexture2D({
674
585
  data: canvas,
675
586
  mag: gl.LINEAR,
@@ -684,44 +595,36 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
684
595
  var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
685
596
  var model;
686
597
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
687
- while (1) {
688
- switch (_context5.prev = _context5.next) {
689
- case 0:
690
- this.filterGlyphs();
691
- _context5.next = 3;
692
- return this.layer.buildLayerModel({
693
- moduleName: 'pointText',
694
- vertexShader: textVert,
695
- fragmentShader: textFrag,
696
- triangulation: TextTrianglation.bind(this),
697
- inject: this.getInject(),
698
- depth: {
699
- enable: false
700
- }
701
- });
702
-
703
- case 3:
704
- model = _context5.sent;
705
- // TODO 渲染流程待修改
706
- this.layer.models = [model];
707
-
708
- case 5:
709
- case "end":
710
- return _context5.stop();
711
- }
598
+ while (1) switch (_context5.prev = _context5.next) {
599
+ case 0:
600
+ this.filterGlyphs();
601
+ _context5.next = 3;
602
+ return this.layer.buildLayerModel({
603
+ moduleName: 'pointText',
604
+ vertexShader: textVert,
605
+ fragmentShader: textFrag,
606
+ triangulation: TextTrianglation.bind(this),
607
+ inject: this.getInject(),
608
+ depth: {
609
+ enable: false
610
+ }
611
+ });
612
+ case 3:
613
+ model = _context5.sent;
614
+ // TODO 渲染流程待修改
615
+ this.layer.models = [model];
616
+ case 5:
617
+ case "end":
618
+ return _context5.stop();
712
619
  }
713
620
  }, _callee5, this);
714
621
  }));
715
-
716
622
  function reBuildModel() {
717
623
  return _reBuildModel.apply(this, arguments);
718
624
  }
719
-
720
625
  return reBuildModel;
721
626
  }()
722
627
  }]);
723
-
724
628
  return TextModel;
725
629
  }(BaseModel);
726
-
727
630
  export { TextModel as default };