@antv/l7-layers 2.8.23 → 2.8.27
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/core/BaseLayer.d.ts +4 -0
- package/es/core/BaseLayer.js +39 -0
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/LayerGroup.d.ts +8 -0
- package/es/core/LayerGroup.js +66 -0
- package/es/core/LayerGroup.js.map +1 -0
- package/es/core/interface.d.ts +7 -0
- package/es/core/interface.js.map +1 -1
- package/es/core/triangulation.d.ts +1 -0
- package/es/core/triangulation.js +1 -0
- package/es/core/triangulation.js.map +1 -1
- package/es/imagetile/index.d.ts +2 -2
- package/es/imagetile/index.js +4 -4
- package/es/imagetile/index.js.map +1 -1
- package/es/imagetile/models/imagetile.d.ts +2 -2
- package/es/imagetile/models/imagetile.js +1 -15
- package/es/imagetile/models/imagetile.js.map +1 -1
- package/es/imagetile/utils/Tile.d.ts +2 -2
- package/es/imagetile/utils/Tile.js +3 -12
- package/es/imagetile/utils/Tile.js.map +1 -1
- package/es/line/models/line.js +15 -6
- package/es/line/models/line.js.map +1 -1
- package/es/mask/models/fill.js +1 -1
- package/es/mask/models/fill.js.map +1 -1
- package/es/plugins/DataMappingPlugin.d.ts +1 -0
- package/es/plugins/DataMappingPlugin.js +30 -7
- package/es/plugins/DataMappingPlugin.js.map +1 -1
- package/es/point/models/fill.js +1 -1
- package/es/polygon/models/ocean.js +4 -4
- package/es/polygon/models/ocean.js.map +1 -1
- package/es/utils/extrude_polyline.d.ts +6 -0
- package/es/utils/extrude_polyline.js +29 -1
- package/es/utils/extrude_polyline.js.map +1 -1
- package/lib/core/BaseLayer.js +36 -0
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/LayerGroup.js +78 -0
- package/lib/core/LayerGroup.js.map +1 -0
- package/lib/core/interface.js.map +1 -1
- package/lib/core/triangulation.js +1 -0
- package/lib/core/triangulation.js.map +1 -1
- package/lib/imagetile/index.js +4 -4
- package/lib/imagetile/index.js.map +1 -1
- package/lib/imagetile/models/imagetile.js +1 -18
- package/lib/imagetile/models/imagetile.js.map +1 -1
- package/lib/imagetile/utils/Tile.js +3 -12
- package/lib/imagetile/utils/Tile.js.map +1 -1
- package/lib/line/models/line.js +15 -6
- package/lib/line/models/line.js.map +1 -1
- package/lib/mask/models/fill.js +1 -1
- package/lib/mask/models/fill.js.map +1 -1
- package/lib/plugins/DataMappingPlugin.js +29 -6
- package/lib/plugins/DataMappingPlugin.js.map +1 -1
- package/lib/point/models/fill.js +1 -1
- package/lib/polygon/models/ocean.js +4 -4
- package/lib/polygon/models/ocean.js.map +1 -1
- package/lib/utils/extrude_polyline.js +28 -1
- package/lib/utils/extrude_polyline.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/line.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","LineTriangulation","lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","heightfixed","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_heightfixed","Number","u_vertexScale","u_raisingHeight","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","primitive","TRIANGLES","blend","getBlend","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAYA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;;;AAUA,IAAMC,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;;;oEAkUK,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,EAAElB,EAAE,CAACmB,OAFqB;AAG7BC,QAAAA,GAAG,EAAEpB,EAAE,CAACmB,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKT,WAAL,CAAiBU,YAAjB,IAAiC;AANZ,OAAD,CAA9B;AAQD,K;;;;;;;WAjVD,wBAAqC;AACnC,iBAcI,KAAKR,KAAL,CAAWS,cAAX,EAdJ;AAAA,UACEC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E;AAQV6D,UAAAA,IAAI,EAAE,CARI;AASV7G,UAAAA,MAAM,EAAE,gBACN8G,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMK,OAAO,GAAG,MAAI,CAACpH,WAAL,CAAiBqH,UAAjB,EAAhB;;AACA,gBAAQxH,OAAR,GAAoB+G,OAApB,CAAQ/G,OAAR;;AACA,wBAAiBuH,OAAO,CAACvH,OAAD,CAAP,IAA8B;AAAEyH,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;;;;EAhUoClI,S;;SAAlBK,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n heightfixed = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/line.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","LineTriangulation","lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","heightfixed","arrow","enable","arrowWidth","arrowHeight","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","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","primitive","TRIANGLES","blend","getBlend","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","undefined","DYNAMIC_DRAW","Array","isArray","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAYA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;;;AAUA,IAAMC,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;;;oEAgVK,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,EAAElB,EAAE,CAACmB,OAFqB;AAG7BC,QAAAA,GAAG,EAAEpB,EAAE,CAACmB,OAHqB;AAI7BE,QAAAA,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S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n heightfixed = false,\n arrow = {\n enable: false,\n arrowWidth: 2,\n arrowHeight: 3,\n },\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n\n // arrow\n u_arrow: Number(arrow.enable),\n u_arrowHeight: arrow.arrowHeight || 3,\n u_arrowWidth: arrow.arrowWidth || 2,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
|
package/es/mask/models/fill.js
CHANGED
|
@@ -40,7 +40,6 @@ var MaskModel = function (_BaseModel) {
|
|
|
40
40
|
}, {
|
|
41
41
|
key: "initModels",
|
|
42
42
|
value: function initModels() {
|
|
43
|
-
this.layer.zIndex = -1000;
|
|
44
43
|
return this.buildModels();
|
|
45
44
|
}
|
|
46
45
|
}, {
|
|
@@ -77,6 +76,7 @@ var MaskModel = function (_BaseModel) {
|
|
|
77
76
|
var _this$dataTexture;
|
|
78
77
|
|
|
79
78
|
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
79
|
+
this.layerService.clear();
|
|
80
80
|
}
|
|
81
81
|
}, {
|
|
82
82
|
key: "registerBuiltinAttributes",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["gl","BaseModel","polygonTriangulation","MaskModel","layer","getLayerConfig","opacity","u_opacity","
|
|
1
|
+
{"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["gl","BaseModel","polygonTriangulation","MaskModel","layer","getLayerConfig","opacity","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","mask_vert","fragmentShader","mask_frag","triangulation","blend","getBlend","depth","enable","stencil","mask","func","cmp","ALWAYS","ref","opFront","fail","REPLACE","zfail","zpass","dataTexture","destroy","layerService","clear"],"mappings":";;;;;;;;;;;AAAA,SAASA,EAAT,QAA2B,eAA3B;AAEA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C,aAAO,EAAP;AACD;;;;EA/CoCjC,S;;SAAlBE,S","sourcesContent":["import { gl, IModel } from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleSingle } from '../../core/BaseModel';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport mask_frag from '../shaders/mask_frag.glsl';\nimport mask_vert from '../shaders/mask_vert.glsl';\ninterface IMaskStyleOptions {\n opacity: styleSingle;\n}\nexport default class MaskModel extends BaseModel {\n public getUninforms() {\n const { opacity = 0 } = this.layer.getLayerConfig() as IMaskStyleOptions;\n return {\n u_opacity: isNumber(opacity) ? opacity : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'mask',\n vertexShader: mask_vert,\n fragmentShader: mask_frag,\n triangulation: polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n\n stencil: {\n enable: true,\n mask: 0xff,\n func: {\n cmp: gl.ALWAYS,\n ref: 1,\n mask: 0xff,\n },\n opFront: {\n fail: gl.REPLACE,\n zfail: gl.REPLACE,\n zpass: gl.REPLACE,\n },\n },\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layerService.clear();\n }\n\n protected registerBuiltinAttributes() {\n return '';\n }\n}\n"],"file":"fill.js"}
|
|
@@ -8,6 +8,7 @@ export default class DataMappingPlugin implements ILayerPlugin {
|
|
|
8
8
|
styleAttributeService: IStyleAttributeService;
|
|
9
9
|
}): void;
|
|
10
10
|
private generateMaping;
|
|
11
|
+
private getArrowPoints;
|
|
11
12
|
private mapping;
|
|
12
13
|
private adjustData2Amap2Coordinates;
|
|
13
14
|
private adjustData2SimpleCoordinates;
|
|
@@ -14,7 +14,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
14
14
|
|
|
15
15
|
import { TYPES } from '@antv/l7-core';
|
|
16
16
|
import { Version } from '@antv/l7-maps';
|
|
17
|
-
import { isColor, rgb2arr } from '@antv/l7-utils';
|
|
17
|
+
import { isColor, normalize, rgb2arr } from '@antv/l7-utils';
|
|
18
18
|
import { inject, injectable } from 'inversify';
|
|
19
19
|
import 'reflect-metadata';
|
|
20
20
|
var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfigService), _dec3 = inject(TYPES.IMapService), _dec4 = inject(TYPES.IFontService), _dec(_class = (_class2 = function () {
|
|
@@ -70,10 +70,10 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfig
|
|
|
70
70
|
|
|
71
71
|
if (attributesToRemapping.length) {
|
|
72
72
|
if (filter !== null && filter !== void 0 && filter.needRemapping) {
|
|
73
|
-
layer.setEncodedData(_this.mapping(attributes, filterData, undefined, bottomColor));
|
|
73
|
+
layer.setEncodedData(_this.mapping(attributes, filterData, undefined, bottomColor, layer));
|
|
74
74
|
filter.needRemapping = false;
|
|
75
75
|
} else {
|
|
76
|
-
layer.setEncodedData(_this.mapping(attributesToRemapping, filterData, layer.getEncodedData(), bottomColor));
|
|
76
|
+
layer.setEncodedData(_this.mapping(attributesToRemapping, filterData, layer.getEncodedData(), bottomColor, layer));
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
layer.emit('remapping', null);
|
|
@@ -98,14 +98,28 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfig
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
layer.setEncodedData(this.mapping(attributes, filterData, undefined, bottomColor));
|
|
101
|
+
layer.setEncodedData(this.mapping(attributes, filterData, undefined, bottomColor, layer));
|
|
102
102
|
layer.emit('dataUpdate', null);
|
|
103
103
|
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "getArrowPoints",
|
|
106
|
+
value: function getArrowPoints(p1, p2) {
|
|
107
|
+
var dir = [p2[0] - p1[0], p2[1] - p1[1]];
|
|
108
|
+
var normalizeDir = normalize(dir);
|
|
109
|
+
var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
|
|
110
|
+
return arrowPoint;
|
|
111
|
+
}
|
|
104
112
|
}, {
|
|
105
113
|
key: "mapping",
|
|
106
|
-
value: function mapping(attributes, data, predata, minimumColor) {
|
|
114
|
+
value: function mapping(attributes, data, predata, minimumColor, layer) {
|
|
107
115
|
var _this3 = this;
|
|
108
116
|
|
|
117
|
+
var _ref3 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
|
|
118
|
+
_ref3$arrow = _ref3.arrow,
|
|
119
|
+
arrow = _ref3$arrow === void 0 ? {
|
|
120
|
+
enable: false
|
|
121
|
+
} : _ref3$arrow;
|
|
122
|
+
|
|
109
123
|
var mappedData = data.map(function (record, i) {
|
|
110
124
|
var preRecord = predata ? predata[i] : {};
|
|
111
125
|
|
|
@@ -133,6 +147,15 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfig
|
|
|
133
147
|
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
134
148
|
}
|
|
135
149
|
});
|
|
150
|
+
|
|
151
|
+
if (encodeRecord.shape === 'line' && arrow.enable) {
|
|
152
|
+
var coords = encodeRecord.coordinates;
|
|
153
|
+
|
|
154
|
+
var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
|
|
155
|
+
|
|
156
|
+
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
157
|
+
}
|
|
158
|
+
|
|
136
159
|
return encodeRecord;
|
|
137
160
|
});
|
|
138
161
|
this.adjustData2Amap2Coordinates(mappedData);
|
|
@@ -216,10 +239,10 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfig
|
|
|
216
239
|
|
|
217
240
|
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
218
241
|
var params = [];
|
|
219
|
-
scalers.forEach(function (
|
|
242
|
+
scalers.forEach(function (_ref4) {
|
|
220
243
|
var _attribute$scale2;
|
|
221
244
|
|
|
222
|
-
var field =
|
|
245
|
+
var field = _ref4.field;
|
|
223
246
|
|
|
224
247
|
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
225
248
|
params.push(record[field]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["TYPES","Version","isColor","rgb2arr","inject","injectable","DataMappingPlugin","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coords","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;AAAA,SAWEA,KAXF,QAYO,eAZP;AAaA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,OAAT,EAAkBC,OAAlB,QAAgD,gBAAhD;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AAEA,OAAO,kBAAP;IAGqBC,iB,WADpBD,UAAU,E,UAERD,MAAM,CAACJ,KAAK,CAACO,oBAAP,C,UAGNH,MAAM,CAACJ,KAAK,CAACQ,WAAP,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IAAV,KAAmB,OAAnB,IAA8B,CAACrD,OAAO,CAACmF,aAAa,CAAC,CAAD,CAAd,CAA1C,EAA8D;AAC5D,eAAO,CAACzC,YAAD,CAAP;AACD;;AACD,aAAOyC,aAAP;AAED;;;;;;;;;;;;;;;;;;;;SAxQkB/E,iB","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["TYPES","Version","isColor","normalize","rgb2arr","inject","injectable","DataMappingPlugin","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","p1","p2","dir","normalizeDir","arrowPoint","predata","minimumColor","getLayerConfig","arrow","enable","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","coords","getArrowPoints","splice","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;AAAA,SAYEA,KAZF,QAaO,eAbP;AAcA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,OAAT,EAAkBC,SAAlB,EAA6BC,OAA7B,QAA2D,gBAA3D;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AAEA,OAAO,kBAAP;IAIqBC,iB,WADpBD,UAAU,E,UAERD,MAAM,CAACL,KAAK,CAACQ,oBAAP,C,UAGNH,MAAM,CAACL,KAAK,CAACS,WAAP,C,UAGNJ,MAAM,CAACL,KAAK,CAACU,YAAP,C;;;;;;;;;;;;;WAGP,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,QAAA,KAAI,CAACC,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;AACD,OAHD;AAKAD,MAAAA,KAAK,CAACE,KAAN,CAAYI,gBAAZ,CAA6BF,GAA7B,CAAiC,mBAAjC,EAAsD,YAAM;AAC1DJ,QAAAA,KAAK,CAACO,SAAN,CAAgBC,qBAAhB,GAAwC,KAAxC;;AACA,QAAA,KAA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,GAAG,CAAA3D,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkBwD,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAAC7B,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZ+B,KAAY,SAAZA,KAAY;;AAC7B,YACEzD,MAAM,CAAC0D,cAAP,CAAsBD,KAAtB,KACA,sBAAA7D,SAAS,CAACG,KAAV,wEAAiB4D,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAYtD,MAAM,CAACyD,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGhE,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkBoD,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAI5D,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAAC9D,OAAO,CAAC8F,aAAa,CAAC,CAAD,CAAd,CAA1C,EAA8D;AAC5D,eAAO,CAAC9C,YAAD,CAAP;AACD;;AACD,aAAO8C,aAAP;AAED;;;;;;;;;;;;;;;;;;;;SAhSkBzF,iB","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n Position,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, normalize, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\nimport { ILineLayerStyleOptions } from '../core/interface';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor, layer),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n layer,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor, layer),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private getArrowPoints(p1: Position, p2: Position) {\n const dir = [p2[0] - p1[0], p2[1] - p1[1]];\n const normalizeDir = normalize(dir);\n const arrowPoint = [\n p1[0] + normalizeDir[0] * 0.0001,\n p1[1] + normalizeDir[1] * 0.0001,\n ];\n return arrowPoint;\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n layer?: ILayer,\n ): IEncodeFeature[] {\n const {\n arrow = {\n enable: false,\n },\n } = layer?.getLayerConfig() as ILineLayerStyleOptions;\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n\n if (encodeRecord.shape === 'line' && arrow.enable) {\n // 只有在线图层且支持配置箭头的时候进行插入顶点的处理\n const coords = encodeRecord.coordinates as Position[];\n const arrowPoint = this.getArrowPoints(coords[0], coords[1]);\n encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);\n }\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
|
package/es/point/models/fill.js
CHANGED
|
@@ -17,7 +17,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
17
17
|
import { getCullFace, getMask } from '@antv/l7-utils';
|
|
18
18
|
import BaseModel from '../../core/BaseModel';
|
|
19
19
|
import { GlobelPointFillTriangulation, PointFillTriangulation } from '../../core/triangulation';
|
|
20
|
-
var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\
|
|
20
|
+
var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n \n // TODO: \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n gl_FragColor = filterColorAnimate(gl_FragColor);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
21
21
|
var pointFillFrag = "\nuniform float u_globel;\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(u_globel > 0.0) {\n // TODO: \u5730\u7403\u6A21\u5F0F\u4E0B\u907F\u514D\u591A\u4F59\u7247\u5143\u7ED8\u5236\uFF0C\u540C\u65F6\u4E5F\u80FD\u907F\u514D\u6709\u7528\u7247\u5143\u5728\u900F\u660E\u4E14\u91CD\u53E0\u7684\u60C5\u51B5\u4E0B\u65E0\u6CD5\u5199\u5165\n // \u4ED8\u51FA\u7684\u4EE3\u4EF7\u662F\u8FB9\u7F18\u4F1A\u6709\u4E00\u4E9B\u952F\u9F7F\n if(outer_df > antialiasblur + 0.018) discard;\n }\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n } else {\n gl_FragColor.a *= opacity_t;\n }\n\n if(gl_FragColor.a > 0.0) {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
22
22
|
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_isMeter;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, u_blur);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec3 aPosition = a_Position;\n if(u_isMeter < 1.0) {\n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n } else {\n // \u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n antialiasblur *= pow(19.0 - u_Zoom, 2.0);\n antialiasblur = max(antialiasblur, -0.01);\n // offset *= 0.5;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.xy += offset;\n offset.x = 0.0;\n offset.y = 0.0;\n }\n }\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n if(u_globel > 0.0) {\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
23
23
|
import { Version } from '@antv/l7-maps';
|
|
@@ -133,11 +133,11 @@ var OceanModel = function (_BaseModel) {
|
|
|
133
133
|
}, {
|
|
134
134
|
key: "clearModels",
|
|
135
135
|
value: function clearModels() {
|
|
136
|
-
var _this$dataTexture;
|
|
136
|
+
var _this$texture, _this$texture2, _this$texture3, _this$dataTexture;
|
|
137
137
|
|
|
138
|
-
this.texture1.destroy();
|
|
139
|
-
this.texture2.destroy();
|
|
140
|
-
this.texture3.destroy();
|
|
138
|
+
(_this$texture = this.texture1) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
139
|
+
(_this$texture2 = this.texture2) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
|
|
140
|
+
(_this$texture3 = this.texture3) === null || _this$texture3 === void 0 ? void 0 : _this$texture3.destroy();
|
|
141
141
|
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
142
142
|
}
|
|
143
143
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/polygon/models/ocean.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","polygonTriangulation","OceanModel","layer","getLayerConfig","opacity","watercolor","watercolor2","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_texture1","texture1","u_texture2","texture2","u_texture3","texture3","u_watercolor","u_watercolor2","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_time","getLayerAnimateTime","loadTexture","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","ocean_vert","fragmentShader","ocean_frag","triangulation","depth","enable","stencil","destroy","bbox","getSource","extent","minLng","minLat","maxLng","maxLat","lngLen","latLen","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","lng","lat","rendererService","defaultTextureOptions","initImage","images","initTex","layerService","updateLayerRenderList","renderLayers","callback","loadedCount","loadedImages","map","imgSrc","image","Image","crossOrigin","src","push","onload","wrapS","MIRRORED_REPEAT","wrapT","min","LINEAR","mag"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,oBAAT,QAAqC,0BAArC;;;;IAGqBC,U;;;;;;;;;;;;;;;;;;;;;;;;;;;WAInB,wBAAsB;AACpB,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,iCAEEC,UAFF;AAAA,UAEEA,UAFF,gCAEe,SAFf;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,SAHhB;;AAKA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEJ,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE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,EAAE5G,EAAE,CAAC6G,MANa;AAOrBC,UAAAA,GAAG,EAAE9G,EAAE,CAAC6G;AAPa,SAAD,CAAtB;AASD;AACF;;;;EAzKqC1G,S;;SAAnBE,U","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { create, isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport ocean_frag from '../shaders/water/polygon_ocean_frag.glsl';\nimport ocean_vert from '../shaders/water/polygon_ocean_vert.glsl';\nexport default class OceanModel extends BaseModel {\n private texture1: ITexture2D;\n private texture2: ITexture2D;\n private texture3: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n watercolor = '#6D99A8',\n watercolor2 = '#0F121C',\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_texture1: this.texture1,\n u_texture2: this.texture2,\n u_texture3: this.texture3,\n u_watercolor: rgb2arr(watercolor),\n u_watercolor2: rgb2arr(watercolor2),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n };\n }\n\n public getAnimateUniforms(): IModelUniform {\n return {\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.loadTexture();\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon_ocean',\n vertexShader: ocean_vert,\n fragmentShader: ocean_frag,\n triangulation: polygonTriangulation,\n depth: { enable: false },\n\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.texture1.destroy();\n this.texture2.destroy();\n this.texture3.destroy();\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const bbox = this.layer.getSource().extent;\n const [minLng, minLat, maxLng, maxLat] = bbox;\n const lngLen = maxLng - minLng;\n const latLen = maxLat - minLat;\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'oceanUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.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 ) => {\n const [lng, lat] = vertex;\n return [(lng - minLng) / lngLen, (lat - minLat) / latLen];\n },\n },\n });\n }\n\n private loadTexture() {\n const { createTexture2D } = this.rendererService;\n const defaultTextureOptions = { height: 0, width: 0 };\n // 默认索引为 undefined,所以单独赋值\n this.texture1 = createTexture2D(defaultTextureOptions);\n this.texture2 = createTexture2D(defaultTextureOptions);\n this.texture3 = createTexture2D(defaultTextureOptions);\n\n // 加载完 image 后单独给 texture f赋值\n initImage((images: HTMLImageElement[]) => {\n this.texture1 = initTex(images[0]);\n this.texture2 = initTex(images[1]);\n this.texture3 = initTex(images[2]);\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n });\n\n function initImage(callback: (loadedImages: HTMLImageElement[]) => void) {\n let loadedCount = 0;\n const loadedImages: HTMLImageElement[] = [];\n const images = [\n 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*EojwT4VzSiYAAAAAAAAAAAAAARQnAQ',\n 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*MJ22QbpuCzIAAAAAAAAAAAAAARQnAQ',\n 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*-z2HSIVDsHIAAAAAAAAAAAAAARQnAQ',\n ];\n images.map((imgSrc: string) => {\n const image = new Image();\n image.crossOrigin = '';\n image.src = imgSrc;\n loadedImages.push(image);\n image.onload = () => {\n loadedCount++;\n if (loadedCount === 3) {\n callback(loadedImages);\n }\n };\n });\n }\n\n function initTex(image: HTMLImageElement) {\n return createTexture2D({\n data: image,\n width: image.width,\n height: image.height,\n wrapS: gl.MIRRORED_REPEAT,\n wrapT: gl.MIRRORED_REPEAT,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n });\n }\n }\n}\n"],"file":"ocean.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/polygon/models/ocean.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","polygonTriangulation","OceanModel","layer","getLayerConfig","opacity","watercolor","watercolor2","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_texture1","texture1","u_texture2","texture2","u_texture3","texture3","u_watercolor","u_watercolor2","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_time","getLayerAnimateTime","loadTexture","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","ocean_vert","fragmentShader","ocean_frag","triangulation","depth","enable","stencil","destroy","bbox","getSource","extent","minLng","minLat","maxLng","maxLat","lngLen","latLen","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","lng","lat","rendererService","defaultTextureOptions","initImage","images","initTex","layerService","updateLayerRenderList","renderLayers","callback","loadedCount","loadedImages","map","imgSrc","image","Image","crossOrigin","src","push","onload","wrapS","MIRRORED_REPEAT","wrapT","min","LINEAR","mag"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,oBAAT,QAAqC,0BAArC;;;;IAGqBC,U;;;;;;;;;;;;;;;;;;;;;;;;;;;WAInB,wBAAsB;AACpB,iBAII,KAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,iCAEEC,UAFF;AAAA,UAEEA,UAFF,gCAEe,SAFf;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,SAHhB;;AAKA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEJ,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKK,oBAAL,CAA0B;AAAEL,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,YAAMM,UAAU,GAAG,KAAKR,KAAL,CAAWS,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd,sBAAcA,KAAd;AAAA,YAAqBC,MAArB,sBAAqBA,MAArB;;AAKA,aAAKC,QAAL,GAAgBD,MAAhB;AAEA,aAAKE,WAAL,GACE,KAAKN,UAAL,GAAkB,CAAlB,IAAuBE,IAAI,CAACK,MAAL,GAAc,CAArC,GACI,KAAKC,eAAL,CAAqB;AAC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,EAGb,uFAHa,CAAf;AAKAA,QAAAA,MAAM,CAACQ,GAAP,CAAW,UAACC,MAAD,EAAoB;AAC7B,cAAMC,KAAK,GAAG,IAAIC,KAAJ,EAAd;AACAD,UAAAA,KAAK,CAACE,WAAN,GAAoB,EAApB;AACAF,UAAAA,KAAK,CAACG,GAAN,GAAYJ,MAAZ;AACAF,UAAAA,YAAY,CAACO,IAAb,CAAkBJ,KAAlB;;AACAA,UAAAA,KAAK,CAACK,MAAN,GAAe,YAAM;AACnBT,YAAAA,WAAW;;AACX,gBAAIA,WAAW,KAAK,CAApB,EAAuB;AACrBD,cAAAA,QAAQ,CAACE,YAAD,CAAR;AACD;AACF,WALD;AAMD,SAXD;AAYD;;AAED,eAASN,OAAT,CAAiBS,KAAjB,EAA0C;AACxC,eAAO1E,eAAe,CAAC;AACrBN,UAAAA,IAAI,EAAEgF,KADe;AAErB/E,UAAAA,KAAK,EAAE+E,KAAK,CAAC/E,KAFQ;AAGrBC,UAAAA,MAAM,EAAE8E,KAAK,CAAC9E,MAHO;AAIrBoF,UAAAA,KAAK,EAAEzG,EAAE,CAAC0G,eAJW;AAKrBC,UAAAA,KAAK,EAAE3G,EAAE,CAAC0G,eALW;AAMrBE,UAAAA,GAAG,EAAE5G,EAAE,CAAC6G,MANa;AAOrBC,UAAAA,GAAG,EAAE9G,EAAE,CAAC6G;AAPa,SAAD,CAAtB;AASD;AACF;;;;EAzKqC1G,S;;SAAnBE,U","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { create, isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport ocean_frag from '../shaders/water/polygon_ocean_frag.glsl';\nimport ocean_vert from '../shaders/water/polygon_ocean_vert.glsl';\nexport default class OceanModel extends BaseModel {\n private texture1: ITexture2D;\n private texture2: ITexture2D;\n private texture3: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n watercolor = '#6D99A8',\n watercolor2 = '#0F121C',\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_texture1: this.texture1,\n u_texture2: this.texture2,\n u_texture3: this.texture3,\n u_watercolor: rgb2arr(watercolor),\n u_watercolor2: rgb2arr(watercolor2),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n };\n }\n\n public getAnimateUniforms(): IModelUniform {\n return {\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.loadTexture();\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon_ocean',\n vertexShader: ocean_vert,\n fragmentShader: ocean_frag,\n triangulation: polygonTriangulation,\n depth: { enable: false },\n\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.texture1?.destroy();\n this.texture2?.destroy();\n this.texture3?.destroy();\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const bbox = this.layer.getSource().extent;\n const [minLng, minLat, maxLng, maxLat] = bbox;\n const lngLen = maxLng - minLng;\n const latLen = maxLat - minLat;\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'oceanUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.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 ) => {\n const [lng, lat] = vertex;\n return [(lng - minLng) / lngLen, (lat - minLat) / latLen];\n },\n },\n });\n }\n\n private loadTexture() {\n const { createTexture2D } = this.rendererService;\n const defaultTextureOptions = { height: 0, width: 0 };\n // 默认索引为 undefined,所以单独赋值\n this.texture1 = createTexture2D(defaultTextureOptions);\n this.texture2 = createTexture2D(defaultTextureOptions);\n this.texture3 = createTexture2D(defaultTextureOptions);\n\n // 加载完 image 后单独给 texture f赋值\n initImage((images: HTMLImageElement[]) => {\n this.texture1 = initTex(images[0]);\n this.texture2 = initTex(images[1]);\n this.texture3 = initTex(images[2]);\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n });\n\n function initImage(callback: (loadedImages: HTMLImageElement[]) => void) {\n let loadedCount = 0;\n const loadedImages: HTMLImageElement[] = [];\n const images = [\n 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*EojwT4VzSiYAAAAAAAAAAAAAARQnAQ',\n 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*MJ22QbpuCzIAAAAAAAAAAAAAARQnAQ',\n 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*-z2HSIVDsHIAAAAAAAAAAAAAARQnAQ',\n ];\n images.map((imgSrc: string) => {\n const image = new Image();\n image.crossOrigin = '';\n image.src = imgSrc;\n loadedImages.push(image);\n image.onload = () => {\n loadedCount++;\n if (loadedCount === 3) {\n callback(loadedImages);\n }\n };\n });\n }\n\n function initTex(image: HTMLImageElement) {\n return createTexture2D({\n data: image,\n width: image.width,\n height: image.height,\n wrapS: gl.MIRRORED_REPEAT,\n wrapT: gl.MIRRORED_REPEAT,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n });\n }\n }\n}\n"],"file":"ocean.js"}
|
|
@@ -17,6 +17,7 @@ export default class ExtrudePolyline {
|
|
|
17
17
|
indices: number[];
|
|
18
18
|
normals: number[];
|
|
19
19
|
startIndex: number;
|
|
20
|
+
indexes: number[];
|
|
20
21
|
};
|
|
21
22
|
private join;
|
|
22
23
|
private cap;
|
|
@@ -28,30 +29,35 @@ export default class ExtrudePolyline {
|
|
|
28
29
|
private started;
|
|
29
30
|
private dash;
|
|
30
31
|
private totalDistance;
|
|
32
|
+
private currentIndex;
|
|
31
33
|
constructor(opts?: Partial<IExtrudeLineOption>);
|
|
32
34
|
extrude_gaode2(points: number[][], originPoints: number[][]): {
|
|
33
35
|
positions: number[];
|
|
34
36
|
indices: number[];
|
|
35
37
|
normals: number[];
|
|
36
38
|
startIndex: number;
|
|
39
|
+
indexes: number[];
|
|
37
40
|
};
|
|
38
41
|
simpleExtrude_gaode2(points: number[][], originPoints: number[][]): {
|
|
39
42
|
positions: number[];
|
|
40
43
|
indices: number[];
|
|
41
44
|
normals: number[];
|
|
42
45
|
startIndex: number;
|
|
46
|
+
indexes: number[];
|
|
43
47
|
};
|
|
44
48
|
extrude(points: number[][]): {
|
|
45
49
|
positions: number[];
|
|
46
50
|
indices: number[];
|
|
47
51
|
normals: number[];
|
|
48
52
|
startIndex: number;
|
|
53
|
+
indexes: number[];
|
|
49
54
|
};
|
|
50
55
|
simpleExtrude(points: number[][]): {
|
|
51
56
|
positions: number[];
|
|
52
57
|
indices: number[];
|
|
53
58
|
normals: number[];
|
|
54
59
|
startIndex: number;
|
|
60
|
+
indexes: number[];
|
|
55
61
|
};
|
|
56
62
|
private segment_gaode2;
|
|
57
63
|
private simpleSegment;
|
|
@@ -75,6 +75,8 @@ var ExtrudePolyline = function () {
|
|
|
75
75
|
|
|
76
76
|
_defineProperty(this, "totalDistance", 0);
|
|
77
77
|
|
|
78
|
+
_defineProperty(this, "currentIndex", 0);
|
|
79
|
+
|
|
78
80
|
this.join = opts.join || 'miter';
|
|
79
81
|
this.cap = opts.cap || 'butt';
|
|
80
82
|
this.miterLimit = opts.miterLimit || 10;
|
|
@@ -84,7 +86,8 @@ var ExtrudePolyline = function () {
|
|
|
84
86
|
positions: [],
|
|
85
87
|
indices: [],
|
|
86
88
|
normals: [],
|
|
87
|
-
startIndex: 0
|
|
89
|
+
startIndex: 0,
|
|
90
|
+
indexes: []
|
|
88
91
|
};
|
|
89
92
|
}
|
|
90
93
|
|
|
@@ -269,7 +272,10 @@ var ExtrudePolyline = function () {
|
|
|
269
272
|
normals.push(out2[0], out2[1], 0);
|
|
270
273
|
normals.push(out1[0], out1[1], 0);
|
|
271
274
|
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
|
|
275
|
+
this.complex.indexes.push(this.currentIndex);
|
|
272
276
|
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, this.thickness, last[2] | 0);
|
|
277
|
+
this.complex.indexes.push(this.currentIndex);
|
|
278
|
+
this.currentIndex++;
|
|
273
279
|
} else {
|
|
274
280
|
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
275
281
|
}
|
|
@@ -290,7 +296,10 @@ var ExtrudePolyline = function () {
|
|
|
290
296
|
normals.push(_out2[0], _out2[1], 0);
|
|
291
297
|
normals.push(_out[0], _out[1], 0);
|
|
292
298
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
299
|
+
this.complex.indexes.push(this.currentIndex);
|
|
293
300
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
301
|
+
this.complex.indexes.push(this.currentIndex);
|
|
302
|
+
this.currentIndex++;
|
|
294
303
|
} else {
|
|
295
304
|
this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
|
|
296
305
|
}
|
|
@@ -324,13 +333,18 @@ var ExtrudePolyline = function () {
|
|
|
324
333
|
normals.push(this.normal[0], this.normal[1], 0);
|
|
325
334
|
normals.push(miter[0], miter[1], 0);
|
|
326
335
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
336
|
+
this.complex.indexes.push(this.currentIndex);
|
|
327
337
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness * flip, cur[2] | 0);
|
|
338
|
+
this.complex.indexes.push(this.currentIndex);
|
|
339
|
+
this.currentIndex++;
|
|
328
340
|
indices.push.apply(indices, _toConsumableArray(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
329
341
|
indices.push(index + 2, index + 3, index + 4);
|
|
330
342
|
computeNormal(tmp, lineB);
|
|
331
343
|
vec2.copy(this.normal, tmp);
|
|
332
344
|
normals.push(this.normal[0], this.normal[1], 0);
|
|
333
345
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
346
|
+
this.complex.indexes.push(this.currentIndex);
|
|
347
|
+
this.currentIndex++;
|
|
334
348
|
count += 3;
|
|
335
349
|
} else {
|
|
336
350
|
this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
|
|
@@ -439,7 +453,10 @@ var ExtrudePolyline = function () {
|
|
|
439
453
|
normals.push(out2[0], out2[1], 0);
|
|
440
454
|
normals.push(out1[0], out1[1], 0);
|
|
441
455
|
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
|
|
456
|
+
this.complex.indexes.push(this.currentIndex);
|
|
442
457
|
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, this.thickness, last[2] | 0);
|
|
458
|
+
this.complex.indexes.push(this.currentIndex);
|
|
459
|
+
this.currentIndex++;
|
|
443
460
|
} else {
|
|
444
461
|
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
445
462
|
}
|
|
@@ -460,7 +477,10 @@ var ExtrudePolyline = function () {
|
|
|
460
477
|
normals.push(_out4[0], _out4[1], 0);
|
|
461
478
|
normals.push(_out3[0], _out3[1], 0);
|
|
462
479
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
480
|
+
this.complex.indexes.push(this.currentIndex);
|
|
463
481
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
482
|
+
this.complex.indexes.push(this.currentIndex);
|
|
483
|
+
this.currentIndex++;
|
|
464
484
|
} else {
|
|
465
485
|
this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
|
|
466
486
|
}
|
|
@@ -496,13 +516,18 @@ var ExtrudePolyline = function () {
|
|
|
496
516
|
normals.push(this.normal[0], this.normal[1], 0);
|
|
497
517
|
normals.push(miter[0], miter[1], 0);
|
|
498
518
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
519
|
+
this.complex.indexes.push(this.currentIndex);
|
|
499
520
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness * flip, cur[2] | 0);
|
|
521
|
+
this.complex.indexes.push(this.currentIndex);
|
|
522
|
+
this.currentIndex++;
|
|
500
523
|
indices.push.apply(indices, _toConsumableArray(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
501
524
|
indices.push(index + 2, index + 3, index + 4);
|
|
502
525
|
computeNormal(tmp, lineB);
|
|
503
526
|
vec2.copy(this.normal, tmp);
|
|
504
527
|
normals.push(this.normal[0], this.normal[1], 0);
|
|
505
528
|
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
529
|
+
this.complex.indexes.push(this.currentIndex);
|
|
530
|
+
this.currentIndex++;
|
|
506
531
|
count += 3;
|
|
507
532
|
} else {
|
|
508
533
|
this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
|
|
@@ -523,7 +548,10 @@ var ExtrudePolyline = function () {
|
|
|
523
548
|
normals.push(normal[0], normal[1], 0);
|
|
524
549
|
normals.push(normal[0], normal[1], 0);
|
|
525
550
|
positions.push(point[0], point[1], point[2] | 0, distanceRadio, -thickness, point[2] | 0);
|
|
551
|
+
this.complex.indexes.push(this.currentIndex);
|
|
526
552
|
positions.push(point[0], point[1], point[2] | 0, distanceRadio, thickness, point[2] | 0);
|
|
553
|
+
this.complex.indexes.push(this.currentIndex);
|
|
554
|
+
this.currentIndex++;
|
|
527
555
|
}
|
|
528
556
|
}, {
|
|
529
557
|
key: "lineSegmentDistance",
|