@antv/l7-layers 2.8.15 → 2.8.16

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.
@@ -24,6 +24,7 @@ export interface ILineLayerStyleOptions {
24
24
  borderWidth?: number;
25
25
  borderColor?: string;
26
26
  heightfixed?: boolean;
27
+ raisingHeight?: number;
27
28
  mask?: boolean;
28
29
  maskInside?: boolean;
29
30
  }
@@ -41,6 +42,7 @@ export interface IPointLayerStyleOptions {
41
42
  fontWeight?: string;
42
43
  fontFamily?: string;
43
44
  textAllowOverlap?: boolean;
45
+ raisingHeight?: number;
44
46
  pickLight?: boolean;
45
47
  depth?: boolean;
46
48
  sourceColor?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType","CanvasUpdateType"],"mappings":"AAIA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a;;AAuHZ,WAAYC,gBAAZ;;WAAYA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,KAAAA,gB","sourcesContent":["import { IMapService } from '@antv/l7-core';\nimport { IColorRamp } from '@antv/l7-utils';\nimport { styleOffset, styleSingle } from '../core/BaseModel';\nimport { anchorType } from '../utils/symbol-layout';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n\n mask?: boolean; // 可选参数 时候允许蒙层\n maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部\n}\n\nexport interface IPointLayerStyleOptions {\n opacity: number;\n strokeOpacity: number;\n strokeWidth: number;\n stroke: string;\n\n textOffset?: [number, number];\n textAnchor?: anchorType;\n spacing?: number;\n padding?: [number, number];\n halo?: number;\n gamma?: number;\n fontWeight?: string;\n fontFamily?: string;\n textAllowOverlap?: boolean;\n\n // cylinder\n pickLight?: boolean;\n depth?: boolean;\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n opacityLinear?: {\n enable: boolean;\n dir: string;\n };\n lightEnable: boolean;\n heightfixed?: boolean; // 圆柱体高度是否固定(不随 zoom 发生变化)\n\n offsets?: styleOffset;\n blend?: string;\n unit?: string;\n mask?: boolean;\n maskInside?: boolean;\n\n rotation?: number; // angle\n speed?: number;\n}\n\nexport interface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n\n raisingHeight?: number; // 挤出几何体抬升高度\n heightfixed?: boolean; // 挤出几何体高度是否固定(不随 zoom 发生变化)\n\n pickLight: boolean;\n mask?: boolean;\n maskInside?: boolean;\n\n // water\n waterTexture?: string;\n speed?: number;\n // ocean\n watercolor?: string;\n watercolor2?: string;\n}\n\nexport interface IImageLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IGeometryLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n\n mapTexture?: string;\n terrainTexture?: string;\n\n // planeGeometry\n center?: [number, number];\n width?: number;\n height?: number;\n\n widthSegments?: number;\n heightSegments?: number;\n\n terrainClipHeight?: number;\n rgb2height?: (r: number, g: number, b: number) => number;\n}\n\nexport enum CanvasUpdateType {\n 'ALWAYS' = 'always',\n 'DRAGEND' = 'dragend',\n}\n\nexport interface IDrawingOnCanvas {\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n mapService: IMapService;\n size: [number, number];\n}\nexport interface ICanvasLayerStyleOptions {\n zIndex: number;\n update: CanvasUpdateType | string;\n drawingOnCanvas: (option: IDrawingOnCanvas) => void;\n}\n\nexport interface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n\n coverage?: number;\n}\n\nexport interface IRasterLayerStyleOptions {\n opacity: number;\n domain: [number, number];\n noDataValue: number;\n clampLow: boolean;\n clampHigh: boolean;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n}\n"],"file":"interface.js"}
1
+ {"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType","CanvasUpdateType"],"mappings":"AAIA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a;;AA0HZ,WAAYC,gBAAZ;;WAAYA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,KAAAA,gB","sourcesContent":["import { IMapService } from '@antv/l7-core';\nimport { IColorRamp } from '@antv/l7-utils';\nimport { styleOffset, styleSingle } from '../core/BaseModel';\nimport { anchorType } from '../utils/symbol-layout';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n raisingHeight?: number; // 线图层抬升高度\n\n mask?: boolean; // 可选参数 时候允许蒙层\n maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部\n}\n\nexport interface IPointLayerStyleOptions {\n opacity: number;\n strokeOpacity: number;\n strokeWidth: number;\n stroke: string;\n\n textOffset?: [number, number];\n textAnchor?: anchorType;\n spacing?: number;\n padding?: [number, number];\n halo?: number;\n gamma?: number;\n fontWeight?: string;\n fontFamily?: string;\n textAllowOverlap?: boolean;\n\n raisingHeight?: number; // 线图层抬升高度\n\n // cylinder\n pickLight?: boolean;\n depth?: boolean;\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n opacityLinear?: {\n enable: boolean;\n dir: string;\n };\n lightEnable: boolean;\n heightfixed?: boolean; // 圆柱体高度是否固定(不随 zoom 发生变化)\n\n offsets?: styleOffset;\n blend?: string;\n unit?: string;\n mask?: boolean;\n maskInside?: boolean;\n\n rotation?: number; // angle\n speed?: number;\n}\n\nexport interface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n\n raisingHeight?: number; // 挤出几何体抬升高度\n heightfixed?: boolean; // 挤出几何体高度是否固定(不随 zoom 发生变化)\n\n pickLight: boolean;\n mask?: boolean;\n maskInside?: boolean;\n\n // water\n waterTexture?: string;\n speed?: number;\n // ocean\n watercolor?: string;\n watercolor2?: string;\n}\n\nexport interface IImageLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IGeometryLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n\n mapTexture?: string;\n terrainTexture?: string;\n\n // planeGeometry\n center?: [number, number];\n width?: number;\n height?: number;\n\n widthSegments?: number;\n heightSegments?: number;\n\n terrainClipHeight?: number;\n rgb2height?: (r: number, g: number, b: number) => number;\n}\n\nexport enum CanvasUpdateType {\n 'ALWAYS' = 'always',\n 'DRAGEND' = 'dragend',\n}\n\nexport interface IDrawingOnCanvas {\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n mapService: IMapService;\n size: [number, number];\n}\nexport interface ICanvasLayerStyleOptions {\n zIndex: number;\n update: CanvasUpdateType | string;\n drawingOnCanvas: (option: IDrawingOnCanvas) => void;\n}\n\nexport interface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n\n coverage?: number;\n}\n\nexport interface IRasterLayerStyleOptions {\n opacity: number;\n domain: [number, number];\n noDataValue: number;\n clampLow: boolean;\n clampHigh: boolean;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n}\n"],"file":"interface.js"}
@@ -18,7 +18,7 @@ import { LineTriangulation } from '../../core/triangulation';
18
18
  var line_dash_frag = "#define LineTypeSolid 0.0\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n // dash line\n \n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
19
19
  var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y), 1.0));\n } else {\n float lineHeight = a_Size.y;\n \n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
20
20
  var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying vec2 v_iconMapUV;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + animateSpeed);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n \n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = styleMappingMat[3].a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth/2.0;\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) {\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
21
- var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance;; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
21
+ var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance;; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n // project_pos.z += u_raisingHeight;\n // if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n // project_pos.z += u_raisingHeight * mapboxZoomScale;\n // }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y) + h * 0.2 + u_raisingHeight, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n // h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n } else {\n h += u_raisingHeight;\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
22
22
  var linear_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
23
23
  var lineStyleObj = {
24
24
  solid: 0.0,
@@ -91,7 +91,9 @@ var LineModel = function (_BaseModel) {
91
91
  _ref$borderWidth = _ref.borderWidth,
92
92
  borderWidth = _ref$borderWidth === void 0 ? 0.0 : _ref$borderWidth,
93
93
  _ref$borderColor = _ref.borderColor,
94
- borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor;
94
+ borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
95
+ _ref$raisingHeight = _ref.raisingHeight,
96
+ raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight;
95
97
 
96
98
  if (dashArray.length === 2) {
97
99
  dashArray.push(0, 0);
@@ -158,7 +160,8 @@ var LineModel = function (_BaseModel) {
158
160
  u_linearColor: useLinearColor,
159
161
  u_sourceColor: sourceColorArr,
160
162
  u_targetColor: targetColorArr,
161
- u_vertexScale: vertexHeightScale
163
+ u_vertexScale: vertexHeightScale,
164
+ u_raisingHeight: Number(raisingHeight)
162
165
  };
163
166
  }
164
167
  }, {
@@ -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","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","primitive","TRIANGLES","blend","getBlend","depth","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;;;;;;;;;;;;;;;;;;oEA0TK,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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E,CAACyH,YAFJ;AAGN5G,YAAAA,IAAI,EAAE,EAHA;AAIN4C,YAAAA,IAAI,EAAEzD,EAAE,CAAC0D;AAJH,WAFE;AAQV0D,UAAAA,IAAI,EAAE,CARI;AASVxG,UAAAA,MAAM,EAAE,gBACNyG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMK,OAAO,GAAG,MAAI,CAAC/G,WAAL,CAAiBgH,UAAjB,EAAhB;;AACA,gBAAQnH,OAAR,GAAoB0G,OAApB,CAAQ1G,OAAR;;AACA,wBAAiBkH,OAAO,CAAClH,OAAD,CAAP,IAA8B;AAAEoH,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;;;;EAxToC7H,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 } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
1
+ {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["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","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","u_raisingHeight","Number","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","primitive","TRIANGLES","blend","getBlend","depth","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;;;;;;;;;;;;;;;;;;oEA4TK,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,C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AA,MAAM,EAAE,gBACN4G,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMK,OAAO,GAAG,MAAI,CAAClH,WAAL,CAAiBmH,UAAjB,EAAhB;;AACA,gBAAQtH,OAAR,GAAoB6G,OAApB,CAAQ7G,OAAR;;AACA,wBAAiBqH,OAAO,CAACrH,OAAD,CAAP,IAA8B;AAAEuH,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;;;;EA1ToChI,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 } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
@@ -25,7 +25,7 @@ import CollisionIndex from '../../utils/collision-index';
25
25
  import { calculateCentroid } from '../../utils/geo';
26
26
  import { getGlyphQuads, shapeText } from '../../utils/symbol-layout';
27
27
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
28
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\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_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\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 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 // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
28
+ var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\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_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\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 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 // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
29
29
  export function TextTriangulation(feature) {
30
30
  var that = this;
31
31
  var id = feature.id;
@@ -133,7 +133,9 @@ var TextModel = function (_BaseModel) {
133
133
  _ref2$halo = _ref2.halo,
134
134
  halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
135
135
  _ref2$gamma = _ref2.gamma,
136
- gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma;
136
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
137
+ _ref2$raisingHeight = _ref2.raisingHeight,
138
+ raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
137
139
 
138
140
  var _this$fontService = this.fontService,
139
141
  canvas = _this$fontService.canvas,
@@ -187,6 +189,7 @@ var TextModel = function (_BaseModel) {
187
189
  return {
188
190
  u_dataTexture: this.dataTexture,
189
191
  u_cellTypeLayout: this.getCellTypeLayout(),
192
+ u_raisingHeight: Number(raisingHeight),
190
193
  u_opacity: _isNumber(opacity) ? opacity : 1.0,
191
194
  u_stroke_width: _isNumber(strokeWidth) ? strokeWidth : 0.0,
192
195
  u_stroke_color: this.getStrokeColor(stroke),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/text.ts"],"names":["AttributeType","gl","boundsContains","getMask","padBounds","BaseModel","CollisionIndex","calculateCentroid","getGlyphQuads","shapeText","TextTriangulation","feature","that","id","vertices","indices","glyphInfoMap","size","centroid","coord","length","glyphQuads","forEach","quad","index","push","tex","x","y","height","tl","width","tr","br","bl","TextModel","layer","getLayerConfig","mask","maskInside","initGlyph","updateTexture","filterGlyphs","reBuildModel","buildLayerModel","moduleName","vertexShader","textVert","fragmentShader","textFrag","triangulation","bind","depth","enable","blend","getBlend","stencil","opacity","stroke","strokeWidth","textAnchor","textAllowOverlap","halo","gamma","fontService","canvas","mapping","Object","keys","textCount","preTextStyle","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_sdf_map","texture","u_halo_blur","u_gamma_scale","u_sdf_map_size","on","buildModels","extent","textExtent","zoom","mapService","getZoom","getBounds","flag","Math","abs","currentZoom","destroy","off","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","rotate","Array","isArray","STATIC_DRAW","bounds","fontWeight","fontFamily","characterSet","item","shape","toString","char","indexOf","setFontOptions","iconfont","spacing","glyphInfo","map","textOffset","shaping","coordinates","originCentroid","version","originCoordinates","padding","rendererService","getViewportSize","collisionIndex","filterData","filter","fontScale","pixels","lngLatToContainer","placeCollisionBox","x1","left","x2","right","y1","top","y2","bottom","anchorPointX","anchorPointY","box","insertCollisionBox","initIconFontTex","initTextFont","generateGlyphLayout","textureHeight","mag","LINEAR","min","models"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,cAAT,EAAyBC,OAAzB,EAAkCC,SAAlC,QAAmD,gBAAnD;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,OAAOC,cAAP,MAA2B,6BAA3B;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AACA,SACEC,aADF,EAGEC,SAHF,QAIO,2BAJP;;;AAQA,OAAO,SAASC,iBAAT,CAA2BC,OAA3B,EAAoD;AAEzD,MAAMC,IAAI,GAAG,IAAb;AACA,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAnB;AACA,MAAMC,QAAkB,GAAG,EAA3B;AACA,MAAMC,OAAiB,GAAG,EAA1B;;AAEA,MAAI,CAACH,IAAI,CAACI,YAAN,IAAsB,CAACJ,IAAI,CAACI,YAAL,CAAkBH,EAAlB,CAA3B,EAAkD;AAChD,WAAO;AACLC,MAAAA,QAAQ,EAAE,EADL;AAELC,MAAAA,OAAO,EAAE,EAFJ;AAGLE,MAAAA,IAAI,EAAE;AAHD,KAAP;AAKD;;AACD,MAAMC,QAAQ,GAAGN,IAAI,CAACI,YAAL,CAAkBH,EAAlB,EAAsBK,QAAvC;AACA,MAAMC,KAAK,GACTD,QAAQ,CAACE,MAAT,KAAoB,CAApB,GAAwB,CAACF,QAAQ,CAAC,CAAD,CAAT,EAAcA,QAAQ,CAAC,CAAD,CAAtB,EAA2B,CAA3B,CAAxB,GAAwDA,QAD1D;AAEAN,EAAAA,IAAI,CAACI,YAAL,CAAkBH,EAAlB,EAAsBQ,UAAtB,CAAiCC,OAAjC,CACE,UAACC,IAAD,EAAmBC,KAAnB,EAAqC;AACnCV,IAAAA,QAAQ,CAACW,IAAT,OAAAX,QAAQ,qBACHK,KADG,UAENI,IAAI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JU;AAKzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EANkB;AAOzBC,QAAAA,OAAO,EAAErD,OAAO,CAACmC,IAAD,EAAOC,UAAP;AAPS,OAA3B,CADkB,CAApB;AAWD;;;;EAjcoClC,S;;SAAlB8B,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { boundsContains, getMask, padBounds } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport CollisionIndex from '../../utils/collision-index';\nimport { calculateCentroid } from '../../utils/geo';\nimport {\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../../utils/symbol-layout';\nimport textFrag from '../shaders/text_frag.glsl';\nimport textVert from '../shaders/text_vert.glsl';\n\nexport function TextTriangulation(feature: IEncodeFeature) {\n // @ts-ignore\n const that = this as TextModel;\n const id = feature.id as number;\n const vertices: number[] = [];\n const indices: number[] = [];\n\n if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {\n return {\n vertices: [], // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices: [],\n size: 7,\n };\n }\n const centroid = that.glyphInfoMap[id].centroid as number[]; // 计算中心点\n const coord =\n centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;\n that.glyphInfoMap[id].glyphQuads.forEach(\n (quad: IGlyphQuad, index: number) => {\n vertices.push(\n ...coord,\n quad.tex.x,\n quad.tex.y + quad.tex.height,\n quad.tl.x,\n quad.tl.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y + quad.tex.height,\n quad.tr.x,\n quad.tr.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y,\n quad.br.x,\n quad.br.y,\n ...coord,\n quad.tex.x,\n quad.tex.y,\n quad.bl.x,\n quad.bl.y,\n );\n indices.push(\n 0 + index * 4,\n 1 + index * 4,\n 2 + index * 4,\n 2 + index * 4,\n 3 + index * 4,\n 0 + index * 4,\n );\n },\n );\n return {\n vertices, // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices,\n size: 7,\n };\n}\n\nexport default class TextModel extends BaseModel {\n public glyphInfo: IEncodeFeature[];\n public glyphInfoMap: {\n [key: string]: {\n shaping: any;\n glyphQuads: IGlyphQuad[];\n centroid: number[];\n };\n } = {};\n private texture: ITexture2D;\n private currentZoom: number = -1;\n private extent: [[number, number], [number, number]];\n private textureHeight: number = 0;\n private textCount: number = 0;\n private preTextStyle: Partial<IPointLayerStyleOptions> = {};\n public getUninforms(): IModelUniform {\n const {\n opacity = 1.0,\n stroke = '#fff',\n strokeWidth = 0,\n textAnchor = 'center',\n textAllowOverlap = false,\n halo = 0.5,\n gamma = 2.0,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { canvas, mapping } = this.fontService;\n if (Object.keys(mapping).length !== this.textCount) {\n this.updateTexture();\n this.textCount = Object.keys(mapping).length;\n }\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeWidth,\n stroke,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n strokeWidth,\n stroke,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n\n u_sdf_map: this.texture,\n u_halo_blur: halo,\n u_gamma_scale: gamma,\n u_sdf_map_size: [canvas.width, canvas.height],\n };\n }\n\n public initModels(): IModel[] {\n this.layer.on('remapping', this.buildModels);\n this.extent = this.textExtent();\n const {\n textAnchor = 'center',\n textAllowOverlap = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n return this.buildModels();\n }\n\n public buildModels = () => {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.initGlyph();\n this.updateTexture();\n this.filterGlyphs();\n this.reBuildModel();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n };\n public needUpdate() {\n const {\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n // textAllowOverlap 发生改变\n const zoom = this.mapService.getZoom();\n const extent = this.mapService.getBounds();\n const flag = boundsContains(this.extent, extent);\n // 文本不能压盖则进行过滤\n if (\n (!textAllowOverlap && (Math.abs(this.currentZoom - zoom) > 1 || !flag)) ||\n textAllowOverlap !== this.preTextStyle.textAllowOverlap\n ) {\n this.reBuildModel();\n return true;\n }\n return false;\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layer.off('remapping', this.buildModels);\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\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 { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'textOffsets',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_textOffsets',\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 ) => {\n return [vertex[5], vertex[6]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 12 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'textUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_tex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n private textExtent(): [[number, number], [number, number]] {\n const bounds = this.mapService.getBounds();\n return padBounds(bounds, 0.5);\n }\n /**\n * 生成文字纹理(生成文字纹理字典)\n */\n private initTextFont() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n for (const char of shape) {\n // 去重\n if (characterSet.indexOf(char) === -1) {\n characterSet.push(char);\n }\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: false,\n });\n }\n\n /**\n * 生成 iconfont 纹理字典\n */\n private initIconFontTex() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = `${shape}`;\n if (characterSet.indexOf(shape) === -1) {\n characterSet.push(shape);\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: true,\n });\n }\n\n /**\n * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)\n */\n private generateGlyphLayout(iconfont: boolean) {\n // TODO:更新文字布局\n const { mapping } = this.fontService;\n const {\n spacing = 2,\n textAnchor = 'center',\n // textOffset,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n\n this.glyphInfo = data.map((feature: IEncodeFeature) => {\n const { shape = '', id, size = 1, textOffset = [0, 0] } = feature;\n\n const shaping = shapeText(\n shape.toString(),\n mapping,\n // @ts-ignore\n size,\n textAnchor,\n 'left',\n spacing,\n textOffset,\n iconfont,\n );\n const glyphQuads = getGlyphQuads(shaping, textOffset, false);\n feature.shaping = shaping;\n feature.glyphQuads = glyphQuads;\n // feature.centroid = calculteCentroid(coordinates);\n\n feature.centroid = calculateCentroid(feature.coordinates);\n\n // 此时地图高德2.0 originCentroid == centroid\n feature.originCentroid =\n feature.version === 'GAODE2.x'\n ? calculateCentroid(feature.originCoordinates)\n : (feature.originCentroid = feature.centroid);\n\n this.glyphInfoMap[id as number] = {\n shaping,\n glyphQuads,\n centroid: calculateCentroid(feature.coordinates),\n };\n return feature;\n });\n }\n /**\n * 文字避让 depend on originCentorid\n */\n private filterGlyphs() {\n const {\n padding = [4, 4],\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (textAllowOverlap) {\n // 如果允许文本覆盖\n // this.layer.setEncodedData(this.glyphInfo);\n return;\n }\n this.glyphInfoMap = {};\n this.currentZoom = this.mapService.getZoom();\n this.extent = this.textExtent();\n const { width, height } = this.rendererService.getViewportSize();\n const collisionIndex = new CollisionIndex(width, height);\n const filterData = this.glyphInfo.filter((feature: IEncodeFeature) => {\n const { shaping, id = 0 } = feature;\n // const centroid = feature.centroid as [number, number];\n // const centroid = feature.originCentroid as [number, number];\n const centroid = (feature.version === 'GAODE2.x'\n ? feature.originCentroid\n : feature.centroid) as [number, number];\n const size = feature.size as number;\n const fontScale: number = size / 24;\n const pixels = this.mapService.lngLatToContainer(centroid);\n const { box } = collisionIndex.placeCollisionBox({\n x1: shaping.left * fontScale - padding[0],\n x2: shaping.right * fontScale + padding[0],\n y1: shaping.top * fontScale - padding[1],\n y2: shaping.bottom * fontScale + padding[1],\n anchorPointX: pixels.x,\n anchorPointY: pixels.y,\n });\n if (box && box.length) {\n // TODO:featureIndex\n collisionIndex.insertCollisionBox(box, id);\n return true;\n } else {\n return false;\n }\n });\n filterData.forEach((item) => {\n // @ts-ignore\n this.glyphInfoMap[item.id as number] = item;\n });\n // this.layer.setEncodedData(filterData);\n }\n /**\n * 初始化文字布局\n */\n private initGlyph() {\n const { iconfont = false } = this.layer.getLayerConfig();\n // 1.生成文字纹理(或是生成 iconfont)\n iconfont ? this.initIconFontTex() : this.initTextFont();\n // this.initTextFont();\n\n // 2.生成文字布局\n this.generateGlyphLayout(iconfont);\n }\n /**\n * 更新文字纹理\n */\n private updateTexture() {\n const { createTexture2D } = this.rendererService;\n const { canvas } = this.fontService;\n this.textureHeight = canvas.height;\n if (this.texture) {\n this.texture.destroy();\n }\n\n this.texture = createTexture2D({\n data: canvas,\n mag: gl.LINEAR,\n min: gl.LINEAR,\n width: canvas.width,\n height: canvas.height,\n });\n }\n\n private reBuildModel() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.filterGlyphs();\n this.layer.models = [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n}\n"],"file":"text.js"}
1
+ {"version":3,"sources":["../../../src/point/models/text.ts"],"names":["AttributeType","gl","boundsContains","getMask","padBounds","BaseModel","CollisionIndex","calculateCentroid","getGlyphQuads","shapeText","TextTriangulation","feature","that","id","vertices","indices","glyphInfoMap","size","centroid","coord","length","glyphQuads","forEach","quad","index","push","tex","x","y","height","tl","width","tr","br","bl","TextModel","layer","getLayerConfig","mask","maskInside","initGlyph","updateTexture","filterGlyphs","reBuildModel","buildLayerModel","moduleName","vertexShader","textVert","fragmentShader","textFrag","triangulation","bind","depth","enable","blend","getBlend","stencil","opacity","stroke","strokeWidth","textAnchor","textAllowOverlap","halo","gamma","raisingHeight","fontService","canvas","mapping","Object","keys","textCount","preTextStyle","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","Number","u_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_sdf_map","texture","u_halo_blur","u_gamma_scale","u_sdf_map_size","on","buildModels","extent","textExtent","zoom","mapService","getZoom","getBounds","flag","Math","abs","currentZoom","destroy","off","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","rotate","Array","isArray","STATIC_DRAW","bounds","fontWeight","fontFamily","characterSet","item","shape","toString","char","indexOf","setFontOptions","iconfont","spacing","glyphInfo","map","textOffset","shaping","coordinates","originCentroid","version","originCoordinates","padding","rendererService","getViewportSize","collisionIndex","filterData","filter","fontScale","pixels","lngLatToContainer","placeCollisionBox","x1","left","x2","right","y1","top","y2","bottom","anchorPointX","anchorPointY","box","insertCollisionBox","initIconFontTex","initTextFont","generateGlyphLayout","textureHeight","mag","LINEAR","min","models"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAOO,eAPP;AAQA,SAASC,cAAT,EAAyBC,OAAzB,EAAkCC,SAAlC,QAAmD,gBAAnD;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,OAAOC,cAAP,MAA2B,6BAA3B;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AACA,SACEC,aADF,EAGEC,SAHF,QAIO,2BAJP;;;AAQA,OAAO,SAASC,iBAAT,CAA2BC,OAA3B,EAAoD;AAEzD,MAAMC,IAAI,GAAG,IAAb;AACA,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAnB;AACA,MAAMC,QAAkB,GAAG,EAA3B;AACA,MAAMC,OAAiB,GAAG,EAA1B;;AAEA,MAAI,CAACH,IAAI,CAACI,YAAN,IAAsB,CAACJ,IAAI,CAACI,YAAL,CAAkBH,EAAlB,CAA3B,EAAkD;AAChD,WAAO;AACLC,MAAAA,QAAQ,EAAE,EADL;AAELC,MAAAA,OAAO,EAAE,EAFJ;AAGLE,MAAAA,IAAI,EAAE;AAHD,KAAP;AAKD;;AACD,MAAMC,QAAQ,GAAGN,IAAI,CAACI,YAAL,CAAkBH,EAAlB,EAAsBK,QAAvC;AACA,MAAMC,KAAK,GACTD,QAAQ,CAACE,MAAT,KAAoB,CAApB,GAAwB,CAACF,QAAQ,CAAC,CAAD,CAAT,EAAcA,QAAQ,CAAC,CAAD,CAAtB,EAA2B,CAA3B,CAAxB,GAAwDA,QAD1D;AAEAN,EAAAA,IAAI,CA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,UAFF;AAAA,UAEEA,UAFF,iCAEe,IAFf;;AAIA,WAAKG,YAAL;AACA,WAAKN,KAAL,CAAWkJ,MAAX,GAAoB,CAClB,KAAKlJ,KAAL,CAAWQ,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,WADa;AAEzBC,QAAAA,YAAY,EAAEC,QAFW;AAGzBC,QAAAA,cAAc,EAAEC,QAHS;AAIzBC,QAAAA,aAAa,EAAExC,iBAAiB,CAACyC,IAAlB,CAAuB,IAAvB,CAJU;AAKzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EANkB;AAOzBC,QAAAA,OAAO,EAAErD,OAAO,CAACmC,IAAD,EAAOC,UAAP;AAPS,OAA3B,CADkB,CAApB;AAWD;;;;EAncoClC,S;;SAAlB8B,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { boundsContains, getMask, padBounds } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport CollisionIndex from '../../utils/collision-index';\nimport { calculateCentroid } from '../../utils/geo';\nimport {\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../../utils/symbol-layout';\nimport textFrag from '../shaders/text_frag.glsl';\nimport textVert from '../shaders/text_vert.glsl';\n\nexport function TextTriangulation(feature: IEncodeFeature) {\n // @ts-ignore\n const that = this as TextModel;\n const id = feature.id as number;\n const vertices: number[] = [];\n const indices: number[] = [];\n\n if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {\n return {\n vertices: [], // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices: [],\n size: 7,\n };\n }\n const centroid = that.glyphInfoMap[id].centroid as number[]; // 计算中心点\n const coord =\n centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;\n that.glyphInfoMap[id].glyphQuads.forEach(\n (quad: IGlyphQuad, index: number) => {\n vertices.push(\n ...coord,\n quad.tex.x,\n quad.tex.y + quad.tex.height,\n quad.tl.x,\n quad.tl.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y + quad.tex.height,\n quad.tr.x,\n quad.tr.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y,\n quad.br.x,\n quad.br.y,\n ...coord,\n quad.tex.x,\n quad.tex.y,\n quad.bl.x,\n quad.bl.y,\n );\n indices.push(\n 0 + index * 4,\n 1 + index * 4,\n 2 + index * 4,\n 2 + index * 4,\n 3 + index * 4,\n 0 + index * 4,\n );\n },\n );\n return {\n vertices, // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices,\n size: 7,\n };\n}\n\nexport default class TextModel extends BaseModel {\n public glyphInfo: IEncodeFeature[];\n public glyphInfoMap: {\n [key: string]: {\n shaping: any;\n glyphQuads: IGlyphQuad[];\n centroid: number[];\n };\n } = {};\n private texture: ITexture2D;\n private currentZoom: number = -1;\n private extent: [[number, number], [number, number]];\n private textureHeight: number = 0;\n private textCount: number = 0;\n private preTextStyle: Partial<IPointLayerStyleOptions> = {};\n public getUninforms(): IModelUniform {\n const {\n opacity = 1.0,\n stroke = '#fff',\n strokeWidth = 0,\n textAnchor = 'center',\n textAllowOverlap = false,\n halo = 0.5,\n gamma = 2.0,\n raisingHeight = 0,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { canvas, mapping } = this.fontService;\n if (Object.keys(mapping).length !== this.textCount) {\n this.updateTexture();\n this.textCount = Object.keys(mapping).length;\n }\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeWidth,\n stroke,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n strokeWidth,\n stroke,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_raisingHeight: Number(raisingHeight),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n\n u_sdf_map: this.texture,\n u_halo_blur: halo,\n u_gamma_scale: gamma,\n u_sdf_map_size: [canvas.width, canvas.height],\n };\n }\n\n public initModels(): IModel[] {\n this.layer.on('remapping', this.buildModels);\n this.extent = this.textExtent();\n const {\n textAnchor = 'center',\n textAllowOverlap = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n return this.buildModels();\n }\n\n public buildModels = () => {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.initGlyph();\n this.updateTexture();\n this.filterGlyphs();\n this.reBuildModel();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n };\n public needUpdate() {\n const {\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n // textAllowOverlap 发生改变\n const zoom = this.mapService.getZoom();\n const extent = this.mapService.getBounds();\n const flag = boundsContains(this.extent, extent);\n // 文本不能压盖则进行过滤\n if (\n (!textAllowOverlap && (Math.abs(this.currentZoom - zoom) > 1 || !flag)) ||\n textAllowOverlap !== this.preTextStyle.textAllowOverlap\n ) {\n this.reBuildModel();\n return true;\n }\n return false;\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layer.off('remapping', this.buildModels);\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\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 { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'textOffsets',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_textOffsets',\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 ) => {\n return [vertex[5], vertex[6]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 12 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'textUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_tex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n private textExtent(): [[number, number], [number, number]] {\n const bounds = this.mapService.getBounds();\n return padBounds(bounds, 0.5);\n }\n /**\n * 生成文字纹理(生成文字纹理字典)\n */\n private initTextFont() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n for (const char of shape) {\n // 去重\n if (characterSet.indexOf(char) === -1) {\n characterSet.push(char);\n }\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: false,\n });\n }\n\n /**\n * 生成 iconfont 纹理字典\n */\n private initIconFontTex() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = `${shape}`;\n if (characterSet.indexOf(shape) === -1) {\n characterSet.push(shape);\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: true,\n });\n }\n\n /**\n * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)\n */\n private generateGlyphLayout(iconfont: boolean) {\n // TODO:更新文字布局\n const { mapping } = this.fontService;\n const {\n spacing = 2,\n textAnchor = 'center',\n // textOffset,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n\n this.glyphInfo = data.map((feature: IEncodeFeature) => {\n const { shape = '', id, size = 1, textOffset = [0, 0] } = feature;\n\n const shaping = shapeText(\n shape.toString(),\n mapping,\n // @ts-ignore\n size,\n textAnchor,\n 'left',\n spacing,\n textOffset,\n iconfont,\n );\n const glyphQuads = getGlyphQuads(shaping, textOffset, false);\n feature.shaping = shaping;\n feature.glyphQuads = glyphQuads;\n // feature.centroid = calculteCentroid(coordinates);\n\n feature.centroid = calculateCentroid(feature.coordinates);\n\n // 此时地图高德2.0 originCentroid == centroid\n feature.originCentroid =\n feature.version === 'GAODE2.x'\n ? calculateCentroid(feature.originCoordinates)\n : (feature.originCentroid = feature.centroid);\n\n this.glyphInfoMap[id as number] = {\n shaping,\n glyphQuads,\n centroid: calculateCentroid(feature.coordinates),\n };\n return feature;\n });\n }\n /**\n * 文字避让 depend on originCentorid\n */\n private filterGlyphs() {\n const {\n padding = [4, 4],\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (textAllowOverlap) {\n // 如果允许文本覆盖\n // this.layer.setEncodedData(this.glyphInfo);\n return;\n }\n this.glyphInfoMap = {};\n this.currentZoom = this.mapService.getZoom();\n this.extent = this.textExtent();\n const { width, height } = this.rendererService.getViewportSize();\n const collisionIndex = new CollisionIndex(width, height);\n const filterData = this.glyphInfo.filter((feature: IEncodeFeature) => {\n const { shaping, id = 0 } = feature;\n // const centroid = feature.centroid as [number, number];\n // const centroid = feature.originCentroid as [number, number];\n const centroid = (feature.version === 'GAODE2.x'\n ? feature.originCentroid\n : feature.centroid) as [number, number];\n const size = feature.size as number;\n const fontScale: number = size / 24;\n const pixels = this.mapService.lngLatToContainer(centroid);\n const { box } = collisionIndex.placeCollisionBox({\n x1: shaping.left * fontScale - padding[0],\n x2: shaping.right * fontScale + padding[0],\n y1: shaping.top * fontScale - padding[1],\n y2: shaping.bottom * fontScale + padding[1],\n anchorPointX: pixels.x,\n anchorPointY: pixels.y,\n });\n if (box && box.length) {\n // TODO:featureIndex\n collisionIndex.insertCollisionBox(box, id);\n return true;\n } else {\n return false;\n }\n });\n filterData.forEach((item) => {\n // @ts-ignore\n this.glyphInfoMap[item.id as number] = item;\n });\n // this.layer.setEncodedData(filterData);\n }\n /**\n * 初始化文字布局\n */\n private initGlyph() {\n const { iconfont = false } = this.layer.getLayerConfig();\n // 1.生成文字纹理(或是生成 iconfont)\n iconfont ? this.initIconFontTex() : this.initTextFont();\n // this.initTextFont();\n\n // 2.生成文字布局\n this.generateGlyphLayout(iconfont);\n }\n /**\n * 更新文字纹理\n */\n private updateTexture() {\n const { createTexture2D } = this.rendererService;\n const { canvas } = this.fontService;\n this.textureHeight = canvas.height;\n if (this.texture) {\n this.texture.destroy();\n }\n\n this.texture = createTexture2D({\n data: canvas,\n mag: gl.LINEAR,\n min: gl.LINEAR,\n width: canvas.width,\n height: canvas.height,\n });\n }\n\n private reBuildModel() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.filterGlyphs();\n this.layer.models = [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n}\n"],"file":"text.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType","CanvasUpdateType"],"mappings":";;;;;;IAIYA,a;;;WAAAA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a;;IAuHAC,gB;;;WAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,gCAAAA,gB","sourcesContent":["import { IMapService } from '@antv/l7-core';\nimport { IColorRamp } from '@antv/l7-utils';\nimport { styleOffset, styleSingle } from '../core/BaseModel';\nimport { anchorType } from '../utils/symbol-layout';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n\n mask?: boolean; // 可选参数 时候允许蒙层\n maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部\n}\n\nexport interface IPointLayerStyleOptions {\n opacity: number;\n strokeOpacity: number;\n strokeWidth: number;\n stroke: string;\n\n textOffset?: [number, number];\n textAnchor?: anchorType;\n spacing?: number;\n padding?: [number, number];\n halo?: number;\n gamma?: number;\n fontWeight?: string;\n fontFamily?: string;\n textAllowOverlap?: boolean;\n\n // cylinder\n pickLight?: boolean;\n depth?: boolean;\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n opacityLinear?: {\n enable: boolean;\n dir: string;\n };\n lightEnable: boolean;\n heightfixed?: boolean; // 圆柱体高度是否固定(不随 zoom 发生变化)\n\n offsets?: styleOffset;\n blend?: string;\n unit?: string;\n mask?: boolean;\n maskInside?: boolean;\n\n rotation?: number; // angle\n speed?: number;\n}\n\nexport interface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n\n raisingHeight?: number; // 挤出几何体抬升高度\n heightfixed?: boolean; // 挤出几何体高度是否固定(不随 zoom 发生变化)\n\n pickLight: boolean;\n mask?: boolean;\n maskInside?: boolean;\n\n // water\n waterTexture?: string;\n speed?: number;\n // ocean\n watercolor?: string;\n watercolor2?: string;\n}\n\nexport interface IImageLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IGeometryLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n\n mapTexture?: string;\n terrainTexture?: string;\n\n // planeGeometry\n center?: [number, number];\n width?: number;\n height?: number;\n\n widthSegments?: number;\n heightSegments?: number;\n\n terrainClipHeight?: number;\n rgb2height?: (r: number, g: number, b: number) => number;\n}\n\nexport enum CanvasUpdateType {\n 'ALWAYS' = 'always',\n 'DRAGEND' = 'dragend',\n}\n\nexport interface IDrawingOnCanvas {\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n mapService: IMapService;\n size: [number, number];\n}\nexport interface ICanvasLayerStyleOptions {\n zIndex: number;\n update: CanvasUpdateType | string;\n drawingOnCanvas: (option: IDrawingOnCanvas) => void;\n}\n\nexport interface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n\n coverage?: number;\n}\n\nexport interface IRasterLayerStyleOptions {\n opacity: number;\n domain: [number, number];\n noDataValue: number;\n clampLow: boolean;\n clampHigh: boolean;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n}\n"],"file":"interface.js"}
1
+ {"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType","CanvasUpdateType"],"mappings":";;;;;;IAIYA,a;;;WAAAA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a;;IA0HAC,gB;;;WAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,gCAAAA,gB","sourcesContent":["import { IMapService } from '@antv/l7-core';\nimport { IColorRamp } from '@antv/l7-utils';\nimport { styleOffset, styleSingle } from '../core/BaseModel';\nimport { anchorType } from '../utils/symbol-layout';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n raisingHeight?: number; // 线图层抬升高度\n\n mask?: boolean; // 可选参数 时候允许蒙层\n maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部\n}\n\nexport interface IPointLayerStyleOptions {\n opacity: number;\n strokeOpacity: number;\n strokeWidth: number;\n stroke: string;\n\n textOffset?: [number, number];\n textAnchor?: anchorType;\n spacing?: number;\n padding?: [number, number];\n halo?: number;\n gamma?: number;\n fontWeight?: string;\n fontFamily?: string;\n textAllowOverlap?: boolean;\n\n raisingHeight?: number; // 线图层抬升高度\n\n // cylinder\n pickLight?: boolean;\n depth?: boolean;\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n opacityLinear?: {\n enable: boolean;\n dir: string;\n };\n lightEnable: boolean;\n heightfixed?: boolean; // 圆柱体高度是否固定(不随 zoom 发生变化)\n\n offsets?: styleOffset;\n blend?: string;\n unit?: string;\n mask?: boolean;\n maskInside?: boolean;\n\n rotation?: number; // angle\n speed?: number;\n}\n\nexport interface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n\n raisingHeight?: number; // 挤出几何体抬升高度\n heightfixed?: boolean; // 挤出几何体高度是否固定(不随 zoom 发生变化)\n\n pickLight: boolean;\n mask?: boolean;\n maskInside?: boolean;\n\n // water\n waterTexture?: string;\n speed?: number;\n // ocean\n watercolor?: string;\n watercolor2?: string;\n}\n\nexport interface IImageLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IGeometryLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n\n mapTexture?: string;\n terrainTexture?: string;\n\n // planeGeometry\n center?: [number, number];\n width?: number;\n height?: number;\n\n widthSegments?: number;\n heightSegments?: number;\n\n terrainClipHeight?: number;\n rgb2height?: (r: number, g: number, b: number) => number;\n}\n\nexport enum CanvasUpdateType {\n 'ALWAYS' = 'always',\n 'DRAGEND' = 'dragend',\n}\n\nexport interface IDrawingOnCanvas {\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n mapService: IMapService;\n size: [number, number];\n}\nexport interface ICanvasLayerStyleOptions {\n zIndex: number;\n update: CanvasUpdateType | string;\n drawingOnCanvas: (option: IDrawingOnCanvas) => void;\n}\n\nexport interface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n\n coverage?: number;\n}\n\nexport interface IRasterLayerStyleOptions {\n opacity: number;\n domain: [number, number];\n noDataValue: number;\n clampLow: boolean;\n clampHigh: boolean;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n}\n"],"file":"interface.js"}
@@ -38,7 +38,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
38
38
  var line_dash_frag = "#define LineTypeSolid 0.0\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n // dash line\n \n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
39
39
  var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y), 1.0));\n } else {\n float lineHeight = a_Size.y;\n \n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
40
40
  var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying vec2 v_iconMapUV;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + animateSpeed);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n \n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = styleMappingMat[3].a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth/2.0;\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) {\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
41
- var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance;; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
41
+ var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_Distance / a_Total_Distance;; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n // project_pos.z += u_raisingHeight;\n // if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n // project_pos.z += u_raisingHeight * mapboxZoomScale;\n // }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y) + h * 0.2 + u_raisingHeight, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n // h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n } else {\n h += u_raisingHeight;\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
42
42
  var linear_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
43
43
  var lineStyleObj = {
44
44
  solid: 0.0,
@@ -108,7 +108,9 @@ var LineModel = function (_BaseModel) {
108
108
  _ref$borderWidth = _ref.borderWidth,
109
109
  borderWidth = _ref$borderWidth === void 0 ? 0.0 : _ref$borderWidth,
110
110
  _ref$borderColor = _ref.borderColor,
111
- borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor;
111
+ borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
112
+ _ref$raisingHeight = _ref.raisingHeight,
113
+ raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight;
112
114
 
113
115
  if (dashArray.length === 2) {
114
116
  dashArray.push(0, 0);
@@ -175,7 +177,8 @@ var LineModel = function (_BaseModel) {
175
177
  u_linearColor: useLinearColor,
176
178
  u_sourceColor: sourceColorArr,
177
179
  u_targetColor: targetColorArr,
178
- u_vertexScale: vertexHeightScale
180
+ u_vertexScale: vertexHeightScale,
181
+ u_raisingHeight: Number(raisingHeight)
179
182
  };
180
183
  }
181
184
  }, {
@@ -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","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineTriangulation","primitive","TRIANGLES","blend","getBlend","depth","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAYA;;AAEA;;AAEA;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;gGA0TK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MA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,YAAAA,IAAI,EAAE,EAHA;AAIN6C,YAAAA,IAAI,EAAEvC,WAAGwC;AAJH,WAFE;AAQV4D,UAAAA,IAAI,EAAE,CARI;AASV3G,UAAAA,MAAM,EAAE,gBACN4G,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMK,OAAO,GAAG,MAAI,CAAClH,WAAL,CAAiBmH,UAAjB,EAAhB;;AACA,gBAAQtH,OAAR,GAAoB6G,OAApB,CAAQ7G,OAAR;;AACA,wBAAiBqH,OAAO,CAACrH,OAAD,CAAP,IAA8B;AAAEuH,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;;;EAxToCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
1
+ {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","raisingHeight","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","u_raisingHeight","Number","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","LineTriangulation","primitive","TRIANGLES","blend","getBlend","depth","enable","stencil","line_dash_frag","line_dash_vert","linear_line_frag","line_vert","line_frag","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAYA;;AAEA;;AAEA;;;;;;;;;;;AAUA,IAAMA,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;gGA4TK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEC,WAAGC,OAFqB;AAG7BC,QAAAA,GAAG,EAAEF,WAAGC,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKV,WAAL,CAAiBW,YAAjB,IAAiC;AANZ,OAAD,CAA9B;AAQD,K;;;;;;WA3UD,wBAAqC;AACnC,iBAaI,KAAKT,KAAL,CAAWU,cAAX,EAbJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,WAFF,QAEEA,WAFF;AAAA,UA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AAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA1ToCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n// dash line shader\nimport line_dash_frag from '../shaders/dash/line_dash_frag.glsl';\nimport line_dash_vert from '../shaders/dash/line_dash_vert.glsl';\n// basic line shader\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\n// other function shaders\nimport linear_line_frag from '../shaders/linear/line_linear_frag.glsl';\n\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n raisingHeight = 0,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n return [\n this.layer.buildLayerModel({\n moduleName: 'line' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n const {\n sourceColor,\n targetColor,\n lineType,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (lineType === 'dash') {\n return {\n frag: line_dash_frag,\n vert: line_dash_vert,\n type: 'dash',\n };\n }\n\n if (sourceColor && targetColor) {\n // 分离 linear 功能\n return {\n frag: linear_line_frag,\n vert: line_vert,\n type: 'linear',\n };\n } else {\n return {\n frag: line_frag,\n vert: line_vert,\n type: 'normal',\n };\n }\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"line.js"}
@@ -49,7 +49,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
49
49
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
50
50
 
51
51
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
52
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\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_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\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 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 // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
52
+ var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\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_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\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 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 // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
53
53
 
54
54
  function TextTriangulation(feature) {
55
55
  var that = this;
@@ -148,7 +148,9 @@ var TextModel = function (_BaseModel) {
148
148
  _ref2$halo = _ref2.halo,
149
149
  halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
150
150
  _ref2$gamma = _ref2.gamma,
151
- gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma;
151
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
152
+ _ref2$raisingHeight = _ref2.raisingHeight,
153
+ raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
152
154
 
153
155
  var _this$fontService = this.fontService,
154
156
  canvas = _this$fontService.canvas,
@@ -202,6 +204,7 @@ var TextModel = function (_BaseModel) {
202
204
  return {
203
205
  u_dataTexture: this.dataTexture,
204
206
  u_cellTypeLayout: this.getCellTypeLayout(),
207
+ u_raisingHeight: Number(raisingHeight),
205
208
  u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
206
209
  u_stroke_width: (0, _isNumber2.default)(strokeWidth) ? strokeWidth : 0.0,
207
210
  u_stroke_color: this.getStrokeColor(stroke),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/text.ts"],"names":["TextTriangulation","feature","that","id","vertices","indices","glyphInfoMap","size","centroid","coord","length","glyphQuads","forEach","quad","index","push","tex","x","y","height","tl","width","tr","br","bl","TextModel","layer","getLayerConfig","mask","maskInside","initGlyph","updateTexture","filterGlyphs","reBuildModel","buildLayerModel","moduleName","vertexShader","textVert","fragmentShader","textFrag","triangulation","bind","depth","enable","blend","getBlend","stencil","opacity","stroke","strokeWidth","textAnchor","textAllowOverlap","halo","gamma","fontService","canvas","mapping","Object","keys","textCount","preTextStyle","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","rowCount","dataTexture","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_sdf_map","texture","u_halo_blur","u_gamma_scale","u_sdf_map_size","on","buildModels","extent","textExtent","zoom","mapService","getZoom","getBounds","flag","Math","abs","currentZoom","destroy","off","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","rotate","Array","isArray","STATIC_DRAW","bounds","fontWeight","fontFamily","characterSet","item","shape","toString","char","indexOf","setFontOptions","iconfont","spacing","glyphInfo","map","textOffset","shaping","coordinates","originCentroid","version","originCoordinates","padding","rendererService","getViewportSize","collisionIndex","CollisionIndex","filterData","filter","fontScale","pixels","lngLatToContainer","placeCollisionBox","x1","left","x2","right","y1","top","y2","bottom","anchorPointX","anchorPointY","box","insertCollisionBox","initIconFontTex","initTextFont","generateGlyphLayout","textureHeight","mag","LINEAR","min","models","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;AAQO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoD;AAEzD,MAAMC,IAAI,GAAG,IAAb;AACA,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AFqB;AAG7BC,QAAAA,GAAG,EAAEhG,WAAG+F,MAHqB;AAI7BrJ,QAAAA,KAAK,EAAEkC,MAAM,CAAClC,KAJe;AAK7BF,QAAAA,MAAM,EAAEoC,MAAM,CAACpC;AALc,OAAD,CAA9B;AAOD;;;WAED,wBAAuB;AACrB,kBAGI,KAAKO,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEC,IADF;AAAA,UACEA,IADF,2BACS,KADT;AAAA,mCAEEC,UAFF;AAAA,UAEEA,UAFF,iCAEe,IAFf;;AAIA,WAAKG,YAAL;AACA,WAAKN,KAAL,CAAWkJ,MAAX,GAAoB,CAClB,KAAKlJ,KAAL,CAAWQ,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,WADa;AAEzBC,QAAAA,YAAY,EAAEC,QAFW;AAGzBC,QAAAA,cAAc,EAAEC,QAHS;AAIzBC,QAAAA,aAAa,EAAExC,iBAAiB,CAACyC,IAAlB,CAAuB,IAAvB,CAJU;AAKzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EANkB;AAOzBC,QAAAA,OAAO,EAAE,sBAAQlB,IAAR,EAAcC,UAAd;AAPgB,OAA3B,CADkB,CAApB;AAWD;;;EAjcoCgJ,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { boundsContains, getMask, padBounds } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport CollisionIndex from '../../utils/collision-index';\nimport { calculateCentroid } from '../../utils/geo';\nimport {\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../../utils/symbol-layout';\nimport textFrag from '../shaders/text_frag.glsl';\nimport textVert from '../shaders/text_vert.glsl';\n\nexport function TextTriangulation(feature: IEncodeFeature) {\n // @ts-ignore\n const that = this as TextModel;\n const id = feature.id as number;\n const vertices: number[] = [];\n const indices: number[] = [];\n\n if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {\n return {\n vertices: [], // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices: [],\n size: 7,\n };\n }\n const centroid = that.glyphInfoMap[id].centroid as number[]; // 计算中心点\n const coord =\n centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;\n that.glyphInfoMap[id].glyphQuads.forEach(\n (quad: IGlyphQuad, index: number) => {\n vertices.push(\n ...coord,\n quad.tex.x,\n quad.tex.y + quad.tex.height,\n quad.tl.x,\n quad.tl.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y + quad.tex.height,\n quad.tr.x,\n quad.tr.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y,\n quad.br.x,\n quad.br.y,\n ...coord,\n quad.tex.x,\n quad.tex.y,\n quad.bl.x,\n quad.bl.y,\n );\n indices.push(\n 0 + index * 4,\n 1 + index * 4,\n 2 + index * 4,\n 2 + index * 4,\n 3 + index * 4,\n 0 + index * 4,\n );\n },\n );\n return {\n vertices, // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices,\n size: 7,\n };\n}\n\nexport default class TextModel extends BaseModel {\n public glyphInfo: IEncodeFeature[];\n public glyphInfoMap: {\n [key: string]: {\n shaping: any;\n glyphQuads: IGlyphQuad[];\n centroid: number[];\n };\n } = {};\n private texture: ITexture2D;\n private currentZoom: number = -1;\n private extent: [[number, number], [number, number]];\n private textureHeight: number = 0;\n private textCount: number = 0;\n private preTextStyle: Partial<IPointLayerStyleOptions> = {};\n public getUninforms(): IModelUniform {\n const {\n opacity = 1.0,\n stroke = '#fff',\n strokeWidth = 0,\n textAnchor = 'center',\n textAllowOverlap = false,\n halo = 0.5,\n gamma = 2.0,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { canvas, mapping } = this.fontService;\n if (Object.keys(mapping).length !== this.textCount) {\n this.updateTexture();\n this.textCount = Object.keys(mapping).length;\n }\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeWidth,\n stroke,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n strokeWidth,\n stroke,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n\n u_sdf_map: this.texture,\n u_halo_blur: halo,\n u_gamma_scale: gamma,\n u_sdf_map_size: [canvas.width, canvas.height],\n };\n }\n\n public initModels(): IModel[] {\n this.layer.on('remapping', this.buildModels);\n this.extent = this.textExtent();\n const {\n textAnchor = 'center',\n textAllowOverlap = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n return this.buildModels();\n }\n\n public buildModels = () => {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.initGlyph();\n this.updateTexture();\n this.filterGlyphs();\n this.reBuildModel();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n };\n public needUpdate() {\n const {\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n // textAllowOverlap 发生改变\n const zoom = this.mapService.getZoom();\n const extent = this.mapService.getBounds();\n const flag = boundsContains(this.extent, extent);\n // 文本不能压盖则进行过滤\n if (\n (!textAllowOverlap && (Math.abs(this.currentZoom - zoom) > 1 || !flag)) ||\n textAllowOverlap !== this.preTextStyle.textAllowOverlap\n ) {\n this.reBuildModel();\n return true;\n }\n return false;\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layer.off('remapping', this.buildModels);\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\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 { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'textOffsets',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_textOffsets',\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 ) => {\n return [vertex[5], vertex[6]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 12 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'textUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_tex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n private textExtent(): [[number, number], [number, number]] {\n const bounds = this.mapService.getBounds();\n return padBounds(bounds, 0.5);\n }\n /**\n * 生成文字纹理(生成文字纹理字典)\n */\n private initTextFont() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n for (const char of shape) {\n // 去重\n if (characterSet.indexOf(char) === -1) {\n characterSet.push(char);\n }\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: false,\n });\n }\n\n /**\n * 生成 iconfont 纹理字典\n */\n private initIconFontTex() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = `${shape}`;\n if (characterSet.indexOf(shape) === -1) {\n characterSet.push(shape);\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: true,\n });\n }\n\n /**\n * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)\n */\n private generateGlyphLayout(iconfont: boolean) {\n // TODO:更新文字布局\n const { mapping } = this.fontService;\n const {\n spacing = 2,\n textAnchor = 'center',\n // textOffset,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n\n this.glyphInfo = data.map((feature: IEncodeFeature) => {\n const { shape = '', id, size = 1, textOffset = [0, 0] } = feature;\n\n const shaping = shapeText(\n shape.toString(),\n mapping,\n // @ts-ignore\n size,\n textAnchor,\n 'left',\n spacing,\n textOffset,\n iconfont,\n );\n const glyphQuads = getGlyphQuads(shaping, textOffset, false);\n feature.shaping = shaping;\n feature.glyphQuads = glyphQuads;\n // feature.centroid = calculteCentroid(coordinates);\n\n feature.centroid = calculateCentroid(feature.coordinates);\n\n // 此时地图高德2.0 originCentroid == centroid\n feature.originCentroid =\n feature.version === 'GAODE2.x'\n ? calculateCentroid(feature.originCoordinates)\n : (feature.originCentroid = feature.centroid);\n\n this.glyphInfoMap[id as number] = {\n shaping,\n glyphQuads,\n centroid: calculateCentroid(feature.coordinates),\n };\n return feature;\n });\n }\n /**\n * 文字避让 depend on originCentorid\n */\n private filterGlyphs() {\n const {\n padding = [4, 4],\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (textAllowOverlap) {\n // 如果允许文本覆盖\n // this.layer.setEncodedData(this.glyphInfo);\n return;\n }\n this.glyphInfoMap = {};\n this.currentZoom = this.mapService.getZoom();\n this.extent = this.textExtent();\n const { width, height } = this.rendererService.getViewportSize();\n const collisionIndex = new CollisionIndex(width, height);\n const filterData = this.glyphInfo.filter((feature: IEncodeFeature) => {\n const { shaping, id = 0 } = feature;\n // const centroid = feature.centroid as [number, number];\n // const centroid = feature.originCentroid as [number, number];\n const centroid = (feature.version === 'GAODE2.x'\n ? feature.originCentroid\n : feature.centroid) as [number, number];\n const size = feature.size as number;\n const fontScale: number = size / 24;\n const pixels = this.mapService.lngLatToContainer(centroid);\n const { box } = collisionIndex.placeCollisionBox({\n x1: shaping.left * fontScale - padding[0],\n x2: shaping.right * fontScale + padding[0],\n y1: shaping.top * fontScale - padding[1],\n y2: shaping.bottom * fontScale + padding[1],\n anchorPointX: pixels.x,\n anchorPointY: pixels.y,\n });\n if (box && box.length) {\n // TODO:featureIndex\n collisionIndex.insertCollisionBox(box, id);\n return true;\n } else {\n return false;\n }\n });\n filterData.forEach((item) => {\n // @ts-ignore\n this.glyphInfoMap[item.id as number] = item;\n });\n // this.layer.setEncodedData(filterData);\n }\n /**\n * 初始化文字布局\n */\n private initGlyph() {\n const { iconfont = false } = this.layer.getLayerConfig();\n // 1.生成文字纹理(或是生成 iconfont)\n iconfont ? this.initIconFontTex() : this.initTextFont();\n // this.initTextFont();\n\n // 2.生成文字布局\n this.generateGlyphLayout(iconfont);\n }\n /**\n * 更新文字纹理\n */\n private updateTexture() {\n const { createTexture2D } = this.rendererService;\n const { canvas } = this.fontService;\n this.textureHeight = canvas.height;\n if (this.texture) {\n this.texture.destroy();\n }\n\n this.texture = createTexture2D({\n data: canvas,\n mag: gl.LINEAR,\n min: gl.LINEAR,\n width: canvas.width,\n height: canvas.height,\n });\n }\n\n private reBuildModel() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.filterGlyphs();\n this.layer.models = [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n}\n"],"file":"text.js"}
1
+ {"version":3,"sources":["../../../src/point/models/text.ts"],"names":["TextTriangulation","feature","that","id","vertices","indices","glyphInfoMap","size","centroid","coord","length","glyphQuads","forEach","quad","index","push","tex","x","y","height","tl","width","tr","br","bl","TextModel","layer","getLayerConfig","mask","maskInside","initGlyph","updateTexture","filterGlyphs","reBuildModel","buildLayerModel","moduleName","vertexShader","textVert","fragmentShader","textFrag","triangulation","bind","depth","enable","blend","getBlend","stencil","opacity","stroke","strokeWidth","textAnchor","textAllowOverlap","halo","gamma","raisingHeight","fontService","canvas","mapping","Object","keys","textCount","preTextStyle","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","rowCount","dataTexture","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","Number","u_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_sdf_map","texture","u_halo_blur","u_gamma_scale","u_sdf_map_size","on","buildModels","extent","textExtent","zoom","mapService","getZoom","getBounds","flag","Math","abs","currentZoom","destroy","off","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","rotate","Array","isArray","STATIC_DRAW","bounds","fontWeight","fontFamily","characterSet","item","shape","toString","char","indexOf","setFontOptions","iconfont","spacing","glyphInfo","map","textOffset","shaping","coordinates","originCentroid","version","originCoordinates","padding","rendererService","getViewportSize","collisionIndex","CollisionIndex","filterData","filter","fontScale","pixels","lngLatToContainer","placeCollisionBox","x1","left","x2","right","y1","top","y2","bottom","anchorPointX","anchorPointY","box","insertCollisionBox","initIconFontTex","initTextFont","generateGlyphLayout","textureHeight","mag","LINEAR","min","models","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;AAQO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoD;AAEzD,MAAMC,IAAI,GAAG,IAAb;AACA,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAnB;AACA,MAAMC,QAAkB,GAAG,EAA3B;AACA,MAAMC,OAAiB,GAAG,EAA1B;;AAEA,MAAI,CAACH,IAAI,CAACI,YAAN,IAAsB,CAACJ,IAAI,CAACI,YAAL,CAAkBH,EAAlB,CAA3B,EAAkD;AAChD,WAAO;AACLC,MAAAA,QAAQ,E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K7BF,QAAAA,MAAM,EAAEqC,MAAM,CAACrC;AALc,OAAD,CAA9B;AAOD;;;WAED,wBAAuB;AACrB,kBAGI,KAAKO,KAAL,CAAWC,cAAX,EAHJ;AAAA,6BACEC,IADF;AAAA,UACEA,IADF,2BACS,KADT;AAAA,mCAEEC,UAFF;AAAA,UAEEA,UAFF,iCAEe,IAFf;;AAIA,WAAKG,YAAL;AACA,WAAKN,KAAL,CAAWqJ,MAAX,GAAoB,CAClB,KAAKrJ,KAAL,CAAWQ,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,WADa;AAEzBC,QAAAA,YAAY,EAAEC,QAFW;AAGzBC,QAAAA,cAAc,EAAEC,QAHS;AAIzBC,QAAAA,aAAa,EAAExC,iBAAiB,CAACyC,IAAlB,CAAuB,IAAvB,CAJU;AAKzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EANkB;AAOzBC,QAAAA,OAAO,EAAE,sBAAQlB,IAAR,EAAcC,UAAd;AAPgB,OAA3B,CADkB,CAApB;AAWD;;;EAncoCmJ,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { boundsContains, getMask, padBounds } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport CollisionIndex from '../../utils/collision-index';\nimport { calculateCentroid } from '../../utils/geo';\nimport {\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../../utils/symbol-layout';\nimport textFrag from '../shaders/text_frag.glsl';\nimport textVert from '../shaders/text_vert.glsl';\n\nexport function TextTriangulation(feature: IEncodeFeature) {\n // @ts-ignore\n const that = this as TextModel;\n const id = feature.id as number;\n const vertices: number[] = [];\n const indices: number[] = [];\n\n if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {\n return {\n vertices: [], // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices: [],\n size: 7,\n };\n }\n const centroid = that.glyphInfoMap[id].centroid as number[]; // 计算中心点\n const coord =\n centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;\n that.glyphInfoMap[id].glyphQuads.forEach(\n (quad: IGlyphQuad, index: number) => {\n vertices.push(\n ...coord,\n quad.tex.x,\n quad.tex.y + quad.tex.height,\n quad.tl.x,\n quad.tl.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y + quad.tex.height,\n quad.tr.x,\n quad.tr.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y,\n quad.br.x,\n quad.br.y,\n ...coord,\n quad.tex.x,\n quad.tex.y,\n quad.bl.x,\n quad.bl.y,\n );\n indices.push(\n 0 + index * 4,\n 1 + index * 4,\n 2 + index * 4,\n 2 + index * 4,\n 3 + index * 4,\n 0 + index * 4,\n );\n },\n );\n return {\n vertices, // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices,\n size: 7,\n };\n}\n\nexport default class TextModel extends BaseModel {\n public glyphInfo: IEncodeFeature[];\n public glyphInfoMap: {\n [key: string]: {\n shaping: any;\n glyphQuads: IGlyphQuad[];\n centroid: number[];\n };\n } = {};\n private texture: ITexture2D;\n private currentZoom: number = -1;\n private extent: [[number, number], [number, number]];\n private textureHeight: number = 0;\n private textCount: number = 0;\n private preTextStyle: Partial<IPointLayerStyleOptions> = {};\n public getUninforms(): IModelUniform {\n const {\n opacity = 1.0,\n stroke = '#fff',\n strokeWidth = 0,\n textAnchor = 'center',\n textAllowOverlap = false,\n halo = 0.5,\n gamma = 2.0,\n raisingHeight = 0,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { canvas, mapping } = this.fontService;\n if (Object.keys(mapping).length !== this.textCount) {\n this.updateTexture();\n this.textCount = Object.keys(mapping).length;\n }\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeWidth,\n stroke,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n strokeWidth,\n stroke,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_raisingHeight: Number(raisingHeight),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n\n u_sdf_map: this.texture,\n u_halo_blur: halo,\n u_gamma_scale: gamma,\n u_sdf_map_size: [canvas.width, canvas.height],\n };\n }\n\n public initModels(): IModel[] {\n this.layer.on('remapping', this.buildModels);\n this.extent = this.textExtent();\n const {\n textAnchor = 'center',\n textAllowOverlap = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n return this.buildModels();\n }\n\n public buildModels = () => {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.initGlyph();\n this.updateTexture();\n this.filterGlyphs();\n this.reBuildModel();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n };\n public needUpdate() {\n const {\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n // textAllowOverlap 发生改变\n const zoom = this.mapService.getZoom();\n const extent = this.mapService.getBounds();\n const flag = boundsContains(this.extent, extent);\n // 文本不能压盖则进行过滤\n if (\n (!textAllowOverlap && (Math.abs(this.currentZoom - zoom) > 1 || !flag)) ||\n textAllowOverlap !== this.preTextStyle.textAllowOverlap\n ) {\n this.reBuildModel();\n return true;\n }\n return false;\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layer.off('remapping', this.buildModels);\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\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 { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'textOffsets',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_textOffsets',\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 ) => {\n return [vertex[5], vertex[6]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 12 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'textUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_tex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n private textExtent(): [[number, number], [number, number]] {\n const bounds = this.mapService.getBounds();\n return padBounds(bounds, 0.5);\n }\n /**\n * 生成文字纹理(生成文字纹理字典)\n */\n private initTextFont() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n for (const char of shape) {\n // 去重\n if (characterSet.indexOf(char) === -1) {\n characterSet.push(char);\n }\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: false,\n });\n }\n\n /**\n * 生成 iconfont 纹理字典\n */\n private initIconFontTex() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = `${shape}`;\n if (characterSet.indexOf(shape) === -1) {\n characterSet.push(shape);\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: true,\n });\n }\n\n /**\n * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)\n */\n private generateGlyphLayout(iconfont: boolean) {\n // TODO:更新文字布局\n const { mapping } = this.fontService;\n const {\n spacing = 2,\n textAnchor = 'center',\n // textOffset,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const data = this.layer.getEncodedData();\n\n this.glyphInfo = data.map((feature: IEncodeFeature) => {\n const { shape = '', id, size = 1, textOffset = [0, 0] } = feature;\n\n const shaping = shapeText(\n shape.toString(),\n mapping,\n // @ts-ignore\n size,\n textAnchor,\n 'left',\n spacing,\n textOffset,\n iconfont,\n );\n const glyphQuads = getGlyphQuads(shaping, textOffset, false);\n feature.shaping = shaping;\n feature.glyphQuads = glyphQuads;\n // feature.centroid = calculteCentroid(coordinates);\n\n feature.centroid = calculateCentroid(feature.coordinates);\n\n // 此时地图高德2.0 originCentroid == centroid\n feature.originCentroid =\n feature.version === 'GAODE2.x'\n ? calculateCentroid(feature.originCoordinates)\n : (feature.originCentroid = feature.centroid);\n\n this.glyphInfoMap[id as number] = {\n shaping,\n glyphQuads,\n centroid: calculateCentroid(feature.coordinates),\n };\n return feature;\n });\n }\n /**\n * 文字避让 depend on originCentorid\n */\n private filterGlyphs() {\n const {\n padding = [4, 4],\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (textAllowOverlap) {\n // 如果允许文本覆盖\n // this.layer.setEncodedData(this.glyphInfo);\n return;\n }\n this.glyphInfoMap = {};\n this.currentZoom = this.mapService.getZoom();\n this.extent = this.textExtent();\n const { width, height } = this.rendererService.getViewportSize();\n const collisionIndex = new CollisionIndex(width, height);\n const filterData = this.glyphInfo.filter((feature: IEncodeFeature) => {\n const { shaping, id = 0 } = feature;\n // const centroid = feature.centroid as [number, number];\n // const centroid = feature.originCentroid as [number, number];\n const centroid = (feature.version === 'GAODE2.x'\n ? feature.originCentroid\n : feature.centroid) as [number, number];\n const size = feature.size as number;\n const fontScale: number = size / 24;\n const pixels = this.mapService.lngLatToContainer(centroid);\n const { box } = collisionIndex.placeCollisionBox({\n x1: shaping.left * fontScale - padding[0],\n x2: shaping.right * fontScale + padding[0],\n y1: shaping.top * fontScale - padding[1],\n y2: shaping.bottom * fontScale + padding[1],\n anchorPointX: pixels.x,\n anchorPointY: pixels.y,\n });\n if (box && box.length) {\n // TODO:featureIndex\n collisionIndex.insertCollisionBox(box, id);\n return true;\n } else {\n return false;\n }\n });\n filterData.forEach((item) => {\n // @ts-ignore\n this.glyphInfoMap[item.id as number] = item;\n });\n // this.layer.setEncodedData(filterData);\n }\n /**\n * 初始化文字布局\n */\n private initGlyph() {\n const { iconfont = false } = this.layer.getLayerConfig();\n // 1.生成文字纹理(或是生成 iconfont)\n iconfont ? this.initIconFontTex() : this.initTextFont();\n // this.initTextFont();\n\n // 2.生成文字布局\n this.generateGlyphLayout(iconfont);\n }\n /**\n * 更新文字纹理\n */\n private updateTexture() {\n const { createTexture2D } = this.rendererService;\n const { canvas } = this.fontService;\n this.textureHeight = canvas.height;\n if (this.texture) {\n this.texture.destroy();\n }\n\n this.texture = createTexture2D({\n data: canvas,\n mag: gl.LINEAR,\n min: gl.LINEAR,\n width: canvas.width,\n height: canvas.height,\n });\n }\n\n private reBuildModel() {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.filterGlyphs();\n this.layer.models = [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n}\n"],"file":"text.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.8.15",
3
+ "version": "2.8.16",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,9 +24,9 @@
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@antv/geo-coord": "^1.0.8",
27
- "@antv/l7-core": "^2.8.15",
28
- "@antv/l7-source": "^2.8.15",
29
- "@antv/l7-utils": "^2.8.15",
27
+ "@antv/l7-core": "^2.8.16",
28
+ "@antv/l7-source": "^2.8.16",
29
+ "@antv/l7-utils": "^2.8.16",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "@mapbox/martini": "^0.2.0",
32
32
  "@turf/meta": "^6.0.2",
@@ -52,7 +52,7 @@
52
52
  "@types/gl-matrix": "^2.4.5",
53
53
  "@types/lodash": "^4.14.138"
54
54
  },
55
- "gitHead": "09af464412bd421898fc23bafdd71b44790873a9",
55
+ "gitHead": "83e1bc375b5540c688c1a660e6864acc6a6763ce",
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  }