@antv/l7-layers 2.7.1 → 2.7.2

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 (117) hide show
  1. package/es/core/interface.d.ts +60 -1
  2. package/es/core/interface.js.map +1 -1
  3. package/es/heatmap/index.d.ts +1 -4
  4. package/es/heatmap/index.js.map +1 -1
  5. package/es/heatmap/models/grid.js +9 -1
  6. package/es/heatmap/models/grid.js.map +1 -1
  7. package/es/heatmap/models/grid3d.js +9 -1
  8. package/es/heatmap/models/grid3d.js.map +1 -1
  9. package/es/heatmap/models/heatmap.js +29 -15
  10. package/es/heatmap/models/heatmap.js.map +1 -1
  11. package/es/heatmap/models/hexagon.js +9 -1
  12. package/es/heatmap/models/hexagon.js.map +1 -1
  13. package/es/image/index.d.ts +1 -4
  14. package/es/image/index.js.map +1 -1
  15. package/es/image/models/image.d.ts +3 -3
  16. package/es/image/models/image.js +9 -2
  17. package/es/image/models/image.js.map +1 -1
  18. package/es/index.d.ts +2 -1
  19. package/es/index.js +2 -1
  20. package/es/index.js.map +1 -1
  21. package/es/line/models/arc.js +8 -3
  22. package/es/line/models/arc.js.map +1 -1
  23. package/es/line/models/arc_3d.js +8 -3
  24. package/es/line/models/arc_3d.js.map +1 -1
  25. package/es/line/models/great_circle.js +13 -6
  26. package/es/line/models/great_circle.js.map +1 -1
  27. package/es/line/models/line.js +12 -5
  28. package/es/line/models/line.js.map +1 -1
  29. package/es/line/models/simpleLine.js +9 -2
  30. package/es/line/models/simpleLine.js.map +1 -1
  31. package/es/mask/index.d.ts +21 -0
  32. package/es/mask/index.js +73 -0
  33. package/es/mask/index.js.map +1 -0
  34. package/es/mask/models/fill.d.ts +11 -0
  35. package/es/mask/models/fill.js +92 -0
  36. package/es/mask/models/fill.js.map +1 -0
  37. package/es/mask/models/index.d.ts +5 -0
  38. package/es/mask/models/index.js +6 -0
  39. package/es/mask/models/index.js.map +1 -0
  40. package/es/point/index.d.ts +1 -6
  41. package/es/point/index.js.map +1 -1
  42. package/es/point/models/fill.js +9 -1
  43. package/es/point/models/fill.js.map +1 -1
  44. package/es/point/models/image.js +12 -4
  45. package/es/point/models/image.js.map +1 -1
  46. package/es/point/models/index.js.map +1 -1
  47. package/es/point/models/normal.d.ts +2 -6
  48. package/es/point/models/normal.js +9 -1
  49. package/es/point/models/normal.js.map +1 -1
  50. package/es/point/models/simplePoint.d.ts +2 -10
  51. package/es/point/models/simplePoint.js +9 -1
  52. package/es/point/models/simplePoint.js.map +1 -1
  53. package/es/point/models/text.js +60 -46
  54. package/es/point/models/text.js.map +1 -1
  55. package/es/polygon/index.d.ts +1 -4
  56. package/es/polygon/index.js.map +1 -1
  57. package/es/polygon/models/extrude.js +8 -2
  58. package/es/polygon/models/extrude.js.map +1 -1
  59. package/es/polygon/models/fill.js +8 -2
  60. package/es/polygon/models/fill.js.map +1 -1
  61. package/es/raster/index.d.ts +1 -10
  62. package/es/raster/index.js.map +1 -1
  63. package/es/raster/models/raster.d.ts +3 -3
  64. package/es/raster/models/raster.js +13 -6
  65. package/es/raster/models/raster.js.map +1 -1
  66. package/lib/core/interface.js.map +1 -1
  67. package/lib/heatmap/index.js.map +1 -1
  68. package/lib/heatmap/models/grid.js +10 -1
  69. package/lib/heatmap/models/grid.js.map +1 -1
  70. package/lib/heatmap/models/grid3d.js +10 -1
  71. package/lib/heatmap/models/grid3d.js.map +1 -1
  72. package/lib/heatmap/models/heatmap.js +28 -14
  73. package/lib/heatmap/models/heatmap.js.map +1 -1
  74. package/lib/heatmap/models/hexagon.js +10 -1
  75. package/lib/heatmap/models/hexagon.js.map +1 -1
  76. package/lib/image/index.js.map +1 -1
  77. package/lib/image/models/image.js +8 -1
  78. package/lib/image/models/image.js.map +1 -1
  79. package/lib/index.js +8 -0
  80. package/lib/index.js.map +1 -1
  81. package/lib/line/models/arc.js +7 -2
  82. package/lib/line/models/arc.js.map +1 -1
  83. package/lib/line/models/arc_3d.js +7 -2
  84. package/lib/line/models/arc_3d.js.map +1 -1
  85. package/lib/line/models/great_circle.js +12 -5
  86. package/lib/line/models/great_circle.js.map +1 -1
  87. package/lib/line/models/line.js +11 -4
  88. package/lib/line/models/line.js.map +1 -1
  89. package/lib/line/models/simpleLine.js +8 -1
  90. package/lib/line/models/simpleLine.js.map +1 -1
  91. package/lib/mask/index.js +86 -0
  92. package/lib/mask/index.js.map +1 -0
  93. package/lib/mask/models/fill.js +107 -0
  94. package/lib/mask/models/fill.js.map +1 -0
  95. package/lib/mask/models/index.js +17 -0
  96. package/lib/mask/models/index.js.map +1 -0
  97. package/lib/point/index.js.map +1 -1
  98. package/lib/point/models/fill.js +10 -1
  99. package/lib/point/models/fill.js.map +1 -1
  100. package/lib/point/models/image.js +13 -4
  101. package/lib/point/models/image.js.map +1 -1
  102. package/lib/point/models/index.js.map +1 -1
  103. package/lib/point/models/normal.js +10 -1
  104. package/lib/point/models/normal.js.map +1 -1
  105. package/lib/point/models/simplePoint.js +10 -1
  106. package/lib/point/models/simplePoint.js.map +1 -1
  107. package/lib/point/models/text.js +59 -45
  108. package/lib/point/models/text.js.map +1 -1
  109. package/lib/polygon/index.js.map +1 -1
  110. package/lib/polygon/models/extrude.js +9 -2
  111. package/lib/polygon/models/extrude.js.map +1 -1
  112. package/lib/polygon/models/fill.js +9 -2
  113. package/lib/polygon/models/fill.js.map +1 -1
  114. package/lib/raster/index.js.map +1 -1
  115. package/lib/raster/models/raster.js +12 -5
  116. package/lib/raster/models/raster.js.map +1 -1
  117. package/package.json +5 -5
@@ -1,4 +1,6 @@
1
- import { styleSingle } from '../core/BaseModel';
1
+ import { IColorRamp } from '@antv/l7-utils';
2
+ import { styleOffset, styleSingle } from '../core/BaseModel';
3
+ import { anchorType } from '../utils/symbol-layout';
2
4
  export declare enum lineStyleType {
3
5
  'solid' = 0,
4
6
  'dash' = 1
@@ -21,4 +23,61 @@ export interface ILineLayerStyleOptions {
21
23
  borderWidth?: number;
22
24
  borderColor?: string;
23
25
  heightfixed?: boolean;
26
+ mask?: boolean;
27
+ maskInside?: boolean;
28
+ }
29
+ export interface IPointLayerStyleOptions {
30
+ opacity: number;
31
+ strokeOpacity: number;
32
+ strokeWidth: number;
33
+ stroke: string;
34
+ textOffset?: [number, number];
35
+ textAnchor?: anchorType;
36
+ spacing?: number;
37
+ padding?: [number, number];
38
+ halo?: number;
39
+ gamma?: number;
40
+ fontWeight?: string;
41
+ fontFamily?: string;
42
+ textAllowOverlap?: boolean;
43
+ offsets?: styleOffset;
44
+ blend?: string;
45
+ unit?: string;
46
+ mask?: boolean;
47
+ maskInside?: boolean;
48
+ }
49
+ export interface IPolygonLayerStyleOptions {
50
+ opacity: styleSingle;
51
+ opacityLinear: {
52
+ enable: boolean;
53
+ dir: string;
54
+ };
55
+ pickLight: boolean;
56
+ mask?: boolean;
57
+ maskInside?: boolean;
58
+ }
59
+ export interface IImageLayerStyleOptions {
60
+ opacity: number;
61
+ mask?: boolean;
62
+ maskInside?: boolean;
63
+ }
64
+ export interface IHeatMapLayerStyleOptions {
65
+ opacity: number;
66
+ intensity: number;
67
+ radius: number;
68
+ angle: number;
69
+ rampColors: IColorRamp;
70
+ mask?: boolean;
71
+ maskInside?: boolean;
72
+ coverage?: number;
73
+ }
74
+ export interface IRasterLayerStyleOptions {
75
+ opacity: number;
76
+ domain: [number, number];
77
+ noDataValue: number;
78
+ clampLow: boolean;
79
+ clampHigh: boolean;
80
+ rampColors: IColorRamp;
81
+ mask?: boolean;
82
+ maskInside?: boolean;
24
83
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType"],"mappings":"AACA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["import { styleSingle } from '../core/BaseModel';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n}\n"],"file":"interface.js"}
1
+ {"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType"],"mappings":"AAQA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["import { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\nimport { styleColor, styleOffset, styleSingle } from '../core/BaseModel';\nimport {\n anchorType,\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../utils/symbol-layout';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n\n mask?: boolean; // 可选参数 时候允许蒙层\n maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部\n}\n\nexport interface IPointLayerStyleOptions {\n opacity: number;\n strokeOpacity: number;\n strokeWidth: number;\n stroke: string;\n\n textOffset?: [number, number];\n textAnchor?: anchorType;\n spacing?: number;\n padding?: [number, number];\n halo?: number;\n gamma?: number;\n fontWeight?: string;\n fontFamily?: string;\n textAllowOverlap?: boolean;\n\n offsets?: styleOffset;\n blend?: string;\n unit?: string;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n\n pickLight: boolean;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IImageLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n\n coverage?: number;\n}\n\nexport interface IRasterLayerStyleOptions {\n opacity: number;\n domain: [number, number];\n noDataValue: number;\n clampLow: boolean;\n clampHigh: boolean;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n}\n"],"file":"interface.js"}
@@ -1,8 +1,6 @@
1
1
  import BaseLayer from '../core/BaseLayer';
2
+ import { IHeatMapLayerStyleOptions } from '../core/interface';
2
3
  import { HeatMapModelType } from './models';
3
- interface IHeatMapLayerStyleOptions {
4
- opacity: number;
5
- }
6
4
  export default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {
7
5
  type: string;
8
6
  buildModels(): void;
@@ -19,4 +17,3 @@ export default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {
19
17
  };
20
18
  protected getModelType(): HeatMapModelType;
21
19
  }
22
- export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/heatmap/index.ts"],"names":["BaseLayer","HeatMapModels","HeatMapLayer","shape","getModelType","layerModel","models","initModels","buildModels","render","layerModelNeedUpdate","forEach","model","draw","uniforms","getUninforms","properties","opacity","type","minimum","maximum","shapeAttribute","styleAttributeService","getLayerStyleAttribute","getLayerConfig","shape3d","source","getSource","sourceType","data","scale","field","indexOf"],"mappings":";;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,mBAAtB;AACA,OAAOC,aAAP,MAAgD,UAAhD;;IAIqBC,Y;;;;;;;;;;;;;;;;2DACG,c;;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIJ,aAAa,CAACE,KAAD,CAAjB,CAAyB,IAAzB,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WACD,wBAAsB;AAAA;;AACpB,UAAML,KAAK,GAAG,KAAKC,YAAL,EAAd;;AACA,UAAID,KAAK,KAAK,SAAd,EAAyB;AACvB,YAAI,KAAKE,UAAT,EAAqB;AACnB,eAAKA,UAAL,CAAgBI,MAAhB;AACD;;AAED,eAAO,IAAP;AACD;;AACD,UAAI,KAAKC,oBAAT,EAA+B;AAC7B,aAAKJ,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACA,aAAKE,oBAAL,GAA4B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C,MAAjC,GAA0C,QAAjD;AACD;;AACD,aAAO,SAAP;AACD;;;;EA9DuCH,S;;SAArBE,Y","sourcesContent":["import { AttributeType, gl, IEncodeFeature, ILayer } from '@antv/l7-core';\nimport BaseLayer from '../core/BaseLayer';\nimport HeatMapModels, { HeatMapModelType } from './models';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n}\nexport default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {\n public type: string = 'HeatMapLayer';\n\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new HeatMapModels[shape](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n public renderModels() {\n const shape = this.getModelType();\n if (shape === 'heatmap') {\n if (this.layerModel) {\n this.layerModel.render(); // 独立的渲染流程\n }\n\n return this;\n }\n if (this.layerModelNeedUpdate) {\n this.models = this.layerModel.buildModels();\n this.layerModelNeedUpdate = false;\n }\n this.models.forEach((model) =>\n model.draw({\n uniforms: this.layerModel.getUninforms(),\n }),\n );\n return this;\n }\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected getModelType(): HeatMapModelType {\n const shapeAttribute = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const { shape3d } = this.getLayerConfig();\n const source = this.getSource();\n const sourceType = source.data.type;\n const shape =\n (shapeAttribute?.scale?.field as HeatMapModelType) || 'heatmap';\n if (shape === 'heatmap' || shape === 'heatmap3d') {\n return 'heatmap';\n }\n if (sourceType === 'hexagon') {\n return shape3d?.indexOf(shape) === -1 ? 'hexagon' : 'grid3d';\n }\n if (sourceType === 'grid') {\n return shape3d?.indexOf(shape) === -1 ? 'grid' : 'grid3d';\n }\n return 'heatmap';\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/heatmap/index.ts"],"names":["BaseLayer","HeatMapModels","HeatMapLayer","shape","getModelType","layerModel","models","initModels","buildModels","render","layerModelNeedUpdate","forEach","model","draw","uniforms","getUninforms","properties","opacity","type","minimum","maximum","shapeAttribute","styleAttributeService","getLayerStyleAttribute","getLayerConfig","shape3d","source","getSource","sourceType","data","scale","field","indexOf"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,aAAP,MAAgD,UAAhD;;IACqBC,Y;;;;;;;;;;;;;;;;2DACG,c;;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIJ,aAAa,CAACE,KAAD,CAAjB,CAAyB,IAAzB,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WACD,wBAAsB;AAAA;;AACpB,UAAML,KAAK,GAAG,KAAKC,YAAL,EAAd;;AACA,UAAID,KAAK,KAAK,SAAd,EAAyB;AACvB,YAAI,KAAKE,UAAT,EAAqB;AACnB,eAAKA,UAAL,CAAgBI,MAAhB;AACD;;AAED,eAAO,IAAP;AACD;;AACD,UAAI,KAAKC,oBAAT,EAA+B;AAC7B,aAAKJ,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACA,aAAKE,oBAAL,GAA4B,KAA5B;AACD;;AACD,WAAKJ,MAAL,CAAYK,OAAZ,CAAoB,UAACC,KAAD;AAAA,eAClBA,KAAK,CAACC,IAAN,CAAW;AACTC,UAAAA,QAAQ,EAAE,MAAI,CAACT,UAAL,CAAgBU,YAAhB;AADD,SAAX,CADkB;AAAA,OAApB;AAKA,aAAO,IAAP;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;;;WAED,wBAA2C;AAAA;;AACzC,UAAMC,cAAc,GAAG,KAAKC,qBAAL,CAA2BC,sBAA3B,CACrB,OADqB,CAAvB;;AAGA,iCAAoB,KAAKC,cAAL,EAApB;AAAA,UAAQC,OAAR,wBAAQA,OAAR;;AACA,UAAMC,MAAM,GAAG,KAAKC,SAAL,EAAf;AACA,UAAMC,UAAU,GAAGF,MAAM,CAACG,IAAP,CAAYX,IAA/B;AACA,UAAMf,KAAK,GACT,CAACkB,cAAD,aAACA,cAAD,gDAACA,cAAc,CAAES,KAAjB,0DAAC,sBAAuBC,KAAxB,KAAsD,SADxD;;AAEA,UAAI5B,KAAK,KAAK,SAAV,IAAuBA,KAAK,KAAK,WAArC,EAAkD;AAChD,eAAO,SAAP;AACD;;AACD,UAAIyB,UAAU,KAAK,SAAnB,EAA8B;AAC5B,eAAO,CAAAH,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEO,OAAT,CAAiB7B,KAAjB,OAA4B,CAAC,CAA7B,GAAiC,SAAjC,GAA6C,QAApD;AACD;;AACD,UAAIyB,UAAU,KAAK,MAAnB,EAA2B;AACzB,eAAO,CAAAH,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEO,OAAT,CAAiB7B,KAAjB,OAA4B,CAAC,CAA7B,GAAiC,MAAjC,GAA0C,QAAjD;AACD;;AACD,aAAO,SAAP;AACD;;;;EA9DuCH,S;;SAArBE,Y","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { IHeatMapLayerStyleOptions } from '../core/interface';\nimport HeatMapModels, { HeatMapModelType } from './models';\nexport default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {\n public type: string = 'HeatMapLayer';\n\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new HeatMapModels[shape](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n public renderModels() {\n const shape = this.getModelType();\n if (shape === 'heatmap') {\n if (this.layerModel) {\n this.layerModel.render(); // 独立的渲染流程\n }\n\n return this;\n }\n if (this.layerModelNeedUpdate) {\n this.models = this.layerModel.buildModels();\n this.layerModelNeedUpdate = false;\n }\n this.models.forEach((model) =>\n model.draw({\n uniforms: this.layerModel.getUninforms(),\n }),\n );\n return this;\n }\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected getModelType(): HeatMapModelType {\n const shapeAttribute = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const { shape3d } = this.getLayerConfig();\n const source = this.getSource();\n const sourceType = source.data.type;\n const shape =\n (shapeAttribute?.scale?.field as HeatMapModelType) || 'heatmap';\n if (shape === 'heatmap' || shape === 'heatmap3d') {\n return 'heatmap';\n }\n if (sourceType === 'hexagon') {\n return shape3d?.indexOf(shape) === -1 ? 'hexagon' : 'grid3d';\n }\n if (sourceType === 'grid') {\n return shape3d?.indexOf(shape) === -1 ? 'grid' : 'grid3d';\n }\n return 'heatmap';\n }\n}\n"],"file":"index.js"}
@@ -9,6 +9,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
9
9
  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; } }
10
10
 
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
+ import { getMask } from '@antv/l7-utils';
12
13
  import BaseModel from '../../core/BaseModel';
13
14
  import { HeatmapGridTriangulation } from '../../core/triangulation';
14
15
  var heatmapGridVert = "precision highp float;\r\n// \u591A\u8FB9\u5F62\u9876\u70B9\u5750\u6807\r\nattribute vec3 a_Position;\r\n// \u591A\u8FB9\u5F62\u7ECF\u7EAC\u5EA6\u5750\u6807\r\nattribute vec3 a_Pos;\r\nattribute float a_Size;\r\nattribute vec4 a_Color;\r\nuniform vec2 u_radius;\r\nuniform float u_coverage: 0.9;\r\nuniform float u_angle: 0;\r\nuniform mat4 u_ModelMatrix;\r\nuniform mat4 u_Mvp;\r\nvarying vec4 v_color;\r\n\r\nuniform vec2 u_SceneCenterMKT;\r\n\r\n#pragma include \"projection\"\r\n#pragma include \"project\"\r\n#pragma include \"picking\"\r\n\r\nvoid main() {\r\n v_color = a_Color;\r\n\r\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\r\n vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage ;\r\n // vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\r\n // vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\r\n // gl_Position = project_common_position_to_clipspace(project_pos);\r\n\r\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\r\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\r\n vec2 customLnglat = customProject(lnglat) - u_SceneCenterMKT; // \u5C06\u7ECF\u7EAC\u5EA6\u8F6C\u6362\u4E3A\u9AD8\u5FB72.0\u9700\u8981\u7684\u5E73\u9762\u5750\u6807\r\n vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));\r\n gl_Position = u_Mvp * (project_pos);\r\n } else {\r\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\r\n vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\r\n gl_Position = project_common_position_to_clipspace(project_pos);\r\n }\r\n\r\n setPickingColor(a_PickingColor);\r\n}\r\n";
@@ -48,6 +49,12 @@ var GridModel = function (_BaseModel) {
48
49
  }, {
49
50
  key: "buildModels",
50
51
  value: function buildModels() {
52
+ var _ref2 = this.layer.getLayerConfig(),
53
+ _ref2$mask = _ref2.mask,
54
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
55
+ _ref2$maskInside = _ref2.maskInside,
56
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
57
+
51
58
  return [this.layer.buildLayerModel({
52
59
  moduleName: 'gridheatmap',
53
60
  vertexShader: heatmapGridVert,
@@ -57,7 +64,8 @@ var GridModel = function (_BaseModel) {
57
64
  enable: false
58
65
  },
59
66
  primitive: gl.TRIANGLES,
60
- blend: this.getBlend()
67
+ blend: this.getBlend(),
68
+ stencil: getMask(mask, maskInside)
61
69
  })];
62
70
  }
63
71
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/heatmap/models/grid.ts"],"names":["AttributeType","gl","BaseModel","HeatmapGridTriangulation","GridModel","layer","getLayerConfig","opacity","coverage","angle","u_opacity","u_coverage","u_angle","u_radius","getSource","data","xOffset","yOffset","buildModels","buildLayerModel","moduleName","vertexShader","heatmapGridVert","fragmentShader","heatmapGridFrag","triangulation","depth","enable","primitive","TRIANGLES","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates"],"mappings":";;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,wBAAT,QAAyC,0BAAzC;;;;IAQqBC,S;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,QAFF,QAEEA,QAFF;AAAA,UAGEC,KAHF,QAGEA,KAHF;;AAKA,aAAO;AACLC,QAAAA,SAAS,EAAEH,OAAO,IAAI,GADjB;AAELI,QAAAA,UAAU,EAAEH,QAAQ,IAAI,GAFnB;AAGLI,QAAAA,OAAO,EAAEH,KAAK,IAAI,CAHb;AAILI,QAAAA,QAAQ,EAAE,CACR,KAAKR,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BC,OADpB,E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AzDoC5C,S;;SAAlBE,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapGridTriangulation } from '../../core/triangulation';\nimport heatmapGridVert from '../shaders/grid_vert.glsl';\nimport heatmapGridFrag from '../shaders/hexagon_frag.glsl';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n coverage: number;\n angle: number;\n}\nexport default class GridModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n coverage,\n angle,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n return {\n u_opacity: opacity || 1.0,\n u_coverage: coverage || 0.9,\n u_angle: angle || 0,\n u_radius: [\n this.layer.getSource().data.xOffset,\n this.layer.getSource().data.yOffset,\n ],\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: 'gridheatmap',\n vertexShader: heatmapGridVert,\n fragmentShader: heatmapGridFrag,\n triangulation: HeatmapGridTriangulation,\n depth: { enable: false },\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos', // 顶点经纬度位置\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: (feature: IEncodeFeature, featureIdx: number) => {\n // const coordinates = feature.coordinates as number[];\n const coordinates = (feature.version === 'GAODE2.x'\n ? feature.originCoordinates\n : feature.coordinates) as number[];\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"grid.js"}
1
+ {"version":3,"sources":["../../../src/heatmap/models/grid.ts"],"names":["AttributeType","gl","getMask","BaseModel","HeatmapGridTriangulation","GridModel","layer","getLayerConfig","opacity","coverage","angle","u_opacity","u_coverage","u_angle","u_radius","getSource","data","xOffset","yOffset","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","heatmapGridVert","fragmentShader","heatmapGridFrag","triangulation","depth","enable","primitive","TRIANGLES","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates"],"mappings":";;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,wBAAT,QAAyC,0BAAzC;;;;IAGqBC,S;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,QAFF,QAEEA,QAFF;AAAA,UAGEC,KAHF,QAGEA,KAHF;;AAKA,aAAO;AACLC,QAAAA,SAAS,EAAEH,OAAO,IAAI,GADjB;AAELI,QAAAA,UAAU,EAAEH,QAAQ,IAAI,GAFnB;AAGLI,QAAAA,OAAO,EAAEH,KAAK,IAAI,CAHb;AAILI,QAAAA,QAAQ,EAAE,CACR,KAAKR,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BC,OADpB,EAER,KAAKX,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BE,OAFpB;AAJL,OAAP;AASD;;;WAED,sBAA8B;AAC5B,aAAO,KAAKC,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,kBAGI,KAAKb,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEa,IADF;AAAA,UACEA,IADF,2BACS,KADT;AAAA,mCAEEC,UAFF;AAAA,UAEEA,UAFF,iCAEe,IAFf;;AAIA,aAAO,CACL,KAAKf,KAAL,CAAWgB,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,aADa;AAEzBC,QAAAA,YAAY,EAAEC,eAFW;AAGzBC,QAAAA,cAAc,EAAEC,eAHS;AAIzBC,QAAAA,aAAa,EAAExB,wBAJU;AAKzByB,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,SAAS,EAAE9B,EAAE,CAAC+B,SANW;AAOzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EAPkB;AAQzBC,QAAAA,OAAO,EAAEjC,OAAO,CAACkB,IAAD,EAAOC,UAAP;AARS,OAA3B,CADK,CAAP;AAYD;;;WACD,qCAAsC;AACpC,WAAKe,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhDC,QAAAA,IAAI,EAAEvC,aAAa,CAACwC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE1C,EAAE,CAAC2C,YAFJ;AAGN5B,YAAAA,IAAI,EAAE,EAHA;AAINuB,YAAAA,IAAI,EAAEtC,EAAE,CAAC4C;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AAEvD,gBAAMC,WAAW,GAAIF,OAAO,CAACG,OAAR,KAAoB,UAApB,GACjBH,OAAO,CAACI,iBADS,GAEjBJ,OAAO,CAACE,WAFZ;AAGA,mBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AAfS;AAHoC,OAAlD;AAqBD;;;;EA9DoC/C,S;;SAAlBE,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IHeatMapLayerStyleOptions } from '../../core/interface';\nimport { HeatmapGridTriangulation } from '../../core/triangulation';\nimport heatmapGridVert from '../shaders/grid_vert.glsl';\nimport heatmapGridFrag from '../shaders/hexagon_frag.glsl';\nexport default class GridModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n coverage,\n angle,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n return {\n u_opacity: opacity || 1.0,\n u_coverage: coverage || 0.9,\n u_angle: angle || 0,\n u_radius: [\n this.layer.getSource().data.xOffset,\n this.layer.getSource().data.yOffset,\n ],\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 IHeatMapLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'gridheatmap',\n vertexShader: heatmapGridVert,\n fragmentShader: heatmapGridFrag,\n triangulation: HeatmapGridTriangulation,\n depth: { enable: false },\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos', // 顶点经纬度位置\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: (feature: IEncodeFeature, featureIdx: number) => {\n // const coordinates = feature.coordinates as number[];\n const coordinates = (feature.version === 'GAODE2.x'\n ? feature.originCoordinates\n : feature.coordinates) as number[];\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"grid.js"}
@@ -9,6 +9,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
9
9
  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; } }
10
10
 
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
+ import { getMask } from '@antv/l7-utils';
12
13
  import BaseModel from '../../core/BaseModel';
13
14
  import { PointExtrudeTriangulation } from '../../core/triangulation';
14
15
  var heatmapGrid3dVert = "precision highp float;\n// \u591A\u8FB9\u5F62\u9876\u70B9\u5750\u6807\nattribute vec3 a_Position;\n// \u591A\u8FB9\u5F62\u7ECF\u7EAC\u5EA6\u5750\u6807\nattribute vec3 a_Pos;\n\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec4 a_Color;\nuniform vec2 u_radius;\nuniform float u_coverage: 0.9;\nuniform float u_angle: 0;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform vec2 u_SceneCenterMKT;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n\nvoid main() {\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));\n // vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u5B9E\u9645\u7684\u7ECF\u7EAC\u5EA6\n // vec2 lnglat = (a_Pos.xy + offset); \n // vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n // gl_Position = project_common_position_to_clipspace(project_pos);\n // float lightWeight = calc_lighting(project_pos);\n // v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // vec2 lnglat = (a_Pos.xy + offset); \n // vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n\n // float lightWeight = calc_lighting(project_pos);\n // v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n \n // gl_Position = u_Mvp * vec4(lnglat , a_Position.z * a_Size, 1.0);\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u7ECF\u7EAC\u5EA6\n vec2 customLnglat = customProject(lnglat) - u_SceneCenterMKT; // \u5C06\u7ECF\u7EAC\u5EA6\u8F6C\u6362\u4E3A\u9AD8\u5FB72.0\u9700\u8981\u7684\u5E73\u9762\u5750\u6807\n vec4 project_pos = project_position(vec4(customLnglat, a_Position.z * a_Size, 1.0));\n\n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n \n gl_Position = u_Mvp * vec4(customLnglat , a_Position.z * a_Size, 1.0);\n } else {\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u5B9E\u9645\u7684\u7ECF\u7EAC\u5EA6\n vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n \n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n \n gl_Position = project_common_position_to_clipspace(project_pos);\n }\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
@@ -48,6 +49,12 @@ var Grid3DModel = function (_BaseModel) {
48
49
  }, {
49
50
  key: "buildModels",
50
51
  value: function buildModels() {
52
+ var _ref2 = this.layer.getLayerConfig(),
53
+ _ref2$mask = _ref2.mask,
54
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
55
+ _ref2$maskInside = _ref2.maskInside,
56
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
57
+
51
58
  return [this.layer.buildLayerModel({
52
59
  moduleName: 'grid3dheatmap',
53
60
  vertexShader: heatmapGrid3dVert,
@@ -56,7 +63,8 @@ var Grid3DModel = function (_BaseModel) {
56
63
  depth: {
57
64
  enable: true
58
65
  },
59
- blend: this.getBlend()
66
+ blend: this.getBlend(),
67
+ stencil: getMask(mask, maskInside)
60
68
  })];
61
69
  }
62
70
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/heatmap/models/grid3d.ts"],"names":["AttributeType","gl","BaseModel","PointExtrudeTriangulation","Grid3DModel","layer","getLayerConfig","opacity","coverage","angle","u_opacity","u_coverage","u_angle","u_radius","getSource","data","xOffset","yOffset","buildModels","buildLayerModel","moduleName","vertexShader","heatmapGrid3dVert","fragmentShader","heatmapGridFrag","triangulation","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","normal","coordinates","version","originCoordinates"],"mappings":";;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAQA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,yBAAT,QAA0C,0BAA1C;;;;IAQqBC,W;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,QAFF,QAEEA,QAFF;AAAA,UAGEC,KAHF,QAGEA,KAHF;;AAKA,aAAO;AACLC,QAAAA,SAAS,EAAEH,OAAO,IAAI,GADjB;AAELI,QAAAA,UAAU,EAAEH,QAAQ,IAAI,GAFnB;AAGLI,QAAAA,OAAO,EAAEH,KAAK,IAAI,CAHb;AAILI,QAAAA,QAAQ,EAAE,CACR,KAAKR,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BC,OADpB,EAER,KAAKX,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BE,OAFpB;AAJL,OAAP;AASD;;;WAED,sBAA8B;AAC5B,aAAO,KAAKC,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,aAAO,CACL,KAAKb,KAAL,CAAWc,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,eADa;AAEzBC,QAAAA,YAAY,EAAEC,iBAFW;AAGzBC,QAAAA,cAAc,EAAEC,eAHS;AAIzBC,QAAAA,aAAa,EAAEtB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M,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNI,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKnB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhDC,QAAAA,IAAI,EAAEjC,aAAa,CAACkC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEpC,EAAE,CAACqC,YAFJ;AAGNvB,YAAAA,IAAI,EAAE,EAHA;AAINkB,YAAAA,IAAI,EAAEhC,EAAE,CAACsC;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMO,WAAW,GAAIR,OAAO,CAACS,OAAR,KAAoB,UAApB,GACjBT,OAAO,CAACU,iBADS,GAEjBV,OAAO,CAACQ,WAFZ;AAKA,mBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;;EA1GsChD,S;;SAApBE,W","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { aProjectFlat, Satistics, unProjectFlat } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport heatmapGrid3dVert from '../shaders/hexagon_3d_vert.glsl';\nimport heatmapGridFrag from '../shaders/hexagon_frag.glsl';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n coverage: number;\n angle: number;\n}\nexport default class Grid3DModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n coverage,\n angle,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n return {\n u_opacity: opacity || 1.0,\n u_coverage: coverage || 1.0,\n u_angle: angle || 0,\n u_radius: [\n this.layer.getSource().data.xOffset,\n this.layer.getSource().data.yOffset,\n ],\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: 'grid3dheatmap',\n vertexShader: heatmapGrid3dVert,\n fragmentShader: heatmapGridFrag,\n triangulation: PointExtrudeTriangulation,\n depth: { enable: true },\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 } = 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: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos', // 顶点经纬度位置\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = (feature.version === 'GAODE2.x'\n ? feature.originCoordinates\n : feature.coordinates) as number[];\n // const coordinates = feature.coordinates as number[];\n // const coordinates = feature.originCoordinates as number[];\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"grid3d.js"}
1
+ {"version":3,"sources":["../../../src/heatmap/models/grid3d.ts"],"names":["AttributeType","gl","getMask","BaseModel","PointExtrudeTriangulation","Grid3DModel","layer","getLayerConfig","opacity","coverage","angle","u_opacity","u_coverage","u_angle","u_radius","getSource","data","xOffset","yOffset","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","heatmapGrid3dVert","fragmentShader","heatmapGridFrag","triangulation","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","normal","coordinates","version","originCoordinates"],"mappings":";;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,yBAAT,QAA0C,0BAA1C;;;;IAGqBC,W;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,QAFF,QAEEA,QAFF;AAAA,UAGEC,KAHF,QAGEA,KAHF;;AAKA,aAAO;AACLC,QAAAA,SAAS,EAAEH,OAAO,IAAI,GADjB;AAELI,QAAAA,UAAU,EAAEH,QAAQ,IAAI,GAFnB;AAGLI,QAAAA,OAAO,EAAEH,KAAK,IAAI,CAHb;AAILI,QAAAA,QAAQ,EAAE,CACR,KAAKR,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BC,OADpB,EAER,KAAKX,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BE,OAFpB;AAJL,OAAP;AASD;;;WAED,sBAA8B;AAC5B,aAAO,KAAKC,WAAL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AApBE,W","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IHeatMapLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport heatmapGrid3dVert from '../shaders/hexagon_3d_vert.glsl';\nimport heatmapGridFrag from '../shaders/hexagon_frag.glsl';\nexport default class Grid3DModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n coverage,\n angle,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n return {\n u_opacity: opacity || 1.0,\n u_coverage: coverage || 1.0,\n u_angle: angle || 0,\n u_radius: [\n this.layer.getSource().data.xOffset,\n this.layer.getSource().data.yOffset,\n ],\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 IHeatMapLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'grid3dheatmap',\n vertexShader: heatmapGrid3dVert,\n fragmentShader: heatmapGridFrag,\n triangulation: PointExtrudeTriangulation,\n depth: { enable: true },\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 } = 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: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos', // 顶点经纬度位置\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = (feature.version === 'GAODE2.x'\n ? feature.originCoordinates\n : feature.coordinates) as number[];\n // const coordinates = feature.coordinates as number[];\n // const coordinates = feature.originCoordinates as number[];\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"grid3d.js"}
@@ -18,7 +18,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
18
18
  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; } }
19
19
 
20
20
  import { AttributeType, gl } from '@antv/l7-core';
21
- import { generateColorRamp } from '@antv/l7-utils';
21
+ import { generateColorRamp, getMask } from '@antv/l7-utils';
22
22
  import { mat4 } from 'gl-matrix';
23
23
  import { injectable } from 'inversify';
24
24
  import 'reflect-metadata';
@@ -195,6 +195,12 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
195
195
  }, {
196
196
  key: "buildHeatmapColor",
197
197
  value: function buildHeatmapColor() {
198
+ var _ref = this.layer.getLayerConfig(),
199
+ _ref$mask = _ref.mask,
200
+ mask = _ref$mask === void 0 ? false : _ref$mask,
201
+ _ref$maskInside = _ref.maskInside,
202
+ maskInside = _ref$maskInside === void 0 ? true : _ref$maskInside;
203
+
198
204
  this.shaderModuleService.registerModule('heatmapColor', {
199
205
  vs: heatmapColorVert,
200
206
  fs: heatmapColorFrag
@@ -239,18 +245,19 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
239
245
  data: [0, 2, 1, 2, 3, 1],
240
246
  type: gl.UNSIGNED_INT,
241
247
  count: 6
242
- })
248
+ }),
249
+ stencil: getMask(mask, maskInside)
243
250
  });
244
251
  }
245
252
  }, {
246
253
  key: "drawIntensityMode",
247
254
  value: function drawIntensityMode() {
248
- var _ref = this.layer.getLayerConfig(),
249
- opacity = _ref.opacity,
250
- _ref$intensity = _ref.intensity,
251
- intensity = _ref$intensity === void 0 ? 10 : _ref$intensity,
252
- _ref$radius = _ref.radius,
253
- radius = _ref$radius === void 0 ? 5 : _ref$radius;
255
+ var _ref2 = this.layer.getLayerConfig(),
256
+ opacity = _ref2.opacity,
257
+ _ref2$intensity = _ref2.intensity,
258
+ intensity = _ref2$intensity === void 0 ? 10 : _ref2$intensity,
259
+ _ref2$radius = _ref2.radius,
260
+ radius = _ref2$radius === void 0 ? 5 : _ref2$radius;
254
261
 
255
262
  this.intensityModel.draw({
256
263
  uniforms: {
@@ -263,8 +270,8 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
263
270
  }, {
264
271
  key: "drawColorMode",
265
272
  value: function drawColorMode() {
266
- var _ref2 = this.layer.getLayerConfig(),
267
- opacity = _ref2.opacity;
273
+ var _ref3 = this.layer.getLayerConfig(),
274
+ opacity = _ref3.opacity;
268
275
 
269
276
  this.colorModel.draw({
270
277
  uniforms: {
@@ -277,8 +284,8 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
277
284
  }, {
278
285
  key: "draw3DHeatMap",
279
286
  value: function draw3DHeatMap() {
280
- var _ref3 = this.layer.getLayerConfig(),
281
- opacity = _ref3.opacity;
287
+ var _ref4 = this.layer.getLayerConfig(),
288
+ opacity = _ref4.opacity;
282
289
 
283
290
  var invert = mat4.create();
284
291
  mat4.invert(invert, this.cameraService.getViewProjectionMatrixUncentered());
@@ -295,6 +302,12 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
295
302
  }, {
296
303
  key: "build3dHeatMap",
297
304
  value: function build3dHeatMap() {
305
+ var _ref5 = this.layer.getLayerConfig(),
306
+ _ref5$mask = _ref5.mask,
307
+ mask = _ref5$mask === void 0 ? false : _ref5$mask,
308
+ _ref5$maskInside = _ref5.maskInside,
309
+ maskInside = _ref5$maskInside === void 0 ? true : _ref5$maskInside;
310
+
298
311
  var getViewportSize = this.rendererService.getViewportSize;
299
312
 
300
313
  var _getViewportSize2 = getViewportSize(),
@@ -354,7 +367,8 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
354
367
  data: triangulation.indices,
355
368
  type: gl.UNSIGNED_INT,
356
369
  count: triangulation.indices.length
357
- })
370
+ }),
371
+ stencil: getMask(mask, maskInside)
358
372
  });
359
373
  }
360
374
  }, {
@@ -371,8 +385,8 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
371
385
  this.texture.destroy();
372
386
  }
373
387
 
374
- var _ref4 = this.layer.getLayerConfig(),
375
- rampColors = _ref4.rampColors;
388
+ var _ref6 = this.layer.getLayerConfig(),
389
+ rampColors = _ref6.rampColors;
376
390
 
377
391
  var imageData = generateColorRamp(rampColors);
378
392
  this.colorTexture = createTexture2D({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["AttributeType","gl","generateColorRamp","mat4","injectable","BaseModel","HeatmapTriangulation","heatMap3DTriangulation","HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","getLayerConfig","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AASA,SAASC,iBAAT,QAA8C,gBAA9C;AACA,SAASC,IAAT,QAAqB,WAArB;AACA,SAAiBC,UAAjB,QAAmC,WAAnC;AACA,OAAO,kBAAP;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,oBAAT,QAAqC,0BAArC;;;;;;;AAOA,SAASC,sBAAT,QAAuC,kBAAvC;IASqBC,Y,WADpBJ,UAAU,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAST,kBAAgB;AAAA;;AACd,kCAAkC,KAAKK,eAAvC;AAAA,UAAQC,KAAR,yBAAQA,KAAR;AAAA,UAAeC,cAAf,yBAAeA,cAAf;AACAA,MAAAA,cAAc,CAAC,KAAKC,m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AACqD,OAAd,CAAsBC;AAHN,SAAD;AAnCP,OAAD,CAAlB;AAyCD;;;WACD,uBAAsB;AACpB,WAAKzG,kBAAL;AACD;;;WAED,8BAA6B;AAC3B,UAAQO,eAAR,GAA4B,KAAKlB,eAAjC,CAAQkB,eAAR;;AACA,UAAI,KAAKmG,OAAT,EAAkB;AAChB,aAAKA,OAAL,CAAaC,OAAb;AACD;;AAED,kBAEI,KAAK7G,KAAL,CAAWiF,cAAX,EAFJ;AAAA,UACE6B,UADF,SACEA,UADF;;AAGA,UAAMC,SAAS,GAAG/H,iBAAiB,CAAC8H,UAAD,CAAnC;AACA,WAAKpB,YAAL,GAAoBjF,eAAe,CAAC;AAClC8B,QAAAA,IAAI,EAAE,IAAIyE,UAAJ,CAAeD,SAAS,CAACxE,IAAzB,CAD4B;AAElCnB,QAAAA,KAAK,EAAE2F,SAAS,CAAC3F,KAFiB;AAGlCC,QAAAA,MAAM,EAAE0F,SAAS,CAAC1F,MAHgB;AAIlCG,QAAAA,KAAK,EAAEzC,EAAE,CAAC0C,aAJwB;AAKlCC,QAAAA,KAAK,EAAE3C,EAAE,CAAC0C,aALwB;AAMlCE,QAAAA,GAAG,EAAE5C,EAAE,CAACkI,OAN0B;AAOlCpF,QAAAA,GAAG,EAAE9C,EAAE,CAACkI,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;;EA9UuC/H,S;SAArBG,Y","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { generateColorRamp, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapFramebufferFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapFramebufferVert from '../shaders/heatmap_framebuffer_vert.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\nimport { heatMap3DTriangulation } from '../triangulation';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n}\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // 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 [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapFramebufferVert,\n fragmentShader: heatmapFramebufferFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
1
+ {"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["AttributeType","gl","generateColorRamp","getMask","mat4","injectable","BaseModel","HeatmapTriangulation","heatMap3DTriangulation","HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","getLayerConfig","mask","maskInside","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AASA,SAASC,iBAAT,EAA4BC,OAA5B,QAAuD,gBAAvD;AACA,SAASC,IAAT,QAAqB,WAArB;AACA,SAAiBC,UAAjB,QAAmC,WAAnC;AACA,OAAO,kBAAP;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,oBAAT,QAAqC,0BAArC;;;;;;;AAOA,SAASC,sBAAT,QAAuC,kBAAvC;IAEqBC,Y,WADpBJ,UAAU,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAST,kBAAgB;AAAA;;AACd,kCAAkC,KAAKK,eAAvC;AAAA,U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K,EAAE5C,EAAE,CAAC2C,aALwB;AAMlCE,QAAAA,GAAG,EAAE7C,EAAE,CAACqI,OAN0B;AAOlCtF,QAAAA,GAAG,EAAE/C,EAAE,CAACqI,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;;EAxVuCjI,S;SAArBG,Y","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { IHeatMapLayerStyleOptions } from '../../core/interface';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapFramebufferFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapFramebufferVert from '../shaders/heatmap_framebuffer_vert.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\nimport { heatMap3DTriangulation } from '../triangulation';\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // 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 [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapFramebufferVert,\n fragmentShader: heatmapFramebufferFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n stencil: getMask(mask, maskInside),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n stencil: getMask(mask, maskInside),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
@@ -9,6 +9,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
9
9
  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; } }
10
10
 
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
+ import { getMask } from '@antv/l7-utils';
12
13
  import BaseModel from '../../core/BaseModel';
13
14
  import { HeatmapGridTriangulation } from '../../core/triangulation';
14
15
  var heatmapGridFrag = "precision highp float;\nvarying vec4 v_color;\nuniform float u_opacity: 1;\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n gl_FragColor.a *= u_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
@@ -48,6 +49,12 @@ var HexagonModel = function (_BaseModel) {
48
49
  }, {
49
50
  key: "buildModels",
50
51
  value: function buildModels() {
52
+ var _ref2 = this.layer.getLayerConfig(),
53
+ _ref2$mask = _ref2.mask,
54
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
55
+ _ref2$maskInside = _ref2.maskInside,
56
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
57
+
51
58
  return [this.layer.buildLayerModel({
52
59
  moduleName: 'hexagonheatmap',
53
60
  vertexShader: heatmapGridVert,
@@ -57,7 +64,8 @@ var HexagonModel = function (_BaseModel) {
57
64
  enable: false
58
65
  },
59
66
  primitive: gl.TRIANGLES,
60
- blend: this.getBlend()
67
+ blend: this.getBlend(),
68
+ stencil: getMask(mask, maskInside)
61
69
  })];
62
70
  }
63
71
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/heatmap/models/hexagon.ts"],"names":["AttributeType","gl","BaseModel","HeatmapGridTriangulation","HexagonModel","layer","getLayerConfig","opacity","coverage","angle","u_opacity","u_coverage","u_angle","u_radius","getSource","data","xOffset","yOffset","buildModels","buildLayerModel","moduleName","vertexShader","heatmapGridVert","fragmentShader","heatmapGridFrag","triangulation","depth","enable","primitive","TRIANGLES","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates"],"mappings":";;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,wBAAT,QAAyC,0BAAzC;;;;IAUqBC,Y;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,QAFF,QAEEA,QAFF;AAAA,UAGEC,KAHF,QAGEA,KAHF;;AAKA,aAAO;AACLC,QAAAA,SAAS,EAAEH,OAAO,IAAI,GADjB;AAELI,QAAAA,UAAU,EAAEH,QAAQ,IAAI,GAFnB;AAGLI,QAAAA,OAAO,EAAEH,KAAK,IAAI,CAHb;AAILI,QAAAA,QAAQ,EAAE,CACR,KAAKR,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BC,OADpB,EAER,KAAKX,KAAL,CAAWS,SAAX,GAAu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["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapGridTriangulation } from '../../core/triangulation';\nimport heatmapGridFrag from '../shaders/hexagon_frag.glsl';\nimport heatmapGridVert from '../shaders/hexagon_vert.glsl';\n\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n coverage: number;\n angle: number;\n}\n\nexport default class HexagonModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n coverage,\n angle,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n return {\n u_opacity: opacity || 1.0,\n u_coverage: coverage || 0.9,\n u_angle: angle || 0,\n u_radius: [\n this.layer.getSource().data.xOffset,\n this.layer.getSource().data.yOffset,\n ],\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: 'hexagonheatmap',\n vertexShader: heatmapGridVert,\n fragmentShader: heatmapGridFrag,\n triangulation: HeatmapGridTriangulation,\n depth: { enable: false },\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos', // 顶点经纬度位置\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: (feature: IEncodeFeature, featureIdx: number) => {\n // const coordinates = (feature.verison==='GAODE2.x'?feature.originoordinates:feature.coordinates) as number[];\n const coordinates = (feature.version === 'GAODE2.x'\n ? feature.originCoordinates\n : feature.coordinates) as number[];\n // const coordinates = feature.coordinates as number[];\n // const coordinates = feature.originCoordinates as number[];\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"hexagon.js"}
1
+ {"version":3,"sources":["../../../src/heatmap/models/hexagon.ts"],"names":["AttributeType","gl","getMask","BaseModel","HeatmapGridTriangulation","HexagonModel","layer","getLayerConfig","opacity","coverage","angle","u_opacity","u_coverage","u_angle","u_radius","getSource","data","xOffset","yOffset","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","heatmapGridVert","fragmentShader","heatmapGridFrag","triangulation","depth","enable","primitive","TRIANGLES","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates"],"mappings":";;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,wBAAT,QAAyC,0BAAzC;;;;IAIqBC,Y;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,QAFF,QAEEA,QAFF;AAAA,UAGEC,KAHF,QAGEA,KAHF;;AAKA,aAAO;AACLC,QAAAA,SAAS,EAAEH,OAAO,IAAI,GADjB;AAELI,QAAAA,UAAU,EAAEH,QAAQ,IAAI,GAFnB;AAGLI,QAAAA,OAAO,EAAEH,KAAK,IAAI,CAHb;AAILI,QAAAA,QAAQ,EAAE,CACR,KAAKR,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BC,OADpB,EAER,KAAKX,KAAL,CAAWS,SAAX,GAAuBC,IAAvB,CAA4BE,OAFpB;AAJL,OAAP;AASD;;;WAED,sBAA8B;AAC5B,aAAO,KAAKC,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,kBAGI,KAAKb,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEa,IADF;AAAA,UACEA,IADF,2BACS,KADT;AAAA,mCAEEC,UAFF;AAAA,UAEEA,UAFF,iCAEe,IAFf;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IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IHeatMapLayerStyleOptions } from '../../core/interface';\nimport { HeatmapGridTriangulation } from '../../core/triangulation';\nimport heatmapGridFrag from '../shaders/hexagon_frag.glsl';\nimport heatmapGridVert from '../shaders/hexagon_vert.glsl';\n\nexport default class HexagonModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n coverage,\n angle,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n return {\n u_opacity: opacity || 1.0,\n u_coverage: coverage || 0.9,\n u_angle: angle || 0,\n u_radius: [\n this.layer.getSource().data.xOffset,\n this.layer.getSource().data.yOffset,\n ],\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 IHeatMapLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'hexagonheatmap',\n vertexShader: heatmapGridVert,\n fragmentShader: heatmapGridFrag,\n triangulation: HeatmapGridTriangulation,\n depth: { enable: false },\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos', // 顶点经纬度位置\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: (feature: IEncodeFeature, featureIdx: number) => {\n // const coordinates = (feature.verison==='GAODE2.x'?feature.originoordinates:feature.coordinates) as number[];\n const coordinates = (feature.version === 'GAODE2.x'\n ? feature.originCoordinates\n : feature.coordinates) as number[];\n // const coordinates = feature.coordinates as number[];\n // const coordinates = feature.originCoordinates as number[];\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"hexagon.js"}
@@ -1,8 +1,6 @@
1
1
  import BaseLayer from '../core/BaseLayer';
2
+ import { IImageLayerStyleOptions } from '../core/interface';
2
3
  import { ImageModelType } from './models/index';
3
- interface IImageLayerStyleOptions {
4
- opacity: number;
5
- }
6
4
  export default class ImageLayer extends BaseLayer<IImageLayerStyleOptions> {
7
5
  type: string;
8
6
  buildModels(): void;
@@ -19,4 +17,3 @@ export default class ImageLayer extends BaseLayer<IImageLayerStyleOptions> {
19
17
  protected getDefaultConfig(): {};
20
18
  protected getModelType(): ImageModelType;
21
19
  }
22
- export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/image/index.ts"],"names":["BaseLayer","ImageModels","ImageLayer","modelType","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","image"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AACA,OAAOC,WAAP,MAA4C,gBAA5C;;IAIqBC,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,GAAG;AACpBC,QAAAA,KAAK,EAAE;AADa,OAAtB;AAGA,aAAOD,aAAa,CAACH,IAAD,CAApB;AACD;;;WAED,wBAAyC;AACvC,aAAO,OAAP;AACD;;;;EA/BqCX,S;;SAAnBE,U","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport ImageModels, { ImageModelType } from './models/index';\ninterface IImageLayerStyleOptions {\n opacity: number;\n}\nexport default class ImageLayer extends BaseLayer<IImageLayerStyleOptions> {\n public type: string = 'ImageLayer';\n public buildModels() {\n const modelType = this.getModelType();\n this.layerModel = new ImageModels[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 image: {},\n };\n return defaultConfig[type];\n }\n\n protected getModelType(): ImageModelType {\n return 'image';\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/image/index.ts"],"names":["BaseLayer","ImageModels","ImageLayer","modelType","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","image"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,WAAP,MAA4C,gBAA5C;;IACqBC,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,GAAG;AACpBC,QAAAA,KAAK,EAAE;AADa,OAAtB;AAGA,aAAOD,aAAa,CAACH,IAAD,CAApB;AACD;;;WAED,wBAAyC;AACvC,aAAO,OAAP;AACD;;;;EA/BqCX,S;;SAAnBE,U","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { IImageLayerStyleOptions } from '../core/interface';\nimport ImageModels, { ImageModelType } from './models/index';\nexport default class ImageLayer extends BaseLayer<IImageLayerStyleOptions> {\n public type: string = 'ImageLayer';\n public buildModels() {\n const modelType = this.getModelType();\n this.layerModel = new ImageModels[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 image: {},\n };\n return defaultConfig[type];\n }\n\n protected getModelType(): ImageModelType {\n return 'image';\n }\n}\n"],"file":"index.js"}
@@ -1,10 +1,10 @@
1
- import { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
1
+ import { IModelUniform, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ImageModel extends BaseModel {
4
4
  protected texture: ITexture2D;
5
5
  getUninforms(): IModelUniform;
6
- initModels(): IModel[];
7
- buildModels(): IModel[];
6
+ initModels(): import("@antv/l7-core").IModel[];
7
+ buildModels(): import("@antv/l7-core").IModel[];
8
8
  protected getConfigSchema(): {
9
9
  properties: {
10
10
  opacity: {
@@ -11,7 +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, gl } from '@antv/l7-core';
14
- import { isMini } from '@antv/l7-utils';
14
+ import { getMask, isMini } from '@antv/l7-utils';
15
15
  import BaseModel from '../../core/BaseModel';
16
16
  import { RasterImageTriangulation } from '../../core/triangulation';
17
17
  var ImageFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nvoid main() {\n vec4 color = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y));\n gl_FragColor = color;\n gl_FragColor.a *= u_opacity;\n}\n";
@@ -54,6 +54,12 @@ var ImageModel = function (_BaseModel) {
54
54
  value: function initModels() {
55
55
  var _this2 = this;
56
56
 
57
+ var _ref2 = this.layer.getLayerConfig(),
58
+ _ref2$mask = _ref2.mask,
59
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
60
+ _ref2$maskInside = _ref2.maskInside,
61
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
62
+
57
63
  var source = this.layer.getSource();
58
64
  var createTexture2D = this.rendererService.createTexture2D;
59
65
  this.texture = createTexture2D({
@@ -101,7 +107,8 @@ var ImageModel = function (_BaseModel) {
101
107
  depth: {
102
108
  enable: false
103
109
  },
104
- blend: this.getBlend()
110
+ blend: this.getBlend(),
111
+ stencil: getMask(mask, maskInside)
105
112
  })];
106
113
  }
107
114
  }, {