@antv/l7-layers 2.16.0 → 2.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/core/BaseLayer.d.ts +3 -0
- package/es/core/BaseLayer.js +76 -80
- package/es/core/BaseModel.d.ts +9 -71
- package/es/core/BaseModel.js +75 -357
- package/es/core/CommonStyleAttribute.d.ts +2 -0
- package/es/core/CommonStyleAttribute.js +66 -0
- package/es/core/interface.d.ts +13 -3
- package/es/core/shape/extrude.js +18 -6
- package/es/core/triangulation.d.ts +12 -0
- package/es/core/triangulation.js +70 -0
- package/es/heatmap/models/grid.js +1 -1
- package/es/heatmap/models/grid3d.js +1 -1
- package/es/heatmap/models/heatmap.d.ts +1 -0
- package/es/heatmap/models/heatmap.js +17 -13
- package/es/heatmap/models/hexagon.js +1 -1
- package/es/heatmap/shaders/grid_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/es/line/index.d.ts +1 -0
- package/es/line/index.js +3 -2
- package/es/line/models/arc.js +9 -45
- package/es/line/models/arc_3d.js +12 -45
- package/es/line/models/earthArc_3d.js +6 -40
- package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
- package/es/line/models/flow.js +167 -0
- package/es/line/models/great_circle.js +4 -38
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +3 -3
- package/es/line/models/line.js +7 -41
- package/es/line/models/linearline.js +4 -38
- package/es/line/models/simpleLine.d.ts +0 -1
- package/es/line/models/simpleLine.js +4 -43
- package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/es/line/shaders/line_arc_frag.glsl +7 -11
- package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/es/line/shaders/line_arc_vert.glsl +9 -45
- package/es/line/shaders/line_frag.glsl +15 -17
- package/es/line/shaders/line_vert.glsl +3 -34
- package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/es/plugins/DataMappingPlugin.js +20 -34
- package/es/plugins/LayerModelPlugin.js +13 -1
- package/es/plugins/ShaderUniformPlugin.js +3 -3
- package/es/point/index.d.ts +1 -0
- package/es/point/index.js +1 -0
- package/es/point/models/earthExtrude.d.ts +0 -3
- package/es/point/models/earthExtrude.js +2 -40
- package/es/point/models/earthFill.d.ts +0 -1
- package/es/point/models/earthFill.js +9 -60
- package/es/point/models/extrude.d.ts +0 -3
- package/es/point/models/extrude.js +3 -42
- package/es/point/models/fill.d.ts +0 -1
- package/es/point/models/fill.js +15 -76
- package/es/point/models/fillmage.js +6 -43
- package/es/point/models/image.js +7 -41
- package/es/point/models/normal.js +2 -2
- package/es/point/models/radar.d.ts +0 -1
- package/es/point/models/radar.js +4 -13
- package/es/point/models/simplePoint.d.ts +0 -1
- package/es/point/models/simplePoint.js +8 -49
- package/es/point/models/text.js +17 -47
- package/es/point/shaders/animate/wave_frag.glsl +1 -11
- package/es/point/shaders/earth/extrude_frag.glsl +5 -17
- package/es/point/shaders/earth/extrude_vert.glsl +14 -29
- package/es/point/shaders/earth/fill_frag.glsl +5 -14
- package/es/point/shaders/earth/fill_vert.glsl +1 -75
- package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/es/point/shaders/fill_frag.glsl +9 -20
- package/es/point/shaders/fill_vert.glsl +16 -101
- package/es/point/shaders/image/fillImage_frag.glsl +2 -5
- package/es/point/shaders/image/fillImage_vert.glsl +4 -47
- package/es/point/shaders/image_frag.glsl +1 -5
- package/es/point/shaders/image_vert.glsl +1 -44
- package/es/point/shaders/normal_frag.glsl +0 -2
- package/es/point/shaders/normal_vert.glsl +2 -1
- package/es/point/shaders/radar/radar_vert.glsl +2 -2
- package/es/point/shaders/simplePoint_frag.glsl +0 -7
- package/es/point/shaders/simplePoint_vert.glsl +3 -45
- package/es/point/shaders/text_frag.glsl +6 -19
- package/es/point/shaders/text_vert.glsl +5 -66
- package/es/polygon/index.d.ts +1 -0
- package/es/polygon/index.js +1 -0
- package/es/polygon/models/extrude.d.ts +0 -3
- package/es/polygon/models/extrude.js +86 -82
- package/es/polygon/models/fill.d.ts +0 -4
- package/es/polygon/models/fill.js +8 -47
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/es/polygon/shaders/polygon_frag.glsl +0 -5
- package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/es/polygon/shaders/polygon_vert.glsl +1 -27
- package/es/utils/layerData.js +2 -2
- package/lib/core/BaseLayer.js +74 -78
- package/lib/core/BaseModel.js +74 -356
- package/lib/core/CommonStyleAttribute.js +72 -0
- package/lib/core/shape/extrude.js +18 -6
- package/lib/core/triangulation.js +72 -0
- package/lib/heatmap/models/grid.js +1 -1
- package/lib/heatmap/models/grid3d.js +1 -1
- package/lib/heatmap/models/heatmap.js +17 -13
- package/lib/heatmap/models/hexagon.js +1 -1
- package/lib/heatmap/shaders/grid_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/lib/line/index.js +3 -2
- package/lib/line/models/arc.js +9 -45
- package/lib/line/models/arc_3d.js +12 -45
- package/lib/line/models/earthArc_3d.js +6 -40
- package/lib/line/models/flow.js +174 -0
- package/lib/line/models/great_circle.js +4 -38
- package/lib/line/models/index.js +3 -3
- package/lib/line/models/line.js +7 -41
- package/lib/line/models/linearline.js +4 -38
- package/lib/line/models/simpleLine.js +4 -43
- package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/lib/line/shaders/line_arc_frag.glsl +7 -11
- package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/lib/line/shaders/line_arc_vert.glsl +9 -45
- package/lib/line/shaders/line_frag.glsl +15 -17
- package/lib/line/shaders/line_vert.glsl +3 -34
- package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/lib/plugins/DataMappingPlugin.js +20 -34
- package/lib/plugins/LayerModelPlugin.js +13 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -3
- package/lib/point/index.js +1 -0
- package/lib/point/models/earthExtrude.js +2 -40
- package/lib/point/models/earthFill.js +9 -60
- package/lib/point/models/extrude.js +3 -42
- package/lib/point/models/fill.js +15 -76
- package/lib/point/models/fillmage.js +6 -43
- package/lib/point/models/image.js +7 -41
- package/lib/point/models/normal.js +2 -2
- package/lib/point/models/radar.js +4 -13
- package/lib/point/models/simplePoint.js +8 -49
- package/lib/point/models/text.js +15 -45
- package/lib/point/shaders/animate/wave_frag.glsl +1 -11
- package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
- package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
- package/lib/point/shaders/earth/fill_frag.glsl +5 -14
- package/lib/point/shaders/earth/fill_vert.glsl +1 -75
- package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/lib/point/shaders/fill_frag.glsl +9 -20
- package/lib/point/shaders/fill_vert.glsl +16 -101
- package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
- package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
- package/lib/point/shaders/image_frag.glsl +1 -5
- package/lib/point/shaders/image_vert.glsl +1 -44
- package/lib/point/shaders/normal_frag.glsl +0 -2
- package/lib/point/shaders/normal_vert.glsl +2 -1
- package/lib/point/shaders/radar/radar_vert.glsl +2 -2
- package/lib/point/shaders/simplePoint_frag.glsl +0 -7
- package/lib/point/shaders/simplePoint_vert.glsl +3 -45
- package/lib/point/shaders/text_frag.glsl +6 -19
- package/lib/point/shaders/text_vert.glsl +5 -66
- package/lib/polygon/index.js +1 -0
- package/lib/polygon/models/extrude.js +86 -82
- package/lib/polygon/models/fill.js +8 -47
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/lib/polygon/shaders/polygon_frag.glsl +0 -5
- package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/lib/polygon/shaders/polygon_vert.glsl +1 -27
- package/lib/utils/layerData.js +2 -2
- package/package.json +7 -7
- package/es/line/models/half.js +0 -267
- package/es/line/shaders/half/line_half_frag.glsl +0 -53
- package/es/line/shaders/half/line_half_vert.glsl +0 -169
- package/es/utils/dataMappingStyle.d.ts +0 -31
- package/es/utils/dataMappingStyle.js +0 -137
- package/lib/line/models/half.js +0 -274
- package/lib/line/shaders/half/line_half_frag.glsl +0 -53
- package/lib/line/shaders/half/line_half_vert.glsl +0 -169
- package/lib/utils/dataMappingStyle.js +0 -140
|
@@ -6,10 +6,7 @@ export default class ExtrudeModel extends BaseModel {
|
|
|
6
6
|
u_topsurface: number;
|
|
7
7
|
u_sidesurface: number;
|
|
8
8
|
u_heightfixed: number;
|
|
9
|
-
u_dataTexture: ITexture2D;
|
|
10
|
-
u_cellTypeLayout: number[];
|
|
11
9
|
u_raisingHeight: number;
|
|
12
|
-
u_opacity: number;
|
|
13
10
|
u_linearColor: number;
|
|
14
11
|
u_sourceColor: number[];
|
|
15
12
|
u_targetColor: number[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
@@ -10,21 +11,20 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
10
11
|
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; } }
|
|
11
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
12
13
|
import { rgb2arr } from '@antv/l7-utils';
|
|
13
|
-
import { isNumber } from 'lodash';
|
|
14
14
|
import BaseModel from "../../core/BaseModel";
|
|
15
15
|
import { PolygonExtrudeTriangulation } from "../../core/triangulation";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
|
|
17
|
-
var polygonExtrudeFrag = "uniform
|
|
17
|
+
var polygonExtrudeFrag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\n\n#pragma include \"picking\"\n\nvoid main() {\n\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = v_Color;\n \n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
|
|
19
|
-
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;\
|
|
19
|
+
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;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n float isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n\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\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 // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
|
|
20
20
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
|
|
21
|
-
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying
|
|
21
|
+
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying vec3 v_uvs;\nvarying vec2 v_texture_data;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(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 } else {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = texture2D(u_texture, vec2(topU, topV));\n // gl_FragColor = vec4(1.0, 0., 0., 1.0);\n }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; // texture
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
|
|
23
|
-
var polygonExtrudeTexVert = "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
|
|
23
|
+
var polygonExtrudeTexVert = "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;\nuniform sampler2D u_texture;\n\n\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_linearColor: 0.0;\n\nvarying vec2 v_texture_data;\nvarying vec3 v_uvs;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_uvs = a_uvs;\n\n v_texture_data = vec2(a_Position.z, lightWeight);\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\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\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
|
|
25
|
-
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying
|
|
25
|
+
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying vec3 v_uvs;\nvarying vec2 v_texture_data;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n // side notuse linear\n gl_FragColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n}\n";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
|
|
27
|
-
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\
|
|
27
|
+
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\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_texture_data;\nvarying vec3 v_uvs;\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n\n\n v_uvs = a_uvs;\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_texture_data = vec2(a_Position.z,lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
28
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
29
29
|
_inherits(ExtrudeModel, _BaseModel);
|
|
30
30
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -36,8 +36,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
36
36
|
key: "getUninforms",
|
|
37
37
|
value: function getUninforms() {
|
|
38
38
|
var _ref = this.layer.getLayerConfig(),
|
|
39
|
-
_ref$opacity = _ref.opacity,
|
|
40
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
41
39
|
_ref$heightfixed = _ref.heightfixed,
|
|
42
40
|
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
43
41
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
@@ -48,35 +46,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
48
46
|
sidesurface = _ref$sidesurface === void 0 ? true : _ref$sidesurface,
|
|
49
47
|
sourceColor = _ref.sourceColor,
|
|
50
48
|
targetColor = _ref.targetColor;
|
|
51
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
52
|
-
opacity: opacity
|
|
53
|
-
})) {
|
|
54
|
-
this.judgeStyleAttributes({
|
|
55
|
-
opacity: opacity
|
|
56
|
-
});
|
|
57
|
-
var encodeData = this.layer.getEncodedData();
|
|
58
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
59
|
-
data = _this$calDataFrame.data,
|
|
60
|
-
width = _this$calDataFrame.width,
|
|
61
|
-
height = _this$calDataFrame.height;
|
|
62
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
63
|
-
|
|
64
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
65
|
-
flipY: true,
|
|
66
|
-
data: data,
|
|
67
|
-
format: gl.LUMINANCE,
|
|
68
|
-
type: gl.FLOAT,
|
|
69
|
-
width: width,
|
|
70
|
-
height: height
|
|
71
|
-
}) : this.createTexture2D({
|
|
72
|
-
flipY: true,
|
|
73
|
-
data: [1],
|
|
74
|
-
format: gl.LUMINANCE,
|
|
75
|
-
type: gl.FLOAT,
|
|
76
|
-
width: 1,
|
|
77
|
-
height: 1
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
49
|
|
|
81
50
|
// 转化渐变色
|
|
82
51
|
var useLinearColor = 0; // 默认不生效
|
|
@@ -87,22 +56,18 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
87
56
|
targetColorArr = rgb2arr(targetColor);
|
|
88
57
|
useLinearColor = 1;
|
|
89
58
|
}
|
|
90
|
-
return {
|
|
59
|
+
return _objectSpread({
|
|
91
60
|
// 控制侧面和顶面的显示隐藏
|
|
92
61
|
u_topsurface: Number(topsurface),
|
|
93
62
|
u_sidesurface: Number(sidesurface),
|
|
94
63
|
u_heightfixed: Number(heightfixed),
|
|
95
|
-
u_dataTexture: this.dataTexture,
|
|
96
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
97
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
98
64
|
u_raisingHeight: Number(raisingHeight),
|
|
99
|
-
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
|
100
65
|
// 渐变色支持参数
|
|
101
66
|
u_linearColor: useLinearColor,
|
|
102
67
|
u_sourceColor: sourceColorArr,
|
|
103
68
|
u_targetColor: targetColorArr,
|
|
104
69
|
u_texture: this.texture
|
|
105
|
-
};
|
|
70
|
+
}, this.getStyleAttribute());
|
|
106
71
|
}
|
|
107
72
|
}, {
|
|
108
73
|
key: "initModels",
|
|
@@ -111,9 +76,11 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
111
76
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
112
77
|
while (1) switch (_context.prev = _context.next) {
|
|
113
78
|
case 0:
|
|
114
|
-
|
|
115
|
-
return
|
|
79
|
+
_context.next = 2;
|
|
80
|
+
return this.loadTexture();
|
|
116
81
|
case 2:
|
|
82
|
+
return _context.abrupt("return", this.buildModels());
|
|
83
|
+
case 3:
|
|
117
84
|
case "end":
|
|
118
85
|
return _context.stop();
|
|
119
86
|
}
|
|
@@ -138,6 +105,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
138
105
|
moduleName: type,
|
|
139
106
|
vertexShader: vert,
|
|
140
107
|
fragmentShader: frag,
|
|
108
|
+
inject: this.getInject(),
|
|
141
109
|
triangulation: PolygonExtrudeTriangulation
|
|
142
110
|
});
|
|
143
111
|
case 3:
|
|
@@ -184,21 +152,32 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
184
152
|
}, {
|
|
185
153
|
key: "clearModels",
|
|
186
154
|
value: function clearModels() {
|
|
187
|
-
var _this$
|
|
188
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
155
|
+
var _this$texture;
|
|
189
156
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
190
157
|
}
|
|
191
158
|
}, {
|
|
192
159
|
key: "registerBuiltinAttributes",
|
|
193
160
|
value: function registerBuiltinAttributes() {
|
|
194
161
|
var bbox = this.layer.getSource().extent;
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
162
|
+
var bounds = bbox;
|
|
163
|
+
var layerCenter = this.layer.coordCenter || this.layer.getSource().center;
|
|
164
|
+
var lngLen = bounds[2] - bounds[0];
|
|
165
|
+
var latLen = bounds[3] - bounds[1];
|
|
166
|
+
if (this.mapService.version === 'GAODE2.x') {
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
var _this$mapService$coor = this.mapService.coordToAMap2RelativeCoordinates([bbox[0], bbox[1]], layerCenter),
|
|
169
|
+
_this$mapService$coor2 = _slicedToArray(_this$mapService$coor, 2),
|
|
170
|
+
minX = _this$mapService$coor2[0],
|
|
171
|
+
minY = _this$mapService$coor2[1];
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
var _this$mapService$coor3 = this.mapService.coordToAMap2RelativeCoordinates([bbox[2], bbox[3]], layerCenter),
|
|
174
|
+
_this$mapService$coor4 = _slicedToArray(_this$mapService$coor3, 2),
|
|
175
|
+
maxX = _this$mapService$coor4[0],
|
|
176
|
+
maxY = _this$mapService$coor4[1];
|
|
177
|
+
lngLen = maxX - minX;
|
|
178
|
+
latLen = maxY - minY;
|
|
179
|
+
bounds = [minX, minY, maxX, maxY];
|
|
180
|
+
}
|
|
202
181
|
this.styleAttributeService.registerStyleAttribute({
|
|
203
182
|
name: 'uvs',
|
|
204
183
|
type: AttributeType.Attribute,
|
|
@@ -214,7 +193,9 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
214
193
|
update: function update(feature, featureIdx, vertex) {
|
|
215
194
|
var lng = vertex[0];
|
|
216
195
|
var lat = vertex[1];
|
|
217
|
-
|
|
196
|
+
// console.log((lng - bounds[0]) / lngLen, (lat - bounds[1]) / latLen, vertex[4])
|
|
197
|
+
// 临时 兼容高德V2
|
|
198
|
+
return [(lng - bounds[0]) / lngLen, (lat - bounds[1]) / latLen, vertex[4]];
|
|
218
199
|
}
|
|
219
200
|
}
|
|
220
201
|
});
|
|
@@ -256,33 +237,56 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
256
237
|
}
|
|
257
238
|
}, {
|
|
258
239
|
key: "loadTexture",
|
|
259
|
-
value: function
|
|
260
|
-
var
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
240
|
+
value: function () {
|
|
241
|
+
var _loadTexture = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
242
|
+
var _this = this;
|
|
243
|
+
var _ref3, mapTexture, createTexture2D;
|
|
244
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
245
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
246
|
+
case 0:
|
|
247
|
+
_ref3 = this.layer.getLayerConfig(), mapTexture = _ref3.mapTexture;
|
|
248
|
+
createTexture2D = this.rendererService.createTexture2D;
|
|
249
|
+
this.texture = createTexture2D({
|
|
250
|
+
height: 0,
|
|
251
|
+
width: 0
|
|
252
|
+
});
|
|
253
|
+
if (!mapTexture) {
|
|
254
|
+
_context3.next = 5;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
return _context3.abrupt("return", new Promise(function (resolve, reject) {
|
|
258
|
+
var image = new Image();
|
|
259
|
+
image.crossOrigin = 'anonymous';
|
|
260
|
+
image.src = mapTexture;
|
|
261
|
+
image.onload = function () {
|
|
262
|
+
_this.texture = createTexture2D({
|
|
263
|
+
data: image,
|
|
264
|
+
width: image.width,
|
|
265
|
+
height: image.height,
|
|
266
|
+
wrapS: gl.CLAMP_TO_EDGE,
|
|
267
|
+
wrapT: gl.CLAMP_TO_EDGE,
|
|
268
|
+
min: gl.LINEAR,
|
|
269
|
+
mag: gl.LINEAR
|
|
270
|
+
});
|
|
271
|
+
return resolve(null);
|
|
272
|
+
// this.layerService.reRender();
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
image.onerror = function () {
|
|
276
|
+
reject(new Error('image load error'));
|
|
277
|
+
};
|
|
278
|
+
}));
|
|
279
|
+
case 5:
|
|
280
|
+
case "end":
|
|
281
|
+
return _context3.stop();
|
|
282
|
+
}
|
|
283
|
+
}, _callee3, this);
|
|
284
|
+
}));
|
|
285
|
+
function loadTexture() {
|
|
286
|
+
return _loadTexture.apply(this, arguments);
|
|
284
287
|
}
|
|
285
|
-
|
|
288
|
+
return loadTexture;
|
|
289
|
+
}()
|
|
286
290
|
}]);
|
|
287
291
|
return ExtrudeModel;
|
|
288
292
|
}(BaseModel);
|
|
@@ -2,16 +2,12 @@ import { IModel } from '@antv/l7-core';
|
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class FillModel extends BaseModel {
|
|
4
4
|
getUninforms(): {
|
|
5
|
-
u_dataTexture: import("@antv/l7-core").ITexture2D;
|
|
6
|
-
u_cellTypeLayout: number[];
|
|
7
5
|
u_raisingHeight: number;
|
|
8
|
-
u_opacity: number;
|
|
9
6
|
u_opacitylinear: number;
|
|
10
7
|
u_dir: number;
|
|
11
8
|
};
|
|
12
9
|
initModels(): Promise<IModel[]>;
|
|
13
10
|
buildModels(): Promise<IModel[]>;
|
|
14
|
-
clearModels(): void;
|
|
15
11
|
protected registerBuiltinAttributes(): void;
|
|
16
12
|
private getModelParams;
|
|
17
13
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
@@ -9,17 +10,16 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
9
10
|
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; } }
|
|
10
11
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
11
12
|
import { polygonFillTriangulation } from '@antv/l7-utils';
|
|
12
|
-
import { isNumber } from 'lodash';
|
|
13
13
|
import BaseModel from "../../core/BaseModel";
|
|
14
14
|
import { polygonTriangulationWithCenter } from "../../core/triangulation";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/polygon_frag.glsl' */
|
|
16
|
-
var polygon_frag = "
|
|
16
|
+
var polygon_frag = "varying vec4 v_color;\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/polygon_linear_frag.glsl' */
|
|
18
|
-
var polygon_linear_frag = "
|
|
18
|
+
var polygon_linear_frag = "#pragma include \"picking\"\nuniform float u_opacitylinear: 0.0;\nuniform float u_dir: 1.0;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\n\nvoid main() {\n \n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/polygon_linear_vert.glsl' */
|
|
20
|
-
var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float
|
|
20
|
+
var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nuniform float u_opacitylinear: 0.0;\n\nattribute vec3 a_linear;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\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 if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\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 setPickingColor(a_PickingColor);\n}";
|
|
21
21
|
/* babel-plugin-inline-import '../shaders/polygon_vert.glsl' */
|
|
22
|
-
var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float
|
|
22
|
+
var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_color;\n\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\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\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 if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\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 setPickingColor(a_PickingColor);\n}\n\n";
|
|
23
23
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
24
24
|
_inherits(FillModel, _BaseModel);
|
|
25
25
|
var _super = _createSuper(FillModel);
|
|
@@ -33,50 +33,16 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
33
33
|
var _ref = this.layer.getLayerConfig(),
|
|
34
34
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
35
35
|
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
36
|
-
_ref$opacity = _ref.opacity,
|
|
37
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
38
36
|
_ref$opacityLinear = _ref.opacityLinear,
|
|
39
37
|
opacityLinear = _ref$opacityLinear === void 0 ? {
|
|
40
38
|
enable: false,
|
|
41
39
|
dir: 'in'
|
|
42
40
|
} : _ref$opacityLinear;
|
|
43
|
-
|
|
44
|
-
opacity: opacity
|
|
45
|
-
})) {
|
|
46
|
-
this.judgeStyleAttributes({
|
|
47
|
-
opacity: opacity
|
|
48
|
-
});
|
|
49
|
-
var encodeData = this.layer.getEncodedData();
|
|
50
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
51
|
-
data = _this$calDataFrame.data,
|
|
52
|
-
width = _this$calDataFrame.width,
|
|
53
|
-
height = _this$calDataFrame.height;
|
|
54
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
55
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
56
|
-
flipY: true,
|
|
57
|
-
data: data,
|
|
58
|
-
format: gl.LUMINANCE,
|
|
59
|
-
type: gl.FLOAT,
|
|
60
|
-
width: width,
|
|
61
|
-
height: height
|
|
62
|
-
}) : this.createTexture2D({
|
|
63
|
-
flipY: true,
|
|
64
|
-
data: [1],
|
|
65
|
-
format: gl.LUMINANCE,
|
|
66
|
-
type: gl.FLOAT,
|
|
67
|
-
width: 1,
|
|
68
|
-
height: 1
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
u_dataTexture: this.dataTexture,
|
|
73
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
74
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
41
|
+
return _objectSpread({
|
|
75
42
|
u_raisingHeight: Number(raisingHeight),
|
|
76
|
-
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
|
77
43
|
u_opacitylinear: Number(opacityLinear.enable),
|
|
78
44
|
u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0
|
|
79
|
-
};
|
|
45
|
+
}, this.getStyleAttribute());
|
|
80
46
|
}
|
|
81
47
|
}, {
|
|
82
48
|
key: "initModels",
|
|
@@ -113,6 +79,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
113
79
|
moduleName: type,
|
|
114
80
|
vertexShader: vert,
|
|
115
81
|
fragmentShader: frag,
|
|
82
|
+
inject: this.getInject(),
|
|
116
83
|
triangulation: triangulation,
|
|
117
84
|
primitive: gl.TRIANGLES,
|
|
118
85
|
depth: {
|
|
@@ -138,12 +105,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
138
105
|
}
|
|
139
106
|
return buildModels;
|
|
140
107
|
}()
|
|
141
|
-
}, {
|
|
142
|
-
key: "clearModels",
|
|
143
|
-
value: function clearModels() {
|
|
144
|
-
var _this$dataTexture;
|
|
145
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
146
|
-
}
|
|
147
108
|
}, {
|
|
148
109
|
key: "registerBuiltinAttributes",
|
|
149
110
|
value: function registerBuiltinAttributes() {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
uniform float u_opacity: 1.0;
|
|
2
1
|
uniform vec4 u_sourceColor;
|
|
3
2
|
uniform vec4 u_targetColor;
|
|
4
3
|
uniform float u_linearColor: 0;
|
|
@@ -7,39 +6,19 @@ uniform float u_topsurface: 1.0;
|
|
|
7
6
|
uniform float u_sidesurface: 1.0;
|
|
8
7
|
|
|
9
8
|
varying vec4 v_Color;
|
|
10
|
-
|
|
9
|
+
|
|
11
10
|
#pragma include "picking"
|
|
12
11
|
|
|
13
12
|
void main() {
|
|
14
|
-
float opacity = styleMappingMat[0][0];
|
|
15
|
-
float isSide = styleMappingMat[0][3];
|
|
16
|
-
float sidey = styleMappingMat[3][0];
|
|
17
|
-
float lightWeight = styleMappingMat[3][1];
|
|
18
|
-
|
|
19
|
-
// Tip: 部分机型 GPU 计算精度兼容
|
|
20
|
-
if(isSide < 0.999) {
|
|
21
|
-
// side face
|
|
22
|
-
if(u_sidesurface < 1.0) {
|
|
23
|
-
discard;
|
|
24
|
-
}
|
|
25
13
|
|
|
26
|
-
if(u_linearColor == 1.0) {
|
|
27
|
-
vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);
|
|
28
|
-
linearColor.rgb *= lightWeight;
|
|
29
|
-
gl_FragColor = linearColor;
|
|
30
|
-
} else {
|
|
31
|
-
gl_FragColor = v_Color;
|
|
32
|
-
}
|
|
33
14
|
|
|
34
|
-
} else {
|
|
35
15
|
// top face
|
|
36
16
|
if(u_topsurface < 1.0) {
|
|
37
17
|
discard;
|
|
38
18
|
}
|
|
39
19
|
|
|
40
20
|
gl_FragColor = v_Color;
|
|
41
|
-
|
|
21
|
+
|
|
42
22
|
|
|
43
|
-
gl_FragColor.a *= opacity;
|
|
44
23
|
gl_FragColor = filterColor(gl_FragColor);
|
|
45
24
|
}
|
|
@@ -7,14 +7,16 @@ uniform float u_topsurface: 1.0;
|
|
|
7
7
|
uniform float u_sidesurface: 1.0;
|
|
8
8
|
|
|
9
9
|
varying vec4 v_Color;
|
|
10
|
-
varying
|
|
10
|
+
varying vec3 v_uvs;
|
|
11
|
+
varying vec2 v_texture_data;
|
|
12
|
+
|
|
11
13
|
#pragma include "picking"
|
|
12
14
|
|
|
13
15
|
void main() {
|
|
14
|
-
float opacity =
|
|
15
|
-
float isSide =
|
|
16
|
-
float sidey =
|
|
17
|
-
float lightWeight =
|
|
16
|
+
float opacity = u_opacity;
|
|
17
|
+
float isSide = v_texture_data.x;
|
|
18
|
+
float sidey = v_uvs[2];
|
|
19
|
+
float lightWeight = v_texture_data.y;
|
|
18
20
|
|
|
19
21
|
// Tip: 部分机型 GPU 计算精度兼容
|
|
20
22
|
if(isSide < 0.999) {
|
|
@@ -12,46 +12,22 @@ attribute vec3 a_uvs;
|
|
|
12
12
|
uniform mat4 u_ModelMatrix;
|
|
13
13
|
uniform mat4 u_Mvp;
|
|
14
14
|
|
|
15
|
-
varying vec4 v_Color;
|
|
16
15
|
uniform float u_heightfixed: 0.0; // 默认不固定
|
|
17
16
|
uniform float u_raisingHeight: 0.0;
|
|
18
|
-
uniform float u_opacity: 1.0;
|
|
19
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
varying vec2 v_texture_data;
|
|
19
|
+
varying vec3 v_uvs;
|
|
20
|
+
varying vec4 v_Color;
|
|
21
|
+
|
|
23
22
|
|
|
24
23
|
#pragma include "projection"
|
|
25
24
|
#pragma include "light"
|
|
26
25
|
#pragma include "picking"
|
|
27
26
|
|
|
28
27
|
void main() {
|
|
29
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
30
|
-
styleMappingMat = mat4(
|
|
31
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide
|
|
32
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
33
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
34
|
-
0.0, 0.0, 0.0, 0.0 // sidey
|
|
35
|
-
);
|
|
36
|
-
styleMappingMat[0][3] = a_Position.z;
|
|
37
|
-
styleMappingMat[3][0] = a_uvs[2];
|
|
38
28
|
|
|
39
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
40
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
41
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
42
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
43
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
44
|
-
float id = a_vertexId; // 第n个顶点
|
|
45
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
46
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
47
|
-
|
|
48
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
49
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
50
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
51
29
|
|
|
52
|
-
|
|
53
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
54
|
-
textureOffset = opacityAndOffset.g;
|
|
30
|
+
v_uvs = a_uvs;
|
|
55
31
|
// cal style mapping - 数据纹理映射部分的计算
|
|
56
32
|
vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
|
|
57
33
|
vec4 project_pos = project_position(pos);
|
|
@@ -76,10 +52,9 @@ void main() {
|
|
|
76
52
|
}
|
|
77
53
|
|
|
78
54
|
float lightWeight = calc_lighting(pos);
|
|
79
|
-
|
|
80
|
-
v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);
|
|
55
|
+
v_texture_data = vec2(a_Position.z,lightWeight);
|
|
81
56
|
|
|
82
|
-
|
|
57
|
+
v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);
|
|
83
58
|
|
|
84
59
|
setPickingColor(a_PickingColor);
|
|
85
60
|
}
|