@antv/l7-layers 2.5.37 → 2.5.41

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 (69) hide show
  1. package/es/core/BaseLayer.d.ts +3 -1
  2. package/es/core/BaseLayer.js +6 -1
  3. package/es/core/BaseLayer.js.map +1 -1
  4. package/es/imagetile/index.d.ts +22 -0
  5. package/es/imagetile/index.js +82 -0
  6. package/es/imagetile/index.js.map +1 -0
  7. package/es/imagetile/models/imagetile.d.ts +11 -0
  8. package/es/imagetile/models/imagetile.js +160 -0
  9. package/es/imagetile/models/imagetile.js.map +1 -0
  10. package/es/imagetile/models/index.d.ts +5 -0
  11. package/es/imagetile/models/index.js +6 -0
  12. package/es/imagetile/models/index.js.map +1 -0
  13. package/es/imagetile/utils/ImageTile.d.ts +20 -0
  14. package/es/imagetile/utils/ImageTile.js +90 -0
  15. package/es/imagetile/utils/ImageTile.js.map +1 -0
  16. package/es/imagetile/utils/Tile.d.ts +27 -0
  17. package/es/imagetile/utils/Tile.js +321 -0
  18. package/es/imagetile/utils/Tile.js.map +1 -0
  19. package/es/imagetile/utils/lruCache.d.ts +20 -0
  20. package/es/imagetile/utils/lruCache.js +105 -0
  21. package/es/imagetile/utils/lruCache.js.map +1 -0
  22. package/es/imagetile/utils/tileCache.d.ts +8 -0
  23. package/es/imagetile/utils/tileCache.js +50 -0
  24. package/es/imagetile/utils/tileCache.js.map +1 -0
  25. package/es/index.d.ts +2 -1
  26. package/es/index.js +2 -1
  27. package/es/index.js.map +1 -1
  28. package/es/line/index.d.ts +2 -0
  29. package/es/line/index.js +3 -0
  30. package/es/line/index.js.map +1 -1
  31. package/es/line/models/arc.js +2 -2
  32. package/es/line/models/arc_3d.js +2 -2
  33. package/es/line/models/arcmini.d.ts +9 -0
  34. package/es/line/models/arcmini.js +144 -0
  35. package/es/line/models/arcmini.js.map +1 -0
  36. package/es/line/models/great_circle.js +2 -2
  37. package/es/line/models/index.d.ts +1 -1
  38. package/es/line/models/index.js +2 -0
  39. package/es/line/models/index.js.map +1 -1
  40. package/es/line/models/line.js +2 -2
  41. package/lib/core/BaseLayer.js +4 -1
  42. package/lib/core/BaseLayer.js.map +1 -1
  43. package/lib/imagetile/index.js +95 -0
  44. package/lib/imagetile/index.js.map +1 -0
  45. package/lib/imagetile/models/imagetile.js +177 -0
  46. package/lib/imagetile/models/imagetile.js.map +1 -0
  47. package/lib/imagetile/models/index.js +17 -0
  48. package/lib/imagetile/models/index.js.map +1 -0
  49. package/lib/imagetile/utils/ImageTile.js +99 -0
  50. package/lib/imagetile/utils/ImageTile.js.map +1 -0
  51. package/lib/imagetile/utils/Tile.js +324 -0
  52. package/lib/imagetile/utils/Tile.js.map +1 -0
  53. package/lib/imagetile/utils/lruCache.js +109 -0
  54. package/lib/imagetile/utils/lruCache.js.map +1 -0
  55. package/lib/imagetile/utils/tileCache.js +58 -0
  56. package/lib/imagetile/utils/tileCache.js.map +1 -0
  57. package/lib/index.js +8 -0
  58. package/lib/index.js.map +1 -1
  59. package/lib/line/index.js +3 -0
  60. package/lib/line/index.js.map +1 -1
  61. package/lib/line/models/arc.js +2 -2
  62. package/lib/line/models/arc_3d.js +2 -2
  63. package/lib/line/models/arcmini.js +160 -0
  64. package/lib/line/models/arcmini.js.map +1 -0
  65. package/lib/line/models/great_circle.js +2 -2
  66. package/lib/line/models/index.js +3 -0
  67. package/lib/line/models/index.js.map +1 -1
  68. package/lib/line/models/line.js +2 -2
  69. package/package.json +6 -5
@@ -0,0 +1,50 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import LRUCache from './lruCache';
5
+
6
+ var TileCache = function () {
7
+ function TileCache() {
8
+ var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 50;
9
+ var tileDestroy = arguments.length > 1 ? arguments[1] : undefined;
10
+
11
+ _classCallCheck(this, TileCache);
12
+
13
+ _defineProperty(this, "cache", void 0);
14
+
15
+ this.cache = new LRUCache(limit, tileDestroy);
16
+ }
17
+
18
+ _createClass(TileCache, [{
19
+ key: "getTile",
20
+ value: function getTile(key) {
21
+ return this.cache.get(key);
22
+ }
23
+ }, {
24
+ key: "setTile",
25
+ value: function setTile(tile, key) {
26
+ this.cache.set(key, tile);
27
+ }
28
+ }, {
29
+ key: "destory",
30
+ value: function destory() {
31
+ this.cache.clear();
32
+ }
33
+ }, {
34
+ key: "setNeedUpdate",
35
+ value: function setNeedUpdate() {
36
+ var _this = this;
37
+
38
+ this.cache.order.forEach(function (key) {
39
+ var tile = _this.cache.get(key);
40
+
41
+ tile.needUpdate = true;
42
+ });
43
+ }
44
+ }]);
45
+
46
+ return TileCache;
47
+ }();
48
+
49
+ export { TileCache as default };
50
+ //# sourceMappingURL=tileCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/imagetile/utils/tileCache.ts"],"names":["LRUCache","TileCache","limit","tileDestroy","cache","key","get","tile","set","clear","order","forEach","needUpdate"],"mappings":";;;AAAA,OAAOA,QAAP,MAAqB,YAArB;;IACqBC,S;AAEnB,uBAA0C;AAAA,QAA9BC,KAA8B,uEAAtB,EAAsB;AAAA,QAAlBC,WAAkB;;AAAA;;AAAA;;AACxC,SAAKC,KAAL,GAAa,IAAIJ,QAAJ,CAAaE,KAAb,EAAoBC,WAApB,CAAb;AACD;;;;WAED,iBAAeE,GAAf,EAA4B;AAC1B,aAAO,KAAKD,KAAL,CAAWE,GAAX,CAAeD,GAAf,CAAP;AACD;;;WAED,iBAAeE,IAAf,EAA0BF,GAA1B,EAAuC;AACrC,WAAKD,KAAL,CAAWI,GAAX,CAAeH,GAAf,EAAoBE,IAApB;AACD;;;WACD,mBAAiB;AACf,WAAKH,KAAL,CAAWK,KAAX;AACD;;;WACD,yBAAuB;AAAA;;AACrB,WAAKL,KAAL,CAAWM,KAAX,CAAiBC,OAAjB,CAAyB,UAACN,GAAD,EAAiB;AACxC,YAAME,IAAI,GAAG,KAAI,CAACH,KAAL,CAAWE,GAAX,CAAeD,GAAf,CAAb;;AACAE,QAAAA,IAAI,CAACK,UAAL,GAAkB,IAAlB;AACD,OAHD;AAID;;;;;;SArBkBX,S","sourcesContent":["import LRUCache from './lruCache';\nexport default class TileCache {\n public cache: any;\n constructor(limit = 50, tileDestroy: any) {\n this.cache = new LRUCache(limit, tileDestroy);\n }\n\n public getTile(key: string) {\n return this.cache.get(key);\n }\n\n public setTile(tile: any, key: string) {\n this.cache.set(key, tile);\n }\n public destory() {\n this.cache.clear();\n }\n public setNeedUpdate() {\n this.cache.order.forEach((key: string) => {\n const tile = this.cache.get(key);\n tile.needUpdate = true;\n });\n }\n}\n"],"file":"tileCache.js"}
package/es/index.d.ts CHANGED
@@ -3,9 +3,10 @@ import BaseLayer from './core/BaseLayer';
3
3
  import './glsl.d';
4
4
  import HeatmapLayer from './heatmap';
5
5
  import ImageLayer from './image';
6
+ import ImageTileLayer from './imagetile';
6
7
  import LineLayer from './line/index';
7
8
  import PointLayer from './point';
8
9
  import PolygonLayer from './polygon';
9
10
  import RasterLayer from './raster';
10
11
  import EarthLayer from './earth';
11
- export { BaseLayer, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, ImageLayer, RasterLayer, HeatmapLayer, EarthLayer, };
12
+ export { BaseLayer, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, ImageLayer, ImageTileLayer, RasterLayer, HeatmapLayer, EarthLayer, };
package/es/index.js CHANGED
@@ -4,6 +4,7 @@ import BaseLayer from './core/BaseLayer';
4
4
  import './glsl.d';
5
5
  import HeatmapLayer from './heatmap';
6
6
  import ImageLayer from './image';
7
+ import ImageTileLayer from './imagetile';
7
8
  import LineLayer from './line/index';
8
9
  import PointLayer from './point';
9
10
  import PolygonLayer from './polygon';
@@ -35,5 +36,5 @@ container.bind(TYPES.ILayerPlugin).to(LayerAnimateStylePlugin).inRequestScope();
35
36
  container.bind(TYPES.ILayerPlugin).to(LightingPlugin).inRequestScope();
36
37
  container.bind(TYPES.ILayerPlugin).to(PixelPickingPlugin).inRequestScope();
37
38
  container.bind(TYPES.ILayerPlugin).to(LayerModelPlugin).inRequestScope();
38
- export { BaseLayer, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, ImageLayer, RasterLayer, HeatmapLayer, EarthLayer };
39
+ export { BaseLayer, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, ImageLayer, ImageTileLayer, RasterLayer, HeatmapLayer, EarthLayer };
39
40
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["container","TYPES","CityBuildingLayer","BaseLayer","HeatmapLayer","ImageLayer","LineLayer","PointLayer","PolygonLayer","RasterLayer","EarthLayer","DataMappingPlugin","DataSourcePlugin","FeatureScalePlugin","LayerAnimateStylePlugin","LayerModelPlugin","LayerStylePlugin","LightingPlugin","MultiPassRendererPlugin","PixelPickingPlugin","RegisterStyleAttributePlugin","ShaderUniformPlugin","UpdateModelPlugin","UpdateStyleAttributePlugin","bind","ILayerPlugin","to","inRequestScope"],"mappings":"AAAA,SAASA,SAAT,EAAkCC,KAAlC,QAA+C,eAA/C;AACA,OAAOC,iBAAP,MAA8B,yBAA9B;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAO,UAAP;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,WAAP,MAAwB,UAAxB;AAEA,OAAOC,UAAP,MAAuB,SAAvB;AAGA,OAAOC,iBAAP,MAA8B,6BAA9B;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,kBAAP,MAA+B,8BAA/B;AACA,OAAOC,uBAAP,MAAoC,mCAApC;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,uBAAP,MAAoC,mCAApC;AACA,OAAOC,kBAAP,MAA+B,8BAA/B;AACA,OAAOC,4BAAP,MAAyC,wCAAzC;AACA,OAAOC,mBAAP,MAAgC,+BAAhC;AACA,OAAOC,iBAAP,MAA8B,6BAA9B;AACA,OAAOC,0BAAP,MAAuC,sCAAvC;AAYAvB,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMd,gBAFN,EAGGe,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMN,4BAFN,EAGGO,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMb,kBAFN,EAGGc,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMf,iBAFN,EAGGgB,cAHH;AAQA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMV,gBAFN,EAGGW,cAHH;AAQA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMH,0BAFN,EAGGI,cAHH;AAQA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMJ,iBAFN,EAGGK,cAHH;AAQA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMR,uBAFN,EAGGS,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEML,mBAFN,EAGGM,cAHH;AAQA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMZ,uBAFN,EAGGa,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMT,cAFN,EAGGU,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMP,kBAFN,EAGGQ,cAHH;AAOA3B,SAAS,CACNwB,IADH,CACsBvB,KAAK,CAACwB,YAD5B,EAEGC,EAFH,CAEMX,gBAFN,EAGGY,cAHH;AAKA,SACExB,SADF,EAEEI,UAFF,EAGEC,YAHF,EAIEF,SAJF,EAKEJ,iBALF,EAMEG,UANF,EAOEI,WAPF,EAQEL,YARF,EASEM,UATF","sourcesContent":["import { container, ILayerPlugin, TYPES } from '@antv/l7-core';\nimport CityBuildingLayer from './citybuliding/building';\nimport BaseLayer from './core/BaseLayer';\nimport './glsl.d';\nimport HeatmapLayer from './heatmap';\nimport ImageLayer from './image';\nimport LineLayer from './line/index';\nimport PointLayer from './point';\nimport PolygonLayer from './polygon';\nimport RasterLayer from './raster';\n\nimport EarthLayer from './earth';\n\n// import ConfigSchemaValidationPlugin from './plugins/ConfigSchemaValidationPlugin';\nimport DataMappingPlugin from './plugins/DataMappingPlugin';\nimport DataSourcePlugin from './plugins/DataSourcePlugin';\nimport FeatureScalePlugin from './plugins/FeatureScalePlugin';\nimport LayerAnimateStylePlugin from './plugins/LayerAnimateStylePlugin';\nimport LayerModelPlugin from './plugins/LayerModelPlugin';\nimport LayerStylePlugin from './plugins/LayerStylePlugin';\nimport LightingPlugin from './plugins/LightingPlugin';\nimport MultiPassRendererPlugin from './plugins/MultiPassRendererPlugin';\nimport PixelPickingPlugin from './plugins/PixelPickingPlugin';\nimport RegisterStyleAttributePlugin from './plugins/RegisterStyleAttributePlugin';\nimport ShaderUniformPlugin from './plugins/ShaderUniformPlugin';\nimport UpdateModelPlugin from './plugins/UpdateModelPlugin';\nimport UpdateStyleAttributePlugin from './plugins/UpdateStyleAttributePlugin';\n/**\n * 校验传入参数配置项的正确性\n * @see /dev-docs/ConfigSchemaValidation.md\n */\n// container\n// .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n// .to(ConfigSchemaValidationPlugin)\n// .inRequestScope();\n/**\n * 获取 Source\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(DataSourcePlugin)\n .inRequestScope();\n/**\n * 根据 StyleAttribute 创建 VertexAttribute\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(RegisterStyleAttributePlugin)\n .inRequestScope();\n/**\n * 根据 Source 创建 Scale\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(FeatureScalePlugin)\n .inRequestScope();\n/**\n * 使用 Scale 进行数据映射\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(DataMappingPlugin)\n .inRequestScope();\n\n/**\n * 更新地图样式配置项 如active, show, hide\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LayerStylePlugin)\n .inRequestScope();\n\n/**\n * 负责属性更新\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(UpdateStyleAttributePlugin)\n .inRequestScope();\n\n/**\n * 负责Model更新\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(UpdateModelPlugin)\n .inRequestScope();\n\n/**\n * Multi Pass 自定义渲染管线\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(MultiPassRendererPlugin)\n .inRequestScope();\n/**\n * 传入相机坐标系参数\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(ShaderUniformPlugin)\n .inRequestScope();\n\n/**\n * 传入动画参数\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LayerAnimateStylePlugin)\n .inRequestScope();\n/**\n * 传入光照相关参数\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LightingPlugin)\n .inRequestScope();\n/**\n * 负责拾取过程中 Encode 以及 Highlight 阶段及结束后恢复\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(PixelPickingPlugin)\n .inRequestScope();\n/**\n * 初始化Model\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LayerModelPlugin)\n .inRequestScope();\n\nexport {\n BaseLayer,\n PointLayer,\n PolygonLayer,\n LineLayer,\n CityBuildingLayer,\n ImageLayer,\n RasterLayer,\n HeatmapLayer,\n EarthLayer,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["container","TYPES","CityBuildingLayer","BaseLayer","HeatmapLayer","ImageLayer","ImageTileLayer","LineLayer","PointLayer","PolygonLayer","RasterLayer","EarthLayer","DataMappingPlugin","DataSourcePlugin","FeatureScalePlugin","LayerAnimateStylePlugin","LayerModelPlugin","LayerStylePlugin","LightingPlugin","MultiPassRendererPlugin","PixelPickingPlugin","RegisterStyleAttributePlugin","ShaderUniformPlugin","UpdateModelPlugin","UpdateStyleAttributePlugin","bind","ILayerPlugin","to","inRequestScope"],"mappings":"AAAA,SAASA,SAAT,EAAkCC,KAAlC,QAA+C,eAA/C;AACA,OAAOC,iBAAP,MAA8B,yBAA9B;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAO,UAAP;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,cAAP,MAA2B,aAA3B;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,WAAP,MAAwB,UAAxB;AAEA,OAAOC,UAAP,MAAuB,SAAvB;AAGA,OAAOC,iBAAP,MAA8B,6BAA9B;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,kBAAP,MAA+B,8BAA/B;AACA,OAAOC,uBAAP,MAAoC,mCAApC;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,uBAAP,MAAoC,mCAApC;AACA,OAAOC,kBAAP,MAA+B,8BAA/B;AACA,OAAOC,4BAAP,MAAyC,wCAAzC;AACA,OAAOC,mBAAP,MAAgC,+BAAhC;AACA,OAAOC,iBAAP,MAA8B,6BAA9B;AACA,OAAOC,0BAAP,MAAuC,sCAAvC;AAaAxB,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMd,gBAFN,EAGGe,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMN,4BAFN,EAGGO,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMb,kBAFN,EAGGc,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMf,iBAFN,EAGGgB,cAHH;AAQA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMV,gBAFN,EAGGW,cAHH;AAQA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMH,0BAFN,EAGGI,cAHH;AAQA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMJ,iBAFN,EAGGK,cAHH;AAQA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMR,uBAFN,EAGGS,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEML,mBAFN,EAGGM,cAHH;AAQA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMZ,uBAFN,EAGGa,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMT,cAFN,EAGGU,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMP,kBAFN,EAGGQ,cAHH;AAOA5B,SAAS,CACNyB,IADH,CACsBxB,KAAK,CAACyB,YAD5B,EAEGC,EAFH,CAEMX,gBAFN,EAGGY,cAHH;AAKA,SACEzB,SADF,EAEEK,UAFF,EAGEC,YAHF,EAIEF,SAJF,EAKEL,iBALF,EAMEG,UANF,EAOEC,cAPF,EAQEI,WARF,EASEN,YATF,EAUEO,UAVF","sourcesContent":["import { container, ILayerPlugin, TYPES } from '@antv/l7-core';\nimport CityBuildingLayer from './citybuliding/building';\nimport BaseLayer from './core/BaseLayer';\nimport './glsl.d';\nimport HeatmapLayer from './heatmap';\nimport ImageLayer from './image';\nimport ImageTileLayer from './imagetile';\nimport LineLayer from './line/index';\nimport PointLayer from './point';\nimport PolygonLayer from './polygon';\nimport RasterLayer from './raster';\n\nimport EarthLayer from './earth';\n\n// import ConfigSchemaValidationPlugin from './plugins/ConfigSchemaValidationPlugin';\nimport DataMappingPlugin from './plugins/DataMappingPlugin';\nimport DataSourcePlugin from './plugins/DataSourcePlugin';\nimport FeatureScalePlugin from './plugins/FeatureScalePlugin';\nimport LayerAnimateStylePlugin from './plugins/LayerAnimateStylePlugin';\nimport LayerModelPlugin from './plugins/LayerModelPlugin';\nimport LayerStylePlugin from './plugins/LayerStylePlugin';\nimport LightingPlugin from './plugins/LightingPlugin';\nimport MultiPassRendererPlugin from './plugins/MultiPassRendererPlugin';\nimport PixelPickingPlugin from './plugins/PixelPickingPlugin';\nimport RegisterStyleAttributePlugin from './plugins/RegisterStyleAttributePlugin';\nimport ShaderUniformPlugin from './plugins/ShaderUniformPlugin';\nimport UpdateModelPlugin from './plugins/UpdateModelPlugin';\nimport UpdateStyleAttributePlugin from './plugins/UpdateStyleAttributePlugin';\n\n/**\n * 校验传入参数配置项的正确性\n * @see /dev-docs/ConfigSchemaValidation.md\n */\n// container\n// .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n// .to(ConfigSchemaValidationPlugin)\n// .inRequestScope();\n/**\n * 获取 Source\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(DataSourcePlugin)\n .inRequestScope();\n/**\n * 根据 StyleAttribute 创建 VertexAttribute\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(RegisterStyleAttributePlugin)\n .inRequestScope();\n/**\n * 根据 Source 创建 Scale\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(FeatureScalePlugin)\n .inRequestScope();\n/**\n * 使用 Scale 进行数据映射\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(DataMappingPlugin)\n .inRequestScope();\n\n/**\n * 更新地图样式配置项 如active, show, hide\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LayerStylePlugin)\n .inRequestScope();\n\n/**\n * 负责属性更新\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(UpdateStyleAttributePlugin)\n .inRequestScope();\n\n/**\n * 负责Model更新\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(UpdateModelPlugin)\n .inRequestScope();\n\n/**\n * Multi Pass 自定义渲染管线\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(MultiPassRendererPlugin)\n .inRequestScope();\n/**\n * 传入相机坐标系参数\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(ShaderUniformPlugin)\n .inRequestScope();\n\n/**\n * 传入动画参数\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LayerAnimateStylePlugin)\n .inRequestScope();\n/**\n * 传入光照相关参数\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LightingPlugin)\n .inRequestScope();\n/**\n * 负责拾取过程中 Encode 以及 Highlight 阶段及结束后恢复\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(PixelPickingPlugin)\n .inRequestScope();\n/**\n * 初始化Model\n */\ncontainer\n .bind<ILayerPlugin>(TYPES.ILayerPlugin)\n .to(LayerModelPlugin)\n .inRequestScope();\n\nexport {\n BaseLayer,\n PointLayer,\n PolygonLayer,\n LineLayer,\n CityBuildingLayer,\n ImageLayer,\n ImageTileLayer,\n RasterLayer,\n HeatmapLayer,\n EarthLayer,\n};\n"],"file":"index.js"}
@@ -20,6 +20,8 @@ export default class LineLayer extends BaseLayer<ILineLayerStyleOptions> {
20
20
  blend: string;
21
21
  } | {
22
22
  blend: string;
23
+ } | {
24
+ blend: string;
23
25
  };
24
26
  protected getModelType(): LineModelType;
25
27
  }
package/es/line/index.js CHANGED
@@ -71,6 +71,9 @@ var LineLayer = function (_BaseLayer) {
71
71
  arc: {
72
72
  blend: 'additive'
73
73
  },
74
+ arcmini: {
75
+ blend: 'additive'
76
+ },
74
77
  greatcircle: {
75
78
  blend: 'additive'
76
79
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/line/index.ts"],"names":["BaseLayer","LineModels","LineLayer","shape","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","line","arc3d","blend","arc","greatcircle","shapeAttribute","styleAttributeService","getLayerStyleAttribute","scale","field"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,UAAP,MAA0C,UAA1C;;IAEqBC,S;;;;;;;;;;;;;;;;2DACG,W;;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIJ,UAAU,CAACE,KAAD,CAAd,CAAsB,IAAtB,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKP,YAAL,EAAb;AACA,UAAMU,aAAa,GAAG;AACpBC,QAAAA,IAAI,EAAE,EADc;AAEpBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,KAAK,EAAE;AAAT,SAFa;AAGpBC,QAAAA,GAAG,EAAE;AAAED,UAAAA,KAAK,EAAE;AAAT,SAHe;AAIpBE,QAAAA,WAAW,EAAE;AAAEF,UAAAA,KAAK,EAAE;AAAT;AAJO,OAAtB;AAMA,aAAOH,aAAa,CAACH,IAAD,CAApB;AACD;;;WACD,wBAAwC;AAAA;;AACtC,UAAMS,cAAc,GAAG,KAAKC,qBAAL,CAA2BC,sBAA3B,CACrB,OADqB,CAAvB;AAGA,UAAMnB,KAAK,GAAGiB,cAAH,aAAGA,cAAH,gDAAGA,cAAc,CAAEG,KAAnB,0DAAG,sBAAuBC,KAArC;AACA,aAAOrB,KAAK,IAAI,MAAhB;AACD;;;;EAvCoCH,S;;SAAlBE,S","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { ILineLayerStyleOptions } from '../core/interface';\nimport LineModels, { LineModelType } from './models';\n\nexport default class LineLayer extends BaseLayer<ILineLayerStyleOptions> {\n public type: string = 'LineLayer';\n\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new LineModels[shape](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n protected getDefaultConfig() {\n const type = this.getModelType();\n const defaultConfig = {\n line: {},\n arc3d: { blend: 'additive' },\n arc: { blend: 'additive' },\n greatcircle: { blend: 'additive' },\n };\n return defaultConfig[type];\n }\n protected getModelType(): LineModelType {\n const shapeAttribute = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shape = shapeAttribute?.scale?.field as LineModelType;\n return shape || 'line';\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/line/index.ts"],"names":["BaseLayer","LineModels","LineLayer","shape","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","line","arc3d","blend","arc","arcmini","greatcircle","shapeAttribute","styleAttributeService","getLayerStyleAttribute","scale","field"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,UAAP,MAA0C,UAA1C;;IAEqBC,S;;;;;;;;;;;;;;;;2DACG,W;;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIJ,UAAU,CAACE,KAAD,CAAd,CAAsB,IAAtB,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKP,YAAL,EAAb;AACA,UAAMU,aAAa,GAAG;AACpBC,QAAAA,IAAI,EAAE,EADc;AAEpBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,KAAK,EAAE;AAAT,SAFa;AAGpBC,QAAAA,GAAG,EAAE;AAAED,UAAAA,KAAK,EAAE;AAAT,SAHe;AAIpBE,QAAAA,OAAO,EAAE;AAAEF,UAAAA,KAAK,EAAE;AAAT,SAJW;AAKpBG,QAAAA,WAAW,EAAE;AAAEH,UAAAA,KAAK,EAAE;AAAT;AALO,OAAtB;AAOA,aAAOH,aAAa,CAACH,IAAD,CAApB;AACD;;;WACD,wBAAwC;AAAA;;AACtC,UAAMU,cAAc,GAAG,KAAKC,qBAAL,CAA2BC,sBAA3B,CACrB,OADqB,CAAvB;AAGA,UAAMpB,KAAK,GAAGkB,cAAH,aAAGA,cAAH,gDAAGA,cAAc,CAAEG,KAAnB,0DAAG,sBAAuBC,KAArC;AACA,aAAOtB,KAAK,IAAI,MAAhB;AACD;;;;EAxCoCH,S;;SAAlBE,S","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { ILineLayerStyleOptions } from '../core/interface';\nimport LineModels, { LineModelType } from './models';\n\nexport default class LineLayer extends BaseLayer<ILineLayerStyleOptions> {\n public type: string = 'LineLayer';\n\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new LineModels[shape](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n protected getDefaultConfig() {\n const type = this.getModelType();\n const defaultConfig = {\n line: {},\n arc3d: { blend: 'additive' },\n arc: { blend: 'additive' },\n arcmini: { blend: 'additive' },\n greatcircle: { blend: 'additive' },\n };\n return defaultConfig[type];\n }\n protected getModelType(): LineModelType {\n const shapeAttribute = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shape = shapeAttribute?.scale?.field as LineModelType;\n return shape || 'line';\n }\n}\n"],"file":"index.js"}
@@ -15,8 +15,8 @@ import { AttributeType, gl } from '@antv/l7-core';
15
15
  import { rgb2arr } from '@antv/l7-utils';
16
16
  import BaseModel from '../../core/BaseModel';
17
17
  import { LineArcTriangulation } from '../../core/triangulation';
18
- var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float segmentNumber;\nvarying vec2 v_iconMapUV;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6 - \u7528\u4E8E\u5408\u5E76\u5355\u4E2A\u7684 varying \u53D8\u91CF\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_segmentIndex = v_dataset.r; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n float d_distance_ratio = v_dataset.b; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u6BD4\u4F8B\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n \n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float d_texCount = v_dataset.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float u = 1.0 - fract(arcRadio * d_texCount + animateSpeed);\n\n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n float v = v_dataset.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n // gl_FragColor = vec4(1.0 - fract(arcRadio * 20000.0), 0.0, 0.0, 1.0);\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n // gl_FragColor = filterColor(texture2D(u_texture, uv));\n \n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n // gl_FragColor = filterColor(gl_FragColor);\n}";
19
- var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_lineDir: 1.0;\nvarying vec4 v_dash_array;\n\nuniform float u_thetaOffset: 0.314;\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6 - \u7528\u4E8E\u5408\u5E76\u5355\u4E2A\u7684 varying \u53D8\u91CF\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = u_thetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n \n if(u_aimate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_dataset.b = d_distance_ratio;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_dataset.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_dataset.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n v_dataset.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n";
18
+ var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float segmentNumber;\nvarying vec2 v_iconMapUV;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_segmentIndex = styleMappingMat[3].r; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n float d_distance_ratio = styleMappingMat[3].b; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u6BD4\u4F8B\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n \n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float d_texCount = styleMappingMat[3].g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float u = 1.0 - fract(arcRadio * d_texCount + animateSpeed);\n\n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n float v = styleMappingMat[3].a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n // gl_FragColor = vec4(1.0 - fract(arcRadio * 20000.0), 0.0, 0.0, 1.0);\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n // gl_FragColor = filterColor(texture2D(u_texture, uv));\n \n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n // gl_FragColor = filterColor(gl_FragColor);\n}";
19
+ var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_lineDir: 1.0;\nvarying vec4 v_dash_array;\n\nuniform float u_thetaOffset: 0.314;\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = u_thetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // dataset \u6570\u636E\u96C6\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n \n if(u_aimate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n styleMappingMat[3].b = d_distance_ratio;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n styleMappingMat[3].r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n styleMappingMat[3].g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n";
20
20
  var lineStyleObj = {
21
21
  solid: 0.0,
22
22
  dash: 1.0
@@ -16,8 +16,8 @@ import { rgb2arr } from '@antv/l7-utils';
16
16
  import BaseModel from '../../core/BaseModel';
17
17
  import { LineArcTriangulation } from '../../core/triangulation';
18
18
  import { EARTH_RADIUS } from '../../earth/utils';
19
- var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying float v_segmentIndex;\nuniform float segmentNumber;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.g; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));\n float arcRadio = v_segmentIndex / (segmentNumber - 1.0);\n float count = v_dataset.b; // // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float u = fract(arcRadio * count - animateSpeed * count);\n \n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n gl_FragColor = filterColor(pattern);\n }\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
- var line_arc_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_segmentIndex;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // TODO: + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // TODO: \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n }\n v_dataset.g = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n\n v_segmentIndex = a_Position.x;\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n\n float arcDistrance = length(source - target);\n float pixelLen = project_pixel(u_icon_step);\n v_dataset.b = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n vec2 projectOffset = project_pixel(offset);\n float lineOffsetWidth = length(projectOffset + projectOffset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_dataset.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n }\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n";
19
+ var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying float v_segmentIndex;\nuniform float segmentNumber;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = styleMappingMat[3].g; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));\n float arcRadio = v_segmentIndex / (segmentNumber - 1.0);\n float count = styleMappingMat[3].b; // // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float u = fract(arcRadio * count - animateSpeed * count);\n \n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n gl_FragColor = filterColor(pattern);\n }\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
+ var line_arc_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_segmentIndex;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // TODO: + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // TODO: \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // dataset \u6570\u636E\u96C6\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n }\n styleMappingMat[3].g = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n\n v_segmentIndex = a_Position.x;\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n\n float arcDistrance = length(source - target);\n float pixelLen = project_pixel(u_icon_step);\n styleMappingMat[3].b = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n vec2 projectOffset = project_pixel(offset);\n float lineOffsetWidth = length(projectOffset + projectOffset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n }\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n";
21
21
  var lineStyleObj = {
22
22
  solid: 0.0,
23
23
  dash: 1.0
@@ -0,0 +1,9 @@
1
+ import { IModel, IModelUniform } from '@antv/l7-core';
2
+ import BaseModel from '../../core/BaseModel';
3
+ export default class ArcMiniModel extends BaseModel {
4
+ getUninforms(): IModelUniform;
5
+ getAnimateUniforms(): IModelUniform;
6
+ initModels(): IModel[];
7
+ buildModels(): IModel[];
8
+ protected registerBuiltinAttributes(): void;
9
+ }
@@ -0,0 +1,144 @@
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 { rgb2arr } from '@antv/l7-utils';
14
+ import BaseModel from '../../core/BaseModel';
15
+ import { LineArcTriangulation } from '../../core/triangulation';
16
+ var line_arcmini_frag = "#define LineTypeSolid 0.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\n// varying vec2 v_normal;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float segmentNumber;\nvarying float v_distance_ratio;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n \n \n gl_FragColor.a *= u_opacity;\n\n if(u_aimate.x == Animate) {\n float animateSpeed = u_time / u_aimate.y; // \u8FD0\u52A8\u901F\u5EA6\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}";
17
+ var line_arcmini_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nuniform float u_lineDir: 1.0;\n\n// \u504F\u79FB\u91CF\nuniform float u_thetaOffset: 0.314;\n\nuniform float u_opacity: 1.0;\nvarying float v_distance_ratio;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = u_thetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n v_distance_ratio = segmentIndex / segmentNumber;\n \n if(u_aimate.x == Animate && u_lineDir != 1.0) {\n v_distance_ratio = 1.0 - v_distance_ratio;\n }\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n";
18
+
19
+ var ArcMiniModel = function (_BaseModel) {
20
+ _inherits(ArcMiniModel, _BaseModel);
21
+
22
+ var _super = _createSuper(ArcMiniModel);
23
+
24
+ function ArcMiniModel() {
25
+ _classCallCheck(this, ArcMiniModel);
26
+
27
+ return _super.apply(this, arguments);
28
+ }
29
+
30
+ _createClass(ArcMiniModel, [{
31
+ key: "getUninforms",
32
+ value: function getUninforms() {
33
+ var _ref = this.layer.getLayerConfig(),
34
+ opacity = _ref.opacity,
35
+ sourceColor = _ref.sourceColor,
36
+ targetColor = _ref.targetColor,
37
+ _ref$forward = _ref.forward,
38
+ forward = _ref$forward === void 0 ? true : _ref$forward,
39
+ _ref$segmentNumber = _ref.segmentNumber,
40
+ segmentNumber = _ref$segmentNumber === void 0 ? 30 : _ref$segmentNumber,
41
+ _ref$thetaOffset = _ref.thetaOffset,
42
+ thetaOffset = _ref$thetaOffset === void 0 ? 0.314 : _ref$thetaOffset;
43
+
44
+ var useLinearColor = 0;
45
+ var sourceColorArr = [0, 0, 0, 0];
46
+ var targetColorArr = [0, 0, 0, 0];
47
+
48
+ if (sourceColor && targetColor) {
49
+ sourceColorArr = rgb2arr(sourceColor);
50
+ targetColorArr = rgb2arr(targetColor);
51
+ useLinearColor = 1;
52
+ }
53
+
54
+ return {
55
+ u_thetaOffset: thetaOffset,
56
+ u_opacity: _isNumber(opacity) ? opacity : 1.0,
57
+ segmentNumber: segmentNumber,
58
+ u_blur: 0.9,
59
+ u_lineDir: forward ? 1 : -1,
60
+ u_linearColor: useLinearColor,
61
+ u_sourceColor: sourceColorArr,
62
+ u_targetColor: targetColorArr
63
+ };
64
+ }
65
+ }, {
66
+ key: "getAnimateUniforms",
67
+ value: function getAnimateUniforms() {
68
+ var _ref2 = this.layer.getLayerConfig(),
69
+ animateOption = _ref2.animateOption;
70
+
71
+ return {
72
+ u_aimate: this.animateOption2Array(animateOption),
73
+ u_time: this.layer.getLayerAnimateTime()
74
+ };
75
+ }
76
+ }, {
77
+ key: "initModels",
78
+ value: function initModels() {
79
+ return this.buildModels();
80
+ }
81
+ }, {
82
+ key: "buildModels",
83
+ value: function buildModels() {
84
+ var _ref3 = this.layer.getLayerConfig(),
85
+ _ref3$segmentNumber = _ref3.segmentNumber,
86
+ segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
87
+
88
+ return [this.layer.buildLayerModel({
89
+ moduleName: 'arc2dminiline',
90
+ vertexShader: line_arcmini_vert,
91
+ fragmentShader: line_arcmini_frag,
92
+ triangulation: LineArcTriangulation,
93
+ depth: {
94
+ enable: false
95
+ },
96
+ blend: this.getBlend(),
97
+ segmentNumber: segmentNumber
98
+ })];
99
+ }
100
+ }, {
101
+ key: "registerBuiltinAttributes",
102
+ value: function registerBuiltinAttributes() {
103
+ this.styleAttributeService.registerStyleAttribute({
104
+ name: 'size',
105
+ type: AttributeType.Attribute,
106
+ descriptor: {
107
+ name: 'a_Size',
108
+ buffer: {
109
+ usage: gl.DYNAMIC_DRAW,
110
+ data: [],
111
+ type: gl.FLOAT
112
+ },
113
+ size: 1,
114
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
115
+ var _feature$size = feature.size,
116
+ size = _feature$size === void 0 ? 1 : _feature$size;
117
+ return Array.isArray(size) ? [size[0]] : [size];
118
+ }
119
+ }
120
+ });
121
+ this.styleAttributeService.registerStyleAttribute({
122
+ name: 'instance',
123
+ type: AttributeType.Attribute,
124
+ descriptor: {
125
+ name: 'a_Instance',
126
+ buffer: {
127
+ usage: gl.STATIC_DRAW,
128
+ data: [],
129
+ type: gl.FLOAT
130
+ },
131
+ size: 4,
132
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
133
+ return [vertex[3], vertex[4], vertex[5], vertex[6]];
134
+ }
135
+ }
136
+ });
137
+ }
138
+ }]);
139
+
140
+ return ArcMiniModel;
141
+ }(BaseModel);
142
+
143
+ export { ArcMiniModel as default };
144
+ //# sourceMappingURL=arcmini.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/line/models/arcmini.ts"],"names":["AttributeType","gl","rgb2arr","BaseModel","LineArcTriangulation","ArcMiniModel","layer","getLayerConfig","opacity","sourceColor","targetColor","forward","segmentNumber","thetaOffset","useLinearColor","sourceColorArr","targetColorArr","u_thetaOffset","u_opacity","u_blur","u_lineDir","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","buildModels","buildLayerModel","moduleName","vertexShader","line_arcmini_vert","fragmentShader","line_arcmini_frag","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"],"mappings":";;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AAUA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,oBAAT,QAAqC,0BAArC;;;;IAIqBC,Y;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,WAFF,QAEEA,WAFF;AAAA,UAGEC,WAHF,QAGEA,WAHF;AAAA,8BAIEC,OAJF;AAAA,UAIEA,OAJF,6BAIY,IAJZ;AAAA,oCAKEC,aALF;AAAA,UAKEA,aALF,mCAKkB,EALlB;AAAA,kCAMEC,WANF;AAAA,UAMEA,WANF,iCAMgB,KANhB;;AAUA,UAAIC,cAAc,GAAG,CAArB;AACA,UAAIC,cAAc,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAArB;AACA,UAAIC,cAAc,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAArB;;AACA,UAAIP,WAAW,IAAIC,WAAnB,EAAgC;AAC9BK,QAAAA,cAAc,GAAGb,OAAO,CAACO,WAAD,CAAxB;AACAO,QAAAA,cAAc,GAAGd,OAAO,CAACQ,WAAD,CAAxB;AACAI,QAAAA,cAAc,GAAG,CAAjB;AACD;;AAED,aAAO;AACLG,QAAAA,aAAa,EAAEJ,WADV;AAGLK,QAAAA,SAAS,EAAE,UAASV,OAAT,IAAoBA,OAApB,GAA8B,GAHpC;AAKLI,QAAAA,aAAa,EAAbA,aALK;AAMLO,QAAAA,MAAM,EAAE,GANH;AAOLC,QAAAA,SAAS,EAAET,OAAO,GAAG,CAAH,GAAO,CAAC,CAPrB;AAULU,QAAAA,aAAa,EAAEP,cAVV;AAWLQ,QAAAA,aAAa,EAAEP,cAXV;AAYLQ,QAAAA,aAAa,EAAEP;AAZV,OAAP;AAcD;;;WAED,8BAA2C;AACzC,kBAA0B,KAAKV,KAAL,CAAWC,cAAX,EAA1B;AAAA,UAAQiB,aAAR,SAAQA,aAAR;;AACA,aAAO;AACLC,QAAAA,QAAQ,EAAE,KAAKC,mBAAL,CAAyBF,aAAzB,CADL;AAELG,QAAAA,MAAM,EAAE,KAAKrB,KAAL,CAAWsB,mBAAX;AAFH,OAAP;AAID;;;WAED,sBAA8B;AAC5B,aAAO,KAAKC,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,kBAEI,KAAKvB,KAAL,CAAWC,cAAX,EAFJ;AAAA,sCACEK,aADF;AAAA,UACEA,aADF,oCACkB,EADlB;;AAIA,aAAO,CACL,KAAKN,KAAL,CAAWwB,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,eADa;AAEzBC,QAAAA,YAAY,EAAEC,iBAFW;AAGzBC,QAAAA,cAAc,EAAEC,iBAHS;AAIzBC,QAAAA,aAAa,EAAEhC,oBAJU;AAKzBiC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EANkB;AAOzB5B,QAAAA,aAAa,EAAbA;AAPyB,OAA3B,CADK,CAAP;AAWD;;;WAED,qCAAsC;AAEpC,WAAK6B,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhDC,QAAAA,IAAI,EAAE5C,aAAa,CAAC6C,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,QADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE/C,EAAE,CAACgD,YAFJ;AAGNC,YAAAA,IAAI,EAAE,EAHA;AAINN,YAAAA,IAAI,EAAE3C,EAAE,CAACkD;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBH,OAArB,CAAQF,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAOM,KAAK,CAACC,OAAN,CAAcP,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAwBA,WAAKX,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,UAD0C;AAEhDC,QAAAA,IAAI,EAAE5C,aAAa,CAAC6C,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,YADI;AAEVI,UAAAA,MAAM,EAAE;AACNC,YAAAA,KAAK,EAAE/C,EAAE,CAAC2D,WADJ;AAENV,YAAAA,IAAI,EAAE,EAFA;AAGNN,YAAAA,IAAI,EAAE3C,EAAE,CAACkD;AAHH,WAFE;AAOVC,UAAAA,IAAI,EAAE,CAPI;AAQVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAP;AACD;AAfS;AAHoC,OAAlD;AAqBD;;;;EAlHuCrD,S;;SAArBE,Y","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport line_arcmini_frag from '../shaders/line_arcmini_frag.glsl';\nimport line_arcmini_vert from '../shaders/line_arcmini_vert.glsl';\n\nexport default class ArcMiniModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n forward = true,\n segmentNumber = 30,\n thetaOffset = 0.314,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n return {\n u_thetaOffset: thetaOffset,\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n segmentNumber,\n u_blur: 0.9,\n u_lineDir: forward ? 1 : -1,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\n }\n\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'arc2dminiline',\n vertexShader: line_arcmini_vert,\n fragmentShader: line_arcmini_frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n segmentNumber,\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: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\n },\n },\n });\n }\n}\n"],"file":"arcmini.js"}
@@ -15,8 +15,8 @@ import { AttributeType, gl } from '@antv/l7-core';
15
15
  import { rgb2arr } from '@antv/l7-utils';
16
16
  import BaseModel from '../../core/BaseModel';
17
17
  import { LineArcTriangulation } from '../../core/triangulation';
18
- var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0;\n float d_segmentIndex = v_dataset.g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- smoothstep(0.0, 1.0, v_distance_ratio), u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = v_dataset.b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
19
- var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n }else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*8.0;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba);\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\n v_dataset.g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\n v_dataset.b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_dataset.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + offset, curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n\n";
18
+ var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0;\n float d_segmentIndex = styleMappingMat[3].g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- smoothstep(0.0, 1.0, v_distance_ratio), u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = styleMappingMat[3].b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
19
+ var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n }else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // dataset \u6570\u636E\u96C6\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*8.0;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba);\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\n styleMappingMat[3].g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\n styleMappingMat[3].b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + offset, curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n\n";
20
20
  var lineStyleObj = {
21
21
  solid: 0.0,
22
22
  dash: 1.0
@@ -1,4 +1,4 @@
1
- export declare type LineModelType = 'arc' | 'arc3d' | 'greatcircle' | 'line';
1
+ export declare type LineModelType = 'arc' | 'arcmini' | 'arc3d' | 'greatcircle' | 'line';
2
2
  declare const LineModels: {
3
3
  [key in LineModelType]: any;
4
4
  };
@@ -1,9 +1,11 @@
1
1
  import ArcModel from './arc';
2
2
  import Arc3DModel from './arc_3d';
3
+ import ArcMiniModel from './arcmini';
3
4
  import GreatCircleModel from './great_circle';
4
5
  import LineModel from './line';
5
6
  var LineModels = {
6
7
  arc: ArcModel,
8
+ arcmini: ArcMiniModel,
7
9
  arc3d: Arc3DModel,
8
10
  greatcircle: GreatCircleModel,
9
11
  line: LineModel
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/line/models/index.ts"],"names":["ArcModel","Arc3DModel","GreatCircleModel","LineModel","LineModels","arc","arc3d","greatcircle","line"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,OAArB;AACA,OAAOC,UAAP,MAAuB,UAAvB;AACA,OAAOC,gBAAP,MAA6B,gBAA7B;AACA,OAAOC,SAAP,MAAsB,QAAtB;AAIA,IAAMC,UAA2C,GAAG;AAClDC,EAAAA,GAAG,EAAEL,QAD6C;AAElDM,EAAAA,KAAK,EAAEL,UAF2C;AAGlDM,EAAAA,WAAW,EAAEL,gBAHqC;AAIlDM,EAAAA,IAAI,EAAEL;AAJ4C,CAApD;AAOA,eAAeC,UAAf","sourcesContent":["import ArcModel from './arc';\nimport Arc3DModel from './arc_3d';\nimport GreatCircleModel from './great_circle';\nimport LineModel from './line';\n\nexport type LineModelType = 'arc' | 'arc3d' | 'greatcircle' | 'line';\n\nconst LineModels: { [key in LineModelType]: any } = {\n arc: ArcModel,\n arc3d: Arc3DModel,\n greatcircle: GreatCircleModel,\n line: LineModel,\n};\n\nexport default LineModels;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/line/models/index.ts"],"names":["ArcModel","Arc3DModel","ArcMiniModel","GreatCircleModel","LineModel","LineModels","arc","arcmini","arc3d","greatcircle","line"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,OAArB;AACA,OAAOC,UAAP,MAAuB,UAAvB;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,gBAAP,MAA6B,gBAA7B;AACA,OAAOC,SAAP,MAAsB,QAAtB;AASA,IAAMC,UAA2C,GAAG;AAClDC,EAAAA,GAAG,EAAEN,QAD6C;AAElDO,EAAAA,OAAO,EAAEL,YAFyC;AAGlDM,EAAAA,KAAK,EAAEP,UAH2C;AAIlDQ,EAAAA,WAAW,EAAEN,gBAJqC;AAKlDO,EAAAA,IAAI,EAAEN;AAL4C,CAApD;AAQA,eAAeC,UAAf","sourcesContent":["import ArcModel from './arc';\nimport Arc3DModel from './arc_3d';\nimport ArcMiniModel from './arcmini';\nimport GreatCircleModel from './great_circle';\nimport LineModel from './line';\n\nexport type LineModelType =\n | 'arc'\n | 'arcmini'\n | 'arc3d'\n | 'greatcircle'\n | 'line';\n\nconst LineModels: { [key in LineModelType]: any } = {\n arc: ArcModel,\n arcmini: ArcMiniModel,\n arc3d: Arc3DModel,\n greatcircle: GreatCircleModel,\n line: LineModel,\n};\n\nexport default LineModels;\n"],"file":"index.js"}