@antv/l7-layers 2.21.10 → 2.21.11-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 (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,6 +1,22 @@
1
1
  import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class CityBuildModel 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
+ NORMAL: number;
18
+ UV: number;
19
+ };
4
20
  private cityCenter;
5
21
  private cityMinSize;
6
22
  protected getCommonUniformsInfo(): {
@@ -3,18 +3,25 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import { AttributeType, gl } from '@antv/l7-core';
4
4
  import { rgb2arr } from '@antv/l7-utils';
5
5
  import BaseModel from "../../core/BaseModel";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  import { PolygonExtrudeTriangulation } from "../../core/triangulation";
8
7
  /* babel-plugin-inline-import '../shaders/build_frag.glsl' */
9
- const buildFrag = "precision highp float;\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_brightColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_windowColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_circleSweepColor;\n vec2 u_cityCenter;\n float u_circleSweep;\n float u_cityMinSize;\n float u_circleSweepSpeed;\n float u_opacity: 1.0;\n float u_near : 0;\n float u_far : 1;\n float u_time;\n};\nin vec4 v_Color;\nin vec2 v_texCoord;\nin float v_worldDis;\nout vec4 outputColor;\n\n#pragma include \"picking\"\n#pragma include \"scene_uniforms\"\n\nvec3 getWindowColor(float n, float hot, vec3 brightColor, vec3 darkColor) {\n float s = step(hot, n);\n vec3 color = mix(brightColor,vec3(0.9,0.9,1.0),n);\n\n return mix(darkColor, color, s);\n}\nfloat random (vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);\n}\n\nfloat LinearizeDepth()\n{\n float z = gl_FragCoord.z * 2.0 - 1.0;\n return (2.0 * u_near * u_far) / (u_far + u_near - z * (u_far - u_near));\n}\n\nvec3 fog(vec3 color, vec3 fogColor, float depth){\n float fogFactor=clamp(depth,0.0,1.0);\n vec3 output_color=mix(fogColor,color,fogFactor);\n return output_color;\n}\n\nfloat sdRect(vec2 p, vec2 sz) {\n vec2 d = abs(p) - sz;\n float outside = length(max(d, 0.));\n float inside = min(max(d.x, d.y), 0.);\n return outside + inside;\n}\n\nvoid main() {\n outputColor = v_Color;\n vec3 baseColor = u_baseColor.xyz;\n vec3 brightColor = u_brightColor.xyz;\n vec3 windowColor = u_windowColor.xyz;\n float targetColId = 5.;\n float depth = 1.0 - LinearizeDepth() / u_far * u_Zoom;\n vec3 fogColor = vec3(23.0/255.0,31.0/255.0,51.0/255.0);\n if(v_texCoord.x < 0.) { //\u9876\u90E8\u989C\u8272\n vec3 foggedColor = fog(baseColor.xyz + vec3(0.12*0.9,0.2*0.9,0.3*0.9),fogColor,depth);\n outputColor = vec4( foggedColor, v_Color.w);\n }else { // \u4FA7\u9762\u989C\u8272\n vec2 st = v_texCoord;\n vec2 UvScale = v_texCoord;\n float tStep = min(0.08,max(0.05* (18.0-u_Zoom),0.02));\n float tStart = 0.25 * tStep;\n float tEnd = 0.75 * tStep;\n float u = mod(UvScale.x, tStep);\n float v = mod(UvScale.y, tStep);\n float ux = floor(UvScale.x/tStep);\n float uy = floor(UvScale.y/tStep);\n float n = random(vec2(ux,uy));\n float lightP = u_time;\n float head = 1.0- step(0.005,st.y);\n /*step3*/\n // \u5C06\u7A97\u6237\u989C\u8272\u548C\u5899\u9762\u989C\u8272\u533A\u522B\u5F00\u6765\n float sU = step(tStart, u) - step(tEnd, u);\n float sV = step(tStart, v) - step(tEnd, v);\n vec2 windowSize = vec2(abs(tEnd-tStart),abs(tEnd-tStart));\n float dist = sdRect(vec2(u,v), windowSize);\n float s = sU * sV;\n\n float curColId = floor(UvScale.x / tStep);\n float sCol = step(targetColId - 0.2, curColId) - step(targetColId + 0.2, curColId);\n\n float mLightP = mod(lightP, 2.);\n float sRow = step(mLightP - 0.2, st.y) - step(mLightP, st.y);\n if(ux == targetColId){\n n =0.;\n }\n float timeP = min(0.75, abs ( sin(u_time/3.0) ) );\n float hot = smoothstep(1.0,0.0,timeP);\n vec3 color = mix(baseColor, getWindowColor(n,hot,brightColor,windowColor), s);\n //vec3 color = mix(baseColor, getWindowColor(n,hot,brightColor,windowColor), 1.0);\n float sFinal = s * sCol * sRow;\n color += mix(baseColor, brightColor, sFinal*n);\n if (st.y<0.01){\n color = baseColor;\n }\n if(head ==1.0) { // \u9876\u90E8\u4EAE\u7EBF\n color = brightColor;\n }\n color = color * v_Color.rgb;\n\n vec3 foggedColor = fog(color,fogColor,depth);\n\n outputColor = vec4(foggedColor,1.0);\n }\n\n\n if(u_circleSweep > 0.0 && v_worldDis < u_cityMinSize) {\n float r = fract(((v_worldDis/u_cityMinSize) - u_time * u_circleSweepSpeed) * 2.0);\n outputColor.rgb += r * r * u_circleSweepColor.rgb;\n }\n \n outputColor.a *= u_opacity;\n outputColor = filterColor(outputColor);\n}\n";
8
+ const buildFrag = "precision highp float;\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor: [ 1.0, 0, 0, 1.0 ];\n vec4 u_brightColor: [ 1.0, 0, 0, 1.0 ];\n vec4 u_windowColor: [ 1.0, 0, 0, 1.0 ];\n vec4 u_circleSweepColor;\n vec2 u_cityCenter;\n float u_circleSweep;\n float u_cityMinSize;\n float u_circleSweepSpeed;\n float u_opacity: 1.0;\n float u_near: 0;\n float u_far: 1;\n float u_time;\n};\nin vec4 v_Color;\nin vec2 v_texCoord;\nin float v_worldDis;\nout vec4 outputColor;\n\n#pragma include \"picking\"\n#pragma include \"scene_uniforms\"\n\nvec3 getWindowColor(float n, float hot, vec3 brightColor, vec3 darkColor) {\n float s = step(hot, n);\n vec3 color = mix(brightColor,vec3(0.9,0.9,1.0),n);\n\n return mix(darkColor, color, s);\n}\nfloat random (vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);\n}\n\nfloat LinearizeDepth()\n{\n float z = gl_FragCoord.z * 2.0 - 1.0;\n return (2.0 * u_near * u_far) / (u_far + u_near - z * (u_far - u_near));\n}\n\nvec3 fog(vec3 color, vec3 fogColor, float depth){\n float fogFactor=clamp(depth,0.0,1.0);\n vec3 output_color=mix(fogColor,color,fogFactor);\n return output_color;\n}\n\nfloat sdRect(vec2 p, vec2 sz) {\n vec2 d = abs(p) - sz;\n float outside = length(max(d, 0.));\n float inside = min(max(d.x, d.y), 0.);\n return outside + inside;\n}\n\nvoid main() {\n outputColor = v_Color;\n vec3 baseColor = u_baseColor.xyz;\n vec3 brightColor = u_brightColor.xyz;\n vec3 windowColor = u_windowColor.xyz;\n float targetColId = 5.;\n float depth = 1.0 - LinearizeDepth() / u_far * u_Zoom;\n vec3 fogColor = vec3(23.0/255.0,31.0/255.0,51.0/255.0);\n if(v_texCoord.x < 0.) { //\u9876\u90E8\u989C\u8272\n vec3 foggedColor = fog(baseColor.xyz + vec3(0.12*0.9,0.2*0.9,0.3*0.9),fogColor,depth);\n outputColor = vec4( foggedColor, v_Color.w);\n }else { // \u4FA7\u9762\u989C\u8272\n vec2 st = v_texCoord;\n vec2 UvScale = v_texCoord;\n float tStep = min(0.08,max(0.05* (18.0-u_Zoom),0.02));\n float tStart = 0.25 * tStep;\n float tEnd = 0.75 * tStep;\n float u = mod(UvScale.x, tStep);\n float v = mod(UvScale.y, tStep);\n float ux = floor(UvScale.x/tStep);\n float uy = floor(UvScale.y/tStep);\n float n = random(vec2(ux,uy));\n float lightP = u_time;\n float head = 1.0- step(0.005,st.y);\n /*step3*/\n // \u5C06\u7A97\u6237\u989C\u8272\u548C\u5899\u9762\u989C\u8272\u533A\u522B\u5F00\u6765\n float sU = step(tStart, u) - step(tEnd, u);\n float sV = step(tStart, v) - step(tEnd, v);\n vec2 windowSize = vec2(abs(tEnd-tStart),abs(tEnd-tStart));\n float dist = sdRect(vec2(u,v), windowSize);\n float s = sU * sV;\n\n float curColId = floor(UvScale.x / tStep);\n float sCol = step(targetColId - 0.2, curColId) - step(targetColId + 0.2, curColId);\n\n float mLightP = mod(lightP, 2.);\n float sRow = step(mLightP - 0.2, st.y) - step(mLightP, st.y);\n if(ux == targetColId){\n n =0.;\n }\n float timeP = min(0.75, abs ( sin(u_time/3.0) ) );\n float hot = smoothstep(1.0,0.0,timeP);\n vec3 color = mix(baseColor, getWindowColor(n,hot,brightColor,windowColor), s);\n //vec3 color = mix(baseColor, getWindowColor(n,hot,brightColor,windowColor), 1.0);\n float sFinal = s * sCol * sRow;\n color += mix(baseColor, brightColor, sFinal*n);\n if (st.y<0.01){\n color = baseColor;\n }\n if(head ==1.0) { // \u9876\u90E8\u4EAE\u7EBF\n color = brightColor;\n }\n color = color * v_Color.rgb;\n\n vec3 foggedColor = fog(color,fogColor,depth);\n\n outputColor = vec4(foggedColor,1.0);\n }\n\n\n if(u_circleSweep > 0.0 && v_worldDis < u_cityMinSize) {\n float r = fract(((v_worldDis/u_cityMinSize) - u_time * u_circleSweepSpeed) * 2.0);\n outputColor.rgb += r * r * u_circleSweepColor.rgb;\n }\n\n outputColor.a *= u_opacity;\n outputColor = filterColor(outputColor);\n}\n";
10
9
  /* babel-plugin-inline-import '../shaders/build_vert.glsl' */
11
- const buildVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec2 a_Uv;\n\nout vec2 v_texCoord;\nout vec4 v_Color;\nout float v_worldDis;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_brightColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_windowColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_circleSweepColor;\n vec2 u_cityCenter;\n float u_circleSweep;\n float u_cityMinSize;\n float u_circleSweepSpeed;\n float u_opacity: 1.0;\n float u_near : 0;\n float u_far : 1;\n float u_time;\n};\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n v_texCoord = a_Uv;\n\n if(u_circleSweep > 0.0) {\n vec2 lnglatscale = vec2(0.0);\n if(u_CoordinateSystem != COORDINATE_SYSTEM_P20_2) {\n lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);\n }\n v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);\n }\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
10
+ const buildVert = "precision highp float;\n\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 float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nout vec2 v_texCoord;\nout vec4 v_Color;\nout float v_worldDis;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_baseColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_brightColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_windowColor : [ 1.0, 0, 0, 1.0 ];\n vec4 u_circleSweepColor;\n vec2 u_cityCenter;\n float u_circleSweep;\n float u_cityMinSize;\n float u_circleSweepSpeed;\n float u_opacity: 1.0;\n float u_near : 0;\n float u_far : 1;\n float u_time;\n};\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n v_texCoord = a_Uv;\n\n if(u_circleSweep > 0.0) {\n vec2 lnglatscale = vec2(0.0);\n lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);\n v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
12
11
  export default class CityBuildModel extends BaseModel {
13
12
  constructor(...args) {
14
13
  super(...args);
15
14
  _defineProperty(this, "cityCenter", void 0);
16
15
  _defineProperty(this, "cityMinSize", void 0);
17
16
  }
17
+ get attributeLocation() {
18
+ return Object.assign(super.attributeLocation, {
19
+ MAX: super.attributeLocation.MAX,
20
+ SIZE: 9,
21
+ NORMAL: 10,
22
+ UV: 11
23
+ });
24
+ }
18
25
  getCommonUniformsInfo() {
19
26
  const {
20
27
  opacity = 1,
@@ -50,20 +57,10 @@ export default class CityBuildModel extends BaseModel {
50
57
  calCityGeo() {
51
58
  // @ts-ignore
52
59
  const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
53
- if (this.mapService.version === 'GAODE2.x') {
54
- // @ts-ignore
55
- this.cityCenter = this.mapService.lngLatToCoord([(maxLng + minLng) / 2, (maxLat + minLat) / 2]);
56
- // @ts-ignore
57
- const l1 = this.mapService.lngLatToCoord([maxLng, maxLat]);
58
- // @ts-ignore
59
- const l2 = this.mapService.lngLatToCoord([minLng, minLat]);
60
- this.cityMinSize = Math.sqrt(Math.pow(l1[0] - l2[0], 2) + Math.pow(l1[1] - l2[1], 2)) / 4;
61
- } else {
62
- const w = maxLng - minLng;
63
- const h = maxLat - minLat;
64
- this.cityCenter = [(maxLng + minLng) / 2, (maxLat + minLat) / 2];
65
- this.cityMinSize = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2)) / 4;
66
- }
60
+ const w = maxLng - minLng;
61
+ const h = maxLat - minLat;
62
+ this.cityCenter = [(maxLng + minLng) / 2, (maxLat + minLat) / 2];
63
+ this.cityMinSize = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2)) / 4;
67
64
  }
68
65
  initModels() {
69
66
  var _this = this;
@@ -85,6 +82,7 @@ export default class CityBuildModel extends BaseModel {
85
82
  depth: {
86
83
  enable: true
87
84
  },
85
+ defines: _this2.getDefines(),
88
86
  inject: _this2.getInject(),
89
87
  cull: {
90
88
  enable: true,
@@ -101,7 +99,7 @@ export default class CityBuildModel extends BaseModel {
101
99
  type: AttributeType.Attribute,
102
100
  descriptor: {
103
101
  name: 'a_Normal',
104
- shaderLocation: ShaderLocation.NORMAL,
102
+ shaderLocation: this.attributeLocation.NORMAL,
105
103
  buffer: {
106
104
  // give the WebGL driver a hint that this buffer may change
107
105
  usage: gl.STATIC_DRAW,
@@ -119,7 +117,7 @@ export default class CityBuildModel extends BaseModel {
119
117
  type: AttributeType.Attribute,
120
118
  descriptor: {
121
119
  name: 'a_Size',
122
- shaderLocation: ShaderLocation.SIZE,
120
+ shaderLocation: this.attributeLocation.SIZE,
123
121
  buffer: {
124
122
  // give the WebGL driver a hint that this buffer may change
125
123
  usage: gl.DYNAMIC_DRAW,
@@ -140,7 +138,7 @@ export default class CityBuildModel extends BaseModel {
140
138
  type: AttributeType.Attribute,
141
139
  descriptor: {
142
140
  name: 'a_Uv',
143
- shaderLocation: ShaderLocation.UV,
141
+ shaderLocation: this.attributeLocation.UV,
144
142
  buffer: {
145
143
  // give the WebGL driver a hint that this buffer may change
146
144
  usage: gl.DYNAMIC_DRAW,
@@ -1,16 +1,16 @@
1
1
  precision highp float;
2
2
  layout(std140) uniform commonUniforms {
3
- vec4 u_baseColor : [ 1.0, 0, 0, 1.0 ];
4
- vec4 u_brightColor : [ 1.0, 0, 0, 1.0 ];
5
- vec4 u_windowColor : [ 1.0, 0, 0, 1.0 ];
3
+ vec4 u_baseColor: [ 1.0, 0, 0, 1.0 ];
4
+ vec4 u_brightColor: [ 1.0, 0, 0, 1.0 ];
5
+ vec4 u_windowColor: [ 1.0, 0, 0, 1.0 ];
6
6
  vec4 u_circleSweepColor;
7
7
  vec2 u_cityCenter;
8
8
  float u_circleSweep;
9
9
  float u_cityMinSize;
10
10
  float u_circleSweepSpeed;
11
11
  float u_opacity: 1.0;
12
- float u_near : 0;
13
- float u_far : 1;
12
+ float u_near: 0;
13
+ float u_far: 1;
14
14
  float u_time;
15
15
  };
16
16
  in vec4 v_Color;
@@ -114,7 +114,7 @@ void main() {
114
114
  float r = fract(((v_worldDis/u_cityMinSize) - u_time * u_circleSweepSpeed) * 2.0);
115
115
  outputColor.rgb += r * r * u_circleSweepColor.rgb;
116
116
  }
117
-
117
+
118
118
  outputColor.a *= u_opacity;
119
119
  outputColor = filterColor(outputColor);
120
120
  }
@@ -4,11 +4,11 @@ precision highp float;
4
4
  #define diffuseRatio 0.3
5
5
  #define specularRatio 0.2
6
6
 
7
- layout(location = 0) in vec3 a_Position;
8
- layout(location = 1) in vec4 a_Color;
9
- layout(location = 9) in float a_Size;
10
- layout(location = 13) in vec3 a_Normal;
11
- layout(location = 14) in vec2 a_Uv;
7
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
8
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
9
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
10
+ layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
11
+ layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
12
12
 
13
13
  out vec2 v_texCoord;
14
14
  out vec4 v_Color;
@@ -41,17 +41,11 @@ void main() {
41
41
 
42
42
  if(u_circleSweep > 0.0) {
43
43
  vec2 lnglatscale = vec2(0.0);
44
- if(u_CoordinateSystem != COORDINATE_SYSTEM_P20_2) {
45
- lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);
46
- }
44
+ lnglatscale = (a_Position.xy - u_cityCenter) * vec2(0.0, 0.135);
47
45
  v_worldDis = length(a_Position.xy + lnglatscale - u_cityCenter);
48
46
  }
49
-
50
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
51
- gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
52
- } else {
53
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
54
- }
47
+
48
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
55
49
 
56
50
  float lightWeight = calc_lighting(pos);
57
51
  // v_Color = a_Color;
@@ -237,7 +237,6 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
237
237
  protected getDefaultConfig(): {};
238
238
  protected sourceEvent: () => void;
239
239
  protected initLayerModels(): Promise<void>;
240
- getLayerUniformBuffer(): IBuffer;
241
240
  getPickingUniformBuffer(): IBuffer;
242
241
  protected reRender(): void;
243
242
  protected splitValuesAndCallbackInAttribute(valuesOrCallback?: unknown[]): {
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
5
  const _excluded = ["passes"],
6
- _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption", "pickingEnabled"];
6
+ _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "defines", "inject", "triangulation", "styleOption", "pickingEnabled"];
7
7
  // @ts-ignore
8
8
  import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
9
9
  import { BlendType, IDebugLog, ILayerStage, globalConfigService } from '@antv/l7-core';
@@ -58,7 +58,8 @@ export default class BaseLayer extends EventEmitter {
58
58
  return this.container.interactionService;
59
59
  }
60
60
  get mapService() {
61
- return this.container.mapService;
61
+ var _this$container;
62
+ return (_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.mapService;
62
63
  }
63
64
  get normalPassFactory() {
64
65
  return this.container.normalPassFactory;
@@ -918,12 +919,8 @@ export default class BaseLayer extends EventEmitter {
918
919
  type
919
920
  }) => {
920
921
  if (this.coordCenter === undefined) {
921
- var _this$mapService;
922
922
  const layerCenter = this.layerSource.center;
923
923
  this.coordCenter = layerCenter;
924
- if ((_this$mapService = this.mapService) !== null && _this$mapService !== void 0 && _this$mapService.setCoordCenter) {
925
- this.mapService.setCoordCenter(layerCenter);
926
- }
927
924
  }
928
925
  if (type === 'update') {
929
926
  if (this.tileLayer) {
@@ -1017,6 +1014,7 @@ export default class BaseLayer extends EventEmitter {
1017
1014
  moduleName,
1018
1015
  vertexShader,
1019
1016
  fragmentShader,
1017
+ defines,
1020
1018
  inject,
1021
1019
  triangulation,
1022
1020
  styleOption,
@@ -1026,6 +1024,7 @@ export default class BaseLayer extends EventEmitter {
1026
1024
  _this3.shaderModuleService.registerModule(moduleName, {
1027
1025
  vs: vertexShader,
1028
1026
  fs: fragmentShader,
1027
+ defines,
1029
1028
  inject
1030
1029
  });
1031
1030
  const {
@@ -1042,7 +1041,7 @@ export default class BaseLayer extends EventEmitter {
1042
1041
  elements,
1043
1042
  count
1044
1043
  } = _this3.styleAttributeService.createAttributesAndIndices(_this3.encodedData, triangulation, styleOption, _this3);
1045
- const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers, _this3.getLayerUniformBuffer()];
1044
+ const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers];
1046
1045
  if (pickingEnabled) {
1047
1046
  uniformBuffers.push(_this3.getPickingUniformBuffer());
1048
1047
  }
@@ -1225,28 +1224,19 @@ export default class BaseLayer extends EventEmitter {
1225
1224
  buffer.destroy();
1226
1225
  });
1227
1226
  _this5.uniformBuffers = [];
1228
- // Layer Uniform
1229
- const layerUniforms = _this5.rendererService.createBuffer({
1230
- data: new Float32Array(16 + 4).fill(0),
1231
- // u_Mvp
1232
- isUBO: true
1233
- });
1234
- _this5.uniformBuffers.push(layerUniforms);
1235
1227
 
1236
1228
  // Picking Uniform
1237
1229
  const pickingUniforms = _this5.rendererService.createBuffer({
1238
1230
  data: new Float32Array(20).fill(0),
1239
- isUBO: true
1231
+ isUBO: true,
1232
+ label: 'pickingUniforms'
1240
1233
  });
1241
1234
  _this5.uniformBuffers.push(pickingUniforms);
1242
1235
  _this5.models = yield _this5.layerModel.initModels();
1243
1236
  })();
1244
1237
  }
1245
- getLayerUniformBuffer() {
1246
- return this.uniformBuffers[0];
1247
- }
1248
1238
  getPickingUniformBuffer() {
1249
- return this.uniformBuffers[1];
1239
+ return this.uniformBuffers[0];
1250
1240
  }
1251
1241
  reRender() {
1252
1242
  if (this.inited) {
@@ -1,4 +1,5 @@
1
- import type { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, IInject, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
1
+ import type { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRenderOptions, IRendererService, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, ShaderDefine, ShaderInject, Triangulation } from '@antv/l7-core';
2
+ import { COMMON_ATTRIBUTE_LOCATION } from './CommonStyleAttribute';
2
3
  export type styleSingle = number | string | [string, (single: any) => number] | [string, [number, number]];
3
4
  export type styleOffset = string | [number, number] | [string, (single: any) => number];
4
5
  export type styleColor = string | [string, (single: any) => string] | [string, [string, string]];
@@ -11,10 +12,15 @@ export interface ICellProperty {
11
12
  attr: string;
12
13
  count: number;
13
14
  }
15
+ type AttributeLayoutLocationType = typeof COMMON_ATTRIBUTE_LOCATION & Record<string, number>;
14
16
  export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerModel {
15
17
  triangulation: Triangulation;
16
18
  uniformBuffers: IBuffer[];
17
19
  textures: ITexture2D[];
20
+ /**
21
+ * Attribute Layout Location in Shader
22
+ */
23
+ protected get attributeLocation(): AttributeLayoutLocationType;
18
24
  createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
19
25
  preStyleAttribute: Record<string, any>;
20
26
  protected encodeStyleAttribute: Record<string, boolean>;
@@ -55,11 +61,17 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
55
61
  protected registerBuiltinAttributes(): void;
56
62
  protected animateOption2Array(option: IAnimateOption): number[];
57
63
  protected startModelAnimate(): void;
58
- protected getInject(): IInject;
64
+ protected getInject(): ShaderInject;
65
+ protected getDefines(): Record<string, ShaderDefine>;
59
66
  protected getStyleAttribute(): {
60
67
  [key: string]: any;
61
68
  };
62
69
  protected registerStyleAttribute(): void;
70
+ /**
71
+ * 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
72
+ * 避免大于 20层级以上出现数据偏移
73
+ */
74
+ protected registerPosition64LowAttribute(enable64bitPosition?: boolean): void;
63
75
  updateEncodeAttribute(type: string, flag: boolean): void;
64
76
  initUniformsBuffer(): void;
65
77
  protected getUniformsBufferInfo(uniformsOption: {
@@ -80,3 +92,4 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
80
92
  };
81
93
  updateStyleUnifoms(): void;
82
94
  }
95
+ export {};
@@ -1,24 +1,27 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import { BlendType, MaskOperation, StencilType } from '@antv/l7-core';
5
- import { rgb2arr } from '@antv/l7-utils';
4
+ import { AttributeType, BlendType, MaskOperation, StencilType, gl } from '@antv/l7-core';
5
+ import { fp64LowPart, rgb2arr } from '@antv/l7-utils';
6
6
  import { BlendTypes } from "../utils/blend";
7
7
  import { getStencil, getStencilMask } from "../utils/stencil";
8
- import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
8
+ import { COMMON_ATTRIBUTE_LOCATION, getCommonStyleAttributeOptions } from "./CommonStyleAttribute";
9
9
  import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
10
10
  import { MultipleOfFourNumber } from "./utils";
11
- const shaderLocationMap = {
12
- opacity: ShaderLocation.OPACITY,
13
- stroke: ShaderLocation.STROKE,
14
- offsets: ShaderLocation.OFFSETS,
15
- rotation: ShaderLocation.ROTATION,
16
- extrusionBase: ShaderLocation.EXTRUSION_BASE,
17
- thetaOffset: 15
18
- };
11
+ // 属性索引宏定义前缀,使用命名空间避免 define 名称重复情况
12
+ const DEFINE_ATTRIBUTE_LOCATION_PREFIX = 'ATTRIBUTE_LOCATION_';
19
13
 
20
14
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
15
  export default class BaseModel {
16
+ /**
17
+ * Attribute Layout Location in Shader
18
+ */
19
+ get attributeLocation() {
20
+ return _objectSpread({}, COMMON_ATTRIBUTE_LOCATION);
21
+ }
22
+
23
+ // style texture data mapping
24
+
22
25
  // 不支持数据映射的buffer
23
26
 
24
27
  // style texture data mapping
@@ -27,7 +30,6 @@ export default class BaseModel {
27
30
  _defineProperty(this, "triangulation", void 0);
28
31
  _defineProperty(this, "uniformBuffers", []);
29
32
  _defineProperty(this, "textures", []);
30
- // style texture data mapping
31
33
  _defineProperty(this, "createTexture2D", void 0);
32
34
  _defineProperty(this, "preStyleAttribute", {});
33
35
  _defineProperty(this, "encodeStyleAttribute", {});
@@ -178,55 +180,18 @@ export default class BaseModel {
178
180
  this.layer.setAnimateStartTime();
179
181
  }
180
182
  }
181
-
182
- // 动态注入参与数据映射的uniform
183
183
  getInject() {
184
- const encodeStyleAttribute = this.layer.encodeStyleAttribute;
185
- let str = '';
186
- // a_Position = 0
187
- // a_Color = 1
188
- // a_PickingColor = 2
189
-
190
- const uniforms = [];
191
- // 支持数据映射的类型
192
- this.layer.enableShaderEncodeStyles.forEach(key => {
193
- if (encodeStyleAttribute[key]) {
194
- // 配置了数据映射的类型
195
- str += `#define USE_ATTRIBUTE_${key.toUpperCase()} 0.0; \n\n`;
196
- } else {
197
- uniforms.push(` ${DefaultUniformStyleType[key]} u_${key};`);
198
- }
199
- let location = shaderLocationMap[key];
200
- if (!location && key === 'THETA_OFFSET') {
201
- location = 15;
202
- }
203
- str += `
204
- #ifdef USE_ATTRIBUTE_${key.toUpperCase()}
205
- layout(location = ${shaderLocationMap[key]}) in ${DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
206
- #endif\n
207
- `;
208
- });
209
- const attributeUniforms = uniforms.length ? `
210
- layout(std140) uniform AttributeUniforms {
211
- ${uniforms.join('\n')}
212
- };
213
- ` : '';
214
- str += attributeUniforms;
215
- let innerStr = '';
216
- this.layer.enableShaderEncodeStyles.forEach(key => {
217
- innerStr += `\n
218
- #ifdef USE_ATTRIBUTE_${key.toUpperCase()}
219
- ${DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
220
- #else
221
- ${DefaultUniformStyleType[key]} ${key} = u_${key};
222
- #endif\n
223
- `;
224
- });
225
- return {
226
- 'vs:#decl': str,
227
- 'fs:#decl': attributeUniforms,
228
- 'vs:#main-start': innerStr
229
- };
184
+ const shaderInject = getDynamicStyleInject(this.layer.enableShaderEncodeStyles, this.layer.encodeStyleAttribute);
185
+ return shaderInject;
186
+ }
187
+ getDefines() {
188
+ // define atribute Layout Location
189
+ const atributeLocationDefines = Object.keys(this.attributeLocation).reduce((result, key) => {
190
+ const normalizedKey = DEFINE_ATTRIBUTE_LOCATION_PREFIX + key;
191
+ result[normalizedKey] = this.attributeLocation[key];
192
+ return result;
193
+ }, {});
194
+ return _objectSpread({}, atributeLocationDefines);
230
195
  }
231
196
 
232
197
  // 获取数据映射样式
@@ -247,14 +212,36 @@ ${uniforms.join('\n')}
247
212
  });
248
213
  return options;
249
214
  }
215
+
250
216
  // 注册数据映射样式
251
217
  registerStyleAttribute() {
252
218
  Object.keys(this.layer.encodeStyleAttribute).forEach(key => {
253
219
  const options = getCommonStyleAttributeOptions(key);
254
220
  if (options) {
255
221
  this.styleAttributeService.registerStyleAttribute(options);
256
- if (options.descriptor) {
257
- options.descriptor.shaderLocation = shaderLocationMap[key];
222
+ }
223
+ });
224
+ }
225
+
226
+ /**
227
+ * 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
228
+ * 避免大于 20层级以上出现数据偏移
229
+ */
230
+ registerPosition64LowAttribute(enable64bitPosition = true) {
231
+ // save low part for enabled double precision POSITION attribute
232
+ this.styleAttributeService.registerStyleAttribute({
233
+ name: 'position64Low',
234
+ type: AttributeType.Attribute,
235
+ descriptor: {
236
+ name: 'a_Position64Low',
237
+ shaderLocation: this.attributeLocation.POSITION_64LOW,
238
+ buffer: {
239
+ data: [],
240
+ type: gl.FLOAT
241
+ },
242
+ size: 2,
243
+ update: (feature, featureIdx, vertex) => {
244
+ return enable64bitPosition ? [fp64LowPart(vertex[0]), fp64LowPart(vertex[1])] : [0, 0];
258
245
  }
259
246
  }
260
247
  });
@@ -269,14 +256,16 @@ ${uniforms.join('\n')}
269
256
  this.attributeUnifoms = this.rendererService.createBuffer({
270
257
  data: new Float32Array(MultipleOfFourNumber(attrUniforms.uniformsLength)).fill(0),
271
258
  // 长度需要大于等于 4
272
- isUBO: true
259
+ isUBO: true,
260
+ label: 'layerModelAttributeUnifoms'
273
261
  });
274
262
  this.uniformBuffers.push(this.attributeUnifoms);
275
263
  }
276
264
  if (commonUniforms.uniformsLength !== 0) {
277
265
  this.commonUnifoms = this.rendererService.createBuffer({
278
266
  data: new Float32Array(MultipleOfFourNumber(commonUniforms.uniformsLength)).fill(0),
279
- isUBO: true
267
+ isUBO: true,
268
+ label: 'layerModelCommonUnifoms'
280
269
  });
281
270
  this.uniformBuffers.push(this.commonUnifoms);
282
271
  }
@@ -330,4 +319,49 @@ ${uniforms.join('\n')}
330
319
  data: new Uint8Array(new Float32Array(commonUniformsArray).buffer)
331
320
  });
332
321
  }
322
+ }
323
+
324
+ /**
325
+ * 获取动态注入参与数据映射 uniform/attribute
326
+ */
327
+ function getDynamicStyleInject(shaderEncodeStyles, styleAttribute) {
328
+ const uniforms = [];
329
+ let vsDeclInjection = '';
330
+
331
+ // 支持数据映射的类型
332
+ shaderEncodeStyles.forEach(key => {
333
+ const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
334
+ const shaderDefineName = DEFINE_ATTRIBUTE_LOCATION_PREFIX + upperCaseKey;
335
+ if (styleAttribute[key]) {
336
+ // 配置了数据映射的类型
337
+ vsDeclInjection += `#define USE_ATTRIBUTE_${upperCaseKey} 0.0 \n`;
338
+ } else {
339
+ uniforms.push(` ${DefaultUniformStyleType[key]} u_${key};`);
340
+ }
341
+ vsDeclInjection += `
342
+ #ifdef USE_ATTRIBUTE_${upperCaseKey}
343
+ layout(location = ${shaderDefineName}) in ${DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
344
+ #endif \n`;
345
+ });
346
+ const fsDeclInjection = uniforms.length ? `
347
+ layout(std140) uniform AttributeUniforms {
348
+ ${uniforms.join('\n')}
349
+ };\n` : '';
350
+ vsDeclInjection += fsDeclInjection;
351
+ let vsMainInjection = '';
352
+ shaderEncodeStyles.forEach(key => {
353
+ const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
354
+ vsMainInjection += `
355
+ #ifdef USE_ATTRIBUTE_${upperCaseKey}
356
+ ${DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
357
+ #else
358
+ ${DefaultUniformStyleType[key]} ${key} = u_${key};
359
+ #endif
360
+ `;
361
+ });
362
+ return {
363
+ 'vs:#decl': vsDeclInjection,
364
+ 'fs:#decl': fsDeclInjection,
365
+ 'vs:#main-start': vsMainInjection
366
+ };
333
367
  }
@@ -1,20 +1,16 @@
1
1
  import type { IStyleAttribute } from '@antv/l7-core';
2
- export declare enum ShaderLocation {
3
- POSITION = 0,
4
- COLOR = 1,
5
- VERTEX_ID = 2,
6
- PICKING_COLOR = 3,
7
- STROKE = 4,
8
- OPACITY = 5,
9
- OFFSETS = 6,
10
- ROTATION = 7,
11
- EXTRUSION_BASE = 8,
12
- SIZE = 9,
13
- SHAPE = 10,
14
- EXTRUDE = 11,
15
- MAX = 12,
16
- NORMAL = 13,
17
- UV = 14,
18
- LINEAR = 15
19
- }
2
+ /**
3
+ * Attribute Layout Location in Shader
4
+ */
5
+ export declare const COMMON_ATTRIBUTE_LOCATION: {
6
+ readonly POSITION: 0;
7
+ readonly POSITION_64LOW: 1;
8
+ readonly COLOR: 2;
9
+ readonly PICKING_COLOR: 3;
10
+ readonly STROKE: 4;
11
+ readonly OPACITY: 5;
12
+ readonly OFFSETS: 6;
13
+ readonly ROTATION: 7;
14
+ readonly MAX: 8;
15
+ };
20
16
  export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;