@antv/l7-layers 2.21.1 → 2.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (394) hide show
  1. package/es/canvas/index.js +60 -113
  2. package/es/canvas/models/canvas.js +95 -135
  3. package/es/canvas/models/constants.js +1 -1
  4. package/es/citybuliding/building.js +20 -58
  5. package/es/citybuliding/models/build.js +142 -199
  6. package/es/core/BaseLayer.d.ts +1 -1
  7. package/es/core/BaseLayer.js +1113 -1412
  8. package/es/core/BaseModel.js +263 -317
  9. package/es/core/CommonStyleAttribute.js +25 -18
  10. package/es/core/LayerPickService.js +92 -141
  11. package/es/core/TextureService.js +58 -69
  12. package/es/core/constant.js +2 -2
  13. package/es/core/interface.js +5 -5
  14. package/es/core/line_trangluation.js +38 -43
  15. package/es/core/shape/Path.js +21 -12
  16. package/es/core/shape/arrow.js +50 -62
  17. package/es/core/shape/extrude.js +54 -62
  18. package/es/core/triangulation.js +192 -171
  19. package/es/core/utils.js +5 -5
  20. package/es/earth/index.js +35 -73
  21. package/es/earth/models/atmosphere.js +98 -148
  22. package/es/earth/models/base.js +148 -201
  23. package/es/earth/models/bloomsphere.js +97 -147
  24. package/es/earth/utils.js +37 -38
  25. package/es/geometry/index.js +36 -75
  26. package/es/geometry/models/billboard.js +147 -204
  27. package/es/geometry/models/index.js +1 -1
  28. package/es/geometry/models/plane.js +277 -357
  29. package/es/geometry/models/sprite.js +182 -240
  30. package/es/heatmap/index.js +72 -121
  31. package/es/heatmap/models/grid.js +66 -118
  32. package/es/heatmap/models/grid3d.js +101 -151
  33. package/es/heatmap/models/heatmap.js +398 -455
  34. package/es/heatmap/models/hexagon.js +67 -119
  35. package/es/heatmap/models/index.js +1 -1
  36. package/es/heatmap/triangulation.js +20 -20
  37. package/es/image/index.js +23 -62
  38. package/es/image/models/image.js +99 -163
  39. package/es/image/models/index.js +1 -1
  40. package/es/line/index.js +65 -106
  41. package/es/line/models/arc.js +200 -248
  42. package/es/line/models/arc_3d.js +190 -241
  43. package/es/line/models/flow.js +101 -153
  44. package/es/line/models/great_circle.js +183 -234
  45. package/es/line/models/index.js +1 -1
  46. package/es/line/models/line.js +230 -285
  47. package/es/line/models/simple_line.js +142 -192
  48. package/es/line/models/wall.js +221 -273
  49. package/es/mask/index.js +16 -53
  50. package/es/mask/models/fill.js +51 -108
  51. package/es/mask/models/index.js +1 -1
  52. package/es/plugins/DataMappingPlugin.js +205 -249
  53. package/es/plugins/DataSourcePlugin.js +64 -92
  54. package/es/plugins/FeatureScalePlugin.js +258 -302
  55. package/es/plugins/LayerAnimateStylePlugin.js +12 -22
  56. package/es/plugins/LayerMaskPlugin.js +15 -24
  57. package/es/plugins/LayerModelPlugin.js +52 -136
  58. package/es/plugins/LayerStylePlugin.js +14 -23
  59. package/es/plugins/LightingPlugin.js +26 -37
  60. package/es/plugins/MultiPassRendererPlugin.js +34 -39
  61. package/es/plugins/PixelPickingPlugin.js +129 -150
  62. package/es/plugins/RegisterStyleAttributePlugin.js +80 -96
  63. package/es/plugins/ShaderUniformPlugin.js +159 -131
  64. package/es/plugins/UpdateModelPlugin.js +16 -26
  65. package/es/plugins/UpdateStyleAttributePlugin.js +47 -65
  66. package/es/plugins/index.d.ts +1 -1
  67. package/es/point/index.js +118 -182
  68. package/es/point/models/billboard_point.js +72 -127
  69. package/es/point/models/earthExtrude.js +170 -220
  70. package/es/point/models/earthFill.js +136 -192
  71. package/es/point/models/extrude.js +167 -217
  72. package/es/point/models/fill.js +152 -209
  73. package/es/point/models/fillImage.js +156 -211
  74. package/es/point/models/image.js +127 -180
  75. package/es/point/models/index.js +1 -1
  76. package/es/point/models/normal.js +67 -122
  77. package/es/point/models/radar.js +93 -148
  78. package/es/point/models/text.js +447 -578
  79. package/es/point/shape/extrude.js +19 -25
  80. package/es/polygon/index.js +61 -99
  81. package/es/polygon/models/extrude.js +208 -281
  82. package/es/polygon/models/extrusion.js +95 -142
  83. package/es/polygon/models/fill.js +102 -153
  84. package/es/polygon/models/index.js +1 -1
  85. package/es/polygon/models/ocean.js +139 -198
  86. package/es/polygon/models/water.js +120 -179
  87. package/es/raster/buffers/triangulation.js +13 -11
  88. package/es/raster/index.js +47 -88
  89. package/es/raster/models/index.js +1 -1
  90. package/es/raster/models/raster.js +134 -202
  91. package/es/raster/models/rasterRgb.js +134 -208
  92. package/es/raster/models/rasterTerrainRgb.js +98 -153
  93. package/es/tile/core/BaseLayer.d.ts +1 -0
  94. package/es/tile/core/BaseLayer.js +206 -282
  95. package/es/tile/core/TileDebugLayer.js +12 -46
  96. package/es/tile/interaction/getRasterData.js +24 -30
  97. package/es/tile/interaction/utils.js +15 -33
  98. package/es/tile/service/TileLayerService.js +104 -177
  99. package/es/tile/service/TilePickService.js +99 -156
  100. package/es/tile/service/TileSourceService.js +17 -26
  101. package/es/tile/tile/DebugTile.js +41 -78
  102. package/es/tile/tile/ImageTile.js +33 -66
  103. package/es/tile/tile/MaskTile.js +47 -81
  104. package/es/tile/tile/RasterRGBTile.js +40 -71
  105. package/es/tile/tile/RasterTerrainRGBTile.js +33 -66
  106. package/es/tile/tile/RasterTile.js +69 -104
  107. package/es/tile/tile/Tile.d.ts +1 -1
  108. package/es/tile/tile/Tile.js +151 -232
  109. package/es/tile/tile/VectorTile.js +77 -124
  110. package/es/tile/tile/index.d.ts +1 -1
  111. package/es/tile/tile/index.js +4 -2
  112. package/es/tile/tile/util.d.ts +1 -1
  113. package/es/tile/utils/constants.js +1 -1
  114. package/es/tile/utils/utils.js +2 -2
  115. package/es/utils/blend.js +52 -46
  116. package/es/utils/collision-index.js +62 -70
  117. package/es/utils/extrude_polyline.js +441 -471
  118. package/es/utils/grid-index.js +97 -123
  119. package/es/utils/identityScale.js +5 -5
  120. package/es/utils/load-image.js +15 -39
  121. package/es/utils/multiPassRender.js +7 -9
  122. package/es/utils/polylineNormal.js +40 -42
  123. package/es/utils/rampcolor_legend.js +5 -3
  124. package/es/utils/simpleLine.js +53 -66
  125. package/es/utils/symbol-layout.js +95 -117
  126. package/es/wind/index.js +28 -70
  127. package/es/wind/models/index.js +1 -1
  128. package/es/wind/models/utils.js +36 -34
  129. package/es/wind/models/wind.js +203 -260
  130. package/es/wind/models/windRender.js +258 -269
  131. package/es/wind/models/windShader.js +145 -6
  132. package/lib/canvas/index.d.ts +18 -0
  133. package/lib/canvas/index.js +64 -113
  134. package/lib/canvas/models/canvas.d.ts +23 -0
  135. package/lib/canvas/models/canvas.js +97 -136
  136. package/lib/canvas/models/constants.d.ts +2 -0
  137. package/lib/canvas/models/constants.js +1 -1
  138. package/lib/canvas/models/index.d.ts +2 -0
  139. package/lib/canvas/models/index.js +2 -2
  140. package/lib/citybuliding/building.d.ts +7 -0
  141. package/lib/citybuliding/building.js +22 -58
  142. package/lib/citybuliding/models/build.d.ts +17 -0
  143. package/lib/citybuliding/models/build.js +144 -199
  144. package/lib/core/BaseLayer.d.ts +247 -0
  145. package/lib/core/BaseLayer.js +1115 -1412
  146. package/lib/core/BaseModel.d.ts +82 -0
  147. package/lib/core/BaseModel.js +263 -315
  148. package/lib/core/CommonStyleAttribute.d.ts +20 -0
  149. package/lib/core/CommonStyleAttribute.js +25 -18
  150. package/lib/core/LayerPickService.d.ts +12 -0
  151. package/lib/core/LayerPickService.js +93 -140
  152. package/lib/core/TextureService.d.ts +15 -0
  153. package/lib/core/TextureService.js +59 -68
  154. package/lib/core/constant.d.ts +6 -0
  155. package/lib/core/constant.js +2 -2
  156. package/lib/core/interface.d.ts +282 -0
  157. package/lib/core/interface.js +5 -5
  158. package/lib/core/line_trangluation.d.ts +19 -0
  159. package/lib/core/line_trangluation.js +38 -43
  160. package/lib/core/schema.d.ts +27 -0
  161. package/lib/core/shape/Path.d.ts +39 -0
  162. package/lib/core/shape/Path.js +21 -13
  163. package/lib/core/shape/arrow.d.ts +25 -0
  164. package/lib/core/shape/arrow.js +50 -62
  165. package/lib/core/shape/extrude.d.ts +17 -0
  166. package/lib/core/shape/extrude.js +54 -62
  167. package/lib/core/triangulation.d.ts +136 -0
  168. package/lib/core/triangulation.js +194 -174
  169. package/lib/core/utils.d.ts +4 -0
  170. package/lib/core/utils.js +5 -5
  171. package/lib/earth/index.d.ts +22 -0
  172. package/lib/earth/index.js +37 -73
  173. package/lib/earth/models/atmosphere.d.ts +15 -0
  174. package/lib/earth/models/atmosphere.js +100 -148
  175. package/lib/earth/models/base.d.ts +22 -0
  176. package/lib/earth/models/base.js +150 -201
  177. package/lib/earth/models/bloomsphere.d.ts +15 -0
  178. package/lib/earth/models/bloomsphere.js +99 -147
  179. package/lib/earth/utils.d.ts +26 -0
  180. package/lib/earth/utils.js +37 -39
  181. package/lib/geometry/index.d.ts +22 -0
  182. package/lib/geometry/index.js +38 -75
  183. package/lib/geometry/models/billboard.d.ts +24 -0
  184. package/lib/geometry/models/billboard.js +149 -204
  185. package/lib/geometry/models/index.d.ts +5 -0
  186. package/lib/geometry/models/index.js +1 -1
  187. package/lib/geometry/models/plane.d.ts +43 -0
  188. package/lib/geometry/models/plane.js +280 -357
  189. package/lib/geometry/models/sprite.d.ts +48 -0
  190. package/lib/geometry/models/sprite.js +184 -240
  191. package/lib/heatmap/index.d.ts +13 -0
  192. package/lib/heatmap/index.js +74 -121
  193. package/lib/heatmap/models/grid.d.ts +15 -0
  194. package/lib/heatmap/models/grid.js +68 -118
  195. package/lib/heatmap/models/grid3d.d.ts +15 -0
  196. package/lib/heatmap/models/grid3d.js +103 -151
  197. package/lib/heatmap/models/heatmap.d.ts +27 -0
  198. package/lib/heatmap/models/heatmap.js +400 -455
  199. package/lib/heatmap/models/hexagon.d.ts +15 -0
  200. package/lib/heatmap/models/hexagon.js +69 -119
  201. package/lib/heatmap/models/index.d.ts +5 -0
  202. package/lib/heatmap/models/index.js +1 -1
  203. package/lib/heatmap/triangulation.d.ts +5 -0
  204. package/lib/heatmap/triangulation.js +20 -20
  205. package/lib/image/index.d.ts +9 -0
  206. package/lib/image/index.js +25 -62
  207. package/lib/image/models/image.d.ts +17 -0
  208. package/lib/image/models/image.js +101 -163
  209. package/lib/image/models/index.d.ts +5 -0
  210. package/lib/image/models/index.js +1 -1
  211. package/lib/index.d.ts +18 -0
  212. package/lib/index.js +17 -17
  213. package/lib/line/index.d.ts +36 -0
  214. package/lib/line/index.js +67 -106
  215. package/lib/line/models/arc.d.ts +22 -0
  216. package/lib/line/models/arc.js +202 -248
  217. package/lib/line/models/arc_3d.d.ts +22 -0
  218. package/lib/line/models/arc_3d.js +193 -241
  219. package/lib/line/models/flow.d.ts +14 -0
  220. package/lib/line/models/flow.js +103 -153
  221. package/lib/line/models/great_circle.d.ts +17 -0
  222. package/lib/line/models/great_circle.js +185 -234
  223. package/lib/line/models/index.d.ts +5 -0
  224. package/lib/line/models/index.js +1 -1
  225. package/lib/line/models/line.d.ts +27 -0
  226. package/lib/line/models/line.js +232 -285
  227. package/lib/line/models/simple_line.d.ts +19 -0
  228. package/lib/line/models/simple_line.js +144 -192
  229. package/lib/line/models/wall.d.ts +17 -0
  230. package/lib/line/models/wall.js +223 -273
  231. package/lib/mask/index.d.ts +16 -0
  232. package/lib/mask/index.js +18 -53
  233. package/lib/mask/models/fill.d.ts +18 -0
  234. package/lib/mask/models/fill.js +53 -108
  235. package/lib/mask/models/index.d.ts +5 -0
  236. package/lib/mask/models/index.js +1 -1
  237. package/lib/plugins/DataMappingPlugin.d.ts +13 -0
  238. package/lib/plugins/DataMappingPlugin.js +206 -248
  239. package/lib/plugins/DataSourcePlugin.d.ts +6 -0
  240. package/lib/plugins/DataSourcePlugin.js +65 -91
  241. package/lib/plugins/FeatureScalePlugin.d.ts +20 -0
  242. package/lib/plugins/FeatureScalePlugin.js +261 -304
  243. package/lib/plugins/LayerAnimateStylePlugin.d.ts +4 -0
  244. package/lib/plugins/LayerAnimateStylePlugin.js +13 -21
  245. package/lib/plugins/LayerMaskPlugin.d.ts +7 -0
  246. package/lib/plugins/LayerMaskPlugin.js +16 -24
  247. package/lib/plugins/LayerModelPlugin.d.ts +10 -0
  248. package/lib/plugins/LayerModelPlugin.js +53 -135
  249. package/lib/plugins/LayerStylePlugin.d.ts +7 -0
  250. package/lib/plugins/LayerStylePlugin.js +15 -23
  251. package/lib/plugins/LightingPlugin.d.ts +35 -0
  252. package/lib/plugins/LightingPlugin.js +27 -36
  253. package/lib/plugins/MultiPassRendererPlugin.d.ts +22 -0
  254. package/lib/plugins/MultiPassRendererPlugin.js +35 -38
  255. package/lib/plugins/PixelPickingPlugin.d.ts +11 -0
  256. package/lib/plugins/PixelPickingPlugin.js +130 -149
  257. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +11 -0
  258. package/lib/plugins/RegisterStyleAttributePlugin.js +81 -96
  259. package/lib/plugins/ShaderUniformPlugin.d.ts +22 -0
  260. package/lib/plugins/ShaderUniformPlugin.js +160 -130
  261. package/lib/plugins/UpdateModelPlugin.d.ts +7 -0
  262. package/lib/plugins/UpdateModelPlugin.js +17 -26
  263. package/lib/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
  264. package/lib/plugins/UpdateStyleAttributePlugin.js +48 -65
  265. package/lib/plugins/index.d.ts +15 -0
  266. package/lib/point/index.d.ts +33 -0
  267. package/lib/point/index.js +120 -182
  268. package/lib/point/models/billboard_point.d.ts +21 -0
  269. package/lib/point/models/billboard_point.js +74 -127
  270. package/lib/point/models/earthExtrude.d.ts +16 -0
  271. package/lib/point/models/earthExtrude.js +172 -220
  272. package/lib/point/models/earthFill.d.ts +15 -0
  273. package/lib/point/models/earthFill.js +138 -192
  274. package/lib/point/models/extrude.d.ts +16 -0
  275. package/lib/point/models/extrude.js +169 -217
  276. package/lib/point/models/fill.d.ts +31 -0
  277. package/lib/point/models/fill.js +154 -209
  278. package/lib/point/models/fillImage.d.ts +26 -0
  279. package/lib/point/models/fillImage.js +159 -211
  280. package/lib/point/models/image.d.ts +18 -0
  281. package/lib/point/models/image.js +129 -180
  282. package/lib/point/models/index.d.ts +5 -0
  283. package/lib/point/models/index.js +1 -1
  284. package/lib/point/models/normal.d.ts +22 -0
  285. package/lib/point/models/normal.js +69 -122
  286. package/lib/point/models/radar.d.ts +22 -0
  287. package/lib/point/models/radar.js +95 -148
  288. package/lib/point/models/text.d.ts +69 -0
  289. package/lib/point/models/text.js +449 -578
  290. package/lib/point/shape/extrude.d.ts +15 -0
  291. package/lib/point/shape/extrude.js +19 -25
  292. package/lib/polygon/index.d.ts +18 -0
  293. package/lib/polygon/index.js +63 -99
  294. package/lib/polygon/models/extrude.d.ts +25 -0
  295. package/lib/polygon/models/extrude.js +210 -281
  296. package/lib/polygon/models/extrusion.d.ts +24 -0
  297. package/lib/polygon/models/extrusion.js +97 -142
  298. package/lib/polygon/models/fill.d.ts +18 -0
  299. package/lib/polygon/models/fill.js +104 -153
  300. package/lib/polygon/models/index.d.ts +5 -0
  301. package/lib/polygon/models/index.js +1 -1
  302. package/lib/polygon/models/ocean.d.ts +23 -0
  303. package/lib/polygon/models/ocean.js +141 -198
  304. package/lib/polygon/models/water.d.ts +21 -0
  305. package/lib/polygon/models/water.js +122 -179
  306. package/lib/raster/buffers/triangulation.d.ts +6 -0
  307. package/lib/raster/buffers/triangulation.js +13 -11
  308. package/lib/raster/index.d.ts +11 -0
  309. package/lib/raster/index.js +49 -88
  310. package/lib/raster/models/index.d.ts +5 -0
  311. package/lib/raster/models/index.js +1 -1
  312. package/lib/raster/models/raster.d.ts +21 -0
  313. package/lib/raster/models/raster.js +136 -202
  314. package/lib/raster/models/rasterRgb.d.ts +21 -0
  315. package/lib/raster/models/rasterRgb.js +136 -208
  316. package/lib/raster/models/rasterTerrainRgb.d.ts +16 -0
  317. package/lib/raster/models/rasterTerrainRgb.js +100 -153
  318. package/lib/tile/core/BaseLayer.d.ts +48 -0
  319. package/lib/tile/core/BaseLayer.js +207 -281
  320. package/lib/tile/core/TileDebugLayer.d.ts +15 -0
  321. package/lib/tile/core/TileDebugLayer.js +14 -46
  322. package/lib/tile/interaction/getFeatureData.d.ts +0 -0
  323. package/lib/tile/interaction/getRasterData.d.ts +4 -0
  324. package/lib/tile/interaction/getRasterData.js +24 -31
  325. package/lib/tile/interaction/utils.d.ts +11 -0
  326. package/lib/tile/interaction/utils.js +15 -34
  327. package/lib/tile/interface.d.ts +29 -0
  328. package/lib/tile/service/TileLayerService.d.ts +33 -0
  329. package/lib/tile/service/TileLayerService.js +105 -177
  330. package/lib/tile/service/TilePickService.d.ts +26 -0
  331. package/lib/tile/service/TilePickService.js +100 -156
  332. package/lib/tile/service/TileSourceService.d.ts +7 -0
  333. package/lib/tile/service/TileSourceService.js +20 -29
  334. package/lib/tile/tile/DebugTile.d.ts +16 -0
  335. package/lib/tile/tile/DebugTile.js +43 -78
  336. package/lib/tile/tile/ImageTile.d.ts +14 -0
  337. package/lib/tile/tile/ImageTile.js +35 -66
  338. package/lib/tile/tile/MaskTile.d.ts +18 -0
  339. package/lib/tile/tile/MaskTile.js +49 -81
  340. package/lib/tile/tile/RasterRGBTile.d.ts +11 -0
  341. package/lib/tile/tile/RasterRGBTile.js +42 -71
  342. package/lib/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
  343. package/lib/tile/tile/RasterTerrainRGBTile.js +35 -66
  344. package/lib/tile/tile/RasterTile.d.ts +18 -0
  345. package/lib/tile/tile/RasterTile.js +71 -104
  346. package/lib/tile/tile/Tile.d.ts +114 -0
  347. package/lib/tile/tile/Tile.js +152 -231
  348. package/lib/tile/tile/VectorTile.d.ts +26 -0
  349. package/lib/tile/tile/VectorTile.js +79 -124
  350. package/lib/tile/tile/index.d.ts +12 -0
  351. package/lib/tile/tile/index.js +6 -4
  352. package/lib/tile/tile/util.d.ts +5 -0
  353. package/lib/tile/utils/constants.d.ts +1 -0
  354. package/lib/tile/utils/constants.js +1 -1
  355. package/lib/tile/utils/utils.d.ts +8 -0
  356. package/lib/tile/utils/utils.js +2 -2
  357. package/lib/utils/blend.d.ts +2 -0
  358. package/lib/utils/blend.js +52 -47
  359. package/lib/utils/collision-index.d.ts +47 -0
  360. package/lib/utils/collision-index.js +64 -69
  361. package/lib/utils/extrude_polyline.d.ts +68 -0
  362. package/lib/utils/extrude_polyline.js +442 -470
  363. package/lib/utils/grid-index.d.ts +28 -0
  364. package/lib/utils/grid-index.js +97 -123
  365. package/lib/utils/identityScale.d.ts +8 -0
  366. package/lib/utils/identityScale.js +5 -5
  367. package/lib/utils/load-image.d.ts +1 -0
  368. package/lib/utils/load-image.js +15 -39
  369. package/lib/utils/multiPassRender.d.ts +16 -0
  370. package/lib/utils/multiPassRender.js +7 -10
  371. package/lib/utils/polylineNormal.d.ts +9 -0
  372. package/lib/utils/polylineNormal.js +40 -43
  373. package/lib/utils/rampcolor_legend.d.ts +6 -0
  374. package/lib/utils/rampcolor_legend.js +5 -4
  375. package/lib/utils/simpleLine.d.ts +23 -0
  376. package/lib/utils/simpleLine.js +54 -65
  377. package/lib/utils/stencil.d.ts +7 -0
  378. package/lib/utils/symbol-layout.d.ts +43 -0
  379. package/lib/utils/symbol-layout.js +95 -117
  380. package/lib/wind/index.d.ts +11 -0
  381. package/lib/wind/index.js +30 -70
  382. package/lib/wind/models/index.d.ts +5 -0
  383. package/lib/wind/models/index.js +1 -1
  384. package/lib/wind/models/utils.d.ts +19 -0
  385. package/lib/wind/models/utils.js +36 -34
  386. package/lib/wind/models/wind.d.ts +24 -0
  387. package/lib/wind/models/wind.js +205 -260
  388. package/lib/wind/models/windRender.d.ts +104 -0
  389. package/lib/wind/models/windRender.js +261 -272
  390. package/lib/wind/models/windShader.d.ts +12 -0
  391. package/lib/wind/models/windShader.js +145 -6
  392. package/package.json +16 -19
  393. package/es/glsl.d.ts +0 -5
  394. package/lib/glsl.d.ts +0 -5
@@ -1,5 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
1
  import { calculateCentroid, calculatePointsCenterAndRadius, lngLatToMeters, aProjectFlat } from '@antv/l7-utils';
4
2
  import earcut from 'earcut';
5
3
  // @ts-ignore
@@ -8,7 +6,7 @@ import { EARTH_RADIUS, EARTH_RADIUS_OUTER, EARTH_SEGMENTS, lglt2xyz, primitiveSp
8
6
  import ExtrudePolyline from "../utils/extrude_polyline";
9
7
  import extrudePolygon, { extrude_PolygonNormal, fillPolygon } from "./shape/extrude";
10
8
  import { geometryShape } from "./shape/Path";
11
- var GeometryCache = {};
9
+ const GeometryCache = {};
12
10
 
13
11
  /**
14
12
  * 计算2D 填充点图顶点
@@ -16,9 +14,9 @@ var GeometryCache = {};
16
14
  */
17
15
 
18
16
  export function PointFillTriangulation(feature) {
19
- var coordinates = calculateCentroid(feature.coordinates);
17
+ const coordinates = calculateCentroid(feature.coordinates);
20
18
  return {
21
- vertices: [].concat(_toConsumableArray(coordinates), _toConsumableArray(coordinates), _toConsumableArray(coordinates), _toConsumableArray(coordinates)),
19
+ vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates],
22
20
  indices: [0, 1, 2, 2, 3, 0],
23
21
  size: coordinates.length
24
22
  };
@@ -28,10 +26,10 @@ export function PointFillTriangulation(feature) {
28
26
  * @param feature 映射feature
29
27
  */
30
28
  export function GlobelPointFillTriangulation(feature) {
31
- var coordinates = calculateCentroid(feature.coordinates);
32
- var xyz = lglt2xyz(coordinates);
29
+ const coordinates = calculateCentroid(feature.coordinates);
30
+ const xyz = lglt2xyz(coordinates);
33
31
  return {
34
- vertices: [].concat(_toConsumableArray(xyz), _toConsumableArray(xyz), _toConsumableArray(xyz), _toConsumableArray(xyz)),
32
+ vertices: [...xyz, ...xyz, ...xyz, ...xyz],
35
33
  indices: [0, 1, 2, 2, 3, 0],
36
34
  size: xyz.length
37
35
  };
@@ -42,15 +40,18 @@ export function GlobelPointFillTriangulation(feature) {
42
40
  * @param feature 映射feature
43
41
  */
44
42
  export function PointExtrudeTriangulation(feature) {
45
- var shape = feature.shape;
46
- var _getGeometry = getGeometry(shape, false),
47
- positions = _getGeometry.positions,
48
- index = _getGeometry.index,
49
- normals = _getGeometry.normals;
43
+ const {
44
+ shape
45
+ } = feature;
46
+ const {
47
+ positions,
48
+ index,
49
+ normals
50
+ } = getGeometry(shape, false);
50
51
  return {
51
52
  vertices: positions,
52
53
  indices: index,
53
- normals: normals,
54
+ normals,
54
55
  size: 5
55
56
  };
56
57
  }
@@ -60,9 +61,9 @@ export function PointExtrudeTriangulation(feature) {
60
61
  * @param feature 映射feature
61
62
  */
62
63
  export function PointImageTriangulation(feature) {
63
- var coordinates = calculateCentroid(feature.coordinates);
64
+ const coordinates = calculateCentroid(feature.coordinates);
64
65
  return {
65
- vertices: _toConsumableArray(coordinates),
66
+ vertices: [...coordinates],
66
67
  indices: [0],
67
68
  size: coordinates.length
68
69
  };
@@ -73,45 +74,47 @@ export function PointImageTriangulation(feature) {
73
74
  * @param feature 映射feature
74
75
  */
75
76
  export function LineTriangulation(feature) {
76
- var coordinates = feature.coordinates,
77
- originCoordinates = feature.originCoordinates,
78
- version = feature.version;
77
+ const {
78
+ coordinates,
79
+ originCoordinates,
80
+ version
81
+ } = feature;
79
82
  // let path = coordinates as number[][][] | number[][];
80
83
  // if (!Array.isArray(path[0][0])) {
81
84
  // path = [coordinates] as number[][][];
82
85
  // }
83
86
 
84
- var line = new ExtrudePolyline({
87
+ const line = new ExtrudePolyline({
85
88
  dash: true,
86
89
  join: 'bevel'
87
90
  });
88
91
  if (version === 'GAODE2.x') {
89
92
  // 处理高德2.0几何体构建
90
- var path1 = coordinates; // 计算位置
93
+ let path1 = coordinates; // 计算位置
91
94
  if (!Array.isArray(path1[0][0])) {
92
95
  path1 = [coordinates];
93
96
  }
94
- var path2 = originCoordinates; // 计算法线
97
+ let path2 = originCoordinates; // 计算法线
95
98
  if (!Array.isArray(path2[0][0])) {
96
99
  path2 = [originCoordinates];
97
100
  }
98
- for (var i = 0; i < path1.length; i++) {
101
+ for (let i = 0; i < path1.length; i++) {
99
102
  // 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
100
- var item1 = path1[i];
101
- var item2 = path2[i];
103
+ const item1 = path1[i];
104
+ const item2 = path2[i];
102
105
  line.extrude_gaode2(item1, item2);
103
106
  }
104
107
  } else {
105
108
  // 处理非高德2.0的几何体构建
106
- var path = coordinates;
109
+ let path = coordinates;
107
110
  if (path[0] && !Array.isArray(path[0][0])) {
108
111
  path = [coordinates];
109
112
  }
110
- path.forEach(function (item) {
113
+ path.forEach(item => {
111
114
  line.extrude(item);
112
115
  });
113
116
  }
114
- var linebuffer = line.complex;
117
+ const linebuffer = line.complex;
115
118
  return {
116
119
  vertices: linebuffer.positions,
117
120
  // [ x,y,z, distance, miter,total ]
@@ -123,29 +126,38 @@ export function LineTriangulation(feature) {
123
126
  }
124
127
  export function FlowLineFillTriangulation(feature) {
125
128
  // @ts-ignore
126
- var coord = feature.coordinates.flat();
127
- var tin = 1;
128
- var tout = 1.0;
129
+ const coord = feature.coordinates.flat();
130
+ const tin = 1;
131
+ const tout = 1.0;
129
132
  return {
130
- vertices: [1, 0, 0].concat(_toConsumableArray(coord), [
133
+ vertices: [1, 0, 0, ...coord,
131
134
  // 0
132
- 1, 2, -3], _toConsumableArray(coord), [
135
+ 1, 2, -3,
136
+ // mapbox 为正
137
+ ...coord,
133
138
  // 1
134
- 1, 1, -3], _toConsumableArray(coord), [
139
+ 1, 1, -3,
140
+ // mapbox 为正
141
+ ...coord,
135
142
  // 2
136
- 0, 1, 0], _toConsumableArray(coord), [
143
+ 0, 1, 0, ...coord,
137
144
  // 3
138
- 0, 0, 0], _toConsumableArray(coord), [
145
+ 0, 0, 0, ...coord,
139
146
  // 4
140
- 1, 0, 0], _toConsumableArray(coord), [
147
+ 1, 0, 0, ...coord,
141
148
  // 0
142
- 1, 2, -3], _toConsumableArray(coord), [
149
+ 1, 2, -3,
150
+ // mapbox 为正
151
+ ...coord,
143
152
  // 1
144
- 1, 1, -3], _toConsumableArray(coord), [
153
+ 1, 1, -3,
154
+ // // mapbox 为正
155
+ ...coord,
145
156
  // 2
146
- 0, 1, 0], _toConsumableArray(coord), [
157
+ 0, 1, 0, ...coord,
147
158
  // 3
148
- 0, 0, 0], _toConsumableArray(coord)),
159
+ 0, 0, 0, ...coord // 4
160
+ ],
149
161
  normals: [-tin, 2 * tout, 1,
150
162
  // 0
151
163
  2 * tout, -tout, 1,
@@ -162,9 +174,11 @@ export function FlowLineFillTriangulation(feature) {
162
174
  };
163
175
  }
164
176
  export function SimpleLineTriangulation(feature) {
165
- var coordinates = feature.coordinates,
166
- originCoordinates = feature.originCoordinates;
167
- var pos = [];
177
+ const {
178
+ coordinates,
179
+ originCoordinates
180
+ } = feature;
181
+ const pos = [];
168
182
  if (!Array.isArray(coordinates[0])) {
169
183
  return {
170
184
  vertices: [],
@@ -174,10 +188,11 @@ export function SimpleLineTriangulation(feature) {
174
188
  count: 0
175
189
  };
176
190
  }
177
- var _getSimpleLineVertice = getSimpleLineVertices(coordinates, originCoordinates),
178
- results = _getSimpleLineVertice.results,
179
- totalDistance = _getSimpleLineVertice.totalDistance;
180
- results.map(function (point) {
191
+ const {
192
+ results,
193
+ totalDistance
194
+ } = getSimpleLineVertices(coordinates, originCoordinates);
195
+ results.map(point => {
181
196
  pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
182
197
  });
183
198
  return {
@@ -189,8 +204,10 @@ export function SimpleLineTriangulation(feature) {
189
204
  };
190
205
  }
191
206
  export function TileSimpleLineTriangulation(feature) {
192
- var coordinates = feature.coordinates;
193
- var pos = [];
207
+ const {
208
+ coordinates
209
+ } = feature;
210
+ const pos = [];
194
211
  if (!Array.isArray(coordinates[0])) {
195
212
  return {
196
213
  vertices: [],
@@ -199,9 +216,10 @@ export function TileSimpleLineTriangulation(feature) {
199
216
  count: 0
200
217
  };
201
218
  }
202
- var _getTileSimpleLineVer = getTileSimpleLineVertices(coordinates),
203
- results = _getTileSimpleLineVer.results;
204
- results.map(function (point) {
219
+ const {
220
+ results
221
+ } = getTileSimpleLineVertices(coordinates);
222
+ results.map(point => {
205
223
  pos.push(point[0], point[1], point[2], point[3]);
206
224
  });
207
225
  return {
@@ -212,8 +230,8 @@ export function TileSimpleLineTriangulation(feature) {
212
230
  };
213
231
  }
214
232
  function lineSegmentDistance(b1, a1) {
215
- var dx = a1[0] - b1[0];
216
- var dy = a1[1] - b1[1];
233
+ const dx = a1[0] - b1[0];
234
+ const dy = a1[1] - b1[1];
217
235
  return Math.sqrt(dx * dx + dy * dy);
218
236
  }
219
237
  function pushDis(point, n) {
@@ -226,9 +244,9 @@ function pushDis(point, n) {
226
244
  return point;
227
245
  }
228
246
  function getSimpleLineVertices(coordinates, originCoordinates) {
229
- var points = coordinates;
247
+ let points = coordinates;
230
248
  //除了amap2.0以外 coordinates就是经纬度数据
231
- var originPoints = originCoordinates || coordinates;
249
+ let originPoints = originCoordinates || coordinates;
232
250
  if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
233
251
  // @ts-ignore
234
252
  points = originCoordinates.flat();
@@ -236,28 +254,28 @@ function getSimpleLineVertices(coordinates, originCoordinates) {
236
254
  originPoints = originCoordinates.flat();
237
255
  }
238
256
  //修改计算距离的方式,与普通线的计算方式保持一致 edit by huyang 20231214
239
- var distance = 0;
257
+ let distance = 0;
240
258
  if (points.length < 2) {
241
259
  return {
242
260
  results: points,
243
261
  totalDistance: 0
244
262
  };
245
263
  } else {
246
- var results = [];
247
- var point = pushDis(points[0], distance);
264
+ const results = [];
265
+ const point = pushDis(points[0], distance);
248
266
  results.push(point);
249
- for (var i = 1; i < points.length - 1; i++) {
250
- var subDistance = lineSegmentDistance(aProjectFlat(originPoints[i - 1]), aProjectFlat(originPoints[i]));
267
+ for (let i = 1; i < points.length - 1; i++) {
268
+ const subDistance = lineSegmentDistance(aProjectFlat(originPoints[i - 1]), aProjectFlat(originPoints[i]));
251
269
  distance += subDistance;
252
- var mulPoint = pushDis(points[i], distance);
270
+ const mulPoint = pushDis(points[i], distance);
253
271
  results.push(mulPoint);
254
272
  results.push(mulPoint);
255
273
  }
256
- var pointDistance = lineSegmentDistance(aProjectFlat(originPoints[originPoints.length - 2]), aProjectFlat(originPoints[originPoints.length - 1]));
274
+ const pointDistance = lineSegmentDistance(aProjectFlat(originPoints[originPoints.length - 2]), aProjectFlat(originPoints[originPoints.length - 1]));
257
275
  distance += pointDistance;
258
276
  results.push(pushDis(points[points.length - 1], distance));
259
277
  return {
260
- results: results,
278
+ results,
261
279
  totalDistance: distance
262
280
  };
263
281
  }
@@ -268,40 +286,48 @@ function getTileSimpleLineVertices(points) {
268
286
  results: points
269
287
  };
270
288
  } else {
271
- var results = [];
272
- var point = pushDis(points[0]);
289
+ const results = [];
290
+ const point = pushDis(points[0]);
273
291
  results.push(point);
274
- for (var i = 1; i < points.length - 1; i++) {
275
- var mulPoint = pushDis(points[i]);
292
+ for (let i = 1; i < points.length - 1; i++) {
293
+ const mulPoint = pushDis(points[i]);
276
294
  results.push(mulPoint);
277
295
  results.push(mulPoint);
278
296
  }
279
297
  results.push(pushDis(points[points.length - 1]));
280
298
  return {
281
- results: results
299
+ results
282
300
  };
283
301
  }
284
302
  }
285
303
  export function polygonTriangulation(feature) {
286
- var coordinates = feature.coordinates;
287
- var flattengeo = earcut.flatten(coordinates);
288
- var vertices = flattengeo.vertices,
289
- dimensions = flattengeo.dimensions,
290
- holes = flattengeo.holes;
304
+ const {
305
+ coordinates
306
+ } = feature;
307
+ const flattengeo = earcut.flatten(coordinates);
308
+ const {
309
+ vertices,
310
+ dimensions,
311
+ holes
312
+ } = flattengeo;
291
313
  return {
292
314
  indices: earcut(vertices, holes, dimensions),
293
- vertices: vertices,
315
+ vertices,
294
316
  size: dimensions
295
317
  };
296
318
  }
297
319
 
298
320
  // 构建几何图形(带有中心点和大小)
299
321
  export function polygonTriangulationWithCenter(feature) {
300
- var coordinates = feature.coordinates;
301
- var flattengeo = earcut.flatten(coordinates);
302
- var vertices = flattengeo.vertices,
303
- dimensions = flattengeo.dimensions,
304
- holes = flattengeo.holes;
322
+ const {
323
+ coordinates
324
+ } = feature;
325
+ const flattengeo = earcut.flatten(coordinates);
326
+ const {
327
+ vertices,
328
+ dimensions,
329
+ holes
330
+ } = flattengeo;
305
331
  return {
306
332
  indices: earcut(vertices, holes, dimensions),
307
333
  vertices: getVerticesWithCenter(vertices),
@@ -309,36 +335,41 @@ export function polygonTriangulationWithCenter(feature) {
309
335
  };
310
336
  }
311
337
  function getVerticesWithCenter(vertices) {
312
- var verticesWithCenter = [];
313
- var _calculatePointsCente = calculatePointsCenterAndRadius(vertices),
314
- center = _calculatePointsCente.center,
315
- radius = _calculatePointsCente.radius;
316
- for (var i = 0; i < vertices.length; i += 2) {
317
- var lng = vertices[i];
318
- var lat = vertices[i + 1];
319
- verticesWithCenter.push.apply(verticesWithCenter, [lng, lat, 0].concat(_toConsumableArray(center), [radius]));
338
+ const verticesWithCenter = [];
339
+ const {
340
+ center,
341
+ radius
342
+ } = calculatePointsCenterAndRadius(vertices);
343
+ for (let i = 0; i < vertices.length; i += 2) {
344
+ const lng = vertices[i];
345
+ const lat = vertices[i + 1];
346
+ verticesWithCenter.push(lng, lat, 0, ...center, radius);
320
347
  }
321
348
  return verticesWithCenter;
322
349
  }
323
350
  export function PolygonExtrudeTriangulation(feature) {
324
- var coordinates = feature.coordinates;
325
- var _extrude_PolygonNorma = extrude_PolygonNormal(coordinates, true),
326
- positions = _extrude_PolygonNorma.positions,
327
- index = _extrude_PolygonNorma.index,
328
- normals = _extrude_PolygonNorma.normals;
351
+ const coordinates = feature.coordinates;
352
+ const {
353
+ positions,
354
+ index,
355
+ normals
356
+ } = extrude_PolygonNormal(coordinates, true);
329
357
  return {
330
358
  vertices: positions,
331
359
  // [ x, y, z, uv.x,uv.y ]
332
360
  indices: index,
333
- normals: normals,
361
+ normals,
334
362
  size: 5
335
363
  };
336
364
  }
337
365
  export function HeatmapGridTriangulation(feature) {
338
- var shape = feature.shape;
339
- var _getHeatmapGeometry = getHeatmapGeometry(shape),
340
- positions = _getHeatmapGeometry.positions,
341
- index = _getHeatmapGeometry.index;
366
+ const {
367
+ shape
368
+ } = feature;
369
+ const {
370
+ positions,
371
+ index
372
+ } = getHeatmapGeometry(shape);
342
373
  return {
343
374
  vertices: positions,
344
375
  // [ x, y, z ] 多边形顶点
@@ -352,10 +383,10 @@ export function HeatmapGridTriangulation(feature) {
352
383
  * @param feature 数据
353
384
  */
354
385
  export function RasterImageTriangulation(feature) {
355
- var coordinates = feature.coordinates;
386
+ const coordinates = feature.coordinates;
356
387
  // [ x, y, z. uv.x, uv.y]
357
- var positions = [].concat(_toConsumableArray(coordinates[0]), [0, 0, 0], _toConsumableArray(coordinates[1]), [0, 1, 0], _toConsumableArray(coordinates[2]), [0, 1, 1], _toConsumableArray(coordinates[3]), [0, 0, 1]);
358
- var indexs = [0, 1, 2, 0, 2, 3];
388
+ const positions = [...coordinates[0], 0, 0, 0, ...coordinates[1], 0, 1, 0, ...coordinates[2], 0, 1, 1, ...coordinates[3], 0, 0, 1];
389
+ const indexs = [0, 1, 2, 0, 2, 3];
359
390
  return {
360
391
  vertices: positions,
361
392
  indices: indexs,
@@ -370,23 +401,21 @@ export function RasterImageTriangulation(feature) {
370
401
  */
371
402
  export function LineArcTriangulation(feature, styleOption) {
372
403
  // @ts-ignore
373
- var _styleOption$segmentN = styleOption.segmentNumber,
374
- segmentNumber = _styleOption$segmentN === void 0 ? 30 : _styleOption$segmentN;
375
- var coordinates = feature.coordinates;
376
- var positions = [];
377
- var indexArray = [];
378
- var _loop = function _loop(i) {
404
+ const {
405
+ segmentNumber = 30
406
+ } = styleOption;
407
+ const coordinates = feature.coordinates;
408
+ const positions = [];
409
+ const indexArray = [];
410
+ for (let i = 0; i < segmentNumber; i++) {
379
411
  // 上线两个顶点
380
412
  // [ x, y, z, sx,sy, tx,ty]
381
413
  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]);
382
414
  if (i !== segmentNumber - 1) {
383
- indexArray.push.apply(indexArray, _toConsumableArray([0, 1, 2, 1, 3, 2].map(function (v) {
415
+ indexArray.push(...[0, 1, 2, 1, 3, 2].map(v => {
384
416
  return i * 2 + v;
385
- })));
417
+ }));
386
418
  }
387
- };
388
- for (var i = 0; i < segmentNumber; i++) {
389
- _loop(i);
390
419
  }
391
420
  return {
392
421
  vertices: positions,
@@ -401,17 +430,17 @@ export function LineArcTriangulation(feature, styleOption) {
401
430
  * @returns
402
431
  */
403
432
  export function HeatmapTriangulation(feature) {
404
- var coordinates = feature.coordinates;
433
+ const coordinates = feature.coordinates;
405
434
  if (coordinates.length === 2) {
406
435
  coordinates.push(0);
407
436
  }
408
- var dir = addDir(-1, 1);
409
- var dir1 = addDir(1, 1);
410
- var dir2 = addDir(-1, -1);
411
- var dir3 = addDir(1, -1);
437
+ const dir = addDir(-1, 1);
438
+ const dir1 = addDir(1, 1);
439
+ const dir2 = addDir(-1, -1);
440
+ const dir3 = addDir(1, -1);
412
441
  // [x,y,z, dirx ,diry, weight]
413
- var positions = [].concat(_toConsumableArray(coordinates), _toConsumableArray(dir), _toConsumableArray(coordinates), _toConsumableArray(dir2), _toConsumableArray(coordinates), _toConsumableArray(dir3), _toConsumableArray(coordinates), _toConsumableArray(dir1));
414
- var indexArray = [0, 1, 2, 3, 0, 2];
442
+ const positions = [...coordinates, ...dir, ...coordinates, ...dir2, ...coordinates, ...dir3, ...coordinates, ...dir1];
443
+ const indexArray = [0, 1, 2, 3, 0, 2];
415
444
  return {
416
445
  vertices: positions,
417
446
  indices: indexArray,
@@ -423,53 +452,41 @@ export function HeatmapTriangulation(feature) {
423
452
  * 点图层3d geomerty
424
453
  * @param shape 3D形状
425
454
  */
426
- function getGeometry(shape) {
427
- var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
455
+ function getGeometry(shape, needFlat = false) {
428
456
  if (GeometryCache && GeometryCache[shape]) {
429
457
  return GeometryCache[shape];
430
458
  }
431
- var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.cylinder();
432
- var geometry = extrude_PolygonNormal([path], needFlat);
459
+ const path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.cylinder();
460
+ const geometry = extrude_PolygonNormal([path], needFlat);
433
461
  GeometryCache[shape] = geometry;
434
462
  return geometry;
435
463
  }
436
- export function computeVertexNormals(positions, indexArray) {
437
- var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
438
- var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
439
- var normals = new Float32Array(positions.length / dim * 3);
440
- var vA;
441
- var vB;
442
- var vC;
443
- var cb = vec3.create();
444
- var ab = vec3.create();
445
- var normal = vec3.create();
446
- for (var i = 0, li = indexArray.length; i < li; i += 3) {
464
+ export function computeVertexNormals(positions, indexArray, dim = 3, needFlat = false) {
465
+ const normals = new Float32Array(positions.length / dim * 3);
466
+ let vA;
467
+ let vB;
468
+ let vC;
469
+ const cb = vec3.create();
470
+ const ab = vec3.create();
471
+ const normal = vec3.create();
472
+ for (let i = 0, li = indexArray.length; i < li; i += 3) {
447
473
  vA = indexArray[i + 0] * 3;
448
474
  vB = indexArray[i + 1] * 3;
449
475
  vC = indexArray[i + 2] * 3;
450
- var p1 = [positions[vA], positions[vA + 1]];
451
- var p2 = [positions[vB], positions[vB + 1]];
452
- var p3 = [positions[vC], positions[vC + 1]];
476
+ let p1 = [positions[vA], positions[vA + 1]];
477
+ let p2 = [positions[vB], positions[vB + 1]];
478
+ let p3 = [positions[vC], positions[vC + 1]];
453
479
  if (needFlat) {
454
480
  p1 = lngLatToMeters(p1);
455
481
  p2 = lngLatToMeters(p2);
456
482
  p3 = lngLatToMeters(p3);
457
483
  }
458
- var _p = p1,
459
- _p2 = _slicedToArray(_p, 2),
460
- ax = _p2[0],
461
- ay = _p2[1];
462
- var pA = vec3.fromValues(ax, ay, positions[vA + 2]);
463
- var _p3 = p2,
464
- _p4 = _slicedToArray(_p3, 2),
465
- bx = _p4[0],
466
- by = _p4[1];
467
- var pB = vec3.fromValues(bx, by, positions[vB + 2]);
468
- var _p5 = p3,
469
- _p6 = _slicedToArray(_p5, 2),
470
- cx = _p6[0],
471
- cy = _p6[1];
472
- var pC = vec3.fromValues(cx, cy, positions[vC + 2]);
484
+ const [ax, ay] = p1;
485
+ const pA = vec3.fromValues(ax, ay, positions[vA + 2]);
486
+ const [bx, by] = p2;
487
+ const pB = vec3.fromValues(bx, by, positions[vB + 2]);
488
+ const [cx, cy] = p3;
489
+ const pC = vec3.fromValues(cx, cy, positions[vC + 2]);
473
490
  vec3.sub(cb, pC, pB);
474
491
  vec3.sub(ab, pA, pB);
475
492
  vec3.cross(normal, cb, ab);
@@ -487,29 +504,29 @@ export function computeVertexNormals(positions, indexArray) {
487
504
  return normals;
488
505
  }
489
506
  function normalizeNormals(normals) {
490
- for (var i = 0, li = normals.length; i < li; i += 3) {
491
- var normal = vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
492
- var newNormal = vec3.create();
507
+ for (let i = 0, li = normals.length; i < li; i += 3) {
508
+ const normal = vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
509
+ const newNormal = vec3.create();
493
510
  vec3.normalize(newNormal, normal);
494
511
  normals.set(newNormal, i);
495
512
  }
496
513
  }
497
514
  export function checkIsClosed(points) {
498
- var p1 = points[0][0];
499
- var p2 = points[0][points[0].length - 1];
515
+ const p1 = points[0][0];
516
+ const p2 = points[0][points[0].length - 1];
500
517
  return p1[0] === p2[0] && p1[1] === p2[1];
501
518
  }
502
519
  function getHeatmapGeometry(shape) {
503
- var shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
504
- var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.circle();
505
- var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]);
520
+ const shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
521
+ const path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.circle();
522
+ const geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]);
506
523
  // const geometry = fillPolygon([path]);
507
524
  return geometry;
508
525
  }
509
526
  // 热力图计算范围
510
527
  function addDir(dirX, dirY) {
511
- var x = (dirX + 1) / 2;
512
- var y = (dirY + 1) / 2;
528
+ const x = (dirX + 1) / 2;
529
+ const y = (dirY + 1) / 2;
513
530
  return [x, y];
514
531
  }
515
532
 
@@ -518,12 +535,14 @@ function addDir(dirX, dirY) {
518
535
  * @returns
519
536
  */
520
537
  export function earthTriangulation() {
521
- var earthmesh = primitiveSphere(EARTH_RADIUS, {
538
+ const earthmesh = primitiveSphere(EARTH_RADIUS, {
522
539
  segments: EARTH_SEGMENTS
523
540
  });
524
- var positionsArr = earthmesh.positionsArr,
525
- indicesArr = earthmesh.indicesArr,
526
- normalArr = earthmesh.normalArr;
541
+ const {
542
+ positionsArr,
543
+ indicesArr,
544
+ normalArr
545
+ } = earthmesh;
527
546
  return {
528
547
  vertices: positionsArr,
529
548
  indices: indicesArr,
@@ -532,12 +551,14 @@ export function earthTriangulation() {
532
551
  };
533
552
  }
534
553
  export function earthOuterTriangulation() {
535
- var earthmesh = primitiveSphere(EARTH_RADIUS + EARTH_RADIUS_OUTER, {
554
+ const earthmesh = primitiveSphere(EARTH_RADIUS + EARTH_RADIUS_OUTER, {
536
555
  segments: EARTH_SEGMENTS
537
556
  });
538
- var positionsArr = earthmesh.positionsArr,
539
- indicesArr = earthmesh.indicesArr,
540
- normalArr = earthmesh.normalArr;
557
+ const {
558
+ positionsArr,
559
+ indicesArr,
560
+ normalArr
561
+ } = earthmesh;
541
562
  return {
542
563
  vertices: positionsArr,
543
564
  indices: indicesArr,
package/es/core/utils.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export function formatUniformsOption2Std140(uniformsOption) {
2
- var std140_str = '';
3
- Object.keys(uniformsOption).forEach(function (key) {
4
- var value = uniformsOption[key];
2
+ let std140_str = '';
3
+ Object.keys(uniformsOption).forEach(key => {
4
+ const value = uniformsOption[key];
5
5
  if (Array.isArray(value)) {
6
- std140_str += "vec".concat(value.length, " ").concat(key, ";\n");
6
+ std140_str += `vec${value.length} ${key};\n`;
7
7
  } else {
8
- std140_str += "flot ".concat(key, ";\n");
8
+ std140_str += `flot ${key};\n`;
9
9
  }
10
10
  });
11
11
  return std140_str;