@antv/l7-layers 2.17.4 → 2.17.6

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 (250) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.js +325 -483
  10. package/es/core/BaseModel.js +51 -80
  11. package/es/core/CommonStyleAttribute.js +2 -5
  12. package/es/core/LayerPickService.js +21 -32
  13. package/es/core/TextureService.js +0 -13
  14. package/es/core/interface.js +17 -24
  15. package/es/core/shape/Path.js +13 -20
  16. package/es/core/shape/extrude.js +27 -39
  17. package/es/core/triangulation.js +99 -136
  18. package/es/earth/index.js +9 -33
  19. package/es/earth/models/atmosphere.js +30 -54
  20. package/es/earth/models/base.js +47 -85
  21. package/es/earth/models/bloomsphere.js +30 -54
  22. package/es/earth/utils.js +9 -13
  23. package/es/heatmap/index.js +10 -40
  24. package/es/heatmap/models/grid.js +28 -52
  25. package/es/heatmap/models/grid3d.js +28 -52
  26. package/es/heatmap/models/heatmap.js +92 -149
  27. package/es/heatmap/models/hexagon.js +28 -52
  28. package/es/heatmap/triangulation.js +0 -4
  29. package/es/image/index.js +9 -28
  30. package/es/image/models/image.js +66 -100
  31. package/es/index.js +9 -17
  32. package/es/line/index.js +9 -35
  33. package/es/line/models/arc.js +63 -112
  34. package/es/line/models/arc_3d.js +58 -102
  35. package/es/line/models/earthArc_3d.js +60 -105
  36. package/es/line/models/flow.js +36 -60
  37. package/es/line/models/great_circle.js +53 -94
  38. package/es/line/models/line.js +92 -144
  39. package/es/line/models/linearline.js +42 -74
  40. package/es/line/models/simpleLine.js +38 -67
  41. package/es/line/models/wall.js +52 -92
  42. package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
  43. package/es/line/shaders/line_frag.glsl +1 -3
  44. package/es/line/shaders/line_vert.glsl +2 -0
  45. package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
  46. package/es/mask/index.js +9 -28
  47. package/es/mask/models/fill.js +29 -54
  48. package/es/plugins/DataMappingPlugin.js +78 -114
  49. package/es/plugins/DataSourcePlugin.js +45 -68
  50. package/es/plugins/FeatureScalePlugin.js +67 -122
  51. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  52. package/es/plugins/LayerMaskPlugin.js +3 -11
  53. package/es/plugins/LayerModelPlugin.js +69 -118
  54. package/es/plugins/LayerStylePlugin.js +4 -9
  55. package/es/plugins/LightingPlugin.js +12 -18
  56. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  57. package/es/plugins/PixelPickingPlugin.js +12 -21
  58. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  59. package/es/plugins/ShaderUniformPlugin.js +13 -27
  60. package/es/plugins/UpdateModelPlugin.js +0 -5
  61. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  62. package/es/point/index.js +26 -78
  63. package/es/point/models/earthExtrude.js +58 -95
  64. package/es/point/models/earthFill.js +52 -80
  65. package/es/point/models/extrude.js +57 -94
  66. package/es/point/models/fill.js +56 -81
  67. package/es/point/models/fillmage.js +60 -100
  68. package/es/point/models/image.js +47 -83
  69. package/es/point/models/index.js +2 -2
  70. package/es/point/models/normal.js +30 -54
  71. package/es/point/models/radar.js +38 -63
  72. package/es/point/models/simplePoint.js +38 -62
  73. package/es/point/models/text.js +199 -296
  74. package/es/point/shape/extrude.js +4 -13
  75. package/es/polygon/index.js +11 -41
  76. package/es/polygon/models/extrude.js +87 -135
  77. package/es/polygon/models/fill.js +50 -79
  78. package/es/polygon/models/index.js +3 -2
  79. package/es/polygon/models/ocean.js +42 -76
  80. package/es/polygon/models/water.js +37 -71
  81. package/es/raster/buffers/triangulation.js +2 -4
  82. package/es/raster/index.js +9 -32
  83. package/es/raster/models/raster.js +80 -116
  84. package/es/raster/models/rasterRgb.js +84 -127
  85. package/es/raster/models/rasterTerrainRgb.js +56 -84
  86. package/es/tile/interaction/getRasterData.js +14 -20
  87. package/es/tile/interaction/utils.js +7 -9
  88. package/es/tile/manager/base.js +63 -96
  89. package/es/tile/service/TileLayerService.js +33 -55
  90. package/es/tile/service/TilePickService.js +26 -40
  91. package/es/tile/service/TileSourceService.js +3 -7
  92. package/es/tile/tileFactory/DebugTile.js +29 -46
  93. package/es/tile/tileFactory/ImageTile.js +20 -38
  94. package/es/tile/tileFactory/MaskTile.js +22 -43
  95. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  96. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  97. package/es/tile/tileFactory/RasterTile.js +30 -53
  98. package/es/tile/tileFactory/Tile.js +63 -97
  99. package/es/tile/tileFactory/VectorTile.js +41 -68
  100. package/es/tile/tileFactory/index.js +0 -11
  101. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  102. package/es/tile/tileFactory/util.js +0 -3
  103. package/es/tile/tileLayer/BaseLayer.js +105 -146
  104. package/es/tile/utils.js +1 -1
  105. package/es/utils/blend.js +0 -2
  106. package/es/utils/collision-index.js +9 -16
  107. package/es/utils/extrude_polyline.js +101 -149
  108. package/es/utils/grid-index.js +2 -27
  109. package/es/utils/identityScale.js +0 -8
  110. package/es/utils/layerData.js +30 -44
  111. package/es/utils/multiPassRender.js +11 -13
  112. package/es/utils/polylineNormal.js +31 -37
  113. package/es/utils/simpleLine.js +2 -16
  114. package/es/utils/stencil.js +2 -3
  115. package/es/utils/symbol-layout.js +27 -53
  116. package/es/wind/index.js +9 -29
  117. package/es/wind/models/utils.js +26 -51
  118. package/es/wind/models/wind.js +101 -147
  119. package/es/wind/models/windRender.js +53 -66
  120. package/lib/Geometry/index.js +9 -38
  121. package/lib/Geometry/models/billboard.js +51 -97
  122. package/lib/Geometry/models/index.js +0 -5
  123. package/lib/Geometry/models/plane.js +79 -151
  124. package/lib/Geometry/models/sprite.js +60 -127
  125. package/lib/canvas/index.js +10 -40
  126. package/lib/canvas/models/canvas.js +41 -101
  127. package/lib/canvas/models/index.js +0 -3
  128. package/lib/citybuliding/building.js +8 -35
  129. package/lib/citybuliding/models/build.js +57 -92
  130. package/lib/core/BaseLayer.js +325 -474
  131. package/lib/core/BaseModel.js +51 -90
  132. package/lib/core/CommonStyleAttribute.js +2 -7
  133. package/lib/core/LayerPickService.js +21 -37
  134. package/lib/core/TextureService.js +0 -16
  135. package/lib/core/interface.js +21 -31
  136. package/lib/core/schema.js +0 -1
  137. package/lib/core/shape/Path.js +14 -31
  138. package/lib/core/shape/extrude.js +27 -62
  139. package/lib/core/triangulation.js +98 -177
  140. package/lib/earth/index.js +9 -43
  141. package/lib/earth/models/atmosphere.js +30 -63
  142. package/lib/earth/models/base.js +47 -90
  143. package/lib/earth/models/bloomsphere.js +30 -63
  144. package/lib/earth/utils.js +7 -31
  145. package/lib/heatmap/index.js +10 -48
  146. package/lib/heatmap/models/grid.js +28 -60
  147. package/lib/heatmap/models/grid3d.js +28 -60
  148. package/lib/heatmap/models/heatmap.js +92 -166
  149. package/lib/heatmap/models/hexagon.js +28 -60
  150. package/lib/heatmap/models/index.js +0 -6
  151. package/lib/heatmap/triangulation.js +0 -5
  152. package/lib/image/index.js +9 -36
  153. package/lib/image/models/image.js +66 -109
  154. package/lib/image/models/index.js +0 -3
  155. package/lib/index.js +7 -61
  156. package/lib/line/index.js +9 -40
  157. package/lib/line/models/arc.js +61 -122
  158. package/lib/line/models/arc_3d.js +56 -113
  159. package/lib/line/models/earthArc_3d.js +58 -115
  160. package/lib/line/models/flow.js +36 -70
  161. package/lib/line/models/great_circle.js +53 -104
  162. package/lib/line/models/index.js +0 -11
  163. package/lib/line/models/line.js +90 -152
  164. package/lib/line/models/linearline.js +42 -86
  165. package/lib/line/models/simpleLine.js +38 -77
  166. package/lib/line/models/wall.js +52 -103
  167. package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
  168. package/lib/line/shaders/line_frag.glsl +1 -3
  169. package/lib/line/shaders/line_vert.glsl +2 -0
  170. package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
  171. package/lib/mask/index.js +9 -36
  172. package/lib/mask/models/fill.js +29 -63
  173. package/lib/mask/models/index.js +0 -3
  174. package/lib/plugins/DataMappingPlugin.js +78 -125
  175. package/lib/plugins/DataSourcePlugin.js +45 -76
  176. package/lib/plugins/FeatureScalePlugin.js +67 -138
  177. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  178. package/lib/plugins/LayerMaskPlugin.js +4 -17
  179. package/lib/plugins/LayerModelPlugin.js +70 -127
  180. package/lib/plugins/LayerStylePlugin.js +5 -14
  181. package/lib/plugins/LightingPlugin.js +12 -25
  182. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  183. package/lib/plugins/PixelPickingPlugin.js +12 -27
  184. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  185. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  186. package/lib/plugins/UpdateModelPlugin.js +1 -10
  187. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  188. package/lib/point/index.js +26 -83
  189. package/lib/point/models/earthExtrude.js +58 -106
  190. package/lib/point/models/earthFill.js +52 -110
  191. package/lib/point/models/extrude.js +57 -103
  192. package/lib/point/models/fill.js +54 -90
  193. package/lib/point/models/fillmage.js +58 -107
  194. package/lib/point/models/image.js +47 -92
  195. package/lib/point/models/index.js +1 -12
  196. package/lib/point/models/normal.js +30 -64
  197. package/lib/point/models/radar.js +38 -72
  198. package/lib/point/models/simplePoint.js +38 -72
  199. package/lib/point/models/text.js +199 -305
  200. package/lib/point/shape/extrude.js +4 -20
  201. package/lib/polygon/index.js +11 -48
  202. package/lib/polygon/models/extrude.js +87 -146
  203. package/lib/polygon/models/fill.js +50 -89
  204. package/lib/polygon/models/index.js +2 -14
  205. package/lib/polygon/models/ocean.js +42 -88
  206. package/lib/polygon/models/water.js +37 -82
  207. package/lib/raster/buffers/triangulation.js +3 -7
  208. package/lib/raster/index.js +9 -40
  209. package/lib/raster/models/index.js +0 -5
  210. package/lib/raster/models/raster.js +80 -125
  211. package/lib/raster/models/rasterRgb.js +84 -139
  212. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  213. package/lib/tile/interaction/getRasterData.js +14 -25
  214. package/lib/tile/interaction/utils.js +7 -19
  215. package/lib/tile/manager/base.js +63 -104
  216. package/lib/tile/service/TileLayerService.js +33 -60
  217. package/lib/tile/service/TilePickService.js +26 -48
  218. package/lib/tile/service/TileSourceService.js +2 -16
  219. package/lib/tile/style/utils.js +0 -3
  220. package/lib/tile/tileFactory/DebugTile.js +29 -54
  221. package/lib/tile/tileFactory/ImageTile.js +20 -46
  222. package/lib/tile/tileFactory/MaskTile.js +22 -51
  223. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  224. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  225. package/lib/tile/tileFactory/RasterTile.js +30 -63
  226. package/lib/tile/tileFactory/Tile.js +63 -102
  227. package/lib/tile/tileFactory/VectorTile.js +41 -76
  228. package/lib/tile/tileFactory/index.js +0 -25
  229. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  230. package/lib/tile/tileFactory/util.js +0 -9
  231. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  232. package/lib/tile/utils.js +1 -5
  233. package/lib/utils/blend.js +0 -5
  234. package/lib/utils/collision-index.js +9 -25
  235. package/lib/utils/extrude_polyline.js +101 -181
  236. package/lib/utils/grid-index.js +2 -28
  237. package/lib/utils/identityScale.js +0 -9
  238. package/lib/utils/layerData.js +30 -49
  239. package/lib/utils/multiPassRender.js +11 -16
  240. package/lib/utils/polylineNormal.js +31 -66
  241. package/lib/utils/simpleLine.js +2 -21
  242. package/lib/utils/stencil.js +0 -4
  243. package/lib/utils/symbol-layout.js +27 -55
  244. package/lib/wind/index.js +9 -37
  245. package/lib/wind/models/index.js +0 -3
  246. package/lib/wind/models/utils.js +26 -62
  247. package/lib/wind/models/wind.js +101 -157
  248. package/lib/wind/models/windRender.js +53 -71
  249. package/lib/wind/models/windShader.js +0 -1
  250. package/package.json +7 -7
@@ -9,75 +9,56 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
9
9
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
10
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
11
  import _regeneratorRuntime from "@babel/runtime/regenerator";
12
-
13
12
  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); }; }
14
-
15
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; } }
16
-
17
14
  import { AttributeType, gl } from '@antv/l7-core';
18
- import { Version } from '@antv/l7-maps'; // import { mat4, vec3 } from 'gl-matrix';
19
-
15
+ import { Version } from '@antv/l7-maps';
16
+ // import { mat4, vec3 } from 'gl-matrix';
20
17
  import BaseModel from "../../core/BaseModel";
21
-
22
18
  /* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
23
19
  var planeFrag = "\nuniform sampler2D u_texture;\nuniform float u_mapFlag;\nuniform float u_opacity;\n\nvarying vec3 v_Color;\nvarying vec2 v_uv;\nvarying float v_clip;\n\n#pragma include \"picking\"\nvoid main() {\n // gl_FragColor = vec4(v_Color, u_opacity);\n if(u_mapFlag > 0.0) {\n gl_FragColor = texture2D(u_texture, vec2(v_uv.x, 1.0 - v_uv.y));\n gl_FragColor.a *= u_opacity;\n } else {\n // gl_FragColor = vec4(v_uv, 0.0, u_opacity);\n gl_FragColor = vec4(v_Color, u_opacity);\n }\n gl_FragColor.a *= v_clip;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
24
-
25
20
  /* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
26
21
  var planeVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\n\nuniform mat4 u_Mvp;\nuniform float u_opacity;\nuniform float u_terrainClipHeight;\n\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nattribute vec3 a_Color;\n\nvarying vec3 v_Color;\nvarying vec2 v_uv;\nvarying float v_clip;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvoid main() {\n v_Color = a_Color;\n v_uv = a_Uv;\n \n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n v_clip = 1.0;\n if(a_Position.z < u_terrainClipHeight) {\n v_clip = 0.0;\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n\n // float x = 1.0;\n // float y = 0.0;\n // float z = 0.0;\n // mat3 translateMatrix = mat3(\n // 1.0, 0.0, 0.0 \n // 0.0, 1.0, 0.0\n // -project_pos.x, -project_pos.y, 1.0\n // );\n // mat4 translateMatrix = mat4(\n // 1.0, 0.0, 0.0, 0.0 ,\n // 0.0, 1.0, 0.0, 0.0,\n // 0.0, 0.0, 1.0, 0.0,\n // 1.0, 0.0, 0.0, 1.0\n // );\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, a_Position.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
27
-
28
22
  var PlaneModel = /*#__PURE__*/function (_BaseModel) {
29
23
  _inherits(PlaneModel, _BaseModel);
30
-
31
24
  var _super = _createSuper(PlaneModel);
32
-
33
25
  function PlaneModel() {
34
26
  var _this;
35
-
36
27
  _classCallCheck(this, PlaneModel);
37
-
38
28
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
39
29
  args[_key] = arguments[_key];
40
30
  }
41
-
42
31
  _this = _super.call.apply(_super, [this].concat(args));
43
-
44
32
  _defineProperty(_assertThisInitialized(_this), "terrainImageLoaded", false);
45
-
46
33
  _defineProperty(_assertThisInitialized(_this), "planeGeometryTriangulation", function () {
47
34
  var _this2;
48
-
49
35
  var _ref = _this.layer.getLayerConfig(),
50
- _ref$width = _ref.width,
51
- width = _ref$width === void 0 ? 1 : _ref$width,
52
- _ref$height = _ref.height,
53
- height = _ref$height === void 0 ? 1 : _ref$height,
54
- _ref$widthSegments = _ref.widthSegments,
55
- widthSegments = _ref$widthSegments === void 0 ? 1 : _ref$widthSegments,
56
- _ref$heightSegments = _ref.heightSegments,
57
- heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
58
- _ref$center = _ref.center,
59
- center = _ref$center === void 0 ? [120, 30] : _ref$center,
60
- terrainTexture = _ref.terrainTexture;
61
-
36
+ _ref$width = _ref.width,
37
+ width = _ref$width === void 0 ? 1 : _ref$width,
38
+ _ref$height = _ref.height,
39
+ height = _ref$height === void 0 ? 1 : _ref$height,
40
+ _ref$widthSegments = _ref.widthSegments,
41
+ widthSegments = _ref$widthSegments === void 0 ? 1 : _ref$widthSegments,
42
+ _ref$heightSegments = _ref.heightSegments,
43
+ heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
44
+ _ref$center = _ref.center,
45
+ center = _ref$center === void 0 ? [120, 30] : _ref$center,
46
+ terrainTexture = _ref.terrainTexture;
62
47
  var _this$initPlane = (_this2 = _this).initPlane.apply(_this2, [width, height, widthSegments, heightSegments].concat(_toConsumableArray(center))),
63
- indices = _this$initPlane.indices,
64
- positions = _this$initPlane.positions;
65
-
48
+ indices = _this$initPlane.indices,
49
+ positions = _this$initPlane.positions;
66
50
  if (terrainTexture) {
67
51
  // 存在地形贴图的时候会根据地形贴图对顶点进行偏移
68
52
  _this.loadTerrainTexture(positions, indices);
69
53
  }
70
-
71
54
  return {
72
55
  vertices: positions,
73
56
  indices: indices,
74
57
  size: 5
75
58
  };
76
59
  });
77
-
78
60
  return _this;
79
61
  }
80
-
81
62
  _createClass(PlaneModel, [{
82
63
  key: "initPlane",
83
64
  value: function initPlane() {
@@ -98,43 +79,34 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
98
79
  var segmentHeight = height / gridY;
99
80
  var indices = [];
100
81
  var positions = [];
101
-
102
82
  for (var iy = 0; iy < gridY1; iy++) {
103
83
  var y = iy * segmentHeight - heightHalf;
104
-
105
84
  for (var ix = 0; ix < gridX1; ix++) {
106
85
  var x = ix * segmentWidth - widthHalf;
107
-
108
86
  if (this.mapService.version === Version['GAODE2.x']) {
109
87
  // @ts-ignore
110
88
  var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
111
- _ref3 = _slicedToArray(_ref2, 2),
112
- a = _ref3[0],
113
- _b = _ref3[1];
114
-
89
+ _ref3 = _slicedToArray(_ref2, 2),
90
+ a = _ref3[0],
91
+ _b = _ref3[1];
115
92
  positions.push(a, _b, 0);
116
93
  } else {
117
94
  positions.push(x + lng, -y + lat, 0);
118
95
  }
119
-
120
96
  positions.push(ix / gridX);
121
97
  positions.push(1 - iy / gridY);
122
98
  }
123
99
  }
124
-
125
100
  for (var _iy = 0; _iy < gridY; _iy++) {
126
101
  for (var _ix = 0; _ix < gridX; _ix++) {
127
102
  var _a = _ix + gridX1 * _iy;
128
-
129
103
  var _b2 = _ix + gridX1 * (_iy + 1);
130
-
131
104
  var c = _ix + 1 + gridX1 * (_iy + 1);
132
105
  var d = _ix + 1 + gridX1 * _iy;
133
106
  indices.push(_a, _b2, d);
134
107
  indices.push(_b2, c, d);
135
108
  }
136
109
  }
137
-
138
110
  return {
139
111
  indices: indices,
140
112
  positions: positions
@@ -144,20 +116,17 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
144
116
  key: "getUninforms",
145
117
  value: function getUninforms() {
146
118
  var _ref4 = this.layer.getLayerConfig(),
147
- opacity = _ref4.opacity,
148
- mapTexture = _ref4.mapTexture,
149
- _ref4$terrainClipHeig = _ref4.terrainClipHeight,
150
- terrainClipHeight = _ref4$terrainClipHeig === void 0 ? 0 : _ref4$terrainClipHeig,
151
- terrainTexture = _ref4.terrainTexture;
152
-
119
+ opacity = _ref4.opacity,
120
+ mapTexture = _ref4.mapTexture,
121
+ _ref4$terrainClipHeig = _ref4.terrainClipHeight,
122
+ terrainClipHeight = _ref4$terrainClipHeig === void 0 ? 0 : _ref4$terrainClipHeig,
123
+ terrainTexture = _ref4.terrainTexture;
153
124
  if (this.mapTexture !== mapTexture) {
154
125
  var _this$texture;
155
-
156
126
  this.mapTexture = mapTexture;
157
127
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
158
128
  this.updateTexture(mapTexture);
159
129
  }
160
-
161
130
  return {
162
131
  u_opacity: opacity || 1,
163
132
  u_mapFlag: mapTexture ? 1 : 0,
@@ -169,7 +138,6 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
169
138
  key: "clearModels",
170
139
  value: function clearModels() {
171
140
  var _this$texture2;
172
-
173
141
  // @ts-ignore
174
142
  this.terrainImage = null;
175
143
  (_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
@@ -179,52 +147,44 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
179
147
  value: function () {
180
148
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
181
149
  var _ref5, mapTexture, createTexture2D, model;
182
-
183
150
  return _regeneratorRuntime.wrap(function _callee$(_context) {
184
- while (1) {
185
- switch (_context.prev = _context.next) {
186
- case 0:
187
- _ref5 = this.layer.getLayerConfig(), mapTexture = _ref5.mapTexture;
188
- this.mapTexture = mapTexture;
189
- createTexture2D = this.rendererService.createTexture2D;
190
- this.texture = createTexture2D({
191
- height: 0,
192
- width: 0
193
- });
194
- this.updateTexture(mapTexture);
195
- _context.next = 7;
196
- return this.layer.buildLayerModel({
197
- moduleName: 'geometryPlane',
198
- vertexShader: planeVert,
199
- fragmentShader: planeFrag,
200
- triangulation: this.planeGeometryTriangulation,
201
- primitive: gl.TRIANGLES,
202
- depth: {
203
- enable: true
204
- },
205
- cull: {
206
- enable: true,
207
- face: gl.BACK // gl.FRONT | gl.BACK;
208
-
209
- }
210
- });
211
-
212
- case 7:
213
- model = _context.sent;
214
- return _context.abrupt("return", [model]);
215
-
216
- case 9:
217
- case "end":
218
- return _context.stop();
219
- }
151
+ while (1) switch (_context.prev = _context.next) {
152
+ case 0:
153
+ _ref5 = this.layer.getLayerConfig(), mapTexture = _ref5.mapTexture;
154
+ this.mapTexture = mapTexture;
155
+ createTexture2D = this.rendererService.createTexture2D;
156
+ this.texture = createTexture2D({
157
+ height: 0,
158
+ width: 0
159
+ });
160
+ this.updateTexture(mapTexture);
161
+ _context.next = 7;
162
+ return this.layer.buildLayerModel({
163
+ moduleName: 'geometryPlane',
164
+ vertexShader: planeVert,
165
+ fragmentShader: planeFrag,
166
+ triangulation: this.planeGeometryTriangulation,
167
+ primitive: gl.TRIANGLES,
168
+ depth: {
169
+ enable: true
170
+ },
171
+ cull: {
172
+ enable: true,
173
+ face: gl.BACK // gl.FRONT | gl.BACK;
174
+ }
175
+ });
176
+ case 7:
177
+ model = _context.sent;
178
+ return _context.abrupt("return", [model]);
179
+ case 9:
180
+ case "end":
181
+ return _context.stop();
220
182
  }
221
183
  }, _callee, this);
222
184
  }));
223
-
224
185
  function initModels() {
225
186
  return _initModels.apply(this, arguments);
226
187
  }
227
-
228
188
  return initModels;
229
189
  }()
230
190
  }, {
@@ -232,23 +192,18 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
232
192
  value: function () {
233
193
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
234
194
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
235
- while (1) {
236
- switch (_context2.prev = _context2.next) {
237
- case 0:
238
- return _context2.abrupt("return", this.initModels());
239
-
240
- case 1:
241
- case "end":
242
- return _context2.stop();
243
- }
195
+ while (1) switch (_context2.prev = _context2.next) {
196
+ case 0:
197
+ return _context2.abrupt("return", this.initModels());
198
+ case 1:
199
+ case "end":
200
+ return _context2.stop();
244
201
  }
245
202
  }, _callee2, this);
246
203
  }));
247
-
248
204
  function buildModels() {
249
205
  return _buildModels.apply(this, arguments);
250
206
  }
251
-
252
207
  return buildModels;
253
208
  }()
254
209
  }, {
@@ -256,16 +211,15 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
256
211
  value: function createModelData(options) {
257
212
  if (options) {
258
213
  var _ref6 = this.layer.getLayerConfig(),
259
- oldwidthSegments = _ref6.widthSegments,
260
- oldheightSegments = _ref6.heightSegments,
261
- oldwidth = _ref6.width,
262
- oldheight = _ref6.height;
263
-
214
+ oldwidthSegments = _ref6.widthSegments,
215
+ oldheightSegments = _ref6.heightSegments,
216
+ oldwidth = _ref6.width,
217
+ oldheight = _ref6.height;
264
218
  var _ref7 = options,
265
- widthSegments = _ref7.widthSegments,
266
- heightSegments = _ref7.heightSegments,
267
- width = _ref7.width,
268
- height = _ref7.height;
219
+ widthSegments = _ref7.widthSegments,
220
+ heightSegments = _ref7.heightSegments,
221
+ width = _ref7.width,
222
+ height = _ref7.height;
269
223
  this.layer.style({
270
224
  widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
271
225
  heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
@@ -273,7 +227,6 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
273
227
  height: height !== undefined ? height : oldheight
274
228
  });
275
229
  }
276
-
277
230
  var oldFeatures = this.layer.getEncodedData();
278
231
  var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
279
232
  return res;
@@ -282,13 +235,10 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
282
235
  key: "updateTexture",
283
236
  value: function updateTexture(mapTexture) {
284
237
  var _this3 = this;
285
-
286
238
  var createTexture2D = this.rendererService.createTexture2D;
287
-
288
239
  if (mapTexture) {
289
240
  var img = new Image();
290
241
  img.crossOrigin = 'anonymous';
291
-
292
242
  img.onload = function () {
293
243
  _this3.texture = createTexture2D({
294
244
  data: img,
@@ -297,10 +247,8 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
297
247
  wrapS: gl.CLAMP_TO_EDGE,
298
248
  wrapT: gl.CLAMP_TO_EDGE
299
249
  });
300
-
301
250
  _this3.layerService.reRender();
302
251
  };
303
-
304
252
  img.src = mapTexture;
305
253
  } else {
306
254
  this.texture = createTexture2D({
@@ -315,7 +263,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
315
263
  var canvas = document.createElement('canvas');
316
264
  var ctx = canvas.getContext('2d');
317
265
  var width = img.width,
318
- height = img.height;
266
+ height = img.height;
319
267
  canvas.width = width;
320
268
  canvas.height = height;
321
269
  ctx.drawImage(img, 0, 0, width, height);
@@ -334,11 +282,9 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
334
282
  var gridY1 = gridY + 1;
335
283
  var widthStep = imgWidth / gridX;
336
284
  var heightStep = imgHeight / gridY;
337
-
338
285
  for (var iy = 0; iy < gridY1; iy++) {
339
286
  var imgIndexY = Math.floor(iy * heightStep);
340
287
  var imgLen = imgIndexY * imgWidth;
341
-
342
288
  for (var ix = 0; ix < gridX1; ix++) {
343
289
  var imgIndexX = Math.floor(ix * widthStep);
344
290
  var imgDataIndex = (imgLen + imgIndexX) * 4;
@@ -349,7 +295,6 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
349
295
  positions[z] = rgb2height(_r, _g, _b3);
350
296
  }
351
297
  }
352
-
353
298
  var oldFeatures = this.layer.getEncodedData();
354
299
  var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
355
300
  return {
@@ -361,26 +306,24 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
361
306
  this.layer.updateModelData(modelData);
362
307
  this.layerService.throttleRenderLayers();
363
308
  }
309
+
364
310
  /**
365
311
  * load terrain texture & offset attribute z
366
312
  */
367
-
368
313
  }, {
369
314
  key: "loadTerrainTexture",
370
315
  value: function loadTerrainTexture(positions, indices) {
371
316
  var _this4 = this;
372
-
373
317
  var _ref8 = this.layer.getLayerConfig(),
374
- _ref8$widthSegments = _ref8.widthSegments,
375
- widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
376
- _ref8$heightSegments = _ref8.heightSegments,
377
- heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
378
- terrainTexture = _ref8.terrainTexture,
379
- _ref8$rgb2height = _ref8.rgb2height,
380
- rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
381
- return r + g + b;
382
- } : _ref8$rgb2height;
383
-
318
+ _ref8$widthSegments = _ref8.widthSegments,
319
+ widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
320
+ _ref8$heightSegments = _ref8.heightSegments,
321
+ heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
322
+ terrainTexture = _ref8.terrainTexture,
323
+ _ref8$rgb2height = _ref8.rgb2height,
324
+ rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
325
+ return r + g + b;
326
+ } : _ref8$rgb2height;
384
327
  if (this.terrainImage) {
385
328
  // 若当前已经存在 image,直接进行偏移计算(LOD)
386
329
  if (this.terrainImageLoaded) {
@@ -395,17 +338,14 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
395
338
  var terrainImage = new Image();
396
339
  this.terrainImage = terrainImage;
397
340
  terrainImage.crossOrigin = 'anonymous';
398
-
399
341
  terrainImage.onload = function () {
400
- _this4.terrainImageLoaded = true; // 图片加载完,触发事件,可以进行地形图的顶点计算存储
401
-
342
+ _this4.terrainImageLoaded = true;
343
+ // 图片加载完,触发事件,可以进行地形图的顶点计算存储
402
344
  setTimeout(function () {
403
345
  return _this4.layer.emit('terrainImageLoaded', null);
404
346
  });
405
-
406
347
  _this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
407
348
  };
408
-
409
349
  terrainImage.src = terrainTexture;
410
350
  }
411
351
  }
@@ -432,8 +372,6 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
432
372
  });
433
373
  }
434
374
  }]);
435
-
436
375
  return PlaneModel;
437
376
  }(BaseModel);
438
-
439
377
  export { PlaneModel as default };