@antv/l7-layers 2.8.17 → 2.8.20

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 (52) hide show
  1. package/es/Geometry/models/plane.js +10 -2
  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 +1 -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 +10 -5
  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 +6 -2
  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/fill.js +4 -0
  24. package/es/polygon/models/fill.js.map +1 -1
  25. package/es/utils/symbol-layout.js +1 -1
  26. package/es/utils/symbol-layout.js.map +1 -1
  27. package/lib/Geometry/models/plane.js +10 -2
  28. package/lib/Geometry/models/plane.js.map +1 -1
  29. package/lib/citybuliding/models/build.js +5 -1
  30. package/lib/citybuliding/models/build.js.map +1 -1
  31. package/lib/core/BaseLayer.js +0 -2
  32. package/lib/core/BaseLayer.js.map +1 -1
  33. package/lib/core/interface.js.map +1 -1
  34. package/lib/heatmap/models/heatmap.js +4 -0
  35. package/lib/heatmap/models/heatmap.js.map +1 -1
  36. package/lib/line/models/line.js +10 -5
  37. package/lib/line/models/line.js.map +1 -1
  38. package/lib/plugins/DataMappingPlugin.js +1 -0
  39. package/lib/plugins/DataMappingPlugin.js.map +1 -1
  40. package/lib/point/models/extrude.js +1 -1
  41. package/lib/point/models/extrude.js.map +1 -1
  42. package/lib/point/models/fill.js +6 -2
  43. package/lib/point/models/fill.js.map +1 -1
  44. package/lib/point/models/fillmage.js +5 -1
  45. package/lib/point/models/fillmage.js.map +1 -1
  46. package/lib/point/models/radar.js +5 -1
  47. package/lib/point/models/radar.js.map +1 -1
  48. package/lib/polygon/models/fill.js +4 -0
  49. package/lib/polygon/models/fill.js.map +1 -1
  50. package/lib/utils/symbol-layout.js +1 -1
  51. package/lib/utils/symbol-layout.js.map +1 -1
  52. package/package.json +5 -5
@@ -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,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AR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA7VoCE,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 {\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,K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QAAAA,IAAI,EAAE,OAD0C;AAEhDxF,QAAAA,IAAI,EAAEyF,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,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
  }, {
@@ -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,EAAE,IANsB;AAO7BC,QAAAA,MAAM,EAAE,MAAKZ,WAAL,CAAiBa,YAAjB,IAAiC,GAPZ;AAQ7BT,QAAAA,MAAM,EAAE;AARqB,OAAD,CAA9B;AAUD,K;;;;;;WAlUD,wBAAqC;AACnC,iB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N,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;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,6BAIE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C,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,CAA0B;AACxBT,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,aAAa,EAAbA,aAFwB;AAGxBC,UAAAA,WAAW,EAAXA,WAHwB;AAIxBC,UAAAA,MAAM,EAANA,MAJwB;AAKxBC,UAAAA,OAAO,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;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBH,OAArB,CAAQF,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AAEA,mBAAOQ,KAAK,CAACC,OAAN,CAAcT,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;AA4BA,WAAKnC,qBAAL,CAA2B0D,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,OAD0C;AAEhD9E,QAAAA,IAAI,EAAE+E,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAErF,WAAGsF,YAFJ;AAGN/F,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVoF,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQQ,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAAC5H,KAAL,CAAWC,cAAX,GAA4B2H,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;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;AACxBT,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,aAAa,EAAbA,aAFwB;AAGxBC,UAAAA,WAAW,EAAXA,WAHwB;AAIxBC,UAAAA,MAAM,EAANA,MAJwB;AAKxBC,UAAAA,OAAO,EAAPA;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ent":["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"}
@@ -125,6 +125,10 @@ var FillModel = function (_BaseModel) {
125
125
  depth: {
126
126
  enable: false
127
127
  },
128
+ cull: {
129
+ enable: true,
130
+ face: _l7Core.gl.BACK
131
+ },
128
132
  stencil: (0, _l7Utils.getMask)(mask, maskInside)
129
133
  })];
130
134
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","opacityLinear","enable","dir","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_opacitylinear","Number","u_dir","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","polygon_linear_vert","polygon_vert","fragmentShader","polygon_linear_frag","polygon_frag","triangulation","polygonTriangulationWithCenter","polygonTriangulation","blend","getBlend","depth","stencil","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;;;;;;;;IAQqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OAFlB;;AAOA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEL,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKM,oBAAL,CAA0B;AAAEN,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,YAAMO,UAAU,GAAG,KAAKT,KAAL,CAAWU,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd,sBAAcA,KAAd;AAAA,YAAqBC,MAArB,sBAAqBA,MAArB;;AAKA,aAAKC,QAAL,GAAgBD,MAAhB;AAEA,aAAKE,WAAL,GACE,KAAKN,UAAL,GAAkB,CAAlB,IAAuBE,IAAI,CAACK,MAAL,GAAc,CAArC,GACI,KAAKC,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AAEnBP,UAAAA,IAAI,EAAJA,IAFmB;AAGnBQ,UAAAA,MA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;AAlBS;AAHoC,SAAlD;AAwBD;AACF;;;EAtHoCG,mB","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport {\n polygonTriangulation,\n polygonTriangulationWithCenter,\n} from '../../core/triangulation';\nimport polygon_frag from '../shaders/polygon_frag.glsl';\nimport polygon_linear_frag from '../shaders/polygon_linear_frag.glsl';\nimport polygon_linear_vert from '../shaders/polygon_linear_vert.glsl';\nimport polygon_vert from '../shaders/polygon_vert.glsl';\nexport default class FillModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n u_opacitylinear: Number(opacityLinear.enable),\n u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon',\n vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,\n fragmentShader: opacityLinear.enable\n ? polygon_linear_frag\n : polygon_frag,\n // triangulation: polygonTriangulation,\n triangulation: opacityLinear.enable\n ? polygonTriangulationWithCenter\n : polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (opacityLinear.enable) {\n this.styleAttributeService.registerStyleAttribute({\n name: 'linear',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_linear',\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 // center[0] center[1] radius\n return [vertex[3], vertex[4], vertex[5]];\n },\n },\n });\n }\n }\n}\n"],"file":"fill.js"}
1
+ {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","opacityLinear","enable","dir","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_opacitylinear","Number","u_dir","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","polygon_linear_vert","polygon_vert","fragmentShader","polygon_linear_frag","polygon_frag","triangulation","polygonTriangulationWithCenter","polygonTriangulation","blend","getBlend","depth","cull","face","BACK","stencil","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;;;;;;;;IAQqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OAFlB;;AAOA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEL,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKM,oBAAL,CAA0B;AAAEN,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,YAAMO,UAAU,GAAG,KAAKT,KAAL,CAAWU,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd,sBAAcA,KAAd;AAAA,YAAqBC,MAArB,sBAAqBA,MAArB;;AAKA,aAAKC,QAAL,GAAgBD,MAAhB;AAEA,aAAKE,WAAL,GACE,KAAKN,UAAL,GAAkB,CAAlB,IAAuBE,IAAI,CAACK,MAAL,GAAc,CAArC,GACI,KAAKC,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AAEnBP,UAAAA,IAAI,EAAJA,IAFmB;AAGnBQ,UAAAA,MAAM,EAAEC,WAAGC,SAHQ;AAInBC,UAAAA,IAAI,EAAEF,WAAGG,KAJU;AAKnBX,UAAAA,KAAK,EAALA,K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AAD,CAA7B,CAAP;AACD;AAlBS;AAHoC,SAAlD;AAwBD;AACF;;;EAzHoCG,mB","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport {\n polygonTriangulation,\n polygonTriangulationWithCenter,\n} from '../../core/triangulation';\nimport polygon_frag from '../shaders/polygon_frag.glsl';\nimport polygon_linear_frag from '../shaders/polygon_linear_frag.glsl';\nimport polygon_linear_vert from '../shaders/polygon_linear_vert.glsl';\nimport polygon_vert from '../shaders/polygon_vert.glsl';\nexport default class FillModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n u_opacitylinear: Number(opacityLinear.enable),\n u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon',\n vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,\n fragmentShader: opacityLinear.enable\n ? polygon_linear_frag\n : polygon_frag,\n // triangulation: polygonTriangulation,\n triangulation: opacityLinear.enable\n ? polygonTriangulationWithCenter\n : polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (opacityLinear.enable) {\n this.styleAttributeService.registerStyleAttribute({\n name: 'linear',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_linear',\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 // center[0] center[1] radius\n return [vertex[3], vertex[4], vertex[5]];\n },\n },\n });\n }\n }\n}\n"],"file":"fill.js"}
@@ -157,7 +157,7 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
157
157
  if (glyph) {
158
158
  positionedGlyphs.push({
159
159
  glyph: iconfont,
160
- x: x,
160
+ x: glyph.advance / 2,
161
161
  y: y + baselineOffset,
162
162
  vertical: false,
163
163
  scale: 1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/symbol-layout.ts"],"names":["getAnchorAlignment","anchor","horizontalAlign","verticalAlign","justifyLine","positionedGlyphs","glyphMap","start","end","justify","lastPositionedGlyph","glyph","lastAdvance","advance","scale","lineIndent","x","j","align","maxLineLength","lineHeight","lineCount","shiftX","shiftY","glyphs","y","shapeLines","shaping","lines","textAnchor","textJustify","spacing","yOffset","lineStartIndex","length","forEach","line","split","char","baselineOffset","push","vertical","metrics","lineLength","Math","max","height","top","bottom","left","right","shapeIconFont","iconfonts","iconfont","shapeText","text","translate","isIconFont","getGlyphQuads","textOffset","alongLine","quads","positionedGlyph","rect","rectBuffer","halfAdvance","glyphOffset","builtInOffset","x1","y1","x2","width","y2","tl","tr","bl","br","tex"],"mappings":";;;;;;;;;;;;;;AAyCA,SAASA,kBAAT,CAA4BC,MAA5B,EAAgD;AAC9C,MAAIC,eAAe,GAAG,GAAtB;AACA,MAAIC,aAAa,GAAG,GAApB;;AACA,UAAQF,MAAR;AACE,SAAK,OAAL;AACA,SAAK,WAAL;AACA,SAAK,cAAL;AACEC,MAAAA,eAAe,GAAG,CAAlB;AACA;;AACF,SAAK,MAAL;AACA,SAAK,UAAL;AACA,SAAK,aAAL;AACEA,MAAAA,eAAe,GAAG,CAAlB;AACA;;AACF;AACEA,MAAAA,eAAe,GAAG,GAAlB;AAZJ;;AAeA,UAAQD,MAAR;AACE,SAAK,QAAL;AACA,SAAK,cAAL;AACA,SAAK,aAAL;AACEE,MAAAA,aAAa,GAAG,CAAhB;AACA;;AACF,SAAK,KAAL;AACA,SAAK,WAAL;AACA,SAAK,UAAL;AACEA,MAAAA,aAAa,GAAG,CAAhB;AACA;;AACF;AACEA,MAAAA,aAAa,GAAG,GAAhB;AAZJ;;AAeA,SAAO;AAAED,IAAAA,eAAe,EAAfA,eAAF;AAAmBC,IAAAA,aAAa,EAAbA;AAAnB,GAAP;AACD;;AAGD,SAASC,WAAT,CACEC,gBADF,EAEEC,QAFF,EAGEC,KAHF,EAIEC,GAJF,EAKEC,OALF,EAME;AACA,MAAI,CAACA,OAAL,EAAc;AACZ;AACD;;AAED,MAAMC,mBAAmB,GAAGL,gBAAgB,CAACG,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AAAZ,OAAX;AACA,UAAMK,EAAE,GAAG;AAAE1D,QAAAA,CAAC,EAAEsD,EAAL;AAAS7C,QAAAA,CAAC,EAAE4C;AAAZ,OAAX;AACA,UAAMM,EAAE,GAAG;AAAE3D,QAAAA,CAAC,EAAEoD,EAAL;AAAS3C,QAAAA,CAAC,EAAE+C;AAAZ,OAAX;AACA,UAAMI,EAAE,GAAG;AAAE5D,QAAAA,CAAC,EAAEsD,EAAL;AAAS7C,QAAAA,CAAC,EAAE+C;AAAZ,OAAX;AAIAX,MAAAA,KAAK,CAACrB,IAAN,CAAW;AAAEiC,QAAAA,EAAE,EAAFA,EAAF;AAAMC,QAAAA,EAAE,EAAFA,EAAN;AAAUC,QAAAA,EAAE,EAAFA,EAAV;AAAcC,QAAAA,EAAE,EAAFA,EAAd;AAAkBC,QAAAA,GAAG,EAAEd,IAAvB;AAA6BG,QAAAA,WAAW,EAAXA;AAA7B,OAAX;AACD;AArCa;AAAA;AAAA;AAAA;AAAA;;AAuCd,SAAOL,KAAP;AACD","sourcesContent":["import { type } from 'os';\n\ninterface IPoint {\n x: number;\n y: number;\n}\nexport type anchorType =\n | 'right'\n | 'top-right'\n | 'left'\n | 'bottom-right'\n | 'left'\n | 'top-left'\n | 'bottom-left'\n | 'bottom'\n | 'bottom-right'\n | 'bottom-left'\n | 'top'\n | 'top-right'\n | 'top-left'\n | 'center';\nexport interface IGlyphQuad {\n tr: IPoint;\n tl: IPoint;\n bl: IPoint;\n br: IPoint;\n tex: {\n x: number;\n y: number;\n height: number;\n width: number;\n advance: number;\n };\n glyphOffset: [number, number];\n}\n\n/**\n * 返回文本相对锚点位置\n * @param {string} anchor 锚点位置\n * @return {alignment} alignment\n */\nfunction getAnchorAlignment(anchor: anchorType) {\n let horizontalAlign = 0.5;\n let verticalAlign = 0.5;\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n horizontalAlign = 1;\n break;\n case 'left':\n case 'top-left':\n case 'bottom-left':\n horizontalAlign = 0;\n break;\n default:\n horizontalAlign = 0.5;\n }\n\n switch (anchor) {\n case 'bottom':\n case 'bottom-right':\n case 'bottom-left':\n verticalAlign = 1;\n break;\n case 'top':\n case 'top-right':\n case 'top-left':\n verticalAlign = 0;\n break;\n default:\n verticalAlign = 0.5;\n }\n\n return { horizontalAlign, verticalAlign };\n}\n\n// justify right = 1, left = 0, center = 0.5\nfunction justifyLine(\n positionedGlyphs: any,\n glyphMap: any,\n start: number,\n end: number,\n justify: number,\n) {\n if (!justify) {\n return;\n }\n\n const lastPositionedGlyph = positionedGlyphs[end];\n const glyph = lastPositionedGlyph.glyph;\n if (glyph) {\n const lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;\n const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;\n\n for (let j = start; j <= end; j++) {\n positionedGlyphs[j].x -= lineIndent;\n }\n }\n}\n\n// justify right=1 left=0 center=0.5\n// horizontalAlign right=1 left=0 center=0.5\n// verticalAlign right=1 left=0 center=0.5\nfunction align(\n positionedGlyphs: any[],\n justify: number,\n horizontalAlign: number,\n verticalAlign: number,\n maxLineLength: number,\n lineHeight: number,\n lineCount: number,\n) {\n const shiftX = (justify - horizontalAlign) * maxLineLength;\n const shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;\n\n for (const glyphs of positionedGlyphs) {\n glyphs.x += shiftX;\n glyphs.y += shiftY;\n }\n}\n\nfunction shapeLines(\n shaping: any,\n glyphMap: any,\n lines: any[],\n lineHeight: number,\n textAnchor: anchorType,\n textJustify: string,\n spacing: number,\n) {\n // buffer 为 4\n const yOffset = -8;\n\n let x = 0;\n let y = yOffset;\n\n let maxLineLength = 0;\n const positionedGlyphs = shaping.positionedGlyphs;\n\n const justify =\n textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;\n\n const lineStartIndex = positionedGlyphs.length;\n lines.forEach((line) => {\n line.split('').forEach((char: string) => {\n const glyph = glyphMap[char];\n const baselineOffset = 0;\n\n if (glyph) {\n positionedGlyphs.push({\n glyph: char,\n x,\n y: y + baselineOffset,\n vertical: false, // TODO:目前只支持水平方向\n scale: 1,\n metrics: glyph,\n });\n x += glyph.advance + spacing;\n }\n });\n\n // 左右对齐\n if (positionedGlyphs.length !== lineStartIndex) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(\n positionedGlyphs,\n glyphMap,\n lineStartIndex,\n positionedGlyphs.length - 1,\n justify,\n );\n }\n\n x = 0;\n y -= lineHeight + 5;\n });\n\n const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor);\n align(\n positionedGlyphs,\n justify,\n horizontalAlign,\n verticalAlign,\n maxLineLength,\n lineHeight,\n lines.length,\n );\n\n // 计算包围盒\n const height = y - yOffset;\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top - height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\nfunction shapeIconFont(\n shaping: any,\n glyphMap: any,\n iconfonts: any[],\n lineHeight: number,\n textAnchor: anchorType,\n textJustify: string,\n spacing: number,\n) {\n // buffer 为 4\n const yOffset = -8;\n\n let x = 0;\n let y = yOffset;\n\n let maxLineLength = 0;\n const positionedGlyphs = shaping.positionedGlyphs;\n\n const justify =\n textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;\n\n const lineStartIndex = positionedGlyphs.length;\n iconfonts.forEach((iconfont) => {\n const glyph = glyphMap[iconfont];\n const baselineOffset = 0;\n\n if (glyph) {\n positionedGlyphs.push({\n glyph: iconfont,\n x,\n y: y + baselineOffset,\n vertical: false, // TODO:目前只支持水平方向\n scale: 1,\n metrics: glyph,\n });\n x += glyph.advance + spacing;\n }\n\n // 左右对齐\n if (positionedGlyphs.length !== lineStartIndex) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(\n positionedGlyphs,\n glyphMap,\n lineStartIndex,\n positionedGlyphs.length - 1,\n justify,\n );\n }\n\n x = 0;\n y -= lineHeight + 5;\n });\n\n const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor);\n align(\n positionedGlyphs,\n justify,\n horizontalAlign,\n verticalAlign,\n maxLineLength,\n lineHeight,\n iconfonts.length,\n );\n\n // 计算包围盒\n const height = y - yOffset;\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top - height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\n/**\n * 计算文本中每个独立字符相对锚点的位置\n *\n * @param {string} text 原始文本\n * @param {*} glyphs mapping\n * @param {number} lineHeight 行高\n * @param {string} textAnchor 文本相对于锚点的位置\n * @param {string} textJustify 左右对齐\n * @param {number} spacing 字符间距\n * @param {[number, number]} translate 文本水平 & 垂直偏移量\n * @param {[boolean]} isIconFont 是否是 iconfont\n * @return {boolean|shaping} 每个字符相对于锚点的位置\n */\nexport function shapeText(\n text: string,\n glyphs: any,\n lineHeight: number,\n textAnchor: anchorType,\n textJustify: string,\n spacing: number,\n translate: [number, number] = [0, 0],\n isIconFont: boolean,\n) {\n // TODO:处理换行\n const lines = text.split('\\n');\n\n const positionedGlyphs: any[] = [];\n const shaping = {\n positionedGlyphs,\n top: translate[1],\n bottom: translate[1],\n left: translate[0],\n right: translate[0],\n lineCount: lines.length,\n text,\n };\n isIconFont\n ? shapeIconFont(\n shaping,\n glyphs,\n lines,\n lineHeight,\n textAnchor,\n textJustify,\n spacing,\n )\n : shapeLines(\n shaping,\n glyphs,\n lines,\n lineHeight,\n textAnchor,\n textJustify,\n spacing,\n );\n if (!positionedGlyphs.length) {\n return false;\n }\n\n return shaping;\n}\n\nexport function getGlyphQuads(\n shaping: any,\n textOffset: [number, number] = [0, 0],\n alongLine: boolean,\n): IGlyphQuad[] {\n const { positionedGlyphs = [] } = shaping;\n const quads: IGlyphQuad[] = [];\n\n for (const positionedGlyph of positionedGlyphs) {\n const rect = positionedGlyph.metrics;\n\n // The rects have an addditional buffer that is not included in their size.\n const rectBuffer = 4;\n\n const halfAdvance = (rect.advance * positionedGlyph.scale) / 2;\n\n const glyphOffset: [number, number] = alongLine\n ? [positionedGlyph.x + halfAdvance, positionedGlyph.y]\n : [0, 0];\n\n const builtInOffset = alongLine\n ? [0, 0]\n : [\n positionedGlyph.x + halfAdvance + textOffset[0],\n positionedGlyph.y + textOffset[1],\n ];\n\n const x1 =\n (0 - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];\n const y1 = (0 - rectBuffer) * positionedGlyph.scale + builtInOffset[1];\n const x2 = x1 + rect.width * positionedGlyph.scale;\n const y2 = y1 + rect.height * positionedGlyph.scale;\n\n const tl = { x: x1, y: y1 };\n const tr = { x: x2, y: y1 };\n const bl = { x: x1, y: y2 };\n const br = { x: x2, y: y2 };\n\n // TODO:处理字符旋转的情况\n\n quads.push({ tl, tr, bl, br, tex: rect, glyphOffset });\n }\n\n return quads;\n}\n"],"file":"symbol-layout.js"}
1
+ {"version":3,"sources":["../../src/utils/symbol-layout.ts"],"names":["getAnchorAlignment","anchor","horizontalAlign","verticalAlign","justifyLine","positionedGlyphs","glyphMap","start","end","justify","lastPositionedGlyph","glyph","lastAdvance","advance","scale","lineIndent","x","j","align","maxLineLength","lineHeight","lineCount","shiftX","shiftY","glyphs","y","shapeLines","shaping","lines","textAnchor","textJustify","spacing","yOffset","lineStartIndex","length","forEach","line","split","char","baselineOffset","push","vertical","metrics","lineLength","Math","max","height","top","bottom","left","right","shapeIconFont","iconfonts","iconfont","shapeText","text","translate","isIconFont","getGlyphQuads","textOffset","alongLine","quads","positionedGlyph","rect","rectBuffer","halfAdvance","glyphOffset","builtInOffset","x1","y1","x2","width","y2","tl","tr","bl","br","tex"],"mappings":";;;;;;;;;;;;;;AAyCA,SAASA,kBAAT,CAA4BC,MAA5B,EAAgD;AAC9C,MAAIC,eAAe,GAAG,GAAtB;AACA,MAAIC,aAAa,GAAG,GAApB;;AACA,UAAQF,MAAR;AACE,SAAK,OAAL;AACA,SAAK,WAAL;AACA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AG,EAAEd,IAAvB;AAA6BG,QAAAA,WAAW,EAAXA;AAA7B,OAAX;AACD;AArCa;AAAA;AAAA;AAAA;AAAA;;AAuCd,SAAOL,KAAP;AACD","sourcesContent":["import { type } from 'os';\n\ninterface IPoint {\n x: number;\n y: number;\n}\nexport type anchorType =\n | 'right'\n | 'top-right'\n | 'left'\n | 'bottom-right'\n | 'left'\n | 'top-left'\n | 'bottom-left'\n | 'bottom'\n | 'bottom-right'\n | 'bottom-left'\n | 'top'\n | 'top-right'\n | 'top-left'\n | 'center';\nexport interface IGlyphQuad {\n tr: IPoint;\n tl: IPoint;\n bl: IPoint;\n br: IPoint;\n tex: {\n x: number;\n y: number;\n height: number;\n width: number;\n advance: number;\n };\n glyphOffset: [number, number];\n}\n\n/**\n * 返回文本相对锚点位置\n * @param {string} anchor 锚点位置\n * @return {alignment} alignment\n */\nfunction getAnchorAlignment(anchor: anchorType) {\n let horizontalAlign = 0.5;\n let verticalAlign = 0.5;\n switch (anchor) {\n case 'right':\n case 'top-right':\n case 'bottom-right':\n horizontalAlign = 1;\n break;\n case 'left':\n case 'top-left':\n case 'bottom-left':\n horizontalAlign = 0;\n break;\n default:\n horizontalAlign = 0.5;\n }\n\n switch (anchor) {\n case 'bottom':\n case 'bottom-right':\n case 'bottom-left':\n verticalAlign = 1;\n break;\n case 'top':\n case 'top-right':\n case 'top-left':\n verticalAlign = 0;\n break;\n default:\n verticalAlign = 0.5;\n }\n\n return { horizontalAlign, verticalAlign };\n}\n\n// justify right = 1, left = 0, center = 0.5\nfunction justifyLine(\n positionedGlyphs: any,\n glyphMap: any,\n start: number,\n end: number,\n justify: number,\n) {\n if (!justify) {\n return;\n }\n\n const lastPositionedGlyph = positionedGlyphs[end];\n const glyph = lastPositionedGlyph.glyph;\n if (glyph) {\n const lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;\n const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;\n\n for (let j = start; j <= end; j++) {\n positionedGlyphs[j].x -= lineIndent;\n }\n }\n}\n\n// justify right=1 left=0 center=0.5\n// horizontalAlign right=1 left=0 center=0.5\n// verticalAlign right=1 left=0 center=0.5\nfunction align(\n positionedGlyphs: any[],\n justify: number,\n horizontalAlign: number,\n verticalAlign: number,\n maxLineLength: number,\n lineHeight: number,\n lineCount: number,\n) {\n const shiftX = (justify - horizontalAlign) * maxLineLength;\n const shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;\n\n for (const glyphs of positionedGlyphs) {\n glyphs.x += shiftX;\n glyphs.y += shiftY;\n }\n}\n\nfunction shapeLines(\n shaping: any,\n glyphMap: any,\n lines: any[],\n lineHeight: number,\n textAnchor: anchorType,\n textJustify: string,\n spacing: number,\n) {\n // buffer 为 4\n const yOffset = -8;\n\n let x = 0;\n let y = yOffset;\n\n let maxLineLength = 0;\n const positionedGlyphs = shaping.positionedGlyphs;\n\n const justify =\n textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;\n\n const lineStartIndex = positionedGlyphs.length;\n lines.forEach((line) => {\n line.split('').forEach((char: string) => {\n const glyph = glyphMap[char];\n const baselineOffset = 0;\n\n if (glyph) {\n positionedGlyphs.push({\n glyph: char,\n x,\n y: y + baselineOffset,\n vertical: false, // TODO:目前只支持水平方向\n scale: 1,\n metrics: glyph,\n });\n x += glyph.advance + spacing;\n }\n });\n\n // 左右对齐\n if (positionedGlyphs.length !== lineStartIndex) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(\n positionedGlyphs,\n glyphMap,\n lineStartIndex,\n positionedGlyphs.length - 1,\n justify,\n );\n }\n\n x = 0;\n y -= lineHeight + 5;\n });\n\n const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor);\n align(\n positionedGlyphs,\n justify,\n horizontalAlign,\n verticalAlign,\n maxLineLength,\n lineHeight,\n lines.length,\n );\n\n // 计算包围盒\n const height = y - yOffset;\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top - height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\nfunction shapeIconFont(\n shaping: any,\n glyphMap: any,\n iconfonts: any[],\n lineHeight: number,\n textAnchor: anchorType,\n textJustify: string,\n spacing: number,\n) {\n // buffer 为 4\n const yOffset = -8;\n\n let x = 0;\n let y = yOffset;\n\n let maxLineLength = 0;\n const positionedGlyphs = shaping.positionedGlyphs;\n\n const justify =\n textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;\n\n const lineStartIndex = positionedGlyphs.length;\n iconfonts.forEach((iconfont) => {\n const glyph = glyphMap[iconfont];\n const baselineOffset = 0;\n\n if (glyph) {\n positionedGlyphs.push({\n glyph: iconfont,\n // x,\n /**\n * iconfont\n * 在计算大小的时候计算的是 unicode 字符 如 &#xe6d4;\n * 在布局计算 icon 位置的时候应该始终保持居中(且 icon 只占一个字符的位置)\n */\n x: glyph.advance / 2,\n y: y + baselineOffset,\n vertical: false, // TODO:目前只支持水平方向\n scale: 1,\n metrics: glyph,\n });\n x += glyph.advance + spacing;\n }\n\n // 左右对齐\n if (positionedGlyphs.length !== lineStartIndex) {\n const lineLength = x - spacing;\n maxLineLength = Math.max(lineLength, maxLineLength);\n justifyLine(\n positionedGlyphs,\n glyphMap,\n lineStartIndex,\n positionedGlyphs.length - 1,\n justify,\n );\n }\n\n x = 0;\n y -= lineHeight + 5;\n });\n\n const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor);\n align(\n positionedGlyphs,\n justify,\n horizontalAlign,\n verticalAlign,\n maxLineLength,\n lineHeight,\n iconfonts.length,\n );\n\n // 计算包围盒\n const height = y - yOffset;\n\n shaping.top += -verticalAlign * height;\n shaping.bottom = shaping.top - height;\n shaping.left += -horizontalAlign * maxLineLength;\n shaping.right = shaping.left + maxLineLength;\n}\n\n/**\n * 计算文本中每个独立字符相对锚点的位置\n *\n * @param {string} text 原始文本\n * @param {*} glyphs mapping\n * @param {number} lineHeight 行高\n * @param {string} textAnchor 文本相对于锚点的位置\n * @param {string} textJustify 左右对齐\n * @param {number} spacing 字符间距\n * @param {[number, number]} translate 文本水平 & 垂直偏移量\n * @param {[boolean]} isIconFont 是否是 iconfont\n * @return {boolean|shaping} 每个字符相对于锚点的位置\n */\nexport function shapeText(\n text: string,\n glyphs: any,\n lineHeight: number,\n textAnchor: anchorType,\n textJustify: string,\n spacing: number,\n translate: [number, number] = [0, 0],\n isIconFont: boolean,\n) {\n // TODO:处理换行\n const lines = text.split('\\n');\n\n const positionedGlyphs: any[] = [];\n const shaping = {\n positionedGlyphs,\n top: translate[1],\n bottom: translate[1],\n left: translate[0],\n right: translate[0],\n lineCount: lines.length,\n text,\n };\n isIconFont\n ? shapeIconFont(\n shaping,\n glyphs,\n lines,\n lineHeight,\n textAnchor,\n textJustify,\n spacing,\n )\n : shapeLines(\n shaping,\n glyphs,\n lines,\n lineHeight,\n textAnchor,\n textJustify,\n spacing,\n );\n if (!positionedGlyphs.length) {\n return false;\n }\n\n return shaping;\n}\n\nexport function getGlyphQuads(\n shaping: any,\n textOffset: [number, number] = [0, 0],\n alongLine: boolean,\n): IGlyphQuad[] {\n const { positionedGlyphs = [] } = shaping;\n const quads: IGlyphQuad[] = [];\n\n for (const positionedGlyph of positionedGlyphs) {\n const rect = positionedGlyph.metrics;\n\n // The rects have an addditional buffer that is not included in their size.\n const rectBuffer = 4;\n\n const halfAdvance = (rect.advance * positionedGlyph.scale) / 2;\n\n const glyphOffset: [number, number] = alongLine\n ? [positionedGlyph.x + halfAdvance, positionedGlyph.y]\n : [0, 0];\n\n const builtInOffset = alongLine\n ? [0, 0]\n : [\n positionedGlyph.x + halfAdvance + textOffset[0],\n positionedGlyph.y + textOffset[1],\n ];\n\n const x1 =\n (0 - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];\n const y1 = (0 - rectBuffer) * positionedGlyph.scale + builtInOffset[1];\n const x2 = x1 + rect.width * positionedGlyph.scale;\n const y2 = y1 + rect.height * positionedGlyph.scale;\n\n const tl = { x: x1, y: y1 };\n const tr = { x: x2, y: y1 };\n const bl = { x: x1, y: y2 };\n const br = { x: x2, y: y2 };\n\n // TODO:处理字符旋转的情况\n\n quads.push({ tl, tr, bl, br, tex: rect, glyphOffset });\n }\n\n return quads;\n}\n"],"file":"symbol-layout.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.8.17",
3
+ "version": "2.8.20",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,9 +24,9 @@
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@antv/geo-coord": "^1.0.8",
27
- "@antv/l7-core": "^2.8.17",
28
- "@antv/l7-source": "^2.8.17",
29
- "@antv/l7-utils": "^2.8.17",
27
+ "@antv/l7-core": "^2.8.20",
28
+ "@antv/l7-source": "^2.8.20",
29
+ "@antv/l7-utils": "^2.8.20",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "@mapbox/martini": "^0.2.0",
32
32
  "@turf/meta": "^6.0.2",
@@ -52,7 +52,7 @@
52
52
  "@types/gl-matrix": "^2.4.5",
53
53
  "@types/lodash": "^4.14.138"
54
54
  },
55
- "gitHead": "e0a48d8dab5a515a6ec814de0d69292f1783cfc0",
55
+ "gitHead": "1b4784d51403b6ee3130b918bc1847c680c0c455",
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  }