@antv/l7-layers 2.15.5 → 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 (243) 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 +486 -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.d.ts +2 -1
  69. package/es/point/models/text.js +305 -201
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +40 -11
  72. package/es/polygon/models/extrude.js +92 -48
  73. package/es/polygon/models/fill.js +88 -54
  74. package/es/polygon/models/index.js +2 -3
  75. package/es/polygon/models/ocean.js +76 -42
  76. package/es/polygon/models/water.js +71 -37
  77. package/es/raster/buffers/triangulation.js +4 -2
  78. package/es/raster/index.js +32 -9
  79. package/es/raster/models/raster.js +116 -80
  80. package/es/raster/models/rasterRgb.js +127 -84
  81. package/es/raster/models/rasterTerrainRgb.js +84 -56
  82. package/es/tile/interaction/getRasterData.js +20 -14
  83. package/es/tile/interaction/utils.js +9 -7
  84. package/es/tile/manager/base.js +96 -63
  85. package/es/tile/service/TileLayerService.js +55 -33
  86. package/es/tile/service/TilePickService.js +40 -26
  87. package/es/tile/service/TileSourceService.js +7 -3
  88. package/es/tile/tileFactory/DebugTile.js +46 -29
  89. package/es/tile/tileFactory/ImageTile.js +38 -20
  90. package/es/tile/tileFactory/MaskTile.js +43 -22
  91. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  93. package/es/tile/tileFactory/RasterTile.js +53 -30
  94. package/es/tile/tileFactory/Tile.js +97 -63
  95. package/es/tile/tileFactory/VectorTile.js +68 -41
  96. package/es/tile/tileFactory/index.js +11 -0
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  98. package/es/tile/tileFactory/util.js +3 -0
  99. package/es/tile/tileLayer/BaseLayer.js +146 -105
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +2 -0
  102. package/es/utils/collision-index.js +16 -9
  103. package/es/utils/dataMappingStyle.js +18 -8
  104. package/es/utils/extrude_polyline.js +149 -101
  105. package/es/utils/grid-index.js +27 -2
  106. package/es/utils/identityScale.js +8 -0
  107. package/es/utils/layerData.js +44 -30
  108. package/es/utils/multiPassRender.js +13 -11
  109. package/es/utils/polylineNormal.js +37 -31
  110. package/es/utils/simpleLine.js +16 -2
  111. package/es/utils/stencil.js +3 -2
  112. package/es/utils/symbol-layout.js +53 -27
  113. package/es/wind/index.js +29 -9
  114. package/es/wind/models/utils.js +51 -26
  115. package/es/wind/models/wind.js +147 -101
  116. package/es/wind/models/windRender.js +66 -53
  117. package/lib/Geometry/index.js +38 -9
  118. package/lib/Geometry/models/billboard.js +97 -51
  119. package/lib/Geometry/models/index.js +5 -0
  120. package/lib/Geometry/models/plane.js +151 -79
  121. package/lib/Geometry/models/sprite.js +127 -60
  122. package/lib/canvas/index.js +40 -10
  123. package/lib/canvas/models/canvas.js +101 -41
  124. package/lib/canvas/models/index.js +3 -0
  125. package/lib/citybuliding/building.js +35 -8
  126. package/lib/citybuliding/models/build.js +92 -57
  127. package/lib/core/BaseLayer.js +480 -321
  128. package/lib/core/BaseModel.js +139 -97
  129. package/lib/core/LayerPickService.js +37 -21
  130. package/lib/core/TextureService.js +16 -0
  131. package/lib/core/interface.js +31 -21
  132. package/lib/core/schema.js +1 -0
  133. package/lib/core/shape/Path.js +31 -14
  134. package/lib/core/shape/extrude.js +54 -10
  135. package/lib/core/triangulation.js +153 -53
  136. package/lib/earth/index.js +43 -9
  137. package/lib/earth/models/atmosphere.js +63 -30
  138. package/lib/earth/models/base.js +90 -47
  139. package/lib/earth/models/bloomsphere.js +63 -30
  140. package/lib/earth/utils.js +31 -7
  141. package/lib/heatmap/index.js +48 -10
  142. package/lib/heatmap/models/grid.js +60 -28
  143. package/lib/heatmap/models/grid3d.js +60 -28
  144. package/lib/heatmap/models/heatmap.js +162 -91
  145. package/lib/heatmap/models/hexagon.js +60 -28
  146. package/lib/heatmap/models/index.js +6 -0
  147. package/lib/heatmap/triangulation.js +5 -0
  148. package/lib/image/index.js +36 -9
  149. package/lib/image/models/image.js +109 -66
  150. package/lib/image/models/index.js +3 -0
  151. package/lib/index.js +61 -7
  152. package/lib/line/index.js +40 -9
  153. package/lib/line/models/arc.js +128 -64
  154. package/lib/line/models/arc_3d.js +119 -58
  155. package/lib/line/models/earthArc_3d.js +122 -61
  156. package/lib/line/models/great_circle.js +111 -56
  157. package/lib/line/models/half.js +87 -46
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +156 -92
  160. package/lib/line/models/linearline.js +92 -45
  161. package/lib/line/models/simpleLine.js +84 -41
  162. package/lib/line/models/wall.js +103 -52
  163. package/lib/mask/index.js +36 -9
  164. package/lib/mask/models/fill.js +63 -29
  165. package/lib/mask/models/index.js +3 -0
  166. package/lib/plugins/DataMappingPlugin.js +128 -80
  167. package/lib/plugins/DataSourcePlugin.js +76 -45
  168. package/lib/plugins/FeatureScalePlugin.js +138 -67
  169. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  170. package/lib/plugins/LayerMaskPlugin.js +17 -4
  171. package/lib/plugins/LayerModelPlugin.js +113 -68
  172. package/lib/plugins/LayerStylePlugin.js +14 -4
  173. package/lib/plugins/LightingPlugin.js +25 -12
  174. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  175. package/lib/plugins/PixelPickingPlugin.js +27 -12
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  177. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  178. package/lib/plugins/UpdateModelPlugin.js +10 -1
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  180. package/lib/point/index.js +83 -26
  181. package/lib/point/models/earthExtrude.js +113 -61
  182. package/lib/point/models/earthFill.js +117 -57
  183. package/lib/point/models/extrude.js +111 -60
  184. package/lib/point/models/fill.js +109 -68
  185. package/lib/point/models/fillmage.js +115 -61
  186. package/lib/point/models/image.js +98 -48
  187. package/lib/point/models/index.js +12 -1
  188. package/lib/point/models/normal.js +64 -30
  189. package/lib/point/models/radar.js +74 -40
  190. package/lib/point/models/simplePoint.js +79 -41
  191. package/lib/point/models/text.js +314 -202
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +103 -48
  195. package/lib/polygon/models/fill.js +98 -54
  196. package/lib/polygon/models/index.js +14 -2
  197. package/lib/polygon/models/ocean.js +88 -42
  198. package/lib/polygon/models/water.js +82 -37
  199. package/lib/raster/buffers/triangulation.js +7 -3
  200. package/lib/raster/index.js +40 -9
  201. package/lib/raster/models/index.js +5 -0
  202. package/lib/raster/models/raster.js +125 -80
  203. package/lib/raster/models/rasterRgb.js +139 -84
  204. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  205. package/lib/tile/interaction/getRasterData.js +25 -14
  206. package/lib/tile/interaction/utils.js +19 -7
  207. package/lib/tile/manager/base.js +104 -63
  208. package/lib/tile/service/TileLayerService.js +60 -33
  209. package/lib/tile/service/TilePickService.js +48 -26
  210. package/lib/tile/service/TileSourceService.js +16 -2
  211. package/lib/tile/style/utils.js +3 -0
  212. package/lib/tile/tileFactory/DebugTile.js +54 -29
  213. package/lib/tile/tileFactory/ImageTile.js +46 -20
  214. package/lib/tile/tileFactory/MaskTile.js +51 -22
  215. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  217. package/lib/tile/tileFactory/RasterTile.js +63 -30
  218. package/lib/tile/tileFactory/Tile.js +102 -63
  219. package/lib/tile/tileFactory/VectorTile.js +76 -41
  220. package/lib/tile/tileFactory/index.js +25 -0
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  222. package/lib/tile/tileFactory/util.js +9 -0
  223. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  224. package/lib/tile/utils.js +5 -1
  225. package/lib/utils/blend.js +5 -0
  226. package/lib/utils/collision-index.js +25 -9
  227. package/lib/utils/dataMappingStyle.js +19 -8
  228. package/lib/utils/extrude_polyline.js +181 -101
  229. package/lib/utils/grid-index.js +28 -2
  230. package/lib/utils/identityScale.js +9 -0
  231. package/lib/utils/layerData.js +49 -30
  232. package/lib/utils/multiPassRender.js +16 -11
  233. package/lib/utils/polylineNormal.js +66 -31
  234. package/lib/utils/simpleLine.js +21 -2
  235. package/lib/utils/stencil.js +4 -0
  236. package/lib/utils/symbol-layout.js +55 -27
  237. package/lib/wind/index.js +37 -9
  238. package/lib/wind/models/index.js +3 -0
  239. package/lib/wind/models/utils.js +62 -26
  240. package/lib/wind/models/wind.js +157 -101
  241. package/lib/wind/models/windRender.js +71 -53
  242. package/lib/wind/models/windShader.js +1 -0
  243. package/package.json +7 -7
@@ -2,23 +2,28 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import { TYPES } from '@antv/l7-core';
4
4
  import { generateCatRamp, generateColorRamp, generateCustomRamp, generateLinearRamp, generateQuantizeRamp } from '@antv/l7-utils';
5
+
5
6
  var TextureService = /*#__PURE__*/function () {
6
7
  function TextureService(layer) {
7
8
  _classCallCheck(this, TextureService);
9
+
8
10
  this.layer = layer;
9
11
  var container = this.layer.getContainer();
10
12
  this.rendererService = container.get(TYPES.IRendererService);
11
13
  }
14
+
12
15
  _createClass(TextureService, [{
13
16
  key: "getColorTexture",
14
17
  value: function getColorTexture(colorRamp, domain) {
15
18
  // TODO 支持传入图片
16
19
  var currentkey = this.getTextureKey(colorRamp, domain);
20
+
17
21
  if (this.key === currentkey) {
18
22
  return this.colorTexture;
19
23
  } else {
20
24
  this.createColorTexture(colorRamp, domain);
21
25
  }
26
+
22
27
  this.key = currentkey;
23
28
  return this.colorTexture;
24
29
  }
@@ -46,6 +51,7 @@ var TextureService = /*#__PURE__*/function () {
46
51
  key: "destroy",
47
52
  value: function destroy() {
48
53
  var _this$colorTexture;
54
+
49
55
  (_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.destroy();
50
56
  }
51
57
  }, {
@@ -54,12 +60,16 @@ var TextureService = /*#__PURE__*/function () {
54
60
  switch (colorRamp.type) {
55
61
  case 'cat':
56
62
  return generateCatRamp(colorRamp);
63
+
57
64
  case 'quantize':
58
65
  return generateQuantizeRamp(colorRamp);
66
+
59
67
  case 'custom':
60
68
  return generateCustomRamp(colorRamp, domain);
69
+
61
70
  case 'linear':
62
71
  return generateLinearRamp(colorRamp, domain);
72
+
63
73
  default:
64
74
  return generateColorRamp(colorRamp);
65
75
  }
@@ -68,9 +78,12 @@ var TextureService = /*#__PURE__*/function () {
68
78
  key: "getTextureKey",
69
79
  value: function getTextureKey(colorRamp, domain) {
70
80
  var _colorRamp$positions;
81
+
71
82
  return "".concat(colorRamp.colors.join('_'), "_").concat(colorRamp === null || colorRamp === void 0 ? void 0 : (_colorRamp$positions = colorRamp.positions) === null || _colorRamp$positions === void 0 ? void 0 : _colorRamp$positions.join('_'), "_").concat(colorRamp.type, "_").concat(domain === null || domain === void 0 ? void 0 : domain.join('_'));
72
83
  }
73
84
  }]);
85
+
74
86
  return TextureService;
75
87
  }();
88
+
76
89
  export { TextureService as default };
@@ -1,30 +1,37 @@
1
- export var lineStyleType = /*#__PURE__*/function (lineStyleType) {
1
+ export var lineStyleType;
2
+
3
+ (function (lineStyleType) {
2
4
  lineStyleType[lineStyleType["solid"] = 0] = "solid";
3
5
  lineStyleType[lineStyleType["dash"] = 1] = "dash";
4
- return lineStyleType;
5
- }({});
6
- export var LinearDir = /*#__PURE__*/function (LinearDir) {
6
+ })(lineStyleType || (lineStyleType = {}));
7
+
8
+ export var LinearDir;
9
+
10
+ (function (LinearDir) {
7
11
  LinearDir["VERTICAL"] = "vertical";
8
12
  LinearDir["HORIZONTAL"] = "horizontal";
9
- return LinearDir;
10
- }({});
11
- export var TextureBlend = /*#__PURE__*/function (TextureBlend) {
12
- TextureBlend["NORMAL"] = "normal";
13
- TextureBlend["REPLACE"] = "replace";
14
- return TextureBlend;
15
- }({});
13
+ })(LinearDir || (LinearDir = {}));
16
14
 
15
+ export var TextureBlend;
17
16
  /**
18
17
  * 基础图层类型定义
19
18
  */
20
19
 
21
- export var SizeUnitType = /*#__PURE__*/function (SizeUnitType) {
20
+ (function (TextureBlend) {
21
+ TextureBlend["NORMAL"] = "normal";
22
+ TextureBlend["REPLACE"] = "replace";
23
+ })(TextureBlend || (TextureBlend = {}));
24
+
25
+ export var SizeUnitType;
26
+
27
+ (function (SizeUnitType) {
22
28
  SizeUnitType[SizeUnitType["pixel"] = 0] = "pixel";
23
29
  SizeUnitType[SizeUnitType["meter"] = 1] = "meter";
24
- return SizeUnitType;
25
- }({});
26
- export var CanvasUpdateType = /*#__PURE__*/function (CanvasUpdateType) {
30
+ })(SizeUnitType || (SizeUnitType = {}));
31
+
32
+ export var CanvasUpdateType;
33
+
34
+ (function (CanvasUpdateType) {
27
35
  CanvasUpdateType["ALWAYS"] = "always";
28
36
  CanvasUpdateType["DRAGEND"] = "dragend";
29
- return CanvasUpdateType;
30
- }({});
37
+ })(CanvasUpdateType || (CanvasUpdateType = {}));
@@ -1,40 +1,47 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+
2
3
  var _geometryShape;
3
- export var ShapeType3D = /*#__PURE__*/function (ShapeType3D) {
4
+
5
+ export var ShapeType3D;
6
+
7
+ (function (ShapeType3D) {
4
8
  ShapeType3D["CYLINDER"] = "cylinder";
5
9
  ShapeType3D["SQUARECOLUMN"] = "squareColumn";
6
10
  ShapeType3D["TRIANGLECOLUMN"] = "triangleColumn";
7
11
  ShapeType3D["HEXAGONCOLUMN"] = "hexagonColumn";
8
12
  ShapeType3D["PENTAGONCOLUMN"] = "pentagonColumn";
9
- return ShapeType3D;
10
- }({});
11
- export var ShapeType2D = /*#__PURE__*/function (ShapeType2D) {
12
- ShapeType2D["CIRCLE"] = "circle";
13
- ShapeType2D["SQUARE"] = "square";
14
- ShapeType2D["TRIANGLE"] = "triangle";
15
- ShapeType2D["HEXAGON"] = "hexagon";
16
- ShapeType2D["PENTAGON"] = "pentagon";
17
- return ShapeType2D;
18
- }({});
13
+ })(ShapeType3D || (ShapeType3D = {}));
19
14
 
15
+ export var ShapeType2D;
20
16
  /**
21
17
  * 生成规则多边形顶点个数
22
18
  * @param pointCount 顶点个数 3 => 三角形
23
19
  * @param start 顶点起始角度 调整图形的方向
24
20
  */
21
+
22
+ (function (ShapeType2D) {
23
+ ShapeType2D["CIRCLE"] = "circle";
24
+ ShapeType2D["SQUARE"] = "square";
25
+ ShapeType2D["TRIANGLE"] = "triangle";
26
+ ShapeType2D["HEXAGON"] = "hexagon";
27
+ ShapeType2D["PENTAGON"] = "pentagon";
28
+ })(ShapeType2D || (ShapeType2D = {}));
29
+
25
30
  export function polygonPath(pointCount) {
26
31
  var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
27
32
  var step = Math.PI * 2 / pointCount;
28
33
  var line = [];
34
+
29
35
  for (var i = 0; i < pointCount; i++) {
30
36
  line.push(step * i + start * Math.PI / 12);
31
37
  }
38
+
32
39
  var path = line.map(function (t) {
33
40
  var x = Math.sin(t + Math.PI / 4);
34
41
  var y = Math.cos(t + Math.PI / 4);
35
42
  return [x, y, 0];
36
- });
37
- // path.push(path[0]);
43
+ }); // path.push(path[0]);
44
+
38
45
  return path;
39
46
  }
40
47
  export function circle() {
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import { lngLatToMeters } from '@antv/l7-utils';
3
3
  import earcut from 'earcut';
4
4
  import { vec3 } from 'gl-matrix';
5
+
5
6
  /**
6
7
  * 拉伸多边形顶点,返回拉伸后的顶点信息
7
8
  * @param paths 路径数据组
@@ -10,16 +11,18 @@ import { vec3 } from 'gl-matrix';
10
11
  export default function extrudePolygon(path) {
11
12
  var p1 = path[0][0];
12
13
  var p2 = path[0][path[0].length - 1];
14
+
13
15
  if (p1[0] === p2[0] && p1[1] === p2[1]) {
14
16
  path[0] = path[0].slice(0, path[0].length - 1);
15
17
  }
18
+
16
19
  var n = path[0].length;
17
20
  var flattengeo = earcut.flatten(path);
18
21
  var vertices = flattengeo.vertices,
19
- dimensions = flattengeo.dimensions;
22
+ dimensions = flattengeo.dimensions;
20
23
  var positions = [];
21
- var indexArray = [];
22
- // 设置顶部z值
24
+ var indexArray = []; // 设置顶部z值
25
+
23
26
  for (var j = 0; j < vertices.length / dimensions; j++) {
24
27
  if (dimensions === 2) {
25
28
  positions.push(vertices[j * 2], vertices[j * 2 + 1], 1);
@@ -27,23 +30,29 @@ export default function extrudePolygon(path) {
27
30
  positions.push(vertices[j * 3], vertices[j * 3 + 1], 1);
28
31
  }
29
32
  }
33
+
30
34
  var triangles = earcut(flattengeo.vertices, flattengeo.holes, flattengeo.dimensions);
31
35
  indexArray.push.apply(indexArray, _toConsumableArray(triangles));
32
- var _loop = function _loop() {
36
+
37
+ var _loop = function _loop(i) {
33
38
  var prePoint = flattengeo.vertices.slice(i * dimensions, (i + 1) * dimensions);
34
39
  var nextPoint = flattengeo.vertices.slice((i + 1) * dimensions, (i + 2) * dimensions);
40
+
35
41
  if (nextPoint.length === 0) {
36
42
  nextPoint = flattengeo.vertices.slice(0, dimensions);
37
43
  }
44
+
38
45
  var indexOffset = positions.length / 3;
39
46
  positions.push(prePoint[0], prePoint[1], 1, nextPoint[0], nextPoint[1], 1, prePoint[0], prePoint[1], 0, nextPoint[0], nextPoint[1], 0);
40
47
  indexArray.push.apply(indexArray, _toConsumableArray([0, 2, 1, 2, 3, 1].map(function (v) {
41
48
  return v + indexOffset;
42
49
  })));
43
50
  };
51
+
44
52
  for (var i = 0; i < n; i++) {
45
- _loop();
53
+ _loop(i);
46
54
  }
55
+
47
56
  return {
48
57
  positions: positions,
49
58
  index: indexArray
@@ -61,33 +70,40 @@ export function extrude_PolygonNormal(path) {
61
70
  var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
62
71
  var p1 = path[0][0];
63
72
  var p2 = path[0][path[0].length - 1];
73
+
64
74
  if (p1[0] === p2[0] && p1[1] === p2[1]) {
65
75
  path[0] = path[0].slice(0, path[0].length - 1);
66
76
  }
77
+
67
78
  var n = path[0].length;
68
79
  var flattengeo = earcut.flatten(path);
69
80
  var vertices = flattengeo.vertices,
70
- dimensions = flattengeo.dimensions;
81
+ dimensions = flattengeo.dimensions;
71
82
  var positions = [];
72
83
  var indexArray = [];
73
- var normals = [];
74
- // 设置顶部z值 position uv
84
+ var normals = []; // 设置顶部z值 position uv
85
+
75
86
  for (var j = 0; j < vertices.length / dimensions; j++) {
76
87
  if (dimensions === 2) {
77
88
  positions.push(vertices[j * 2], vertices[j * 2 + 1], 1, -1, -1);
78
89
  } else {
79
90
  positions.push(vertices[j * 3], vertices[j * 3 + 1], 1, -1, -1);
80
91
  }
92
+
81
93
  normals.push(0, 0, 1);
82
94
  }
95
+
83
96
  var triangles = earcut(flattengeo.vertices, flattengeo.holes, flattengeo.dimensions);
84
97
  indexArray.push.apply(indexArray, _toConsumableArray(triangles));
85
- var _loop2 = function _loop2() {
98
+
99
+ var _loop2 = function _loop2(i) {
86
100
  var prePoint = flattengeo.vertices.slice(i * dimensions, (i + 1) * dimensions);
87
101
  var nextPoint = flattengeo.vertices.slice((i + 1) * dimensions, (i + 2) * dimensions);
102
+
88
103
  if (nextPoint.length === 0) {
89
104
  nextPoint = flattengeo.vertices.slice(0, dimensions);
90
105
  }
106
+
91
107
  var indexOffset = positions.length / 5;
92
108
  positions.push(prePoint[0], prePoint[1], 1, 0, 0, nextPoint[0], nextPoint[1], 1, 0.1, 0, prePoint[0], prePoint[1], 0, 0, 0.8, nextPoint[0], nextPoint[1], 0, 0.1, 0.8);
93
109
  var normal = computeVertexNormals([nextPoint[0], nextPoint[1], 1], [prePoint[0], prePoint[1], 0], [prePoint[0], prePoint[1], 1], needFlat);
@@ -96,25 +112,30 @@ export function extrude_PolygonNormal(path) {
96
112
  return v + indexOffset;
97
113
  })));
98
114
  };
115
+
99
116
  for (var i = 0; i < n; i++) {
100
- _loop2();
117
+ _loop2(i);
101
118
  }
119
+
102
120
  return {
103
121
  positions: positions,
104
122
  index: indexArray,
105
123
  normals: normals
106
124
  };
107
125
  }
126
+
108
127
  function computeVertexNormals(p1, p2, p3) {
109
128
  var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
110
129
  var cb = vec3.create();
111
130
  var ab = vec3.create();
112
131
  var normal = vec3.create();
132
+
113
133
  if (needFlat) {
114
134
  p1 = lngLatToMeters(p1);
115
135
  p2 = lngLatToMeters(p2);
116
136
  p3 = lngLatToMeters(p3);
117
137
  }
138
+
118
139
  var pA = vec3.fromValues.apply(vec3, _toConsumableArray(p1));
119
140
  var pB = vec3.fromValues.apply(vec3, _toConsumableArray(p2));
120
141
  var pC = vec3.fromValues.apply(vec3, _toConsumableArray(p3));