@antv/l7-layers 2.20.13 → 2.20.15
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/core/TextureService.js +2 -1
- 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 +16 -11
- 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/raster.js +6 -5
- package/es/raster/models/rasterRgb.js +3 -2
- package/es/raster/models/rasterTerrainRgb.d.ts +8 -2
- package/es/raster/models/rasterTerrainRgb.js +20 -14
- 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 +19 -17
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +12 -5
- package/es/tile/core/BaseLayer.js +7 -7
- 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/core/TextureService.js +2 -1
- 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 +16 -11
- 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/raster.js +6 -5
- package/lib/raster/models/rasterRgb.js +3 -2
- package/lib/raster/models/rasterTerrainRgb.js +20 -14
- 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 +19 -17
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +12 -5
- package/lib/tile/core/BaseLayer.js +7 -7
- 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
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
in vec4 v_color;
|
|
2
2
|
|
|
3
|
+
layout(std140) uniform commonUniforms {
|
|
4
|
+
vec2 u_radius;
|
|
5
|
+
float u_opacity;
|
|
6
|
+
float u_coverage;
|
|
7
|
+
float u_angle;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
#pragma include "scene_uniforms"
|
|
3
11
|
#pragma include "picking"
|
|
12
|
+
|
|
4
13
|
out vec4 outputColor;
|
|
5
14
|
void main() {
|
|
6
15
|
outputColor = v_color;
|
|
@@ -5,10 +5,10 @@ layout(location = 10) in vec3 a_Pos;
|
|
|
5
5
|
layout(location = 13) in vec3 a_Normal;
|
|
6
6
|
|
|
7
7
|
layout(std140) uniform commonUniforms {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
vec2 u_radius;
|
|
9
|
+
float u_opacity;
|
|
10
|
+
float u_coverage;
|
|
11
|
+
float u_angle;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
out vec4 v_color;
|
|
@@ -18,12 +18,10 @@ out vec4 v_color;
|
|
|
18
18
|
#pragma include "light"
|
|
19
19
|
#pragma include "picking"
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
void main() {
|
|
23
22
|
mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
|
|
24
23
|
vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
28
26
|
|
|
29
27
|
vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 经纬度
|
|
@@ -44,7 +42,5 @@ void main() {
|
|
|
44
42
|
gl_Position = project_common_position_to_clipspace(project_pos);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
45
|
setPickingColor(a_PickingColor);
|
|
50
46
|
}
|
|
@@ -5,10 +5,11 @@ layout(std140) uniform commonUniforms {
|
|
|
5
5
|
float u_common_uniforms_padding2;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
in float v_weight;
|
|
9
8
|
in vec2 v_extrude;
|
|
9
|
+
in float v_weight;
|
|
10
10
|
out vec4 outputColor;
|
|
11
11
|
#define GAUSS_COEF 0.3989422804014327
|
|
12
|
+
|
|
12
13
|
void main(){
|
|
13
14
|
float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);
|
|
14
15
|
float val = v_weight * u_intensity * GAUSS_COEF * exp(d);
|
|
@@ -13,12 +13,14 @@ layout(std140) uniform commonUniforms {
|
|
|
13
13
|
out vec2 v_extrude;
|
|
14
14
|
out float v_weight;
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
#define GAUSS_COEF 0.3989422804014327
|
|
18
17
|
|
|
19
18
|
#pragma include "projection"
|
|
19
|
+
#pragma include "picking"
|
|
20
20
|
|
|
21
21
|
void main(){
|
|
22
|
+
vec3 picking_color_placeholder = u_PickingColor;
|
|
23
|
+
|
|
22
24
|
v_weight = a_Size;
|
|
23
25
|
float ZERO = 1.0 / 255.0 / 16.0;
|
|
24
26
|
float extrude_x = a_Dir.x * 2.0 -1.0;
|
|
@@ -13,10 +13,10 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
13
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _l7Core = require("@antv/l7-core");
|
|
16
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
16
17
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
17
|
-
var _triangulation = require("../../core/triangulation");
|
|
18
18
|
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
19
|
-
var
|
|
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
22
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
@@ -34,14 +34,11 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
34
34
|
key: "getCommonUniformsInfo",
|
|
35
35
|
value: function getCommonUniformsInfo() {
|
|
36
36
|
var _ref = this.layer.getLayerConfig(),
|
|
37
|
-
_ref$color = _ref.color,
|
|
38
|
-
color = _ref$color === void 0 ? 'rgb(255,255,255)' : _ref$color,
|
|
39
37
|
opacity = _ref.opacity,
|
|
40
38
|
brightness = _ref.brightness,
|
|
41
39
|
contrast = _ref.contrast,
|
|
42
40
|
saturation = _ref.saturation,
|
|
43
41
|
gamma = _ref.gamma;
|
|
44
|
-
var colorArry = (0, _l7Utils.rgb2arr)(color);
|
|
45
42
|
var commonOptions = {
|
|
46
43
|
u_opacity: (0, _l7Utils.defaultValue)(opacity, 1.0),
|
|
47
44
|
u_brightness: (0, _l7Utils.defaultValue)(brightness, 1.0),
|
|
@@ -91,8 +88,8 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
91
88
|
case 0:
|
|
92
89
|
createTexture2D = this.rendererService.createTexture2D;
|
|
93
90
|
this.texture = createTexture2D({
|
|
94
|
-
height:
|
|
95
|
-
width:
|
|
91
|
+
height: 1,
|
|
92
|
+
width: 1
|
|
96
93
|
});
|
|
97
94
|
source = this.layer.getSource();
|
|
98
95
|
_context2.next = 5;
|
|
@@ -139,7 +136,8 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
139
136
|
},
|
|
140
137
|
depth: {
|
|
141
138
|
enable: false
|
|
142
|
-
}
|
|
139
|
+
},
|
|
140
|
+
pickingEnabled: false
|
|
143
141
|
});
|
|
144
142
|
case 3:
|
|
145
143
|
model = _context3.sent;
|
package/lib/line/models/arc.js
CHANGED
|
@@ -22,7 +22,7 @@ var _triangulation = require("../../core/triangulation");
|
|
|
22
22
|
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); }; }
|
|
23
23
|
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; } }
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_frag.glsl' */
|
|
25
|
-
var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\nin
|
|
25
|
+
var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\n\nin vec4 v_color;\nin vec2 v_iconMapUV;\nin vec4 v_lineData;\n//dash\nin vec4 v_dash_array;\nin float v_distance_ratio;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n outputColor = v_color;\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n outputColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = filterColor(pattern);\n }\n \n } else {\n outputColor = filterColor(outputColor);\n }\n}";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_vert.glsl' */
|
|
27
27
|
var arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_lineData;\n//dash\nout vec4 v_dash_array;\nout float v_distance_ratio;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n // return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n\n\n\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n //\u8BA1\u7B97dashArray\u548CdistanceRatio \u8F93\u51FA\u5230\u7247\u5143\n vec2 s = source;\n vec2 t = target;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n v_distance_ratio = segmentIndex / segmentNumber;\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n \n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_lineData.b = d_distance_ratio;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_lineData.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_lineData.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n v_lineData.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
28
|
var lineStyleObj = {
|
package/lib/line/models/line.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -22,9 +23,9 @@ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
|
22
23
|
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); }; }
|
|
23
24
|
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; } } // import { LineTriangulation } from '../../core/triangulation';
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
25
|
-
var line_frag = "// #extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\
|
|
26
|
+
var line_frag = "// #extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\n// dash\nin vec4 v_dash_array;\nin float v_d_distance_ratio;\nin vec2 v_iconMapUV;\nin vec4 v_texture_data;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n d_distance_ratio = v_texture_data.a;\n }\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n outputColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_texture_data.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_texture_data.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_texture_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float strokeWidth = min(0.5, u_strokeWidth);\n // \u7ED8\u5236 border\n if(strokeWidth > 0.01) {\n float borderOuterWidth = strokeWidth / 2.0;\n\n\n if(v >= 1.0 - strokeWidth || v <= strokeWidth) {\n if(v > strokeWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n outputColor.rgb = mix(outputColor.rgb, v_stroke.rgb, linear);\n } else if(v <= strokeWidth) {\n float linear = smoothstep(0.0, 1.0, v/strokeWidth);\n outputColor.rgb = mix(v_stroke.rgb, outputColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n outputColor.a = mix(0.0, outputColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = v_texture_data.a;\n if(blurV < 0.5) {\n outputColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n outputColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n outputColor = filterColor(outputColor);\n}\n";
|
|
26
27
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
27
|
-
var line_vert = "\n#define Animate 0.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location =
|
|
28
|
+
var line_vert = "\n#define Animate 0.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 10) in vec3 a_DistanceAndIndexAndMiter;\nlayout(location = 13) in vec4 a_Normal_Total_Distance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\n\nout vec4 v_color;\nout vec4 v_stroke;\n//dash\nout vec4 v_dash_array;\nout float v_d_distance_ratio;\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;\n float a_Miter = a_DistanceAndIndexAndMiter.z;\n vec3 a_Normal = a_Normal_Total_Distance.xyz;\n float a_Total_Distance = a_Normal_Total_Distance.w;\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n v_color.a *= opacity;\n v_stroke = stroke;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n \n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
29
|
var lineStyleObj = {
|
|
29
30
|
solid: 0.0,
|
|
30
31
|
dash: 1.0
|
|
@@ -240,7 +241,7 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
240
241
|
name: 'distanceAndIndex',
|
|
241
242
|
type: _l7Core.AttributeType.Attribute,
|
|
242
243
|
descriptor: {
|
|
243
|
-
name: '
|
|
244
|
+
name: 'a_DistanceAndIndexAndMiter',
|
|
244
245
|
shaderLocation: 10,
|
|
245
246
|
buffer: {
|
|
246
247
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -248,27 +249,9 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
248
249
|
data: [],
|
|
249
250
|
type: _l7Core.gl.FLOAT
|
|
250
251
|
},
|
|
251
|
-
size:
|
|
252
|
+
size: 3,
|
|
252
253
|
update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
|
|
253
|
-
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
258
|
-
name: 'total_distance',
|
|
259
|
-
type: _l7Core.AttributeType.Attribute,
|
|
260
|
-
descriptor: {
|
|
261
|
-
name: 'a_Total_Distance',
|
|
262
|
-
shaderLocation: 11,
|
|
263
|
-
buffer: {
|
|
264
|
-
// give the WebGL driver a hint that this buffer may change
|
|
265
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
266
|
-
data: [],
|
|
267
|
-
type: _l7Core.gl.FLOAT
|
|
268
|
-
},
|
|
269
|
-
size: 1,
|
|
270
|
-
update: function update(feature, featureIdx, vertex) {
|
|
271
|
-
return [vertex[5]];
|
|
254
|
+
return vertexIndex === undefined ? [vertex[3], 10, vertex[4]] : [vertex[3], vertexIndex, vertex[4]];
|
|
272
255
|
}
|
|
273
256
|
}
|
|
274
257
|
});
|
|
@@ -295,10 +278,10 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
295
278
|
|
|
296
279
|
// point layer size;
|
|
297
280
|
this.styleAttributeService.registerStyleAttribute({
|
|
298
|
-
name: '
|
|
281
|
+
name: 'normal_total_distance',
|
|
299
282
|
type: _l7Core.AttributeType.Attribute,
|
|
300
283
|
descriptor: {
|
|
301
|
-
name: '
|
|
284
|
+
name: 'a_Normal_Total_Distance',
|
|
302
285
|
shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
|
|
303
286
|
buffer: {
|
|
304
287
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -306,27 +289,9 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
306
289
|
data: [],
|
|
307
290
|
type: _l7Core.gl.FLOAT
|
|
308
291
|
},
|
|
309
|
-
size:
|
|
292
|
+
size: 4,
|
|
310
293
|
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
311
|
-
return normal;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
316
|
-
name: 'miter',
|
|
317
|
-
type: _l7Core.AttributeType.Attribute,
|
|
318
|
-
descriptor: {
|
|
319
|
-
shaderLocation: 15,
|
|
320
|
-
name: 'a_Miter',
|
|
321
|
-
buffer: {
|
|
322
|
-
// give the WebGL driver a hint that this buffer may change
|
|
323
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
324
|
-
data: [],
|
|
325
|
-
type: _l7Core.gl.FLOAT
|
|
326
|
-
},
|
|
327
|
-
size: 1,
|
|
328
|
-
update: function update(feature, featureIdx, vertex) {
|
|
329
|
-
return [vertex[4]];
|
|
294
|
+
return [].concat((0, _toConsumableArray2.default)(normal), [vertex[5]]);
|
|
330
295
|
}
|
|
331
296
|
}
|
|
332
297
|
});
|
|
@@ -24,11 +24,11 @@ layout(std140) uniform commonUniorm {
|
|
|
24
24
|
|
|
25
25
|
in vec4 v_color;
|
|
26
26
|
in vec4 v_stroke;
|
|
27
|
-
in vec2 v_iconMapUV;
|
|
28
|
-
in vec4 v_texture_data;
|
|
29
27
|
// dash
|
|
30
28
|
in vec4 v_dash_array;
|
|
31
29
|
in float v_d_distance_ratio;
|
|
30
|
+
in vec2 v_iconMapUV;
|
|
31
|
+
in vec4 v_texture_data;
|
|
32
32
|
|
|
33
33
|
out vec4 outputColor;
|
|
34
34
|
#pragma include "picking"
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
layout(location = 0) in vec3 a_Position;
|
|
5
5
|
layout(location = 1) in vec4 a_Color;
|
|
6
|
-
layout(location = 10) in vec2 a_DistanceAndIndex;
|
|
7
6
|
layout(location = 9) in vec2 a_Size;
|
|
8
|
-
layout(location =
|
|
9
|
-
layout(location = 13) in
|
|
10
|
-
layout(location = 15) in float a_Miter;
|
|
7
|
+
layout(location = 10) in vec3 a_DistanceAndIndexAndMiter;
|
|
8
|
+
layout(location = 13) in vec4 a_Normal_Total_Distance;
|
|
11
9
|
layout(location = 14) in vec2 a_iconMapUV;
|
|
12
10
|
|
|
13
11
|
layout(std140) uniform commonUniorm {
|
|
@@ -28,20 +26,25 @@ layout(std140) uniform commonUniorm {
|
|
|
28
26
|
float u_linearColor: 0;
|
|
29
27
|
float u_time;
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
#pragma include "picking"
|
|
29
|
+
|
|
33
30
|
|
|
34
31
|
out vec4 v_color;
|
|
35
32
|
out vec4 v_stroke;
|
|
36
33
|
//dash
|
|
37
34
|
out vec4 v_dash_array;
|
|
38
35
|
out float v_d_distance_ratio;
|
|
39
|
-
|
|
40
36
|
// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
|
|
41
37
|
out vec2 v_iconMapUV;
|
|
42
38
|
out vec4 v_texture_data;
|
|
43
39
|
|
|
40
|
+
#pragma include "projection"
|
|
41
|
+
#pragma include "picking"
|
|
42
|
+
|
|
44
43
|
void main() {
|
|
44
|
+
vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;
|
|
45
|
+
float a_Miter = a_DistanceAndIndexAndMiter.z;
|
|
46
|
+
vec3 a_Normal = a_Normal_Total_Distance.xyz;
|
|
47
|
+
float a_Total_Distance = a_Normal_Total_Distance.w;
|
|
45
48
|
//dash输出
|
|
46
49
|
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;
|
|
47
50
|
v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
|
|
@@ -73,22 +73,27 @@ var ShaderUniformPlugin = exports.default = (_dec = (0, _inversify.injectable)()
|
|
|
73
73
|
var _this$generateUBO = _this.generateUBO(mvp, sceneCenterMercator, width, height),
|
|
74
74
|
data = _this$generateUBO.data,
|
|
75
75
|
uniforms = _this$generateUBO.uniforms;
|
|
76
|
-
if (_this.layerService.alreadyInRendering &&
|
|
76
|
+
if (_this.layerService.alreadyInRendering && _this.rendererService.uniformBuffers[0]) {
|
|
77
|
+
var renderUniformBuffer = _this.rendererService.uniformBuffers[0];
|
|
77
78
|
// Update only once since all models can share one UBO.
|
|
78
|
-
|
|
79
|
+
renderUniformBuffer.subData({
|
|
79
80
|
offset: 0,
|
|
80
81
|
data: data
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
}
|
|
92
97
|
});
|
|
93
98
|
}
|
|
94
99
|
|