@antv/l7-layers 2.7.0 → 2.7.4
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/BaseLayer.d.ts +1 -0
- package/es/core/BaseLayer.js +12 -6
- package/es/core/BaseLayer.js.map +1 -1
- 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/plugins/DataSourcePlugin.js +6 -2
- package/es/plugins/DataSourcePlugin.js.map +1 -1
- package/es/plugins/MultiPassRendererPlugin.js +22 -3
- package/es/plugins/MultiPassRendererPlugin.js.map +1 -1
- package/es/plugins/PixelPickingPlugin.js +16 -18
- package/es/plugins/PixelPickingPlugin.js.map +1 -1
- 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/BaseLayer.js +11 -6
- package/lib/core/BaseLayer.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/plugins/DataSourcePlugin.js +6 -2
- package/lib/plugins/DataSourcePlugin.js.map +1 -1
- package/lib/plugins/MultiPassRendererPlugin.js +23 -3
- package/lib/plugins/MultiPassRendererPlugin.js.map +1 -1
- package/lib/plugins/PixelPickingPlugin.js +16 -18
- package/lib/plugins/PixelPickingPlugin.js.map +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/image.ts"],"names":["AttributeType","gl","BaseModel","PointImageTriangulation","ImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","offsets","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","registerBuiltinAttributes","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","pointImageVert","fragmentShader","pointImageFrag","triangulation","primitive","POINTS","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","iconMap","getIconMap","shape","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AAUA,OAAOC,SAAP,MAAoD,sBAApD;AACA,SAASC,uBAAT,QAAwC,0BAAxC;;;;IAOqBC,U;;;;;;;;;;;;;;;;;;oEAiJK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADY;AAElBC,UAAAA,GAAG,EAAE,QAFa;AAGlBC,UAAAA,GAAG,EAAE,uBAHa;AAIlBC,UAAAA,MAAM,EAAE;AAJU,SAApB;;AAQA,cAAKC,KAAL,CAAWC,YAAX;;AACA;AACD;;AACD,YAAKT,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAA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kD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhD/B,QAAAA,IAAI,EAAE1C,aAAa,CAAC0E,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,MADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE5E,EAAE,CAAC6E,YAFJ;AAGNrE,YAAAA,IAAI,EAAE,EAHA;AAINiC,YAAAA,IAAI,EAAEzC,EAAE,CAAC0C;AAJH,WAFE;AAQVoC,UAAAA,IAAI,EAAE,CARI;AASVvE,UAAAA,MAAM,EAAE,gBACNwE,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMG,OAAO,GAAG,MAAI,CAAC5E,WAAL,CAAiB6E,UAAjB,EAAhB;;AACA,gBAAQC,KAAR,GAAkBR,OAAlB,CAAQQ,KAAR;;AACA,wBAAiBF,OAAO,CAACE,KAAD,CAAP,IAA4B;AAAEC,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA7C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EA/IqCxF,S;;SAAnBE,U","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';\nimport { PointImageTriangulation } from '../../core/triangulation';\nimport pointImageFrag from '../shaders/image_frag.glsl';\nimport pointImageVert from '../shaders/image_vert.glsl';\ninterface IImageLayerStyleOptions {\n opacity: styleSingle;\n offsets: styleOffset;\n}\nexport default class ImageModel extends BaseModel {\n private texture: ITexture2D;\n\n public getUninforms(): IModelUniform {\n const {\n opacity,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_texture: this.texture,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n // u_opacity: opacity || 1.0,\n // u_offsets: [-offsets[0], offsets[1]],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n this.registerBuiltinAttributes();\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointImage',\n vertexShader: pointImageVert,\n fragmentShader: pointImageFrag,\n triangulation: PointImageTriangulation,\n primitive: gl.POINTS,\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { shape } = feature;\n const { x, y } = iconMap[shape as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n mag: 'linear',\n min: 'linear mipmap nearest',\n mipmap: true,\n });\n // this.layer.render();\n // TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层\n this.layer.renderLayers();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.LINEAR,\n // min: gl.LINEAR,\n min: gl.LINEAR_MIPMAP_LINEAR,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n mipmap: true,\n });\n };\n}\n"],"file":"image.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/image.ts"],"names":["AttributeType","gl","getMask","BaseModel","PointImageTriangulation","ImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","offsets","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","registerBuiltinAttributes","updateTexture","on","buildModels","destroy","off","mask","maskInside","buildLayerModel","moduleName","vertexShader","pointImageVert","fragmentShader","pointImageFrag","triangulation","primitive","POINTS","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","iconMap","getIconMap","shape","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,uBAAT,QAAwC,0BAAxC;;;;IAGqBC,U;;;;;;;;;;;;;;;;;;oEAsJK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADY;AAElBC,UAAAA,GAAG,EAAE,QAFa;AAGlBC,UAAAA,GAAG,EAAE,uBAHa;AAIlBC,UAAAA,MAAM,EAAE;AAJU,SAApB;;AAQA,cAAKC,KAAL,CAAWC,YAAX;;AACA;AACD;;AACD,YAAKT,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BC,QAAAA,GAAG,EAAEZ,EAAE,CAACiB,MAFqB;AAI7BJ,QAAAA,GAAG,EAAEb,EAAE,CAACkB,oBAJqB;AAK7BC,QAAAA,gBAAgB,EA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BS;AAHoC,OAAlD;AAyBA,WAAKR,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhDlC,QAAAA,IAAI,EAAE3C,aAAa,CAAC8E,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,MADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEhF,EAAE,CAACiF,YAFJ;AAGNxE,YAAAA,IAAI,EAAE,EAHA;AAINiC,YAAAA,IAAI,EAAE1C,EAAE,CAAC2C;AAJH,WAFE;AAQVuC,UAAAA,IAAI,EAAE,CARI;AASV1E,UAAAA,MAAM,EAAE,gBACN2E,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMG,OAAO,GAAG,MAAI,CAAC/E,WAAL,CAAiBgF,UAAjB,EAAhB;;AACA,gBAAQC,KAAR,GAAkBR,OAAlB,CAAQQ,KAAR;;AACA,wBAAiBF,OAAO,CAACE,KAAD,CAAP,IAA4B;AAAEC,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA7C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EApJqC3F,S;;SAAnBE,U","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointImageTriangulation } from '../../core/triangulation';\nimport pointImageFrag from '../shaders/image_frag.glsl';\nimport pointImageVert from '../shaders/image_vert.glsl';\nexport default class ImageModel extends BaseModel {\n private texture: ITexture2D;\n\n public getUninforms(): IModelUniform {\n const {\n opacity,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_texture: this.texture,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n // u_opacity: opacity || 1.0,\n // u_offsets: [-offsets[0], offsets[1]],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n this.registerBuiltinAttributes();\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointImage',\n vertexShader: pointImageVert,\n fragmentShader: pointImageFrag,\n triangulation: PointImageTriangulation,\n primitive: gl.POINTS,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { shape } = feature;\n const { x, y } = iconMap[shape as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n mag: 'linear',\n min: 'linear mipmap nearest',\n mipmap: true,\n });\n // this.layer.render();\n // TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层\n this.layer.renderLayers();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.LINEAR,\n // min: gl.LINEAR,\n min: gl.LINEAR_MIPMAP_LINEAR,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n mipmap: true,\n });\n };\n}\n"],"file":"image.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/index.ts"],"names":["ExtrudeModel","FillModel","IconModel","IMageModel","NormalModel","SimplePopint","TextModel","PointModels","fill","image","normal","simplePoint","extrude","text","icon"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/index.ts"],"names":["ExtrudeModel","FillModel","IconModel","IMageModel","NormalModel","SimplePopint","TextModel","PointModels","fill","image","normal","simplePoint","extrude","text","icon"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,WAAzB;AACA,OAAOC,SAAP,MAAsB,QAAtB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,UAAP,MAAuB,SAAvB;AACA,OAAOC,WAAP,MAAwB,UAAxB;AACA,OAAOC,YAAP,MAAyB,eAAzB;AACA,OAAOC,SAAP,MAAsB,QAAtB;AAWA,IAAMC,WAAwC,GAAG;AAC/CC,EAAAA,IAAI,EAAEP,SADyC;AAE/CQ,EAAAA,KAAK,EAAEN,UAFwC;AAG/CO,EAAAA,MAAM,EAAEN,WAHuC;AAI/CO,EAAAA,WAAW,EAAEN,YAJkC;AAK/CO,EAAAA,OAAO,EAAEZ,YALsC;AAM/Ca,EAAAA,IAAI,EAAEP,SANyC;AAO/CQ,EAAAA,IAAI,EAAEZ;AAPyC,CAAjD;AAUA,eAAeK,WAAf","sourcesContent":["import ExtrudeModel from './extrude';\nimport FillModel from './fill';\nimport IconModel from './icon-font';\nimport IMageModel from './image';\nimport NormalModel from './normal';\nimport SimplePopint from './simplePoint';\nimport TextModel from './text';\n\nexport type PointType =\n | 'fill'\n | 'image'\n | 'normal'\n | 'simplePoint'\n | 'extrude'\n | 'text'\n | 'icon';\n\nconst PointModels: { [key in PointType]: any } = {\n fill: FillModel,\n image: IMageModel,\n normal: NormalModel,\n simplePoint: SimplePopint,\n extrude: ExtrudeModel,\n text: TextModel,\n icon: IconModel,\n};\n\nexport default PointModels;\n"],"file":"index.js"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { IEncodeFeature, ILayerConfig, IModel, IModelUniform } from '@antv/l7-core';
|
|
2
|
-
import BaseModel
|
|
3
|
-
|
|
4
|
-
opacity: styleSingle;
|
|
5
|
-
offsets: styleOffset;
|
|
6
|
-
}
|
|
2
|
+
import BaseModel from '../../core/BaseModel';
|
|
3
|
+
import { IPointLayerStyleOptions } from '../../core/interface';
|
|
7
4
|
export declare function PointTriangulation(feature: IEncodeFeature): {
|
|
8
5
|
vertices: number[];
|
|
9
6
|
indices: number[];
|
|
@@ -18,4 +15,3 @@ export default class NormalModel extends BaseModel {
|
|
|
18
15
|
protected registerBuiltinAttributes(): void;
|
|
19
16
|
private defaultStyleOptions;
|
|
20
17
|
}
|
|
21
|
-
export {};
|
|
@@ -11,6 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
13
|
import { AttributeType, BlendType, gl } from '@antv/l7-core';
|
|
14
|
+
import { getMask } from '@antv/l7-utils';
|
|
14
15
|
import BaseModel from '../../core/BaseModel';
|
|
15
16
|
var normalFrag = "\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n float opacity = styleMappingMat[0][0];\n\n gl_FragColor = v_color;\n // gl_FragColor.a =gl_FragColor.a * u_opacity;\n gl_FragColor.a =gl_FragColor.a * opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
16
17
|
var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n \n // vec2 offset = project_pixel(u_offsets);\n vec2 offset = project_pixel(textrueOffsets);\n // vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n // gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\\\n // \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // vec2 offset = project_pixel((u_offsets));\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n // vec2 offset = project_pixel(u_offsets);\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
@@ -98,6 +99,12 @@ var NormalModel = function (_BaseModel) {
|
|
|
98
99
|
}, {
|
|
99
100
|
key: "buildModels",
|
|
100
101
|
value: function buildModels() {
|
|
102
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
103
|
+
_ref2$mask = _ref2.mask,
|
|
104
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
105
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
106
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
107
|
+
|
|
101
108
|
return [this.layer.buildLayerModel({
|
|
102
109
|
moduleName: 'normalpoint',
|
|
103
110
|
vertexShader: normalVert,
|
|
@@ -107,7 +114,8 @@ var NormalModel = function (_BaseModel) {
|
|
|
107
114
|
enable: false
|
|
108
115
|
},
|
|
109
116
|
primitive: gl.POINTS,
|
|
110
|
-
blend: this.getBlend()
|
|
117
|
+
blend: this.getBlend(),
|
|
118
|
+
stencil: getMask(mask, maskInside)
|
|
111
119
|
})];
|
|
112
120
|
}
|
|
113
121
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["AttributeType","BlendType","gl","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","NormalModel","blend","layer","getLayerConfig","opacity","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","triangulation","depth","enable","primitive","POINTS","getBlend","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAQO,eARP;
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","NormalModel","blend","layer","getLayerConfig","opacity","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","triangulation","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAQO,eARP;AASA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;;;AAKA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,W;;;;;;;;;;;;;WACnB,2BAA0E;AACxE,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;;WACD,wBAAqC;AACnC,iBAGI,KAAKC,KAAL,CAAWC,cAAX,EAHJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAAC,CAAD,EAAI,CAAJ,CAFZ;;AAKA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBH,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,OAAO,EAAPA;AAFyB,OAA3B,CAFF,EAME;A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,UAAAA,MAAM,EAAE,gBACN9D,OADM,EAEN+D,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBjE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAO8D,KAAK,CAACC,OAAN,CAAc/D,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAEE;AACA,aAAO;AACLG,QAAAA,KAAK,EAAEZ,SAAS,CAACyE;AADZ,OAAP;AAGD;;;;EAzHsCtE,S;;SAApBQ,W","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport normalFrag from '../shaders/normal_frag.glsl';\nimport normalVert from '../shaders/normal_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class NormalModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions & ILayerConfig> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'normalpoint',\n vertexShader: normalVert,\n fragmentShader: normalFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private defaultStyleOptions(): Partial<\n IPointLayerStyleOptions & ILayerConfig\n > {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"normal.js"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { IEncodeFeature, ILayerConfig, IModel, IModelUniform } from '@antv/l7-core';
|
|
2
|
-
import BaseModel
|
|
3
|
-
|
|
4
|
-
opacity: styleSingle;
|
|
5
|
-
offsets: styleOffset;
|
|
6
|
-
blend: string;
|
|
7
|
-
strokeOpacity: styleSingle;
|
|
8
|
-
strokeWidth: styleSingle;
|
|
9
|
-
stroke: styleColor;
|
|
10
|
-
}
|
|
2
|
+
import BaseModel from '../../core/BaseModel';
|
|
3
|
+
import { IPointLayerStyleOptions } from '../../core/interface';
|
|
11
4
|
export declare function PointTriangulation(feature: IEncodeFeature): {
|
|
12
5
|
vertices: number[];
|
|
13
6
|
indices: number[];
|
|
@@ -22,4 +15,3 @@ export default class SimplePointModel extends BaseModel {
|
|
|
22
15
|
protected registerBuiltinAttributes(): void;
|
|
23
16
|
private defaultStyleOptions;
|
|
24
17
|
}
|
|
25
|
-
export {};
|
|
@@ -11,6 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
13
|
import { AttributeType, BlendType, gl } from '@antv/l7-core';
|
|
14
|
+
import { getMask } from '@antv/l7-utils';
|
|
14
15
|
import BaseModel from '../../core/BaseModel';
|
|
15
16
|
var simplePointFrag = "\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_additive;\n\nuniform float u_stroke_opacity : 1;\n\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\nvarying float v_blur;\nvarying float v_innerRadius;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n float opacity = styleMappingMat[0][0];\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n gl_FragColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n gl_FragColor = mix(v_color, stroke, mixR);\n } else {\n gl_FragColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n\n \n\n \n \n if(u_additive > 0.0) {\n gl_FragColor *= circleClipOpacity;\n } else {\n gl_FragColor.a *= circleClipOpacity;\n }\n\n}\n";
|
|
16
17
|
var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_stroke_width;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\nvarying float v_blur;\nvarying float v_innerRadius;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = a_Color;\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n \n // vec2 offset = project_pixel(u_offsets);\n vec2 offset = project_pixel(textrueOffsets);\n // vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n // gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\\\n // \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // vec2 offset = project_pixel((u_offsets));\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n // vec2 offset = project_pixel(u_offsets);\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
@@ -109,6 +110,12 @@ var SimplePointModel = function (_BaseModel) {
|
|
|
109
110
|
}, {
|
|
110
111
|
key: "buildModels",
|
|
111
112
|
value: function buildModels() {
|
|
113
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
114
|
+
_ref2$mask = _ref2.mask,
|
|
115
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
116
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
117
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
118
|
+
|
|
112
119
|
return [this.layer.buildLayerModel({
|
|
113
120
|
moduleName: 'simplepoint',
|
|
114
121
|
vertexShader: simplePointVert,
|
|
@@ -118,7 +125,8 @@ var SimplePointModel = function (_BaseModel) {
|
|
|
118
125
|
enable: false
|
|
119
126
|
},
|
|
120
127
|
primitive: gl.POINTS,
|
|
121
|
-
blend: this.getBlend()
|
|
128
|
+
blend: this.getBlend(),
|
|
129
|
+
stencil: getMask(mask, maskInside)
|
|
122
130
|
})];
|
|
123
131
|
}
|
|
124
132
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/simplePoint.ts"],"names":["AttributeType","BlendType","gl","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","SimplePointModel","blend","layer","getLayerConfig","opacity","offsets","strokeOpacity","strokeWidth","stroke","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","buildModels","buildLayerModel","moduleName","vertexShader","simplePointVert","fragmentShader","simplePointFrag","triangulation","depth","enable","primitive","POINTS","getBlend","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAQO,eARP;
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/simplePoint.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","SimplePointModel","blend","layer","getLayerConfig","opacity","offsets","strokeOpacity","strokeWidth","stroke","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","simplePointVert","fragmentShader","simplePointFrag","triangulation","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAQO,eARP;AAUA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;;;AAMA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,gB;;;;;;;;;;;;;WACnB,2BAA0E;AACxE,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;;WACD,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAAC,CAAD,EAAI,CAAJ,CAFZ;AAAA,UAGEJ,KAHF,QAGEA,KAHF;AAAA,oCAIEK,aAJF;AAAA,UAIEA,aAJF,mCAIkB,CAJlB;AAAA,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AD,EAAOC,UAAP;AARS,OAA3B,CADK,CAAP;AAYD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKpB,WAAL,wEAAkBkC,OAAlB;AACD;;;WAED,qCAAsC;AAEpC,WAAKC,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhDhC,QAAAA,IAAI,EAAEtC,aAAa,CAACuE,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,QADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAExE,EAAE,CAACyE,YAFJ;AAGN9C,YAAAA,IAAI,EAAE,EAHA;AAINS,YAAAA,IAAI,EAAEpC,EAAE,CAACqC;AAJH,WAFE;AAQV7B,UAAAA,IAAI,EAAE,CARI;AASVkE,UAAAA,MAAM,EAAE,gBACNtE,OADM,EAENuE,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBzE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAOsE,KAAK,CAACC,OAAN,CAAcvE,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAEE;AACA,aAAO;AACLG,QAAAA,KAAK,EAAEZ,SAAS,CAACiF;AADZ,OAAP;AAGD;;;;EAlI2C9E,S;;SAAzBQ,gB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\n\nimport simplePointFrag from '../shaders/simplePoint_frag.glsl';\nimport simplePointVert from '../shaders/simplePoint_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class SimplePointModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions & ILayerConfig> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n blend,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = '#fff',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'simplepoint',\n vertexShader: simplePointVert,\n fragmentShader: simplePointFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private defaultStyleOptions(): Partial<\n IPointLayerStyleOptions & ILayerConfig\n > {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"simplePoint.js"}
|
package/es/point/models/text.js
CHANGED
|
@@ -19,7 +19,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
19
19
|
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; } }
|
|
20
20
|
|
|
21
21
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
22
|
-
import { boundsContains, padBounds } from '@antv/l7-utils';
|
|
22
|
+
import { boundsContains, getMask, padBounds } from '@antv/l7-utils';
|
|
23
23
|
import BaseModel from '../../core/BaseModel';
|
|
24
24
|
import CollisionIndex from '../../utils/collision-index';
|
|
25
25
|
import { calculateCentroid } from '../../utils/geo';
|
|
@@ -86,6 +86,12 @@ var TextModel = function (_BaseModel) {
|
|
|
86
86
|
_defineProperty(_assertThisInitialized(_this), "preTextStyle", {});
|
|
87
87
|
|
|
88
88
|
_defineProperty(_assertThisInitialized(_this), "buildModels", function () {
|
|
89
|
+
var _ref = _this.layer.getLayerConfig(),
|
|
90
|
+
_ref$mask = _ref.mask,
|
|
91
|
+
mask = _ref$mask === void 0 ? false : _ref$mask,
|
|
92
|
+
_ref$maskInside = _ref.maskInside,
|
|
93
|
+
maskInside = _ref$maskInside === void 0 ? true : _ref$maskInside;
|
|
94
|
+
|
|
89
95
|
_this.initGlyph();
|
|
90
96
|
|
|
91
97
|
_this.updateTexture();
|
|
@@ -102,7 +108,8 @@ var TextModel = function (_BaseModel) {
|
|
|
102
108
|
depth: {
|
|
103
109
|
enable: false
|
|
104
110
|
},
|
|
105
|
-
blend: _this.getBlend()
|
|
111
|
+
blend: _this.getBlend(),
|
|
112
|
+
stencil: getMask(mask, maskInside)
|
|
106
113
|
})];
|
|
107
114
|
});
|
|
108
115
|
|
|
@@ -112,21 +119,21 @@ var TextModel = function (_BaseModel) {
|
|
|
112
119
|
_createClass(TextModel, [{
|
|
113
120
|
key: "getUninforms",
|
|
114
121
|
value: function getUninforms() {
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
opacity =
|
|
118
|
-
|
|
119
|
-
stroke =
|
|
120
|
-
|
|
121
|
-
strokeWidth =
|
|
122
|
-
|
|
123
|
-
textAnchor =
|
|
124
|
-
|
|
125
|
-
textAllowOverlap =
|
|
126
|
-
|
|
127
|
-
halo =
|
|
128
|
-
|
|
129
|
-
gamma =
|
|
122
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
123
|
+
_ref2$opacity = _ref2.opacity,
|
|
124
|
+
opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
|
|
125
|
+
_ref2$stroke = _ref2.stroke,
|
|
126
|
+
stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
|
|
127
|
+
_ref2$strokeWidth = _ref2.strokeWidth,
|
|
128
|
+
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
129
|
+
_ref2$textAnchor = _ref2.textAnchor,
|
|
130
|
+
textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
|
|
131
|
+
_ref2$textAllowOverla = _ref2.textAllowOverlap,
|
|
132
|
+
textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
|
|
133
|
+
_ref2$halo = _ref2.halo,
|
|
134
|
+
halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
|
|
135
|
+
_ref2$gamma = _ref2.gamma,
|
|
136
|
+
gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma;
|
|
130
137
|
|
|
131
138
|
var _this$fontService = this.fontService,
|
|
132
139
|
canvas = _this$fontService.canvas,
|
|
@@ -195,11 +202,11 @@ var TextModel = function (_BaseModel) {
|
|
|
195
202
|
this.layer.on('remapping', this.buildModels);
|
|
196
203
|
this.extent = this.textExtent();
|
|
197
204
|
|
|
198
|
-
var
|
|
199
|
-
|
|
200
|
-
textAnchor =
|
|
201
|
-
|
|
202
|
-
textAllowOverlap =
|
|
205
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
206
|
+
_ref3$textAnchor = _ref3.textAnchor,
|
|
207
|
+
textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor,
|
|
208
|
+
_ref3$textAllowOverla = _ref3.textAllowOverlap,
|
|
209
|
+
textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla;
|
|
203
210
|
|
|
204
211
|
this.preTextStyle = {
|
|
205
212
|
textAnchor: textAnchor,
|
|
@@ -210,9 +217,9 @@ var TextModel = function (_BaseModel) {
|
|
|
210
217
|
}, {
|
|
211
218
|
key: "needUpdate",
|
|
212
219
|
value: function needUpdate() {
|
|
213
|
-
var
|
|
214
|
-
|
|
215
|
-
textAllowOverlap =
|
|
220
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
221
|
+
_ref4$textAllowOverla = _ref4.textAllowOverlap,
|
|
222
|
+
textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla;
|
|
216
223
|
|
|
217
224
|
var zoom = this.mapService.getZoom();
|
|
218
225
|
var extent = this.mapService.getBounds();
|
|
@@ -314,11 +321,11 @@ var TextModel = function (_BaseModel) {
|
|
|
314
321
|
}, {
|
|
315
322
|
key: "initTextFont",
|
|
316
323
|
value: function initTextFont() {
|
|
317
|
-
var
|
|
318
|
-
|
|
319
|
-
fontWeight =
|
|
320
|
-
|
|
321
|
-
fontFamily =
|
|
324
|
+
var _ref5 = this.layer.getLayerConfig(),
|
|
325
|
+
_ref5$fontWeight = _ref5.fontWeight,
|
|
326
|
+
fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
|
|
327
|
+
_ref5$fontFamily = _ref5.fontFamily,
|
|
328
|
+
fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily;
|
|
322
329
|
|
|
323
330
|
var data = this.layer.getEncodedData();
|
|
324
331
|
var characterSet = [];
|
|
@@ -354,11 +361,11 @@ var TextModel = function (_BaseModel) {
|
|
|
354
361
|
}, {
|
|
355
362
|
key: "initIconFontTex",
|
|
356
363
|
value: function initIconFontTex() {
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
fontWeight =
|
|
360
|
-
|
|
361
|
-
fontFamily =
|
|
364
|
+
var _ref6 = this.layer.getLayerConfig(),
|
|
365
|
+
_ref6$fontWeight = _ref6.fontWeight,
|
|
366
|
+
fontWeight = _ref6$fontWeight === void 0 ? '400' : _ref6$fontWeight,
|
|
367
|
+
_ref6$fontFamily = _ref6.fontFamily,
|
|
368
|
+
fontFamily = _ref6$fontFamily === void 0 ? 'sans-serif' : _ref6$fontFamily;
|
|
362
369
|
|
|
363
370
|
var data = this.layer.getEncodedData();
|
|
364
371
|
var characterSet = [];
|
|
@@ -385,11 +392,11 @@ var TextModel = function (_BaseModel) {
|
|
|
385
392
|
|
|
386
393
|
var mapping = this.fontService.mapping;
|
|
387
394
|
|
|
388
|
-
var
|
|
389
|
-
|
|
390
|
-
spacing =
|
|
391
|
-
|
|
392
|
-
textAnchor =
|
|
395
|
+
var _ref7 = this.layer.getLayerConfig(),
|
|
396
|
+
_ref7$spacing = _ref7.spacing,
|
|
397
|
+
spacing = _ref7$spacing === void 0 ? 2 : _ref7$spacing,
|
|
398
|
+
_ref7$textAnchor = _ref7.textAnchor,
|
|
399
|
+
textAnchor = _ref7$textAnchor === void 0 ? 'center' : _ref7$textAnchor;
|
|
393
400
|
|
|
394
401
|
var data = this.layer.getEncodedData();
|
|
395
402
|
this.glyphInfo = data.map(function (feature) {
|
|
@@ -419,11 +426,11 @@ var TextModel = function (_BaseModel) {
|
|
|
419
426
|
value: function filterGlyphs() {
|
|
420
427
|
var _this3 = this;
|
|
421
428
|
|
|
422
|
-
var
|
|
423
|
-
|
|
424
|
-
padding =
|
|
425
|
-
|
|
426
|
-
textAllowOverlap =
|
|
429
|
+
var _ref8 = this.layer.getLayerConfig(),
|
|
430
|
+
_ref8$padding = _ref8.padding,
|
|
431
|
+
padding = _ref8$padding === void 0 ? [4, 4] : _ref8$padding,
|
|
432
|
+
_ref8$textAllowOverla = _ref8.textAllowOverlap,
|
|
433
|
+
textAllowOverlap = _ref8$textAllowOverla === void 0 ? false : _ref8$textAllowOverla;
|
|
427
434
|
|
|
428
435
|
if (textAllowOverlap) {
|
|
429
436
|
return;
|
|
@@ -501,6 +508,12 @@ var TextModel = function (_BaseModel) {
|
|
|
501
508
|
}, {
|
|
502
509
|
key: "reBuildModel",
|
|
503
510
|
value: function reBuildModel() {
|
|
511
|
+
var _ref9 = this.layer.getLayerConfig(),
|
|
512
|
+
_ref9$mask = _ref9.mask,
|
|
513
|
+
mask = _ref9$mask === void 0 ? false : _ref9$mask,
|
|
514
|
+
_ref9$maskInside = _ref9.maskInside,
|
|
515
|
+
maskInside = _ref9$maskInside === void 0 ? true : _ref9$maskInside;
|
|
516
|
+
|
|
504
517
|
this.filterGlyphs();
|
|
505
518
|
this.layer.models = [this.layer.buildLayerModel({
|
|
506
519
|
moduleName: 'pointText',
|
|
@@ -510,7 +523,8 @@ var TextModel = function (_BaseModel) {
|
|
|
510
523
|
depth: {
|
|
511
524
|
enable: false
|
|
512
525
|
},
|
|
513
|
-
blend: this.getBlend()
|
|
526
|
+
blend: this.getBlend(),
|
|
527
|
+
stencil: getMask(mask, maskInside)
|
|
514
528
|
})];
|
|
515
529
|
}
|
|
516
530
|
}]);
|