@antv/l7-layers 2.17.2 → 2.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/es/Geometry/index.js +31 -9
  2. package/es/Geometry/models/billboard.js +89 -51
  3. package/es/Geometry/models/plane.js +143 -81
  4. package/es/Geometry/models/sprite.js +118 -60
  5. package/es/canvas/index.js +33 -10
  6. package/es/canvas/models/canvas.js +97 -41
  7. package/es/citybuliding/building.js +27 -8
  8. package/es/citybuliding/models/build.js +82 -57
  9. package/es/core/BaseLayer.js +478 -313
  10. package/es/core/BaseModel.js +80 -51
  11. package/es/core/CommonStyleAttribute.js +5 -2
  12. package/es/core/LayerPickService.js +32 -21
  13. package/es/core/TextureService.js +13 -0
  14. package/es/core/interface.js +24 -17
  15. package/es/core/shape/Path.js +20 -13
  16. package/es/core/shape/extrude.js +39 -27
  17. package/es/core/triangulation.js +136 -99
  18. package/es/earth/index.js +33 -9
  19. package/es/earth/models/atmosphere.js +54 -30
  20. package/es/earth/models/base.js +85 -47
  21. package/es/earth/models/bloomsphere.js +54 -30
  22. package/es/earth/utils.js +13 -9
  23. package/es/heatmap/index.js +40 -10
  24. package/es/heatmap/models/grid.js +52 -28
  25. package/es/heatmap/models/grid3d.js +52 -28
  26. package/es/heatmap/models/heatmap.js +149 -92
  27. package/es/heatmap/models/hexagon.js +52 -28
  28. package/es/heatmap/triangulation.js +4 -0
  29. package/es/image/index.js +28 -9
  30. package/es/image/models/image.js +100 -66
  31. package/es/index.js +17 -9
  32. package/es/line/index.js +35 -9
  33. package/es/line/models/arc.js +114 -64
  34. package/es/line/models/arc_3d.js +102 -58
  35. package/es/line/models/earthArc_3d.js +105 -60
  36. package/es/line/models/flow.js +60 -36
  37. package/es/line/models/great_circle.js +94 -53
  38. package/es/line/models/line.js +138 -86
  39. package/es/line/models/linearline.js +76 -43
  40. package/es/line/models/simpleLine.js +69 -39
  41. package/es/line/models/wall.js +92 -52
  42. package/es/mask/index.js +28 -9
  43. package/es/mask/models/fill.js +54 -29
  44. package/es/plugins/DataMappingPlugin.js +114 -78
  45. package/es/plugins/DataSourcePlugin.js +68 -45
  46. package/es/plugins/FeatureScalePlugin.js +122 -67
  47. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  48. package/es/plugins/LayerMaskPlugin.js +11 -3
  49. package/es/plugins/LayerModelPlugin.js +108 -69
  50. package/es/plugins/LayerStylePlugin.js +9 -3
  51. package/es/plugins/LightingPlugin.js +18 -12
  52. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  53. package/es/plugins/PixelPickingPlugin.js +21 -12
  54. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  55. package/es/plugins/ShaderUniformPlugin.js +27 -13
  56. package/es/plugins/UpdateModelPlugin.js +5 -0
  57. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  58. package/es/point/index.js +78 -26
  59. package/es/point/models/earthExtrude.js +95 -58
  60. package/es/point/models/earthFill.js +80 -52
  61. package/es/point/models/extrude.js +94 -57
  62. package/es/point/models/fill.js +81 -56
  63. package/es/point/models/fillmage.js +100 -60
  64. package/es/point/models/image.js +83 -47
  65. package/es/point/models/index.js +2 -2
  66. package/es/point/models/normal.js +54 -30
  67. package/es/point/models/radar.js +63 -38
  68. package/es/point/models/simplePoint.js +62 -38
  69. package/es/point/models/text.js +296 -199
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +41 -11
  72. package/es/polygon/models/extrude.js +135 -87
  73. package/es/polygon/models/fill.js +79 -50
  74. package/es/polygon/models/index.js +2 -3
  75. package/es/polygon/models/ocean.js +76 -42
  76. package/es/polygon/models/water.js +71 -37
  77. package/es/raster/buffers/triangulation.js +4 -2
  78. package/es/raster/index.js +32 -9
  79. package/es/raster/models/raster.js +116 -80
  80. package/es/raster/models/rasterRgb.js +127 -84
  81. package/es/raster/models/rasterTerrainRgb.js +84 -56
  82. package/es/tile/interaction/getRasterData.js +20 -14
  83. package/es/tile/interaction/utils.js +9 -7
  84. package/es/tile/manager/base.js +96 -63
  85. package/es/tile/service/TileLayerService.js +55 -33
  86. package/es/tile/service/TilePickService.js +40 -26
  87. package/es/tile/service/TileSourceService.js +7 -3
  88. package/es/tile/tileFactory/DebugTile.js +46 -29
  89. package/es/tile/tileFactory/ImageTile.js +38 -20
  90. package/es/tile/tileFactory/MaskTile.js +43 -22
  91. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  93. package/es/tile/tileFactory/RasterTile.js +53 -30
  94. package/es/tile/tileFactory/Tile.js +97 -63
  95. package/es/tile/tileFactory/VectorTile.js +68 -41
  96. package/es/tile/tileFactory/index.js +11 -0
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  98. package/es/tile/tileFactory/util.js +3 -0
  99. package/es/tile/tileLayer/BaseLayer.js +146 -105
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +2 -0
  102. package/es/utils/collision-index.js +16 -9
  103. package/es/utils/extrude_polyline.js +149 -101
  104. package/es/utils/grid-index.js +27 -2
  105. package/es/utils/identityScale.js +8 -0
  106. package/es/utils/layerData.js +44 -30
  107. package/es/utils/multiPassRender.js +13 -11
  108. package/es/utils/polylineNormal.js +37 -31
  109. package/es/utils/simpleLine.js +16 -2
  110. package/es/utils/stencil.js +3 -2
  111. package/es/utils/symbol-layout.js +53 -27
  112. package/es/wind/index.js +29 -9
  113. package/es/wind/models/utils.js +51 -26
  114. package/es/wind/models/wind.js +147 -101
  115. package/es/wind/models/windRender.js +66 -53
  116. package/lib/Geometry/index.js +38 -9
  117. package/lib/Geometry/models/billboard.js +97 -51
  118. package/lib/Geometry/models/index.js +5 -0
  119. package/lib/Geometry/models/plane.js +151 -79
  120. package/lib/Geometry/models/sprite.js +127 -60
  121. package/lib/canvas/index.js +40 -10
  122. package/lib/canvas/models/canvas.js +101 -41
  123. package/lib/canvas/models/index.js +3 -0
  124. package/lib/citybuliding/building.js +35 -8
  125. package/lib/citybuliding/models/build.js +92 -57
  126. package/lib/core/BaseLayer.js +469 -313
  127. package/lib/core/BaseModel.js +90 -51
  128. package/lib/core/CommonStyleAttribute.js +7 -2
  129. package/lib/core/LayerPickService.js +37 -21
  130. package/lib/core/TextureService.js +16 -0
  131. package/lib/core/interface.js +31 -21
  132. package/lib/core/schema.js +1 -0
  133. package/lib/core/shape/Path.js +31 -14
  134. package/lib/core/shape/extrude.js +62 -27
  135. package/lib/core/triangulation.js +177 -98
  136. package/lib/earth/index.js +43 -9
  137. package/lib/earth/models/atmosphere.js +63 -30
  138. package/lib/earth/models/base.js +90 -47
  139. package/lib/earth/models/bloomsphere.js +63 -30
  140. package/lib/earth/utils.js +31 -7
  141. package/lib/heatmap/index.js +48 -10
  142. package/lib/heatmap/models/grid.js +60 -28
  143. package/lib/heatmap/models/grid3d.js +60 -28
  144. package/lib/heatmap/models/heatmap.js +166 -92
  145. package/lib/heatmap/models/hexagon.js +60 -28
  146. package/lib/heatmap/models/index.js +6 -0
  147. package/lib/heatmap/triangulation.js +5 -0
  148. package/lib/image/index.js +36 -9
  149. package/lib/image/models/image.js +109 -66
  150. package/lib/image/models/index.js +3 -0
  151. package/lib/index.js +61 -7
  152. package/lib/line/index.js +40 -9
  153. package/lib/line/models/arc.js +124 -62
  154. package/lib/line/models/arc_3d.js +113 -56
  155. package/lib/line/models/earthArc_3d.js +115 -58
  156. package/lib/line/models/flow.js +70 -36
  157. package/lib/line/models/great_circle.js +104 -53
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +146 -84
  160. package/lib/line/models/linearline.js +88 -43
  161. package/lib/line/models/simpleLine.js +79 -39
  162. package/lib/line/models/wall.js +103 -52
  163. package/lib/mask/index.js +36 -9
  164. package/lib/mask/models/fill.js +63 -29
  165. package/lib/mask/models/index.js +3 -0
  166. package/lib/plugins/DataMappingPlugin.js +125 -78
  167. package/lib/plugins/DataSourcePlugin.js +76 -45
  168. package/lib/plugins/FeatureScalePlugin.js +138 -67
  169. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  170. package/lib/plugins/LayerMaskPlugin.js +17 -4
  171. package/lib/plugins/LayerModelPlugin.js +117 -70
  172. package/lib/plugins/LayerStylePlugin.js +14 -4
  173. package/lib/plugins/LightingPlugin.js +25 -12
  174. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  175. package/lib/plugins/PixelPickingPlugin.js +27 -12
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  177. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  178. package/lib/plugins/UpdateModelPlugin.js +10 -1
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  180. package/lib/point/index.js +83 -26
  181. package/lib/point/models/earthExtrude.js +106 -58
  182. package/lib/point/models/earthFill.js +110 -52
  183. package/lib/point/models/extrude.js +103 -57
  184. package/lib/point/models/fill.js +90 -54
  185. package/lib/point/models/fillmage.js +107 -58
  186. package/lib/point/models/image.js +92 -47
  187. package/lib/point/models/index.js +12 -1
  188. package/lib/point/models/normal.js +64 -30
  189. package/lib/point/models/radar.js +72 -38
  190. package/lib/point/models/simplePoint.js +72 -38
  191. package/lib/point/models/text.js +305 -199
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +146 -87
  195. package/lib/polygon/models/fill.js +89 -50
  196. package/lib/polygon/models/index.js +14 -2
  197. package/lib/polygon/models/ocean.js +88 -42
  198. package/lib/polygon/models/water.js +82 -37
  199. package/lib/raster/buffers/triangulation.js +7 -3
  200. package/lib/raster/index.js +40 -9
  201. package/lib/raster/models/index.js +5 -0
  202. package/lib/raster/models/raster.js +125 -80
  203. package/lib/raster/models/rasterRgb.js +139 -84
  204. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  205. package/lib/tile/interaction/getRasterData.js +25 -14
  206. package/lib/tile/interaction/utils.js +19 -7
  207. package/lib/tile/manager/base.js +104 -63
  208. package/lib/tile/service/TileLayerService.js +60 -33
  209. package/lib/tile/service/TilePickService.js +48 -26
  210. package/lib/tile/service/TileSourceService.js +16 -2
  211. package/lib/tile/style/utils.js +3 -0
  212. package/lib/tile/tileFactory/DebugTile.js +54 -29
  213. package/lib/tile/tileFactory/ImageTile.js +46 -20
  214. package/lib/tile/tileFactory/MaskTile.js +51 -22
  215. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  217. package/lib/tile/tileFactory/RasterTile.js +63 -30
  218. package/lib/tile/tileFactory/Tile.js +102 -63
  219. package/lib/tile/tileFactory/VectorTile.js +76 -41
  220. package/lib/tile/tileFactory/index.js +25 -0
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  222. package/lib/tile/tileFactory/util.js +9 -0
  223. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  224. package/lib/tile/utils.js +5 -1
  225. package/lib/utils/blend.js +5 -0
  226. package/lib/utils/collision-index.js +25 -9
  227. package/lib/utils/extrude_polyline.js +181 -101
  228. package/lib/utils/grid-index.js +28 -2
  229. package/lib/utils/identityScale.js +9 -0
  230. package/lib/utils/layerData.js +49 -30
  231. package/lib/utils/multiPassRender.js +16 -11
  232. package/lib/utils/polylineNormal.js +66 -31
  233. package/lib/utils/simpleLine.js +21 -2
  234. package/lib/utils/stencil.js +4 -0
  235. package/lib/utils/symbol-layout.js +55 -27
  236. package/lib/wind/index.js +37 -9
  237. package/lib/wind/models/index.js +3 -0
  238. package/lib/wind/models/utils.js +62 -26
  239. package/lib/wind/models/wind.js +157 -101
  240. package/lib/wind/models/windRender.js +71 -53
  241. package/lib/wind/models/windShader.js +1 -0
  242. package/package.json +7 -7
@@ -1,62 +1,91 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
9
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
10
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
11
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
12
18
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
13
20
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
14
22
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
23
+
15
24
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
+
16
26
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
27
+
17
28
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
29
+
18
30
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
+
19
32
  var _l7Core = require("@antv/l7-core");
33
+
20
34
  var _l7Maps = require("@antv/l7-maps");
35
+
21
36
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
37
+
22
38
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
39
+
23
40
  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; } }
41
+
24
42
  /* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
25
43
  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";
44
+
26
45
  /* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
27
46
  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";
47
+
28
48
  var PlaneModel = /*#__PURE__*/function (_BaseModel) {
29
49
  (0, _inherits2.default)(PlaneModel, _BaseModel);
50
+
30
51
  var _super = _createSuper(PlaneModel);
52
+
31
53
  function PlaneModel() {
32
54
  var _this;
55
+
33
56
  (0, _classCallCheck2.default)(this, PlaneModel);
57
+
34
58
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
59
  args[_key] = arguments[_key];
36
60
  }
61
+
37
62
  _this = _super.call.apply(_super, [this].concat(args));
38
63
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "terrainImageLoaded", false);
39
64
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "planeGeometryTriangulation", function () {
40
65
  var _this2;
66
+
41
67
  var _ref = _this.layer.getLayerConfig(),
42
- _ref$width = _ref.width,
43
- width = _ref$width === void 0 ? 1 : _ref$width,
44
- _ref$height = _ref.height,
45
- height = _ref$height === void 0 ? 1 : _ref$height,
46
- _ref$widthSegments = _ref.widthSegments,
47
- widthSegments = _ref$widthSegments === void 0 ? 1 : _ref$widthSegments,
48
- _ref$heightSegments = _ref.heightSegments,
49
- heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
50
- _ref$center = _ref.center,
51
- center = _ref$center === void 0 ? [120, 30] : _ref$center,
52
- terrainTexture = _ref.terrainTexture;
68
+ _ref$width = _ref.width,
69
+ width = _ref$width === void 0 ? 1 : _ref$width,
70
+ _ref$height = _ref.height,
71
+ height = _ref$height === void 0 ? 1 : _ref$height,
72
+ _ref$widthSegments = _ref.widthSegments,
73
+ widthSegments = _ref$widthSegments === void 0 ? 1 : _ref$widthSegments,
74
+ _ref$heightSegments = _ref.heightSegments,
75
+ heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
76
+ _ref$center = _ref.center,
77
+ center = _ref$center === void 0 ? [120, 30] : _ref$center,
78
+ terrainTexture = _ref.terrainTexture;
79
+
53
80
  var _this$initPlane = (_this2 = _this).initPlane.apply(_this2, [width, height, widthSegments, heightSegments].concat((0, _toConsumableArray2.default)(center))),
54
- indices = _this$initPlane.indices,
55
- positions = _this$initPlane.positions;
81
+ indices = _this$initPlane.indices,
82
+ positions = _this$initPlane.positions;
83
+
56
84
  if (terrainTexture) {
57
85
  // 存在地形贴图的时候会根据地形贴图对顶点进行偏移
58
86
  _this.loadTerrainTexture(positions, indices);
59
87
  }
88
+
60
89
  return {
61
90
  vertices: positions,
62
91
  indices: indices,
@@ -65,6 +94,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
65
94
  });
66
95
  return _this;
67
96
  }
97
+
68
98
  (0, _createClass2.default)(PlaneModel, [{
69
99
  key: "initPlane",
70
100
  value: function initPlane() {
@@ -85,34 +115,43 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
85
115
  var segmentHeight = height / gridY;
86
116
  var indices = [];
87
117
  var positions = [];
118
+
88
119
  for (var iy = 0; iy < gridY1; iy++) {
89
120
  var y = iy * segmentHeight - heightHalf;
121
+
90
122
  for (var ix = 0; ix < gridX1; ix++) {
91
123
  var x = ix * segmentWidth - widthHalf;
124
+
92
125
  if (this.mapService.version === _l7Maps.Version['GAODE2.x']) {
93
126
  // @ts-ignore
94
127
  var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
95
- _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
96
- a = _ref3[0],
97
- _b = _ref3[1];
128
+ _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
129
+ a = _ref3[0],
130
+ _b = _ref3[1];
131
+
98
132
  positions.push(a, _b, 0);
99
133
  } else {
100
134
  positions.push(x + lng, -y + lat, 0);
101
135
  }
136
+
102
137
  positions.push(ix / gridX);
103
138
  positions.push(1 - iy / gridY);
104
139
  }
105
140
  }
141
+
106
142
  for (var _iy = 0; _iy < gridY; _iy++) {
107
143
  for (var _ix = 0; _ix < gridX; _ix++) {
108
144
  var _a = _ix + gridX1 * _iy;
145
+
109
146
  var _b2 = _ix + gridX1 * (_iy + 1);
147
+
110
148
  var c = _ix + 1 + gridX1 * (_iy + 1);
111
149
  var d = _ix + 1 + gridX1 * _iy;
112
150
  indices.push(_a, _b2, d);
113
151
  indices.push(_b2, c, d);
114
152
  }
115
153
  }
154
+
116
155
  return {
117
156
  indices: indices,
118
157
  positions: positions
@@ -122,17 +161,20 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
122
161
  key: "getUninforms",
123
162
  value: function getUninforms() {
124
163
  var _ref4 = this.layer.getLayerConfig(),
125
- opacity = _ref4.opacity,
126
- mapTexture = _ref4.mapTexture,
127
- _ref4$terrainClipHeig = _ref4.terrainClipHeight,
128
- terrainClipHeight = _ref4$terrainClipHeig === void 0 ? 0 : _ref4$terrainClipHeig,
129
- terrainTexture = _ref4.terrainTexture;
164
+ opacity = _ref4.opacity,
165
+ mapTexture = _ref4.mapTexture,
166
+ _ref4$terrainClipHeig = _ref4.terrainClipHeight,
167
+ terrainClipHeight = _ref4$terrainClipHeig === void 0 ? 0 : _ref4$terrainClipHeig,
168
+ terrainTexture = _ref4.terrainTexture;
169
+
130
170
  if (this.mapTexture !== mapTexture) {
131
171
  var _this$texture;
172
+
132
173
  this.mapTexture = mapTexture;
133
174
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
134
175
  this.updateTexture(mapTexture);
135
176
  }
177
+
136
178
  return {
137
179
  u_opacity: opacity || 1,
138
180
  u_mapFlag: mapTexture ? 1 : 0,
@@ -144,6 +186,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
144
186
  key: "clearModels",
145
187
  value: function clearModels() {
146
188
  var _this$texture2;
189
+
147
190
  // @ts-ignore
148
191
  this.terrainImage = null;
149
192
  (_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
@@ -153,44 +196,52 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
153
196
  value: function () {
154
197
  var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
155
198
  var _ref5, mapTexture, createTexture2D, model;
199
+
156
200
  return _regenerator.default.wrap(function _callee$(_context) {
157
- while (1) switch (_context.prev = _context.next) {
158
- case 0:
159
- _ref5 = this.layer.getLayerConfig(), mapTexture = _ref5.mapTexture;
160
- this.mapTexture = mapTexture;
161
- createTexture2D = this.rendererService.createTexture2D;
162
- this.texture = createTexture2D({
163
- height: 0,
164
- width: 0
165
- });
166
- this.updateTexture(mapTexture);
167
- _context.next = 7;
168
- return this.layer.buildLayerModel({
169
- moduleName: 'geometryPlane',
170
- vertexShader: planeVert,
171
- fragmentShader: planeFrag,
172
- triangulation: this.planeGeometryTriangulation,
173
- primitive: _l7Core.gl.TRIANGLES,
174
- depth: {
175
- enable: true
176
- },
177
- cull: {
178
- enable: true,
179
- face: _l7Core.gl.BACK // gl.FRONT | gl.BACK;
180
- }
181
- });
182
- case 7:
183
- model = _context.sent;
184
- return _context.abrupt("return", [model]);
185
- case 9:
186
- case "end":
187
- return _context.stop();
201
+ while (1) {
202
+ switch (_context.prev = _context.next) {
203
+ case 0:
204
+ _ref5 = this.layer.getLayerConfig(), mapTexture = _ref5.mapTexture;
205
+ this.mapTexture = mapTexture;
206
+ createTexture2D = this.rendererService.createTexture2D;
207
+ this.texture = createTexture2D({
208
+ height: 0,
209
+ width: 0
210
+ });
211
+ this.updateTexture(mapTexture);
212
+ _context.next = 7;
213
+ return this.layer.buildLayerModel({
214
+ moduleName: 'geometryPlane',
215
+ vertexShader: planeVert,
216
+ fragmentShader: planeFrag,
217
+ triangulation: this.planeGeometryTriangulation,
218
+ primitive: _l7Core.gl.TRIANGLES,
219
+ depth: {
220
+ enable: true
221
+ },
222
+ cull: {
223
+ enable: true,
224
+ face: _l7Core.gl.BACK // gl.FRONT | gl.BACK;
225
+
226
+ }
227
+ });
228
+
229
+ case 7:
230
+ model = _context.sent;
231
+ return _context.abrupt("return", [model]);
232
+
233
+ case 9:
234
+ case "end":
235
+ return _context.stop();
236
+ }
188
237
  }
189
238
  }, _callee, this);
190
239
  }));
240
+
191
241
  function initModels() {
192
242
  return _initModels.apply(this, arguments);
193
243
  }
244
+
194
245
  return initModels;
195
246
  }()
196
247
  }, {
@@ -198,18 +249,23 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
198
249
  value: function () {
199
250
  var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
200
251
  return _regenerator.default.wrap(function _callee2$(_context2) {
201
- while (1) switch (_context2.prev = _context2.next) {
202
- case 0:
203
- return _context2.abrupt("return", this.initModels());
204
- case 1:
205
- case "end":
206
- return _context2.stop();
252
+ while (1) {
253
+ switch (_context2.prev = _context2.next) {
254
+ case 0:
255
+ return _context2.abrupt("return", this.initModels());
256
+
257
+ case 1:
258
+ case "end":
259
+ return _context2.stop();
260
+ }
207
261
  }
208
262
  }, _callee2, this);
209
263
  }));
264
+
210
265
  function buildModels() {
211
266
  return _buildModels.apply(this, arguments);
212
267
  }
268
+
213
269
  return buildModels;
214
270
  }()
215
271
  }, {
@@ -217,15 +273,16 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
217
273
  value: function createModelData(options) {
218
274
  if (options) {
219
275
  var _ref6 = this.layer.getLayerConfig(),
220
- oldwidthSegments = _ref6.widthSegments,
221
- oldheightSegments = _ref6.heightSegments,
222
- oldwidth = _ref6.width,
223
- oldheight = _ref6.height;
276
+ oldwidthSegments = _ref6.widthSegments,
277
+ oldheightSegments = _ref6.heightSegments,
278
+ oldwidth = _ref6.width,
279
+ oldheight = _ref6.height;
280
+
224
281
  var _ref7 = options,
225
- widthSegments = _ref7.widthSegments,
226
- heightSegments = _ref7.heightSegments,
227
- width = _ref7.width,
228
- height = _ref7.height;
282
+ widthSegments = _ref7.widthSegments,
283
+ heightSegments = _ref7.heightSegments,
284
+ width = _ref7.width,
285
+ height = _ref7.height;
229
286
  this.layer.style({
230
287
  widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
231
288
  heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
@@ -233,6 +290,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
233
290
  height: height !== undefined ? height : oldheight
234
291
  });
235
292
  }
293
+
236
294
  var oldFeatures = this.layer.getEncodedData();
237
295
  var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
238
296
  return res;
@@ -241,10 +299,13 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
241
299
  key: "updateTexture",
242
300
  value: function updateTexture(mapTexture) {
243
301
  var _this3 = this;
302
+
244
303
  var createTexture2D = this.rendererService.createTexture2D;
304
+
245
305
  if (mapTexture) {
246
306
  var img = new Image();
247
307
  img.crossOrigin = 'anonymous';
308
+
248
309
  img.onload = function () {
249
310
  _this3.texture = createTexture2D({
250
311
  data: img,
@@ -253,8 +314,10 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
253
314
  wrapS: _l7Core.gl.CLAMP_TO_EDGE,
254
315
  wrapT: _l7Core.gl.CLAMP_TO_EDGE
255
316
  });
317
+
256
318
  _this3.layerService.reRender();
257
319
  };
320
+
258
321
  img.src = mapTexture;
259
322
  } else {
260
323
  this.texture = createTexture2D({
@@ -269,7 +332,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
269
332
  var canvas = document.createElement('canvas');
270
333
  var ctx = canvas.getContext('2d');
271
334
  var width = img.width,
272
- height = img.height;
335
+ height = img.height;
273
336
  canvas.width = width;
274
337
  canvas.height = height;
275
338
  ctx.drawImage(img, 0, 0, width, height);
@@ -288,9 +351,11 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
288
351
  var gridY1 = gridY + 1;
289
352
  var widthStep = imgWidth / gridX;
290
353
  var heightStep = imgHeight / gridY;
354
+
291
355
  for (var iy = 0; iy < gridY1; iy++) {
292
356
  var imgIndexY = Math.floor(iy * heightStep);
293
357
  var imgLen = imgIndexY * imgWidth;
358
+
294
359
  for (var ix = 0; ix < gridX1; ix++) {
295
360
  var imgIndexX = Math.floor(ix * widthStep);
296
361
  var imgDataIndex = (imgLen + imgIndexX) * 4;
@@ -301,6 +366,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
301
366
  positions[z] = rgb2height(_r, _g, _b3);
302
367
  }
303
368
  }
369
+
304
370
  var oldFeatures = this.layer.getEncodedData();
305
371
  var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
306
372
  return {
@@ -312,24 +378,26 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
312
378
  this.layer.updateModelData(modelData);
313
379
  this.layerService.throttleRenderLayers();
314
380
  }
315
-
316
381
  /**
317
382
  * load terrain texture & offset attribute z
318
383
  */
384
+
319
385
  }, {
320
386
  key: "loadTerrainTexture",
321
387
  value: function loadTerrainTexture(positions, indices) {
322
388
  var _this4 = this;
389
+
323
390
  var _ref8 = this.layer.getLayerConfig(),
324
- _ref8$widthSegments = _ref8.widthSegments,
325
- widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
326
- _ref8$heightSegments = _ref8.heightSegments,
327
- heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
328
- terrainTexture = _ref8.terrainTexture,
329
- _ref8$rgb2height = _ref8.rgb2height,
330
- rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
331
- return r + g + b;
332
- } : _ref8$rgb2height;
391
+ _ref8$widthSegments = _ref8.widthSegments,
392
+ widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
393
+ _ref8$heightSegments = _ref8.heightSegments,
394
+ heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
395
+ terrainTexture = _ref8.terrainTexture,
396
+ _ref8$rgb2height = _ref8.rgb2height,
397
+ rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
398
+ return r + g + b;
399
+ } : _ref8$rgb2height;
400
+
333
401
  if (this.terrainImage) {
334
402
  // 若当前已经存在 image,直接进行偏移计算(LOD)
335
403
  if (this.terrainImageLoaded) {
@@ -344,14 +412,17 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
344
412
  var terrainImage = new Image();
345
413
  this.terrainImage = terrainImage;
346
414
  terrainImage.crossOrigin = 'anonymous';
415
+
347
416
  terrainImage.onload = function () {
348
- _this4.terrainImageLoaded = true;
349
- // 图片加载完,触发事件,可以进行地形图的顶点计算存储
417
+ _this4.terrainImageLoaded = true; // 图片加载完,触发事件,可以进行地形图的顶点计算存储
418
+
350
419
  setTimeout(function () {
351
420
  return _this4.layer.emit('terrainImageLoaded', null);
352
421
  });
422
+
353
423
  _this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
354
424
  };
425
+
355
426
  terrainImage.src = terrainTexture;
356
427
  }
357
428
  }
@@ -380,4 +451,5 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
380
451
  }]);
381
452
  return PlaneModel;
382
453
  }(_BaseModel2.default);
454
+
383
455
  exports.default = PlaneModel;