@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,63 +1,86 @@
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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
11
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
12
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
13
20
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
14
22
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
15
24
  var _l7Core = require("@antv/l7-core");
25
+
16
26
  var _l7Utils = require("@antv/l7-utils");
27
+
17
28
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
29
+
18
30
  var _triangulation = require("../../core/triangulation");
31
+
19
32
  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); }; }
33
+
20
34
  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; } }
35
+
21
36
  /* babel-plugin-inline-import '../shaders/raster_terrain_rgb_frag.glsl' */
22
37
  var Raster_terrainFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nvarying vec2 v_texCoord;\n\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nuniform vec4 u_unpack;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_texture, coord,bias) * 255.0;\n data.a = -1.0;\n return dot(data, u_unpack);\n}\n\nvec4 getColor(float value) {\n float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec2 coord = vec2(normalisedValue, 0);\n return texture2D(u_colorTexture, coord);\n}\n\nvoid main() {\n float value = getElevation(v_texCoord,0.0);\n if (value == u_noDataValue) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else {\n \n gl_FragColor = getColor(value);\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n if(gl_FragColor.a < 0.01)\n discard;\n }\n}\n";
38
+
23
39
  /* babel-plugin-inline-import '../shaders/rater_terrain_rgb_vert.glsl' */
24
40
  var Raster_terrainVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
41
+
25
42
  var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
26
43
  (0, _inherits2.default)(RasterTerrainRGB, _BaseModel);
44
+
27
45
  var _super = _createSuper(RasterTerrainRGB);
46
+
28
47
  function RasterTerrainRGB() {
29
48
  (0, _classCallCheck2.default)(this, RasterTerrainRGB);
30
49
  return _super.apply(this, arguments);
31
50
  }
51
+
32
52
  (0, _createClass2.default)(RasterTerrainRGB, [{
33
53
  key: "getUninforms",
34
54
  value: function getUninforms() {
35
55
  var _ref = this.layer.getLayerConfig(),
36
- opacity = _ref.opacity,
37
- _ref$clampLow = _ref.clampLow,
38
- clampLow = _ref$clampLow === void 0 ? true : _ref$clampLow,
39
- _ref$clampHigh = _ref.clampHigh,
40
- clampHigh = _ref$clampHigh === void 0 ? true : _ref$clampHigh,
41
- _ref$noDataValue = _ref.noDataValue,
42
- noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
43
- domain = _ref.domain,
44
- rampColors = _ref.rampColors,
45
- colorTexture = _ref.colorTexture,
46
- _ref$rScaler = _ref.rScaler,
47
- rScaler = _ref$rScaler === void 0 ? 6553.6 : _ref$rScaler,
48
- _ref$gScaler = _ref.gScaler,
49
- gScaler = _ref$gScaler === void 0 ? 25.6 : _ref$gScaler,
50
- _ref$bScaler = _ref.bScaler,
51
- bScaler = _ref$bScaler === void 0 ? 0.1 : _ref$bScaler,
52
- _ref$offset = _ref.offset,
53
- offset = _ref$offset === void 0 ? 10000 : _ref$offset;
56
+ opacity = _ref.opacity,
57
+ _ref$clampLow = _ref.clampLow,
58
+ clampLow = _ref$clampLow === void 0 ? true : _ref$clampLow,
59
+ _ref$clampHigh = _ref.clampHigh,
60
+ clampHigh = _ref$clampHigh === void 0 ? true : _ref$clampHigh,
61
+ _ref$noDataValue = _ref.noDataValue,
62
+ noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
63
+ domain = _ref.domain,
64
+ rampColors = _ref.rampColors,
65
+ colorTexture = _ref.colorTexture,
66
+ _ref$rScaler = _ref.rScaler,
67
+ rScaler = _ref$rScaler === void 0 ? 6553.6 : _ref$rScaler,
68
+ _ref$gScaler = _ref.gScaler,
69
+ gScaler = _ref$gScaler === void 0 ? 25.6 : _ref$gScaler,
70
+ _ref$bScaler = _ref.bScaler,
71
+ bScaler = _ref$bScaler === void 0 ? 0.1 : _ref$bScaler,
72
+ _ref$offset = _ref.offset,
73
+ offset = _ref$offset === void 0 ? 10000 : _ref$offset;
74
+
54
75
  var newdomain = domain || (0, _l7Utils.getDefaultDomain)(rampColors);
55
76
  var texture = colorTexture;
77
+
56
78
  if (!colorTexture) {
57
79
  texture = this.layer.textureService.getColorTexture(rampColors, newdomain);
58
80
  } else {
59
81
  this.layer.textureService.setColorTexture(colorTexture, rampColors, newdomain);
60
82
  }
83
+
61
84
  return {
62
85
  u_opacity: opacity || 1,
63
86
  u_texture: this.texture,
@@ -75,50 +98,58 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
75
98
  var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
76
99
  var source, createTexture2D, imageData, model;
77
100
  return _regenerator.default.wrap(function _callee$(_context) {
78
- while (1) switch (_context.prev = _context.next) {
79
- case 0:
80
- source = this.layer.getSource();
81
- createTexture2D = this.rendererService.createTexture2D;
82
- _context.next = 4;
83
- return source.data.images;
84
- case 4:
85
- imageData = _context.sent;
86
- this.texture = createTexture2D({
87
- data: imageData[0],
88
- width: imageData[0].width,
89
- height: imageData[0].height,
90
- min: _l7Core.gl.LINEAR,
91
- mag: _l7Core.gl.LINEAR
92
- });
93
- _context.next = 8;
94
- return this.layer.buildLayerModel({
95
- moduleName: 'RasterTileDataImage',
96
- vertexShader: Raster_terrainVert,
97
- fragmentShader: Raster_terrainFrag,
98
- triangulation: _triangulation.RasterImageTriangulation,
99
- primitive: _l7Core.gl.TRIANGLES,
100
- depth: {
101
- enable: false
102
- }
103
- });
104
- case 8:
105
- model = _context.sent;
106
- return _context.abrupt("return", [model]);
107
- case 10:
108
- case "end":
109
- return _context.stop();
101
+ while (1) {
102
+ switch (_context.prev = _context.next) {
103
+ case 0:
104
+ source = this.layer.getSource();
105
+ createTexture2D = this.rendererService.createTexture2D;
106
+ _context.next = 4;
107
+ return source.data.images;
108
+
109
+ case 4:
110
+ imageData = _context.sent;
111
+ this.texture = createTexture2D({
112
+ data: imageData[0],
113
+ width: imageData[0].width,
114
+ height: imageData[0].height,
115
+ min: _l7Core.gl.LINEAR,
116
+ mag: _l7Core.gl.LINEAR
117
+ });
118
+ _context.next = 8;
119
+ return this.layer.buildLayerModel({
120
+ moduleName: 'RasterTileDataImage',
121
+ vertexShader: Raster_terrainVert,
122
+ fragmentShader: Raster_terrainFrag,
123
+ triangulation: _triangulation.RasterImageTriangulation,
124
+ primitive: _l7Core.gl.TRIANGLES,
125
+ depth: {
126
+ enable: false
127
+ }
128
+ });
129
+
130
+ case 8:
131
+ model = _context.sent;
132
+ return _context.abrupt("return", [model]);
133
+
134
+ case 10:
135
+ case "end":
136
+ return _context.stop();
137
+ }
110
138
  }
111
139
  }, _callee, this);
112
140
  }));
141
+
113
142
  function initModels() {
114
143
  return _initModels.apply(this, arguments);
115
144
  }
145
+
116
146
  return initModels;
117
147
  }()
118
148
  }, {
119
149
  key: "clearModels",
120
150
  value: function clearModels() {
121
151
  var _this$texture;
152
+
122
153
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
123
154
  }
124
155
  }, {
@@ -126,18 +157,23 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
126
157
  value: function () {
127
158
  var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
128
159
  return _regenerator.default.wrap(function _callee2$(_context2) {
129
- while (1) switch (_context2.prev = _context2.next) {
130
- case 0:
131
- return _context2.abrupt("return", this.initModels());
132
- case 1:
133
- case "end":
134
- return _context2.stop();
160
+ while (1) {
161
+ switch (_context2.prev = _context2.next) {
162
+ case 0:
163
+ return _context2.abrupt("return", this.initModels());
164
+
165
+ case 1:
166
+ case "end":
167
+ return _context2.stop();
168
+ }
135
169
  }
136
170
  }, _callee2, this);
137
171
  }));
172
+
138
173
  function buildModels() {
139
174
  return _buildModels.apply(this, arguments);
140
175
  }
176
+
141
177
  return buildModels;
142
178
  }()
143
179
  }, {
@@ -163,4 +199,5 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
163
199
  }]);
164
200
  return RasterTerrainRGB;
165
201
  }(_BaseModel2.default);
202
+
166
203
  exports.default = RasterTerrainRGB;
@@ -1,34 +1,39 @@
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.readPixel = readPixel;
8
9
  exports.readRasterValue = readRasterValue;
10
+
9
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+
10
13
  var _l7Utils = require("@antv/l7-utils");
14
+
11
15
  function readRasterValue(tile, mapService, x, y) {
12
16
  var _tile$bboxPolygon, _tile$data, _tile$data2, _tile$data3;
17
+
13
18
  var bbox = (tile === null || tile === void 0 ? void 0 : (_tile$bboxPolygon = tile.bboxPolygon) === null || _tile$bboxPolygon === void 0 ? void 0 : _tile$bboxPolygon.bbox) || [0, 0, 10, -10];
19
+
14
20
  var _bbox = (0, _slicedToArray2.default)(bbox, 4),
15
- _bbox$ = _bbox[0],
16
- minLng = _bbox$ === void 0 ? 0 : _bbox$,
17
- _bbox$2 = _bbox[1],
18
- minLat = _bbox$2 === void 0 ? 0 : _bbox$2,
19
- _bbox$3 = _bbox[2],
20
- maxLng = _bbox$3 === void 0 ? 10 : _bbox$3,
21
- _bbox$4 = _bbox[3],
22
- maxLat = _bbox$4 === void 0 ? -10 : _bbox$4;
21
+ _bbox$ = _bbox[0],
22
+ minLng = _bbox$ === void 0 ? 0 : _bbox$,
23
+ _bbox$2 = _bbox[1],
24
+ minLat = _bbox$2 === void 0 ? 0 : _bbox$2,
25
+ _bbox$3 = _bbox[2],
26
+ maxLng = _bbox$3 === void 0 ? 10 : _bbox$3,
27
+ _bbox$4 = _bbox[3],
28
+ maxLat = _bbox$4 === void 0 ? -10 : _bbox$4;
29
+
23
30
  var tileXY = mapService.lngLatToContainer([minLng, minLat]);
24
31
  var tileMaxXY = mapService.lngLatToContainer([maxLng, maxLat]);
25
32
  var tilePixelWidth = tileMaxXY.x - tileXY.x;
26
33
  var tilePixelHeight = tileXY.y - tileMaxXY.y;
27
- var pos = [(x - tileXY.x) / tilePixelWidth,
28
- // x
34
+ var pos = [(x - tileXY.x) / tilePixelWidth, // x
29
35
  (y - tileMaxXY.y) / tilePixelHeight // y
30
36
  ];
31
-
32
37
  var tileWidth = (tile === null || tile === void 0 ? void 0 : (_tile$data = tile.data) === null || _tile$data === void 0 ? void 0 : _tile$data.width) || 1;
33
38
  var tileHeight = (tile === null || tile === void 0 ? void 0 : (_tile$data2 = tile.data) === null || _tile$data2 === void 0 ? void 0 : _tile$data2.height) || 1;
34
39
  var indexX = Math.floor(pos[0] * tileWidth);
@@ -37,19 +42,24 @@ function readRasterValue(tile, mapService, x, y) {
37
42
  var data = tile === null || tile === void 0 ? void 0 : (_tile$data3 = tile.data) === null || _tile$data3 === void 0 ? void 0 : _tile$data3.data[index];
38
43
  return data;
39
44
  }
45
+
40
46
  function readPixel(x, y, rendererService) {
41
47
  var readPixels = rendererService.readPixels,
42
- getContainer = rendererService.getContainer;
48
+ getContainer = rendererService.getContainer;
43
49
  var xInDevicePixel = x * _l7Utils.DOM.DPR;
44
50
  var yInDevicePixel = y * _l7Utils.DOM.DPR;
51
+
45
52
  var _getContainerSize = getContainerSize(getContainer()),
46
- width = _getContainerSize.width,
47
- height = _getContainerSize.height;
53
+ width = _getContainerSize.width,
54
+ height = _getContainerSize.height;
55
+
48
56
  width *= _l7Utils.DOM.DPR;
49
57
  height *= _l7Utils.DOM.DPR;
58
+
50
59
  if (xInDevicePixel > width - 1 * _l7Utils.DOM.DPR || xInDevicePixel < 0 || yInDevicePixel > height - 1 * _l7Utils.DOM.DPR || yInDevicePixel < 0) {
51
60
  return false;
52
61
  }
62
+
53
63
  var pickedColors = readPixels({
54
64
  x: Math.floor(xInDevicePixel),
55
65
  // 视口坐标系原点在左上,而 WebGL 在左下,需要翻转 Y 轴
@@ -60,6 +70,7 @@ function readPixel(x, y, rendererService) {
60
70
  });
61
71
  return pickedColors;
62
72
  }
73
+
63
74
  function getContainerSize(container) {
64
75
  if (container.getContext) {
65
76
  return {
@@ -1,6 +1,7 @@
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
  });
@@ -11,8 +12,11 @@ exports.setFeatureSelect = setFeatureSelect;
11
12
  exports.setHighlight = setHighlight;
12
13
  exports.setPickState = setPickState;
13
14
  exports.setSelect = setSelect;
15
+
14
16
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
+
15
18
  var _l7Utils = require("@antv/l7-utils");
19
+
16
20
  function clearPickState(layers) {
17
21
  layers.filter(function (layer) {
18
22
  return layer.inited && layer.isVisible();
@@ -23,6 +27,7 @@ function clearPickState(layers) {
23
27
  layer.setCurrentSelectedId(null);
24
28
  });
25
29
  }
30
+
26
31
  function setSelect(layers, pickedColors, renderList) {
27
32
  var selectedId = (0, _l7Utils.decodePickingColor)(pickedColors);
28
33
  var pickColor;
@@ -33,11 +38,12 @@ function setSelect(layers, pickedColors, renderList) {
33
38
  pickColor = pickedColors;
34
39
  } else {
35
40
  selectFeature(layer, new Uint8Array([0, 0, 0, 0])); // toggle select
41
+
36
42
  layer.setCurrentSelectedId(null);
37
43
  pickColor = null;
38
44
  }
39
- });
40
- // unselect normal layer
45
+ }); // unselect normal layer
46
+
41
47
  renderList.filter(function (layer) {
42
48
  return layer.inited && layer.isVisible() && layer.needPick('click');
43
49
  }).filter(function (layer) {
@@ -48,12 +54,12 @@ function setSelect(layers, pickedColors, renderList) {
48
54
  });
49
55
  return pickColor;
50
56
  }
57
+
51
58
  function setHighlight(layers, pickedColors) {
52
59
  var pickId = (0, _l7Utils.decodePickingColor)(pickedColors);
53
60
  layers.filter(function (layer) {
54
61
  return layer.inited && layer.isVisible();
55
- })
56
- // @ts-ignore
62
+ }) // @ts-ignore
57
63
  .filter(function (layer) {
58
64
  return layer.getPickID() !== pickId;
59
65
  }).map(function (layer) {
@@ -62,12 +68,14 @@ function setHighlight(layers, pickedColors) {
62
68
  layer.hooks.beforeHighlight.call(pickedColors);
63
69
  });
64
70
  }
71
+
65
72
  function setPickState(layers, pickColors) {
66
73
  if (pickColors.select) {
67
74
  layers.map(function (layer) {
68
75
  selectFeature(layer, pickColors.select);
69
76
  });
70
77
  }
78
+
71
79
  if (pickColors.active) {
72
80
  layers.filter(function (layer) {
73
81
  return layer.inited && layer.isVisible();
@@ -76,14 +84,17 @@ function setPickState(layers, pickColors) {
76
84
  });
77
85
  }
78
86
  }
87
+
79
88
  function selectFeature(layer, pickedColors) {
80
89
  // @ts-ignore
81
90
  var _pickedColors = (0, _slicedToArray2.default)(pickedColors, 3),
82
- r = _pickedColors[0],
83
- g = _pickedColors[1],
84
- b = _pickedColors[2];
91
+ r = _pickedColors[0],
92
+ g = _pickedColors[1],
93
+ b = _pickedColors[2];
94
+
85
95
  layer.hooks.beforeSelect.call([r, g, b]);
86
96
  }
97
+
87
98
  function setFeatureSelect(color, layers) {
88
99
  var id = (0, _l7Utils.decodePickingColor)(color);
89
100
  layers.map(function (layer) {
@@ -91,6 +102,7 @@ function setFeatureSelect(color, layers) {
91
102
  layer.setCurrentSelectedId(id);
92
103
  });
93
104
  }
105
+
94
106
  function setFeatureActive(color, layers) {
95
107
  var id = (0, _l7Utils.decodePickingColor)(color);
96
108
  layers.map(function (layer) {