@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,17 +2,22 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
4
4
|
import BaseModel from "../../core/BaseModel";
|
|
5
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
6
5
|
import { polygonTriangulation, polygonTriangulationWithCenter } from "../../core/triangulation";
|
|
7
6
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
8
7
|
const polygon_frag = "in vec4 v_color;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
9
8
|
/* babel-plugin-inline-import '../shaders/fill/fill_linear_frag.glsl' */
|
|
10
9
|
const polygon_linear_frag = "\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\nin vec4 v_color;\nin vec3 v_linear;\nin vec2 v_pos;\nout vec4 outputColor;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n outputColor = v_color;\n if (u_opacitylinear > 0.0) {\n outputColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
11
10
|
/* babel-plugin-inline-import '../shaders/fill/fill_linear_vert.glsl' */
|
|
12
|
-
const polygon_linear_vert = "layout(location =
|
|
11
|
+
const polygon_linear_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_LINEAR) in vec3 a_linear;\n\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\nout vec4 v_color;\nout vec3 v_linear;\nout vec2 v_pos;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n if (u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n project_pos.z += u_raisingHeight;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n setPickingColor(a_PickingColor);\n}\n";
|
|
13
12
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
14
|
-
const polygon_vert = "layout(location =
|
|
13
|
+
const polygon_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;\n\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n\n project_pos.z += u_raisingHeight;\n\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
15
14
|
export default class FillModel extends BaseModel {
|
|
15
|
+
get attributeLocation() {
|
|
16
|
+
return Object.assign(super.attributeLocation, {
|
|
17
|
+
MAX: super.attributeLocation.MAX,
|
|
18
|
+
LINEAR: 9
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
getUninforms() {
|
|
17
22
|
const commoninfo = this.getCommonUniformsInfo();
|
|
18
23
|
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
@@ -56,6 +61,7 @@ export default class FillModel extends BaseModel {
|
|
|
56
61
|
moduleName: type,
|
|
57
62
|
vertexShader: vert,
|
|
58
63
|
fragmentShader: frag,
|
|
64
|
+
defines: _this2.getDefines(),
|
|
59
65
|
inject: _this2.getInject(),
|
|
60
66
|
triangulation,
|
|
61
67
|
primitive: gl.TRIANGLES,
|
|
@@ -67,6 +73,8 @@ export default class FillModel extends BaseModel {
|
|
|
67
73
|
})();
|
|
68
74
|
}
|
|
69
75
|
registerBuiltinAttributes() {
|
|
76
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
|
|
77
|
+
this.registerPosition64LowAttribute();
|
|
70
78
|
const {
|
|
71
79
|
opacityLinear = {
|
|
72
80
|
enable: false,
|
|
@@ -79,7 +87,7 @@ export default class FillModel extends BaseModel {
|
|
|
79
87
|
type: AttributeType.Attribute,
|
|
80
88
|
descriptor: {
|
|
81
89
|
name: 'a_linear',
|
|
82
|
-
shaderLocation:
|
|
90
|
+
shaderLocation: this.attributeLocation.LINEAR,
|
|
83
91
|
buffer: {
|
|
84
92
|
// give the WebGL driver a hint that this buffer may change
|
|
85
93
|
usage: gl.STATIC_DRAW,
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { IModel, IModelUniform } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class OceanModel 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
|
+
UV: number;
|
|
17
|
+
};
|
|
4
18
|
private texture1;
|
|
5
19
|
private texture2;
|
|
6
20
|
private texture3;
|
|
@@ -4,12 +4,11 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
4
4
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
5
5
|
import { rgb2arr } from '@antv/l7-utils';
|
|
6
6
|
import BaseModel from "../../core/BaseModel";
|
|
7
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
8
7
|
import { polygonTriangulation } from "../../core/triangulation";
|
|
9
8
|
/* babel-plugin-inline-import '../shaders/ocean/ocean_frag.glsl' */
|
|
10
9
|
const ocean_frag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\nin vec2 v_uv;\nin float v_opacity;\nout vec4 outputColor;\n\nfloat coast2water_fadedepth = 0.10;\nfloat large_waveheight = .750; // change to adjust the \"heavy\" waves\nfloat large_wavesize = 3.4; // factor to adjust the large wave size\nfloat small_waveheight = 0.6; // change to adjust the small random waves\nfloat small_wavesize = 0.5; // factor to ajust the small wave size\nfloat water_softlight_fact = 15.; // range [1..200] (should be << smaller than glossy-fact)\nfloat water_glossylight_fact= 120.; // range [1..200]\nfloat particle_amount = 70.;\n\nvec3 water_specularcolor = vec3(1.3, 1.3, 0.9); // specular Color (RGB) of the water-highlights\n#define light vec3(-0., sin(u_time*0.5)*.5 + .35, 2.8) // position of the sun\n\nuniform sampler2D u_texture1;\nuniform sampler2D u_texture2;\nuniform sampler2D u_texture3;\n\n \n\nfloat hash( float n ) {\n return fract(sin(n)*43758.5453123);\n}\n\n// 2d noise function\nfloat noise1( in vec2 x ) {\n vec2 p = floor(x);\n vec2 f = smoothstep(0.0, 1.0, fract(x));\n float n = p.x + p.y*57.0;\n return mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),\n mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);\n}\n\nfloat noise(vec2 p) {\n return texture(SAMPLER_2D(u_texture2),p*vec2(1./256.)).x;\n}\n\nvec4 highness(vec2 p) {\n vec4 t = texture(SAMPLER_2D(u_texture1),fract(p));\n float clipped = -2.0-smoothstep(3.,10.,t.a)*6.9-smoothstep(10.,100.,t.a)*89.9-smoothstep(0.,10000.,t.a)*10000.0;\n return clamp(t, 0.0,3.0)+clamp(t/3.0-1.0, 0.0,1.0)+clamp(t/16.0-1.0, 0.0,1.0);\n}\n\nfloat height_map( vec2 p ) {\n vec4 height=highness(p);\n /*\n height = -0.5+\n 0.5*smoothstep(-100.,0.,-height)+\n 2.75*smoothstep(0.,2.,height)+\n 1.75*smoothstep(2.,4.,height)+\n 2.75*smoothstep(4.,16.,height)+\n 1.5*smoothstep(16.,1000.,height);\n */\n\n mat2 m = mat2( 0.9563*1.4, -0.2924*1.4, 0.2924*1.4, 0.9563*1.4 );\n //p = p*6.;\n float f = 0.6000*noise1( p ); p = m*p*1.1*6.;\n f += 0.2500*noise( p ); p = m*p*1.32;\n f += 0.1666*noise( p ); p = m*p*1.11;\n f += 0.0834*noise( p ); p = m*p*1.12;\n f += 0.0634*noise( p ); p = m*p*1.13;\n f += 0.0444*noise( p ); p = m*p*1.14;\n f += 0.0274*noise( p ); p = m*p*1.15;\n f += 0.0134*noise( p ); p = m*p*1.16;\n f += 0.0104*noise( p ); p = m*p*1.17;\n f += 0.0084*noise( p );\n f = .25*f+dot(height,vec4(-.03125,-.125,.25,.25))*.5;\n const float FLAT_LEVEL = 0.92525;\n //f = f*0.25+height*0.75;\n if (f<FLAT_LEVEL)\n f = f;\n else\n f = pow((f-FLAT_LEVEL)/(1.-FLAT_LEVEL), 2.)*(1.-FLAT_LEVEL)*2.0+FLAT_LEVEL; // makes a smooth coast-increase\n return clamp(f, 0., 10.);\n}\n\nvec3 plasma_quintic( float x ) {\n x = clamp( x, 0.0, 1.0);\n vec4 x1 = vec4( 1.0, x, x * x, x * x * x ); // 1 x x2 x3\n vec4 x2 = x1 * x1.w * x; // x4 x5 x6 x7\n return vec3(\n dot( x1.xyzw, vec4( +0.063861086, +1.992659096, -1.023901152, -0.490832805 ) ) + dot( x2.xy, vec2( +1.308442123, -0.914547012 ) ),\n dot( x1.xyzw, vec4( +0.049718590, -0.791144343, +2.892305078, +0.811726816 ) ) + dot( x2.xy, vec2( -4.686502417, +2.717794514 ) ),\n dot( x1.xyzw, vec4( +0.513275779, +1.580255060, -5.164414457, +4.559573646 ) ) + dot( x2.xy, vec2( -1.916810682, +0.570638854 ) ) );\n}\n\nvec4 color(vec2 p){\n vec4 c1 = vec4(1.7,1.6,.9,1);\n vec4 c2 = vec4(.2,.94,.1,1);\n vec4 c3 = vec4(.3,.2,.0,1);\n vec4 c4 = vec4(.99,.99,1.6,1);\n vec4 v = highness(p);\n float los = smoothstep(0.1,1.1,v.b);\n float his = smoothstep(3.5,6.5,v.b);\n float ces = smoothstep(1.,5.,v.a);\n vec4 lo = mix(c1,c2,los);\n vec4 hi = mix(c3,c4,his);\n vec4 ce = mix(lo,hi,ces);\n\n return vec4(plasma_quintic(ces),1).ragb;\n}\n\nvec3 terrain_map( vec2 p )\n{\n return color(p).rgb*0.75+0.25*vec3(0.7, .55, .4)+texture(SAMPLER_2D(u_texture3), fract(p*5.)).rgb*.5; // test-terrain is simply 'sandstone'\n}\n\nconst mat2 m = mat2( 0.72, -1.60, 1.60, 0.72 );\n\nfloat water_map( vec2 p, float height ) {\n vec2 p2 = p*large_wavesize;\n vec2 shift1 = 0.001*vec2( u_time*160.0*2.0, u_time*120.0*2.0 );\n vec2 shift2 = 0.001*vec2( u_time*190.0*2.0, -u_time*130.0*2.0 );\n\n // coarse crossing 'ocean' waves...\n float f = 0.6000*noise( p );\n f += 0.2500*noise( p*m );\n f += 0.1666*noise( p*m*m );\n float wave = sin(p2.x*0.622+p2.y*0.622+shift2.x*4.269)*large_waveheight*f*height*height ;\n\n p *= small_wavesize;\n f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<9; i++)\n { p = m*p*.947; f -= amp*abs(sin((noise( p+shift1*s )-.5)*2.)); amp = amp*.59; s*=-1.329; }\n \n return wave+f*small_waveheight;\n}\n\nfloat nautic(vec2 p) {\n p *= 18.;\n float f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*abs(smoothstep(0., 1., noise( p+u_time*s ))-.5); amp = amp*.5; s*=-1.227; }\n return pow(1.-f, 5.);\n}\n\nfloat particles(vec2 p) {\n p *= 200.;\n float f = 0.;\n float amp = 1.0, s = 1.5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*noise( p+u_time*s ); amp = amp*.5; s*=-1.227; }\n return pow(f*.35, 7.)*particle_amount;\n}\n\nfloat test_shadow( vec2 xy, float height) {\n vec3 r0 = vec3(xy, height);\n vec3 rd = normalize( light - r0 );\n \n float hit = 1.0;\n float t = 0.001;\n for (int j=1; j<25; j++)\n {\n vec3 p = r0 + t*rd;\n float h = height_map( p.xy );\n float height_diff = p.z - h;\n if (height_diff<0.0)\n {\n return 0.0;\n }\n t += 0.01+height_diff*.02;\n hit = min(hit, 2.*height_diff/t); // soft shaddow \n }\n return hit;\n}\n\nvec3 CalcTerrain(vec2 uv, float height) {\n vec3 col = terrain_map( uv );\n vec2 iResolution = vec2(512.);\n float h1 = height_map(uv-vec2(0., 0.5)/ iResolution.xy);\n float h2 = height_map(uv+vec2(0., 0.5)/ iResolution.xy);\n float h3 = height_map(uv-vec2(0.5, 0.)/ iResolution.xy);\n float h4 = height_map(uv+vec2(0.5, 0.)/ iResolution.xy);\n vec3 norm = normalize(vec3(h3-h4, h1-h2, 1.));\n vec3 r0 = vec3(uv, height);\n vec3 rd = normalize( light - r0 );\n float grad = dot(norm, rd);\n col *= grad+pow(grad, 8.);\n float terrainshade = test_shadow( uv, height );\n col = mix(col*.25, col, terrainshade);\n return col;\n}\n\n\nvoid main() {\n vec3 watercolor = u_watercolor.rgb;\n vec3 watercolor2 = u_watercolor2.rgb;\n vec2 uv = v_uv;\n float WATER_LEVEL = 0.84; // Water level (range: 0.0 - 2.0)\n float deepwater_fadedepth = 0.4 + coast2water_fadedepth;\n float height = height_map( uv );\n vec3 col;\n\n float waveheight = clamp(WATER_LEVEL*3.-1.5, 0., 1.);\n float level = WATER_LEVEL + .2*water_map(uv*15. + vec2(u_time*.1), waveheight);\n if (height > level)\n {\n col = CalcTerrain(uv, height);\n }\n if (height <= level)\n {\n vec2 dif = vec2(.0, .01);\n vec2 pos = uv*15. + vec2(u_time*.01);\n float h1 = water_map(pos-dif,waveheight);\n float h2 = water_map(pos+dif,waveheight);\n float h3 = water_map(pos-dif.yx,waveheight);\n float h4 = water_map(pos+dif.yx,waveheight);\n vec3 normwater = normalize(vec3(h3-h4, h1-h2, .125)); // norm-vector of the 'bumpy' water-plane\n uv += normwater.xy*.002*(level-height);\n \n col = CalcTerrain(uv, height);\n\n float coastfade = clamp((level-height)/coast2water_fadedepth, 0., 1.);\n float coastfade2= clamp((level-height)/deepwater_fadedepth, 0., 1.);\n float intensity = col.r*.2126+col.g*.7152+col.b*.0722;\n watercolor = mix(watercolor*intensity, watercolor2, smoothstep(0., 1., coastfade2));\n\n vec3 r0 = vec3(uv, WATER_LEVEL);\n vec3 rd = normalize( light - r0 ); // ray-direction to the light from water-position\n float grad = dot(normwater, rd); // dot-product of norm-vector and light-direction\n float specular = pow(grad, water_softlight_fact); // used for soft highlights \n float specular2= pow(grad, water_glossylight_fact); // used for glossy highlights\n float gradpos = dot(vec3(0., 0., 1.), rd);\n float specular1= smoothstep(0., 1., pow(gradpos, 5.)); // used for diffusity (some darker corona around light's specular reflections...) \n float watershade = test_shadow( uv, level );\n watercolor *= 2.2+watershade;\n watercolor += (.2+.8*watershade) * ((grad-1.0)*.5+specular) * .25;\n watercolor /= (1.+specular1*1.25);\n watercolor += watershade*specular2*water_specularcolor;\n watercolor += watershade*coastfade*(1.-coastfade2)*(vec3(.5, .6, .7)*nautic(uv)+vec3(1., 1., 1.)*particles(uv));\n \n col = mix(col, watercolor, coastfade);\n }\n \n outputColor = vec4(col, v_opacity); \n}\n";
|
|
11
10
|
/* babel-plugin-inline-import '../shaders/ocean/ocean_vert.glsl' */
|
|
12
|
-
const ocean_vert = "layout(location =
|
|
11
|
+
const ocean_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_uv;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\nout vec2 v_uv;\nout float v_opacity;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_opacity = opacity;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n}\n\n";
|
|
13
12
|
export default class OceanModel extends BaseModel {
|
|
14
13
|
constructor(...args) {
|
|
15
14
|
super(...args);
|
|
@@ -17,6 +16,12 @@ export default class OceanModel extends BaseModel {
|
|
|
17
16
|
_defineProperty(this, "texture2", void 0);
|
|
18
17
|
_defineProperty(this, "texture3", void 0);
|
|
19
18
|
}
|
|
19
|
+
get attributeLocation() {
|
|
20
|
+
return Object.assign(super.attributeLocation, {
|
|
21
|
+
MAX: super.attributeLocation.MAX,
|
|
22
|
+
UV: 9
|
|
23
|
+
});
|
|
24
|
+
}
|
|
20
25
|
getUninforms() {
|
|
21
26
|
const commoninfo = this.getCommonUniformsInfo();
|
|
22
27
|
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
@@ -62,6 +67,7 @@ export default class OceanModel extends BaseModel {
|
|
|
62
67
|
moduleName: 'polygonOcean',
|
|
63
68
|
vertexShader: ocean_vert,
|
|
64
69
|
fragmentShader: ocean_frag,
|
|
70
|
+
defines: _this2.getDefines(),
|
|
65
71
|
inject: _this2.getInject(),
|
|
66
72
|
triangulation: polygonTriangulation,
|
|
67
73
|
primitive: gl.TRIANGLES,
|
|
@@ -88,7 +94,7 @@ export default class OceanModel extends BaseModel {
|
|
|
88
94
|
type: AttributeType.Attribute,
|
|
89
95
|
descriptor: {
|
|
90
96
|
name: 'a_uv',
|
|
91
|
-
shaderLocation:
|
|
97
|
+
shaderLocation: this.attributeLocation.UV,
|
|
92
98
|
buffer: {
|
|
93
99
|
// give the WebGL driver a hint that this buffer may change
|
|
94
100
|
usage: gl.STATIC_DRAW,
|
|
@@ -96,9 +102,8 @@ export default class OceanModel extends BaseModel {
|
|
|
96
102
|
type: gl.FLOAT
|
|
97
103
|
},
|
|
98
104
|
size: 2,
|
|
99
|
-
update: (feature, featureIdx, vertex
|
|
100
|
-
const
|
|
101
|
-
const [lng, lat] = v;
|
|
105
|
+
update: (feature, featureIdx, vertex) => {
|
|
106
|
+
const [lng, lat] = vertex;
|
|
102
107
|
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { IModel, IModelUniform } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class WaterModel 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
|
+
UV: number;
|
|
17
|
+
};
|
|
4
18
|
private texture;
|
|
5
19
|
getUninforms(): {
|
|
6
20
|
[x: string]: any;
|
|
@@ -3,17 +3,22 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
7
6
|
import { polygonTriangulation } from "../../core/triangulation";
|
|
8
7
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_frag.glsl' */
|
|
9
8
|
const water_frag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\n\nout vec4 outputColor;\n\n\nin vec4 v_Color;\nin vec2 v_uv;\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n\n outputColor = v_Color;\n float spc = calSpc();\n outputColor += spc * 0.4;\n}\n";
|
|
10
9
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
|
|
11
|
-
const water_vert = "layout(location =
|
|
10
|
+
const water_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_uv;\n\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\nout vec4 v_Color;\nout vec2 v_uv;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_Color = a_Color;\n v_Color.a *= opacity;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n}\n\n";
|
|
12
11
|
export default class WaterModel extends BaseModel {
|
|
13
12
|
constructor(...args) {
|
|
14
13
|
super(...args);
|
|
15
14
|
_defineProperty(this, "texture", void 0);
|
|
16
15
|
}
|
|
16
|
+
get attributeLocation() {
|
|
17
|
+
return Object.assign(super.attributeLocation, {
|
|
18
|
+
MAX: super.attributeLocation.MAX,
|
|
19
|
+
UV: 9
|
|
20
|
+
});
|
|
21
|
+
}
|
|
17
22
|
getUninforms() {
|
|
18
23
|
const commoninfo = this.getCommonUniformsInfo();
|
|
19
24
|
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
@@ -56,6 +61,7 @@ export default class WaterModel extends BaseModel {
|
|
|
56
61
|
vertexShader: water_vert,
|
|
57
62
|
fragmentShader: water_frag,
|
|
58
63
|
triangulation: polygonTriangulation,
|
|
64
|
+
defines: _this2.getDefines(),
|
|
59
65
|
inject: _this2.getInject(),
|
|
60
66
|
primitive: gl.TRIANGLES,
|
|
61
67
|
depth: {
|
|
@@ -81,7 +87,7 @@ export default class WaterModel extends BaseModel {
|
|
|
81
87
|
type: AttributeType.Attribute,
|
|
82
88
|
descriptor: {
|
|
83
89
|
name: 'a_uv',
|
|
84
|
-
shaderLocation:
|
|
90
|
+
shaderLocation: this.attributeLocation.UV,
|
|
85
91
|
buffer: {
|
|
86
92
|
// give the WebGL driver a hint that this buffer may change
|
|
87
93
|
usage: gl.STATIC_DRAW,
|
|
@@ -89,9 +95,8 @@ export default class WaterModel extends BaseModel {
|
|
|
89
95
|
type: gl.FLOAT
|
|
90
96
|
},
|
|
91
97
|
size: 2,
|
|
92
|
-
update: (feature, featureIdx, vertex
|
|
93
|
-
const
|
|
94
|
-
const [lng, lat] = v;
|
|
98
|
+
update: (feature, featureIdx, vertex) => {
|
|
99
|
+
const [lng, lat] = vertex;
|
|
95
100
|
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
|
96
101
|
}
|
|
97
102
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
layout(location =
|
|
5
|
-
layout(location =
|
|
6
|
-
|
|
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_COLOR) in vec4 a_Color;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
5
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
6
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec3 a_uvs;
|
|
7
7
|
|
|
8
8
|
layout(std140) uniform commonUniforms {
|
|
9
9
|
vec4 u_sourceColor;
|
|
@@ -24,26 +24,28 @@ out vec2 v_texture_data;
|
|
|
24
24
|
#pragma include "picking"
|
|
25
25
|
|
|
26
26
|
void main() {
|
|
27
|
-
|
|
28
|
-
|
|
29
27
|
v_uvs = a_uvs;
|
|
30
28
|
// cal style mapping - 数据纹理映射部分的计算
|
|
31
29
|
vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
|
|
32
|
-
vec4 project_pos = project_position(pos);
|
|
30
|
+
vec4 project_pos = project_position(pos, a_Position64Low);
|
|
33
31
|
|
|
34
|
-
if(u_heightfixed > 0.0) {
|
|
32
|
+
if (u_heightfixed > 0.0) {
|
|
33
|
+
// 判断几何体是否固定高度
|
|
35
34
|
project_pos.z = a_Position.z * a_Size;
|
|
36
35
|
project_pos.z += u_raisingHeight;
|
|
37
|
-
if(
|
|
38
|
-
|
|
36
|
+
if (
|
|
37
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
|
38
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
|
|
39
|
+
) {
|
|
40
|
+
float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
|
|
39
41
|
project_pos.z *= mapboxZoomScale;
|
|
40
42
|
project_pos.z += u_raisingHeight * mapboxZoomScale;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
gl_Position =
|
|
45
|
-
float lightWeight = calc_lighting(
|
|
46
|
-
v_texture_data = vec2(a_Position.z,lightWeight);
|
|
46
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
47
|
+
float lightWeight = calc_lighting(project_pos);
|
|
48
|
+
v_texture_data = vec2(a_Position.z, lightWeight);
|
|
47
49
|
|
|
48
50
|
v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
|
|
49
51
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
layout(location =
|
|
5
|
-
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_COLOR) in vec4 a_Color;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
5
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
6
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec3 a_uvs;
|
|
6
7
|
|
|
7
8
|
layout(std140) uniform commonUniforms {
|
|
8
9
|
vec4 u_sourceColor;
|
|
@@ -21,39 +22,41 @@ out vec4 v_Color;
|
|
|
21
22
|
#pragma include "picking"
|
|
22
23
|
|
|
23
24
|
void main() {
|
|
24
|
-
|
|
25
|
-
float
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
float sidey = a_uvs[2];
|
|
25
|
+
float isSide = a_Position.z;
|
|
26
|
+
float topU = a_uvs[0];
|
|
27
|
+
float topV = 1.0 - a_uvs[1];
|
|
28
|
+
float sidey = a_uvs[2];
|
|
29
29
|
|
|
30
30
|
vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
|
|
31
|
-
float lightWeight = calc_lighting(pos);
|
|
32
31
|
|
|
33
|
-
vec4 project_pos = project_position(pos);
|
|
32
|
+
vec4 project_pos = project_position(pos, a_Position64Low);
|
|
33
|
+
float lightWeight = calc_lighting(project_pos);
|
|
34
34
|
|
|
35
|
-
if(u_heightfixed > 0.0) {
|
|
35
|
+
if (u_heightfixed > 0.0) {
|
|
36
|
+
// 判断几何体是否固定高度
|
|
36
37
|
project_pos.z = a_Position.z * a_Size;
|
|
37
38
|
project_pos.z += u_raisingHeight;
|
|
38
39
|
|
|
39
|
-
if(
|
|
40
|
-
|
|
40
|
+
if (
|
|
41
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
|
42
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
|
|
43
|
+
) {
|
|
44
|
+
float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
|
|
41
45
|
project_pos.z *= mapboxZoomScale;
|
|
42
46
|
project_pos.z += u_raisingHeight * mapboxZoomScale;
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));
|
|
50
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
48
51
|
|
|
49
52
|
// Tip: 部分机型 GPU 计算精度兼容
|
|
50
|
-
if(isSide < 0.999) {
|
|
53
|
+
if (isSide < 0.999) {
|
|
51
54
|
// side face
|
|
52
55
|
// if(u_sidesurface < 1.0) {
|
|
53
56
|
// discard;
|
|
54
57
|
// }
|
|
55
58
|
|
|
56
|
-
if(u_linearColor == 1.0) {
|
|
59
|
+
if (u_linearColor == 1.0) {
|
|
57
60
|
vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);
|
|
58
61
|
linearColor.rgb *= lightWeight;
|
|
59
62
|
v_Color = linearColor;
|
|
@@ -67,6 +70,5 @@ float isSide = a_Position.z;
|
|
|
67
70
|
|
|
68
71
|
v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);
|
|
69
72
|
|
|
70
|
-
|
|
71
73
|
setPickingColor(a_PickingColor);
|
|
72
74
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
layout(location =
|
|
5
|
-
layout(location =
|
|
6
|
-
|
|
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_COLOR) in vec4 a_Color;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
5
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
6
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec3 a_uvs;
|
|
7
7
|
|
|
8
8
|
layout(std140) uniform commonUniforms {
|
|
9
9
|
vec4 u_sourceColor;
|
|
@@ -24,31 +24,31 @@ out vec2 v_texture_data;
|
|
|
24
24
|
#pragma include "picking"
|
|
25
25
|
|
|
26
26
|
void main() {
|
|
27
|
-
|
|
28
27
|
vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
vec4 project_pos = project_position(pos, a_Position64Low);
|
|
29
|
+
float lightWeight = calc_lighting(project_pos);
|
|
31
30
|
v_uvs = a_uvs;
|
|
32
31
|
v_Color = a_Color;
|
|
33
32
|
v_Color.a *= opacity;
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
v_texture_data = vec2(a_Position.z, lightWeight);
|
|
36
35
|
|
|
37
|
-
if(u_heightfixed > 0.0) {
|
|
36
|
+
if (u_heightfixed > 0.0) {
|
|
37
|
+
// 判断几何体是否固定高度
|
|
38
38
|
project_pos.z = a_Position.z * a_Size;
|
|
39
39
|
project_pos.z += u_raisingHeight;
|
|
40
40
|
|
|
41
|
-
if(
|
|
42
|
-
|
|
41
|
+
if (
|
|
42
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
|
43
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
|
|
44
|
+
) {
|
|
45
|
+
float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
|
|
43
46
|
project_pos.z *= mapboxZoomScale;
|
|
44
47
|
project_pos.z += u_raisingHeight * mapboxZoomScale;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
52
52
|
|
|
53
53
|
setPickingColor(a_PickingColor);
|
|
54
54
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
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_COLOR) in vec4 a_Color;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
5
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
5
6
|
|
|
6
7
|
out vec4 v_Color;
|
|
7
8
|
|
|
@@ -10,15 +11,14 @@ out vec4 v_Color;
|
|
|
10
11
|
#pragma include "picking"
|
|
11
12
|
|
|
12
13
|
void main() {
|
|
13
|
-
|
|
14
14
|
vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size + (1.0 - a_Position.z) * extrusionBase, 1.0);
|
|
15
15
|
|
|
16
|
-
vec4 project_pos = project_position(pos);
|
|
17
|
-
|
|
16
|
+
vec4 project_pos = project_position(pos, a_Position64Low);
|
|
17
|
+
float lightWeight = calc_lighting(project_pos);
|
|
18
18
|
v_Color = a_Color;
|
|
19
19
|
v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);
|
|
20
20
|
|
|
21
|
-
gl_Position =
|
|
21
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
22
22
|
|
|
23
23
|
setPickingColor(a_PickingColor);
|
|
24
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
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_COLOR) in vec4 a_Color;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_LINEAR) in vec3 a_linear;
|
|
4
5
|
|
|
5
6
|
layout(std140) uniform commonUniforms {
|
|
6
7
|
float u_raisingHeight;
|
|
@@ -21,7 +22,7 @@ void main() {
|
|
|
21
22
|
v_pos = a_Position.xy;
|
|
22
23
|
}
|
|
23
24
|
v_color = vec4(a_Color.xyz, a_Color.w * opacity);
|
|
24
|
-
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
25
|
+
vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
|
|
25
26
|
project_pos.z += u_raisingHeight;
|
|
26
27
|
|
|
27
28
|
if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
@@ -30,6 +31,6 @@ void main() {
|
|
|
30
31
|
project_pos.z += u_raisingHeight * mapboxZoomScale;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
gl_Position =
|
|
34
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
34
35
|
setPickingColor(a_PickingColor);
|
|
35
|
-
}
|
|
36
|
+
}
|
|
@@ -1,36 +1,34 @@
|
|
|
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_COLOR) in vec4 a_Color;
|
|
3
4
|
|
|
4
5
|
layout(std140) uniform commonUniforms {
|
|
5
6
|
float u_raisingHeight;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
|
-
|
|
9
9
|
out vec4 v_color;
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
#pragma include "projection"
|
|
13
12
|
#pragma include "picking"
|
|
14
13
|
|
|
15
14
|
void main() {
|
|
16
15
|
// cal style mapping - 数据纹理映射部分的计算
|
|
17
16
|
|
|
18
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
19
|
-
|
|
20
17
|
v_color = vec4(a_Color.xyz, a_Color.w * opacity);
|
|
21
|
-
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
22
|
-
// gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
18
|
+
vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
|
|
23
19
|
|
|
24
20
|
project_pos.z += u_raisingHeight;
|
|
25
21
|
|
|
26
|
-
if(
|
|
27
|
-
|
|
22
|
+
if (
|
|
23
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
|
24
|
+
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
|
|
25
|
+
) {
|
|
26
|
+
float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
|
|
28
27
|
project_pos.z *= mapboxZoomScale;
|
|
29
28
|
project_pos.z += u_raisingHeight * mapboxZoomScale;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));
|
|
31
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
34
32
|
|
|
35
33
|
setPickingColor(a_PickingColor);
|
|
36
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_uv;
|
|
3
3
|
|
|
4
4
|
layout(std140) uniform commonUniforms {
|
|
5
5
|
vec4 u_watercolor;
|
|
@@ -7,7 +7,6 @@ layout(std140) uniform commonUniforms {
|
|
|
7
7
|
float u_time;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
out vec2 v_uv;
|
|
12
11
|
out float v_opacity;
|
|
13
12
|
|
|
@@ -17,6 +16,6 @@ void main() {
|
|
|
17
16
|
v_uv = a_uv;
|
|
18
17
|
v_opacity = opacity;
|
|
19
18
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
20
|
-
gl_Position =
|
|
19
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_uv;
|
|
4
|
+
|
|
4
5
|
layout(std140) uniform commonUniforms {
|
|
5
6
|
float u_speed;
|
|
6
7
|
float u_time;
|
|
@@ -8,7 +9,6 @@ layout(std140) uniform commonUniforms {
|
|
|
8
9
|
out vec4 v_Color;
|
|
9
10
|
out vec2 v_uv;
|
|
10
11
|
|
|
11
|
-
|
|
12
12
|
#pragma include "projection"
|
|
13
13
|
|
|
14
14
|
void main() {
|
|
@@ -17,6 +17,6 @@ void main() {
|
|
|
17
17
|
v_Color.a *= opacity;
|
|
18
18
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
19
19
|
|
|
20
|
-
gl_Position =
|
|
20
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
21
21
|
}
|
|
22
22
|
|
package/es/raster/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ILegend } from '@antv/l7-core';
|
|
|
2
2
|
import BaseLayer from '../core/BaseLayer';
|
|
3
3
|
import type { IRasterLayerStyleOptions } from '../core/interface';
|
|
4
4
|
import type { RasterModelType } from './models/index';
|
|
5
|
-
export default class
|
|
5
|
+
export default class RasterLayer extends BaseLayer<IRasterLayerStyleOptions> {
|
|
6
6
|
type: string;
|
|
7
7
|
buildModels(): Promise<void>;
|
|
8
8
|
protected getDefaultConfig(): {} | {} | {} | {};
|
package/es/raster/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
import BaseLayer from "../core/BaseLayer";
|
|
4
4
|
import { rampColor2legend } from "../utils/rampcolor_legend";
|
|
5
5
|
import RasterModels from "./models/index";
|
|
6
|
-
export default class
|
|
6
|
+
export default class RasterLayer extends BaseLayer {
|
|
7
7
|
constructor(...args) {
|
|
8
8
|
super(...args);
|
|
9
9
|
_defineProperty(this, "type", 'RasterLayer');
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class RasterModel 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
|
+
UV: number;
|
|
17
|
+
};
|
|
4
18
|
protected texture: ITexture2D;
|
|
5
19
|
protected colorTexture: ITexture2D;
|
|
6
20
|
getUninforms(): {
|