@antv/l7-layers 2.21.9-beta.0 → 2.21.10
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 +0 -16
- package/es/citybuliding/models/build.js +20 -18
- package/es/citybuliding/shaders/build_frag.glsl +6 -6
- package/es/citybuliding/shaders/build_vert.glsl +14 -8
- package/es/core/BaseLayer.js +8 -12
- package/es/core/BaseModel.d.ts +2 -15
- package/es/core/BaseModel.js +62 -94
- package/es/core/CommonStyleAttribute.d.ts +18 -14
- package/es/core/CommonStyleAttribute.js +67 -23
- package/es/core/triangulation.js +39 -13
- package/es/earth/models/atmosphere.d.ts +0 -15
- package/es/earth/models/atmosphere.js +24 -30
- package/es/earth/models/base.d.ts +0 -15
- package/es/earth/models/base.js +24 -30
- package/es/earth/models/bloomsphere.d.ts +0 -15
- package/es/earth/models/bloomsphere.js +24 -30
- package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
- package/es/earth/shaders/base/base_vert.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
- package/es/geometry/models/billboard.d.ts +0 -15
- package/es/geometry/models/billboard.js +8 -14
- package/es/geometry/models/plane.d.ts +0 -14
- package/es/geometry/models/plane.js +10 -10
- package/es/geometry/models/sprite.js +9 -3
- package/es/geometry/shaders/billboard_vert.glsl +25 -28
- package/es/geometry/shaders/plane_vert.glsl +6 -6
- package/es/geometry/shaders/sprite_vert.glsl +9 -7
- package/es/heatmap/models/grid.d.ts +0 -14
- package/es/heatmap/models/grid.js +3 -10
- package/es/heatmap/models/grid3d.d.ts +0 -16
- package/es/heatmap/models/grid3d.js +6 -14
- package/es/heatmap/models/heatmap.d.ts +1 -20
- package/es/heatmap/models/heatmap.js +83 -96
- package/es/heatmap/models/hexagon.d.ts +0 -14
- package/es/heatmap/models/hexagon.js +3 -9
- package/es/heatmap/shaders/grid/grid_vert.glsl +42 -30
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
- package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
- package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
- package/es/image/models/image.d.ts +0 -14
- package/es/image/models/image.js +3 -11
- package/es/image/shaders/image_vert.glsl +6 -7
- package/es/line/models/arc.d.ts +0 -18
- package/es/line/models/arc.js +8 -57
- package/es/line/models/arc_3d.d.ts +0 -18
- package/es/line/models/arc_3d.js +7 -55
- package/es/line/models/flow.d.ts +0 -17
- package/es/line/models/flow.js +7 -35
- package/es/line/models/great_circle.d.ts +0 -17
- package/es/line/models/great_circle.js +6 -34
- package/es/line/models/line.d.ts +0 -17
- package/es/line/models/line.js +8 -17
- package/es/line/models/simple_line.d.ts +0 -14
- package/es/line/models/simple_line.js +47 -12
- package/es/line/models/wall.d.ts +0 -17
- package/es/line/models/wall.js +48 -22
- package/es/line/shaders/arc/line_arc_vert.glsl +48 -42
- package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
- package/es/line/shaders/flow/flow_line_vert.glsl +48 -30
- package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
- package/es/line/shaders/line/line_vert.glsl +48 -31
- package/es/line/shaders/simple/simpleline_vert.glsl +23 -18
- package/es/line/shaders/wall/wall_vert.glsl +45 -36
- package/es/mask/models/fill.js +1 -2
- package/es/mask/shaders/mask_vert.glsl +7 -2
- package/es/plugins/DataMappingPlugin.d.ts +1 -0
- package/es/plugins/DataMappingPlugin.js +24 -1
- package/es/plugins/PixelPickingPlugin.js +2 -2
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
- package/es/plugins/RegisterStyleAttributePlugin.js +25 -3
- package/es/plugins/ShaderUniformPlugin.d.ts +5 -0
- package/es/plugins/ShaderUniformPlugin.js +34 -2
- package/es/point/models/billboard_point.d.ts +0 -14
- package/es/point/models/billboard_point.js +3 -11
- package/es/point/models/earthExtrude.d.ts +0 -16
- package/es/point/models/earthExtrude.js +8 -15
- package/es/point/models/earthFill.d.ts +0 -16
- package/es/point/models/earthFill.js +5 -13
- package/es/point/models/extrude.d.ts +0 -16
- package/es/point/models/extrude.js +12 -19
- package/es/point/models/fill.d.ts +0 -16
- package/es/point/models/fill.js +5 -16
- package/es/point/models/fillImage.d.ts +0 -16
- package/es/point/models/fillImage.js +16 -16
- package/es/point/models/image.d.ts +0 -15
- package/es/point/models/image.js +4 -14
- package/es/point/models/normal.d.ts +0 -14
- package/es/point/models/normal.js +3 -11
- package/es/point/models/radar.d.ts +0 -15
- package/es/point/models/radar.js +4 -13
- package/es/point/models/text.d.ts +0 -16
- package/es/point/models/text.js +11 -18
- package/es/point/shaders/billboard/billboard_point_vert.glsl +13 -10
- package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
- package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/es/point/shaders/extrude/extrude_vert.glsl +39 -35
- package/es/point/shaders/fill/fill_vert.glsl +14 -12
- package/es/point/shaders/fillImage/fillImage_vert.glsl +28 -16
- package/es/point/shaders/image/image_vert.glsl +12 -15
- package/es/point/shaders/normal/normal_vert.glsl +10 -7
- package/es/point/shaders/radar/radar_vert.glsl +11 -11
- package/es/point/shaders/text/text_vert.glsl +9 -10
- package/es/polygon/models/extrude.d.ts +0 -16
- package/es/polygon/models/extrude.js +26 -26
- package/es/polygon/models/extrusion.d.ts +0 -16
- package/es/polygon/models/extrusion.js +4 -34
- package/es/polygon/models/fill.d.ts +0 -14
- package/es/polygon/models/fill.js +4 -12
- package/es/polygon/models/ocean.d.ts +0 -14
- package/es/polygon/models/ocean.js +6 -11
- package/es/polygon/models/water.d.ts +0 -14
- package/es/polygon/models/water.js +6 -11
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
- 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 +6 -7
- package/es/polygon/shaders/fill/fill_vert.glsl +12 -10
- package/es/polygon/shaders/ocean/ocean_vert.glsl +4 -3
- 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 +0 -14
- package/es/raster/models/raster.js +3 -12
- package/es/raster/models/rasterRgb.d.ts +0 -14
- package/es/raster/models/rasterRgb.js +3 -12
- package/es/raster/models/rasterTerrainRgb.d.ts +0 -14
- package/es/raster/models/rasterTerrainRgb.js +3 -11
- 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 +16 -0
- package/es/tile/tile/Tile.d.ts +0 -2
- package/es/utils/extrude_polyline.d.ts +15 -0
- package/es/utils/extrude_polyline.js +217 -0
- package/es/utils/multiPassRender.js +2 -10
- package/es/wind/models/wind.d.ts +0 -14
- package/es/wind/models/wind.js +1 -9
- package/es/wind/shaders/wind_vert.glsl +5 -6
- package/lib/citybuliding/models/build.d.ts +0 -16
- package/lib/citybuliding/models/build.js +20 -18
- package/lib/citybuliding/shaders/build_frag.glsl +6 -6
- package/lib/citybuliding/shaders/build_vert.glsl +14 -8
- package/lib/core/BaseLayer.js +8 -12
- package/lib/core/BaseModel.d.ts +2 -15
- package/lib/core/BaseModel.js +60 -92
- package/lib/core/CommonStyleAttribute.d.ts +18 -14
- package/lib/core/CommonStyleAttribute.js +68 -23
- package/lib/core/triangulation.js +39 -13
- package/lib/earth/models/atmosphere.d.ts +0 -15
- package/lib/earth/models/atmosphere.js +24 -30
- package/lib/earth/models/base.d.ts +0 -15
- package/lib/earth/models/base.js +24 -30
- package/lib/earth/models/bloomsphere.d.ts +0 -15
- package/lib/earth/models/bloomsphere.js +24 -30
- package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
- package/lib/earth/shaders/base/base_vert.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
- package/lib/geometry/models/billboard.d.ts +0 -15
- package/lib/geometry/models/billboard.js +8 -14
- package/lib/geometry/models/plane.d.ts +0 -14
- package/lib/geometry/models/plane.js +10 -10
- package/lib/geometry/models/sprite.js +9 -3
- package/lib/geometry/shaders/billboard_vert.glsl +25 -28
- package/lib/geometry/shaders/plane_vert.glsl +6 -6
- package/lib/geometry/shaders/sprite_vert.glsl +9 -7
- package/lib/heatmap/models/grid.d.ts +0 -14
- package/lib/heatmap/models/grid.js +3 -10
- package/lib/heatmap/models/grid3d.d.ts +0 -16
- package/lib/heatmap/models/grid3d.js +6 -14
- package/lib/heatmap/models/heatmap.d.ts +1 -20
- package/lib/heatmap/models/heatmap.js +82 -95
- package/lib/heatmap/models/hexagon.d.ts +0 -14
- package/lib/heatmap/models/hexagon.js +3 -9
- package/lib/heatmap/shaders/grid/grid_vert.glsl +42 -30
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
- package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
- package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
- package/lib/image/models/image.d.ts +0 -14
- package/lib/image/models/image.js +3 -11
- package/lib/image/shaders/image_vert.glsl +6 -7
- package/lib/line/models/arc.d.ts +0 -18
- package/lib/line/models/arc.js +7 -56
- package/lib/line/models/arc_3d.d.ts +0 -18
- package/lib/line/models/arc_3d.js +7 -55
- package/lib/line/models/flow.d.ts +0 -17
- package/lib/line/models/flow.js +7 -35
- package/lib/line/models/great_circle.d.ts +0 -17
- package/lib/line/models/great_circle.js +5 -33
- package/lib/line/models/line.d.ts +0 -17
- package/lib/line/models/line.js +8 -17
- package/lib/line/models/simple_line.d.ts +0 -14
- package/lib/line/models/simple_line.js +47 -12
- package/lib/line/models/wall.d.ts +0 -17
- package/lib/line/models/wall.js +48 -22
- package/lib/line/shaders/arc/line_arc_vert.glsl +48 -42
- package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
- package/lib/line/shaders/flow/flow_line_vert.glsl +48 -30
- package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
- package/lib/line/shaders/line/line_vert.glsl +48 -31
- package/lib/line/shaders/simple/simpleline_vert.glsl +23 -18
- package/lib/line/shaders/wall/wall_vert.glsl +45 -36
- package/lib/mask/models/fill.js +1 -2
- package/lib/mask/shaders/mask_vert.glsl +7 -2
- package/lib/plugins/DataMappingPlugin.d.ts +1 -0
- package/lib/plugins/DataMappingPlugin.js +23 -0
- package/lib/plugins/PixelPickingPlugin.js +1 -1
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
- package/lib/plugins/RegisterStyleAttributePlugin.js +24 -2
- package/lib/plugins/ShaderUniformPlugin.d.ts +5 -0
- package/lib/plugins/ShaderUniformPlugin.js +34 -2
- package/lib/point/models/billboard_point.d.ts +0 -14
- package/lib/point/models/billboard_point.js +3 -11
- package/lib/point/models/earthExtrude.d.ts +0 -16
- package/lib/point/models/earthExtrude.js +7 -14
- package/lib/point/models/earthFill.d.ts +0 -16
- package/lib/point/models/earthFill.js +5 -13
- package/lib/point/models/extrude.d.ts +0 -16
- package/lib/point/models/extrude.js +11 -18
- package/lib/point/models/fill.d.ts +0 -16
- package/lib/point/models/fill.js +5 -16
- package/lib/point/models/fillImage.d.ts +0 -16
- package/lib/point/models/fillImage.js +16 -16
- package/lib/point/models/image.d.ts +0 -15
- package/lib/point/models/image.js +4 -14
- package/lib/point/models/normal.d.ts +0 -14
- package/lib/point/models/normal.js +3 -11
- package/lib/point/models/radar.d.ts +0 -15
- package/lib/point/models/radar.js +4 -13
- package/lib/point/models/text.d.ts +0 -16
- package/lib/point/models/text.js +11 -18
- package/lib/point/shaders/billboard/billboard_point_vert.glsl +13 -10
- package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
- package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/lib/point/shaders/extrude/extrude_vert.glsl +39 -35
- package/lib/point/shaders/fill/fill_vert.glsl +14 -12
- package/lib/point/shaders/fillImage/fillImage_vert.glsl +28 -16
- package/lib/point/shaders/image/image_vert.glsl +12 -15
- package/lib/point/shaders/normal/normal_vert.glsl +10 -7
- package/lib/point/shaders/radar/radar_vert.glsl +11 -11
- package/lib/point/shaders/text/text_vert.glsl +9 -10
- package/lib/polygon/models/extrude.d.ts +0 -16
- package/lib/polygon/models/extrude.js +25 -25
- package/lib/polygon/models/extrusion.d.ts +0 -16
- package/lib/polygon/models/extrusion.js +4 -34
- package/lib/polygon/models/fill.d.ts +0 -14
- package/lib/polygon/models/fill.js +4 -12
- package/lib/polygon/models/ocean.d.ts +0 -14
- package/lib/polygon/models/ocean.js +6 -11
- package/lib/polygon/models/water.d.ts +0 -14
- package/lib/polygon/models/water.js +6 -11
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
- 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 +6 -7
- package/lib/polygon/shaders/fill/fill_vert.glsl +12 -10
- package/lib/polygon/shaders/ocean/ocean_vert.glsl +4 -3
- 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 +0 -14
- package/lib/raster/models/raster.js +3 -12
- package/lib/raster/models/rasterRgb.d.ts +0 -14
- package/lib/raster/models/rasterRgb.js +3 -12
- package/lib/raster/models/rasterTerrainRgb.d.ts +0 -14
- package/lib/raster/models/rasterTerrainRgb.js +3 -11
- 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 +16 -0
- package/lib/tile/tile/Tile.d.ts +0 -2
- package/lib/utils/extrude_polyline.d.ts +15 -0
- package/lib/utils/extrude_polyline.js +217 -0
- package/lib/utils/multiPassRender.js +2 -10
- package/lib/wind/models/wind.d.ts +0 -14
- package/lib/wind/models/wind.js +1 -9
- package/lib/wind/shaders/wind_vert.glsl +5 -6
- package/package.json +9 -9
|
@@ -1,22 +1,6 @@
|
|
|
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
|
-
};
|
|
20
4
|
private cityCenter;
|
|
21
5
|
private cityMinSize;
|
|
22
6
|
protected getCommonUniformsInfo(): {
|
|
@@ -3,25 +3,18 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
4
4
|
import { rgb2arr } from '@antv/l7-utils';
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
6
7
|
import { PolygonExtrudeTriangulation } from "../../core/triangulation";
|
|
7
8
|
/* babel-plugin-inline-import '../shaders/build_frag.glsl' */
|
|
8
|
-
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";
|
|
9
|
+
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";
|
|
9
10
|
/* babel-plugin-inline-import '../shaders/build_vert.glsl' */
|
|
10
|
-
const buildVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location =
|
|
11
|
+
const buildVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) 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 if(u_CoordinateSystem != COORDINATE_SYSTEM_P20_2) {\n lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);\n }\n v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);\n }\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\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";
|
|
11
12
|
export default class CityBuildModel extends BaseModel {
|
|
12
13
|
constructor(...args) {
|
|
13
14
|
super(...args);
|
|
14
15
|
_defineProperty(this, "cityCenter", void 0);
|
|
15
16
|
_defineProperty(this, "cityMinSize", void 0);
|
|
16
17
|
}
|
|
17
|
-
get attributeLocation() {
|
|
18
|
-
return Object.assign(super.attributeLocation, {
|
|
19
|
-
MAX: super.attributeLocation.MAX,
|
|
20
|
-
SIZE: 9,
|
|
21
|
-
NORMAL: 10,
|
|
22
|
-
UV: 11
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
18
|
getCommonUniformsInfo() {
|
|
26
19
|
const {
|
|
27
20
|
opacity = 1,
|
|
@@ -57,10 +50,20 @@ export default class CityBuildModel extends BaseModel {
|
|
|
57
50
|
calCityGeo() {
|
|
58
51
|
// @ts-ignore
|
|
59
52
|
const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
if (this.mapService.version === 'GAODE2.x') {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
this.cityCenter = this.mapService.lngLatToCoord([(maxLng + minLng) / 2, (maxLat + minLat) / 2]);
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
const l1 = this.mapService.lngLatToCoord([maxLng, maxLat]);
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
const l2 = this.mapService.lngLatToCoord([minLng, minLat]);
|
|
60
|
+
this.cityMinSize = Math.sqrt(Math.pow(l1[0] - l2[0], 2) + Math.pow(l1[1] - l2[1], 2)) / 4;
|
|
61
|
+
} else {
|
|
62
|
+
const w = maxLng - minLng;
|
|
63
|
+
const h = maxLat - minLat;
|
|
64
|
+
this.cityCenter = [(maxLng + minLng) / 2, (maxLat + minLat) / 2];
|
|
65
|
+
this.cityMinSize = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2)) / 4;
|
|
66
|
+
}
|
|
64
67
|
}
|
|
65
68
|
initModels() {
|
|
66
69
|
var _this = this;
|
|
@@ -82,7 +85,6 @@ export default class CityBuildModel extends BaseModel {
|
|
|
82
85
|
depth: {
|
|
83
86
|
enable: true
|
|
84
87
|
},
|
|
85
|
-
defines: _this2.getDefines(),
|
|
86
88
|
inject: _this2.getInject(),
|
|
87
89
|
cull: {
|
|
88
90
|
enable: true,
|
|
@@ -99,7 +101,7 @@ export default class CityBuildModel extends BaseModel {
|
|
|
99
101
|
type: AttributeType.Attribute,
|
|
100
102
|
descriptor: {
|
|
101
103
|
name: 'a_Normal',
|
|
102
|
-
shaderLocation:
|
|
104
|
+
shaderLocation: ShaderLocation.NORMAL,
|
|
103
105
|
buffer: {
|
|
104
106
|
// give the WebGL driver a hint that this buffer may change
|
|
105
107
|
usage: gl.STATIC_DRAW,
|
|
@@ -117,7 +119,7 @@ export default class CityBuildModel extends BaseModel {
|
|
|
117
119
|
type: AttributeType.Attribute,
|
|
118
120
|
descriptor: {
|
|
119
121
|
name: 'a_Size',
|
|
120
|
-
shaderLocation:
|
|
122
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
121
123
|
buffer: {
|
|
122
124
|
// give the WebGL driver a hint that this buffer may change
|
|
123
125
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -138,7 +140,7 @@ export default class CityBuildModel extends BaseModel {
|
|
|
138
140
|
type: AttributeType.Attribute,
|
|
139
141
|
descriptor: {
|
|
140
142
|
name: 'a_Uv',
|
|
141
|
-
shaderLocation:
|
|
143
|
+
shaderLocation: ShaderLocation.UV,
|
|
142
144
|
buffer: {
|
|
143
145
|
// give the WebGL driver a hint that this buffer may change
|
|
144
146
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
precision highp float;
|
|
2
2
|
layout(std140) uniform commonUniforms {
|
|
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 ];
|
|
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: 0;
|
|
13
|
-
float u_far: 1;
|
|
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 = 0) in vec3 a_Position;
|
|
8
|
+
layout(location = 1) in vec4 a_Color;
|
|
9
|
+
layout(location = 9) in float a_Size;
|
|
10
|
+
layout(location = 13) in vec3 a_Normal;
|
|
11
|
+
layout(location = 14) in vec2 a_Uv;
|
|
12
12
|
|
|
13
13
|
out vec2 v_texCoord;
|
|
14
14
|
out vec4 v_Color;
|
|
@@ -41,11 +41,17 @@ void main() {
|
|
|
41
41
|
|
|
42
42
|
if(u_circleSweep > 0.0) {
|
|
43
43
|
vec2 lnglatscale = vec2(0.0);
|
|
44
|
-
|
|
44
|
+
if(u_CoordinateSystem != COORDINATE_SYSTEM_P20_2) {
|
|
45
|
+
lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);
|
|
46
|
+
}
|
|
45
47
|
v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
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
|
+
}
|
|
49
55
|
|
|
50
56
|
float lightWeight = calc_lighting(pos);
|
|
51
57
|
// v_Color = a_Color;
|
package/es/core/BaseLayer.js
CHANGED
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
5
|
const _excluded = ["passes"],
|
|
6
|
-
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "
|
|
6
|
+
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption", "pickingEnabled"];
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
|
|
9
9
|
import { BlendType, IDebugLog, ILayerStage, globalConfigService } from '@antv/l7-core';
|
|
@@ -58,8 +58,7 @@ export default class BaseLayer extends EventEmitter {
|
|
|
58
58
|
return this.container.interactionService;
|
|
59
59
|
}
|
|
60
60
|
get mapService() {
|
|
61
|
-
|
|
62
|
-
return (_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.mapService;
|
|
61
|
+
return this.container.mapService;
|
|
63
62
|
}
|
|
64
63
|
get normalPassFactory() {
|
|
65
64
|
return this.container.normalPassFactory;
|
|
@@ -606,9 +605,6 @@ export default class BaseLayer extends EventEmitter {
|
|
|
606
605
|
if (_this2.multiPassRenderer && _this2.multiPassRenderer.getRenderFlag()) {
|
|
607
606
|
// multi render 开始执行 multiPassRender 的渲染流程
|
|
608
607
|
yield _this2.multiPassRenderer.render();
|
|
609
|
-
} else if (_this2.multiPassRenderer) {
|
|
610
|
-
// renderPass 触发的渲染
|
|
611
|
-
_this2.renderModels();
|
|
612
608
|
} else {
|
|
613
609
|
_this2.renderModels();
|
|
614
610
|
}
|
|
@@ -922,8 +918,12 @@ export default class BaseLayer extends EventEmitter {
|
|
|
922
918
|
type
|
|
923
919
|
}) => {
|
|
924
920
|
if (this.coordCenter === undefined) {
|
|
921
|
+
var _this$mapService;
|
|
925
922
|
const layerCenter = this.layerSource.center;
|
|
926
923
|
this.coordCenter = layerCenter;
|
|
924
|
+
if ((_this$mapService = this.mapService) !== null && _this$mapService !== void 0 && _this$mapService.setCoordCenter) {
|
|
925
|
+
this.mapService.setCoordCenter(layerCenter);
|
|
926
|
+
}
|
|
927
927
|
}
|
|
928
928
|
if (type === 'update') {
|
|
929
929
|
if (this.tileLayer) {
|
|
@@ -1017,7 +1017,6 @@ export default class BaseLayer extends EventEmitter {
|
|
|
1017
1017
|
moduleName,
|
|
1018
1018
|
vertexShader,
|
|
1019
1019
|
fragmentShader,
|
|
1020
|
-
defines,
|
|
1021
1020
|
inject,
|
|
1022
1021
|
triangulation,
|
|
1023
1022
|
styleOption,
|
|
@@ -1027,7 +1026,6 @@ export default class BaseLayer extends EventEmitter {
|
|
|
1027
1026
|
_this3.shaderModuleService.registerModule(moduleName, {
|
|
1028
1027
|
vs: vertexShader,
|
|
1029
1028
|
fs: fragmentShader,
|
|
1030
|
-
defines,
|
|
1031
1029
|
inject
|
|
1032
1030
|
});
|
|
1033
1031
|
const {
|
|
@@ -1044,9 +1042,7 @@ export default class BaseLayer extends EventEmitter {
|
|
|
1044
1042
|
elements,
|
|
1045
1043
|
count
|
|
1046
1044
|
} = _this3.styleAttributeService.createAttributesAndIndices(_this3.encodedData, triangulation, styleOption, _this3);
|
|
1047
|
-
const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers,
|
|
1048
|
-
// TODO: 目前未使用
|
|
1049
|
-
_this3.getLayerUniformBuffer()];
|
|
1045
|
+
const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers, _this3.getLayerUniformBuffer()];
|
|
1050
1046
|
if (pickingEnabled) {
|
|
1051
1047
|
uniformBuffers.push(_this3.getPickingUniformBuffer());
|
|
1052
1048
|
}
|
|
@@ -1231,8 +1227,8 @@ export default class BaseLayer extends EventEmitter {
|
|
|
1231
1227
|
_this5.uniformBuffers = [];
|
|
1232
1228
|
// Layer Uniform
|
|
1233
1229
|
const layerUniforms = _this5.rendererService.createBuffer({
|
|
1234
|
-
// TODO: 不再需要,之前用于 amap2 u_Mvp
|
|
1235
1230
|
data: new Float32Array(16 + 4).fill(0),
|
|
1231
|
+
// u_Mvp
|
|
1236
1232
|
isUBO: true
|
|
1237
1233
|
});
|
|
1238
1234
|
_this5.uniformBuffers.push(layerUniforms);
|
package/es/core/BaseModel.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService,
|
|
2
|
-
import { COMMON_ATTRIBUTE_LOCATION } from './CommonStyleAttribute';
|
|
1
|
+
import type { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, IInject, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
|
|
3
2
|
export type styleSingle = number | string | [string, (single: any) => number] | [string, [number, number]];
|
|
4
3
|
export type styleOffset = string | [number, number] | [string, (single: any) => number];
|
|
5
4
|
export type styleColor = string | [string, (single: any) => string] | [string, [string, string]];
|
|
@@ -12,15 +11,10 @@ export interface ICellProperty {
|
|
|
12
11
|
attr: string;
|
|
13
12
|
count: number;
|
|
14
13
|
}
|
|
15
|
-
type AttributeLayoutLocationType = typeof COMMON_ATTRIBUTE_LOCATION & Record<string, number>;
|
|
16
14
|
export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerModel {
|
|
17
15
|
triangulation: Triangulation;
|
|
18
16
|
uniformBuffers: IBuffer[];
|
|
19
17
|
textures: ITexture2D[];
|
|
20
|
-
/**
|
|
21
|
-
* Attribute Layout Location in Shader
|
|
22
|
-
*/
|
|
23
|
-
protected get attributeLocation(): AttributeLayoutLocationType;
|
|
24
18
|
createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
|
|
25
19
|
preStyleAttribute: Record<string, any>;
|
|
26
20
|
protected encodeStyleAttribute: Record<string, boolean>;
|
|
@@ -61,17 +55,11 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
61
55
|
protected registerBuiltinAttributes(): void;
|
|
62
56
|
protected animateOption2Array(option: IAnimateOption): number[];
|
|
63
57
|
protected startModelAnimate(): void;
|
|
64
|
-
protected getInject():
|
|
65
|
-
protected getDefines(): Record<string, ShaderDefine>;
|
|
58
|
+
protected getInject(): IInject;
|
|
66
59
|
protected getStyleAttribute(): {
|
|
67
60
|
[key: string]: any;
|
|
68
61
|
};
|
|
69
62
|
protected registerStyleAttribute(): void;
|
|
70
|
-
/**
|
|
71
|
-
* 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
|
|
72
|
-
* 避免大于 20层级以上出现数据偏移
|
|
73
|
-
*/
|
|
74
|
-
protected registerPosition64LowAttribute(enable64bitPosition?: boolean): void;
|
|
75
63
|
updateEncodeAttribute(type: string, flag: boolean): void;
|
|
76
64
|
initUniformsBuffer(): void;
|
|
77
65
|
protected getUniformsBufferInfo(uniformsOption: {
|
|
@@ -92,4 +80,3 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
92
80
|
};
|
|
93
81
|
updateStyleUnifoms(): void;
|
|
94
82
|
}
|
|
95
|
-
export {};
|
package/es/core/BaseModel.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { BlendType, MaskOperation, StencilType } from '@antv/l7-core';
|
|
5
|
+
import { rgb2arr } from '@antv/l7-utils';
|
|
6
6
|
import { BlendTypes } from "../utils/blend";
|
|
7
7
|
import { getStencil, getStencilMask } from "../utils/stencil";
|
|
8
|
-
import {
|
|
8
|
+
import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
|
|
9
9
|
import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
|
|
10
10
|
import { MultipleOfFourNumber } from "./utils";
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const shaderLocationMap = {
|
|
12
|
+
opacity: ShaderLocation.OPACITY,
|
|
13
|
+
stroke: ShaderLocation.STROKE,
|
|
14
|
+
offsets: ShaderLocation.OFFSETS,
|
|
15
|
+
rotation: ShaderLocation.ROTATION,
|
|
16
|
+
extrusionBase: ShaderLocation.EXTRUSION_BASE,
|
|
17
|
+
thetaOffset: 15
|
|
18
|
+
};
|
|
13
19
|
|
|
14
20
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
21
|
export default class BaseModel {
|
|
16
|
-
/**
|
|
17
|
-
* Attribute Layout Location in Shader
|
|
18
|
-
*/
|
|
19
|
-
get attributeLocation() {
|
|
20
|
-
return _objectSpread({}, COMMON_ATTRIBUTE_LOCATION);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// style texture data mapping
|
|
24
|
-
|
|
25
22
|
// 不支持数据映射的buffer
|
|
26
23
|
|
|
27
24
|
// style texture data mapping
|
|
@@ -30,6 +27,7 @@ export default class BaseModel {
|
|
|
30
27
|
_defineProperty(this, "triangulation", void 0);
|
|
31
28
|
_defineProperty(this, "uniformBuffers", []);
|
|
32
29
|
_defineProperty(this, "textures", []);
|
|
30
|
+
// style texture data mapping
|
|
33
31
|
_defineProperty(this, "createTexture2D", void 0);
|
|
34
32
|
_defineProperty(this, "preStyleAttribute", {});
|
|
35
33
|
_defineProperty(this, "encodeStyleAttribute", {});
|
|
@@ -180,18 +178,55 @@ export default class BaseModel {
|
|
|
180
178
|
this.layer.setAnimateStartTime();
|
|
181
179
|
}
|
|
182
180
|
}
|
|
181
|
+
|
|
182
|
+
// 动态注入参与数据映射的uniform
|
|
183
183
|
getInject() {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
184
|
+
const encodeStyleAttribute = this.layer.encodeStyleAttribute;
|
|
185
|
+
let str = '';
|
|
186
|
+
// a_Position = 0
|
|
187
|
+
// a_Color = 1
|
|
188
|
+
// a_PickingColor = 2
|
|
189
|
+
|
|
190
|
+
const uniforms = [];
|
|
191
|
+
// 支持数据映射的类型
|
|
192
|
+
this.layer.enableShaderEncodeStyles.forEach(key => {
|
|
193
|
+
if (encodeStyleAttribute[key]) {
|
|
194
|
+
// 配置了数据映射的类型
|
|
195
|
+
str += `#define USE_ATTRIBUTE_${key.toUpperCase()} 0.0; \n\n`;
|
|
196
|
+
} else {
|
|
197
|
+
uniforms.push(` ${DefaultUniformStyleType[key]} u_${key};`);
|
|
198
|
+
}
|
|
199
|
+
let location = shaderLocationMap[key];
|
|
200
|
+
if (!location && key === 'THETA_OFFSET') {
|
|
201
|
+
location = 15;
|
|
202
|
+
}
|
|
203
|
+
str += `
|
|
204
|
+
#ifdef USE_ATTRIBUTE_${key.toUpperCase()}
|
|
205
|
+
layout(location = ${shaderLocationMap[key]}) in ${DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
206
|
+
#endif\n
|
|
207
|
+
`;
|
|
208
|
+
});
|
|
209
|
+
const attributeUniforms = uniforms.length ? `
|
|
210
|
+
layout(std140) uniform AttributeUniforms {
|
|
211
|
+
${uniforms.join('\n')}
|
|
212
|
+
};
|
|
213
|
+
` : '';
|
|
214
|
+
str += attributeUniforms;
|
|
215
|
+
let innerStr = '';
|
|
216
|
+
this.layer.enableShaderEncodeStyles.forEach(key => {
|
|
217
|
+
innerStr += `\n
|
|
218
|
+
#ifdef USE_ATTRIBUTE_${key.toUpperCase()}
|
|
219
|
+
${DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
220
|
+
#else
|
|
221
|
+
${DefaultUniformStyleType[key]} ${key} = u_${key};
|
|
222
|
+
#endif\n
|
|
223
|
+
`;
|
|
224
|
+
});
|
|
225
|
+
return {
|
|
226
|
+
'vs:#decl': str,
|
|
227
|
+
'fs:#decl': attributeUniforms,
|
|
228
|
+
'vs:#main-start': innerStr
|
|
229
|
+
};
|
|
195
230
|
}
|
|
196
231
|
|
|
197
232
|
// 获取数据映射样式
|
|
@@ -212,36 +247,14 @@ export default class BaseModel {
|
|
|
212
247
|
});
|
|
213
248
|
return options;
|
|
214
249
|
}
|
|
215
|
-
|
|
216
250
|
// 注册数据映射样式
|
|
217
251
|
registerStyleAttribute() {
|
|
218
252
|
Object.keys(this.layer.encodeStyleAttribute).forEach(key => {
|
|
219
253
|
const options = getCommonStyleAttributeOptions(key);
|
|
220
254
|
if (options) {
|
|
221
255
|
this.styleAttributeService.registerStyleAttribute(options);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
|
|
228
|
-
* 避免大于 20层级以上出现数据偏移
|
|
229
|
-
*/
|
|
230
|
-
registerPosition64LowAttribute(enable64bitPosition = true) {
|
|
231
|
-
// save low part for enabled double precision POSITION attribute
|
|
232
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
233
|
-
name: 'position64Low',
|
|
234
|
-
type: AttributeType.Attribute,
|
|
235
|
-
descriptor: {
|
|
236
|
-
name: 'a_Position64Low',
|
|
237
|
-
shaderLocation: this.attributeLocation.POSITION_64LOW,
|
|
238
|
-
buffer: {
|
|
239
|
-
data: [],
|
|
240
|
-
type: gl.FLOAT
|
|
241
|
-
},
|
|
242
|
-
size: 2,
|
|
243
|
-
update: (feature, featureIdx, vertex) => {
|
|
244
|
-
return enable64bitPosition ? [fp64LowPart(vertex[0]), fp64LowPart(vertex[1])] : [0, 0];
|
|
256
|
+
if (options.descriptor) {
|
|
257
|
+
options.descriptor.shaderLocation = shaderLocationMap[key];
|
|
245
258
|
}
|
|
246
259
|
}
|
|
247
260
|
});
|
|
@@ -317,49 +330,4 @@ export default class BaseModel {
|
|
|
317
330
|
data: new Uint8Array(new Float32Array(commonUniformsArray).buffer)
|
|
318
331
|
});
|
|
319
332
|
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* 获取动态注入参与数据映射 uniform/attribute
|
|
324
|
-
*/
|
|
325
|
-
function getDynamicStyleInject(shaderEncodeStyles, styleAttribute) {
|
|
326
|
-
const uniforms = [];
|
|
327
|
-
let vsDeclInjection = '';
|
|
328
|
-
|
|
329
|
-
// 支持数据映射的类型
|
|
330
|
-
shaderEncodeStyles.forEach(key => {
|
|
331
|
-
const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
332
|
-
const shaderDefineName = DEFINE_ATTRIBUTE_LOCATION_PREFIX + upperCaseKey;
|
|
333
|
-
if (styleAttribute[key]) {
|
|
334
|
-
// 配置了数据映射的类型
|
|
335
|
-
vsDeclInjection += `#define USE_ATTRIBUTE_${upperCaseKey} 0.0 \n`;
|
|
336
|
-
} else {
|
|
337
|
-
uniforms.push(` ${DefaultUniformStyleType[key]} u_${key};`);
|
|
338
|
-
}
|
|
339
|
-
vsDeclInjection += `
|
|
340
|
-
#ifdef USE_ATTRIBUTE_${upperCaseKey}
|
|
341
|
-
layout(location = ${shaderDefineName}) in ${DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
342
|
-
#endif \n`;
|
|
343
|
-
});
|
|
344
|
-
const fsDeclInjection = uniforms.length ? `
|
|
345
|
-
layout(std140) uniform AttributeUniforms {
|
|
346
|
-
${uniforms.join('\n')}
|
|
347
|
-
};\n` : '';
|
|
348
|
-
vsDeclInjection += fsDeclInjection;
|
|
349
|
-
let vsMainInjection = '';
|
|
350
|
-
shaderEncodeStyles.forEach(key => {
|
|
351
|
-
const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
352
|
-
vsMainInjection += `
|
|
353
|
-
#ifdef USE_ATTRIBUTE_${upperCaseKey}
|
|
354
|
-
${DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
355
|
-
#else
|
|
356
|
-
${DefaultUniformStyleType[key]} ${key} = u_${key};
|
|
357
|
-
#endif
|
|
358
|
-
`;
|
|
359
|
-
});
|
|
360
|
-
return {
|
|
361
|
-
'vs:#decl': vsDeclInjection,
|
|
362
|
-
'fs:#decl': fsDeclInjection,
|
|
363
|
-
'vs:#main-start': vsMainInjection
|
|
364
|
-
};
|
|
365
333
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { IStyleAttribute } from '@antv/l7-core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
export declare enum ShaderLocation {
|
|
3
|
+
POSITION = 0,
|
|
4
|
+
COLOR = 1,
|
|
5
|
+
VERTEX_ID = 2,
|
|
6
|
+
PICKING_COLOR = 3,
|
|
7
|
+
STROKE = 4,
|
|
8
|
+
OPACITY = 5,
|
|
9
|
+
OFFSETS = 6,
|
|
10
|
+
ROTATION = 7,
|
|
11
|
+
EXTRUSION_BASE = 8,
|
|
12
|
+
SIZE = 9,
|
|
13
|
+
SHAPE = 10,
|
|
14
|
+
EXTRUDE = 11,
|
|
15
|
+
MAX = 12,
|
|
16
|
+
NORMAL = 13,
|
|
17
|
+
UV = 14,
|
|
18
|
+
LINEAR = 15
|
|
19
|
+
}
|
|
16
20
|
export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
|