@antv/l7-layers 2.22.5 → 2.22.7
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 +19 -0
- package/es/core/BaseLayer.js +56 -0
- package/es/core/interface.d.ts +4 -3
- package/es/earth/models/atmosphere.js +1 -1
- package/es/earth/models/base.js +1 -1
- package/es/earth/models/bloomsphere.js +1 -1
- package/es/earth/shaders/atmosphere/atmosphere_frag.glsl +6 -9
- package/es/earth/shaders/base/base_frag.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_frag.glsl +5 -6
- package/es/geometry/models/billboard.js +1 -1
- package/es/geometry/models/sprite.js +1 -1
- package/es/geometry/shaders/billboard_frag.glsl +4 -4
- package/es/geometry/shaders/sprite_frag.glsl +2 -4
- package/es/heatmap/models/heatmap.js +3 -3
- package/es/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +6 -7
- package/es/heatmap/shaders/heatmap/heatmap_frag.glsl +24 -36
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +5 -5
- package/es/line/models/flow.js +1 -1
- package/es/line/shaders/flow/flow_line_frag.glsl +0 -1
- package/es/plugins/LayerMaskPlugin.js +1 -1
- package/es/plugins/ShaderUniformPlugin.js +26 -8
- package/es/point/models/billboard_point.js +1 -1
- package/es/point/models/extrude.js +1 -1
- package/es/point/models/fill.js +1 -1
- package/es/point/models/image.js +1 -1
- package/es/point/models/normal.js +1 -1
- package/es/point/shaders/billboard/billboard_point_frag.glsl +6 -8
- package/es/point/shaders/extrude/extrude_frag.glsl +1 -3
- package/es/point/shaders/fill/fill_frag.glsl +14 -17
- package/es/point/shaders/image/image_frag.glsl +15 -12
- package/es/point/shaders/normal/normal_frag.glsl +1 -1
- package/es/polygon/models/extrude.js +3 -3
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/fill.js +1 -1
- package/es/polygon/models/ocean.js +1 -1
- package/es/polygon/models/water.js +1 -1
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +5 -6
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -8
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +4 -3
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +0 -2
- package/es/polygon/shaders/fill/fill_linear_frag.glsl +4 -2
- package/es/polygon/shaders/ocean/ocean_frag.glsl +212 -182
- package/es/polygon/shaders/water/polygon_water_frag.glsl +25 -20
- package/es/raster/index.js +2 -1
- package/es/raster/models/raster.js +1 -1
- package/es/raster/models/rasterRgb.js +1 -1
- package/es/raster/models/rasterTerrainRgb.js +1 -1
- package/es/raster/shaders/raster/raster_2d_frag.glsl +10 -7
- package/es/raster/shaders/rgb/raster_rgb_frag.glsl +16 -13
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -21
- package/lib/core/BaseLayer.d.ts +19 -0
- package/lib/core/BaseLayer.js +56 -0
- package/lib/core/interface.d.ts +4 -3
- package/lib/earth/models/atmosphere.js +1 -1
- package/lib/earth/models/base.js +1 -1
- package/lib/earth/models/bloomsphere.js +1 -1
- package/lib/earth/shaders/atmosphere/atmosphere_frag.glsl +6 -9
- package/lib/earth/shaders/base/base_frag.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_frag.glsl +5 -6
- package/lib/geometry/models/billboard.js +1 -1
- package/lib/geometry/models/sprite.js +1 -1
- package/lib/geometry/shaders/billboard_frag.glsl +4 -4
- package/lib/geometry/shaders/sprite_frag.glsl +2 -4
- package/lib/heatmap/models/heatmap.js +3 -3
- package/lib/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +6 -7
- package/lib/heatmap/shaders/heatmap/heatmap_frag.glsl +24 -36
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +5 -5
- package/lib/line/models/flow.js +1 -1
- package/lib/line/shaders/flow/flow_line_frag.glsl +0 -1
- package/lib/plugins/LayerMaskPlugin.js +1 -1
- package/lib/plugins/ShaderUniformPlugin.js +26 -8
- package/lib/point/models/billboard_point.js +1 -1
- package/lib/point/models/extrude.js +1 -1
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/image.js +1 -1
- package/lib/point/models/normal.js +1 -1
- package/lib/point/shaders/billboard/billboard_point_frag.glsl +6 -8
- package/lib/point/shaders/extrude/extrude_frag.glsl +1 -3
- package/lib/point/shaders/fill/fill_frag.glsl +14 -17
- package/lib/point/shaders/image/image_frag.glsl +15 -12
- package/lib/point/shaders/normal/normal_frag.glsl +1 -1
- package/lib/polygon/models/extrude.js +3 -3
- package/lib/polygon/models/extrusion.js +1 -1
- package/lib/polygon/models/fill.js +1 -1
- package/lib/polygon/models/ocean.js +1 -1
- package/lib/polygon/models/water.js +1 -1
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +5 -6
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -8
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +4 -3
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +0 -2
- package/lib/polygon/shaders/fill/fill_linear_frag.glsl +4 -2
- package/lib/polygon/shaders/ocean/ocean_frag.glsl +212 -182
- package/lib/polygon/shaders/water/polygon_water_frag.glsl +25 -20
- package/lib/raster/index.js +2 -1
- package/lib/raster/models/raster.js +1 -1
- package/lib/raster/models/rasterRgb.js +1 -1
- package/lib/raster/models/rasterTerrainRgb.js +1 -1
- package/lib/raster/shaders/raster/raster_2d_frag.glsl +10 -7
- package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +16 -13
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -21
- package/package.json +6 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
uniform sampler2D u_texture;
|
|
2
2
|
layout(std140) uniform commonUniforms {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
vec2 u_rminmax;
|
|
4
|
+
vec2 u_gminmax;
|
|
5
|
+
vec2 u_bminmax;
|
|
6
|
+
float u_opacity;
|
|
7
|
+
float u_noDataValue;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
in vec2 v_texCoord;
|
|
@@ -12,16 +12,19 @@ in vec2 v_texCoord;
|
|
|
12
12
|
out vec4 outputColor;
|
|
13
13
|
|
|
14
14
|
void main() {
|
|
15
|
+
vec3 rgb = texture(SAMPLER_2D(u_texture), vec2(v_texCoord.x, v_texCoord.y)).rgb;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if(rgb == vec3(u_noDataValue)) {
|
|
17
|
+
if (rgb == vec3(u_noDataValue)) {
|
|
19
18
|
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
20
19
|
} else {
|
|
21
|
-
outputColor = vec4(
|
|
20
|
+
outputColor = vec4(
|
|
21
|
+
rgb.r / (u_rminmax.y - u_rminmax.x),
|
|
22
|
+
rgb.g / (u_gminmax.y - u_gminmax.x),
|
|
23
|
+
rgb.b / (u_bminmax.y - u_bminmax.x),
|
|
24
|
+
u_opacity
|
|
25
|
+
);
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
if(outputColor.a < 0.01)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
+
if (outputColor.a < 0.01) discard;
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -2,42 +2,39 @@ uniform sampler2D u_texture;
|
|
|
2
2
|
uniform sampler2D u_colorTexture;
|
|
3
3
|
|
|
4
4
|
layout(std140) uniform commonUniforms {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
vec4 u_unpack;
|
|
6
|
+
vec2 u_domain;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_noDataValue;
|
|
9
|
+
float u_clampLow;
|
|
10
|
+
float u_clampHigh;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
in vec2 v_texCoord;
|
|
14
14
|
out vec4 outputColor;
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
float getElevation(vec2 coord, float bias) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
// Convert encoded elevation value to meters
|
|
18
|
+
vec4 data = texture(SAMPLER_2D(u_texture), coord, bias) * 255.0;
|
|
19
|
+
data.a = -1.0;
|
|
20
|
+
return dot(data, u_unpack);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
vec4 getColor(float value) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
float normalisedValue = (value - u_domain[0]) / (u_domain[1] - u_domain[0]);
|
|
25
|
+
vec2 coord = vec2(normalisedValue, 0);
|
|
26
|
+
return texture(SAMPLER_2D(u_colorTexture), coord);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
void main() {
|
|
31
|
-
float value = getElevation(v_texCoord,0.0);
|
|
30
|
+
float value = getElevation(v_texCoord, 0.0);
|
|
32
31
|
if (value == u_noDataValue) {
|
|
33
32
|
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
34
|
-
} else if (
|
|
35
|
-
|
|
33
|
+
} else if (u_clampLow < 0.5 && value < u_domain[0] || u_clampHigh < 0.5 && value > u_domain[1]) {
|
|
34
|
+
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
36
35
|
} else {
|
|
37
|
-
|
|
38
36
|
outputColor = getColor(value);
|
|
39
|
-
outputColor.a =
|
|
40
|
-
|
|
41
|
-
discard;
|
|
37
|
+
outputColor.a = outputColor.a * u_opacity;
|
|
38
|
+
if (outputColor.a < 0.01) discard;
|
|
42
39
|
}
|
|
43
40
|
}
|
package/lib/core/BaseLayer.d.ts
CHANGED
|
@@ -78,6 +78,9 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
78
78
|
postProcessingPassFactory: (name: string) => IPostProcessingPass<unknown>;
|
|
79
79
|
get normalPassFactory(): (name: string) => import("@antv/l7-core").IPass<unknown>;
|
|
80
80
|
protected animateOptions: IAnimateOption;
|
|
81
|
+
protected relativeOrigin: [number, number];
|
|
82
|
+
protected originalExtent: [number, number, number, number];
|
|
83
|
+
protected absoluteDataArray: IParseDataItem[];
|
|
81
84
|
/**
|
|
82
85
|
* 图层容器
|
|
83
86
|
*/
|
|
@@ -235,6 +238,22 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
235
238
|
processData(filterData: IParseDataItem[]): IParseDataItem[];
|
|
236
239
|
getModelType(): string;
|
|
237
240
|
protected getDefaultConfig(): {};
|
|
241
|
+
/**
|
|
242
|
+
* 处理相对坐标转换
|
|
243
|
+
*/
|
|
244
|
+
protected processRelativeCoordinates(): void;
|
|
245
|
+
/**
|
|
246
|
+
* 获取绝对坐标数据(用于交互计算)
|
|
247
|
+
*/
|
|
248
|
+
getAbsoluteData(): IParseDataItem[];
|
|
249
|
+
/**
|
|
250
|
+
* 获取相对坐标原点
|
|
251
|
+
*/
|
|
252
|
+
getRelativeOrigin(): [number, number];
|
|
253
|
+
/**
|
|
254
|
+
* 获取原始数据范围
|
|
255
|
+
*/
|
|
256
|
+
getOriginalExtent(): [number, number, number, number];
|
|
238
257
|
protected sourceEvent: () => void;
|
|
239
258
|
protected initLayerModels(): Promise<void>;
|
|
240
259
|
getPickingUniformBuffer(): IBuffer;
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -11,6 +11,7 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
var _asyncHook = require("@antv/async-hook");
|
|
13
13
|
var _l7Core = require("@antv/l7-core");
|
|
14
|
+
var _l7Source = require("@antv/l7-source");
|
|
14
15
|
var _l7Utils = require("@antv/l7-utils");
|
|
15
16
|
var _eventemitter = require("eventemitter3");
|
|
16
17
|
var _plugins = require("../plugins");
|
|
@@ -146,6 +147,11 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
146
147
|
(0, _defineProperty2.default)(this, "animateOptions", {
|
|
147
148
|
enable: false
|
|
148
149
|
});
|
|
150
|
+
// 相对坐标系支持
|
|
151
|
+
(0, _defineProperty2.default)(this, "relativeOrigin", [0, 0]);
|
|
152
|
+
(0, _defineProperty2.default)(this, "originalExtent", [0, 0, 0, 0]);
|
|
153
|
+
(0, _defineProperty2.default)(this, "absoluteDataArray", []);
|
|
154
|
+
// 保存绝对坐标数据用于交互
|
|
149
155
|
/**
|
|
150
156
|
* 图层容器
|
|
151
157
|
*/
|
|
@@ -172,6 +178,8 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
172
178
|
(0, _defineProperty2.default)(this, "encodeDataLength", 0);
|
|
173
179
|
(0, _defineProperty2.default)(this, "sourceEvent", () => {
|
|
174
180
|
this.dataState.dataSourceNeedUpdate = true;
|
|
181
|
+
// 处理相对坐标转换
|
|
182
|
+
this.processRelativeCoordinates();
|
|
175
183
|
const layerConfig = this.getLayerConfig();
|
|
176
184
|
if (layerConfig && layerConfig.autoFit) {
|
|
177
185
|
this.fitBounds(layerConfig.fitBoundsOptions);
|
|
@@ -937,6 +945,9 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
937
945
|
// source 初始化不需要处理
|
|
938
946
|
this.sourceEvent();
|
|
939
947
|
}
|
|
948
|
+
if (type === 'inited') {
|
|
949
|
+
this.processRelativeCoordinates();
|
|
950
|
+
}
|
|
940
951
|
});
|
|
941
952
|
}
|
|
942
953
|
getSource() {
|
|
@@ -1221,6 +1232,51 @@ class BaseLayer extends _eventemitter.EventEmitter {
|
|
|
1221
1232
|
getDefaultConfig() {
|
|
1222
1233
|
return {};
|
|
1223
1234
|
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* 处理相对坐标转换
|
|
1238
|
+
*/
|
|
1239
|
+
processRelativeCoordinates() {
|
|
1240
|
+
const layerConfig = this.getLayerConfig();
|
|
1241
|
+
const enableRelativeCoordinates = layerConfig.enableRelativeCoordinates;
|
|
1242
|
+
if (!enableRelativeCoordinates || !this.layerSource || !this.layerSource.data) {
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// 保存原始绝对坐标数据用于交互
|
|
1247
|
+
this.absoluteDataArray = [...this.layerSource.data.dataArray];
|
|
1248
|
+
|
|
1249
|
+
// 处理相对坐标转换
|
|
1250
|
+
const result = (0, _l7Source.processRelativeCoordinates)(this.layerSource.data.dataArray, {
|
|
1251
|
+
enableRelativeCoordinates: true
|
|
1252
|
+
});
|
|
1253
|
+
|
|
1254
|
+
// 更新source数据为相对坐标
|
|
1255
|
+
this.layerSource.data.dataArray = result.dataArray;
|
|
1256
|
+
this.relativeOrigin = result.relativeOrigin;
|
|
1257
|
+
this.originalExtent = result.originalExtent;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* 获取绝对坐标数据(用于交互计算)
|
|
1262
|
+
*/
|
|
1263
|
+
getAbsoluteData() {
|
|
1264
|
+
return this.absoluteDataArray;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* 获取相对坐标原点
|
|
1269
|
+
*/
|
|
1270
|
+
getRelativeOrigin() {
|
|
1271
|
+
return this.relativeOrigin;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* 获取原始数据范围
|
|
1276
|
+
*/
|
|
1277
|
+
getOriginalExtent() {
|
|
1278
|
+
return this.originalExtent;
|
|
1279
|
+
}
|
|
1224
1280
|
initLayerModels() {
|
|
1225
1281
|
var _this5 = this;
|
|
1226
1282
|
return (0, _asyncToGenerator2.default)(function* () {
|
package/lib/core/interface.d.ts
CHANGED
|
@@ -26,11 +26,12 @@ export interface IBaseLayerStyleOptions {
|
|
|
26
26
|
zIndex?: number;
|
|
27
27
|
mask?: boolean;
|
|
28
28
|
maskInside?: boolean;
|
|
29
|
+
enableRelativeCoordinates?: boolean;
|
|
29
30
|
color?: string;
|
|
30
31
|
size?: number;
|
|
31
32
|
}
|
|
32
33
|
export interface ILineLayerStyleOptions extends IBaseLayerStyleOptions {
|
|
33
|
-
|
|
34
|
+
relativeOrigin?: number[];
|
|
34
35
|
coord?: string;
|
|
35
36
|
lineType?: keyof typeof lineStyleType;
|
|
36
37
|
dashArray?: [number, number];
|
|
@@ -63,7 +64,7 @@ export declare enum SizeUnitType {
|
|
|
63
64
|
meter = 1
|
|
64
65
|
}
|
|
65
66
|
export interface IPointLayerStyleOptions extends IBaseLayerStyleOptions {
|
|
66
|
-
|
|
67
|
+
relativeOrigin?: number[];
|
|
67
68
|
coord?: string;
|
|
68
69
|
strokeOpacity: number;
|
|
69
70
|
strokeWidth: number;
|
|
@@ -95,7 +96,7 @@ export interface IPointLayerStyleOptions extends IBaseLayerStyleOptions {
|
|
|
95
96
|
sourceLayer?: string;
|
|
96
97
|
}
|
|
97
98
|
export interface IPolygonLayerStyleOptions extends IBaseLayerStyleOptions {
|
|
98
|
-
|
|
99
|
+
relativeOrigin?: number[];
|
|
99
100
|
coord?: string;
|
|
100
101
|
opacityLinear?: {
|
|
101
102
|
enable: boolean;
|
|
@@ -11,7 +11,7 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
12
|
var _triangulation = require("../../core/triangulation");
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/atmosphere/atmosphere_frag.glsl' */
|
|
14
|
-
const atmoSphereFrag = "
|
|
14
|
+
const atmoSphereFrag = "layout(std140) uniform commonUniforms {\n float u_opacity;\n};\nin vec3 vVertexNormal;\nin float v_offset;\nin vec4 v_Color;\n\n#pragma include \"scene_uniforms\"\nout vec4 outputColor;\nvoid main() {\n // float intensity = pow(0.5 + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);\n float intensity = pow(v_offset + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);\n // \u53BB\u9664\u80CC\u9762\n if (intensity > 1.0) intensity = 0.0;\n\n outputColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/atmosphere/atmosphere_vert.glsl' */
|
|
16
16
|
const atmoSphereVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\n\n#pragma include \"scene_uniforms\"\nout vec3 vVertexNormal;\nout vec4 v_Color;\nout float v_offset;\n\nvoid main() {\n float EARTH_RADIUS = 100.0;\n\n v_Color = a_Color;\n\n v_offset = min(((length(u_CameraPosition) - EARTH_RADIUS)/600.0) * 0.5 + 0.4, 1.0);\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
|
|
17
17
|
const {
|
package/lib/earth/models/base.js
CHANGED
|
@@ -11,7 +11,7 @@ var _l7Core = require("@antv/l7-core");
|
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
12
|
var _triangulation = require("../../core/triangulation");
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/base/base_frag.glsl' */
|
|
14
|
-
const baseFrag = "uniform sampler2D u_texture;\n\nin vec2 v_texCoord;\nin float v_lightWeight;\nout vec4 outputColor;\n\nvoid main() {\n
|
|
14
|
+
const baseFrag = "uniform sampler2D u_texture;\n\nin vec2 v_texCoord;\nin float v_lightWeight;\nout vec4 outputColor;\n\nvoid main() {\n vec4 color = texture(SAMPLER_2D(u_texture), vec2(v_texCoord.x, v_texCoord.y));\n color.xyz = color.xyz * v_lightWeight;\n outputColor = color;\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/base/base_vert.glsl' */
|
|
16
16
|
const baseVert = "// attribute vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\n// attribute vec2 a_Extrude;\n// attribute float a_Size;\n// attribute float a_Shape;\n\nlayout(std140) uniform commonUniforms {\n\tvec4 u_sunLight: [1.0, -10.5, 12.0,0.0];\n\tfloat u_ambientRatio : 0.5;\n\tfloat u_diffuseRatio : 0.3;\n\tfloat u_specularRatio : 0.2;\n};\n\n#pragma include \"scene_uniforms\"\n\nout vec2 v_texCoord;\nout float v_lightWeight;\n\nfloat calc_lighting(vec4 pos) {\n\n\tvec3 worldPos = vec3(pos * u_ModelMatrix);\n\n\tvec3 worldNormal = a_Normal;\n\n\t// cal light weight\n\tvec3 viewDir = normalize(u_CameraPosition - worldPos);\n\n\tvec3 lightDir = normalize(u_sunLight.xyz);\n\n\tvec3 halfDir = normalize(viewDir+lightDir);\n\t// lambert\n\tfloat lambert = dot(worldNormal, lightDir);\n\t// specular\n\tfloat specular = pow(max(0.0, dot(worldNormal, halfDir)), 32.0);\n\t//sum to light weight\n\tfloat lightWeight = u_ambientRatio + u_diffuseRatio * lambert + u_specularRatio * specular;\n\n\treturn lightWeight;\n}\n\nvoid main() {\n\n\tv_texCoord = a_Uv;\n\n\tfloat lightWeight = calc_lighting(vec4(a_Position, 1.0));\n\tv_lightWeight = lightWeight;\n\n\tgl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
|
|
17
17
|
class BaseEarthModel extends _BaseModel.default {
|
|
@@ -11,7 +11,7 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
12
|
var _triangulation = require("../../core/triangulation");
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/bloomshpere/bloomsphere_frag.glsl' */
|
|
14
|
-
const bloomSphereFrag = "
|
|
14
|
+
const bloomSphereFrag = "in vec3 vVertexNormal;\nin vec4 v_Color;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\nout vec4 outputColor;\n#pragma include \"scene_uniforms\"\nvoid main() {\n float intensity = -dot(normalize(vVertexNormal), normalize(u_CameraPosition));\n // \u53BB\u9664\u80CC\u9762\n if (intensity > 1.0) intensity = 0.0;\n\n outputColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/bloomshpere/bloomsphere_vert.glsl' */
|
|
16
16
|
const bloomSphereVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n};\n#pragma include \"scene_uniforms\"\n\nout vec3 vVertexNormal;\nout vec4 v_Color;\n\nvoid main() {\n v_Color = a_Color;\n\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
|
|
17
17
|
const {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
layout(std140) uniform commonUniforms {
|
|
3
|
-
|
|
2
|
+
float u_opacity;
|
|
4
3
|
};
|
|
5
4
|
in vec3 vVertexNormal;
|
|
6
5
|
in float v_offset;
|
|
@@ -9,12 +8,10 @@ in vec4 v_Color;
|
|
|
9
8
|
#pragma include "scene_uniforms"
|
|
10
9
|
out vec4 outputColor;
|
|
11
10
|
void main() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// 去除背面
|
|
17
|
-
if(intensity > 1.0) intensity = 0.0;
|
|
11
|
+
// float intensity = pow(0.5 + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);
|
|
12
|
+
float intensity = pow(v_offset + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);
|
|
13
|
+
// 去除背面
|
|
14
|
+
if (intensity > 1.0) intensity = 0.0;
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
outputColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);
|
|
20
17
|
}
|
|
@@ -5,7 +5,7 @@ in float v_lightWeight;
|
|
|
5
5
|
out vec4 outputColor;
|
|
6
6
|
|
|
7
7
|
void main() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
vec4 color = texture(SAMPLER_2D(u_texture), vec2(v_texCoord.x, v_texCoord.y));
|
|
9
|
+
color.xyz = color.xyz * v_lightWeight;
|
|
10
|
+
outputColor = color;
|
|
11
11
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
in vec3 vVertexNormal;
|
|
3
2
|
in vec4 v_Color;
|
|
4
3
|
|
|
5
4
|
layout(std140) uniform commonUniforms {
|
|
6
|
-
|
|
5
|
+
float u_opacity;
|
|
7
6
|
};
|
|
8
7
|
out vec4 outputColor;
|
|
9
8
|
#pragma include "scene_uniforms"
|
|
10
9
|
void main() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
float intensity = -dot(normalize(vVertexNormal), normalize(u_CameraPosition));
|
|
11
|
+
// 去除背面
|
|
12
|
+
if (intensity > 1.0) intensity = 0.0;
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
outputColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);
|
|
16
15
|
}
|
|
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _l7Core = require("@antv/l7-core");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/billboard_frag.glsl' */
|
|
14
|
-
const planeFrag = "layout(std140) uniform commonUniforms {\n
|
|
14
|
+
const planeFrag = "layout(std140) uniform commonUniforms {\n vec2 u_size;\n float u_raisingHeight;\n float u_rotation;\n float u_opacity;\n};\n\nuniform sampler2D u_texture;\n\nin vec2 v_uv;\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_texture), vec2(v_uv.x, 1.0 - v_uv.y));\n outputColor.a *= u_opacity;\n outputColor = filterColor(outputColor);\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/billboard_vert.glsl' */
|
|
16
16
|
const planeVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_size;\n float u_raisingHeight;\n float u_rotation;\n float u_opacity;\n};\n\nout vec2 v_uv;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = a_Uv;\n float raiseHeight = u_raisingHeight;\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n // \u8BA1\u7B97\u7ECF\u7EAC\u5EA6\u70B9\u4F4D\u5750\u6807\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // \u8BA1\u7B97\u7ED5 z \u8F74\u65CB\u8F6C\u540E\u7684\u504F\u79FB\n vec2 offsetXY = project_pixel(rotate_matrix(vec2(extrude.x * u_size.x, 0.0), u_rotation));\n // \u7ED5 z \u8F74\u65CB\u8F6C\n float x = project_pos.x + offsetXY.x;\n float y = project_pos.y + offsetXY.y;\n // z \u8F74\u4E0D\u53C2\u4E0E\u65CB\u8F6C\n float z = project_pixel(extrude.y * u_size.y + raiseHeight);\n\n gl_Position = project_common_position_to_clipspace(vec4(x, y, z, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
17
17
|
class BillBoardModel extends _BaseModel.default {
|
|
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _l7Core = require("@antv/l7-core");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/sprite_frag.glsl' */
|
|
14
|
-
const spriteFrag = "
|
|
14
|
+
const spriteFrag = "layout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_Scale;\n};\nuniform sampler2D u_texture;\n\nin vec3 v_Color;\nin float v_d;\nout vec4 outputColor;\n\nvoid main() {\n if (v_d < 0.0) {\n discard;\n }\n\n if (u_mapFlag > 0.0) {\n outputColor = texture(SAMPLER_2D(u_texture), gl_PointCoord);\n outputColor.a *= u_opacity;\n } else {\n outputColor = vec4(v_Color, u_opacity);\n }\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/sprite_vert.glsl' */
|
|
16
16
|
const spriteVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec3 a_Color;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_Scale;\n};\n\nout vec3 v_Color;\nout float v_d;\n\n#pragma include \"projection\"\nvoid main() {\n v_Color = a_Color.xyz;\n v_d = a_Position.z;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n gl_PointSize = pow(u_Zoom - 1.0, 2.0) * u_Scale;\n}\n";
|
|
17
17
|
var SPRITE_ANIMATE_DIR = /*#__PURE__*/function (SPRITE_ANIMATE_DIR) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
layout(std140) uniform commonUniforms {
|
|
3
2
|
float u_opacity;
|
|
4
3
|
float u_mapFlag;
|
|
@@ -11,12 +10,11 @@ in float v_d;
|
|
|
11
10
|
out vec4 outputColor;
|
|
12
11
|
|
|
13
12
|
void main() {
|
|
14
|
-
|
|
15
|
-
if(v_d < 0.0) {
|
|
13
|
+
if (v_d < 0.0) {
|
|
16
14
|
discard;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
if(u_mapFlag > 0.0) {
|
|
17
|
+
if (u_mapFlag > 0.0) {
|
|
20
18
|
outputColor = texture(SAMPLER_2D(u_texture), gl_PointCoord);
|
|
21
19
|
outputColor.a *= u_opacity;
|
|
22
20
|
} else {
|
|
@@ -15,15 +15,15 @@ var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
|
15
15
|
var _triangulation = require("../../core/triangulation");
|
|
16
16
|
var _triangulation2 = require("../triangulation");
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_3d_frag.glsl' */
|
|
18
|
-
const heatmap_3d_frag = "layout(std140) uniform commonUniforms {\n mat4 u_ViewProjectionMatrixUncentered;\n mat4 u_InverseViewProjectionMatrix;\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\nin float v_intensity;\nout vec4 outputColor;\n\nvoid main(){\n
|
|
18
|
+
const heatmap_3d_frag = "layout(std140) uniform commonUniforms {\n mat4 u_ViewProjectionMatrixUncentered;\n mat4 u_InverseViewProjectionMatrix;\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\nin float v_intensity;\nout vec4 outputColor;\n\nvoid main() {\n float intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(intensity, 0));\n outputColor = color;\n // gl_FragColor.a = color.a * smoothstep(0.1,0.2,intensity)* u_opacity;\n outputColor.a = color.a * smoothstep(0.0, 0.1, intensity) * u_opacity;\n}\n";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_3d_vert.glsl' */
|
|
20
20
|
const heatmap_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 10) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n mat4 u_ViewProjectionMatrixUncentered;\n mat4 u_InverseViewProjectionMatrix;\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nout vec2 v_texCoord;\nout float v_intensity;\n\nvec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {\n float t2 = t * t;\n float one_minus_t = 1.0 - t;\n float one_minus_t2 = one_minus_t * one_minus_t;\n return P0 * one_minus_t2 * one_minus_t +\n P1 * 3.0 * t * one_minus_t2 +\n P2 * 3.0 * t2 * one_minus_t +\n P3 * t2 * t;\n}\nvec2 toBezier(float t, vec4 p) {\n return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));\n}\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_texCoord = a_Uv;\n\n vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // \u5C06\u539F\u672C 0 -> 1 \u7684 uv \u8F6C\u6362\u4E3A -1 -> 1 \u7684\u6807\u51C6\u5750\u6807\u7A7A\u95F4\uFF08NDC\uFF09\n\n vec4 p1 = vec4(pos, 0.0, 1.0); // x/y \u5E73\u9762\u4E0A\u7684\u70B9\uFF08z == 0\uFF09\u53EF\u4EE5\u8BA4\u4E3A\u662F\u4E09\u7EF4\u4E0A\u7684\u70B9\u88AB\u6295\u5F71\u5230\u5E73\u9762\u540E\u7684\u70B9\n vec4 p2 = vec4(pos, 1.0, 1.0); // \u5E73\u884C\u4E8Ex/y\u5E73\u9762\u3001z==1 \u7684\u5E73\u9762\u4E0A\u7684\u70B9\n\n vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // \u6839\u636E\u89C6\u56FE\u6295\u5F71\u77E9\u9635\u7684\u9006\u77E9\u9635\u5E73\u9762\u4E0A\u7684\u53CD\u7B97\u51FA\u4E09\u7EF4\u7A7A\u95F4\u4E2D\u7684\u70B9\uFF08p1\u5E73\u9762\u4E0A\u7684\u70B9\uFF09\n vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;\n\n inverseP1 = inverseP1 / inverseP1.w; // \u5F52\u4E00\u5316\u64CD\u4F5C\uFF08\u5F52\u4E00\u5316\u540E\u4E3A\u4E16\u754C\u5750\u6807\uFF09\n inverseP2 = inverseP2 / inverseP2.w;\n\n float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??\n vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);\n\n vec4 b = vec4(0.5, 0.0, 1.0, 0.5);\n float fh;\n\n v_intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;\n fh = toBezier(v_intensity, b).y;\n gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.0), 1.0);\n\n}\n"; // 绘制平面热力的 shader
|
|
21
21
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_frag.glsl' */
|
|
22
|
-
const heatmap_frag = "uniform sampler2D u_texture;
|
|
22
|
+
const 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 (i11 + i12 + i13 + i21 + i21 + i22 + i23 + i31 + i32 + i33) / 9.0;\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, 0.1, intensity) * u_opacity;\n}\n";
|
|
23
23
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_vert.glsl' */
|
|
24
24
|
const heatmap_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 10) 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.0);\n}\n";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_frag.glsl' */
|
|
26
|
-
const 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
|
|
26
|
+
const 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.0, 1.0, 1.0);\n}\n";
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_vert.glsl' */
|
|
28
28
|
const heatmap_framebuffer_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_DIR) in vec2 a_Dir;\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}\n";
|
|
29
29
|
const {
|
|
@@ -14,11 +14,10 @@ in vec2 v_texCoord;
|
|
|
14
14
|
in float v_intensity;
|
|
15
15
|
out vec4 outputColor;
|
|
16
16
|
|
|
17
|
-
void main(){
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
outputColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;
|
|
17
|
+
void main() {
|
|
18
|
+
float intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;
|
|
19
|
+
vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(intensity, 0));
|
|
20
|
+
outputColor = color;
|
|
21
|
+
// gl_FragColor.a = color.a * smoothstep(0.1,0.2,intensity)* u_opacity;
|
|
22
|
+
outputColor.a = color.a * smoothstep(0.0, 0.1, intensity) * u_opacity;
|
|
24
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
uniform sampler2D u_texture;
|
|
2
|
-
uniform sampler2D u_colorTexture;
|
|
1
|
+
uniform sampler2D u_texture; // 热力强度图
|
|
2
|
+
uniform sampler2D u_colorTexture; // 根据强度分布的色带
|
|
3
3
|
|
|
4
4
|
layout(std140) uniform commonUniforms {
|
|
5
5
|
float u_opacity;
|
|
@@ -13,40 +13,28 @@ out vec4 outputColor;
|
|
|
13
13
|
#pragma include "scene_uniforms"
|
|
14
14
|
|
|
15
15
|
float getBlurIndusty() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
i11 +
|
|
33
|
-
i12 +
|
|
34
|
-
i13 +
|
|
35
|
-
i21 +
|
|
36
|
-
i21 +
|
|
37
|
-
i22 +
|
|
38
|
-
i23 +
|
|
39
|
-
i31 +
|
|
40
|
-
i32 +
|
|
41
|
-
i33
|
|
42
|
-
)/9.0;
|
|
16
|
+
float vW = 2.0 / u_ViewportSize.x;
|
|
17
|
+
float vH = 2.0 / u_ViewportSize.y;
|
|
18
|
+
vec2 vUv = v_texCoord;
|
|
19
|
+
float i11 = texture(SAMPLER_2D(u_texture), vec2(vUv.x - 1.0 * vW, vUv.y + 1.0 * vH)).r;
|
|
20
|
+
float i12 = texture(SAMPLER_2D(u_texture), vec2(vUv.x - 0.0 * vW, vUv.y + 1.0 * vH)).r;
|
|
21
|
+
float i13 = texture(SAMPLER_2D(u_texture), vec2(vUv.x + 1.0 * vW, vUv.y + 1.0 * vH)).r;
|
|
22
|
+
|
|
23
|
+
float i21 = texture(SAMPLER_2D(u_texture), vec2(vUv.x - 1.0 * vW, vUv.y)).r;
|
|
24
|
+
float i22 = texture(SAMPLER_2D(u_texture), vec2(vUv.x, vUv.y)).r;
|
|
25
|
+
float i23 = texture(SAMPLER_2D(u_texture), vec2(vUv.x + 1.0 * vW, vUv.y)).r;
|
|
26
|
+
|
|
27
|
+
float i31 = texture(SAMPLER_2D(u_texture), vec2(vUv.x - 1.0 * vW, vUv.y - 1.0 * vH)).r;
|
|
28
|
+
float i32 = texture(SAMPLER_2D(u_texture), vec2(vUv.x - 0.0 * vW, vUv.y - 1.0 * vH)).r;
|
|
29
|
+
float i33 = texture(SAMPLER_2D(u_texture), vec2(vUv.x + 1.0 * vW, vUv.y - 1.0 * vH)).r;
|
|
30
|
+
|
|
31
|
+
return (i11 + i12 + i13 + i21 + i21 + i22 + i23 + i31 + i32 + i33) / 9.0;
|
|
43
32
|
}
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
outputColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;
|
|
34
|
+
void main() {
|
|
35
|
+
// float intensity = texture(u_texture, v_texCoord).r;
|
|
36
|
+
float intensity = getBlurIndusty();
|
|
37
|
+
vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(intensity, 0.0));
|
|
38
|
+
outputColor = color;
|
|
39
|
+
outputColor.a = color.a * smoothstep(0.0, 0.1, intensity) * u_opacity;
|
|
52
40
|
}
|
|
@@ -8,10 +8,10 @@ layout(std140) uniform commonUniforms {
|
|
|
8
8
|
in vec2 v_extrude;
|
|
9
9
|
in float v_weight;
|
|
10
10
|
out vec4 outputColor;
|
|
11
|
-
#define GAUSS_COEF
|
|
11
|
+
#define GAUSS_COEF (0.3989422804014327)
|
|
12
12
|
|
|
13
|
-
void main(){
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
void main() {
|
|
14
|
+
float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);
|
|
15
|
+
float val = v_weight * u_intensity * GAUSS_COEF * exp(d);
|
|
16
|
+
outputColor = vec4(val, 1.0, 1.0, 1.0);
|
|
17
17
|
}
|
package/lib/line/models/flow.js
CHANGED
|
@@ -11,7 +11,7 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
12
|
var _line_trangluation = require("../../core/line_trangluation");
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
|
|
14
|
-
const flow_line_frag = "// #extension GL_OES_standard_derivatives : enable\n\nin vec4 v_color;\nout vec4 outputColor;\n\n
|
|
14
|
+
const flow_line_frag = "// #extension GL_OES_standard_derivatives : enable\n\nin vec4 v_color;\nout vec4 outputColor;\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
|
|
16
16
|
const flow_line_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniorm {\n float u_gap_width: 1.0;\n float u_stroke_width: 1.0;\n float u_stroke_opacity: 1.0;\n};\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nout vec4 v_color;\n\nvec2 project_pixel_offset(vec2 offsets) {\n vec2 data = project_pixel(offsets);\n\n return vec2(data.x, -data.y);\n}\n\nvec2 line_dir(vec2 target, vec2 source) {\n return normalize(ProjectFlat(target) - ProjectFlat(source));\n}\n\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source_world = a_Instance.rg; // \u8D77\u70B9\n vec2 target_world = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = line_dir(target_world, source_world);\n vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);\n\n vec2 position = mix(source_world, target_world, a_Position.x);\n vec2 position64Low = mix(a_Instance64Low.rg, a_Instance64Low.ba, a_Position.x);\n\n float lengthCommon = length(\n project_position(vec4(target_world, 0, 1)) - project_position(vec4(source_world, 0, 1))\n );\n vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || \u9AD8\u5FB7\n vec2 limitedOffsetDistances = clamp(\n offsetDistances,\n project_pixel(-lengthCommon * 0.2),\n project_pixel(lengthCommon * 0.2)\n );\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon * 0.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon * 0.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y));\n\n float gapCommon = -1. * project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0), position64Low);\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
17
17
|
class FlowLineModel extends _BaseModel.default {
|