@antv/l7-layers 2.16.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/es/Geometry/index.js +31 -9
  2. package/es/Geometry/models/billboard.js +89 -51
  3. package/es/Geometry/models/plane.js +143 -81
  4. package/es/Geometry/models/sprite.js +118 -60
  5. package/es/canvas/index.js +33 -10
  6. package/es/canvas/models/canvas.js +97 -41
  7. package/es/citybuliding/building.js +27 -8
  8. package/es/citybuliding/models/build.js +82 -57
  9. package/es/core/BaseLayer.js +485 -321
  10. package/es/core/BaseModel.js +126 -97
  11. package/es/core/LayerPickService.js +32 -21
  12. package/es/core/TextureService.js +13 -0
  13. package/es/core/interface.js +24 -17
  14. package/es/core/shape/Path.js +20 -13
  15. package/es/core/shape/extrude.js +31 -10
  16. package/es/core/triangulation.js +114 -54
  17. package/es/earth/index.js +33 -9
  18. package/es/earth/models/atmosphere.js +54 -30
  19. package/es/earth/models/base.js +85 -47
  20. package/es/earth/models/bloomsphere.js +54 -30
  21. package/es/earth/utils.js +13 -9
  22. package/es/heatmap/index.js +40 -10
  23. package/es/heatmap/models/grid.js +52 -28
  24. package/es/heatmap/models/grid3d.js +52 -28
  25. package/es/heatmap/models/heatmap.js +146 -91
  26. package/es/heatmap/models/hexagon.js +52 -28
  27. package/es/heatmap/triangulation.js +4 -0
  28. package/es/image/index.js +28 -9
  29. package/es/image/models/image.js +100 -66
  30. package/es/index.js +17 -9
  31. package/es/line/index.js +34 -9
  32. package/es/line/models/arc.js +118 -66
  33. package/es/line/models/arc_3d.js +108 -60
  34. package/es/line/models/earthArc_3d.js +111 -63
  35. package/es/line/models/great_circle.js +100 -56
  36. package/es/line/models/half.js +77 -46
  37. package/es/line/models/line.js +148 -94
  38. package/es/line/models/linearline.js +80 -45
  39. package/es/line/models/simpleLine.js +74 -41
  40. package/es/line/models/wall.js +92 -52
  41. package/es/mask/index.js +28 -9
  42. package/es/mask/models/fill.js +54 -29
  43. package/es/plugins/DataMappingPlugin.js +117 -80
  44. package/es/plugins/DataSourcePlugin.js +68 -45
  45. package/es/plugins/FeatureScalePlugin.js +122 -67
  46. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  47. package/es/plugins/LayerMaskPlugin.js +11 -3
  48. package/es/plugins/LayerModelPlugin.js +104 -67
  49. package/es/plugins/LayerStylePlugin.js +9 -3
  50. package/es/plugins/LightingPlugin.js +18 -12
  51. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  52. package/es/plugins/PixelPickingPlugin.js +21 -12
  53. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  54. package/es/plugins/ShaderUniformPlugin.js +27 -13
  55. package/es/plugins/UpdateModelPlugin.js +5 -0
  56. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  57. package/es/point/index.js +77 -26
  58. package/es/point/models/earthExtrude.js +102 -61
  59. package/es/point/models/earthFill.js +87 -57
  60. package/es/point/models/extrude.js +101 -60
  61. package/es/point/models/fill.js +100 -70
  62. package/es/point/models/fillmage.js +107 -63
  63. package/es/point/models/image.js +88 -48
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +54 -30
  66. package/es/point/models/radar.js +64 -40
  67. package/es/point/models/simplePoint.js +69 -41
  68. package/es/point/models/text.js +301 -198
  69. package/es/point/shape/extrude.js +13 -4
  70. package/es/polygon/index.js +40 -11
  71. package/es/polygon/models/extrude.js +92 -48
  72. package/es/polygon/models/fill.js +88 -54
  73. package/es/polygon/models/index.js +2 -3
  74. package/es/polygon/models/ocean.js +76 -42
  75. package/es/polygon/models/water.js +71 -37
  76. package/es/raster/buffers/triangulation.js +4 -2
  77. package/es/raster/index.js +32 -9
  78. package/es/raster/models/raster.js +116 -80
  79. package/es/raster/models/rasterRgb.js +127 -84
  80. package/es/raster/models/rasterTerrainRgb.js +84 -56
  81. package/es/tile/interaction/getRasterData.js +20 -14
  82. package/es/tile/interaction/utils.js +9 -7
  83. package/es/tile/manager/base.js +96 -63
  84. package/es/tile/service/TileLayerService.js +55 -33
  85. package/es/tile/service/TilePickService.js +40 -26
  86. package/es/tile/service/TileSourceService.js +7 -3
  87. package/es/tile/tileFactory/DebugTile.js +46 -29
  88. package/es/tile/tileFactory/ImageTile.js +38 -20
  89. package/es/tile/tileFactory/MaskTile.js +43 -22
  90. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  91. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  92. package/es/tile/tileFactory/RasterTile.js +53 -30
  93. package/es/tile/tileFactory/Tile.js +97 -63
  94. package/es/tile/tileFactory/VectorTile.js +68 -41
  95. package/es/tile/tileFactory/index.js +11 -0
  96. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  97. package/es/tile/tileFactory/util.js +3 -0
  98. package/es/tile/tileLayer/BaseLayer.js +146 -105
  99. package/es/tile/utils.js +1 -1
  100. package/es/utils/blend.js +2 -0
  101. package/es/utils/collision-index.js +16 -9
  102. package/es/utils/dataMappingStyle.js +18 -8
  103. package/es/utils/extrude_polyline.js +149 -101
  104. package/es/utils/grid-index.js +27 -2
  105. package/es/utils/identityScale.js +8 -0
  106. package/es/utils/layerData.js +44 -30
  107. package/es/utils/multiPassRender.js +13 -11
  108. package/es/utils/polylineNormal.js +37 -31
  109. package/es/utils/simpleLine.js +16 -2
  110. package/es/utils/stencil.js +3 -2
  111. package/es/utils/symbol-layout.js +53 -27
  112. package/es/wind/index.js +29 -9
  113. package/es/wind/models/utils.js +51 -26
  114. package/es/wind/models/wind.js +147 -101
  115. package/es/wind/models/windRender.js +66 -53
  116. package/lib/Geometry/index.js +38 -9
  117. package/lib/Geometry/models/billboard.js +97 -51
  118. package/lib/Geometry/models/index.js +5 -0
  119. package/lib/Geometry/models/plane.js +151 -79
  120. package/lib/Geometry/models/sprite.js +127 -60
  121. package/lib/canvas/index.js +40 -10
  122. package/lib/canvas/models/canvas.js +101 -41
  123. package/lib/canvas/models/index.js +3 -0
  124. package/lib/citybuliding/building.js +35 -8
  125. package/lib/citybuliding/models/build.js +92 -57
  126. package/lib/core/BaseLayer.js +479 -321
  127. package/lib/core/BaseModel.js +139 -97
  128. package/lib/core/LayerPickService.js +37 -21
  129. package/lib/core/TextureService.js +16 -0
  130. package/lib/core/interface.js +31 -21
  131. package/lib/core/schema.js +1 -0
  132. package/lib/core/shape/Path.js +31 -14
  133. package/lib/core/shape/extrude.js +54 -10
  134. package/lib/core/triangulation.js +153 -53
  135. package/lib/earth/index.js +43 -9
  136. package/lib/earth/models/atmosphere.js +63 -30
  137. package/lib/earth/models/base.js +90 -47
  138. package/lib/earth/models/bloomsphere.js +63 -30
  139. package/lib/earth/utils.js +31 -7
  140. package/lib/heatmap/index.js +48 -10
  141. package/lib/heatmap/models/grid.js +60 -28
  142. package/lib/heatmap/models/grid3d.js +60 -28
  143. package/lib/heatmap/models/heatmap.js +162 -91
  144. package/lib/heatmap/models/hexagon.js +60 -28
  145. package/lib/heatmap/models/index.js +6 -0
  146. package/lib/heatmap/triangulation.js +5 -0
  147. package/lib/image/index.js +36 -9
  148. package/lib/image/models/image.js +109 -66
  149. package/lib/image/models/index.js +3 -0
  150. package/lib/index.js +61 -7
  151. package/lib/line/index.js +40 -9
  152. package/lib/line/models/arc.js +128 -64
  153. package/lib/line/models/arc_3d.js +119 -58
  154. package/lib/line/models/earthArc_3d.js +122 -61
  155. package/lib/line/models/great_circle.js +111 -56
  156. package/lib/line/models/half.js +87 -46
  157. package/lib/line/models/index.js +11 -0
  158. package/lib/line/models/line.js +156 -92
  159. package/lib/line/models/linearline.js +92 -45
  160. package/lib/line/models/simpleLine.js +84 -41
  161. package/lib/line/models/wall.js +103 -52
  162. package/lib/mask/index.js +36 -9
  163. package/lib/mask/models/fill.js +63 -29
  164. package/lib/mask/models/index.js +3 -0
  165. package/lib/plugins/DataMappingPlugin.js +128 -80
  166. package/lib/plugins/DataSourcePlugin.js +76 -45
  167. package/lib/plugins/FeatureScalePlugin.js +138 -67
  168. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  169. package/lib/plugins/LayerMaskPlugin.js +17 -4
  170. package/lib/plugins/LayerModelPlugin.js +113 -68
  171. package/lib/plugins/LayerStylePlugin.js +14 -4
  172. package/lib/plugins/LightingPlugin.js +25 -12
  173. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  174. package/lib/plugins/PixelPickingPlugin.js +27 -12
  175. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  176. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  177. package/lib/plugins/UpdateModelPlugin.js +10 -1
  178. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  179. package/lib/point/index.js +83 -26
  180. package/lib/point/models/earthExtrude.js +113 -61
  181. package/lib/point/models/earthFill.js +117 -57
  182. package/lib/point/models/extrude.js +111 -60
  183. package/lib/point/models/fill.js +109 -68
  184. package/lib/point/models/fillmage.js +115 -61
  185. package/lib/point/models/image.js +98 -48
  186. package/lib/point/models/index.js +12 -1
  187. package/lib/point/models/normal.js +64 -30
  188. package/lib/point/models/radar.js +74 -40
  189. package/lib/point/models/simplePoint.js +79 -41
  190. package/lib/point/models/text.js +309 -198
  191. package/lib/point/shape/extrude.js +20 -4
  192. package/lib/polygon/index.js +48 -11
  193. package/lib/polygon/models/extrude.js +103 -48
  194. package/lib/polygon/models/fill.js +98 -54
  195. package/lib/polygon/models/index.js +14 -2
  196. package/lib/polygon/models/ocean.js +88 -42
  197. package/lib/polygon/models/water.js +82 -37
  198. package/lib/raster/buffers/triangulation.js +7 -3
  199. package/lib/raster/index.js +40 -9
  200. package/lib/raster/models/index.js +5 -0
  201. package/lib/raster/models/raster.js +125 -80
  202. package/lib/raster/models/rasterRgb.js +139 -84
  203. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  204. package/lib/tile/interaction/getRasterData.js +25 -14
  205. package/lib/tile/interaction/utils.js +19 -7
  206. package/lib/tile/manager/base.js +104 -63
  207. package/lib/tile/service/TileLayerService.js +60 -33
  208. package/lib/tile/service/TilePickService.js +48 -26
  209. package/lib/tile/service/TileSourceService.js +16 -2
  210. package/lib/tile/style/utils.js +3 -0
  211. package/lib/tile/tileFactory/DebugTile.js +54 -29
  212. package/lib/tile/tileFactory/ImageTile.js +46 -20
  213. package/lib/tile/tileFactory/MaskTile.js +51 -22
  214. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  215. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  216. package/lib/tile/tileFactory/RasterTile.js +63 -30
  217. package/lib/tile/tileFactory/Tile.js +102 -63
  218. package/lib/tile/tileFactory/VectorTile.js +76 -41
  219. package/lib/tile/tileFactory/index.js +25 -0
  220. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  221. package/lib/tile/tileFactory/util.js +9 -0
  222. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  223. package/lib/tile/utils.js +5 -1
  224. package/lib/utils/blend.js +5 -0
  225. package/lib/utils/collision-index.js +25 -9
  226. package/lib/utils/dataMappingStyle.js +19 -8
  227. package/lib/utils/extrude_polyline.js +181 -101
  228. package/lib/utils/grid-index.js +28 -2
  229. package/lib/utils/identityScale.js +9 -0
  230. package/lib/utils/layerData.js +49 -30
  231. package/lib/utils/multiPassRender.js +16 -11
  232. package/lib/utils/polylineNormal.js +66 -31
  233. package/lib/utils/simpleLine.js +21 -2
  234. package/lib/utils/stencil.js +4 -0
  235. package/lib/utils/symbol-layout.js +55 -27
  236. package/lib/wind/index.js +37 -9
  237. package/lib/wind/models/index.js +3 -0
  238. package/lib/wind/models/utils.js +62 -26
  239. package/lib/wind/models/wind.js +157 -101
  240. package/lib/wind/models/windRender.js +71 -53
  241. package/lib/wind/models/windShader.js +1 -0
  242. package/package.json +7 -7
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -9,41 +10,66 @@ exports.computeNormal = computeNormal;
9
10
  exports.default = void 0;
10
11
  exports.direction = direction;
11
12
  exports.getArrayUnique = getArrayUnique;
13
+
12
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
13
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
14
18
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
15
20
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
16
22
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
17
24
  var _l7Utils = require("@antv/l7-utils");
25
+
18
26
  var _glMatrix = require("gl-matrix");
19
- var tmp = _glMatrix.vec2.create();
20
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+
28
+ var tmp = _glMatrix.vec2.create(); // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+
30
+
21
31
  var capEnd = _glMatrix.vec2.create();
32
+
22
33
  var lineA = _glMatrix.vec2.create();
34
+
23
35
  var lineB = _glMatrix.vec2.create();
36
+
24
37
  var tangent = _glMatrix.vec2.create();
38
+
25
39
  function computeMiter(lineTangent, miter, start, end, halfThick) {
26
40
  _glMatrix.vec2.add(lineTangent, start, end);
41
+
27
42
  _glMatrix.vec2.normalize(lineTangent, lineTangent);
43
+
28
44
  miter = _glMatrix.vec2.fromValues(-lineTangent[1], lineTangent[0]);
45
+
29
46
  var tmpvec = _glMatrix.vec2.fromValues(-start[1], start[0]);
47
+
30
48
  return [halfThick / _glMatrix.vec2.dot(miter, tmpvec), miter];
31
49
  }
50
+
32
51
  function computeNormal(out, dir) {
33
52
  return _glMatrix.vec2.set(out, -dir[1], dir[0]);
34
53
  }
54
+
35
55
  function direction(out, a, b) {
36
56
  _glMatrix.vec2.sub(out, a, b);
57
+
37
58
  _glMatrix.vec2.normalize(out, out);
59
+
38
60
  return out;
39
61
  }
62
+
40
63
  function isPointEqual(a, b) {
41
64
  return a[0] === b[0] && a[1] === b[1];
42
65
  }
66
+
43
67
  function getArrayUnique(matrix) {
44
68
  var map = new Map();
69
+
45
70
  for (var i = 0; i < matrix.length; i++) {
46
71
  var key = matrix[0].toString() + '-' + matrix[1].toString();
72
+
47
73
  if (map.get(key)) {
48
74
  matrix.splice(i, 1);
49
75
  i++;
@@ -51,8 +77,10 @@ function getArrayUnique(matrix) {
51
77
  map.set(key, key);
52
78
  }
53
79
  }
80
+
54
81
  return matrix;
55
82
  }
83
+
56
84
  var ExtrudePolyline = /*#__PURE__*/function () {
57
85
  function ExtrudePolyline() {
58
86
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -76,19 +104,23 @@ var ExtrudePolyline = /*#__PURE__*/function () {
76
104
  indexes: []
77
105
  };
78
106
  }
107
+
79
108
  (0, _createClass2.default)(ExtrudePolyline, [{
80
109
  key: "simpleExtrude",
81
110
  value: function simpleExtrude(points) {
82
111
  var complex = this.complex;
112
+
83
113
  if (points.length <= 1) {
84
114
  return complex;
85
115
  }
116
+
86
117
  this.lastFlip = -1;
87
118
  this.started = false;
88
119
  this.normal = null;
89
120
  this.totalDistance = 0;
90
121
  var total = points.length;
91
122
  var count = complex.startIndex;
123
+
92
124
  for (var i = 1; i < total; i++) {
93
125
  var last = points[i - 1];
94
126
  var cur = points[i];
@@ -96,11 +128,13 @@ var ExtrudePolyline = /*#__PURE__*/function () {
96
128
  var amt = this.simpleSegment(complex, count, last, cur, next);
97
129
  count += amt;
98
130
  }
131
+
99
132
  if (this.dash) {
100
133
  for (var _i = 0; _i < complex.positions.length / 6; _i++) {
101
134
  complex.positions[_i * 6 + 5] = this.totalDistance;
102
135
  }
103
136
  }
137
+
104
138
  complex.startIndex = complex.positions.length / 6;
105
139
  return complex;
106
140
  }
@@ -108,47 +142,48 @@ var ExtrudePolyline = /*#__PURE__*/function () {
108
142
  key: "simpleExtrude_gaode2",
109
143
  value: function simpleExtrude_gaode2(points, originPoints) {
110
144
  var complex = this.complex;
145
+
111
146
  if (points.length <= 1) {
112
147
  return complex;
113
148
  }
149
+
114
150
  this.lastFlip = -1;
115
151
  this.started = false;
116
152
  this.normal = null;
117
- this.totalDistance = 0;
118
- // 去除数组里重复的点
153
+ this.totalDistance = 0; // 去除数组里重复的点
119
154
  // points = getArrayUnique(points);
155
+
120
156
  var total = points.length;
121
157
  var count = complex.startIndex;
158
+
122
159
  for (var i = 1; i < total; i++) {
123
160
  var _originPoints$, _originPoints$i$, _originPoints$2;
161
+
124
162
  var last = points[i - 1];
125
- last.push((_originPoints$ = originPoints[i - 1][2]) !== null && _originPoints$ !== void 0 ? _originPoints$ : 0);
126
- // @ts-ignore
163
+ last.push((_originPoints$ = originPoints[i - 1][2]) !== null && _originPoints$ !== void 0 ? _originPoints$ : 0); // @ts-ignore
164
+
127
165
  var originLast = originPoints[i - 1];
128
166
  var cur = points[i];
129
- cur.push((_originPoints$i$ = originPoints[i][2]) !== null && _originPoints$i$ !== void 0 ? _originPoints$i$ : 0);
130
- // @ts-ignore
167
+ cur.push((_originPoints$i$ = originPoints[i][2]) !== null && _originPoints$i$ !== void 0 ? _originPoints$i$ : 0); // @ts-ignore
168
+
131
169
  var originCur = originPoints[i];
132
170
  var next = i < points.length - 1 ? [].concat((0, _toConsumableArray2.default)(points[i + 1]), [(_originPoints$2 = originPoints[i + 1][2]) !== null && _originPoints$2 !== void 0 ? _originPoints$2 : 0]) : null;
133
171
  var originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
134
- var amt = this.simpleSegment(complex, count,
135
- // @ts-ignore
136
- last,
137
- // @ts-ignore
138
- cur,
139
- // @ts-ignore
140
- next,
141
- // @ts-ignore
142
- originLast, originCur,
143
- // @ts-ignore
172
+ var amt = this.simpleSegment(complex, count, // @ts-ignore
173
+ last, // @ts-ignore
174
+ cur, // @ts-ignore
175
+ next, // @ts-ignore
176
+ originLast, originCur, // @ts-ignore
144
177
  originNext);
145
178
  count += amt;
146
179
  }
180
+
147
181
  if (this.dash) {
148
182
  for (var _i2 = 0; _i2 < complex.positions.length / 6; _i2++) {
149
183
  complex.positions[_i2 * 6 + 5] = this.totalDistance;
150
184
  }
151
185
  }
186
+
152
187
  complex.startIndex = complex.positions.length / 6;
153
188
  return complex;
154
189
  }
@@ -156,47 +191,48 @@ var ExtrudePolyline = /*#__PURE__*/function () {
156
191
  key: "extrude_gaode2",
157
192
  value: function extrude_gaode2(points, originPoints) {
158
193
  var complex = this.complex;
194
+
159
195
  if (points.length <= 1) {
160
196
  return complex;
161
197
  }
198
+
162
199
  this.lastFlip = -1;
163
200
  this.started = false;
164
201
  this.normal = null;
165
- this.totalDistance = 0;
166
- // 去除数组里重复的点
202
+ this.totalDistance = 0; // 去除数组里重复的点
167
203
  // points = getArrayUnique(points);
204
+
168
205
  var total = points.length;
169
206
  var count = complex.startIndex;
207
+
170
208
  for (var i = 1; i < total; i++) {
171
209
  var _originPoints$3, _originPoints$i$2, _originPoints$4;
210
+
172
211
  var last = points[i - 1];
173
- last.push((_originPoints$3 = originPoints[i - 1][2]) !== null && _originPoints$3 !== void 0 ? _originPoints$3 : 0);
174
- // @ts-ignore
212
+ last.push((_originPoints$3 = originPoints[i - 1][2]) !== null && _originPoints$3 !== void 0 ? _originPoints$3 : 0); // @ts-ignore
213
+
175
214
  var originLast = originPoints[i - 1];
176
215
  var cur = points[i];
177
- cur.push((_originPoints$i$2 = originPoints[i][2]) !== null && _originPoints$i$2 !== void 0 ? _originPoints$i$2 : 0);
178
- // @ts-ignore
216
+ cur.push((_originPoints$i$2 = originPoints[i][2]) !== null && _originPoints$i$2 !== void 0 ? _originPoints$i$2 : 0); // @ts-ignore
217
+
179
218
  var originCur = originPoints[i];
180
219
  var next = i < points.length - 1 ? [].concat((0, _toConsumableArray2.default)(points[i + 1]), [(_originPoints$4 = originPoints[i + 1][2]) !== null && _originPoints$4 !== void 0 ? _originPoints$4 : 0]) : null;
181
220
  var originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
182
- var amt = this.segment_gaode2(complex, count,
183
- // @ts-ignore
184
- last,
185
- // @ts-ignore
186
- cur,
187
- // @ts-ignore
188
- next,
189
- // @ts-ignore
190
- originLast, originCur,
191
- // @ts-ignore
221
+ var amt = this.segment_gaode2(complex, count, // @ts-ignore
222
+ last, // @ts-ignore
223
+ cur, // @ts-ignore
224
+ next, // @ts-ignore
225
+ originLast, originCur, // @ts-ignore
192
226
  originNext);
193
227
  count += amt;
194
228
  }
229
+
195
230
  if (this.dash) {
196
231
  for (var _i3 = 0; _i3 < complex.positions.length / 6; _i3++) {
197
232
  complex.positions[_i3 * 6 + 5] = this.totalDistance;
198
233
  }
199
234
  }
235
+
200
236
  complex.startIndex = complex.positions.length / 6;
201
237
  return complex;
202
238
  }
@@ -204,17 +240,20 @@ var ExtrudePolyline = /*#__PURE__*/function () {
204
240
  key: "extrude",
205
241
  value: function extrude(points) {
206
242
  var complex = this.complex;
243
+
207
244
  if (points.length <= 1) {
208
245
  return complex;
209
246
  }
247
+
210
248
  this.lastFlip = -1;
211
249
  this.started = false;
212
250
  this.normal = null;
213
- this.totalDistance = 0;
214
- // 去除数组里重复的点
251
+ this.totalDistance = 0; // 去除数组里重复的点
215
252
  // points = getArrayUnique(points);
253
+
216
254
  var total = points.length;
217
255
  var count = complex.startIndex;
256
+
218
257
  for (var i = 1; i < total; i++) {
219
258
  var last = points[i - 1];
220
259
  var cur = points[i];
@@ -222,11 +261,13 @@ var ExtrudePolyline = /*#__PURE__*/function () {
222
261
  var amt = this.segment(complex, count, last, cur, next);
223
262
  count += amt;
224
263
  }
264
+
225
265
  if (this.dash) {
226
266
  for (var _i4 = 0; _i4 < complex.positions.length / 6; _i4++) {
227
267
  complex.positions[_i4 * 6 + 5] = this.totalDistance;
228
268
  }
229
269
  }
270
+
230
271
  complex.startIndex = complex.positions.length / 6;
231
272
  return complex;
232
273
  }
@@ -238,24 +279,29 @@ var ExtrudePolyline = /*#__PURE__*/function () {
238
279
  var positions = complex.positions;
239
280
  var normals = complex.normals;
240
281
  var flatCur = (0, _l7Utils.aProjectFlat)([cur[0], cur[1]]);
241
- var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]);
242
- // @ts-ignore
282
+ var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]); // @ts-ignore
283
+
243
284
  direction(lineA, flatCur, flatLast);
244
285
  var segmentDistance = 0;
286
+
245
287
  if (this.dash) {
246
288
  // @ts-ignore
247
289
  segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
248
290
  this.totalDistance += segmentDistance;
249
291
  }
292
+
250
293
  if (!this.normal) {
251
294
  this.normal = _glMatrix.vec2.create();
252
295
  computeNormal(this.normal, lineA);
253
296
  }
297
+
254
298
  if (!this.started) {
255
299
  this.started = true;
256
300
  this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
257
301
  }
302
+
258
303
  indices.push(index + 0, index + 1, index + 2);
304
+
259
305
  if (!next) {
260
306
  computeNormal(this.normal, lineA);
261
307
  this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
@@ -263,36 +309,36 @@ var ExtrudePolyline = /*#__PURE__*/function () {
263
309
  count += 2;
264
310
  } else {
265
311
  var flatNext = (0, _l7Utils.aProjectFlat)([next[0], next[1]]);
312
+
266
313
  if (isPointEqual(flatCur, flatNext)) {
267
314
  _glMatrix.vec2.add(flatNext, flatCur, _glMatrix.vec2.normalize(flatNext, _glMatrix.vec2.subtract(flatNext, flatCur, flatLast)));
268
315
  }
269
- direction(lineB, flatNext, flatCur);
270
316
 
271
- // stores tangent & miter
317
+ direction(lineB, flatNext, flatCur); // stores tangent & miter
272
318
 
273
319
  var _computeMiter = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
274
- _computeMiter2 = (0, _slicedToArray2.default)(_computeMiter, 2),
275
- miterLen = _computeMiter2[0],
276
- miter = _computeMiter2[1];
277
- // normal(tmp, lineA)
278
-
320
+ _computeMiter2 = (0, _slicedToArray2.default)(_computeMiter, 2),
321
+ miterLen = _computeMiter2[0],
322
+ miter = _computeMiter2[1]; // normal(tmp, lineA)
279
323
  // get orientation
324
+
325
+
280
326
  var flip = _glMatrix.vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
281
327
  this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
282
328
  indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
283
- flip = -1;
329
+ flip = -1; // the miter is now the normal for our next join
284
330
 
285
- // the miter is now the normal for our next join
286
331
  _glMatrix.vec2.copy(this.normal, miter);
332
+
287
333
  count += 2;
288
334
  this.lastFlip = flip;
289
335
  }
336
+
290
337
  return count;
291
338
  }
292
339
  }, {
293
340
  key: "segment_gaode2",
294
- value: function segment_gaode2(complex, index, last, cur, next, originLast, originCur,
295
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
341
+ value: function segment_gaode2(complex, index, last, cur, next, originLast, originCur, // eslint-disable-next-line @typescript-eslint/no-unused-vars
296
342
  originNext) {
297
343
  var count = 0;
298
344
  var indices = complex.indices;
@@ -301,29 +347,35 @@ var ExtrudePolyline = /*#__PURE__*/function () {
301
347
  var capSquare = this.cap === 'square';
302
348
  var joinBevel = this.join === 'bevel';
303
349
  var flatCur = (0, _l7Utils.aProjectFlat)([originCur[0], originCur[1]]);
304
- var flatLast = (0, _l7Utils.aProjectFlat)([originLast[0], originLast[1]]);
305
- // @ts-ignore
350
+ var flatLast = (0, _l7Utils.aProjectFlat)([originLast[0], originLast[1]]); // @ts-ignore
351
+
306
352
  direction(lineA, cur, last);
307
353
  var segmentDistance = 0;
354
+
308
355
  if (this.dash) {
309
356
  // @ts-ignore
310
357
  segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
311
358
  this.totalDistance += segmentDistance;
312
359
  }
360
+
313
361
  if (!this.normal) {
314
362
  this.normal = _glMatrix.vec2.create();
315
363
  computeNormal(this.normal, lineA);
316
364
  }
365
+
317
366
  if (!this.started) {
318
- this.started = true;
367
+ this.started = true; // if the end cap is type square, we can just push the verts out a bit
319
368
 
320
- // if the end cap is type square, we can just push the verts out a bit
321
369
  if (capSquare) {
322
370
  // vec2.scaleAndAdd(capEnd, last, lineA, -this.thickness);
323
371
  var out1 = _glMatrix.vec2.create();
372
+
324
373
  var out2 = _glMatrix.vec2.create();
374
+
325
375
  _glMatrix.vec2.add(out1, this.normal, lineA);
376
+
326
377
  _glMatrix.vec2.add(out2, this.normal, lineA);
378
+
327
379
  normals.push(out2[0], out2[1], 0);
328
380
  normals.push(out1[0], out1[1], 0);
329
381
  positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
@@ -335,14 +387,21 @@ var ExtrudePolyline = /*#__PURE__*/function () {
335
387
  this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
336
388
  }
337
389
  }
390
+
338
391
  indices.push(index + 0, index + 1, index + 2);
392
+
339
393
  if (!next) {
340
394
  computeNormal(this.normal, lineA);
395
+
341
396
  if (capSquare) {
342
397
  var _out = _glMatrix.vec2.create();
398
+
343
399
  var _out2 = _glMatrix.vec2.create();
400
+
344
401
  _glMatrix.vec2.sub(_out2, lineA, this.normal);
402
+
345
403
  _glMatrix.vec2.add(_out, lineA, this.normal);
404
+
346
405
  normals.push(_out2[0], _out2[1], 0);
347
406
  normals.push(_out[0], _out[1], 0);
348
407
  positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
@@ -353,40 +412,40 @@ var ExtrudePolyline = /*#__PURE__*/function () {
353
412
  } else {
354
413
  this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
355
414
  }
415
+
356
416
  indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
357
417
  count += 2;
358
418
  } else {
359
419
  // @ts-ignore
360
420
  if (isPointEqual(cur, next)) {
361
- _glMatrix.vec2.add(
362
- // @ts-ignore
363
- next,
364
- // @ts-ignore
365
- cur, _glMatrix.vec2.normalize(
366
- // @ts-ignore
367
- next,
368
- // @ts-ignore
421
+ _glMatrix.vec2.add( // @ts-ignore
422
+ next, // @ts-ignore
423
+ cur, _glMatrix.vec2.normalize( // @ts-ignore
424
+ next, // @ts-ignore
369
425
  _glMatrix.vec2.subtract(next, cur, last)));
370
- }
371
- // @ts-ignore
372
- direction(lineB, next, cur);
373
- // stores tangent & miter
426
+ } // @ts-ignore
374
427
 
375
- var _computeMiter3 = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
376
- _computeMiter4 = (0, _slicedToArray2.default)(_computeMiter3, 2),
377
- miterLen = _computeMiter4[0],
378
- miter = _computeMiter4[1];
379
- // normal(tmp, lineA)
380
428
 
429
+ direction(lineB, next, cur); // stores tangent & miter
430
+
431
+ var _computeMiter3 = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
432
+ _computeMiter4 = (0, _slicedToArray2.default)(_computeMiter3, 2),
433
+ miterLen = _computeMiter4[0],
434
+ miter = _computeMiter4[1]; // normal(tmp, lineA)
381
435
  // get orientation
436
+
437
+
382
438
  var flip = _glMatrix.vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
383
439
  var bevel = joinBevel;
440
+
384
441
  if (!bevel && this.join === 'miter') {
385
442
  var limit = miterLen;
443
+
386
444
  if (limit > this.miterLimit) {
387
445
  bevel = true;
388
446
  }
389
447
  }
448
+
390
449
  if (bevel) {
391
450
  normals.push(this.normal[0], this.normal[1], 0);
392
451
  normals.push(miter[0], miter[1], 0);
@@ -395,12 +454,14 @@ var ExtrudePolyline = /*#__PURE__*/function () {
395
454
  positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness * flip, cur[2] | 0);
396
455
  this.complex.indexes.push(this.currentIndex);
397
456
  this.currentIndex++;
398
- indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
457
+ indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3])); // now add the bevel triangle
399
458
 
400
- // now add the bevel triangle
401
459
  indices.push(index + 2, index + 3, index + 4);
402
460
  computeNormal(tmp, lineB);
461
+
403
462
  _glMatrix.vec2.copy(this.normal, tmp); // store normal for next round
463
+
464
+
404
465
  normals.push(this.normal[0], this.normal[1], 0);
405
466
  positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
406
467
  this.complex.indexes.push(this.currentIndex);
@@ -409,14 +470,16 @@ var ExtrudePolyline = /*#__PURE__*/function () {
409
470
  } else {
410
471
  this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
411
472
  indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
412
- flip = -1;
473
+ flip = -1; // the miter is now the normal for our next join
413
474
 
414
- // the miter is now the normal for our next join
415
475
  _glMatrix.vec2.copy(this.normal, miter);
476
+
416
477
  count += 2;
417
478
  }
479
+
418
480
  this.lastFlip = flip;
419
481
  }
482
+
420
483
  return count;
421
484
  }
422
485
  }, {
@@ -429,53 +492,65 @@ var ExtrudePolyline = /*#__PURE__*/function () {
429
492
  var capSquare = this.cap === 'square';
430
493
  var joinBevel = this.join === 'bevel';
431
494
  var flatCur = (0, _l7Utils.aProjectFlat)([cur[0], cur[1]]);
432
- var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]);
433
- // @ts-ignore
495
+ var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]); // @ts-ignore
496
+
434
497
  direction(lineA, flatCur, flatLast);
435
498
  var segmentDistance = 0;
499
+
436
500
  if (this.dash) {
437
501
  // @ts-ignore
438
502
  segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
439
503
  this.totalDistance += segmentDistance;
440
504
  }
505
+
441
506
  if (!this.normal) {
442
507
  this.normal = _glMatrix.vec2.create();
443
508
  computeNormal(this.normal, lineA);
444
509
  }
510
+
445
511
  if (!this.started) {
446
- this.started = true;
512
+ this.started = true; // if the end cap is type square, we can just push the verts out a bit
447
513
 
448
- // if the end cap is type square, we can just push the verts out a bit
449
514
  if (capSquare) {
450
515
  // vec2.scaleAndAdd(capEnd, last, lineA, -this.thickness);
451
516
  var out1 = _glMatrix.vec2.create();
517
+
452
518
  var out2 = _glMatrix.vec2.create();
519
+
453
520
  _glMatrix.vec2.add(out1, this.normal, lineA);
521
+
454
522
  _glMatrix.vec2.add(out2, this.normal, lineA);
523
+
455
524
  normals.push(out2[0], out2[1], 0);
456
525
  normals.push(out1[0], out1[1], 0);
457
526
  positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
458
527
  this.complex.indexes.push(this.currentIndex);
459
528
  positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, this.thickness, last[2] | 0);
460
529
  this.complex.indexes.push(this.currentIndex);
461
- this.currentIndex++;
462
- // this.extrusions(positions, normals, last, out, this.thickness);
530
+ this.currentIndex++; // this.extrusions(positions, normals, last, out, this.thickness);
463
531
  // last = capEnd;
464
532
  } else {
465
533
  this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
466
534
  }
467
535
  }
536
+
468
537
  indices.push(index + 0, index + 1, index + 2);
538
+
469
539
  if (!next) {
470
540
  computeNormal(this.normal, lineA);
541
+
471
542
  if (capSquare) {
472
543
  // vec2.scaleAndAdd(capEnd, cur, lineA, this.thickness);
473
544
  // cur = capEnd;
474
545
  var _out3 = _glMatrix.vec2.create();
546
+
475
547
  var _out4 = _glMatrix.vec2.create();
548
+
476
549
  _glMatrix.vec2.sub(_out4, lineA, this.normal);
477
- _glMatrix.vec2.add(_out3, lineA, this.normal);
478
- // this.extrusions(positions, normals, cur, out, this.thickness);
550
+
551
+ _glMatrix.vec2.add(_out3, lineA, this.normal); // this.extrusions(positions, normals, cur, out, this.thickness);
552
+
553
+
479
554
  normals.push(_out4[0], _out4[1], 0);
480
555
  normals.push(_out3[0], _out3[1], 0);
481
556
  positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
@@ -485,35 +560,38 @@ var ExtrudePolyline = /*#__PURE__*/function () {
485
560
  this.currentIndex++;
486
561
  } else {
487
562
  this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
488
- }
563
+ } // this.extrusions(positions, normals, cur, this.normal, this.thickness);
564
+
489
565
 
490
- // this.extrusions(positions, normals, cur, this.normal, this.thickness);
491
566
  indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
492
567
  count += 2;
493
568
  } else {
494
569
  var flatNext = (0, _l7Utils.aProjectFlat)([next[0], next[1]]);
570
+
495
571
  if (isPointEqual(flatCur, flatNext)) {
496
572
  _glMatrix.vec2.add(flatNext, flatCur, _glMatrix.vec2.normalize(flatNext, _glMatrix.vec2.subtract(flatNext, flatCur, flatLast)));
497
573
  }
498
- direction(lineB, flatNext, flatCur);
499
574
 
500
- // stores tangent & miter
575
+ direction(lineB, flatNext, flatCur); // stores tangent & miter
501
576
 
502
577
  var _computeMiter5 = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
503
- _computeMiter6 = (0, _slicedToArray2.default)(_computeMiter5, 2),
504
- miterLen = _computeMiter6[0],
505
- miter = _computeMiter6[1];
506
- // normal(tmp, lineA)
507
-
578
+ _computeMiter6 = (0, _slicedToArray2.default)(_computeMiter5, 2),
579
+ miterLen = _computeMiter6[0],
580
+ miter = _computeMiter6[1]; // normal(tmp, lineA)
508
581
  // get orientation
582
+
583
+
509
584
  var flip = _glMatrix.vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
510
585
  var bevel = joinBevel;
586
+
511
587
  if (!bevel && this.join === 'miter') {
512
588
  var limit = miterLen;
589
+
513
590
  if (limit > this.miterLimit) {
514
591
  bevel = true;
515
592
  }
516
593
  }
594
+
517
595
  if (bevel) {
518
596
  normals.push(this.normal[0], this.normal[1], 0);
519
597
  normals.push(miter[0], miter[1], 0);
@@ -522,12 +600,14 @@ var ExtrudePolyline = /*#__PURE__*/function () {
522
600
  positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness * flip, cur[2] | 0);
523
601
  this.complex.indexes.push(this.currentIndex);
524
602
  this.currentIndex++;
525
- indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
603
+ indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3])); // now add the bevel triangle
526
604
 
527
- // now add the bevel triangle
528
605
  indices.push(index + 2, index + 3, index + 4);
529
606
  computeNormal(tmp, lineB);
607
+
530
608
  _glMatrix.vec2.copy(this.normal, tmp); // store normal for next round
609
+
610
+
531
611
  normals.push(this.normal[0], this.normal[1], 0);
532
612
  positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
533
613
  this.complex.indexes.push(this.currentIndex);
@@ -536,24 +616,23 @@ var ExtrudePolyline = /*#__PURE__*/function () {
536
616
  } else {
537
617
  this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
538
618
  indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
539
- flip = -1;
619
+ flip = -1; // the miter is now the normal for our next join
540
620
 
541
- // the miter is now the normal for our next join
542
621
  _glMatrix.vec2.copy(this.normal, miter);
622
+
543
623
  count += 2;
544
624
  }
625
+
545
626
  this.lastFlip = flip;
546
627
  }
628
+
547
629
  return count;
548
630
  }
549
631
  }, {
550
632
  key: "extrusions",
551
- value: function extrusions(positions, normals, point,
552
- // 顶点
553
- normal,
554
- // 法向量
555
- thickness,
556
- // 高度
633
+ value: function extrusions(positions, normals, point, // 顶点
634
+ normal, // 法向量
635
+ thickness, // 高度
557
636
  distanceRadio) {
558
637
  normals.push(normal[0], normal[1], 0);
559
638
  normals.push(normal[0], normal[1], 0);
@@ -573,4 +652,5 @@ var ExtrudePolyline = /*#__PURE__*/function () {
573
652
  }]);
574
653
  return ExtrudePolyline;
575
654
  }();
655
+
576
656
  exports.default = ExtrudePolyline;