@antv/l7-layers 2.6.36 → 2.7.3

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 (126) hide show
  1. package/es/core/BaseLayer.d.ts +1 -0
  2. package/es/core/BaseLayer.js +4 -0
  3. package/es/core/BaseLayer.js.map +1 -1
  4. package/es/core/interface.d.ts +60 -1
  5. package/es/core/interface.js.map +1 -1
  6. package/es/heatmap/index.d.ts +1 -4
  7. package/es/heatmap/index.js.map +1 -1
  8. package/es/heatmap/models/grid.js +9 -1
  9. package/es/heatmap/models/grid.js.map +1 -1
  10. package/es/heatmap/models/grid3d.js +9 -1
  11. package/es/heatmap/models/grid3d.js.map +1 -1
  12. package/es/heatmap/models/heatmap.js +29 -15
  13. package/es/heatmap/models/heatmap.js.map +1 -1
  14. package/es/heatmap/models/hexagon.js +9 -1
  15. package/es/heatmap/models/hexagon.js.map +1 -1
  16. package/es/image/index.d.ts +1 -4
  17. package/es/image/index.js.map +1 -1
  18. package/es/image/models/image.d.ts +3 -3
  19. package/es/image/models/image.js +9 -2
  20. package/es/image/models/image.js.map +1 -1
  21. package/es/index.d.ts +2 -1
  22. package/es/index.js +2 -1
  23. package/es/index.js.map +1 -1
  24. package/es/line/models/arc.js +8 -3
  25. package/es/line/models/arc.js.map +1 -1
  26. package/es/line/models/arc_3d.js +8 -3
  27. package/es/line/models/arc_3d.js.map +1 -1
  28. package/es/line/models/great_circle.js +13 -6
  29. package/es/line/models/great_circle.js.map +1 -1
  30. package/es/line/models/line.js +12 -5
  31. package/es/line/models/line.js.map +1 -1
  32. package/es/line/models/simpleLine.js +9 -2
  33. package/es/line/models/simpleLine.js.map +1 -1
  34. package/es/mask/index.d.ts +21 -0
  35. package/es/mask/index.js +73 -0
  36. package/es/mask/index.js.map +1 -0
  37. package/es/mask/models/fill.d.ts +11 -0
  38. package/es/mask/models/fill.js +92 -0
  39. package/es/mask/models/fill.js.map +1 -0
  40. package/es/mask/models/index.d.ts +5 -0
  41. package/es/mask/models/index.js +6 -0
  42. package/es/mask/models/index.js.map +1 -0
  43. package/es/plugins/DataSourcePlugin.js +6 -2
  44. package/es/plugins/DataSourcePlugin.js.map +1 -1
  45. package/es/point/index.d.ts +1 -6
  46. package/es/point/index.js.map +1 -1
  47. package/es/point/models/fill.js +9 -1
  48. package/es/point/models/fill.js.map +1 -1
  49. package/es/point/models/image.js +12 -4
  50. package/es/point/models/image.js.map +1 -1
  51. package/es/point/models/index.js.map +1 -1
  52. package/es/point/models/normal.d.ts +2 -6
  53. package/es/point/models/normal.js +9 -1
  54. package/es/point/models/normal.js.map +1 -1
  55. package/es/point/models/simplePoint.d.ts +2 -10
  56. package/es/point/models/simplePoint.js +9 -1
  57. package/es/point/models/simplePoint.js.map +1 -1
  58. package/es/point/models/text.js +60 -46
  59. package/es/point/models/text.js.map +1 -1
  60. package/es/polygon/index.d.ts +1 -4
  61. package/es/polygon/index.js.map +1 -1
  62. package/es/polygon/models/extrude.js +8 -2
  63. package/es/polygon/models/extrude.js.map +1 -1
  64. package/es/polygon/models/fill.js +8 -2
  65. package/es/polygon/models/fill.js.map +1 -1
  66. package/es/raster/index.d.ts +1 -10
  67. package/es/raster/index.js.map +1 -1
  68. package/es/raster/models/raster.d.ts +3 -3
  69. package/es/raster/models/raster.js +13 -6
  70. package/es/raster/models/raster.js.map +1 -1
  71. package/lib/core/BaseLayer.js +3 -0
  72. package/lib/core/BaseLayer.js.map +1 -1
  73. package/lib/core/interface.js.map +1 -1
  74. package/lib/heatmap/index.js.map +1 -1
  75. package/lib/heatmap/models/grid.js +10 -1
  76. package/lib/heatmap/models/grid.js.map +1 -1
  77. package/lib/heatmap/models/grid3d.js +10 -1
  78. package/lib/heatmap/models/grid3d.js.map +1 -1
  79. package/lib/heatmap/models/heatmap.js +28 -14
  80. package/lib/heatmap/models/heatmap.js.map +1 -1
  81. package/lib/heatmap/models/hexagon.js +10 -1
  82. package/lib/heatmap/models/hexagon.js.map +1 -1
  83. package/lib/image/index.js.map +1 -1
  84. package/lib/image/models/image.js +8 -1
  85. package/lib/image/models/image.js.map +1 -1
  86. package/lib/index.js +8 -0
  87. package/lib/index.js.map +1 -1
  88. package/lib/line/models/arc.js +7 -2
  89. package/lib/line/models/arc.js.map +1 -1
  90. package/lib/line/models/arc_3d.js +7 -2
  91. package/lib/line/models/arc_3d.js.map +1 -1
  92. package/lib/line/models/great_circle.js +12 -5
  93. package/lib/line/models/great_circle.js.map +1 -1
  94. package/lib/line/models/line.js +11 -4
  95. package/lib/line/models/line.js.map +1 -1
  96. package/lib/line/models/simpleLine.js +8 -1
  97. package/lib/line/models/simpleLine.js.map +1 -1
  98. package/lib/mask/index.js +86 -0
  99. package/lib/mask/index.js.map +1 -0
  100. package/lib/mask/models/fill.js +107 -0
  101. package/lib/mask/models/fill.js.map +1 -0
  102. package/lib/mask/models/index.js +17 -0
  103. package/lib/mask/models/index.js.map +1 -0
  104. package/lib/plugins/DataSourcePlugin.js +6 -2
  105. package/lib/plugins/DataSourcePlugin.js.map +1 -1
  106. package/lib/point/index.js.map +1 -1
  107. package/lib/point/models/fill.js +10 -1
  108. package/lib/point/models/fill.js.map +1 -1
  109. package/lib/point/models/image.js +13 -4
  110. package/lib/point/models/image.js.map +1 -1
  111. package/lib/point/models/index.js.map +1 -1
  112. package/lib/point/models/normal.js +10 -1
  113. package/lib/point/models/normal.js.map +1 -1
  114. package/lib/point/models/simplePoint.js +10 -1
  115. package/lib/point/models/simplePoint.js.map +1 -1
  116. package/lib/point/models/text.js +59 -45
  117. package/lib/point/models/text.js.map +1 -1
  118. package/lib/polygon/index.js.map +1 -1
  119. package/lib/polygon/models/extrude.js +9 -2
  120. package/lib/polygon/models/extrude.js.map +1 -1
  121. package/lib/polygon/models/fill.js +9 -2
  122. package/lib/polygon/models/fill.js.map +1 -1
  123. package/lib/raster/index.js.map +1 -1
  124. package/lib/raster/models/raster.js +12 -5
  125. package/lib/raster/models/raster.js.map +1 -1
  126. package/package.json +5 -5
@@ -0,0 +1,92 @@
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 { gl } from '@antv/l7-core';
13
+ import BaseModel from '../../core/BaseModel';
14
+ import { polygonTriangulation } from '../../core/triangulation';
15
+ var mask_frag = "uniform float u_opacity;\nvarying vec4 v_Color;\n\nvoid main() {\n gl_FragColor = v_Color;\n gl_FragColor.a *= u_opacity;\n}\n";
16
+ var mask_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\n\n#pragma include \"projection\"\n\nvoid main() {\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
17
+
18
+ var MaskModel = function (_BaseModel) {
19
+ _inherits(MaskModel, _BaseModel);
20
+
21
+ var _super = _createSuper(MaskModel);
22
+
23
+ function MaskModel() {
24
+ _classCallCheck(this, MaskModel);
25
+
26
+ return _super.apply(this, arguments);
27
+ }
28
+
29
+ _createClass(MaskModel, [{
30
+ key: "getUninforms",
31
+ value: function getUninforms() {
32
+ var _ref = this.layer.getLayerConfig(),
33
+ _ref$opacity = _ref.opacity,
34
+ opacity = _ref$opacity === void 0 ? 0 : _ref$opacity;
35
+
36
+ return {
37
+ u_opacity: _isNumber(opacity) ? opacity : 0.0
38
+ };
39
+ }
40
+ }, {
41
+ key: "initModels",
42
+ value: function initModels() {
43
+ this.layer.zIndex = -1000;
44
+ return this.buildModels();
45
+ }
46
+ }, {
47
+ key: "buildModels",
48
+ value: function buildModels() {
49
+ return [this.layer.buildLayerModel({
50
+ moduleName: 'mask',
51
+ vertexShader: mask_vert,
52
+ fragmentShader: mask_frag,
53
+ triangulation: polygonTriangulation,
54
+ blend: this.getBlend(),
55
+ depth: {
56
+ enable: false
57
+ },
58
+ stencil: {
59
+ enable: true,
60
+ mask: 0xff,
61
+ func: {
62
+ cmp: gl.ALWAYS,
63
+ ref: 1,
64
+ mask: 0xff
65
+ },
66
+ opFront: {
67
+ fail: gl.REPLACE,
68
+ zfail: gl.REPLACE,
69
+ zpass: gl.REPLACE
70
+ }
71
+ }
72
+ })];
73
+ }
74
+ }, {
75
+ key: "clearModels",
76
+ value: function clearModels() {
77
+ var _this$dataTexture;
78
+
79
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
80
+ }
81
+ }, {
82
+ key: "registerBuiltinAttributes",
83
+ value: function registerBuiltinAttributes() {
84
+ return '';
85
+ }
86
+ }]);
87
+
88
+ return MaskModel;
89
+ }(BaseModel);
90
+
91
+ export { MaskModel as default };
92
+ //# sourceMappingURL=fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["gl","BaseModel","polygonTriangulation","MaskModel","layer","getLayerConfig","opacity","u_opacity","zIndex","buildModels","buildLayerModel","moduleName","vertexShader","mask_vert","fragmentShader","mask_frag","triangulation","blend","getBlend","depth","enable","stencil","mask","func","cmp","ALWAYS","ref","opFront","fail","REPLACE","zfail","zpass","dataTexture","destroy"],"mappings":";;;;;;;;;;;AAAA,SAASA,EAAT,QAA2B,eAA3B;AAEA,OAAOC,SAAP,MAAuC,sBAAvC;AACA,SAASC,oBAAT,QAAqC,0BAArC;;;;IAMqBC,S;;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAAwB,KAAKC,KAAL,CAAWC,cAAX,EAAxB;AAAA,8BAAQC,OAAR;AAAA,UAAQA,OAAR,6BAAkB,CAAlB;;AACA,aAAO;AACLC,QAAAA,SAAS,EAAE,UAASD,OAAT,IAAoBA,OAApB,GAA8B;AADpC,OAAP;AAGD;;;WAED,sBAA8B;AAE5B,WAAKF,KAAL,CAAWI,MAAX,GAAoB,CAAC,IAArB;AACA,aAAO,KAAKC,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,aAAO,CACL,KAAKL,KAAL,CAAWM,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,MADa;AAEzBC,QAAAA,YAAY,EAAEC,SAFW;AAGzBC,QAAAA,cAAc,EAAEC,SAHS;AAIzBC,QAAAA,aAAa,EAAEd,oBAJU;AAKzBe,QAAAA,KAAK,EAAE,KAAKC,QAAL,EALkB;AAMzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SANkB;AAQzBC,QAAAA,OAAO,EAAE;AACPD,UAAAA,MAAM,EAAE,IADD;AAEPE,UAAAA,IAAI,EAAE,IAFC;AAGPC,UAAAA,IAAI,EAAE;AACJC,YAAAA,GAAG,EAAExB,EAAE,CAACyB,MADJ;AAEJC,YAAAA,GAAG,EAAE,CAFD;AAGJJ,YAAAA,IAAI,EAAE;AAHF,WAHC;AAQPK,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE5B,EAAE,CAAC6B,OADF;AAEPC,YAAAA,KAAK,EAAE9B,EAAE,CAAC6B,OAFH;AAGPE,YAAAA,KAAK,EAAE/B,EAAE,CAAC6B;AAHH;AARF;AARgB,OAA3B,CADK,CAAP;AAyBD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKG,WAAL,wEAAkBC,OAAlB;AACD;;;WAED,qCAAsC;AACpC,aAAO,EAAP;AACD;;;;EAhDoChC,S;;SAAlBE,S","sourcesContent":["import { gl, IModel } from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleSingle } from '../../core/BaseModel';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport mask_frag from '../shaders/mask_frag.glsl';\nimport mask_vert from '../shaders/mask_vert.glsl';\ninterface IMaskStyleOptions {\n opacity: styleSingle;\n}\nexport default class MaskModel extends BaseModel {\n public getUninforms() {\n const { opacity = 0 } = this.layer.getLayerConfig() as IMaskStyleOptions;\n return {\n u_opacity: isNumber(opacity) ? opacity : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n // TODO: 瓦片组件默认在最下层\n this.layer.zIndex = -1000;\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'mask',\n vertexShader: mask_vert,\n fragmentShader: mask_frag,\n triangulation: polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n\n stencil: {\n enable: true,\n mask: 0xff,\n func: {\n cmp: gl.ALWAYS,\n ref: 1,\n mask: 0xff,\n },\n opFront: {\n fail: gl.REPLACE,\n zfail: gl.REPLACE,\n zpass: gl.REPLACE,\n },\n },\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n return '';\n }\n}\n"],"file":"fill.js"}
@@ -0,0 +1,5 @@
1
+ export declare type MaskModelType = 'fill';
2
+ declare const MaskModels: {
3
+ [key in MaskModelType]: any;
4
+ };
5
+ export default MaskModels;
@@ -0,0 +1,6 @@
1
+ import FillModel from './fill';
2
+ var MaskModels = {
3
+ fill: FillModel
4
+ };
5
+ export default MaskModels;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/mask/models/index.ts"],"names":["FillModel","MaskModels","fill"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,QAAtB;AAIA,IAAMC,UAA2C,GAAG;AAClDC,EAAAA,IAAI,EAAEF;AAD4C,CAApD;AAGA,eAAeC,UAAf","sourcesContent":["import FillModel from './fill';\n\nexport type MaskModelType = 'fill';\n\nconst MaskModels: { [key in MaskModelType]: any } = {\n fill: FillModel,\n};\nexport default MaskModels;\n"],"file":"index.js"}
@@ -58,8 +58,12 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = function () {
58
58
  var newZoom = this.mapService.getZoom() - 1;
59
59
  var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
60
60
 
61
- if (cluster && (dataSourceNeedUpdate || Math.abs(zoom - newZoom) > 1) && maxZoom > zoom) {
62
- source.updateClusterData(Math.floor(newZoom));
61
+ if (cluster && (dataSourceNeedUpdate || Math.abs(layer.clusterZoom - newZoom) >= 1)) {
62
+ if (zoom !== Math.floor(newZoom)) {
63
+ source.updateClusterData(Math.floor(newZoom));
64
+ }
65
+
66
+ layer.clusterZoom = newZoom;
63
67
  return true;
64
68
  }
65
69
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/DataSourcePlugin.ts"],"names":["TYPES","Source","DEFAULT_DATA","DEFAULT_PARSER","injectable","DataSourcePlugin","layer","mapService","getContainer","get","IMapService","hooks","init","tap","source","getSource","sourceOption","data","options","setSource","updateClusterData","beforeRenderData","neeUpdateCluster","dataSourceNeedUpdate","dataState","cluster","clusterOptions","zoom","maxZoom","newZoom","getZoom","Math","abs","floor"],"mappings":";;;;;;AAAA,SAKEA,KALF,QAMO,eANP;AAOA,OAAOC,MAAP,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,MAAM,CAACW,OAAvB;AACA,kCAAmCX,MAAM,CAACY,cAA1C;AAAA,yDAAQC,IAAR;AAAA,UAAQA,IAAR,uCAAe,CAAf;AAAA,yDAAkBC,OAAlB;AAAA,UAAkBA,OAAlB,uCAA4B,EAA5B;AACA,UAAMC,OAAO,GAAG,KAAKtB,UAAL,CAAgBuB,OAAhB,KAA4B,CAA5C;AACA,UAAMP,oBAAoB,GAAGjB,KAAK,CAACkB,SAAN,CAAgBD,oBAA7C;;AAEA,UACEE,OAAO,KACNF,oBAAoB,IAAIQ,IAAI,CAACC,GAAL,CAASL,IAAI,GAAGE,OAAhB,IAA2B,CAD7C,CAAP,IAEAD,OAAO,GAAGD,IAHZ,EAIE;AACAb,QAAAA,MAAM,CAACM,iBAAP,CAAyBW,IAAI,CAACE,KAAL,CAAWJ,OAAX,CAAzB;AACA,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD;;;;;SA3CkBxB,gB","sourcesContent":["import {\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n TYPES,\n} from '@antv/l7-core';\nimport Source, { DEFAULT_DATA, DEFAULT_PARSER } from '@antv/l7-source';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataSourcePlugin implements ILayerPlugin {\n protected mapService: IMapService;\n public apply(layer: ILayer) {\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n layer.hooks.init.tap('DataSourcePlugin', () => {\n const source = layer.getSource();\n if (!source) {\n // TODO: 允许用户不使用 layer 的 source 方法,在这里传入一个默认的替换的默认数据\n const { data, options } = layer.sourceOption || {\n data: DEFAULT_DATA,\n options: DEFAULT_PARSER,\n };\n layer.setSource(new Source(data, options));\n }\n\n this.updateClusterData(layer);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {\n const neeUpdateCluster = this.updateClusterData(layer);\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n layer.dataState.dataSourceNeedUpdate = false;\n return neeUpdateCluster || dataSourceNeedUpdate;\n });\n }\n\n private updateClusterData(layer: ILayer): boolean {\n const source = layer.getSource();\n const cluster = source.cluster;\n const { zoom = 0, maxZoom = 16 } = source.clusterOptions;\n const newZoom = this.mapService.getZoom() - 1;\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次\n if (\n cluster &&\n (dataSourceNeedUpdate || Math.abs(zoom - newZoom) > 1) &&\n maxZoom > zoom\n ) {\n source.updateClusterData(Math.floor(newZoom));\n return true;\n }\n return false;\n }\n}\n"],"file":"DataSourcePlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/DataSourcePlugin.ts"],"names":["TYPES","Source","DEFAULT_DATA","DEFAULT_PARSER","injectable","DataSourcePlugin","layer","mapService","getContainer","get","IMapService","hooks","init","tap","source","getSource","sourceOption","data","options","setSource","updateClusterData","beforeRenderData","neeUpdateCluster","dataSourceNeedUpdate","dataState","cluster","clusterOptions","zoom","maxZoom","newZoom","getZoom","Math","abs","clusterZoom","floor"],"mappings":";;;;;;AAAA,SAKEA,KALF,QAMO,eANP;AAOA,OAAOC,MAAP,IAAiBC,YAAjB,EAA+BC,cAA/B,QAAqD,iBAArD;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,OAAO,kBAAP;IAGqBC,gB,WADpBD,UAAU,E;;;;;;;;;WAGT,eAAaE,KAAb,EAA4B;AAAA;;AAC1B,WAAKC,UAAL,GAAkBD,KAAK,CAACE,YAAN,GAAqBC,GAArB,CAAsCT,KAAK,CAACU,WAA5C,CAAlB;AACAJ,MAAAA,KAAK,CAACK,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,kBAArB,EAAyC,YAAM;AAC7C,YAAMC,MAAM,GAAGR,KAAK,CAACS,SAAN,EAAf;;AACA,YAAI,CAACD,MAAL,EAAa;AAEX,qBAA0BR,KAAK,CAACU,YAAN,IAAsB;AAC9CC,YA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AAX,CAAb,EAAkC;AAChCf,UAAAA,MAAM,CAACM,iBAAP,CAAyBW,IAAI,CAACG,KAAL,CAAWL,OAAX,CAAzB;AACD;;AACDvB,QAAAA,KAAK,CAAC2B,WAAN,GAAoBJ,OAApB;AACA,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD;;;;;SA9CkBxB,gB","sourcesContent":["import {\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n TYPES,\n} from '@antv/l7-core';\nimport Source, { DEFAULT_DATA, DEFAULT_PARSER } from '@antv/l7-source';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataSourcePlugin implements ILayerPlugin {\n protected mapService: IMapService;\n public apply(layer: ILayer) {\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n layer.hooks.init.tap('DataSourcePlugin', () => {\n const source = layer.getSource();\n if (!source) {\n // TODO: 允许用户不使用 layer 的 source 方法,在这里传入一个默认的替换的默认数据\n const { data, options } = layer.sourceOption || {\n data: DEFAULT_DATA,\n options: DEFAULT_PARSER,\n };\n layer.setSource(new Source(data, options));\n }\n\n this.updateClusterData(layer);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {\n const neeUpdateCluster = this.updateClusterData(layer);\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n layer.dataState.dataSourceNeedUpdate = false;\n return neeUpdateCluster || dataSourceNeedUpdate;\n });\n }\n\n private updateClusterData(layer: ILayer): boolean {\n const source = layer.getSource();\n const cluster = source.cluster;\n const { zoom = 0, maxZoom = 16 } = source.clusterOptions;\n const newZoom = this.mapService.getZoom() - 1;\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次\n if (\n cluster &&\n (dataSourceNeedUpdate || Math.abs(layer.clusterZoom - newZoom) >= 1)\n ) {\n // TODO 判断数据是否更新\n if (zoom !== Math.floor(newZoom)) {\n source.updateClusterData(Math.floor(newZoom));\n }\n layer.clusterZoom = newZoom;\n return true;\n }\n return false;\n }\n}\n"],"file":"DataSourcePlugin.js"}
@@ -1,10 +1,6 @@
1
1
  import BaseLayer from '../core/BaseLayer';
2
+ import { IPointLayerStyleOptions } from '../core/interface';
2
3
  import { PointType } from './models/index';
3
- interface IPointLayerStyleOptions {
4
- opacity: number;
5
- strokeWidth: number;
6
- stroke: string;
7
- }
8
4
  export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
9
5
  type: string;
10
6
  buildModels(): void;
@@ -27,4 +23,3 @@ export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
27
23
  };
28
24
  protected getModelType(): PointType;
29
25
  }
30
- export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/point/index.ts"],"names":["BaseLayer","PointModels","PointLayer","modelType","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","normal","blend","simplePoint","fill","extrude","image","icon","text","layerData","getEncodedData","getLayerConfig","shape2d","shape3d","iconMap","iconService","getIconMap","item","find","fe","hasOwnProperty","shape","indexOf","fontService","getGlyph"],"mappings":";;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,mBAAtB;AACA,OAAOC,WAAP,MAAuC,gBAAvC;;IAMqBC,U;;;;;;;;;;;;;;;;2DACG,Y;;;;;;;WACtB,uBAAqB;AACnB,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;AACA,WAAKC,UAAL,GAAkB,IAAIJ,WAAW,CAACE,SAAD,CAAf,CAA2B,IAA3B,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WACD,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAA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T,CAAiBD,KAAjB,OAAsC,CAAC,CAA3C,EAA8C;AAC5C,iBAAO,MAAP;AACD;;AACD,YAAI,CAAAR,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAES,OAAT,CAAiBD,KAAjB,OAAsC,CAAC,CAA3C,EAA8C;AAC5C,iBAAO,SAAP;AACD;;AACD,YAAIP,OAAO,CAACM,cAAR,CAAuBC,KAAvB,CAAJ,EAA6C;AAC3C,iBAAO,OAAP;AACD;;AACD,YAAI,KAAKE,WAAL,CAAiBC,QAAjB,CAA0BH,KAA1B,MAA+C,EAAnD,EAAuD;AACrD,iBAAO,MAAP;AACD;;AACD,eAAO,MAAP;AACD;AACF;;;;EAxEqCnC,S;;SAAnBE,U","sourcesContent":["import { IEncodeFeature } from '@antv/l7-core';\nimport BaseLayer from '../core/BaseLayer';\nimport PointModels, { PointType } from './models/index';\ninterface IPointLayerStyleOptions {\n opacity: number;\n strokeWidth: number;\n stroke: string;\n}\nexport default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {\n public type: string = 'PointLayer';\n public buildModels() {\n const modelType = this.getModelType();\n this.layerModel = new PointModels[modelType](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\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 normal: {\n blend: 'additive',\n },\n simplePoint: {},\n fill: { blend: 'normal' },\n extrude: {},\n image: {},\n icon: {},\n text: {\n blend: 'normal',\n },\n };\n return defaultConfig[type];\n }\n\n protected getModelType(): PointType {\n // pointlayer\n // 2D、 3d、 shape、image、text、normal、\n const layerData = this.getEncodedData();\n const { shape2d, shape3d } = this.getLayerConfig();\n const iconMap = this.iconService.getIconMap();\n const item = layerData.find((fe: IEncodeFeature) => {\n return fe.hasOwnProperty('shape');\n });\n if (!item) {\n return 'normal';\n } else {\n const shape = item.shape;\n if (shape === 'dot') {\n return 'normal';\n }\n if (shape === 'simple') {\n return 'simplePoint';\n }\n if (shape2d?.indexOf(shape as string) !== -1) {\n return 'fill';\n }\n if (shape3d?.indexOf(shape as string) !== -1) {\n return 'extrude';\n }\n if (iconMap.hasOwnProperty(shape as string)) {\n return 'image';\n }\n if (this.fontService.getGlyph(shape as string) !== '') {\n return 'icon';\n }\n return 'text';\n }\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/point/index.ts"],"names":["BaseLayer","PointModels","PointLayer","modelType","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","normal","blend","simplePoint","fill","extrude","image","icon","text","layerData","getEncodedData","getLayerConfig","shape2d","shape3d","iconMap","iconService","getIconMap","item","find","fe","hasOwnProperty","shape","indexOf","fontService","getGlyph"],"mappings":";;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,WAAP,MAAuC,gBAAvC;;IAEqBC,U;;;;;;;;;;;;;;;;2DACG,Y;;;;;;;WACtB,uBAAqB;AACnB,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;AACA,WAAKC,UAAL,GAAkB,IAAIJ,WAAW,CAACE,SAAD,CAAf,CAA2B,IAA3B,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WACD,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,G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3C,EAA8C;AAC5C,iBAAO,SAAP;AACD;;AACD,YAAIP,OAAO,CAACM,cAAR,CAAuBC,KAAvB,CAAJ,EAA6C;AAC3C,iBAAO,OAAP;AACD;;AACD,YAAI,KAAKE,WAAL,CAAiBC,QAAjB,CAA0BH,KAA1B,MAA+C,EAAnD,EAAuD;AACrD,iBAAO,MAAP;AACD;;AACD,eAAO,MAAP;AACD;AACF;;;;EAxEqCnC,S;;SAAnBE,U","sourcesContent":["import { IEncodeFeature } from '@antv/l7-core';\nimport BaseLayer from '../core/BaseLayer';\nimport { IPointLayerStyleOptions } from '../core/interface';\nimport PointModels, { PointType } from './models/index';\n\nexport default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {\n public type: string = 'PointLayer';\n public buildModels() {\n const modelType = this.getModelType();\n this.layerModel = new PointModels[modelType](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\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 normal: {\n blend: 'additive',\n },\n simplePoint: {},\n fill: { blend: 'normal' },\n extrude: {},\n image: {},\n icon: {},\n text: {\n blend: 'normal',\n },\n };\n return defaultConfig[type];\n }\n\n protected getModelType(): PointType {\n // pointlayer\n // 2D、 3d、 shape、image、text、normal、\n const layerData = this.getEncodedData();\n const { shape2d, shape3d } = this.getLayerConfig();\n const iconMap = this.iconService.getIconMap();\n const item = layerData.find((fe: IEncodeFeature) => {\n return fe.hasOwnProperty('shape');\n });\n if (!item) {\n return 'normal';\n } else {\n const shape = item.shape;\n if (shape === 'dot') {\n return 'normal';\n }\n if (shape === 'simple') {\n return 'simplePoint';\n }\n if (shape2d?.indexOf(shape as string) !== -1) {\n return 'fill';\n }\n if (shape3d?.indexOf(shape as string) !== -1) {\n return 'extrude';\n }\n if (iconMap.hasOwnProperty(shape as string)) {\n return 'image';\n }\n if (this.fontService.getGlyph(shape as string) !== '') {\n return 'icon';\n }\n return 'text';\n }\n }\n}\n"],"file":"index.js"}
@@ -14,6 +14,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
14
14
  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; } }
15
15
 
16
16
  import { AttributeType, gl } from '@antv/l7-core';
17
+ import { getMask } from '@antv/l7-utils';
17
18
  import BaseModel from '../../core/BaseModel';
18
19
  import { GlobelPointFillTriangulation, PointFillTriangulation } from '../../core/triangulation';
19
20
  var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n \n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(u_globel > 0.0) {\n // TODO: \u5730\u7403\u6A21\u5F0F\u4E0B\u907F\u514D\u591A\u4F59\u7247\u5143\u7ED8\u5236\uFF0C\u540C\u65F6\u4E5F\u80FD\u907F\u514D\u6709\u7528\u7247\u5143\u5728\u900F\u660E\u4E14\u91CD\u53E0\u7684\u60C5\u51B5\u4E0B\u65E0\u6CD5\u5199\u5165\n // \u4ED8\u51FA\u7684\u4EE3\u4EF7\u662F\u8FB9\u7F18\u4F1A\u6709\u4E00\u4E9B\u952F\u9F7F\n if(outer_df > antialiasblur + 0.018) discard;\n }\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n }\n\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n \n // TODO: \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, intensity);\n }\n \n // TODO: \u4F18\u5316\u5728\u6C34\u6CE2\u7EB9\u60C5\u51B5\u4E0B\u7684\u62FE\u53D6\uFF08a == 0 \u65F6\u65E0\u6CD5\u62FE\u53D6\uFF09\n if(d < 0.7) {\n gl_FragColor.a = max(gl_FragColor.a, 0.001);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor = filterColorAnimate(gl_FragColor);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n \n }\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n } else {\n gl_FragColor.a *= opacity_t;\n }\n}\n";
@@ -165,6 +166,12 @@ var FillModel = function (_BaseModel) {
165
166
  }, {
166
167
  key: "buildModels",
167
168
  value: function buildModels() {
169
+ var _ref4 = this.layer.getLayerConfig(),
170
+ _ref4$mask = _ref4.mask,
171
+ mask = _ref4$mask === void 0 ? false : _ref4$mask,
172
+ _ref4$maskInside = _ref4.maskInside,
173
+ maskInside = _ref4$maskInside === void 0 ? true : _ref4$maskInside;
174
+
168
175
  var isGlobel = this.mapService.version === 'GLOBEL';
169
176
  return [this.layer.buildLayerModel({
170
177
  moduleName: 'pointfill',
@@ -174,7 +181,8 @@ var FillModel = function (_BaseModel) {
174
181
  depth: {
175
182
  enable: isGlobel
176
183
  },
177
- blend: this.getBlend()
184
+ blend: this.getBlend(),
185
+ stencil: getMask(mask, maskInside)
178
186
  })];
179
187
  }
180
188
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["AttributeType","gl","BaseModel","GlobelPointFillTriangulation","PointFillTriangulation","Version","mat4","vec3","FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_additive","u_globel","mapService","version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","unit","L7MAP","MAPBOX","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","m1","meterToCoord","m2","meter2coord","Boolean","isGlobel","buildLayerModel","moduleName","vertexShader","pointFillVert","fragmentShader","pointFillFrag","triangulation","depth","enable","getBlend","destroy","option","speed","rings","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","x","y","z","n1","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf"],"mappings":";;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAWA,OAAOC,SAAP,MAIO,sBAJP;AAKA,SACEC,4BADF,EAEEC,sBAFF,QAGO,0BAHP;;;AASA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,IAA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AA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,OAD0C;AAEhD5D,QAAAA,IAAI,EAAEnC,aAAa,CAACgG,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,SADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElG,EAAE,CAACmG,YAFJ;AAGN3E,YAAAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAElC,EAAE,CAACmC;AAJH,WAFE;AAQViE,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQ8B,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAAC7H,KAAL,CAAWC,cAAX,GAA4B4H,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EA1RoCrI,S;;SAAlBM,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n strokeOpacity: styleSingle;\n offsets: styleOffset;\n blend: string;\n unit: string;\n}\n// 判断当前使用的 style 中的变量属性是否需要进行数据映射\nexport default class FillModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\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 getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL &&\n version !== Version.MAPBOX\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill',\n vertexShader: pointFillVert,\n fragmentShader: pointFillFrag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
1
+ {"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["AttributeType","gl","getMask","BaseModel","GlobelPointFillTriangulation","PointFillTriangulation","Version","mat4","vec3","FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_additive","u_globel","mapService","version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","unit","L7MAP","MAPBOX","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","m1","meterToCoord","m2","meter2coord","Boolean","mask","maskInside","isGlobel","buildLayerModel","moduleName","vertexShader","pointFillVert","fragmentShader","pointFillFrag","triangulation","depth","enable","getBlend","stencil","destroy","option","speed","rings","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","x","y","z","n1","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf"],"mappings":";;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAWA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SACEC,4BADF,EAEEC,sBAFF,QAGO,0BAHP;;;AASA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,WAA3B;;IACqBC,S;;;;;;;;;;;;;;;;kEACU,C;;8DACF,K;;;;;;;WAC3B,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;;AASA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBP,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA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AFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQ8B,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAAChI,KAAL,CAAWC,cAAX,GAA4B+H,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EA/RoCxI,S;;SAAlBM,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\nexport default class FillModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\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 getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL &&\n version !== Version.MAPBOX\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill',\n vertexShader: pointFillVert,\n fragmentShader: pointFillFrag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
@@ -12,6 +12,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
12
12
  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; } }
13
13
 
14
14
  import { AttributeType, gl } from '@antv/l7-core';
15
+ import { getMask } from '@antv/l7-utils';
15
16
  import BaseModel from '../../core/BaseModel';
16
17
  import { PointImageTriangulation } from '../../core/triangulation';
17
18
  var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main(){\n float opacity = styleMappingMat[0][0];\n float size = styleMappingMat[1][0];\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n\n gl_FragColor.a = gl_FragColor.a * opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
@@ -139,6 +140,12 @@ var ImageModel = function (_BaseModel) {
139
140
  }, {
140
141
  key: "buildModels",
141
142
  value: function buildModels() {
143
+ var _ref2 = this.layer.getLayerConfig(),
144
+ _ref2$mask = _ref2.mask,
145
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
146
+ _ref2$maskInside = _ref2.maskInside,
147
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
148
+
142
149
  return [this.layer.buildLayerModel({
143
150
  moduleName: 'pointImage',
144
151
  vertexShader: pointImageVert,
@@ -148,7 +155,8 @@ var ImageModel = function (_BaseModel) {
148
155
  depth: {
149
156
  enable: false
150
157
  },
151
- blend: this.getBlend()
158
+ blend: this.getBlend(),
159
+ stencil: getMask(mask, maskInside)
152
160
  })];
153
161
  }
154
162
  }, {
@@ -190,12 +198,12 @@ var ImageModel = function (_BaseModel) {
190
198
 
191
199
  var shape = feature.shape;
192
200
 
193
- var _ref2 = iconMap[shape] || {
201
+ var _ref3 = iconMap[shape] || {
194
202
  x: 0,
195
203
  y: 0
196
204
  },
197
- x = _ref2.x,
198
- y = _ref2.y;
205
+ x = _ref3.x,
206
+ y = _ref3.y;
199
207
 
200
208
  return [x, y];
201
209
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/image.ts"],"names":["AttributeType","gl","BaseModel","PointImageTriangulation","ImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","offsets","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","registerBuiltinAttributes","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","pointImageVert","fragmentShader","pointImageFrag","triangulation","primitive","POINTS","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","iconMap","getIconMap","shape","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AAUA,OAAOC,SAAP,MAAoD,sBAApD;AACA,SAASC,uBAAT,QAAwC,0BAAxC;;;;IAOqBC,U;;;;;;;;;;;;;;;;;;oEAiJK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADY;AAElBC,UAAAA,GAAG,EAAE,QAFa;AAGlBC,UAAAA,GAAG,EAAE,uBAHa;AAIlBC,UAAAA,MAAM,EAAE;AAJU,SAApB;;AAQA,cAAKC,KAAL,CAAWC,YAAX;;AACA;AACD;;AACD,YAAKT,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BC,QAAAA,GAAG,EAAEX,EAAE,CAACgB,MAFqB;AAI7BJ,QAAAA,GAAG,EAAEZ,EAAE,CAACiB,oBAJqB;AAK7BC,QAAAA,gBAAgB,EAAE,KALW;AAM7BC,QAAAA,KAAK,EAAE,IANsB;AAO7BC,QAAAA,MAAM,EAAE,MAAKX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rE,YAAAA,IAAI,EAAE,EAHA;AAINiC,YAAAA,IAAI,EAAEzC,EAAE,CAAC0C;AAJH,WAFE;AAQVoC,UAAAA,IAAI,EAAE,CARI;AASVvE,UAAAA,MAAM,EAAE,gBACNwE,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMG,OAAO,GAAG,MAAI,CAAC5E,WAAL,CAAiB6E,UAAjB,EAAhB;;AACA,gBAAQC,KAAR,GAAkBR,OAAlB,CAAQQ,KAAR;;AACA,wBAAiBF,OAAO,CAACE,KAAD,CAAP,IAA4B;AAAEC,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA7C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EA/IqCxF,S;;SAAnBE,U","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';\nimport { PointImageTriangulation } from '../../core/triangulation';\nimport pointImageFrag from '../shaders/image_frag.glsl';\nimport pointImageVert from '../shaders/image_vert.glsl';\ninterface IImageLayerStyleOptions {\n opacity: styleSingle;\n offsets: styleOffset;\n}\nexport default class ImageModel extends BaseModel {\n private texture: ITexture2D;\n\n public getUninforms(): IModelUniform {\n const {\n opacity,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_texture: this.texture,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n // u_opacity: opacity || 1.0,\n // u_offsets: [-offsets[0], offsets[1]],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n this.registerBuiltinAttributes();\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointImage',\n vertexShader: pointImageVert,\n fragmentShader: pointImageFrag,\n triangulation: PointImageTriangulation,\n primitive: gl.POINTS,\n depth: { enable: false },\n blend: this.getBlend(),\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 = 5 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { shape } = feature;\n const { x, y } = iconMap[shape as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n mag: 'linear',\n min: 'linear mipmap nearest',\n mipmap: true,\n });\n // this.layer.render();\n // TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层\n this.layer.renderLayers();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.LINEAR,\n // min: gl.LINEAR,\n min: gl.LINEAR_MIPMAP_LINEAR,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n mipmap: true,\n });\n };\n}\n"],"file":"image.js"}
1
+ {"version":3,"sources":["../../../src/point/models/image.ts"],"names":["AttributeType","gl","getMask","BaseModel","PointImageTriangulation","ImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","offsets","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","registerBuiltinAttributes","updateTexture","on","buildModels","destroy","off","mask","maskInside","buildLayerModel","moduleName","vertexShader","pointImageVert","fragmentShader","pointImageFrag","triangulation","primitive","POINTS","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","iconMap","getIconMap","shape","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,uBAAT,QAAwC,0BAAxC;;;;IAGqBC,U;;;;;;;;;;;;;;;;;;oEAsJK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADY;AAElBC,UAAAA,GAAG,EAAE,QAFa;AAGlBC,UAAAA,GAAG,EAAE,uBAHa;AAIlBC,UAAAA,MAAM,EAAE;AAJU,SAApB;;AAQA,cAAKC,KAAL,CAAWC,YAAX;;AACA;AACD;;AACD,YAAKT,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BC,QAAAA,GAAG,EAAEZ,EAAE,CAACiB,MAFqB;AAI7BJ,QAAAA,GAAG,EAAEb,EAAE,CAACkB,oBAJqB;AAK7BC,QAAAA,gBAAgB,EAAE,KALW;AAM7BC,QAAAA,KAAK,EAAE,IANsB;AAO7BC,QAAAA,MAAM,EAAE,MAAKX,WAAL,CAAiBY,YAAjB,IAAiC,GAPZ;AAQ7BR,QAAAA,MAAM,EAAE;AARqB,OAAD,CAA9B;AAUD,K;;;;;;;WA3KD,wBAAqC;AACnC,iBAGI,KAAKC,KAAL,CAAWQ,cAAX,EA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AENC,YAAAA,KAAK,EAAEhF,EAAE,CAACiF,YAFJ;AAGNxE,YAAAA,IAAI,EAAE,EAHA;AAINiC,YAAAA,IAAI,EAAE1C,EAAE,CAAC2C;AAJH,WAFE;AAQVuC,UAAAA,IAAI,EAAE,CARI;AASV1E,UAAAA,MAAM,EAAE,gBACN2E,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMG,OAAO,GAAG,MAAI,CAAC/E,WAAL,CAAiBgF,UAAjB,EAAhB;;AACA,gBAAQC,KAAR,GAAkBR,OAAlB,CAAQQ,KAAR;;AACA,wBAAiBF,OAAO,CAACE,KAAD,CAAP,IAA4B;AAAEC,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA7C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EApJqC3F,S;;SAAnBE,U","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointImageTriangulation } from '../../core/triangulation';\nimport pointImageFrag from '../shaders/image_frag.glsl';\nimport pointImageVert from '../shaders/image_vert.glsl';\nexport default class ImageModel extends BaseModel {\n private texture: ITexture2D;\n\n public getUninforms(): IModelUniform {\n const {\n opacity,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_texture: this.texture,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n // u_opacity: opacity || 1.0,\n // u_offsets: [-offsets[0], offsets[1]],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n this.registerBuiltinAttributes();\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointImage',\n vertexShader: pointImageVert,\n fragmentShader: pointImageFrag,\n triangulation: PointImageTriangulation,\n primitive: gl.POINTS,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\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 = 5 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { shape } = feature;\n const { x, y } = iconMap[shape as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n mag: 'linear',\n min: 'linear mipmap nearest',\n mipmap: true,\n });\n // this.layer.render();\n // TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层\n this.layer.renderLayers();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.LINEAR,\n // min: gl.LINEAR,\n min: gl.LINEAR_MIPMAP_LINEAR,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n mipmap: true,\n });\n };\n}\n"],"file":"image.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/index.ts"],"names":["ExtrudeModel","FillModel","IconModel","IMageModel","NormalModel","SimplePopint","TextModel","PointModels","fill","image","normal","simplePoint","extrude","text","icon"],"mappings":"AACA,OAAOA,YAAP,MAAyB,WAAzB;AACA,OAAOC,SAAP,MAAsB,QAAtB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,WAAP,MAAwB,UAAxB;AACA,OAAOC,YAAP,MAAyB,eAAzB;AACA,OAAOC,SAAP,MAAsB,QAAtB;AAWA,IAAMC,WAAwC,GAAG;AAC/CC,EAAAA,IAAI,EAAEP,SADyC;AAE/CQ,EAAAA,KAAK,EAAEN,UAFwC;AAG/CO,EAAAA,MAAM,EAAEN,WAHuC;AAI/CO,EAAAA,WAAW,EAAEN,YAJkC;AAK/CO,EAAAA,OAAO,EAAEZ,YALsC;AAM/Ca,EAAAA,IAAI,EAAEP,SANyC;AAO/CQ,EAAAA,IAAI,EAAEZ;AAPyC,CAAjD;AAUA,eAAeK,WAAf","sourcesContent":["import { ILayerModel } from '@antv/l7-core';\nimport ExtrudeModel from './extrude';\nimport FillModel from './fill';\nimport IconModel from './icon-font';\nimport IMageModel from './image';\nimport NormalModel from './normal';\nimport SimplePopint from './simplePoint';\nimport TextModel from './text';\n\nexport type PointType =\n | 'fill'\n | 'image'\n | 'normal'\n | 'simplePoint'\n | 'extrude'\n | 'text'\n | 'icon';\n\nconst PointModels: { [key in PointType]: any } = {\n fill: FillModel,\n image: IMageModel,\n normal: NormalModel,\n simplePoint: SimplePopint,\n extrude: ExtrudeModel,\n text: TextModel,\n icon: IconModel,\n};\n\nexport default PointModels;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/point/models/index.ts"],"names":["ExtrudeModel","FillModel","IconModel","IMageModel","NormalModel","SimplePopint","TextModel","PointModels","fill","image","normal","simplePoint","extrude","text","icon"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,WAAzB;AACA,OAAOC,SAAP,MAAsB,QAAtB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,WAAP,MAAwB,UAAxB;AACA,OAAOC,YAAP,MAAyB,eAAzB;AACA,OAAOC,SAAP,MAAsB,QAAtB;AAWA,IAAMC,WAAwC,GAAG;AAC/CC,EAAAA,IAAI,EAAEP,SADyC;AAE/CQ,EAAAA,KAAK,EAAEN,UAFwC;AAG/CO,EAAAA,MAAM,EAAEN,WAHuC;AAI/CO,EAAAA,WAAW,EAAEN,YAJkC;AAK/CO,EAAAA,OAAO,EAAEZ,YALsC;AAM/Ca,EAAAA,IAAI,EAAEP,SANyC;AAO/CQ,EAAAA,IAAI,EAAEZ;AAPyC,CAAjD;AAUA,eAAeK,WAAf","sourcesContent":["import ExtrudeModel from './extrude';\nimport FillModel from './fill';\nimport IconModel from './icon-font';\nimport IMageModel from './image';\nimport NormalModel from './normal';\nimport SimplePopint from './simplePoint';\nimport TextModel from './text';\n\nexport type PointType =\n | 'fill'\n | 'image'\n | 'normal'\n | 'simplePoint'\n | 'extrude'\n | 'text'\n | 'icon';\n\nconst PointModels: { [key in PointType]: any } = {\n fill: FillModel,\n image: IMageModel,\n normal: NormalModel,\n simplePoint: SimplePopint,\n extrude: ExtrudeModel,\n text: TextModel,\n icon: IconModel,\n};\n\nexport default PointModels;\n"],"file":"index.js"}
@@ -1,9 +1,6 @@
1
1
  import { IEncodeFeature, ILayerConfig, IModel, IModelUniform } from '@antv/l7-core';
2
- import BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';
3
- interface IPointLayerStyleOptions {
4
- opacity: styleSingle;
5
- offsets: styleOffset;
6
- }
2
+ import BaseModel from '../../core/BaseModel';
3
+ import { IPointLayerStyleOptions } from '../../core/interface';
7
4
  export declare function PointTriangulation(feature: IEncodeFeature): {
8
5
  vertices: number[];
9
6
  indices: number[];
@@ -18,4 +15,3 @@ export default class NormalModel extends BaseModel {
18
15
  protected registerBuiltinAttributes(): void;
19
16
  private defaultStyleOptions;
20
17
  }
21
- export {};
@@ -11,6 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
12
 
13
13
  import { AttributeType, BlendType, gl } from '@antv/l7-core';
14
+ import { getMask } from '@antv/l7-utils';
14
15
  import BaseModel from '../../core/BaseModel';
15
16
  var normalFrag = "\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n float opacity = styleMappingMat[0][0];\n\n gl_FragColor = v_color;\n // gl_FragColor.a =gl_FragColor.a * u_opacity;\n gl_FragColor.a =gl_FragColor.a * opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
16
17
  var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\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 \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = 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\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n \n // vec2 offset = project_pixel(u_offsets);\n vec2 offset = project_pixel(textrueOffsets);\n // vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n // gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\\\n // \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // vec2 offset = project_pixel((u_offsets));\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n // vec2 offset = project_pixel(u_offsets);\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
@@ -98,6 +99,12 @@ var NormalModel = function (_BaseModel) {
98
99
  }, {
99
100
  key: "buildModels",
100
101
  value: function buildModels() {
102
+ var _ref2 = this.layer.getLayerConfig(),
103
+ _ref2$mask = _ref2.mask,
104
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
105
+ _ref2$maskInside = _ref2.maskInside,
106
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
107
+
101
108
  return [this.layer.buildLayerModel({
102
109
  moduleName: 'normalpoint',
103
110
  vertexShader: normalVert,
@@ -107,7 +114,8 @@ var NormalModel = function (_BaseModel) {
107
114
  enable: false
108
115
  },
109
116
  primitive: gl.POINTS,
110
- blend: this.getBlend()
117
+ blend: this.getBlend(),
118
+ stencil: getMask(mask, maskInside)
111
119
  })];
112
120
  }
113
121
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["AttributeType","BlendType","gl","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","NormalModel","blend","layer","getLayerConfig","opacity","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","triangulation","depth","enable","primitive","POINTS","getBlend","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAQO,eARP;AAYA,OAAOC,SAAP,MAAoD,sBAApD;;;AAQA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,W;;;;;;;;;;;;;WACnB,2BAA0E;AACxE,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;;WACD,wBAAqC;AACnC,iBAGI,KAAKC,KAAL,CAAWC,cAAX,EAHJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAAC,CAAD,EAAI,CAAJ,CAFZ;;AAKA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBH,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,OAAO,EAAPA;AAFyB,OAA3B,CAFF,EAME;AAEA,aAAKG,oBAAL,CAA0B;AACxBJ,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,OAAO,EAAPA;AAFwB,SAA1B;AAIA,YAAMI,UAAU,GAAG,KAAKP,KAAL,CAAWQ,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAA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ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';\nimport { BlendTypes } from '../../utils/blend';\nimport normalFrag from '../shaders/normal_frag.glsl';\nimport normalVert from '../shaders/normal_vert.glsl';\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n offsets: styleOffset;\n}\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class NormalModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions & ILayerConfig> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n // u_stroke_width: strokeWidth,\n // u_stroke_color: rgb2arr(stroke),\n // u_offsets: [-offsets[0], offsets[1]],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'normalpoint',\n vertexShader: normalVert,\n fragmentShader: normalFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\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\n private defaultStyleOptions(): Partial<\n IPointLayerStyleOptions & ILayerConfig\n > {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"normal.js"}
1
+ {"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","NormalModel","blend","layer","getLayerConfig","opacity","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","triangulation","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAQO,eARP;AASA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;;;AAKA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,W;;;;;;;;;;;;;WACnB,2BAA0E;AACxE,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;;WACD,wBAAqC;AACnC,iBAGI,KAAKC,KAAL,CAAWC,cAAX,EAHJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAAC,CAAD,EAAI,CAAJ,CAFZ;;AAKA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBH,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,OAAO,EAAPA;AAFyB,OAA3B,CAFF,EAME;AAEA,aAAKG,oBAAL,CAA0B;AACxBJ,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,OAAO,EAAPA;AAFwB,SAA1B;AAIA,YAAMI,UAAU,GAAG,KAAKP,KAAL,CAAWQ,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd,sBAAcA,KAAd;A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AACLG,QAAAA,KAAK,EAAEZ,SAAS,CAACyE;AADZ,OAAP;AAGD;;;;EAzHsCtE,S;;SAApBQ,W","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport normalFrag from '../shaders/normal_frag.glsl';\nimport normalVert from '../shaders/normal_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class NormalModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions & ILayerConfig> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'normalpoint',\n vertexShader: normalVert,\n fragmentShader: normalFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\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\n private defaultStyleOptions(): Partial<\n IPointLayerStyleOptions & ILayerConfig\n > {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"normal.js"}
@@ -1,13 +1,6 @@
1
1
  import { IEncodeFeature, ILayerConfig, IModel, IModelUniform } from '@antv/l7-core';
2
- import BaseModel, { styleColor, styleOffset, styleSingle } from '../../core/BaseModel';
3
- interface IPointLayerStyleOptions {
4
- opacity: styleSingle;
5
- offsets: styleOffset;
6
- blend: string;
7
- strokeOpacity: styleSingle;
8
- strokeWidth: styleSingle;
9
- stroke: styleColor;
10
- }
2
+ import BaseModel from '../../core/BaseModel';
3
+ import { IPointLayerStyleOptions } from '../../core/interface';
11
4
  export declare function PointTriangulation(feature: IEncodeFeature): {
12
5
  vertices: number[];
13
6
  indices: number[];
@@ -22,4 +15,3 @@ export default class SimplePointModel extends BaseModel {
22
15
  protected registerBuiltinAttributes(): void;
23
16
  private defaultStyleOptions;
24
17
  }
25
- export {};