@antv/l7-layers 2.17.12 → 2.18.3

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 (79) hide show
  1. package/es/core/BaseLayer.js +7 -2
  2. package/es/core/BaseModel.d.ts +0 -20
  3. package/es/core/BaseModel.js +4 -2
  4. package/es/core/CommonStyleAttribute.js +20 -0
  5. package/es/core/interface.d.ts +1 -0
  6. package/es/earth/models/atmosphere.js +2 -1
  7. package/es/earth/models/bloomsphere.js +2 -1
  8. package/es/heatmap/models/heatmap.js +2 -2
  9. package/es/image/models/image.js +6 -29
  10. package/es/line/models/arc.js +2 -2
  11. package/es/line/models/linearline.js +2 -2
  12. package/es/line/models/simpleLine.js +2 -2
  13. package/es/line/models/wall.js +2 -2
  14. package/es/mask/models/fill.js +2 -2
  15. package/es/plugins/DataMappingPlugin.js +2 -2
  16. package/es/plugins/FeatureScalePlugin.js +6 -2
  17. package/es/plugins/ShaderUniformPlugin.js +1 -2
  18. package/es/point/index.js +5 -3
  19. package/es/point/models/{simplePoint.js → billboard_point.js} +2 -2
  20. package/es/point/models/earthExtrude.js +2 -2
  21. package/es/point/models/fill.js +1 -1
  22. package/es/point/models/fillmage.js +8 -37
  23. package/es/point/models/image.js +7 -7
  24. package/es/point/models/index.js +1 -1
  25. package/es/point/models/normal.js +6 -5
  26. package/es/point/models/text.js +3 -21
  27. package/es/point/shaders/fill_vert.glsl +3 -4
  28. package/es/point/shaders/image/fillImage_frag.glsl +2 -1
  29. package/es/point/shaders/image/fillImage_vert.glsl +9 -11
  30. package/es/point/shaders/image_frag.glsl +2 -4
  31. package/es/point/shaders/image_vert.glsl +3 -4
  32. package/es/point/shaders/normal_vert.glsl +1 -2
  33. package/es/point/shaders/text_vert.glsl +4 -6
  34. package/es/polygon/models/ocean.js +2 -2
  35. package/es/polygon/models/water.js +2 -1
  36. package/es/tile/tileFactory/Tile.d.ts +0 -1
  37. package/es/tile/tileLayer/BaseLayer.js +2 -1
  38. package/es/utils/layerData.js +2 -2
  39. package/lib/core/BaseLayer.js +30 -25
  40. package/lib/core/BaseModel.js +4 -2
  41. package/lib/core/CommonStyleAttribute.js +20 -0
  42. package/lib/earth/models/atmosphere.js +3 -2
  43. package/lib/earth/models/bloomsphere.js +3 -2
  44. package/lib/heatmap/models/heatmap.js +2 -2
  45. package/lib/image/models/image.js +6 -29
  46. package/lib/line/models/arc.js +2 -2
  47. package/lib/line/models/linearline.js +2 -2
  48. package/lib/line/models/simpleLine.js +2 -2
  49. package/lib/line/models/wall.js +2 -2
  50. package/lib/mask/models/fill.js +2 -2
  51. package/lib/plugins/DataMappingPlugin.js +2 -2
  52. package/lib/plugins/FeatureScalePlugin.js +10 -6
  53. package/lib/plugins/ShaderUniformPlugin.js +1 -2
  54. package/lib/point/index.js +5 -3
  55. package/lib/point/models/{simplePoint.js → billboard_point.js} +2 -2
  56. package/lib/point/models/earthExtrude.js +2 -2
  57. package/lib/point/models/fill.js +1 -1
  58. package/lib/point/models/fillmage.js +8 -37
  59. package/lib/point/models/image.js +7 -7
  60. package/lib/point/models/index.js +2 -2
  61. package/lib/point/models/normal.js +6 -5
  62. package/lib/point/models/text.js +3 -21
  63. package/lib/point/shaders/fill_vert.glsl +3 -4
  64. package/lib/point/shaders/image/fillImage_frag.glsl +2 -1
  65. package/lib/point/shaders/image/fillImage_vert.glsl +9 -11
  66. package/lib/point/shaders/image_frag.glsl +2 -4
  67. package/lib/point/shaders/image_vert.glsl +3 -4
  68. package/lib/point/shaders/normal_vert.glsl +1 -2
  69. package/lib/point/shaders/text_vert.glsl +4 -6
  70. package/lib/polygon/models/ocean.js +2 -2
  71. package/lib/polygon/models/water.js +3 -2
  72. package/lib/tile/tileLayer/BaseLayer.js +3 -2
  73. package/lib/utils/layerData.js +3 -3
  74. package/package.json +7 -8
  75. /package/es/point/models/{simplePoint.d.ts → billboard_point.d.ts} +0 -0
  76. /package/es/point/shaders/{simplePoint_frag.glsl → billboard_point_frag.glsl} +0 -0
  77. /package/es/point/shaders/{simplePoint_vert.glsl → billboard_point_vert.glsl} +0 -0
  78. /package/lib/point/shaders/{simplePoint_frag.glsl → billboard_point_frag.glsl} +0 -0
  79. /package/lib/point/shaders/{simplePoint_vert.glsl → billboard_point_vert.glsl} +0 -0
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -16,9 +17,9 @@ import { SizeUnitType } from "../../core/interface";
16
17
  import { PointFillTriangulation } from "../../core/triangulation";
17
18
  // static pointLayer shader - not support animate
18
19
  /* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
19
- var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= u_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
+ var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\nvarying float v_opacity;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= v_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
21
  /* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
21
- var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
22
+ var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nvarying float v_opacity;\n// uniform vec2 u_offsets; // shader \u6CE8\u5165\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n \n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (extrude.xy * (newSize) + offsets);\n\n offset = rotate_matrix(offset,rotation);\n\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
22
23
  var FillImageModel = /*#__PURE__*/function (_BaseModel) {
23
24
  _inherits(FillImageModel, _BaseModel);
24
25
  var _super = _createSuper(FillImageModel);
@@ -63,11 +64,6 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
63
64
  // 旋转的弧度
64
65
  function getUninforms() {
65
66
  var _ref = this.layer.getLayerConfig(),
66
- _ref$opacity = _ref.opacity,
67
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
68
- _ref$offsets = _ref.offsets,
69
- offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
70
- rotation = _ref.rotation,
71
67
  _ref$raisingHeight = _ref.raisingHeight,
72
68
  raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
73
69
  _ref$heightfixed = _ref.heightfixed,
@@ -84,22 +80,14 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
84
80
  * GAODE2.x -1
85
81
  * GAODE1.x -1
86
82
  */
87
- var rotateFlag = 1;
88
- if (this.mapService.version === 'GAODE2.x' || this.mapService.version === 'GAODE1.x') {
89
- rotateFlag = -1;
90
- }
91
- // 控制图标的旋转角度(绕 Z 轴旋转)
92
- this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
93
- return {
83
+
84
+ return _objectSpread({
94
85
  u_raisingHeight: Number(raisingHeight),
95
86
  u_heightfixed: Number(heightfixed),
96
87
  u_size_unit: SizeUnitType[unit],
97
- u_RotateMatrix: new Float32Array([Math.cos(this.radian), Math.sin(this.radian), -Math.sin(this.radian), Math.cos(this.radian)]),
98
88
  u_texture: this.texture,
99
- u_textSize: [1024, this.iconService.canvasHeight || 128],
100
- u_opacity: opacity,
101
- u_offsets: offsets
102
- };
89
+ u_textSize: [1024, this.iconService.canvasHeight || 128]
90
+ }, this.getStyleAttribute());
103
91
  }
104
92
  }, {
105
93
  key: "getAttribute",
@@ -144,6 +132,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
144
132
  depth: {
145
133
  enable: false
146
134
  },
135
+ inject: this.getInject(),
147
136
  cull: {
148
137
  enable: true,
149
138
  face: getCullFace(this.mapService.version)
@@ -176,24 +165,6 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
176
165
  key: "registerBuiltinAttributes",
177
166
  value: function registerBuiltinAttributes() {
178
167
  var _this2 = this;
179
- this.styleAttributeService.registerStyleAttribute({
180
- name: 'rotate',
181
- type: AttributeType.Attribute,
182
- descriptor: {
183
- name: 'a_Rotate',
184
- buffer: {
185
- usage: gl.DYNAMIC_DRAW,
186
- data: [],
187
- type: gl.FLOAT
188
- },
189
- size: 1,
190
- update: function update(feature) {
191
- var _feature$rotate = feature.rotate,
192
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
193
- return Array.isArray(rotate) ? [rotate[0]] : [rotate];
194
- }
195
- }
196
- });
197
168
  this.styleAttributeService.registerStyleAttribute({
198
169
  name: 'uv',
199
170
  type: AttributeType.Attribute,
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -13,9 +14,9 @@ import { AttributeType, gl } from '@antv/l7-core';
13
14
  import BaseModel from "../../core/BaseModel";
14
15
  import { PointImageTriangulation } from "../../core/triangulation";
15
16
  /* babel-plugin-inline-import '../shaders/image_frag.glsl' */
16
- var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n \n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
+ var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_opacity;\nuniform vec2 u_textSize;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n gl_FragColor.a *= v_opacity;\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
18
  /* babel-plugin-inline-import '../shaders/image_vert.glsl' */
18
- var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec2 u_offsets;\n\nuniform float u_opacity : 1;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(u_offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
19
+ var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_opacity;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_opacity = opacity;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
19
20
  var ImageModel = /*#__PURE__*/function (_BaseModel) {
20
21
  _inherits(ImageModel, _BaseModel);
21
22
  var _super = _createSuper(ImageModel);
@@ -72,14 +73,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
72
73
  if (this.rendererService.getDirty()) {
73
74
  this.texture.bind();
74
75
  }
75
- return {
76
+ return _objectSpread({
76
77
  u_raisingHeight: Number(raisingHeight),
77
78
  u_heightfixed: Number(heightfixed),
78
79
  u_texture: this.texture,
79
- u_textSize: [1024, this.iconService.canvasHeight || 128],
80
- u_opacity: opacity,
81
- u_offsets: offsets
82
- };
80
+ u_textSize: [1024, this.iconService.canvasHeight || 128]
81
+ }, this.getStyleAttribute());
83
82
  }
84
83
  }, {
85
84
  key: "initModels",
@@ -123,6 +122,7 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
123
122
  vertexShader: pointImageVert,
124
123
  fragmentShader: pointImageFrag,
125
124
  triangulation: PointImageTriangulation,
125
+ inject: this.getInject(),
126
126
  depth: {
127
127
  enable: false
128
128
  },
@@ -1,3 +1,4 @@
1
+ import SimplePoint from "./billboard_point";
1
2
  import EarthExtrudeModel from "./earthExtrude";
2
3
  // earth
3
4
  import EarthFillModel from "./earthFill";
@@ -7,7 +8,6 @@ import FillImageModel from "./fillmage";
7
8
  import IMageModel from "./image";
8
9
  import NormalModel from "./normal";
9
10
  import Radar from "./radar";
10
- import SimplePoint from "./simplePoint";
11
11
  import TextModel from "./text";
12
12
  var PointModels = {
13
13
  fillImage: FillImageModel,
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
@@ -9,12 +10,13 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
11
  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; } }
11
12
  import { AttributeType, gl } from '@antv/l7-core';
12
- import { isNumber } from 'lodash';
13
+ import { lodashUtil } from '@antv/l7-utils';
13
14
  import BaseModel from "../../core/BaseModel";
14
15
  /* babel-plugin-inline-import '../shaders/normal_frag.glsl' */
15
16
  var normalFrag = "varying vec4 v_color;\nvoid main() {\n gl_FragColor = v_color;\n}\n";
16
17
  /* babel-plugin-inline-import '../shaders/normal_vert.glsl' */
17
- var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform float u_opacity : 1;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
18
+ var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
19
+ var isNumber = lodashUtil.isNumber;
18
20
  export function PointTriangulation(feature) {
19
21
  var coordinates = feature.coordinates;
20
22
  return {
@@ -43,9 +45,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
43
45
  var _ref = this.layer.getLayerConfig(),
44
46
  _ref$opacity = _ref.opacity,
45
47
  opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
46
- return {
47
- u_opacity: isNumber(opacity) ? opacity : 1.0
48
- };
48
+ return _objectSpread({}, this.getStyleAttribute());
49
49
  }
50
50
  }, {
51
51
  key: "initModels",
@@ -81,6 +81,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
81
81
  vertexShader: normalVert,
82
82
  fragmentShader: normalFrag,
83
83
  triangulation: PointTriangulation,
84
+ inject: this.getInject(),
84
85
  depth: {
85
86
  enable: false
86
87
  },
@@ -15,15 +15,15 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
15
15
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
16
  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; } }
17
17
  import { AttributeType, gl } from '@antv/l7-core';
18
- import { boundsContains, calculateCentroid, padBounds, rgb2arr } from '@antv/l7-utils';
19
- import { isEqual } from 'lodash';
18
+ import { boundsContains, calculateCentroid, lodashUtil, padBounds, rgb2arr } from '@antv/l7-utils';
20
19
  import BaseModel from "../../core/BaseModel";
21
20
  import CollisionIndex from "../../utils/collision-index";
22
21
  import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
23
22
  /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
24
23
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
25
24
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
26
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\n// uniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
25
+ var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
26
+ var isEqual = lodashUtil.isEqual;
27
27
  export function TextTrianglation(feature) {
28
28
  // @ts-ignore
29
29
  var that = this;
@@ -241,24 +241,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
241
241
  }, {
242
242
  key: "registerBuiltinAttributes",
243
243
  value: function registerBuiltinAttributes() {
244
- this.styleAttributeService.registerStyleAttribute({
245
- name: 'rotate',
246
- type: AttributeType.Attribute,
247
- descriptor: {
248
- name: 'a_Rotate',
249
- buffer: {
250
- usage: gl.DYNAMIC_DRAW,
251
- data: [],
252
- type: gl.FLOAT
253
- },
254
- size: 1,
255
- update: function update(feature) {
256
- var _feature$rotate = feature.rotate,
257
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
258
- return Array.isArray(rotate) ? [rotate[0]] : [rotate];
259
- }
260
- }
261
- });
262
244
  this.styleAttributeService.registerStyleAttribute({
263
245
  name: 'textOffsets',
264
246
  type: AttributeType.Attribute,
@@ -3,7 +3,6 @@ attribute vec3 a_Position;
3
3
  attribute vec3 a_Extrude;
4
4
  attribute float a_Size;
5
5
  attribute float a_Shape;
6
-
7
6
  uniform mat4 u_ModelMatrix;
8
7
  uniform mat4 u_Mvp;
9
8
  uniform int u_size_unit;
@@ -12,19 +11,18 @@ varying vec4 v_data;
12
11
  varying vec4 v_color;
13
12
  varying float v_radius;
14
13
  varying vec4 v_stroke;
15
-
16
- // uniform float u_opacity : 1;
17
14
  uniform float u_stroke_width: 2;
18
15
  uniform vec3 u_blur_height_fixed: [0, 0, 0];
19
16
 
20
17
 
21
18
  #pragma include "projection"
22
19
  #pragma include "picking"
20
+ #pragma include "rotation_2d"
23
21
 
24
22
 
25
23
  void main() {
26
24
  // 透明度计算
27
- v_stroke = stroke;
25
+ v_stroke = stroke;
28
26
  vec3 extrude = a_Extrude;
29
27
  float shape_type = a_Shape;
30
28
  /*
@@ -53,6 +51,7 @@ void main() {
53
51
  vec3 aPosition = a_Position;
54
52
 
55
53
  offset = project_pixel(offset);
54
+ offset = rotate_matrix(offset,rotation);
56
55
 
57
56
  // TODP: /abs(extrude.x) 是为了兼容地球模式
58
57
  v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
@@ -6,12 +6,13 @@ uniform float u_opacity : 1;
6
6
  #pragma include "picking"
7
7
  varying vec2 v_uv; // 本身的 uv 坐标
8
8
  varying vec2 v_Iconuv;
9
+ varying float v_opacity;
9
10
 
10
11
  void main() {
11
12
 
12
13
  vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;
13
14
  gl_FragColor = texture2D(u_texture, pos);
14
- gl_FragColor.a *= u_opacity;
15
+ gl_FragColor.a *= v_opacity;
15
16
 
16
17
  gl_FragColor = filterColor(gl_FragColor);
17
18
  }
@@ -3,7 +3,6 @@ attribute vec3 a_Position;
3
3
  attribute vec3 a_Extrude;
4
4
  attribute float a_Size;
5
5
  attribute vec2 a_Uv;
6
- attribute float a_Rotate;
7
6
 
8
7
  uniform mat4 u_ModelMatrix;
9
8
  uniform mat4 u_Mvp;
@@ -15,31 +14,30 @@ varying vec2 v_Iconuv; // icon 贴图的 uv 坐标
15
14
 
16
15
  uniform float u_raisingHeight: 0.0;
17
16
  uniform float u_heightfixed: 0.0;
18
- uniform float u_opacity : 1;
19
- uniform vec2 u_offsets;
20
-
17
+ varying float v_opacity;
18
+ // uniform vec2 u_offsets; // shader 注入
21
19
 
22
20
 
23
21
  #pragma include "projection"
24
22
  #pragma include "picking"
23
+ #pragma include "rotation_2d"
25
24
 
26
25
  void main() {
27
26
  vec3 extrude = a_Extrude;
28
27
  v_uv = (a_Extrude.xy + 1.0)/2.0;
29
28
  v_uv.y = 1.0 - v_uv.y;
30
29
  v_Iconuv = a_Uv;
31
-
32
-
33
- highp float angle_sin = sin(a_Rotate);
34
- highp float angle_cos = cos(a_Rotate);
35
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
30
+ v_opacity = opacity;
36
31
  float newSize = a_Size;
37
32
  if(u_size_unit == 1) {
38
33
  newSize = newSize * u_PixelsPerMeter.z;
39
34
  }
40
-
35
+
41
36
  // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
42
- vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);
37
+ vec2 offset = (extrude.xy * (newSize) + offsets);
38
+
39
+ offset = rotate_matrix(offset,rotation);
40
+
43
41
  vec3 aPosition = a_Position;
44
42
 
45
43
  offset = project_pixel(offset);
@@ -2,8 +2,8 @@
2
2
  uniform sampler2D u_texture;
3
3
  varying vec4 v_color;
4
4
  varying vec2 v_uv;
5
+ varying float v_opacity;
5
6
  uniform vec2 u_textSize;
6
- uniform float u_opacity : 1;
7
7
 
8
8
  #pragma include "picking"
9
9
 
@@ -29,9 +29,7 @@ void main(){
29
29
  }else {
30
30
  gl_FragColor= step(0.01, textureColor.z) * v_color;
31
31
  }
32
-
33
- gl_FragColor.a = gl_FragColor.a * u_opacity;
34
-
32
+ gl_FragColor.a *= v_opacity;
35
33
  if (gl_FragColor.a < 0.01) {
36
34
  discard;
37
35
  }
@@ -5,15 +5,13 @@ attribute vec2 a_Uv;
5
5
  attribute float a_Size;
6
6
  varying vec4 v_color;
7
7
  varying vec2 v_uv;
8
+ varying float v_opacity;
8
9
  uniform mat4 u_ModelMatrix;
9
10
  uniform mat4 u_Mvp;
10
- uniform vec2 u_offsets;
11
11
 
12
- uniform float u_opacity : 1;
13
12
  uniform float u_raisingHeight: 0.0;
14
13
  uniform float u_heightfixed: 0.0;
15
14
 
16
-
17
15
  #pragma include "projection"
18
16
  #pragma include "picking"
19
17
 
@@ -21,10 +19,11 @@ void main() {
21
19
 
22
20
  // cal style mapping - 数据纹理映射部分的计算
23
21
  v_color = a_Color;
22
+ v_opacity = opacity;
24
23
  v_uv = a_Uv;
25
24
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
26
25
 
27
- vec2 offset = project_pixel(u_offsets);
26
+ vec2 offset = project_pixel(offsets);
28
27
 
29
28
  float raisingHeight = u_raisingHeight;
30
29
  if(u_heightfixed < 1.0) { // false
@@ -1,7 +1,6 @@
1
1
 
2
2
  attribute vec3 a_Position;
3
3
  uniform mat4 u_ModelMatrix;
4
- uniform float u_opacity : 1;
5
4
  uniform mat4 u_Mvp;
6
5
  attribute float a_Size;
7
6
  attribute vec4 a_Color;
@@ -12,7 +11,7 @@ varying vec4 v_color;
12
11
  #pragma include "project"
13
12
 
14
13
  void main() {
15
- v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
14
+ v_color = vec4(a_Color.xyz, a_Color.w * opacity);
16
15
 
17
16
  if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
18
17
  gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);
@@ -6,7 +6,6 @@ attribute vec2 a_tex;
6
6
  attribute vec2 a_textOffsets;
7
7
  attribute vec4 a_Color;
8
8
  attribute float a_Size;
9
- attribute float a_Rotate;
10
9
 
11
10
  uniform vec2 u_sdf_map_size;
12
11
  uniform mat4 u_ModelMatrix;
@@ -18,13 +17,14 @@ varying float v_gamma_scale;
18
17
  varying vec4 v_color;
19
18
  varying vec4 v_stroke_color;
20
19
  varying float v_fontScale;
21
- // uniform float u_opacity : 1;
22
20
  uniform float u_stroke_width : 2;
23
21
  uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
24
22
 
25
23
 
24
+
26
25
  #pragma include "projection"
27
26
  #pragma include "picking"
27
+ #pragma include "rotation_2d"
28
28
 
29
29
  void main() {
30
30
  // cal style mapping - 数据纹理映射部分的计算
@@ -43,9 +43,7 @@ void main() {
43
43
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
44
44
  // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
45
45
 
46
- highp float angle_sin = sin(a_Rotate);
47
- highp float angle_cos = cos(a_Rotate);
48
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
46
+ vec2 offset = rotate_matrix(a_textOffsets,rotation);
49
47
 
50
48
  // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
51
49
 
@@ -63,7 +61,7 @@ void main() {
63
61
  }
64
62
 
65
63
  gl_Position = vec4(
66
- projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
64
+ projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
67
65
  v_gamma_scale = gl_Position.w;
68
66
  setPickingColor(a_PickingColor);
69
67
 
@@ -10,14 +10,14 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
10
10
  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; } }
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
12
  import { Version } from '@antv/l7-maps';
13
- import { rgb2arr } from '@antv/l7-utils';
14
- import { isNumber } from 'lodash';
13
+ import { lodashUtil, rgb2arr } from '@antv/l7-utils';
15
14
  import BaseModel from "../../core/BaseModel";
16
15
  import { polygonTriangulation } from "../../core/triangulation";
17
16
  /* babel-plugin-inline-import '../shaders/water/polygon_ocean_frag.glsl' */
18
17
  var ocean_frag = "\nuniform float u_time: 0.0;\nuniform float u_opacity: 1.0;\n\nvarying vec2 v_uv;\n\nfloat coast2water_fadedepth = 0.10;\nfloat large_waveheight = .750; // change to adjust the \"heavy\" waves\nfloat large_wavesize = 3.4; // factor to adjust the large wave size\nfloat small_waveheight = 0.6; // change to adjust the small random waves\nfloat small_wavesize = 0.5; // factor to ajust the small wave size\nfloat water_softlight_fact = 15.; // range [1..200] (should be << smaller than glossy-fact)\nfloat water_glossylight_fact= 120.; // range [1..200]\nfloat particle_amount = 70.;\n// vec3 watercolor = vec3(0.43, 0.60, 0.66); // 'transparent' low-water color (RGB)\n// vec3 watercolor2 = vec3(0.06, 0.07, 0.11); // deep-water color (RGB, should be darker than the low-water color)\nuniform vec4 u_watercolor;\nuniform vec4 u_watercolor2;\nvec3 water_specularcolor = vec3(1.3, 1.3, 0.9); // specular Color (RGB) of the water-highlights\n#define light vec3(-0., sin(u_time*0.5)*.5 + .35, 2.8) // position of the sun\n\nuniform sampler2D u_texture1;\nuniform sampler2D u_texture2;\nuniform sampler2D u_texture3;\n\n \n\nfloat hash( float n ) {\n return fract(sin(n)*43758.5453123);\n}\n\n// 2d noise function\nfloat noise1( in vec2 x ) {\n vec2 p = floor(x);\n vec2 f = smoothstep(0.0, 1.0, fract(x));\n float n = p.x + p.y*57.0;\n return mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),\n mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);\n}\n\nfloat noise(vec2 p) {\n return texture2D(u_texture2,p*vec2(1./256.)).x;\n}\n\nvec4 highness(vec2 p) {\n vec4 t = texture2D(u_texture1,fract(p));\n float clipped = -2.0-smoothstep(3.,10.,t.a)*6.9-smoothstep(10.,100.,t.a)*89.9-smoothstep(0.,10000.,t.a)*10000.0;\n return clamp(t, 0.0,3.0)+clamp(t/3.0-1.0, 0.0,1.0)+clamp(t/16.0-1.0, 0.0,1.0);\n}\n\nfloat height_map( vec2 p ) {\n vec4 height=highness(p);\n /*\n height = -0.5+\n 0.5*smoothstep(-100.,0.,-height)+\n 2.75*smoothstep(0.,2.,height)+\n 1.75*smoothstep(2.,4.,height)+\n 2.75*smoothstep(4.,16.,height)+\n 1.5*smoothstep(16.,1000.,height);\n */\n\n mat2 m = mat2( 0.9563*1.4, -0.2924*1.4, 0.2924*1.4, 0.9563*1.4 );\n //p = p*6.;\n float f = 0.6000*noise1( p ); p = m*p*1.1*6.;\n f += 0.2500*noise( p ); p = m*p*1.32;\n f += 0.1666*noise( p ); p = m*p*1.11;\n f += 0.0834*noise( p ); p = m*p*1.12;\n f += 0.0634*noise( p ); p = m*p*1.13;\n f += 0.0444*noise( p ); p = m*p*1.14;\n f += 0.0274*noise( p ); p = m*p*1.15;\n f += 0.0134*noise( p ); p = m*p*1.16;\n f += 0.0104*noise( p ); p = m*p*1.17;\n f += 0.0084*noise( p );\n f = .25*f+dot(height,vec4(-.03125,-.125,.25,.25))*.5;\n const float FLAT_LEVEL = 0.92525;\n //f = f*0.25+height*0.75;\n if (f<FLAT_LEVEL)\n f = f;\n else\n f = pow((f-FLAT_LEVEL)/(1.-FLAT_LEVEL), 2.)*(1.-FLAT_LEVEL)*2.0+FLAT_LEVEL; // makes a smooth coast-increase\n return clamp(f, 0., 10.);\n}\n\nvec3 plasma_quintic( float x ) {\n x = clamp( x, 0.0, 1.0);\n vec4 x1 = vec4( 1.0, x, x * x, x * x * x ); // 1 x x2 x3\n vec4 x2 = x1 * x1.w * x; // x4 x5 x6 x7\n return vec3(\n dot( x1.xyzw, vec4( +0.063861086, +1.992659096, -1.023901152, -0.490832805 ) ) + dot( x2.xy, vec2( +1.308442123, -0.914547012 ) ),\n dot( x1.xyzw, vec4( +0.049718590, -0.791144343, +2.892305078, +0.811726816 ) ) + dot( x2.xy, vec2( -4.686502417, +2.717794514 ) ),\n dot( x1.xyzw, vec4( +0.513275779, +1.580255060, -5.164414457, +4.559573646 ) ) + dot( x2.xy, vec2( -1.916810682, +0.570638854 ) ) );\n}\n\nvec4 color(vec2 p){\n vec4 c1 = vec4(1.7,1.6,.9,1);\n vec4 c2 = vec4(.2,.94,.1,1);\n vec4 c3 = vec4(.3,.2,.0,1);\n vec4 c4 = vec4(.99,.99,1.6,1);\n vec4 v = highness(p);\n float los = smoothstep(0.1,1.1,v.b);\n float his = smoothstep(3.5,6.5,v.b);\n float ces = smoothstep(1.,5.,v.a);\n vec4 lo = mix(c1,c2,los);\n vec4 hi = mix(c3,c4,his);\n vec4 ce = mix(lo,hi,ces);\n\n return vec4(plasma_quintic(ces),1).ragb;\n}\n\nvec3 terrain_map( vec2 p )\n{\n return color(p).rgb*0.75+0.25*vec3(0.7, .55, .4)+texture2D(u_texture3, fract(p*5.)).rgb*.5; // test-terrain is simply 'sandstone'\n}\n\nconst mat2 m = mat2( 0.72, -1.60, 1.60, 0.72 );\n\nfloat water_map( vec2 p, float height ) {\n vec2 p2 = p*large_wavesize;\n vec2 shift1 = 0.001*vec2( u_time*160.0*2.0, u_time*120.0*2.0 );\n vec2 shift2 = 0.001*vec2( u_time*190.0*2.0, -u_time*130.0*2.0 );\n\n // coarse crossing 'ocean' waves...\n float f = 0.6000*noise( p );\n f += 0.2500*noise( p*m );\n f += 0.1666*noise( p*m*m );\n float wave = sin(p2.x*0.622+p2.y*0.622+shift2.x*4.269)*large_waveheight*f*height*height ;\n\n p *= small_wavesize;\n f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<9; i++)\n { p = m*p*.947; f -= amp*abs(sin((noise( p+shift1*s )-.5)*2.)); amp = amp*.59; s*=-1.329; }\n \n return wave+f*small_waveheight;\n}\n\nfloat nautic(vec2 p) {\n p *= 18.;\n float f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*abs(smoothstep(0., 1., noise( p+u_time*s ))-.5); amp = amp*.5; s*=-1.227; }\n return pow(1.-f, 5.);\n}\n\nfloat particles(vec2 p) {\n p *= 200.;\n float f = 0.;\n float amp = 1.0, s = 1.5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*noise( p+u_time*s ); amp = amp*.5; s*=-1.227; }\n return pow(f*.35, 7.)*particle_amount;\n}\n\nfloat test_shadow( vec2 xy, float height) {\n vec3 r0 = vec3(xy, height);\n vec3 rd = normalize( light - r0 );\n \n float hit = 1.0;\n float t = 0.001;\n for (int j=1; j<25; j++)\n {\n vec3 p = r0 + t*rd;\n float h = height_map( p.xy );\n float height_diff = p.z - h;\n if (height_diff<0.0)\n {\n return 0.0;\n }\n t += 0.01+height_diff*.02;\n hit = min(hit, 2.*height_diff/t); // soft shaddow \n }\n return hit;\n}\n\nvec3 CalcTerrain(vec2 uv, float height) {\n vec3 col = terrain_map( uv );\n vec2 iResolution = vec2(512.);\n float h1 = height_map(uv-vec2(0., 0.5)/ iResolution.xy);\n float h2 = height_map(uv+vec2(0., 0.5)/ iResolution.xy);\n float h3 = height_map(uv-vec2(0.5, 0.)/ iResolution.xy);\n float h4 = height_map(uv+vec2(0.5, 0.)/ iResolution.xy);\n vec3 norm = normalize(vec3(h3-h4, h1-h2, 1.));\n vec3 r0 = vec3(uv, height);\n vec3 rd = normalize( light - r0 );\n float grad = dot(norm, rd);\n col *= grad+pow(grad, 8.);\n float terrainshade = test_shadow( uv, height );\n col = mix(col*.25, col, terrainshade);\n return col;\n}\n\n\nvoid main() {\n vec3 watercolor = u_watercolor.rgb;\n vec3 watercolor2 = u_watercolor2.rgb;\n vec2 uv = v_uv;\n float WATER_LEVEL = 0.84; // Water level (range: 0.0 - 2.0)\n float deepwater_fadedepth = 0.4 + coast2water_fadedepth;\n float height = height_map( uv );\n vec3 col;\n\n float waveheight = clamp(WATER_LEVEL*3.-1.5, 0., 1.);\n float level = WATER_LEVEL + .2*water_map(uv*15. + vec2(u_time*.1), waveheight);\n if (height > level)\n {\n col = CalcTerrain(uv, height);\n }\n if (height <= level)\n {\n vec2 dif = vec2(.0, .01);\n vec2 pos = uv*15. + vec2(u_time*.01);\n float h1 = water_map(pos-dif,waveheight);\n float h2 = water_map(pos+dif,waveheight);\n float h3 = water_map(pos-dif.yx,waveheight);\n float h4 = water_map(pos+dif.yx,waveheight);\n vec3 normwater = normalize(vec3(h3-h4, h1-h2, .125)); // norm-vector of the 'bumpy' water-plane\n uv += normwater.xy*.002*(level-height);\n \n col = CalcTerrain(uv, height);\n\n float coastfade = clamp((level-height)/coast2water_fadedepth, 0., 1.);\n float coastfade2= clamp((level-height)/deepwater_fadedepth, 0., 1.);\n float intensity = col.r*.2126+col.g*.7152+col.b*.0722;\n watercolor = mix(watercolor*intensity, watercolor2, smoothstep(0., 1., coastfade2));\n\n vec3 r0 = vec3(uv, WATER_LEVEL);\n vec3 rd = normalize( light - r0 ); // ray-direction to the light from water-position\n float grad = dot(normwater, rd); // dot-product of norm-vector and light-direction\n float specular = pow(grad, water_softlight_fact); // used for soft highlights \n float specular2= pow(grad, water_glossylight_fact); // used for glossy highlights\n float gradpos = dot(vec3(0., 0., 1.), rd);\n float specular1= smoothstep(0., 1., pow(gradpos, 5.)); // used for diffusity (some darker corona around light's specular reflections...) \n float watershade = test_shadow( uv, level );\n watercolor *= 2.2+watershade;\n watercolor += (.2+.8*watershade) * ((grad-1.0)*.5+specular) * .25;\n watercolor /= (1.+specular1*1.25);\n watercolor += watershade*specular2*water_specularcolor;\n watercolor += watershade*coastfade*(1.-coastfade2)*(vec3(.5, .6, .7)*nautic(uv)+vec3(1., 1., 1.)*particles(uv));\n \n col = mix(col, watercolor, coastfade);\n }\n \n\n float opacity = u_opacity;\n gl_FragColor = vec4(col, opacity); \n}\n";
19
18
  /* babel-plugin-inline-import '../shaders/water/polygon_ocean_vert.glsl' */
20
19
  var ocean_vert = "attribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec2 v_uv;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
20
+ var isNumber = lodashUtil.isNumber;
21
21
  var OceanModel = /*#__PURE__*/function (_BaseModel) {
22
22
  _inherits(OceanModel, _BaseModel);
23
23
  var _super = _createSuper(OceanModel);
@@ -10,13 +10,14 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
10
10
  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; } }
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
12
  import { Version } from '@antv/l7-maps';
13
- import { isNumber } from 'lodash';
13
+ import { lodashUtil } from '@antv/l7-utils';
14
14
  import BaseModel from "../../core/BaseModel";
15
15
  import { polygonTriangulation } from "../../core/triangulation";
16
16
  /* babel-plugin-inline-import '../shaders/water/polygon_water_frag.glsl' */
17
17
  var water_frag = "uniform sampler2D u_texture;\nuniform float u_time: 0.0;\nuniform float u_speed: 1.0;\nuniform float u_opacity: 1.0;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture2D(u_texture, p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n float opacity = u_opacity;\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n\n float spc = calSpc();\n gl_FragColor += spc * 0.4;\n}\n";
18
18
  /* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
19
19
  var water_vert = "attribute vec4 a_Color;\nattribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\nuniform float u_opacity: 1.0;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
20
+ var isNumber = lodashUtil.isNumber;
20
21
  var WaterModel = /*#__PURE__*/function (_BaseModel) {
21
22
  _inherits(WaterModel, _BaseModel);
22
23
  var _super = _createSuper(WaterModel);
@@ -83,7 +83,6 @@ export default abstract class Tile implements ITile {
83
83
  map?: import("@antv/l7-core").IMapWrapper | undefined;
84
84
  logoPosition?: import("@antv/l7-core").PositionName | undefined;
85
85
  logoVisible?: boolean | undefined;
86
- isMini?: boolean | undefined;
87
86
  animate?: boolean | undefined;
88
87
  pickBufferScale?: number | undefined;
89
88
  stencil?: boolean | undefined;
@@ -4,11 +4,12 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { TYPES } from '@antv/l7-core';
7
- import { debounce } from 'lodash';
7
+ import { lodashUtil } from '@antv/l7-utils';
8
8
  import { TileLayerService } from "../service/TileLayerService";
9
9
  import { TilePickService } from "../service/TilePickService";
10
10
  import { ProxyFuncs } from "../style/constants";
11
11
  import { getTileFactory } from "../tileFactory";
12
+ var debounce = lodashUtil.debounce;
12
13
  var BaseTileLayer = /*#__PURE__*/function () {
13
14
  // 瓦片是否加载成功
14
15
 
@@ -1,7 +1,7 @@
1
1
  import { Version } from '@antv/l7-maps';
2
2
  import Source from '@antv/l7-source';
3
- import { normalize, rgb2arr } from '@antv/l7-utils';
4
- import { cloneDeep } from 'lodash';
3
+ import { lodashUtil, normalize, rgb2arr } from '@antv/l7-utils';
4
+ var cloneDeep = lodashUtil.cloneDeep;
5
5
  function getArrowPoints(p1, p2) {
6
6
  var dir = [p2[0] - p1[0], p2[1] - p1[1]];
7
7
  var normalizeDir = normalize(dir);