@antv/l7-layers 2.20.14 → 2.20.16
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/TextureService.js +2 -1
- package/es/plugins/ShaderUniformPlugin.js +13 -9
- package/es/raster/models/raster.js +6 -5
- package/es/raster/models/rasterRgb.js +3 -2
- package/es/raster/models/rasterTerrainRgb.js +2 -2
- package/es/raster/shaders/raster/raster_2d_frag.glsl +3 -3
- package/es/raster/shaders/raster/raster_2d_vert.glsl +2 -2
- package/es/raster/shaders/rgb/raster_rgb_frag.glsl +1 -0
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +3 -3
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +6 -7
- package/es/tile/core/BaseLayer.js +7 -7
- package/lib/core/TextureService.js +2 -1
- package/lib/plugins/ShaderUniformPlugin.js +13 -9
- package/lib/raster/models/raster.js +6 -5
- package/lib/raster/models/rasterRgb.js +3 -2
- package/lib/raster/models/rasterTerrainRgb.js +2 -2
- package/lib/raster/shaders/raster/raster_2d_frag.glsl +3 -3
- package/lib/raster/shaders/raster/raster_2d_vert.glsl +2 -2
- package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +1 -0
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +3 -3
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +6 -7
- package/lib/tile/core/BaseLayer.js +7 -7
- package/package.json +7 -7
|
@@ -75,15 +75,19 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
75
75
|
data: data
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
|
|
79
|
+
// For WebGL1. regl
|
|
80
|
+
var platformString = _this.rendererService.queryVerdorInfo();
|
|
81
|
+
if (platformString === 'WebGL1') {
|
|
82
|
+
layer.models.forEach(function (model) {
|
|
83
|
+
model.addUniforms(_objectSpread(_objectSpread({}, uniforms), {}, {
|
|
84
|
+
// TODO: move these 2 uniforms to PixelPickingPlugin
|
|
85
|
+
u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
|
|
86
|
+
// Tip: 当前地图是否在拖动
|
|
87
|
+
u_shaderPick: Number(layer.getShaderPickStat())
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
|
|
@@ -14,9 +14,9 @@ import BaseModel from "../../core/BaseModel";
|
|
|
14
14
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
15
15
|
import { RasterImageTriangulation } from "../../core/triangulation";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/raster/raster_2d_frag.glsl' */
|
|
17
|
-
var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n
|
|
17
|
+
var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n float u_clampLow;\n float u_clampHigh;\n};\n\nuniform sampler2D u_rasterTexture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\n\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\nout vec4 outputColor;\n\nvoid main() {\n // Can use any component here since u_rasterTexture is under luminance format.\n float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value)) {\n discard;\n } else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {\n discard;\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(normalisedValue, 0));\n \n outputColor = color;\n outputColor.a = outputColor.a * u_opacity ;\n if (outputColor.a < 0.01)\n discard;\n }\n}\n";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/raster/raster_2d_vert.glsl' */
|
|
19
|
-
var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n
|
|
19
|
+
var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n float u_clampLow;\n float u_clampHigh;\n};\n\nout vec2 v_texCoord;\n\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";
|
|
20
20
|
var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
21
21
|
_inherits(RasterModel, _BaseModel);
|
|
22
22
|
var _super = _createSuper(RasterModel);
|
|
@@ -52,8 +52,8 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
52
52
|
u_domain: newdomain,
|
|
53
53
|
u_opacity: opacity || 1,
|
|
54
54
|
u_noDataValue: noDataValue,
|
|
55
|
-
u_clampLow: clampLow,
|
|
56
|
-
u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
|
|
55
|
+
u_clampLow: clampLow ? 1 : 0,
|
|
56
|
+
u_clampHigh: (typeof clampHigh !== 'undefined' ? clampHigh : clampLow) ? 1 : 0,
|
|
57
57
|
u_rasterTexture: this.texture,
|
|
58
58
|
u_colorTexture: this.colorTexture
|
|
59
59
|
};
|
|
@@ -161,7 +161,8 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
161
161
|
primitive: gl.TRIANGLES,
|
|
162
162
|
depth: {
|
|
163
163
|
enable: false
|
|
164
|
-
}
|
|
164
|
+
},
|
|
165
|
+
pickingEnabled: false
|
|
165
166
|
});
|
|
166
167
|
case 13:
|
|
167
168
|
model = _context3.sent;
|
|
@@ -18,7 +18,7 @@ import BaseModel from "../../core/BaseModel";
|
|
|
18
18
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
19
19
|
import { RasterImageTriangulation } from "../../core/triangulation";
|
|
20
20
|
/* babel-plugin-inline-import '../shaders/rgb/raster_rgb_frag.glsl' */
|
|
21
|
-
var rasterFrag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n vec2 u_rminmax;\n vec2 u_gminmax;\n vec2 u_bminmax;\n float u_opacity;\n float u_noDataValue;\n};\n\nin vec2 v_texCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n\n vec3 rgb = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y)).rgb;\n\n if(rgb == vec3(u_noDataValue)) {\n outputColor = vec4(0.0, 0, 0, 0.0);\n } else {\n outputColor = vec4(rgb.r / (u_rminmax.y -u_rminmax.x), rgb.g /(u_gminmax.y -u_gminmax.x), rgb.b/ (u_bminmax.y - u_bminmax.x), u_opacity);\n }\n if(outputColor.a < 0.01)\n discard;\n \n}";
|
|
21
|
+
var rasterFrag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n vec2 u_rminmax;\n vec2 u_gminmax;\n vec2 u_bminmax;\n float u_opacity;\n float u_noDataValue;\n};\n\nin vec2 v_texCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n\n vec3 rgb = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y)).rgb;\n\n if(rgb == vec3(u_noDataValue)) {\n outputColor = vec4(0.0, 0, 0, 0.0);\n } else {\n outputColor = vec4(rgb.r / (u_rminmax.y -u_rminmax.x), rgb.g /(u_gminmax.y -u_gminmax.x), rgb.b/ (u_bminmax.y - u_bminmax.x), u_opacity);\n }\n\n if(outputColor.a < 0.01)\n discard;\n \n}";
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/rgb/raster_rgb_vert.glsl' */
|
|
23
23
|
var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_rminmax;\n vec2 u_gminmax;\n vec2 u_bminmax;\n float u_opacity;\n float u_noDataValue;\n};\n\nout vec2 v_texCoord;\n\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";
|
|
24
24
|
var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
@@ -152,7 +152,8 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
152
152
|
primitive: gl.TRIANGLES,
|
|
153
153
|
depth: {
|
|
154
154
|
enable: false
|
|
155
|
-
}
|
|
155
|
+
},
|
|
156
|
+
pickingEnabled: false
|
|
156
157
|
});
|
|
157
158
|
case 13:
|
|
158
159
|
model = _context2.sent;
|
|
@@ -13,9 +13,9 @@ import BaseModel from "../../core/BaseModel";
|
|
|
13
13
|
import { RasterImageTriangulation } from "../../core/triangulation";
|
|
14
14
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_frag.glsl' */
|
|
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
|
|
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 float u_clampLow;\n float 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 < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && 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";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_vert.glsl' */
|
|
18
|
-
var Raster_terrainVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n
|
|
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 float u_clampLow;\n float u_clampHigh;\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";
|
|
19
19
|
var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
20
20
|
_inherits(RasterTerrainRGB, _BaseModel);
|
|
21
21
|
var _super = _createSuper(RasterTerrainRGB);
|
|
@@ -2,8 +2,8 @@ layout(std140) uniform commonUniforms {
|
|
|
2
2
|
vec2 u_domain;
|
|
3
3
|
float u_opacity;
|
|
4
4
|
float u_noDataValue;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
float u_clampLow;
|
|
6
|
+
float u_clampHigh;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
uniform sampler2D u_rasterTexture;
|
|
@@ -20,7 +20,7 @@ void main() {
|
|
|
20
20
|
float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;
|
|
21
21
|
if (value == u_noDataValue || isnan_emu(value)) {
|
|
22
22
|
discard;
|
|
23
|
-
} else if ((
|
|
23
|
+
} else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {
|
|
24
24
|
discard;
|
|
25
25
|
} else {
|
|
26
26
|
float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);
|
|
@@ -6,8 +6,8 @@ layout(std140) uniform commonUniforms {
|
|
|
6
6
|
vec2 u_domain;
|
|
7
7
|
float u_opacity;
|
|
8
8
|
float u_noDataValue;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
float u_clampLow;
|
|
10
|
+
float u_clampHigh;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
in vec2 v_texCoord;
|
|
@@ -31,7 +31,7 @@ void main() {
|
|
|
31
31
|
float value = getElevation(v_texCoord,0.0);
|
|
32
32
|
if (value == u_noDataValue) {
|
|
33
33
|
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
34
|
-
} else if ((
|
|
34
|
+
} else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {
|
|
35
35
|
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
36
36
|
} else {
|
|
37
37
|
|
|
@@ -2,13 +2,12 @@ layout(location = 0) in vec3 a_Position;
|
|
|
2
2
|
layout(location = 14) in vec2 a_Uv;
|
|
3
3
|
|
|
4
4
|
layout(std140) uniform commonUniforms {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
vec4 u_unpack;
|
|
6
|
+
vec2 u_domain;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_noDataValue;
|
|
9
|
+
float u_clampLow;
|
|
10
|
+
float u_clampHigh;
|
|
12
11
|
};
|
|
13
12
|
out vec2 v_texCoord;
|
|
14
13
|
#pragma include "projection"
|
|
@@ -204,7 +204,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
204
204
|
value: function () {
|
|
205
205
|
var _tileUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
206
206
|
var _this3 = this;
|
|
207
|
-
var minZoom, maxZoom;
|
|
207
|
+
var minZoom, maxZoom, tiles;
|
|
208
208
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
209
209
|
while (1) switch (_context2.prev = _context2.next) {
|
|
210
210
|
case 0:
|
|
@@ -216,8 +216,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
216
216
|
case 2:
|
|
217
217
|
minZoom = this.parent.getMinZoom();
|
|
218
218
|
maxZoom = this.parent.getMaxZoom();
|
|
219
|
-
|
|
220
|
-
return Promise.all(this.tilesetManager.tiles.filter(function (tile) {
|
|
219
|
+
tiles = this.tilesetManager.tiles.filter(function (tile) {
|
|
221
220
|
return tile.isLoaded;
|
|
222
221
|
}) // 过滤未加载完成的
|
|
223
222
|
.filter(function (tile) {
|
|
@@ -228,8 +227,9 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
228
227
|
}) //
|
|
229
228
|
.filter(function (tile) {
|
|
230
229
|
return tile.z >= minZoom && tile.z < maxZoom;
|
|
231
|
-
}) // 过滤不可见见
|
|
232
|
-
.
|
|
230
|
+
}); // 过滤不可见见
|
|
231
|
+
_context2.next = 7;
|
|
232
|
+
return Promise.all(tiles.map( /*#__PURE__*/function () {
|
|
233
233
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile) {
|
|
234
234
|
var tileInstance, tileLayer;
|
|
235
235
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -267,12 +267,12 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
267
267
|
return _ref.apply(this, arguments);
|
|
268
268
|
};
|
|
269
269
|
}()));
|
|
270
|
-
case
|
|
270
|
+
case 7:
|
|
271
271
|
if (this.tilesetManager.isLoaded) {
|
|
272
272
|
// 将事件抛出,图层上可以使用瓦片
|
|
273
273
|
this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
|
|
274
274
|
}
|
|
275
|
-
case
|
|
275
|
+
case 8:
|
|
276
276
|
case "end":
|
|
277
277
|
return _context2.stop();
|
|
278
278
|
}
|
|
@@ -38,7 +38,8 @@ var TextureService = exports.default = /*#__PURE__*/function () {
|
|
|
38
38
|
data: new Uint8Array(imageData.data),
|
|
39
39
|
width: imageData.width,
|
|
40
40
|
height: imageData.height,
|
|
41
|
-
flipY: false
|
|
41
|
+
flipY: false,
|
|
42
|
+
unorm: true
|
|
42
43
|
});
|
|
43
44
|
this.colorTexture = texture;
|
|
44
45
|
return texture;
|
|
@@ -81,15 +81,19 @@ var ShaderUniformPlugin = exports.default = (_dec = (0, _inversify.injectable)()
|
|
|
81
81
|
data: data
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
|
|
85
|
+
// For WebGL1. regl
|
|
86
|
+
var platformString = _this.rendererService.queryVerdorInfo();
|
|
87
|
+
if (platformString === 'WebGL1') {
|
|
88
|
+
layer.models.forEach(function (model) {
|
|
89
|
+
model.addUniforms((0, _objectSpread2.default)((0, _objectSpread2.default)({}, uniforms), {}, {
|
|
90
|
+
// TODO: move these 2 uniforms to PixelPickingPlugin
|
|
91
|
+
u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
|
|
92
|
+
// Tip: 当前地图是否在拖动
|
|
93
|
+
u_shaderPick: Number(layer.getShaderPickStat())
|
|
94
|
+
}));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -21,9 +21,9 @@ var _triangulation = require("../../core/triangulation");
|
|
|
21
21
|
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); }; }
|
|
22
22
|
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; } }
|
|
23
23
|
/* babel-plugin-inline-import '../shaders/raster/raster_2d_frag.glsl' */
|
|
24
|
-
var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n
|
|
24
|
+
var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n float u_clampLow;\n float u_clampHigh;\n};\n\nuniform sampler2D u_rasterTexture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\n\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\nout vec4 outputColor;\n\nvoid main() {\n // Can use any component here since u_rasterTexture is under luminance format.\n float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value)) {\n discard;\n } else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {\n discard;\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(normalisedValue, 0));\n \n outputColor = color;\n outputColor.a = outputColor.a * u_opacity ;\n if (outputColor.a < 0.01)\n discard;\n }\n}\n";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/raster/raster_2d_vert.glsl' */
|
|
26
|
-
var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n
|
|
26
|
+
var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n float u_clampLow;\n float u_clampHigh;\n};\n\nout vec2 v_texCoord;\n\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";
|
|
27
27
|
var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
28
28
|
(0, _inherits2.default)(RasterModel, _BaseModel);
|
|
29
29
|
var _super = _createSuper(RasterModel);
|
|
@@ -59,8 +59,8 @@ var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
59
59
|
u_domain: newdomain,
|
|
60
60
|
u_opacity: opacity || 1,
|
|
61
61
|
u_noDataValue: noDataValue,
|
|
62
|
-
u_clampLow: clampLow,
|
|
63
|
-
u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
|
|
62
|
+
u_clampLow: clampLow ? 1 : 0,
|
|
63
|
+
u_clampHigh: (typeof clampHigh !== 'undefined' ? clampHigh : clampLow) ? 1 : 0,
|
|
64
64
|
u_rasterTexture: this.texture,
|
|
65
65
|
u_colorTexture: this.colorTexture
|
|
66
66
|
};
|
|
@@ -168,7 +168,8 @@ var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
168
168
|
primitive: _l7Core.gl.TRIANGLES,
|
|
169
169
|
depth: {
|
|
170
170
|
enable: false
|
|
171
|
-
}
|
|
171
|
+
},
|
|
172
|
+
pickingEnabled: false
|
|
172
173
|
});
|
|
173
174
|
case 13:
|
|
174
175
|
model = _context3.sent;
|
|
@@ -25,7 +25,7 @@ var _excluded = ["data"],
|
|
|
25
25
|
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); }; }
|
|
26
26
|
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; } }
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/rgb/raster_rgb_frag.glsl' */
|
|
28
|
-
var rasterFrag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n vec2 u_rminmax;\n vec2 u_gminmax;\n vec2 u_bminmax;\n float u_opacity;\n float u_noDataValue;\n};\n\nin vec2 v_texCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n\n vec3 rgb = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y)).rgb;\n\n if(rgb == vec3(u_noDataValue)) {\n outputColor = vec4(0.0, 0, 0, 0.0);\n } else {\n outputColor = vec4(rgb.r / (u_rminmax.y -u_rminmax.x), rgb.g /(u_gminmax.y -u_gminmax.x), rgb.b/ (u_bminmax.y - u_bminmax.x), u_opacity);\n }\n if(outputColor.a < 0.01)\n discard;\n \n}";
|
|
28
|
+
var rasterFrag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n vec2 u_rminmax;\n vec2 u_gminmax;\n vec2 u_bminmax;\n float u_opacity;\n float u_noDataValue;\n};\n\nin vec2 v_texCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n\n vec3 rgb = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y)).rgb;\n\n if(rgb == vec3(u_noDataValue)) {\n outputColor = vec4(0.0, 0, 0, 0.0);\n } else {\n outputColor = vec4(rgb.r / (u_rminmax.y -u_rminmax.x), rgb.g /(u_gminmax.y -u_gminmax.x), rgb.b/ (u_bminmax.y - u_bminmax.x), u_opacity);\n }\n\n if(outputColor.a < 0.01)\n discard;\n \n}";
|
|
29
29
|
/* babel-plugin-inline-import '../shaders/rgb/raster_rgb_vert.glsl' */
|
|
30
30
|
var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_rminmax;\n vec2 u_gminmax;\n vec2 u_bminmax;\n float u_opacity;\n float u_noDataValue;\n};\n\nout vec2 v_texCoord;\n\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";
|
|
31
31
|
var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
@@ -159,7 +159,8 @@ var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
159
159
|
primitive: _l7Core.gl.TRIANGLES,
|
|
160
160
|
depth: {
|
|
161
161
|
enable: false
|
|
162
|
-
}
|
|
162
|
+
},
|
|
163
|
+
pickingEnabled: false
|
|
163
164
|
});
|
|
164
165
|
case 13:
|
|
165
166
|
model = _context2.sent;
|
|
@@ -20,9 +20,9 @@ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
|
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
22
|
/* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_frag.glsl' */
|
|
23
|
-
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
|
|
23
|
+
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 float u_clampLow;\n float 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 < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && 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";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_vert.glsl' */
|
|
25
|
-
var Raster_terrainVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n
|
|
25
|
+
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 float u_clampLow;\n float u_clampHigh;\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";
|
|
26
26
|
var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
27
27
|
(0, _inherits2.default)(RasterTerrainRGB, _BaseModel);
|
|
28
28
|
var _super = _createSuper(RasterTerrainRGB);
|
|
@@ -2,8 +2,8 @@ layout(std140) uniform commonUniforms {
|
|
|
2
2
|
vec2 u_domain;
|
|
3
3
|
float u_opacity;
|
|
4
4
|
float u_noDataValue;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
float u_clampLow;
|
|
6
|
+
float u_clampHigh;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
uniform sampler2D u_rasterTexture;
|
|
@@ -20,7 +20,7 @@ void main() {
|
|
|
20
20
|
float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;
|
|
21
21
|
if (value == u_noDataValue || isnan_emu(value)) {
|
|
22
22
|
discard;
|
|
23
|
-
} else if ((
|
|
23
|
+
} else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {
|
|
24
24
|
discard;
|
|
25
25
|
} else {
|
|
26
26
|
float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);
|
|
@@ -6,8 +6,8 @@ layout(std140) uniform commonUniforms {
|
|
|
6
6
|
vec2 u_domain;
|
|
7
7
|
float u_opacity;
|
|
8
8
|
float u_noDataValue;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
float u_clampLow;
|
|
10
|
+
float u_clampHigh;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
in vec2 v_texCoord;
|
|
@@ -31,7 +31,7 @@ void main() {
|
|
|
31
31
|
float value = getElevation(v_texCoord,0.0);
|
|
32
32
|
if (value == u_noDataValue) {
|
|
33
33
|
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
34
|
-
} else if ((
|
|
34
|
+
} else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {
|
|
35
35
|
outputColor = vec4(0.0, 0, 0, 0.0);
|
|
36
36
|
} else {
|
|
37
37
|
|
|
@@ -2,13 +2,12 @@ layout(location = 0) in vec3 a_Position;
|
|
|
2
2
|
layout(location = 14) in vec2 a_Uv;
|
|
3
3
|
|
|
4
4
|
layout(std140) uniform commonUniforms {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
vec4 u_unpack;
|
|
6
|
+
vec2 u_domain;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_noDataValue;
|
|
9
|
+
float u_clampLow;
|
|
10
|
+
float u_clampHigh;
|
|
12
11
|
};
|
|
13
12
|
out vec2 v_texCoord;
|
|
14
13
|
#pragma include "projection"
|
|
@@ -211,7 +211,7 @@ var BaseTileLayer = exports.default = /*#__PURE__*/function () {
|
|
|
211
211
|
value: function () {
|
|
212
212
|
var _tileUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
213
213
|
var _this3 = this;
|
|
214
|
-
var minZoom, maxZoom;
|
|
214
|
+
var minZoom, maxZoom, tiles;
|
|
215
215
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
216
216
|
while (1) switch (_context2.prev = _context2.next) {
|
|
217
217
|
case 0:
|
|
@@ -223,8 +223,7 @@ var BaseTileLayer = exports.default = /*#__PURE__*/function () {
|
|
|
223
223
|
case 2:
|
|
224
224
|
minZoom = this.parent.getMinZoom();
|
|
225
225
|
maxZoom = this.parent.getMaxZoom();
|
|
226
|
-
|
|
227
|
-
return Promise.all(this.tilesetManager.tiles.filter(function (tile) {
|
|
226
|
+
tiles = this.tilesetManager.tiles.filter(function (tile) {
|
|
228
227
|
return tile.isLoaded;
|
|
229
228
|
}) // 过滤未加载完成的
|
|
230
229
|
.filter(function (tile) {
|
|
@@ -235,8 +234,9 @@ var BaseTileLayer = exports.default = /*#__PURE__*/function () {
|
|
|
235
234
|
}) //
|
|
236
235
|
.filter(function (tile) {
|
|
237
236
|
return tile.z >= minZoom && tile.z < maxZoom;
|
|
238
|
-
}) // 过滤不可见见
|
|
239
|
-
.
|
|
237
|
+
}); // 过滤不可见见
|
|
238
|
+
_context2.next = 7;
|
|
239
|
+
return Promise.all(tiles.map( /*#__PURE__*/function () {
|
|
240
240
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tile) {
|
|
241
241
|
var tileInstance, tileLayer;
|
|
242
242
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
@@ -274,12 +274,12 @@ var BaseTileLayer = exports.default = /*#__PURE__*/function () {
|
|
|
274
274
|
return _ref.apply(this, arguments);
|
|
275
275
|
};
|
|
276
276
|
}()));
|
|
277
|
-
case
|
|
277
|
+
case 7:
|
|
278
278
|
if (this.tilesetManager.isLoaded) {
|
|
279
279
|
// 将事件抛出,图层上可以使用瓦片
|
|
280
280
|
this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
|
|
281
281
|
}
|
|
282
|
-
case
|
|
282
|
+
case 8:
|
|
283
283
|
case "end":
|
|
284
284
|
return _context2.stop();
|
|
285
285
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.16",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.20.
|
|
31
|
-
"@antv/l7-maps": "2.20.
|
|
32
|
-
"@antv/l7-source": "2.20.
|
|
33
|
-
"@antv/l7-utils": "2.20.
|
|
30
|
+
"@antv/l7-core": "2.20.16",
|
|
31
|
+
"@antv/l7-maps": "2.20.16",
|
|
32
|
+
"@antv/l7-source": "2.20.16",
|
|
33
|
+
"@antv/l7-utils": "2.20.16",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"reflect-metadata": "^0.1.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@antv/l7-test-utils": "2.20.
|
|
55
|
+
"@antv/l7-test-utils": "2.20.16",
|
|
56
56
|
"@types/d3-array": "^2.0.0",
|
|
57
57
|
"@types/d3-color": "^1.2.2",
|
|
58
58
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "63b45d16a6d3cab498f5d6b298d51a6d30bb3f3b",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|