@antv/l7-layers 2.8.31 → 2.8.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Geometry/models/plane.d.ts +13 -11
- package/es/Geometry/models/plane.js +134 -110
- package/es/Geometry/models/plane.js.map +1 -1
- package/es/canvas/models/canvas.js +5 -3
- package/es/canvas/models/canvas.js.map +1 -1
- package/es/core/BaseLayer.d.ts +5 -1
- package/es/core/BaseLayer.js +47 -0
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/interface.d.ts +3 -0
- package/es/core/interface.js.map +1 -1
- package/es/heatmap/index.d.ts +2 -0
- package/es/heatmap/index.js +9 -0
- package/es/heatmap/index.js.map +1 -1
- package/es/heatmap/models/heatmap.js +1 -0
- package/es/heatmap/models/heatmap.js.map +1 -1
- package/es/line/index.d.ts +1 -1
- package/es/line/index.js +1 -0
- package/es/line/index.js.map +1 -1
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +3 -1
- package/es/line/models/index.js.map +1 -1
- package/es/line/models/line.js +1 -0
- package/es/line/models/line.js.map +1 -1
- package/es/line/models/linearline.d.ts +20 -0
- package/es/line/models/linearline.js +267 -0
- package/es/line/models/linearline.js.map +1 -0
- package/es/point/models/fill.js +6 -2
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/normal.js +1 -0
- package/es/point/models/normal.js.map +1 -1
- package/es/point/models/simplePoint.js +1 -0
- package/es/point/models/simplePoint.js.map +1 -1
- package/es/polygon/models/extrude.d.ts +2 -0
- package/es/polygon/models/extrude.js +11 -5
- package/es/polygon/models/extrude.js.map +1 -1
- package/es/polygon/models/fill.d.ts +1 -0
- package/es/polygon/models/fill.js +6 -2
- package/es/polygon/models/fill.js.map +1 -1
- package/es/utils/layerData.d.ts +2 -0
- package/es/utils/layerData.js +152 -0
- package/es/utils/layerData.js.map +1 -0
- package/lib/Geometry/models/plane.js +133 -108
- package/lib/Geometry/models/plane.js.map +1 -1
- package/lib/canvas/models/canvas.js +5 -3
- package/lib/canvas/models/canvas.js.map +1 -1
- package/lib/core/BaseLayer.js +47 -0
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/heatmap/index.js +9 -0
- package/lib/heatmap/index.js.map +1 -1
- package/lib/heatmap/models/heatmap.js +1 -0
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/line/index.js +1 -0
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/index.js +4 -1
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/line.js +1 -0
- package/lib/line/models/line.js.map +1 -1
- package/lib/line/models/linearline.js +283 -0
- package/lib/line/models/linearline.js.map +1 -0
- package/lib/point/models/fill.js +6 -2
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/normal.js +1 -0
- package/lib/point/models/normal.js.map +1 -1
- package/lib/point/models/simplePoint.js +1 -0
- package/lib/point/models/simplePoint.js.map +1 -1
- package/lib/polygon/models/extrude.js +11 -5
- package/lib/polygon/models/extrude.js.map +1 -1
- package/lib/polygon/models/fill.js +6 -2
- package/lib/polygon/models/fill.js.map +1 -1
- package/lib/utils/layerData.js +163 -0
- package/lib/utils/layerData.js.map +1 -0
- 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","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;AAC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D,OAAd,CAAsBC;AAHN,SAAD,CAnCP;AAwCjBxH,QAAAA,OAAO,EAAE,sBAAQyE,IAAR,EAAcC,UAAd;AAxCQ,OAAD,CAAlB;AA0CD;;;WACD,uBAAsB;AACpB,WAAKrE,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"}
|
|
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","triangulation","HeatmapTriangulation","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","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,UA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aALwB;AAMlCE,QAAAA,GAAG,EAAEH,WAAGkG,OAN0B;AAOlC7F,QAAAA,GAAG,EAAEL,WAAGkG,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EA7VuCC,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 this.layer.triangulation = HeatmapTriangulation;\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"}
|
package/lib/line/index.js
CHANGED
package/lib/line/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/line/index.ts"],"names":["LineLayer","shape","getModelType","layerModel","LineModels","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","line","simple","wall","arc3d","blend","arc","arcmini","greatcircle","shapeAttribute","styleAttributeService","getLayerStyleAttribute","scale","field","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IAEqBA,S;;;;;;;;;;;;;;;uFACG,W;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIC,gBAAWH,KAAX,CAAJ,CAAsB,IAAtB,CAAlB;AACA,WAAKI,MAAL,GAAc,KAAKF,UAAL,CAAgBG,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKF,UAAL,CAAgBI,WAAhB,EAAd;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKR,YAAL,EAAb;AACA,UAAMW,aAAa,GAAG;AACpBC,QAAAA,IAAI,EAAE,EADc;AAEpBC,QAAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/line/index.ts"],"names":["LineLayer","shape","getModelType","layerModel","LineModels","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","line","linearline","simple","wall","arc3d","blend","arc","arcmini","greatcircle","shapeAttribute","styleAttributeService","getLayerStyleAttribute","scale","field","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IAEqBA,S;;;;;;;;;;;;;;;uFACG,W;;;;;;WAEtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIC,gBAAWH,KAAX,CAAJ,CAAsB,IAAtB,CAAlB;AACA,WAAKI,MAAL,GAAc,KAAKF,UAAL,CAAgBG,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKF,UAAL,CAAgBI,WAAhB,EAAd;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKR,YAAL,EAAb;AACA,UAAMW,aAAa,GAAG;AACpBC,QAAAA,IAAI,EAAE,EADc;AAEpBC,QAAAA,UAAU,EAAE,EAFQ;AAGpBC,QAAAA,MAAM,EAAE,EAHY;AAIpBC,QAAAA,IAAI,EAAE,EAJc;AAKpBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,KAAK,EAAE;AAAT,SALa;AAMpBC,QAAAA,GAAG,EAAE;AAAED,UAAAA,KAAK,EAAE;AAAT,SANe;AAOpBE,QAAAA,OAAO,EAAE;AAAEF,UAAAA,KAAK,EAAE;AAAT,SAPW;AAQpBG,QAAAA,WAAW,EAAE;AAAEH,UAAAA,KAAK,EAAE;AAAT;AARO,OAAtB;AAUA,aAAON,aAAa,CAACH,IAAD,CAApB;AACD;;;WACD,wBAAwC;AAAA;;AACtC,UAAMa,cAAc,GAAG,KAAKC,qBAAL,CAA2BC,sBAA3B,CACrB,OADqB,CAAvB;AAGA,UAAMxB,KAAK,GAAGsB,cAAH,aAAGA,cAAH,gDAAGA,cAAc,CAAEG,KAAnB,0DAAG,sBAAuBC,KAArC;AACA,aAAO1B,KAAK,IAAI,MAAhB;AACD;;;EA3CoC2B,mB","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { ILineLayerStyleOptions } from '../core/interface';\nimport LineModels, { LineModelType } from './models';\n\nexport default class LineLayer extends BaseLayer<ILineLayerStyleOptions> {\n public type: string = 'LineLayer';\n\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new LineModels[shape](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n protected getDefaultConfig() {\n const type = this.getModelType();\n const defaultConfig = {\n line: {},\n linearline: {},\n simple: {},\n wall: {},\n arc3d: { blend: 'additive' },\n arc: { blend: 'additive' },\n arcmini: { blend: 'additive' },\n greatcircle: { blend: 'additive' },\n };\n return defaultConfig[type];\n }\n protected getModelType(): LineModelType {\n const shapeAttribute = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shape = shapeAttribute?.scale?.field as LineModelType;\n return shape || 'line';\n }\n}\n"],"file":"index.js"}
|
package/lib/line/models/index.js
CHANGED
|
@@ -17,6 +17,8 @@ var _great_circle = _interopRequireDefault(require("./great_circle"));
|
|
|
17
17
|
|
|
18
18
|
var _line = _interopRequireDefault(require("./line"));
|
|
19
19
|
|
|
20
|
+
var _linearline = _interopRequireDefault(require("./linearline"));
|
|
21
|
+
|
|
20
22
|
var _simpleLine = _interopRequireDefault(require("./simpleLine"));
|
|
21
23
|
|
|
22
24
|
var _wall = _interopRequireDefault(require("./wall"));
|
|
@@ -28,7 +30,8 @@ var LineModels = {
|
|
|
28
30
|
greatcircle: _great_circle.default,
|
|
29
31
|
wall: _wall.default,
|
|
30
32
|
line: _line.default,
|
|
31
|
-
simple: _simpleLine.default
|
|
33
|
+
simple: _simpleLine.default,
|
|
34
|
+
linearline: _linearline.default
|
|
32
35
|
};
|
|
33
36
|
var _default = LineModels;
|
|
34
37
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/index.ts"],"names":["LineModels","arc","ArcModel","arcmini","ArcMiniModel","arc3d","Arc3DModel","greatcircle","GreatCircleModel","wall","LineWallModel","line","LineModel","simple","SimpleLineModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/index.ts"],"names":["LineModels","arc","ArcModel","arcmini","ArcMiniModel","arc3d","Arc3DModel","greatcircle","GreatCircleModel","wall","LineWallModel","line","LineModel","simple","SimpleLineModel","linearline","LinearLine"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAYA,IAAMA,UAA2C,GAAG;AAClDC,EAAAA,GAAG,EAAEC,YAD6C;AAElDC,EAAAA,OAAO,EAAEC,gBAFyC;AAGlDC,EAAAA,KAAK,EAAEC,eAH2C;AAIlDC,EAAAA,WAAW,EAAEC,qBAJqC;AAKlDC,EAAAA,IAAI,EAAEC,aAL4C;AAMlDC,EAAAA,IAAI,EAAEC,aAN4C;AAOlDC,EAAAA,MAAM,EAAEC,mBAP0C;AAQlDC,EAAAA,UAAU,EAAEC;AARsC,CAApD;eAWehB,U","sourcesContent":["import ArcModel from './arc';\nimport Arc3DModel from './arc_3d';\nimport ArcMiniModel from './arcmini';\nimport GreatCircleModel from './great_circle';\nimport LineModel from './line';\nimport LinearLine from './linearline';\nimport SimpleLineModel from './simpleLine';\nimport LineWallModel from './wall';\n\nexport type LineModelType =\n | 'arc'\n | 'arcmini'\n | 'arc3d'\n | 'greatcircle'\n | 'wall'\n | 'simple'\n | 'line'\n | 'linearline';\n\nconst LineModels: { [key in LineModelType]: any } = {\n arc: ArcModel,\n arcmini: ArcMiniModel,\n arc3d: Arc3DModel,\n greatcircle: GreatCircleModel,\n wall: LineWallModel,\n line: LineModel,\n simple: SimpleLineModel,\n linearline: LinearLine,\n};\n\nexport default LineModels;\n"],"file":"index.js"}
|
package/lib/line/models/line.js
CHANGED
|
@@ -238,6 +238,7 @@ var LineModel = function (_BaseModel) {
|
|
|
238
238
|
vert = _this$getShaders.vert,
|
|
239
239
|
type = _this$getShaders.type;
|
|
240
240
|
|
|
241
|
+
this.layer.triangulation = _triangulation.LineTriangulation;
|
|
241
242
|
return [this.layer.buildLayerModel({
|
|
242
243
|
moduleName: 'line_' + type,
|
|
243
244
|
vertexShader: vert,
|
|
@@ -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","heightfixed","arrow","enable","arrowWidth","arrowHeight","tailWidth","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","u_arrow","u_arrowHeight","u_arrowWidth","u_tailWidth","undefined","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","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","normal","vertexIndex","DYNAMIC_DRAW","Array","isArray","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;;;;;;;;;;;;;;;;gGAiVK,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;AAE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AAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA/UoCC,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 arrow = {\n enable: false,\n arrowWidth: 2,\n arrowHeight: 3,\n tailWidth: 1,\n },\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 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 // arrow\n u_arrow: Number(arrow.enable),\n u_arrowHeight: arrow.arrowHeight || 3,\n u_arrowWidth: arrow.arrowWidth || 2,\n u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth,\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: 'distanceAndIndex',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_DistanceAndIndex',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\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","arrow","enable","arrowWidth","arrowHeight","tailWidth","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","u_arrow","u_arrowHeight","u_arrowWidth","u_tailWidth","undefined","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","triangulation","LineTriangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","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","normal","vertexIndex","DYNAMIC_DRAW","Array","isArray","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;;;;;;;;;;;;;;;;gGAkVK,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;AAQD,K;;;;;;WAjWD,wBAAqC;AACnC,iBAoBI,KAAKT,KAAL,CAAWU,cAAX,EApBJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,WAFF,QAEEA,WAFF;AAAA,UAGEC,WAHF,QAG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UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAuBA,WAAKZ,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhD7D,QAAAA,IAAI,EAAE8D,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,aADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEhH,WAAGyH,YAFJ;AAGN/H,YAAAA,IAAI,EAAE,EAHA;AAINoD,YAAAA,IAAI,EAAE9C,WAAG+C;AAJH,WAFE;AAQVmE,UAAAA,IAAI,EAAE,CARI;AASVzH,UAAAA,MAAM,EAAE,gBACN0H,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMM,OAAO,GAAG,MAAI,CAACjI,WAAL,CAAiBkI,UAAjB,EAAhB;;AACA,gBAAQrI,OAAR,GAAoB2H,OAApB,CAAQ3H,OAAR;;AACA,wBAAiBoI,OAAO,CAACpI,OAAD,CAAP,IAA8B;AAAEsI,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;;;EAhVoCC,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 arrow = {\n enable: false,\n arrowWidth: 2,\n arrowHeight: 3,\n tailWidth: 1,\n },\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 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 // arrow\n u_arrow: Number(arrow.enable),\n u_arrowHeight: arrow.arrowHeight || 3,\n u_arrowWidth: arrow.arrowWidth || 2,\n u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth,\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 this.layer.triangulation = LineTriangulation;\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: 'distanceAndIndex',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_DistanceAndIndex',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\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"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
25
|
+
|
|
26
|
+
var _l7Core = require("@antv/l7-core");
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
31
|
+
|
|
32
|
+
var _triangulation = require("../../core/triangulation");
|
|
33
|
+
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
var linear_line_frag = "uniform float u_opacity : 1.0;\nuniform sampler2D u_texture;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat;\n\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 gl_FragColor = texture2D(u_texture, vec2(d_distance_ratio, 0.5));\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
39
|
+
var linear_line_vert = "\nattribute float a_Miter;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nuniform float u_opacity: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\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 vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \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] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\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";
|
|
40
|
+
|
|
41
|
+
var LinearLineModel = function (_BaseModel) {
|
|
42
|
+
(0, _inherits2.default)(LinearLineModel, _BaseModel);
|
|
43
|
+
|
|
44
|
+
var _super = _createSuper(LinearLineModel);
|
|
45
|
+
|
|
46
|
+
function LinearLineModel() {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
(0, _classCallCheck2.default)(this, LinearLineModel);
|
|
50
|
+
|
|
51
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
+
args[_key] = arguments[_key];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "colorTexture", void 0);
|
|
57
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
|
|
58
|
+
var createTexture2D = _this.rendererService.createTexture2D;
|
|
59
|
+
|
|
60
|
+
if (_this.colorTexture) {
|
|
61
|
+
_this.colorTexture.destroy();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var _ref = _this.layer.getLayerConfig(),
|
|
65
|
+
rampColors = _ref.rampColors;
|
|
66
|
+
|
|
67
|
+
var imageData = (0, _l7Utils.generateColorRamp)(rampColors);
|
|
68
|
+
_this.colorTexture = createTexture2D({
|
|
69
|
+
data: new Uint8Array(imageData.data),
|
|
70
|
+
width: imageData.width,
|
|
71
|
+
height: imageData.height,
|
|
72
|
+
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
73
|
+
wrapT: _l7Core.gl.CLAMP_TO_EDGE,
|
|
74
|
+
min: _l7Core.gl.NEAREST,
|
|
75
|
+
mag: _l7Core.gl.NEAREST,
|
|
76
|
+
flipY: false
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
(0, _createClass2.default)(LinearLineModel, [{
|
|
83
|
+
key: "getUninforms",
|
|
84
|
+
value: function getUninforms() {
|
|
85
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
86
|
+
opacity = _ref2.opacity,
|
|
87
|
+
_ref2$vertexHeightSca = _ref2.vertexHeightScale,
|
|
88
|
+
vertexHeightScale = _ref2$vertexHeightSca === void 0 ? 20.0 : _ref2$vertexHeightSca,
|
|
89
|
+
_ref2$raisingHeight = _ref2.raisingHeight,
|
|
90
|
+
raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight,
|
|
91
|
+
_ref2$heightfixed = _ref2.heightfixed,
|
|
92
|
+
heightfixed = _ref2$heightfixed === void 0 ? false : _ref2$heightfixed;
|
|
93
|
+
|
|
94
|
+
if (this.rendererService.getDirty()) {
|
|
95
|
+
this.colorTexture.bind();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
99
|
+
opacity: opacity
|
|
100
|
+
})) {
|
|
101
|
+
this.judgeStyleAttributes({
|
|
102
|
+
opacity: opacity
|
|
103
|
+
});
|
|
104
|
+
var encodeData = this.layer.getEncodedData();
|
|
105
|
+
|
|
106
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
107
|
+
data = _this$calDataFrame.data,
|
|
108
|
+
width = _this$calDataFrame.width,
|
|
109
|
+
height = _this$calDataFrame.height;
|
|
110
|
+
|
|
111
|
+
this.rowCount = height;
|
|
112
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
113
|
+
flipY: true,
|
|
114
|
+
data: data,
|
|
115
|
+
format: _l7Core.gl.LUMINANCE,
|
|
116
|
+
type: _l7Core.gl.FLOAT,
|
|
117
|
+
width: width,
|
|
118
|
+
height: height
|
|
119
|
+
}) : this.createTexture2D({
|
|
120
|
+
flipY: true,
|
|
121
|
+
data: [1],
|
|
122
|
+
format: _l7Core.gl.LUMINANCE,
|
|
123
|
+
type: _l7Core.gl.FLOAT,
|
|
124
|
+
width: 1,
|
|
125
|
+
height: 1
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
u_dataTexture: this.dataTexture,
|
|
131
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
132
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
133
|
+
u_texture: this.colorTexture,
|
|
134
|
+
u_heightfixed: Number(heightfixed),
|
|
135
|
+
u_vertexScale: vertexHeightScale,
|
|
136
|
+
u_raisingHeight: Number(raisingHeight)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "initModels",
|
|
141
|
+
value: function initModels() {
|
|
142
|
+
this.updateTexture();
|
|
143
|
+
return this.buildModels();
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "clearModels",
|
|
147
|
+
value: function clearModels() {
|
|
148
|
+
var _this$colorTexture, _this$dataTexture;
|
|
149
|
+
|
|
150
|
+
(_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.destroy();
|
|
151
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "buildModels",
|
|
155
|
+
value: function buildModels() {
|
|
156
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
157
|
+
_ref3$mask = _ref3.mask,
|
|
158
|
+
mask = _ref3$mask === void 0 ? false : _ref3$mask,
|
|
159
|
+
_ref3$maskInside = _ref3.maskInside,
|
|
160
|
+
maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
|
|
161
|
+
_ref3$depth = _ref3.depth,
|
|
162
|
+
depth = _ref3$depth === void 0 ? false : _ref3$depth;
|
|
163
|
+
|
|
164
|
+
var _this$getShaders = this.getShaders(),
|
|
165
|
+
frag = _this$getShaders.frag,
|
|
166
|
+
vert = _this$getShaders.vert,
|
|
167
|
+
type = _this$getShaders.type;
|
|
168
|
+
|
|
169
|
+
this.layer.triangulation = _triangulation.LineTriangulation;
|
|
170
|
+
return [this.layer.buildLayerModel({
|
|
171
|
+
moduleName: 'line_' + type,
|
|
172
|
+
vertexShader: vert,
|
|
173
|
+
fragmentShader: frag,
|
|
174
|
+
triangulation: _triangulation.LineTriangulation,
|
|
175
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
176
|
+
blend: this.getBlend(),
|
|
177
|
+
depth: {
|
|
178
|
+
enable: depth
|
|
179
|
+
},
|
|
180
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
181
|
+
})];
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "getShaders",
|
|
185
|
+
value: function getShaders() {
|
|
186
|
+
return {
|
|
187
|
+
frag: linear_line_frag,
|
|
188
|
+
vert: linear_line_vert,
|
|
189
|
+
type: 'linear_rampColors'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "registerBuiltinAttributes",
|
|
194
|
+
value: function registerBuiltinAttributes() {
|
|
195
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
196
|
+
name: 'distanceAndIndex',
|
|
197
|
+
type: _l7Core.AttributeType.Attribute,
|
|
198
|
+
descriptor: {
|
|
199
|
+
name: 'a_DistanceAndIndex',
|
|
200
|
+
buffer: {
|
|
201
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
202
|
+
data: [],
|
|
203
|
+
type: _l7Core.gl.FLOAT
|
|
204
|
+
},
|
|
205
|
+
size: 2,
|
|
206
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
|
|
207
|
+
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
212
|
+
name: 'total_distance',
|
|
213
|
+
type: _l7Core.AttributeType.Attribute,
|
|
214
|
+
descriptor: {
|
|
215
|
+
name: 'a_Total_Distance',
|
|
216
|
+
buffer: {
|
|
217
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
218
|
+
data: [],
|
|
219
|
+
type: _l7Core.gl.FLOAT
|
|
220
|
+
},
|
|
221
|
+
size: 1,
|
|
222
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
223
|
+
return [vertex[5]];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
228
|
+
name: 'size',
|
|
229
|
+
type: _l7Core.AttributeType.Attribute,
|
|
230
|
+
descriptor: {
|
|
231
|
+
name: 'a_Size',
|
|
232
|
+
buffer: {
|
|
233
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
234
|
+
data: [],
|
|
235
|
+
type: _l7Core.gl.FLOAT
|
|
236
|
+
},
|
|
237
|
+
size: 2,
|
|
238
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
239
|
+
var _feature$size = feature.size,
|
|
240
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
241
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
246
|
+
name: 'normal',
|
|
247
|
+
type: _l7Core.AttributeType.Attribute,
|
|
248
|
+
descriptor: {
|
|
249
|
+
name: 'a_Normal',
|
|
250
|
+
buffer: {
|
|
251
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
252
|
+
data: [],
|
|
253
|
+
type: _l7Core.gl.FLOAT
|
|
254
|
+
},
|
|
255
|
+
size: 3,
|
|
256
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
257
|
+
return normal;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
262
|
+
name: 'miter',
|
|
263
|
+
type: _l7Core.AttributeType.Attribute,
|
|
264
|
+
descriptor: {
|
|
265
|
+
name: 'a_Miter',
|
|
266
|
+
buffer: {
|
|
267
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
268
|
+
data: [],
|
|
269
|
+
type: _l7Core.gl.FLOAT
|
|
270
|
+
},
|
|
271
|
+
size: 1,
|
|
272
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
273
|
+
return [vertex[4]];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}]);
|
|
279
|
+
return LinearLineModel;
|
|
280
|
+
}(_BaseModel2.default);
|
|
281
|
+
|
|
282
|
+
exports.default = LinearLineModel;
|
|
283
|
+
//# sourceMappingURL=linearline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/linearline.ts"],"names":["LinearLineModel","createTexture2D","rendererService","colorTexture","destroy","layer","getLayerConfig","rampColors","imageData","data","Uint8Array","width","height","wrapS","gl","CLAMP_TO_EDGE","wrapT","min","NEAREST","mag","flipY","opacity","vertexHeightScale","raisingHeight","heightfixed","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_texture","u_heightfixed","Number","u_vertexScale","u_raisingHeight","updateTexture","buildModels","mask","maskInside","depth","getShaders","frag","vert","triangulation","LineTriangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","enable","stencil","linear_line_frag","linear_line_vert","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","undefined","DYNAMIC_DRAW","Array","isArray","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAYA;;AAEA;;AAEA;;;;;;;;;IAIqBA,e;;;;;;;;;;;;;;;;gGAoOK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,YAAT,EAAuB;AACrB,cAAKA,YAAL,CAAkBC,OAAlB;AACD;;AACD,iBAEI,MAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,UACEC,UADF,QACEA,UADF;;AAGA,UAAMC,SAAS,GAAG,gCAAkBD,UAAlB,CAAlB;AACA,YAAKJ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WAAG2B;AAJH,WAFE;AAQVyC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;EAlO0CQ,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 { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport linear_line_frag from '../shaders/linearLine/line_linear_frag.glsl';\nimport linear_line_vert from '../shaders/linearLine/line_linear_vert.glsl';\n\nexport default class LinearLineModel extends BaseModel {\n protected colorTexture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n vertexHeightScale = 20.0,\n raisingHeight = 0,\n heightfixed = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.colorTexture.bind();\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 return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n // 纹理支持参数\n u_texture: this.colorTexture, // 贴图\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n return this.buildModels();\n }\n\n public clearModels() {\n this.colorTexture?.destroy();\n this.dataTexture?.destroy();\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 this.layer.triangulation = LineTriangulation;\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 stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: linear_line_frag,\n vert: linear_line_vert,\n type: 'linear_rampColors',\n };\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distanceAndIndex',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_DistanceAndIndex',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\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\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.colorTexture) {\n this.colorTexture.destroy();\n }\n const {\n rampColors,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\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":"linearline.js"}
|