@antv/l7-layers 2.17.3 → 2.17.4

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 +478 -313
  10. package/es/core/BaseModel.js +80 -51
  11. package/es/core/CommonStyleAttribute.js +5 -2
  12. package/es/core/LayerPickService.js +32 -21
  13. package/es/core/TextureService.js +13 -0
  14. package/es/core/interface.js +24 -17
  15. package/es/core/shape/Path.js +20 -13
  16. package/es/core/shape/extrude.js +39 -27
  17. package/es/core/triangulation.js +136 -99
  18. package/es/earth/index.js +33 -9
  19. package/es/earth/models/atmosphere.js +54 -30
  20. package/es/earth/models/base.js +85 -47
  21. package/es/earth/models/bloomsphere.js +54 -30
  22. package/es/earth/utils.js +13 -9
  23. package/es/heatmap/index.js +40 -10
  24. package/es/heatmap/models/grid.js +52 -28
  25. package/es/heatmap/models/grid3d.js +52 -28
  26. package/es/heatmap/models/heatmap.js +149 -92
  27. package/es/heatmap/models/hexagon.js +52 -28
  28. package/es/heatmap/triangulation.js +4 -0
  29. package/es/image/index.js +28 -9
  30. package/es/image/models/image.js +100 -66
  31. package/es/index.js +17 -9
  32. package/es/line/index.js +35 -9
  33. package/es/line/models/arc.js +112 -63
  34. package/es/line/models/arc_3d.js +102 -58
  35. package/es/line/models/earthArc_3d.js +105 -60
  36. package/es/line/models/flow.js +60 -36
  37. package/es/line/models/great_circle.js +94 -53
  38. package/es/line/models/line.js +136 -85
  39. package/es/line/models/linearline.js +74 -42
  40. package/es/line/models/simpleLine.js +67 -38
  41. package/es/line/models/wall.js +92 -52
  42. package/es/mask/index.js +28 -9
  43. package/es/mask/models/fill.js +54 -29
  44. package/es/plugins/DataMappingPlugin.js +114 -78
  45. package/es/plugins/DataSourcePlugin.js +68 -45
  46. package/es/plugins/FeatureScalePlugin.js +122 -67
  47. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  48. package/es/plugins/LayerMaskPlugin.js +11 -3
  49. package/es/plugins/LayerModelPlugin.js +108 -69
  50. package/es/plugins/LayerStylePlugin.js +9 -3
  51. package/es/plugins/LightingPlugin.js +18 -12
  52. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  53. package/es/plugins/PixelPickingPlugin.js +21 -12
  54. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  55. package/es/plugins/ShaderUniformPlugin.js +27 -13
  56. package/es/plugins/UpdateModelPlugin.js +5 -0
  57. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  58. package/es/point/index.js +78 -26
  59. package/es/point/models/earthExtrude.js +95 -58
  60. package/es/point/models/earthFill.js +80 -52
  61. package/es/point/models/extrude.js +94 -57
  62. package/es/point/models/fill.js +81 -56
  63. package/es/point/models/fillmage.js +100 -60
  64. package/es/point/models/image.js +83 -47
  65. package/es/point/models/index.js +2 -2
  66. package/es/point/models/normal.js +54 -30
  67. package/es/point/models/radar.js +63 -38
  68. package/es/point/models/simplePoint.js +62 -38
  69. package/es/point/models/text.js +296 -199
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +41 -11
  72. package/es/polygon/models/extrude.js +135 -87
  73. package/es/polygon/models/fill.js +79 -50
  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/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 +469 -313
  127. package/lib/core/BaseModel.js +90 -51
  128. package/lib/core/CommonStyleAttribute.js +7 -2
  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 +62 -27
  135. package/lib/core/triangulation.js +177 -98
  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 +166 -92
  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 +122 -61
  154. package/lib/line/models/arc_3d.js +113 -56
  155. package/lib/line/models/earthArc_3d.js +115 -58
  156. package/lib/line/models/flow.js +70 -36
  157. package/lib/line/models/great_circle.js +104 -53
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +144 -83
  160. package/lib/line/models/linearline.js +86 -42
  161. package/lib/line/models/simpleLine.js +77 -38
  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 +125 -78
  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 +117 -70
  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 +106 -58
  182. package/lib/point/models/earthFill.js +110 -52
  183. package/lib/point/models/extrude.js +103 -57
  184. package/lib/point/models/fill.js +90 -54
  185. package/lib/point/models/fillmage.js +107 -58
  186. package/lib/point/models/image.js +92 -47
  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 +72 -38
  190. package/lib/point/models/simplePoint.js +72 -38
  191. package/lib/point/models/text.js +305 -199
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +146 -87
  195. package/lib/polygon/models/fill.js +89 -50
  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/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,7 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -25,21 +27,31 @@ exports.earthOuterTriangulation = earthOuterTriangulation;
25
27
  exports.earthTriangulation = earthTriangulation;
26
28
  exports.polygonTriangulation = polygonTriangulation;
27
29
  exports.polygonTriangulationWithCenter = polygonTriangulationWithCenter;
30
+
28
31
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
32
+
29
33
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
34
+
30
35
  var _l7Utils = require("@antv/l7-utils");
36
+
31
37
  var _earcut = _interopRequireDefault(require("earcut"));
38
+
32
39
  var _glMatrix = require("gl-matrix");
40
+
33
41
  var _utils = require("../earth/utils");
42
+
34
43
  var _extrude_polyline = _interopRequireDefault(require("../utils/extrude_polyline"));
44
+
35
45
  var _extrude = _interopRequireWildcard(require("./shape/extrude"));
46
+
36
47
  var _Path = require("./shape/Path");
48
+
37
49
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
50
+
38
51
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
- // @ts-ignore
40
52
 
53
+ // @ts-ignore
41
54
  var GeometryCache = {};
42
-
43
55
  /**
44
56
  * 计算2D 填充点图顶点
45
57
  * @param feature 映射feature
@@ -57,6 +69,8 @@ function PointFillTriangulation(feature) {
57
69
  * 计算2D 填充点图顶点 (地球模式)
58
70
  * @param feature 映射feature
59
71
  */
72
+
73
+
60
74
  function GlobelPointFillTriangulation(feature) {
61
75
  var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
62
76
  var xyz = (0, _utils.lglt2xyz)(coordinates);
@@ -66,17 +80,20 @@ function GlobelPointFillTriangulation(feature) {
66
80
  size: xyz.length
67
81
  };
68
82
  }
69
-
70
83
  /**
71
84
  * 计算3D 拉伸点图
72
85
  * @param feature 映射feature
73
86
  */
87
+
88
+
74
89
  function PointExtrudeTriangulation(feature) {
75
90
  var shape = feature.shape;
91
+
76
92
  var _getGeometry = getGeometry(shape, false),
77
- positions = _getGeometry.positions,
78
- index = _getGeometry.index,
79
- normals = _getGeometry.normals;
93
+ positions = _getGeometry.positions,
94
+ index = _getGeometry.index,
95
+ normals = _getGeometry.normals;
96
+
80
97
  return {
81
98
  vertices: positions,
82
99
  indices: index,
@@ -84,11 +101,12 @@ function PointExtrudeTriangulation(feature) {
84
101
  size: 5
85
102
  };
86
103
  }
87
-
88
104
  /**
89
105
  * 计算图片标注
90
106
  * @param feature 映射feature
91
107
  */
108
+
109
+
92
110
  function PointImageTriangulation(feature) {
93
111
  var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
94
112
  return {
@@ -97,16 +115,16 @@ function PointImageTriangulation(feature) {
97
115
  size: coordinates.length
98
116
  };
99
117
  }
100
-
101
118
  /**
102
119
  * 线三角化
103
120
  * @param feature 映射feature
104
121
  */
122
+
123
+
105
124
  function LineTriangulation(feature) {
106
125
  var coordinates = feature.coordinates,
107
- originCoordinates = feature.originCoordinates,
108
- version = feature.version;
109
- // let path = coordinates as number[][][] | number[][];
126
+ originCoordinates = feature.originCoordinates,
127
+ version = feature.version; // let path = coordinates as number[][][] | number[][];
110
128
  // if (!Array.isArray(path[0][0])) {
111
129
  // path = [coordinates] as number[][][];
112
130
  // }
@@ -115,16 +133,21 @@ function LineTriangulation(feature) {
115
133
  dash: true,
116
134
  join: 'bevel'
117
135
  });
136
+
118
137
  if (version === 'GAODE2.x') {
119
138
  // 处理高德2.0几何体构建
120
139
  var path1 = coordinates; // 计算位置
140
+
121
141
  if (!Array.isArray(path1[0][0])) {
122
142
  path1 = [coordinates];
123
143
  }
144
+
124
145
  var path2 = originCoordinates; // 计算法线
146
+
125
147
  if (!Array.isArray(path2[0][0])) {
126
148
  path2 = [originCoordinates];
127
149
  }
150
+
128
151
  for (var i = 0; i < path1.length; i++) {
129
152
  // 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
130
153
  var item1 = path1[i];
@@ -134,13 +157,16 @@ function LineTriangulation(feature) {
134
157
  } else {
135
158
  // 处理非高德2.0的几何体构建
136
159
  var path = coordinates;
160
+
137
161
  if (path[0] && !Array.isArray(path[0][0])) {
138
162
  path = [coordinates];
139
163
  }
164
+
140
165
  path.forEach(function (item) {
141
166
  line.extrude(item);
142
167
  });
143
168
  }
169
+
144
170
  var linebuffer = line.complex;
145
171
  return {
146
172
  vertices: linebuffer.positions,
@@ -151,79 +177,60 @@ function LineTriangulation(feature) {
151
177
  size: 6
152
178
  };
153
179
  }
180
+
154
181
  function FlowLineFillTriangulation(feature) {
155
182
  // @ts-ignore
156
183
  var coord = feature.coordinates.flat();
157
184
  var tin = 1;
158
185
  var tout = 1.0;
159
186
  return {
160
- vertices: [1, 0, 0].concat((0, _toConsumableArray2.default)(coord), [
161
- // 0
162
- 1, 2, -3], (0, _toConsumableArray2.default)(coord), [
163
- // 1
164
- 1, 1, -3], (0, _toConsumableArray2.default)(coord), [
165
- // 2
166
- 0, 1, 0], (0, _toConsumableArray2.default)(coord), [
167
- // 3
168
- 0, 0, 0], (0, _toConsumableArray2.default)(coord), [
169
- // 4
170
- 1, 0, 0], (0, _toConsumableArray2.default)(coord), [
171
- // 0
172
- 1, 2, -3], (0, _toConsumableArray2.default)(coord), [
173
- // 1
174
- 1, 1, -3], (0, _toConsumableArray2.default)(coord), [
175
- // 2
176
- 0, 1, 0], (0, _toConsumableArray2.default)(coord), [
177
- // 3
187
+ vertices: [1, 0, 0].concat((0, _toConsumableArray2.default)(coord), [// 0
188
+ 1, 2, -3], (0, _toConsumableArray2.default)(coord), [// 1
189
+ 1, 1, -3], (0, _toConsumableArray2.default)(coord), [// 2
190
+ 0, 1, 0], (0, _toConsumableArray2.default)(coord), [// 3
191
+ 0, 0, 0], (0, _toConsumableArray2.default)(coord), [// 4
192
+ 1, 0, 0], (0, _toConsumableArray2.default)(coord), [// 0
193
+ 1, 2, -3], (0, _toConsumableArray2.default)(coord), [// 1
194
+ 1, 1, -3], (0, _toConsumableArray2.default)(coord), [// 2
195
+ 0, 1, 0], (0, _toConsumableArray2.default)(coord), [// 3
178
196
  0, 0, 0], (0, _toConsumableArray2.default)(coord)),
179
- normals: [-tin, 2 * tout, 1,
180
- // 0
181
- 2 * tout, -tout, 1,
182
- // 1
183
- tout, -tout, 1,
184
- // 2
185
- tout, -tout, 1,
186
- // 3
187
- -tin, -tout, 1,
188
- // 4
197
+ normals: [-tin, 2 * tout, 1, // 0
198
+ 2 * tout, -tout, 1, // 1
199
+ tout, -tout, 1, // 2
200
+ tout, -tout, 1, // 3
201
+ -tin, -tout, 1, // 4
189
202
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
190
203
  indices: [0, 1, 2, 0, 2, 3, 0, 3, 4, 5, 6, 7, 5, 7, 8, 5, 8, 9],
191
204
  size: 7
192
205
  };
193
206
  }
207
+
194
208
  function FlowLineStrokeTriangulation(feature) {
195
209
  // @ts-ignore
196
210
  var coord = feature.coordinates.flat();
197
211
  var tin = 1;
198
212
  var tout = 1;
199
213
  return {
200
- vertices: [1, 0, 0].concat((0, _toConsumableArray2.default)(coord), [
201
- // 0
202
- 1, 2, -3], (0, _toConsumableArray2.default)(coord), [
203
- // 1
204
- 1, 1, -3], (0, _toConsumableArray2.default)(coord), [
205
- // 2
206
- 0, 1, 0], (0, _toConsumableArray2.default)(coord), [
207
- // 3
214
+ vertices: [1, 0, 0].concat((0, _toConsumableArray2.default)(coord), [// 0
215
+ 1, 2, -3], (0, _toConsumableArray2.default)(coord), [// 1
216
+ 1, 1, -3], (0, _toConsumableArray2.default)(coord), [// 2
217
+ 0, 1, 0], (0, _toConsumableArray2.default)(coord), [// 3
208
218
  0, 0, 0], (0, _toConsumableArray2.default)(coord)),
209
- normals: [-tin, 2 * tout, 1,
210
- // 0
211
- 2 * tout, -tout, 1,
212
- // 1
213
- tout, -tout, 1,
214
- // 2
215
- tout, -tout, 1,
216
- // 3
219
+ normals: [-tin, 2 * tout, 1, // 0
220
+ 2 * tout, -tout, 1, // 1
221
+ tout, -tout, 1, // 2
222
+ tout, -tout, 1, // 3
217
223
  -tin, -tout, 1 // 4
218
224
  ],
219
-
220
225
  indices: [0, 1, 1, 2, 2, 3, 3, 4, 4, 0],
221
226
  size: 7
222
227
  };
223
228
  }
229
+
224
230
  function SimpleLineTriangulation(feature) {
225
231
  var coordinates = feature.coordinates;
226
232
  var pos = [];
233
+
227
234
  if (!Array.isArray(coordinates[0])) {
228
235
  return {
229
236
  vertices: [],
@@ -233,9 +240,11 @@ function SimpleLineTriangulation(feature) {
233
240
  count: 0
234
241
  };
235
242
  }
243
+
236
244
  var _getSimpleLineVertice = getSimpleLineVertices(coordinates),
237
- results = _getSimpleLineVertice.results,
238
- totalDistance = _getSimpleLineVertice.totalDistance;
245
+ results = _getSimpleLineVertice.results,
246
+ totalDistance = _getSimpleLineVertice.totalDistance;
247
+
239
248
  results.map(function (point) {
240
249
  pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
241
250
  });
@@ -247,9 +256,11 @@ function SimpleLineTriangulation(feature) {
247
256
  count: results.length
248
257
  };
249
258
  }
259
+
250
260
  function TileSimpleLineTriangulation(feature) {
251
261
  var coordinates = feature.coordinates;
252
262
  var pos = [];
263
+
253
264
  if (!Array.isArray(coordinates[0])) {
254
265
  return {
255
266
  vertices: [],
@@ -258,8 +269,10 @@ function TileSimpleLineTriangulation(feature) {
258
269
  count: 0
259
270
  };
260
271
  }
272
+
261
273
  var _getTileSimpleLineVer = getTileSimpleLineVertices(coordinates),
262
- results = _getTileSimpleLineVer.results;
274
+ results = _getTileSimpleLineVer.results;
275
+
263
276
  results.map(function (point) {
264
277
  pos.push(point[0], point[1], point[2], point[3]);
265
278
  });
@@ -270,27 +283,35 @@ function TileSimpleLineTriangulation(feature) {
270
283
  count: results.length
271
284
  };
272
285
  }
286
+
273
287
  function lineSegmentDistance(b1, a1) {
274
288
  var dx = a1[0] - b1[0];
275
289
  var dy = a1[1] - b1[1];
276
290
  return Math.sqrt(dx * dx + dy * dy);
277
291
  }
292
+
278
293
  function pushDis(point, n) {
279
294
  if (point.length < 3) {
280
295
  point.push(0);
281
296
  }
297
+
282
298
  if (n !== undefined) {
283
299
  point.push(n);
284
300
  }
301
+
285
302
  return point;
286
303
  }
304
+
287
305
  function getSimpleLineVertices(coordinates) {
288
306
  var points = coordinates;
307
+
289
308
  if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
290
309
  // @ts-ignore
291
310
  points = coordinates.flat();
292
311
  }
312
+
293
313
  var distance = 0;
314
+
294
315
  if (points.length < 2) {
295
316
  return {
296
317
  results: points,
@@ -300,6 +321,7 @@ function getSimpleLineVertices(coordinates) {
300
321
  var results = [];
301
322
  var point = pushDis(points[0], distance);
302
323
  results.push(point);
324
+
303
325
  for (var i = 1; i < points.length - 1; i++) {
304
326
  var subDistance = lineSegmentDistance(points[i - 1], points[i]);
305
327
  distance += subDistance;
@@ -307,6 +329,7 @@ function getSimpleLineVertices(coordinates) {
307
329
  results.push(mulPoint);
308
330
  results.push(mulPoint);
309
331
  }
332
+
310
333
  var pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
311
334
  distance += pointDistance;
312
335
  results.push(pushDis(points[points.length - 1], distance));
@@ -316,6 +339,7 @@ function getSimpleLineVertices(coordinates) {
316
339
  };
317
340
  }
318
341
  }
342
+
319
343
  function getTileSimpleLineVertices(points) {
320
344
  if (points.length < 2) {
321
345
  return {
@@ -325,61 +349,75 @@ function getTileSimpleLineVertices(points) {
325
349
  var results = [];
326
350
  var point = pushDis(points[0]);
327
351
  results.push(point);
352
+
328
353
  for (var i = 1; i < points.length - 1; i++) {
329
354
  var mulPoint = pushDis(points[i]);
330
355
  results.push(mulPoint);
331
356
  results.push(mulPoint);
332
357
  }
358
+
333
359
  results.push(pushDis(points[points.length - 1]));
334
360
  return {
335
361
  results: results
336
362
  };
337
363
  }
338
364
  }
365
+
339
366
  function polygonTriangulation(feature) {
340
367
  var coordinates = feature.coordinates;
368
+
341
369
  var flattengeo = _earcut.default.flatten(coordinates);
370
+
342
371
  var vertices = flattengeo.vertices,
343
- dimensions = flattengeo.dimensions,
344
- holes = flattengeo.holes;
372
+ dimensions = flattengeo.dimensions,
373
+ holes = flattengeo.holes;
345
374
  return {
346
375
  indices: (0, _earcut.default)(vertices, holes, dimensions),
347
376
  vertices: vertices,
348
377
  size: dimensions
349
378
  };
350
- }
379
+ } // 构建几何图形(带有中心点和大小)
380
+
351
381
 
352
- // 构建几何图形(带有中心点和大小)
353
382
  function polygonTriangulationWithCenter(feature) {
354
383
  var coordinates = feature.coordinates;
384
+
355
385
  var flattengeo = _earcut.default.flatten(coordinates);
386
+
356
387
  var vertices = flattengeo.vertices,
357
- dimensions = flattengeo.dimensions,
358
- holes = flattengeo.holes;
388
+ dimensions = flattengeo.dimensions,
389
+ holes = flattengeo.holes;
359
390
  return {
360
391
  indices: (0, _earcut.default)(vertices, holes, dimensions),
361
392
  vertices: getVerticesWithCenter(vertices),
362
393
  size: dimensions + 4
363
394
  };
364
395
  }
396
+
365
397
  function getVerticesWithCenter(vertices) {
366
398
  var verticesWithCenter = [];
399
+
367
400
  var _calculatePointsCente = (0, _l7Utils.calculatePointsCenterAndRadius)(vertices),
368
- center = _calculatePointsCente.center,
369
- radius = _calculatePointsCente.radius;
401
+ center = _calculatePointsCente.center,
402
+ radius = _calculatePointsCente.radius;
403
+
370
404
  for (var i = 0; i < vertices.length; i += 2) {
371
405
  var lng = vertices[i];
372
406
  var lat = vertices[i + 1];
373
407
  verticesWithCenter.push.apply(verticesWithCenter, [lng, lat, 0].concat((0, _toConsumableArray2.default)(center), [radius]));
374
408
  }
409
+
375
410
  return verticesWithCenter;
376
411
  }
412
+
377
413
  function PolygonExtrudeTriangulation(feature) {
378
414
  var coordinates = feature.coordinates;
415
+
379
416
  var _extrude_PolygonNorma = (0, _extrude.extrude_PolygonNormal)(coordinates, true),
380
- positions = _extrude_PolygonNorma.positions,
381
- index = _extrude_PolygonNorma.index,
382
- normals = _extrude_PolygonNorma.normals;
417
+ positions = _extrude_PolygonNorma.positions,
418
+ index = _extrude_PolygonNorma.index,
419
+ normals = _extrude_PolygonNorma.normals;
420
+
383
421
  return {
384
422
  vertices: positions,
385
423
  // [ x, y, z, uv.x,uv.y ]
@@ -388,11 +426,14 @@ function PolygonExtrudeTriangulation(feature) {
388
426
  size: 5
389
427
  };
390
428
  }
429
+
391
430
  function HeatmapGridTriangulation(feature) {
392
431
  var shape = feature.shape;
432
+
393
433
  var _getHeatmapGeometry = getHeatmapGeometry(shape),
394
- positions = _getHeatmapGeometry.positions,
395
- index = _getHeatmapGeometry.index;
434
+ positions = _getHeatmapGeometry.positions,
435
+ index = _getHeatmapGeometry.index;
436
+
396
437
  return {
397
438
  vertices: positions,
398
439
  // [ x, y, z ] 多边形顶点
@@ -400,14 +441,15 @@ function HeatmapGridTriangulation(feature) {
400
441
  size: 3
401
442
  };
402
443
  }
403
-
404
444
  /**
405
445
  * 图片图层顶点构造
406
446
  * @param feature 数据
407
447
  */
448
+
449
+
408
450
  function RasterImageTriangulation(feature) {
409
- var coordinates = feature.coordinates;
410
- // [ x, y, z. uv.x, uv.y]
451
+ var coordinates = feature.coordinates; // [ x, y, z. uv.x, uv.y]
452
+
411
453
  var positions = [].concat((0, _toConsumableArray2.default)(coordinates[0]), [0, 0, 1, coordinates[1][0], coordinates[0][1], 0, 1, 1], (0, _toConsumableArray2.default)(coordinates[1]), [0, 1, 0], (0, _toConsumableArray2.default)(coordinates[0]), [0, 0, 1], (0, _toConsumableArray2.default)(coordinates[1]), [0, 1, 0, coordinates[0][0], coordinates[1][1], 0, 0, 0]);
412
454
  var indexs = [0, 1, 2, 3, 4, 5];
413
455
  return {
@@ -416,52 +458,60 @@ function RasterImageTriangulation(feature) {
416
458
  size: 5
417
459
  };
418
460
  }
419
-
420
461
  /**
421
462
  * 计算3D弧线顶点
422
463
  * @param feature 映射数据
423
464
  * @param segNum 弧线线段数
424
465
  */
466
+
467
+
425
468
  function LineArcTriangulation(feature, segmentNumber) {
426
469
  var segNum = segmentNumber ? segmentNumber : 30;
427
470
  var coordinates = feature.coordinates;
428
471
  var positions = [];
429
472
  var indexArray = [];
473
+
430
474
  var _loop = function _loop(i) {
431
475
  // 上线两个顶点
432
476
  // [ x, y, z, sx,sy, tx,ty]
433
477
  positions.push(i, 1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1], i, -1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1]);
478
+
434
479
  if (i !== segNum - 1) {
435
480
  indexArray.push.apply(indexArray, (0, _toConsumableArray2.default)([0, 1, 2, 1, 3, 2].map(function (v) {
436
481
  return i * 2 + v;
437
482
  })));
438
483
  }
439
484
  };
485
+
440
486
  for (var i = 0; i < segNum; i++) {
441
487
  _loop(i);
442
488
  }
489
+
443
490
  return {
444
491
  vertices: positions,
445
492
  indices: indexArray,
446
493
  size: 7
447
494
  };
448
495
  }
449
-
450
496
  /**
451
497
  * 构建热力图密度图的顶点
452
498
  * @param feature
453
499
  * @returns
454
500
  */
501
+
502
+
455
503
  function HeatmapTriangulation(feature) {
456
504
  var coordinates = feature.coordinates;
505
+
457
506
  if (coordinates.length === 2) {
458
507
  coordinates.push(0);
459
508
  }
509
+
460
510
  var dir = addDir(-1, 1);
461
511
  var dir1 = addDir(1, 1);
462
512
  var dir2 = addDir(-1, -1);
463
- var dir3 = addDir(1, -1);
464
- // [x,y,z, dirx ,diry, weight]
513
+ var dir3 = addDir(1, -1); // [x,y,z, dirx ,diry, weight]
514
+
465
515
  var positions = [].concat((0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir2), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir3), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir1));
466
516
  var indexArray = [0, 1, 2, 3, 0, 2];
467
517
  return {
@@ -470,21 +520,25 @@ function HeatmapTriangulation(feature) {
470
520
  size: 5
471
521
  };
472
522
  }
473
-
474
523
  /**
475
524
  * 点图层3d geomerty
476
525
  * @param shape 3D形状
477
526
  */
527
+
528
+
478
529
  function getGeometry(shape) {
479
530
  var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
531
+
480
532
  if (GeometryCache && GeometryCache[shape]) {
481
533
  return GeometryCache[shape];
482
534
  }
535
+
483
536
  var path = _Path.geometryShape[shape] ? _Path.geometryShape[shape]() : _Path.geometryShape.cylinder();
484
537
  var geometry = (0, _extrude.extrude_PolygonNormal)([path], needFlat);
485
538
  GeometryCache[shape] = geometry;
486
539
  return geometry;
487
540
  }
541
+
488
542
  function computeVertexNormals(positions, indexArray) {
489
543
  var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
490
544
  var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -492,9 +546,13 @@ function computeVertexNormals(positions, indexArray) {
492
546
  var vA;
493
547
  var vB;
494
548
  var vC;
549
+
495
550
  var cb = _glMatrix.vec3.create();
551
+
496
552
  var ab = _glMatrix.vec3.create();
553
+
497
554
  var normal = _glMatrix.vec3.create();
555
+
498
556
  for (var i = 0, li = indexArray.length; i < li; i += 3) {
499
557
  vA = indexArray[i + 0] * 3;
500
558
  vB = indexArray[i + 1] * 3;
@@ -502,29 +560,40 @@ function computeVertexNormals(positions, indexArray) {
502
560
  var p1 = [positions[vA], positions[vA + 1]];
503
561
  var p2 = [positions[vB], positions[vB + 1]];
504
562
  var p3 = [positions[vC], positions[vC + 1]];
563
+
505
564
  if (needFlat) {
506
565
  p1 = (0, _l7Utils.lngLatToMeters)(p1);
507
566
  p2 = (0, _l7Utils.lngLatToMeters)(p2);
508
567
  p3 = (0, _l7Utils.lngLatToMeters)(p3);
509
568
  }
569
+
510
570
  var _p = p1,
511
- _p2 = (0, _slicedToArray2.default)(_p, 2),
512
- ax = _p2[0],
513
- ay = _p2[1];
571
+ _p2 = (0, _slicedToArray2.default)(_p, 2),
572
+ ax = _p2[0],
573
+ ay = _p2[1];
574
+
514
575
  var pA = _glMatrix.vec3.fromValues(ax, ay, positions[vA + 2]);
576
+
515
577
  var _p3 = p2,
516
- _p4 = (0, _slicedToArray2.default)(_p3, 2),
517
- bx = _p4[0],
518
- by = _p4[1];
578
+ _p4 = (0, _slicedToArray2.default)(_p3, 2),
579
+ bx = _p4[0],
580
+ by = _p4[1];
581
+
519
582
  var pB = _glMatrix.vec3.fromValues(bx, by, positions[vB + 2]);
583
+
520
584
  var _p5 = p3,
521
- _p6 = (0, _slicedToArray2.default)(_p5, 2),
522
- cx = _p6[0],
523
- cy = _p6[1];
585
+ _p6 = (0, _slicedToArray2.default)(_p5, 2),
586
+ cx = _p6[0],
587
+ cy = _p6[1];
588
+
524
589
  var pC = _glMatrix.vec3.fromValues(cx, cy, positions[vC + 2]);
590
+
525
591
  _glMatrix.vec3.sub(cb, pC, pB);
592
+
526
593
  _glMatrix.vec3.sub(ab, pA, pB);
594
+
527
595
  _glMatrix.vec3.cross(normal, cb, ab);
596
+
528
597
  normals[vA] += cb[0];
529
598
  normals[vA + 1] += cb[1];
530
599
  normals[vA + 2] += cb[2];
@@ -535,47 +604,56 @@ function computeVertexNormals(positions, indexArray) {
535
604
  normals[vC + 1] += cb[1];
536
605
  normals[vC + 2] += cb[2];
537
606
  }
607
+
538
608
  normalizeNormals(normals);
539
609
  return normals;
540
610
  }
611
+
541
612
  function normalizeNormals(normals) {
542
613
  for (var i = 0, li = normals.length; i < li; i += 3) {
543
614
  var normal = _glMatrix.vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
615
+
544
616
  var newNormal = _glMatrix.vec3.create();
617
+
545
618
  _glMatrix.vec3.normalize(newNormal, normal);
619
+
546
620
  normals.set(newNormal, i);
547
621
  }
548
622
  }
623
+
549
624
  function checkIsClosed(points) {
550
625
  var p1 = points[0][0];
551
626
  var p2 = points[0][points[0].length - 1];
552
627
  return p1[0] === p2[0] && p1[1] === p2[1];
553
628
  }
629
+
554
630
  function getHeatmapGeometry(shape) {
555
631
  var shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
556
632
  var path = _Path.geometryShape[shape] ? _Path.geometryShape[shape]() : _Path.geometryShape.circle();
557
- var geometry = shape3d.indexOf(shape) === -1 ? (0, _extrude.fillPolygon)([path]) : (0, _extrude.default)([path]);
558
- // const geometry = fillPolygon([path]);
633
+ var geometry = shape3d.indexOf(shape) === -1 ? (0, _extrude.fillPolygon)([path]) : (0, _extrude.default)([path]); // const geometry = fillPolygon([path]);
634
+
559
635
  return geometry;
560
- }
561
- // 热力图计算范围
636
+ } // 热力图计算范围
637
+
638
+
562
639
  function addDir(dirX, dirY) {
563
640
  var x = (dirX + 1) / 2;
564
641
  var y = (dirY + 1) / 2;
565
642
  return [x, y];
566
643
  }
567
-
568
644
  /**
569
645
  * 构建地球三角网格
570
646
  * @returns
571
647
  */
648
+
649
+
572
650
  function earthTriangulation() {
573
651
  var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS, {
574
652
  segments: _utils.EARTH_SEGMENTS
575
653
  });
576
654
  var positionsArr = earthmesh.positionsArr,
577
- indicesArr = earthmesh.indicesArr,
578
- normalArr = earthmesh.normalArr;
655
+ indicesArr = earthmesh.indicesArr,
656
+ normalArr = earthmesh.normalArr;
579
657
  return {
580
658
  vertices: positionsArr,
581
659
  indices: indicesArr,
@@ -583,13 +661,14 @@ function earthTriangulation() {
583
661
  normals: normalArr
584
662
  };
585
663
  }
664
+
586
665
  function earthOuterTriangulation() {
587
666
  var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS + _utils.EARTH_RADIUS_OUTER, {
588
667
  segments: _utils.EARTH_SEGMENTS
589
668
  });
590
669
  var positionsArr = earthmesh.positionsArr,
591
- indicesArr = earthmesh.indicesArr,
592
- normalArr = earthmesh.normalArr;
670
+ indicesArr = earthmesh.indicesArr,
671
+ normalArr = earthmesh.normalArr;
593
672
  return {
594
673
  vertices: positionsArr,
595
674
  indices: indicesArr,