@antv/l7-layers 2.16.0 → 2.16.2

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 (218) hide show
  1. package/es/core/BaseLayer.d.ts +3 -0
  2. package/es/core/BaseLayer.js +76 -80
  3. package/es/core/BaseModel.d.ts +9 -71
  4. package/es/core/BaseModel.js +75 -357
  5. package/es/core/CommonStyleAttribute.d.ts +2 -0
  6. package/es/core/CommonStyleAttribute.js +66 -0
  7. package/es/core/interface.d.ts +13 -3
  8. package/es/core/shape/extrude.js +18 -6
  9. package/es/core/triangulation.d.ts +12 -0
  10. package/es/core/triangulation.js +70 -0
  11. package/es/heatmap/models/grid.js +1 -1
  12. package/es/heatmap/models/grid3d.js +1 -1
  13. package/es/heatmap/models/heatmap.d.ts +1 -0
  14. package/es/heatmap/models/heatmap.js +17 -13
  15. package/es/heatmap/models/hexagon.js +1 -1
  16. package/es/heatmap/shaders/grid_vert.glsl +2 -2
  17. package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  18. package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
  19. package/es/line/index.d.ts +1 -0
  20. package/es/line/index.js +3 -2
  21. package/es/line/models/arc.js +9 -45
  22. package/es/line/models/arc_3d.js +12 -45
  23. package/es/line/models/earthArc_3d.js +6 -40
  24. package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
  25. package/es/line/models/flow.js +167 -0
  26. package/es/line/models/great_circle.js +4 -38
  27. package/es/line/models/index.d.ts +1 -1
  28. package/es/line/models/index.js +3 -3
  29. package/es/line/models/line.js +7 -41
  30. package/es/line/models/linearline.js +4 -38
  31. package/es/line/models/simpleLine.d.ts +0 -1
  32. package/es/line/models/simpleLine.js +4 -43
  33. package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
  34. package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
  35. package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
  36. package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
  37. package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
  38. package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
  39. package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
  40. package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
  41. package/es/line/shaders/line_arc_frag.glsl +7 -11
  42. package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  43. package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  44. package/es/line/shaders/line_arc_vert.glsl +9 -45
  45. package/es/line/shaders/line_frag.glsl +15 -17
  46. package/es/line/shaders/line_vert.glsl +3 -34
  47. package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  48. package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  49. package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
  50. package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
  51. package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
  52. package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  53. package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  54. package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
  55. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  56. package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
  57. package/es/plugins/DataMappingPlugin.js +20 -34
  58. package/es/plugins/LayerModelPlugin.js +13 -1
  59. package/es/plugins/ShaderUniformPlugin.js +3 -3
  60. package/es/point/index.d.ts +1 -0
  61. package/es/point/index.js +1 -0
  62. package/es/point/models/earthExtrude.d.ts +0 -3
  63. package/es/point/models/earthExtrude.js +2 -40
  64. package/es/point/models/earthFill.d.ts +0 -1
  65. package/es/point/models/earthFill.js +9 -60
  66. package/es/point/models/extrude.d.ts +0 -3
  67. package/es/point/models/extrude.js +3 -42
  68. package/es/point/models/fill.d.ts +0 -1
  69. package/es/point/models/fill.js +15 -76
  70. package/es/point/models/fillmage.js +6 -43
  71. package/es/point/models/image.js +7 -41
  72. package/es/point/models/normal.js +2 -2
  73. package/es/point/models/radar.d.ts +0 -1
  74. package/es/point/models/radar.js +4 -13
  75. package/es/point/models/simplePoint.d.ts +0 -1
  76. package/es/point/models/simplePoint.js +8 -49
  77. package/es/point/models/text.js +17 -47
  78. package/es/point/shaders/animate/wave_frag.glsl +1 -11
  79. package/es/point/shaders/earth/extrude_frag.glsl +5 -17
  80. package/es/point/shaders/earth/extrude_vert.glsl +14 -29
  81. package/es/point/shaders/earth/fill_frag.glsl +5 -14
  82. package/es/point/shaders/earth/fill_vert.glsl +1 -75
  83. package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
  84. package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
  85. package/es/point/shaders/fill_frag.glsl +9 -20
  86. package/es/point/shaders/fill_vert.glsl +16 -101
  87. package/es/point/shaders/image/fillImage_frag.glsl +2 -5
  88. package/es/point/shaders/image/fillImage_vert.glsl +4 -47
  89. package/es/point/shaders/image_frag.glsl +1 -5
  90. package/es/point/shaders/image_vert.glsl +1 -44
  91. package/es/point/shaders/normal_frag.glsl +0 -2
  92. package/es/point/shaders/normal_vert.glsl +2 -1
  93. package/es/point/shaders/radar/radar_vert.glsl +2 -2
  94. package/es/point/shaders/simplePoint_frag.glsl +0 -7
  95. package/es/point/shaders/simplePoint_vert.glsl +3 -45
  96. package/es/point/shaders/text_frag.glsl +6 -19
  97. package/es/point/shaders/text_vert.glsl +5 -66
  98. package/es/polygon/index.d.ts +1 -0
  99. package/es/polygon/index.js +1 -0
  100. package/es/polygon/models/extrude.d.ts +0 -3
  101. package/es/polygon/models/extrude.js +86 -82
  102. package/es/polygon/models/fill.d.ts +0 -4
  103. package/es/polygon/models/fill.js +8 -47
  104. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  105. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  106. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  107. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  108. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  109. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  110. package/es/polygon/shaders/polygon_frag.glsl +0 -5
  111. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
  112. package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
  113. package/es/polygon/shaders/polygon_vert.glsl +1 -27
  114. package/es/utils/layerData.js +2 -2
  115. package/lib/core/BaseLayer.js +74 -78
  116. package/lib/core/BaseModel.js +74 -356
  117. package/lib/core/CommonStyleAttribute.js +72 -0
  118. package/lib/core/shape/extrude.js +18 -6
  119. package/lib/core/triangulation.js +72 -0
  120. package/lib/heatmap/models/grid.js +1 -1
  121. package/lib/heatmap/models/grid3d.js +1 -1
  122. package/lib/heatmap/models/heatmap.js +17 -13
  123. package/lib/heatmap/models/hexagon.js +1 -1
  124. package/lib/heatmap/shaders/grid_vert.glsl +2 -2
  125. package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  126. package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
  127. package/lib/line/index.js +3 -2
  128. package/lib/line/models/arc.js +9 -45
  129. package/lib/line/models/arc_3d.js +12 -45
  130. package/lib/line/models/earthArc_3d.js +6 -40
  131. package/lib/line/models/flow.js +174 -0
  132. package/lib/line/models/great_circle.js +4 -38
  133. package/lib/line/models/index.js +3 -3
  134. package/lib/line/models/line.js +7 -41
  135. package/lib/line/models/linearline.js +4 -38
  136. package/lib/line/models/simpleLine.js +4 -43
  137. package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
  138. package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
  139. package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
  140. package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
  141. package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
  142. package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
  143. package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
  144. package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
  145. package/lib/line/shaders/line_arc_frag.glsl +7 -11
  146. package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  147. package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  148. package/lib/line/shaders/line_arc_vert.glsl +9 -45
  149. package/lib/line/shaders/line_frag.glsl +15 -17
  150. package/lib/line/shaders/line_vert.glsl +3 -34
  151. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  152. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  153. package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
  154. package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
  155. package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
  156. package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  157. package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  158. package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
  159. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  160. package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
  161. package/lib/plugins/DataMappingPlugin.js +20 -34
  162. package/lib/plugins/LayerModelPlugin.js +13 -1
  163. package/lib/plugins/ShaderUniformPlugin.js +3 -3
  164. package/lib/point/index.js +1 -0
  165. package/lib/point/models/earthExtrude.js +2 -40
  166. package/lib/point/models/earthFill.js +9 -60
  167. package/lib/point/models/extrude.js +3 -42
  168. package/lib/point/models/fill.js +15 -76
  169. package/lib/point/models/fillmage.js +6 -43
  170. package/lib/point/models/image.js +7 -41
  171. package/lib/point/models/normal.js +2 -2
  172. package/lib/point/models/radar.js +4 -13
  173. package/lib/point/models/simplePoint.js +8 -49
  174. package/lib/point/models/text.js +15 -45
  175. package/lib/point/shaders/animate/wave_frag.glsl +1 -11
  176. package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
  177. package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
  178. package/lib/point/shaders/earth/fill_frag.glsl +5 -14
  179. package/lib/point/shaders/earth/fill_vert.glsl +1 -75
  180. package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
  181. package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
  182. package/lib/point/shaders/fill_frag.glsl +9 -20
  183. package/lib/point/shaders/fill_vert.glsl +16 -101
  184. package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
  185. package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
  186. package/lib/point/shaders/image_frag.glsl +1 -5
  187. package/lib/point/shaders/image_vert.glsl +1 -44
  188. package/lib/point/shaders/normal_frag.glsl +0 -2
  189. package/lib/point/shaders/normal_vert.glsl +2 -1
  190. package/lib/point/shaders/radar/radar_vert.glsl +2 -2
  191. package/lib/point/shaders/simplePoint_frag.glsl +0 -7
  192. package/lib/point/shaders/simplePoint_vert.glsl +3 -45
  193. package/lib/point/shaders/text_frag.glsl +6 -19
  194. package/lib/point/shaders/text_vert.glsl +5 -66
  195. package/lib/polygon/index.js +1 -0
  196. package/lib/polygon/models/extrude.js +86 -82
  197. package/lib/polygon/models/fill.js +8 -47
  198. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  199. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  200. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  201. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  202. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  203. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  204. package/lib/polygon/shaders/polygon_frag.glsl +0 -5
  205. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
  206. package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
  207. package/lib/polygon/shaders/polygon_vert.glsl +1 -27
  208. package/lib/utils/layerData.js +2 -2
  209. package/package.json +7 -7
  210. package/es/line/models/half.js +0 -267
  211. package/es/line/shaders/half/line_half_frag.glsl +0 -53
  212. package/es/line/shaders/half/line_half_vert.glsl +0 -169
  213. package/es/utils/dataMappingStyle.d.ts +0 -31
  214. package/es/utils/dataMappingStyle.js +0 -137
  215. package/lib/line/models/half.js +0 -274
  216. package/lib/line/shaders/half/line_half_frag.glsl +0 -53
  217. package/lib/line/shaders/half/line_half_vert.glsl +0 -169
  218. package/lib/utils/dataMappingStyle.js +0 -140
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -14,19 +15,18 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
14
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
16
  var _l7Core = require("@antv/l7-core");
16
17
  var _l7Utils = require("@antv/l7-utils");
17
- var _lodash = require("lodash");
18
18
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
19
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/polygon_frag.glsl' */
23
- var polygon_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
23
+ var polygon_frag = "varying vec4 v_color;\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
24
24
  /* babel-plugin-inline-import '../shaders/polygon_linear_frag.glsl' */
25
- var polygon_linear_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nuniform float u_opacitylinear: 0.0;\nuniform float u_dir: 1.0;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n \n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
25
+ var polygon_linear_frag = "#pragma include \"picking\"\nuniform float u_opacitylinear: 0.0;\nuniform float u_dir: 1.0;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\n\nvoid main() {\n \n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
26
26
  /* babel-plugin-inline-import '../shaders/polygon_linear_vert.glsl' */
27
- var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_opacity: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nuniform float u_opacitylinear: 0.0;\n\nattribute vec3 a_linear;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n project_pos.z += u_raisingHeight;\n\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 project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\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 setPickingColor(a_PickingColor);\n}";
27
+ var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nuniform float u_opacitylinear: 0.0;\n\nattribute vec3 a_linear;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n project_pos.z += u_raisingHeight;\n\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 project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\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 setPickingColor(a_PickingColor);\n}";
28
28
  /* babel-plugin-inline-import '../shaders/polygon_vert.glsl' */
29
- var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_opacity: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_color;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\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\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n project_pos.z += u_raisingHeight;\n\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 project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\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 setPickingColor(a_PickingColor);\n}\n\n";
29
+ var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_color;\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 // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n project_pos.z += u_raisingHeight;\n\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 project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\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 setPickingColor(a_PickingColor);\n}\n\n";
30
30
  var FillModel = /*#__PURE__*/function (_BaseModel) {
31
31
  (0, _inherits2.default)(FillModel, _BaseModel);
32
32
  var _super = _createSuper(FillModel);
@@ -40,50 +40,16 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
40
40
  var _ref = this.layer.getLayerConfig(),
41
41
  _ref$raisingHeight = _ref.raisingHeight,
42
42
  raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
43
- _ref$opacity = _ref.opacity,
44
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
45
43
  _ref$opacityLinear = _ref.opacityLinear,
46
44
  opacityLinear = _ref$opacityLinear === void 0 ? {
47
45
  enable: false,
48
46
  dir: 'in'
49
47
  } : _ref$opacityLinear;
50
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
51
- opacity: opacity
52
- })) {
53
- this.judgeStyleAttributes({
54
- opacity: opacity
55
- });
56
- var encodeData = this.layer.getEncodedData();
57
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
58
- data = _this$calDataFrame.data,
59
- width = _this$calDataFrame.width,
60
- height = _this$calDataFrame.height;
61
- this.rowCount = height; // 当前数据纹理有多少行
62
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
63
- flipY: true,
64
- data: data,
65
- format: _l7Core.gl.LUMINANCE,
66
- type: _l7Core.gl.FLOAT,
67
- width: width,
68
- height: height
69
- }) : this.createTexture2D({
70
- flipY: true,
71
- data: [1],
72
- format: _l7Core.gl.LUMINANCE,
73
- type: _l7Core.gl.FLOAT,
74
- width: 1,
75
- height: 1
76
- });
77
- }
78
- return {
79
- u_dataTexture: this.dataTexture,
80
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
81
- u_cellTypeLayout: this.getCellTypeLayout(),
48
+ return (0, _objectSpread2.default)({
82
49
  u_raisingHeight: Number(raisingHeight),
83
- u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
84
50
  u_opacitylinear: Number(opacityLinear.enable),
85
51
  u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0
86
- };
52
+ }, this.getStyleAttribute());
87
53
  }
88
54
  }, {
89
55
  key: "initModels",
@@ -120,6 +86,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
120
86
  moduleName: type,
121
87
  vertexShader: vert,
122
88
  fragmentShader: frag,
89
+ inject: this.getInject(),
123
90
  triangulation: triangulation,
124
91
  primitive: _l7Core.gl.TRIANGLES,
125
92
  depth: {
@@ -145,12 +112,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
145
112
  }
146
113
  return buildModels;
147
114
  }()
148
- }, {
149
- key: "clearModels",
150
- value: function clearModels() {
151
- var _this$dataTexture;
152
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
153
- }
154
115
  }, {
155
116
  key: "registerBuiltinAttributes",
156
117
  value: function registerBuiltinAttributes() {
@@ -1,4 +1,3 @@
1
- uniform float u_opacity: 1.0;
2
1
  uniform vec4 u_sourceColor;
3
2
  uniform vec4 u_targetColor;
4
3
  uniform float u_linearColor: 0;
@@ -7,39 +6,19 @@ uniform float u_topsurface: 1.0;
7
6
  uniform float u_sidesurface: 1.0;
8
7
 
9
8
  varying vec4 v_Color;
10
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
9
+
11
10
  #pragma include "picking"
12
11
 
13
12
  void main() {
14
- float opacity = styleMappingMat[0][0];
15
- float isSide = styleMappingMat[0][3];
16
- float sidey = styleMappingMat[3][0];
17
- float lightWeight = styleMappingMat[3][1];
18
-
19
- // Tip: 部分机型 GPU 计算精度兼容
20
- if(isSide < 0.999) {
21
- // side face
22
- if(u_sidesurface < 1.0) {
23
- discard;
24
- }
25
13
 
26
- if(u_linearColor == 1.0) {
27
- vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);
28
- linearColor.rgb *= lightWeight;
29
- gl_FragColor = linearColor;
30
- } else {
31
- gl_FragColor = v_Color;
32
- }
33
14
 
34
- } else {
35
15
  // top face
36
16
  if(u_topsurface < 1.0) {
37
17
  discard;
38
18
  }
39
19
 
40
20
  gl_FragColor = v_Color;
41
- }
21
+
42
22
 
43
- gl_FragColor.a *= opacity;
44
23
  gl_FragColor = filterColor(gl_FragColor);
45
24
  }
@@ -7,14 +7,16 @@ uniform float u_topsurface: 1.0;
7
7
  uniform float u_sidesurface: 1.0;
8
8
 
9
9
  varying vec4 v_Color;
10
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
10
+ varying vec3 v_uvs;
11
+ varying vec2 v_texture_data;
12
+
11
13
  #pragma include "picking"
12
14
 
13
15
  void main() {
14
- float opacity = styleMappingMat[0][0];
15
- float isSide = styleMappingMat[0][3];
16
- float sidey = styleMappingMat[3][0];
17
- float lightWeight = styleMappingMat[3][1];
16
+ float opacity = u_opacity;
17
+ float isSide = v_texture_data.x;
18
+ float sidey = v_uvs[2];
19
+ float lightWeight = v_texture_data.y;
18
20
 
19
21
  // Tip: 部分机型 GPU 计算精度兼容
20
22
  if(isSide < 0.999) {
@@ -12,46 +12,22 @@ attribute vec3 a_uvs;
12
12
  uniform mat4 u_ModelMatrix;
13
13
  uniform mat4 u_Mvp;
14
14
 
15
- varying vec4 v_Color;
16
15
  uniform float u_heightfixed: 0.0; // 默认不固定
17
16
  uniform float u_raisingHeight: 0.0;
18
- uniform float u_opacity: 1.0;
19
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
20
17
 
21
- #pragma include "styleMapping"
22
- #pragma include "styleMappingCalOpacity"
18
+ varying vec2 v_texture_data;
19
+ varying vec3 v_uvs;
20
+ varying vec4 v_Color;
21
+
23
22
 
24
23
  #pragma include "projection"
25
24
  #pragma include "light"
26
25
  #pragma include "picking"
27
26
 
28
27
  void main() {
29
- // cal style mapping - 数据纹理映射部分的计算
30
- styleMappingMat = mat4(
31
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide
32
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
33
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
34
- 0.0, 0.0, 0.0, 0.0 // sidey
35
- );
36
- styleMappingMat[0][3] = a_Position.z;
37
- styleMappingMat[3][0] = a_uvs[2];
38
28
 
39
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
40
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
41
- float columnWidth = 1.0/columnCount; // 列宽
42
- float rowHeight = 1.0/rowCount; // 行高
43
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
44
- float id = a_vertexId; // 第n个顶点
45
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
46
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
47
-
48
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
49
- // 按顺序从 cell 中取值、若没有则自动往下取值
50
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
51
29
 
52
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
53
- styleMappingMat[0][0] = opacityAndOffset.r;
54
- textureOffset = opacityAndOffset.g;
30
+ v_uvs = a_uvs;
55
31
  // cal style mapping - 数据纹理映射部分的计算
56
32
  vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
57
33
  vec4 project_pos = project_position(pos);
@@ -76,10 +52,9 @@ void main() {
76
52
  }
77
53
 
78
54
  float lightWeight = calc_lighting(pos);
79
- // v_Color = a_Color;
80
- v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);
55
+ v_texture_data = vec2(a_Position.z,lightWeight);
81
56
 
82
- styleMappingMat[3][1] = lightWeight;
57
+ v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);
83
58
 
84
59
  setPickingColor(a_PickingColor);
85
60
  }
@@ -11,50 +11,31 @@ attribute float a_Size;
11
11
  attribute vec3 a_uvs;
12
12
  uniform mat4 u_ModelMatrix;
13
13
  uniform mat4 u_Mvp;
14
+ uniform vec4 u_sourceColor;
15
+ uniform vec4 u_targetColor;
16
+ uniform float u_linearColor: 0;
17
+
18
+ uniform float u_topsurface: 1.0;
19
+ uniform float u_sidesurface: 1.0;
14
20
 
15
21
  varying vec4 v_Color;
16
22
  uniform float u_heightfixed: 0.0; // 默认不固定
17
23
  uniform float u_raisingHeight: 0.0;
18
- uniform float u_opacity: 1.0;
19
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
20
-
21
- #pragma include "styleMapping"
22
- #pragma include "styleMappingCalOpacity"
23
24
 
24
25
  #pragma include "projection"
25
26
  #pragma include "light"
26
27
  #pragma include "picking"
27
28
 
28
29
  void main() {
29
- // cal style mapping - 数据纹理映射部分的计算
30
- styleMappingMat = mat4(
31
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide
32
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
33
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
34
- 0.0, 0.0, 0.0, 0.0 // sidey
35
- );
36
- styleMappingMat[0][3] = a_Position.z;
37
- styleMappingMat[3][0] = a_uvs[2];
38
-
39
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
40
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
41
- float columnWidth = 1.0/columnCount; // 列宽
42
- float rowHeight = 1.0/rowCount; // 行高
43
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
44
- float id = a_vertexId; // 第n个顶点
45
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
46
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
47
-
48
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
49
- // 按顺序从 cell 中取值、若没有则自动往下取值
50
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
51
-
52
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
53
- styleMappingMat[0][0] = opacityAndOffset.r;
54
- textureOffset = opacityAndOffset.g;
55
- // cal style mapping - 数据纹理映射部分的计算
30
+
31
+ float isSide = a_Position.z;
32
+ float topU = a_uvs[0];
33
+ float topV = 1.0 - a_uvs[1];
34
+ float sidey = a_uvs[2];
56
35
 
57
36
  vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
37
+ float lightWeight = calc_lighting(pos);
38
+
58
39
  vec4 project_pos = project_position(pos);
59
40
 
60
41
  if(u_heightfixed > 0.0) { // 判断几何体是否固定高度
@@ -68,10 +49,7 @@ void main() {
68
49
  }
69
50
  }
70
51
 
71
- // project_pos.z += 500000.0; // amap1
72
52
 
73
- // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox
74
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
75
53
 
76
54
  if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
77
55
  // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));
@@ -80,11 +58,28 @@ void main() {
80
58
  gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
81
59
  }
82
60
 
83
- float lightWeight = calc_lighting(pos);
61
+ // Tip: 部分机型 GPU 计算精度兼容
62
+ if(isSide < 0.999) {
63
+ // side face
64
+ // if(u_sidesurface < 1.0) {
65
+ // discard;
66
+ // }
67
+
68
+ if(u_linearColor == 1.0) {
69
+ vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);
70
+ linearColor.rgb *= lightWeight;
71
+ v_Color = linearColor;
72
+ } else {
73
+ v_Color = a_Color;
74
+ }
75
+
76
+ } else {
77
+ v_Color = a_Color;
78
+ }
79
+
84
80
  // v_Color = a_Color;
85
- v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);
81
+ v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
86
82
 
87
- styleMappingMat[3][1] = lightWeight;
88
83
 
89
84
  setPickingColor(a_PickingColor);
90
85
  }
@@ -8,19 +8,21 @@ uniform float u_topsurface: 1.0;
8
8
  uniform float u_sidesurface: 1.0;
9
9
 
10
10
  varying vec4 v_Color;
11
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
11
+ varying vec3 v_uvs;
12
+ varying vec2 v_texture_data;
13
+
14
+
12
15
  #pragma include "picking"
13
16
 
14
17
  void main() {
15
- float opacity = styleMappingMat[0][0];
16
- float isSide = styleMappingMat[0][3];
17
- float lightWeight = styleMappingMat[3][1];
18
- float topU = styleMappingMat[2][2];
19
- float topV = styleMappingMat[2][3];
20
-
21
- float sidey = styleMappingMat[3][0];
18
+ float opacity = u_opacity;
19
+ float isSide = v_texture_data.x;
20
+ float lightWeight = v_texture_data.y;
21
+ float topU = v_uvs[0];
22
+ float topV = 1.0 - v_uvs[1];
23
+ float sidey = v_uvs[2];
22
24
  // Tip: 部分机型 GPU 计算精度兼容
23
- if(isSide < 0.999) {
25
+ if(isSide < 0.999) {// 是否是边缘
24
26
  // side face
25
27
  if(u_sidesurface < 1.0) {
26
28
  discard;
@@ -41,6 +43,7 @@ void main() {
41
43
  }
42
44
 
43
45
  gl_FragColor = texture2D(u_texture, vec2(topU, topV));
46
+ // gl_FragColor = vec4(1.0, 0., 0., 1.0);
44
47
  }
45
48
 
46
49
 
@@ -11,57 +11,33 @@ attribute float a_Size;
11
11
  attribute vec3 a_uvs;
12
12
  uniform mat4 u_ModelMatrix;
13
13
  uniform mat4 u_Mvp;
14
+ uniform sampler2D u_texture;
14
15
 
16
+
17
+ uniform vec4 u_sourceColor;
18
+ uniform vec4 u_targetColor;
19
+ uniform float u_topsurface: 1.0;
20
+ uniform float u_sidesurface: 1.0;
15
21
  varying vec4 v_Color;
16
22
  uniform float u_heightfixed: 0.0; // 默认不固定
17
23
  uniform float u_raisingHeight: 0.0;
18
- uniform float u_opacity: 1.0;
19
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
24
+ uniform float u_linearColor: 0.0;
20
25
 
21
- #pragma include "styleMapping"
22
- #pragma include "styleMappingCalOpacity"
26
+ varying vec2 v_texture_data;
27
+ varying vec3 v_uvs;
23
28
 
24
29
  #pragma include "projection"
25
30
  #pragma include "light"
26
31
  #pragma include "picking"
27
32
 
28
33
  void main() {
29
- v_Color = a_Color;
30
-
31
- // cal style mapping - 数据纹理映射部分的计算
32
- styleMappingMat = mat4(
33
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - a_Position.z(judge side by a_Position.z)
34
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
35
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - u - v
36
- 0.0, 0.0, 0.0, 0.0 // sidey
37
- );
38
-
39
- styleMappingMat[0][3] = a_Position.z;
40
- styleMappingMat[2][2] = a_uvs[0];
41
- styleMappingMat[2][3] = 1.0 - a_uvs[1];
42
- styleMappingMat[3][0] = a_uvs[2];
43
-
44
-
45
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
46
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
47
- float columnWidth = 1.0/columnCount; // 列宽
48
- float rowHeight = 1.0/rowCount; // 行高
49
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
50
- float id = a_vertexId; // 第n个顶点
51
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
52
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
53
-
54
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
55
- // 按顺序从 cell 中取值、若没有则自动往下取值
56
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
57
-
58
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
59
- styleMappingMat[0][0] = opacityAndOffset.r;
60
- textureOffset = opacityAndOffset.g;
61
- // cal style mapping - 数据纹理映射部分的计算
62
-
34
+
63
35
  vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);
36
+ float lightWeight = calc_lighting(pos);
64
37
  vec4 project_pos = project_position(pos);
38
+ v_uvs = a_uvs;
39
+
40
+ v_texture_data = vec2(a_Position.z, lightWeight);
65
41
 
66
42
  if(u_heightfixed > 0.0) { // 判断几何体是否固定高度
67
43
  project_pos.z = a_Position.z * a_Size;
@@ -74,10 +50,6 @@ void main() {
74
50
  }
75
51
  }
76
52
 
77
- // project_pos.z += 500000.0; // amap1
78
-
79
- // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox
80
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
81
53
 
82
54
  if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
83
55
  // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));
@@ -86,8 +58,8 @@ void main() {
86
58
  gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
87
59
  }
88
60
 
89
- float lightWeight = calc_lighting(pos);
90
- styleMappingMat[3][1] = lightWeight;
61
+
62
+
91
63
 
92
64
  setPickingColor(a_PickingColor);
93
65
  }
@@ -1,12 +1,7 @@
1
- uniform float u_opacity: 1.0;
2
1
  varying vec4 v_color;
3
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
4
-
5
2
  #pragma include "picking"
6
3
 
7
4
  void main() {
8
- float opacity = styleMappingMat[0][0];
9
5
  gl_FragColor = v_color;
10
- gl_FragColor.a *= opacity;
11
6
  gl_FragColor = filterColor(gl_FragColor);
12
7
  }
@@ -1,7 +1,3 @@
1
- uniform float u_opacity: 1.0;
2
- varying vec4 v_Color;
3
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
4
-
5
1
  #pragma include "picking"
6
2
  uniform float u_opacitylinear: 0.0;
7
3
  uniform float u_dir: 1.0;
@@ -10,13 +6,9 @@ varying vec2 v_pos;
10
6
 
11
7
 
12
8
  void main() {
13
- float opacity = styleMappingMat[0][0];
14
- gl_FragColor = v_Color;
15
9
 
16
10
  if(u_opacitylinear > 0.0) {
17
11
  gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;
18
12
  }
19
-
20
- gl_FragColor.a *= opacity;
21
13
  gl_FragColor = filterColor(gl_FragColor);
22
14
  }
@@ -3,14 +3,10 @@ attribute vec3 a_Position;
3
3
 
4
4
  uniform mat4 u_ModelMatrix;
5
5
  uniform mat4 u_Mvp;
6
- uniform float u_opacity: 1.0;
7
6
  uniform float u_raisingHeight: 0.0;
8
7
 
9
8
  varying vec4 v_Color;
10
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
11
9
 
12
- #pragma include "styleMapping"
13
- #pragma include "styleMappingCalOpacity"
14
10
 
15
11
  #pragma include "projection"
16
12
  #pragma include "picking"
@@ -26,34 +22,6 @@ void main() {
26
22
  v_linear = a_linear;
27
23
  v_pos = a_Position.xy;
28
24
  }
29
-
30
- // cal style mapping - 数据纹理映射部分的计算
31
- styleMappingMat = mat4(
32
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
33
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
34
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
35
- 0.0, 0.0, 0.0, 0.0
36
- );
37
-
38
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
39
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
40
- float columnWidth = 1.0/columnCount; // 列宽
41
- float rowHeight = 1.0/rowCount; // 行高
42
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
43
- float id = a_vertexId; // 第n个顶点
44
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
45
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
46
-
47
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
48
- // 按顺序从 cell 中取值、若没有则自动往下取值
49
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
50
-
51
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
52
- styleMappingMat[0][0] = opacityAndOffset.r;
53
- textureOffset = opacityAndOffset.g;
54
- // cal style mapping - 数据纹理映射部分的计算
55
-
56
- v_Color = a_Color;
57
25
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
58
26
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
59
27
  project_pos.z += u_raisingHeight;
@@ -4,46 +4,20 @@ attribute vec3 a_Position;
4
4
  uniform mat4 u_ModelMatrix;
5
5
  uniform mat4 u_Mvp;
6
6
 
7
- uniform float u_opacity: 1.0;
8
7
  uniform float u_raisingHeight: 0.0;
9
8
 
10
9
  varying vec4 v_color;
11
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
12
10
 
13
- #pragma include "styleMapping"
14
- #pragma include "styleMappingCalOpacity"
15
11
 
16
12
  #pragma include "projection"
17
13
  #pragma include "picking"
18
14
 
19
15
  void main() {
20
16
  // cal style mapping - 数据纹理映射部分的计算
21
- styleMappingMat = mat4(
22
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
23
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
24
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
25
- 0.0, 0.0, 0.0, 0.0
26
- );
27
17
 
28
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
29
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
30
- float columnWidth = 1.0/columnCount; // 列宽
31
- float rowHeight = 1.0/rowCount; // 行高
32
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
33
- float id = a_vertexId; // 第n个顶点
34
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
35
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
36
-
37
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
38
- // 按顺序从 cell 中取值、若没有则自动往下取值
39
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
40
-
41
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
42
- styleMappingMat[0][0] = opacityAndOffset.r;
43
- textureOffset = opacityAndOffset.g;
44
18
  // cal style mapping - 数据纹理映射部分的计算
45
19
 
46
- v_color = a_Color;
20
+ v_color = vec4(a_Color.xyz, a_Color.w * opacity);
47
21
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
48
22
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
49
23
 
@@ -32,7 +32,7 @@ function adjustData2Amap2Coordinates(mappedData, mapService, layer) {
32
32
  d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
33
33
  // @ts-ignore
34
34
  // d.coordinates = mapService.lngLatToCoord(d.coordinates);
35
- d.coordinates = mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
35
+ d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
36
36
  });
37
37
  } else {
38
38
  // 连续的线、面数据
@@ -47,7 +47,7 @@ function adjustData2Amap2Coordinates(mappedData, mapService, layer) {
47
47
  d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
48
48
  // @ts-ignore
49
49
  // d.coordinates = mapService.lngLatToCoords(d.coordinates);
50
- d.coordinates = mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
50
+ d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
51
51
  });
52
52
  }
53
53
  }