@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/heatmap/models/heatmap.ts"],"names":["HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","gl","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","HeatmapTriangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","getLayerConfig","mask","maskInside","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","mat4","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAWA;;;;;;;;;;;;;;;;;;IAEqBA,Y,WADpB,4B;;;;;;;;;;;;;;;;;;;;;;;;;;WASC,kBAAgB;AAAA;;AACd,kCAAkC,KAAKC,eAAvC;AAAA,UAAQC,KAAR,yBAAQA,KAAR;AAAA,UAAeC,cAAf,yBAAeA,cAAf;AACAA,MAAAA,cAAc,CAAC,KAAKC,mBAAN,EAA2B,YAAM;AAC7CF,QAAAA,KAAK,CAAC;AACJG,UAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADH;AAEJC,UAAAA,KAAK,EAAE,CAFH;AAGJC,UAAAA,OAAO,EAAE,CAHL;AAIJC,UAAAA,WAAW,EAAE,MAAI,CAACJ;AAJd,SAAD,CAAL;;AAMA,QAAA,MAAI,CAACK,iBAAL;AACD,OARa,CAAd;;AASA,UAAI,KAAKC,KAAL,CAAWC,eAAf,EAAgC;AAC9B,aAAKC,kBAAL;AACD;;AACD,WAAKC,SAAL,KAAmB,SAAnB,GAA+B,KAAKC,aAAL,EAA/B,GAAsD,KAAKC,aAAL,EAAtD;AACD;;;WAED,wBAAqC;AACnC,YAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WAED,sBAA8B;AAAA;;AAC5B,mCAMI,KAAKf,eANT;AAAA,UACEgB,iBADF,0BACEA,iBADF;AAAA,UAEEf,KAFF,0BAEEA,KAFF;AAAA,UAGEgB,eAHF,0BAGEA,eAHF;AAAA,UAIEC,eAJF,0BAIEA,eAJF;AAAA,UAKEhB,cAL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AAeD,SAAS,CAAC5E,IAAzB,CAD4B;AAElCrB,QAAAA,KAAK,EAAEiG,SAAS,CAACjG,KAFiB;AAGlCC,QAAAA,MAAM,EAAEgG,SAAS,CAAChG,MAHgB;AAIlCG,QAAAA,KAAK,EAAEC,WAAGC,aAJwB;AAKlCC,QAAAA,KAAK,EAAEF,WAAGC,aALwB;AAMlCE,QAAAA,GAAG,EAAEH,WAAG8F,OAN0B;AAOlCzF,QAAAA,GAAG,EAAEL,WAAG8F,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EAxVuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { IHeatMapLayerStyleOptions } from '../../core/interface';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\n\n// 绘制平面热力的 shader\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\n\nimport heatmapFramebufferFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapFramebufferVert from '../shaders/heatmap_framebuffer_vert.glsl';\n\nimport { heatMap3DTriangulation } from '../triangulation';\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapFramebufferVert,\n fragmentShader: heatmapFramebufferFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n stencil: getMask(mask, maskInside),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n stencil: getMask(mask, maskInside),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
1
+ {"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","gl","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","HeatmapTriangulation","enable","cull","face","mapService","version","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","getLayerConfig","mask","maskInside","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","mat4","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AAMA;;AACA;;AACA;;AACA;;AAEA;;AAWA;;;;;;;;;;;;;;;;;;IAEqBA,Y,WADpB,4B;;;;;;;;;;;;;;;;;;;;;;;;;;WASC,kBAAgB;AAAA;;AACd,kCAAkC,KAAKC,eAAvC;AAAA,UAAQC,KAAR,yBAAQA,KAAR;AAAA,UAAeC,cAAf,yBAAeA,cAAf;AACAA,MAAAA,cAAc,CAAC,KAAKC,mBAAN,EAA2B,YAAM;AAC7CF,QAAAA,KAAK,CAAC;AACJG,UAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADH;AAEJC,UAAAA,KAAK,EAAE,CAFH;AAGJC,UAAAA,OAAO,EAAE,CAHL;AAIJC,UAAAA,WAAW,EAAE,MAAI,CAACJ;AAJd,SAAD,CAAL;;AAMA,QAAA,MAAI,CAACK,iBAAL;AACD,OARa,CAAd;;AASA,UAAI,KAAKC,KAAL,CAAWC,eAAf,EAAgC;AAC9B,aAAKC,kBAAL;AACD;;AACD,WAAKC,SAAL,KAAmB,SAAnB,GAA+B,KAAKC,aAAL,EAA/B,GAAsD,KAAKC,aAAL,EAAtD;AACD;;;WAED,wBAAqC;AACnC,YAAM,IAAIC,K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,kBAAL;AACD;;;WAED,8BAA6B;AAC3B,UAAQO,eAAR,GAA4B,KAAKlB,eAAjC,CAAQkB,eAAR;;AACA,UAAI,KAAK6G,OAAT,EAAkB;AAChB,aAAKA,OAAL,CAAaC,OAAb;AACD;;AAED,kBAEI,KAAKvH,KAAL,CAAWqE,cAAX,EAFJ;AAAA,UACEmD,UADF,SACEA,UADF;;AAGA,UAAMC,SAAS,GAAG,gCAAkBD,UAAlB,CAAlB;AACA,WAAKrB,YAAL,GAAoB1F,eAAe,CAAC;AAClCgC,QAAAA,IAAI,EAAE,IAAIiF,UAAJ,CAAeD,SAAS,CAAChF,IAAzB,CAD4B;AAElCrB,QAAAA,KAAK,EAAEqG,SAAS,CAACrG,KAFiB;AAGlCC,QAAAA,MAAM,EAAEoG,SAAS,CAACpG,MAHgB;AAIlCG,QAAAA,KAAK,EAAEC,WAAGC,aAJwB;AAKlCC,QAAAA,KAAK,EAAEF,WAAGC,aALwB;AAMlCE,QAAAA,GAAG,EAAEH,WAAGkG,OAN0B;AAOlC7F,QAAAA,GAAG,EAAEL,WAAGkG,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EA5VuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport {\n generateColorRamp,\n getCullFace,\n getMask,\n IColorRamp,\n} from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { IHeatMapLayerStyleOptions } from '../../core/interface';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\n\n// 绘制平面热力的 shader\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\n\nimport heatmapFramebufferFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapFramebufferVert from '../shaders/heatmap_framebuffer_vert.glsl';\n\nimport { heatMap3DTriangulation } from '../triangulation';\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapFramebufferVert,\n fragmentShader: heatmapFramebufferFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n stencil: getMask(mask, maskInside),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n stencil: getMask(mask, maskInside),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
@@ -38,7 +38,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
38
38
  var line_dash_frag = "#define LineTypeSolid 0.0\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n // dash line\n \n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
39
39
  var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y), 1.0));\n } else {\n float lineHeight = a_Size.y;\n \n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
40
40
  var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying vec2 v_iconMapUV;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + animateSpeed);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n \n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = styleMappingMat[3].a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth/2.0;\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) {\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
41
- var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance;; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n // project_pos.z += u_raisingHeight;\n // if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n // project_pos.z += u_raisingHeight * mapboxZoomScale;\n // }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y) + h * 0.2 + u_raisingHeight, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n // h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n } else {\n h += u_raisingHeight;\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
41
+ var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance;; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
42
42
  var linear_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
43
43
  var lineStyleObj = {
44
44
  solid: 0.0,
@@ -110,7 +110,9 @@ var LineModel = function (_BaseModel) {
110
110
  _ref$borderColor = _ref.borderColor,
111
111
  borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
112
112
  _ref$raisingHeight = _ref.raisingHeight,
113
- raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight;
113
+ raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
114
+ _ref$heightfixed = _ref.heightfixed,
115
+ heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed;
114
116
 
115
117
  if (dashArray.length === 2) {
116
118
  dashArray.push(0, 0);
@@ -177,6 +179,7 @@ var LineModel = function (_BaseModel) {
177
179
  u_linearColor: useLinearColor,
178
180
  u_sourceColor: sourceColorArr,
179
181
  u_targetColor: targetColorArr,
182
+ u_heightfixed: Number(heightfixed),
180
183
  u_vertexScale: vertexHeightScale,
181
184
  u_raisingHeight: Number(raisingHeight)
182
185
  };
@@ -215,7 +218,9 @@ var LineModel = function (_BaseModel) {
215
218
  _ref3$mask = _ref3.mask,
216
219
  mask = _ref3$mask === void 0 ? false : _ref3$mask,
217
220
  _ref3$maskInside = _ref3.maskInside,
218
- maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside;
221
+ maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
222
+ _ref3$depth = _ref3.depth,
223
+ depth = _ref3$depth === void 0 ? false : _ref3$depth;
219
224
 
220
225
  var _this$getShaders = this.getShaders(),
221
226
  frag = _this$getShaders.frag,
@@ -223,14 +228,14 @@ var LineModel = function (_BaseModel) {
223
228
  type = _this$getShaders.type;
224
229
 
225
230
  return [this.layer.buildLayerModel({
226
- moduleName: 'line' + type,
231
+ moduleName: 'line_' + type,
227
232
  vertexShader: vert,
228
233
  fragmentShader: frag,
229
234
  triangulation: _triangulation.LineTriangulation,
230
235
  primitive: _l7Core.gl.TRIANGLES,
231
236
  blend: this.getBlend(),
232
237
  depth: {
233
- enable: false
238
+ enable: depth
234
239
  },
235
240
  stencil: (0, _l7Utils.getMask)(mask, maskInside)
236
241
  })];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","u_raisingHeight","Number","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineTriangulation","primitive","TRIANGLES","blend","getBlend","depth","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAYA;;AAEA;;AAEA;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;gGA4TK,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;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEC,WAAGC,OAFqB;AAG7BC,QAAAA,GAAG,EAAEF,WAAGC,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKV,WAAL,CAAiBW,YAAjB,IAAiC;AANZ,OAAD,CAA9B;A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;AACA,wBAAiBwH,OAAO,CAACxH,OAAD,CAAP,IAA8B;AAAE0H,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA/C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA1ToCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\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 { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
1
+ {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","heightfixed","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_heightfixed","Number","u_vertexScale","u_raisingHeight","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineTriangulation","primitive","TRIANGLES","blend","getBlend","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","norm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,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAhUoCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n heightfixed = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\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 { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
@@ -116,6 +116,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
116
116
  }
117
117
 
118
118
  layer.setEncodedData(this.mapping(attributes, filterData, undefined, bottomColor));
119
+ layer.emit('dataUpdate', null);
119
120
  }
120
121
  }, {
121
122
  key: "mapping",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coords","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;AACA;;AAEA;;;;;;;;IAGqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;A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lugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coords","coord","c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D;AACF,OARD;AAYA,UAAMG,aAAa,GAAGvD,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkB2C,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAInD,SAAS,CAACwB,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQ+B,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAAC1C,YAAD,CAAP;AACD;;AACD,aAAO0C,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
@@ -187,7 +187,7 @@ var ExtrudeModel = function (_BaseModel) {
187
187
  blend: this.getBlend(),
188
188
  cull: {
189
189
  enable: true,
190
- face: this.mapService.version === 'MAPBOX' ? _l7Core.gl.FRONT : _l7Core.gl.BACK
190
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
191
191
  },
192
192
  depth: {
193
193
  enable: depth
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","FRONT","BACK","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI,KAAKC,KAAL,CAAWC,cAAX,EApBJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE,IAFO;AAGdC,QAAAA,MAAM,EAAE;AAHM,OADlB;AAAA,8BAMEC,OANF;AAAA,UAMEA,OANF,6BAMY,CANZ;AAAA,UAQEC,WARF,QA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O,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EAjPuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: this.mapService.version === 'MAPBOX' ? gl.FRONT : gl.BACK,\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
1
+ {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI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IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVgD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EAjPuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { getCullFace, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
@@ -223,7 +223,7 @@ var FillModel = function (_BaseModel) {
223
223
 
224
224
  var isGlobel = this.mapService.version === 'GLOBEL';
225
225
  return [this.layer.buildLayerModel({
226
- moduleName: 'pointfill-' + type,
226
+ moduleName: 'pointfill_' + type,
227
227
  vertexShader: vert,
228
228
  fragmentShader: frag,
229
229
  triangulation: isGlobel ? _triangulation.GlobelPointFillTriangulation : _triangulation.PointFillTriangulation,
@@ -231,7 +231,11 @@ var FillModel = function (_BaseModel) {
231
231
  enable: isGlobel
232
232
  },
233
233
  blend: this.getBlend(),
234
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
234
+ stencil: (0, _l7Utils.getMask)(mask, maskInside),
235
+ cull: {
236
+ enable: true,
237
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
238
+ }
235
239
  })];
236
240
  }
237
241
  }, {