@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
@@ -7,44 +7,62 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
+
10
11
  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); }; }
12
+
11
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+
12
15
  import { AttributeType, gl } from '@antv/l7-core';
13
16
  import { getCullFace } from '@antv/l7-utils';
14
17
  import BaseModel from "../../core/BaseModel";
15
18
  import { SizeUnitType } from "../../core/interface";
16
- import { PointFillTriangulation } from "../../core/triangulation";
17
- // static pointLayer shader - not support animate
19
+ import { PointFillTriangulation } from "../../core/triangulation"; // static pointLayer shader - not support animate
20
+
18
21
  /* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
19
22
  var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= u_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
23
+
20
24
  /* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
21
25
  var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
26
+
22
27
  var FillImageModel = /*#__PURE__*/function (_BaseModel) {
23
28
  _inherits(FillImageModel, _BaseModel);
29
+
24
30
  var _super = _createSuper(FillImageModel);
31
+
25
32
  function FillImageModel() {
26
33
  var _this;
34
+
27
35
  _classCallCheck(this, FillImageModel);
36
+
28
37
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
38
  args[_key] = arguments[_key];
30
39
  }
40
+
31
41
  _this = _super.call.apply(_super, [this].concat(args));
42
+
32
43
  _defineProperty(_assertThisInitialized(_this), "meter2coord", 1);
44
+
33
45
  _defineProperty(_assertThisInitialized(_this), "isMeter", false);
46
+
34
47
  _defineProperty(_assertThisInitialized(_this), "radian", 0);
48
+
35
49
  _defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
36
50
  var createTexture2D = _this.rendererService.createTexture2D;
51
+
37
52
  if (_this.texture) {
38
53
  _this.texture.update({
39
54
  data: _this.iconService.getCanvas(),
40
55
  mag: 'linear',
41
56
  min: 'linear mipmap nearest',
42
57
  mipmap: true
43
- });
44
- // 更新完纹理后在更新的图层的时候需要更新所有的图层
58
+ }); // 更新完纹理后在更新的图层的时候需要更新所有的图层
59
+
60
+
45
61
  _this.layerService.throttleRenderLayers();
62
+
46
63
  return;
47
64
  }
65
+
48
66
  _this.texture = createTexture2D({
49
67
  data: _this.iconService.getCanvas(),
50
68
  mag: gl.LINEAR,
@@ -55,25 +73,27 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
55
73
  mipmap: true
56
74
  });
57
75
  });
76
+
58
77
  return _this;
59
78
  }
79
+
60
80
  _createClass(FillImageModel, [{
61
81
  key: "getUninforms",
62
- value:
63
- // 旋转的弧度
82
+ value: // 旋转的弧度
64
83
  function getUninforms() {
65
84
  var _ref = this.layer.getLayerConfig(),
66
- _ref$opacity = _ref.opacity,
67
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
68
- _ref$offsets = _ref.offsets,
69
- offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
70
- rotation = _ref.rotation,
71
- _ref$raisingHeight = _ref.raisingHeight,
72
- raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
73
- _ref$heightfixed = _ref.heightfixed,
74
- heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
75
- _ref$unit = _ref.unit,
76
- unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
85
+ _ref$opacity = _ref.opacity,
86
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
87
+ _ref$offsets = _ref.offsets,
88
+ offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
89
+ rotation = _ref.rotation,
90
+ _ref$raisingHeight = _ref.raisingHeight,
91
+ raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
92
+ _ref$heightfixed = _ref.heightfixed,
93
+ heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
94
+ _ref$unit = _ref.unit,
95
+ unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
96
+
77
97
  if (this.rendererService.getDirty()) {
78
98
  this.texture.bind();
79
99
  }
@@ -84,11 +104,15 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
84
104
  * GAODE2.x -1
85
105
  * GAODE1.x -1
86
106
  */
107
+
108
+
87
109
  var rotateFlag = 1;
110
+
88
111
  if (this.mapService.version === 'GAODE2.x' || this.mapService.version === 'GAODE1.x') {
89
112
  rotateFlag = -1;
90
- }
91
- // 控制图标的旋转角度(绕 Z 轴旋转)
113
+ } // 控制图标的旋转角度(绕 Z 轴旋转)
114
+
115
+
92
116
  this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
93
117
  return {
94
118
  u_raisingHeight: Number(raisingHeight),
@@ -111,20 +135,25 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
111
135
  value: function () {
112
136
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
113
137
  return _regeneratorRuntime.wrap(function _callee$(_context) {
114
- while (1) switch (_context.prev = _context.next) {
115
- case 0:
116
- this.iconService.on('imageUpdate', this.updateTexture);
117
- this.updateTexture();
118
- return _context.abrupt("return", this.buildModels());
119
- case 3:
120
- case "end":
121
- return _context.stop();
138
+ while (1) {
139
+ switch (_context.prev = _context.next) {
140
+ case 0:
141
+ this.iconService.on('imageUpdate', this.updateTexture);
142
+ this.updateTexture();
143
+ return _context.abrupt("return", this.buildModels());
144
+
145
+ case 3:
146
+ case "end":
147
+ return _context.stop();
148
+ }
122
149
  }
123
150
  }, _callee, this);
124
151
  }));
152
+
125
153
  function initModels() {
126
154
  return _initModels.apply(this, arguments);
127
155
  }
156
+
128
157
  return initModels;
129
158
  }()
130
159
  }, {
@@ -133,49 +162,56 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
133
162
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
134
163
  var model;
135
164
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
136
- while (1) switch (_context2.prev = _context2.next) {
137
- case 0:
138
- _context2.next = 2;
139
- return this.layer.buildLayerModel({
140
- moduleName: 'pointFillImage',
141
- vertexShader: pointFillVert,
142
- fragmentShader: pointFillFrag,
143
- triangulation: PointFillTriangulation,
144
- depth: {
145
- enable: false
146
- },
147
- cull: {
148
- enable: true,
149
- face: getCullFace(this.mapService.version)
150
- }
151
- });
152
- case 2:
153
- model = _context2.sent;
154
- return _context2.abrupt("return", [model]);
155
- case 4:
156
- case "end":
157
- return _context2.stop();
165
+ while (1) {
166
+ switch (_context2.prev = _context2.next) {
167
+ case 0:
168
+ _context2.next = 2;
169
+ return this.layer.buildLayerModel({
170
+ moduleName: 'pointFillImage',
171
+ vertexShader: pointFillVert,
172
+ fragmentShader: pointFillFrag,
173
+ triangulation: PointFillTriangulation,
174
+ depth: {
175
+ enable: false
176
+ },
177
+ cull: {
178
+ enable: true,
179
+ face: getCullFace(this.mapService.version)
180
+ }
181
+ });
182
+
183
+ case 2:
184
+ model = _context2.sent;
185
+ return _context2.abrupt("return", [model]);
186
+
187
+ case 4:
188
+ case "end":
189
+ return _context2.stop();
190
+ }
158
191
  }
159
192
  }, _callee2, this);
160
193
  }));
194
+
161
195
  function buildModels() {
162
196
  return _buildModels.apply(this, arguments);
163
197
  }
198
+
164
199
  return buildModels;
165
200
  }()
166
201
  }, {
167
202
  key: "clearModels",
168
203
  value: function clearModels() {
169
204
  var _this$texture;
205
+
170
206
  this.iconService.off('imageUpdate', this.updateTexture);
171
207
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
172
- }
208
+ } // overwrite baseModel func
173
209
 
174
- // overwrite baseModel func
175
210
  }, {
176
211
  key: "registerBuiltinAttributes",
177
212
  value: function registerBuiltinAttributes() {
178
213
  var _this2 = this;
214
+
179
215
  this.styleAttributeService.registerStyleAttribute({
180
216
  name: 'rotate',
181
217
  type: AttributeType.Attribute,
@@ -189,7 +225,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
189
225
  size: 1,
190
226
  update: function update(feature) {
191
227
  var _feature$rotate = feature.rotate,
192
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
228
+ rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
193
229
  return Array.isArray(rotate) ? [rotate[0]] : [rotate];
194
230
  }
195
231
  }
@@ -208,13 +244,16 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
208
244
  size: 2,
209
245
  update: function update(feature) {
210
246
  var iconMap = _this2.iconService.getIconMap();
247
+
211
248
  var shape = feature.shape;
249
+
212
250
  var _ref2 = iconMap[shape] || {
213
- x: -64,
214
- y: -64
215
- },
216
- x = _ref2.x,
217
- y = _ref2.y;
251
+ x: -64,
252
+ y: -64
253
+ },
254
+ x = _ref2.x,
255
+ y = _ref2.y;
256
+
218
257
  return [x, y];
219
258
  }
220
259
  }
@@ -237,9 +276,8 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
237
276
  return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
238
277
  }
239
278
  }
240
- });
279
+ }); // point layer size;
241
280
 
242
- // point layer size;
243
281
  this.styleAttributeService.registerStyleAttribute({
244
282
  name: 'size',
245
283
  type: AttributeType.Attribute,
@@ -254,13 +292,15 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
254
292
  size: 1,
255
293
  update: function update(feature) {
256
294
  var _feature$size = feature.size,
257
- size = _feature$size === void 0 ? 5 : _feature$size;
295
+ size = _feature$size === void 0 ? 5 : _feature$size;
258
296
  return Array.isArray(size) ? [size[0]] : [size];
259
297
  }
260
298
  }
261
299
  });
262
300
  }
263
301
  }]);
302
+
264
303
  return FillImageModel;
265
304
  }(BaseModel);
305
+
266
306
  export { FillImageModel as default };
@@ -7,42 +7,57 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
+
10
11
  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); }; }
12
+
11
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+
12
15
  import { AttributeType, gl } from '@antv/l7-core';
13
16
  import BaseModel from "../../core/BaseModel";
14
17
  import { PointImageTriangulation } from "../../core/triangulation";
18
+
15
19
  /* babel-plugin-inline-import '../shaders/image_frag.glsl' */
16
20
  var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n \n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
21
+
17
22
  /* babel-plugin-inline-import '../shaders/image_vert.glsl' */
18
23
  var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec2 u_offsets;\n\nuniform float u_opacity : 1;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(u_offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
24
+
19
25
  var ImageModel = /*#__PURE__*/function (_BaseModel) {
20
26
  _inherits(ImageModel, _BaseModel);
27
+
21
28
  var _super = _createSuper(ImageModel);
29
+
22
30
  function ImageModel() {
23
31
  var _this;
32
+
24
33
  _classCallCheck(this, ImageModel);
34
+
25
35
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
36
  args[_key] = arguments[_key];
27
37
  }
38
+
28
39
  _this = _super.call.apply(_super, [this].concat(args));
40
+
29
41
  _defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
30
42
  var createTexture2D = _this.rendererService.createTexture2D;
43
+
31
44
  if (_this.texture) {
32
45
  _this.texture.update({
33
46
  data: _this.iconService.getCanvas(),
34
47
  mag: 'linear',
35
48
  min: 'linear mipmap nearest',
36
49
  mipmap: true
37
- });
38
- // 更新完纹理后在更新的图层的时候需要更新所有的图层
50
+ }); // 更新完纹理后在更新的图层的时候需要更新所有的图层
39
51
  // this.layer.layerModelNeedUpdate = true;
52
+
53
+
40
54
  setTimeout(function () {
41
55
  // 延迟渲染
42
56
  _this.layerService.throttleRenderLayers();
43
57
  });
44
58
  return;
45
59
  }
60
+
46
61
  _this.texture = createTexture2D({
47
62
  data: _this.iconService.getCanvas(),
48
63
  mag: gl.LINEAR,
@@ -53,25 +68,28 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
53
68
  mipmap: true
54
69
  });
55
70
  });
71
+
56
72
  return _this;
57
73
  }
74
+
58
75
  _createClass(ImageModel, [{
59
76
  key: "getUninforms",
60
77
  value: function getUninforms() {
61
78
  var _ref = this.layer.getLayerConfig(),
62
- _ref$opacity = _ref.opacity,
63
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
64
- _ref$offsets = _ref.offsets,
65
- offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
66
- _ref$raisingHeight = _ref.raisingHeight,
67
- raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
68
- _ref$heightfixed = _ref.heightfixed,
69
- heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed;
70
-
71
- // ThreeJS 图层兼容
79
+ _ref$opacity = _ref.opacity,
80
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
81
+ _ref$offsets = _ref.offsets,
82
+ offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
83
+ _ref$raisingHeight = _ref.raisingHeight,
84
+ raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
85
+ _ref$heightfixed = _ref.heightfixed,
86
+ heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed; // ThreeJS 图层兼容
87
+
88
+
72
89
  if (this.rendererService.getDirty()) {
73
90
  this.texture.bind();
74
91
  }
92
+
75
93
  return {
76
94
  u_raisingHeight: Number(raisingHeight),
77
95
  u_heightfixed: Number(heightfixed),
@@ -86,26 +104,32 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
86
104
  value: function () {
87
105
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
88
106
  return _regeneratorRuntime.wrap(function _callee$(_context) {
89
- while (1) switch (_context.prev = _context.next) {
90
- case 0:
91
- this.iconService.on('imageUpdate', this.updateTexture);
92
- this.updateTexture();
93
- return _context.abrupt("return", this.buildModels());
94
- case 3:
95
- case "end":
96
- return _context.stop();
107
+ while (1) {
108
+ switch (_context.prev = _context.next) {
109
+ case 0:
110
+ this.iconService.on('imageUpdate', this.updateTexture);
111
+ this.updateTexture();
112
+ return _context.abrupt("return", this.buildModels());
113
+
114
+ case 3:
115
+ case "end":
116
+ return _context.stop();
117
+ }
97
118
  }
98
119
  }, _callee, this);
99
120
  }));
121
+
100
122
  function initModels() {
101
123
  return _initModels.apply(this, arguments);
102
124
  }
125
+
103
126
  return initModels;
104
127
  }()
105
128
  }, {
106
129
  key: "clearModels",
107
130
  value: function clearModels() {
108
131
  var _this$texture;
132
+
109
133
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
110
134
  this.iconService.off('imageUpdate', this.updateTexture);
111
135
  }
@@ -115,37 +139,44 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
115
139
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
116
140
  var model;
117
141
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
118
- while (1) switch (_context2.prev = _context2.next) {
119
- case 0:
120
- _context2.next = 2;
121
- return this.layer.buildLayerModel({
122
- moduleName: 'pointImage',
123
- vertexShader: pointImageVert,
124
- fragmentShader: pointImageFrag,
125
- triangulation: PointImageTriangulation,
126
- depth: {
127
- enable: false
128
- },
129
- primitive: gl.POINTS
130
- });
131
- case 2:
132
- model = _context2.sent;
133
- return _context2.abrupt("return", [model]);
134
- case 4:
135
- case "end":
136
- return _context2.stop();
142
+ while (1) {
143
+ switch (_context2.prev = _context2.next) {
144
+ case 0:
145
+ _context2.next = 2;
146
+ return this.layer.buildLayerModel({
147
+ moduleName: 'pointImage',
148
+ vertexShader: pointImageVert,
149
+ fragmentShader: pointImageFrag,
150
+ triangulation: PointImageTriangulation,
151
+ depth: {
152
+ enable: false
153
+ },
154
+ primitive: gl.POINTS
155
+ });
156
+
157
+ case 2:
158
+ model = _context2.sent;
159
+ return _context2.abrupt("return", [model]);
160
+
161
+ case 4:
162
+ case "end":
163
+ return _context2.stop();
164
+ }
137
165
  }
138
166
  }, _callee2, this);
139
167
  }));
168
+
140
169
  function buildModels() {
141
170
  return _buildModels.apply(this, arguments);
142
171
  }
172
+
143
173
  return buildModels;
144
174
  }()
145
175
  }, {
146
176
  key: "registerBuiltinAttributes",
147
177
  value: function registerBuiltinAttributes() {
148
178
  var _this2 = this;
179
+
149
180
  // point layer size;
150
181
  this.styleAttributeService.registerStyleAttribute({
151
182
  name: 'size',
@@ -161,13 +192,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
161
192
  size: 1,
162
193
  update: function update(feature) {
163
194
  var _feature$size = feature.size,
164
- size = _feature$size === void 0 ? 5 : _feature$size;
195
+ size = _feature$size === void 0 ? 5 : _feature$size;
165
196
  return Array.isArray(size) ? [size[0]] : [size];
166
197
  }
167
198
  }
168
- });
199
+ }); // point layer size;
169
200
 
170
- // point layer size;
171
201
  this.styleAttributeService.registerStyleAttribute({
172
202
  name: 'uv',
173
203
  type: AttributeType.Attribute,
@@ -182,19 +212,25 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
182
212
  size: 2,
183
213
  update: function update(feature) {
184
214
  var iconMap = _this2.iconService.getIconMap();
215
+
185
216
  var shape = feature.shape;
217
+
186
218
  var _ref2 = iconMap[shape] || {
187
- x: -64,
188
- y: -64
189
- },
190
- x = _ref2.x,
191
- y = _ref2.y; // 非画布区域,默认的图标改为透明
219
+ x: -64,
220
+ y: -64
221
+ },
222
+ x = _ref2.x,
223
+ y = _ref2.y; // 非画布区域,默认的图标改为透明
224
+
225
+
192
226
  return [x, y];
193
227
  }
194
228
  }
195
229
  });
196
230
  }
197
231
  }]);
232
+
198
233
  return ImageModel;
199
234
  }(BaseModel);
235
+
200
236
  export { ImageModel as default };
@@ -1,5 +1,5 @@
1
- import EarthExtrudeModel from "./earthExtrude";
2
- // earth
1
+ import EarthExtrudeModel from "./earthExtrude"; // earth
2
+
3
3
  import EarthFillModel from "./earthFill";
4
4
  import ExtrudeModel from "./extrude";
5
5
  import FillModel from "./fill";