@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.
Files changed (116) hide show
  1. package/es/core/BaseLayer.d.ts +0 -1
  2. package/es/core/BaseLayer.js +8 -5
  3. package/es/core/LayerPickService.d.ts +1 -1
  4. package/es/core/LayerPickService.js +28 -10
  5. package/es/core/TextureService.js +2 -1
  6. package/es/geometry/models/sprite.js +2 -2
  7. package/es/heatmap/models/grid.js +2 -2
  8. package/es/heatmap/models/grid3d.js +4 -4
  9. package/es/heatmap/models/heatmap.js +10 -6
  10. package/es/heatmap/shaders/grid/grid_frag.glsl +1 -0
  11. package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
  12. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
  13. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
  14. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
  15. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
  16. package/es/image/models/image.js +6 -8
  17. package/es/line/models/arc.js +1 -1
  18. package/es/line/models/line.js +10 -45
  19. package/es/line/shaders/arc/line_arc_frag.glsl +2 -1
  20. package/es/line/shaders/line/line_frag.glsl +2 -2
  21. package/es/line/shaders/line/line_vert.glsl +10 -7
  22. package/es/plugins/ShaderUniformPlugin.js +16 -11
  23. package/es/point/models/extrude.js +2 -2
  24. package/es/point/models/fill.js +1 -1
  25. package/es/point/models/fillImage.js +3 -5
  26. package/es/point/models/text.js +2 -2
  27. package/es/point/shaders/extrude/extrude_frag.glsl +1 -0
  28. package/es/point/shaders/extrude/extrude_vert.glsl +0 -1
  29. package/es/point/shaders/fill/fill_frag.glsl +1 -1
  30. package/es/point/shaders/fillImage/fillImage_frag.glsl +1 -2
  31. package/es/point/shaders/text/text_frag.glsl +3 -2
  32. package/es/point/shaders/text/text_vert.glsl +0 -2
  33. package/es/polygon/models/extrude.js +30 -39
  34. package/es/polygon/models/extrusion.js +1 -1
  35. package/es/polygon/models/fill.js +3 -3
  36. package/es/polygon/models/water.js +6 -4
  37. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
  38. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
  39. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
  40. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
  41. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
  42. package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
  43. package/es/polygon/shaders/fill/fill_frag.glsl +1 -0
  44. package/es/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
  45. package/es/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
  46. package/es/raster/models/raster.js +6 -5
  47. package/es/raster/models/rasterRgb.js +3 -2
  48. package/es/raster/models/rasterTerrainRgb.d.ts +8 -2
  49. package/es/raster/models/rasterTerrainRgb.js +20 -14
  50. package/es/raster/shaders/raster/raster_2d_frag.glsl +3 -3
  51. package/es/raster/shaders/raster/raster_2d_vert.glsl +2 -2
  52. package/es/raster/shaders/rgb/raster_rgb_frag.glsl +1 -0
  53. package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +19 -17
  54. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +12 -5
  55. package/es/tile/core/BaseLayer.js +7 -7
  56. package/es/tile/service/TilePickService.d.ts +1 -1
  57. package/es/tile/service/TilePickService.js +36 -13
  58. package/es/tile/tile/Tile.js +4 -3
  59. package/es/utils/load-image.d.ts +1 -0
  60. package/es/utils/load-image.js +46 -0
  61. package/lib/core/BaseLayer.js +8 -5
  62. package/lib/core/LayerPickService.js +28 -10
  63. package/lib/core/TextureService.js +2 -1
  64. package/lib/geometry/models/sprite.js +2 -2
  65. package/lib/heatmap/models/grid.js +2 -2
  66. package/lib/heatmap/models/grid3d.js +4 -4
  67. package/lib/heatmap/models/heatmap.js +10 -6
  68. package/lib/heatmap/shaders/grid/grid_frag.glsl +1 -0
  69. package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
  70. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
  71. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
  72. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
  73. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
  74. package/lib/image/models/image.js +6 -8
  75. package/lib/line/models/arc.js +1 -1
  76. package/lib/line/models/line.js +10 -45
  77. package/lib/line/shaders/arc/line_arc_frag.glsl +2 -1
  78. package/lib/line/shaders/line/line_frag.glsl +2 -2
  79. package/lib/line/shaders/line/line_vert.glsl +10 -7
  80. package/lib/plugins/ShaderUniformPlugin.js +16 -11
  81. package/lib/point/models/extrude.js +2 -2
  82. package/lib/point/models/fill.js +1 -1
  83. package/lib/point/models/fillImage.js +3 -5
  84. package/lib/point/models/text.js +2 -2
  85. package/lib/point/shaders/extrude/extrude_frag.glsl +1 -0
  86. package/lib/point/shaders/extrude/extrude_vert.glsl +0 -1
  87. package/lib/point/shaders/fill/fill_frag.glsl +1 -1
  88. package/lib/point/shaders/fillImage/fillImage_frag.glsl +1 -2
  89. package/lib/point/shaders/text/text_frag.glsl +3 -2
  90. package/lib/point/shaders/text/text_vert.glsl +0 -2
  91. package/lib/polygon/models/extrude.js +29 -38
  92. package/lib/polygon/models/extrusion.js +1 -1
  93. package/lib/polygon/models/fill.js +3 -3
  94. package/lib/polygon/models/water.js +6 -4
  95. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
  96. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
  97. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
  98. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
  99. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
  100. package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
  101. package/lib/polygon/shaders/fill/fill_frag.glsl +1 -0
  102. package/lib/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
  103. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
  104. package/lib/raster/models/raster.js +6 -5
  105. package/lib/raster/models/rasterRgb.js +3 -2
  106. package/lib/raster/models/rasterTerrainRgb.js +20 -14
  107. package/lib/raster/shaders/raster/raster_2d_frag.glsl +3 -3
  108. package/lib/raster/shaders/raster/raster_2d_vert.glsl +2 -2
  109. package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +1 -0
  110. package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +19 -17
  111. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +12 -5
  112. package/lib/tile/core/BaseLayer.js +7 -7
  113. package/lib/tile/service/TilePickService.js +36 -13
  114. package/lib/tile/tile/Tile.js +4 -3
  115. package/lib/utils/load-image.js +53 -0
  116. package/package.json +7 -7
@@ -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 bool u_clampLow;\n bool 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 && value < u_domain[0]) || (!u_clampHigh && 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";
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 bool u_clampLow;\n bool 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";
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;
@@ -16,12 +16,13 @@ var _l7Core = require("@antv/l7-core");
16
16
  var _l7Utils = require("@antv/l7-utils");
17
17
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
18
18
  var _triangulation = require("../../core/triangulation");
19
+ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
19
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); }; }
20
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; } }
21
22
  /* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_frag.glsl' */
22
- var Raster_terrainFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nvarying vec2 v_texCoord;\n\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nuniform vec4 u_unpack;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(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 texture2D(u_colorTexture, coord);\n}\n\nvoid main() {\n float value = getElevation(v_texCoord,0.0);\n if (value == u_noDataValue) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n } else {\n \n gl_FragColor = getColor(value);\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n if(gl_FragColor.a < 0.01)\n discard;\n }\n}\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";
23
24
  /* babel-plugin-inline-import '../shaders/terrain/terrain_rgb_vert.glsl' */
24
- var Raster_terrainVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\n\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\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";
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";
25
26
  var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
26
27
  (0, _inherits2.default)(RasterTerrainRGB, _BaseModel);
27
28
  var _super = _createSuper(RasterTerrainRGB);
@@ -30,8 +31,8 @@ var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
30
31
  return _super.apply(this, arguments);
31
32
  }
32
33
  (0, _createClass2.default)(RasterTerrainRGB, [{
33
- key: "getUninforms",
34
- value: function getUninforms() {
34
+ key: "getCommonUniformsInfo",
35
+ value: function getCommonUniformsInfo() {
35
36
  var _ref = this.layer.getLayerConfig(),
36
37
  opacity = _ref.opacity,
37
38
  _ref$clampLow = _ref.clampLow,
@@ -58,16 +59,19 @@ var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
58
59
  } else {
59
60
  this.layer.textureService.setColorTexture(colorTexture, rampColors, newdomain);
60
61
  }
61
- return {
62
- u_opacity: opacity || 1,
63
- u_texture: this.texture,
62
+ var commonOptions = {
63
+ u_unpack: [rScaler, gScaler, bScaler, offset],
64
64
  u_domain: newdomain,
65
+ u_opacity: opacity || 1,
66
+ u_noDataValue: noDataValue,
65
67
  u_clampLow: clampLow,
66
68
  u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
67
- u_noDataValue: noDataValue,
68
- u_unpack: [rScaler, gScaler, bScaler, offset],
69
+ u_texture: this.texture,
69
70
  u_colorTexture: texture
70
71
  };
72
+ this.textures = [this.texture, texture];
73
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
74
+ return commonBufferInfo;
71
75
  }
72
76
  }, {
73
77
  key: "initModels",
@@ -77,11 +81,12 @@ var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
77
81
  return _regenerator.default.wrap(function _callee$(_context) {
78
82
  while (1) switch (_context.prev = _context.next) {
79
83
  case 0:
84
+ this.initUniformsBuffer();
80
85
  source = this.layer.getSource();
81
86
  createTexture2D = this.rendererService.createTexture2D;
82
- _context.next = 4;
87
+ _context.next = 5;
83
88
  return source.data.images;
84
- case 4:
89
+ case 5:
85
90
  imageData = _context.sent;
86
91
  this.texture = createTexture2D({
87
92
  data: imageData[0],
@@ -90,7 +95,7 @@ var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
90
95
  min: _l7Core.gl.LINEAR,
91
96
  mag: _l7Core.gl.LINEAR
92
97
  });
93
- _context.next = 8;
98
+ _context.next = 9;
94
99
  return this.layer.buildLayerModel({
95
100
  moduleName: 'RasterTileDataImage',
96
101
  vertexShader: Raster_terrainVert,
@@ -101,10 +106,10 @@ var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
101
106
  enable: false
102
107
  }
103
108
  });
104
- case 8:
109
+ case 9:
105
110
  model = _context.sent;
106
111
  return _context.abrupt("return", [model]);
107
- case 10:
112
+ case 11:
108
113
  case "end":
109
114
  return _context.stop();
110
115
  }
@@ -148,6 +153,7 @@ var RasterTerrainRGB = exports.default = /*#__PURE__*/function (_BaseModel) {
148
153
  type: _l7Core.AttributeType.Attribute,
149
154
  descriptor: {
150
155
  name: 'a_Uv',
156
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
151
157
  buffer: {
152
158
  usage: _l7Core.gl.DYNAMIC_DRAW,
153
159
  data: [],
@@ -2,8 +2,8 @@ layout(std140) uniform commonUniforms {
2
2
  vec2 u_domain;
3
3
  float u_opacity;
4
4
  float u_noDataValue;
5
- bool u_clampLow;
6
- bool u_clampHigh;
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 ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
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
- bool u_clampLow;
10
- bool u_clampHigh;
9
+ float u_clampLow;
10
+ float u_clampHigh;
11
11
  };
12
12
 
13
13
  out vec2 v_texCoord;
@@ -20,6 +20,7 @@ void main() {
20
20
  } else {
21
21
  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);
22
22
  }
23
+
23
24
  if(outputColor.a < 0.01)
24
25
  discard;
25
26
 
@@ -1,20 +1,22 @@
1
- precision mediump float;
2
- uniform float u_opacity: 1.0;
3
-
4
1
  uniform sampler2D u_texture;
5
2
  uniform sampler2D u_colorTexture;
6
3
 
7
- varying vec2 v_texCoord;
4
+ layout(std140) uniform commonUniforms {
5
+ vec4 u_unpack;
6
+ vec2 u_domain;
7
+ float u_opacity;
8
+ float u_noDataValue;
9
+ float u_clampLow;
10
+ float u_clampHigh;
11
+ };
12
+
13
+ in vec2 v_texCoord;
14
+ out vec4 outputColor;
8
15
 
9
- uniform vec2 u_domain;
10
- uniform float u_noDataValue;
11
- uniform bool u_clampLow: true;
12
- uniform bool u_clampHigh: true;
13
- uniform vec4 u_unpack;
14
16
 
15
17
  float getElevation(vec2 coord, float bias) {
16
18
  // Convert encoded elevation value to meters
17
- vec4 data = texture2D(u_texture, coord,bias) * 255.0;
19
+ vec4 data = texture(SAMPLER_2D(u_texture), coord,bias) * 255.0;
18
20
  data.a = -1.0;
19
21
  return dot(data, u_unpack);
20
22
  }
@@ -22,20 +24,20 @@ float getElevation(vec2 coord, float bias) {
22
24
  vec4 getColor(float value) {
23
25
  float normalisedValue =(value- u_domain[0]) / (u_domain[1] - u_domain[0]);
24
26
  vec2 coord = vec2(normalisedValue, 0);
25
- return texture2D(u_colorTexture, coord);
27
+ return texture(SAMPLER_2D(u_colorTexture), coord);
26
28
  }
27
29
 
28
30
  void main() {
29
31
  float value = getElevation(v_texCoord,0.0);
30
32
  if (value == u_noDataValue) {
31
- gl_FragColor = vec4(0.0, 0, 0, 0.0);
32
- } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
33
- gl_FragColor = vec4(0.0, 0, 0, 0.0);
33
+ outputColor = vec4(0.0, 0, 0, 0.0);
34
+ } else if ((u_clampLow < 0.5 && value < u_domain[0]) || (u_clampHigh < 0.5 && value > u_domain[1])) {
35
+ outputColor = vec4(0.0, 0, 0, 0.0);
34
36
  } else {
35
37
 
36
- gl_FragColor = getColor(value);
37
- gl_FragColor.a = gl_FragColor.a * u_opacity ;
38
- if(gl_FragColor.a < 0.01)
38
+ outputColor = getColor(value);
39
+ outputColor.a = outputColor.a * u_opacity ;
40
+ if(outputColor.a < 0.01)
39
41
  discard;
40
42
  }
41
43
  }
@@ -1,10 +1,17 @@
1
- precision highp float;
2
- uniform mat4 u_ModelMatrix;
1
+ layout(location = 0) in vec3 a_Position;
2
+ layout(location = 14) in vec2 a_Uv;
3
3
 
4
- attribute vec3 a_Position;
5
- attribute vec2 a_Uv;
6
- varying vec2 v_texCoord;
4
+ layout(std140) uniform commonUniforms {
5
+ vec4 u_unpack;
6
+ vec2 u_domain;
7
+ float u_opacity;
8
+ float u_noDataValue;
9
+ float u_clampLow;
10
+ float u_clampHigh;
11
+ };
12
+ out vec2 v_texCoord;
7
13
  #pragma include "projection"
14
+
8
15
  void main() {
9
16
  v_texCoord = a_Uv;
10
17
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
@@ -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
- _context2.next = 6;
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
- .map( /*#__PURE__*/function () {
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 6:
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 7:
282
+ case 8:
283
283
  case "end":
284
284
  return _context2.stop();
285
285
  }
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.TilePickService = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -40,20 +42,41 @@ var TilePickService = exports.TilePickService = /*#__PURE__*/function () {
40
42
  }
41
43
  }, {
42
44
  key: "pick",
43
- value: function pick(layer, target) {
44
- var container = this.parent.getContainer();
45
- var pickingService = container.get(_l7Core.TYPES.IPickingService);
46
- if (layer.type === 'RasterLayer') {
47
- var tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
48
- if (tile && tile.getMainLayer() !== undefined) {
49
- var pickLayer = tile.getMainLayer();
50
- return pickLayer.layerPickService.pickRasterLayer(pickLayer, target, this.parent);
51
- }
52
- return false;
45
+ value: function () {
46
+ var _pick = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(layer, target) {
47
+ var container, pickingService, tile, pickLayer;
48
+ return _regenerator.default.wrap(function _callee$(_context) {
49
+ while (1) switch (_context.prev = _context.next) {
50
+ case 0:
51
+ container = this.parent.getContainer();
52
+ pickingService = container.get(_l7Core.TYPES.IPickingService);
53
+ if (!(layer.type === 'RasterLayer')) {
54
+ _context.next = 8;
55
+ break;
56
+ }
57
+ tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
58
+ if (!(tile && tile.getMainLayer() !== undefined)) {
59
+ _context.next = 7;
60
+ break;
61
+ }
62
+ pickLayer = tile.getMainLayer();
63
+ return _context.abrupt("return", pickLayer.layerPickService.pickRasterLayer(pickLayer, target, this.parent));
64
+ case 7:
65
+ return _context.abrupt("return", false);
66
+ case 8:
67
+ this.pickRender(target);
68
+ return _context.abrupt("return", pickingService.pickFromPickingFBO(layer, target));
69
+ case 10:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee, this);
74
+ }));
75
+ function pick(_x, _x2) {
76
+ return _pick.apply(this, arguments);
53
77
  }
54
- this.pickRender(target);
55
- return pickingService.pickFromPickingFBO(layer, target);
56
- }
78
+ return pick;
79
+ }()
57
80
  }, {
58
81
  key: "selectFeature",
59
82
  value: function selectFeature(pickedColors) {
@@ -111,7 +111,8 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
111
111
  while (1) switch (_context.prev = _context.next) {
112
112
  case 0:
113
113
  mask = new _polygon.default({
114
- visible: false,
114
+ name: 'mask',
115
+ visible: true,
115
116
  enablePicking: false
116
117
  }).source({
117
118
  type: 'FeatureCollection',
@@ -121,7 +122,7 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
121
122
  type: 'geojson',
122
123
  featureId: 'id'
123
124
  }
124
- }).shape('fill').style({
125
+ }).shape('fill').color('#0f0').style({
125
126
  opacity: 0.5
126
127
  });
127
128
  container = (0, _l7Core.createLayerContainer)(this.parent.sceneContainer);
@@ -145,7 +146,7 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
145
146
  return _addTileMask.apply(this, arguments);
146
147
  }
147
148
  return addTileMask;
148
- }()
149
+ }() // 全局 Mask
149
150
  }, {
150
151
  key: "addMask",
151
152
  value: function () {
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.loadImage = loadImage;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ function loadImage(_x) {
11
+ return _loadImage.apply(this, arguments);
12
+ }
13
+ function _loadImage() {
14
+ _loadImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
15
+ var response, imageBitmap, image;
16
+ return _regenerator.default.wrap(function _callee$(_context) {
17
+ while (1) switch (_context.prev = _context.next) {
18
+ case 0:
19
+ if (!window.createImageBitmap) {
20
+ _context.next = 14;
21
+ break;
22
+ }
23
+ _context.next = 3;
24
+ return fetch(url);
25
+ case 3:
26
+ response = _context.sent;
27
+ _context.t0 = createImageBitmap;
28
+ _context.next = 7;
29
+ return response.blob();
30
+ case 7:
31
+ _context.t1 = _context.sent;
32
+ _context.next = 10;
33
+ return (0, _context.t0)(_context.t1);
34
+ case 10:
35
+ imageBitmap = _context.sent;
36
+ return _context.abrupt("return", imageBitmap);
37
+ case 14:
38
+ image = new window.Image();
39
+ return _context.abrupt("return", new Promise(function (res) {
40
+ image.onload = function () {
41
+ return res(image);
42
+ };
43
+ image.src = url;
44
+ image.crossOrigin = 'Anonymous';
45
+ }));
46
+ case 16:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }, _callee);
51
+ }));
52
+ return _loadImage.apply(this, arguments);
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.20.13",
3
+ "version": "2.20.15",
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.13",
31
- "@antv/l7-maps": "2.20.13",
32
- "@antv/l7-source": "2.20.13",
33
- "@antv/l7-utils": "2.20.13",
30
+ "@antv/l7-core": "2.20.15",
31
+ "@antv/l7-maps": "2.20.15",
32
+ "@antv/l7-source": "2.20.15",
33
+ "@antv/l7-utils": "2.20.15",
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.13",
55
+ "@antv/l7-test-utils": "2.20.15",
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": "9487cca3bdd14eb2fc81b310e4eae5d30a30496f",
64
+ "gitHead": "283c12854a06cd2181552d6a9cf00d3e34bbd58e",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }