@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
@@ -9,56 +9,75 @@ 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
+
12
13
  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
+
13
15
  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
+
14
17
  import { AttributeType, gl } from '@antv/l7-core';
15
- import { Version } from '@antv/l7-maps';
16
- // import { mat4, vec3 } from 'gl-matrix';
18
+ import { Version } from '@antv/l7-maps'; // import { mat4, vec3 } from 'gl-matrix';
19
+
17
20
  import BaseModel from "../../core/BaseModel";
21
+
18
22
  /* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
19
23
  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
+
20
25
  /* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
21
26
  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
+
22
28
  var PlaneModel = /*#__PURE__*/function (_BaseModel) {
23
29
  _inherits(PlaneModel, _BaseModel);
30
+
24
31
  var _super = _createSuper(PlaneModel);
32
+
25
33
  function PlaneModel() {
26
34
  var _this;
35
+
27
36
  _classCallCheck(this, PlaneModel);
37
+
28
38
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
39
  args[_key] = arguments[_key];
30
40
  }
41
+
31
42
  _this = _super.call.apply(_super, [this].concat(args));
43
+
32
44
  _defineProperty(_assertThisInitialized(_this), "terrainImageLoaded", false);
45
+
33
46
  _defineProperty(_assertThisInitialized(_this), "planeGeometryTriangulation", function () {
34
47
  var _this2;
48
+
35
49
  var _ref = _this.layer.getLayerConfig(),
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;
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
+
47
62
  var _this$initPlane = (_this2 = _this).initPlane.apply(_this2, [width, height, widthSegments, heightSegments].concat(_toConsumableArray(center))),
48
- indices = _this$initPlane.indices,
49
- positions = _this$initPlane.positions;
63
+ indices = _this$initPlane.indices,
64
+ positions = _this$initPlane.positions;
65
+
50
66
  if (terrainTexture) {
51
67
  // 存在地形贴图的时候会根据地形贴图对顶点进行偏移
52
68
  _this.loadTerrainTexture(positions, indices);
53
69
  }
70
+
54
71
  return {
55
72
  vertices: positions,
56
73
  indices: indices,
57
74
  size: 5
58
75
  };
59
76
  });
77
+
60
78
  return _this;
61
79
  }
80
+
62
81
  _createClass(PlaneModel, [{
63
82
  key: "initPlane",
64
83
  value: function initPlane() {
@@ -79,34 +98,43 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
79
98
  var segmentHeight = height / gridY;
80
99
  var indices = [];
81
100
  var positions = [];
101
+
82
102
  for (var iy = 0; iy < gridY1; iy++) {
83
103
  var y = iy * segmentHeight - heightHalf;
104
+
84
105
  for (var ix = 0; ix < gridX1; ix++) {
85
106
  var x = ix * segmentWidth - widthHalf;
107
+
86
108
  if (this.mapService.version === Version['GAODE2.x']) {
87
109
  // @ts-ignore
88
110
  var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
89
- _ref3 = _slicedToArray(_ref2, 2),
90
- a = _ref3[0],
91
- _b = _ref3[1];
111
+ _ref3 = _slicedToArray(_ref2, 2),
112
+ a = _ref3[0],
113
+ _b = _ref3[1];
114
+
92
115
  positions.push(a, _b, 0);
93
116
  } else {
94
117
  positions.push(x + lng, -y + lat, 0);
95
118
  }
119
+
96
120
  positions.push(ix / gridX);
97
121
  positions.push(1 - iy / gridY);
98
122
  }
99
123
  }
124
+
100
125
  for (var _iy = 0; _iy < gridY; _iy++) {
101
126
  for (var _ix = 0; _ix < gridX; _ix++) {
102
127
  var _a = _ix + gridX1 * _iy;
128
+
103
129
  var _b2 = _ix + gridX1 * (_iy + 1);
130
+
104
131
  var c = _ix + 1 + gridX1 * (_iy + 1);
105
132
  var d = _ix + 1 + gridX1 * _iy;
106
133
  indices.push(_a, _b2, d);
107
134
  indices.push(_b2, c, d);
108
135
  }
109
136
  }
137
+
110
138
  return {
111
139
  indices: indices,
112
140
  positions: positions
@@ -116,17 +144,20 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
116
144
  key: "getUninforms",
117
145
  value: function getUninforms() {
118
146
  var _ref4 = this.layer.getLayerConfig(),
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;
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
+
124
153
  if (this.mapTexture !== mapTexture) {
125
154
  var _this$texture;
155
+
126
156
  this.mapTexture = mapTexture;
127
157
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
128
158
  this.updateTexture(mapTexture);
129
159
  }
160
+
130
161
  return {
131
162
  u_opacity: opacity || 1,
132
163
  u_mapFlag: mapTexture ? 1 : 0,
@@ -138,6 +169,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
138
169
  key: "clearModels",
139
170
  value: function clearModels() {
140
171
  var _this$texture2;
172
+
141
173
  // @ts-ignore
142
174
  this.terrainImage = null;
143
175
  (_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
@@ -147,44 +179,52 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
147
179
  value: function () {
148
180
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
149
181
  var _ref5, mapTexture, createTexture2D, model;
182
+
150
183
  return _regeneratorRuntime.wrap(function _callee$(_context) {
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();
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
+ }
182
220
  }
183
221
  }, _callee, this);
184
222
  }));
223
+
185
224
  function initModels() {
186
225
  return _initModels.apply(this, arguments);
187
226
  }
227
+
188
228
  return initModels;
189
229
  }()
190
230
  }, {
@@ -192,18 +232,23 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
192
232
  value: function () {
193
233
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
194
234
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
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();
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
+ }
201
244
  }
202
245
  }, _callee2, this);
203
246
  }));
247
+
204
248
  function buildModels() {
205
249
  return _buildModels.apply(this, arguments);
206
250
  }
251
+
207
252
  return buildModels;
208
253
  }()
209
254
  }, {
@@ -211,15 +256,16 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
211
256
  value: function createModelData(options) {
212
257
  if (options) {
213
258
  var _ref6 = this.layer.getLayerConfig(),
214
- oldwidthSegments = _ref6.widthSegments,
215
- oldheightSegments = _ref6.heightSegments,
216
- oldwidth = _ref6.width,
217
- oldheight = _ref6.height;
259
+ oldwidthSegments = _ref6.widthSegments,
260
+ oldheightSegments = _ref6.heightSegments,
261
+ oldwidth = _ref6.width,
262
+ oldheight = _ref6.height;
263
+
218
264
  var _ref7 = options,
219
- widthSegments = _ref7.widthSegments,
220
- heightSegments = _ref7.heightSegments,
221
- width = _ref7.width,
222
- height = _ref7.height;
265
+ widthSegments = _ref7.widthSegments,
266
+ heightSegments = _ref7.heightSegments,
267
+ width = _ref7.width,
268
+ height = _ref7.height;
223
269
  this.layer.style({
224
270
  widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
225
271
  heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
@@ -227,6 +273,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
227
273
  height: height !== undefined ? height : oldheight
228
274
  });
229
275
  }
276
+
230
277
  var oldFeatures = this.layer.getEncodedData();
231
278
  var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
232
279
  return res;
@@ -235,10 +282,13 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
235
282
  key: "updateTexture",
236
283
  value: function updateTexture(mapTexture) {
237
284
  var _this3 = this;
285
+
238
286
  var createTexture2D = this.rendererService.createTexture2D;
287
+
239
288
  if (mapTexture) {
240
289
  var img = new Image();
241
290
  img.crossOrigin = 'anonymous';
291
+
242
292
  img.onload = function () {
243
293
  _this3.texture = createTexture2D({
244
294
  data: img,
@@ -247,8 +297,10 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
247
297
  wrapS: gl.CLAMP_TO_EDGE,
248
298
  wrapT: gl.CLAMP_TO_EDGE
249
299
  });
300
+
250
301
  _this3.layerService.reRender();
251
302
  };
303
+
252
304
  img.src = mapTexture;
253
305
  } else {
254
306
  this.texture = createTexture2D({
@@ -263,7 +315,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
263
315
  var canvas = document.createElement('canvas');
264
316
  var ctx = canvas.getContext('2d');
265
317
  var width = img.width,
266
- height = img.height;
318
+ height = img.height;
267
319
  canvas.width = width;
268
320
  canvas.height = height;
269
321
  ctx.drawImage(img, 0, 0, width, height);
@@ -282,9 +334,11 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
282
334
  var gridY1 = gridY + 1;
283
335
  var widthStep = imgWidth / gridX;
284
336
  var heightStep = imgHeight / gridY;
337
+
285
338
  for (var iy = 0; iy < gridY1; iy++) {
286
339
  var imgIndexY = Math.floor(iy * heightStep);
287
340
  var imgLen = imgIndexY * imgWidth;
341
+
288
342
  for (var ix = 0; ix < gridX1; ix++) {
289
343
  var imgIndexX = Math.floor(ix * widthStep);
290
344
  var imgDataIndex = (imgLen + imgIndexX) * 4;
@@ -295,6 +349,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
295
349
  positions[z] = rgb2height(_r, _g, _b3);
296
350
  }
297
351
  }
352
+
298
353
  var oldFeatures = this.layer.getEncodedData();
299
354
  var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
300
355
  return {
@@ -306,24 +361,26 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
306
361
  this.layer.updateModelData(modelData);
307
362
  this.layerService.throttleRenderLayers();
308
363
  }
309
-
310
364
  /**
311
365
  * load terrain texture & offset attribute z
312
366
  */
367
+
313
368
  }, {
314
369
  key: "loadTerrainTexture",
315
370
  value: function loadTerrainTexture(positions, indices) {
316
371
  var _this4 = this;
372
+
317
373
  var _ref8 = this.layer.getLayerConfig(),
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;
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
+
327
384
  if (this.terrainImage) {
328
385
  // 若当前已经存在 image,直接进行偏移计算(LOD)
329
386
  if (this.terrainImageLoaded) {
@@ -338,14 +395,17 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
338
395
  var terrainImage = new Image();
339
396
  this.terrainImage = terrainImage;
340
397
  terrainImage.crossOrigin = 'anonymous';
398
+
341
399
  terrainImage.onload = function () {
342
- _this4.terrainImageLoaded = true;
343
- // 图片加载完,触发事件,可以进行地形图的顶点计算存储
400
+ _this4.terrainImageLoaded = true; // 图片加载完,触发事件,可以进行地形图的顶点计算存储
401
+
344
402
  setTimeout(function () {
345
403
  return _this4.layer.emit('terrainImageLoaded', null);
346
404
  });
405
+
347
406
  _this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
348
407
  };
408
+
349
409
  terrainImage.src = terrainTexture;
350
410
  }
351
411
  }
@@ -372,6 +432,8 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
372
432
  });
373
433
  }
374
434
  }]);
435
+
375
436
  return PlaneModel;
376
437
  }(BaseModel);
438
+
377
439
  export { PlaneModel as default };