@antv/l7-layers 2.20.5 → 2.20.6

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 (447) hide show
  1. package/es/canvas/index.d.ts +3 -3
  2. package/es/citybuliding/models/build.d.ts +7 -12
  3. package/es/citybuliding/models/build.js +22 -11
  4. package/es/citybuliding/shaders/build_frag.glsl +26 -23
  5. package/es/citybuliding/shaders/build_vert.glsl +24 -16
  6. package/es/core/BaseLayer.d.ts +14 -2
  7. package/es/core/BaseLayer.js +53 -9
  8. package/es/core/BaseModel.d.ts +1 -1
  9. package/es/core/BaseModel.js +41 -15
  10. package/es/core/CommonStyleAttribute.d.ts +4 -2
  11. package/es/core/CommonStyleAttribute.js +3 -0
  12. package/es/core/LayerPickService.d.ts +1 -1
  13. package/es/core/TextureService.d.ts +2 -2
  14. package/es/core/interface.d.ts +7 -3
  15. package/es/core/interface.js +0 -1
  16. package/es/core/line_trangluation.d.ts +1 -1
  17. package/es/core/shape/arrow.d.ts +1 -1
  18. package/es/core/shape/extrude.d.ts +1 -1
  19. package/es/core/triangulation.d.ts +1 -1
  20. package/es/core/triangulation.js +13 -7
  21. package/es/core/utils.js +1 -1
  22. package/es/earth/index.d.ts +1 -1
  23. package/es/earth/models/atmosphere.d.ts +8 -2
  24. package/es/earth/models/atmosphere.js +15 -8
  25. package/es/earth/models/base.d.ts +8 -2
  26. package/es/earth/models/base.js +21 -12
  27. package/es/earth/models/bloomsphere.d.ts +8 -2
  28. package/es/earth/models/bloomsphere.js +15 -8
  29. package/es/earth/shaders/{atmosphere_frag.glsl → atmosphere/atmosphere_frag.glsl} +9 -6
  30. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +22 -0
  31. package/es/earth/shaders/base/base_frag.glsl +11 -0
  32. package/es/earth/shaders/base/base_vert.glsl +52 -0
  33. package/es/earth/shaders/bloomshpere/bloomsphere_frag.glsl +16 -0
  34. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +19 -0
  35. package/es/geometry/index.d.ts +2 -2
  36. package/es/geometry/models/billboard.d.ts +8 -1
  37. package/es/geometry/models/billboard.js +26 -11
  38. package/es/geometry/models/plane.d.ts +8 -1
  39. package/es/geometry/models/plane.js +23 -6
  40. package/es/geometry/models/sprite.d.ts +12 -2
  41. package/es/geometry/models/sprite.js +44 -18
  42. package/es/geometry/shaders/billboard_frag.glsl +11 -6
  43. package/es/geometry/shaders/billboard_vert.glsl +12 -15
  44. package/es/geometry/shaders/plane_frag.glsl +14 -10
  45. package/es/geometry/shaders/plane_vert.glsl +11 -10
  46. package/es/geometry/shaders/sprite_frag.glsl +11 -7
  47. package/es/geometry/shaders/sprite_vert.glsl +10 -9
  48. package/es/heatmap/index.d.ts +3 -3
  49. package/es/heatmap/models/grid.d.ts +8 -1
  50. package/es/heatmap/models/grid.js +25 -12
  51. package/es/heatmap/models/grid3d.d.ts +8 -1
  52. package/es/heatmap/models/grid3d.js +29 -13
  53. package/es/heatmap/models/heatmap.d.ts +6 -4
  54. package/es/heatmap/models/heatmap.js +123 -75
  55. package/es/heatmap/models/hexagon.d.ts +8 -1
  56. package/es/heatmap/models/hexagon.js +25 -12
  57. package/es/heatmap/shaders/grid/grid_frag.glsl +8 -0
  58. package/es/heatmap/shaders/{grid_vert.glsl → grid/grid_vert.glsl} +15 -15
  59. package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +8 -0
  60. package/{lib/heatmap/shaders/hexagon_3d_vert.glsl → es/heatmap/shaders/grid3d/grid_3d_vert.glsl} +13 -16
  61. package/es/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +24 -0
  62. package/es/heatmap/shaders/{heatmap_3d_vert.glsl → heatmap/heatmap_3d_vert.glsl} +19 -9
  63. package/es/heatmap/shaders/heatmap/heatmap_frag.glsl +52 -0
  64. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +16 -0
  65. package/{lib/heatmap/shaders → es/heatmap/shaders/heatmap}/heatmap_framebuffer_vert.glsl +14 -9
  66. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +19 -0
  67. package/es/heatmap/shaders/hexagon/hexagon_frag.glsl +8 -0
  68. package/es/heatmap/shaders/{hexagon_vert.glsl → hexagon/hexagon_vert.glsl} +12 -13
  69. package/es/image/index.d.ts +2 -2
  70. package/es/image/models/image.d.ts +9 -2
  71. package/es/image/models/image.js +83 -44
  72. package/es/image/shaders/image_frag.glsl +34 -7
  73. package/es/image/shaders/image_vert.glsl +11 -5
  74. package/es/line/index.d.ts +4 -4
  75. package/es/line/index.js +2 -1
  76. package/es/line/models/arc.d.ts +8 -3
  77. package/es/line/models/arc.js +57 -76
  78. package/es/line/models/arc_3d.d.ts +8 -3
  79. package/es/line/models/arc_3d.js +46 -57
  80. package/es/line/models/flow.d.ts +8 -2
  81. package/es/line/models/flow.js +14 -12
  82. package/es/line/models/great_circle.d.ts +8 -3
  83. package/es/line/models/great_circle.js +40 -29
  84. package/es/line/models/index.d.ts +1 -1
  85. package/es/line/models/index.js +3 -6
  86. package/es/line/models/line.d.ts +8 -3
  87. package/es/line/models/line.js +67 -140
  88. package/es/line/models/{simpleLine.d.ts → simple_line.d.ts} +8 -2
  89. package/es/line/models/simple_line.js +204 -0
  90. package/es/line/models/wall.d.ts +8 -3
  91. package/es/line/models/wall.js +35 -27
  92. package/es/line/shaders/{line_arc_frag.glsl → arc/line_arc_frag.glsl} +36 -26
  93. package/es/line/shaders/{line_arc_vert.glsl → arc/line_arc_vert.glsl} +52 -22
  94. package/es/line/shaders/{line_arc_3d_frag.glsl → arc3d/line_arc_3d_frag.glsl} +32 -24
  95. package/{lib/line/shaders → es/line/shaders/arc3d}/line_arc_3d_vert.glsl +37 -27
  96. package/es/line/shaders/flow/flow_line_frag.glsl +5 -4
  97. package/es/line/shaders/flow/flow_line_vert.glsl +17 -18
  98. package/es/line/shaders/{line_arc_great_circle_frag.glsl → greatCircle/line_arc_great_circle_frag.glsl} +30 -30
  99. package/{lib/line/shaders → es/line/shaders/greatCircle}/line_arc_great_circle_vert.glsl +43 -40
  100. package/es/line/shaders/{line_frag.glsl → line/line_frag.glsl} +55 -28
  101. package/es/line/shaders/line/line_vert.glsl +114 -0
  102. package/es/line/shaders/simple/simpleline_frag.glsl +27 -3
  103. package/es/line/shaders/simple/simpleline_vert.glsl +20 -20
  104. package/es/line/shaders/wall/wall_frag.glsl +31 -26
  105. package/es/line/shaders/wall/wall_vert.glsl +29 -22
  106. package/es/mask/index.d.ts +2 -2
  107. package/es/mask/models/fill.d.ts +1 -1
  108. package/es/plugins/DataMappingPlugin.d.ts +1 -1
  109. package/es/plugins/DataMappingPlugin.js +1 -3
  110. package/es/plugins/DataSourcePlugin.d.ts +1 -1
  111. package/es/plugins/FeatureScalePlugin.d.ts +1 -1
  112. package/es/plugins/FeatureScalePlugin.js +14 -3
  113. package/es/plugins/LayerAnimateStylePlugin.d.ts +1 -1
  114. package/es/plugins/LayerMaskPlugin.d.ts +1 -1
  115. package/es/plugins/LayerModelPlugin.d.ts +1 -1
  116. package/es/plugins/LayerStylePlugin.d.ts +1 -1
  117. package/es/plugins/LightingPlugin.d.ts +1 -1
  118. package/es/plugins/MultiPassRendererPlugin.d.ts +1 -1
  119. package/es/plugins/PixelPickingPlugin.d.ts +6 -2
  120. package/es/plugins/PixelPickingPlugin.js +36 -49
  121. package/es/plugins/RegisterStyleAttributePlugin.d.ts +1 -1
  122. package/es/plugins/ShaderUniformPlugin.d.ts +1 -1
  123. package/es/plugins/ShaderUniformPlugin.js +11 -6
  124. package/es/plugins/UpdateModelPlugin.d.ts +1 -1
  125. package/es/plugins/UpdateStyleAttributePlugin.d.ts +1 -1
  126. package/es/point/index.d.ts +2 -2
  127. package/es/point/index.js +1 -0
  128. package/es/point/models/billboard_point.d.ts +9 -3
  129. package/es/point/models/billboard_point.js +18 -18
  130. package/es/point/models/earthExtrude.d.ts +7 -12
  131. package/es/point/models/earthExtrude.js +21 -13
  132. package/es/point/models/earthFill.d.ts +8 -3
  133. package/es/point/models/earthFill.js +18 -30
  134. package/es/point/models/extrude.d.ts +1 -4
  135. package/es/point/models/extrude.js +2 -11
  136. package/es/point/models/fill.d.ts +8 -2
  137. package/es/point/models/fill.js +33 -84
  138. package/es/point/models/{fillmage.d.ts → fillImage.d.ts} +8 -2
  139. package/es/point/models/{fillmage.js → fillImage.js} +23 -15
  140. package/es/point/models/image.d.ts +8 -1
  141. package/es/point/models/image.js +31 -17
  142. package/es/point/models/index.js +1 -1
  143. package/es/point/models/normal.d.ts +9 -3
  144. package/es/point/models/normal.js +13 -30
  145. package/es/point/models/radar.d.ts +8 -2
  146. package/es/point/models/radar.js +23 -45
  147. package/es/point/models/text.d.ts +9 -2
  148. package/es/point/models/text.js +31 -32
  149. package/{lib/point/shaders → es/point/shaders/billboard}/billboard_point_frag.glsl +17 -13
  150. package/{lib/point/shaders → es/point/shaders/billboard}/billboard_point_vert.glsl +13 -14
  151. package/es/point/shaders/earthExtrude/earthExtrude_frag.glsl +36 -0
  152. package/{lib/point/shaders/earth/extrude_vert.glsl → es/point/shaders/earthExtrude/earthExtrude_vert.glsl} +25 -22
  153. package/{lib/point/shaders/earth/fill_frag.glsl → es/point/shaders/earthFill/earthFill_frag.glsl} +20 -18
  154. package/{lib/point/shaders/earth/fill_vert.glsl → es/point/shaders/earthFill/earthFill_vert.glsl} +17 -22
  155. package/es/point/shaders/extrude/extrude_vert.glsl +0 -3
  156. package/{lib/point/shaders → es/point/shaders/fill}/fill_frag.glsl +18 -1
  157. package/es/point/shaders/{fill_vert.glsl → fill/fill_vert.glsl} +5 -4
  158. package/es/point/shaders/fillImage/fillImage_frag.glsl +24 -0
  159. package/{lib/point/shaders/image → es/point/shaders/fillImage}/fillImage_vert.glsl +15 -17
  160. package/es/point/shaders/image/image_frag.glsl +42 -0
  161. package/{lib/point/shaders → es/point/shaders/image}/image_vert.glsl +14 -13
  162. package/es/point/shaders/radar/radar_frag.glsl +19 -14
  163. package/es/point/shaders/radar/radar_vert.glsl +21 -24
  164. package/es/point/shaders/text/text_frag.glsl +44 -0
  165. package/es/point/shaders/{text_vert.glsl → text/text_vert.glsl} +19 -17
  166. package/es/point/shape/extrude.d.ts +1 -1
  167. package/es/polygon/index.d.ts +2 -2
  168. package/es/polygon/models/extrude.d.ts +9 -9
  169. package/es/polygon/models/extrude.js +38 -15
  170. package/es/polygon/models/extrusion.d.ts +8 -1
  171. package/es/polygon/models/extrusion.js +24 -7
  172. package/es/polygon/models/fill.d.ts +9 -4
  173. package/es/polygon/models/fill.js +26 -13
  174. package/es/polygon/models/ocean.d.ts +9 -7
  175. package/es/polygon/models/ocean.js +30 -14
  176. package/es/polygon/models/water.d.ts +9 -4
  177. package/es/polygon/models/water.js +26 -10
  178. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +14 -14
  179. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +17 -15
  180. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +18 -18
  181. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +18 -24
  182. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +19 -15
  183. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +20 -24
  184. package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +4 -8
  185. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +7 -16
  186. package/es/polygon/shaders/fill/fill_frag.glsl +7 -0
  187. package/es/polygon/shaders/fill/fill_linear_frag.glsl +20 -0
  188. package/{lib/polygon/shaders/polygon_linear_vert.glsl → es/polygon/shaders/fill/fill_linear_vert.glsl} +12 -11
  189. package/es/polygon/shaders/{polygon_vert.glsl → fill/fill_vert.glsl} +6 -6
  190. package/es/polygon/shaders/{water/polygon_ocean_frag.glsl → ocean/ocean_frag.glsl} +13 -13
  191. package/es/polygon/shaders/ocean/ocean_vert.glsl +22 -0
  192. package/es/polygon/shaders/water/polygon_water_frag.glsl +14 -12
  193. package/es/polygon/shaders/water/polygon_water_vert.glsl +10 -10
  194. package/es/raster/buffers/triangulation.d.ts +1 -1
  195. package/es/raster/index.d.ts +2 -2
  196. package/es/raster/models/raster.d.ts +9 -8
  197. package/es/raster/models/raster.js +54 -38
  198. package/es/raster/models/rasterRgb.d.ts +9 -7
  199. package/es/raster/models/rasterRgb.js +36 -19
  200. package/es/raster/models/rasterTerrainRgb.d.ts +1 -1
  201. package/es/raster/models/rasterTerrainRgb.js +2 -2
  202. package/es/raster/shaders/raster/raster_2d_frag.glsl +34 -0
  203. package/es/raster/shaders/raster/raster_2d_vert.glsl +21 -0
  204. package/es/raster/shaders/rgb/raster_rgb_frag.glsl +26 -0
  205. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +21 -0
  206. package/es/tile/core/BaseLayer.d.ts +2 -2
  207. package/es/tile/core/TileDebugLayer.d.ts +1 -1
  208. package/es/tile/interaction/getRasterData.d.ts +2 -2
  209. package/es/tile/interaction/utils.d.ts +1 -1
  210. package/es/tile/interface.d.ts +2 -2
  211. package/es/tile/service/TileLayerService.d.ts +2 -2
  212. package/es/tile/service/TilePickService.d.ts +2 -2
  213. package/es/tile/service/TileSourceService.d.ts +1 -1
  214. package/es/tile/tile/Tile.d.ts +2 -3
  215. package/es/tile/tile/VectorTile.d.ts +1 -1
  216. package/es/tile/tile/index.d.ts +1 -1
  217. package/es/tile/utils/constants.js +1 -1
  218. package/es/tile/utils/utils.d.ts +1 -1
  219. package/es/utils/blend.d.ts +1 -1
  220. package/es/utils/multiPassRender.d.ts +1 -1
  221. package/es/utils/stencil.d.ts +1 -1
  222. package/es/wind/index.d.ts +3 -3
  223. package/es/wind/models/wind.d.ts +1 -1
  224. package/lib/citybuliding/models/build.js +22 -11
  225. package/lib/citybuliding/shaders/build_frag.glsl +26 -23
  226. package/lib/citybuliding/shaders/build_vert.glsl +24 -16
  227. package/lib/core/BaseLayer.js +53 -9
  228. package/lib/core/BaseModel.js +41 -15
  229. package/lib/core/CommonStyleAttribute.js +3 -0
  230. package/lib/core/triangulation.js +12 -6
  231. package/lib/core/utils.js +1 -1
  232. package/lib/earth/models/atmosphere.js +15 -8
  233. package/lib/earth/models/base.js +21 -12
  234. package/lib/earth/models/bloomsphere.js +15 -8
  235. package/lib/earth/shaders/{atmosphere_frag.glsl → atmosphere/atmosphere_frag.glsl} +9 -6
  236. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +22 -0
  237. package/lib/earth/shaders/base/base_frag.glsl +11 -0
  238. package/lib/earth/shaders/base/base_vert.glsl +52 -0
  239. package/lib/earth/shaders/bloomshpere/bloomsphere_frag.glsl +16 -0
  240. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +19 -0
  241. package/lib/geometry/models/billboard.js +26 -11
  242. package/lib/geometry/models/plane.js +23 -6
  243. package/lib/geometry/models/sprite.js +44 -18
  244. package/lib/geometry/shaders/billboard_frag.glsl +11 -6
  245. package/lib/geometry/shaders/billboard_vert.glsl +12 -15
  246. package/lib/geometry/shaders/plane_frag.glsl +14 -10
  247. package/lib/geometry/shaders/plane_vert.glsl +11 -10
  248. package/lib/geometry/shaders/sprite_frag.glsl +11 -7
  249. package/lib/geometry/shaders/sprite_vert.glsl +10 -9
  250. package/lib/heatmap/models/grid.js +25 -12
  251. package/lib/heatmap/models/grid3d.js +29 -13
  252. package/lib/heatmap/models/heatmap.js +122 -74
  253. package/lib/heatmap/models/hexagon.js +25 -12
  254. package/lib/heatmap/shaders/grid/grid_frag.glsl +8 -0
  255. package/lib/heatmap/shaders/{grid_vert.glsl → grid/grid_vert.glsl} +15 -15
  256. package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +8 -0
  257. package/{es/heatmap/shaders/hexagon_3d_vert.glsl → lib/heatmap/shaders/grid3d/grid_3d_vert.glsl} +13 -16
  258. package/lib/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +24 -0
  259. package/lib/heatmap/shaders/{heatmap_3d_vert.glsl → heatmap/heatmap_3d_vert.glsl} +19 -9
  260. package/lib/heatmap/shaders/heatmap/heatmap_frag.glsl +52 -0
  261. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +16 -0
  262. package/{es/heatmap/shaders → lib/heatmap/shaders/heatmap}/heatmap_framebuffer_vert.glsl +14 -9
  263. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +19 -0
  264. package/lib/heatmap/shaders/hexagon/hexagon_frag.glsl +8 -0
  265. package/lib/heatmap/shaders/{hexagon_vert.glsl → hexagon/hexagon_vert.glsl} +12 -13
  266. package/lib/image/models/image.js +83 -44
  267. package/lib/image/shaders/image_frag.glsl +34 -7
  268. package/lib/image/shaders/image_vert.glsl +11 -5
  269. package/lib/line/index.js +2 -1
  270. package/lib/line/models/arc.js +57 -76
  271. package/lib/line/models/arc_3d.js +47 -59
  272. package/lib/line/models/flow.js +14 -12
  273. package/lib/line/models/great_circle.js +40 -29
  274. package/lib/line/models/index.js +4 -7
  275. package/lib/line/models/line.js +67 -142
  276. package/lib/line/models/{simpleLine.js → simple_line.js} +84 -74
  277. package/lib/line/models/wall.js +35 -27
  278. package/lib/line/shaders/{line_arc_frag.glsl → arc/line_arc_frag.glsl} +36 -26
  279. package/lib/line/shaders/{line_arc_vert.glsl → arc/line_arc_vert.glsl} +52 -22
  280. package/lib/line/shaders/{line_arc_3d_frag.glsl → arc3d/line_arc_3d_frag.glsl} +32 -24
  281. package/{es/line/shaders → lib/line/shaders/arc3d}/line_arc_3d_vert.glsl +37 -27
  282. package/lib/line/shaders/flow/flow_line_frag.glsl +5 -4
  283. package/lib/line/shaders/flow/flow_line_vert.glsl +17 -18
  284. package/lib/line/shaders/{line_arc_great_circle_frag.glsl → greatCircle/line_arc_great_circle_frag.glsl} +30 -30
  285. package/{es/line/shaders → lib/line/shaders/greatCircle}/line_arc_great_circle_vert.glsl +43 -40
  286. package/lib/line/shaders/{line_frag.glsl → line/line_frag.glsl} +55 -28
  287. package/lib/line/shaders/line/line_vert.glsl +114 -0
  288. package/lib/line/shaders/simple/simpleline_frag.glsl +27 -3
  289. package/lib/line/shaders/simple/simpleline_vert.glsl +20 -20
  290. package/lib/line/shaders/wall/wall_frag.glsl +31 -26
  291. package/lib/line/shaders/wall/wall_vert.glsl +29 -22
  292. package/lib/plugins/DataMappingPlugin.js +1 -3
  293. package/lib/plugins/FeatureScalePlugin.js +14 -3
  294. package/lib/plugins/PixelPickingPlugin.js +35 -48
  295. package/lib/plugins/ShaderUniformPlugin.js +11 -6
  296. package/lib/point/index.js +1 -0
  297. package/lib/point/models/billboard_point.js +18 -18
  298. package/lib/point/models/earthExtrude.js +21 -13
  299. package/lib/point/models/earthFill.js +18 -30
  300. package/lib/point/models/extrude.js +2 -11
  301. package/lib/point/models/fill.js +33 -84
  302. package/lib/point/models/{fillmage.js → fillImage.js} +24 -17
  303. package/lib/point/models/image.js +31 -17
  304. package/lib/point/models/index.js +2 -2
  305. package/lib/point/models/normal.js +13 -30
  306. package/lib/point/models/radar.js +23 -45
  307. package/lib/point/models/text.js +31 -32
  308. package/{es/point/shaders → lib/point/shaders/billboard}/billboard_point_frag.glsl +17 -13
  309. package/{es/point/shaders → lib/point/shaders/billboard}/billboard_point_vert.glsl +13 -14
  310. package/lib/point/shaders/earthExtrude/earthExtrude_frag.glsl +36 -0
  311. package/{es/point/shaders/earth/extrude_vert.glsl → lib/point/shaders/earthExtrude/earthExtrude_vert.glsl} +25 -22
  312. package/{es/point/shaders/earth/fill_frag.glsl → lib/point/shaders/earthFill/earthFill_frag.glsl} +20 -18
  313. package/{es/point/shaders/earth/fill_vert.glsl → lib/point/shaders/earthFill/earthFill_vert.glsl} +17 -22
  314. package/lib/point/shaders/extrude/extrude_vert.glsl +0 -3
  315. package/{es/point/shaders → lib/point/shaders/fill}/fill_frag.glsl +18 -1
  316. package/lib/point/shaders/{fill_vert.glsl → fill/fill_vert.glsl} +5 -4
  317. package/lib/point/shaders/fillImage/fillImage_frag.glsl +24 -0
  318. package/{es/point/shaders/image → lib/point/shaders/fillImage}/fillImage_vert.glsl +15 -17
  319. package/lib/point/shaders/image/image_frag.glsl +42 -0
  320. package/{es/point/shaders → lib/point/shaders/image}/image_vert.glsl +14 -13
  321. package/lib/point/shaders/radar/radar_frag.glsl +19 -14
  322. package/lib/point/shaders/radar/radar_vert.glsl +21 -24
  323. package/lib/point/shaders/text/text_frag.glsl +44 -0
  324. package/lib/point/shaders/{text_vert.glsl → text/text_vert.glsl} +19 -17
  325. package/lib/polygon/models/extrude.js +38 -15
  326. package/lib/polygon/models/extrusion.js +24 -7
  327. package/lib/polygon/models/fill.js +26 -13
  328. package/lib/polygon/models/ocean.js +30 -14
  329. package/lib/polygon/models/water.js +26 -10
  330. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +14 -14
  331. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +17 -15
  332. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +18 -18
  333. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +18 -24
  334. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +19 -15
  335. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +20 -24
  336. package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +4 -8
  337. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +7 -16
  338. package/lib/polygon/shaders/fill/fill_frag.glsl +7 -0
  339. package/lib/polygon/shaders/fill/fill_linear_frag.glsl +20 -0
  340. package/{es/polygon/shaders/polygon_linear_vert.glsl → lib/polygon/shaders/fill/fill_linear_vert.glsl} +12 -11
  341. package/lib/polygon/shaders/{polygon_vert.glsl → fill/fill_vert.glsl} +6 -6
  342. package/lib/polygon/shaders/{water/polygon_ocean_frag.glsl → ocean/ocean_frag.glsl} +13 -13
  343. package/lib/polygon/shaders/ocean/ocean_vert.glsl +22 -0
  344. package/lib/polygon/shaders/water/polygon_water_frag.glsl +14 -12
  345. package/lib/polygon/shaders/water/polygon_water_vert.glsl +10 -10
  346. package/lib/raster/models/raster.js +54 -38
  347. package/lib/raster/models/rasterRgb.js +36 -19
  348. package/lib/raster/models/rasterTerrainRgb.js +2 -2
  349. package/lib/raster/shaders/raster/raster_2d_frag.glsl +34 -0
  350. package/lib/raster/shaders/raster/raster_2d_vert.glsl +21 -0
  351. package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +26 -0
  352. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +21 -0
  353. package/lib/tile/utils/constants.js +1 -1
  354. package/package.json +7 -7
  355. package/es/earth/shaders/atmosphere_vert.glsl +0 -26
  356. package/es/earth/shaders/base_frag.glsl +0 -13
  357. package/es/earth/shaders/base_vert.glsl +0 -52
  358. package/es/earth/shaders/bloomsphere_frag.glsl +0 -15
  359. package/es/earth/shaders/bloomsphere_vert.glsl +0 -20
  360. package/es/heatmap/shaders/heatmap_3d_frag.glsl +0 -14
  361. package/es/heatmap/shaders/heatmap_frag.glsl +0 -47
  362. package/es/heatmap/shaders/heatmap_framebuffer_frag.glsl +0 -10
  363. package/es/heatmap/shaders/heatmap_vert.glsl +0 -10
  364. package/es/heatmap/shaders/hexagon_frag.glsl +0 -12
  365. package/es/line/models/earthArc_3d.d.ts +0 -17
  366. package/es/line/models/earthArc_3d.js +0 -285
  367. package/es/line/models/linearline.d.ts +0 -11
  368. package/es/line/models/linearline.js +0 -241
  369. package/es/line/models/simpleLine.js +0 -194
  370. package/es/line/shaders/arc_chunks.vert.glsl +0 -21
  371. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -21
  372. package/es/line/shaders/dash/arc_dash_vert.glsl +0 -102
  373. package/es/line/shaders/dash/line_dash_frag.glsl +0 -27
  374. package/es/line/shaders/dash/line_dash_vert.glsl +0 -82
  375. package/es/line/shaders/line_arc2d_vert.glsl +0 -114
  376. package/es/line/shaders/line_bezier_vert.glsl +0 -85
  377. package/es/line/shaders/line_vert.glsl +0 -165
  378. package/es/line/shaders/linear/arc3d_linear_frag.glsl +0 -32
  379. package/es/line/shaders/linear/arc3d_linear_vert.glsl +0 -161
  380. package/es/line/shaders/linear/arc_linear_frag.glsl +0 -10
  381. package/es/line/shaders/linear/arc_linear_vert.glsl +0 -98
  382. package/es/line/shaders/linear/line_linear_frag.glsl +0 -25
  383. package/es/line/shaders/linearLine/line_linear_frag.glsl +0 -8
  384. package/es/line/shaders/linearLine/line_linear_vert.glsl +0 -93
  385. package/es/line/shaders/simple/simpleline_linear_frag.glsl +0 -8
  386. package/es/point/shaders/animate/wave_frag.glsl +0 -55
  387. package/es/point/shaders/earth/extrude_frag.glsl +0 -32
  388. package/es/point/shaders/image/fillImage_frag.glsl +0 -18
  389. package/es/point/shaders/image_frag.glsl +0 -37
  390. package/es/point/shaders/text_frag.glsl +0 -39
  391. package/es/polygon/shaders/polygon_frag.glsl +0 -7
  392. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -15
  393. package/es/polygon/shaders/water/polygon_ocean_vert.glsl +0 -16
  394. package/es/raster/shaders/raster_2d_frag.glsl +0 -32
  395. package/es/raster/shaders/raster_2d_vert.glsl +0 -13
  396. package/es/raster/shaders/raster_frag.glsl +0 -11
  397. package/es/raster/shaders/raster_rgb_frag.glsl +0 -20
  398. package/es/raster/shaders/raster_vert.glsl +0 -34
  399. package/lib/earth/shaders/atmosphere_vert.glsl +0 -26
  400. package/lib/earth/shaders/base_frag.glsl +0 -13
  401. package/lib/earth/shaders/base_vert.glsl +0 -52
  402. package/lib/earth/shaders/bloomsphere_frag.glsl +0 -15
  403. package/lib/earth/shaders/bloomsphere_vert.glsl +0 -20
  404. package/lib/heatmap/shaders/heatmap_3d_frag.glsl +0 -14
  405. package/lib/heatmap/shaders/heatmap_frag.glsl +0 -47
  406. package/lib/heatmap/shaders/heatmap_framebuffer_frag.glsl +0 -10
  407. package/lib/heatmap/shaders/heatmap_vert.glsl +0 -10
  408. package/lib/heatmap/shaders/hexagon_frag.glsl +0 -12
  409. package/lib/line/models/earthArc_3d.js +0 -291
  410. package/lib/line/models/linearline.js +0 -247
  411. package/lib/line/shaders/arc_chunks.vert.glsl +0 -21
  412. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -21
  413. package/lib/line/shaders/dash/arc_dash_vert.glsl +0 -102
  414. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -27
  415. package/lib/line/shaders/dash/line_dash_vert.glsl +0 -82
  416. package/lib/line/shaders/line_arc2d_vert.glsl +0 -114
  417. package/lib/line/shaders/line_bezier_vert.glsl +0 -85
  418. package/lib/line/shaders/line_vert.glsl +0 -165
  419. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +0 -32
  420. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +0 -161
  421. package/lib/line/shaders/linear/arc_linear_frag.glsl +0 -10
  422. package/lib/line/shaders/linear/arc_linear_vert.glsl +0 -98
  423. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -25
  424. package/lib/line/shaders/linearLine/line_linear_frag.glsl +0 -8
  425. package/lib/line/shaders/linearLine/line_linear_vert.glsl +0 -93
  426. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +0 -8
  427. package/lib/point/shaders/animate/wave_frag.glsl +0 -55
  428. package/lib/point/shaders/earth/extrude_frag.glsl +0 -32
  429. package/lib/point/shaders/image/fillImage_frag.glsl +0 -18
  430. package/lib/point/shaders/image_frag.glsl +0 -37
  431. package/lib/point/shaders/text_frag.glsl +0 -39
  432. package/lib/polygon/shaders/polygon_frag.glsl +0 -7
  433. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -15
  434. package/lib/polygon/shaders/water/polygon_ocean_vert.glsl +0 -16
  435. package/lib/raster/shaders/raster_2d_frag.glsl +0 -32
  436. package/lib/raster/shaders/raster_2d_vert.glsl +0 -13
  437. package/lib/raster/shaders/raster_frag.glsl +0 -11
  438. package/lib/raster/shaders/raster_rgb_frag.glsl +0 -20
  439. package/lib/raster/shaders/raster_vert.glsl +0 -34
  440. /package/es/point/shaders/{normal_frag.glsl → normal/normal_frag.glsl} +0 -0
  441. /package/es/point/shaders/{normal_vert.glsl → normal/normal_vert.glsl} +0 -0
  442. /package/es/raster/shaders/{raster_terrain_rgb_frag.glsl → terrain/terrain_rgb_frag.glsl} +0 -0
  443. /package/es/raster/shaders/{rater_terrain_rgb_vert.glsl → terrain/terrain_rgb_vert.glsl} +0 -0
  444. /package/lib/point/shaders/{normal_frag.glsl → normal/normal_frag.glsl} +0 -0
  445. /package/lib/point/shaders/{normal_vert.glsl → normal/normal_vert.glsl} +0 -0
  446. /package/lib/raster/shaders/{raster_terrain_rgb_frag.glsl → terrain/terrain_rgb_frag.glsl} +0 -0
  447. /package/lib/raster/shaders/{rater_terrain_rgb_vert.glsl → terrain/terrain_rgb_vert.glsl} +0 -0
@@ -14,17 +14,18 @@ import { rgb2arr } from '@antv/l7-utils';
14
14
  import BaseModel from "../../core/BaseModel";
15
15
  import { PolygonExtrudeTriangulation } from "../../core/triangulation";
16
16
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
17
- var polygonExtrudeFrag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\n\n#pragma include \"picking\"\n\nvoid main() {\n\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = v_Color;\n \n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
+ var polygonExtrudeFrag = "layout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n outputColor = v_Color;\n \n outputColor = filterColor(outputColor);\n}\n";
18
18
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
19
- var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n float isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
19
+ var polygonExtrudeVert = "layout(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 vec3 a_uvs;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \nfloat isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
20
20
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
21
- var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying vec3 v_uvs;\nvarying vec2 v_texture_data;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n } else {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = texture2D(u_texture, vec2(topU, topV));\n // gl_FragColor = vec4(1.0, 0., 0., 1.0);\n }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; // texture
21
+ var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\n\n\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n outputColor = v_Color;\n }\n } else {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));\n }\n \n\n outputColor.a *= opacity;\n outputColor = filterColor(outputColor);\n}\n"; // texture
22
22
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
23
- var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\n\nuniform sampler2D u_texture;\n\n\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_linearColor: 0.0;\n\nvarying vec2 v_texture_data;\nvarying vec3 v_uvs;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_uvs = a_uvs;\n\n v_texture_data = vec2(a_Position.z, lightWeight);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
23
+ var polygonExtrudeTexVert = "layout(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 vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\n\nout vec2 v_texture_data;\nout vec3 v_uvs;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_uvs = a_uvs;\n v_Color = a_Color;\n v_Color.a *= opacity;\n \n v_texture_data = vec2(a_Position.z, lightWeight);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
24
24
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
25
- var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying vec3 v_uvs;\nvarying vec2 v_texture_data;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n // side notuse linear\n gl_FragColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n}\n";
25
+ var polygonExtrudePickLightFrag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n // side notuse linear\n outputColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n outputColor = v_Color;\n }\n\n outputColor = filterColorAlpha(outputColor, lightWeight);\n}\n";
26
26
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
27
- var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_texture_data;\nvarying vec3 v_uvs;\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n\n\n v_uvs = a_uvs;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n float lightWeight = calc_lighting(pos);\n v_texture_data = vec2(a_Position.z,lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
27
+ var polygonExtrudePickLightVert = "layout(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 vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec2 v_texture_data;\nout vec3 v_uvs;\nout vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n\n\n v_uvs = a_uvs;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n float lightWeight = calc_lighting(pos);\n v_texture_data = vec2(a_Position.z,lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n setPickingColor(a_PickingColor);\n}\n";
28
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
28
29
  var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
29
30
  _inherits(ExtrudeModel, _BaseModel);
30
31
  var _super = _createSuper(ExtrudeModel);
@@ -35,6 +36,14 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
35
36
  _createClass(ExtrudeModel, [{
36
37
  key: "getUninforms",
37
38
  value: function getUninforms() {
39
+ var commoninfo = this.getCommonUniformsInfo();
40
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
41
+ this.updateStyleUnifoms();
42
+ return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
43
+ }
44
+ }, {
45
+ key: "getCommonUniformsInfo",
46
+ value: function getCommonUniformsInfo() {
38
47
  var _ref = this.layer.getLayerConfig(),
39
48
  _ref$heightfixed = _ref.heightfixed,
40
49
  heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
@@ -56,18 +65,24 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
56
65
  targetColorArr = rgb2arr(targetColor);
57
66
  useLinearColor = 1;
58
67
  }
59
- return _objectSpread({
68
+ var commonOptions = {
69
+ u_sourceColor: sourceColorArr,
70
+ u_targetColor: targetColorArr,
71
+ u_linearColor: useLinearColor,
60
72
  // 控制侧面和顶面的显示隐藏
61
73
  u_topsurface: Number(topsurface),
62
74
  u_sidesurface: Number(sidesurface),
63
75
  u_heightfixed: Number(heightfixed),
64
76
  u_raisingHeight: Number(raisingHeight),
65
77
  // 渐变色支持参数
66
- u_linearColor: useLinearColor,
67
- u_sourceColor: sourceColorArr,
68
- u_targetColor: targetColorArr,
69
- u_texture: this.texture
70
- }, this.getStyleAttribute());
78
+ u_texture: this.texture // 纹理
79
+ };
80
+
81
+ if (this.texture) {
82
+ this.textures = [this.texture];
83
+ }
84
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
85
+ return commonBufferInfo;
71
86
  }
72
87
  }, {
73
88
  key: "initModels",
@@ -100,18 +115,22 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
100
115
  while (1) switch (_context2.prev = _context2.next) {
101
116
  case 0:
102
117
  _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
103
- _context2.next = 3;
118
+ this.initUniformsBuffer();
119
+ _context2.next = 4;
104
120
  return this.layer.buildLayerModel({
105
121
  moduleName: type,
106
122
  vertexShader: vert,
107
123
  fragmentShader: frag,
124
+ depth: {
125
+ enable: true
126
+ },
108
127
  inject: this.getInject(),
109
128
  triangulation: PolygonExtrudeTriangulation
110
129
  });
111
- case 3:
130
+ case 4:
112
131
  model = _context2.sent;
113
132
  return _context2.abrupt("return", [model]);
114
- case 5:
133
+ case 6:
115
134
  case "end":
116
135
  return _context2.stop();
117
136
  }
@@ -154,6 +173,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
154
173
  value: function clearModels() {
155
174
  var _this$texture;
156
175
  (_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
176
+ this.textures = [];
157
177
  }
158
178
  }, {
159
179
  key: "registerBuiltinAttributes",
@@ -183,6 +203,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
183
203
  type: AttributeType.Attribute,
184
204
  descriptor: {
185
205
  name: 'a_uvs',
206
+ shaderLocation: ShaderLocation.UV,
186
207
  buffer: {
187
208
  // give the WebGL driver a hint that this buffer may change
188
209
  usage: gl.STATIC_DRAW,
@@ -204,6 +225,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
204
225
  type: AttributeType.Attribute,
205
226
  descriptor: {
206
227
  name: 'a_Normal',
228
+ shaderLocation: ShaderLocation.NORMAL,
207
229
  buffer: {
208
230
  // give the WebGL driver a hint that this buffer may change
209
231
  usage: gl.STATIC_DRAW,
@@ -221,6 +243,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
221
243
  type: AttributeType.Attribute,
222
244
  descriptor: {
223
245
  name: 'a_Size',
246
+ shaderLocation: ShaderLocation.SIZE,
224
247
  buffer: {
225
248
  usage: gl.DYNAMIC_DRAW,
226
249
  data: [],
@@ -1,10 +1,17 @@
1
- import { IModel, ITexture2D } from '@antv/l7-core';
1
+ import type { IModel, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ExtrusionModel extends BaseModel {
4
4
  protected texture: ITexture2D;
5
5
  getUninforms(): {
6
6
  [x: string]: any;
7
7
  };
8
+ protected getCommonUniformsInfo(): {
9
+ uniformsArray: number[];
10
+ uniformsLength: number;
11
+ uniformsOption: {
12
+ [key: string]: any;
13
+ };
14
+ };
8
15
  initModels(): Promise<IModel[]>;
9
16
  buildModels(): Promise<IModel[]>;
10
17
  getShaders(): {
@@ -12,9 +12,10 @@ import { AttributeType, gl } from '@antv/l7-core';
12
12
  import BaseModel from "../../core/BaseModel";
13
13
  import { PolygonExtrudeTriangulation } from "../../core/triangulation";
14
14
  /* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_frag.glsl' */
15
- var polygonExtrudeFrag = "\nuniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying vec2 v_texture_data;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n\n gl_FragColor = v_Color;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
15
+ var polygonExtrudeFrag = "\nin vec4 v_Color;\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n outputColor = v_Color;\n outputColor = filterColor(outputColor);\n}\n";
16
16
  /* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_vert.glsl' */
17
- var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\n\n\n\nvarying vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size + (1.0 - a_Position.z) * extrusionBase, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_Color = a_Color;\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
17
+ var polygonExtrudeVert = "layout(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;\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size + (1.0 - a_Position.z) * extrusionBase, 1.0);\n\n vec4 project_pos = project_position(pos);\n float lightWeight = calc_lighting(project_pos);\n v_Color = a_Color;\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
18
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
18
19
  var ExtrusionModel = /*#__PURE__*/function (_BaseModel) {
19
20
  _inherits(ExtrusionModel, _BaseModel);
20
21
  var _super = _createSuper(ExtrusionModel);
@@ -25,7 +26,17 @@ var ExtrusionModel = /*#__PURE__*/function (_BaseModel) {
25
26
  _createClass(ExtrusionModel, [{
26
27
  key: "getUninforms",
27
28
  value: function getUninforms() {
28
- return _objectSpread({}, this.getStyleAttribute());
29
+ var commoninfo = this.getCommonUniformsInfo();
30
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
31
+ this.updateStyleUnifoms();
32
+ return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
33
+ }
34
+ }, {
35
+ key: "getCommonUniformsInfo",
36
+ value: function getCommonUniformsInfo() {
37
+ var commonOptions = {};
38
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
39
+ return commonBufferInfo;
29
40
  }
30
41
  }, {
31
42
  key: "initModels",
@@ -55,18 +66,22 @@ var ExtrusionModel = /*#__PURE__*/function (_BaseModel) {
55
66
  while (1) switch (_context2.prev = _context2.next) {
56
67
  case 0:
57
68
  _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
58
- _context2.next = 3;
69
+ this.initUniformsBuffer();
70
+ _context2.next = 4;
59
71
  return this.layer.buildLayerModel({
60
72
  moduleName: type,
61
73
  vertexShader: vert,
62
74
  fragmentShader: frag,
63
75
  inject: this.getInject(),
64
- triangulation: PolygonExtrudeTriangulation
76
+ triangulation: PolygonExtrudeTriangulation,
77
+ depth: {
78
+ enable: true
79
+ }
65
80
  });
66
- case 3:
81
+ case 4:
67
82
  model = _context2.sent;
68
83
  return _context2.abrupt("return", [model]);
69
- case 5:
84
+ case 6:
70
85
  case "end":
71
86
  return _context2.stop();
72
87
  }
@@ -100,6 +115,7 @@ var ExtrusionModel = /*#__PURE__*/function (_BaseModel) {
100
115
  type: AttributeType.Attribute,
101
116
  descriptor: {
102
117
  name: 'a_Normal',
118
+ shaderLocation: ShaderLocation.NORMAL,
103
119
  buffer: {
104
120
  // give the WebGL driver a hint that this buffer may change
105
121
  usage: gl.STATIC_DRAW,
@@ -117,6 +133,7 @@ var ExtrusionModel = /*#__PURE__*/function (_BaseModel) {
117
133
  type: AttributeType.Attribute,
118
134
  descriptor: {
119
135
  name: 'a_Size',
136
+ shaderLocation: ShaderLocation.SIZE,
120
137
  buffer: {
121
138
  usage: gl.DYNAMIC_DRAW,
122
139
  data: [],
@@ -1,10 +1,15 @@
1
- import { IModel } from '@antv/l7-core';
1
+ import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class FillModel extends BaseModel {
4
4
  getUninforms(): {
5
- u_raisingHeight: number;
6
- u_opacitylinear: number;
7
- u_dir: number;
5
+ [x: string]: any;
6
+ };
7
+ protected getCommonUniformsInfo(): {
8
+ uniformsArray: number[];
9
+ uniformsLength: number;
10
+ uniformsOption: {
11
+ [key: string]: any;
12
+ };
8
13
  };
9
14
  initModels(): Promise<IModel[]>;
10
15
  buildModels(): Promise<IModel[]>;
@@ -12,14 +12,15 @@ import { AttributeType, gl } from '@antv/l7-core';
12
12
  import { polygonFillTriangulation } from '@antv/l7-utils';
13
13
  import BaseModel from "../../core/BaseModel";
14
14
  import { polygonTriangulationWithCenter } from "../../core/triangulation";
15
- /* babel-plugin-inline-import '../shaders/polygon_frag.glsl' */
16
- var polygon_frag = "varying vec4 v_color;\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
- /* babel-plugin-inline-import '../shaders/polygon_linear_frag.glsl' */
18
- var polygon_linear_frag = "#pragma include \"picking\"\nuniform float u_opacitylinear: 0.0;\nuniform float u_dir: 1.0;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\nvarying vec4 v_Color;\n\n\nvoid main() {\n gl_FragColor = v_Color;\n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
19
- /* babel-plugin-inline-import '../shaders/polygon_linear_vert.glsl' */
20
- var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nuniform float u_opacitylinear: 0.0;\n\nattribute vec3 a_linear;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n v_Color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n setPickingColor(a_PickingColor);\n}";
21
- /* babel-plugin-inline-import '../shaders/polygon_vert.glsl' */
22
- var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_raisingHeight: 0.0;\n\nvarying vec4 v_color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n\n";
15
+ /* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
16
+ var polygon_frag = "in vec4 v_color;\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
17
+ /* babel-plugin-inline-import '../shaders/fill/fill_linear_frag.glsl' */
18
+ var polygon_linear_frag = "\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\nin vec3 v_linear;\nin vec2 v_pos;\nin vec4 v_color;\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n outputColor = v_color;\n if(u_opacitylinear > 0.0) {\n outputColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n outputColor = filterColor(outputColor);\n}\n";
19
+ /* babel-plugin-inline-import '../shaders/fill/fill_linear_vert.glsl' */
20
+ var polygon_linear_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 15) in vec3 a_linear;\n\n\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec3 v_linear;\nout vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n setPickingColor(a_PickingColor);\n}";
21
+ /* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
22
+ var polygon_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\n\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n};\n\n\nout vec4 v_color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n\n";
23
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
23
24
  var FillModel = /*#__PURE__*/function (_BaseModel) {
24
25
  _inherits(FillModel, _BaseModel);
25
26
  var _super = _createSuper(FillModel);
@@ -30,6 +31,14 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
30
31
  _createClass(FillModel, [{
31
32
  key: "getUninforms",
32
33
  value: function getUninforms() {
34
+ var commoninfo = this.getCommonUniformsInfo();
35
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
36
+ this.updateStyleUnifoms();
37
+ return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
38
+ }
39
+ }, {
40
+ key: "getCommonUniformsInfo",
41
+ value: function getCommonUniformsInfo() {
33
42
  var _ref = this.layer.getLayerConfig(),
34
43
  _ref$raisingHeight = _ref.raisingHeight,
35
44
  raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
@@ -38,11 +47,13 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
38
47
  enable: false,
39
48
  dir: 'in'
40
49
  } : _ref$opacityLinear;
41
- return _objectSpread({
50
+ var commonOptions = {
42
51
  u_raisingHeight: Number(raisingHeight),
43
52
  u_opacitylinear: Number(opacityLinear.enable),
44
53
  u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0
45
- }, this.getStyleAttribute());
54
+ };
55
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
56
+ return commonBufferInfo;
46
57
  }
47
58
  }, {
48
59
  key: "initModels",
@@ -72,8 +83,9 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
72
83
  while (1) switch (_context2.prev = _context2.next) {
73
84
  case 0:
74
85
  _this$getModelParams = this.getModelParams(), frag = _this$getModelParams.frag, vert = _this$getModelParams.vert, triangulation = _this$getModelParams.triangulation, type = _this$getModelParams.type;
86
+ this.initUniformsBuffer();
75
87
  this.layer.triangulation = triangulation;
76
- _context2.next = 4;
88
+ _context2.next = 5;
77
89
  return this.layer.buildLayerModel({
78
90
  moduleName: type,
79
91
  vertexShader: vert,
@@ -85,10 +97,10 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
85
97
  enable: false
86
98
  }
87
99
  });
88
- case 4:
100
+ case 5:
89
101
  model = _context2.sent;
90
102
  return _context2.abrupt("return", [model]);
91
- case 6:
103
+ case 7:
92
104
  case "end":
93
105
  return _context2.stop();
94
106
  }
@@ -114,6 +126,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
114
126
  type: AttributeType.Attribute,
115
127
  descriptor: {
116
128
  name: 'a_linear',
129
+ shaderLocation: ShaderLocation.LINEAR,
117
130
  buffer: {
118
131
  // give the WebGL driver a hint that this buffer may change
119
132
  usage: gl.STATIC_DRAW,
@@ -1,16 +1,18 @@
1
- import { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
1
+ import type { IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class OceanModel extends BaseModel {
4
4
  private texture1;
5
5
  private texture2;
6
6
  private texture3;
7
7
  getUninforms(): {
8
- u_texture1: ITexture2D;
9
- u_texture2: ITexture2D;
10
- u_texture3: ITexture2D;
11
- u_watercolor: number[];
12
- u_watercolor2: number[];
13
- u_opacity: number;
8
+ [x: string]: any;
9
+ };
10
+ protected getCommonUniformsInfo(): {
11
+ uniformsArray: number[];
12
+ uniformsLength: number;
13
+ uniformsOption: {
14
+ [key: string]: any;
15
+ };
14
16
  };
15
17
  getAnimateUniforms(): IModelUniform;
16
18
  initModels(): Promise<IModel[]>;
@@ -1,5 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
4
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
5
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
@@ -12,10 +13,11 @@ import { AttributeType, gl } from '@antv/l7-core';
12
13
  import { lodashUtil, rgb2arr } from '@antv/l7-utils';
13
14
  import BaseModel from "../../core/BaseModel";
14
15
  import { polygonTriangulation } from "../../core/triangulation";
15
- /* babel-plugin-inline-import '../shaders/water/polygon_ocean_frag.glsl' */
16
- var ocean_frag = "\nuniform float u_time: 0.0;\nuniform float u_opacity: 1.0;\n\nvarying vec2 v_uv;\n\nfloat coast2water_fadedepth = 0.10;\nfloat large_waveheight = .750; // change to adjust the \"heavy\" waves\nfloat large_wavesize = 3.4; // factor to adjust the large wave size\nfloat small_waveheight = 0.6; // change to adjust the small random waves\nfloat small_wavesize = 0.5; // factor to ajust the small wave size\nfloat water_softlight_fact = 15.; // range [1..200] (should be << smaller than glossy-fact)\nfloat water_glossylight_fact= 120.; // range [1..200]\nfloat particle_amount = 70.;\n// vec3 watercolor = vec3(0.43, 0.60, 0.66); // 'transparent' low-water color (RGB)\n// vec3 watercolor2 = vec3(0.06, 0.07, 0.11); // deep-water color (RGB, should be darker than the low-water color)\nuniform vec4 u_watercolor;\nuniform vec4 u_watercolor2;\nvec3 water_specularcolor = vec3(1.3, 1.3, 0.9); // specular Color (RGB) of the water-highlights\n#define light vec3(-0., sin(u_time*0.5)*.5 + .35, 2.8) // position of the sun\n\nuniform sampler2D u_texture1;\nuniform sampler2D u_texture2;\nuniform sampler2D u_texture3;\n\n \n\nfloat hash( float n ) {\n return fract(sin(n)*43758.5453123);\n}\n\n// 2d noise function\nfloat noise1( in vec2 x ) {\n vec2 p = floor(x);\n vec2 f = smoothstep(0.0, 1.0, fract(x));\n float n = p.x + p.y*57.0;\n return mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),\n mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);\n}\n\nfloat noise(vec2 p) {\n return texture2D(u_texture2,p*vec2(1./256.)).x;\n}\n\nvec4 highness(vec2 p) {\n vec4 t = texture2D(u_texture1,fract(p));\n float clipped = -2.0-smoothstep(3.,10.,t.a)*6.9-smoothstep(10.,100.,t.a)*89.9-smoothstep(0.,10000.,t.a)*10000.0;\n return clamp(t, 0.0,3.0)+clamp(t/3.0-1.0, 0.0,1.0)+clamp(t/16.0-1.0, 0.0,1.0);\n}\n\nfloat height_map( vec2 p ) {\n vec4 height=highness(p);\n /*\n height = -0.5+\n 0.5*smoothstep(-100.,0.,-height)+\n 2.75*smoothstep(0.,2.,height)+\n 1.75*smoothstep(2.,4.,height)+\n 2.75*smoothstep(4.,16.,height)+\n 1.5*smoothstep(16.,1000.,height);\n */\n\n mat2 m = mat2( 0.9563*1.4, -0.2924*1.4, 0.2924*1.4, 0.9563*1.4 );\n //p = p*6.;\n float f = 0.6000*noise1( p ); p = m*p*1.1*6.;\n f += 0.2500*noise( p ); p = m*p*1.32;\n f += 0.1666*noise( p ); p = m*p*1.11;\n f += 0.0834*noise( p ); p = m*p*1.12;\n f += 0.0634*noise( p ); p = m*p*1.13;\n f += 0.0444*noise( p ); p = m*p*1.14;\n f += 0.0274*noise( p ); p = m*p*1.15;\n f += 0.0134*noise( p ); p = m*p*1.16;\n f += 0.0104*noise( p ); p = m*p*1.17;\n f += 0.0084*noise( p );\n f = .25*f+dot(height,vec4(-.03125,-.125,.25,.25))*.5;\n const float FLAT_LEVEL = 0.92525;\n //f = f*0.25+height*0.75;\n if (f<FLAT_LEVEL)\n f = f;\n else\n f = pow((f-FLAT_LEVEL)/(1.-FLAT_LEVEL), 2.)*(1.-FLAT_LEVEL)*2.0+FLAT_LEVEL; // makes a smooth coast-increase\n return clamp(f, 0., 10.);\n}\n\nvec3 plasma_quintic( float x ) {\n x = clamp( x, 0.0, 1.0);\n vec4 x1 = vec4( 1.0, x, x * x, x * x * x ); // 1 x x2 x3\n vec4 x2 = x1 * x1.w * x; // x4 x5 x6 x7\n return vec3(\n dot( x1.xyzw, vec4( +0.063861086, +1.992659096, -1.023901152, -0.490832805 ) ) + dot( x2.xy, vec2( +1.308442123, -0.914547012 ) ),\n dot( x1.xyzw, vec4( +0.049718590, -0.791144343, +2.892305078, +0.811726816 ) ) + dot( x2.xy, vec2( -4.686502417, +2.717794514 ) ),\n dot( x1.xyzw, vec4( +0.513275779, +1.580255060, -5.164414457, +4.559573646 ) ) + dot( x2.xy, vec2( -1.916810682, +0.570638854 ) ) );\n}\n\nvec4 color(vec2 p){\n vec4 c1 = vec4(1.7,1.6,.9,1);\n vec4 c2 = vec4(.2,.94,.1,1);\n vec4 c3 = vec4(.3,.2,.0,1);\n vec4 c4 = vec4(.99,.99,1.6,1);\n vec4 v = highness(p);\n float los = smoothstep(0.1,1.1,v.b);\n float his = smoothstep(3.5,6.5,v.b);\n float ces = smoothstep(1.,5.,v.a);\n vec4 lo = mix(c1,c2,los);\n vec4 hi = mix(c3,c4,his);\n vec4 ce = mix(lo,hi,ces);\n\n return vec4(plasma_quintic(ces),1).ragb;\n}\n\nvec3 terrain_map( vec2 p )\n{\n return color(p).rgb*0.75+0.25*vec3(0.7, .55, .4)+texture2D(u_texture3, fract(p*5.)).rgb*.5; // test-terrain is simply 'sandstone'\n}\n\nconst mat2 m = mat2( 0.72, -1.60, 1.60, 0.72 );\n\nfloat water_map( vec2 p, float height ) {\n vec2 p2 = p*large_wavesize;\n vec2 shift1 = 0.001*vec2( u_time*160.0*2.0, u_time*120.0*2.0 );\n vec2 shift2 = 0.001*vec2( u_time*190.0*2.0, -u_time*130.0*2.0 );\n\n // coarse crossing 'ocean' waves...\n float f = 0.6000*noise( p );\n f += 0.2500*noise( p*m );\n f += 0.1666*noise( p*m*m );\n float wave = sin(p2.x*0.622+p2.y*0.622+shift2.x*4.269)*large_waveheight*f*height*height ;\n\n p *= small_wavesize;\n f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<9; i++)\n { p = m*p*.947; f -= amp*abs(sin((noise( p+shift1*s )-.5)*2.)); amp = amp*.59; s*=-1.329; }\n \n return wave+f*small_waveheight;\n}\n\nfloat nautic(vec2 p) {\n p *= 18.;\n float f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*abs(smoothstep(0., 1., noise( p+u_time*s ))-.5); amp = amp*.5; s*=-1.227; }\n return pow(1.-f, 5.);\n}\n\nfloat particles(vec2 p) {\n p *= 200.;\n float f = 0.;\n float amp = 1.0, s = 1.5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*noise( p+u_time*s ); amp = amp*.5; s*=-1.227; }\n return pow(f*.35, 7.)*particle_amount;\n}\n\nfloat test_shadow( vec2 xy, float height) {\n vec3 r0 = vec3(xy, height);\n vec3 rd = normalize( light - r0 );\n \n float hit = 1.0;\n float t = 0.001;\n for (int j=1; j<25; j++)\n {\n vec3 p = r0 + t*rd;\n float h = height_map( p.xy );\n float height_diff = p.z - h;\n if (height_diff<0.0)\n {\n return 0.0;\n }\n t += 0.01+height_diff*.02;\n hit = min(hit, 2.*height_diff/t); // soft shaddow \n }\n return hit;\n}\n\nvec3 CalcTerrain(vec2 uv, float height) {\n vec3 col = terrain_map( uv );\n vec2 iResolution = vec2(512.);\n float h1 = height_map(uv-vec2(0., 0.5)/ iResolution.xy);\n float h2 = height_map(uv+vec2(0., 0.5)/ iResolution.xy);\n float h3 = height_map(uv-vec2(0.5, 0.)/ iResolution.xy);\n float h4 = height_map(uv+vec2(0.5, 0.)/ iResolution.xy);\n vec3 norm = normalize(vec3(h3-h4, h1-h2, 1.));\n vec3 r0 = vec3(uv, height);\n vec3 rd = normalize( light - r0 );\n float grad = dot(norm, rd);\n col *= grad+pow(grad, 8.);\n float terrainshade = test_shadow( uv, height );\n col = mix(col*.25, col, terrainshade);\n return col;\n}\n\n\nvoid main() {\n vec3 watercolor = u_watercolor.rgb;\n vec3 watercolor2 = u_watercolor2.rgb;\n vec2 uv = v_uv;\n float WATER_LEVEL = 0.84; // Water level (range: 0.0 - 2.0)\n float deepwater_fadedepth = 0.4 + coast2water_fadedepth;\n float height = height_map( uv );\n vec3 col;\n\n float waveheight = clamp(WATER_LEVEL*3.-1.5, 0., 1.);\n float level = WATER_LEVEL + .2*water_map(uv*15. + vec2(u_time*.1), waveheight);\n if (height > level)\n {\n col = CalcTerrain(uv, height);\n }\n if (height <= level)\n {\n vec2 dif = vec2(.0, .01);\n vec2 pos = uv*15. + vec2(u_time*.01);\n float h1 = water_map(pos-dif,waveheight);\n float h2 = water_map(pos+dif,waveheight);\n float h3 = water_map(pos-dif.yx,waveheight);\n float h4 = water_map(pos+dif.yx,waveheight);\n vec3 normwater = normalize(vec3(h3-h4, h1-h2, .125)); // norm-vector of the 'bumpy' water-plane\n uv += normwater.xy*.002*(level-height);\n \n col = CalcTerrain(uv, height);\n\n float coastfade = clamp((level-height)/coast2water_fadedepth, 0., 1.);\n float coastfade2= clamp((level-height)/deepwater_fadedepth, 0., 1.);\n float intensity = col.r*.2126+col.g*.7152+col.b*.0722;\n watercolor = mix(watercolor*intensity, watercolor2, smoothstep(0., 1., coastfade2));\n\n vec3 r0 = vec3(uv, WATER_LEVEL);\n vec3 rd = normalize( light - r0 ); // ray-direction to the light from water-position\n float grad = dot(normwater, rd); // dot-product of norm-vector and light-direction\n float specular = pow(grad, water_softlight_fact); // used for soft highlights \n float specular2= pow(grad, water_glossylight_fact); // used for glossy highlights\n float gradpos = dot(vec3(0., 0., 1.), rd);\n float specular1= smoothstep(0., 1., pow(gradpos, 5.)); // used for diffusity (some darker corona around light's specular reflections...) \n float watershade = test_shadow( uv, level );\n watercolor *= 2.2+watershade;\n watercolor += (.2+.8*watershade) * ((grad-1.0)*.5+specular) * .25;\n watercolor /= (1.+specular1*1.25);\n watercolor += watershade*specular2*water_specularcolor;\n watercolor += watershade*coastfade*(1.-coastfade2)*(vec3(.5, .6, .7)*nautic(uv)+vec3(1., 1., 1.)*particles(uv));\n \n col = mix(col, watercolor, coastfade);\n }\n \n\n float opacity = u_opacity;\n gl_FragColor = vec4(col, opacity); \n}\n";
17
- /* babel-plugin-inline-import '../shaders/water/polygon_ocean_vert.glsl' */
18
- var ocean_vert = "attribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\n\n\nvarying vec2 v_uv;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n}\n\n";
16
+ /* babel-plugin-inline-import '../shaders/ocean/ocean_frag.glsl' */
17
+ var ocean_frag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\nin vec2 v_uv;\nin float v_opacity;\nout vec4 outputColor;\n\nfloat coast2water_fadedepth = 0.10;\nfloat large_waveheight = .750; // change to adjust the \"heavy\" waves\nfloat large_wavesize = 3.4; // factor to adjust the large wave size\nfloat small_waveheight = 0.6; // change to adjust the small random waves\nfloat small_wavesize = 0.5; // factor to ajust the small wave size\nfloat water_softlight_fact = 15.; // range [1..200] (should be << smaller than glossy-fact)\nfloat water_glossylight_fact= 120.; // range [1..200]\nfloat particle_amount = 70.;\n\nvec3 water_specularcolor = vec3(1.3, 1.3, 0.9); // specular Color (RGB) of the water-highlights\n#define light vec3(-0., sin(u_time*0.5)*.5 + .35, 2.8) // position of the sun\n\nuniform sampler2D u_texture1;\nuniform sampler2D u_texture2;\nuniform sampler2D u_texture3;\n\n \n\nfloat hash( float n ) {\n return fract(sin(n)*43758.5453123);\n}\n\n// 2d noise function\nfloat noise1( in vec2 x ) {\n vec2 p = floor(x);\n vec2 f = smoothstep(0.0, 1.0, fract(x));\n float n = p.x + p.y*57.0;\n return mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),\n mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);\n}\n\nfloat noise(vec2 p) {\n return texture(SAMPLER_2D(u_texture2),p*vec2(1./256.)).x;\n}\n\nvec4 highness(vec2 p) {\n vec4 t = texture(SAMPLER_2D(u_texture1),fract(p));\n float clipped = -2.0-smoothstep(3.,10.,t.a)*6.9-smoothstep(10.,100.,t.a)*89.9-smoothstep(0.,10000.,t.a)*10000.0;\n return clamp(t, 0.0,3.0)+clamp(t/3.0-1.0, 0.0,1.0)+clamp(t/16.0-1.0, 0.0,1.0);\n}\n\nfloat height_map( vec2 p ) {\n vec4 height=highness(p);\n /*\n height = -0.5+\n 0.5*smoothstep(-100.,0.,-height)+\n 2.75*smoothstep(0.,2.,height)+\n 1.75*smoothstep(2.,4.,height)+\n 2.75*smoothstep(4.,16.,height)+\n 1.5*smoothstep(16.,1000.,height);\n */\n\n mat2 m = mat2( 0.9563*1.4, -0.2924*1.4, 0.2924*1.4, 0.9563*1.4 );\n //p = p*6.;\n float f = 0.6000*noise1( p ); p = m*p*1.1*6.;\n f += 0.2500*noise( p ); p = m*p*1.32;\n f += 0.1666*noise( p ); p = m*p*1.11;\n f += 0.0834*noise( p ); p = m*p*1.12;\n f += 0.0634*noise( p ); p = m*p*1.13;\n f += 0.0444*noise( p ); p = m*p*1.14;\n f += 0.0274*noise( p ); p = m*p*1.15;\n f += 0.0134*noise( p ); p = m*p*1.16;\n f += 0.0104*noise( p ); p = m*p*1.17;\n f += 0.0084*noise( p );\n f = .25*f+dot(height,vec4(-.03125,-.125,.25,.25))*.5;\n const float FLAT_LEVEL = 0.92525;\n //f = f*0.25+height*0.75;\n if (f<FLAT_LEVEL)\n f = f;\n else\n f = pow((f-FLAT_LEVEL)/(1.-FLAT_LEVEL), 2.)*(1.-FLAT_LEVEL)*2.0+FLAT_LEVEL; // makes a smooth coast-increase\n return clamp(f, 0., 10.);\n}\n\nvec3 plasma_quintic( float x ) {\n x = clamp( x, 0.0, 1.0);\n vec4 x1 = vec4( 1.0, x, x * x, x * x * x ); // 1 x x2 x3\n vec4 x2 = x1 * x1.w * x; // x4 x5 x6 x7\n return vec3(\n dot( x1.xyzw, vec4( +0.063861086, +1.992659096, -1.023901152, -0.490832805 ) ) + dot( x2.xy, vec2( +1.308442123, -0.914547012 ) ),\n dot( x1.xyzw, vec4( +0.049718590, -0.791144343, +2.892305078, +0.811726816 ) ) + dot( x2.xy, vec2( -4.686502417, +2.717794514 ) ),\n dot( x1.xyzw, vec4( +0.513275779, +1.580255060, -5.164414457, +4.559573646 ) ) + dot( x2.xy, vec2( -1.916810682, +0.570638854 ) ) );\n}\n\nvec4 color(vec2 p){\n vec4 c1 = vec4(1.7,1.6,.9,1);\n vec4 c2 = vec4(.2,.94,.1,1);\n vec4 c3 = vec4(.3,.2,.0,1);\n vec4 c4 = vec4(.99,.99,1.6,1);\n vec4 v = highness(p);\n float los = smoothstep(0.1,1.1,v.b);\n float his = smoothstep(3.5,6.5,v.b);\n float ces = smoothstep(1.,5.,v.a);\n vec4 lo = mix(c1,c2,los);\n vec4 hi = mix(c3,c4,his);\n vec4 ce = mix(lo,hi,ces);\n\n return vec4(plasma_quintic(ces),1).ragb;\n}\n\nvec3 terrain_map( vec2 p )\n{\n return color(p).rgb*0.75+0.25*vec3(0.7, .55, .4)+texture(SAMPLER_2D(u_texture3), fract(p*5.)).rgb*.5; // test-terrain is simply 'sandstone'\n}\n\nconst mat2 m = mat2( 0.72, -1.60, 1.60, 0.72 );\n\nfloat water_map( vec2 p, float height ) {\n vec2 p2 = p*large_wavesize;\n vec2 shift1 = 0.001*vec2( u_time*160.0*2.0, u_time*120.0*2.0 );\n vec2 shift2 = 0.001*vec2( u_time*190.0*2.0, -u_time*130.0*2.0 );\n\n // coarse crossing 'ocean' waves...\n float f = 0.6000*noise( p );\n f += 0.2500*noise( p*m );\n f += 0.1666*noise( p*m*m );\n float wave = sin(p2.x*0.622+p2.y*0.622+shift2.x*4.269)*large_waveheight*f*height*height ;\n\n p *= small_wavesize;\n f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<9; i++)\n { p = m*p*.947; f -= amp*abs(sin((noise( p+shift1*s )-.5)*2.)); amp = amp*.59; s*=-1.329; }\n \n return wave+f*small_waveheight;\n}\n\nfloat nautic(vec2 p) {\n p *= 18.;\n float f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*abs(smoothstep(0., 1., noise( p+u_time*s ))-.5); amp = amp*.5; s*=-1.227; }\n return pow(1.-f, 5.);\n}\n\nfloat particles(vec2 p) {\n p *= 200.;\n float f = 0.;\n float amp = 1.0, s = 1.5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*noise( p+u_time*s ); amp = amp*.5; s*=-1.227; }\n return pow(f*.35, 7.)*particle_amount;\n}\n\nfloat test_shadow( vec2 xy, float height) {\n vec3 r0 = vec3(xy, height);\n vec3 rd = normalize( light - r0 );\n \n float hit = 1.0;\n float t = 0.001;\n for (int j=1; j<25; j++)\n {\n vec3 p = r0 + t*rd;\n float h = height_map( p.xy );\n float height_diff = p.z - h;\n if (height_diff<0.0)\n {\n return 0.0;\n }\n t += 0.01+height_diff*.02;\n hit = min(hit, 2.*height_diff/t); // soft shaddow \n }\n return hit;\n}\n\nvec3 CalcTerrain(vec2 uv, float height) {\n vec3 col = terrain_map( uv );\n vec2 iResolution = vec2(512.);\n float h1 = height_map(uv-vec2(0., 0.5)/ iResolution.xy);\n float h2 = height_map(uv+vec2(0., 0.5)/ iResolution.xy);\n float h3 = height_map(uv-vec2(0.5, 0.)/ iResolution.xy);\n float h4 = height_map(uv+vec2(0.5, 0.)/ iResolution.xy);\n vec3 norm = normalize(vec3(h3-h4, h1-h2, 1.));\n vec3 r0 = vec3(uv, height);\n vec3 rd = normalize( light - r0 );\n float grad = dot(norm, rd);\n col *= grad+pow(grad, 8.);\n float terrainshade = test_shadow( uv, height );\n col = mix(col*.25, col, terrainshade);\n return col;\n}\n\n\nvoid main() {\n vec3 watercolor = u_watercolor.rgb;\n vec3 watercolor2 = u_watercolor2.rgb;\n vec2 uv = v_uv;\n float WATER_LEVEL = 0.84; // Water level (range: 0.0 - 2.0)\n float deepwater_fadedepth = 0.4 + coast2water_fadedepth;\n float height = height_map( uv );\n vec3 col;\n\n float waveheight = clamp(WATER_LEVEL*3.-1.5, 0., 1.);\n float level = WATER_LEVEL + .2*water_map(uv*15. + vec2(u_time*.1), waveheight);\n if (height > level)\n {\n col = CalcTerrain(uv, height);\n }\n if (height <= level)\n {\n vec2 dif = vec2(.0, .01);\n vec2 pos = uv*15. + vec2(u_time*.01);\n float h1 = water_map(pos-dif,waveheight);\n float h2 = water_map(pos+dif,waveheight);\n float h3 = water_map(pos-dif.yx,waveheight);\n float h4 = water_map(pos+dif.yx,waveheight);\n vec3 normwater = normalize(vec3(h3-h4, h1-h2, .125)); // norm-vector of the 'bumpy' water-plane\n uv += normwater.xy*.002*(level-height);\n \n col = CalcTerrain(uv, height);\n\n float coastfade = clamp((level-height)/coast2water_fadedepth, 0., 1.);\n float coastfade2= clamp((level-height)/deepwater_fadedepth, 0., 1.);\n float intensity = col.r*.2126+col.g*.7152+col.b*.0722;\n watercolor = mix(watercolor*intensity, watercolor2, smoothstep(0., 1., coastfade2));\n\n vec3 r0 = vec3(uv, WATER_LEVEL);\n vec3 rd = normalize( light - r0 ); // ray-direction to the light from water-position\n float grad = dot(normwater, rd); // dot-product of norm-vector and light-direction\n float specular = pow(grad, water_softlight_fact); // used for soft highlights \n float specular2= pow(grad, water_glossylight_fact); // used for glossy highlights\n float gradpos = dot(vec3(0., 0., 1.), rd);\n float specular1= smoothstep(0., 1., pow(gradpos, 5.)); // used for diffusity (some darker corona around light's specular reflections...) \n float watershade = test_shadow( uv, level );\n watercolor *= 2.2+watershade;\n watercolor += (.2+.8*watershade) * ((grad-1.0)*.5+specular) * .25;\n watercolor /= (1.+specular1*1.25);\n watercolor += watershade*specular2*water_specularcolor;\n watercolor += watershade*coastfade*(1.-coastfade2)*(vec3(.5, .6, .7)*nautic(uv)+vec3(1., 1., 1.)*particles(uv));\n \n col = mix(col, watercolor, coastfade);\n }\n \n outputColor = vec4(col, v_opacity); \n}\n";
18
+ /* babel-plugin-inline-import '../shaders/ocean/ocean_vert.glsl' */
19
+ var ocean_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_uv;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\n\nout vec2 v_uv;\nout float v_opacity;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_opacity = opacity;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n}\n\n";
20
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
19
21
  var isNumber = lodashUtil.isNumber;
20
22
  var OceanModel = /*#__PURE__*/function (_BaseModel) {
21
23
  _inherits(OceanModel, _BaseModel);
@@ -27,21 +29,32 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
27
29
  _createClass(OceanModel, [{
28
30
  key: "getUninforms",
29
31
  value: function getUninforms() {
32
+ var commoninfo = this.getCommonUniformsInfo();
33
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
34
+ this.updateStyleUnifoms();
35
+ return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
36
+ }
37
+ }, {
38
+ key: "getCommonUniformsInfo",
39
+ value: function getCommonUniformsInfo() {
30
40
  var _ref = this.layer.getLayerConfig(),
31
- _ref$opacity = _ref.opacity,
32
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
33
41
  _ref$watercolor = _ref.watercolor,
34
42
  watercolor = _ref$watercolor === void 0 ? '#6D99A8' : _ref$watercolor,
35
43
  _ref$watercolor2 = _ref.watercolor2,
36
44
  watercolor2 = _ref$watercolor2 === void 0 ? '#0F121C' : _ref$watercolor2;
37
- return {
38
- u_texture1: this.texture1,
39
- u_texture2: this.texture2,
40
- u_texture3: this.texture3,
45
+ var commonOptions = {
41
46
  u_watercolor: rgb2arr(watercolor),
42
47
  u_watercolor2: rgb2arr(watercolor2),
43
- u_opacity: isNumber(opacity) ? opacity : 1.0
48
+ u_time: this.layer.getLayerAnimateTime(),
49
+ u_texture1: this.texture1,
50
+ u_texture2: this.texture2,
51
+ u_texture3: this.texture3
44
52
  };
53
+
54
+ // u_opacity: isNumber(opacity) ? opacity : 1.0,
55
+ this.textures = [this.texture1, this.texture2, this.texture3];
56
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
57
+ return commonBufferInfo;
45
58
  }
46
59
  }, {
47
60
  key: "getAnimateUniforms",
@@ -78,21 +91,23 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
78
91
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
79
92
  while (1) switch (_context2.prev = _context2.next) {
80
93
  case 0:
81
- _context2.next = 2;
94
+ this.initUniformsBuffer();
95
+ _context2.next = 3;
82
96
  return this.layer.buildLayerModel({
83
97
  moduleName: 'polygonOcean',
84
98
  vertexShader: ocean_vert,
85
99
  fragmentShader: ocean_frag,
100
+ inject: this.getInject(),
86
101
  triangulation: polygonTriangulation,
87
102
  primitive: gl.TRIANGLES,
88
103
  depth: {
89
104
  enable: false
90
105
  }
91
106
  });
92
- case 2:
107
+ case 3:
93
108
  model = _context2.sent;
94
109
  return _context2.abrupt("return", [model]);
95
- case 4:
110
+ case 5:
96
111
  case "end":
97
112
  return _context2.stop();
98
113
  }
@@ -127,6 +142,7 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
127
142
  type: AttributeType.Attribute,
128
143
  descriptor: {
129
144
  name: 'a_uv',
145
+ shaderLocation: ShaderLocation.UV,
130
146
  buffer: {
131
147
  // give the WebGL driver a hint that this buffer may change
132
148
  usage: gl.STATIC_DRAW,
@@ -1,11 +1,16 @@
1
- import { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
1
+ import type { IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class WaterModel extends BaseModel {
4
4
  private texture;
5
5
  getUninforms(): {
6
- u_texture: ITexture2D;
7
- u_speed: number;
8
- u_opacity: number;
6
+ [x: string]: any;
7
+ };
8
+ protected getCommonUniformsInfo(): {
9
+ uniformsArray: number[];
10
+ uniformsLength: number;
11
+ uniformsOption: {
12
+ [key: string]: any;
13
+ };
9
14
  };
10
15
  getAnimateUniforms(): IModelUniform;
11
16
  initModels(): Promise<IModel[]>;