@antv/l7-layers 2.21.10 → 2.21.11-beta.1

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 (287) 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.d.ts +0 -1
  6. package/es/core/BaseLayer.js +9 -19
  7. package/es/core/BaseModel.d.ts +15 -2
  8. package/es/core/BaseModel.js +98 -64
  9. package/es/core/CommonStyleAttribute.d.ts +14 -18
  10. package/es/core/CommonStyleAttribute.js +23 -67
  11. package/es/core/shape/extrude.js +6 -3
  12. package/es/core/triangulation.js +22 -50
  13. package/es/core/utils.d.ts +4 -0
  14. package/es/core/utils.js +33 -0
  15. package/es/earth/models/atmosphere.d.ts +15 -0
  16. package/es/earth/models/atmosphere.js +30 -24
  17. package/es/earth/models/base.d.ts +15 -0
  18. package/es/earth/models/base.js +30 -24
  19. package/es/earth/models/bloomsphere.d.ts +15 -0
  20. package/es/earth/models/bloomsphere.js +30 -24
  21. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  22. package/es/earth/shaders/base/base_vert.glsl +3 -3
  23. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  24. package/es/geometry/models/billboard.d.ts +15 -0
  25. package/es/geometry/models/billboard.js +14 -8
  26. package/es/geometry/models/plane.d.ts +14 -0
  27. package/es/geometry/models/plane.js +10 -10
  28. package/es/geometry/models/sprite.js +3 -9
  29. package/es/geometry/shaders/billboard_vert.glsl +28 -25
  30. package/es/geometry/shaders/plane_vert.glsl +6 -6
  31. package/es/geometry/shaders/sprite_vert.glsl +7 -9
  32. package/es/heatmap/models/grid.d.ts +14 -0
  33. package/es/heatmap/models/grid.js +10 -3
  34. package/es/heatmap/models/grid3d.d.ts +16 -0
  35. package/es/heatmap/models/grid3d.js +14 -6
  36. package/es/heatmap/models/heatmap.d.ts +20 -1
  37. package/es/heatmap/models/heatmap.js +96 -83
  38. package/es/heatmap/models/hexagon.d.ts +14 -0
  39. package/es/heatmap/models/hexagon.js +9 -3
  40. package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
  41. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  42. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  43. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  44. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  45. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  46. package/es/image/models/image.d.ts +14 -0
  47. package/es/image/models/image.js +11 -7
  48. package/es/image/shaders/image_vert.glsl +7 -6
  49. package/es/line/models/arc.d.ts +18 -0
  50. package/es/line/models/arc.js +57 -8
  51. package/es/line/models/arc_3d.d.ts +18 -0
  52. package/es/line/models/arc_3d.js +55 -7
  53. package/es/line/models/flow.d.ts +17 -0
  54. package/es/line/models/flow.js +35 -7
  55. package/es/line/models/great_circle.d.ts +17 -0
  56. package/es/line/models/great_circle.js +34 -6
  57. package/es/line/models/line.d.ts +17 -0
  58. package/es/line/models/line.js +17 -8
  59. package/es/line/models/simple_line.d.ts +14 -0
  60. package/es/line/models/simple_line.js +12 -47
  61. package/es/line/models/wall.d.ts +17 -0
  62. package/es/line/models/wall.js +22 -48
  63. package/es/line/shaders/arc/line_arc_vert.glsl +44 -52
  64. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  65. package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
  66. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
  67. package/es/line/shaders/line/line_vert.glsl +31 -48
  68. package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
  69. package/es/line/shaders/wall/wall_vert.glsl +36 -45
  70. package/es/mask/models/fill.js +2 -1
  71. package/es/mask/shaders/mask_vert.glsl +2 -7
  72. package/es/plugins/DataMappingPlugin.d.ts +0 -1
  73. package/es/plugins/DataMappingPlugin.js +1 -24
  74. package/es/plugins/PixelPickingPlugin.js +2 -2
  75. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  76. package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
  77. package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
  78. package/es/plugins/ShaderUniformPlugin.js +4 -35
  79. package/es/point/models/billboard_point.d.ts +14 -0
  80. package/es/point/models/billboard_point.js +11 -3
  81. package/es/point/models/earthExtrude.d.ts +16 -0
  82. package/es/point/models/earthExtrude.js +15 -8
  83. package/es/point/models/earthFill.d.ts +16 -0
  84. package/es/point/models/earthFill.js +13 -5
  85. package/es/point/models/extrude.d.ts +16 -0
  86. package/es/point/models/extrude.js +19 -12
  87. package/es/point/models/fill.d.ts +16 -0
  88. package/es/point/models/fill.js +16 -5
  89. package/es/point/models/fillImage.d.ts +16 -0
  90. package/es/point/models/fillImage.js +16 -16
  91. package/es/point/models/image.d.ts +15 -0
  92. package/es/point/models/image.js +14 -4
  93. package/es/point/models/normal.d.ts +14 -0
  94. package/es/point/models/normal.js +11 -3
  95. package/es/point/models/radar.d.ts +15 -0
  96. package/es/point/models/radar.js +13 -4
  97. package/es/point/models/text.d.ts +16 -0
  98. package/es/point/models/text.js +18 -11
  99. package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  100. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  101. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  102. package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
  103. package/es/point/shaders/fill/fill_vert.glsl +12 -14
  104. package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  105. package/es/point/shaders/image/image_vert.glsl +15 -12
  106. package/es/point/shaders/normal/normal_vert.glsl +7 -10
  107. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  108. package/es/point/shaders/text/text_vert.glsl +10 -9
  109. package/es/polygon/models/extrude.d.ts +16 -0
  110. package/es/polygon/models/extrude.js +26 -26
  111. package/es/polygon/models/extrusion.d.ts +16 -0
  112. package/es/polygon/models/extrusion.js +34 -4
  113. package/es/polygon/models/fill.d.ts +14 -0
  114. package/es/polygon/models/fill.js +12 -4
  115. package/es/polygon/models/ocean.d.ts +14 -0
  116. package/es/polygon/models/ocean.js +11 -6
  117. package/es/polygon/models/water.d.ts +14 -0
  118. package/es/polygon/models/water.js +11 -6
  119. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  120. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  121. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  122. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  123. package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  124. package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
  125. package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  126. package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  127. package/es/raster/index.d.ts +1 -1
  128. package/es/raster/index.js +1 -1
  129. package/es/raster/models/raster.d.ts +14 -0
  130. package/es/raster/models/raster.js +13 -3
  131. package/es/raster/models/rasterRgb.d.ts +14 -0
  132. package/es/raster/models/rasterRgb.js +12 -3
  133. package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
  134. package/es/raster/models/rasterTerrainRgb.js +11 -3
  135. package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  136. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  137. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  138. package/es/tile/core/BaseLayer.js +0 -16
  139. package/es/utils/extrude_polyline.d.ts +0 -15
  140. package/es/utils/extrude_polyline.js +0 -217
  141. package/es/wind/models/wind.d.ts +14 -0
  142. package/es/wind/models/wind.js +9 -1
  143. package/es/wind/shaders/wind_vert.glsl +6 -5
  144. package/lib/citybuliding/models/build.d.ts +16 -0
  145. package/lib/citybuliding/models/build.js +18 -20
  146. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  147. package/lib/citybuliding/shaders/build_vert.glsl +8 -14
  148. package/lib/core/BaseLayer.d.ts +0 -1
  149. package/lib/core/BaseLayer.js +9 -19
  150. package/lib/core/BaseModel.d.ts +15 -2
  151. package/lib/core/BaseModel.js +96 -62
  152. package/lib/core/CommonStyleAttribute.d.ts +14 -18
  153. package/lib/core/CommonStyleAttribute.js +23 -68
  154. package/lib/core/shape/extrude.js +6 -3
  155. package/lib/core/triangulation.js +22 -50
  156. package/lib/core/utils.d.ts +4 -0
  157. package/lib/core/utils.js +35 -0
  158. package/lib/earth/models/atmosphere.d.ts +15 -0
  159. package/lib/earth/models/atmosphere.js +30 -24
  160. package/lib/earth/models/base.d.ts +15 -0
  161. package/lib/earth/models/base.js +30 -24
  162. package/lib/earth/models/bloomsphere.d.ts +15 -0
  163. package/lib/earth/models/bloomsphere.js +30 -24
  164. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  165. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  166. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  167. package/lib/geometry/models/billboard.d.ts +15 -0
  168. package/lib/geometry/models/billboard.js +14 -8
  169. package/lib/geometry/models/plane.d.ts +14 -0
  170. package/lib/geometry/models/plane.js +10 -10
  171. package/lib/geometry/models/sprite.js +3 -9
  172. package/lib/geometry/shaders/billboard_vert.glsl +28 -25
  173. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  174. package/lib/geometry/shaders/sprite_vert.glsl +7 -9
  175. package/lib/heatmap/models/grid.d.ts +14 -0
  176. package/lib/heatmap/models/grid.js +10 -3
  177. package/lib/heatmap/models/grid3d.d.ts +16 -0
  178. package/lib/heatmap/models/grid3d.js +14 -6
  179. package/lib/heatmap/models/heatmap.d.ts +20 -1
  180. package/lib/heatmap/models/heatmap.js +95 -82
  181. package/lib/heatmap/models/hexagon.d.ts +14 -0
  182. package/lib/heatmap/models/hexagon.js +9 -3
  183. package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
  184. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  185. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  186. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  187. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  188. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  189. package/lib/image/models/image.d.ts +14 -0
  190. package/lib/image/models/image.js +11 -7
  191. package/lib/image/shaders/image_vert.glsl +7 -6
  192. package/lib/line/models/arc.d.ts +18 -0
  193. package/lib/line/models/arc.js +56 -7
  194. package/lib/line/models/arc_3d.d.ts +18 -0
  195. package/lib/line/models/arc_3d.js +55 -7
  196. package/lib/line/models/flow.d.ts +17 -0
  197. package/lib/line/models/flow.js +35 -7
  198. package/lib/line/models/great_circle.d.ts +17 -0
  199. package/lib/line/models/great_circle.js +33 -5
  200. package/lib/line/models/line.d.ts +17 -0
  201. package/lib/line/models/line.js +17 -8
  202. package/lib/line/models/simple_line.d.ts +14 -0
  203. package/lib/line/models/simple_line.js +12 -47
  204. package/lib/line/models/wall.d.ts +17 -0
  205. package/lib/line/models/wall.js +22 -48
  206. package/lib/line/shaders/arc/line_arc_vert.glsl +44 -52
  207. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  208. package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
  209. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
  210. package/lib/line/shaders/line/line_vert.glsl +31 -48
  211. package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
  212. package/lib/line/shaders/wall/wall_vert.glsl +36 -45
  213. package/lib/mask/models/fill.js +2 -1
  214. package/lib/mask/shaders/mask_vert.glsl +2 -7
  215. package/lib/plugins/DataMappingPlugin.d.ts +0 -1
  216. package/lib/plugins/DataMappingPlugin.js +0 -23
  217. package/lib/plugins/PixelPickingPlugin.js +1 -1
  218. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  219. package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
  220. package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
  221. package/lib/plugins/ShaderUniformPlugin.js +4 -35
  222. package/lib/point/models/billboard_point.d.ts +14 -0
  223. package/lib/point/models/billboard_point.js +11 -3
  224. package/lib/point/models/earthExtrude.d.ts +16 -0
  225. package/lib/point/models/earthExtrude.js +14 -7
  226. package/lib/point/models/earthFill.d.ts +16 -0
  227. package/lib/point/models/earthFill.js +13 -5
  228. package/lib/point/models/extrude.d.ts +16 -0
  229. package/lib/point/models/extrude.js +18 -11
  230. package/lib/point/models/fill.d.ts +16 -0
  231. package/lib/point/models/fill.js +16 -5
  232. package/lib/point/models/fillImage.d.ts +16 -0
  233. package/lib/point/models/fillImage.js +16 -16
  234. package/lib/point/models/image.d.ts +15 -0
  235. package/lib/point/models/image.js +14 -4
  236. package/lib/point/models/normal.d.ts +14 -0
  237. package/lib/point/models/normal.js +11 -3
  238. package/lib/point/models/radar.d.ts +15 -0
  239. package/lib/point/models/radar.js +13 -4
  240. package/lib/point/models/text.d.ts +16 -0
  241. package/lib/point/models/text.js +18 -11
  242. package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  243. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  244. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  245. package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
  246. package/lib/point/shaders/fill/fill_vert.glsl +12 -14
  247. package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  248. package/lib/point/shaders/image/image_vert.glsl +15 -12
  249. package/lib/point/shaders/normal/normal_vert.glsl +7 -10
  250. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  251. package/lib/point/shaders/text/text_vert.glsl +10 -9
  252. package/lib/polygon/models/extrude.d.ts +16 -0
  253. package/lib/polygon/models/extrude.js +25 -25
  254. package/lib/polygon/models/extrusion.d.ts +16 -0
  255. package/lib/polygon/models/extrusion.js +34 -4
  256. package/lib/polygon/models/fill.d.ts +14 -0
  257. package/lib/polygon/models/fill.js +12 -4
  258. package/lib/polygon/models/ocean.d.ts +14 -0
  259. package/lib/polygon/models/ocean.js +11 -6
  260. package/lib/polygon/models/water.d.ts +14 -0
  261. package/lib/polygon/models/water.js +11 -6
  262. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  263. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  264. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  265. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  266. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  267. package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
  268. package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  269. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  270. package/lib/raster/index.d.ts +1 -1
  271. package/lib/raster/index.js +2 -2
  272. package/lib/raster/models/raster.d.ts +14 -0
  273. package/lib/raster/models/raster.js +13 -3
  274. package/lib/raster/models/rasterRgb.d.ts +14 -0
  275. package/lib/raster/models/rasterRgb.js +12 -3
  276. package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
  277. package/lib/raster/models/rasterTerrainRgb.js +11 -3
  278. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  279. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  280. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  281. package/lib/tile/core/BaseLayer.js +0 -16
  282. package/lib/utils/extrude_polyline.d.ts +0 -15
  283. package/lib/utils/extrude_polyline.js +0 -217
  284. package/lib/wind/models/wind.d.ts +14 -0
  285. package/lib/wind/models/wind.js +9 -1
  286. package/lib/wind/shaders/wind_vert.glsl +6 -5
  287. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  import { AttributeType, gl } from '@antv/l7-core';
2
- import { ShaderLocation } from "../core/CommonStyleAttribute";
2
+ import { COMMON_ATTRIBUTE_LOCATION } from "../core/CommonStyleAttribute";
3
3
  import { isTileGroup } from "../tile/utils/utils";
4
4
 
5
5
  /**
@@ -27,7 +27,6 @@ export default class RegisterStyleAttributePlugin {
27
27
  this.registerPositionAttribute(styleAttributeService);
28
28
  // this.registerFilterAttribute(styleAttributeService);//数据层数据过滤
29
29
  this.registerColorAttribute(styleAttributeService);
30
- this.registerVertexIdAttribute(styleAttributeService);
31
30
  }
32
31
  registerPositionAttribute(styleAttributeService) {
33
32
  styleAttributeService.registerStyleAttribute({
@@ -35,7 +34,7 @@ export default class RegisterStyleAttributePlugin {
35
34
  type: AttributeType.Attribute,
36
35
  descriptor: {
37
36
  name: 'a_Position',
38
- shaderLocation: ShaderLocation.POSITION,
37
+ shaderLocation: COMMON_ATTRIBUTE_LOCATION.POSITION,
39
38
  buffer: {
40
39
  data: [],
41
40
  type: gl.FLOAT
@@ -53,7 +52,7 @@ export default class RegisterStyleAttributePlugin {
53
52
  type: AttributeType.Attribute,
54
53
  descriptor: {
55
54
  name: 'a_Color',
56
- shaderLocation: ShaderLocation.COLOR,
55
+ shaderLocation: COMMON_ATTRIBUTE_LOCATION.COLOR,
57
56
  buffer: {
58
57
  // give the WebGL driver a hint that this buffer may change
59
58
  usage: gl.DYNAMIC_DRAW,
@@ -70,25 +69,4 @@ export default class RegisterStyleAttributePlugin {
70
69
  }
71
70
  });
72
71
  }
73
- registerVertexIdAttribute(styleAttributeService) {
74
- styleAttributeService.registerStyleAttribute({
75
- // 统一注册每个顶点的唯一编号(目前用于样式的数据映射计算使用)
76
- name: 'vertexId',
77
- type: AttributeType.Attribute,
78
- descriptor: {
79
- name: 'a_vertexId',
80
- shaderLocation: ShaderLocation.VERTEX_ID,
81
- buffer: {
82
- // give the WebGL driver a hint that this buffer may change
83
- usage: gl.DYNAMIC_DRAW,
84
- data: [],
85
- type: gl.FLOAT
86
- },
87
- size: 1,
88
- update: (feature, featureIdx) => {
89
- return [featureIdx];
90
- }
91
- }
92
- });
93
- }
94
72
  }
@@ -13,10 +13,5 @@ export default class ShaderUniformPlugin implements ILayerPlugin {
13
13
  private mapService;
14
14
  private layerService;
15
15
  apply(layer: ILayer, { rendererService, mapService, layerService, coordinateSystemService, cameraService, }: L7Container): void;
16
- /**
17
- * 对于每个 layer 都有不同的几何中心点,因此在绘制每个 layer 的时候都需要重新设置
18
- * @param layer
19
- */
20
- private setLayerCenter;
21
16
  private generateUBO;
22
17
  }
@@ -29,15 +29,13 @@ export default class ShaderUniformPlugin {
29
29
  this.layerService = layerService;
30
30
  this.coordinateSystemService = coordinateSystemService;
31
31
  this.cameraService = cameraService;
32
- const version = this.mapService.version;
33
- let mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
34
- let sceneCenterMercator = [0, 0];
35
32
  let uniformBuffer;
36
33
  if (!this.rendererService.uniformBuffers[0]) {
37
34
  // Create a Uniform Buffer Object(UBO).
38
35
  uniformBuffer = this.rendererService.createBuffer({
39
36
  data: new Float32Array(16 * 4 + 4 * 7),
40
- isUBO: true
37
+ isUBO: true,
38
+ label: 'renderUniformBuffer'
41
39
  });
42
40
  this.rendererService.uniformBuffers[0] = uniformBuffer;
43
41
  }
@@ -46,19 +44,6 @@ export default class ShaderUniformPlugin {
46
44
  const offset = layer.getLayerConfig().tileOrigin;
47
45
  // 重新计算坐标系参数
48
46
  this.coordinateSystemService.refresh(offset);
49
- if (version === 'GAODE2.x') {
50
- this.setLayerCenter(layer);
51
- // @ts-ignore
52
- mvp = this.mapService.map.customCoords.getMVPMatrix();
53
- // mvp = amapCustomCoords.getMVPMatrix()
54
- // @ts-ignore
55
- sceneCenterMercator = this.mapService.getCustomCoordCenter();
56
- const uniformBuffer = layer.getLayerUniformBuffer();
57
- uniformBuffer.subData({
58
- offset: 0,
59
- data: new Uint8Array(new Float32Array([...mvp, ...sceneCenterMercator]).buffer)
60
- });
61
- }
62
47
  const {
63
48
  width,
64
49
  height
@@ -66,7 +51,7 @@ export default class ShaderUniformPlugin {
66
51
  const {
67
52
  data,
68
53
  uniforms
69
- } = this.generateUBO(mvp, sceneCenterMercator, width, height);
54
+ } = this.generateUBO(width, height);
70
55
  if (this.layerService.alreadyInRendering && this.rendererService.uniformBuffers[0]) {
71
56
  const renderUniformBuffer = this.rendererService.uniformBuffers[0];
72
57
  // Update only once since all models can share one UBO.
@@ -90,20 +75,7 @@ export default class ShaderUniformPlugin {
90
75
  }
91
76
  });
92
77
  }
93
-
94
- /**
95
- * 对于每个 layer 都有不同的几何中心点,因此在绘制每个 layer 的时候都需要重新设置
96
- * @param layer
97
- */
98
- setLayerCenter(layer) {
99
- if (layer.coordCenter === undefined) {
100
- layer.coordCenter = layer.getSource().center;
101
- }
102
- if (this.mapService.setCoordCenter) {
103
- this.mapService.setCoordCenter(layer.coordCenter);
104
- }
105
- }
106
- generateUBO(u_Mvp, sceneCenterMercator, width, height) {
78
+ generateUBO(width, height) {
107
79
  const u_ProjectionMatrix = this.cameraService.getProjectionMatrix();
108
80
  const u_ViewMatrix = this.cameraService.getViewMatrix();
109
81
  const u_ViewProjectionMatrix = this.cameraService.getViewProjectionMatrix();
@@ -163,9 +135,6 @@ export default class ShaderUniformPlugin {
163
135
  [CoordinateUniform.PixelsPerDegree]: u_PixelsPerDegree,
164
136
  [CoordinateUniform.PixelsPerDegree2]: u_PixelsPerDegree2,
165
137
  [CoordinateUniform.PixelsPerMeter]: u_PixelsPerMeter,
166
- // 坐标系是高德2.0的时候单独计算
167
- [CoordinateUniform.Mvp]: u_Mvp,
168
- u_sceneCenterMercator: sceneCenterMercator,
169
138
  // 其他参数,例如视口大小、DPR 等
170
139
  u_ViewportSize: u_ViewportSize,
171
140
  u_ModelMatrix,
@@ -7,6 +7,20 @@ export declare function PointTriangulation(feature: IEncodeFeature): {
7
7
  size: number;
8
8
  };
9
9
  export default class SimplePointModel 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[];
@@ -2,11 +2,10 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import { AttributeType, gl } from '@antv/l7-core';
3
3
  import BaseModel from "../../core/BaseModel";
4
4
  import { rgb2arr } from '@antv/l7-utils';
5
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
6
5
  /* babel-plugin-inline-import '../shaders/billboard/billboard_point_frag.glsl' */
7
6
  const simplePointFrag = "\nlayout(std140) uniform commonUniorm {\n vec4 u_stroke_color;\n float u_additive;\n float u_stroke_opacity;\n float u_stroke_width;\n};\n\nin vec4 v_color;\nin float v_blur;\nin float v_innerRadius;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n outputColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n outputColor = mix(v_color, stroke, mixR);\n } else {\n outputColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n outputColor = v_color;\n }\n\n outputColor = filterColor(outputColor);\n \n if(u_additive > 0.0) {\n outputColor *= circleClipOpacity;\n } else {\n outputColor.a *= circleClipOpacity;\n }\n\n}\n";
8
7
  /* babel-plugin-inline-import '../shaders/billboard/billboard_point_vert.glsl' */
9
- const simplePointVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_stroke_color;\n float u_additive;\n float u_stroke_opacity;\n float u_stroke_width;\n};\n\nout vec4 v_color;\nout float v_blur;\nout float v_innerRadius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n \n vec2 offset = project_pixel(u_offsets);\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n \n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
8
+ const simplePointVert = "\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;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_stroke_color;\n float u_additive;\n float u_stroke_opacity;\n float u_stroke_width;\n};\n\nout vec4 v_color;\nout float v_blur;\nout float v_innerRadius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_blur = 1.0 - max(2.0 / a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n\n vec2 offset = project_pixel(u_offsets);\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
10
9
  export function PointTriangulation(feature) {
11
10
  const coordinates = feature.coordinates;
12
11
  return {
@@ -16,6 +15,12 @@ export function PointTriangulation(feature) {
16
15
  };
17
16
  }
18
17
  export default class SimplePointModel extends BaseModel {
18
+ get attributeLocation() {
19
+ return Object.assign(super.attributeLocation, {
20
+ MAX: super.attributeLocation.MAX,
21
+ SIZE: 9
22
+ });
23
+ }
19
24
  getDefaultStyle() {
20
25
  return {
21
26
  blend: 'additive'
@@ -52,6 +57,7 @@ export default class SimplePointModel extends BaseModel {
52
57
  moduleName: 'pointSimple',
53
58
  vertexShader: simplePointVert,
54
59
  fragmentShader: simplePointFrag,
60
+ defines: _this2.getDefines(),
55
61
  inject: _this2.getInject(),
56
62
  triangulation: PointTriangulation,
57
63
  depth: {
@@ -63,12 +69,14 @@ export default class SimplePointModel extends BaseModel {
63
69
  })();
64
70
  }
65
71
  registerBuiltinAttributes() {
72
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
73
+ this.registerPosition64LowAttribute();
66
74
  this.styleAttributeService.registerStyleAttribute({
67
75
  name: 'size',
68
76
  type: AttributeType.Attribute,
69
77
  descriptor: {
70
78
  name: 'a_Size',
71
- shaderLocation: ShaderLocation.SIZE,
79
+ shaderLocation: this.attributeLocation.SIZE,
72
80
  buffer: {
73
81
  usage: gl.DYNAMIC_DRAW,
74
82
  data: [],
@@ -1,6 +1,22 @@
1
1
  import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ExtrudeModel 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
+ POS: number;
18
+ NORMAL: number;
19
+ };
4
20
  private raiseCount;
5
21
  private raiseRepeat;
6
22
  protected getCommonUniformsInfo(): {
@@ -1,15 +1,14 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import { AttributeType, gl } from '@antv/l7-core';
4
- import { calculateCentroid, getCullFace, lodashUtil, rgb2arr } from '@antv/l7-utils';
4
+ import { calculateCentroid, lodashUtil, rgb2arr } from '@antv/l7-utils';
5
5
  import BaseModel from "../../core/BaseModel";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  import { PointExtrudeTriangulation } from "../../core/triangulation";
8
7
  import { lglt2xyz } from "../../earth/utils";
9
8
  /* babel-plugin-inline-import '../shaders/earthExtrude/earthExtrude_frag.glsl' */
10
9
  const pointExtrudeFrag = "precision highp float;\nin vec4 v_color;\n\n#pragma include \"picking\"\n\nlayout(std140) uniform commonUniform {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor: 0;\n float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_globel;\n float u_r;\n float u_pickLight: 0.0;\n float u_opacitylinear: 0.0;\n float u_opacitylinear_dir: 1.0;\n float u_lightEnable: 1.0;\n};\nin float v_lightWeight;\nin float v_barLinearZ;\nout vec4 outputColor;\nvoid main() {\n\n outputColor = v_color;\n\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n if(u_opacitylinear > 0.0) {\n outputColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - v_barLinearZ): v_barLinearZ;\n }\n\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
11
10
  /* babel-plugin-inline-import '../shaders/earthExtrude/earthExtrude_vert.glsl' */
12
- const pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Pos;\nlayout(location = 13) in vec3 a_Normal;\n\n\nlayout(std140) uniform commonUniform {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor: 0;\n float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_globel;\n float u_r;\n float u_pickLight: 0.0;\n float u_opacitylinear: 0.0;\n float u_opacitylinear_dir: 1.0;\n float u_lightEnable: 1.0;\n};\n\nout vec4 v_color;\nout float v_lightWeight;\nout float v_barLinearZ;\n// \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n // a_Position.z \u662F\u5728\u6784\u5EFA\u7F51\u683C\u7684\u65F6\u5019\u4F20\u5165\u7684\u6807\u51C6\u503C 0 - 1\uFF0C\u5728\u63D2\u503C\u5668\u63D2\u503C\u53EF\u4EE5\u83B7\u53D6 0\uFF5E1 \u7EBF\u6027\u6E10\u53D8\u7684\u503C\n v_barLinearZ = a_Position.z;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n v_lightWeight = lightWeight;\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, v_barLinearZ);\n v_color.rgb *= lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n v_color = a_Color;\n }\n v_color.a *= u_opacity;\n\n \n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0, \n 0,xcos,-xsin,0, \n 0,xsin,xcos,0, \n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0, \n 0,1,0,0, \n ysin,0,ycos,0, \n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n \n\n setPickingColor(a_PickingColor);\n}\n";
11
+ const pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec3 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniform {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor: 0;\n float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_globel;\n float u_r;\n float u_pickLight: 0.0;\n float u_opacitylinear: 0.0;\n float u_opacitylinear_dir: 1.0;\n float u_lightEnable: 1.0;\n};\n\nout vec4 v_color;\nout float v_lightWeight;\nout float v_barLinearZ;\n// \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) +\n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n // a_Position.z \u662F\u5728\u6784\u5EFA\u7F51\u683C\u7684\u65F6\u5019\u4F20\u5165\u7684\u6807\u51C6\u503C 0 - 1\uFF0C\u5728\u63D2\u503C\u5668\u63D2\u503C\u53EF\u4EE5\u83B7\u53D6 0\uFF5E1 \u7EBF\u6027\u6E10\u53D8\u7684\u503C\n v_barLinearZ = a_Position.z;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n //\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n v_lightWeight = lightWeight;\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, v_barLinearZ);\n v_color.rgb *= lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n v_color = a_Color;\n }\n v_color.a *= u_opacity;\n\n\n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0,\n 0,xcos,-xsin,0,\n 0,xsin,xcos,0,\n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0,\n 0,1,0,0,\n ysin,0,ycos,0,\n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n\n\n setPickingColor(a_PickingColor);\n}\n";
13
12
  const {
14
13
  isNumber
15
14
  } = lodashUtil;
@@ -19,6 +18,14 @@ export default class ExtrudeModel extends BaseModel {
19
18
  _defineProperty(this, "raiseCount", 0);
20
19
  _defineProperty(this, "raiseRepeat", 0);
21
20
  }
21
+ get attributeLocation() {
22
+ return Object.assign(super.attributeLocation, {
23
+ MAX: super.attributeLocation.MAX,
24
+ SIZE: 9,
25
+ POS: 10,
26
+ NORMAL: 11
27
+ });
28
+ }
22
29
  getCommonUniformsInfo() {
23
30
  const {
24
31
  animateOption = {
@@ -93,7 +100,6 @@ export default class ExtrudeModel extends BaseModel {
93
100
  buildModels() {
94
101
  var _this2 = this;
95
102
  return _asyncToGenerator(function* () {
96
- // GAODE1.x GAODE2.x MAPBOX
97
103
  const {
98
104
  animateOption: {
99
105
  repeat = 1
@@ -108,10 +114,11 @@ export default class ExtrudeModel extends BaseModel {
108
114
  depth: {
109
115
  enable: true
110
116
  },
117
+ defines: _this2.getDefines(),
111
118
  inject: _this2.getInject(),
112
119
  cull: {
113
120
  enable: true,
114
- face: getCullFace(_this2.mapService.version)
121
+ face: gl.FRONT
115
122
  },
116
123
  blend: _this2.getBlend()
117
124
  });
@@ -124,7 +131,7 @@ export default class ExtrudeModel extends BaseModel {
124
131
  type: AttributeType.Attribute,
125
132
  descriptor: {
126
133
  name: 'a_Size',
127
- shaderLocation: ShaderLocation.SIZE,
134
+ shaderLocation: this.attributeLocation.SIZE,
128
135
  buffer: {
129
136
  usage: gl.DYNAMIC_DRAW,
130
137
  data: [],
@@ -157,7 +164,7 @@ export default class ExtrudeModel extends BaseModel {
157
164
  type: AttributeType.Attribute,
158
165
  descriptor: {
159
166
  name: 'a_Normal',
160
- shaderLocation: ShaderLocation.NORMAL,
167
+ shaderLocation: this.attributeLocation.NORMAL,
161
168
  buffer: {
162
169
  // give the WebGL driver a hint that this buffer may change
163
170
  usage: gl.STATIC_DRAW,
@@ -175,7 +182,7 @@ export default class ExtrudeModel extends BaseModel {
175
182
  type: AttributeType.Attribute,
176
183
  descriptor: {
177
184
  name: 'a_Pos',
178
- shaderLocation: 15,
185
+ shaderLocation: this.attributeLocation.POS,
179
186
  buffer: {
180
187
  usage: gl.DYNAMIC_DRAW,
181
188
  data: [],
@@ -1,6 +1,22 @@
1
1
  import type { IAnimateOption, IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class FillModel 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
+ SHAPE: number;
18
+ EXTRUDE: number;
19
+ };
4
20
  protected getCommonUniformsInfo(): {
5
21
  uniformsArray: number[];
6
22
  uniformsLength: number;
@@ -5,10 +5,17 @@ import { GlobelPointFillTriangulation } from "../../core/triangulation";
5
5
  /* babel-plugin-inline-import '../shaders/earthFill/earthFill_frag.glsl' */
6
6
  const pointFillFrag = "in vec4 v_data;\nin vec4 v_color;\nin float v_radius;\n\nlayout(std140) uniform commonUniform {\n float u_additive;\n float u_stroke_opacity : 1;\n float u_stroke_width : 2;\n float u_blur : 0.0;\n};\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n vec4 strokeColor = u_stroke == vec4(0.0) ? v_color : u_stroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(outer_df > antialiasblur + 0.018) discard;\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(u_stroke_width < 0.01) {\n outputColor = vec4(v_color.rgb, v_color.a * u_opacity);\n } else {\n outputColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n outputColor = filterColorAlpha(outputColor, outputColor.a);\n } else {\n outputColor.a *= opacity_t;\n outputColor = filterColor(outputColor);\n }\n}\n";
7
7
  /* babel-plugin-inline-import '../shaders/earthFill/earthFill_vert.glsl' */
8
- 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 = 10) in float a_Shape;\nlayout(location = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniform {\n float u_additive;\n float u_stroke_opacity : 1;\n float u_stroke_width : 2;\n float u_blur : 0.0;\n};\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + vec3(u_offsets,0.0), 1.0);\n\n setPickingColor(a_PickingColor);\n}";
8
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_SHAPE) in float a_Shape;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniform {\n float u_additive;\n float u_stroke_opacity : 1;\n float u_stroke_width : 2;\n float u_blur : 0.0;\n};\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + vec3(u_offsets,0.0), 1.0);\n\n setPickingColor(a_PickingColor);\n}\n";
9
9
  import { mat4, vec3 } from 'gl-matrix';
10
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
11
10
  export default class FillModel extends BaseModel {
11
+ get attributeLocation() {
12
+ return Object.assign(super.attributeLocation, {
13
+ MAX: super.attributeLocation.MAX,
14
+ SIZE: 9,
15
+ SHAPE: 10,
16
+ EXTRUDE: 11
17
+ });
18
+ }
12
19
  getCommonUniformsInfo() {
13
20
  const {
14
21
  strokeOpacity = 1,
@@ -43,6 +50,7 @@ export default class FillModel extends BaseModel {
43
50
  vertexShader: pointFillVert,
44
51
  fragmentShader: pointFillFrag,
45
52
  triangulation: GlobelPointFillTriangulation,
53
+ defines: _this2.getDefines(),
46
54
  inject: _this2.getInject(),
47
55
  depth: {
48
56
  enable: true
@@ -63,7 +71,7 @@ export default class FillModel extends BaseModel {
63
71
  type: AttributeType.Attribute,
64
72
  descriptor: {
65
73
  name: 'a_Extrude',
66
- shaderLocation: ShaderLocation.EXTRUDE,
74
+ shaderLocation: this.attributeLocation.EXTRUDE,
67
75
  buffer: {
68
76
  // give the WebGL driver a hint that this buffer may change
69
77
  usage: gl.DYNAMIC_DRAW,
@@ -105,7 +113,7 @@ export default class FillModel extends BaseModel {
105
113
  type: AttributeType.Attribute,
106
114
  descriptor: {
107
115
  name: 'a_Size',
108
- shaderLocation: ShaderLocation.SIZE,
116
+ shaderLocation: this.attributeLocation.SIZE,
109
117
  buffer: {
110
118
  // give the WebGL driver a hint that this buffer may change
111
119
  usage: gl.DYNAMIC_DRAW,
@@ -128,7 +136,7 @@ export default class FillModel extends BaseModel {
128
136
  type: AttributeType.Attribute,
129
137
  descriptor: {
130
138
  name: 'a_Shape',
131
- shaderLocation: ShaderLocation.SHAPE,
139
+ shaderLocation: this.attributeLocation.SHAPE,
132
140
  buffer: {
133
141
  // give the WebGL driver a hint that this buffer may change
134
142
  usage: gl.DYNAMIC_DRAW,
@@ -1,6 +1,22 @@
1
1
  import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ExtrudeModel 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
+ NORMAL: number;
19
+ };
4
20
  private raiseCount;
5
21
  private raiseRepeat;
6
22
  protected getCommonUniformsInfo(): {
@@ -1,20 +1,27 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import { AttributeType, gl } from '@antv/l7-core';
4
- import { calculateCentroid, getCullFace, rgb2arr } from '@antv/l7-utils';
4
+ import { calculateCentroid, fp64LowPart, rgb2arr } from '@antv/l7-utils';
5
5
  import BaseModel from "../../core/BaseModel";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  import { PointExtrudeTriangulation } from "../../core/triangulation";
8
7
  /* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
9
8
  const pointExtrudeFrag = "\nin vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
10
9
  /* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
11
- const pointExtrudeVert = "#define pi 3.1415926535\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n\n vec3 size = a_Size * a_Position;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
10
+ const pointExtrudeVert = "#define pi (3.1415926535)\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec3 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec4 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if (x > 0.0 && z > 0.0) {\n return atan(x / z);\n } else if (x > 0.0 && z <= 0.0) {\n return atan(-z / x) + pi / 2.0;\n } else if (x <= 0.0 && z <= 0.0) {\n return pi + atan(x / z); //atan(x/z) +\n } else {\n return atan(z / -x) + pi * 3.0 / 2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y / r);\n}\n\nvoid main() {\n vec3 size = a_Size * a_Position;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n\n if (u_heightfixed < 1.0) {\n // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n } else {\n // \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n offset *= 4.0 / pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n vec2 positions = a_Extrude.xy;\n vec2 positions64Low = a_Extrude.zw;\n vec4 project_pos = project_position(vec4(positions, 0.0, 1.0), positions64Low);\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n\n if (u_lightEnable > 0.0) {\n // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if (u_linearColor == 1.0) {\n // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n }\n\n if (u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? 1.0 - a_Position.z : a_Position.z;\n }\n\n gl_Position = project_common_position_to_clipspace(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
12
11
  export default class ExtrudeModel extends BaseModel {
13
12
  constructor(...args) {
14
13
  super(...args);
15
14
  _defineProperty(this, "raiseCount", 0);
16
15
  _defineProperty(this, "raiseRepeat", 0);
17
16
  }
17
+ get attributeLocation() {
18
+ return Object.assign(super.attributeLocation, {
19
+ MAX: super.attributeLocation.MAX,
20
+ SIZE: 9,
21
+ EXTRUDE: 10,
22
+ NORMAL: 11
23
+ });
24
+ }
18
25
  getCommonUniformsInfo() {
19
26
  const {
20
27
  animateOption = {
@@ -86,7 +93,6 @@ export default class ExtrudeModel extends BaseModel {
86
93
  buildModels() {
87
94
  var _this2 = this;
88
95
  return _asyncToGenerator(function* () {
89
- // GAODE1.x GAODE2.x MAPBOX
90
96
  const {
91
97
  depth = true,
92
98
  animateOption: {
@@ -100,10 +106,11 @@ export default class ExtrudeModel extends BaseModel {
100
106
  vertexShader: pointExtrudeVert,
101
107
  fragmentShader: pointExtrudeFrag,
102
108
  triangulation: PointExtrudeTriangulation,
109
+ defines: _this2.getDefines(),
103
110
  inject: _this2.getInject(),
104
111
  cull: {
105
112
  enable: true,
106
- face: getCullFace(_this2.mapService.version)
113
+ face: gl.FRONT
107
114
  },
108
115
  depth: {
109
116
  enable: depth
@@ -119,7 +126,7 @@ export default class ExtrudeModel extends BaseModel {
119
126
  type: AttributeType.Attribute,
120
127
  descriptor: {
121
128
  name: 'a_Size',
122
- shaderLocation: ShaderLocation.SIZE,
129
+ shaderLocation: this.attributeLocation.SIZE,
123
130
  buffer: {
124
131
  usage: gl.DYNAMIC_DRAW,
125
132
  data: [],
@@ -145,14 +152,12 @@ export default class ExtrudeModel extends BaseModel {
145
152
  }
146
153
  }
147
154
  });
148
-
149
- // point layer size;
150
155
  this.styleAttributeService.registerStyleAttribute({
151
156
  name: 'normal',
152
157
  type: AttributeType.Attribute,
153
158
  descriptor: {
154
159
  name: 'a_Normal',
155
- shaderLocation: ShaderLocation.NORMAL,
160
+ shaderLocation: this.attributeLocation.NORMAL,
156
161
  buffer: {
157
162
  // give the WebGL driver a hint that this buffer may change
158
163
  usage: gl.STATIC_DRAW,
@@ -170,17 +175,19 @@ export default class ExtrudeModel extends BaseModel {
170
175
  type: AttributeType.Attribute,
171
176
  descriptor: {
172
177
  name: 'a_Extrude',
173
- shaderLocation: ShaderLocation.EXTRUDE,
178
+ shaderLocation: this.attributeLocation.EXTRUDE,
174
179
  buffer: {
175
180
  // give the WebGL driver a hint that this buffer may change
176
181
  usage: gl.DYNAMIC_DRAW,
177
182
  data: [],
178
183
  type: gl.FLOAT
179
184
  },
180
- size: 3,
185
+ size: 4,
181
186
  update: feature => {
182
187
  const coordinates = calculateCentroid(feature.coordinates);
183
- return [coordinates[0], coordinates[1], 0];
188
+ // [lng, lat, lowLng, lowLat]
189
+ // low part for enabled double precision
190
+ return [coordinates[0], coordinates[1], fp64LowPart(coordinates[0]), fp64LowPart(coordinates[1])];
184
191
  }
185
192
  }
186
193
  });
@@ -1,6 +1,22 @@
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 FillModel 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
+ SHAPE: number;
18
+ EXTRUDE: number;
19
+ };
4
20
  protected getCommonUniformsInfo(): {
5
21
  uniformsArray: number[];
6
22
  uniformsLength: number;