@antv/l7-layers 2.21.8 → 2.21.9-beta.0

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 (279) hide show
  1. package/es/citybuliding/models/build.d.ts +16 -0
  2. package/es/citybuliding/models/build.js +18 -20
  3. package/es/citybuliding/shaders/build_frag.glsl +6 -6
  4. package/es/citybuliding/shaders/build_vert.glsl +8 -14
  5. package/es/core/BaseLayer.js +9 -8
  6. package/es/core/BaseModel.d.ts +15 -2
  7. package/es/core/BaseModel.js +94 -62
  8. package/es/core/CommonStyleAttribute.d.ts +14 -18
  9. package/es/core/CommonStyleAttribute.js +23 -67
  10. package/es/core/triangulation.js +13 -39
  11. package/es/earth/models/atmosphere.d.ts +15 -0
  12. package/es/earth/models/atmosphere.js +30 -24
  13. package/es/earth/models/base.d.ts +15 -0
  14. package/es/earth/models/base.js +30 -24
  15. package/es/earth/models/bloomsphere.d.ts +15 -0
  16. package/es/earth/models/bloomsphere.js +30 -24
  17. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  18. package/es/earth/shaders/base/base_vert.glsl +3 -3
  19. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  20. package/es/geometry/models/billboard.d.ts +15 -0
  21. package/es/geometry/models/billboard.js +14 -8
  22. package/es/geometry/models/plane.d.ts +14 -0
  23. package/es/geometry/models/plane.js +10 -10
  24. package/es/geometry/models/sprite.js +3 -9
  25. package/es/geometry/shaders/billboard_vert.glsl +28 -25
  26. package/es/geometry/shaders/plane_vert.glsl +6 -6
  27. package/es/geometry/shaders/sprite_vert.glsl +7 -9
  28. package/es/heatmap/models/grid.d.ts +14 -0
  29. package/es/heatmap/models/grid.js +10 -3
  30. package/es/heatmap/models/grid3d.d.ts +16 -0
  31. package/es/heatmap/models/grid3d.js +14 -6
  32. package/es/heatmap/models/heatmap.d.ts +20 -1
  33. package/es/heatmap/models/heatmap.js +96 -83
  34. package/es/heatmap/models/hexagon.d.ts +14 -0
  35. package/es/heatmap/models/hexagon.js +9 -3
  36. package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
  37. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  38. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  39. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  40. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  41. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  42. package/es/image/models/image.d.ts +14 -0
  43. package/es/image/models/image.js +11 -3
  44. package/es/image/shaders/image_vert.glsl +7 -6
  45. package/es/line/models/arc.d.ts +18 -0
  46. package/es/line/models/arc.js +57 -8
  47. package/es/line/models/arc_3d.d.ts +18 -0
  48. package/es/line/models/arc_3d.js +55 -7
  49. package/es/line/models/flow.d.ts +17 -0
  50. package/es/line/models/flow.js +35 -7
  51. package/es/line/models/great_circle.d.ts +17 -0
  52. package/es/line/models/great_circle.js +34 -6
  53. package/es/line/models/line.d.ts +17 -0
  54. package/es/line/models/line.js +17 -8
  55. package/es/line/models/simple_line.d.ts +14 -0
  56. package/es/line/models/simple_line.js +12 -47
  57. package/es/line/models/wall.d.ts +17 -0
  58. package/es/line/models/wall.js +22 -48
  59. package/es/line/shaders/arc/line_arc_vert.glsl +42 -48
  60. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  61. package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
  62. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +56 -72
  63. package/es/line/shaders/line/line_vert.glsl +31 -48
  64. package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
  65. package/es/line/shaders/wall/wall_vert.glsl +36 -45
  66. package/es/mask/models/fill.js +2 -1
  67. package/es/mask/shaders/mask_vert.glsl +2 -7
  68. package/es/plugins/DataMappingPlugin.d.ts +0 -1
  69. package/es/plugins/DataMappingPlugin.js +1 -24
  70. package/es/plugins/PixelPickingPlugin.js +2 -2
  71. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  72. package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
  73. package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
  74. package/es/plugins/ShaderUniformPlugin.js +2 -34
  75. package/es/point/models/billboard_point.d.ts +14 -0
  76. package/es/point/models/billboard_point.js +11 -3
  77. package/es/point/models/earthExtrude.d.ts +16 -0
  78. package/es/point/models/earthExtrude.js +15 -8
  79. package/es/point/models/earthFill.d.ts +16 -0
  80. package/es/point/models/earthFill.js +13 -5
  81. package/es/point/models/extrude.d.ts +16 -0
  82. package/es/point/models/extrude.js +19 -12
  83. package/es/point/models/fill.d.ts +16 -0
  84. package/es/point/models/fill.js +16 -5
  85. package/es/point/models/fillImage.d.ts +16 -0
  86. package/es/point/models/fillImage.js +16 -16
  87. package/es/point/models/image.d.ts +15 -0
  88. package/es/point/models/image.js +14 -4
  89. package/es/point/models/normal.d.ts +14 -0
  90. package/es/point/models/normal.js +11 -3
  91. package/es/point/models/radar.d.ts +15 -0
  92. package/es/point/models/radar.js +13 -4
  93. package/es/point/models/text.d.ts +16 -0
  94. package/es/point/models/text.js +18 -11
  95. package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  96. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  97. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  98. package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
  99. package/es/point/shaders/fill/fill_vert.glsl +12 -14
  100. package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  101. package/es/point/shaders/image/image_vert.glsl +15 -12
  102. package/es/point/shaders/normal/normal_vert.glsl +7 -10
  103. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  104. package/es/point/shaders/text/text_vert.glsl +10 -9
  105. package/es/polygon/models/extrude.d.ts +16 -0
  106. package/es/polygon/models/extrude.js +26 -26
  107. package/es/polygon/models/extrusion.d.ts +16 -0
  108. package/es/polygon/models/extrusion.js +34 -4
  109. package/es/polygon/models/fill.d.ts +14 -0
  110. package/es/polygon/models/fill.js +12 -4
  111. package/es/polygon/models/ocean.d.ts +14 -0
  112. package/es/polygon/models/ocean.js +11 -6
  113. package/es/polygon/models/water.d.ts +14 -0
  114. package/es/polygon/models/water.js +11 -6
  115. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  116. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  117. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  118. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  119. package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  120. package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
  121. package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  122. package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  123. package/es/raster/index.d.ts +1 -1
  124. package/es/raster/index.js +1 -1
  125. package/es/raster/models/raster.d.ts +14 -0
  126. package/es/raster/models/raster.js +12 -3
  127. package/es/raster/models/rasterRgb.d.ts +14 -0
  128. package/es/raster/models/rasterRgb.js +12 -3
  129. package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
  130. package/es/raster/models/rasterTerrainRgb.js +11 -3
  131. package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  132. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  133. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  134. package/es/tile/core/BaseLayer.js +0 -16
  135. package/es/utils/extrude_polyline.d.ts +0 -15
  136. package/es/utils/extrude_polyline.js +0 -217
  137. package/es/wind/models/wind.d.ts +14 -0
  138. package/es/wind/models/wind.js +9 -1
  139. package/es/wind/shaders/wind_vert.glsl +6 -5
  140. package/lib/citybuliding/models/build.d.ts +16 -0
  141. package/lib/citybuliding/models/build.js +18 -20
  142. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  143. package/lib/citybuliding/shaders/build_vert.glsl +8 -14
  144. package/lib/core/BaseLayer.js +9 -8
  145. package/lib/core/BaseModel.d.ts +15 -2
  146. package/lib/core/BaseModel.js +92 -60
  147. package/lib/core/CommonStyleAttribute.d.ts +14 -18
  148. package/lib/core/CommonStyleAttribute.js +23 -68
  149. package/lib/core/triangulation.js +13 -39
  150. package/lib/earth/models/atmosphere.d.ts +15 -0
  151. package/lib/earth/models/atmosphere.js +30 -24
  152. package/lib/earth/models/base.d.ts +15 -0
  153. package/lib/earth/models/base.js +30 -24
  154. package/lib/earth/models/bloomsphere.d.ts +15 -0
  155. package/lib/earth/models/bloomsphere.js +30 -24
  156. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  157. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  158. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  159. package/lib/geometry/models/billboard.d.ts +15 -0
  160. package/lib/geometry/models/billboard.js +14 -8
  161. package/lib/geometry/models/plane.d.ts +14 -0
  162. package/lib/geometry/models/plane.js +10 -10
  163. package/lib/geometry/models/sprite.js +3 -9
  164. package/lib/geometry/shaders/billboard_vert.glsl +28 -25
  165. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  166. package/lib/geometry/shaders/sprite_vert.glsl +7 -9
  167. package/lib/heatmap/models/grid.d.ts +14 -0
  168. package/lib/heatmap/models/grid.js +10 -3
  169. package/lib/heatmap/models/grid3d.d.ts +16 -0
  170. package/lib/heatmap/models/grid3d.js +14 -6
  171. package/lib/heatmap/models/heatmap.d.ts +20 -1
  172. package/lib/heatmap/models/heatmap.js +95 -82
  173. package/lib/heatmap/models/hexagon.d.ts +14 -0
  174. package/lib/heatmap/models/hexagon.js +9 -3
  175. package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
  176. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  177. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  178. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  179. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  180. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  181. package/lib/image/models/image.d.ts +14 -0
  182. package/lib/image/models/image.js +11 -3
  183. package/lib/image/shaders/image_vert.glsl +7 -6
  184. package/lib/line/models/arc.d.ts +18 -0
  185. package/lib/line/models/arc.js +56 -7
  186. package/lib/line/models/arc_3d.d.ts +18 -0
  187. package/lib/line/models/arc_3d.js +55 -7
  188. package/lib/line/models/flow.d.ts +17 -0
  189. package/lib/line/models/flow.js +35 -7
  190. package/lib/line/models/great_circle.d.ts +17 -0
  191. package/lib/line/models/great_circle.js +33 -5
  192. package/lib/line/models/line.d.ts +17 -0
  193. package/lib/line/models/line.js +17 -8
  194. package/lib/line/models/simple_line.d.ts +14 -0
  195. package/lib/line/models/simple_line.js +12 -47
  196. package/lib/line/models/wall.d.ts +17 -0
  197. package/lib/line/models/wall.js +22 -48
  198. package/lib/line/shaders/arc/line_arc_vert.glsl +42 -48
  199. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  200. package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
  201. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +56 -72
  202. package/lib/line/shaders/line/line_vert.glsl +31 -48
  203. package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
  204. package/lib/line/shaders/wall/wall_vert.glsl +36 -45
  205. package/lib/mask/models/fill.js +2 -1
  206. package/lib/mask/shaders/mask_vert.glsl +2 -7
  207. package/lib/plugins/DataMappingPlugin.d.ts +0 -1
  208. package/lib/plugins/DataMappingPlugin.js +0 -23
  209. package/lib/plugins/PixelPickingPlugin.js +1 -1
  210. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  211. package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
  212. package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
  213. package/lib/plugins/ShaderUniformPlugin.js +2 -34
  214. package/lib/point/models/billboard_point.d.ts +14 -0
  215. package/lib/point/models/billboard_point.js +11 -3
  216. package/lib/point/models/earthExtrude.d.ts +16 -0
  217. package/lib/point/models/earthExtrude.js +14 -7
  218. package/lib/point/models/earthFill.d.ts +16 -0
  219. package/lib/point/models/earthFill.js +13 -5
  220. package/lib/point/models/extrude.d.ts +16 -0
  221. package/lib/point/models/extrude.js +18 -11
  222. package/lib/point/models/fill.d.ts +16 -0
  223. package/lib/point/models/fill.js +16 -5
  224. package/lib/point/models/fillImage.d.ts +16 -0
  225. package/lib/point/models/fillImage.js +16 -16
  226. package/lib/point/models/image.d.ts +15 -0
  227. package/lib/point/models/image.js +14 -4
  228. package/lib/point/models/normal.d.ts +14 -0
  229. package/lib/point/models/normal.js +11 -3
  230. package/lib/point/models/radar.d.ts +15 -0
  231. package/lib/point/models/radar.js +13 -4
  232. package/lib/point/models/text.d.ts +16 -0
  233. package/lib/point/models/text.js +18 -11
  234. package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  235. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  236. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  237. package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
  238. package/lib/point/shaders/fill/fill_vert.glsl +12 -14
  239. package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  240. package/lib/point/shaders/image/image_vert.glsl +15 -12
  241. package/lib/point/shaders/normal/normal_vert.glsl +7 -10
  242. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  243. package/lib/point/shaders/text/text_vert.glsl +10 -9
  244. package/lib/polygon/models/extrude.d.ts +16 -0
  245. package/lib/polygon/models/extrude.js +25 -25
  246. package/lib/polygon/models/extrusion.d.ts +16 -0
  247. package/lib/polygon/models/extrusion.js +34 -4
  248. package/lib/polygon/models/fill.d.ts +14 -0
  249. package/lib/polygon/models/fill.js +12 -4
  250. package/lib/polygon/models/ocean.d.ts +14 -0
  251. package/lib/polygon/models/ocean.js +11 -6
  252. package/lib/polygon/models/water.d.ts +14 -0
  253. package/lib/polygon/models/water.js +11 -6
  254. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  255. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  256. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  257. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  258. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  259. package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
  260. package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  261. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  262. package/lib/raster/index.d.ts +1 -1
  263. package/lib/raster/index.js +2 -2
  264. package/lib/raster/models/raster.d.ts +14 -0
  265. package/lib/raster/models/raster.js +12 -3
  266. package/lib/raster/models/rasterRgb.d.ts +14 -0
  267. package/lib/raster/models/rasterRgb.js +12 -3
  268. package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
  269. package/lib/raster/models/rasterTerrainRgb.js +11 -3
  270. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  271. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  272. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  273. package/lib/tile/core/BaseLayer.js +0 -16
  274. package/lib/utils/extrude_polyline.d.ts +0 -15
  275. package/lib/utils/extrude_polyline.js +0 -217
  276. package/lib/wind/models/wind.d.ts +14 -0
  277. package/lib/wind/models/wind.js +9 -1
  278. package/lib/wind/shaders/wind_vert.glsl +6 -5
  279. package/package.json +6 -6
@@ -7,6 +7,20 @@ export declare function PointTriangulation(feature: IEncodeFeature): {
7
7
  size: number;
8
8
  };
9
9
  export default class NormalModel extends BaseModel {
10
+ protected get attributeLocation(): {
11
+ readonly POSITION: 0;
12
+ readonly POSITION_64LOW: 1;
13
+ readonly COLOR: 2;
14
+ readonly PICKING_COLOR: 3;
15
+ readonly STROKE: 4;
16
+ readonly OPACITY: 5;
17
+ readonly OFFSETS: 6;
18
+ readonly ROTATION: 7;
19
+ readonly MAX: 8;
20
+ } & Record<string, number> & {
21
+ MAX: 8;
22
+ SIZE: number;
23
+ };
10
24
  getDefaultStyle(): Partial<IPointLayerStyleOptions>;
11
25
  protected getCommonUniformsInfo(): {
12
26
  uniformsArray: number[];
@@ -9,11 +9,10 @@ exports.default = void 0;
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _l7Core = require("@antv/l7-core");
11
11
  var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
12
- var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
13
12
  /* babel-plugin-inline-import '../shaders/normal/normal_frag.glsl' */
14
13
  const normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}";
15
14
  /* babel-plugin-inline-import '../shaders/normal/normal_vert.glsl' */
16
- const normalVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout 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, 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(project_pos);\n }\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
15
+ const normalVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout 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 vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(project_pos);\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
17
16
  function PointTriangulation(feature) {
18
17
  const coordinates = feature.coordinates;
19
18
  return {
@@ -23,6 +22,12 @@ function PointTriangulation(feature) {
23
22
  };
24
23
  }
25
24
  class NormalModel extends _BaseModel.default {
25
+ get attributeLocation() {
26
+ return Object.assign(super.attributeLocation, {
27
+ MAX: super.attributeLocation.MAX,
28
+ SIZE: 9
29
+ });
30
+ }
26
31
  getDefaultStyle() {
27
32
  return {
28
33
  blend: 'additive'
@@ -51,6 +56,7 @@ class NormalModel extends _BaseModel.default {
51
56
  vertexShader: normalVert,
52
57
  fragmentShader: normalFrag,
53
58
  triangulation: PointTriangulation,
59
+ defines: _this2.getDefines(),
54
60
  inject: _this2.getInject(),
55
61
  depth: {
56
62
  enable: false
@@ -65,12 +71,14 @@ class NormalModel extends _BaseModel.default {
65
71
  return;
66
72
  }
67
73
  registerBuiltinAttributes() {
74
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
75
+ this.registerPosition64LowAttribute();
68
76
  this.styleAttributeService.registerStyleAttribute({
69
77
  name: 'size',
70
78
  type: _l7Core.AttributeType.Attribute,
71
79
  descriptor: {
72
80
  name: 'a_Size',
73
- shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
81
+ shaderLocation: this.attributeLocation.SIZE,
74
82
  buffer: {
75
83
  usage: _l7Core.gl.DYNAMIC_DRAW,
76
84
  data: [],
@@ -1,6 +1,21 @@
1
1
  import type { IAnimateOption, IAttribute, IElements, IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class RadarModel extends BaseModel {
4
+ protected get attributeLocation(): {
5
+ readonly POSITION: 0;
6
+ readonly POSITION_64LOW: 1;
7
+ readonly COLOR: 2;
8
+ readonly PICKING_COLOR: 3;
9
+ readonly STROKE: 4;
10
+ readonly OPACITY: 5;
11
+ readonly OFFSETS: 6;
12
+ readonly ROTATION: 7;
13
+ readonly MAX: 8;
14
+ } & Record<string, number> & {
15
+ MAX: 8;
16
+ SIZE: number;
17
+ EXTRUDE: number;
18
+ };
4
19
  protected getCommonUniformsInfo(): {
5
20
  uniformsArray: number[];
6
21
  uniformsLength: number;
@@ -10,12 +10,18 @@ var _l7Core = require("@antv/l7-core");
10
10
  var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
11
11
  var _interface = require("../../core/interface");
12
12
  var _triangulation = require("../../core/triangulation");
13
- var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
14
13
  /* babel-plugin-inline-import '../shaders/radar/radar_frag.glsl' */
15
14
  const pointFillFrag = "\nlayout(std140) uniform commonUniorm{\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\nin vec4 v_data;\nin vec4 v_color;\nin float v_radius;\nin vec2 v_extrude;\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df = sdCircle(v_data.xy, 1.0);\n float inner_df = sdCircle(v_data.xy, r);\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n outputColor = vec4(v_color.rgb, v_color.a);\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n } else {\n outputColor.a *= opacity_t;\n }\n\n if(outputColor.a > 0.0) {\n outputColor = filterColor(outputColor);\n }\n\n vec2 extrude = v_extrude;\n vec2 dir = normalize(extrude);\n vec2 baseDir = vec2(1.0, 0.0);\n float pi = 3.14159265359;\n float flag = sign(dir.y);\n float rades = dot(dir, baseDir);\n float radar_v = (flag - 1.0) * -0.5 * acos(rades)/pi;\n // simple AA\n if(radar_v > 0.99) {\n radar_v = 1.0 - (radar_v - 0.99)/0.01;\n }\n\n outputColor.a *= radar_v;\n}\n";
16
15
  /* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
17
- const pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniorm {\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\n\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\nout vec2 v_extrude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2( \n cos(time), sin(time), \n -sin(time), cos(time)\n );\n v_extrude = rotateMatrix * a_Extrude.xy;\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1.) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n v_radius = newSize;\n\n vec2 offset = (a_Extrude.xy * (newSize));\n vec3 aPosition = a_Position;\n \n offset = project_pixel(offset);\n \n v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
16
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniorm {\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\n\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\nout vec2 v_extrude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2(\n cos(time), sin(time),\n -sin(time), cos(time)\n );\n v_extrude = rotateMatrix * a_Extrude.xy;\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1.) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n v_radius = newSize;\n\n vec2 offset = (a_Extrude.xy * (newSize));\n\n offset = project_pixel(offset);\n\n v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
18
17
  class RadarModel extends _BaseModel.default {
18
+ get attributeLocation() {
19
+ return Object.assign(super.attributeLocation, {
20
+ MAX: super.attributeLocation.MAX,
21
+ SIZE: 9,
22
+ EXTRUDE: 10
23
+ });
24
+ }
19
25
  getCommonUniformsInfo() {
20
26
  const {
21
27
  blend,
@@ -52,6 +58,7 @@ class RadarModel extends _BaseModel.default {
52
58
  vertexShader: pointFillVert,
53
59
  fragmentShader: pointFillFrag,
54
60
  triangulation: _triangulation.PointFillTriangulation,
61
+ defines: _this2.getDefines(),
55
62
  inject: _this2.getInject(),
56
63
  depth: {
57
64
  enable: false
@@ -66,12 +73,14 @@ class RadarModel extends _BaseModel.default {
66
73
  return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];
67
74
  }
68
75
  registerBuiltinAttributes() {
76
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
77
+ this.registerPosition64LowAttribute();
69
78
  this.styleAttributeService.registerStyleAttribute({
70
79
  name: 'extrude',
71
80
  type: _l7Core.AttributeType.Attribute,
72
81
  descriptor: {
73
82
  name: 'a_Extrude',
74
- shaderLocation: _CommonStyleAttribute.ShaderLocation.EXTRUDE,
83
+ shaderLocation: this.attributeLocation.EXTRUDE,
75
84
  buffer: {
76
85
  // give the WebGL driver a hint that this buffer may change
77
86
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -92,7 +101,7 @@ class RadarModel extends _BaseModel.default {
92
101
  name: 'size',
93
102
  type: _l7Core.AttributeType.Attribute,
94
103
  descriptor: {
95
- shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
104
+ shaderLocation: this.attributeLocation.SIZE,
96
105
  name: 'a_Size',
97
106
  buffer: {
98
107
  // give the WebGL driver a hint that this buffer may change
@@ -7,6 +7,22 @@ export declare function TextTrianglation(feature: IEncodeFeature): {
7
7
  size: number;
8
8
  };
9
9
  export default class TextModel extends BaseModel {
10
+ protected get attributeLocation(): {
11
+ readonly POSITION: 0;
12
+ readonly POSITION_64LOW: 1;
13
+ readonly COLOR: 2;
14
+ readonly PICKING_COLOR: 3;
15
+ readonly STROKE: 4;
16
+ readonly OPACITY: 5;
17
+ readonly OFFSETS: 6;
18
+ readonly ROTATION: 7;
19
+ readonly MAX: 8;
20
+ } & Record<string, number> & {
21
+ MAX: 8;
22
+ SIZE: number;
23
+ TEXT_OFFSETS: number;
24
+ UV: number;
25
+ };
10
26
  glyphInfo: IEncodeFeature[];
11
27
  glyphInfoMap: {
12
28
  [key: string]: {
@@ -12,13 +12,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
12
12
  var _l7Core = require("@antv/l7-core");
13
13
  var _l7Utils = require("@antv/l7-utils");
14
14
  var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
15
- var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
16
15
  var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
17
16
  var _symbolLayout = require("../../utils/symbol-layout");
18
17
  /* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
19
18
  const textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(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 outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
20
19
  /* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
21
- const textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\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 = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\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";
20
+ const textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_TEXT_OFFSETS) in vec2 a_textOffsets;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\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), a_Position64Low);\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 = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\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";
22
21
  const {
23
22
  isEqual
24
23
  } = _l7Utils.lodashUtil;
@@ -69,6 +68,14 @@ class TextModel extends _BaseModel.default {
69
68
  yield _this.reBuildModel();
70
69
  }));
71
70
  }
71
+ get attributeLocation() {
72
+ return Object.assign(super.attributeLocation, {
73
+ MAX: super.attributeLocation.MAX,
74
+ SIZE: 9,
75
+ TEXT_OFFSETS: 10,
76
+ UV: 11
77
+ });
78
+ }
72
79
  getUninforms() {
73
80
  const commoninfo = this.getCommonUniformsInfo();
74
81
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -132,6 +139,7 @@ class TextModel extends _BaseModel.default {
132
139
  moduleName: 'pointText',
133
140
  vertexShader: textVert,
134
141
  fragmentShader: textFrag,
142
+ defines: _this3.getDefines(),
135
143
  inject: _this3.getInject(),
136
144
  triangulation: TextTrianglation.bind(_this3),
137
145
  depth: {
@@ -187,11 +195,13 @@ class TextModel extends _BaseModel.default {
187
195
  this.layer.off('remapping', this.mapping);
188
196
  }
189
197
  registerBuiltinAttributes() {
198
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
199
+ this.registerPosition64LowAttribute();
190
200
  this.styleAttributeService.registerStyleAttribute({
191
201
  name: 'textOffsets',
192
202
  type: _l7Core.AttributeType.Attribute,
193
203
  descriptor: {
194
- shaderLocation: 10,
204
+ shaderLocation: this.attributeLocation.TEXT_OFFSETS,
195
205
  name: 'a_textOffsets',
196
206
  // 文字偏移量
197
207
  buffer: {
@@ -211,7 +221,7 @@ class TextModel extends _BaseModel.default {
211
221
  type: _l7Core.AttributeType.Attribute,
212
222
  descriptor: {
213
223
  name: 'a_tex',
214
- shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
224
+ shaderLocation: this.attributeLocation.UV,
215
225
  buffer: {
216
226
  usage: _l7Core.gl.DYNAMIC_DRAW,
217
227
  data: [],
@@ -223,13 +233,14 @@ class TextModel extends _BaseModel.default {
223
233
  }
224
234
  }
225
235
  });
236
+
226
237
  // point layer size;
227
238
  this.styleAttributeService.registerStyleAttribute({
228
239
  name: 'size',
229
240
  type: _l7Core.AttributeType.Attribute,
230
241
  descriptor: {
231
242
  name: 'a_Size',
232
- shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
243
+ shaderLocation: this.attributeLocation.SIZE,
233
244
  buffer: {
234
245
  // give the WebGL driver a hint that this buffer may change
235
246
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -369,9 +380,6 @@ class TextModel extends _BaseModel.default {
369
380
  // feature.centroid = calculteCentroid(coordinates);
370
381
 
371
382
  feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
372
-
373
- // 此时地图高德2.0 originCentroid == centroid
374
- feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
375
383
  this.glyphInfoMap[id] = {
376
384
  shaping,
377
385
  glyphQuads,
@@ -421,9 +429,7 @@ class TextModel extends _BaseModel.default {
421
429
  shaping,
422
430
  id = 0
423
431
  } = feature;
424
- // const centroid = feature.centroid as [number, number];
425
- // const centroid = feature.originCentroid as [number, number];
426
- const centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
432
+ const centroid = feature.centroid;
427
433
  const size = feature.size;
428
434
  const fontScale = size / 16;
429
435
  const pixels = this.mapService.lngLatToContainer(centroid);
@@ -492,6 +498,7 @@ class TextModel extends _BaseModel.default {
492
498
  vertexShader: textVert,
493
499
  fragmentShader: textFrag,
494
500
  triangulation: TextTrianglation.bind(_this5),
501
+ defines: _this5.getDefines(),
495
502
  inject: _this5.getInject(),
496
503
  depth: {
497
504
  enable: false
@@ -1,7 +1,8 @@
1
1
 
2
- layout(location = 0) in vec3 a_Position;
3
- layout(location = 1) in vec4 a_Color;
4
- layout(location = 9) in float a_Size;
2
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
3
+ layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
4
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
5
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
5
6
 
6
7
  layout(std140) uniform commonUniorm {
7
8
  vec4 u_stroke_color;
@@ -19,18 +20,14 @@ out float v_innerRadius;
19
20
  #pragma include "project"
20
21
  void main() {
21
22
  v_color = vec4(a_Color.xyz, a_Color.w * opacity);
22
- v_blur = 1.0 - max(2.0/a_Size, 0.05);
23
+ v_blur = 1.0 - max(2.0 / a_Size, 0.05);
23
24
  v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);
24
-
25
+
25
26
  vec2 offset = project_pixel(u_offsets);
26
-
27
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
28
- gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);
29
- } else { // else
30
- vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);
31
- gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
32
- }
33
-
27
+
28
+ vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
29
+ gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
30
+
34
31
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
35
32
  setPickingColor(a_PickingColor);
36
33
  }
@@ -5,13 +5,11 @@ precision highp float;
5
5
  #define diffuseRatio 0.3
6
6
  #define specularRatio 0.2
7
7
 
8
-
9
- layout(location = 0) in vec3 a_Position;
10
- layout(location = 1) in vec4 a_Color;
11
- layout(location = 9) in vec3 a_Size;
12
- layout(location = 11) in vec3 a_Pos;
13
- layout(location = 13) in vec3 a_Normal;
14
-
8
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
9
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
10
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in vec3 a_Size;
11
+ layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
12
+ layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
15
13
 
16
14
  layout(std140) uniform commonUniform {
17
15
  vec4 u_sourceColor;
@@ -42,7 +40,7 @@ float getYRadian(float x, float z) {
42
40
  } else if(x > 0.0 && z <= 0.0){
43
41
  return atan(-z/x) + pi/2.0;
44
42
  } else if(x <= 0.0 && z <= 0.0) {
45
- return pi + atan(x/z); //atan(x/z) +
43
+ return pi + atan(x/z); //atan(x/z) +
46
44
  } else {
47
45
  return atan(z/-x) + pi*3.0/2.0;
48
46
  }
@@ -62,15 +60,7 @@ void main() {
62
60
 
63
61
  vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
64
62
  if(u_heightfixed < 1.0) { // 圆柱体不固定高度
65
-
66
- if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
67
- // P20 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减1
68
- offset = offset * pow(2.0, (19.0 - u_Zoom));
69
- }
70
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
71
- // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
72
- offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));
73
- }
63
+ //
74
64
  } else {// 圆柱体固定高度 ( 处理 mapbox )
75
65
  if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
76
66
  offset *= 4.0/pow(2.0, 21.0 - u_Zoom);
@@ -98,7 +88,7 @@ void main() {
98
88
  }
99
89
  v_color.a *= u_opacity;
100
90
 
101
-
91
+
102
92
  // 在地球模式下,将原本垂直于 xy 平面的圆柱调整姿态到适应圆的角度
103
93
  //旋转矩阵mx,创建绕x轴旋转矩阵
104
94
  float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);
@@ -106,9 +96,9 @@ void main() {
106
96
  float xcos = cos(xRadian);//求解旋转角度余弦值
107
97
  float xsin = sin(xRadian);//求解旋转角度正弦值
108
98
  mat4 mx = mat4(
109
- 1,0,0,0,
110
- 0,xcos,-xsin,0,
111
- 0,xsin,xcos,0,
99
+ 1,0,0,0,
100
+ 0,xcos,-xsin,0,
101
+ 0,xsin,xcos,0,
112
102
  0,0,0,1);
113
103
 
114
104
  //旋转矩阵my,创建绕y轴旋转矩阵
@@ -116,13 +106,13 @@ void main() {
116
106
  float ycos = cos(yRadian);//求解旋转角度余弦值
117
107
  float ysin = sin(yRadian);//求解旋转角度正弦值
118
108
  mat4 my = mat4(
119
- ycos,0,-ysin,0,
120
- 0,1,0,0,
121
- ysin,0,ycos,0,
109
+ ycos,0,-ysin,0,
110
+ 0,1,0,0,
111
+ ysin,0,ycos,0,
122
112
  0,0,0,1);
123
113
 
124
114
  gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);
125
-
115
+
126
116
 
127
117
  setPickingColor(a_PickingColor);
128
118
  }
@@ -1,8 +1,8 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
4
- layout(location = 10) in float a_Shape;
5
- layout(location = 11) in vec3 a_Extrude;
1
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
3
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
4
+ layout(location = ATTRIBUTE_LOCATION_SHAPE) in float a_Shape;
5
+ layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;
6
6
 
7
7
  layout(std140) uniform commonUniform {
8
8
  float u_additive;
@@ -43,4 +43,4 @@ void main() {
43
43
  gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + vec3(u_offsets,0.0), 1.0);
44
44
 
45
45
  setPickingColor(a_PickingColor);
46
- }
46
+ }
@@ -1,10 +1,10 @@
1
- #define pi 3.1415926535
1
+ #define pi (3.1415926535)
2
2
 
3
- layout(location = 0) in vec3 a_Position;
4
- layout(location = 1) in vec4 a_Color;
5
- layout(location = 9) in vec3 a_Size;
6
- layout(location = 11) in vec3 a_Extrude;
7
- layout(location = 13) in vec3 a_Normal;
3
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
4
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
5
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in vec3 a_Size;
6
+ layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec4 a_Extrude;
7
+ layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
8
8
 
9
9
  layout(std140) uniform commonUniforms {
10
10
  float u_pickLight;
@@ -25,46 +25,41 @@ out float v_lightWeight;
25
25
  #pragma include "picking"
26
26
 
27
27
  float getYRadian(float x, float z) {
28
- if(x > 0.0 && z > 0.0) {
29
- return atan(x/z);
30
- } else if(x > 0.0 && z <= 0.0){
31
- return atan(-z/x) + pi/2.0;
32
- } else if(x <= 0.0 && z <= 0.0) {
33
- return pi + atan(x/z); //atan(x/z) +
28
+ if (x > 0.0 && z > 0.0) {
29
+ return atan(x / z);
30
+ } else if (x > 0.0 && z <= 0.0) {
31
+ return atan(-z / x) + pi / 2.0;
32
+ } else if (x <= 0.0 && z <= 0.0) {
33
+ return pi + atan(x / z); //atan(x/z) +
34
34
  } else {
35
- return atan(z/-x) + pi*3.0/2.0;
35
+ return atan(z / -x) + pi * 3.0 / 2.0;
36
36
  }
37
37
  }
38
38
 
39
39
  float getXRadian(float y, float r) {
40
- return atan(y/r);
40
+ return atan(y / r);
41
41
  }
42
42
 
43
43
  void main() {
44
-
45
-
46
44
  vec3 size = a_Size * a_Position;
47
45
 
48
46
  vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
49
47
 
50
- if(u_heightfixed < 1.0) { // 圆柱体不固定高度
51
-
52
- if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
53
- // P20 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减1
54
- offset = offset * pow(2.0, (19.0 - u_Zoom));
55
- }
56
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
57
- // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
58
- offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));
59
- }
60
- } else {// 圆柱体固定高度 ( 处理 mapbox )
61
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
62
- offset *= 4.0/pow(2.0, 21.0 - u_Zoom);
48
+ if (u_heightfixed < 1.0) {
49
+ // 圆柱体不固定高度
50
+ } else {
51
+ // 圆柱体固定高度 处理 mapbox
52
+ if (
53
+ u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
54
+ u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
55
+ ) {
56
+ offset *= 4.0 / pow(2.0, 21.0 - u_Zoom);
63
57
  }
64
58
  }
65
59
 
66
-
67
- vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));
60
+ vec2 positions = a_Extrude.xy;
61
+ vec2 positions64Low = a_Extrude.zw;
62
+ vec4 project_pos = project_position(vec4(positions, 0.0, 1.0), positions64Low);
68
63
 
69
64
  // u_r 控制圆柱的生长
70
65
  vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
@@ -72,7 +67,8 @@ void main() {
72
67
  // // 圆柱光照效果
73
68
  float lightWeight = 1.0;
74
69
 
75
- if(u_lightEnable > 0.0) { // 取消三元表达式,增强健壮性
70
+ if (u_lightEnable > 0.0) {
71
+ // 取消三元表达式,增强健壮性
76
72
  lightWeight = calc_lighting(pos);
77
73
  }
78
74
 
@@ -80,20 +76,20 @@ void main() {
80
76
 
81
77
  v_color = a_Color;
82
78
 
83
- // 设置圆柱的底色
84
- if(u_linearColor == 1.0) { // 使用渐变颜色
79
+ // 设置圆柱的底色
80
+ if (u_linearColor == 1.0) {
81
+ // 使用渐变颜色
85
82
  v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
86
- v_color.a = v_color.a * opacity;
83
+ v_color.a = v_color.a * opacity;
87
84
  } else {
88
85
  v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
89
86
  }
90
87
 
91
- if(u_opacitylinear > 0.0) {
92
- v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;
88
+ if (u_opacitylinear > 0.0) {
89
+ v_color.a *= u_opacitylinear_dir > 0.0 ? 1.0 - a_Position.z : a_Position.z;
93
90
  }
94
91
 
95
-
96
- gl_Position = project_common_position_to_clipspace_v2(pos);
92
+ gl_Position = project_common_position_to_clipspace(pos);
97
93
 
98
94
  setPickingColor(a_PickingColor);
99
95
  }
@@ -1,8 +1,9 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
4
- layout(location = 10) in float a_Shape;
5
- layout(location = 11) in vec3 a_Extrude;
1
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
+ layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
3
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
4
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
5
+ layout(location = ATTRIBUTE_LOCATION_SHAPE) in float a_Shape;
6
+ layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;
6
7
 
7
8
  layout(std140) uniform commonUniforms {
8
9
  vec3 u_blur_height_fixed;
@@ -11,7 +12,7 @@ layout(std140) uniform commonUniforms {
11
12
  float u_stroke_opacity;
12
13
  float u_size_unit;
13
14
  float u_time;
14
- vec4 u_animate;
15
+ vec4 u_animate;
15
16
  };
16
17
 
17
18
  out vec4 v_color;
@@ -25,7 +26,7 @@ out float v_radius;
25
26
 
26
27
  void main() {
27
28
  // 透明度计算
28
- v_stroke = stroke;
29
+ v_stroke = stroke;
29
30
  vec3 extrude = a_Extrude;
30
31
  float shape_type = a_Shape;
31
32
  /*
@@ -51,17 +52,14 @@ void main() {
51
52
  float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);
52
53
 
53
54
  vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);
54
- vec3 aPosition = a_Position;
55
55
 
56
56
  offset = project_pixel(offset);
57
57
  offset = rotate_matrix(offset,rotation);
58
-
58
+
59
59
  // TODP: /abs(extrude.x) 是为了兼容地球模式
60
60
  v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
61
61
 
62
-
63
- // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
64
- vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
62
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);
65
63
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
66
64
 
67
65
  float raisingHeight = u_blur_height_fixed.y;
@@ -74,8 +72,8 @@ void main() {
74
72
  raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;
75
73
  }
76
74
  }
77
-
78
- gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));
75
+
76
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
79
77
 
80
78
  setPickingColor(a_PickingColor);
81
79
  }