@antv/l7-layers 2.8.41 → 2.8.44
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/line/models/arc.js +3 -2
- package/es/line/models/arc.js.map +1 -1
- package/es/line/models/arc_3d.js +2 -1
- package/es/line/models/arc_3d.js.map +1 -1
- package/es/line/models/arcmini.js +2 -1
- package/es/line/models/arcmini.js.map +1 -1
- package/es/line/models/great_circle.js +2 -1
- package/es/line/models/great_circle.js.map +1 -1
- package/es/line/models/line.js +2 -1
- package/es/line/models/line.js.map +1 -1
- package/es/line/models/linearline.js +2 -1
- package/es/line/models/linearline.js.map +1 -1
- package/es/line/models/simpleLine.js +2 -1
- package/es/line/models/simpleLine.js.map +1 -1
- package/es/line/models/wall.js +2 -1
- package/es/line/models/wall.js.map +1 -1
- package/es/point/models/extrude.js +2 -1
- package/es/point/models/extrude.js.map +1 -1
- package/es/point/models/fill.js +4 -3
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/fillmage.js +2 -1
- package/es/point/models/fillmage.js.map +1 -1
- package/es/point/models/image.js +2 -1
- package/es/point/models/image.js.map +1 -1
- package/es/point/models/normal.js +2 -1
- package/es/point/models/normal.js.map +1 -1
- package/es/point/models/radar.js +2 -1
- package/es/point/models/radar.js.map +1 -1
- package/es/point/models/simplePoint.js +4 -3
- package/es/point/models/simplePoint.js.map +1 -1
- package/es/point/models/text.js +3 -2
- package/es/point/models/text.js.map +1 -1
- package/es/polygon/models/extrude.js +3 -6
- package/es/polygon/models/extrude.js.map +1 -1
- package/es/polygon/models/fill.js +2 -5
- package/es/polygon/models/fill.js.map +1 -1
- package/es/polygon/models/ocean.js +2 -1
- package/es/polygon/models/ocean.js.map +1 -1
- package/es/polygon/models/water.js +2 -1
- package/es/polygon/models/water.js.map +1 -1
- package/lib/line/models/arc.js +4 -2
- package/lib/line/models/arc.js.map +1 -1
- package/lib/line/models/arc_3d.js +3 -1
- package/lib/line/models/arc_3d.js.map +1 -1
- package/lib/line/models/arcmini.js +3 -1
- package/lib/line/models/arcmini.js.map +1 -1
- package/lib/line/models/great_circle.js +3 -1
- package/lib/line/models/great_circle.js.map +1 -1
- package/lib/line/models/line.js +3 -1
- package/lib/line/models/line.js.map +1 -1
- package/lib/line/models/linearline.js +3 -1
- package/lib/line/models/linearline.js.map +1 -1
- package/lib/line/models/simpleLine.js +3 -1
- package/lib/line/models/simpleLine.js.map +1 -1
- package/lib/line/models/wall.js +3 -1
- package/lib/line/models/wall.js.map +1 -1
- package/lib/point/models/extrude.js +3 -1
- package/lib/point/models/extrude.js.map +1 -1
- package/lib/point/models/fill.js +5 -3
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/fillmage.js +3 -1
- package/lib/point/models/fillmage.js.map +1 -1
- package/lib/point/models/image.js +3 -1
- package/lib/point/models/image.js.map +1 -1
- package/lib/point/models/normal.js +3 -1
- package/lib/point/models/normal.js.map +1 -1
- package/lib/point/models/radar.js +3 -1
- package/lib/point/models/radar.js.map +1 -1
- package/lib/point/models/simplePoint.js +5 -3
- package/lib/point/models/simplePoint.js.map +1 -1
- package/lib/point/models/text.js +4 -2
- package/lib/point/models/text.js.map +1 -1
- package/lib/polygon/models/extrude.js +4 -6
- package/lib/polygon/models/extrude.js.map +1 -1
- package/lib/polygon/models/fill.js +3 -5
- package/lib/polygon/models/fill.js.map +1 -1
- package/lib/polygon/models/ocean.js +3 -1
- package/lib/polygon/models/ocean.js.map +1 -1
- package/lib/polygon/models/water.js +3 -1
- package/lib/polygon/models/water.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/arc.ts"],"names":["lineStyleObj","solid","dash","ArcModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","forward","lineTexture","iconStep","segmentNumber","thetaOffset","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","push","useLinearColor","sourceColorArr","targetColorArr","getDirty","bind","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_thetaOffset","Number","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_blur","u_lineDir","u_texture","u_line_texture","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","frag","arc_dash_frag","vert","arc_dash_vert","arc_linear_frag","arc_linear_vert","arc_line_frag","arc_line_vert","mask","maskInside","getShaders","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineArcTriangulation","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,Q;;;;;;;;;;;;;;;;gGAiPK,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;A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wBAAiBoH,OAAO,CAACpH,OAAD,CAAP,IAA8B;AAAEsH,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;;;EA/OmCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\n// arc dash line\nimport arc_dash_frag from '../shaders/dash/arc_dash_frag.glsl';\nimport arc_dash_vert from '../shaders/dash/arc_dash_vert.glsl';\n// arc normal line\nimport arc_line_frag from '../shaders/line_arc_frag.glsl';\nimport arc_line_vert from '../shaders/line_arc_vert.glsl';\n// arc linear line\nimport arc_linear_frag from '../shaders/linear/arc_linear_frag.glsl';\nimport arc_linear_vert from '../shaders/linear/arc_linear_vert.glsl';\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class ArcModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5],\n forward = true,\n lineTexture = false,\n iconStep = 100,\n segmentNumber = 30,\n thetaOffset = 0.314,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({ opacity, thetaOffset })\n ) {\n this.judgeStyleAttributes({ opacity, thetaOffset });\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 if (dashArray.length === 2) {\n dashArray.push(0, 0);\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.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_thetaOffset: Number(thetaOffset),\n u_opacity: Number(opacity),\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n segmentNumber,\n u_line_type: lineStyleObj[lineType || 'solid'],\n u_dash_array: dashArray,\n u_blur: 0.9,\n u_lineDir: forward ? 1 : -1,\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 // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\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 getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (lineType === 'dash') {\n return {\n frag: arc_dash_frag,\n vert: arc_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: arc_linear_frag,\n vert: arc_linear_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: arc_line_frag,\n vert: arc_line_vert,\n type: 'normal',\n };\n }\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\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: 'arc2dline' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n segmentNumber,\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\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":"arc.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/arc.ts"],"names":["lineStyleObj","solid","dash","ArcModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","forward","lineTexture","iconStep","segmentNumber","thetaOffset","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","push","useLinearColor","sourceColorArr","targetColorArr","getDirty","bind","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_thetaOffset","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_blur","u_lineDir","u_texture","u_line_texture","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","frag","arc_dash_frag","vert","arc_dash_vert","arc_linear_frag","arc_linear_vert","arc_line_frag","arc_line_vert","mask","maskInside","getShaders","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineArcTriangulation","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AAEA;;AAEA;;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,Q;;;;;;;;;;;;;;;;gGAiPK,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;;;;;;WAhQD,wBAAqC;AACnC,iBAYI,KAAKT,KAAL,CAAWU,cAAX,EAZJ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B","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\n// arc dash line\nimport arc_dash_frag from '../shaders/dash/arc_dash_frag.glsl';\nimport arc_dash_vert from '../shaders/dash/arc_dash_vert.glsl';\n// arc normal line\nimport arc_line_frag from '../shaders/line_arc_frag.glsl';\nimport arc_line_vert from '../shaders/line_arc_vert.glsl';\n// arc linear line\nimport arc_linear_frag from '../shaders/linear/arc_linear_frag.glsl';\nimport arc_linear_vert from '../shaders/linear/arc_linear_vert.glsl';\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class ArcModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5],\n forward = true,\n lineTexture = false,\n iconStep = 100,\n segmentNumber = 30,\n thetaOffset = 0.314,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({ opacity, thetaOffset })\n ) {\n this.judgeStyleAttributes({ opacity, thetaOffset });\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 if (dashArray.length === 2) {\n dashArray.push(0, 0);\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.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_thetaOffset: isNumber(thetaOffset) ? thetaOffset : 0.0,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n segmentNumber,\n u_line_type: lineStyleObj[lineType || 'solid'],\n u_dash_array: dashArray,\n u_blur: 0.9,\n u_lineDir: forward ? 1 : -1,\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 // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\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 getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (lineType === 'dash') {\n return {\n frag: arc_dash_frag,\n vert: arc_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: arc_linear_frag,\n vert: arc_linear_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: arc_line_frag,\n vert: arc_line_vert,\n type: 'normal',\n };\n }\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\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: 'arc2dline' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n segmentNumber,\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\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":"arc.js"}
|
|
@@ -21,6 +21,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
21
21
|
|
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
23
|
|
|
24
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
25
|
+
|
|
24
26
|
var _l7Core = require("@antv/l7-core");
|
|
25
27
|
|
|
26
28
|
var _l7Utils = require("@antv/l7-utils");
|
|
@@ -163,7 +165,7 @@ var Arc3DModel = function (_BaseModel) {
|
|
|
163
165
|
u_global_height: globalArcHeight,
|
|
164
166
|
u_dataTexture: this.dataTexture,
|
|
165
167
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
166
|
-
u_opacity:
|
|
168
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
167
169
|
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
|
|
168
170
|
segmentNumber: segmentNumber,
|
|
169
171
|
u_line_type: lineStyleObj[lineType] || 0.0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/arc_3d.ts"],"names":["lineStyleObj","solid","dash","Arc3DModel","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","segmentNumber","globalArcHeight","length","push","useLinearColor","sourceColorArr","targetColorArr","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_globel","mapService","version","u_globel_radius","EARTH_RADIUS","u_global_height","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","Number","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","frag","arc3d_linear_frag","vert","arc3d_linear_vert","arc3d_line_frag","arc3d_line_vert","mask","maskInside","getShaders","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineArcTriangulation","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AACA;;;;;;;;;;AAQA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,U;;;;;;;;;;;;;;;;gGAoOK,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,S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,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAlOqCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport { EARTH_RADIUS } from '../../earth/utils';\n// arc3d line layer\nimport arc3d_line_frag from '../shaders/line_arc_3d_frag.glsl';\nimport arc3d_line_vert from '../shaders/line_arc_3d_vert.glsl';\n// arc3d linear layer\nimport arc3d_linear_frag from '../shaders/linear/arc3d_linear_frag.glsl';\nimport arc3d_linear_vert from '../shaders/linear/arc3d_linear_vert.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class Arc3DModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5],\n lineTexture = false,\n iconStep = 100,\n segmentNumber = 30,\n globalArcHeight = 10,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\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.rendererService.getDirty()) {\n this.texture.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\n return {\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n u_globel_radius: EARTH_RADIUS, // 地球半径\n u_global_height: globalArcHeight,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: Number(opacity),\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n segmentNumber,\n u_line_type: lineStyleObj[lineType as string] || 0.0,\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 // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\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 getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: arc3d_linear_frag,\n vert: arc3d_linear_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: arc3d_line_frag,\n vert: arc3d_line_vert,\n type: 'normal',\n };\n }\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\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: 'arc3Dline' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineArcTriangulation,\n blend: this.getBlend(),\n segmentNumber,\n // primitive: gl.POINTS,\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\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":"arc_3d.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/arc_3d.ts"],"names":["lineStyleObj","solid","dash","Arc3DModel","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","segmentNumber","globalArcHeight","length","push","useLinearColor","sourceColorArr","targetColorArr","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_globel","mapService","version","u_globel_radius","EARTH_RADIUS","u_global_height","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_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","frag","arc3d_linear_frag","vert","arc3d_linear_vert","arc3d_line_frag","arc3d_line_vert","mask","maskInside","getShaders","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineArcTriangulation","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attribute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AAI,EAAEtC,WAAGuC;AAJH,WAFE;AAQV0D,UAAAA,IAAI,EAAE,CARI;AASVxG,UAAAA,MAAM,EAAE,gBACNyG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMI,OAAO,GAAG,MAAI,CAAC9G,WAAL,CAAiB+G,UAAjB,EAAhB;;AACA,gBAAQlH,OAAR,GAAoB0G,OAApB,CAAQ1G,OAAR;;AACA,wBAAiBiH,OAAO,CAACjH,OAAD,CAAP,IAA8B;AAAEmH,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;;;EAlOqCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport { EARTH_RADIUS } from '../../earth/utils';\n// arc3d line layer\nimport arc3d_line_frag from '../shaders/line_arc_3d_frag.glsl';\nimport arc3d_line_vert from '../shaders/line_arc_3d_vert.glsl';\n// arc3d linear layer\nimport arc3d_linear_frag from '../shaders/linear/arc3d_linear_frag.glsl';\nimport arc3d_linear_vert from '../shaders/linear/arc3d_linear_vert.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class Arc3DModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5],\n lineTexture = false,\n iconStep = 100,\n segmentNumber = 30,\n globalArcHeight = 10,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\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.rendererService.getDirty()) {\n this.texture.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\n return {\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n u_globel_radius: EARTH_RADIUS, // 地球半径\n u_global_height: globalArcHeight,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n segmentNumber,\n u_line_type: lineStyleObj[lineType as string] || 0.0,\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 // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\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 getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: arc3d_linear_frag,\n vert: arc3d_linear_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: arc3d_line_frag,\n vert: arc3d_line_vert,\n type: 'normal',\n };\n }\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\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: 'arc3Dline' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineArcTriangulation,\n blend: this.getBlend(),\n segmentNumber,\n // primitive: gl.POINTS,\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\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":"arc_3d.js"}
|
|
@@ -17,6 +17,8 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
17
17
|
|
|
18
18
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
19
|
|
|
20
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
21
|
+
|
|
20
22
|
var _l7Core = require("@antv/l7-core");
|
|
21
23
|
|
|
22
24
|
var _l7Utils = require("@antv/l7-utils");
|
|
@@ -69,7 +71,7 @@ var ArcMiniModel = function (_BaseModel) {
|
|
|
69
71
|
|
|
70
72
|
return {
|
|
71
73
|
u_thetaOffset: thetaOffset,
|
|
72
|
-
u_opacity:
|
|
74
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
73
75
|
segmentNumber: segmentNumber,
|
|
74
76
|
u_blur: 0.9,
|
|
75
77
|
u_lineDir: forward ? 1 : -1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/arcmini.ts"],"names":["ArcMiniModel","layer","getLayerConfig","opacity","sourceColor","targetColor","forward","segmentNumber","thetaOffset","useLinearColor","sourceColorArr","targetColorArr","u_thetaOffset","u_opacity","
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/arcmini.ts"],"names":["ArcMiniModel","layer","getLayerConfig","opacity","sourceColor","targetColor","forward","segmentNumber","thetaOffset","useLinearColor","sourceColorArr","targetColorArr","u_thetaOffset","u_opacity","u_blur","u_lineDir","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","buildModels","buildLayerModel","moduleName","vertexShader","line_arcmini_vert","fragmentShader","line_arcmini_frag","triangulation","LineArcTriangulation","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","gl","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AAEA;;AAEA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,UAEEC,WAFF,QAEEA,WAFF;AAAA,UAGEC,WAHF,QAGEA,WAHF;AAAA,8BAIEC,OAJF;AAAA,UAIEA,OAJF,6BAIY,IAJZ;AA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AM,EAAE;AACNC,YAAAA,KAAK,EAAEC,WAAGY,WADJ;AAENV,YAAAA,IAAI,EAAE,EAFA;AAGNR,YAAAA,IAAI,EAAEM,WAAGG;AAHH,WAFE;AAOVC,UAAAA,IAAI,EAAE,CAPI;AAQVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAP;AACD;AAfS;AAHoC,OAAlD;AAqBD;;;EAlHuCK,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport line_arcmini_frag from '../shaders/line_arcmini_frag.glsl';\nimport line_arcmini_vert from '../shaders/line_arcmini_vert.glsl';\n\nexport default class ArcMiniModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n forward = true,\n segmentNumber = 30,\n thetaOffset = 0.314,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\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 return {\n u_thetaOffset: thetaOffset,\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n segmentNumber,\n u_blur: 0.9,\n u_lineDir: forward ? 1 : -1,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\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 return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'arc2dminiline',\n vertexShader: line_arcmini_vert,\n fragmentShader: line_arcmini_frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n segmentNumber,\n }),\n ];\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\n },\n },\n });\n }\n}\n"],"file":"arcmini.js"}
|
|
@@ -21,6 +21,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
21
21
|
|
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
23
|
|
|
24
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
25
|
+
|
|
24
26
|
var _l7Core = require("@antv/l7-core");
|
|
25
27
|
|
|
26
28
|
var _l7Utils = require("@antv/l7-utils");
|
|
@@ -154,7 +156,7 @@ var GreatCircleModel = function (_BaseModel) {
|
|
|
154
156
|
return {
|
|
155
157
|
u_dataTexture: this.dataTexture,
|
|
156
158
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
157
|
-
u_opacity:
|
|
159
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
158
160
|
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
|
|
159
161
|
segmentNumber: segmentNumber,
|
|
160
162
|
u_line_type: lineStyleObj[lineType] || 0.0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/great_circle.ts"],"names":["lineStyleObj","solid","dash","GreatCircleModel","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","segmentNumber","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","Number","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","buildLayerModel","moduleName","vertexShader","line_arc2d_vert","fragmentShader","line_arc_frag","triangulation","LineArcTriangulation","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;;;;;;;AAGA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAKqBC,gB;;;;;;;;;;;;;;;;gGAqMK,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;;;;;;WApND,wBAAqC;AACnC,iBAUI,KAAKT,KAAL,CAAWU,cAAX,EAVJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,UAEEC,WAFF,QAEEA,WAFF;AAAA,UAGEC,WAHF,QAGEA,WAHF;AAAA,mCAIEC,YAJF;AAAA,UAIEA,YAJF,kCAIiB,QAJjB;AAAA,+BAKEC,QALF;AAAA,UAKEA,QALF,8BAKa,OALb;AAAA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,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAP;AACD;AAfS;AAHoC,OAAlD;AAsBA,WAAKZ,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhD5C,QAAAA,IAAI,EAAE6C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,aADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEtF,WAAGuF,YAFJ;AAGN7F,YAAAA,IAAI,EAAE,EAHA;AAIN2C,YAAAA,IAAI,EAAErC,WAAGsC;AAJH,WAFE;AAQVkD,UAAAA,IAAI,EAAE,CARI;AASV/F,UAAAA,MAAM,EAAE,gBACNgG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMI,OAAO,GAAG,MAAI,CAACrG,WAAL,CAAiBsG,UAAjB,EAAhB;;AACA,gBAAQzG,OAAR,GAAoBiG,OAApB,CAAQjG,OAAR;;AAEA,wBAAiBwG,OAAO,CAACxG,OAAD,CAAP,IAA8B;AAAE0G,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;AApBS;AAHoC,OAAlD;AA0BD;;;EAnM2CC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport line_arc_frag from '../shaders/line_arc_great_circle_frag.glsl';\nimport line_arc2d_vert from '../shaders/line_arc_great_circle_vert.glsl';\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\n\nexport default class GreatCircleModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5],\n lineTexture = false,\n iconStep = 100,\n segmentNumber = 30,\n } = this.layer.getLayerConfig() as Partial<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\n u_opacity: Number(opacity),\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n segmentNumber,\n u_line_type: lineStyleObj[lineType as string] || 0.0,\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 // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\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 return [\n this.layer.buildLayerModel({\n moduleName: 'greatcircleline',\n vertexShader: line_arc2d_vert,\n fragmentShader: line_arc_frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\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 // console.log('icon feature', 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":"great_circle.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/great_circle.ts"],"names":["lineStyleObj","solid","dash","GreatCircleModel","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","segmentNumber","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_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","buildLayerModel","moduleName","vertexShader","line_arc2d_vert","fragmentShader","line_arc_frag","triangulation","LineArcTriangulation","depth","enable","blend","getBlend","stencil","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AAEA;;AAEA;;;;;;;;AAGA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAKqBC,gB;;;;;;;;;;;;;;;;gGAqMK,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;;;;;;WApND,wBAAqC;AACnC,iBAUI,KAAKT,KAAL,CAAWU,cAAX,EA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;EAnM2CC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport line_arc_frag from '../shaders/line_arc_great_circle_frag.glsl';\nimport line_arc2d_vert from '../shaders/line_arc_great_circle_vert.glsl';\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\n\nexport default class GreatCircleModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5],\n lineTexture = false,\n iconStep = 100,\n segmentNumber = 30,\n } = this.layer.getLayerConfig() as Partial<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\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n segmentNumber,\n u_line_type: lineStyleObj[lineType as string] || 0.0,\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 // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\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 return [\n this.layer.buildLayerModel({\n moduleName: 'greatcircleline',\n vertexShader: line_arc2d_vert,\n fragmentShader: line_arc_frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\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 // console.log('icon feature', 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":"great_circle.js"}
|
package/lib/line/models/line.js
CHANGED
|
@@ -21,6 +21,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
21
21
|
|
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
23
|
|
|
24
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
25
|
+
|
|
24
26
|
var _l7Core = require("@antv/l7-core");
|
|
25
27
|
|
|
26
28
|
var _l7Utils = require("@antv/l7-utils");
|
|
@@ -172,7 +174,7 @@ var LineModel = function (_BaseModel) {
|
|
|
172
174
|
return {
|
|
173
175
|
u_dataTexture: this.dataTexture,
|
|
174
176
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
175
|
-
u_opacity:
|
|
177
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
176
178
|
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
|
|
177
179
|
u_line_type: lineStyleObj[lineType],
|
|
178
180
|
u_dash_array: dashArray,
|
|
@@ -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","Number","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","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;;AACA;;AAEA;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;gGAgVK,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;;;;;;WA/VD,wBAAqC;AACnC,iBAoBI,KAAKT,KAAL,CAAWU,cAAX,EApBJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,UAEEC,WAFF,QAEEA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,EAENC,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;;;EA9UoCC,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 BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } 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 = 1,\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: Number(opacity),\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 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;;AAWA;;AAEA;;AAEA;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,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I,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;;;EA9UoCC,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';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } 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 = 1,\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: 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 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"}
|
|
@@ -21,6 +21,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
21
21
|
|
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
23
|
|
|
24
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
25
|
+
|
|
24
26
|
var _l7Core = require("@antv/l7-core");
|
|
25
27
|
|
|
26
28
|
var _l7Utils = require("@antv/l7-utils");
|
|
@@ -128,7 +130,7 @@ var LinearLineModel = function (_BaseModel) {
|
|
|
128
130
|
return {
|
|
129
131
|
u_dataTexture: this.dataTexture,
|
|
130
132
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
131
|
-
u_opacity:
|
|
133
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
132
134
|
u_texture: this.colorTexture,
|
|
133
135
|
u_heightfixed: Number(heightfixed),
|
|
134
136
|
u_vertexScale: vertexHeightScale,
|
|
@@ -1 +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","Number","u_texture","u_heightfixed","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;;AASA;;AACA;;AAEA;;;;;;;;;IAIqBA,e;;;;;;;;;;;;;;;;gGAoOK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UA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AAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElE,WAAGmE,WAFJ;AAGNxE,YAAAA,IAAI,EAAE,EAHA;AAIN+B,YAAAA,IAAI,EAAE1B,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 IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\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 = 1,\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: Number(opacity),\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"}
|
|
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;;AAQA;;AAEA;;AAEA;;;;;;;;;IAIqBA,e;;;;;;;;;;;;;;;;gGAoOK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,YAAT,EAAuB;AACrB,cAAKA,YAAL,CAAkBC,OAAlB;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VH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElE,WAAGmE,WAFJ;AAGNxE,YAAAA,IAAI,EAAE,EAHA;AAIN+B,YAAAA,IAAI,EAAE1B,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 IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\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 = 1,\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"}
|