@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
|
@@ -9,16 +9,22 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
9
9
|
var _l7Core = require("@antv/l7-core");
|
|
10
10
|
var _l7Utils = require("@antv/l7-utils");
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
13
12
|
var _triangulation = require("../../core/triangulation");
|
|
14
13
|
/* babel-plugin-inline-import '../shaders/atmosphere/atmosphere_frag.glsl' */
|
|
15
14
|
const atmoSphereFrag = "\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\nin vec3 vVertexNormal;\nin float v_offset;\nin vec4 v_Color;\n\n#pragma include \"scene_uniforms\"\nout vec4 outputColor;\nvoid main() {\n \n \n // float intensity = pow(0.5 + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);\n float intensity = pow(v_offset + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);\n // \u53BB\u9664\u80CC\u9762\n if(intensity > 1.0) intensity = 0.0;\n\n outputColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/atmosphere/atmosphere_vert.glsl' */
|
|
17
|
-
const atmoSphereVert = "layout(location =
|
|
16
|
+
const atmoSphereVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\n\n#pragma include \"scene_uniforms\"\nout vec3 vVertexNormal;\nout vec4 v_Color;\nout float v_offset;\n\nvoid main() {\n float EARTH_RADIUS = 100.0;\n\n v_Color = a_Color;\n\n v_offset = min(((length(u_CameraPosition) - EARTH_RADIUS)/600.0) * 0.5 + 0.4, 1.0);\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
|
|
18
17
|
const {
|
|
19
18
|
isNumber
|
|
20
19
|
} = _l7Utils.lodashUtil;
|
|
21
20
|
class EarthAtomSphereModel extends _BaseModel.default {
|
|
21
|
+
get attributeLocation() {
|
|
22
|
+
return Object.assign(super.attributeLocation, {
|
|
23
|
+
MAX: super.attributeLocation.MAX,
|
|
24
|
+
NORMAL: 9,
|
|
25
|
+
UV: 10
|
|
26
|
+
});
|
|
27
|
+
}
|
|
22
28
|
getCommonUniformsInfo() {
|
|
23
29
|
const {
|
|
24
30
|
opacity = 1
|
|
@@ -48,6 +54,7 @@ class EarthAtomSphereModel extends _BaseModel.default {
|
|
|
48
54
|
moduleName: 'earthAtmoSphere',
|
|
49
55
|
vertexShader: atmoSphereVert,
|
|
50
56
|
fragmentShader: atmoSphereFrag,
|
|
57
|
+
defines: _this2.getDefines(),
|
|
51
58
|
triangulation: _triangulation.earthTriangulation,
|
|
52
59
|
depth: {
|
|
53
60
|
enable: false
|
|
@@ -59,32 +66,31 @@ class EarthAtomSphereModel extends _BaseModel.default {
|
|
|
59
66
|
}
|
|
60
67
|
registerBuiltinAttributes() {
|
|
61
68
|
// point layer size;
|
|
62
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
69
|
+
// this.styleAttributeService.registerStyleAttribute({
|
|
70
|
+
// name: 'size',
|
|
71
|
+
// type: AttributeType.Attribute,
|
|
72
|
+
// descriptor: {
|
|
73
|
+
// name: 'a_Size',
|
|
74
|
+
// shaderLocation: this.attributeLocation.SIZE,
|
|
75
|
+
// buffer: {
|
|
76
|
+
// usage: gl.DYNAMIC_DRAW,
|
|
77
|
+
// data: [],
|
|
78
|
+
// type: gl.FLOAT,
|
|
79
|
+
// },
|
|
80
|
+
// size: 1,
|
|
81
|
+
// update: (feature: IEncodeFeature) => {
|
|
82
|
+
// const { size = 1 } = feature;
|
|
83
|
+
// return Array.isArray(size) ? [size[0]] : [size as number];
|
|
84
|
+
// },
|
|
85
|
+
// },
|
|
86
|
+
// });
|
|
87
|
+
|
|
82
88
|
this.styleAttributeService.registerStyleAttribute({
|
|
83
89
|
name: 'normal',
|
|
84
90
|
type: _l7Core.AttributeType.Attribute,
|
|
85
91
|
descriptor: {
|
|
86
92
|
name: 'a_Normal',
|
|
87
|
-
shaderLocation:
|
|
93
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
88
94
|
buffer: {
|
|
89
95
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
90
96
|
data: [],
|
|
@@ -101,7 +107,7 @@ class EarthAtomSphereModel extends _BaseModel.default {
|
|
|
101
107
|
type: _l7Core.AttributeType.Attribute,
|
|
102
108
|
descriptor: {
|
|
103
109
|
name: 'a_Uv',
|
|
104
|
-
shaderLocation:
|
|
110
|
+
shaderLocation: this.attributeLocation.UV,
|
|
105
111
|
buffer: {
|
|
106
112
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
107
113
|
data: [],
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class BaseEarthModel 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
|
+
NORMAL: number;
|
|
17
|
+
UV: number;
|
|
18
|
+
};
|
|
4
19
|
protected texture: ITexture2D;
|
|
5
20
|
private earthTime;
|
|
6
21
|
private sunX;
|
package/lib/earth/models/base.js
CHANGED
|
@@ -10,11 +10,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _l7Core = require("@antv/l7-core");
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
12
|
var _triangulation = require("../../core/triangulation");
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
/* babel-plugin-inline-import '../shaders/base/base_frag.glsl' */
|
|
15
14
|
const baseFrag = "uniform sampler2D u_texture;\n\nin vec2 v_texCoord;\nin float v_lightWeight;\nout vec4 outputColor;\n\nvoid main() {\n vec4 color = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y));\n color.xyz = color.xyz * v_lightWeight;\n outputColor = color;\n}\n";
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/base/base_vert.glsl' */
|
|
17
|
-
const baseVert = "// attribute vec4 a_Color;\nlayout(location =
|
|
16
|
+
const baseVert = "// attribute vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\n// attribute vec2 a_Extrude;\n// attribute float a_Size;\n// attribute float a_Shape;\n\nlayout(std140) uniform commonUniforms {\n\tvec4 u_sunLight: [1.0, -10.5, 12.0,0.0];\n\tfloat u_ambientRatio : 0.5;\n\tfloat u_diffuseRatio : 0.3;\n\tfloat u_specularRatio : 0.2;\n};\n\n#pragma include \"scene_uniforms\"\n\nout vec2 v_texCoord;\nout float v_lightWeight;\n\nfloat calc_lighting(vec4 pos) {\n\n\tvec3 worldPos = vec3(pos * u_ModelMatrix);\n\n\tvec3 worldNormal = a_Normal;\n\n\t// cal light weight\n\tvec3 viewDir = normalize(u_CameraPosition - worldPos);\n\n\tvec3 lightDir = normalize(u_sunLight.xyz);\n\n\tvec3 halfDir = normalize(viewDir+lightDir);\n\t// lambert\n\tfloat lambert = dot(worldNormal, lightDir);\n\t// specular\n\tfloat specular = pow(max(0.0, dot(worldNormal, halfDir)), 32.0);\n\t//sum to light weight\n\tfloat lightWeight = u_ambientRatio + u_diffuseRatio * lambert + u_specularRatio * specular;\n\n\treturn lightWeight;\n}\n\nvoid main() {\n\n\tv_texCoord = a_Uv;\n\n\tfloat lightWeight = calc_lighting(vec4(a_Position, 1.0));\n\tv_lightWeight = lightWeight;\n\n\tgl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
|
|
18
17
|
class BaseEarthModel extends _BaseModel.default {
|
|
19
18
|
constructor(...args) {
|
|
20
19
|
super(...args);
|
|
@@ -26,6 +25,13 @@ class BaseEarthModel extends _BaseModel.default {
|
|
|
26
25
|
(0, _defineProperty2.default)(this, "sunZ", 1000);
|
|
27
26
|
(0, _defineProperty2.default)(this, "sunRadius", Math.sqrt(this.sunX * this.sunX + this.sunY * this.sunY + this.sunZ * this.sunZ));
|
|
28
27
|
}
|
|
28
|
+
get attributeLocation() {
|
|
29
|
+
return Object.assign(super.attributeLocation, {
|
|
30
|
+
MAX: super.attributeLocation.MAX,
|
|
31
|
+
NORMAL: 9,
|
|
32
|
+
UV: 10
|
|
33
|
+
});
|
|
34
|
+
}
|
|
29
35
|
getCommonUniformsInfo() {
|
|
30
36
|
const {
|
|
31
37
|
animateOption,
|
|
@@ -104,6 +110,7 @@ class BaseEarthModel extends _BaseModel.default {
|
|
|
104
110
|
moduleName: 'earthBase',
|
|
105
111
|
vertexShader: baseVert,
|
|
106
112
|
fragmentShader: baseFrag,
|
|
113
|
+
defines: _this2.getDefines(),
|
|
107
114
|
triangulation: _triangulation.earthTriangulation,
|
|
108
115
|
depth: {
|
|
109
116
|
enable: true
|
|
@@ -114,32 +121,31 @@ class BaseEarthModel extends _BaseModel.default {
|
|
|
114
121
|
})();
|
|
115
122
|
}
|
|
116
123
|
registerBuiltinAttributes() {
|
|
117
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
124
|
+
// this.styleAttributeService.registerStyleAttribute({
|
|
125
|
+
// name: 'size',
|
|
126
|
+
// type: AttributeType.Attribute,
|
|
127
|
+
// descriptor: {
|
|
128
|
+
// name: 'a_Size',
|
|
129
|
+
// shaderLocation: this.attributeLocation.SIZE,
|
|
130
|
+
// buffer: {
|
|
131
|
+
// usage: gl.DYNAMIC_DRAW,
|
|
132
|
+
// data: [],
|
|
133
|
+
// type: gl.FLOAT,
|
|
134
|
+
// },
|
|
135
|
+
// size: 1,
|
|
136
|
+
// update: (feature: IEncodeFeature) => {
|
|
137
|
+
// const { size = 1 } = feature;
|
|
138
|
+
// return Array.isArray(size) ? [size[0]] : [size as number];
|
|
139
|
+
// },
|
|
140
|
+
// },
|
|
141
|
+
// });
|
|
142
|
+
|
|
137
143
|
this.styleAttributeService.registerStyleAttribute({
|
|
138
144
|
name: 'normal',
|
|
139
145
|
type: _l7Core.AttributeType.Attribute,
|
|
140
146
|
descriptor: {
|
|
141
147
|
name: 'a_Normal',
|
|
142
|
-
shaderLocation:
|
|
148
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
143
149
|
buffer: {
|
|
144
150
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
145
151
|
data: [],
|
|
@@ -156,7 +162,7 @@ class BaseEarthModel extends _BaseModel.default {
|
|
|
156
162
|
type: _l7Core.AttributeType.Attribute,
|
|
157
163
|
descriptor: {
|
|
158
164
|
name: 'a_Uv',
|
|
159
|
-
shaderLocation:
|
|
165
|
+
shaderLocation: this.attributeLocation.UV,
|
|
160
166
|
buffer: {
|
|
161
167
|
// give the WebGL driver a hint that this buffer may change
|
|
162
168
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { IModel } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class EarthBloomSphereModel 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
|
+
NORMAL: number;
|
|
17
|
+
UV: number;
|
|
18
|
+
};
|
|
4
19
|
protected getCommonUniformsInfo(): {
|
|
5
20
|
uniformsArray: number[];
|
|
6
21
|
uniformsLength: number;
|
|
@@ -9,16 +9,22 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
9
9
|
var _l7Core = require("@antv/l7-core");
|
|
10
10
|
var _l7Utils = require("@antv/l7-utils");
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
13
12
|
var _triangulation = require("../../core/triangulation");
|
|
14
13
|
/* babel-plugin-inline-import '../shaders/bloomshpere/bloomsphere_frag.glsl' */
|
|
15
14
|
const bloomSphereFrag = "\nin vec3 vVertexNormal;\nin vec4 v_Color;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\nout vec4 outputColor;\n#pragma include \"scene_uniforms\"\nvoid main() {\n float intensity = - dot(normalize(vVertexNormal), normalize(u_CameraPosition));\n // \u53BB\u9664\u80CC\u9762\n if(intensity > 1.0) intensity = 0.0;\n\n outputColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/bloomshpere/bloomsphere_vert.glsl' */
|
|
17
|
-
const bloomSphereVert = "layout(location =
|
|
16
|
+
const bloomSphereVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\n#pragma include \"scene_uniforms\"\n\nout vec3 vVertexNormal;\nout vec4 v_Color;\n\nvoid main() {\n v_Color = a_Color;\n\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
|
|
18
17
|
const {
|
|
19
18
|
isNumber
|
|
20
19
|
} = _l7Utils.lodashUtil;
|
|
21
20
|
class EarthBloomSphereModel extends _BaseModel.default {
|
|
21
|
+
get attributeLocation() {
|
|
22
|
+
return Object.assign(super.attributeLocation, {
|
|
23
|
+
MAX: super.attributeLocation.MAX,
|
|
24
|
+
NORMAL: 9,
|
|
25
|
+
UV: 10
|
|
26
|
+
});
|
|
27
|
+
}
|
|
22
28
|
getCommonUniformsInfo() {
|
|
23
29
|
const {
|
|
24
30
|
opacity = 1
|
|
@@ -48,6 +54,7 @@ class EarthBloomSphereModel extends _BaseModel.default {
|
|
|
48
54
|
moduleName: 'earthBloom',
|
|
49
55
|
vertexShader: bloomSphereVert,
|
|
50
56
|
fragmentShader: bloomSphereFrag,
|
|
57
|
+
defines: _this2.getDefines(),
|
|
51
58
|
triangulation: _triangulation.earthOuterTriangulation,
|
|
52
59
|
depth: {
|
|
53
60
|
enable: false
|
|
@@ -58,32 +65,31 @@ class EarthBloomSphereModel extends _BaseModel.default {
|
|
|
58
65
|
})();
|
|
59
66
|
}
|
|
60
67
|
registerBuiltinAttributes() {
|
|
61
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
68
|
+
// this.styleAttributeService.registerStyleAttribute({
|
|
69
|
+
// name: 'size',
|
|
70
|
+
// type: AttributeType.Attribute,
|
|
71
|
+
// descriptor: {
|
|
72
|
+
// name: 'a_Size',
|
|
73
|
+
// shaderLocation: this.attributeLocation.SIZE,
|
|
74
|
+
// buffer: {
|
|
75
|
+
// usage: gl.DYNAMIC_DRAW,
|
|
76
|
+
// data: [],
|
|
77
|
+
// type: gl.FLOAT,
|
|
78
|
+
// },
|
|
79
|
+
// size: 1,
|
|
80
|
+
// update: (feature: IEncodeFeature) => {
|
|
81
|
+
// const { size = 1 } = feature;
|
|
82
|
+
// return Array.isArray(size) ? [size[0]] : [size as number];
|
|
83
|
+
// },
|
|
84
|
+
// },
|
|
85
|
+
// });
|
|
86
|
+
|
|
81
87
|
this.styleAttributeService.registerStyleAttribute({
|
|
82
88
|
name: 'normal',
|
|
83
89
|
type: _l7Core.AttributeType.Attribute,
|
|
84
90
|
descriptor: {
|
|
85
91
|
name: 'a_Normal',
|
|
86
|
-
shaderLocation:
|
|
92
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
87
93
|
buffer: {
|
|
88
94
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
89
95
|
data: [],
|
|
@@ -100,7 +106,7 @@ class EarthBloomSphereModel extends _BaseModel.default {
|
|
|
100
106
|
type: _l7Core.AttributeType.Attribute,
|
|
101
107
|
descriptor: {
|
|
102
108
|
name: 'a_Uv',
|
|
103
|
-
shaderLocation:
|
|
109
|
+
shaderLocation: this.attributeLocation.UV,
|
|
104
110
|
buffer: {
|
|
105
111
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
106
112
|
data: [],
|
|
@@ -1,10 +1,12 @@
|
|
|
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_COLOR) vec4 a_Color;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
|
|
5
|
+
|
|
5
6
|
layout(std140) uniform commonUniforms {
|
|
6
7
|
float u_opacity;
|
|
7
8
|
};
|
|
9
|
+
|
|
8
10
|
#pragma include "scene_uniforms"
|
|
9
11
|
out vec3 vVertexNormal;
|
|
10
12
|
out vec4 v_Color;
|
|
@@ -12,7 +14,7 @@ out float v_offset;
|
|
|
12
14
|
|
|
13
15
|
void main() {
|
|
14
16
|
float EARTH_RADIUS = 100.0;
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
v_Color = a_Color;
|
|
17
19
|
|
|
18
20
|
v_offset = min(((length(u_CameraPosition) - EARTH_RADIUS)/600.0) * 0.5 + 0.4, 1.0);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// attribute vec4 a_Color;
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
layout(location =
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
|
|
5
5
|
|
|
6
6
|
// attribute vec2 a_Extrude;
|
|
7
7
|
// attribute float a_Size;
|
|
@@ -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_COLOR) vec4 a_Color;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
|
|
5
|
+
|
|
5
6
|
layout(std140) uniform commonUniforms {
|
|
6
7
|
float u_opacity;
|
|
7
8
|
};
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class BillBoardModel 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
|
+
EXTRUDE: number;
|
|
17
|
+
UV: number;
|
|
18
|
+
};
|
|
4
19
|
protected texture: ITexture2D;
|
|
5
20
|
private radian;
|
|
6
21
|
planeGeometryTriangulation: () => {
|
|
@@ -10,11 +10,10 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _l7Core = require("@antv/l7-core");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
/* babel-plugin-inline-import '../shaders/billboard_frag.glsl' */
|
|
15
14
|
const planeFrag = "layout(std140) uniform commonUniforms {\n vec2 u_size;\n float u_raisingHeight;\n float u_rotation;\n float u_opacity;\n};\n\nuniform sampler2D u_texture;\n\nin vec2 v_uv;\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_texture), vec2(v_uv.x, 1.0 - v_uv.y));\n outputColor.a *= u_opacity;\n outputColor = filterColor(outputColor);\n}\n";
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/billboard_vert.glsl' */
|
|
17
|
-
const planeVert = "layout(location =
|
|
16
|
+
const planeVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_size;\n float u_raisingHeight;\n float u_rotation;\n float u_opacity;\n};\n\nout vec2 v_uv;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = a_Uv;\n float raiseHeight = u_raisingHeight;\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 raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n // \u8BA1\u7B97\u7ECF\u7EAC\u5EA6\u70B9\u4F4D\u5750\u6807\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // \u8BA1\u7B97\u7ED5 z \u8F74\u65CB\u8F6C\u540E\u7684\u504F\u79FB\n vec2 offsetXY = project_pixel(rotate_matrix(vec2(extrude.x * u_size.x, 0.0), u_rotation));\n // \u7ED5 z \u8F74\u65CB\u8F6C\n float x = project_pos.x + offsetXY.x;\n float y = project_pos.y + offsetXY.y;\n // z \u8F74\u4E0D\u53C2\u4E0E\u65CB\u8F6C\n float z = project_pixel(extrude.y * u_size.y + raiseHeight);\n\n gl_Position = project_common_position_to_clipspace(vec4(x, y, z, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
18
17
|
class BillBoardModel extends _BaseModel.default {
|
|
19
18
|
constructor(...args) {
|
|
20
19
|
super(...args);
|
|
@@ -32,6 +31,13 @@ class BillBoardModel extends _BaseModel.default {
|
|
|
32
31
|
};
|
|
33
32
|
});
|
|
34
33
|
}
|
|
34
|
+
get attributeLocation() {
|
|
35
|
+
return Object.assign(super.attributeLocation, {
|
|
36
|
+
MAX: super.attributeLocation.MAX,
|
|
37
|
+
EXTRUDE: 9,
|
|
38
|
+
UV: 10
|
|
39
|
+
});
|
|
40
|
+
}
|
|
35
41
|
getUninforms() {
|
|
36
42
|
const commoninfo = this.getCommonUniformsInfo();
|
|
37
43
|
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
@@ -49,12 +55,11 @@ class BillBoardModel extends _BaseModel.default {
|
|
|
49
55
|
/**
|
|
50
56
|
* rotateFlag
|
|
51
57
|
* DEFAULT 1
|
|
52
|
-
* MAPBOX
|
|
53
|
-
*
|
|
54
|
-
* GAODE1.x -1
|
|
58
|
+
* MAPBOX 1
|
|
59
|
+
* AMAP -1
|
|
55
60
|
*/
|
|
56
61
|
let rotateFlag = 1;
|
|
57
|
-
if (this.mapService.
|
|
62
|
+
if (this.mapService.getType() === 'amap') {
|
|
58
63
|
rotateFlag = -1;
|
|
59
64
|
}
|
|
60
65
|
// 控制图标的旋转角度(绕 Z 轴旋转)
|
|
@@ -96,6 +101,7 @@ class BillBoardModel extends _BaseModel.default {
|
|
|
96
101
|
vertexShader: planeVert,
|
|
97
102
|
fragmentShader: planeFrag,
|
|
98
103
|
triangulation: _this.planeGeometryTriangulation,
|
|
104
|
+
defines: _this.getDefines(),
|
|
99
105
|
inject: _this.getInject(),
|
|
100
106
|
primitive: _l7Core.gl.TRIANGLES,
|
|
101
107
|
depth: {
|
|
@@ -141,7 +147,7 @@ class BillBoardModel extends _BaseModel.default {
|
|
|
141
147
|
type: _l7Core.AttributeType.Attribute,
|
|
142
148
|
descriptor: {
|
|
143
149
|
name: 'a_Extrude',
|
|
144
|
-
shaderLocation:
|
|
150
|
+
shaderLocation: this.attributeLocation.EXTRUDE,
|
|
145
151
|
buffer: {
|
|
146
152
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
147
153
|
data: [],
|
|
@@ -160,7 +166,7 @@ class BillBoardModel extends _BaseModel.default {
|
|
|
160
166
|
type: _l7Core.AttributeType.Attribute,
|
|
161
167
|
descriptor: {
|
|
162
168
|
name: 'a_Uv',
|
|
163
|
-
shaderLocation:
|
|
169
|
+
shaderLocation: this.attributeLocation.UV,
|
|
164
170
|
buffer: {
|
|
165
171
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
166
172
|
data: [],
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class PlaneModel 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 terrainImage: HTMLImageElement;
|
|
6
20
|
protected terrainImageLoaded: boolean;
|
|
@@ -10,12 +10,11 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _l7Core = require("@antv/l7-core");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
// import { mat4, vec3 } from 'gl-matrix';
|
|
15
14
|
/* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
|
|
16
15
|
const planeFrag = "\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_terrainClipHeight;\n};\n\nin vec3 v_Color;\nin vec2 v_uv;\nin float v_clip;\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // gl_FragColor = vec4(v_Color, u_opacity);\n if(u_mapFlag > 0.0) {\n outputColor = texture(SAMPLER_2D(u_texture), vec2(v_uv.x, 1.0 - v_uv.y));\n outputColor.a *= u_opacity;\n } else {\n // gl_FragColor = vec4(v_uv, 0.0, u_opacity);\n outputColor = vec4(v_Color, u_opacity);\n }\n outputColor.a *= v_clip;\n outputColor = filterColor(outputColor);\n}\n";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
|
|
18
|
-
const planeVert = "\nlayout(location =
|
|
17
|
+
const planeVert = "\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec3 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_terrainClipHeight;\n};\n\nout vec3 v_Color;\nout vec2 v_uv;\nout float v_clip;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvoid main() {\n v_Color = a_Color;\n v_uv = a_Uv;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n v_clip = 1.0;\n if(a_Position.z < u_terrainClipHeight) {\n v_clip = 0.0;\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
18
|
class PlaneModel extends _BaseModel.default {
|
|
20
19
|
constructor(...args) {
|
|
21
20
|
super(...args);
|
|
@@ -47,6 +46,12 @@ class PlaneModel extends _BaseModel.default {
|
|
|
47
46
|
};
|
|
48
47
|
});
|
|
49
48
|
}
|
|
49
|
+
get attributeLocation() {
|
|
50
|
+
return Object.assign(super.attributeLocation, {
|
|
51
|
+
MAX: super.attributeLocation.MAX,
|
|
52
|
+
UV: 10
|
|
53
|
+
});
|
|
54
|
+
}
|
|
50
55
|
initPlane(width = 1, height = 1, widthSegments = 1, heightSegments = 1, lng = 120, lat = 30) {
|
|
51
56
|
// https://github.com/mrdoob/three.js/blob/dev/src/geometries/PlaneGeometry.js
|
|
52
57
|
const widthHalf = width / 2;
|
|
@@ -63,13 +68,7 @@ class PlaneModel extends _BaseModel.default {
|
|
|
63
68
|
const y = iy * segmentHeight - heightHalf;
|
|
64
69
|
for (let ix = 0; ix < gridX1; ix++) {
|
|
65
70
|
const x = ix * segmentWidth - widthHalf;
|
|
66
|
-
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
const [a, b] = this.mapService.lngLatToCoord([x + lng, -y + lat]);
|
|
69
|
-
positions.push(a, b, 0);
|
|
70
|
-
} else {
|
|
71
|
-
positions.push(x + lng, -y + lat, 0);
|
|
72
|
-
}
|
|
71
|
+
positions.push(x + lng, -y + lat, 0);
|
|
73
72
|
positions.push(ix / gridX);
|
|
74
73
|
positions.push(1 - iy / gridY);
|
|
75
74
|
}
|
|
@@ -146,6 +145,7 @@ class PlaneModel extends _BaseModel.default {
|
|
|
146
145
|
vertexShader: planeVert,
|
|
147
146
|
fragmentShader: planeFrag,
|
|
148
147
|
triangulation: _this.planeGeometryTriangulation,
|
|
148
|
+
defines: _this.getDefines(),
|
|
149
149
|
inject: _this.getInject(),
|
|
150
150
|
primitive: _l7Core.gl.TRIANGLES,
|
|
151
151
|
depth: {
|
|
@@ -303,7 +303,7 @@ class PlaneModel extends _BaseModel.default {
|
|
|
303
303
|
type: _l7Core.AttributeType.Attribute,
|
|
304
304
|
descriptor: {
|
|
305
305
|
name: 'a_Uv',
|
|
306
|
-
shaderLocation:
|
|
306
|
+
shaderLocation: this.attributeLocation.UV,
|
|
307
307
|
buffer: {
|
|
308
308
|
// give the WebGL driver a hint that this buffer may change
|
|
309
309
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -13,7 +13,7 @@ var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/sprite_frag.glsl' */
|
|
14
14
|
const spriteFrag = "\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_Scale;\n};\nuniform sampler2D u_texture;\n\nin vec3 v_Color;\nin float v_d;\nout vec4 outputColor;\n\nvoid main() {\n\n if(v_d < 0.0) {\n discard;\n }\n\n if(u_mapFlag > 0.0) {\n outputColor = texture(SAMPLER_2D(u_texture), gl_PointCoord);\n outputColor.a *= u_opacity;\n } else {\n outputColor = vec4(v_Color, u_opacity);\n }\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/sprite_vert.glsl' */
|
|
16
|
-
const spriteVert = "layout(location =
|
|
16
|
+
const spriteVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec3 a_Color;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_Scale;\n};\n\nout vec3 v_Color;\nout float v_d;\n\n#pragma include \"projection\"\nvoid main() {\n v_Color = a_Color.xyz;\n v_d = a_Position.z;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n gl_PointSize = pow(u_Zoom - 1.0, 2.0) * u_Scale;\n}\n";
|
|
17
17
|
var SPRITE_ANIMATE_DIR = /*#__PURE__*/function (SPRITE_ANIMATE_DIR) {
|
|
18
18
|
SPRITE_ANIMATE_DIR["UP"] = "up";
|
|
19
19
|
SPRITE_ANIMATE_DIR["DOWN"] = "down";
|
|
@@ -99,7 +99,6 @@ class SpriteModel extends _BaseModel.default {
|
|
|
99
99
|
initSprite(radius = 10, spriteCount = 100, lng = 120, lat = 30) {
|
|
100
100
|
const indices = [];
|
|
101
101
|
const positions = [];
|
|
102
|
-
const mapService = this.mapService;
|
|
103
102
|
const heightLimit = this.spriteAnimate === SPRITE_ANIMATE_DIR.UP ? -this.spriteTop : this.spriteTop;
|
|
104
103
|
for (let i = 0; i < spriteCount; i++) {
|
|
105
104
|
const height = Math.random() * heightLimit;
|
|
@@ -113,13 +112,7 @@ class SpriteModel extends _BaseModel.default {
|
|
|
113
112
|
const randomY = radius * Math.random();
|
|
114
113
|
const x = -radius / 2 + randomX;
|
|
115
114
|
const y = -radius / 2 + randomY;
|
|
116
|
-
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
const [a, b] = mapService.lngLatToCoord([x + lng, -y + lat]);
|
|
119
|
-
return [a, b, z, 0, 0];
|
|
120
|
-
} else {
|
|
121
|
-
return [x + lng, -y + lat, z, 0, 0];
|
|
122
|
-
}
|
|
115
|
+
return [x + lng, -y + lat, z, 0, 0];
|
|
123
116
|
}
|
|
124
117
|
return {
|
|
125
118
|
indices,
|
|
@@ -191,6 +184,7 @@ class SpriteModel extends _BaseModel.default {
|
|
|
191
184
|
vertexShader: spriteVert,
|
|
192
185
|
fragmentShader: spriteFrag,
|
|
193
186
|
triangulation: _this.planeGeometryTriangulation,
|
|
187
|
+
defines: _this.getDefines(),
|
|
194
188
|
inject: _this.getInject(),
|
|
195
189
|
primitive: _l7Core.gl.POINTS,
|
|
196
190
|
depth: {
|