@antv/l7-layers 2.8.30 → 2.8.31
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.
|
@@ -16,12 +16,12 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
16
16
|
import { getMask, rgb2arr } from '@antv/l7-utils';
|
|
17
17
|
import BaseModel from '../../core/BaseModel';
|
|
18
18
|
import { PolygonExtrudeTriangulation } from '../../core/triangulation';
|
|
19
|
-
var polygonExtrudeFrag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n
|
|
20
|
-
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 -
|
|
21
|
-
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n// varying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n
|
|
22
|
-
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute
|
|
23
|
-
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\
|
|
24
|
-
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\
|
|
19
|
+
var polygonExtrudeFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0]; \n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\n\n if(isSide < 1.0 && u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
20
|
+
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 - isSide\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 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\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 *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
21
|
+
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n// varying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float lightWeight = styleMappingMat[3][1];\n float topU = styleMappingMat[2][2];\n float topV = styleMappingMat[2][3];\n\n float sidey = styleMappingMat[3][0];\n if(isSide < 1.0) {\n gl_FragColor = mix(u_targetColor, u_sourceColor, sidey);\n gl_FragColor.rgb *= lightWeight;\n } else {\n gl_FragColor = texture2D(u_texture, vec2(topU, topV));\n }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
22
|
+
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n// varying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 - a_Position.z(judge side by a_Position.z)\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] - u - v\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n \n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[2][2] = a_uvs[0];\n styleMappingMat[2][3] = 1.0 - a_uvs[1];\n styleMappingMat[3][0] = a_uvs[2];\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\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 *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
23
|
+
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\n\n if(isSide < 1.0 && u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n}\n";
|
|
24
|
+
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 - isSide\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 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\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 *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
25
25
|
|
|
26
26
|
var ExtrudeModel = function (_BaseModel) {
|
|
27
27
|
_inherits(ExtrudeModel, _BaseModel);
|
|
@@ -88,12 +88,14 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
var useLinearColor = 0;
|
|
91
92
|
var sourceColorArr = [1, 1, 1, 1];
|
|
92
93
|
var targetColorArr = [1, 1, 1, 1];
|
|
93
94
|
|
|
94
95
|
if (sourceColor && targetColor) {
|
|
95
96
|
sourceColorArr = rgb2arr(sourceColor);
|
|
96
97
|
targetColorArr = rgb2arr(targetColor);
|
|
98
|
+
useLinearColor = 1;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
return {
|
|
@@ -102,6 +104,7 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
102
104
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
103
105
|
u_raisingHeight: Number(raisingHeight),
|
|
104
106
|
u_opacity: _isNumber(opacity) ? opacity : 1.0,
|
|
107
|
+
u_linearColor: useLinearColor,
|
|
105
108
|
u_sourceColor: sourceColorArr,
|
|
106
109
|
u_targetColor: targetColorArr,
|
|
107
110
|
u_texture: this.texture
|
|
@@ -179,40 +182,34 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
179
182
|
}, {
|
|
180
183
|
key: "registerBuiltinAttributes",
|
|
181
184
|
value: function registerBuiltinAttributes() {
|
|
182
|
-
var
|
|
183
|
-
mapTexture = _ref4.mapTexture;
|
|
185
|
+
var bbox = this.layer.getSource().extent;
|
|
184
186
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
minLat = _bbox[1],
|
|
191
|
-
maxLng = _bbox[2],
|
|
192
|
-
maxLat = _bbox[3];
|
|
193
|
-
|
|
194
|
-
var lngLen = maxLng - minLng;
|
|
195
|
-
var latLen = maxLat - minLat;
|
|
196
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
197
|
-
name: 'uvs',
|
|
198
|
-
type: AttributeType.Attribute,
|
|
199
|
-
descriptor: {
|
|
200
|
-
name: 'a_uvs',
|
|
201
|
-
buffer: {
|
|
202
|
-
usage: gl.STATIC_DRAW,
|
|
203
|
-
data: [],
|
|
204
|
-
type: gl.FLOAT
|
|
205
|
-
},
|
|
206
|
-
size: 3,
|
|
207
|
-
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
208
|
-
var lng = vertex[0];
|
|
209
|
-
var lat = vertex[1];
|
|
210
|
-
return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
187
|
+
var _bbox = _slicedToArray(bbox, 4),
|
|
188
|
+
minLng = _bbox[0],
|
|
189
|
+
minLat = _bbox[1],
|
|
190
|
+
maxLng = _bbox[2],
|
|
191
|
+
maxLat = _bbox[3];
|
|
215
192
|
|
|
193
|
+
var lngLen = maxLng - minLng;
|
|
194
|
+
var latLen = maxLat - minLat;
|
|
195
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
196
|
+
name: 'uvs',
|
|
197
|
+
type: AttributeType.Attribute,
|
|
198
|
+
descriptor: {
|
|
199
|
+
name: 'a_uvs',
|
|
200
|
+
buffer: {
|
|
201
|
+
usage: gl.STATIC_DRAW,
|
|
202
|
+
data: [],
|
|
203
|
+
type: gl.FLOAT
|
|
204
|
+
},
|
|
205
|
+
size: 3,
|
|
206
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
207
|
+
var lng = vertex[0];
|
|
208
|
+
var lat = vertex[1];
|
|
209
|
+
return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
216
213
|
this.styleAttributeService.registerStyleAttribute({
|
|
217
214
|
name: 'normal',
|
|
218
215
|
type: AttributeType.Attribute,
|
|
@@ -253,8 +250,8 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
253
250
|
value: function loadTexture() {
|
|
254
251
|
var _this2 = this;
|
|
255
252
|
|
|
256
|
-
var
|
|
257
|
-
mapTexture =
|
|
253
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
254
|
+
mapTexture = _ref4.mapTexture;
|
|
258
255
|
|
|
259
256
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
260
257
|
this.texture = createTexture2D({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/polygon/models/extrude.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","PolygonExtrudeTriangulation","ExtrudeModel","layer","getLayerConfig","opacity","heightfixed","raisingHeight","sourceColor","targetColor","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","sourceColorArr","targetColorArr","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","u_opacity","u_sourceColor","u_targetColor","u_texture","texture","loadTexture","buildModels","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","stencil","cull","enable","face","BACK","pickLight","mapTexture","polygonExtrudeTexFrag","polygonExtrudeTexVert","polygonExtrudePickLightFrag","polygonExtrudePickLightVert","polygonExtrudeFrag","polygonExtrudeVert","destroy","bbox","getSource","extent","minLng","minLat","maxLng","maxLat","lngLen","latLen","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","lng","lat","DYNAMIC_DRAW","Array","isArray","rendererService","image","Image","crossOrigin","src","onload","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","layerService","updateLayerRenderList","renderLayers"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBA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AAR,GAA4B,KAAK0E,eAAjC,CAAQ1E,eAAR;AACA,WAAKkB,OAAL,GAAelB,eAAe,CAAC;AAC7BJ,QAAAA,MAAM,EAAE,CADqB;AAE7BD,QAAAA,KAAK,EAAE;AAFsB,OAAD,CAA9B;;AAIA,UAAI0C,UAAJ,EAAgB;AACd,YAAMsC,KAAK,GAAG,IAAIC,KAAJ,EAAd;AACAD,QAAAA,KAAK,CAACE,WAAN,GAAoB,EAApB;AACAF,QAAAA,KAAK,CAACG,GAAN,GAAYzC,UAAZ;;AAEAsC,QAAAA,KAAK,CAACI,MAAN,GAAe,YAAM;AACnB,UAAA,MAAI,CAAC7D,OAAL,GAAelB,eAAe,CAAC;AAC7BN,YAAAA,IAAI,EAAEiF,KADuB;AAE7BhF,YAAAA,KAAK,EAAEgF,KAAK,CAAChF,KAFgB;AAG7BC,YAAAA,MAAM,EAAE+E,KAAK,CAAC/E,MAHe;AAI7BoF,YAAAA,KAAK,EAAE3G,EAAE,CAAC4G,aAJmB;AAK7BC,YAAAA,KAAK,EAAE7G,EAAE,CAAC4G,aALmB;AAM7BE,YAAAA,GAAG,EAAE9G,EAAE,CAAC+G,MANqB;AAO7BC,YAAAA,GAAG,EAAEhH,EAAE,CAAC+G;AAPqB,WAAD,CAA9B;;AASA,UAAA,MAAI,CAACE,YAAL,CAAkBC,qBAAlB;;AACA,UAAA,MAAI,CAACD,YAAL,CAAkBE,YAAlB;AACD,SAZD;AAaD;AACF;;;;EAjPuChH,S;;SAArBE,Y","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport { PolygonExtrudeTriangulation } from '../../core/triangulation';\nimport polygonExtrudeFrag from '../shaders/extrude/polygon_extrude_frag.glsl';\n// extrude\nimport polygonExtrudeVert from '../shaders/extrude/polygon_extrude_vert.glsl';\nimport polygonExtrudeTexFrag from '../shaders/extrude/polygon_extrudetex_frag.glsl';\n// texture\nimport polygonExtrudeTexVert from '../shaders/extrude/polygon_extrudetex_vert.glsl';\n// extrude picking\n\nimport polygonExtrudePickLightFrag from '../shaders/extrude/polygon_extrude_picklight_frag.glsl';\nimport polygonExtrudePickLightVert from '../shaders/extrude/polygon_extrude_picklight_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n heightfixed = false,\n raisingHeight = 0,\n sourceColor,\n targetColor,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\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 // 转化渐变色\n let sourceColorArr = [1, 1, 1, 1];\n let targetColorArr = [1, 1, 1, 1];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n }\n\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_raisingHeight: Number(raisingHeight),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n u_texture: this.texture,\n };\n }\n\n public initModels(): IModel[] {\n this.loadTexture();\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PolygonExtrudeTriangulation,\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n }),\n ];\n }\n\n public getShaders() {\n const {\n pickLight,\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (mapTexture) {\n return {\n frag: polygonExtrudeTexFrag,\n vert: polygonExtrudeTexVert,\n type: 'polygonExtrudeTexture',\n };\n }\n if (pickLight) {\n return {\n frag: polygonExtrudePickLightFrag,\n vert: polygonExtrudePickLightVert,\n type: 'polygonExtrude',\n };\n } else {\n return {\n frag: polygonExtrudeFrag,\n vert: polygonExtrudeVert,\n type: 'polygonExtrude',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.texture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n if (mapTexture) {\n const bbox = this.layer.getSource().extent;\n const [minLng, minLat, maxLng, maxLat] = bbox;\n const lngLen = maxLng - minLng;\n const latLen = maxLat - minLat;\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uvs',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_uvs',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n const lng = vertex[0];\n const lat = vertex[1];\n return [\n (lng - minLng) / lngLen,\n (lat - minLat) / latLen,\n vertex[4],\n ];\n },\n },\n });\n }\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\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 = 10 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private loadTexture() {\n const {\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n if (mapTexture) {\n const image = new Image();\n image.crossOrigin = '';\n image.src = mapTexture;\n\n image.onload = () => {\n this.texture = createTexture2D({\n data: image,\n width: image.width,\n height: image.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n };\n }\n }\n}\n"],"file":"extrude.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/polygon/models/extrude.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","PolygonExtrudeTriangulation","ExtrudeModel","layer","getLayerConfig","opacity","heightfixed","raisingHeight","sourceColor","targetColor","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_texture","texture","loadTexture","buildModels","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","stencil","cull","enable","face","BACK","pickLight","mapTexture","polygonExtrudeTexFrag","polygonExtrudeTexVert","polygonExtrudePickLightFrag","polygonExtrudePickLightVert","polygonExtrudeFrag","polygonExtrudeVert","destroy","bbox","getSource","extent","minLng","minLat","maxLng","maxLat","lngLen","latLen","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","lng","lat","DYNAMIC_DRAW","Array","isArray","rendererService","image","Image","crossOrigin","src","onload","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","layerService","updateLayerRenderList","renderLayers"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAMO,eANP;AAOA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,2BAAT,QAA4C,0BAA5C;;;;;;;;IAYqBC,Y;;;;;;;;;;;;;;;;;;;;;;;WAEnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,kCAEEC,WAFF;AAAA,UAEEA,WAFF,iCAEgB,KAFhB;AAAA,oCAGEC,aAHF;AAAA,UAGEA,aAHF,mCAGkB,CAHlB;AAAA,UAIEC,WAJF,QAIEA,WAJF;AAAA,UAKEC,WALF,QAKEA,WALF;;AAQA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEN,QAAAA,OAAO,EAAP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kF,KAAK,CAAClF,KAFgB;AAG7BC,YAAAA,MAAM,EAAEiF,KAAK,CAACjF,MAHe;AAI7BsF,YAAAA,KAAK,EAAE7G,EAAE,CAAC8G,aAJmB;AAK7BC,YAAAA,KAAK,EAAE/G,EAAE,CAAC8G,aALmB;AAM7BE,YAAAA,GAAG,EAAEhH,EAAE,CAACiH,MANqB;AAO7BC,YAAAA,GAAG,EAAElH,EAAE,CAACiH;AAPqB,WAAD,CAA9B;;AASA,UAAA,MAAI,CAACE,YAAL,CAAkBC,qBAAlB;;AACA,UAAA,MAAI,CAACD,YAAL,CAAkBE,YAAlB;AACD,SAZD;AAaD;AACF;;;;EA5OuClH,S;;SAArBE,Y","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport { PolygonExtrudeTriangulation } from '../../core/triangulation';\nimport polygonExtrudeFrag from '../shaders/extrude/polygon_extrude_frag.glsl';\n// extrude\nimport polygonExtrudeVert from '../shaders/extrude/polygon_extrude_vert.glsl';\nimport polygonExtrudeTexFrag from '../shaders/extrude/polygon_extrudetex_frag.glsl';\n// texture\nimport polygonExtrudeTexVert from '../shaders/extrude/polygon_extrudetex_vert.glsl';\n// extrude picking\n\nimport polygonExtrudePickLightFrag from '../shaders/extrude/polygon_extrude_picklight_frag.glsl';\nimport polygonExtrudePickLightVert from '../shaders/extrude/polygon_extrude_picklight_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n heightfixed = false,\n raisingHeight = 0,\n sourceColor,\n targetColor,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\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 // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [1, 1, 1, 1];\n let targetColorArr = [1, 1, 1, 1];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_raisingHeight: Number(raisingHeight),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n u_texture: this.texture,\n };\n }\n\n public initModels(): IModel[] {\n this.loadTexture();\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PolygonExtrudeTriangulation,\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n }),\n ];\n }\n\n public getShaders() {\n const {\n pickLight,\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (mapTexture) {\n return {\n frag: polygonExtrudeTexFrag,\n vert: polygonExtrudeTexVert,\n type: 'polygonExtrudeTexture',\n };\n }\n if (pickLight) {\n return {\n frag: polygonExtrudePickLightFrag,\n vert: polygonExtrudePickLightVert,\n type: 'polygonExtrude',\n };\n } else {\n return {\n frag: polygonExtrudeFrag,\n vert: polygonExtrudeVert,\n type: 'polygonExtrude',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.texture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const bbox = this.layer.getSource().extent;\n const [minLng, minLat, maxLng, maxLat] = bbox;\n const lngLen = maxLng - minLng;\n const latLen = maxLat - minLat;\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uvs',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_uvs',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n const lng = vertex[0];\n const lat = vertex[1];\n return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];\n },\n },\n });\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: '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 = 10 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private loadTexture() {\n const {\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n if (mapTexture) {\n const image = new Image();\n image.crossOrigin = '';\n image.src = mapTexture;\n\n image.onload = () => {\n this.texture = createTexture2D({\n data: image,\n width: image.width,\n height: image.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n };\n }\n }\n}\n"],"file":"extrude.js"}
|
|
@@ -37,12 +37,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
37
37
|
|
|
38
38
|
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; } }
|
|
39
39
|
|
|
40
|
-
var polygonExtrudeFrag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n
|
|
41
|
-
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 -
|
|
42
|
-
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n// varying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n
|
|
43
|
-
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute
|
|
44
|
-
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\
|
|
45
|
-
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\
|
|
40
|
+
var polygonExtrudeFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0]; \n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\n\n if(isSide < 1.0 && u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
41
|
+
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 - isSide\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 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\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 *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
42
|
+
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n// varying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float lightWeight = styleMappingMat[3][1];\n float topU = styleMappingMat[2][2];\n float topV = styleMappingMat[2][3];\n\n float sidey = styleMappingMat[3][0];\n if(isSide < 1.0) {\n gl_FragColor = mix(u_targetColor, u_sourceColor, sidey);\n gl_FragColor.rgb *= lightWeight;\n } else {\n gl_FragColor = texture2D(u_texture, vec2(topU, topV));\n }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
43
|
+
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n// varying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 - a_Position.z(judge side by a_Position.z)\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] - u - v\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n \n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[2][2] = a_uvs[0];\n styleMappingMat[2][3] = 1.0 - a_uvs[1];\n styleMappingMat[3][0] = a_uvs[2];\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\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 *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
44
|
+
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\n\n if(isSide < 1.0 && u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n}\n";
|
|
45
|
+
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\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\n#pragma include \"projection\"\n#pragma include \"light\"\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 - isSide\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 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\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 *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
46
46
|
|
|
47
47
|
var ExtrudeModel = function (_BaseModel) {
|
|
48
48
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
@@ -107,12 +107,14 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
var useLinearColor = 0;
|
|
110
111
|
var sourceColorArr = [1, 1, 1, 1];
|
|
111
112
|
var targetColorArr = [1, 1, 1, 1];
|
|
112
113
|
|
|
113
114
|
if (sourceColor && targetColor) {
|
|
114
115
|
sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
|
|
115
116
|
targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
|
|
117
|
+
useLinearColor = 1;
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
return {
|
|
@@ -121,6 +123,7 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
121
123
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
122
124
|
u_raisingHeight: Number(raisingHeight),
|
|
123
125
|
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
126
|
+
u_linearColor: useLinearColor,
|
|
124
127
|
u_sourceColor: sourceColorArr,
|
|
125
128
|
u_targetColor: targetColorArr,
|
|
126
129
|
u_texture: this.texture
|
|
@@ -198,40 +201,34 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
198
201
|
}, {
|
|
199
202
|
key: "registerBuiltinAttributes",
|
|
200
203
|
value: function registerBuiltinAttributes() {
|
|
201
|
-
var
|
|
202
|
-
mapTexture = _ref4.mapTexture;
|
|
204
|
+
var bbox = this.layer.getSource().extent;
|
|
203
205
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
minLat = _bbox[1],
|
|
210
|
-
maxLng = _bbox[2],
|
|
211
|
-
maxLat = _bbox[3];
|
|
212
|
-
|
|
213
|
-
var lngLen = maxLng - minLng;
|
|
214
|
-
var latLen = maxLat - minLat;
|
|
215
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
216
|
-
name: 'uvs',
|
|
217
|
-
type: _l7Core.AttributeType.Attribute,
|
|
218
|
-
descriptor: {
|
|
219
|
-
name: 'a_uvs',
|
|
220
|
-
buffer: {
|
|
221
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
222
|
-
data: [],
|
|
223
|
-
type: _l7Core.gl.FLOAT
|
|
224
|
-
},
|
|
225
|
-
size: 3,
|
|
226
|
-
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
227
|
-
var lng = vertex[0];
|
|
228
|
-
var lat = vertex[1];
|
|
229
|
-
return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}
|
|
206
|
+
var _bbox = (0, _slicedToArray2.default)(bbox, 4),
|
|
207
|
+
minLng = _bbox[0],
|
|
208
|
+
minLat = _bbox[1],
|
|
209
|
+
maxLng = _bbox[2],
|
|
210
|
+
maxLat = _bbox[3];
|
|
234
211
|
|
|
212
|
+
var lngLen = maxLng - minLng;
|
|
213
|
+
var latLen = maxLat - minLat;
|
|
214
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
215
|
+
name: 'uvs',
|
|
216
|
+
type: _l7Core.AttributeType.Attribute,
|
|
217
|
+
descriptor: {
|
|
218
|
+
name: 'a_uvs',
|
|
219
|
+
buffer: {
|
|
220
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
221
|
+
data: [],
|
|
222
|
+
type: _l7Core.gl.FLOAT
|
|
223
|
+
},
|
|
224
|
+
size: 3,
|
|
225
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
226
|
+
var lng = vertex[0];
|
|
227
|
+
var lat = vertex[1];
|
|
228
|
+
return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
235
232
|
this.styleAttributeService.registerStyleAttribute({
|
|
236
233
|
name: 'normal',
|
|
237
234
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -272,8 +269,8 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
272
269
|
value: function loadTexture() {
|
|
273
270
|
var _this2 = this;
|
|
274
271
|
|
|
275
|
-
var
|
|
276
|
-
mapTexture =
|
|
272
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
273
|
+
mapTexture = _ref4.mapTexture;
|
|
277
274
|
|
|
278
275
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
279
276
|
this.texture = createTexture2D({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/polygon/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","opacity","heightfixed","raisingHeight","sourceColor","targetColor","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","sourceColorArr","targetColorArr","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","u_opacity","u_sourceColor","u_targetColor","u_texture","texture","loadTexture","buildModels","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","PolygonExtrudeTriangulation","stencil","cull","enable","face","BACK","pickLight","mapTexture","polygonExtrudeTexFrag","polygonExtrudeTexVert","polygonExtrudePickLightFrag","polygonExtrudePickLightVert","polygonExtrudeFrag","polygonExtrudeVert","destroy","bbox","getSource","extent","minLng","minLat","maxLng","maxLat","lngLen","latLen","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","lng","lat","DYNAMIC_DRAW","Array","isArray","rendererService","image","Image","crossOrigin","src","onload","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","layerService","updateLayerRenderList","renderLayers","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;;;;;;;;;;;;IAYqBA,Y;;;;;;;;;;;;;;;;;;;;;WAEnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,kCAEEC,WAFF;AAAA,UAEEA,WAFF,iCAEgB,KAFhB;AAAA,oCAGEC,aAHF;AAAA,UAGEA,aAHF,mCAGkB,CAHlB;AAAA,UAIEC,WAJF,QAIEA,WAJF;AAAA,UAKEC,WALF,QAKEA,WALF;;AAQA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEN,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKO,oBAAL,CAA0B;AAAEP,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,YAAMQ,UAAU,GAAG,KAAKV,KAAL,CAAWW,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd,sBAAcA,KAAd;AAAA,Y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l,\n IEncodeFeature,\n IModel,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport { PolygonExtrudeTriangulation } from '../../core/triangulation';\nimport polygonExtrudeFrag from '../shaders/extrude/polygon_extrude_frag.glsl';\n// extrude\nimport polygonExtrudeVert from '../shaders/extrude/polygon_extrude_vert.glsl';\nimport polygonExtrudeTexFrag from '../shaders/extrude/polygon_extrudetex_frag.glsl';\n// texture\nimport polygonExtrudeTexVert from '../shaders/extrude/polygon_extrudetex_vert.glsl';\n// extrude picking\n\nimport polygonExtrudePickLightFrag from '../shaders/extrude/polygon_extrude_picklight_frag.glsl';\nimport polygonExtrudePickLightVert from '../shaders/extrude/polygon_extrude_picklight_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n heightfixed = false,\n raisingHeight = 0,\n sourceColor,\n targetColor,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\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 // 转化渐变色\n let sourceColorArr = [1, 1, 1, 1];\n let targetColorArr = [1, 1, 1, 1];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n }\n\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_raisingHeight: Number(raisingHeight),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n u_texture: this.texture,\n };\n }\n\n public initModels(): IModel[] {\n this.loadTexture();\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PolygonExtrudeTriangulation,\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n }),\n ];\n }\n\n public getShaders() {\n const {\n pickLight,\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (mapTexture) {\n return {\n frag: polygonExtrudeTexFrag,\n vert: polygonExtrudeTexVert,\n type: 'polygonExtrudeTexture',\n };\n }\n if (pickLight) {\n return {\n frag: polygonExtrudePickLightFrag,\n vert: polygonExtrudePickLightVert,\n type: 'polygonExtrude',\n };\n } else {\n return {\n frag: polygonExtrudeFrag,\n vert: polygonExtrudeVert,\n type: 'polygonExtrude',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.texture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n if (mapTexture) {\n const bbox = this.layer.getSource().extent;\n const [minLng, minLat, maxLng, maxLat] = bbox;\n const lngLen = maxLng - minLng;\n const latLen = maxLat - minLat;\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uvs',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_uvs',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n const lng = vertex[0];\n const lat = vertex[1];\n return [\n (lng - minLng) / lngLen,\n (lat - minLat) / latLen,\n vertex[4],\n ];\n },\n },\n });\n }\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\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 = 10 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private loadTexture() {\n const {\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n if (mapTexture) {\n const image = new Image();\n image.crossOrigin = '';\n image.src = mapTexture;\n\n image.onload = () => {\n this.texture = createTexture2D({\n data: image,\n width: image.width,\n height: image.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n };\n }\n }\n}\n"],"file":"extrude.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/polygon/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","opacity","heightfixed","raisingHeight","sourceColor","targetColor","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_texture","texture","loadTexture","buildModels","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","PolygonExtrudeTriangulation","stencil","cull","enable","face","BACK","pickLight","mapTexture","polygonExtrudeTexFrag","polygonExtrudeTexVert","polygonExtrudePickLightFrag","polygonExtrudePickLightVert","polygonExtrudeFrag","polygonExtrudeVert","destroy","bbox","getSource","extent","minLng","minLat","maxLng","maxLat","lngLen","latLen","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","lng","lat","DYNAMIC_DRAW","Array","isArray","rendererService","image","Image","crossOrigin","src","onload","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","layerService","updateLayerRenderList","renderLayers","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;;;;;;;;;;;;IAYqBA,Y;;;;;;;;;;;;;;;;;;;;;WAEnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,kCAEEC,WAFF;AAAA,UAEEA,WAFF,iCAEgB,KAFhB;AAAA,oCAGEC,aAHF;AAAA,UAGEA,aAHF,mCAGkB,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EAAEsF,KADuB;AAE7BrF,YAAAA,KAAK,EAAEqF,KAAK,CAACrF,KAFgB;AAG7BC,YAAAA,MAAM,EAAEoF,KAAK,CAACpF,MAHe;AAI7ByF,YAAAA,KAAK,EAAElF,WAAGmF,aAJmB;AAK7BC,YAAAA,KAAK,EAAEpF,WAAGmF,aALmB;AAM7BE,YAAAA,GAAG,EAAErF,WAAGsF,MANqB;AAO7BC,YAAAA,GAAG,EAAEvF,WAAGsF;AAPqB,WAAD,CAA9B;;AASA,UAAA,MAAI,CAACE,YAAL,CAAkBC,qBAAlB;;AACA,UAAA,MAAI,CAACD,YAAL,CAAkBE,YAAlB;AACD,SAZD;AAaD;AACF;;;EA5OuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport { PolygonExtrudeTriangulation } from '../../core/triangulation';\nimport polygonExtrudeFrag from '../shaders/extrude/polygon_extrude_frag.glsl';\n// extrude\nimport polygonExtrudeVert from '../shaders/extrude/polygon_extrude_vert.glsl';\nimport polygonExtrudeTexFrag from '../shaders/extrude/polygon_extrudetex_frag.glsl';\n// texture\nimport polygonExtrudeTexVert from '../shaders/extrude/polygon_extrudetex_vert.glsl';\n// extrude picking\n\nimport polygonExtrudePickLightFrag from '../shaders/extrude/polygon_extrude_picklight_frag.glsl';\nimport polygonExtrudePickLightVert from '../shaders/extrude/polygon_extrude_picklight_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms() {\n const {\n opacity = 1,\n heightfixed = false,\n raisingHeight = 0,\n sourceColor,\n targetColor,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\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 // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [1, 1, 1, 1];\n let targetColorArr = [1, 1, 1, 1];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_raisingHeight: Number(raisingHeight),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n u_texture: this.texture,\n };\n }\n\n public initModels(): IModel[] {\n this.loadTexture();\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PolygonExtrudeTriangulation,\n stencil: getMask(mask, maskInside),\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n }),\n ];\n }\n\n public getShaders() {\n const {\n pickLight,\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (mapTexture) {\n return {\n frag: polygonExtrudeTexFrag,\n vert: polygonExtrudeTexVert,\n type: 'polygonExtrudeTexture',\n };\n }\n if (pickLight) {\n return {\n frag: polygonExtrudePickLightFrag,\n vert: polygonExtrudePickLightVert,\n type: 'polygonExtrude',\n };\n } else {\n return {\n frag: polygonExtrudeFrag,\n vert: polygonExtrudeVert,\n type: 'polygonExtrude',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.texture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const bbox = this.layer.getSource().extent;\n const [minLng, minLat, maxLng, maxLat] = bbox;\n const lngLen = maxLng - minLng;\n const latLen = maxLat - minLat;\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uvs',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_uvs',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n const lng = vertex[0];\n const lat = vertex[1];\n return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];\n },\n },\n });\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: '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 = 10 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private loadTexture() {\n const {\n mapTexture,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n if (mapTexture) {\n const image = new Image();\n image.crossOrigin = '';\n image.src = mapTexture;\n\n image.onload = () => {\n this.texture = createTexture2D({\n data: image,\n width: image.width,\n height: image.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n };\n }\n }\n}\n"],"file":"extrude.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.31",
|
|
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.
|
|
28
|
-
"@antv/l7-source": "^2.8.
|
|
29
|
-
"@antv/l7-utils": "^2.8.
|
|
27
|
+
"@antv/l7-core": "^2.8.31",
|
|
28
|
+
"@antv/l7-source": "^2.8.31",
|
|
29
|
+
"@antv/l7-utils": "^2.8.31",
|
|
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": "
|
|
55
|
+
"gitHead": "c08e7c79a25ea94b63b0c6b142addb07f0920717",
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
}
|