@antv/l7-layers 2.21.7 → 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
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { IModel } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class CityBuildModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
SIZE: number;
|
|
17
|
+
NORMAL: number;
|
|
18
|
+
UV: number;
|
|
19
|
+
};
|
|
4
20
|
private cityCenter;
|
|
5
21
|
private cityMinSize;
|
|
6
22
|
protected getCommonUniformsInfo(): {
|
|
@@ -10,18 +10,25 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _l7Core = require("@antv/l7-core");
|
|
11
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
var _triangulation = require("../../core/triangulation");
|
|
15
14
|
/* babel-plugin-inline-import '../shaders/build_frag.glsl' */
|
|
16
|
-
const buildFrag = "precision highp float;\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor
|
|
15
|
+
const buildFrag = "precision highp float;\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor: [ 1.0, 0, 0, 1.0 ];\n vec4 u_brightColor: [ 1.0, 0, 0, 1.0 ];\n vec4 u_windowColor: [ 1.0, 0, 0, 1.0 ];\n vec4 u_circleSweepColor;\n vec2 u_cityCenter;\n float u_circleSweep;\n float u_cityMinSize;\n float u_circleSweepSpeed;\n float u_opacity: 1.0;\n float u_near: 0;\n float u_far: 1;\n float u_time;\n};\nin vec4 v_Color;\nin vec2 v_texCoord;\nin float v_worldDis;\nout vec4 outputColor;\n\n#pragma include \"picking\"\n#pragma include \"scene_uniforms\"\n\nvec3 getWindowColor(float n, float hot, vec3 brightColor, vec3 darkColor) {\n float s = step(hot, n);\n vec3 color = mix(brightColor,vec3(0.9,0.9,1.0),n);\n\n return mix(darkColor, color, s);\n}\nfloat random (vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);\n}\n\nfloat LinearizeDepth()\n{\n float z = gl_FragCoord.z * 2.0 - 1.0;\n return (2.0 * u_near * u_far) / (u_far + u_near - z * (u_far - u_near));\n}\n\nvec3 fog(vec3 color, vec3 fogColor, float depth){\n float fogFactor=clamp(depth,0.0,1.0);\n vec3 output_color=mix(fogColor,color,fogFactor);\n return output_color;\n}\n\nfloat sdRect(vec2 p, vec2 sz) {\n vec2 d = abs(p) - sz;\n float outside = length(max(d, 0.));\n float inside = min(max(d.x, d.y), 0.);\n return outside + inside;\n}\n\nvoid main() {\n outputColor = v_Color;\n vec3 baseColor = u_baseColor.xyz;\n vec3 brightColor = u_brightColor.xyz;\n vec3 windowColor = u_windowColor.xyz;\n float targetColId = 5.;\n float depth = 1.0 - LinearizeDepth() / u_far * u_Zoom;\n vec3 fogColor = vec3(23.0/255.0,31.0/255.0,51.0/255.0);\n if(v_texCoord.x < 0.) { //\u9876\u90E8\u989C\u8272\n vec3 foggedColor = fog(baseColor.xyz + vec3(0.12*0.9,0.2*0.9,0.3*0.9),fogColor,depth);\n outputColor = vec4( foggedColor, v_Color.w);\n }else { // \u4FA7\u9762\u989C\u8272\n vec2 st = v_texCoord;\n vec2 UvScale = v_texCoord;\n float tStep = min(0.08,max(0.05* (18.0-u_Zoom),0.02));\n float tStart = 0.25 * tStep;\n float tEnd = 0.75 * tStep;\n float u = mod(UvScale.x, tStep);\n float v = mod(UvScale.y, tStep);\n float ux = floor(UvScale.x/tStep);\n float uy = floor(UvScale.y/tStep);\n float n = random(vec2(ux,uy));\n float lightP = u_time;\n float head = 1.0- step(0.005,st.y);\n /*step3*/\n // \u5C06\u7A97\u6237\u989C\u8272\u548C\u5899\u9762\u989C\u8272\u533A\u522B\u5F00\u6765\n float sU = step(tStart, u) - step(tEnd, u);\n float sV = step(tStart, v) - step(tEnd, v);\n vec2 windowSize = vec2(abs(tEnd-tStart),abs(tEnd-tStart));\n float dist = sdRect(vec2(u,v), windowSize);\n float s = sU * sV;\n\n float curColId = floor(UvScale.x / tStep);\n float sCol = step(targetColId - 0.2, curColId) - step(targetColId + 0.2, curColId);\n\n float mLightP = mod(lightP, 2.);\n float sRow = step(mLightP - 0.2, st.y) - step(mLightP, st.y);\n if(ux == targetColId){\n n =0.;\n }\n float timeP = min(0.75, abs ( sin(u_time/3.0) ) );\n float hot = smoothstep(1.0,0.0,timeP);\n vec3 color = mix(baseColor, getWindowColor(n,hot,brightColor,windowColor), s);\n //vec3 color = mix(baseColor, getWindowColor(n,hot,brightColor,windowColor), 1.0);\n float sFinal = s * sCol * sRow;\n color += mix(baseColor, brightColor, sFinal*n);\n if (st.y<0.01){\n color = baseColor;\n }\n if(head ==1.0) { // \u9876\u90E8\u4EAE\u7EBF\n color = brightColor;\n }\n color = color * v_Color.rgb;\n\n vec3 foggedColor = fog(color,fogColor,depth);\n\n outputColor = vec4(foggedColor,1.0);\n }\n\n\n if(u_circleSweep > 0.0 && v_worldDis < u_cityMinSize) {\n float r = fract(((v_worldDis/u_cityMinSize) - u_time * u_circleSweepSpeed) * 2.0);\n outputColor.rgb += r * r * u_circleSweepColor.rgb;\n }\n\n outputColor.a *= u_opacity;\n outputColor = filterColor(outputColor);\n}\n";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/build_vert.glsl' */
|
|
18
|
-
const buildVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location =
|
|
17
|
+
const buildVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nout vec2 v_texCoord;\nout vec4 v_Color;\nout float v_worldDis;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_brightColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_windowColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_circleSweepColor;\n vec2 u_cityCenter;\n float u_circleSweep;\n float u_cityMinSize;\n float u_circleSweepSpeed;\n float u_opacity: 1.0;\n float u_near : 0;\n float u_far : 1;\n float u_time;\n};\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n v_texCoord = a_Uv;\n\n if(u_circleSweep > 0.0) {\n vec2 lnglatscale = vec2(0.0);\n lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);\n v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
18
|
class CityBuildModel extends _BaseModel.default {
|
|
20
19
|
constructor(...args) {
|
|
21
20
|
super(...args);
|
|
22
21
|
(0, _defineProperty2.default)(this, "cityCenter", void 0);
|
|
23
22
|
(0, _defineProperty2.default)(this, "cityMinSize", void 0);
|
|
24
23
|
}
|
|
24
|
+
get attributeLocation() {
|
|
25
|
+
return Object.assign(super.attributeLocation, {
|
|
26
|
+
MAX: super.attributeLocation.MAX,
|
|
27
|
+
SIZE: 9,
|
|
28
|
+
NORMAL: 10,
|
|
29
|
+
UV: 11
|
|
30
|
+
});
|
|
31
|
+
}
|
|
25
32
|
getCommonUniformsInfo() {
|
|
26
33
|
const {
|
|
27
34
|
opacity = 1,
|
|
@@ -57,20 +64,10 @@ class CityBuildModel extends _BaseModel.default {
|
|
|
57
64
|
calCityGeo() {
|
|
58
65
|
// @ts-ignore
|
|
59
66
|
const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const l1 = this.mapService.lngLatToCoord([maxLng, maxLat]);
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
const l2 = this.mapService.lngLatToCoord([minLng, minLat]);
|
|
67
|
-
this.cityMinSize = Math.sqrt(Math.pow(l1[0] - l2[0], 2) + Math.pow(l1[1] - l2[1], 2)) / 4;
|
|
68
|
-
} else {
|
|
69
|
-
const w = maxLng - minLng;
|
|
70
|
-
const h = maxLat - minLat;
|
|
71
|
-
this.cityCenter = [(maxLng + minLng) / 2, (maxLat + minLat) / 2];
|
|
72
|
-
this.cityMinSize = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2)) / 4;
|
|
73
|
-
}
|
|
67
|
+
const w = maxLng - minLng;
|
|
68
|
+
const h = maxLat - minLat;
|
|
69
|
+
this.cityCenter = [(maxLng + minLng) / 2, (maxLat + minLat) / 2];
|
|
70
|
+
this.cityMinSize = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2)) / 4;
|
|
74
71
|
}
|
|
75
72
|
initModels() {
|
|
76
73
|
var _this = this;
|
|
@@ -92,6 +89,7 @@ class CityBuildModel extends _BaseModel.default {
|
|
|
92
89
|
depth: {
|
|
93
90
|
enable: true
|
|
94
91
|
},
|
|
92
|
+
defines: _this2.getDefines(),
|
|
95
93
|
inject: _this2.getInject(),
|
|
96
94
|
cull: {
|
|
97
95
|
enable: true,
|
|
@@ -108,7 +106,7 @@ class CityBuildModel extends _BaseModel.default {
|
|
|
108
106
|
type: _l7Core.AttributeType.Attribute,
|
|
109
107
|
descriptor: {
|
|
110
108
|
name: 'a_Normal',
|
|
111
|
-
shaderLocation:
|
|
109
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
112
110
|
buffer: {
|
|
113
111
|
// give the WebGL driver a hint that this buffer may change
|
|
114
112
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -126,7 +124,7 @@ class CityBuildModel extends _BaseModel.default {
|
|
|
126
124
|
type: _l7Core.AttributeType.Attribute,
|
|
127
125
|
descriptor: {
|
|
128
126
|
name: 'a_Size',
|
|
129
|
-
shaderLocation:
|
|
127
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
130
128
|
buffer: {
|
|
131
129
|
// give the WebGL driver a hint that this buffer may change
|
|
132
130
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -147,7 +145,7 @@ class CityBuildModel extends _BaseModel.default {
|
|
|
147
145
|
type: _l7Core.AttributeType.Attribute,
|
|
148
146
|
descriptor: {
|
|
149
147
|
name: 'a_Uv',
|
|
150
|
-
shaderLocation:
|
|
148
|
+
shaderLocation: this.attributeLocation.UV,
|
|
151
149
|
buffer: {
|
|
152
150
|
// give the WebGL driver a hint that this buffer may change
|
|
153
151
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
precision highp float;
|
|
2
2
|
layout(std140) uniform commonUniforms {
|
|
3
|
-
vec4 u_baseColor
|
|
4
|
-
vec4 u_brightColor
|
|
5
|
-
vec4 u_windowColor
|
|
3
|
+
vec4 u_baseColor: [ 1.0, 0, 0, 1.0 ];
|
|
4
|
+
vec4 u_brightColor: [ 1.0, 0, 0, 1.0 ];
|
|
5
|
+
vec4 u_windowColor: [ 1.0, 0, 0, 1.0 ];
|
|
6
6
|
vec4 u_circleSweepColor;
|
|
7
7
|
vec2 u_cityCenter;
|
|
8
8
|
float u_circleSweep;
|
|
9
9
|
float u_cityMinSize;
|
|
10
10
|
float u_circleSweepSpeed;
|
|
11
11
|
float u_opacity: 1.0;
|
|
12
|
-
float u_near
|
|
13
|
-
float u_far
|
|
12
|
+
float u_near: 0;
|
|
13
|
+
float u_far: 1;
|
|
14
14
|
float u_time;
|
|
15
15
|
};
|
|
16
16
|
in vec4 v_Color;
|
|
@@ -114,7 +114,7 @@ void main() {
|
|
|
114
114
|
float r = fract(((v_worldDis/u_cityMinSize) - u_time * u_circleSweepSpeed) * 2.0);
|
|
115
115
|
outputColor.rgb += r * r * u_circleSweepColor.rgb;
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
outputColor.a *= u_opacity;
|
|
119
119
|
outputColor = filterColor(outputColor);
|
|
120
120
|
}
|
|
@@ -4,11 +4,11 @@ precision highp float;
|
|
|
4
4
|
#define diffuseRatio 0.3
|
|
5
5
|
#define specularRatio 0.2
|
|
6
6
|
|
|
7
|
-
layout(location =
|
|
8
|
-
layout(location =
|
|
9
|
-
layout(location =
|
|
10
|
-
layout(location =
|
|
11
|
-
layout(location =
|
|
7
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
8
|
+
layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
|
|
9
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
10
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
11
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
|
|
12
12
|
|
|
13
13
|
out vec2 v_texCoord;
|
|
14
14
|
out vec4 v_Color;
|
|
@@ -41,17 +41,11 @@ void main() {
|
|
|
41
41
|
|
|
42
42
|
if(u_circleSweep > 0.0) {
|
|
43
43
|
vec2 lnglatscale = vec2(0.0);
|
|
44
|
-
|
|
45
|
-
lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);
|
|
46
|
-
}
|
|
44
|
+
lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);
|
|
47
45
|
v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
|
|
52
|
-
} else {
|
|
53
|
-
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
54
|
-
}
|
|
47
|
+
|
|
48
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
55
49
|
|
|
56
50
|
float lightWeight = calc_lighting(pos);
|
|
57
51
|
// v_Color = a_Color;
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -19,7 +19,7 @@ var _multiPassRender = require("../utils/multiPassRender");
|
|
|
19
19
|
var _LayerPickService = _interopRequireDefault(require("./LayerPickService"));
|
|
20
20
|
var _TextureService = _interopRequireDefault(require("./TextureService"));
|
|
21
21
|
const _excluded = ["passes"],
|
|
22
|
-
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption", "pickingEnabled"]; // @ts-ignore
|
|
22
|
+
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "defines", "inject", "triangulation", "styleOption", "pickingEnabled"]; // @ts-ignore
|
|
23
23
|
const {
|
|
24
24
|
isEqual,
|
|
25
25
|
isFunction,
|
|
@@ -64,7 +64,8 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
64
64
|
return this.container.interactionService;
|
|
65
65
|
}
|
|
66
66
|
get mapService() {
|
|
67
|
-
|
|
67
|
+
var _this$container;
|
|
68
|
+
return (_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.mapService;
|
|
68
69
|
}
|
|
69
70
|
get normalPassFactory() {
|
|
70
71
|
return this.container.normalPassFactory;
|
|
@@ -927,12 +928,8 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
927
928
|
type
|
|
928
929
|
}) => {
|
|
929
930
|
if (this.coordCenter === undefined) {
|
|
930
|
-
var _this$mapService;
|
|
931
931
|
const layerCenter = this.layerSource.center;
|
|
932
932
|
this.coordCenter = layerCenter;
|
|
933
|
-
if ((_this$mapService = this.mapService) !== null && _this$mapService !== void 0 && _this$mapService.setCoordCenter) {
|
|
934
|
-
this.mapService.setCoordCenter(layerCenter);
|
|
935
|
-
}
|
|
936
933
|
}
|
|
937
934
|
if (type === 'update') {
|
|
938
935
|
if (this.tileLayer) {
|
|
@@ -1026,6 +1023,7 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
1026
1023
|
moduleName,
|
|
1027
1024
|
vertexShader,
|
|
1028
1025
|
fragmentShader,
|
|
1026
|
+
defines,
|
|
1029
1027
|
inject,
|
|
1030
1028
|
triangulation,
|
|
1031
1029
|
styleOption,
|
|
@@ -1035,6 +1033,7 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
1035
1033
|
_this3.shaderModuleService.registerModule(moduleName, {
|
|
1036
1034
|
vs: vertexShader,
|
|
1037
1035
|
fs: fragmentShader,
|
|
1036
|
+
defines,
|
|
1038
1037
|
inject
|
|
1039
1038
|
});
|
|
1040
1039
|
const {
|
|
@@ -1051,7 +1050,9 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
1051
1050
|
elements,
|
|
1052
1051
|
count
|
|
1053
1052
|
} = _this3.styleAttributeService.createAttributesAndIndices(_this3.encodedData, triangulation, styleOption, _this3);
|
|
1054
|
-
const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers,
|
|
1053
|
+
const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers,
|
|
1054
|
+
// TODO: 目前未使用
|
|
1055
|
+
_this3.getLayerUniformBuffer()];
|
|
1055
1056
|
if (pickingEnabled) {
|
|
1056
1057
|
uniformBuffers.push(_this3.getPickingUniformBuffer());
|
|
1057
1058
|
}
|
|
@@ -1236,8 +1237,8 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
1236
1237
|
_this5.uniformBuffers = [];
|
|
1237
1238
|
// Layer Uniform
|
|
1238
1239
|
const layerUniforms = _this5.rendererService.createBuffer({
|
|
1240
|
+
// TODO: 不再需要,之前用于 amap2 u_Mvp
|
|
1239
1241
|
data: new Float32Array(16 + 4).fill(0),
|
|
1240
|
-
// u_Mvp
|
|
1241
1242
|
isUBO: true
|
|
1242
1243
|
});
|
|
1243
1244
|
_this5.uniformBuffers.push(layerUniforms);
|
package/lib/core/BaseModel.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService,
|
|
1
|
+
import type { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRenderOptions, IRendererService, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, ShaderDefine, ShaderInject, Triangulation } from '@antv/l7-core';
|
|
2
|
+
import { COMMON_ATTRIBUTE_LOCATION } from './CommonStyleAttribute';
|
|
2
3
|
export type styleSingle = number | string | [string, (single: any) => number] | [string, [number, number]];
|
|
3
4
|
export type styleOffset = string | [number, number] | [string, (single: any) => number];
|
|
4
5
|
export type styleColor = string | [string, (single: any) => string] | [string, [string, string]];
|
|
@@ -11,10 +12,15 @@ export interface ICellProperty {
|
|
|
11
12
|
attr: string;
|
|
12
13
|
count: number;
|
|
13
14
|
}
|
|
15
|
+
type AttributeLayoutLocationType = typeof COMMON_ATTRIBUTE_LOCATION & Record<string, number>;
|
|
14
16
|
export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerModel {
|
|
15
17
|
triangulation: Triangulation;
|
|
16
18
|
uniformBuffers: IBuffer[];
|
|
17
19
|
textures: ITexture2D[];
|
|
20
|
+
/**
|
|
21
|
+
* Attribute Layout Location in Shader
|
|
22
|
+
*/
|
|
23
|
+
protected get attributeLocation(): AttributeLayoutLocationType;
|
|
18
24
|
createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
|
|
19
25
|
preStyleAttribute: Record<string, any>;
|
|
20
26
|
protected encodeStyleAttribute: Record<string, boolean>;
|
|
@@ -55,11 +61,17 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
55
61
|
protected registerBuiltinAttributes(): void;
|
|
56
62
|
protected animateOption2Array(option: IAnimateOption): number[];
|
|
57
63
|
protected startModelAnimate(): void;
|
|
58
|
-
protected getInject():
|
|
64
|
+
protected getInject(): ShaderInject;
|
|
65
|
+
protected getDefines(): Record<string, ShaderDefine>;
|
|
59
66
|
protected getStyleAttribute(): {
|
|
60
67
|
[key: string]: any;
|
|
61
68
|
};
|
|
62
69
|
protected registerStyleAttribute(): void;
|
|
70
|
+
/**
|
|
71
|
+
* 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
|
|
72
|
+
* 避免大于 20层级以上出现数据偏移
|
|
73
|
+
*/
|
|
74
|
+
protected registerPosition64LowAttribute(enable64bitPosition?: boolean): void;
|
|
63
75
|
updateEncodeAttribute(type: string, flag: boolean): void;
|
|
64
76
|
initUniformsBuffer(): void;
|
|
65
77
|
protected getUniformsBufferInfo(uniformsOption: {
|
|
@@ -80,3 +92,4 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
80
92
|
};
|
|
81
93
|
updateStyleUnifoms(): void;
|
|
82
94
|
}
|
|
95
|
+
export {};
|
package/lib/core/BaseModel.js
CHANGED
|
@@ -15,17 +15,20 @@ var _stencil = require("../utils/stencil");
|
|
|
15
15
|
var _CommonStyleAttribute = require("./CommonStyleAttribute");
|
|
16
16
|
var _constant = require("./constant");
|
|
17
17
|
var _utils = require("./utils");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stroke: _CommonStyleAttribute.ShaderLocation.STROKE,
|
|
21
|
-
offsets: _CommonStyleAttribute.ShaderLocation.OFFSETS,
|
|
22
|
-
rotation: _CommonStyleAttribute.ShaderLocation.ROTATION,
|
|
23
|
-
extrusionBase: _CommonStyleAttribute.ShaderLocation.EXTRUSION_BASE,
|
|
24
|
-
thetaOffset: 15
|
|
25
|
-
};
|
|
18
|
+
// 属性索引宏定义前缀,使用命名空间避免 define 名称重复情况
|
|
19
|
+
const DEFINE_ATTRIBUTE_LOCATION_PREFIX = 'ATTRIBUTE_LOCATION_';
|
|
26
20
|
|
|
27
21
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
22
|
class BaseModel {
|
|
23
|
+
/**
|
|
24
|
+
* Attribute Layout Location in Shader
|
|
25
|
+
*/
|
|
26
|
+
get attributeLocation() {
|
|
27
|
+
return (0, _objectSpread2.default)({}, _CommonStyleAttribute.COMMON_ATTRIBUTE_LOCATION);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// style texture data mapping
|
|
31
|
+
|
|
29
32
|
// 不支持数据映射的buffer
|
|
30
33
|
|
|
31
34
|
// style texture data mapping
|
|
@@ -34,7 +37,6 @@ class BaseModel {
|
|
|
34
37
|
(0, _defineProperty2.default)(this, "triangulation", void 0);
|
|
35
38
|
(0, _defineProperty2.default)(this, "uniformBuffers", []);
|
|
36
39
|
(0, _defineProperty2.default)(this, "textures", []);
|
|
37
|
-
// style texture data mapping
|
|
38
40
|
(0, _defineProperty2.default)(this, "createTexture2D", void 0);
|
|
39
41
|
(0, _defineProperty2.default)(this, "preStyleAttribute", {});
|
|
40
42
|
(0, _defineProperty2.default)(this, "encodeStyleAttribute", {});
|
|
@@ -185,55 +187,18 @@ class BaseModel {
|
|
|
185
187
|
this.layer.setAnimateStartTime();
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
|
-
|
|
189
|
-
// 动态注入参与数据映射的uniform
|
|
190
190
|
getInject() {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
str += `#define USE_ATTRIBUTE_${key.toUpperCase()} 0.0; \n\n`;
|
|
203
|
-
} else {
|
|
204
|
-
uniforms.push(` ${_constant.DefaultUniformStyleType[key]} u_${key};`);
|
|
205
|
-
}
|
|
206
|
-
let location = shaderLocationMap[key];
|
|
207
|
-
if (!location && key === 'THETA_OFFSET') {
|
|
208
|
-
location = 15;
|
|
209
|
-
}
|
|
210
|
-
str += `
|
|
211
|
-
#ifdef USE_ATTRIBUTE_${key.toUpperCase()}
|
|
212
|
-
layout(location = ${shaderLocationMap[key]}) in ${_constant.DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
213
|
-
#endif\n
|
|
214
|
-
`;
|
|
215
|
-
});
|
|
216
|
-
const attributeUniforms = uniforms.length ? `
|
|
217
|
-
layout(std140) uniform AttributeUniforms {
|
|
218
|
-
${uniforms.join('\n')}
|
|
219
|
-
};
|
|
220
|
-
` : '';
|
|
221
|
-
str += attributeUniforms;
|
|
222
|
-
let innerStr = '';
|
|
223
|
-
this.layer.enableShaderEncodeStyles.forEach(key => {
|
|
224
|
-
innerStr += `\n
|
|
225
|
-
#ifdef USE_ATTRIBUTE_${key.toUpperCase()}
|
|
226
|
-
${_constant.DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
227
|
-
#else
|
|
228
|
-
${_constant.DefaultUniformStyleType[key]} ${key} = u_${key};
|
|
229
|
-
#endif\n
|
|
230
|
-
`;
|
|
231
|
-
});
|
|
232
|
-
return {
|
|
233
|
-
'vs:#decl': str,
|
|
234
|
-
'fs:#decl': attributeUniforms,
|
|
235
|
-
'vs:#main-start': innerStr
|
|
236
|
-
};
|
|
191
|
+
const shaderInject = getDynamicStyleInject(this.layer.enableShaderEncodeStyles, this.layer.encodeStyleAttribute);
|
|
192
|
+
return shaderInject;
|
|
193
|
+
}
|
|
194
|
+
getDefines() {
|
|
195
|
+
// define atribute Layout Location
|
|
196
|
+
const atributeLocationDefines = Object.keys(this.attributeLocation).reduce((result, key) => {
|
|
197
|
+
const normalizedKey = DEFINE_ATTRIBUTE_LOCATION_PREFIX + key;
|
|
198
|
+
result[normalizedKey] = this.attributeLocation[key];
|
|
199
|
+
return result;
|
|
200
|
+
}, {});
|
|
201
|
+
return (0, _objectSpread2.default)({}, atributeLocationDefines);
|
|
237
202
|
}
|
|
238
203
|
|
|
239
204
|
// 获取数据映射样式
|
|
@@ -254,14 +219,36 @@ ${uniforms.join('\n')}
|
|
|
254
219
|
});
|
|
255
220
|
return options;
|
|
256
221
|
}
|
|
222
|
+
|
|
257
223
|
// 注册数据映射样式
|
|
258
224
|
registerStyleAttribute() {
|
|
259
225
|
Object.keys(this.layer.encodeStyleAttribute).forEach(key => {
|
|
260
226
|
const options = (0, _CommonStyleAttribute.getCommonStyleAttributeOptions)(key);
|
|
261
227
|
if (options) {
|
|
262
228
|
this.styleAttributeService.registerStyleAttribute(options);
|
|
263
|
-
|
|
264
|
-
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
|
|
235
|
+
* 避免大于 20层级以上出现数据偏移
|
|
236
|
+
*/
|
|
237
|
+
registerPosition64LowAttribute(enable64bitPosition = true) {
|
|
238
|
+
// save low part for enabled double precision POSITION attribute
|
|
239
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
240
|
+
name: 'position64Low',
|
|
241
|
+
type: _l7Core.AttributeType.Attribute,
|
|
242
|
+
descriptor: {
|
|
243
|
+
name: 'a_Position64Low',
|
|
244
|
+
shaderLocation: this.attributeLocation.POSITION_64LOW,
|
|
245
|
+
buffer: {
|
|
246
|
+
data: [],
|
|
247
|
+
type: _l7Core.gl.FLOAT
|
|
248
|
+
},
|
|
249
|
+
size: 2,
|
|
250
|
+
update: (feature, featureIdx, vertex) => {
|
|
251
|
+
return enable64bitPosition ? [(0, _l7Utils.fp64LowPart)(vertex[0]), (0, _l7Utils.fp64LowPart)(vertex[1])] : [0, 0];
|
|
265
252
|
}
|
|
266
253
|
}
|
|
267
254
|
});
|
|
@@ -338,4 +325,49 @@ ${uniforms.join('\n')}
|
|
|
338
325
|
});
|
|
339
326
|
}
|
|
340
327
|
}
|
|
341
|
-
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 获取动态注入参与数据映射 uniform/attribute
|
|
331
|
+
*/
|
|
332
|
+
exports.default = BaseModel;
|
|
333
|
+
function getDynamicStyleInject(shaderEncodeStyles, styleAttribute) {
|
|
334
|
+
const uniforms = [];
|
|
335
|
+
let vsDeclInjection = '';
|
|
336
|
+
|
|
337
|
+
// 支持数据映射的类型
|
|
338
|
+
shaderEncodeStyles.forEach(key => {
|
|
339
|
+
const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
340
|
+
const shaderDefineName = DEFINE_ATTRIBUTE_LOCATION_PREFIX + upperCaseKey;
|
|
341
|
+
if (styleAttribute[key]) {
|
|
342
|
+
// 配置了数据映射的类型
|
|
343
|
+
vsDeclInjection += `#define USE_ATTRIBUTE_${upperCaseKey} 0.0 \n`;
|
|
344
|
+
} else {
|
|
345
|
+
uniforms.push(` ${_constant.DefaultUniformStyleType[key]} u_${key};`);
|
|
346
|
+
}
|
|
347
|
+
vsDeclInjection += `
|
|
348
|
+
#ifdef USE_ATTRIBUTE_${upperCaseKey}
|
|
349
|
+
layout(location = ${shaderDefineName}) in ${_constant.DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
350
|
+
#endif \n`;
|
|
351
|
+
});
|
|
352
|
+
const fsDeclInjection = uniforms.length ? `
|
|
353
|
+
layout(std140) uniform AttributeUniforms {
|
|
354
|
+
${uniforms.join('\n')}
|
|
355
|
+
};\n` : '';
|
|
356
|
+
vsDeclInjection += fsDeclInjection;
|
|
357
|
+
let vsMainInjection = '';
|
|
358
|
+
shaderEncodeStyles.forEach(key => {
|
|
359
|
+
const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
360
|
+
vsMainInjection += `
|
|
361
|
+
#ifdef USE_ATTRIBUTE_${upperCaseKey}
|
|
362
|
+
${_constant.DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
363
|
+
#else
|
|
364
|
+
${_constant.DefaultUniformStyleType[key]} ${key} = u_${key};
|
|
365
|
+
#endif
|
|
366
|
+
`;
|
|
367
|
+
});
|
|
368
|
+
return {
|
|
369
|
+
'vs:#decl': vsDeclInjection,
|
|
370
|
+
'fs:#decl': fsDeclInjection,
|
|
371
|
+
'vs:#main-start': vsMainInjection
|
|
372
|
+
};
|
|
373
|
+
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import type { IStyleAttribute } from '@antv/l7-core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
NORMAL = 13,
|
|
17
|
-
UV = 14,
|
|
18
|
-
LINEAR = 15
|
|
19
|
-
}
|
|
2
|
+
/**
|
|
3
|
+
* Attribute Layout Location in Shader
|
|
4
|
+
*/
|
|
5
|
+
export declare const COMMON_ATTRIBUTE_LOCATION: {
|
|
6
|
+
readonly POSITION: 0;
|
|
7
|
+
readonly POSITION_64LOW: 1;
|
|
8
|
+
readonly COLOR: 2;
|
|
9
|
+
readonly PICKING_COLOR: 3;
|
|
10
|
+
readonly STROKE: 4;
|
|
11
|
+
readonly OPACITY: 5;
|
|
12
|
+
readonly OFFSETS: 6;
|
|
13
|
+
readonly ROTATION: 7;
|
|
14
|
+
readonly MAX: 8;
|
|
15
|
+
};
|
|
20
16
|
export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
|