@antv/l7-layers 2.21.8 → 2.21.9-beta.0
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/citybuliding/models/build.d.ts +16 -0
- package/es/citybuliding/models/build.js +18 -20
- package/es/citybuliding/shaders/build_frag.glsl +6 -6
- package/es/citybuliding/shaders/build_vert.glsl +8 -14
- package/es/core/BaseLayer.js +9 -8
- package/es/core/BaseModel.d.ts +15 -2
- package/es/core/BaseModel.js +94 -62
- package/es/core/CommonStyleAttribute.d.ts +14 -18
- package/es/core/CommonStyleAttribute.js +23 -67
- package/es/core/triangulation.js +13 -39
- package/es/earth/models/atmosphere.d.ts +15 -0
- package/es/earth/models/atmosphere.js +30 -24
- package/es/earth/models/base.d.ts +15 -0
- package/es/earth/models/base.js +30 -24
- package/es/earth/models/bloomsphere.d.ts +15 -0
- package/es/earth/models/bloomsphere.js +30 -24
- package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
- package/es/earth/shaders/base/base_vert.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
- package/es/geometry/models/billboard.d.ts +15 -0
- package/es/geometry/models/billboard.js +14 -8
- package/es/geometry/models/plane.d.ts +14 -0
- package/es/geometry/models/plane.js +10 -10
- package/es/geometry/models/sprite.js +3 -9
- package/es/geometry/shaders/billboard_vert.glsl +28 -25
- package/es/geometry/shaders/plane_vert.glsl +6 -6
- package/es/geometry/shaders/sprite_vert.glsl +7 -9
- package/es/heatmap/models/grid.d.ts +14 -0
- package/es/heatmap/models/grid.js +10 -3
- package/es/heatmap/models/grid3d.d.ts +16 -0
- package/es/heatmap/models/grid3d.js +14 -6
- package/es/heatmap/models/heatmap.d.ts +20 -1
- package/es/heatmap/models/heatmap.js +96 -83
- package/es/heatmap/models/hexagon.d.ts +14 -0
- package/es/heatmap/models/hexagon.js +9 -3
- package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
- package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
- package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
- package/es/image/models/image.d.ts +14 -0
- package/es/image/models/image.js +11 -3
- package/es/image/shaders/image_vert.glsl +7 -6
- package/es/line/models/arc.d.ts +18 -0
- package/es/line/models/arc.js +57 -8
- package/es/line/models/arc_3d.d.ts +18 -0
- package/es/line/models/arc_3d.js +55 -7
- package/es/line/models/flow.d.ts +17 -0
- package/es/line/models/flow.js +35 -7
- package/es/line/models/great_circle.d.ts +17 -0
- package/es/line/models/great_circle.js +34 -6
- package/es/line/models/line.d.ts +17 -0
- package/es/line/models/line.js +17 -8
- package/es/line/models/simple_line.d.ts +14 -0
- package/es/line/models/simple_line.js +12 -47
- package/es/line/models/wall.d.ts +17 -0
- package/es/line/models/wall.js +22 -48
- package/es/line/shaders/arc/line_arc_vert.glsl +42 -48
- package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
- package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
- package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +56 -72
- package/es/line/shaders/line/line_vert.glsl +31 -48
- package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
- package/es/line/shaders/wall/wall_vert.glsl +36 -45
- package/es/mask/models/fill.js +2 -1
- package/es/mask/shaders/mask_vert.glsl +2 -7
- package/es/plugins/DataMappingPlugin.d.ts +0 -1
- package/es/plugins/DataMappingPlugin.js +1 -24
- package/es/plugins/PixelPickingPlugin.js +2 -2
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
- package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
- package/es/plugins/ShaderUniformPlugin.js +2 -34
- package/es/point/models/billboard_point.d.ts +14 -0
- package/es/point/models/billboard_point.js +11 -3
- package/es/point/models/earthExtrude.d.ts +16 -0
- package/es/point/models/earthExtrude.js +15 -8
- package/es/point/models/earthFill.d.ts +16 -0
- package/es/point/models/earthFill.js +13 -5
- package/es/point/models/extrude.d.ts +16 -0
- package/es/point/models/extrude.js +19 -12
- package/es/point/models/fill.d.ts +16 -0
- package/es/point/models/fill.js +16 -5
- package/es/point/models/fillImage.d.ts +16 -0
- package/es/point/models/fillImage.js +16 -16
- package/es/point/models/image.d.ts +15 -0
- package/es/point/models/image.js +14 -4
- package/es/point/models/normal.d.ts +14 -0
- package/es/point/models/normal.js +11 -3
- package/es/point/models/radar.d.ts +15 -0
- package/es/point/models/radar.js +13 -4
- package/es/point/models/text.d.ts +16 -0
- package/es/point/models/text.js +18 -11
- package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
- package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
- package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
- package/es/point/shaders/fill/fill_vert.glsl +12 -14
- package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
- package/es/point/shaders/image/image_vert.glsl +15 -12
- package/es/point/shaders/normal/normal_vert.glsl +7 -10
- package/es/point/shaders/radar/radar_vert.glsl +11 -11
- package/es/point/shaders/text/text_vert.glsl +10 -9
- package/es/polygon/models/extrude.d.ts +16 -0
- package/es/polygon/models/extrude.js +26 -26
- package/es/polygon/models/extrusion.d.ts +16 -0
- package/es/polygon/models/extrusion.js +34 -4
- package/es/polygon/models/fill.d.ts +14 -0
- package/es/polygon/models/fill.js +12 -4
- package/es/polygon/models/ocean.d.ts +14 -0
- package/es/polygon/models/ocean.js +11 -6
- package/es/polygon/models/water.d.ts +14 -0
- package/es/polygon/models/water.js +11 -6
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
- package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
- package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
- package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
- package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
- package/es/raster/index.d.ts +1 -1
- package/es/raster/index.js +1 -1
- package/es/raster/models/raster.d.ts +14 -0
- package/es/raster/models/raster.js +12 -3
- package/es/raster/models/rasterRgb.d.ts +14 -0
- package/es/raster/models/rasterRgb.js +12 -3
- package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
- package/es/raster/models/rasterTerrainRgb.js +11 -3
- package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
- package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
- package/es/tile/core/BaseLayer.js +0 -16
- package/es/utils/extrude_polyline.d.ts +0 -15
- package/es/utils/extrude_polyline.js +0 -217
- package/es/wind/models/wind.d.ts +14 -0
- package/es/wind/models/wind.js +9 -1
- package/es/wind/shaders/wind_vert.glsl +6 -5
- package/lib/citybuliding/models/build.d.ts +16 -0
- package/lib/citybuliding/models/build.js +18 -20
- package/lib/citybuliding/shaders/build_frag.glsl +6 -6
- package/lib/citybuliding/shaders/build_vert.glsl +8 -14
- package/lib/core/BaseLayer.js +9 -8
- package/lib/core/BaseModel.d.ts +15 -2
- package/lib/core/BaseModel.js +92 -60
- package/lib/core/CommonStyleAttribute.d.ts +14 -18
- package/lib/core/CommonStyleAttribute.js +23 -68
- package/lib/core/triangulation.js +13 -39
- package/lib/earth/models/atmosphere.d.ts +15 -0
- package/lib/earth/models/atmosphere.js +30 -24
- package/lib/earth/models/base.d.ts +15 -0
- package/lib/earth/models/base.js +30 -24
- package/lib/earth/models/bloomsphere.d.ts +15 -0
- package/lib/earth/models/bloomsphere.js +30 -24
- package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
- package/lib/earth/shaders/base/base_vert.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
- package/lib/geometry/models/billboard.d.ts +15 -0
- package/lib/geometry/models/billboard.js +14 -8
- package/lib/geometry/models/plane.d.ts +14 -0
- package/lib/geometry/models/plane.js +10 -10
- package/lib/geometry/models/sprite.js +3 -9
- package/lib/geometry/shaders/billboard_vert.glsl +28 -25
- package/lib/geometry/shaders/plane_vert.glsl +6 -6
- package/lib/geometry/shaders/sprite_vert.glsl +7 -9
- package/lib/heatmap/models/grid.d.ts +14 -0
- package/lib/heatmap/models/grid.js +10 -3
- package/lib/heatmap/models/grid3d.d.ts +16 -0
- package/lib/heatmap/models/grid3d.js +14 -6
- package/lib/heatmap/models/heatmap.d.ts +20 -1
- package/lib/heatmap/models/heatmap.js +95 -82
- package/lib/heatmap/models/hexagon.d.ts +14 -0
- package/lib/heatmap/models/hexagon.js +9 -3
- package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
- package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
- package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
- package/lib/image/models/image.d.ts +14 -0
- package/lib/image/models/image.js +11 -3
- package/lib/image/shaders/image_vert.glsl +7 -6
- package/lib/line/models/arc.d.ts +18 -0
- package/lib/line/models/arc.js +56 -7
- package/lib/line/models/arc_3d.d.ts +18 -0
- package/lib/line/models/arc_3d.js +55 -7
- package/lib/line/models/flow.d.ts +17 -0
- package/lib/line/models/flow.js +35 -7
- package/lib/line/models/great_circle.d.ts +17 -0
- package/lib/line/models/great_circle.js +33 -5
- package/lib/line/models/line.d.ts +17 -0
- package/lib/line/models/line.js +17 -8
- package/lib/line/models/simple_line.d.ts +14 -0
- package/lib/line/models/simple_line.js +12 -47
- package/lib/line/models/wall.d.ts +17 -0
- package/lib/line/models/wall.js +22 -48
- package/lib/line/shaders/arc/line_arc_vert.glsl +42 -48
- package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
- package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
- package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +56 -72
- package/lib/line/shaders/line/line_vert.glsl +31 -48
- package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
- package/lib/line/shaders/wall/wall_vert.glsl +36 -45
- package/lib/mask/models/fill.js +2 -1
- package/lib/mask/shaders/mask_vert.glsl +2 -7
- package/lib/plugins/DataMappingPlugin.d.ts +0 -1
- package/lib/plugins/DataMappingPlugin.js +0 -23
- package/lib/plugins/PixelPickingPlugin.js +1 -1
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
- package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
- package/lib/plugins/ShaderUniformPlugin.js +2 -34
- package/lib/point/models/billboard_point.d.ts +14 -0
- package/lib/point/models/billboard_point.js +11 -3
- package/lib/point/models/earthExtrude.d.ts +16 -0
- package/lib/point/models/earthExtrude.js +14 -7
- package/lib/point/models/earthFill.d.ts +16 -0
- package/lib/point/models/earthFill.js +13 -5
- package/lib/point/models/extrude.d.ts +16 -0
- package/lib/point/models/extrude.js +18 -11
- package/lib/point/models/fill.d.ts +16 -0
- package/lib/point/models/fill.js +16 -5
- package/lib/point/models/fillImage.d.ts +16 -0
- package/lib/point/models/fillImage.js +16 -16
- package/lib/point/models/image.d.ts +15 -0
- package/lib/point/models/image.js +14 -4
- package/lib/point/models/normal.d.ts +14 -0
- package/lib/point/models/normal.js +11 -3
- package/lib/point/models/radar.d.ts +15 -0
- package/lib/point/models/radar.js +13 -4
- package/lib/point/models/text.d.ts +16 -0
- package/lib/point/models/text.js +18 -11
- package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
- package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
- package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
- package/lib/point/shaders/fill/fill_vert.glsl +12 -14
- package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
- package/lib/point/shaders/image/image_vert.glsl +15 -12
- package/lib/point/shaders/normal/normal_vert.glsl +7 -10
- package/lib/point/shaders/radar/radar_vert.glsl +11 -11
- package/lib/point/shaders/text/text_vert.glsl +10 -9
- package/lib/polygon/models/extrude.d.ts +16 -0
- package/lib/polygon/models/extrude.js +25 -25
- package/lib/polygon/models/extrusion.d.ts +16 -0
- package/lib/polygon/models/extrusion.js +34 -4
- package/lib/polygon/models/fill.d.ts +14 -0
- package/lib/polygon/models/fill.js +12 -4
- package/lib/polygon/models/ocean.d.ts +14 -0
- package/lib/polygon/models/ocean.js +11 -6
- package/lib/polygon/models/water.d.ts +14 -0
- package/lib/polygon/models/water.js +11 -6
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
- package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
- package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
- package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
- package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
- package/lib/raster/index.d.ts +1 -1
- package/lib/raster/index.js +2 -2
- package/lib/raster/models/raster.d.ts +14 -0
- package/lib/raster/models/raster.js +12 -3
- package/lib/raster/models/rasterRgb.d.ts +14 -0
- package/lib/raster/models/rasterRgb.js +12 -3
- package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
- package/lib/raster/models/rasterTerrainRgb.js +11 -3
- package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
- package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
- package/lib/tile/core/BaseLayer.js +0 -16
- package/lib/utils/extrude_polyline.d.ts +0 -15
- package/lib/utils/extrude_polyline.js +0 -217
- package/lib/wind/models/wind.d.ts +14 -0
- package/lib/wind/models/wind.js +9 -1
- package/lib/wind/shaders/wind_vert.glsl +6 -5
- package/package.json +6 -6
|
@@ -2,6 +2,20 @@ import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class ImageModel extends BaseModel {
|
|
4
4
|
protected texture: ITexture2D;
|
|
5
|
+
protected get attributeLocation(): {
|
|
6
|
+
readonly POSITION: 0;
|
|
7
|
+
readonly POSITION_64LOW: 1;
|
|
8
|
+
readonly COLOR: 2;
|
|
9
|
+
readonly PICKING_COLOR: 3;
|
|
10
|
+
readonly STROKE: 4;
|
|
11
|
+
readonly OPACITY: 5;
|
|
12
|
+
readonly OFFSETS: 6;
|
|
13
|
+
readonly ROTATION: 7;
|
|
14
|
+
readonly MAX: 8;
|
|
15
|
+
} & Record<string, number> & {
|
|
16
|
+
MAX: 8;
|
|
17
|
+
UV: number;
|
|
18
|
+
};
|
|
5
19
|
protected getCommonUniformsInfo(): {
|
|
6
20
|
uniformsArray: number[];
|
|
7
21
|
uniformsLength: number;
|
|
@@ -10,17 +10,22 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _l7Core = require("@antv/l7-core");
|
|
11
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
var _triangulation = require("../../core/triangulation");
|
|
15
14
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
16
15
|
const ImageFrag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_opacity:1.0;\n float u_brightness:1.0;\n float u_contrast:1.0;\n float u_saturation:1.0;\n float u_gamma:1.0;\n};\n\nin vec2 v_texCoord;\nout vec4 outputColor;\nvec3 setContrast(vec3 rgb, float contrast) {\n vec3 color = mix(vec3(0.5), rgb, contrast);\n color = clamp(color, 0.0, 1.0);\n return color;\n}\nvec3 setSaturation(vec3 rgb, float adjustment) {\n const vec3 grayVector = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, grayVector));\n vec3 color = mix(intensity, rgb, adjustment);\n color = clamp(color, 0.0, 1.0);\n return color;\n}\nvoid main() {\n vec4 color = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y));\n //brightness\n color.rgb = mix(vec3(0.0, 0.0, 0.0), color.rgb, u_brightness);\n //contrast\n color.rgb = setContrast(color.rgb, u_contrast);\n // saturation\n color.rgb = setSaturation(color.rgb, u_saturation);\n // gamma\n color.rgb = pow(color.rgb, vec3(u_gamma));\n outputColor = color;\n outputColor.a *= u_opacity;\n if(outputColor.a < 0.01)\n discard;\n}\n";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
18
|
-
const ImageVert = "layout(location =
|
|
17
|
+
const ImageVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity:1.0;\n float u_brightness:1.0;\n float u_contrast:1.0;\n float u_saturation:1.0;\n float u_gamma:1.0;\n};\n\nout vec2 v_texCoord;\n#pragma include \"projection\"\n\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));\n}\n";
|
|
19
18
|
class ImageModel extends _BaseModel.default {
|
|
20
19
|
constructor(...args) {
|
|
21
20
|
super(...args);
|
|
22
21
|
(0, _defineProperty2.default)(this, "texture", void 0);
|
|
23
22
|
}
|
|
23
|
+
get attributeLocation() {
|
|
24
|
+
return Object.assign(super.attributeLocation, {
|
|
25
|
+
MAX: super.attributeLocation.MAX,
|
|
26
|
+
UV: 9
|
|
27
|
+
});
|
|
28
|
+
}
|
|
24
29
|
getCommonUniformsInfo() {
|
|
25
30
|
const {
|
|
26
31
|
opacity,
|
|
@@ -80,6 +85,7 @@ class ImageModel extends _BaseModel.default {
|
|
|
80
85
|
moduleName: 'rasterImage',
|
|
81
86
|
vertexShader: ImageVert,
|
|
82
87
|
fragmentShader: ImageFrag,
|
|
88
|
+
defines: _this3.getDefines(),
|
|
83
89
|
triangulation: _triangulation.RasterImageTriangulation,
|
|
84
90
|
primitive: _l7Core.gl.TRIANGLES,
|
|
85
91
|
blend: {
|
|
@@ -95,12 +101,14 @@ class ImageModel extends _BaseModel.default {
|
|
|
95
101
|
})();
|
|
96
102
|
}
|
|
97
103
|
registerBuiltinAttributes() {
|
|
104
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
|
|
105
|
+
this.registerPosition64LowAttribute();
|
|
98
106
|
this.styleAttributeService.registerStyleAttribute({
|
|
99
107
|
name: 'uv',
|
|
100
108
|
type: _l7Core.AttributeType.Attribute,
|
|
101
109
|
descriptor: {
|
|
102
110
|
name: 'a_Uv',
|
|
103
|
-
shaderLocation:
|
|
111
|
+
shaderLocation: this.attributeLocation.UV,
|
|
104
112
|
buffer: {
|
|
105
113
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
106
114
|
data: [],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
|
|
3
4
|
|
|
4
5
|
layout(std140) uniform commonUniforms {
|
|
5
6
|
float u_opacity:1.0;
|
|
@@ -11,9 +12,9 @@ layout(std140) uniform commonUniforms {
|
|
|
11
12
|
|
|
12
13
|
out vec2 v_texCoord;
|
|
13
14
|
#pragma include "projection"
|
|
15
|
+
|
|
14
16
|
void main() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
v_texCoord = a_Uv;
|
|
18
|
+
vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
|
|
19
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));
|
|
19
20
|
}
|
package/lib/line/models/arc.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class ArcModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
SIZE: number;
|
|
17
|
+
INSTANCE: number;
|
|
18
|
+
INSTANCE_64LOW: number;
|
|
19
|
+
UV: number;
|
|
20
|
+
THETA_OFFSET: number;
|
|
21
|
+
};
|
|
4
22
|
protected texture: ITexture2D;
|
|
5
23
|
protected getCommonUniformsInfo(): {
|
|
6
24
|
uniformsArray: number[];
|
package/lib/line/models/arc.js
CHANGED
|
@@ -10,12 +10,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _l7Core = require("@antv/l7-core");
|
|
11
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
var _triangulation = require("../../core/triangulation");
|
|
15
14
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_frag.glsl' */
|
|
16
15
|
const arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\n\nin vec4 v_color;\nin vec2 v_iconMapUV;\nin vec4 v_lineData;\n//dash\nin vec4 v_dash_array;\nin float v_distance_ratio;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_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 discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n outputColor = v_color;\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- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\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 outputColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \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 float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture(SAMPLER_2D(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 outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = filterColor(pattern);\n }\n \n } else {\n outputColor = filterColor(outputColor);\n }\n}";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_vert.glsl' */
|
|
18
|
-
const arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\nlayout(location =
|
|
17
|
+
const arc_line_vert = "#define Animate (0.0)\n#define LineTexture (1.0)\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\n\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_lineData;\n//dash\nout vec4 v_dash_array;\nout float v_distance_ratio;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1.0 - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2 * cos(theta2) + source.x, r2 * sin(theta2) + source.y);\n if (u_lineDir == 1.0) {\n // \u6B63\u5411\n return mid;\n } else {\n // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n // return index / (segmentNumber - 1.);\n}\nvec2 interpolate(vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x, t), bezier3(y, t));\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 vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\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 dir_screenspace.xy * sign(offset_direction);\n}\n\nvoid main() {\n //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if (u_linearColor == 1.0) {\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex / segmentNumber);\n } else {\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n\n vec2 source_world = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target_world = a_Instance.ba; // \u7EC8\u70B9\n\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n // \u8BA1\u7B97 dashArray \u548C distanceRatio \u8F93\u51FA\u5230\u7247\u5143\n float total_Distance = pixelDistance(source_world, target_world) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n v_distance_ratio = segmentIndex / segmentNumber;\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n\n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_lineData.b = d_distance_ratio;\n\n vec4 source = project_position(vec4(source_world, 0, 1.), a_Instance64Low.xy);\n vec4 target = project_position(vec4(target_world, 0, 1.), a_Instance64Low.zw);\n\n vec2 currPos = interpolate(source.xy, target.xy, segmentRatio, thetaOffset);\n vec2 nextPos = interpolate(source.xy, target.xy, nextSegmentRatio, thetaOffset);\n\n vec2 offset = project_pixel(\n getExtrusionOffset((nextPos.xy - currPos.xy) * indexDir, a_Position.y)\n );\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_lineData.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance / pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_lineData.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * 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\n v_lineData.a = lineOffsetWidth / linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(currPos.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
18
|
const lineStyleObj = {
|
|
20
19
|
solid: 0.0,
|
|
21
20
|
dash: 1.0
|
|
@@ -46,6 +45,16 @@ class ArcModel extends _BaseModel.default {
|
|
|
46
45
|
this.textures = [this.texture];
|
|
47
46
|
});
|
|
48
47
|
}
|
|
48
|
+
get attributeLocation() {
|
|
49
|
+
return Object.assign(super.attributeLocation, {
|
|
50
|
+
MAX: super.attributeLocation.MAX,
|
|
51
|
+
SIZE: 9,
|
|
52
|
+
INSTANCE: 10,
|
|
53
|
+
INSTANCE_64LOW: 11,
|
|
54
|
+
UV: 12,
|
|
55
|
+
THETA_OFFSET: 13
|
|
56
|
+
});
|
|
57
|
+
}
|
|
49
58
|
getCommonUniformsInfo() {
|
|
50
59
|
const {
|
|
51
60
|
sourceColor,
|
|
@@ -152,6 +161,7 @@ class ArcModel extends _BaseModel.default {
|
|
|
152
161
|
moduleName: 'lineArc2d' + type,
|
|
153
162
|
vertexShader: vert,
|
|
154
163
|
fragmentShader: frag,
|
|
164
|
+
defines: _this2.getDefines(),
|
|
155
165
|
inject: _this2.getInject(),
|
|
156
166
|
triangulation: _triangulation.LineArcTriangulation,
|
|
157
167
|
depth: {
|
|
@@ -170,7 +180,7 @@ class ArcModel extends _BaseModel.default {
|
|
|
170
180
|
type: _l7Core.AttributeType.Attribute,
|
|
171
181
|
descriptor: {
|
|
172
182
|
name: 'a_Size',
|
|
173
|
-
shaderLocation:
|
|
183
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
174
184
|
buffer: {
|
|
175
185
|
// give the WebGL driver a hint that this buffer may change
|
|
176
186
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -186,13 +196,14 @@ class ArcModel extends _BaseModel.default {
|
|
|
186
196
|
}
|
|
187
197
|
}
|
|
188
198
|
});
|
|
199
|
+
|
|
200
|
+
// 弧线起始点信息
|
|
189
201
|
this.styleAttributeService.registerStyleAttribute({
|
|
190
202
|
name: 'instance',
|
|
191
|
-
// 弧线起始点信息
|
|
192
203
|
type: _l7Core.AttributeType.Attribute,
|
|
193
204
|
descriptor: {
|
|
194
205
|
name: 'a_Instance',
|
|
195
|
-
shaderLocation:
|
|
206
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
196
207
|
buffer: {
|
|
197
208
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
198
209
|
data: [],
|
|
@@ -204,14 +215,32 @@ class ArcModel extends _BaseModel.default {
|
|
|
204
215
|
}
|
|
205
216
|
}
|
|
206
217
|
});
|
|
218
|
+
|
|
219
|
+
// save low part for enabled double precision INSTANCE attribute
|
|
220
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
221
|
+
name: 'instance64Low',
|
|
222
|
+
type: _l7Core.AttributeType.Attribute,
|
|
223
|
+
descriptor: {
|
|
224
|
+
name: 'a_Instance64Low',
|
|
225
|
+
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
226
|
+
buffer: {
|
|
227
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
228
|
+
data: [],
|
|
229
|
+
type: _l7Core.gl.FLOAT
|
|
230
|
+
},
|
|
231
|
+
size: 4,
|
|
232
|
+
update: (feature, featureIdx, vertex) => {
|
|
233
|
+
return [(0, _l7Utils.fp64LowPart)(vertex[3]), (0, _l7Utils.fp64LowPart)(vertex[4]), (0, _l7Utils.fp64LowPart)(vertex[5]), (0, _l7Utils.fp64LowPart)(vertex[6])];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
207
237
|
this.styleAttributeService.registerStyleAttribute({
|
|
208
238
|
name: 'uv',
|
|
209
239
|
type: _l7Core.AttributeType.Attribute,
|
|
210
240
|
descriptor: {
|
|
211
241
|
name: 'a_iconMapUV',
|
|
212
|
-
shaderLocation:
|
|
242
|
+
shaderLocation: this.attributeLocation.UV,
|
|
213
243
|
buffer: {
|
|
214
|
-
// give the WebGL driver a hint that this buffer may change
|
|
215
244
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
216
245
|
data: [],
|
|
217
246
|
type: _l7Core.gl.FLOAT
|
|
@@ -233,6 +262,26 @@ class ArcModel extends _BaseModel.default {
|
|
|
233
262
|
}
|
|
234
263
|
}
|
|
235
264
|
});
|
|
265
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
266
|
+
name: 'thetaOffset',
|
|
267
|
+
type: _l7Core.AttributeType.Attribute,
|
|
268
|
+
descriptor: {
|
|
269
|
+
name: 'a_ThetaOffset',
|
|
270
|
+
shaderLocation: this.attributeLocation.THETA_OFFSET,
|
|
271
|
+
buffer: {
|
|
272
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
273
|
+
data: [],
|
|
274
|
+
type: _l7Core.gl.FLOAT
|
|
275
|
+
},
|
|
276
|
+
size: 1,
|
|
277
|
+
update: feature => {
|
|
278
|
+
const {
|
|
279
|
+
thetaOffset: op = 1
|
|
280
|
+
} = feature;
|
|
281
|
+
return [op];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
236
285
|
}
|
|
237
286
|
}
|
|
238
287
|
exports.default = ArcModel;
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class Arc3DModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
SIZE: number;
|
|
17
|
+
INSTANCE: number;
|
|
18
|
+
INSTANCE_64LOW: number;
|
|
19
|
+
UV: number;
|
|
20
|
+
THETA_OFFSET: number;
|
|
21
|
+
};
|
|
4
22
|
protected texture: ITexture2D;
|
|
5
23
|
protected getCommonUniformsInfo(): {
|
|
6
24
|
uniformsArray: number[];
|
|
@@ -12,12 +12,11 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
13
|
var _triangulation = require("../../core/triangulation");
|
|
14
14
|
var _utils = require("../../earth/utils");
|
|
15
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
16
|
-
// arc3d line layer
|
|
17
15
|
/* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_frag.glsl' */
|
|
16
|
+
// arc3d line layer
|
|
18
17
|
const arc3d_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array: [10.0, 5., 0, 0];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_globel;\n float u_globel_radius;\n float u_global_height: 10;\n float segmentNumber;\n float u_line_type: 0.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_time;\n float u_linearColor: 0.0;\n};\n\n// varying vec2 v_normal;\nin vec4 v_dash_array;\nin vec4 v_color;\nin vec4 v_line_data;\nin float v_segmentIndex;\nin vec2 v_iconMapUV;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\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 outputColor = v_color;\n\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 outputColor.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 outputColor.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 = texture(SAMPLER_2D(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 outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n outputColor = filterColor(pattern);\n }\n }\n\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
19
18
|
/* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_vert.glsl' */
|
|
20
|
-
const arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nlayout(location =
|
|
19
|
+
const arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;\n\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array: [10.0, 5., 0, 0];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_globel;\n float u_globel_radius;\n float u_global_height: 10;\n float segmentNumber;\n float u_line_type: 0.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_time;\n float u_linearColor: 0.0;\n};\nout vec4 v_color;\nout vec4 v_dash_array;\nout float v_segmentIndex;\nout vec2 v_iconMapUV;\nout 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 dir_screenspace.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 //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0), a_Instance64Low.xy).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0), a_Instance64Low.zw).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(source, target) / 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 * thetaOffset, 1.0));\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";
|
|
21
20
|
const lineStyleObj = {
|
|
22
21
|
solid: 0.0,
|
|
23
22
|
dash: 1.0
|
|
@@ -48,6 +47,16 @@ class Arc3DModel extends _BaseModel.default {
|
|
|
48
47
|
this.textures = [this.texture];
|
|
49
48
|
});
|
|
50
49
|
}
|
|
50
|
+
get attributeLocation() {
|
|
51
|
+
return Object.assign(super.attributeLocation, {
|
|
52
|
+
MAX: super.attributeLocation.MAX,
|
|
53
|
+
SIZE: 9,
|
|
54
|
+
INSTANCE: 10,
|
|
55
|
+
INSTANCE_64LOW: 11,
|
|
56
|
+
UV: 12,
|
|
57
|
+
THETA_OFFSET: 13
|
|
58
|
+
});
|
|
59
|
+
}
|
|
51
60
|
// public enableShaderEncodeStyles = ['opacity'];
|
|
52
61
|
getCommonUniformsInfo() {
|
|
53
62
|
const {
|
|
@@ -147,6 +156,7 @@ class Arc3DModel extends _BaseModel.default {
|
|
|
147
156
|
moduleName: 'lineArc3d' + type,
|
|
148
157
|
vertexShader: vert,
|
|
149
158
|
fragmentShader: frag,
|
|
159
|
+
defines: _this2.getDefines(),
|
|
150
160
|
inject: _this2.getInject(),
|
|
151
161
|
triangulation: _triangulation.LineArcTriangulation,
|
|
152
162
|
styleOption: {
|
|
@@ -162,9 +172,8 @@ class Arc3DModel extends _BaseModel.default {
|
|
|
162
172
|
type: _l7Core.AttributeType.Attribute,
|
|
163
173
|
descriptor: {
|
|
164
174
|
name: 'a_Size',
|
|
165
|
-
shaderLocation:
|
|
175
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
166
176
|
buffer: {
|
|
167
|
-
// give the WebGL driver a hint that this buffer may change
|
|
168
177
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
169
178
|
data: [],
|
|
170
179
|
type: _l7Core.gl.FLOAT
|
|
@@ -184,7 +193,7 @@ class Arc3DModel extends _BaseModel.default {
|
|
|
184
193
|
type: _l7Core.AttributeType.Attribute,
|
|
185
194
|
descriptor: {
|
|
186
195
|
name: 'a_Instance',
|
|
187
|
-
shaderLocation:
|
|
196
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
188
197
|
buffer: {
|
|
189
198
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
190
199
|
data: [],
|
|
@@ -196,12 +205,31 @@ class Arc3DModel extends _BaseModel.default {
|
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
207
|
});
|
|
208
|
+
|
|
209
|
+
// save low part for enabled double precision INSTANCE attribute
|
|
210
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
211
|
+
name: 'instance64Low',
|
|
212
|
+
type: _l7Core.AttributeType.Attribute,
|
|
213
|
+
descriptor: {
|
|
214
|
+
name: 'a_Instance64Low',
|
|
215
|
+
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
216
|
+
buffer: {
|
|
217
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
218
|
+
data: [],
|
|
219
|
+
type: _l7Core.gl.FLOAT
|
|
220
|
+
},
|
|
221
|
+
size: 4,
|
|
222
|
+
update: (feature, featureIdx, vertex) => {
|
|
223
|
+
return [(0, _l7Utils.fp64LowPart)(vertex[3]), (0, _l7Utils.fp64LowPart)(vertex[4]), (0, _l7Utils.fp64LowPart)(vertex[5]), (0, _l7Utils.fp64LowPart)(vertex[6])];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
199
227
|
this.styleAttributeService.registerStyleAttribute({
|
|
200
228
|
name: 'uv',
|
|
201
229
|
type: _l7Core.AttributeType.Attribute,
|
|
202
230
|
descriptor: {
|
|
203
231
|
name: 'a_iconMapUV',
|
|
204
|
-
shaderLocation:
|
|
232
|
+
shaderLocation: this.attributeLocation.UV,
|
|
205
233
|
buffer: {
|
|
206
234
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
207
235
|
data: [],
|
|
@@ -224,6 +252,26 @@ class Arc3DModel extends _BaseModel.default {
|
|
|
224
252
|
}
|
|
225
253
|
}
|
|
226
254
|
});
|
|
255
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
256
|
+
name: 'thetaOffset',
|
|
257
|
+
type: _l7Core.AttributeType.Attribute,
|
|
258
|
+
descriptor: {
|
|
259
|
+
name: 'a_ThetaOffset',
|
|
260
|
+
shaderLocation: this.attributeLocation.THETA_OFFSET,
|
|
261
|
+
buffer: {
|
|
262
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
263
|
+
data: [],
|
|
264
|
+
type: _l7Core.gl.FLOAT
|
|
265
|
+
},
|
|
266
|
+
size: 1,
|
|
267
|
+
update: feature => {
|
|
268
|
+
const {
|
|
269
|
+
thetaOffset: op = 1
|
|
270
|
+
} = feature;
|
|
271
|
+
return [op];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
227
275
|
}
|
|
228
276
|
}
|
|
229
277
|
exports.default = Arc3DModel;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import type { IModel } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class FlowLineModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
SIZE: number;
|
|
17
|
+
INSTANCE: number;
|
|
18
|
+
INSTANCE_64LOW: number;
|
|
19
|
+
NORMAL: number;
|
|
20
|
+
};
|
|
4
21
|
protected getCommonUniformsInfo(): {
|
|
5
22
|
uniformsArray: number[];
|
|
6
23
|
uniformsLength: number;
|
package/lib/line/models/flow.js
CHANGED
|
@@ -7,14 +7,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
9
|
var _l7Core = require("@antv/l7-core");
|
|
10
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
10
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
11
12
|
var _line_trangluation = require("../../core/line_trangluation");
|
|
12
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
|
|
14
|
-
const flow_line_frag = "// #extension GL_OES_standard_derivatives : enable\n\nin vec4 v_color;\nout vec4 outputColor;\n\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
14
|
+
const flow_line_frag = "// #extension GL_OES_standard_derivatives : enable\n\nin vec4 v_color;\nout vec4 outputColor;\n\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
|
|
16
|
-
const flow_line_vert = "layout(location =
|
|
16
|
+
const flow_line_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniorm {\n float u_gap_width: 1.0;\n float u_stroke_width: 1.0;\n float u_stroke_opacity: 1.0;\n};\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nout vec4 v_color;\n\nvec2 project_pixel_offset(vec2 offsets) {\n vec2 data = project_pixel(offsets);\n\n return vec2(data.x, -data.y);\n}\n\nvec2 line_dir(vec2 target, vec2 source) {\n return normalize(ProjectFlat(target) - ProjectFlat(source));\n}\n\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source_world = a_Instance.rg; // \u8D77\u70B9\n vec2 target_world = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = line_dir(target_world, source_world);\n vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x); // mapbox || \u9AD8\u5FB7\n\n vec2 position = mix(source_world, target_world, a_Position.x);\n vec2 position64Low = mix(a_Instance64Low.rg, a_Instance64Low.ba, a_Position.x);\n\n float lengthCommon = length(\n project_position(vec4(target_world, 0, 1)) - project_position(vec4(source_world, 0, 1))\n );\n vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || \u9AD8\u5FB7\n vec2 limitedOffsetDistances = clamp(\n offsetDistances,\n project_pixel(-lengthCommon * 0.2),\n project_pixel(lengthCommon * 0.2)\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 * 0.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon * 0.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || \u9AD8\u5FB7\n\n float gapCommon = -1. * 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 vec4 project_pos = project_position(vec4(position.xy, 0, 1.0), position64Low);\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 gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
17
17
|
class FlowLineModel extends _BaseModel.default {
|
|
18
|
+
get attributeLocation() {
|
|
19
|
+
return Object.assign(super.attributeLocation, {
|
|
20
|
+
MAX: super.attributeLocation.MAX,
|
|
21
|
+
SIZE: 9,
|
|
22
|
+
INSTANCE: 10,
|
|
23
|
+
INSTANCE_64LOW: 11,
|
|
24
|
+
NORMAL: 12
|
|
25
|
+
});
|
|
26
|
+
}
|
|
18
27
|
getCommonUniformsInfo() {
|
|
19
28
|
const {
|
|
20
29
|
gapWidth = 2,
|
|
@@ -43,6 +52,7 @@ class FlowLineModel extends _BaseModel.default {
|
|
|
43
52
|
moduleName: 'flow_line',
|
|
44
53
|
vertexShader: flow_line_vert,
|
|
45
54
|
fragmentShader: flow_line_frag,
|
|
55
|
+
defines: _this2.getDefines(),
|
|
46
56
|
inject: _this2.getInject(),
|
|
47
57
|
triangulation: _line_trangluation.FlowLineTriangulation,
|
|
48
58
|
styleOption: _this2.layer.getLayerConfig().symbol,
|
|
@@ -63,7 +73,7 @@ class FlowLineModel extends _BaseModel.default {
|
|
|
63
73
|
descriptor: {
|
|
64
74
|
name: 'a_Size',
|
|
65
75
|
// 宽度
|
|
66
|
-
shaderLocation:
|
|
76
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
67
77
|
buffer: {
|
|
68
78
|
// give the WebGL driver a hint that this buffer may change
|
|
69
79
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -85,7 +95,7 @@ class FlowLineModel extends _BaseModel.default {
|
|
|
85
95
|
type: _l7Core.AttributeType.Attribute,
|
|
86
96
|
descriptor: {
|
|
87
97
|
name: 'a_Instance',
|
|
88
|
-
shaderLocation:
|
|
98
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
89
99
|
buffer: {
|
|
90
100
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
91
101
|
data: [],
|
|
@@ -97,14 +107,32 @@ class FlowLineModel extends _BaseModel.default {
|
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
});
|
|
110
|
+
|
|
111
|
+
// save low part for enabled double precision INSTANCE attribute
|
|
112
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
113
|
+
name: 'instance64Low',
|
|
114
|
+
type: _l7Core.AttributeType.Attribute,
|
|
115
|
+
descriptor: {
|
|
116
|
+
name: 'a_Instance64Low',
|
|
117
|
+
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
118
|
+
buffer: {
|
|
119
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
120
|
+
data: [],
|
|
121
|
+
type: _l7Core.gl.FLOAT
|
|
122
|
+
},
|
|
123
|
+
size: 4,
|
|
124
|
+
update: (feature, featureIdx, vertex) => {
|
|
125
|
+
return [(0, _l7Utils.fp64LowPart)(vertex[3]), (0, _l7Utils.fp64LowPart)(vertex[4]), (0, _l7Utils.fp64LowPart)(vertex[5]), (0, _l7Utils.fp64LowPart)(vertex[6])];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
100
129
|
this.styleAttributeService.registerStyleAttribute({
|
|
101
130
|
name: 'normal',
|
|
102
131
|
type: _l7Core.AttributeType.Attribute,
|
|
103
132
|
descriptor: {
|
|
104
133
|
name: 'a_Normal',
|
|
105
|
-
shaderLocation:
|
|
134
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
106
135
|
buffer: {
|
|
107
|
-
// give the WebGL driver a hint that this buffer may change
|
|
108
136
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
109
137
|
data: [],
|
|
110
138
|
type: _l7Core.gl.FLOAT
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class GreatCircleModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
SIZE: number;
|
|
17
|
+
INSTANCE: number;
|
|
18
|
+
INSTANCE_64LOW: number;
|
|
19
|
+
UV: number;
|
|
20
|
+
};
|
|
4
21
|
protected texture: ITexture2D;
|
|
5
22
|
protected getCommonUniformsInfo(): {
|
|
6
23
|
uniformsArray: number[];
|