@antv/l7-layers 2.21.10 → 2.21.11-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.d.ts +0 -1
- package/es/core/BaseLayer.js +9 -19
- package/es/core/BaseModel.d.ts +15 -2
- package/es/core/BaseModel.js +98 -64
- package/es/core/CommonStyleAttribute.d.ts +14 -18
- package/es/core/CommonStyleAttribute.js +23 -67
- package/es/core/shape/extrude.js +6 -3
- package/es/core/triangulation.js +22 -50
- package/es/core/utils.d.ts +4 -0
- package/es/core/utils.js +33 -0
- 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 -7
- 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 +44 -52
- 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 +53 -74
- 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 +4 -35
- 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 +13 -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.d.ts +0 -1
- package/lib/core/BaseLayer.js +9 -19
- package/lib/core/BaseModel.d.ts +15 -2
- package/lib/core/BaseModel.js +96 -62
- package/lib/core/CommonStyleAttribute.d.ts +14 -18
- package/lib/core/CommonStyleAttribute.js +23 -68
- package/lib/core/shape/extrude.js +6 -3
- package/lib/core/triangulation.js +22 -50
- package/lib/core/utils.d.ts +4 -0
- package/lib/core/utils.js +35 -0
- 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 -7
- 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 +44 -52
- 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 +53 -74
- 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 +4 -35
- 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 +13 -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
package/es/line/models/flow.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
3
|
+
import { fp64LowPart } from '@antv/l7-utils';
|
|
3
4
|
import BaseModel from "../../core/BaseModel";
|
|
4
5
|
import { FlowLineTriangulation } from "../../core/line_trangluation";
|
|
5
6
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
|
|
6
|
-
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";
|
|
7
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
7
|
+
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";
|
|
8
8
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
|
|
9
|
-
const flow_line_vert = "layout(location =
|
|
9
|
+
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);\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));\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";
|
|
10
10
|
export default class FlowLineModel extends BaseModel {
|
|
11
|
+
get attributeLocation() {
|
|
12
|
+
return Object.assign(super.attributeLocation, {
|
|
13
|
+
MAX: super.attributeLocation.MAX,
|
|
14
|
+
SIZE: 9,
|
|
15
|
+
INSTANCE: 10,
|
|
16
|
+
INSTANCE_64LOW: 11,
|
|
17
|
+
NORMAL: 12
|
|
18
|
+
});
|
|
19
|
+
}
|
|
11
20
|
getCommonUniformsInfo() {
|
|
12
21
|
const {
|
|
13
22
|
gapWidth = 2,
|
|
@@ -36,6 +45,7 @@ export default class FlowLineModel extends BaseModel {
|
|
|
36
45
|
moduleName: 'flow_line',
|
|
37
46
|
vertexShader: flow_line_vert,
|
|
38
47
|
fragmentShader: flow_line_frag,
|
|
48
|
+
defines: _this2.getDefines(),
|
|
39
49
|
inject: _this2.getInject(),
|
|
40
50
|
triangulation: FlowLineTriangulation,
|
|
41
51
|
styleOption: _this2.layer.getLayerConfig().symbol,
|
|
@@ -56,7 +66,7 @@ export default class FlowLineModel extends BaseModel {
|
|
|
56
66
|
descriptor: {
|
|
57
67
|
name: 'a_Size',
|
|
58
68
|
// 宽度
|
|
59
|
-
shaderLocation:
|
|
69
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
60
70
|
buffer: {
|
|
61
71
|
// give the WebGL driver a hint that this buffer may change
|
|
62
72
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -78,7 +88,7 @@ export default class FlowLineModel extends BaseModel {
|
|
|
78
88
|
type: AttributeType.Attribute,
|
|
79
89
|
descriptor: {
|
|
80
90
|
name: 'a_Instance',
|
|
81
|
-
shaderLocation:
|
|
91
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
82
92
|
buffer: {
|
|
83
93
|
usage: gl.STATIC_DRAW,
|
|
84
94
|
data: [],
|
|
@@ -90,14 +100,32 @@ export default class FlowLineModel extends BaseModel {
|
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
});
|
|
103
|
+
|
|
104
|
+
// save low part for enabled double precision INSTANCE attribute
|
|
105
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
106
|
+
name: 'instance64Low',
|
|
107
|
+
type: AttributeType.Attribute,
|
|
108
|
+
descriptor: {
|
|
109
|
+
name: 'a_Instance64Low',
|
|
110
|
+
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
111
|
+
buffer: {
|
|
112
|
+
usage: gl.STATIC_DRAW,
|
|
113
|
+
data: [],
|
|
114
|
+
type: gl.FLOAT
|
|
115
|
+
},
|
|
116
|
+
size: 4,
|
|
117
|
+
update: (feature, featureIdx, vertex) => {
|
|
118
|
+
return [fp64LowPart(vertex[3]), fp64LowPart(vertex[4]), fp64LowPart(vertex[5]), fp64LowPart(vertex[6])];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
93
122
|
this.styleAttributeService.registerStyleAttribute({
|
|
94
123
|
name: 'normal',
|
|
95
124
|
type: AttributeType.Attribute,
|
|
96
125
|
descriptor: {
|
|
97
126
|
name: 'a_Normal',
|
|
98
|
-
shaderLocation:
|
|
127
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
99
128
|
buffer: {
|
|
100
|
-
// give the WebGL driver a hint that this buffer may change
|
|
101
129
|
usage: gl.STATIC_DRAW,
|
|
102
130
|
data: [],
|
|
103
131
|
type: 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[];
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
4
|
-
import { rgb2arr } from '@antv/l7-utils';
|
|
4
|
+
import { fp64LowPart, rgb2arr } from '@antv/l7-utils';
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
7
6
|
import { LineArcTriangulation } from "../../core/triangulation";
|
|
8
7
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_frag.glsl' */
|
|
9
8
|
const line_arc_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;\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 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;\n};\n\nin vec4 v_line_data;\nin vec2 v_iconMapUV;\nin vec4 v_dash_array;\nin float v_distance_ratio;\nin vec4 v_color;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n\n float animateSpeed = 0.0;\n float d_segmentIndex = v_line_data.g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n outputColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n if(u_line_type == LineTypeDash) {\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 // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\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 alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_animate.x == Animate) {\n u = outputColor.a/v_color.a;\n }\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\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 } else {\n outputColor = filterColor(outputColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
|
|
10
9
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_vert.glsl' */
|
|
11
|
-
const line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nlayout(location =
|
|
10
|
+
const line_arc2d_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\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 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;\n};\n\nout vec4 v_dash_array;\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_line_data;\nout float v_distance_ratio;\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 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(mix(source, target, segmentRatio), sqrt(max(0.0, vertex_height)));\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}\nfloat getAngularDist(vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) * sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\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 return mid;\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}\n\nvec2 interpolate(vec2 source, vec2 target, float angularDist, float t) {\n if (abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n\n}\n\nvoid main() {\n v_color = a_Color;\n v_color.a = v_color.a * opacity;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\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 if (u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(source, target) / 2.0 * PI;\n total_Distance = total_Distance * 16.0; // total_Distance*16.0 \u8C03\u6574\u9ED8\u8BA4\u7684\u6548\u679C\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n }\n\n if (u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0), a_Instance64Low.xy);\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0), a_Instance64Low.zw);\n\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\n v_line_data.g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if (LineTexture == u_line_texture) {\n float d_arcDistrance = length(source - target);\n d_arcDistrance = project_pixel(d_arcDistrance);\n\n float d_pixelLen = project_pixel(u_icon_step) / 8.0;\n v_line_data.b = floor(d_arcDistrance / d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\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\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 gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
12
11
|
const lineStyleObj = {
|
|
13
12
|
solid: 0.0,
|
|
14
13
|
dash: 1.0
|
|
@@ -39,6 +38,15 @@ export default class GreatCircleModel extends BaseModel {
|
|
|
39
38
|
this.textures = [this.texture];
|
|
40
39
|
});
|
|
41
40
|
}
|
|
41
|
+
get attributeLocation() {
|
|
42
|
+
return Object.assign(super.attributeLocation, {
|
|
43
|
+
MAX: super.attributeLocation.MAX,
|
|
44
|
+
SIZE: 9,
|
|
45
|
+
INSTANCE: 10,
|
|
46
|
+
INSTANCE_64LOW: 11,
|
|
47
|
+
UV: 12
|
|
48
|
+
});
|
|
49
|
+
}
|
|
42
50
|
getCommonUniformsInfo() {
|
|
43
51
|
const {
|
|
44
52
|
sourceColor,
|
|
@@ -131,6 +139,7 @@ export default class GreatCircleModel extends BaseModel {
|
|
|
131
139
|
styleOption: {
|
|
132
140
|
segmentNumber
|
|
133
141
|
},
|
|
142
|
+
defines: _this2.getDefines(),
|
|
134
143
|
inject: _this2.getInject(),
|
|
135
144
|
depth: {
|
|
136
145
|
enable: false
|
|
@@ -145,7 +154,7 @@ export default class GreatCircleModel extends BaseModel {
|
|
|
145
154
|
type: AttributeType.Attribute,
|
|
146
155
|
descriptor: {
|
|
147
156
|
name: 'a_Size',
|
|
148
|
-
shaderLocation:
|
|
157
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
149
158
|
buffer: {
|
|
150
159
|
// give the WebGL driver a hint that this buffer may change
|
|
151
160
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -167,7 +176,7 @@ export default class GreatCircleModel extends BaseModel {
|
|
|
167
176
|
type: AttributeType.Attribute,
|
|
168
177
|
descriptor: {
|
|
169
178
|
name: 'a_Instance',
|
|
170
|
-
shaderLocation:
|
|
179
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
171
180
|
buffer: {
|
|
172
181
|
usage: gl.STATIC_DRAW,
|
|
173
182
|
data: [],
|
|
@@ -179,12 +188,31 @@ export default class GreatCircleModel extends BaseModel {
|
|
|
179
188
|
}
|
|
180
189
|
}
|
|
181
190
|
});
|
|
191
|
+
|
|
192
|
+
// save low part for enabled double precision INSTANCE attribute
|
|
193
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
194
|
+
name: 'instance64Low',
|
|
195
|
+
type: AttributeType.Attribute,
|
|
196
|
+
descriptor: {
|
|
197
|
+
name: 'a_Instance64Low',
|
|
198
|
+
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
199
|
+
buffer: {
|
|
200
|
+
usage: gl.STATIC_DRAW,
|
|
201
|
+
data: [],
|
|
202
|
+
type: gl.FLOAT
|
|
203
|
+
},
|
|
204
|
+
size: 4,
|
|
205
|
+
update: (feature, featureIdx, vertex) => {
|
|
206
|
+
return [fp64LowPart(vertex[3]), fp64LowPart(vertex[4]), fp64LowPart(vertex[5]), fp64LowPart(vertex[6])];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
182
210
|
this.styleAttributeService.registerStyleAttribute({
|
|
183
211
|
name: 'uv',
|
|
184
212
|
type: AttributeType.Attribute,
|
|
185
213
|
descriptor: {
|
|
186
214
|
name: 'a_iconMapUV',
|
|
187
|
-
shaderLocation:
|
|
215
|
+
shaderLocation: this.attributeLocation.UV,
|
|
188
216
|
buffer: {
|
|
189
217
|
// give the WebGL driver a hint that this buffer may change
|
|
190
218
|
usage: gl.DYNAMIC_DRAW,
|
package/es/line/models/line.d.ts
CHANGED
|
@@ -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 LineModel 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
|
+
DISTANCE_INDEX: number;
|
|
18
|
+
NORMAL: number;
|
|
19
|
+
UV: number;
|
|
20
|
+
};
|
|
4
21
|
private textureEventFlag;
|
|
5
22
|
protected texture: ITexture2D;
|
|
6
23
|
protected getCommonUniformsInfo(): {
|
package/es/line/models/line.js
CHANGED
|
@@ -5,11 +5,10 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
6
|
import { LinearDir, TextureBlend } from "../../core/interface";
|
|
7
7
|
import { LineTriangulation } from "../../core/triangulation";
|
|
8
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
9
8
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
10
9
|
const line_frag = "// #extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\n\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_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\n// dash\nin vec4 v_dash_array;\nin float v_d_distance_ratio;\nin vec2 v_iconMapUV;\nin vec4 v_texture_data;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_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 // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n d_distance_ratio = v_texture_data.a;\n }\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n outputColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n if(u_animate.x == Animate) {\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) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_texture_data.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_texture_data.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_texture_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n 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 = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float strokeWidth = min(0.5, u_strokeWidth);\n // \u7ED8\u5236 border\n if(strokeWidth > 0.01) {\n float borderOuterWidth = strokeWidth / 2.0;\n\n\n if(v >= 1.0 - strokeWidth || v <= strokeWidth) {\n if(v > strokeWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n outputColor.rgb = mix(outputColor.rgb, v_stroke.rgb, linear);\n } else if(v <= strokeWidth) {\n float linear = smoothstep(0.0, 1.0, v/strokeWidth);\n outputColor.rgb = mix(v_stroke.rgb, outputColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n outputColor.a = mix(0.0, outputColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = v_texture_data.a;\n if(blurV < 0.5) {\n outputColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n outputColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n outputColor = filterColor(outputColor);\n}\n";
|
|
11
10
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
12
|
-
const line_vert = "
|
|
11
|
+
const line_vert = "#define Animate (0.0)\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_DISTANCE_INDEX) in vec3 a_DistanceAndIndexAndMiter;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec4 a_Normal_Total_Distance;\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_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nout vec4 v_color;\nout vec4 v_stroke;\n//dash\nout vec4 v_dash_array;\nout float v_d_distance_ratio;\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;\n float a_Miter = a_DistanceAndIndexAndMiter.z;\n vec3 a_Normal = a_Normal_Total_Distance.xyz;\n float a_Total_Distance = a_Normal_Total_Distance.w;\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n\n v_color = a_Color;\n v_color.a *= opacity;\n v_stroke = stroke;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * a_Normal;\n\n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth / linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if (u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(\n vec4(project_pos.xy + offset, lineHeight + h, 1.0)\n );\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
13
12
|
export default class LineModel extends BaseModel {
|
|
14
13
|
constructor(...args) {
|
|
15
14
|
super(...args);
|
|
@@ -43,6 +42,15 @@ export default class LineModel extends BaseModel {
|
|
|
43
42
|
});
|
|
44
43
|
});
|
|
45
44
|
}
|
|
45
|
+
get attributeLocation() {
|
|
46
|
+
return Object.assign(super.attributeLocation, {
|
|
47
|
+
MAX: super.attributeLocation.MAX,
|
|
48
|
+
SIZE: 9,
|
|
49
|
+
DISTANCE_INDEX: 10,
|
|
50
|
+
NORMAL: 11,
|
|
51
|
+
UV: 12
|
|
52
|
+
});
|
|
53
|
+
}
|
|
46
54
|
getCommonUniformsInfo() {
|
|
47
55
|
const {
|
|
48
56
|
sourceColor,
|
|
@@ -151,6 +159,7 @@ export default class LineModel extends BaseModel {
|
|
|
151
159
|
vertexShader: vert,
|
|
152
160
|
fragmentShader: frag,
|
|
153
161
|
triangulation: LineTriangulation,
|
|
162
|
+
defines: _this2.getDefines(),
|
|
154
163
|
inject: _this2.getInject(),
|
|
155
164
|
depth: {
|
|
156
165
|
enable: depth
|
|
@@ -172,12 +181,14 @@ export default class LineModel extends BaseModel {
|
|
|
172
181
|
};
|
|
173
182
|
}
|
|
174
183
|
registerBuiltinAttributes() {
|
|
184
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
|
|
185
|
+
this.registerPosition64LowAttribute();
|
|
175
186
|
this.styleAttributeService.registerStyleAttribute({
|
|
176
187
|
name: 'distanceAndIndex',
|
|
177
188
|
type: AttributeType.Attribute,
|
|
178
189
|
descriptor: {
|
|
179
190
|
name: 'a_DistanceAndIndexAndMiter',
|
|
180
|
-
shaderLocation:
|
|
191
|
+
shaderLocation: this.attributeLocation.DISTANCE_INDEX,
|
|
181
192
|
buffer: {
|
|
182
193
|
// give the WebGL driver a hint that this buffer may change
|
|
183
194
|
usage: gl.STATIC_DRAW,
|
|
@@ -195,7 +206,7 @@ export default class LineModel extends BaseModel {
|
|
|
195
206
|
type: AttributeType.Attribute,
|
|
196
207
|
descriptor: {
|
|
197
208
|
name: 'a_Size',
|
|
198
|
-
shaderLocation:
|
|
209
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
199
210
|
buffer: {
|
|
200
211
|
// give the WebGL driver a hint that this buffer may change
|
|
201
212
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -211,14 +222,12 @@ export default class LineModel extends BaseModel {
|
|
|
211
222
|
}
|
|
212
223
|
}
|
|
213
224
|
});
|
|
214
|
-
|
|
215
|
-
// point layer size;
|
|
216
225
|
this.styleAttributeService.registerStyleAttribute({
|
|
217
226
|
name: 'normal_total_distance',
|
|
218
227
|
type: AttributeType.Attribute,
|
|
219
228
|
descriptor: {
|
|
220
229
|
name: 'a_Normal_Total_Distance',
|
|
221
|
-
shaderLocation:
|
|
230
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
222
231
|
buffer: {
|
|
223
232
|
// give the WebGL driver a hint that this buffer may change
|
|
224
233
|
usage: gl.STATIC_DRAW,
|
|
@@ -236,7 +245,7 @@ export default class LineModel extends BaseModel {
|
|
|
236
245
|
type: AttributeType.Attribute,
|
|
237
246
|
descriptor: {
|
|
238
247
|
name: 'a_iconMapUV',
|
|
239
|
-
shaderLocation:
|
|
248
|
+
shaderLocation: this.attributeLocation.UV,
|
|
240
249
|
buffer: {
|
|
241
250
|
// give the WebGL driver a hint that this buffer may change
|
|
242
251
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { IModel } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class SimpleLineModel 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
|
+
};
|
|
4
18
|
protected getCommonUniformsInfo(): {
|
|
5
19
|
uniformsArray: number[];
|
|
6
20
|
uniformsLength: number;
|
|
@@ -2,13 +2,18 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
3
3
|
import { rgb2arr } from '@antv/l7-utils';
|
|
4
4
|
import BaseModel from "../../core/BaseModel";
|
|
5
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
6
5
|
import { SimpleLineTriangulation } from "../../core/triangulation";
|
|
7
6
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_frag.glsl' */
|
|
8
7
|
const simple_line_frag = "\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\nin float v_distanceScale;\nin vec4 v_color;\n//dash\nin vec4 v_dash_array;\n\nout vec4 outputColor;\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distanceScale, 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 // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n if(u_linearColor==1.0){\n outputColor = mix(u_sourceColor, u_targetColor, v_distanceScale);\n outputColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n }\n else{\n outputColor = v_color;\n }\n}\n";
|
|
9
8
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
|
|
10
|
-
const simple_line_vert = "layout(location =
|
|
9
|
+
const simple_line_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec4 a_SizeDistanceAndTotalDistance;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec4 v_color;\nout float v_distanceScale;\nout vec4 v_dash_array;\n\nvoid main() {\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_SizeDistanceAndTotalDistance.a;\n\n v_color = a_Color;\n v_distanceScale = a_SizeDistanceAndTotalDistance.b / a_SizeDistanceAndTotalDistance.a;\n v_color.a = v_color.a * opacity;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n float lineHeight = a_SizeDistanceAndTotalDistance.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0 / pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n\n}\n";
|
|
11
10
|
export default class SimpleLineModel extends BaseModel {
|
|
11
|
+
get attributeLocation() {
|
|
12
|
+
return Object.assign(super.attributeLocation, {
|
|
13
|
+
MAX: super.attributeLocation.MAX,
|
|
14
|
+
SIZE: 9
|
|
15
|
+
});
|
|
16
|
+
}
|
|
12
17
|
getCommonUniformsInfo() {
|
|
13
18
|
const {
|
|
14
19
|
sourceColor,
|
|
@@ -72,6 +77,7 @@ export default class SimpleLineModel extends BaseModel {
|
|
|
72
77
|
vertexShader: vert,
|
|
73
78
|
fragmentShader: frag,
|
|
74
79
|
triangulation: SimpleLineTriangulation,
|
|
80
|
+
defines: _this2.getDefines(),
|
|
75
81
|
inject: _this2.getInject(),
|
|
76
82
|
primitive: gl.LINES,
|
|
77
83
|
depth: {
|
|
@@ -83,57 +89,16 @@ export default class SimpleLineModel extends BaseModel {
|
|
|
83
89
|
})();
|
|
84
90
|
}
|
|
85
91
|
registerBuiltinAttributes() {
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// descriptor: {
|
|
90
|
-
// name: 'a_Distance',
|
|
91
|
-
// shaderLocation: 14,
|
|
92
|
-
// buffer: {
|
|
93
|
-
// // give the WebGL driver a hint that this buffer may change
|
|
94
|
-
// usage: gl.STATIC_DRAW,
|
|
95
|
-
// data: [],
|
|
96
|
-
// type: gl.FLOAT,
|
|
97
|
-
// },
|
|
98
|
-
// size: 1,
|
|
99
|
-
// update: (
|
|
100
|
-
// feature: IEncodeFeature,
|
|
101
|
-
// featureIdx: number,
|
|
102
|
-
// vertex: number[],
|
|
103
|
-
// ) => {
|
|
104
|
-
// return [vertex[3]];
|
|
105
|
-
// },
|
|
106
|
-
// },
|
|
107
|
-
// });
|
|
108
|
-
// this.styleAttributeService.registerStyleAttribute({
|
|
109
|
-
// name: 'total_distance',
|
|
110
|
-
// type: AttributeType.Attribute,
|
|
111
|
-
// descriptor: {
|
|
112
|
-
// name: 'a_Total_Distance',
|
|
113
|
-
// shaderLocation: 13,//枚举不够了,先固定写值吧,在shader中location也成一致的并且不与其他的重复就行了
|
|
114
|
-
// buffer: {
|
|
115
|
-
// // give the WebGL driver a hint that this buffer may change
|
|
116
|
-
// usage: gl.STATIC_DRAW,
|
|
117
|
-
// data: [],
|
|
118
|
-
// type: gl.FLOAT,
|
|
119
|
-
// },
|
|
120
|
-
// size: 1,
|
|
121
|
-
// update: (
|
|
122
|
-
// feature: IEncodeFeature,
|
|
123
|
-
// featureIdx: number,
|
|
124
|
-
// vertex: number[],
|
|
125
|
-
// ) => {
|
|
126
|
-
// return [vertex[5]];
|
|
127
|
-
// },
|
|
128
|
-
// },
|
|
129
|
-
// });
|
|
92
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
|
|
93
|
+
this.registerPosition64LowAttribute();
|
|
94
|
+
|
|
130
95
|
//size.x,size,y,distance,totalDistance
|
|
131
96
|
this.styleAttributeService.registerStyleAttribute({
|
|
132
97
|
name: 'sizeDistanceAndTotalDistance',
|
|
133
98
|
type: AttributeType.Attribute,
|
|
134
99
|
descriptor: {
|
|
135
100
|
name: 'a_SizeDistanceAndTotalDistance',
|
|
136
|
-
shaderLocation:
|
|
101
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
137
102
|
buffer: {
|
|
138
103
|
usage: gl.STATIC_DRAW,
|
|
139
104
|
data: [],
|
package/es/line/models/wall.d.ts
CHANGED
|
@@ -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 LineWallModel 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
|
+
NORMAL: number;
|
|
18
|
+
UV: number;
|
|
19
|
+
DISTANCE_MITER_TOTAL: number;
|
|
20
|
+
};
|
|
4
21
|
protected texture: ITexture2D;
|
|
5
22
|
protected getCommonUniformsInfo(): {
|
|
6
23
|
uniformsArray: number[];
|