@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
@@ -1,15 +1,14 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import { calculateCentroid, calculatePointsCenterAndRadius, lngLatToMeters } from '@antv/l7-utils';
4
- import earcut from 'earcut';
5
- // @ts-ignore
4
+ import earcut from 'earcut'; // @ts-ignore
5
+
6
6
  import { vec3 } from 'gl-matrix';
7
7
  import { EARTH_RADIUS, EARTH_RADIUS_OUTER, EARTH_SEGMENTS, lglt2xyz, primitiveSphere } from "../earth/utils";
8
8
  import ExtrudePolyline from "../utils/extrude_polyline";
9
9
  import extrudePolygon, { extrude_PolygonNormal, fillPolygon } from "./shape/extrude";
10
10
  import { geometryShape } from "./shape/Path";
11
11
  var GeometryCache = {};
12
-
13
12
  /**
14
13
  * 计算2D 填充点图顶点
15
14
  * @param feature 映射feature
@@ -27,6 +26,7 @@ export function PointFillTriangulation(feature) {
27
26
  * 计算2D 填充点图顶点 (地球模式)
28
27
  * @param feature 映射feature
29
28
  */
29
+
30
30
  export function GlobelPointFillTriangulation(feature) {
31
31
  var coordinates = calculateCentroid(feature.coordinates);
32
32
  var xyz = lglt2xyz(coordinates);
@@ -36,17 +36,19 @@ export function GlobelPointFillTriangulation(feature) {
36
36
  size: xyz.length
37
37
  };
38
38
  }
39
-
40
39
  /**
41
40
  * 计算3D 拉伸点图
42
41
  * @param feature 映射feature
43
42
  */
43
+
44
44
  export function PointExtrudeTriangulation(feature) {
45
45
  var shape = feature.shape;
46
+
46
47
  var _getGeometry = getGeometry(shape, false),
47
- positions = _getGeometry.positions,
48
- index = _getGeometry.index,
49
- normals = _getGeometry.normals;
48
+ positions = _getGeometry.positions,
49
+ index = _getGeometry.index,
50
+ normals = _getGeometry.normals;
51
+
50
52
  return {
51
53
  vertices: positions,
52
54
  indices: index,
@@ -54,11 +56,11 @@ export function PointExtrudeTriangulation(feature) {
54
56
  size: 5
55
57
  };
56
58
  }
57
-
58
59
  /**
59
60
  * 计算图片标注
60
61
  * @param feature 映射feature
61
62
  */
63
+
62
64
  export function PointImageTriangulation(feature) {
63
65
  var coordinates = calculateCentroid(feature.coordinates);
64
66
  return {
@@ -67,16 +69,15 @@ export function PointImageTriangulation(feature) {
67
69
  size: coordinates.length
68
70
  };
69
71
  }
70
-
71
72
  /**
72
73
  * 线三角化
73
74
  * @param feature 映射feature
74
75
  */
76
+
75
77
  export function LineTriangulation(feature) {
76
78
  var coordinates = feature.coordinates,
77
- originCoordinates = feature.originCoordinates,
78
- version = feature.version;
79
- // let path = coordinates as number[][][] | number[][];
79
+ originCoordinates = feature.originCoordinates,
80
+ version = feature.version; // let path = coordinates as number[][][] | number[][];
80
81
  // if (!Array.isArray(path[0][0])) {
81
82
  // path = [coordinates] as number[][][];
82
83
  // }
@@ -85,16 +86,21 @@ export function LineTriangulation(feature) {
85
86
  dash: true,
86
87
  join: 'bevel'
87
88
  });
89
+
88
90
  if (version === 'GAODE2.x') {
89
91
  // 处理高德2.0几何体构建
90
92
  var path1 = coordinates; // 计算位置
93
+
91
94
  if (!Array.isArray(path1[0][0])) {
92
95
  path1 = [coordinates];
93
96
  }
97
+
94
98
  var path2 = originCoordinates; // 计算法线
99
+
95
100
  if (!Array.isArray(path2[0][0])) {
96
101
  path2 = [originCoordinates];
97
102
  }
103
+
98
104
  for (var i = 0; i < path1.length; i++) {
99
105
  // 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
100
106
  var item1 = path1[i];
@@ -104,13 +110,16 @@ export function LineTriangulation(feature) {
104
110
  } else {
105
111
  // 处理非高德2.0的几何体构建
106
112
  var path = coordinates;
113
+
107
114
  if (path[0] && !Array.isArray(path[0][0])) {
108
115
  path = [coordinates];
109
116
  }
117
+
110
118
  path.forEach(function (item) {
111
119
  line.extrude(item);
112
120
  });
113
121
  }
122
+
114
123
  var linebuffer = line.complex;
115
124
  return {
116
125
  vertices: linebuffer.positions,
@@ -124,6 +133,7 @@ export function LineTriangulation(feature) {
124
133
  export function SimpleLineTriangulation(feature) {
125
134
  var coordinates = feature.coordinates;
126
135
  var pos = [];
136
+
127
137
  if (!Array.isArray(coordinates[0])) {
128
138
  return {
129
139
  vertices: [],
@@ -133,9 +143,11 @@ export function SimpleLineTriangulation(feature) {
133
143
  count: 0
134
144
  };
135
145
  }
146
+
136
147
  var _getSimpleLineVertice = getSimpleLineVertices(coordinates),
137
- results = _getSimpleLineVertice.results,
138
- totalDistance = _getSimpleLineVertice.totalDistance;
148
+ results = _getSimpleLineVertice.results,
149
+ totalDistance = _getSimpleLineVertice.totalDistance;
150
+
139
151
  results.map(function (point) {
140
152
  pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
141
153
  });
@@ -150,6 +162,7 @@ export function SimpleLineTriangulation(feature) {
150
162
  export function TileSimpleLineTriangulation(feature) {
151
163
  var coordinates = feature.coordinates;
152
164
  var pos = [];
165
+
153
166
  if (!Array.isArray(coordinates[0])) {
154
167
  return {
155
168
  vertices: [],
@@ -158,8 +171,10 @@ export function TileSimpleLineTriangulation(feature) {
158
171
  count: 0
159
172
  };
160
173
  }
174
+
161
175
  var _getTileSimpleLineVer = getTileSimpleLineVertices(coordinates),
162
- results = _getTileSimpleLineVer.results;
176
+ results = _getTileSimpleLineVer.results;
177
+
163
178
  results.map(function (point) {
164
179
  pos.push(point[0], point[1], point[2], point[3]);
165
180
  });
@@ -170,27 +185,35 @@ export function TileSimpleLineTriangulation(feature) {
170
185
  count: results.length
171
186
  };
172
187
  }
188
+
173
189
  function lineSegmentDistance(b1, a1) {
174
190
  var dx = a1[0] - b1[0];
175
191
  var dy = a1[1] - b1[1];
176
192
  return Math.sqrt(dx * dx + dy * dy);
177
193
  }
194
+
178
195
  function pushDis(point, n) {
179
196
  if (point.length < 3) {
180
197
  point.push(0);
181
198
  }
199
+
182
200
  if (n !== undefined) {
183
201
  point.push(n);
184
202
  }
203
+
185
204
  return point;
186
205
  }
206
+
187
207
  function getSimpleLineVertices(coordinates) {
188
208
  var points = coordinates;
209
+
189
210
  if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
190
211
  // @ts-ignore
191
212
  points = coordinates.flat();
192
213
  }
214
+
193
215
  var distance = 0;
216
+
194
217
  if (points.length < 2) {
195
218
  return {
196
219
  results: points,
@@ -200,6 +223,7 @@ function getSimpleLineVertices(coordinates) {
200
223
  var results = [];
201
224
  var point = pushDis(points[0], distance);
202
225
  results.push(point);
226
+
203
227
  for (var i = 1; i < points.length - 1; i++) {
204
228
  var subDistance = lineSegmentDistance(points[i - 1], points[i]);
205
229
  distance += subDistance;
@@ -207,6 +231,7 @@ function getSimpleLineVertices(coordinates) {
207
231
  results.push(mulPoint);
208
232
  results.push(mulPoint);
209
233
  }
234
+
210
235
  var pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
211
236
  distance += pointDistance;
212
237
  results.push(pushDis(points[points.length - 1], distance));
@@ -216,6 +241,7 @@ function getSimpleLineVertices(coordinates) {
216
241
  };
217
242
  }
218
243
  }
244
+
219
245
  function getTileSimpleLineVertices(points) {
220
246
  if (points.length < 2) {
221
247
  return {
@@ -225,61 +251,70 @@ function getTileSimpleLineVertices(points) {
225
251
  var results = [];
226
252
  var point = pushDis(points[0]);
227
253
  results.push(point);
254
+
228
255
  for (var i = 1; i < points.length - 1; i++) {
229
256
  var mulPoint = pushDis(points[i]);
230
257
  results.push(mulPoint);
231
258
  results.push(mulPoint);
232
259
  }
260
+
233
261
  results.push(pushDis(points[points.length - 1]));
234
262
  return {
235
263
  results: results
236
264
  };
237
265
  }
238
266
  }
267
+
239
268
  export function polygonTriangulation(feature) {
240
269
  var coordinates = feature.coordinates;
241
270
  var flattengeo = earcut.flatten(coordinates);
242
271
  var vertices = flattengeo.vertices,
243
- dimensions = flattengeo.dimensions,
244
- holes = flattengeo.holes;
272
+ dimensions = flattengeo.dimensions,
273
+ holes = flattengeo.holes;
245
274
  return {
246
275
  indices: earcut(vertices, holes, dimensions),
247
276
  vertices: vertices,
248
277
  size: dimensions
249
278
  };
250
- }
279
+ } // 构建几何图形(带有中心点和大小)
251
280
 
252
- // 构建几何图形(带有中心点和大小)
253
281
  export function polygonTriangulationWithCenter(feature) {
254
282
  var coordinates = feature.coordinates;
255
283
  var flattengeo = earcut.flatten(coordinates);
256
284
  var vertices = flattengeo.vertices,
257
- dimensions = flattengeo.dimensions,
258
- holes = flattengeo.holes;
285
+ dimensions = flattengeo.dimensions,
286
+ holes = flattengeo.holes;
259
287
  return {
260
288
  indices: earcut(vertices, holes, dimensions),
261
289
  vertices: getVerticesWithCenter(vertices),
262
290
  size: dimensions + 4
263
291
  };
264
292
  }
293
+
265
294
  function getVerticesWithCenter(vertices) {
266
295
  var verticesWithCenter = [];
296
+
267
297
  var _calculatePointsCente = calculatePointsCenterAndRadius(vertices),
268
- center = _calculatePointsCente.center,
269
- radius = _calculatePointsCente.radius;
298
+ center = _calculatePointsCente.center,
299
+ radius = _calculatePointsCente.radius;
300
+
270
301
  for (var i = 0; i < vertices.length; i += 2) {
271
302
  var lng = vertices[i];
272
303
  var lat = vertices[i + 1];
273
304
  verticesWithCenter.push.apply(verticesWithCenter, [lng, lat, 0].concat(_toConsumableArray(center), [radius]));
274
305
  }
306
+
275
307
  return verticesWithCenter;
276
308
  }
309
+
277
310
  export function PolygonExtrudeTriangulation(feature) {
278
311
  var coordinates = feature.coordinates;
312
+
279
313
  var _extrude_PolygonNorma = extrude_PolygonNormal(coordinates, true),
280
- positions = _extrude_PolygonNorma.positions,
281
- index = _extrude_PolygonNorma.index,
282
- normals = _extrude_PolygonNorma.normals;
314
+ positions = _extrude_PolygonNorma.positions,
315
+ index = _extrude_PolygonNorma.index,
316
+ normals = _extrude_PolygonNorma.normals;
317
+
283
318
  return {
284
319
  vertices: positions,
285
320
  // [ x, y, z, uv.x,uv.y ]
@@ -290,9 +325,11 @@ export function PolygonExtrudeTriangulation(feature) {
290
325
  }
291
326
  export function HeatmapGridTriangulation(feature) {
292
327
  var shape = feature.shape;
328
+
293
329
  var _getHeatmapGeometry = getHeatmapGeometry(shape),
294
- positions = _getHeatmapGeometry.positions,
295
- index = _getHeatmapGeometry.index;
330
+ positions = _getHeatmapGeometry.positions,
331
+ index = _getHeatmapGeometry.index;
332
+
296
333
  return {
297
334
  vertices: positions,
298
335
  // [ x, y, z ] 多边形顶点
@@ -300,14 +337,14 @@ export function HeatmapGridTriangulation(feature) {
300
337
  size: 3
301
338
  };
302
339
  }
303
-
304
340
  /**
305
341
  * 图片图层顶点构造
306
342
  * @param feature 数据
307
343
  */
344
+
308
345
  export function RasterImageTriangulation(feature) {
309
- var coordinates = feature.coordinates;
310
- // [ x, y, z. uv.x, uv.y]
346
+ var coordinates = feature.coordinates; // [ x, y, z. uv.x, uv.y]
347
+
311
348
  var positions = [].concat(_toConsumableArray(coordinates[0]), [0, 0, 1, coordinates[1][0], coordinates[0][1], 0, 1, 1], _toConsumableArray(coordinates[1]), [0, 1, 0], _toConsumableArray(coordinates[0]), [0, 0, 1], _toConsumableArray(coordinates[1]), [0, 1, 0, coordinates[0][0], coordinates[1][1], 0, 0, 0]);
312
349
  var indexs = [0, 1, 2, 3, 4, 5];
313
350
  return {
@@ -316,52 +353,58 @@ export function RasterImageTriangulation(feature) {
316
353
  size: 5
317
354
  };
318
355
  }
319
-
320
356
  /**
321
357
  * 计算3D弧线顶点
322
358
  * @param feature 映射数据
323
359
  * @param segNum 弧线线段数
324
360
  */
361
+
325
362
  export function LineArcTriangulation(feature, segmentNumber) {
326
363
  var segNum = segmentNumber ? segmentNumber : 30;
327
364
  var coordinates = feature.coordinates;
328
365
  var positions = [];
329
366
  var indexArray = [];
367
+
330
368
  var _loop = function _loop(i) {
331
369
  // 上线两个顶点
332
370
  // [ x, y, z, sx,sy, tx,ty]
333
371
  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]);
372
+
334
373
  if (i !== segNum - 1) {
335
374
  indexArray.push.apply(indexArray, _toConsumableArray([0, 1, 2, 1, 3, 2].map(function (v) {
336
375
  return i * 2 + v;
337
376
  })));
338
377
  }
339
378
  };
379
+
340
380
  for (var i = 0; i < segNum; i++) {
341
381
  _loop(i);
342
382
  }
383
+
343
384
  return {
344
385
  vertices: positions,
345
386
  indices: indexArray,
346
387
  size: 7
347
388
  };
348
389
  }
349
-
350
390
  /**
351
391
  * 构建热力图密度图的顶点
352
392
  * @param feature
353
393
  * @returns
354
394
  */
395
+
355
396
  export function HeatmapTriangulation(feature) {
356
397
  var coordinates = feature.coordinates;
398
+
357
399
  if (coordinates.length === 2) {
358
400
  coordinates.push(0);
359
401
  }
402
+
360
403
  var dir = addDir(-1, 1);
361
404
  var dir1 = addDir(1, 1);
362
405
  var dir2 = addDir(-1, -1);
363
- var dir3 = addDir(1, -1);
364
- // [x,y,z, dirx ,diry, weight]
406
+ var dir3 = addDir(1, -1); // [x,y,z, dirx ,diry, weight]
407
+
365
408
  var positions = [].concat(_toConsumableArray(coordinates), _toConsumableArray(dir), _toConsumableArray(coordinates), _toConsumableArray(dir2), _toConsumableArray(coordinates), _toConsumableArray(dir3), _toConsumableArray(coordinates), _toConsumableArray(dir1));
366
409
  var indexArray = [0, 1, 2, 3, 0, 2];
367
410
  return {
@@ -370,21 +413,24 @@ export function HeatmapTriangulation(feature) {
370
413
  size: 5
371
414
  };
372
415
  }
373
-
374
416
  /**
375
417
  * 点图层3d geomerty
376
418
  * @param shape 3D形状
377
419
  */
420
+
378
421
  function getGeometry(shape) {
379
422
  var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
423
+
380
424
  if (GeometryCache && GeometryCache[shape]) {
381
425
  return GeometryCache[shape];
382
426
  }
427
+
383
428
  var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.cylinder();
384
429
  var geometry = extrude_PolygonNormal([path], needFlat);
385
430
  GeometryCache[shape] = geometry;
386
431
  return geometry;
387
432
  }
433
+
388
434
  export function computeVertexNormals(positions, indexArray) {
389
435
  var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
390
436
  var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -395,6 +441,7 @@ export function computeVertexNormals(positions, indexArray) {
395
441
  var cb = vec3.create();
396
442
  var ab = vec3.create();
397
443
  var normal = vec3.create();
444
+
398
445
  for (var i = 0, li = indexArray.length; i < li; i += 3) {
399
446
  vA = indexArray[i + 0] * 3;
400
447
  vB = indexArray[i + 1] * 3;
@@ -402,25 +449,32 @@ export function computeVertexNormals(positions, indexArray) {
402
449
  var p1 = [positions[vA], positions[vA + 1]];
403
450
  var p2 = [positions[vB], positions[vB + 1]];
404
451
  var p3 = [positions[vC], positions[vC + 1]];
452
+
405
453
  if (needFlat) {
406
454
  p1 = lngLatToMeters(p1);
407
455
  p2 = lngLatToMeters(p2);
408
456
  p3 = lngLatToMeters(p3);
409
457
  }
458
+
410
459
  var _p = p1,
411
- _p2 = _slicedToArray(_p, 2),
412
- ax = _p2[0],
413
- ay = _p2[1];
460
+ _p2 = _slicedToArray(_p, 2),
461
+ ax = _p2[0],
462
+ ay = _p2[1];
463
+
414
464
  var pA = vec3.fromValues(ax, ay, positions[vA + 2]);
465
+
415
466
  var _p3 = p2,
416
- _p4 = _slicedToArray(_p3, 2),
417
- bx = _p4[0],
418
- by = _p4[1];
467
+ _p4 = _slicedToArray(_p3, 2),
468
+ bx = _p4[0],
469
+ by = _p4[1];
470
+
419
471
  var pB = vec3.fromValues(bx, by, positions[vB + 2]);
472
+
420
473
  var _p5 = p3,
421
- _p6 = _slicedToArray(_p5, 2),
422
- cx = _p6[0],
423
- cy = _p6[1];
474
+ _p6 = _slicedToArray(_p5, 2),
475
+ cx = _p6[0],
476
+ cy = _p6[1];
477
+
424
478
  var pC = vec3.fromValues(cx, cy, positions[vC + 2]);
425
479
  vec3.sub(cb, pC, pB);
426
480
  vec3.sub(ab, pA, pB);
@@ -435,9 +489,11 @@ export function computeVertexNormals(positions, indexArray) {
435
489
  normals[vC + 1] += cb[1];
436
490
  normals[vC + 2] += cb[2];
437
491
  }
492
+
438
493
  normalizeNormals(normals);
439
494
  return normals;
440
495
  }
496
+
441
497
  function normalizeNormals(normals) {
442
498
  for (var i = 0, li = normals.length; i < li; i += 3) {
443
499
  var normal = vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
@@ -446,36 +502,40 @@ function normalizeNormals(normals) {
446
502
  normals.set(newNormal, i);
447
503
  }
448
504
  }
505
+
449
506
  export function checkIsClosed(points) {
450
507
  var p1 = points[0][0];
451
508
  var p2 = points[0][points[0].length - 1];
452
509
  return p1[0] === p2[0] && p1[1] === p2[1];
453
510
  }
511
+
454
512
  function getHeatmapGeometry(shape) {
455
513
  var shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
456
514
  var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.circle();
457
- var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]);
458
- // const geometry = fillPolygon([path]);
515
+ var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]); // const geometry = fillPolygon([path]);
516
+
459
517
  return geometry;
460
- }
461
- // 热力图计算范围
518
+ } // 热力图计算范围
519
+
520
+
462
521
  function addDir(dirX, dirY) {
463
522
  var x = (dirX + 1) / 2;
464
523
  var y = (dirY + 1) / 2;
465
524
  return [x, y];
466
525
  }
467
-
468
526
  /**
469
527
  * 构建地球三角网格
470
528
  * @returns
471
529
  */
530
+
531
+
472
532
  export function earthTriangulation() {
473
533
  var earthmesh = primitiveSphere(EARTH_RADIUS, {
474
534
  segments: EARTH_SEGMENTS
475
535
  });
476
536
  var positionsArr = earthmesh.positionsArr,
477
- indicesArr = earthmesh.indicesArr,
478
- normalArr = earthmesh.normalArr;
537
+ indicesArr = earthmesh.indicesArr,
538
+ normalArr = earthmesh.normalArr;
479
539
  return {
480
540
  vertices: positionsArr,
481
541
  indices: indicesArr,
@@ -488,8 +548,8 @@ export function earthOuterTriangulation() {
488
548
  segments: EARTH_SEGMENTS
489
549
  });
490
550
  var positionsArr = earthmesh.positionsArr,
491
- indicesArr = earthmesh.indicesArr,
492
- normalArr = earthmesh.normalArr;
551
+ indicesArr = earthmesh.indicesArr,
552
+ normalArr = earthmesh.normalArr;
493
553
  return {
494
554
  vertices: positionsArr,
495
555
  indices: indicesArr,
package/es/earth/index.js CHANGED
@@ -7,8 +7,11 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
+
10
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
+
11
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+
12
15
  import BaseLayer from "../core/BaseLayer";
13
16
  import EarthAtomSphereModel from "./models/atmosphere";
14
17
  import BaseEarthModel from "./models/base";
@@ -19,17 +22,25 @@ var EarthModels = {
19
22
  bloomSphere: EarthBloomSphereModel
20
23
  };
21
24
  var earthLayerTypes = ['base', 'atomSphere', 'bloomSphere'];
25
+
22
26
  var EarthLayer = /*#__PURE__*/function (_BaseLayer) {
23
27
  _inherits(EarthLayer, _BaseLayer);
28
+
24
29
  var _super = _createSuper(EarthLayer);
30
+
25
31
  function EarthLayer() {
26
32
  var _this;
33
+
27
34
  _classCallCheck(this, EarthLayer);
35
+
28
36
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
37
  args[_key] = arguments[_key];
30
38
  }
39
+
31
40
  _this = _super.call.apply(_super, [this].concat(args));
41
+
32
42
  _defineProperty(_assertThisInitialized(_this), "type", 'EarthLayer');
43
+
33
44
  _defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
34
45
  data: [],
35
46
  options: {
@@ -38,35 +49,43 @@ var EarthLayer = /*#__PURE__*/function (_BaseLayer) {
38
49
  }
39
50
  }
40
51
  });
52
+
41
53
  return _this;
42
54
  }
55
+
43
56
  _createClass(EarthLayer, [{
44
57
  key: "buildModels",
45
58
  value: function () {
46
59
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
47
60
  var shape;
48
61
  return _regeneratorRuntime.wrap(function _callee$(_context) {
49
- while (1) switch (_context.prev = _context.next) {
50
- case 0:
51
- shape = this.getModelType();
52
- this.layerModel = new EarthModels[shape](this);
53
- _context.next = 4;
54
- return this.initLayerModels();
55
- case 4:
56
- case "end":
57
- return _context.stop();
62
+ while (1) {
63
+ switch (_context.prev = _context.next) {
64
+ case 0:
65
+ shape = this.getModelType();
66
+ this.layerModel = new EarthModels[shape](this);
67
+ _context.next = 4;
68
+ return this.initLayerModels();
69
+
70
+ case 4:
71
+ case "end":
72
+ return _context.stop();
73
+ }
58
74
  }
59
75
  }, _callee, this);
60
76
  }));
77
+
61
78
  function buildModels() {
62
79
  return _buildModels.apply(this, arguments);
63
80
  }
81
+
64
82
  return buildModels;
65
83
  }()
66
84
  /**
67
85
  * 设置当前地球时间
68
86
  * @param time
69
87
  */
88
+
70
89
  }, {
71
90
  key: "setEarthTime",
72
91
  value: function setEarthTime(time) {
@@ -80,14 +99,19 @@ var EarthLayer = /*#__PURE__*/function (_BaseLayer) {
80
99
  key: "getModelType",
81
100
  value: function getModelType() {
82
101
  var _shapeAttribute$scale;
102
+
83
103
  var shapeAttribute = this.styleAttributeService.getLayerStyleAttribute('shape');
84
104
  var shape = (shapeAttribute === null || shapeAttribute === void 0 ? void 0 : (_shapeAttribute$scale = shapeAttribute.scale) === null || _shapeAttribute$scale === void 0 ? void 0 : _shapeAttribute$scale.field) || 'base';
105
+
85
106
  if (earthLayerTypes.indexOf(shape) < 0) {
86
107
  shape = 'base';
87
108
  }
109
+
88
110
  return shape;
89
111
  }
90
112
  }]);
113
+
91
114
  return EarthLayer;
92
115
  }(BaseLayer);
116
+
93
117
  export { EarthLayer as default };