@antv/l7-layers 2.15.1 → 2.15.3

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 (243) 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 +320 -484
  10. package/es/core/BaseModel.js +97 -126
  11. package/es/core/LayerPickService.js +21 -32
  12. package/es/core/TextureService.js +0 -13
  13. package/es/core/interface.js +17 -24
  14. package/es/core/shape/Path.js +13 -20
  15. package/es/core/shape/extrude.js +10 -31
  16. package/es/core/triangulation.js +54 -114
  17. package/es/earth/index.js +9 -33
  18. package/es/earth/models/atmosphere.js +30 -54
  19. package/es/earth/models/base.js +47 -85
  20. package/es/earth/models/bloomsphere.js +30 -54
  21. package/es/earth/utils.js +9 -13
  22. package/es/heatmap/index.js +10 -40
  23. package/es/heatmap/models/grid.js +28 -52
  24. package/es/heatmap/models/grid3d.js +28 -52
  25. package/es/heatmap/models/heatmap.js +91 -146
  26. package/es/heatmap/models/hexagon.js +28 -52
  27. package/es/heatmap/triangulation.js +0 -4
  28. package/es/image/index.js +9 -28
  29. package/es/image/models/image.js +66 -100
  30. package/es/index.js +9 -17
  31. package/es/line/index.js +9 -34
  32. package/es/line/models/arc.js +66 -118
  33. package/es/line/models/arc_3d.js +60 -108
  34. package/es/line/models/earthArc_3d.js +63 -111
  35. package/es/line/models/great_circle.js +56 -100
  36. package/es/line/models/half.js +46 -77
  37. package/es/line/models/line.js +94 -148
  38. package/es/line/models/linearline.js +45 -80
  39. package/es/line/models/simpleLine.js +41 -74
  40. package/es/line/models/wall.js +52 -92
  41. package/es/mask/index.js +9 -28
  42. package/es/mask/models/fill.js +29 -54
  43. package/es/plugins/DataMappingPlugin.js +80 -117
  44. package/es/plugins/DataSourcePlugin.js +45 -68
  45. package/es/plugins/FeatureScalePlugin.js +67 -122
  46. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  47. package/es/plugins/LayerMaskPlugin.js +3 -11
  48. package/es/plugins/LayerModelPlugin.js +67 -104
  49. package/es/plugins/LayerStylePlugin.js +3 -9
  50. package/es/plugins/LightingPlugin.js +12 -18
  51. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  52. package/es/plugins/PixelPickingPlugin.js +12 -21
  53. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  54. package/es/plugins/ShaderUniformPlugin.js +13 -27
  55. package/es/plugins/UpdateModelPlugin.js +0 -5
  56. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  57. package/es/point/index.js +26 -77
  58. package/es/point/models/earthExtrude.js +61 -102
  59. package/es/point/models/earthFill.js +57 -87
  60. package/es/point/models/extrude.js +60 -101
  61. package/es/point/models/fill.js +70 -100
  62. package/es/point/models/fillmage.js +63 -107
  63. package/es/point/models/image.js +48 -88
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +30 -54
  66. package/es/point/models/radar.js +40 -64
  67. package/es/point/models/simplePoint.js +41 -69
  68. package/es/point/models/text.d.ts +2 -0
  69. package/es/point/models/text.js +214 -295
  70. package/es/point/shape/extrude.js +4 -13
  71. package/es/polygon/index.js +11 -40
  72. package/es/polygon/models/extrude.js +48 -92
  73. package/es/polygon/models/fill.js +54 -88
  74. package/es/polygon/models/index.js +3 -2
  75. package/es/polygon/models/ocean.js +42 -76
  76. package/es/polygon/models/water.js +37 -71
  77. package/es/raster/buffers/triangulation.js +2 -4
  78. package/es/raster/index.js +9 -32
  79. package/es/raster/models/raster.js +80 -116
  80. package/es/raster/models/rasterRgb.js +84 -127
  81. package/es/raster/models/rasterTerrainRgb.js +56 -84
  82. package/es/tile/interaction/getRasterData.js +14 -20
  83. package/es/tile/interaction/utils.js +7 -9
  84. package/es/tile/manager/base.js +63 -96
  85. package/es/tile/service/TileLayerService.js +30 -52
  86. package/es/tile/service/TilePickService.js +26 -40
  87. package/es/tile/service/TileSourceService.js +3 -7
  88. package/es/tile/tileFactory/DebugTile.js +28 -45
  89. package/es/tile/tileFactory/ImageTile.js +20 -38
  90. package/es/tile/tileFactory/MaskTile.js +22 -43
  91. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  93. package/es/tile/tileFactory/RasterTile.js +30 -53
  94. package/es/tile/tileFactory/Tile.js +63 -97
  95. package/es/tile/tileFactory/VectorTile.js +41 -68
  96. package/es/tile/tileFactory/index.js +0 -11
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  98. package/es/tile/tileFactory/util.js +0 -3
  99. package/es/tile/tileLayer/BaseLayer.js +105 -146
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +0 -2
  102. package/es/utils/collision-index.js +9 -16
  103. package/es/utils/dataMappingStyle.js +8 -18
  104. package/es/utils/extrude_polyline.js +101 -149
  105. package/es/utils/grid-index.js +2 -27
  106. package/es/utils/identityScale.js +0 -8
  107. package/es/utils/layerData.js +30 -44
  108. package/es/utils/multiPassRender.js +11 -13
  109. package/es/utils/polylineNormal.js +31 -37
  110. package/es/utils/simpleLine.js +2 -16
  111. package/es/utils/stencil.js +2 -3
  112. package/es/utils/symbol-layout.js +27 -53
  113. package/es/wind/index.js +9 -29
  114. package/es/wind/models/utils.js +26 -51
  115. package/es/wind/models/wind.js +101 -147
  116. package/es/wind/models/windRender.js +53 -66
  117. package/lib/Geometry/index.js +9 -38
  118. package/lib/Geometry/models/billboard.js +51 -97
  119. package/lib/Geometry/models/index.js +0 -5
  120. package/lib/Geometry/models/plane.js +79 -151
  121. package/lib/Geometry/models/sprite.js +60 -127
  122. package/lib/canvas/index.js +10 -40
  123. package/lib/canvas/models/canvas.js +41 -101
  124. package/lib/canvas/models/index.js +0 -3
  125. package/lib/citybuliding/building.js +8 -35
  126. package/lib/citybuliding/models/build.js +57 -92
  127. package/lib/core/BaseLayer.js +320 -478
  128. package/lib/core/BaseModel.js +97 -139
  129. package/lib/core/LayerPickService.js +21 -37
  130. package/lib/core/TextureService.js +0 -16
  131. package/lib/core/interface.js +21 -31
  132. package/lib/core/schema.js +0 -1
  133. package/lib/core/shape/Path.js +14 -31
  134. package/lib/core/shape/extrude.js +10 -54
  135. package/lib/core/triangulation.js +53 -153
  136. package/lib/earth/index.js +9 -43
  137. package/lib/earth/models/atmosphere.js +30 -63
  138. package/lib/earth/models/base.js +47 -90
  139. package/lib/earth/models/bloomsphere.js +30 -63
  140. package/lib/earth/utils.js +7 -31
  141. package/lib/heatmap/index.js +10 -48
  142. package/lib/heatmap/models/grid.js +28 -60
  143. package/lib/heatmap/models/grid3d.js +28 -60
  144. package/lib/heatmap/models/heatmap.js +91 -162
  145. package/lib/heatmap/models/hexagon.js +28 -60
  146. package/lib/heatmap/models/index.js +0 -6
  147. package/lib/heatmap/triangulation.js +0 -5
  148. package/lib/image/index.js +9 -36
  149. package/lib/image/models/image.js +66 -109
  150. package/lib/image/models/index.js +0 -3
  151. package/lib/index.js +7 -61
  152. package/lib/line/index.js +9 -40
  153. package/lib/line/models/arc.js +64 -128
  154. package/lib/line/models/arc_3d.js +58 -119
  155. package/lib/line/models/earthArc_3d.js +61 -122
  156. package/lib/line/models/great_circle.js +56 -111
  157. package/lib/line/models/half.js +46 -87
  158. package/lib/line/models/index.js +0 -11
  159. package/lib/line/models/line.js +92 -156
  160. package/lib/line/models/linearline.js +45 -92
  161. package/lib/line/models/simpleLine.js +41 -84
  162. package/lib/line/models/wall.js +52 -103
  163. package/lib/mask/index.js +9 -36
  164. package/lib/mask/models/fill.js +29 -63
  165. package/lib/mask/models/index.js +0 -3
  166. package/lib/plugins/DataMappingPlugin.js +80 -128
  167. package/lib/plugins/DataSourcePlugin.js +45 -76
  168. package/lib/plugins/FeatureScalePlugin.js +67 -138
  169. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  170. package/lib/plugins/LayerMaskPlugin.js +4 -17
  171. package/lib/plugins/LayerModelPlugin.js +68 -113
  172. package/lib/plugins/LayerStylePlugin.js +4 -14
  173. package/lib/plugins/LightingPlugin.js +12 -25
  174. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  175. package/lib/plugins/PixelPickingPlugin.js +12 -27
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  177. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  178. package/lib/plugins/UpdateModelPlugin.js +1 -10
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  180. package/lib/point/index.js +26 -83
  181. package/lib/point/models/earthExtrude.js +61 -113
  182. package/lib/point/models/earthFill.js +57 -117
  183. package/lib/point/models/extrude.js +60 -111
  184. package/lib/point/models/fill.js +68 -109
  185. package/lib/point/models/fillmage.js +61 -115
  186. package/lib/point/models/image.js +48 -98
  187. package/lib/point/models/index.js +1 -12
  188. package/lib/point/models/normal.js +30 -64
  189. package/lib/point/models/radar.js +40 -74
  190. package/lib/point/models/simplePoint.js +41 -79
  191. package/lib/point/models/text.js +214 -303
  192. package/lib/point/shape/extrude.js +4 -20
  193. package/lib/polygon/index.js +11 -48
  194. package/lib/polygon/models/extrude.js +48 -103
  195. package/lib/polygon/models/fill.js +54 -98
  196. package/lib/polygon/models/index.js +2 -14
  197. package/lib/polygon/models/ocean.js +42 -88
  198. package/lib/polygon/models/water.js +37 -82
  199. package/lib/raster/buffers/triangulation.js +3 -7
  200. package/lib/raster/index.js +9 -40
  201. package/lib/raster/models/index.js +0 -5
  202. package/lib/raster/models/raster.js +80 -125
  203. package/lib/raster/models/rasterRgb.js +84 -139
  204. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  205. package/lib/tile/interaction/getRasterData.js +14 -25
  206. package/lib/tile/interaction/utils.js +7 -19
  207. package/lib/tile/manager/base.js +63 -104
  208. package/lib/tile/service/TileLayerService.js +30 -57
  209. package/lib/tile/service/TilePickService.js +26 -48
  210. package/lib/tile/service/TileSourceService.js +2 -16
  211. package/lib/tile/style/utils.js +0 -3
  212. package/lib/tile/tileFactory/DebugTile.js +28 -53
  213. package/lib/tile/tileFactory/ImageTile.js +20 -46
  214. package/lib/tile/tileFactory/MaskTile.js +22 -51
  215. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  217. package/lib/tile/tileFactory/RasterTile.js +30 -63
  218. package/lib/tile/tileFactory/Tile.js +63 -102
  219. package/lib/tile/tileFactory/VectorTile.js +41 -76
  220. package/lib/tile/tileFactory/index.js +0 -25
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  222. package/lib/tile/tileFactory/util.js +0 -9
  223. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  224. package/lib/tile/utils.js +1 -5
  225. package/lib/utils/blend.js +0 -5
  226. package/lib/utils/collision-index.js +9 -25
  227. package/lib/utils/dataMappingStyle.js +8 -19
  228. package/lib/utils/extrude_polyline.js +101 -181
  229. package/lib/utils/grid-index.js +2 -28
  230. package/lib/utils/identityScale.js +0 -9
  231. package/lib/utils/layerData.js +30 -49
  232. package/lib/utils/multiPassRender.js +11 -16
  233. package/lib/utils/polylineNormal.js +31 -66
  234. package/lib/utils/simpleLine.js +2 -21
  235. package/lib/utils/stencil.js +0 -4
  236. package/lib/utils/symbol-layout.js +27 -55
  237. package/lib/wind/index.js +9 -37
  238. package/lib/wind/models/index.js +0 -3
  239. package/lib/wind/models/utils.js +26 -62
  240. package/lib/wind/models/wind.js +101 -157
  241. package/lib/wind/models/windRender.js +53 -71
  242. package/lib/wind/models/windShader.js +0 -1
  243. package/package.json +7 -7
@@ -1,7 +1,6 @@
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
  });
@@ -9,77 +8,53 @@ exports.computeMiter = computeMiter;
9
8
  exports.computeNormal = computeNormal;
10
9
  exports.default = _default;
11
10
  exports.direction = direction;
12
-
13
11
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
14
-
15
12
  var _l7Utils = require("@antv/l7-utils");
16
-
17
13
  var _glMatrix = require("gl-matrix");
18
-
19
14
  function computeMiter(tangent, miter, lineA, lineB, halfThick) {
20
15
  _glMatrix.vec2.add(tangent, lineA, lineB);
21
-
22
16
  _glMatrix.vec2.normalize(tangent, tangent);
23
-
24
17
  miter = _glMatrix.vec2.fromValues(-tangent[1], tangent[0]);
25
-
26
18
  var tmp = _glMatrix.vec2.fromValues(-lineA[1], lineA[0]);
27
-
28
19
  return halfThick / _glMatrix.vec2.dot(miter, tmp);
29
20
  }
30
-
31
21
  function computeNormal(out, dir) {
32
22
  return _glMatrix.vec2.set(out, -dir[1], dir[0]);
33
23
  }
34
-
35
24
  function direction(out, a, b) {
36
25
  // const a1 = aProjectFlat([a[0], a[1]]) as [number, number];
37
26
  // const b1 = aProjectFlat([b[0], b[1]]) as [number, number];
38
27
  _glMatrix.vec2.sub(out, a, b);
39
-
40
28
  _glMatrix.vec2.normalize(out, out);
41
-
42
29
  return out;
43
30
  }
44
-
45
31
  function extrusions(positions, out, miters, point, normal, scale) {
46
32
  addNext(out, miters, normal, -scale);
47
33
  addNext(out, miters, normal, scale);
48
34
  positions.push(point[0], point[1], 0);
49
35
  positions.push(point[0], point[1], 0);
50
36
  }
51
-
52
37
  function addNext(out, miters, normal, length) {
53
38
  out.push(normal[0], normal[1], 0);
54
39
  miters.push(length);
55
40
  }
56
-
57
41
  function lineSegmentDistance(b1, a1) {
58
42
  var dx = a1[0] - b1[0];
59
43
  var dy = a1[1] - b1[1];
60
44
  return Math.sqrt(dx * dx + dy * dy);
61
45
  }
62
-
63
46
  function isPointEqual(a, b) {
64
47
  return a[0] === b[0] && a[1] === b[1];
65
48
  }
66
-
67
49
  function _default(points, closed, indexOffset) {
68
50
  var isDash = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
69
-
70
51
  var lineA = _glMatrix.vec2.fromValues(0, 0);
71
-
72
52
  var lineB = _glMatrix.vec2.fromValues(0, 0);
73
-
74
53
  var tangent = _glMatrix.vec2.fromValues(0, 0);
75
-
76
54
  var miter = _glMatrix.vec2.create();
77
-
78
55
  var started = false;
79
56
  var lineNormal = null;
80
-
81
57
  var tmp = _glMatrix.vec2.create();
82
-
83
58
  var count = indexOffset || 0;
84
59
  var miterLimit = 4;
85
60
  var out = [];
@@ -87,58 +62,46 @@ function _default(points, closed, indexOffset) {
87
62
  var attrIndex = [];
88
63
  var miters = [];
89
64
  var attrDistance = [0, 0];
90
-
91
65
  if (closed) {
92
66
  points = points.slice();
93
67
  points.push(points[0]);
94
68
  }
95
-
96
69
  var total = points.length;
97
-
98
70
  for (var i = 1; i < total; i++) {
99
71
  var index = count;
100
-
101
72
  var last = _glMatrix.vec2.fromValues(points[i - 1][0], points[i - 1][1]);
102
-
103
73
  var cur = _glMatrix.vec2.fromValues(points[i][0], points[i][1]);
104
-
105
- var next = i < points.length - 1 ? _glMatrix.vec2.fromValues(points[i + 1][0], points[i + 1][1]) : null; // 如果当前点和前一点相同,跳过
106
-
74
+ var next = i < points.length - 1 ? _glMatrix.vec2.fromValues(points[i + 1][0], points[i + 1][1]) : null;
75
+ // 如果当前点和前一点相同,跳过
107
76
  if (isPointEqual(last, cur)) {
108
77
  continue;
109
78
  }
110
-
111
79
  if (next) {
112
- var nextIndex = i + 1; // 找到不相同的下一点
113
-
80
+ var nextIndex = i + 1;
81
+ // 找到不相同的下一点
114
82
  while (next && isPointEqual(cur, next)) {
115
83
  next = nextIndex < points.length - 1 ? _glMatrix.vec2.fromValues(points[++nextIndex][0], points[nextIndex][1]) : null;
116
84
  }
117
85
  }
118
-
119
86
  var d = 0;
120
87
  var flatCur = (0, _l7Utils.aProjectFlat)([cur[0], cur[1]]);
121
88
  var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]);
122
-
123
89
  if (isDash) {
124
90
  var lineDistance = lineSegmentDistance(flatCur, flatLast);
125
91
  d = lineDistance + attrDistance[attrDistance.length - 1];
126
92
  }
127
-
128
93
  direction(lineA, flatCur, flatLast);
129
-
130
94
  if (!lineNormal) {
131
95
  lineNormal = _glMatrix.vec2.create();
132
96
  computeNormal(lineNormal, lineA);
133
97
  }
134
-
135
98
  if (!started) {
136
99
  started = true;
137
100
  extrusions(attrPos, out, miters, last, lineNormal, 1);
138
101
  }
102
+ attrIndex.push(index + 0, index + 2, index + 1);
139
103
 
140
- attrIndex.push(index + 0, index + 2, index + 1); // no miter, simple segment
141
-
104
+ // no miter, simple segment
142
105
  if (!next) {
143
106
  // reset normal
144
107
  computeNormal(lineNormal, lineA);
@@ -147,14 +110,18 @@ function _default(points, closed, indexOffset) {
147
110
  attrIndex.push(index + 1, index + 2, index + 3);
148
111
  count += 2;
149
112
  } else {
150
- var flatNext = (0, _l7Utils.aProjectFlat)([next[0], next[1]]); // get unit dir of next line
151
-
152
- direction(lineB, flatNext, flatCur); // stores tangent & miter
113
+ var flatNext = (0, _l7Utils.aProjectFlat)([next[0], next[1]]);
114
+ // get unit dir of next line
115
+ direction(lineB, flatNext, flatCur);
153
116
 
154
- var miterLen = computeMiter(tangent, _glMatrix.vec2.fromValues(miter[0], miter[1]), lineA, lineB, 1); // get orientation
117
+ // stores tangent & miter
118
+ var miterLen = computeMiter(tangent, _glMatrix.vec2.fromValues(miter[0], miter[1]), lineA, lineB, 1);
155
119
 
120
+ // get orientation
156
121
  var flip = _glMatrix.vec2.dot(tangent, lineNormal) < 0 ? -1 : 1;
157
- var bevel = Math.abs(miterLen) > miterLimit; // 处理前后两条线段重合的情况,这种情况不需要使用任何接头(miter/bevel)。
122
+ var bevel = Math.abs(miterLen) > miterLimit;
123
+
124
+ // 处理前后两条线段重合的情况,这种情况不需要使用任何接头(miter/bevel)。
158
125
  // 理论上这种情况下 miterLen = Infinity,本应通过 isFinite(miterLen) 判断,
159
126
  // 但是 AMap 投影变换后丢失精度,只能通过一个阈值(1000)判断。
160
127
 
@@ -163,60 +130,58 @@ function _default(points, closed, indexOffset) {
163
130
  attrIndex.push(index + 1, index + 2, index + 3);
164
131
  attrIndex.push(index + 2, index + 4, index + 3);
165
132
  computeNormal(tmp, lineB);
166
-
167
133
  _glMatrix.vec2.copy(lineNormal, tmp); // store normal for next round
168
134
 
169
-
170
135
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
171
- attrDistance.push(d, d, d, d); // the miter is now the normal for our next join
136
+ attrDistance.push(d, d, d, d);
172
137
 
138
+ // the miter is now the normal for our next join
173
139
  count += 4;
174
140
  continue;
175
141
  }
176
-
177
142
  if (bevel) {
178
- miterLen = miterLimit; // next two points in our first segment
143
+ miterLen = miterLimit;
179
144
 
145
+ // next two points in our first segment
180
146
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
181
- attrIndex.push(index + 1, index + 2, index + 3); // now add the bevel triangle
147
+ attrIndex.push(index + 1, index + 2, index + 3);
182
148
 
149
+ // now add the bevel triangle
183
150
  attrIndex.push.apply(attrIndex, (0, _toConsumableArray2.default)(flip === 1 ? [index + 2, index + 4, index + 5] : [index + 4, index + 5, index + 3]));
184
151
  computeNormal(tmp, lineB);
185
-
186
152
  _glMatrix.vec2.copy(lineNormal, tmp); // store normal for next round
187
153
 
188
-
189
154
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
190
- attrDistance.push(d, d, d, d); // the miter is now the normal for our next join
155
+ attrDistance.push(d, d, d, d);
191
156
 
157
+ // the miter is now the normal for our next join
192
158
  count += 4;
193
159
  } else {
194
160
  // next two points in our first segment
195
161
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
196
- attrIndex.push(index + 1, index + 2, index + 3); // now add the miter triangles
162
+ attrIndex.push(index + 1, index + 2, index + 3);
197
163
 
164
+ // now add the miter triangles
198
165
  addNext(out, miters, lineNormal, miterLen * -flip);
199
166
  attrPos.push(cur[0], cur[1], 0);
200
167
  attrIndex.push(index + 2, index + 4, index + 3);
201
168
  attrIndex.push(index + 4, index + 5, index + 6);
202
169
  computeNormal(tmp, lineB);
203
-
204
170
  _glMatrix.vec2.copy(lineNormal, tmp); // store normal for next round
205
171
 
206
-
207
172
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
208
- attrDistance.push(d, d, d, d, d); // the miter is now the normal for our next join
173
+ attrDistance.push(d, d, d, d, d);
209
174
 
175
+ // the miter is now the normal for our next join
210
176
  count += 5;
211
177
  }
212
178
  }
213
179
  }
214
-
215
180
  var pickData = [];
216
-
217
181
  for (var _i = 0; _i < miters.length; _i++) {
218
182
  var totalDistance = attrDistance[attrDistance.length - 1];
219
- pickData.push(attrPos[_i * 3], attrPos[_i * 3 + 1], attrPos[_i * 3 + 2], attrDistance[_i], // dash
183
+ pickData.push(attrPos[_i * 3], attrPos[_i * 3 + 1], attrPos[_i * 3 + 2], attrDistance[_i],
184
+ // dash
220
185
  miters[_i], totalDistance // dash
221
186
  );
222
187
  }
@@ -225,6 +190,6 @@ function _default(points, closed, indexOffset) {
225
190
  normals: out,
226
191
  attrIndex: attrIndex,
227
192
  attrPos: pickData // [x,y,z, distance, miter ,t0tal ]
228
-
229
193
  };
230
- } // [x,y,z, distance, miter ]
194
+ }
195
+ // [x,y,z, distance, miter ]
@@ -1,33 +1,22 @@
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.default = void 0;
9
8
  exports.direction = direction;
10
-
11
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
-
13
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
-
15
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  var _l7Utils = require("@antv/l7-utils");
18
-
19
13
  var _glMatrix = require("gl-matrix");
20
-
21
14
  var lineA = _glMatrix.vec2.create();
22
-
23
15
  function direction(out, a, b) {
24
16
  _glMatrix.vec2.sub(out, a, b);
25
-
26
17
  _glMatrix.vec2.normalize(out, out);
27
-
28
18
  return out;
29
19
  }
30
-
31
20
  var ExtrudePolyline = /*#__PURE__*/function () {
32
21
  function ExtrudePolyline() {
33
22
  (0, _classCallCheck2.default)(this, ExtrudePolyline);
@@ -41,32 +30,26 @@ var ExtrudePolyline = /*#__PURE__*/function () {
41
30
  indexes: []
42
31
  };
43
32
  }
44
-
45
33
  (0, _createClass2.default)(ExtrudePolyline, [{
46
34
  key: "simpleExtrude",
47
35
  value: function simpleExtrude(points) {
48
36
  var complex = this.complex;
49
-
50
37
  if (points.length <= 1) {
51
38
  return complex;
52
39
  }
53
-
54
40
  this.started = false;
55
41
  this.totalDistance = 0;
56
42
  var total = points.length;
57
43
  var count = complex.startIndex;
58
-
59
44
  for (var i = 1; i < total; i++) {
60
45
  var last = points[i - 1];
61
46
  var cur = points[i];
62
47
  var amt = this.simpleSegment(complex, count, last, cur);
63
48
  count += amt;
64
49
  }
65
-
66
50
  for (var _i = 0; _i < complex.positions.length / 6; _i++) {
67
51
  complex.positions[_i * 6 + 5] = this.totalDistance;
68
52
  }
69
-
70
53
  return complex;
71
54
  }
72
55
  }, {
@@ -80,12 +63,10 @@ var ExtrudePolyline = /*#__PURE__*/function () {
80
63
  direction(lineA, flatCur, flatLast);
81
64
  var segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
82
65
  this.totalDistance += segmentDistance;
83
-
84
66
  if (!this.started) {
85
67
  this.started = true;
86
68
  this.extrusions(positions, last, this.totalDistance - segmentDistance);
87
69
  }
88
-
89
70
  this.extrusions(positions, cur, this.totalDistance);
90
71
  indices.push(index + 0, index + 1, index + 2);
91
72
  indices.push(index + 2, index + 1, index + 3);
@@ -94,7 +75,8 @@ var ExtrudePolyline = /*#__PURE__*/function () {
94
75
  }
95
76
  }, {
96
77
  key: "extrusions",
97
- value: function extrusions(positions, point, // 顶点
78
+ value: function extrusions(positions, point,
79
+ // 顶点
98
80
  distanceRadio) {
99
81
  positions.push(point[0], point[1], point[2] | 0, distanceRadio, 0, point[2] | 0);
100
82
  this.complex.indexes.push(this.currentIndex);
@@ -112,5 +94,4 @@ var ExtrudePolyline = /*#__PURE__*/function () {
112
94
  }]);
113
95
  return ExtrudePolyline;
114
96
  }();
115
-
116
97
  exports.default = ExtrudePolyline;
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getStencil = getStencil;
7
7
  exports.getStencilMask = getStencilMask;
8
-
9
8
  var _l7Core = require("@antv/l7-core");
10
-
11
9
  // 掩膜配置
12
10
  function getStencil(mask, maskInside) {
13
11
  return {
@@ -21,7 +19,6 @@ function getStencil(mask, maskInside) {
21
19
  }
22
20
  };
23
21
  }
24
-
25
22
  // 模版配置
26
23
  function getStencilMask(option) {
27
24
  if (option.maskOperation === _l7Core.MaskOperation.OR) {
@@ -40,7 +37,6 @@ function getStencilMask(option) {
40
37
  }
41
38
  };
42
39
  }
43
-
44
40
  return {
45
41
  enable: true,
46
42
  mask: 0xff,
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getGlyphQuads = getGlyphQuads;
7
7
  exports.shapeText = shapeText;
8
-
9
8
  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; } } }; }
10
-
11
9
  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); }
12
-
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; }
14
-
10
+ 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; }
15
11
  /**
16
12
  * 返回文本相对锚点位置
17
13
  * @param {string} anchor 锚点位置
@@ -20,76 +16,64 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
20
16
  function getAnchorAlignment(anchor) {
21
17
  var horizontalAlign = 0.5;
22
18
  var verticalAlign = 0.5;
23
-
24
19
  switch (anchor) {
25
20
  case 'right':
26
21
  case 'top-right':
27
22
  case 'bottom-right':
28
23
  horizontalAlign = 1;
29
24
  break;
30
-
31
25
  case 'left':
32
26
  case 'top-left':
33
27
  case 'bottom-left':
34
28
  horizontalAlign = 0;
35
29
  break;
36
-
37
30
  default:
38
31
  horizontalAlign = 0.5;
39
32
  }
40
-
41
33
  switch (anchor) {
42
34
  case 'bottom':
43
35
  case 'bottom-right':
44
36
  case 'bottom-left':
45
37
  verticalAlign = 1;
46
38
  break;
47
-
48
39
  case 'top':
49
40
  case 'top-right':
50
41
  case 'top-left':
51
42
  verticalAlign = 0;
52
43
  break;
53
-
54
44
  default:
55
45
  verticalAlign = 0.5;
56
46
  }
57
-
58
47
  return {
59
48
  horizontalAlign: horizontalAlign,
60
49
  verticalAlign: verticalAlign
61
50
  };
62
- } // justify right = 1, left = 0, center = 0.5
63
-
51
+ }
64
52
 
53
+ // justify right = 1, left = 0, center = 0.5
65
54
  function justifyLine(positionedGlyphs, glyphMap, start, end, justify) {
66
55
  if (!justify) {
67
56
  return;
68
57
  }
69
-
70
58
  var lastPositionedGlyph = positionedGlyphs[end];
71
59
  var glyph = lastPositionedGlyph.glyph;
72
-
73
60
  if (glyph) {
74
61
  var lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;
75
62
  var lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;
76
-
77
63
  for (var j = start; j <= end; j++) {
78
64
  positionedGlyphs[j].x -= lineIndent;
79
65
  }
80
66
  }
81
- } // justify right=1 left=0 center=0.5
67
+ }
68
+
69
+ // justify right=1 left=0 center=0.5
82
70
  // horizontalAlign right=1 left=0 center=0.5
83
71
  // verticalAlign right=1 left=0 center=0.5
84
-
85
-
86
72
  function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lineCount) {
87
73
  var shiftX = (justify - horizontalAlign) * maxLineLength;
88
74
  var shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
89
-
90
75
  var _iterator = _createForOfIteratorHelper(positionedGlyphs),
91
- _step;
92
-
76
+ _step;
93
77
  try {
94
78
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
95
79
  var glyphs = _step.value;
@@ -102,7 +86,6 @@ function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLin
102
86
  _iterator.f();
103
87
  }
104
88
  }
105
-
106
89
  function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustify, spacing) {
107
90
  // buffer 为 4
108
91
  var yOffset = -8;
@@ -116,7 +99,6 @@ function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustif
116
99
  line.split('').forEach(function (char) {
117
100
  var glyph = glyphMap[char];
118
101
  var baselineOffset = 0;
119
-
120
102
  if (glyph) {
121
103
  positionedGlyphs.push({
122
104
  glyph: char,
@@ -129,31 +111,29 @@ function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustif
129
111
  });
130
112
  x += glyph.advance + spacing;
131
113
  }
132
- }); // 左右对齐
114
+ });
133
115
 
116
+ // 左右对齐
134
117
  if (positionedGlyphs.length !== lineStartIndex) {
135
118
  var lineLength = x - spacing;
136
119
  maxLineLength = Math.max(lineLength, maxLineLength);
137
120
  justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
138
121
  }
139
-
140
122
  x = 0;
141
123
  y -= lineHeight + 5;
142
124
  });
143
-
144
125
  var _getAnchorAlignment = getAnchorAlignment(textAnchor),
145
- horizontalAlign = _getAnchorAlignment.horizontalAlign,
146
- verticalAlign = _getAnchorAlignment.verticalAlign;
147
-
148
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length); // 计算包围盒
126
+ horizontalAlign = _getAnchorAlignment.horizontalAlign,
127
+ verticalAlign = _getAnchorAlignment.verticalAlign;
128
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length);
149
129
 
130
+ // 计算包围盒
150
131
  var height = y - yOffset;
151
132
  shaping.top += -verticalAlign * height;
152
133
  shaping.bottom = shaping.top - height;
153
134
  shaping.left += -horizontalAlign * maxLineLength;
154
135
  shaping.right = shaping.left + maxLineLength;
155
136
  }
156
-
157
137
  function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, textJustify, spacing) {
158
138
  // buffer 为 4
159
139
  var yOffset = -8;
@@ -166,12 +146,10 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
166
146
  iconfonts.forEach(function (iconfont) {
167
147
  var glyph = glyphMap[iconfont];
168
148
  var baselineOffset = 0;
169
-
170
149
  if (glyph) {
171
150
  positionedGlyphs.push({
172
151
  glyph: iconfont,
173
152
  // x,
174
-
175
153
  /**
176
154
  * iconfont
177
155
  * 在计算大小的时候计算的是 unicode 字符 如 &#xe6d4;
@@ -185,31 +163,30 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
185
163
  metrics: glyph
186
164
  });
187
165
  x += glyph.advance + spacing;
188
- } // 左右对齐
189
-
166
+ }
190
167
 
168
+ // 左右对齐
191
169
  if (positionedGlyphs.length !== lineStartIndex) {
192
170
  var lineLength = x - spacing;
193
171
  maxLineLength = Math.max(lineLength, maxLineLength);
194
172
  justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
195
173
  }
196
-
197
174
  x = 0;
198
175
  y -= lineHeight + 5;
199
176
  });
200
-
201
177
  var _getAnchorAlignment2 = getAnchorAlignment(textAnchor),
202
- horizontalAlign = _getAnchorAlignment2.horizontalAlign,
203
- verticalAlign = _getAnchorAlignment2.verticalAlign;
204
-
205
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length); // 计算包围盒
178
+ horizontalAlign = _getAnchorAlignment2.horizontalAlign,
179
+ verticalAlign = _getAnchorAlignment2.verticalAlign;
180
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length);
206
181
 
182
+ // 计算包围盒
207
183
  var height = y - yOffset;
208
184
  shaping.top += -verticalAlign * height;
209
185
  shaping.bottom = shaping.top - height;
210
186
  shaping.left += -horizontalAlign * maxLineLength;
211
187
  shaping.right = shaping.left + maxLineLength;
212
188
  }
189
+
213
190
  /**
214
191
  * 计算文本中每个独立字符相对锚点的位置
215
192
  *
@@ -223,8 +200,6 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
223
200
  * @param {[boolean]} isIconFont 是否是 iconfont
224
201
  * @return {boolean|shaping} 每个字符相对于锚点的位置
225
202
  */
226
-
227
-
228
203
  function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spacing) {
229
204
  var translate = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [0, 0];
230
205
  var isIconFont = arguments.length > 7 ? arguments[7] : undefined;
@@ -241,29 +216,25 @@ function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spacing) {
241
216
  text: text
242
217
  };
243
218
  isIconFont ? shapeIconFont(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing) : shapeLines(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing);
244
-
245
219
  if (!positionedGlyphs.length) {
246
220
  return false;
247
221
  }
248
-
249
222
  return shaping;
250
223
  }
251
-
252
224
  function getGlyphQuads(shaping) {
253
225
  var textOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
254
226
  var alongLine = arguments.length > 2 ? arguments[2] : undefined;
255
227
  var _shaping$positionedGl = shaping.positionedGlyphs,
256
- positionedGlyphs = _shaping$positionedGl === void 0 ? [] : _shaping$positionedGl;
228
+ positionedGlyphs = _shaping$positionedGl === void 0 ? [] : _shaping$positionedGl;
257
229
  var quads = [];
258
-
259
230
  var _iterator2 = _createForOfIteratorHelper(positionedGlyphs),
260
- _step2;
261
-
231
+ _step2;
262
232
  try {
263
233
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
264
234
  var positionedGlyph = _step2.value;
265
- var rect = positionedGlyph.metrics; // The rects have an addditional buffer that is not included in their size.
235
+ var rect = positionedGlyph.metrics;
266
236
 
237
+ // The rects have an addditional buffer that is not included in their size.
267
238
  var rectBuffer = 4;
268
239
  var halfAdvance = rect.advance * positionedGlyph.scale / 2;
269
240
  var glyphOffset = alongLine ? [positionedGlyph.x + halfAdvance, positionedGlyph.y] : [0, 0];
@@ -287,7 +258,9 @@ function getGlyphQuads(shaping) {
287
258
  var br = {
288
259
  x: x2,
289
260
  y: y2
290
- }; // TODO:处理字符旋转的情况
261
+ };
262
+
263
+ // TODO:处理字符旋转的情况
291
264
 
292
265
  quads.push({
293
266
  tl: tl,
@@ -303,6 +276,5 @@ function getGlyphQuads(shaping) {
303
276
  } finally {
304
277
  _iterator2.f();
305
278
  }
306
-
307
279
  return quads;
308
280
  }