@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.
- package/es/core/interface.d.ts +60 -1
- package/es/core/interface.js.map +1 -1
- package/es/heatmap/index.d.ts +1 -4
- package/es/heatmap/index.js.map +1 -1
- package/es/heatmap/models/grid.js +9 -1
- package/es/heatmap/models/grid.js.map +1 -1
- package/es/heatmap/models/grid3d.js +9 -1
- package/es/heatmap/models/grid3d.js.map +1 -1
- package/es/heatmap/models/heatmap.js +29 -15
- package/es/heatmap/models/heatmap.js.map +1 -1
- package/es/heatmap/models/hexagon.js +9 -1
- package/es/heatmap/models/hexagon.js.map +1 -1
- package/es/image/index.d.ts +1 -4
- package/es/image/index.js.map +1 -1
- package/es/image/models/image.d.ts +3 -3
- package/es/image/models/image.js +9 -2
- package/es/image/models/image.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/index.js.map +1 -1
- package/es/line/models/arc.js +8 -3
- package/es/line/models/arc.js.map +1 -1
- package/es/line/models/arc_3d.js +8 -3
- package/es/line/models/arc_3d.js.map +1 -1
- package/es/line/models/great_circle.js +13 -6
- package/es/line/models/great_circle.js.map +1 -1
- package/es/line/models/line.js +12 -5
- package/es/line/models/line.js.map +1 -1
- package/es/line/models/simpleLine.js +9 -2
- package/es/line/models/simpleLine.js.map +1 -1
- package/es/mask/index.d.ts +21 -0
- package/es/mask/index.js +73 -0
- package/es/mask/index.js.map +1 -0
- package/es/mask/models/fill.d.ts +11 -0
- package/es/mask/models/fill.js +92 -0
- package/es/mask/models/fill.js.map +1 -0
- package/es/mask/models/index.d.ts +5 -0
- package/es/mask/models/index.js +6 -0
- package/es/mask/models/index.js.map +1 -0
- package/es/point/index.d.ts +1 -6
- package/es/point/index.js.map +1 -1
- package/es/point/models/fill.js +9 -1
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/image.js +12 -4
- package/es/point/models/image.js.map +1 -1
- package/es/point/models/index.js.map +1 -1
- package/es/point/models/normal.d.ts +2 -6
- package/es/point/models/normal.js +9 -1
- package/es/point/models/normal.js.map +1 -1
- package/es/point/models/simplePoint.d.ts +2 -10
- package/es/point/models/simplePoint.js +9 -1
- package/es/point/models/simplePoint.js.map +1 -1
- package/es/point/models/text.js +60 -46
- package/es/point/models/text.js.map +1 -1
- package/es/polygon/index.d.ts +1 -4
- package/es/polygon/index.js.map +1 -1
- package/es/polygon/models/extrude.js +8 -2
- package/es/polygon/models/extrude.js.map +1 -1
- package/es/polygon/models/fill.js +8 -2
- package/es/polygon/models/fill.js.map +1 -1
- package/es/raster/index.d.ts +1 -10
- package/es/raster/index.js.map +1 -1
- package/es/raster/models/raster.d.ts +3 -3
- package/es/raster/models/raster.js +13 -6
- package/es/raster/models/raster.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/heatmap/index.js.map +1 -1
- package/lib/heatmap/models/grid.js +10 -1
- package/lib/heatmap/models/grid.js.map +1 -1
- package/lib/heatmap/models/grid3d.js +10 -1
- package/lib/heatmap/models/grid3d.js.map +1 -1
- package/lib/heatmap/models/heatmap.js +28 -14
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/heatmap/models/hexagon.js +10 -1
- package/lib/heatmap/models/hexagon.js.map +1 -1
- package/lib/image/index.js.map +1 -1
- package/lib/image/models/image.js +8 -1
- package/lib/image/models/image.js.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/line/models/arc.js +7 -2
- package/lib/line/models/arc.js.map +1 -1
- package/lib/line/models/arc_3d.js +7 -2
- package/lib/line/models/arc_3d.js.map +1 -1
- package/lib/line/models/great_circle.js +12 -5
- package/lib/line/models/great_circle.js.map +1 -1
- package/lib/line/models/line.js +11 -4
- package/lib/line/models/line.js.map +1 -1
- package/lib/line/models/simpleLine.js +8 -1
- package/lib/line/models/simpleLine.js.map +1 -1
- package/lib/mask/index.js +86 -0
- package/lib/mask/index.js.map +1 -0
- package/lib/mask/models/fill.js +107 -0
- package/lib/mask/models/fill.js.map +1 -0
- package/lib/mask/models/index.js +17 -0
- package/lib/mask/models/index.js.map +1 -0
- package/lib/point/index.js.map +1 -1
- package/lib/point/models/fill.js +10 -1
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/image.js +13 -4
- package/lib/point/models/image.js.map +1 -1
- package/lib/point/models/index.js.map +1 -1
- package/lib/point/models/normal.js +10 -1
- package/lib/point/models/normal.js.map +1 -1
- package/lib/point/models/simplePoint.js +10 -1
- package/lib/point/models/simplePoint.js.map +1 -1
- package/lib/point/models/text.js +59 -45
- package/lib/point/models/text.js.map +1 -1
- package/lib/polygon/index.js.map +1 -1
- package/lib/polygon/models/extrude.js +9 -2
- package/lib/polygon/models/extrude.js.map +1 -1
- package/lib/polygon/models/fill.js +9 -2
- package/lib/polygon/models/fill.js.map +1 -1
- package/lib/raster/index.js.map +1 -1
- package/lib/raster/models/raster.js +12 -5
- package/lib/raster/models/raster.js.map +1 -1
- package/package.json +5 -5
|
@@ -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 { generateColorRamp } from '@antv/l7-utils';
|
|
14
|
+
import { generateColorRamp, getMask } from '@antv/l7-utils';
|
|
15
15
|
import BaseModel from '../../core/BaseModel';
|
|
16
16
|
import { RasterImageTriangulation } from '../../core/triangulation';
|
|
17
17
|
var rasterFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_min;\nuniform float u_max;\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nvarying vec2 v_texCoord;\n\nvoid main() {\n\n float value = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y)).r;\n if (value == u_noDataValue)\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))\n gl_FragColor = vec4(0, 0, 0, 0);\n else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);\n vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n }\n\n\n}\n";
|
|
@@ -69,6 +69,12 @@ var RasterModel = function (_BaseModel) {
|
|
|
69
69
|
}, {
|
|
70
70
|
key: "initModels",
|
|
71
71
|
value: function initModels() {
|
|
72
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
73
|
+
_ref2$mask = _ref2.mask,
|
|
74
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
75
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
76
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
77
|
+
|
|
72
78
|
var source = this.layer.getSource();
|
|
73
79
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
74
80
|
var parserDataItem = source.data.dataArray[0];
|
|
@@ -80,8 +86,8 @@ var RasterModel = function (_BaseModel) {
|
|
|
80
86
|
type: gl.FLOAT
|
|
81
87
|
});
|
|
82
88
|
|
|
83
|
-
var
|
|
84
|
-
rampColors =
|
|
89
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
90
|
+
rampColors = _ref3.rampColors;
|
|
85
91
|
|
|
86
92
|
var imageData = generateColorRamp(rampColors);
|
|
87
93
|
this.colorTexture = createTexture2D({
|
|
@@ -99,7 +105,8 @@ var RasterModel = function (_BaseModel) {
|
|
|
99
105
|
depth: {
|
|
100
106
|
enable: false
|
|
101
107
|
},
|
|
102
|
-
blend: this.getBlend()
|
|
108
|
+
blend: this.getBlend(),
|
|
109
|
+
stencil: getMask(mask, maskInside)
|
|
103
110
|
})];
|
|
104
111
|
}
|
|
105
112
|
}, {
|
|
@@ -132,8 +139,8 @@ var RasterModel = function (_BaseModel) {
|
|
|
132
139
|
value: function updateColorTexure() {
|
|
133
140
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
134
141
|
|
|
135
|
-
var
|
|
136
|
-
rampColors =
|
|
142
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
143
|
+
rampColors = _ref4.rampColors;
|
|
137
144
|
|
|
138
145
|
var imageData = generateColorRamp(rampColors);
|
|
139
146
|
this.colorTexture = createTexture2D({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/raster/models/raster.ts"],"names":["AttributeType","gl","generateColorRamp","BaseModel","RasterImageTriangulation","RasterModel","layer","getLayerConfig","opacity","clampLow","clampHigh","noDataValue","domain","updateColorTexure","u_opacity","u_texture","texture","u_domain","u_clampLow","u_clampHigh","u_noDataValue","u_colorTexture","colorTexture","source","getSource","createTexture2D","rendererService","parserDataItem","data","dataArray","width","height","format","LUMINANCE","type","FLOAT","rampColors","imageData","flipY","buildLayerModel","moduleName","vertexShader","rasterVert","fragmentShader","rasterFrag","triangulation","primitive","TRIANGLES","depth","enable","blend","getBlend","initModels","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,
|
|
1
|
+
{"version":3,"sources":["../../../src/raster/models/raster.ts"],"names":["AttributeType","gl","generateColorRamp","getMask","BaseModel","RasterImageTriangulation","RasterModel","layer","getLayerConfig","opacity","clampLow","clampHigh","noDataValue","domain","updateColorTexure","u_opacity","u_texture","texture","u_domain","u_clampLow","u_clampHigh","u_noDataValue","u_colorTexture","colorTexture","mask","maskInside","source","getSource","createTexture2D","rendererService","parserDataItem","data","dataArray","width","height","format","LUMINANCE","type","FLOAT","rampColors","imageData","flipY","buildLayerModel","moduleName","vertexShader","rasterVert","fragmentShader","rasterFrag","triangulation","primitive","TRIANGLES","depth","enable","blend","getBlend","stencil","initModels","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,iBAAT,EAA4BC,OAA5B,QAAuD,gBAAvD;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,wBAAT,QAAyC,0BAAzC;;;;IAGqBC,W;;;;;;;;;;;;;;;;;;;;;;;;;WAGnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,+BAEEC,QAFF;AAAA,UAEEA,QAFF,8BAEa,IAFb;AAAA,gCAGEC,SAHF;AAAA,UAGEA,SAHF,+BAGc,IAHd;AAAA,kCAIEC,WAJF;AAAA,UAIEA,WAJF,iCAIgB,CAAC,OAJjB;AAAA,6BAKEC,MALF;AAAA,UAKEA,MALF,4BAKW,CAAC,CAAD,EAAI,CAAJ,CALX;;AAOA,WAAKC,iBAAL;AACA,aAAO;AACLC,QAAAA,SAAS,EAAEN,OAAO,IAAI,CADjB;AAELO,QAAAA,SAAS,EAAE,KAAKC,OAFX;AAGLC,QAAAA,QAAQ,EAAEL,MAHL;AAILM,QAAAA,UAAU,EAAET,QAJP;AAKLU,QAAAA,WAAW,EAAE,OAAOT,SAAP,KAAqB,WAArB,GAAmCA,SAAnC,GAA+CD,QALvD;AAMLW,QAAAA,aAAa,EAAET,WANV;AAOLU,QAAAA,cAAc,EAAE,KAAKC;AAPhB,OAAP;AASD;;;WAED,sBAAoB;AAClB,kBAGI,KAAKhB,KAAL,CAAWC,c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AAE;AAJ2B,OAAD,CAAnC;AAMD;;;;EAxGsCrC,S;;SAApBE,W","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ITexture2D,\n lazyInject,\n TYPES,\n} from '@antv/l7-core';\nimport { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IRasterLayerStyleOptions } from '../../core/interface';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport rasterFrag from '../shaders/raster_2d_frag.glsl';\nimport rasterVert from '../shaders/raster_2d_vert.glsl';\nexport default class RasterModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n clampLow = true,\n clampHigh = true,\n noDataValue = -9999999,\n domain = [0, 1],\n } = this.layer.getLayerConfig() as IRasterLayerStyleOptions;\n this.updateColorTexure();\n return {\n u_opacity: opacity || 1,\n u_texture: this.texture,\n u_domain: domain,\n u_clampLow: clampLow,\n u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,\n u_noDataValue: noDataValue,\n u_colorTexture: this.colorTexture,\n };\n }\n\n public initModels() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IRasterLayerStyleOptions;\n const source = this.layer.getSource();\n const { createTexture2D } = this.rendererService;\n const parserDataItem = source.data.dataArray[0];\n this.texture = createTexture2D({\n data: parserDataItem.data,\n width: parserDataItem.width,\n height: parserDataItem.height,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n // aniso: 4,\n });\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IRasterLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: imageData.data,\n width: imageData.width,\n height: imageData.height,\n flipY: false,\n });\n return [\n this.layer.buildLayerModel({\n moduleName: 'RasterImageData',\n vertexShader: rasterVert,\n fragmentShader: rasterFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public buildModels() {\n return this.initModels();\n }\n protected registerBuiltinAttributes() {\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 return [vertex[3], vertex[4]];\n },\n },\n });\n }\n\n private updateColorTexure() {\n const { createTexture2D } = this.rendererService;\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IRasterLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: imageData.data,\n width: imageData.width,\n height: imageData.height,\n flipY: false,\n });\n }\n}\n"],"file":"raster.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType"],"mappings":";;;;;;IAQYA,a;;;WAAAA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,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"}
|
package/lib/heatmap/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/heatmap/index.ts"],"names":["HeatMapLayer","shape","getModelType","layerModel","HeatMapModels","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","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/heatmap/index.ts"],"names":["HeatMapLayer","shape","getModelType","layerModel","HeatMapModels","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","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IACqBA,Y;;;;;;;;;;;;;;;uFACG,c;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIC,gBAAcH,KAAd,CAAJ,CAAyB,IAAzB,CAAlB;AACA,WAAKI,MAAL,GAAc,KAAKF,UAAL,CAAgBG,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKF,UAAL,CAAgBI,WAAhB,EAAd;AACD;;;WACD,wBAAsB;AAAA;;AACpB,UAAMN,KAAK,GAAG,KAAKC,YAAL,EAAd;;AACA,UAAID,KAAK,KAAK,SAAd,EAAyB;AACvB,YAAI,KAAKE,UAAT,EAAqB;AACnB,eAAKA,UAAL,CAAgBK,MAAhB;AACD;;AAED,eAAO,IAAP;AACD;;AACD,UAAI,KAAKC,oBAAT,EAA+B;AAC7B,aAAKJ,MAA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,YAAAA,OAAO,CAAEO,OAAT,CAAiB9B,KAAjB,OAA4B,CAAC,CAA7B,GAAiC,MAAjC,GAA0C,QAAjD;AACD;;AACD,aAAO,SAAP;AACD;;;EA9DuC+B,mB","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"}
|
|
@@ -19,6 +19,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
19
19
|
|
|
20
20
|
var _l7Core = require("@antv/l7-core");
|
|
21
21
|
|
|
22
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
23
|
+
|
|
22
24
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
23
25
|
|
|
24
26
|
var _triangulation = require("../../core/triangulation");
|
|
@@ -63,6 +65,12 @@ var GridModel = function (_BaseModel) {
|
|
|
63
65
|
}, {
|
|
64
66
|
key: "buildModels",
|
|
65
67
|
value: function buildModels() {
|
|
68
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
69
|
+
_ref2$mask = _ref2.mask,
|
|
70
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
71
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
72
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
73
|
+
|
|
66
74
|
return [this.layer.buildLayerModel({
|
|
67
75
|
moduleName: 'gridheatmap',
|
|
68
76
|
vertexShader: heatmapGridVert,
|
|
@@ -72,7 +80,8 @@ var GridModel = function (_BaseModel) {
|
|
|
72
80
|
enable: false
|
|
73
81
|
},
|
|
74
82
|
primitive: _l7Core.gl.TRIANGLES,
|
|
75
|
-
blend: this.getBlend()
|
|
83
|
+
blend: this.getBlend(),
|
|
84
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
76
85
|
})];
|
|
77
86
|
}
|
|
78
87
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap/models/grid.ts"],"names":["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","HeatmapGridTriangulation","depth","enable","primitive","gl","TRIANGLES","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap/models/grid.ts"],"names":["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","HeatmapGridTriangulation","depth","enable","primitive","gl","TRIANGLES","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AAEA;;;;;;;;;IAGqBA,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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{ 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"}
|
|
@@ -19,6 +19,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
19
19
|
|
|
20
20
|
var _l7Core = require("@antv/l7-core");
|
|
21
21
|
|
|
22
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
23
|
+
|
|
22
24
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
23
25
|
|
|
24
26
|
var _triangulation = require("../../core/triangulation");
|
|
@@ -63,6 +65,12 @@ var Grid3DModel = function (_BaseModel) {
|
|
|
63
65
|
}, {
|
|
64
66
|
key: "buildModels",
|
|
65
67
|
value: function buildModels() {
|
|
68
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
69
|
+
_ref2$mask = _ref2.mask,
|
|
70
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
71
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
72
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
73
|
+
|
|
66
74
|
return [this.layer.buildLayerModel({
|
|
67
75
|
moduleName: 'grid3dheatmap',
|
|
68
76
|
vertexShader: heatmapGrid3dVert,
|
|
@@ -71,7 +79,8 @@ var Grid3DModel = function (_BaseModel) {
|
|
|
71
79
|
depth: {
|
|
72
80
|
enable: true
|
|
73
81
|
},
|
|
74
|
-
blend: this.getBlend()
|
|
82
|
+
blend: this.getBlend(),
|
|
83
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
75
84
|
})];
|
|
76
85
|
}
|
|
77
86
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap/models/grid3d.ts"],"names":["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","PointExtrudeTriangulation","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","gl","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","normal","coordinates","version","originCoordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap/models/grid3d.ts"],"names":["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","PointExtrudeTriangulation","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","gl","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","normal","coordinates","version","originCoordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AAEA;;;;;;;;;IAGqBA,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,kBAGI,KAAKb,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEa,IADF;AAAA,UACEA,IADF,2BACS,KADT;AAAA,mCAEEC,UAF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,UAAAA,IAAI,EAAE,UADI;AAEVK,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEC,WAAGW,WAFJ;AAGNvC,YAAAA,IAAI,EAAE,EAHA;AAINsB,YAAAA,IAAI,EAAEM,WAAGE;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNI,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKrB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhDC,QAAAA,IAAI,EAAEC,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVJ,UAAAA,IAAI,EAAE,OADI;AAEVK,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEC,WAAGC,YAFJ;AAGN7B,YAAAA,IAAI,EAAE,EAHA;AAINsB,YAAAA,IAAI,EAAEM,WAAGE;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;;;EA/GsCG,mB","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"}
|
|
@@ -212,6 +212,12 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
212
212
|
}, {
|
|
213
213
|
key: "buildHeatmapColor",
|
|
214
214
|
value: function buildHeatmapColor() {
|
|
215
|
+
var _ref = this.layer.getLayerConfig(),
|
|
216
|
+
_ref$mask = _ref.mask,
|
|
217
|
+
mask = _ref$mask === void 0 ? false : _ref$mask,
|
|
218
|
+
_ref$maskInside = _ref.maskInside,
|
|
219
|
+
maskInside = _ref$maskInside === void 0 ? true : _ref$maskInside;
|
|
220
|
+
|
|
215
221
|
this.shaderModuleService.registerModule('heatmapColor', {
|
|
216
222
|
vs: heatmapColorVert,
|
|
217
223
|
fs: heatmapColorFrag
|
|
@@ -256,18 +262,19 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
256
262
|
data: [0, 2, 1, 2, 3, 1],
|
|
257
263
|
type: _l7Core.gl.UNSIGNED_INT,
|
|
258
264
|
count: 6
|
|
259
|
-
})
|
|
265
|
+
}),
|
|
266
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
260
267
|
});
|
|
261
268
|
}
|
|
262
269
|
}, {
|
|
263
270
|
key: "drawIntensityMode",
|
|
264
271
|
value: function drawIntensityMode() {
|
|
265
|
-
var
|
|
266
|
-
opacity =
|
|
267
|
-
|
|
268
|
-
intensity =
|
|
269
|
-
|
|
270
|
-
radius =
|
|
272
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
273
|
+
opacity = _ref2.opacity,
|
|
274
|
+
_ref2$intensity = _ref2.intensity,
|
|
275
|
+
intensity = _ref2$intensity === void 0 ? 10 : _ref2$intensity,
|
|
276
|
+
_ref2$radius = _ref2.radius,
|
|
277
|
+
radius = _ref2$radius === void 0 ? 5 : _ref2$radius;
|
|
271
278
|
|
|
272
279
|
this.intensityModel.draw({
|
|
273
280
|
uniforms: {
|
|
@@ -280,8 +287,8 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
280
287
|
}, {
|
|
281
288
|
key: "drawColorMode",
|
|
282
289
|
value: function drawColorMode() {
|
|
283
|
-
var
|
|
284
|
-
opacity =
|
|
290
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
291
|
+
opacity = _ref3.opacity;
|
|
285
292
|
|
|
286
293
|
this.colorModel.draw({
|
|
287
294
|
uniforms: {
|
|
@@ -294,8 +301,8 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
294
301
|
}, {
|
|
295
302
|
key: "draw3DHeatMap",
|
|
296
303
|
value: function draw3DHeatMap() {
|
|
297
|
-
var
|
|
298
|
-
opacity =
|
|
304
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
305
|
+
opacity = _ref4.opacity;
|
|
299
306
|
|
|
300
307
|
var invert = _glMatrix.mat4.create();
|
|
301
308
|
|
|
@@ -314,6 +321,12 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
314
321
|
}, {
|
|
315
322
|
key: "build3dHeatMap",
|
|
316
323
|
value: function build3dHeatMap() {
|
|
324
|
+
var _ref5 = this.layer.getLayerConfig(),
|
|
325
|
+
_ref5$mask = _ref5.mask,
|
|
326
|
+
mask = _ref5$mask === void 0 ? false : _ref5$mask,
|
|
327
|
+
_ref5$maskInside = _ref5.maskInside,
|
|
328
|
+
maskInside = _ref5$maskInside === void 0 ? true : _ref5$maskInside;
|
|
329
|
+
|
|
317
330
|
var getViewportSize = this.rendererService.getViewportSize;
|
|
318
331
|
|
|
319
332
|
var _getViewportSize2 = getViewportSize(),
|
|
@@ -373,7 +386,8 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
373
386
|
data: triangulation.indices,
|
|
374
387
|
type: _l7Core.gl.UNSIGNED_INT,
|
|
375
388
|
count: triangulation.indices.length
|
|
376
|
-
})
|
|
389
|
+
}),
|
|
390
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
377
391
|
});
|
|
378
392
|
}
|
|
379
393
|
}, {
|
|
@@ -390,8 +404,8 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
390
404
|
this.texture.destroy();
|
|
391
405
|
}
|
|
392
406
|
|
|
393
|
-
var
|
|
394
|
-
rampColors =
|
|
407
|
+
var _ref6 = this.layer.getLayerConfig(),
|
|
408
|
+
rampColors = _ref6.rampColors;
|
|
395
409
|
|
|
396
410
|
var imageData = (0, _l7Utils.generateColorRamp)(rampColors);
|
|
397
411
|
this.colorTexture = createTexture2D({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["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","gl","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","HeatmapTriangulation","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","mat4","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","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOA;;;;;;;;;;;;;;;;;;IASqBA,Y,WADpB,4B;;;;;;;;;;;;;;;;;;;;;;;;;;WASC,kBAAgB;AAAA;;AACd,kCAAkC,KAAKC,eAAvC;AAAA,UAAQC,KAAR,yBAAQA,KAAR;AAAA,UAAeC,cAAf,yBAAeA,cAAf;AACAA,MAAAA,cAAc,CAAC,KAAKC,mBAAN,EAA2B,YAAM;AAC7CF,QAAAA,KAAK,CAAC;AACJG,UAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADH;AAEJC,UAAAA,KAAK,EAAE,CAFH;AAGJC,UAAAA,OAAO,EAAE,CAHL;AAIJC,UAAAA,WAAW,EAAE,MAAI,CAACJ;AAJd,SAAD,CAAL;;AAMA,QAAA,MAAI,CAACK,iBAAL;AACD,OARa,CAAd;;AASA,UAAI,KAAKC,KAAL,CAAWC,eAAf,EAAgC;AAC9B,aAAKC,kBAAL;AACD;;AACD,WAAKC,SAAL,KAAmB,SAA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,MAAM,EAAE8F,SAAS,CAAC9F,MAHgB;AAIlCG,QAAAA,KAAK,EAAEC,WAAGC,aAJwB;AAKlCC,QAAAA,KAAK,EAAEF,WAAGC,aALwB;AAMlCE,QAAAA,GAAG,EAAEH,WAAG4F,OAN0B;AAOlCvF,QAAAA,GAAG,EAAEL,WAAG4F,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EA9UuCC,mB","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":["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","gl","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","HeatmapTriangulation","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","mat4","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","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAOA;;;;;;;;;;;;;;;;;;IAEqBA,Y,WADpB,4B;;;;;;;;;;;;;;;;;;;;;;;;;;WASC,kBAAgB;AAAA;;AACd,kCAAkC,KAAKC,eAAvC;AAAA,UAAQC,KAAR,yBAAQA,KAAR;AAAA,UAAeC,cAAf,yBAAeA,cAAf;AACAA,MAAAA,cAAc,CAAC,KAAKC,mBAAN,EAA2B,YAAM;AAC7CF,QAAAA,KAAK,CAAC;AACJG,UAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADH;AAEJC,UAAAA,KAAK,EAAE,CAFH;AAGJC,UAAAA,OAAO,EAAE,CAHL;AAIJC,UAAAA,WAAW,EAAE,MAAI,CAACJ;AAJd,SAAD,CAAL;;AAMA,QAAA,MAAI,CAACK,iBAAL;AACD,OARa,CAAd;;AASA,UAAI,KAAKC,KAAL,CAAWC,eAAf,EAAgC;AAC9B,aAAKC,kBAAL;AACD;;AACD,WAAKC,SAAL,KAAmB,SAAnB,GAA+B,KAAKC,aAAL,EAA/B,GAAsD,KAAKC,aAAL,EAAtD;AACD;;;WAED,wBAAqC;AACnC,YAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WAED,sBAA8B;AAAA;;AAC5B,mCAMI,KAAKf,eANT;AAAA,UACEgB,iBADF,0BACEA,iBADF;AAAA,UAEEf,KAFF,0BAEEA,KAFF;AAAA,UAGEgB,eAHF,0BAGEA,eAHF;AAAA,UAIEC,eAJF,0BAIEA,eAJF;AAAA,UAKEhB,cALF,0BAKEA,cALF;AAOA,UAAMiB,SA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B;AAElCrB,QAAAA,KAAK,EAAEiG,SAAS,CAACjG,KAFiB;AAGlCC,QAAAA,MAAM,EAAEgG,SAAS,CAAChG,MAHgB;AAIlCG,QAAAA,KAAK,EAAEC,WAAGC,aAJwB;AAKlCC,QAAAA,KAAK,EAAEF,WAAGC,aALwB;AAMlCE,QAAAA,GAAG,EAAEH,WAAG8F,OAN0B;AAOlCzF,QAAAA,GAAG,EAAEL,WAAG8F,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EAxVuCC,mB","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"}
|
|
@@ -19,6 +19,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
19
19
|
|
|
20
20
|
var _l7Core = require("@antv/l7-core");
|
|
21
21
|
|
|
22
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
23
|
+
|
|
22
24
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
23
25
|
|
|
24
26
|
var _triangulation = require("../../core/triangulation");
|
|
@@ -63,6 +65,12 @@ var HexagonModel = function (_BaseModel) {
|
|
|
63
65
|
}, {
|
|
64
66
|
key: "buildModels",
|
|
65
67
|
value: function buildModels() {
|
|
68
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
69
|
+
_ref2$mask = _ref2.mask,
|
|
70
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
71
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
72
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
73
|
+
|
|
66
74
|
return [this.layer.buildLayerModel({
|
|
67
75
|
moduleName: 'hexagonheatmap',
|
|
68
76
|
vertexShader: heatmapGridVert,
|
|
@@ -72,7 +80,8 @@ var HexagonModel = function (_BaseModel) {
|
|
|
72
80
|
enable: false
|
|
73
81
|
},
|
|
74
82
|
primitive: _l7Core.gl.TRIANGLES,
|
|
75
|
-
blend: this.getBlend()
|
|
83
|
+
blend: this.getBlend(),
|
|
84
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
76
85
|
})];
|
|
77
86
|
}
|
|
78
87
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap/models/hexagon.ts"],"names":["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","HeatmapGridTriangulation","depth","enable","primitive","gl","TRIANGLES","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap/models/hexagon.ts"],"names":["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","HeatmapGridTriangulation","depth","enable","primitive","gl","TRIANGLES","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","coordinates","version","originCoordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AAEA;;;;;;;;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,KAD0C;AAEhDC,QAAAA,IAAI,EAAEC,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVJ,UAAAA,IAAI,EAAE,OADI;AAEVK,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEb,WAAGc,YAFJ;AAGN/B,YAAAA,IAAI,EAAE,EAHA;AAINyB,YAAAA,IAAI,EAAER,WAAGe;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;AAKA,mBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;EAhEuCG,mB","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 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"}
|
package/lib/image/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/image/index.ts"],"names":["ImageLayer","modelType","getModelType","layerModel","ImageModels","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","image","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["../../src/image/index.ts"],"names":["ImageLayer","modelType","getModelType","layerModel","ImageModels","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","image","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IACqBA,U;;;;;;;;;;;;;;;uFACG,Y;;;;;;WACtB,uBAAqB;AACnB,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;AACA,WAAKC,UAAL,GAAkB,IAAIC,eAAYH,SAAZ,CAAJ,CAA2B,IAA3B,CAAlB;AACA,WAAKI,MAAL,GAAc,KAAKF,UAAL,CAAgBG,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKF,UAAL,CAAgBI,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,KAAKR,YAAL,EAAb;AACA,UAAMW,aAAa,GAAG;AACpBC,QAAAA,KAAK,EAAE;AADa,OAAtB;AAGA,aAAOD,aAAa,CAACH,IAAD,CAApB;AACD;;;WAED,wBAAyC;AACvC,aAAO,OAAP;AACD;;;EA/BqCK,mB","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"}
|
|
@@ -71,6 +71,12 @@ var ImageModel = function (_BaseModel) {
|
|
|
71
71
|
value: function initModels() {
|
|
72
72
|
var _this2 = this;
|
|
73
73
|
|
|
74
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
75
|
+
_ref2$mask = _ref2.mask,
|
|
76
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
77
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
78
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
79
|
+
|
|
74
80
|
var source = this.layer.getSource();
|
|
75
81
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
76
82
|
this.texture = createTexture2D({
|
|
@@ -118,7 +124,8 @@ var ImageModel = function (_BaseModel) {
|
|
|
118
124
|
depth: {
|
|
119
125
|
enable: false
|
|
120
126
|
},
|
|
121
|
-
blend: this.getBlend()
|
|
127
|
+
blend: this.getBlend(),
|
|
128
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
122
129
|
})];
|
|
123
130
|
}
|
|
124
131
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/image/models/image.ts"],"names":["ImageModel","layer","getLayerConfig","opacity","u_opacity","u_texture","texture","source","getSource","createTexture2D","rendererService","height","width","isMini","canvas","layerService","sceneService","getSceneConfig","img","createImage","crossOrigin","src","data","originData","onload","updateLayerRenderList","renderLayers","images","then","imageData","buildLayerModel","moduleName","vertexShader","ImageVert","fragmentShader","ImageFrag","triangulation","RasterImageTriangulation","primitive","gl","TRIANGLES","depth","enable","blend","getBlend","initModels","properties","type","minimum","maximum","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/image/models/image.ts"],"names":["ImageModel","layer","getLayerConfig","opacity","u_opacity","u_texture","texture","mask","maskInside","source","getSource","createTexture2D","rendererService","height","width","isMini","canvas","layerService","sceneService","getSceneConfig","img","createImage","crossOrigin","src","data","originData","onload","updateLayerRenderList","renderLayers","images","then","imageData","buildLayerModel","moduleName","vertexShader","ImageVert","fragmentShader","ImageFrag","triangulation","RasterImageTriangulation","primitive","gl","TRIANGLES","depth","enable","blend","getBlend","stencil","initModels","properties","type","minimum","maximum","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AAEA;;;;;;;;;IAIqBA,U;;;;;;;;;;;;;;;;;;;;;WAEnB,wBAAqC;AACnC,iBAAoB,KAAKC,KAAL,CAAWC,cAAX,EAApB;AAAA,UAAQC,OAAR,QAAQA,OAAR;;AACA,aAAO;AACLC,QAAAA,SAAS,EAAED,OAAO,IAAI,CADjB;AAELE,QAAAA,SAAS,EAAE,KAAKC;AAFX,OAAP;AAID;;;WACD,sBAAoB;AAAA;;AAClB,kBAGI,KAAKL,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEK,IADF;AAAA,UACEA,IADF,2BACS,KADT;AAAA,mCAEEC,UAFF;AAAA,UAEEA,UAFF,iCAEe,IAFf;;AAKA,UAAMC,MAAM,GAAG,KAAKR,KAAL,CAAWS,SAAX,EAAf;AACA,UAAQC,eAAR,GAA4B,KAAKC,eAAjC,CAAQD,eAAR;AACA,WAAKL,OAAL,GAAeK,eAAe,CAAC;AAC7BE,QAAAA,MAAM,EAAE,CADqB;AAE7BC,QAAAA,KAAK,EAAE;AAFsB,OAAD,CAA9B;;AAKA,UAAIC,eAAJ,EAAY;AAEV,YAAMC,MAAM,GAAG,KAAKC,YAAL,CAAkBC,YAAlB,CAA+BC,cAA/B,GAAgDH,MAA/D;AACA,YAAMI,GAAG,GAAGJ,MAAM,CAACK,WAAP,EAAZ;AAEAD,QAAAA,GAAG,CAACE,WAAJ,GAAkB,WAAlB;AACAF,QAAAA,GAAG,CAACG,GAAJ,GAAUd,MAAM,CAACe,IAAP,CAAYC,UAAtB;;AAEAL,QAAAA,GAAG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WACD,uBAAqB;AACnB,aAAO,KAAKwC,UAAL,EAAP;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACV9C,UAAAA,OAAO,EAAE;AACP+C,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WAED,qCAAsC;AAEpC,WAAKC,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhDL,QAAAA,IAAI,EAAEM,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,MADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEnB,WAAGoB,YAFJ;AAGNrC,YAAAA,IAAI,EAAE,EAHA;AAIN0B,YAAAA,IAAI,EAAET,WAAGqB;AAJH,WAFE;AAQVC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;EAxGqCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, isMini } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IImageLayerStyleOptions } from '../../core/interface';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport ImageFrag from '../shaders/image_frag.glsl';\nimport ImageVert from '../shaders/image_vert.glsl';\n\nexport default class ImageModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const { opacity } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n return {\n u_opacity: opacity || 1,\n u_texture: this.texture,\n };\n }\n public initModels() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n\n const source = this.layer.getSource();\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n\n if (isMini) {\n // @ts-ignore\n const canvas = this.layerService.sceneService.getSceneConfig().canvas;\n const img = canvas.createImage();\n // let img = new Image()\n img.crossOrigin = 'anonymous';\n img.src = source.data.originData;\n\n img.onload = () => {\n this.texture = createTexture2D({\n data: img,\n width: img.width,\n height: img.height,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n };\n } else {\n source.data.images.then((imageData: HTMLImageElement[]) => {\n this.texture = createTexture2D({\n data: imageData[0],\n width: imageData[0].width,\n height: imageData[0].height,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n });\n }\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'RasterImage',\n vertexShader: ImageVert,\n fragmentShader: ImageFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n public buildModels() {\n return this.initModels();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected registerBuiltinAttributes() {\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 return [vertex[3], vertex[4]];\n },\n },\n });\n }\n}\n"],"file":"image.js"}
|