@antv/l7-layers 2.17.3 → 2.17.4
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/Geometry/index.js +31 -9
- package/es/Geometry/models/billboard.js +89 -51
- package/es/Geometry/models/plane.js +143 -81
- package/es/Geometry/models/sprite.js +118 -60
- package/es/canvas/index.js +33 -10
- package/es/canvas/models/canvas.js +97 -41
- package/es/citybuliding/building.js +27 -8
- package/es/citybuliding/models/build.js +82 -57
- package/es/core/BaseLayer.js +478 -313
- package/es/core/BaseModel.js +80 -51
- package/es/core/CommonStyleAttribute.js +5 -2
- package/es/core/LayerPickService.js +32 -21
- package/es/core/TextureService.js +13 -0
- package/es/core/interface.js +24 -17
- package/es/core/shape/Path.js +20 -13
- package/es/core/shape/extrude.js +39 -27
- package/es/core/triangulation.js +136 -99
- package/es/earth/index.js +33 -9
- package/es/earth/models/atmosphere.js +54 -30
- package/es/earth/models/base.js +85 -47
- package/es/earth/models/bloomsphere.js +54 -30
- package/es/earth/utils.js +13 -9
- package/es/heatmap/index.js +40 -10
- package/es/heatmap/models/grid.js +52 -28
- package/es/heatmap/models/grid3d.js +52 -28
- package/es/heatmap/models/heatmap.js +149 -92
- package/es/heatmap/models/hexagon.js +52 -28
- package/es/heatmap/triangulation.js +4 -0
- package/es/image/index.js +28 -9
- package/es/image/models/image.js +100 -66
- package/es/index.js +17 -9
- package/es/line/index.js +35 -9
- package/es/line/models/arc.js +112 -63
- package/es/line/models/arc_3d.js +102 -58
- package/es/line/models/earthArc_3d.js +105 -60
- package/es/line/models/flow.js +60 -36
- package/es/line/models/great_circle.js +94 -53
- package/es/line/models/line.js +136 -85
- package/es/line/models/linearline.js +74 -42
- package/es/line/models/simpleLine.js +67 -38
- package/es/line/models/wall.js +92 -52
- package/es/mask/index.js +28 -9
- package/es/mask/models/fill.js +54 -29
- package/es/plugins/DataMappingPlugin.js +114 -78
- package/es/plugins/DataSourcePlugin.js +68 -45
- package/es/plugins/FeatureScalePlugin.js +122 -67
- package/es/plugins/LayerAnimateStylePlugin.js +5 -0
- package/es/plugins/LayerMaskPlugin.js +11 -3
- package/es/plugins/LayerModelPlugin.js +108 -69
- package/es/plugins/LayerStylePlugin.js +9 -3
- package/es/plugins/LightingPlugin.js +18 -12
- package/es/plugins/MultiPassRendererPlugin.js +16 -11
- package/es/plugins/PixelPickingPlugin.js +21 -12
- package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
- package/es/plugins/ShaderUniformPlugin.js +27 -13
- package/es/plugins/UpdateModelPlugin.js +5 -0
- package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
- package/es/point/index.js +78 -26
- package/es/point/models/earthExtrude.js +95 -58
- package/es/point/models/earthFill.js +80 -52
- package/es/point/models/extrude.js +94 -57
- package/es/point/models/fill.js +81 -56
- package/es/point/models/fillmage.js +100 -60
- package/es/point/models/image.js +83 -47
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +54 -30
- package/es/point/models/radar.js +63 -38
- package/es/point/models/simplePoint.js +62 -38
- package/es/point/models/text.js +296 -199
- package/es/point/shape/extrude.js +13 -4
- package/es/polygon/index.js +41 -11
- package/es/polygon/models/extrude.js +135 -87
- package/es/polygon/models/fill.js +79 -50
- package/es/polygon/models/index.js +2 -3
- package/es/polygon/models/ocean.js +76 -42
- package/es/polygon/models/water.js +71 -37
- package/es/raster/buffers/triangulation.js +4 -2
- package/es/raster/index.js +32 -9
- package/es/raster/models/raster.js +116 -80
- package/es/raster/models/rasterRgb.js +127 -84
- package/es/raster/models/rasterTerrainRgb.js +84 -56
- package/es/tile/interaction/getRasterData.js +20 -14
- package/es/tile/interaction/utils.js +9 -7
- package/es/tile/manager/base.js +96 -63
- package/es/tile/service/TileLayerService.js +55 -33
- package/es/tile/service/TilePickService.js +40 -26
- package/es/tile/service/TileSourceService.js +7 -3
- package/es/tile/tileFactory/DebugTile.js +46 -29
- package/es/tile/tileFactory/ImageTile.js +38 -20
- package/es/tile/tileFactory/MaskTile.js +43 -22
- package/es/tile/tileFactory/RasterRGBTile.js +42 -22
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
- package/es/tile/tileFactory/RasterTile.js +53 -30
- package/es/tile/tileFactory/Tile.js +97 -63
- package/es/tile/tileFactory/VectorTile.js +68 -41
- package/es/tile/tileFactory/index.js +11 -0
- package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
- package/es/tile/tileFactory/util.js +3 -0
- package/es/tile/tileLayer/BaseLayer.js +146 -105
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +2 -0
- package/es/utils/collision-index.js +16 -9
- package/es/utils/extrude_polyline.js +149 -101
- package/es/utils/grid-index.js +27 -2
- package/es/utils/identityScale.js +8 -0
- package/es/utils/layerData.js +44 -30
- package/es/utils/multiPassRender.js +13 -11
- package/es/utils/polylineNormal.js +37 -31
- package/es/utils/simpleLine.js +16 -2
- package/es/utils/stencil.js +3 -2
- package/es/utils/symbol-layout.js +53 -27
- package/es/wind/index.js +29 -9
- package/es/wind/models/utils.js +51 -26
- package/es/wind/models/wind.js +147 -101
- package/es/wind/models/windRender.js +66 -53
- package/lib/Geometry/index.js +38 -9
- package/lib/Geometry/models/billboard.js +97 -51
- package/lib/Geometry/models/index.js +5 -0
- package/lib/Geometry/models/plane.js +151 -79
- package/lib/Geometry/models/sprite.js +127 -60
- package/lib/canvas/index.js +40 -10
- package/lib/canvas/models/canvas.js +101 -41
- package/lib/canvas/models/index.js +3 -0
- package/lib/citybuliding/building.js +35 -8
- package/lib/citybuliding/models/build.js +92 -57
- package/lib/core/BaseLayer.js +469 -313
- package/lib/core/BaseModel.js +90 -51
- package/lib/core/CommonStyleAttribute.js +7 -2
- package/lib/core/LayerPickService.js +37 -21
- package/lib/core/TextureService.js +16 -0
- package/lib/core/interface.js +31 -21
- package/lib/core/schema.js +1 -0
- package/lib/core/shape/Path.js +31 -14
- package/lib/core/shape/extrude.js +62 -27
- package/lib/core/triangulation.js +177 -98
- package/lib/earth/index.js +43 -9
- package/lib/earth/models/atmosphere.js +63 -30
- package/lib/earth/models/base.js +90 -47
- package/lib/earth/models/bloomsphere.js +63 -30
- package/lib/earth/utils.js +31 -7
- package/lib/heatmap/index.js +48 -10
- package/lib/heatmap/models/grid.js +60 -28
- package/lib/heatmap/models/grid3d.js +60 -28
- package/lib/heatmap/models/heatmap.js +166 -92
- package/lib/heatmap/models/hexagon.js +60 -28
- package/lib/heatmap/models/index.js +6 -0
- package/lib/heatmap/triangulation.js +5 -0
- package/lib/image/index.js +36 -9
- package/lib/image/models/image.js +109 -66
- package/lib/image/models/index.js +3 -0
- package/lib/index.js +61 -7
- package/lib/line/index.js +40 -9
- package/lib/line/models/arc.js +122 -61
- package/lib/line/models/arc_3d.js +113 -56
- package/lib/line/models/earthArc_3d.js +115 -58
- package/lib/line/models/flow.js +70 -36
- package/lib/line/models/great_circle.js +104 -53
- package/lib/line/models/index.js +11 -0
- package/lib/line/models/line.js +144 -83
- package/lib/line/models/linearline.js +86 -42
- package/lib/line/models/simpleLine.js +77 -38
- package/lib/line/models/wall.js +103 -52
- package/lib/mask/index.js +36 -9
- package/lib/mask/models/fill.js +63 -29
- package/lib/mask/models/index.js +3 -0
- package/lib/plugins/DataMappingPlugin.js +125 -78
- package/lib/plugins/DataSourcePlugin.js +76 -45
- package/lib/plugins/FeatureScalePlugin.js +138 -67
- package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
- package/lib/plugins/LayerMaskPlugin.js +17 -4
- package/lib/plugins/LayerModelPlugin.js +117 -70
- package/lib/plugins/LayerStylePlugin.js +14 -4
- package/lib/plugins/LightingPlugin.js +25 -12
- package/lib/plugins/MultiPassRendererPlugin.js +22 -11
- package/lib/plugins/PixelPickingPlugin.js +27 -12
- package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
- package/lib/plugins/ShaderUniformPlugin.js +34 -13
- package/lib/plugins/UpdateModelPlugin.js +10 -1
- package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
- package/lib/point/index.js +83 -26
- package/lib/point/models/earthExtrude.js +106 -58
- package/lib/point/models/earthFill.js +110 -52
- package/lib/point/models/extrude.js +103 -57
- package/lib/point/models/fill.js +90 -54
- package/lib/point/models/fillmage.js +107 -58
- package/lib/point/models/image.js +92 -47
- package/lib/point/models/index.js +12 -1
- package/lib/point/models/normal.js +64 -30
- package/lib/point/models/radar.js +72 -38
- package/lib/point/models/simplePoint.js +72 -38
- package/lib/point/models/text.js +305 -199
- package/lib/point/shape/extrude.js +20 -4
- package/lib/polygon/index.js +48 -11
- package/lib/polygon/models/extrude.js +146 -87
- package/lib/polygon/models/fill.js +89 -50
- package/lib/polygon/models/index.js +14 -2
- package/lib/polygon/models/ocean.js +88 -42
- package/lib/polygon/models/water.js +82 -37
- package/lib/raster/buffers/triangulation.js +7 -3
- package/lib/raster/index.js +40 -9
- package/lib/raster/models/index.js +5 -0
- package/lib/raster/models/raster.js +125 -80
- package/lib/raster/models/rasterRgb.js +139 -84
- package/lib/raster/models/rasterTerrainRgb.js +93 -56
- package/lib/tile/interaction/getRasterData.js +25 -14
- package/lib/tile/interaction/utils.js +19 -7
- package/lib/tile/manager/base.js +104 -63
- package/lib/tile/service/TileLayerService.js +60 -33
- package/lib/tile/service/TilePickService.js +48 -26
- package/lib/tile/service/TileSourceService.js +16 -2
- package/lib/tile/style/utils.js +3 -0
- package/lib/tile/tileFactory/DebugTile.js +54 -29
- package/lib/tile/tileFactory/ImageTile.js +46 -20
- package/lib/tile/tileFactory/MaskTile.js +51 -22
- package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
- package/lib/tile/tileFactory/RasterTile.js +63 -30
- package/lib/tile/tileFactory/Tile.js +102 -63
- package/lib/tile/tileFactory/VectorTile.js +76 -41
- package/lib/tile/tileFactory/index.js +25 -0
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
- package/lib/tile/tileFactory/util.js +9 -0
- package/lib/tile/tileLayer/BaseLayer.js +153 -105
- package/lib/tile/utils.js +5 -1
- package/lib/utils/blend.js +5 -0
- package/lib/utils/collision-index.js +25 -9
- package/lib/utils/extrude_polyline.js +181 -101
- package/lib/utils/grid-index.js +28 -2
- package/lib/utils/identityScale.js +9 -0
- package/lib/utils/layerData.js +49 -30
- package/lib/utils/multiPassRender.js +16 -11
- package/lib/utils/polylineNormal.js +66 -31
- package/lib/utils/simpleLine.js +21 -2
- package/lib/utils/stencil.js +4 -0
- package/lib/utils/symbol-layout.js +55 -27
- package/lib/wind/index.js +37 -9
- package/lib/wind/models/index.js +3 -0
- package/lib/wind/models/utils.js +62 -26
- package/lib/wind/models/wind.js +157 -101
- package/lib/wind/models/windRender.js +71 -53
- package/lib/wind/models/windShader.js +1 -0
- package/package.json +7 -7
|
@@ -7,45 +7,62 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
|
|
10
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
|
|
11
13
|
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; } }
|
|
14
|
+
|
|
12
15
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
13
16
|
import { rgb2arr } from '@antv/l7-utils';
|
|
14
17
|
import BaseModel from "../../core/BaseModel";
|
|
15
18
|
import { LineArcTriangulation } from "../../core/triangulation";
|
|
16
|
-
import { EARTH_RADIUS } from "../../earth/utils";
|
|
17
|
-
|
|
19
|
+
import { EARTH_RADIUS } from "../../earth/utils"; // arc3d line layer
|
|
20
|
+
|
|
18
21
|
/* babel-plugin-inline-import '../shaders/line_arc_3d_frag.glsl' */
|
|
19
22
|
var arc3d_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying vec4 v_line_data;\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying float v_segmentIndex;\nuniform float segmentNumber;\nuniform float u_opacity;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_line_data.g; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));\n float arcRadio = v_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n gl_FragColor = filterColor(pattern);\n }\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
23
|
+
|
|
20
24
|
/* babel-plugin-inline-import '../shaders/line_arc_3d_vert.glsl' */
|
|
21
25
|
var arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_segmentIndex;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_line_data;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n }\n v_line_data.g = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n\n v_segmentIndex = a_Position.x;\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n\n float arcDistrance = length(source - target);\n float pixelLen = project_pixel_texture(u_icon_step);\n v_line_data.b = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n vec2 projectOffset = project_pixel(offset);\n float lineOffsetWidth = length(projectOffset + projectOffset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_line_data.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n \n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n }\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n"; // arc3d linear layer
|
|
26
|
+
|
|
22
27
|
/* babel-plugin-inline-import '../shaders/linear/arc3d_linear_frag.glsl' */
|
|
23
28
|
var arc3d_linear_frag = "\n#define Animate 0.0\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_Color;\n\nvarying float v_distance_ratio;\n#pragma include \"picking\"\n\nvoid main() {\n\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n gl_FragColor = v_Color;\n\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
29
|
+
|
|
24
30
|
/* babel-plugin-inline-import '../shaders/linear/arc3d_linear_vert.glsl' */
|
|
25
31
|
var arc3d_linear_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute vec2 a_iconMapUV;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_distance_ratio;\n\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n v_Color = mix(u_sourceColor, u_targetColor, a_Position.x/segmentNumber);\n\n v_Color.a *= opacity;\n\n\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n }\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
32
|
var lineStyleObj = {
|
|
27
33
|
solid: 0.0,
|
|
28
34
|
dash: 1.0
|
|
29
35
|
};
|
|
36
|
+
|
|
30
37
|
var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
31
38
|
_inherits(Arc3DModel, _BaseModel);
|
|
39
|
+
|
|
32
40
|
var _super = _createSuper(Arc3DModel);
|
|
41
|
+
|
|
33
42
|
function Arc3DModel() {
|
|
34
43
|
var _this;
|
|
44
|
+
|
|
35
45
|
_classCallCheck(this, Arc3DModel);
|
|
46
|
+
|
|
36
47
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
37
48
|
args[_key] = arguments[_key];
|
|
38
49
|
}
|
|
50
|
+
|
|
39
51
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
52
|
+
|
|
40
53
|
_defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
|
|
41
54
|
var createTexture2D = _this.rendererService.createTexture2D;
|
|
55
|
+
|
|
42
56
|
if (_this.texture) {
|
|
43
57
|
_this.texture.update({
|
|
44
58
|
data: _this.iconService.getCanvas()
|
|
45
59
|
});
|
|
60
|
+
|
|
46
61
|
_this.layer.render();
|
|
62
|
+
|
|
47
63
|
return;
|
|
48
64
|
}
|
|
65
|
+
|
|
49
66
|
_this.texture = createTexture2D({
|
|
50
67
|
data: _this.iconService.getCanvas(),
|
|
51
68
|
mag: gl.NEAREST,
|
|
@@ -55,46 +72,53 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
55
72
|
height: _this.iconService.canvasHeight || 128
|
|
56
73
|
});
|
|
57
74
|
});
|
|
75
|
+
|
|
58
76
|
return _this;
|
|
59
77
|
}
|
|
78
|
+
|
|
60
79
|
_createClass(Arc3DModel, [{
|
|
61
80
|
key: "getUninforms",
|
|
62
81
|
value: function getUninforms() {
|
|
63
82
|
var _ref = this.layer.getLayerConfig(),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
_ref$opacity = _ref.opacity,
|
|
84
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
85
|
+
sourceColor = _ref.sourceColor,
|
|
86
|
+
targetColor = _ref.targetColor,
|
|
87
|
+
_ref$textureBlend = _ref.textureBlend,
|
|
88
|
+
textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
|
|
89
|
+
_ref$lineType = _ref.lineType,
|
|
90
|
+
lineType = _ref$lineType === void 0 ? 'solid' : _ref$lineType,
|
|
91
|
+
_ref$dashArray = _ref.dashArray,
|
|
92
|
+
dashArray = _ref$dashArray === void 0 ? [10, 5] : _ref$dashArray,
|
|
93
|
+
_ref$lineTexture = _ref.lineTexture,
|
|
94
|
+
lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
|
|
95
|
+
_ref$iconStep = _ref.iconStep,
|
|
96
|
+
iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
|
|
97
|
+
_ref$segmentNumber = _ref.segmentNumber,
|
|
98
|
+
segmentNumber = _ref$segmentNumber === void 0 ? 30 : _ref$segmentNumber,
|
|
99
|
+
_ref$globalArcHeight = _ref.globalArcHeight,
|
|
100
|
+
globalArcHeight = _ref$globalArcHeight === void 0 ? 10 : _ref$globalArcHeight;
|
|
101
|
+
|
|
82
102
|
if (dashArray.length === 2) {
|
|
83
103
|
dashArray.push(0, 0);
|
|
84
|
-
}
|
|
104
|
+
} // 转化渐变色
|
|
105
|
+
|
|
85
106
|
|
|
86
|
-
// 转化渐变色
|
|
87
107
|
var useLinearColor = 0; // 默认不生效
|
|
108
|
+
|
|
88
109
|
var sourceColorArr = [0, 0, 0, 0];
|
|
89
110
|
var targetColorArr = [0, 0, 0, 0];
|
|
111
|
+
|
|
90
112
|
if (sourceColor && targetColor) {
|
|
91
113
|
sourceColorArr = rgb2arr(sourceColor);
|
|
92
114
|
targetColorArr = rgb2arr(targetColor);
|
|
93
115
|
useLinearColor = 1;
|
|
94
116
|
}
|
|
117
|
+
|
|
95
118
|
if (this.rendererService.getDirty()) {
|
|
96
119
|
this.texture.bind();
|
|
97
120
|
}
|
|
121
|
+
|
|
98
122
|
return {
|
|
99
123
|
u_globel: 1,
|
|
100
124
|
u_globel_radius: EARTH_RADIUS,
|
|
@@ -122,7 +146,8 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
122
146
|
key: "getAnimateUniforms",
|
|
123
147
|
value: function getAnimateUniforms() {
|
|
124
148
|
var _ref2 = this.layer.getLayerConfig(),
|
|
125
|
-
|
|
149
|
+
animateOption = _ref2.animateOption;
|
|
150
|
+
|
|
126
151
|
return {
|
|
127
152
|
u_animate: this.animateOption2Array(animateOption),
|
|
128
153
|
u_time: this.layer.getLayerAnimateTime()
|
|
@@ -133,26 +158,32 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
133
158
|
value: function () {
|
|
134
159
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
135
160
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
136
|
-
while (1)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
161
|
+
while (1) {
|
|
162
|
+
switch (_context.prev = _context.next) {
|
|
163
|
+
case 0:
|
|
164
|
+
this.updateTexture();
|
|
165
|
+
this.iconService.on('imageUpdate', this.updateTexture);
|
|
166
|
+
return _context.abrupt("return", this.buildModels());
|
|
167
|
+
|
|
168
|
+
case 3:
|
|
169
|
+
case "end":
|
|
170
|
+
return _context.stop();
|
|
171
|
+
}
|
|
144
172
|
}
|
|
145
173
|
}, _callee, this);
|
|
146
174
|
}));
|
|
175
|
+
|
|
147
176
|
function initModels() {
|
|
148
177
|
return _initModels.apply(this, arguments);
|
|
149
178
|
}
|
|
179
|
+
|
|
150
180
|
return initModels;
|
|
151
181
|
}()
|
|
152
182
|
}, {
|
|
153
183
|
key: "clearModels",
|
|
154
184
|
value: function clearModels() {
|
|
155
185
|
var _this$texture;
|
|
186
|
+
|
|
156
187
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
157
188
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
158
189
|
}
|
|
@@ -160,8 +191,9 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
160
191
|
key: "getShaders",
|
|
161
192
|
value: function getShaders() {
|
|
162
193
|
var _ref3 = this.layer.getLayerConfig(),
|
|
163
|
-
|
|
164
|
-
|
|
194
|
+
sourceColor = _ref3.sourceColor,
|
|
195
|
+
targetColor = _ref3.targetColor;
|
|
196
|
+
|
|
165
197
|
if (sourceColor && targetColor) {
|
|
166
198
|
// 分离 linear 功能
|
|
167
199
|
return {
|
|
@@ -182,40 +214,48 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
182
214
|
value: function () {
|
|
183
215
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
184
216
|
var _ref4, _ref4$segmentNumber, segmentNumber, _this$getShaders, frag, vert, type, model;
|
|
217
|
+
|
|
185
218
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
186
|
-
while (1)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
219
|
+
while (1) {
|
|
220
|
+
switch (_context2.prev = _context2.next) {
|
|
221
|
+
case 0:
|
|
222
|
+
_ref4 = this.layer.getLayerConfig(), _ref4$segmentNumber = _ref4.segmentNumber, segmentNumber = _ref4$segmentNumber === void 0 ? 30 : _ref4$segmentNumber;
|
|
223
|
+
_this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
224
|
+
_context2.next = 4;
|
|
225
|
+
return this.layer.buildLayerModel({
|
|
226
|
+
moduleName: 'lineEarthArc3d' + type,
|
|
227
|
+
vertexShader: vert,
|
|
228
|
+
fragmentShader: frag,
|
|
229
|
+
triangulation: LineArcTriangulation,
|
|
230
|
+
depth: {
|
|
231
|
+
enable: true
|
|
232
|
+
},
|
|
233
|
+
segmentNumber: segmentNumber
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
case 4:
|
|
237
|
+
model = _context2.sent;
|
|
238
|
+
return _context2.abrupt("return", [model]);
|
|
239
|
+
|
|
240
|
+
case 6:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context2.stop();
|
|
243
|
+
}
|
|
207
244
|
}
|
|
208
245
|
}, _callee2, this);
|
|
209
246
|
}));
|
|
247
|
+
|
|
210
248
|
function buildModels() {
|
|
211
249
|
return _buildModels.apply(this, arguments);
|
|
212
250
|
}
|
|
251
|
+
|
|
213
252
|
return buildModels;
|
|
214
253
|
}()
|
|
215
254
|
}, {
|
|
216
255
|
key: "registerBuiltinAttributes",
|
|
217
256
|
value: function registerBuiltinAttributes() {
|
|
218
257
|
var _this2 = this;
|
|
258
|
+
|
|
219
259
|
this.styleAttributeService.registerStyleAttribute({
|
|
220
260
|
name: 'size',
|
|
221
261
|
type: AttributeType.Attribute,
|
|
@@ -230,7 +270,7 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
230
270
|
size: 1,
|
|
231
271
|
update: function update(feature) {
|
|
232
272
|
var _feature$size = feature.size,
|
|
233
|
-
|
|
273
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
234
274
|
return Array.isArray(size) ? [size[0]] : [size];
|
|
235
275
|
}
|
|
236
276
|
}
|
|
@@ -265,19 +305,24 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
265
305
|
size: 2,
|
|
266
306
|
update: function update(feature) {
|
|
267
307
|
var iconMap = _this2.iconService.getIconMap();
|
|
308
|
+
|
|
268
309
|
var texture = feature.texture;
|
|
310
|
+
|
|
269
311
|
var _ref5 = iconMap[texture] || {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
312
|
+
x: 0,
|
|
313
|
+
y: 0
|
|
314
|
+
},
|
|
315
|
+
x = _ref5.x,
|
|
316
|
+
y = _ref5.y;
|
|
317
|
+
|
|
275
318
|
return [x, y];
|
|
276
319
|
}
|
|
277
320
|
}
|
|
278
321
|
});
|
|
279
322
|
}
|
|
280
323
|
}]);
|
|
324
|
+
|
|
281
325
|
return Arc3DModel;
|
|
282
326
|
}(BaseModel);
|
|
327
|
+
|
|
283
328
|
export { Arc3DModel as default };
|
package/es/line/models/flow.js
CHANGED
|
@@ -6,35 +6,46 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
|
|
9
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
|
|
10
12
|
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; } }
|
|
13
|
+
|
|
11
14
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
12
15
|
import { rgb2arr } from '@antv/l7-utils';
|
|
13
16
|
import BaseModel from "../../core/BaseModel";
|
|
14
17
|
import { FlowLineFillTriangulation } from "../../core/triangulation";
|
|
18
|
+
|
|
15
19
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
|
|
16
20
|
var flow_line_frag = "#extension GL_OES_standard_derivatives : enable\n\nvarying vec4 v_color;\n\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\ngl_FragColor = v_color;\ngl_FragColor = filterColor(gl_FragColor);\n}\n"; // linear simple line shader
|
|
21
|
+
|
|
17
22
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
|
|
18
23
|
var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvarying vec4 v_color;\nuniform float u_gap_width: 1.0;\nuniform float u_stroke_width: 1.0;\nuniform float u_stroke_opacity: 1.0;\n\n\nvoid main() {\n\n// #ifdef USE_ATTRIBUTE_OPACITY\n// float opacity = a_Opacity;\n// #else\n// float opacity = u_opacity;\n// #endif\n\n\n// #ifdef USE_ATTRIBUTE_OFFSETS\n// vec2 offsets = a_Offsets;\n// #else\n// vec2 offsets = u_offsets;\n// #endif\n\n // float opacity = u_opacity;\n// \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = normalize(target - source);\n vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);\n\n\n vec2 position = mix(source, target, a_Position.x);\n\n float lengthCommon = length(target - source); \n vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);\n vec2 limitedOffsetDistances = clamp( \n offsetDistances,\n -lengthCommon*.8, lengthCommon*.8\n );\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon*.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon*.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);\n\n float gapCommon = project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offsetCommon.xy, 0., 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n }\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
24
|
+
|
|
19
25
|
var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
20
26
|
_inherits(FlowLineModel, _BaseModel);
|
|
27
|
+
|
|
21
28
|
var _super = _createSuper(FlowLineModel);
|
|
29
|
+
|
|
22
30
|
function FlowLineModel() {
|
|
23
31
|
_classCallCheck(this, FlowLineModel);
|
|
32
|
+
|
|
24
33
|
return _super.apply(this, arguments);
|
|
25
34
|
}
|
|
35
|
+
|
|
26
36
|
_createClass(FlowLineModel, [{
|
|
27
37
|
key: "getUninforms",
|
|
28
38
|
value: function getUninforms() {
|
|
29
39
|
var _ref = this.layer.getLayerConfig(),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
_ref$gapWidth = _ref.gapWidth,
|
|
41
|
+
gapWidth = _ref$gapWidth === void 0 ? 2 : _ref$gapWidth,
|
|
42
|
+
_ref$strokeWidth = _ref.strokeWidth,
|
|
43
|
+
strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
|
|
44
|
+
_ref$stroke = _ref.stroke,
|
|
45
|
+
stroke = _ref$stroke === void 0 ? '#000' : _ref$stroke,
|
|
46
|
+
_ref$strokeOpacity = _ref.strokeOpacity,
|
|
47
|
+
strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity;
|
|
48
|
+
|
|
38
49
|
return _objectSpread({
|
|
39
50
|
// u_opacity: opacity,
|
|
40
51
|
// u_offsets: offsets,
|
|
@@ -49,18 +60,23 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
49
60
|
value: function () {
|
|
50
61
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
51
62
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
52
|
-
while (1)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
while (1) {
|
|
64
|
+
switch (_context.prev = _context.next) {
|
|
65
|
+
case 0:
|
|
66
|
+
return _context.abrupt("return", this.buildModels());
|
|
67
|
+
|
|
68
|
+
case 1:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
73
|
}, _callee, this);
|
|
60
74
|
}));
|
|
75
|
+
|
|
61
76
|
function initModels() {
|
|
62
77
|
return _initModels.apply(this, arguments);
|
|
63
78
|
}
|
|
79
|
+
|
|
64
80
|
return initModels;
|
|
65
81
|
}()
|
|
66
82
|
}, {
|
|
@@ -69,33 +85,39 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
69
85
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
70
86
|
var modelFill;
|
|
71
87
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
72
|
-
while (1)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
while (1) {
|
|
89
|
+
switch (_context2.prev = _context2.next) {
|
|
90
|
+
case 0:
|
|
91
|
+
_context2.next = 2;
|
|
92
|
+
return this.layer.buildLayerModel({
|
|
93
|
+
moduleName: 'flow_line',
|
|
94
|
+
vertexShader: flow_line_vert,
|
|
95
|
+
fragmentShader: flow_line_frag,
|
|
96
|
+
inject: this.getInject(),
|
|
97
|
+
triangulation: FlowLineFillTriangulation,
|
|
98
|
+
primitive: gl.TRIANGLES,
|
|
99
|
+
depth: {
|
|
100
|
+
enable: false
|
|
101
|
+
},
|
|
102
|
+
pick: false
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
case 2:
|
|
106
|
+
modelFill = _context2.sent;
|
|
107
|
+
return _context2.abrupt("return", [modelFill]);
|
|
108
|
+
|
|
109
|
+
case 4:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context2.stop();
|
|
112
|
+
}
|
|
93
113
|
}
|
|
94
114
|
}, _callee2, this);
|
|
95
115
|
}));
|
|
116
|
+
|
|
96
117
|
function buildModels() {
|
|
97
118
|
return _buildModels.apply(this, arguments);
|
|
98
119
|
}
|
|
120
|
+
|
|
99
121
|
return buildModels;
|
|
100
122
|
}()
|
|
101
123
|
}, {
|
|
@@ -117,7 +139,7 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
117
139
|
size: 2,
|
|
118
140
|
update: function update(feature) {
|
|
119
141
|
var _feature$size = feature.size,
|
|
120
|
-
|
|
142
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
121
143
|
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
122
144
|
}
|
|
123
145
|
}
|
|
@@ -158,6 +180,8 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
158
180
|
});
|
|
159
181
|
}
|
|
160
182
|
}]);
|
|
183
|
+
|
|
161
184
|
return FlowLineModel;
|
|
162
185
|
}(BaseModel);
|
|
186
|
+
|
|
163
187
|
export { FlowLineModel as default };
|