@antv/l7-layers 2.20.12 → 2.20.14
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/core/BaseLayer.d.ts +0 -1
- package/es/core/BaseLayer.js +8 -5
- package/es/core/LayerPickService.d.ts +1 -1
- package/es/core/LayerPickService.js +28 -10
- package/es/geometry/models/sprite.js +2 -2
- package/es/heatmap/models/grid.js +2 -2
- package/es/heatmap/models/grid3d.js +4 -4
- package/es/heatmap/models/heatmap.js +10 -6
- package/es/heatmap/shaders/grid/grid_frag.glsl +1 -0
- package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
- package/es/image/models/image.js +6 -8
- package/es/line/models/arc.js +1 -1
- package/es/line/models/line.js +10 -45
- package/es/line/shaders/arc/line_arc_frag.glsl +2 -1
- package/es/line/shaders/line/line_frag.glsl +2 -2
- package/es/line/shaders/line/line_vert.glsl +10 -7
- package/es/plugins/ShaderUniformPlugin.js +3 -2
- package/es/point/models/extrude.js +2 -2
- package/es/point/models/fill.js +1 -1
- package/es/point/models/fillImage.js +3 -5
- package/es/point/models/text.js +2 -2
- package/es/point/shaders/extrude/extrude_frag.glsl +1 -0
- package/es/point/shaders/extrude/extrude_vert.glsl +0 -1
- package/es/point/shaders/fill/fill_frag.glsl +1 -1
- package/es/point/shaders/fillImage/fillImage_frag.glsl +1 -2
- package/es/point/shaders/text/text_frag.glsl +3 -2
- package/es/point/shaders/text/text_vert.glsl +0 -2
- package/es/polygon/models/extrude.js +30 -39
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/fill.js +3 -3
- package/es/polygon/models/water.js +6 -4
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
- package/es/polygon/shaders/fill/fill_frag.glsl +1 -0
- package/es/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
- package/es/raster/models/rasterTerrainRgb.d.ts +8 -2
- package/es/raster/models/rasterTerrainRgb.js +20 -14
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -16
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +13 -5
- package/es/tile/service/TilePickService.d.ts +1 -1
- package/es/tile/service/TilePickService.js +36 -13
- package/es/tile/tile/Tile.js +4 -3
- package/es/utils/load-image.d.ts +1 -0
- package/es/utils/load-image.js +46 -0
- package/lib/core/BaseLayer.js +8 -5
- package/lib/core/LayerPickService.js +28 -10
- package/lib/geometry/models/sprite.js +2 -2
- package/lib/heatmap/models/grid.js +2 -2
- package/lib/heatmap/models/grid3d.js +4 -4
- package/lib/heatmap/models/heatmap.js +10 -6
- package/lib/heatmap/shaders/grid/grid_frag.glsl +1 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
- package/lib/image/models/image.js +6 -8
- package/lib/line/models/arc.js +1 -1
- package/lib/line/models/line.js +10 -45
- package/lib/line/shaders/arc/line_arc_frag.glsl +2 -1
- package/lib/line/shaders/line/line_frag.glsl +2 -2
- package/lib/line/shaders/line/line_vert.glsl +10 -7
- package/lib/plugins/ShaderUniformPlugin.js +3 -2
- package/lib/point/models/extrude.js +2 -2
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/fillImage.js +3 -5
- package/lib/point/models/text.js +2 -2
- package/lib/point/shaders/extrude/extrude_frag.glsl +1 -0
- package/lib/point/shaders/extrude/extrude_vert.glsl +0 -1
- package/lib/point/shaders/fill/fill_frag.glsl +1 -1
- package/lib/point/shaders/fillImage/fillImage_frag.glsl +1 -2
- package/lib/point/shaders/text/text_frag.glsl +3 -2
- package/lib/point/shaders/text/text_vert.glsl +0 -2
- package/lib/polygon/models/extrude.js +29 -38
- package/lib/polygon/models/extrusion.js +1 -1
- package/lib/polygon/models/fill.js +3 -3
- package/lib/polygon/models/water.js +6 -4
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
- package/lib/polygon/shaders/fill/fill_frag.glsl +1 -0
- package/lib/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
- package/lib/raster/models/rasterTerrainRgb.js +20 -14
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -16
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +13 -5
- package/lib/tile/service/TilePickService.js +36 -13
- package/lib/tile/tile/Tile.js +4 -3
- package/lib/utils/load-image.js +53 -0
- package/package.json +7 -7
|
@@ -2,24 +2,21 @@ layout(location = 0) in vec3 a_Position;
|
|
|
2
2
|
layout(location = 1) in vec4 a_Color;
|
|
3
3
|
layout(location = 15) in vec3 a_linear;
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
layout(std140) uniform commonUniforms {
|
|
7
6
|
float u_raisingHeight;
|
|
8
7
|
float u_opacitylinear;
|
|
9
8
|
float u_dir;
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
out vec4 v_color;
|
|
12
|
+
out vec3 v_linear;
|
|
13
|
+
out vec2 v_pos;
|
|
14
14
|
|
|
15
15
|
#pragma include "projection"
|
|
16
16
|
#pragma include "picking"
|
|
17
17
|
|
|
18
|
-
out vec3 v_linear;
|
|
19
|
-
out vec2 v_pos;
|
|
20
|
-
|
|
21
18
|
void main() {
|
|
22
|
-
if(u_opacitylinear > 0.0) {
|
|
19
|
+
if (u_opacitylinear > 0.0) {
|
|
23
20
|
v_linear = a_linear;
|
|
24
21
|
v_pos = a_Position.xy;
|
|
25
22
|
}
|
|
@@ -27,12 +24,12 @@ void main() {
|
|
|
27
24
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
28
25
|
project_pos.z += u_raisingHeight;
|
|
29
26
|
|
|
30
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
27
|
+
if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
31
28
|
float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
|
|
32
29
|
project_pos.z *= mapboxZoomScale;
|
|
33
30
|
project_pos.z += u_raisingHeight * mapboxZoomScale;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));
|
|
37
34
|
setPickingColor(a_PickingColor);
|
|
38
35
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type { IModel,
|
|
1
|
+
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class RasterTerrainRGB extends BaseModel {
|
|
4
4
|
protected texture: ITexture2D;
|
|
5
|
-
|
|
5
|
+
protected getCommonUniformsInfo(): {
|
|
6
|
+
uniformsArray: number[];
|
|
7
|
+
uniformsLength: number;
|
|
8
|
+
uniformsOption: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
6
12
|
initModels(): Promise<IModel[]>;
|
|
7
13
|
clearModels(): void;
|
|
8
14
|
buildModels(): Promise<IModel[]>;
|
|
@@ -11,10 +11,11 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
11
11
|
import { getDefaultDomain } from '@antv/l7-utils';
|
|
12
12
|
import BaseModel from "../../core/BaseModel";
|
|
13
13
|
import { RasterImageTriangulation } from "../../core/triangulation";
|
|
14
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
14
15
|
/* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_frag.glsl' */
|
|
15
|
-
var Raster_terrainFrag = "
|
|
16
|
+
var Raster_terrainFrag = "uniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_unpack;\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nin vec2 v_texCoord;\nout vec4 outputColor;\n\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture(SAMPLER_2D(u_texture), coord,bias) * 255.0;\n data.a = -1.0;\n return dot(data, u_unpack);\n}\n\nvec4 getColor(float value) {\n float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec2 coord = vec2(normalisedValue, 0);\n return texture(SAMPLER_2D(u_colorTexture), coord);\n}\n\nvoid main() {\n float value = getElevation(v_texCoord,0.0);\n if (value == u_noDataValue) {\n outputColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n outputColor = vec4(0.0, 0, 0, 0.0);\n } else {\n \n outputColor = getColor(value);\n outputColor.a = outputColor.a * u_opacity ;\n if(outputColor.a < 0.01)\n discard;\n }\n}\n";
|
|
16
17
|
/* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_vert.glsl' */
|
|
17
|
-
var Raster_terrainVert = "
|
|
18
|
+
var Raster_terrainVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_unpack;\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n\n};\nout vec2 v_texCoord;\n#pragma include \"projection\"\n\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy,0., 1.0));\n}\n";
|
|
18
19
|
var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
19
20
|
_inherits(RasterTerrainRGB, _BaseModel);
|
|
20
21
|
var _super = _createSuper(RasterTerrainRGB);
|
|
@@ -23,8 +24,8 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
23
24
|
return _super.apply(this, arguments);
|
|
24
25
|
}
|
|
25
26
|
_createClass(RasterTerrainRGB, [{
|
|
26
|
-
key: "
|
|
27
|
-
value: function
|
|
27
|
+
key: "getCommonUniformsInfo",
|
|
28
|
+
value: function getCommonUniformsInfo() {
|
|
28
29
|
var _ref = this.layer.getLayerConfig(),
|
|
29
30
|
opacity = _ref.opacity,
|
|
30
31
|
_ref$clampLow = _ref.clampLow,
|
|
@@ -51,16 +52,19 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
51
52
|
} else {
|
|
52
53
|
this.layer.textureService.setColorTexture(colorTexture, rampColors, newdomain);
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
u_texture: this.texture,
|
|
55
|
+
var commonOptions = {
|
|
56
|
+
u_unpack: [rScaler, gScaler, bScaler, offset],
|
|
57
57
|
u_domain: newdomain,
|
|
58
|
+
u_opacity: opacity || 1,
|
|
59
|
+
u_noDataValue: noDataValue,
|
|
58
60
|
u_clampLow: clampLow,
|
|
59
61
|
u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
|
|
60
|
-
|
|
61
|
-
u_unpack: [rScaler, gScaler, bScaler, offset],
|
|
62
|
+
u_texture: this.texture,
|
|
62
63
|
u_colorTexture: texture
|
|
63
64
|
};
|
|
65
|
+
this.textures = [this.texture, texture];
|
|
66
|
+
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
67
|
+
return commonBufferInfo;
|
|
64
68
|
}
|
|
65
69
|
}, {
|
|
66
70
|
key: "initModels",
|
|
@@ -70,11 +74,12 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
70
74
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
71
75
|
while (1) switch (_context.prev = _context.next) {
|
|
72
76
|
case 0:
|
|
77
|
+
this.initUniformsBuffer();
|
|
73
78
|
source = this.layer.getSource();
|
|
74
79
|
createTexture2D = this.rendererService.createTexture2D;
|
|
75
|
-
_context.next =
|
|
80
|
+
_context.next = 5;
|
|
76
81
|
return source.data.images;
|
|
77
|
-
case
|
|
82
|
+
case 5:
|
|
78
83
|
imageData = _context.sent;
|
|
79
84
|
this.texture = createTexture2D({
|
|
80
85
|
data: imageData[0],
|
|
@@ -83,7 +88,7 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
83
88
|
min: gl.LINEAR,
|
|
84
89
|
mag: gl.LINEAR
|
|
85
90
|
});
|
|
86
|
-
_context.next =
|
|
91
|
+
_context.next = 9;
|
|
87
92
|
return this.layer.buildLayerModel({
|
|
88
93
|
moduleName: 'RasterTileDataImage',
|
|
89
94
|
vertexShader: Raster_terrainVert,
|
|
@@ -94,10 +99,10 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
94
99
|
enable: false
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
|
-
case
|
|
102
|
+
case 9:
|
|
98
103
|
model = _context.sent;
|
|
99
104
|
return _context.abrupt("return", [model]);
|
|
100
|
-
case
|
|
105
|
+
case 11:
|
|
101
106
|
case "end":
|
|
102
107
|
return _context.stop();
|
|
103
108
|
}
|
|
@@ -141,6 +146,7 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
141
146
|
type: AttributeType.Attribute,
|
|
142
147
|
descriptor: {
|
|
143
148
|
name: 'a_Uv',
|
|
149
|
+
shaderLocation: ShaderLocation.UV,
|
|
144
150
|
buffer: {
|
|
145
151
|
usage: gl.DYNAMIC_DRAW,
|
|
146
152
|
data: [],
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
precision mediump float;
|
|
2
|
-
uniform float u_opacity: 1.0;
|
|
3
|
-
|
|
4
1
|
uniform sampler2D u_texture;
|
|
5
2
|
uniform sampler2D u_colorTexture;
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
layout(std140) uniform commonUniforms {
|
|
5
|
+
vec4 u_unpack;
|
|
6
|
+
vec2 u_domain;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_noDataValue;
|
|
9
|
+
bool u_clampLow;
|
|
10
|
+
bool u_clampHigh;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
in vec2 v_texCoord;
|
|
14
|
+
out vec4 outputColor;
|
|
8
15
|
|
|
9
|
-
uniform vec2 u_domain;
|
|
10
|
-
uniform float u_noDataValue;
|
|
11
|
-
uniform bool u_clampLow: true;
|
|
12
|
-
uniform bool u_clampHigh: true;
|
|
13
|
-
uniform vec4 u_unpack;
|
|
14
16
|
|
|
15
17
|
float getElevation(vec2 coord, float bias) {
|
|
16
18
|
// Convert encoded elevation value to meters
|
|
17
|
-
vec4 data =
|
|
19
|
+
vec4 data = texture(SAMPLER_2D(u_texture), coord,bias) * 255.0;
|
|
18
20
|
data.a = -1.0;
|
|
19
21
|
return dot(data, u_unpack);
|
|
20
22
|
}
|
|
@@ -22,20 +24,20 @@ float getElevation(vec2 coord, float bias) {
|
|
|
22
24
|
vec4 getColor(float value) {
|
|
23
25
|
float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);
|
|
24
26
|
vec2 coord = vec2(normalisedValue, 0);
|
|
25
|
-
return
|
|
27
|
+
return texture(SAMPLER_2D(u_colorTexture), coord);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
void main() {
|
|
29
31
|
float value = getElevation(v_texCoord,0.0);
|
|
30
32
|
if (value == u_noDataValue) {
|
|
31
|
-
|
|
33
|
+
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
32
34
|
} else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
|
|
33
|
-
|
|
35
|
+
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
34
36
|
} else {
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if(
|
|
38
|
+
outputColor = getColor(value);
|
|
39
|
+
outputColor.a = outputColor.a * u_opacity ;
|
|
40
|
+
if(outputColor.a < 0.01)
|
|
39
41
|
discard;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
layout(location = 0) in vec3 a_Position;
|
|
2
|
+
layout(location = 14) in vec2 a_Uv;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
layout(std140) uniform commonUniforms {
|
|
5
|
+
vec4 u_unpack;
|
|
6
|
+
vec2 u_domain;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_noDataValue;
|
|
9
|
+
bool u_clampLow;
|
|
10
|
+
bool u_clampHigh;
|
|
11
|
+
|
|
12
|
+
};
|
|
13
|
+
out vec2 v_texCoord;
|
|
7
14
|
#pragma include "projection"
|
|
15
|
+
|
|
8
16
|
void main() {
|
|
9
17
|
v_texCoord = a_Uv;
|
|
10
18
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
@@ -13,7 +13,7 @@ export declare class TilePickService implements ITilePickService {
|
|
|
13
13
|
private tilePickID;
|
|
14
14
|
constructor({ layerService, tileLayerService, parent, }: ITilePickServiceOptions);
|
|
15
15
|
pickRender(target: IInteractionTarget): void;
|
|
16
|
-
pick(layer: ILayer, target: IInteractionTarget): boolean
|
|
16
|
+
pick(layer: ILayer, target: IInteractionTarget): Promise<boolean>;
|
|
17
17
|
selectFeature(pickedColors: Uint8Array | undefined): void;
|
|
18
18
|
highlightPickedFeature(pickedColors: Uint8Array | undefined): void;
|
|
19
19
|
updateHighLight(r: number, g: number, b: number, type: string): void;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
8
|
import { TYPES } from '@antv/l7-core';
|
|
7
9
|
import { decodePickingColor, encodePickingColor } from '@antv/l7-utils';
|
|
8
10
|
import { TileSourceService } from "./TileSourceService";
|
|
@@ -33,20 +35,41 @@ export var TilePickService = /*#__PURE__*/function () {
|
|
|
33
35
|
}
|
|
34
36
|
}, {
|
|
35
37
|
key: "pick",
|
|
36
|
-
value: function
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
value: function () {
|
|
39
|
+
var _pick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer, target) {
|
|
40
|
+
var container, pickingService, tile, pickLayer;
|
|
41
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
container = this.parent.getContainer();
|
|
45
|
+
pickingService = container.get(TYPES.IPickingService);
|
|
46
|
+
if (!(layer.type === 'RasterLayer')) {
|
|
47
|
+
_context.next = 8;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
|
|
51
|
+
if (!(tile && tile.getMainLayer() !== undefined)) {
|
|
52
|
+
_context.next = 7;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
pickLayer = tile.getMainLayer();
|
|
56
|
+
return _context.abrupt("return", pickLayer.layerPickService.pickRasterLayer(pickLayer, target, this.parent));
|
|
57
|
+
case 7:
|
|
58
|
+
return _context.abrupt("return", false);
|
|
59
|
+
case 8:
|
|
60
|
+
this.pickRender(target);
|
|
61
|
+
return _context.abrupt("return", pickingService.pickFromPickingFBO(layer, target));
|
|
62
|
+
case 10:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee, this);
|
|
67
|
+
}));
|
|
68
|
+
function pick(_x, _x2) {
|
|
69
|
+
return _pick.apply(this, arguments);
|
|
46
70
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
71
|
+
return pick;
|
|
72
|
+
}()
|
|
50
73
|
}, {
|
|
51
74
|
key: "selectFeature",
|
|
52
75
|
value: function selectFeature(pickedColors) {
|
package/es/tile/tile/Tile.js
CHANGED
|
@@ -104,7 +104,8 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
104
104
|
while (1) switch (_context.prev = _context.next) {
|
|
105
105
|
case 0:
|
|
106
106
|
mask = new PolygonLayer({
|
|
107
|
-
|
|
107
|
+
name: 'mask',
|
|
108
|
+
visible: true,
|
|
108
109
|
enablePicking: false
|
|
109
110
|
}).source({
|
|
110
111
|
type: 'FeatureCollection',
|
|
@@ -114,7 +115,7 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
114
115
|
type: 'geojson',
|
|
115
116
|
featureId: 'id'
|
|
116
117
|
}
|
|
117
|
-
}).shape('fill').style({
|
|
118
|
+
}).shape('fill').color('#0f0').style({
|
|
118
119
|
opacity: 0.5
|
|
119
120
|
});
|
|
120
121
|
container = createLayerContainer(this.parent.sceneContainer);
|
|
@@ -138,7 +139,7 @@ var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
|
138
139
|
return _addTileMask.apply(this, arguments);
|
|
139
140
|
}
|
|
140
141
|
return addTileMask;
|
|
141
|
-
}()
|
|
142
|
+
}() // 全局 Mask
|
|
142
143
|
}, {
|
|
143
144
|
key: "addMask",
|
|
144
145
|
value: function () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadImage(url: string): Promise<HTMLImageElement | ImageBitmap>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
export function loadImage(_x) {
|
|
4
|
+
return _loadImage.apply(this, arguments);
|
|
5
|
+
}
|
|
6
|
+
function _loadImage() {
|
|
7
|
+
_loadImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
8
|
+
var response, imageBitmap, image;
|
|
9
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
10
|
+
while (1) switch (_context.prev = _context.next) {
|
|
11
|
+
case 0:
|
|
12
|
+
if (!window.createImageBitmap) {
|
|
13
|
+
_context.next = 14;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
_context.next = 3;
|
|
17
|
+
return fetch(url);
|
|
18
|
+
case 3:
|
|
19
|
+
response = _context.sent;
|
|
20
|
+
_context.t0 = createImageBitmap;
|
|
21
|
+
_context.next = 7;
|
|
22
|
+
return response.blob();
|
|
23
|
+
case 7:
|
|
24
|
+
_context.t1 = _context.sent;
|
|
25
|
+
_context.next = 10;
|
|
26
|
+
return (0, _context.t0)(_context.t1);
|
|
27
|
+
case 10:
|
|
28
|
+
imageBitmap = _context.sent;
|
|
29
|
+
return _context.abrupt("return", imageBitmap);
|
|
30
|
+
case 14:
|
|
31
|
+
image = new window.Image();
|
|
32
|
+
return _context.abrupt("return", new Promise(function (res) {
|
|
33
|
+
image.onload = function () {
|
|
34
|
+
return res(image);
|
|
35
|
+
};
|
|
36
|
+
image.src = url;
|
|
37
|
+
image.crossOrigin = 'Anonymous';
|
|
38
|
+
}));
|
|
39
|
+
case 16:
|
|
40
|
+
case "end":
|
|
41
|
+
return _context.stop();
|
|
42
|
+
}
|
|
43
|
+
}, _callee);
|
|
44
|
+
}));
|
|
45
|
+
return _loadImage.apply(this, arguments);
|
|
46
|
+
}
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -30,7 +30,7 @@ var _multiPassRender = require("../utils/multiPassRender");
|
|
|
30
30
|
var _LayerPickService = _interopRequireDefault(require("./LayerPickService"));
|
|
31
31
|
var _TextureService = _interopRequireDefault(require("./TextureService"));
|
|
32
32
|
var _excluded = ["passes"],
|
|
33
|
-
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption"];
|
|
33
|
+
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption", "pickingEnabled"];
|
|
34
34
|
var _dec, _class, _descriptor; // @ts-ignore
|
|
35
35
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
36
36
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -113,7 +113,6 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
113
113
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", []);
|
|
114
114
|
// 数据层数据映射
|
|
115
115
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableDataEncodeStyles", []);
|
|
116
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enablg", []);
|
|
117
116
|
/**
|
|
118
117
|
* 待更新样式属性,在初始化阶段完成注册
|
|
119
118
|
*/
|
|
@@ -1188,11 +1187,11 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
1188
1187
|
value: function () {
|
|
1189
1188
|
var _buildLayerModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options) {
|
|
1190
1189
|
var _this10 = this;
|
|
1191
|
-
var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
|
|
1190
|
+
var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, _options$pickingEnabl, pickingEnabled, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
|
|
1192
1191
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
1193
1192
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1194
1193
|
case 0:
|
|
1195
|
-
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, rest = (0, _objectWithoutProperties2.default)(options, _excluded2);
|
|
1194
|
+
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, _options$pickingEnabl = options.pickingEnabled, pickingEnabled = _options$pickingEnabl === void 0 ? true : _options$pickingEnabl, rest = (0, _objectWithoutProperties2.default)(options, _excluded2);
|
|
1196
1195
|
this.shaderModuleService.registerModule(moduleName, {
|
|
1197
1196
|
vs: vertexShader,
|
|
1198
1197
|
fs: fragmentShader,
|
|
@@ -1205,6 +1204,10 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
1205
1204
|
attributes = _this10$styleAttribut.attributes,
|
|
1206
1205
|
elements = _this10$styleAttribut.elements,
|
|
1207
1206
|
count = _this10$styleAttribut.count;
|
|
1207
|
+
var uniformBuffers = [].concat((0, _toConsumableArray2.default)(_this10.layerModel.uniformBuffers), (0, _toConsumableArray2.default)(_this10.rendererService.uniformBuffers), [_this10.getLayerUniformBuffer()]);
|
|
1208
|
+
if (pickingEnabled) {
|
|
1209
|
+
uniformBuffers.push(_this10.getPickingUniformBuffer());
|
|
1210
|
+
}
|
|
1208
1211
|
var modelOptions = (0, _objectSpread2.default)({
|
|
1209
1212
|
attributes: attributes,
|
|
1210
1213
|
uniforms: uniforms,
|
|
@@ -1212,7 +1215,7 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
1212
1215
|
vs: vs,
|
|
1213
1216
|
elements: elements,
|
|
1214
1217
|
blend: _blend.BlendTypes[_l7Core.BlendType.normal],
|
|
1215
|
-
uniformBuffers:
|
|
1218
|
+
uniformBuffers: uniformBuffers,
|
|
1216
1219
|
textures: _this10.layerModel.textures
|
|
1217
1220
|
}, rest);
|
|
1218
1221
|
if (count) {
|
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
14
|
var _l7Core = require("@antv/l7-core");
|
|
@@ -26,24 +28,40 @@ var BaseLayerPickService = exports.default = /*#__PURE__*/function () {
|
|
|
26
28
|
if (layer.tileLayer) {
|
|
27
29
|
return layer.tileLayer.pickRender(target);
|
|
28
30
|
}
|
|
29
|
-
layer.hooks.beforePickingEncode.call();
|
|
30
31
|
layerService.renderTileLayerMask(layer);
|
|
31
32
|
layer.renderModels({
|
|
32
33
|
ispick: true
|
|
33
34
|
});
|
|
34
|
-
layer.hooks.afterPickingEncode.call();
|
|
35
35
|
}
|
|
36
36
|
}, {
|
|
37
37
|
key: "pick",
|
|
38
|
-
value: function
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
value: function () {
|
|
39
|
+
var _pick = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(layer, target) {
|
|
40
|
+
var container, pickingService;
|
|
41
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
container = this.layer.getContainer();
|
|
45
|
+
pickingService = container.get(_l7Core.TYPES.IPickingService);
|
|
46
|
+
if (!(layer.type === 'RasterLayer')) {
|
|
47
|
+
_context.next = 4;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
return _context.abrupt("return", this.pickRasterLayer(layer, target));
|
|
51
|
+
case 4:
|
|
52
|
+
this.pickRender(target);
|
|
53
|
+
return _context.abrupt("return", pickingService.pickFromPickingFBO(layer, target));
|
|
54
|
+
case 6:
|
|
55
|
+
case "end":
|
|
56
|
+
return _context.stop();
|
|
57
|
+
}
|
|
58
|
+
}, _callee, this);
|
|
59
|
+
}));
|
|
60
|
+
function pick(_x, _x2) {
|
|
61
|
+
return _pick.apply(this, arguments);
|
|
43
62
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
63
|
+
return pick;
|
|
64
|
+
}()
|
|
47
65
|
}, {
|
|
48
66
|
key: "pickRasterLayer",
|
|
49
67
|
value: function pickRasterLayer(layer, target, parent) {
|
|
@@ -18,10 +18,10 @@ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
|
18
18
|
var _triangulation = require("../../core/triangulation");
|
|
19
19
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
20
20
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
+
/* babel-plugin-inline-import '../shaders/grid/grid_frag.glsl' */
|
|
22
|
+
var grid_frag = "in vec4 v_color;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
21
23
|
/* babel-plugin-inline-import '../shaders/grid/grid_vert.glsl' */
|
|
22
24
|
var grid_vert = "layout(location = 0) in vec3 a_Position;\r\nlayout(location = 1) in vec4 a_Color;\r\nlayout(location = 10) in vec3 a_Pos;\r\n\r\nlayout(std140) uniform commonUniforms {\r\n vec2 u_radius;\r\n float u_opacity;\r\n float u_coverage;\r\n float u_angle;\r\n};\r\n\r\n\r\nout vec4 v_color;\r\n\r\n\r\n#pragma include \"projection\"\r\n#pragma include \"project\"\r\n#pragma include \"picking\"\r\n\r\nvoid main() {\r\n v_color = a_Color;\r\n v_color.a *= u_opacity;\r\n\r\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\r\n vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage ;\r\n // vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\r\n // vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\r\n // gl_Position = project_common_position_to_clipspace(project_pos);\r\n\r\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\r\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\r\n vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // \u5C06\u7ECF\u7EAC\u5EA6\u8F6C\u6362\u4E3A\u9AD8\u5FB72.0\u9700\u8981\u7684\u5E73\u9762\u5750\u6807\r\n vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));\r\n gl_Position = u_Mvp * (project_pos);\r\n } else {\r\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\r\n vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\r\n gl_Position = project_common_position_to_clipspace(project_pos);\r\n }\r\n\r\n setPickingColor(a_PickingColor);\r\n}\r\n";
|
|
23
|
-
/* babel-plugin-inline-import '../shaders/grid/grid_frag.glsl' */
|
|
24
|
-
var grid_frag = "in vec4 v_color;\n\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
25
25
|
var GridModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
26
26
|
(0, _inherits2.default)(GridModel, _BaseModel);
|
|
27
27
|
var _super = _createSuper(GridModel);
|
|
@@ -15,14 +15,14 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
15
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
16
|
var _l7Core = require("@antv/l7-core");
|
|
17
17
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
18
|
-
var _triangulation = require("../../core/triangulation");
|
|
19
18
|
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
19
|
+
var _triangulation = require("../../core/triangulation");
|
|
20
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
21
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
-
/* babel-plugin-inline-import '../shaders/grid3d/grid_3d_vert.glsl' */
|
|
23
|
-
var grid_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec3 a_Pos;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n\nvoid main() {\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));\n\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n \n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u7ECF\u7EAC\u5EA6\n vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // \u5C06\u7ECF\u7EAC\u5EA6\u8F6C\u6362\u4E3A\u9AD8\u5FB72.0\u9700\u8981\u7684\u5E73\u9762\u5750\u6807\n vec4 project_pos = project_position(vec4(customLnglat, a_Position.z * a_Size, 1.0));\n\n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w * u_opacity);\n \n gl_Position = u_Mvp * vec4(customLnglat , a_Position.z * a_Size, 1.0);\n } else {\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u5B9E\u9645\u7684\u7ECF\u7EAC\u5EA6\n vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n \n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n \n gl_Position = project_common_position_to_clipspace(project_pos);\n }\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
24
22
|
/* babel-plugin-inline-import '../shaders/grid3d/grid_3d_frag.glsl' */
|
|
25
|
-
var grid_3d_frag = "in vec4 v_color;\n\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
23
|
+
var grid_3d_frag = "in vec4 v_color;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
24
|
+
/* babel-plugin-inline-import '../shaders/grid3d/grid_3d_vert.glsl' */
|
|
25
|
+
var grid_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec3 a_Pos;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n \n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u7ECF\u7EAC\u5EA6\n vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // \u5C06\u7ECF\u7EAC\u5EA6\u8F6C\u6362\u4E3A\u9AD8\u5FB72.0\u9700\u8981\u7684\u5E73\u9762\u5750\u6807\n vec4 project_pos = project_position(vec4(customLnglat, a_Position.z * a_Size, 1.0));\n\n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w * u_opacity);\n \n gl_Position = u_Mvp * vec4(customLnglat , a_Position.z * a_Size, 1.0);\n } else {\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u5B9E\u9645\u7684\u7ECF\u7EAC\u5EA6\n vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n \n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n \n gl_Position = project_common_position_to_clipspace(project_pos);\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
26
|
var Grid3DModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
27
27
|
(0, _inherits2.default)(Grid3DModel, _BaseModel);
|
|
28
28
|
var _super = _createSuper(Grid3DModel);
|
|
@@ -35,11 +35,11 @@ var heatmap_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location
|
|
|
35
35
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_frag.glsl' */
|
|
36
36
|
var heatmap_frag = "uniform sampler2D u_texture; // \u70ED\u529B\u5F3A\u5EA6\u56FE\nuniform sampler2D u_colorTexture; // \u6839\u636E\u5F3A\u5EA6\u5206\u5E03\u7684\u8272\u5E26\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\nin vec2 v_texCoord;\nout vec4 outputColor;\n\n#pragma include \"scene_uniforms\"\n\nfloat getBlurIndusty() {\n float vW = 2.0/ u_ViewportSize.x;\n float vH = 2.0/ u_ViewportSize.y;\n vec2 vUv = v_texCoord;\n float i11 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 1.0 * vW, vUv.y + 1.0 * vH) ).r;\n float i12 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 0.0 * vW, vUv.y + 1.0 * vH) ).r;\n float i13 = texture(SAMPLER_2D(u_texture), vec2( vUv.x + 1.0 * vW, vUv.y + 1.0 * vH) ).r;\n\n float i21 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 1.0 * vW, vUv.y) ).r;\n float i22 = texture(SAMPLER_2D(u_texture), vec2( vUv.x , vUv.y) ).r;\n float i23 = texture(SAMPLER_2D(u_texture), vec2( vUv.x + 1.0 * vW, vUv.y) ).r;\n\n float i31 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 1.0 * vW, vUv.y-1.0*vH) ).r;\n float i32 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 0.0 * vW, vUv.y-1.0*vH) ).r;\n float i33 = texture(SAMPLER_2D(u_texture), vec2( vUv.x + 1.0 * vW, vUv.y-1.0*vH) ).r;\n\n return(\n i11 + \n i12 + \n i13 + \n i21 + \n i21 + \n i22 + \n i23 + \n i31 + \n i32 + \n i33\n )/9.0;\n}\n\n\nvoid main(){\n // float intensity = texture(u_texture, v_texCoord).r;\n float intensity = getBlurIndusty();\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(intensity, 0.0));\n outputColor = color;\n outputColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n}\n";
|
|
37
37
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_vert.glsl' */
|
|
38
|
-
var heatmap_vert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\n#pragma include \"scene_uniforms\"\n\nout vec2 v_texCoord;\nvoid main() {\n v_texCoord = a_Uv;\n\n gl_Position = vec4(a_Position.xy, 0, 1.);\n}\n";
|
|
38
|
+
var heatmap_vert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\n#pragma include \"scene_uniforms\"\n\nout vec2 v_texCoord;\nvoid main() {\n v_texCoord = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_texCoord.y = 1.0 - v_texCoord.y;\n #endif\n\n gl_Position = vec4(a_Position.xy, 0, 1.);\n}\n";
|
|
39
39
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_frag.glsl' */
|
|
40
|
-
var heatmap_framebuffer_frag = "layout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nin
|
|
40
|
+
var heatmap_framebuffer_frag = "layout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nin vec2 v_extrude;\nin float v_weight;\nout vec4 outputColor;\n#define GAUSS_COEF 0.3989422804014327\n\nvoid main(){\n float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);\n float val = v_weight * u_intensity * GAUSS_COEF * exp(d);\n outputColor = vec4(val, 1., 1., 1.);\n}\n";
|
|
41
41
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_vert.glsl' */
|
|
42
|
-
var heatmap_framebuffer_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_Dir;\n\n\nlayout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nout vec2 v_extrude;\nout float v_weight;\n\n
|
|
42
|
+
var heatmap_framebuffer_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_Dir;\n\n\nlayout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nout vec2 v_extrude;\nout float v_weight;\n\n#define GAUSS_COEF 0.3989422804014327\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main(){\n vec3 picking_color_placeholder = u_PickingColor;\n\n v_weight = a_Size;\n float ZERO = 1.0 / 255.0 / 16.0;\n float extrude_x = a_Dir.x * 2.0 -1.0;\n float extrude_y = a_Dir.y * 2.0 -1.0;\n vec2 extrude_dir = normalize(vec2(extrude_x,extrude_y));\n float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;\n v_extrude = extrude_dir * S;\n\n vec2 offset = project_pixel(v_extrude * u_radius);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n}\n";
|
|
43
43
|
var isEqual = _l7Utils.lodashUtil.isEqual;
|
|
44
44
|
var HeatMapModel = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function (_BaseModel) {
|
|
45
45
|
(0, _inherits2.default)(HeatMapModel, _BaseModel);
|
|
@@ -121,7 +121,9 @@ var HeatMapModel = exports.default = (_dec = (0, _inversify.injectable)(), _dec(
|
|
|
121
121
|
});
|
|
122
122
|
this.heatmapFramerBuffer = createFramebuffer({
|
|
123
123
|
color: this.heatmapTexture,
|
|
124
|
-
depth:
|
|
124
|
+
depth: true,
|
|
125
|
+
width: Math.floor(width / 4),
|
|
126
|
+
height: Math.floor(height / 4)
|
|
125
127
|
});
|
|
126
128
|
this.updateColorTexture();
|
|
127
129
|
return _context.abrupt("return", [this.intensityModel, this.colorModel]);
|
|
@@ -481,14 +483,16 @@ var HeatMapModel = exports.default = (_dec = (0, _inversify.injectable)(), _dec(
|
|
|
481
483
|
rampColors = _ref5.rampColors;
|
|
482
484
|
var imageData = (0, _l7Utils.generateColorRamp)(rampColors);
|
|
483
485
|
this.colorTexture = createTexture2D({
|
|
484
|
-
data:
|
|
486
|
+
data: imageData.data,
|
|
487
|
+
usage: _l7Core.TextureUsage.SAMPLED,
|
|
485
488
|
width: imageData.width,
|
|
486
489
|
height: imageData.height,
|
|
487
490
|
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
488
491
|
wrapT: _l7Core.gl.CLAMP_TO_EDGE,
|
|
489
492
|
min: _l7Core.gl.NEAREST,
|
|
490
493
|
mag: _l7Core.gl.NEAREST,
|
|
491
|
-
flipY: false
|
|
494
|
+
flipY: false,
|
|
495
|
+
unorm: true
|
|
492
496
|
});
|
|
493
497
|
this.preRampColors = rampColors;
|
|
494
498
|
}
|