@antv/l7-layers 2.16.0 → 2.16.1

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 +485 -321
  10. package/es/core/BaseModel.js +126 -97
  11. package/es/core/LayerPickService.js +32 -21
  12. package/es/core/TextureService.js +13 -0
  13. package/es/core/interface.js +24 -17
  14. package/es/core/shape/Path.js +20 -13
  15. package/es/core/shape/extrude.js +31 -10
  16. package/es/core/triangulation.js +114 -54
  17. package/es/earth/index.js +33 -9
  18. package/es/earth/models/atmosphere.js +54 -30
  19. package/es/earth/models/base.js +85 -47
  20. package/es/earth/models/bloomsphere.js +54 -30
  21. package/es/earth/utils.js +13 -9
  22. package/es/heatmap/index.js +40 -10
  23. package/es/heatmap/models/grid.js +52 -28
  24. package/es/heatmap/models/grid3d.js +52 -28
  25. package/es/heatmap/models/heatmap.js +146 -91
  26. package/es/heatmap/models/hexagon.js +52 -28
  27. package/es/heatmap/triangulation.js +4 -0
  28. package/es/image/index.js +28 -9
  29. package/es/image/models/image.js +100 -66
  30. package/es/index.js +17 -9
  31. package/es/line/index.js +34 -9
  32. package/es/line/models/arc.js +118 -66
  33. package/es/line/models/arc_3d.js +108 -60
  34. package/es/line/models/earthArc_3d.js +111 -63
  35. package/es/line/models/great_circle.js +100 -56
  36. package/es/line/models/half.js +77 -46
  37. package/es/line/models/line.js +148 -94
  38. package/es/line/models/linearline.js +80 -45
  39. package/es/line/models/simpleLine.js +74 -41
  40. package/es/line/models/wall.js +92 -52
  41. package/es/mask/index.js +28 -9
  42. package/es/mask/models/fill.js +54 -29
  43. package/es/plugins/DataMappingPlugin.js +117 -80
  44. package/es/plugins/DataSourcePlugin.js +68 -45
  45. package/es/plugins/FeatureScalePlugin.js +122 -67
  46. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  47. package/es/plugins/LayerMaskPlugin.js +11 -3
  48. package/es/plugins/LayerModelPlugin.js +104 -67
  49. package/es/plugins/LayerStylePlugin.js +9 -3
  50. package/es/plugins/LightingPlugin.js +18 -12
  51. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  52. package/es/plugins/PixelPickingPlugin.js +21 -12
  53. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  54. package/es/plugins/ShaderUniformPlugin.js +27 -13
  55. package/es/plugins/UpdateModelPlugin.js +5 -0
  56. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  57. package/es/point/index.js +77 -26
  58. package/es/point/models/earthExtrude.js +102 -61
  59. package/es/point/models/earthFill.js +87 -57
  60. package/es/point/models/extrude.js +101 -60
  61. package/es/point/models/fill.js +100 -70
  62. package/es/point/models/fillmage.js +107 -63
  63. package/es/point/models/image.js +88 -48
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +54 -30
  66. package/es/point/models/radar.js +64 -40
  67. package/es/point/models/simplePoint.js +69 -41
  68. package/es/point/models/text.js +301 -198
  69. package/es/point/shape/extrude.js +13 -4
  70. package/es/polygon/index.js +40 -11
  71. package/es/polygon/models/extrude.js +92 -48
  72. package/es/polygon/models/fill.js +88 -54
  73. package/es/polygon/models/index.js +2 -3
  74. package/es/polygon/models/ocean.js +76 -42
  75. package/es/polygon/models/water.js +71 -37
  76. package/es/raster/buffers/triangulation.js +4 -2
  77. package/es/raster/index.js +32 -9
  78. package/es/raster/models/raster.js +116 -80
  79. package/es/raster/models/rasterRgb.js +127 -84
  80. package/es/raster/models/rasterTerrainRgb.js +84 -56
  81. package/es/tile/interaction/getRasterData.js +20 -14
  82. package/es/tile/interaction/utils.js +9 -7
  83. package/es/tile/manager/base.js +96 -63
  84. package/es/tile/service/TileLayerService.js +55 -33
  85. package/es/tile/service/TilePickService.js +40 -26
  86. package/es/tile/service/TileSourceService.js +7 -3
  87. package/es/tile/tileFactory/DebugTile.js +46 -29
  88. package/es/tile/tileFactory/ImageTile.js +38 -20
  89. package/es/tile/tileFactory/MaskTile.js +43 -22
  90. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  91. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  92. package/es/tile/tileFactory/RasterTile.js +53 -30
  93. package/es/tile/tileFactory/Tile.js +97 -63
  94. package/es/tile/tileFactory/VectorTile.js +68 -41
  95. package/es/tile/tileFactory/index.js +11 -0
  96. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  97. package/es/tile/tileFactory/util.js +3 -0
  98. package/es/tile/tileLayer/BaseLayer.js +146 -105
  99. package/es/tile/utils.js +1 -1
  100. package/es/utils/blend.js +2 -0
  101. package/es/utils/collision-index.js +16 -9
  102. package/es/utils/dataMappingStyle.js +18 -8
  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 +479 -321
  127. package/lib/core/BaseModel.js +139 -97
  128. package/lib/core/LayerPickService.js +37 -21
  129. package/lib/core/TextureService.js +16 -0
  130. package/lib/core/interface.js +31 -21
  131. package/lib/core/schema.js +1 -0
  132. package/lib/core/shape/Path.js +31 -14
  133. package/lib/core/shape/extrude.js +54 -10
  134. package/lib/core/triangulation.js +153 -53
  135. package/lib/earth/index.js +43 -9
  136. package/lib/earth/models/atmosphere.js +63 -30
  137. package/lib/earth/models/base.js +90 -47
  138. package/lib/earth/models/bloomsphere.js +63 -30
  139. package/lib/earth/utils.js +31 -7
  140. package/lib/heatmap/index.js +48 -10
  141. package/lib/heatmap/models/grid.js +60 -28
  142. package/lib/heatmap/models/grid3d.js +60 -28
  143. package/lib/heatmap/models/heatmap.js +162 -91
  144. package/lib/heatmap/models/hexagon.js +60 -28
  145. package/lib/heatmap/models/index.js +6 -0
  146. package/lib/heatmap/triangulation.js +5 -0
  147. package/lib/image/index.js +36 -9
  148. package/lib/image/models/image.js +109 -66
  149. package/lib/image/models/index.js +3 -0
  150. package/lib/index.js +61 -7
  151. package/lib/line/index.js +40 -9
  152. package/lib/line/models/arc.js +128 -64
  153. package/lib/line/models/arc_3d.js +119 -58
  154. package/lib/line/models/earthArc_3d.js +122 -61
  155. package/lib/line/models/great_circle.js +111 -56
  156. package/lib/line/models/half.js +87 -46
  157. package/lib/line/models/index.js +11 -0
  158. package/lib/line/models/line.js +156 -92
  159. package/lib/line/models/linearline.js +92 -45
  160. package/lib/line/models/simpleLine.js +84 -41
  161. package/lib/line/models/wall.js +103 -52
  162. package/lib/mask/index.js +36 -9
  163. package/lib/mask/models/fill.js +63 -29
  164. package/lib/mask/models/index.js +3 -0
  165. package/lib/plugins/DataMappingPlugin.js +128 -80
  166. package/lib/plugins/DataSourcePlugin.js +76 -45
  167. package/lib/plugins/FeatureScalePlugin.js +138 -67
  168. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  169. package/lib/plugins/LayerMaskPlugin.js +17 -4
  170. package/lib/plugins/LayerModelPlugin.js +113 -68
  171. package/lib/plugins/LayerStylePlugin.js +14 -4
  172. package/lib/plugins/LightingPlugin.js +25 -12
  173. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  174. package/lib/plugins/PixelPickingPlugin.js +27 -12
  175. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  176. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  177. package/lib/plugins/UpdateModelPlugin.js +10 -1
  178. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  179. package/lib/point/index.js +83 -26
  180. package/lib/point/models/earthExtrude.js +113 -61
  181. package/lib/point/models/earthFill.js +117 -57
  182. package/lib/point/models/extrude.js +111 -60
  183. package/lib/point/models/fill.js +109 -68
  184. package/lib/point/models/fillmage.js +115 -61
  185. package/lib/point/models/image.js +98 -48
  186. package/lib/point/models/index.js +12 -1
  187. package/lib/point/models/normal.js +64 -30
  188. package/lib/point/models/radar.js +74 -40
  189. package/lib/point/models/simplePoint.js +79 -41
  190. package/lib/point/models/text.js +309 -198
  191. package/lib/point/shape/extrude.js +20 -4
  192. package/lib/polygon/index.js +48 -11
  193. package/lib/polygon/models/extrude.js +103 -48
  194. package/lib/polygon/models/fill.js +98 -54
  195. package/lib/polygon/models/index.js +14 -2
  196. package/lib/polygon/models/ocean.js +88 -42
  197. package/lib/polygon/models/water.js +82 -37
  198. package/lib/raster/buffers/triangulation.js +7 -3
  199. package/lib/raster/index.js +40 -9
  200. package/lib/raster/models/index.js +5 -0
  201. package/lib/raster/models/raster.js +125 -80
  202. package/lib/raster/models/rasterRgb.js +139 -84
  203. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  204. package/lib/tile/interaction/getRasterData.js +25 -14
  205. package/lib/tile/interaction/utils.js +19 -7
  206. package/lib/tile/manager/base.js +104 -63
  207. package/lib/tile/service/TileLayerService.js +60 -33
  208. package/lib/tile/service/TilePickService.js +48 -26
  209. package/lib/tile/service/TileSourceService.js +16 -2
  210. package/lib/tile/style/utils.js +3 -0
  211. package/lib/tile/tileFactory/DebugTile.js +54 -29
  212. package/lib/tile/tileFactory/ImageTile.js +46 -20
  213. package/lib/tile/tileFactory/MaskTile.js +51 -22
  214. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  215. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  216. package/lib/tile/tileFactory/RasterTile.js +63 -30
  217. package/lib/tile/tileFactory/Tile.js +102 -63
  218. package/lib/tile/tileFactory/VectorTile.js +76 -41
  219. package/lib/tile/tileFactory/index.js +25 -0
  220. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  221. package/lib/tile/tileFactory/util.js +9 -0
  222. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  223. package/lib/tile/utils.js +5 -1
  224. package/lib/utils/blend.js +5 -0
  225. package/lib/utils/collision-index.js +25 -9
  226. package/lib/utils/dataMappingStyle.js +19 -8
  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
@@ -5,29 +5,40 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+
8
9
  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); }; }
10
+
9
11
  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; } }
12
+
10
13
  import { AttributeType, gl } from '@antv/l7-core';
11
14
  import { isNumber } from 'lodash';
12
15
  import BaseModel from "../../core/BaseModel";
13
16
  import { earthTriangulation } from "../../core/triangulation";
17
+
14
18
  /* babel-plugin-inline-import '../shaders/atmosphere_frag.glsl' */
15
19
  var atmoSphereFrag = "\nuniform float u_opacity;\nuniform vec3 u_CameraPosition;\n\nvarying vec3 vVertexNormal;\nvarying float v_offset;\nvarying vec4 v_Color;\nvoid main() {\n \n \n // float intensity = pow(0.5 + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);\n float intensity = pow(v_offset + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);\n // \u53BB\u9664\u80CC\u9762\n if(intensity > 1.0) intensity = 0.0;\n\n gl_FragColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
20
+
16
21
  /* babel-plugin-inline-import '../shaders/atmosphere_vert.glsl' */
17
22
  var atmoSphereVert = "\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Uv;\nattribute vec4 a_Color;\nuniform vec3 u_CameraPosition;\nvarying float v_CamreaDistance;\n\nuniform mat4 u_ViewProjectionMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_ViewMatrix;\n\nvarying vec3 vVertexNormal;\nvarying vec4 v_Color;\nvarying float v_offset;\n\nvoid main() {\n float EARTH_RADIUS = 100.0;\n \n v_Color = a_Color;\n\n v_offset = min(((length(u_CameraPosition) - EARTH_RADIUS)/600.0) * 0.5 + 0.4, 1.0);\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
23
+
18
24
  var EarthAtomSphereModel = /*#__PURE__*/function (_BaseModel) {
19
25
  _inherits(EarthAtomSphereModel, _BaseModel);
26
+
20
27
  var _super = _createSuper(EarthAtomSphereModel);
28
+
21
29
  function EarthAtomSphereModel() {
22
30
  _classCallCheck(this, EarthAtomSphereModel);
31
+
23
32
  return _super.apply(this, arguments);
24
33
  }
34
+
25
35
  _createClass(EarthAtomSphereModel, [{
26
36
  key: "getUninforms",
27
37
  value: function getUninforms() {
28
38
  var _ref = this.layer.getLayerConfig(),
29
- _ref$opacity = _ref.opacity,
30
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
39
+ _ref$opacity = _ref.opacity,
40
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
41
+
31
42
  return {
32
43
  u_opacity: isNumber(opacity) ? opacity : 1.0
33
44
  };
@@ -37,18 +48,23 @@ var EarthAtomSphereModel = /*#__PURE__*/function (_BaseModel) {
37
48
  value: function () {
38
49
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
50
  return _regeneratorRuntime.wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- return _context.abrupt("return", this.buildModels());
43
- case 1:
44
- case "end":
45
- return _context.stop();
51
+ while (1) {
52
+ switch (_context.prev = _context.next) {
53
+ case 0:
54
+ return _context.abrupt("return", this.buildModels());
55
+
56
+ case 1:
57
+ case "end":
58
+ return _context.stop();
59
+ }
46
60
  }
47
61
  }, _callee, this);
48
62
  }));
63
+
49
64
  function initModels() {
50
65
  return _initModels.apply(this, arguments);
51
66
  }
67
+
52
68
  return initModels;
53
69
  }()
54
70
  }, {
@@ -62,33 +78,39 @@ var EarthAtomSphereModel = /*#__PURE__*/function (_BaseModel) {
62
78
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
63
79
  var model;
64
80
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
65
- while (1) switch (_context2.prev = _context2.next) {
66
- case 0:
67
- // TODO: 调整图层的绘制顺序 地球大气层
68
- this.layer.zIndex = -997;
69
- _context2.next = 3;
70
- return this.layer.buildLayerModel({
71
- moduleName: 'earthAtmoSphere',
72
- vertexShader: atmoSphereVert,
73
- fragmentShader: atmoSphereFrag,
74
- triangulation: earthTriangulation,
75
- depth: {
76
- enable: false
77
- },
78
- blend: this.getBlend()
79
- });
80
- case 3:
81
- model = _context2.sent;
82
- return _context2.abrupt("return", [model]);
83
- case 5:
84
- case "end":
85
- return _context2.stop();
81
+ while (1) {
82
+ switch (_context2.prev = _context2.next) {
83
+ case 0:
84
+ // TODO: 调整图层的绘制顺序 地球大气层
85
+ this.layer.zIndex = -997;
86
+ _context2.next = 3;
87
+ return this.layer.buildLayerModel({
88
+ moduleName: 'earthAtmoSphere',
89
+ vertexShader: atmoSphereVert,
90
+ fragmentShader: atmoSphereFrag,
91
+ triangulation: earthTriangulation,
92
+ depth: {
93
+ enable: false
94
+ },
95
+ blend: this.getBlend()
96
+ });
97
+
98
+ case 3:
99
+ model = _context2.sent;
100
+ return _context2.abrupt("return", [model]);
101
+
102
+ case 5:
103
+ case "end":
104
+ return _context2.stop();
105
+ }
86
106
  }
87
107
  }, _callee2, this);
88
108
  }));
109
+
89
110
  function buildModels() {
90
111
  return _buildModels.apply(this, arguments);
91
112
  }
113
+
92
114
  return buildModels;
93
115
  }()
94
116
  }, {
@@ -108,7 +130,7 @@ var EarthAtomSphereModel = /*#__PURE__*/function (_BaseModel) {
108
130
  size: 1,
109
131
  update: function update(feature) {
110
132
  var _feature$size = feature.size,
111
- size = _feature$size === void 0 ? 1 : _feature$size;
133
+ size = _feature$size === void 0 ? 1 : _feature$size;
112
134
  return Array.isArray(size) ? [size[0]] : [size];
113
135
  }
114
136
  }
@@ -147,6 +169,8 @@ var EarthAtomSphereModel = /*#__PURE__*/function (_BaseModel) {
147
169
  });
148
170
  }
149
171
  }]);
172
+
150
173
  return EarthAtomSphereModel;
151
174
  }(BaseModel);
175
+
152
176
  export { EarthAtomSphereModel as default };
@@ -7,38 +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 { earthTriangulation } from "../../core/triangulation";
18
+
15
19
  /* babel-plugin-inline-import '../shaders/base_frag.glsl' */
16
20
  var baseFrag = "\nuniform sampler2D u_texture;\n\nvarying vec2 v_texCoord;\nvarying float v_lightWeight;\n\n\nvoid main() {\n\n vec4 color = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y));\n color.xyz = color.xyz * v_lightWeight;\n gl_FragColor = color;\n}\n";
21
+
17
22
  /* babel-plugin-inline-import '../shaders/base_vert.glsl' */
18
23
  var baseVert = "// attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n\n// attribute vec2 a_Extrude;\n// attribute float a_Size;\n// attribute float a_Shape;\n\nuniform vec3 u_CameraPosition;\nuniform mat4 u_ViewProjectionMatrix;\nuniform mat4 u_ModelMatrix;\nuniform float u_ambientRatio : 0.5;\nuniform float u_diffuseRatio : 0.3;\nuniform float u_specularRatio : 0.2;\nuniform vec3 u_sunLight: [1.0, -10.5, 12.0];\n\n\n\nfloat calc_lighting(vec4 pos) {\n\n vec3 worldPos = vec3(pos * u_ModelMatrix);\n\n vec3 worldNormal = a_Normal;\n\n // cal light weight\n vec3 viewDir = normalize(u_CameraPosition - worldPos);\n\n vec3 lightDir = normalize(u_sunLight);\n\n vec3 halfDir = normalize(viewDir+lightDir);\n // lambert\n float lambert = dot(worldNormal, lightDir);\n // specular\n float specular = pow(max(0.0, dot(worldNormal, halfDir)), 32.0);\n //sum to light weight\n float lightWeight = u_ambientRatio + u_diffuseRatio * lambert + u_specularRatio * specular;\n\n return lightWeight;\n}\n\nvarying float v_lightWeight;\nvoid main() {\n\n v_texCoord = a_Uv;\n\n float lightWeight = calc_lighting(vec4(a_Position, 1.0));\n v_lightWeight = lightWeight;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
24
+
19
25
  var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
20
26
  _inherits(BaseEarthModel, _BaseModel);
27
+
21
28
  var _super = _createSuper(BaseEarthModel);
29
+
22
30
  function BaseEarthModel() {
23
31
  var _this;
32
+
24
33
  _classCallCheck(this, BaseEarthModel);
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), "earthTime", 3.4);
42
+
30
43
  _defineProperty(_assertThisInitialized(_this), "sunX", 1000);
44
+
31
45
  _defineProperty(_assertThisInitialized(_this), "sunY", 1000);
46
+
32
47
  _defineProperty(_assertThisInitialized(_this), "sunZ", 1000);
48
+
33
49
  _defineProperty(_assertThisInitialized(_this), "sunRadius", Math.sqrt(_this.sunX * _this.sunX + _this.sunY * _this.sunY + _this.sunZ * _this.sunZ));
50
+
34
51
  return _this;
35
52
  }
53
+
36
54
  _createClass(BaseEarthModel, [{
37
55
  key: "getUninforms",
38
56
  value: function getUninforms() {
39
57
  var _this$layer$getLayerC = this.layer.getLayerConfig(),
40
- animateOption = _this$layer$getLayerC.animateOption,
41
- globalOptions = _this$layer$getLayerC.globalOptions;
58
+ animateOption = _this$layer$getLayerC.animateOption,
59
+ globalOptions = _this$layer$getLayerC.globalOptions;
60
+
42
61
  if (animateOption !== null && animateOption !== void 0 && animateOption.enable) {
43
62
  // @ts-ignore
44
63
  // T: rotateY 方法只有在地球模式下存在
@@ -50,6 +69,7 @@ var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
50
69
  this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
51
70
  this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
52
71
  }
72
+
53
73
  return {
54
74
  u_ambientRatio: (globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.ambientRatio) || 0.6,
55
75
  // 环境光
@@ -75,38 +95,48 @@ var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
75
95
  value: function () {
76
96
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
77
97
  var _this2 = this;
98
+
78
99
  var _this$layer$getLayerC2, globalOptions, source, createTexture2D;
100
+
79
101
  return _regeneratorRuntime.wrap(function _callee$(_context) {
80
- while (1) switch (_context.prev = _context.next) {
81
- case 0:
82
- _this$layer$getLayerC2 = this.layer.getLayerConfig(), globalOptions = _this$layer$getLayerC2.globalOptions;
83
- if ((globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.earthTime) !== undefined) {
84
- this.setEarthTime(globalOptions.earthTime);
85
- }
86
- source = this.layer.getSource();
87
- createTexture2D = this.rendererService.createTexture2D;
88
- this.texture = createTexture2D({
89
- height: 0,
90
- width: 0
91
- });
92
- source.data.images.then(function (imageData) {
93
- _this2.texture = createTexture2D({
94
- data: imageData[0],
95
- width: imageData[0].width,
96
- height: imageData[0].height
102
+ while (1) {
103
+ switch (_context.prev = _context.next) {
104
+ case 0:
105
+ _this$layer$getLayerC2 = this.layer.getLayerConfig(), globalOptions = _this$layer$getLayerC2.globalOptions;
106
+
107
+ if ((globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.earthTime) !== undefined) {
108
+ this.setEarthTime(globalOptions.earthTime);
109
+ }
110
+
111
+ source = this.layer.getSource();
112
+ createTexture2D = this.rendererService.createTexture2D;
113
+ this.texture = createTexture2D({
114
+ height: 0,
115
+ width: 0
97
116
  });
98
- _this2.layerService.reRender();
99
- });
100
- return _context.abrupt("return", this.buildModels());
101
- case 7:
102
- case "end":
103
- return _context.stop();
117
+ source.data.images.then(function (imageData) {
118
+ _this2.texture = createTexture2D({
119
+ data: imageData[0],
120
+ width: imageData[0].width,
121
+ height: imageData[0].height
122
+ });
123
+
124
+ _this2.layerService.reRender();
125
+ });
126
+ return _context.abrupt("return", this.buildModels());
127
+
128
+ case 7:
129
+ case "end":
130
+ return _context.stop();
131
+ }
104
132
  }
105
133
  }, _callee, this);
106
134
  }));
135
+
107
136
  function initModels() {
108
137
  return _initModels.apply(this, arguments);
109
138
  }
139
+
110
140
  return initModels;
111
141
  }()
112
142
  }, {
@@ -120,33 +150,39 @@ var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
120
150
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
121
151
  var model;
122
152
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
123
- while (1) switch (_context2.prev = _context2.next) {
124
- case 0:
125
- // Tip: 调整图层的绘制顺序 地球大气层
126
- this.layer.zIndex = -998;
127
- _context2.next = 3;
128
- return this.layer.buildLayerModel({
129
- moduleName: 'earthBase',
130
- vertexShader: baseVert,
131
- fragmentShader: baseFrag,
132
- triangulation: earthTriangulation,
133
- depth: {
134
- enable: true
135
- },
136
- blend: this.getBlend()
137
- });
138
- case 3:
139
- model = _context2.sent;
140
- return _context2.abrupt("return", [model]);
141
- case 5:
142
- case "end":
143
- return _context2.stop();
153
+ while (1) {
154
+ switch (_context2.prev = _context2.next) {
155
+ case 0:
156
+ // Tip: 调整图层的绘制顺序 地球大气层
157
+ this.layer.zIndex = -998;
158
+ _context2.next = 3;
159
+ return this.layer.buildLayerModel({
160
+ moduleName: 'earthBase',
161
+ vertexShader: baseVert,
162
+ fragmentShader: baseFrag,
163
+ triangulation: earthTriangulation,
164
+ depth: {
165
+ enable: true
166
+ },
167
+ blend: this.getBlend()
168
+ });
169
+
170
+ case 3:
171
+ model = _context2.sent;
172
+ return _context2.abrupt("return", [model]);
173
+
174
+ case 5:
175
+ case "end":
176
+ return _context2.stop();
177
+ }
144
178
  }
145
179
  }, _callee2, this);
146
180
  }));
181
+
147
182
  function buildModels() {
148
183
  return _buildModels.apply(this, arguments);
149
184
  }
185
+
150
186
  return buildModels;
151
187
  }()
152
188
  }, {
@@ -165,7 +201,7 @@ var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
165
201
  size: 1,
166
202
  update: function update(feature) {
167
203
  var _feature$size = feature.size,
168
- size = _feature$size === void 0 ? 1 : _feature$size;
204
+ size = _feature$size === void 0 ? 1 : _feature$size;
169
205
  return Array.isArray(size) ? [size[0]] : [size];
170
206
  }
171
207
  }
@@ -205,6 +241,8 @@ var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
205
241
  });
206
242
  }
207
243
  }]);
244
+
208
245
  return BaseEarthModel;
209
246
  }(BaseModel);
247
+
210
248
  export { BaseEarthModel as default };
@@ -5,29 +5,40 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+
8
9
  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); }; }
10
+
9
11
  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; } }
12
+
10
13
  import { AttributeType, gl } from '@antv/l7-core';
11
14
  import { isNumber } from 'lodash';
12
15
  import BaseModel from "../../core/BaseModel";
13
16
  import { earthOuterTriangulation } from "../../core/triangulation";
17
+
14
18
  /* babel-plugin-inline-import '../shaders/bloomsphere_frag.glsl' */
15
19
  var bloomSphereFrag = "\nuniform float u_opacity;\nuniform vec3 u_CameraPosition;\nvarying vec3 vVertexNormal;\n\nvarying vec4 v_Color;\nvoid main() {\n\n\n float intensity = - dot(normalize(vVertexNormal), normalize(u_CameraPosition));\n // \u53BB\u9664\u80CC\u9762\n if(intensity > 1.0) intensity = 0.0;\n\n gl_FragColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
20
+
16
21
  /* babel-plugin-inline-import '../shaders/bloomsphere_vert.glsl' */
17
22
  var bloomSphereVert = "\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Uv;\nattribute vec4 a_Color;\nuniform vec3 u_CameraPosition;\nuniform mat4 u_ViewProjectionMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_ViewMatrix;\n\nvarying vec3 vVertexNormal;\nvarying vec4 v_Color;\n\nvoid main() {\n v_Color = a_Color;\n\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
23
+
18
24
  var EarthBloomSphereModel = /*#__PURE__*/function (_BaseModel) {
19
25
  _inherits(EarthBloomSphereModel, _BaseModel);
26
+
20
27
  var _super = _createSuper(EarthBloomSphereModel);
28
+
21
29
  function EarthBloomSphereModel() {
22
30
  _classCallCheck(this, EarthBloomSphereModel);
31
+
23
32
  return _super.apply(this, arguments);
24
33
  }
34
+
25
35
  _createClass(EarthBloomSphereModel, [{
26
36
  key: "getUninforms",
27
37
  value: function getUninforms() {
28
38
  var _ref = this.layer.getLayerConfig(),
29
- _ref$opacity = _ref.opacity,
30
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
39
+ _ref$opacity = _ref.opacity,
40
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
41
+
31
42
  return {
32
43
  u_opacity: isNumber(opacity) ? opacity : 1.0
33
44
  };
@@ -37,18 +48,23 @@ var EarthBloomSphereModel = /*#__PURE__*/function (_BaseModel) {
37
48
  value: function () {
38
49
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
50
  return _regeneratorRuntime.wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- return _context.abrupt("return", this.buildModels());
43
- case 1:
44
- case "end":
45
- return _context.stop();
51
+ while (1) {
52
+ switch (_context.prev = _context.next) {
53
+ case 0:
54
+ return _context.abrupt("return", this.buildModels());
55
+
56
+ case 1:
57
+ case "end":
58
+ return _context.stop();
59
+ }
46
60
  }
47
61
  }, _callee, this);
48
62
  }));
63
+
49
64
  function initModels() {
50
65
  return _initModels.apply(this, arguments);
51
66
  }
67
+
52
68
  return initModels;
53
69
  }()
54
70
  }, {
@@ -62,33 +78,39 @@ var EarthBloomSphereModel = /*#__PURE__*/function (_BaseModel) {
62
78
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
63
79
  var model;
64
80
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
65
- while (1) switch (_context2.prev = _context2.next) {
66
- case 0:
67
- // Tip: 调整图层的绘制顺序,让它保持在地球后面(减少锯齿现象)
68
- this.layer.zIndex = -999;
69
- _context2.next = 3;
70
- return this.layer.buildLayerModel({
71
- moduleName: 'earthBloom',
72
- vertexShader: bloomSphereVert,
73
- fragmentShader: bloomSphereFrag,
74
- triangulation: earthOuterTriangulation,
75
- depth: {
76
- enable: false
77
- },
78
- blend: this.getBlend()
79
- });
80
- case 3:
81
- model = _context2.sent;
82
- return _context2.abrupt("return", [model]);
83
- case 5:
84
- case "end":
85
- return _context2.stop();
81
+ while (1) {
82
+ switch (_context2.prev = _context2.next) {
83
+ case 0:
84
+ // Tip: 调整图层的绘制顺序,让它保持在地球后面(减少锯齿现象)
85
+ this.layer.zIndex = -999;
86
+ _context2.next = 3;
87
+ return this.layer.buildLayerModel({
88
+ moduleName: 'earthBloom',
89
+ vertexShader: bloomSphereVert,
90
+ fragmentShader: bloomSphereFrag,
91
+ triangulation: earthOuterTriangulation,
92
+ depth: {
93
+ enable: false
94
+ },
95
+ blend: this.getBlend()
96
+ });
97
+
98
+ case 3:
99
+ model = _context2.sent;
100
+ return _context2.abrupt("return", [model]);
101
+
102
+ case 5:
103
+ case "end":
104
+ return _context2.stop();
105
+ }
86
106
  }
87
107
  }, _callee2, this);
88
108
  }));
109
+
89
110
  function buildModels() {
90
111
  return _buildModels.apply(this, arguments);
91
112
  }
113
+
92
114
  return buildModels;
93
115
  }()
94
116
  }, {
@@ -107,7 +129,7 @@ var EarthBloomSphereModel = /*#__PURE__*/function (_BaseModel) {
107
129
  size: 1,
108
130
  update: function update(feature) {
109
131
  var _feature$size = feature.size,
110
- size = _feature$size === void 0 ? 1 : _feature$size;
132
+ size = _feature$size === void 0 ? 1 : _feature$size;
111
133
  return Array.isArray(size) ? [size[0]] : [size];
112
134
  }
113
135
  }
@@ -146,6 +168,8 @@ var EarthBloomSphereModel = /*#__PURE__*/function (_BaseModel) {
146
168
  });
147
169
  }
148
170
  }]);
171
+
149
172
  return EarthBloomSphereModel;
150
173
  }(BaseModel);
174
+
151
175
  export { EarthBloomSphereModel as default };
package/es/earth/utils.js CHANGED
@@ -1,17 +1,16 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import { mat4, vec3 } from 'gl-matrix';
3
- // 该文件专门记录地球模式的数值
4
-
2
+ import { mat4, vec3 } from 'gl-matrix'; // 该文件专门记录地球模式的数值
5
3
  // 地球网格半径
4
+
6
5
  export var EARTH_RADIUS = 100;
7
6
  export var EARTH_SEGMENTS = 36;
8
7
  export var EARTH_RADIUS_OUTER = 40;
9
-
10
8
  /**
11
9
  * 角度转弧度
12
10
  * @param deg
13
11
  * @returns
14
12
  */
13
+
15
14
  function torad(deg) {
16
15
  return deg / 180 * Math.acos(-1);
17
16
  }
@@ -21,25 +20,26 @@ function torad(deg) {
21
20
  * @param latitude 纬度
22
21
  * @param radius 半径
23
22
  */
23
+
24
+
24
25
  export function lglt2xyz(lnglat) {
25
26
  // TODO: + Math.PI/2 是为了对齐坐标
26
27
  var lng = torad(lnglat[0]) + Math.PI / 2;
27
- var lat = torad(lnglat[1]);
28
+ var lat = torad(lnglat[1]); // TODO: 手动增加一些偏移,减轻面的冲突
28
29
 
29
- // TODO: 手动增加一些偏移,减轻面的冲突
30
30
  var radius = EARTH_RADIUS + Math.random() * 0.4;
31
31
  var z = radius * Math.cos(lat) * Math.cos(lng);
32
32
  var x = radius * Math.cos(lat) * Math.sin(lng);
33
33
  var y = radius * Math.sin(lat);
34
34
  return [x, y, z];
35
35
  }
36
-
37
36
  /**
38
37
  * 构建地球球体网格
39
38
  * @param radius
40
39
  * @param opt
41
40
  * @returns
42
41
  */
42
+
43
43
  export function primitiveSphere(radius, opt) {
44
44
  var matRotY = mat4.create();
45
45
  var matRotZ = mat4.create();
@@ -56,9 +56,11 @@ export function primitiveSphere(radius, opt) {
56
56
  var positionsArr = [];
57
57
  var normalArr = [];
58
58
  var uvs = [];
59
+
59
60
  for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
60
61
  var normalizedZ = zRotationStep / totalZRotationSteps;
61
62
  var angleZ = normalizedZ * Math.PI;
63
+
62
64
  for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
63
65
  var normalizedY = yRotationStep / totalYRotationSteps;
64
66
  var angleY = normalizedY * Math.PI * 2;
@@ -73,14 +75,15 @@ export function primitiveSphere(radius, opt) {
73
75
  positionsArr.push.apply(positionsArr, _toConsumableArray(tmpVec3.slice()));
74
76
  vec3.normalize(tmpVec3, tmpVec3);
75
77
  normalArr.push.apply(normalArr, _toConsumableArray(tmpVec3.slice()));
76
- uvs.push([normalizedY, 1 - normalizedZ]);
78
+ uvs.push([normalizedY, 1 - normalizedZ]); // position 和 uv 一起存储
77
79
 
78
- // position 和 uv 一起存储
79
80
  positionsArr.push(normalizedY, 1 - normalizedZ);
80
81
  }
82
+
81
83
  if (zRotationStep > 0) {
82
84
  var verticesCount = positions.length;
83
85
  var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1);
86
+
84
87
  for (; firstIndex + totalYRotationSteps + 2 < verticesCount; firstIndex++) {
85
88
  indices.push([firstIndex, firstIndex + 1, firstIndex + totalYRotationSteps + 1]);
86
89
  indicesArr.push(firstIndex, firstIndex + 1, firstIndex + totalYRotationSteps + 1);
@@ -89,6 +92,7 @@ export function primitiveSphere(radius, opt) {
89
92
  }
90
93
  }
91
94
  }
95
+
92
96
  return {
93
97
  cells: indices,
94
98
  positions: positions,