@antv/l7-layers 2.8.16 → 2.8.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/es/Geometry/models/plane.js +16 -4
  2. package/es/Geometry/models/plane.js.map +1 -1
  3. package/es/citybuliding/models/build.js +5 -1
  4. package/es/citybuliding/models/build.js.map +1 -1
  5. package/es/core/BaseLayer.js +0 -2
  6. package/es/core/BaseLayer.js.map +1 -1
  7. package/es/core/interface.d.ts +4 -0
  8. package/es/core/interface.js.map +1 -1
  9. package/es/heatmap/models/heatmap.js +5 -1
  10. package/es/heatmap/models/heatmap.js.map +1 -1
  11. package/es/line/models/line.js +5 -3
  12. package/es/line/models/line.js.map +1 -1
  13. package/es/plugins/DataMappingPlugin.js +1 -0
  14. package/es/plugins/DataMappingPlugin.js.map +1 -1
  15. package/es/point/models/extrude.js +2 -2
  16. package/es/point/models/extrude.js.map +1 -1
  17. package/es/point/models/fill.js +7 -3
  18. package/es/point/models/fill.js.map +1 -1
  19. package/es/point/models/fillmage.js +8 -4
  20. package/es/point/models/fillmage.js.map +1 -1
  21. package/es/point/models/radar.js +6 -2
  22. package/es/point/models/radar.js.map +1 -1
  23. package/es/polygon/models/extrude.d.ts +7 -2
  24. package/es/polygon/models/extrude.js +121 -8
  25. package/es/polygon/models/extrude.js.map +1 -1
  26. package/es/polygon/models/fill.js +4 -0
  27. package/es/polygon/models/fill.js.map +1 -1
  28. package/es/polygon/models/ocean.js +1 -1
  29. package/es/polygon/models/ocean.js.map +1 -1
  30. package/es/polygon/models/water.js +3 -3
  31. package/es/polygon/models/water.js.map +1 -1
  32. package/es/utils/symbol-layout.js +1 -1
  33. package/es/utils/symbol-layout.js.map +1 -1
  34. package/lib/Geometry/models/plane.js +16 -4
  35. package/lib/Geometry/models/plane.js.map +1 -1
  36. package/lib/citybuliding/models/build.js +5 -1
  37. package/lib/citybuliding/models/build.js.map +1 -1
  38. package/lib/core/BaseLayer.js +0 -2
  39. package/lib/core/BaseLayer.js.map +1 -1
  40. package/lib/core/interface.js.map +1 -1
  41. package/lib/heatmap/models/heatmap.js +4 -0
  42. package/lib/heatmap/models/heatmap.js.map +1 -1
  43. package/lib/line/models/line.js +5 -3
  44. package/lib/line/models/line.js.map +1 -1
  45. package/lib/plugins/DataMappingPlugin.js +1 -0
  46. package/lib/plugins/DataMappingPlugin.js.map +1 -1
  47. package/lib/point/models/extrude.js +1 -1
  48. package/lib/point/models/extrude.js.map +1 -1
  49. package/lib/point/models/fill.js +6 -2
  50. package/lib/point/models/fill.js.map +1 -1
  51. package/lib/point/models/fillmage.js +7 -3
  52. package/lib/point/models/fillmage.js.map +1 -1
  53. package/lib/point/models/radar.js +5 -1
  54. package/lib/point/models/radar.js.map +1 -1
  55. package/lib/polygon/models/extrude.js +122 -7
  56. package/lib/polygon/models/extrude.js.map +1 -1
  57. package/lib/polygon/models/fill.js +4 -0
  58. package/lib/polygon/models/fill.js.map +1 -1
  59. package/lib/polygon/models/ocean.js +1 -1
  60. package/lib/polygon/models/ocean.js.map +1 -1
  61. package/lib/polygon/models/water.js +3 -3
  62. package/lib/polygon/models/water.js.map +1 -1
  63. package/lib/utils/symbol-layout.js +1 -1
  64. package/lib/utils/symbol-layout.js.map +1 -1
  65. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coords","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;AACA;;AAEA;;;;;;;;IAGqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,QAAA,KAAI,CAACC,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;AACD,OAHD;AAKAD,MAAAA,KAAK,CAACE,KAAN,CAAYI,gBAAZ,CAA6BF,GAA7B,CAAiC,mBAAjC,EAAsD,YAAM;AAC1DJ,QAAAA,KAAK,CAACO,SAAN,CAAgBC,qBAAhB,GAAwC,KAAxC;;AACA,QAAA,KAAI,CAACH,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;;AACA,eAAO,IAAP;AACD,OAJD;AAOAD,MAAAA,KAAK,CAACE,KAAN,CAAYO,YAAZ,CAAyBL,GAAzB,CAA6B,mBAA7B,EAAkD,YAAM;AACtD,YAAIJ,KAAK,CAACU,oBAAV,EAAgC;AAC9B;AACD;;AACD,YAAMC,WAAW,GAAGX,KAAK,CAACY,cAAN,EAApB;AACA,YAAMC,UAAU,GAAGZ,qBAAqB,CAACa,uBAAtB,MAAmD,EAAtE;AACA,YAAMC,MAAM,GAAGd,qBAAqB,CAACe,sBAAtB,CAA6C,QAA7C,C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AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAY7C,MAAM,CAACgD,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGvD,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkB2C,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAInD,SAAS,CAACwB,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQ+B,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAAC1C,YAAD,CAAP;AACD;;AACD,aAAO0C,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coords","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;AACA;;AAEA;;;;;;;;IAGqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,QAAA,KAAI,CAACC,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;AACD,OAHD;AAKAD,MAAAA,KAAK,CAACE,KAAN,CAAYI,gBAAZ,CAA6BF,GAA7B,CAAiC,mBAAjC,EAAsD,YAAM;AAC1DJ,QAAAA,KAAK,CAACO,SAAN,CAAgBC,qBAAhB,GAAwC,KAAxC;;AACA,QAAA,KAAI,CAACH,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;;AACA,eAAO,IAAP;AACD,OAJD;AAOAD,MAAAA,KAAK,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AM+C,OAAO,GAAG,CAAAlD,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkB+C,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAAC5B,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZ8B,KAAY,SAAZA,KAAY;;AAC7B,YACEhD,MAAM,CAACiD,cAAP,CAAsBD,KAAtB,KACA,sBAAApD,SAAS,CAACG,KAAV,wEAAiBmD,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAY7C,MAAM,CAACgD,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGvD,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkB2C,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAInD,SAAS,CAACwB,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQ+B,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAAC1C,YAAD,CAAP;AACD;;AACD,aAAO0C,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
@@ -187,7 +187,7 @@ var ExtrudeModel = function (_BaseModel) {
187
187
  blend: this.getBlend(),
188
188
  cull: {
189
189
  enable: true,
190
- face: this.mapService.version === 'MAPBOX' ? _l7Core.gl.FRONT : _l7Core.gl.BACK
190
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
191
191
  },
192
192
  depth: {
193
193
  enable: depth
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","FRONT","BACK","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","norm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B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhD5C,QAAAA,IAAI,EAAE6C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEnD,WAAGoD,YAFJ;AAGN7D,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVkD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EAjPuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\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\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: this.mapService.version === 'MAPBOX' ? gl.FRONT : gl.BACK,\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\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 = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
1
+ {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI,KAAKC,KAAL,CAAWC,cAAX,EApBJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE,IAFO;AAGdC,QAAAA,MAAM,EAAE;AAHM,OADlB;AAAA,8BAMEC,OANF;AAAA,UAMEA,OANF,6BAMY,CANZ;AAAA,UAQEC,WARF,QAQEA,WARF;AAAA,UASEC,WATF,QASEA,WATF;AAAA,gCAWEC,SAXF;AAAA,UAWEA,SAXF,+BAWc,KAXd;AAAA,kCAYEC,WAZF;AAAA,UAYEA,WAZF,iCAYgB,KAZhB;AAAA,oCAcEC,aAdF;AAAA,UAcEA,aAdF,mCAckB;AACdR,QAAAA,MAAM,EAAE,KADM;AAEdS,QAAAA,GAAG,EAAE;AAFS,OAdlB;AAAA,kCAmBEC,WAnBF;AAAA,UAmBEA,WAnBF,iCAmBgB,IAnBhB;;AAuBA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBT,QAAAA,OAAO,EAAPA;AADyB,OAA3B,CAFF,EAKE;AACA,aAAKU,oBAAL,CAA0B;AACxBV,UAAAA,OAAO,EAAPA;AADwB,SAA1B;AAGA,YAAMW,UAAU,GAAG,KAAKjB,KAAL,CAAWkB,cAAX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AAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNK,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKnB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhD1C,QAAAA,IAAI,EAAE2C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEjD,WAAGkD,YAFJ;AAGN3D,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVgD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EAjPuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { getCullFace, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\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\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\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 = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
@@ -223,7 +223,7 @@ var FillModel = function (_BaseModel) {
223
223
 
224
224
  var isGlobel = this.mapService.version === 'GLOBEL';
225
225
  return [this.layer.buildLayerModel({
226
- moduleName: 'pointfill-' + type,
226
+ moduleName: 'pointfill_' + type,
227
227
  vertexShader: vert,
228
228
  fragmentShader: frag,
229
229
  triangulation: isGlobel ? _triangulation.GlobelPointFillTriangulation : _triangulation.PointFillTriangulation,
@@ -231,7 +231,11 @@ var FillModel = function (_BaseModel) {
231
231
  enable: isGlobel
232
232
  },
233
233
  blend: this.getBlend(),
234
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
234
+ stencil: (0, _l7Utils.getMask)(mask, maskInside),
235
+ cull: {
236
+ enable: true,
237
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
238
+ }
235
239
  })];
236
240
  }
237
241
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_additive","u_globel","mapService","version","Version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","unit","L7MAP","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","isGlobel","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","GlobelPointFillTriangulation","depth","getBlend","stencil","waveFillFrag","pointFillVert","pointFillFrag","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;AAYA;;AACA;;;;;;;;;;IACqBA,S;;;;;;;;;;;;;;;8FACU,C;0FACF,K;;;;;;WAC3B,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;;AASA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBP,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM,EAANA,MAJyB;AAKzBC,QAAAA,OAAO,EAAPA;AALyB,OAA3B,CAFF,EASE;AAEA,aAAKI,oBAAL,CAA0B;AACxBR,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,aAAa,EAAbA,aAFwB;AAGxBC,UAAAA,WAAW,EAAXA,WAHwB;AAIxBC,UAAAA,MAAM,EAANA,MAJwB;AAKxBC,UAAAA,OAAO,EAAPA;AALwB,SAA1B;AAQA,YAAMK,UAAU,GAAG,KAAKX,KAAL,CAAWY,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,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IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\n// animate pointLayer shader - support animate\nimport waveFillFrag from '../shaders/animate/wave_frag.glsl';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\nexport default class FillModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n const { frag, vert, type } = this.getShaders(animateOption);\n\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill-' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(\n animateOption: Partial<IAnimateOption>,\n ): { frag: string; vert: string; type: string } {\n if (animateOption.enable) {\n switch (animateOption.type) {\n case 'wave':\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n default:\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n }\n } else {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
1
+ {"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_additive","u_globel","mapService","version","Version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","unit","L7MAP","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","isGlobel","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","GlobelPointFillTriangulation","depth","getBlend","stencil","cull","face","waveFillFrag","pointFillVert","pointFillFrag","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;AAYA;;AACA;;;;;;;;;;IACqBA,S;;;;;;;;;;;;;;;8FACU,C;0FACF,K;;;;;;WAC3B,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;;AASA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBP,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM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AAAA,KAAK,EAAE/F,WAAGgG,YAFJ;AAGNzG,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV8F,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQ6B,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAAC1J,KAAL,CAAWC,cAAX,GAA4ByJ,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAjWoCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getCullFace, getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\n// animate pointLayer shader - support animate\nimport waveFillFrag from '../shaders/animate/wave_frag.glsl';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\nexport default class FillModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n const { frag, vert, type } = this.getShaders(animateOption);\n\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(\n animateOption: Partial<IAnimateOption>,\n ): { frag: string; vert: string; type: string } {\n if (animateOption.enable) {\n switch (animateOption.type) {\n case 'wave':\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n default:\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n }\n } else {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
@@ -250,7 +250,11 @@ var FillImageModel = function (_BaseModel) {
250
250
  enable: false
251
251
  },
252
252
  blend: this.getBlend(),
253
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
253
+ stencil: (0, _l7Utils.getMask)(mask, maskInside),
254
+ cull: {
255
+ enable: true,
256
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
257
+ }
254
258
  })];
255
259
  }
256
260
  }, {
@@ -265,10 +269,10 @@ var FillImageModel = function (_BaseModel) {
265
269
  }, {
266
270
  key: "clearModels",
267
271
  value: function clearModels() {
268
- var _this$dataTexture;
272
+ var _this$texture, _this$dataTexture;
269
273
 
270
274
  this.iconService.off('imageUpdate', this.updateTexture);
271
- this.texture.destroy();
275
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
272
276
  (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
273
277
  }
274
278
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/fillmage.ts"],"names":["FillImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","gl","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","rotation","getDirty","bind","rotateFlag","mapService","version","radian","Math","PI","getRotation","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_RotateMatrix","Float32Array","cos","sin","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","updateTexture","on","unit","Version","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","enable","getBlend","stencil","pointFillFrag","pointFillVert","off","destroy","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","iconMap","getIconMap","shape","extrude","extrudeIndex","Array","isArray","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AAOA;;;;;;;;;IAEqBA,c;;;;;;;;;;;;;;;8FACU,C;;0FAEF,K;yFACF,C;gGA2SD,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,EAAEK,WAAGC,MAFqB;AAI7BL,QAAAA,GAAG,EAAEI,WAAGE,oBAJqB;AAK7BC,QAAAA,gBAAgB,EAAE,KALW;AAM7BC,QAAAA,KAAK,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A,MAAM,EAAE,gBACNoI,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBH,OAArB,CAAQD,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AAEA,mBAAOU,KAAK,CAACC,OAAN,CAAcX,IAAd,IACH,CAACA,IAAI,CAAC,CAAD,CAAJ,GAAU,MAAI,CAAC/B,WAAhB,CADG,GAEH,CAAE+B,IAAD,GAAmB,MAAI,CAAC/B,WAAzB,CAFJ;AAGD;AApBS;AAHoC,OAAlD;AA0BD;;;EA7SyC2C,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAttribute,\n IElements,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/image/fillImage_frag.glsl';\nimport pointFillVert from '../shaders/image/fillImage_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class FillImageModel extends BaseModel {\n public meter2coord: number = 1;\n private texture: ITexture2D;\n private isMeter: boolean = false;\n private radian: number = 0; // 旋转的弧度\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n rotation,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n /**\n * rotateFlag\n * L7MAP 1\n * MAPBOX 1\n * GAODE2.x -1\n * GAODE1.x -1\n */\n let rotateFlag = 1;\n if (\n this.mapService.version === 'GAODE2.x' ||\n this.mapService.version === 'GAODE1.x'\n ) {\n rotateFlag = -1;\n }\n // 控制图标的旋转角度(绕 Z 轴旋转)\n this.radian = rotation\n ? (rotateFlag * Math.PI * rotation) / 180\n : (rotateFlag * Math.PI * (this.mapService.getRotation() % 360)) / 180;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n u_RotateMatrix: new Float32Array([\n Math.cos(this.radian),\n Math.sin(this.radian),\n -Math.sin(this.radian),\n Math.cos(this.radian),\n ]),\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n\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\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 getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n\n public clearModels() {\n this.iconService.off('imageUpdate', this.updateTexture);\n this.texture.destroy();\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected registerBuiltinAttributes() {\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 this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n }\n\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":"fillmage.js"}
1
+ {"version":3,"sources":["../../../src/point/models/fillmage.ts"],"names":["FillImageModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","mag","min","mipmap","layer","renderLayers","gl","LINEAR","LINEAR_MIPMAP_LINEAR","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","rotation","getDirty","bind","rotateFlag","mapService","version","radian","Math","PI","getRotation","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_RotateMatrix","Float32Array","cos","sin","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_texture","u_textSize","u_opacity","u_offsets","isOffsetStatic","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","updateTexture","on","unit","Version","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","enable","getBlend","stencil","cull","face","pointFillFrag","pointFillVert","off","destroy","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","iconMap","getIconMap","shape","extrude","extrudeIndex","Array","isArray","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AAOA;;;;;;;;;IAEqBA,c;;;;;;;;;;;;;;;8FACU,C;;0FAEF,K;yFACF,C;gGA+SD,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,EAAEK,WAAGC,MAFqB;AAI7BL,QAAAA,GAAG,EAAEI,WAAGE,oBAJqB;AAK7BC,QAAAA,gBAAgB,EAAE,KALW;AAM7BC,QAAAA,KAAK,EAAE,IANsB;AAO7BC,QAAAA,MAAM,EAAE,MAAKZ,WAAL,CAAiBa,YAAjB,IAAiC,GAPZ;AAQ7BT,QAAAA,MAAM,EAAE;AARqB,OAAD,CAA9B;AAUD,K;;;;;;WAtUD,wBAAqC;AACnC,iBAQI,KAAKC,KAAL,CAAWS,cAAX,EARJ;AA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;AACH,gCAAqBH,OAArB,CAAQD,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AAEA,mBAAOU,KAAK,CAACC,OAAN,CAAcX,IAAd,IACH,CAACA,IAAI,CAAC,CAAD,CAAJ,GAAU,MAAI,CAACjC,WAAhB,CADG,GAEH,CAAEiC,IAAD,GAAmB,MAAI,CAACjC,WAAzB,CAFJ;AAGD;AApBS;AAHoC,OAAlD;AA0BD;;;EAjTyC6C,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAttribute,\n IElements,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getCullFace, getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/image/fillImage_frag.glsl';\nimport pointFillVert from '../shaders/image/fillImage_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class FillImageModel extends BaseModel {\n public meter2coord: number = 1;\n private texture: ITexture2D;\n private isMeter: boolean = false;\n private radian: number = 0; // 旋转的弧度\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n rotation,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n /**\n * rotateFlag\n * L7MAP 1\n * MAPBOX 1\n * GAODE2.x -1\n * GAODE1.x -1\n */\n let rotateFlag = 1;\n if (\n this.mapService.version === 'GAODE2.x' ||\n this.mapService.version === 'GAODE1.x'\n ) {\n rotateFlag = -1;\n }\n // 控制图标的旋转角度(绕 Z 轴旋转)\n this.radian = rotation\n ? (rotateFlag * Math.PI * rotation) / 180\n : (rotateFlag * Math.PI * (this.mapService.getRotation() % 360)) / 180;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n u_RotateMatrix: new Float32Array([\n Math.cos(this.radian),\n Math.sin(this.radian),\n -Math.sin(this.radian),\n Math.cos(this.radian),\n ]),\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n\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\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 getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n }),\n ];\n }\n\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n\n public clearModels() {\n this.iconService.off('imageUpdate', this.updateTexture);\n this.texture?.destroy();\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected registerBuiltinAttributes() {\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 this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n }\n\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":"fillmage.js"}
@@ -220,7 +220,11 @@ var RadarModel = function (_BaseModel) {
220
220
  enable: false
221
221
  },
222
222
  blend: this.getBlend(),
223
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
223
+ stencil: (0, _l7Utils.getMask)(mask, maskInside),
224
+ cull: {
225
+ enable: true,
226
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
227
+ }
224
228
  })];
225
229
  }
226
230
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/radar.ts"],"names":["RadarModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","speed","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_speed","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","unit","version","mapService","Version","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","getBlend","stencil","pointFillFrag","pointFillVert","destroy","option","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;AAOA;;;;;;;;;IAEqBA,U;;;;;;;;;;;;;;;8FACU,C;0FACF,K;;;;;;WAC3B,wBAAqC;AACnC,iBAQI,KAAKC,KAAL,CAAWC,cAAX,EARJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;AAAA,4BAOEC,KAPF;AAAA,UAOEA,KAPF,2BAOU,CAPV;;AAUA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBR,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM,EAANA,MAJyB;AAKzBC,QAAAA,OAAO,EAAPA;AALyB,OAA3B,CAFF,EASE;AAEA,aAAKK,oBAAL,C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AlD;AAyBD;;;EAzRqCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n\nimport pointFillFrag from '../shaders/radar/radar_frag.glsl';\nimport pointFillVert from '../shaders/radar/radar_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class RadarModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n speed = 1,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n u_speed: speed,\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 };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'radar',\n };\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"radar.js"}
1
+ {"version":3,"sources":["../../../src/point/models/radar.ts"],"names":["RadarModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","speed","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_speed","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","unit","version","mapService","Version","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","getBlend","stencil","cull","face","pointFillFrag","pointFillVert","destroy","option","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;AAOA;;;;;;;;;IAEqBA,U;;;;;;;;;;;;;;;8FACU,C;0FACF,K;;;;;;WAC3B,wBAAqC;AACnC,iBAQI,KAAKC,KAAL,CAAWC,cAAX,EARJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;AAAA,4BAOEC,KAPF;AAAA,UAOEA,KAPF,2BAOU,CAPV;;AAUA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBR,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM,EAANA,MAJyB;AAKzBC,QAAAA,OAAO,EAAPA;AALyB,OAA3B,CAFF,EASE;AAEA,aAAKK,oBAAL,CAA0B;A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4B6H,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA7RqCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getCullFace, getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n\nimport pointFillFrag from '../shaders/radar/radar_frag.glsl';\nimport pointFillVert from '../shaders/radar/radar_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class RadarModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n speed = 1,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_isMeter: Number(this.isMeter),\n u_speed: speed,\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 };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'radar',\n };\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"radar.js"}