@antv/l7-layers 2.5.35 → 2.5.37-mini11

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 (279) hide show
  1. package/lib/core/BaseLayer.js +10 -4
  2. package/lib/core/BaseLayer.js.map +1 -1
  3. package/lib/core/shape/Path.js +5 -4
  4. package/lib/core/shape/Path.js.map +1 -1
  5. package/lib/core/shape/extrude.js +1 -1
  6. package/lib/core/triangulation.js +13 -9
  7. package/lib/core/triangulation.js.map +1 -1
  8. package/lib/earth/utils.js +1 -1
  9. package/lib/heatmap/models/heatmap.js +1 -1
  10. package/lib/imagetile/index.js +95 -0
  11. package/lib/imagetile/index.js.map +1 -0
  12. package/lib/imagetile/models/imagetile.js +177 -0
  13. package/lib/imagetile/models/imagetile.js.map +1 -0
  14. package/lib/imagetile/models/index.js +17 -0
  15. package/lib/imagetile/models/index.js.map +1 -0
  16. package/lib/imagetile/utils/ImageTile.js +99 -0
  17. package/lib/imagetile/utils/ImageTile.js.map +1 -0
  18. package/lib/imagetile/utils/Tile.js +324 -0
  19. package/lib/imagetile/utils/Tile.js.map +1 -0
  20. package/lib/imagetile/utils/lruCache.js +109 -0
  21. package/lib/imagetile/utils/lruCache.js.map +1 -0
  22. package/lib/imagetile/utils/tileCache.js +58 -0
  23. package/lib/imagetile/utils/tileCache.js.map +1 -0
  24. package/lib/index.js +16 -8
  25. package/lib/index.js.map +1 -1
  26. package/lib/line/index.js +3 -0
  27. package/lib/line/index.js.map +1 -1
  28. package/lib/line/models/arc.js +2 -2
  29. package/lib/line/models/arc_3d.js +2 -2
  30. package/lib/line/models/arcmini.js +160 -0
  31. package/lib/line/models/arcmini.js.map +1 -0
  32. package/lib/line/models/great_circle.js +2 -2
  33. package/lib/line/models/index.js +3 -0
  34. package/lib/line/models/index.js.map +1 -1
  35. package/lib/line/models/line.js +2 -2
  36. package/lib/plugins/DataMappingPlugin.js +1 -1
  37. package/lib/plugins/DataSourcePlugin.js +5 -1
  38. package/lib/plugins/DataSourcePlugin.js.map +1 -1
  39. package/lib/plugins/FeatureScalePlugin.js +5 -1
  40. package/lib/plugins/FeatureScalePlugin.js.map +1 -1
  41. package/lib/plugins/LayerAnimateStylePlugin.js +1 -1
  42. package/lib/plugins/LightingPlugin.js +5 -3
  43. package/lib/plugins/LightingPlugin.js.map +1 -1
  44. package/lib/plugins/MultiPassRendererPlugin.js +1 -1
  45. package/lib/plugins/ShaderUniformPlugin.js +1 -1
  46. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  47. package/lib/plugins/UpdateStyleAttributePlugin.js +6 -6
  48. package/lib/plugins/UpdateStyleAttributePlugin.js.map +1 -1
  49. package/lib/point/shape/Path.js +5 -4
  50. package/lib/point/shape/Path.js.map +1 -1
  51. package/lib/raster/raster.js +1 -1
  52. package/lib/utils/dataMappingStyle.js +1 -1
  53. package/lib/utils/extrude_polyline.js +1 -1
  54. package/lib/utils/polylineNormal.js +1 -1
  55. package/lib/utils/symbol-layout.js +1 -1
  56. package/package.json +6 -5
  57. package/CHANGELOG.md +0 -492
  58. package/LICENSE.md +0 -21
  59. package/es/citybuliding/building.d.ts +0 -17
  60. package/es/citybuliding/building.js +0 -79
  61. package/es/citybuliding/building.js.map +0 -1
  62. package/es/citybuliding/models/build.d.ts +0 -13
  63. package/es/citybuliding/models/build.js +0 -124
  64. package/es/citybuliding/models/build.js.map +0 -1
  65. package/es/core/BaseLayer.d.ts +0 -174
  66. package/es/core/BaseLayer.js +0 -974
  67. package/es/core/BaseLayer.js.map +0 -1
  68. package/es/core/BaseModel.d.ts +0 -135
  69. package/es/core/BaseModel.js +0 -412
  70. package/es/core/BaseModel.js.map +0 -1
  71. package/es/core/interface.d.ts +0 -19
  72. package/es/core/interface.js +0 -7
  73. package/es/core/interface.js.map +0 -1
  74. package/es/core/schema.d.ts +0 -27
  75. package/es/core/schema.js +0 -23
  76. package/es/core/schema.js.map +0 -1
  77. package/es/core/shape/Path.d.ts +0 -39
  78. package/es/core/shape/Path.js +0 -57
  79. package/es/core/shape/Path.js.map +0 -1
  80. package/es/core/shape/extrude.d.ts +0 -17
  81. package/es/core/shape/extrude.js +0 -143
  82. package/es/core/shape/extrude.js.map +0 -1
  83. package/es/core/triangulation.d.ts +0 -109
  84. package/es/core/triangulation.js +0 -328
  85. package/es/core/triangulation.js.map +0 -1
  86. package/es/earth/index.d.ts +0 -17
  87. package/es/earth/index.js +0 -81
  88. package/es/earth/index.js.map +0 -1
  89. package/es/earth/models/atmosphere.d.ts +0 -9
  90. package/es/earth/models/atmosphere.js +0 -125
  91. package/es/earth/models/atmosphere.js.map +0 -1
  92. package/es/earth/models/base.d.ts +0 -16
  93. package/es/earth/models/base.js +0 -193
  94. package/es/earth/models/base.js.map +0 -1
  95. package/es/earth/models/bloomsphere.d.ts +0 -9
  96. package/es/earth/models/bloomsphere.js +0 -125
  97. package/es/earth/models/bloomsphere.js.map +0 -1
  98. package/es/earth/utils.d.ts +0 -26
  99. package/es/earth/utils.js +0 -81
  100. package/es/earth/utils.js.map +0 -1
  101. package/es/glsl.d.js +0 -2
  102. package/es/glsl.d.js.map +0 -1
  103. package/es/heatmap/index.d.ts +0 -22
  104. package/es/heatmap/index.js +0 -123
  105. package/es/heatmap/index.js.map +0 -1
  106. package/es/heatmap/models/grid.d.ts +0 -8
  107. package/es/heatmap/models/grid.js +0 -90
  108. package/es/heatmap/models/grid.js.map +0 -1
  109. package/es/heatmap/models/grid3d.d.ts +0 -8
  110. package/es/heatmap/models/grid3d.js +0 -122
  111. package/es/heatmap/models/grid3d.js.map +0 -1
  112. package/es/heatmap/models/heatmap.d.ts +0 -24
  113. package/es/heatmap/models/heatmap.js +0 -399
  114. package/es/heatmap/models/heatmap.js.map +0 -1
  115. package/es/heatmap/models/hexagon.d.ts +0 -8
  116. package/es/heatmap/models/hexagon.js +0 -90
  117. package/es/heatmap/models/hexagon.js.map +0 -1
  118. package/es/heatmap/models/index.d.ts +0 -5
  119. package/es/heatmap/models/index.js +0 -13
  120. package/es/heatmap/models/index.js.map +0 -1
  121. package/es/heatmap/triangulation.d.ts +0 -5
  122. package/es/heatmap/triangulation.js +0 -38
  123. package/es/heatmap/triangulation.js.map +0 -1
  124. package/es/image/index.d.ts +0 -22
  125. package/es/image/index.js +0 -82
  126. package/es/image/index.js.map +0 -1
  127. package/es/image/models/image.d.ts +0 -18
  128. package/es/image/models/image.js +0 -127
  129. package/es/image/models/image.js.map +0 -1
  130. package/es/image/models/index.d.ts +0 -5
  131. package/es/image/models/index.js +0 -6
  132. package/es/image/models/index.js.map +0 -1
  133. package/es/index.d.ts +0 -11
  134. package/es/index.js +0 -39
  135. package/es/index.js.map +0 -1
  136. package/es/line/index.d.ts +0 -25
  137. package/es/line/index.js +0 -95
  138. package/es/line/index.js.map +0 -1
  139. package/es/line/models/arc.d.ts +0 -12
  140. package/es/line/models/arc.js +0 -281
  141. package/es/line/models/arc.js.map +0 -1
  142. package/es/line/models/arc_3d.d.ts +0 -12
  143. package/es/line/models/arc_3d.js +0 -277
  144. package/es/line/models/arc_3d.js.map +0 -1
  145. package/es/line/models/great_circle.d.ts +0 -12
  146. package/es/line/models/great_circle.js +0 -269
  147. package/es/line/models/great_circle.js.map +0 -1
  148. package/es/line/models/index.d.ts +0 -5
  149. package/es/line/models/index.js +0 -12
  150. package/es/line/models/index.js.map +0 -1
  151. package/es/line/models/line.d.ts +0 -13
  152. package/es/line/models/line.js +0 -342
  153. package/es/line/models/line.js.map +0 -1
  154. package/es/plugins/DataMappingPlugin.d.ts +0 -13
  155. package/es/plugins/DataMappingPlugin.js +0 -199
  156. package/es/plugins/DataMappingPlugin.js.map +0 -1
  157. package/es/plugins/DataSourcePlugin.d.ts +0 -7
  158. package/es/plugins/DataSourcePlugin.js +0 -73
  159. package/es/plugins/DataSourcePlugin.js.map +0 -1
  160. package/es/plugins/FeatureScalePlugin.d.ts +0 -26
  161. package/es/plugins/FeatureScalePlugin.js +0 -270
  162. package/es/plugins/FeatureScalePlugin.js.map +0 -1
  163. package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -7
  164. package/es/plugins/LayerAnimateStylePlugin.js +0 -50
  165. package/es/plugins/LayerAnimateStylePlugin.js.map +0 -1
  166. package/es/plugins/LayerModelPlugin.d.ts +0 -8
  167. package/es/plugins/LayerModelPlugin.js +0 -34
  168. package/es/plugins/LayerModelPlugin.js.map +0 -1
  169. package/es/plugins/LayerStylePlugin.d.ts +0 -8
  170. package/es/plugins/LayerStylePlugin.js +0 -35
  171. package/es/plugins/LayerStylePlugin.js.map +0 -1
  172. package/es/plugins/LightingPlugin.d.ts +0 -36
  173. package/es/plugins/LightingPlugin.js +0 -100
  174. package/es/plugins/LightingPlugin.js.map +0 -1
  175. package/es/plugins/MultiPassRendererPlugin.d.ts +0 -37
  176. package/es/plugins/MultiPassRendererPlugin.js +0 -79
  177. package/es/plugins/MultiPassRendererPlugin.js.map +0 -1
  178. package/es/plugins/PixelPickingPlugin.d.ts +0 -8
  179. package/es/plugins/PixelPickingPlugin.js +0 -112
  180. package/es/plugins/PixelPickingPlugin.js.map +0 -1
  181. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -11
  182. package/es/plugins/RegisterStyleAttributePlugin.js +0 -98
  183. package/es/plugins/RegisterStyleAttributePlugin.js.map +0 -1
  184. package/es/plugins/ShaderUniformPlugin.d.ts +0 -16
  185. package/es/plugins/ShaderUniformPlugin.js +0 -78
  186. package/es/plugins/ShaderUniformPlugin.js.map +0 -1
  187. package/es/plugins/UpdateModelPlugin.d.ts +0 -8
  188. package/es/plugins/UpdateModelPlugin.js +0 -27
  189. package/es/plugins/UpdateModelPlugin.js.map +0 -1
  190. package/es/plugins/UpdateStyleAttributePlugin.d.ts +0 -12
  191. package/es/plugins/UpdateStyleAttributePlugin.js +0 -74
  192. package/es/plugins/UpdateStyleAttributePlugin.js.map +0 -1
  193. package/es/point/index.d.ts +0 -30
  194. package/es/point/index.js +0 -130
  195. package/es/point/index.js.map +0 -1
  196. package/es/point/models/extrude.d.ts +0 -14
  197. package/es/point/models/extrude.js +0 -180
  198. package/es/point/models/extrude.js.map +0 -1
  199. package/es/point/models/fill.d.ts +0 -17
  200. package/es/point/models/fill.js +0 -247
  201. package/es/point/models/fill.js.map +0 -1
  202. package/es/point/models/icon-font.d.ts +0 -11
  203. package/es/point/models/icon-font.js +0 -181
  204. package/es/point/models/icon-font.js.map +0 -1
  205. package/es/point/models/image.d.ts +0 -11
  206. package/es/point/models/image.js +0 -207
  207. package/es/point/models/image.js.map +0 -1
  208. package/es/point/models/index.d.ts +0 -5
  209. package/es/point/models/index.js +0 -16
  210. package/es/point/models/index.js.map +0 -1
  211. package/es/point/models/normal.d.ts +0 -21
  212. package/es/point/models/normal.js +0 -155
  213. package/es/point/models/normal.js.map +0 -1
  214. package/es/point/models/text.d.ts +0 -56
  215. package/es/point/models/text.js +0 -522
  216. package/es/point/models/text.js.map +0 -1
  217. package/es/point/shape/Path.d.ts +0 -40
  218. package/es/point/shape/Path.js +0 -57
  219. package/es/point/shape/Path.js.map +0 -1
  220. package/es/point/shape/extrude.d.ts +0 -15
  221. package/es/point/shape/extrude.js +0 -58
  222. package/es/point/shape/extrude.js.map +0 -1
  223. package/es/polygon/index.d.ts +0 -22
  224. package/es/polygon/index.js +0 -124
  225. package/es/polygon/index.js.map +0 -1
  226. package/es/polygon/models/extrude.d.ts +0 -13
  227. package/es/polygon/models/extrude.js +0 -139
  228. package/es/polygon/models/extrude.js.map +0 -1
  229. package/es/polygon/models/fill.d.ts +0 -13
  230. package/es/polygon/models/fill.js +0 -108
  231. package/es/polygon/models/fill.js.map +0 -1
  232. package/es/polygon/models/index.d.ts +0 -5
  233. package/es/polygon/models/index.js +0 -20
  234. package/es/polygon/models/index.js.map +0 -1
  235. package/es/raster/buffers/triangulation.d.ts +0 -6
  236. package/es/raster/buffers/triangulation.js +0 -28
  237. package/es/raster/buffers/triangulation.js.map +0 -1
  238. package/es/raster/image.d.ts +0 -0
  239. package/es/raster/image.js +0 -2
  240. package/es/raster/image.js.map +0 -1
  241. package/es/raster/index.d.ts +0 -28
  242. package/es/raster/index.js +0 -83
  243. package/es/raster/index.js.map +0 -1
  244. package/es/raster/models/index.d.ts +0 -5
  245. package/es/raster/models/index.js +0 -7
  246. package/es/raster/models/index.js.map +0 -1
  247. package/es/raster/models/raster.d.ts +0 -19
  248. package/es/raster/models/raster.js +0 -152
  249. package/es/raster/models/raster.js.map +0 -1
  250. package/es/raster/raster.d.ts +0 -30
  251. package/es/raster/raster.js +0 -178
  252. package/es/raster/raster.js.map +0 -1
  253. package/es/raster/raster2d.d.ts +0 -27
  254. package/es/raster/raster2d.js +0 -158
  255. package/es/raster/raster2d.js.map +0 -1
  256. package/es/utils/blend.d.ts +0 -2
  257. package/es/utils/blend.js +0 -55
  258. package/es/utils/blend.js.map +0 -1
  259. package/es/utils/collision-index.d.ts +0 -47
  260. package/es/utils/collision-index.js +0 -87
  261. package/es/utils/collision-index.js.map +0 -1
  262. package/es/utils/dataMappingStyle.d.ts +0 -30
  263. package/es/utils/dataMappingStyle.js +0 -88
  264. package/es/utils/dataMappingStyle.js.map +0 -1
  265. package/es/utils/extrude_polyline.d.ts +0 -48
  266. package/es/utils/extrude_polyline.js +0 -405
  267. package/es/utils/extrude_polyline.js.map +0 -1
  268. package/es/utils/geo.d.ts +0 -3
  269. package/es/utils/geo.js +0 -24
  270. package/es/utils/geo.js.map +0 -1
  271. package/es/utils/grid-index.d.ts +0 -28
  272. package/es/utils/grid-index.js +0 -193
  273. package/es/utils/grid-index.js.map +0 -1
  274. package/es/utils/polylineNormal.d.ts +0 -9
  275. package/es/utils/polylineNormal.js +0 -171
  276. package/es/utils/polylineNormal.js.map +0 -1
  277. package/es/utils/symbol-layout.d.ts +0 -43
  278. package/es/utils/symbol-layout.js +0 -260
  279. package/es/utils/symbol-layout.js.map +0 -1
@@ -1,193 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
-
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
-
13
- import { AttributeType, gl } from '@antv/l7-core';
14
- import BaseModel from '../../core/BaseModel';
15
- import { earthTriangulation } from '../../core/triangulation';
16
- 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";
17
- 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";
18
-
19
- var BaseEarthModel = function (_BaseModel) {
20
- _inherits(BaseEarthModel, _BaseModel);
21
-
22
- var _super = _createSuper(BaseEarthModel);
23
-
24
- function BaseEarthModel() {
25
- var _this;
26
-
27
- _classCallCheck(this, BaseEarthModel);
28
-
29
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
- args[_key] = arguments[_key];
31
- }
32
-
33
- _this = _super.call.apply(_super, [this].concat(args));
34
-
35
- _defineProperty(_assertThisInitialized(_this), "texture", void 0);
36
-
37
- _defineProperty(_assertThisInitialized(_this), "earthTime", 3.4);
38
-
39
- _defineProperty(_assertThisInitialized(_this), "sunX", 1000);
40
-
41
- _defineProperty(_assertThisInitialized(_this), "sunY", 1000);
42
-
43
- _defineProperty(_assertThisInitialized(_this), "sunZ", 1000);
44
-
45
- _defineProperty(_assertThisInitialized(_this), "sunRadius", Math.sqrt(_this.sunX * _this.sunX + _this.sunY * _this.sunY + _this.sunZ * _this.sunZ));
46
-
47
- return _this;
48
- }
49
-
50
- _createClass(BaseEarthModel, [{
51
- key: "getUninforms",
52
- value: function getUninforms() {
53
- var _this$layer$getLayerC = this.layer.getLayerConfig(),
54
- animateOption = _this$layer$getLayerC.animateOption,
55
- globelOtions = _this$layer$getLayerC.globelOtions;
56
-
57
- if (animateOption !== null && animateOption !== void 0 && animateOption.enable) {
58
- this.mapService.rotateY({
59
- reg: 0.002
60
- });
61
- this.earthTime += 0.02;
62
- this.sunY = 10;
63
- this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
64
- this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
65
- }
66
-
67
- return {
68
- u_ambientRatio: (globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.ambientRatio) || 0.6,
69
- u_diffuseRatio: (globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.diffuseRatio) || 0.4,
70
- u_specularRatio: (globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.specularRatio) || 0.1,
71
- u_sunLight: [this.sunX, this.sunY, this.sunZ],
72
- u_texture: this.texture
73
- };
74
- }
75
- }, {
76
- key: "setEarthTime",
77
- value: function setEarthTime(time) {
78
- this.earthTime = time;
79
- this.sunY = 10;
80
- this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
81
- this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
82
- this.layerService.renderLayers();
83
- }
84
- }, {
85
- key: "initModels",
86
- value: function initModels() {
87
- var _this2 = this;
88
-
89
- var _this$layer$getLayerC2 = this.layer.getLayerConfig(),
90
- globelOtions = _this$layer$getLayerC2.globelOtions;
91
-
92
- if ((globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.earthTime) !== undefined) {
93
- this.setEarthTime(globelOtions.earthTime);
94
- }
95
-
96
- var source = this.layer.getSource();
97
- var createTexture2D = this.rendererService.createTexture2D;
98
- this.texture = createTexture2D({
99
- height: 0,
100
- width: 0
101
- });
102
- source.data.images.then(function (imageData) {
103
- _this2.texture = createTexture2D({
104
- data: imageData[0],
105
- width: imageData[0].width,
106
- height: imageData[0].height
107
- });
108
-
109
- _this2.layerService.renderLayers();
110
- });
111
- return this.buildModels();
112
- }
113
- }, {
114
- key: "clearModels",
115
- value: function clearModels() {
116
- return '';
117
- }
118
- }, {
119
- key: "buildModels",
120
- value: function buildModels() {
121
- this.layer.zIndex = -998;
122
- return [this.layer.buildLayerModel({
123
- moduleName: 'baseEarth',
124
- vertexShader: baseVert,
125
- fragmentShader: baseFrag,
126
- triangulation: earthTriangulation,
127
- depth: {
128
- enable: true
129
- },
130
- blend: this.getBlend()
131
- })];
132
- }
133
- }, {
134
- key: "registerBuiltinAttributes",
135
- value: function registerBuiltinAttributes() {
136
- this.styleAttributeService.registerStyleAttribute({
137
- name: 'size',
138
- type: AttributeType.Attribute,
139
- descriptor: {
140
- name: 'a_Size',
141
- buffer: {
142
- usage: gl.DYNAMIC_DRAW,
143
- data: [],
144
- type: gl.FLOAT
145
- },
146
- size: 1,
147
- update: function update(feature, featureIdx, vertex, attributeIdx) {
148
- var _feature$size = feature.size,
149
- size = _feature$size === void 0 ? 1 : _feature$size;
150
- return Array.isArray(size) ? [size[0]] : [size];
151
- }
152
- }
153
- });
154
- this.styleAttributeService.registerStyleAttribute({
155
- name: 'normal',
156
- type: AttributeType.Attribute,
157
- descriptor: {
158
- name: 'a_Normal',
159
- buffer: {
160
- usage: gl.STATIC_DRAW,
161
- data: [],
162
- type: gl.FLOAT
163
- },
164
- size: 3,
165
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
166
- return normal;
167
- }
168
- }
169
- });
170
- this.styleAttributeService.registerStyleAttribute({
171
- name: 'uv',
172
- type: AttributeType.Attribute,
173
- descriptor: {
174
- name: 'a_Uv',
175
- buffer: {
176
- usage: gl.DYNAMIC_DRAW,
177
- data: [],
178
- type: gl.FLOAT
179
- },
180
- size: 2,
181
- update: function update(feature, featureIdx, vertex, attributeIdx) {
182
- return [vertex[3], vertex[4]];
183
- }
184
- }
185
- });
186
- }
187
- }]);
188
-
189
- return BaseEarthModel;
190
- }(BaseModel);
191
-
192
- export { BaseEarthModel as default };
193
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/earth/models/base.ts"],"names":["AttributeType","gl","BaseModel","earthTriangulation","BaseEarthModel","Math","sqrt","sunX","sunY","sunZ","layer","getLayerConfig","animateOption","globelOtions","enable","mapService","rotateY","reg","earthTime","cos","sunRadius","sin","u_ambientRatio","ambientRatio","u_diffuseRatio","diffuseRatio","u_specularRatio","specularRatio","u_sunLight","u_texture","texture","time","layerService","renderLayers","undefined","setEarthTime","source","getSource","createTexture2D","rendererService","height","width","data","images","then","imageData","buildModels","zIndex","buildLayerModel","moduleName","vertexShader","baseVert","fragmentShader","baseFrag","triangulation","depth","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","normal"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAGEC,EAHF,QASO,eATP;AAWA,OAAOC,SAAP,MAAoD,sBAApD;AACA,SAASC,kBAAT,QAAmC,0BAAnC;;;;IAKqBC,c;;;;;;;;;;;;;;;;;;gEAGS,G;;2DACb,I;;2DACA,I;;2DACA,I;;gEACKC,IAAI,CAACC,IAAL,CAClB,MAAKC,IAAL,GAAY,MAAKA,IAAjB,GAAwB,MAAKC,IAAL,GAAY,MAAKA,IAAzC,GAAgD,MAAKC,IAAL,GAAY,MAAKA,IAD/C,C;;;;;;;WAIpB,wBAAqC;AACnC,kCAAwC,KAAKC,KAAL,CAAWC,cAAX,EAAxC;AAAA,UAAQC,aAAR,yBAAQA,aAAR;AAAA,UAAuBC,YAAvB,yBAAuBA,YAAvB;;AACA,UAAID,aAAJ,aAAIA,aAAJ,eAAIA,aAAa,CAAEE,MAAnB,EAA2B;AAGzB,aAAKC,UAAL,CAAgBC,OAAhB,CAAwB;AACtBC,UAAAA,GAAG,EAAE;AADiB,SAAxB;AAGA,aAAKC,SAAL,IAAkB,IAAlB;AAEA,aAAKV,IAAL,GAAY,EAAZ;A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A3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhDC,QAAAA,IAAI,EAAE7D,aAAa,CAAC8D,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,MADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEhE,EAAE,CAACiE,YAFJ;AAGNxB,YAAAA,IAAI,EAAE,EAHA;AAINmB,YAAAA,IAAI,EAAE5D,EAAE,CAACkE;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;;EAlKyCtE,S;;SAAvBE,c","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';\nimport { earthTriangulation } from '../../core/triangulation';\n\nimport baseFrag from '../shaders/base_frag.glsl';\nimport baseVert from '../shaders/base_vert.glsl';\n\nexport default class BaseEarthModel extends BaseModel {\n protected texture: ITexture2D;\n // T: 当前的地球时间 - 控制太阳的方位\n private earthTime: number = 3.4;\n private sunX = 1000;\n private sunY = 1000;\n private sunZ = 1000;\n private sunRadius = Math.sqrt(\n this.sunX * this.sunX + this.sunY * this.sunY + this.sunZ * this.sunZ,\n );\n\n public getUninforms(): IModelUniform {\n const { animateOption, globelOtions } = this.layer.getLayerConfig();\n if (animateOption?.enable) {\n // @ts-ignore\n // T: rotateY 方法只有在地球模式下存在\n this.mapService.rotateY({\n reg: 0.002,\n });\n this.earthTime += 0.02;\n\n this.sunY = 10;\n this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);\n this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);\n }\n\n return {\n u_ambientRatio: globelOtions?.ambientRatio || 0.6, // 环境光\n u_diffuseRatio: globelOtions?.diffuseRatio || 0.4, // 漫反射\n u_specularRatio: globelOtions?.specularRatio || 0.1, // 高光反射\n // u_sunLight: [120, 120, 120],\n u_sunLight: [this.sunX, this.sunY, this.sunZ],\n\n u_texture: this.texture,\n };\n }\n\n public setEarthTime(time: number) {\n this.earthTime = time;\n\n this.sunY = 10;\n this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);\n this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);\n\n this.layerService.renderLayers();\n }\n\n public initModels(): IModel[] {\n const { globelOtions } = this.layer.getLayerConfig();\n if (globelOtions?.earthTime !== undefined) {\n this.setEarthTime(globelOtions.earthTime);\n }\n\n const source = this.layer.getSource();\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n source.data.images.then((imageData: HTMLImageElement[]) => {\n this.texture = createTexture2D({\n data: imageData[0],\n width: imageData[0].width,\n height: imageData[0].height,\n });\n this.layerService.renderLayers();\n });\n\n return this.buildModels();\n }\n\n public clearModels() {\n return '';\n }\n\n public buildModels(): IModel[] {\n // TODO: 调整图层的绘制顺序 地球大气层\n this.layer.zIndex = -998;\n return [\n this.layer.buildLayerModel({\n moduleName: 'baseEarth',\n vertexShader: baseVert,\n fragmentShader: baseFrag,\n triangulation: earthTriangulation,\n depth: { enable: true },\n blend: this.getBlend(),\n }),\n ];\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n}\n"],"file":"base.js"}
@@ -1,9 +0,0 @@
1
- import { IModel, IModelUniform } from '@antv/l7-core';
2
- import BaseModel from '../../core/BaseModel';
3
- export default class EarthBloomSphereModel extends BaseModel {
4
- getUninforms(): IModelUniform;
5
- initModels(): IModel[];
6
- clearModels(): string;
7
- buildModels(): IModel[];
8
- protected registerBuiltinAttributes(): void;
9
- }
@@ -1,125 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _isNumber from "lodash/isNumber";
7
-
8
- 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); }; }
9
-
10
- 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; } }
11
-
12
- import { AttributeType, gl } from '@antv/l7-core';
13
- import BaseModel from '../../core/BaseModel';
14
- import { earthOuterTriangulation } from '../../core/triangulation';
15
- 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 // TODO: \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";
16
- 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";
17
-
18
- var EarthBloomSphereModel = function (_BaseModel) {
19
- _inherits(EarthBloomSphereModel, _BaseModel);
20
-
21
- var _super = _createSuper(EarthBloomSphereModel);
22
-
23
- function EarthBloomSphereModel() {
24
- _classCallCheck(this, EarthBloomSphereModel);
25
-
26
- return _super.apply(this, arguments);
27
- }
28
-
29
- _createClass(EarthBloomSphereModel, [{
30
- key: "getUninforms",
31
- value: function getUninforms() {
32
- var _ref = this.layer.getLayerConfig(),
33
- _ref$opacity = _ref.opacity,
34
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
35
-
36
- return {
37
- u_opacity: _isNumber(opacity) ? opacity : 1.0
38
- };
39
- }
40
- }, {
41
- key: "initModels",
42
- value: function initModels() {
43
- return this.buildModels();
44
- }
45
- }, {
46
- key: "clearModels",
47
- value: function clearModels() {
48
- return '';
49
- }
50
- }, {
51
- key: "buildModels",
52
- value: function buildModels() {
53
- this.layer.zIndex = -999;
54
- return [this.layer.buildLayerModel({
55
- moduleName: 'earthBloomSphere',
56
- vertexShader: bloomSphereVert,
57
- fragmentShader: bloomSphereFrag,
58
- triangulation: earthOuterTriangulation,
59
- depth: {
60
- enable: false
61
- },
62
- blend: this.getBlend()
63
- })];
64
- }
65
- }, {
66
- key: "registerBuiltinAttributes",
67
- value: function registerBuiltinAttributes() {
68
- this.styleAttributeService.registerStyleAttribute({
69
- name: 'size',
70
- type: AttributeType.Attribute,
71
- descriptor: {
72
- name: 'a_Size',
73
- buffer: {
74
- usage: gl.DYNAMIC_DRAW,
75
- data: [],
76
- type: gl.FLOAT
77
- },
78
- size: 1,
79
- update: function update(feature, featureIdx, vertex, attributeIdx) {
80
- var _feature$size = feature.size,
81
- size = _feature$size === void 0 ? 1 : _feature$size;
82
- return Array.isArray(size) ? [size[0]] : [size];
83
- }
84
- }
85
- });
86
- this.styleAttributeService.registerStyleAttribute({
87
- name: 'normal',
88
- type: AttributeType.Attribute,
89
- descriptor: {
90
- name: 'a_Normal',
91
- buffer: {
92
- usage: gl.STATIC_DRAW,
93
- data: [],
94
- type: gl.FLOAT
95
- },
96
- size: 3,
97
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
98
- return normal;
99
- }
100
- }
101
- });
102
- this.styleAttributeService.registerStyleAttribute({
103
- name: 'uv',
104
- type: AttributeType.Attribute,
105
- descriptor: {
106
- name: 'a_Uv',
107
- buffer: {
108
- usage: gl.DYNAMIC_DRAW,
109
- data: [],
110
- type: gl.FLOAT
111
- },
112
- size: 2,
113
- update: function update(feature, featureIdx, vertex, attributeIdx) {
114
- return [vertex[3], vertex[4]];
115
- }
116
- }
117
- });
118
- }
119
- }]);
120
-
121
- return EarthBloomSphereModel;
122
- }(BaseModel);
123
-
124
- export { EarthBloomSphereModel as default };
125
- //# sourceMappingURL=bloomsphere.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/earth/models/bloomsphere.ts"],"names":["AttributeType","gl","BaseModel","earthOuterTriangulation","EarthBloomSphereModel","layer","getLayerConfig","opacity","u_opacity","buildModels","zIndex","buildLayerModel","moduleName","vertexShader","bloomSphereVert","fragmentShader","bloomSphereFrag","triangulation","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","normal"],"mappings":";;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AASA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,uBAAT,QAAwC,0BAAxC;;;;IAOqBC,qB;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAEI,KAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;;AAGA,aAAO;AACLC,QAAAA,SAAS,EAAE,UAASD,OAAT,IAAoBA,OAApB,GAA8B;AADpC,OAAP;AAGD;;;WAED,sBAA8B;AAC5B,aAAO,KAAKE,WAAL,EAAP;AACD;;;WAED,uBAAqB;AACnB,aAAO,EAAP;AACD;;;WAED,uBAA+B;AAE7B,WAAKJ,KAAL,CAAWK,MAAX,GAAoB,CAAC,GAArB;AACA,aAAO,CACL,KAAKL,KAAL,CAAWM,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,kBADa;AAEzBC,QAAAA,YAAY,EAAEC,eAFW;AAGzBC,QAAAA,cAAc,EAAEC,eAHS;AAIzBC,QA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,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNI,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAwBA,WAAKpB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhDC,QAAAA,IAAI,EAAEzB,aAAa,CAAC0B,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,MADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE5B,EAAE,CAAC6B,YAFJ;AAGNC,YAAAA,IAAI,EAAE,EAHA;AAINN,YAAAA,IAAI,EAAExB,EAAE,CAAC+B;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;;EA3GgDnC,S;;SAA9BE,qB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { isNumber } from 'lodash';\n\nimport BaseModel from '../../core/BaseModel';\nimport { earthOuterTriangulation } from '../../core/triangulation';\nimport bloomSphereFrag from '../shaders/bloomsphere_frag.glsl';\nimport bloomSphereVert from '../shaders/bloomsphere_vert.glsl';\ninterface IBloomLayerStyleOptions {\n opacity: number;\n}\n\nexport default class EarthBloomSphereModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n } = this.layer.getLayerConfig() as IBloomLayerStyleOptions;\n return {\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public clearModels() {\n return '';\n }\n\n public buildModels(): IModel[] {\n // TODO: 调整图层的绘制顺序,让它保持在地球后面(减少锯齿现象)\n this.layer.zIndex = -999;\n return [\n this.layer.buildLayerModel({\n moduleName: 'earthBloomSphere',\n vertexShader: bloomSphereVert,\n fragmentShader: bloomSphereFrag,\n triangulation: earthOuterTriangulation,\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n }),\n ];\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n}\n"],"file":"bloomsphere.js"}
@@ -1,26 +0,0 @@
1
- export declare const EARTH_RADIUS = 100;
2
- export declare const EARTH_SEGMENTS = 36;
3
- export declare const EARTH_RADIUS_OUTER = 40;
4
- /**
5
- * 经纬度转xyz
6
- * @param longitude 经度
7
- * @param latitude 纬度
8
- * @param radius 半径
9
- */
10
- export declare function lglt2xyz(lnglat: [number, number]): number[];
11
- /**
12
- * 构建地球球体网格
13
- * @param radius
14
- * @param opt
15
- * @returns
16
- */
17
- export declare function primitiveSphere(radius: number, opt: {
18
- segments: number;
19
- }): {
20
- cells: number[][];
21
- positions: (number[] | Float32Array)[];
22
- uvs: number[][];
23
- positionsArr: number[];
24
- indicesArr: number[];
25
- normalArr: number[];
26
- };
package/es/earth/utils.js DELETED
@@ -1,81 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import { mat4, vec3 } from 'gl-matrix';
3
- export var EARTH_RADIUS = 100;
4
- export var EARTH_SEGMENTS = 36;
5
- export var EARTH_RADIUS_OUTER = 40;
6
-
7
- function torad(deg) {
8
- return deg / 180 * Math.acos(-1);
9
- }
10
-
11
- export function lglt2xyz(lnglat) {
12
- var lng = torad(lnglat[0]) + Math.PI / 2;
13
- var lat = torad(lnglat[1]);
14
- var radius = EARTH_RADIUS + Math.random() * 0.4;
15
- var z = radius * Math.cos(lat) * Math.cos(lng);
16
- var x = radius * Math.cos(lat) * Math.sin(lng);
17
- var y = radius * Math.sin(lat);
18
- return [x, y, z];
19
- }
20
- export function primitiveSphere(radius, opt) {
21
- var matRotY = mat4.create();
22
- var matRotZ = mat4.create();
23
- var up = vec3.fromValues(0, 1, 0);
24
- var tmpVec3 = vec3.fromValues(0, 0, 0);
25
- opt = opt || {};
26
- radius = typeof radius !== 'undefined' ? radius : 1;
27
- var segments = typeof opt.segments !== 'undefined' ? opt.segments : 32;
28
- var totalZRotationSteps = 2 + segments;
29
- var totalYRotationSteps = 2 * totalZRotationSteps;
30
- var indices = [];
31
- var indicesArr = [];
32
- var positions = [];
33
- var positionsArr = [];
34
- var normalArr = [];
35
- var uvs = [];
36
-
37
- for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
38
- var normalizedZ = zRotationStep / totalZRotationSteps;
39
- var angleZ = normalizedZ * Math.PI;
40
-
41
- for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
42
- var normalizedY = yRotationStep / totalYRotationSteps;
43
- var angleY = normalizedY * Math.PI * 2;
44
- mat4.identity(matRotZ);
45
- mat4.rotateZ(matRotZ, matRotZ, -angleZ);
46
- mat4.identity(matRotY);
47
- mat4.rotateY(matRotY, matRotY, angleY);
48
- vec3.transformMat4(tmpVec3, up, matRotZ);
49
- vec3.transformMat4(tmpVec3, tmpVec3, matRotY);
50
- vec3.scale(tmpVec3, tmpVec3, -radius);
51
- positions.push(tmpVec3.slice());
52
- positionsArr.push.apply(positionsArr, _toConsumableArray(tmpVec3.slice()));
53
- vec3.normalize(tmpVec3, tmpVec3);
54
- normalArr.push.apply(normalArr, _toConsumableArray(tmpVec3.slice()));
55
- uvs.push([normalizedY, 1 - normalizedZ]);
56
- positionsArr.push(normalizedY, 1 - normalizedZ);
57
- }
58
-
59
- if (zRotationStep > 0) {
60
- var verticesCount = positions.length;
61
- var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1);
62
-
63
- for (; firstIndex + totalYRotationSteps + 2 < verticesCount; firstIndex++) {
64
- indices.push([firstIndex, firstIndex + 1, firstIndex + totalYRotationSteps + 1]);
65
- indicesArr.push(firstIndex, firstIndex + 1, firstIndex + totalYRotationSteps + 1);
66
- indices.push([firstIndex + totalYRotationSteps + 1, firstIndex + 1, firstIndex + totalYRotationSteps + 2]);
67
- indicesArr.push(firstIndex + totalYRotationSteps + 1, firstIndex + 1, firstIndex + totalYRotationSteps + 2);
68
- }
69
- }
70
- }
71
-
72
- return {
73
- cells: indices,
74
- positions: positions,
75
- uvs: uvs,
76
- positionsArr: positionsArr,
77
- indicesArr: indicesArr,
78
- normalArr: normalArr
79
- };
80
- }
81
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/earth/utils.ts"],"names":["mat4","vec3","EARTH_RADIUS","EARTH_SEGMENTS","EARTH_RADIUS_OUTER","torad","deg","Math","acos","lglt2xyz","lnglat","lng","PI","lat","radius","random","z","cos","x","sin","y","primitiveSphere","opt","matRotY","create","matRotZ","up","fromValues","tmpVec3","segments","totalZRotationSteps","totalYRotationSteps","indices","indicesArr","positions","positionsArr","normalArr","uvs","zRotationStep","normalizedZ","angleZ","yRotationStep","normalizedY","angleY","identity","rotateZ","rotateY","transformMat4","scale","push","slice","normalize","verticesCount","length","firstIndex","cells"],"mappings":";AAAA,SAASA,IAAT,EAAeC,IAAf,QAA2B,WAA3B;AAIA,OAAO,IAAMC,YAAY,GAAG,GAArB;AACP,OAAO,IAAMC,cAAc,GAAG,EAAvB;AAEP,OAAO,IAAMC,kBAAkB,GAAG,EAA3B;;AAOP,SAASC,KAAT,CAAeC,GAAf,EAA4B;AAC1B,SAAQA,GAAG,GAAG,GAAP,GAAcC,IAAI,CAACC,IAAL,CAAU,CAAC,CAAX,CAArB;AACD;;AAOD,OAAO,SAASC,QAAT,CAAkBC,MAAlB,EAA4C;AAEjD,MAAMC,GAAG,GAAGN,KAAK,CAACK,MAAM,CAAC,CAAD,CAAP,CAAL,GAAmBH,IAAI,CAACK,EAAL,GAAU,CAAzC;AACA,MAAMC,GAAG,GAAGR,KAAK,CAACK,MAAM,CAAC,CAAD,CAAP,CAAjB;AAGA,MAAMI,MAAM,GAAGZ,YAAY,GAAGK,IAAI,CAACQ,MAAL,KAAgB,GAA9C;AAEA,MAAMC,CAAC,GAAGF,MAAM,GAAGP,IAAI,CAACU,GAAL,CAASJ,GAAT,CAAT,GAAyBN,IAAI,CAACU,GAAL,CAASN,GAAT,CAAnC;AACA,MAAMO,CAAC,GAAGJ,MAAM,GAAGP,IAAI,CAACU,GAAL,CAASJ,GAAT,CAAT,GAAyBN,IAAI,CAACY,GAAL,CAASR,GAAT,CAAnC;AACA,MAAMS,CAAC,GAAGN,MAAM,GAAGP,IAAI,CAACY,GAAL,CA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B,CAAjC;;AACA,aAEEuB,UAAU,GAAGvB,mBAAb,GAAmC,CAAnC,GAAuCqB,aAFzC,EAGEE,UAAU,EAHZ,EAIE;AACAtB,QAAAA,OAAO,CAACiB,IAAR,CAAa,CACXK,UADW,EAEXA,UAAU,GAAG,CAFF,EAGXA,UAAU,GAAGvB,mBAAb,GAAmC,CAHxB,CAAb;AAMAE,QAAAA,UAAU,CAACgB,IAAX,CACEK,UADF,EAEEA,UAAU,GAAG,CAFf,EAGEA,UAAU,GAAGvB,mBAAb,GAAmC,CAHrC;AAKAC,QAAAA,OAAO,CAACiB,IAAR,CAAa,CACXK,UAAU,GAAGvB,mBAAb,GAAmC,CADxB,EAEXuB,UAAU,GAAG,CAFF,EAGXA,UAAU,GAAGvB,mBAAb,GAAmC,CAHxB,CAAb;AAKAE,QAAAA,UAAU,CAACgB,IAAX,CACEK,UAAU,GAAGvB,mBAAb,GAAmC,CADrC,EAEEuB,UAAU,GAAG,CAFf,EAGEA,UAAU,GAAGvB,mBAAb,GAAmC,CAHrC;AAKD;AACF;AACF;;AAED,SAAO;AACLwB,IAAAA,KAAK,EAAEvB,OADF;AAELE,IAAAA,SAAS,EAATA,SAFK;AAGLG,IAAAA,GAAG,EAAHA,GAHK;AAILF,IAAAA,YAAY,EAAZA,YAJK;AAKLF,IAAAA,UAAU,EAAVA,UALK;AAMLG,IAAAA,SAAS,EAATA;AANK,GAAP;AAQD","sourcesContent":["import { mat4, vec3 } from 'gl-matrix';\n// 该文件专门记录地球模式的数值\n\n// 地球网格半径\nexport const EARTH_RADIUS = 100;\nexport const EARTH_SEGMENTS = 36;\n\nexport const EARTH_RADIUS_OUTER = 40;\n\n/**\n * 角度转弧度\n * @param deg\n * @returns\n */\nfunction torad(deg: number) {\n return (deg / 180) * Math.acos(-1);\n}\n/**\n * 经纬度转xyz\n * @param longitude 经度\n * @param latitude 纬度\n * @param radius 半径\n */\nexport function lglt2xyz(lnglat: [number, number]) {\n // TODO: + Math.PI/2 是为了对齐坐标\n const lng = torad(lnglat[0]) + Math.PI / 2;\n const lat = torad(lnglat[1]);\n\n // TODO: 手动增加一些偏移,减轻面的冲突\n const radius = EARTH_RADIUS + Math.random() * 0.4;\n\n const z = radius * Math.cos(lat) * Math.cos(lng);\n const x = radius * Math.cos(lat) * Math.sin(lng);\n const y = radius * Math.sin(lat);\n return [x, y, z];\n}\n\n/**\n * 构建地球球体网格\n * @param radius\n * @param opt\n * @returns\n */\nexport function primitiveSphere(\n radius: number,\n opt: {\n segments: number;\n },\n) {\n const matRotY = mat4.create();\n const matRotZ = mat4.create();\n const up = vec3.fromValues(0, 1, 0);\n const tmpVec3 = vec3.fromValues(0, 0, 0);\n\n opt = opt || {};\n radius = typeof radius !== 'undefined' ? radius : 1;\n const segments = typeof opt.segments !== 'undefined' ? opt.segments : 32;\n\n const totalZRotationSteps = 2 + segments;\n const totalYRotationSteps = 2 * totalZRotationSteps;\n\n const indices = [];\n const indicesArr = [];\n const positions = [];\n const positionsArr = [];\n const normalArr = [];\n const uvs = [];\n\n for (\n let zRotationStep = 0;\n zRotationStep <= totalZRotationSteps;\n zRotationStep++\n ) {\n const normalizedZ = zRotationStep / totalZRotationSteps;\n const angleZ = normalizedZ * Math.PI;\n\n for (\n let yRotationStep = 0;\n yRotationStep <= totalYRotationSteps;\n yRotationStep++\n ) {\n const normalizedY = yRotationStep / totalYRotationSteps;\n const angleY = normalizedY * Math.PI * 2;\n\n mat4.identity(matRotZ);\n mat4.rotateZ(matRotZ, matRotZ, -angleZ);\n\n mat4.identity(matRotY);\n mat4.rotateY(matRotY, matRotY, angleY);\n\n vec3.transformMat4(tmpVec3, up, matRotZ);\n vec3.transformMat4(tmpVec3, tmpVec3, matRotY);\n\n vec3.scale(tmpVec3, tmpVec3, -radius);\n\n positions.push(tmpVec3.slice());\n positionsArr.push(...tmpVec3.slice());\n\n vec3.normalize(tmpVec3, tmpVec3);\n normalArr.push(...tmpVec3.slice());\n\n uvs.push([normalizedY, 1 - normalizedZ]);\n\n // position 和 uv 一起存储\n positionsArr.push(normalizedY, 1 - normalizedZ);\n }\n\n if (zRotationStep > 0) {\n const verticesCount = positions.length;\n let firstIndex = verticesCount - 2 * (totalYRotationSteps + 1);\n for (\n ;\n firstIndex + totalYRotationSteps + 2 < verticesCount;\n firstIndex++\n ) {\n indices.push([\n firstIndex,\n firstIndex + 1,\n firstIndex + totalYRotationSteps + 1,\n ]);\n\n indicesArr.push(\n firstIndex,\n firstIndex + 1,\n firstIndex + totalYRotationSteps + 1,\n );\n indices.push([\n firstIndex + totalYRotationSteps + 1,\n firstIndex + 1,\n firstIndex + totalYRotationSteps + 2,\n ]);\n indicesArr.push(\n firstIndex + totalYRotationSteps + 1,\n firstIndex + 1,\n firstIndex + totalYRotationSteps + 2,\n );\n }\n }\n }\n\n return {\n cells: indices,\n positions,\n uvs,\n positionsArr,\n indicesArr,\n normalArr,\n };\n}\n"],"file":"utils.js"}
package/es/glsl.d.js DELETED
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=glsl.d.js.map
package/es/glsl.d.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"glsl.d.js"}
@@ -1,22 +0,0 @@
1
- import BaseLayer from '../core/BaseLayer';
2
- import { HeatMapModelType } from './models';
3
- interface IHeatMapLayerStyleOptions {
4
- opacity: number;
5
- }
6
- export default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {
7
- type: string;
8
- buildModels(): void;
9
- rebuildModels(): void;
10
- renderModels(): this;
11
- protected getConfigSchema(): {
12
- properties: {
13
- opacity: {
14
- type: string;
15
- minimum: number;
16
- maximum: number;
17
- };
18
- };
19
- };
20
- protected getModelType(): HeatMapModelType;
21
- }
22
- export {};
@@ -1,123 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
-
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
-
13
- import BaseLayer from '../core/BaseLayer';
14
- import HeatMapModels from './models';
15
-
16
- var HeatMapLayer = function (_BaseLayer) {
17
- _inherits(HeatMapLayer, _BaseLayer);
18
-
19
- var _super = _createSuper(HeatMapLayer);
20
-
21
- function HeatMapLayer() {
22
- var _this;
23
-
24
- _classCallCheck(this, HeatMapLayer);
25
-
26
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
- args[_key] = arguments[_key];
28
- }
29
-
30
- _this = _super.call.apply(_super, [this].concat(args));
31
-
32
- _defineProperty(_assertThisInitialized(_this), "type", 'HeatMapLayer');
33
-
34
- return _this;
35
- }
36
-
37
- _createClass(HeatMapLayer, [{
38
- key: "buildModels",
39
- value: function buildModels() {
40
- var shape = this.getModelType();
41
- this.layerModel = new HeatMapModels[shape](this);
42
- this.models = this.layerModel.initModels();
43
- }
44
- }, {
45
- key: "rebuildModels",
46
- value: function rebuildModels() {
47
- this.models = this.layerModel.buildModels();
48
- }
49
- }, {
50
- key: "renderModels",
51
- value: function renderModels() {
52
- var _this2 = this;
53
-
54
- var shape = this.getModelType();
55
-
56
- if (shape === 'heatmap') {
57
- if (this.layerModel) {
58
- this.layerModel.render();
59
- }
60
-
61
- return this;
62
- }
63
-
64
- if (this.layerModelNeedUpdate) {
65
- this.models = this.layerModel.buildModels();
66
- this.layerModelNeedUpdate = false;
67
- }
68
-
69
- this.models.forEach(function (model) {
70
- return model.draw({
71
- uniforms: _this2.layerModel.getUninforms()
72
- });
73
- });
74
- return this;
75
- }
76
- }, {
77
- key: "getConfigSchema",
78
- value: function getConfigSchema() {
79
- return {
80
- properties: {
81
- opacity: {
82
- type: 'number',
83
- minimum: 0,
84
- maximum: 1
85
- }
86
- }
87
- };
88
- }
89
- }, {
90
- key: "getModelType",
91
- value: function getModelType() {
92
- var _shapeAttribute$scale;
93
-
94
- var shapeAttribute = this.styleAttributeService.getLayerStyleAttribute('shape');
95
-
96
- var _this$getLayerConfig = this.getLayerConfig(),
97
- shape3d = _this$getLayerConfig.shape3d;
98
-
99
- var source = this.getSource();
100
- var sourceType = source.data.type;
101
- var shape = (shapeAttribute === null || shapeAttribute === void 0 ? void 0 : (_shapeAttribute$scale = shapeAttribute.scale) === null || _shapeAttribute$scale === void 0 ? void 0 : _shapeAttribute$scale.field) || 'heatmap';
102
-
103
- if (shape === 'heatmap' || shape === 'heatmap3d') {
104
- return 'heatmap';
105
- }
106
-
107
- if (sourceType === 'hexagon') {
108
- return (shape3d === null || shape3d === void 0 ? void 0 : shape3d.indexOf(shape)) === -1 ? 'hexagon' : 'grid3d';
109
- }
110
-
111
- if (sourceType === 'grid') {
112
- return (shape3d === null || shape3d === void 0 ? void 0 : shape3d.indexOf(shape)) === -1 ? 'grid' : 'grid3d';
113
- }
114
-
115
- return 'heatmap';
116
- }
117
- }]);
118
-
119
- return HeatMapLayer;
120
- }(BaseLayer);
121
-
122
- export { HeatMapLayer as default };
123
- //# sourceMappingURL=index.js.map