@antv/l7-layers 2.9.27-alpha.1 → 2.9.27-alpha.3

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 (302) hide show
  1. package/es/Geometry/index.d.ts +13 -0
  2. package/es/Geometry/index.js +20 -2
  3. package/es/Geometry/models/billboard.js +1 -2
  4. package/es/Geometry/models/plane.js +2 -4
  5. package/es/Geometry/models/sprite.js +2 -4
  6. package/es/canvas/index.d.ts +4 -0
  7. package/es/canvas/index.js +38 -2
  8. package/es/citybuliding/building.js +6 -2
  9. package/es/citybuliding/models/build.js +2 -3
  10. package/es/core/BaseLayer.d.ts +17 -6
  11. package/es/core/BaseLayer.js +89 -94
  12. package/es/core/BaseModel.d.ts +1 -1
  13. package/es/core/BaseModel.js +7 -3
  14. package/es/core/interface.d.ts +18 -0
  15. package/es/core/triangulation.d.ts +6 -0
  16. package/es/core/triangulation.js +64 -2
  17. package/es/earth/index.d.ts +5 -0
  18. package/es/earth/index.js +12 -1
  19. package/es/earth/models/base.js +2 -4
  20. package/es/earth/shaders/atmosphere_frag.glsl +1 -1
  21. package/es/earth/shaders/bloomsphere_frag.glsl +1 -1
  22. package/es/heatmap/index.js +6 -2
  23. package/es/heatmap/models/heatmap.js +5 -3
  24. package/es/image/index.js +6 -2
  25. package/es/image/models/dataImage.js +4 -7
  26. package/es/image/models/image.js +4 -7
  27. package/es/line/index.d.ts +1 -0
  28. package/es/line/index.js +8 -2
  29. package/es/line/models/arc.js +6 -5
  30. package/es/line/models/half.js +3 -4
  31. package/es/line/models/line.js +9 -8
  32. package/es/line/models/simpleLine.js +2 -1
  33. package/es/line/models/simpleTileLine.d.ts +9 -0
  34. package/es/line/models/simpleTileLine.js +100 -0
  35. package/es/line/models/tile.d.ts +1 -4
  36. package/es/line/models/tile.js +49 -222
  37. package/es/line/models/wall.js +10 -46
  38. package/es/line/shaders/dash/arc_dash_vert.glsl +2 -0
  39. package/es/line/shaders/dash/line_dash_frag.glsl +1 -1
  40. package/es/line/shaders/line_arc2d_vert.glsl +1 -1
  41. package/es/line/shaders/line_arc_3d_frag.glsl +1 -1
  42. package/es/line/shaders/line_arc_3d_vert.glsl +3 -3
  43. package/es/line/shaders/line_arc_frag.glsl +1 -1
  44. package/es/line/shaders/line_arc_great_circle_frag.glsl +1 -1
  45. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -1
  46. package/es/line/shaders/line_arc_vert.glsl +5 -3
  47. package/es/line/shaders/line_bezier_vert.glsl +1 -1
  48. package/es/line/shaders/line_frag.glsl +1 -2
  49. package/es/line/shaders/line_vert.glsl +1 -1
  50. package/es/line/shaders/linear/arc3d_linear_frag.glsl +1 -1
  51. package/es/line/shaders/linear/arc3d_linear_vert.glsl +3 -3
  52. package/es/line/shaders/linear/arc_linear_frag.glsl +1 -1
  53. package/es/line/shaders/tile/line_tile_map_vert.glsl +25 -0
  54. package/es/line/shaders/tile/line_tile_vert.glsl +19 -177
  55. package/es/line/shaders/tile/simpleline_map_vert.glsl +15 -0
  56. package/es/line/shaders/tile/simpleline_vert.glsl +21 -0
  57. package/es/line/shaders/{wall_frag.glsl → wall/wall_frag.glsl} +17 -21
  58. package/es/line/shaders/wall/wall_vert.glsl +77 -0
  59. package/es/mask/index.d.ts +1 -0
  60. package/es/mask/index.js +80 -5
  61. package/es/mask/models/fill.d.ts +2 -1
  62. package/es/mask/models/fill.js +13 -10
  63. package/es/mask/shaders/mask_vert.glsl +0 -6
  64. package/es/plugins/DataMappingPlugin.d.ts +4 -3
  65. package/es/plugins/DataMappingPlugin.js +129 -58
  66. package/es/plugins/DataSourcePlugin.js +3 -2
  67. package/es/plugins/FeatureScalePlugin.d.ts +0 -2
  68. package/es/plugins/FeatureScalePlugin.js +8 -51
  69. package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -2
  70. package/es/plugins/LayerAnimateStylePlugin.js +7 -27
  71. package/es/plugins/LayerModelPlugin.js +2 -6
  72. package/es/plugins/LightingPlugin.js +1 -7
  73. package/es/plugins/MultiPassRendererPlugin.d.ts +0 -1
  74. package/es/plugins/MultiPassRendererPlugin.js +4 -16
  75. package/es/plugins/PixelPickingPlugin.d.ts +1 -1
  76. package/es/plugins/PixelPickingPlugin.js +8 -28
  77. package/es/plugins/RegisterStyleAttributePlugin.d.ts +4 -0
  78. package/es/plugins/RegisterStyleAttributePlugin.js +56 -5
  79. package/es/plugins/UpdateStyleAttributePlugin.js +2 -9
  80. package/es/point/index.js +6 -2
  81. package/es/point/models/fill.js +2 -2
  82. package/es/point/models/fillmage.js +1 -1
  83. package/es/point/models/image.js +1 -1
  84. package/es/point/models/normal.d.ts +0 -1
  85. package/es/point/models/normal.js +9 -60
  86. package/es/point/models/radar.js +4 -69
  87. package/es/point/models/simplePoint.d.ts +0 -1
  88. package/es/point/models/simplePoint.js +2 -11
  89. package/es/point/models/text.js +6 -7
  90. package/es/point/models/tile.d.ts +0 -7
  91. package/es/point/models/tile.js +22 -155
  92. package/es/point/models/tileText.d.ts +0 -4
  93. package/es/point/models/tileText.js +98 -185
  94. package/es/point/shaders/animate/wave_frag.glsl +3 -3
  95. package/es/point/shaders/earth/fill_vert.glsl +0 -1
  96. package/es/point/shaders/fill_vert.glsl +0 -1
  97. package/es/point/shaders/normal_frag.glsl +1 -10
  98. package/es/point/shaders/normal_vert.glsl +5 -60
  99. package/es/point/shaders/radar/radar_frag.glsl +4 -15
  100. package/es/point/shaders/radar/radar_vert.glsl +4 -54
  101. package/es/point/shaders/tile/fill_tile_frag.glsl +10 -17
  102. package/es/point/shaders/tile/fill_tile_vert.glsl +20 -123
  103. package/es/point/shaders/tile/text_frag.glsl +33 -0
  104. package/es/point/shaders/tile/text_map_frag.glsl +31 -0
  105. package/es/point/shaders/tile/text_map_vert.glsl +38 -0
  106. package/es/point/shaders/tile/text_vert.glsl +48 -0
  107. package/es/polygon/index.js +6 -2
  108. package/es/polygon/models/extrude.js +1 -3
  109. package/es/polygon/models/fill.js +3 -4
  110. package/es/polygon/models/ocean.d.ts +0 -2
  111. package/es/polygon/models/ocean.js +13 -47
  112. package/es/polygon/models/tile.d.ts +1 -4
  113. package/es/polygon/models/tile.js +25 -57
  114. package/es/polygon/models/water.d.ts +0 -2
  115. package/es/polygon/models/water.js +13 -47
  116. package/es/polygon/shaders/polygon_frag.glsl +2 -2
  117. package/es/polygon/shaders/polygon_vert.glsl +2 -2
  118. package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +16 -0
  119. package/es/polygon/shaders/tile/polygon_tile_vert.glsl +20 -60
  120. package/es/polygon/shaders/water/polygon_ocean_frag.glsl +1 -2
  121. package/es/polygon/shaders/water/polygon_ocean_vert.glsl +0 -31
  122. package/es/polygon/shaders/water/polygon_water_frag.glsl +1 -3
  123. package/es/polygon/shaders/water/polygon_water_vert.glsl +0 -29
  124. package/es/raster/buffers/triangulation.js +1 -4
  125. package/es/raster/index.js +6 -2
  126. package/es/raster/models/raster.js +3 -2
  127. package/es/shader/minify_frag.glsl +7 -0
  128. package/es/shader/minify_picking_frag.glsl +10 -0
  129. package/es/tile/manager/baseMapTileLayerManager.d.ts +29 -0
  130. package/es/tile/manager/baseMapTileLayerManager.js +207 -0
  131. package/es/tile/manager/tileLayerManager.d.ts +2 -2
  132. package/es/tile/manager/tileLayerManager.js +2 -2
  133. package/es/tile/manager/tilePickerManager.d.ts +2 -3
  134. package/es/tile/manager/tilePickerManager.js +1 -2
  135. package/es/tile/models/tileModel.d.ts +1 -0
  136. package/es/tile/models/tileModel.js +18 -2
  137. package/es/tile/tileFactory/base.d.ts +1 -1
  138. package/es/tile/tileFactory/base.js +58 -33
  139. package/es/tile/tileFactory/line.js +3 -0
  140. package/es/tile/tileFactory/point.js +3 -0
  141. package/es/tile/tileFactory/polygon.js +3 -0
  142. package/es/tile/tileFactory/raster.js +3 -0
  143. package/es/tile/tileFactory/rasterData.js +3 -0
  144. package/es/tile/tileFactory/rasterDataLayer.js +6 -2
  145. package/es/tile/tileFactory/test.js +26 -5
  146. package/es/tile/tileFactory/vectorLayer.d.ts +4 -1
  147. package/es/tile/tileFactory/vectorLayer.js +110 -7
  148. package/es/tile/tileLayer/baseMapTileLayer.d.ts +29 -0
  149. package/es/tile/tileLayer/baseMapTileLayer.js +188 -0
  150. package/es/tile/tileLayer/baseTileLayer.d.ts +4 -4
  151. package/es/tile/tileLayer/baseTileLayer.js +46 -75
  152. package/es/tile/tileTest.d.ts +1 -0
  153. package/es/tile/tileTest.js +3 -2
  154. package/es/tile/tmsMapTileLayer.d.ts +9 -0
  155. package/es/tile/tmsMapTileLayer.js +119 -0
  156. package/es/tile/tmsTileLayer.d.ts +2 -0
  157. package/es/tile/tmsTileLayer.js +24 -2
  158. package/es/tile/utils.d.ts +4 -0
  159. package/es/tile/utils.js +30 -0
  160. package/es/utils/dataMappingStyle.js +3 -0
  161. package/es/utils/layerData.js +2 -2
  162. package/es/utils/updateShape.js +2 -2
  163. package/es/wind/index.js +6 -2
  164. package/es/wind/models/wind.js +8 -8
  165. package/es/wind/shaders/wind_vert.glsl +1 -1
  166. package/lib/Geometry/index.js +19 -2
  167. package/lib/Geometry/models/billboard.js +1 -2
  168. package/lib/Geometry/models/plane.js +2 -4
  169. package/lib/Geometry/models/sprite.js +2 -4
  170. package/lib/canvas/index.js +37 -2
  171. package/lib/citybuliding/building.js +6 -2
  172. package/lib/citybuliding/models/build.js +2 -3
  173. package/lib/core/BaseLayer.js +86 -94
  174. package/lib/core/BaseModel.js +7 -3
  175. package/lib/core/triangulation.js +66 -2
  176. package/lib/earth/index.js +11 -1
  177. package/lib/earth/models/base.js +2 -4
  178. package/lib/earth/shaders/atmosphere_frag.glsl +1 -1
  179. package/lib/earth/shaders/bloomsphere_frag.glsl +1 -1
  180. package/lib/heatmap/index.js +6 -2
  181. package/lib/heatmap/models/heatmap.js +5 -3
  182. package/lib/image/index.js +6 -2
  183. package/lib/image/models/dataImage.js +4 -7
  184. package/lib/image/models/image.js +4 -7
  185. package/lib/line/index.js +7 -2
  186. package/lib/line/models/arc.js +6 -5
  187. package/lib/line/models/half.js +3 -4
  188. package/lib/line/models/line.js +9 -8
  189. package/lib/line/models/simpleLine.js +2 -1
  190. package/lib/line/models/simpleTileLine.js +115 -0
  191. package/lib/line/models/tile.js +49 -223
  192. package/lib/line/models/wall.js +10 -46
  193. package/lib/line/shaders/dash/arc_dash_vert.glsl +2 -0
  194. package/lib/line/shaders/dash/line_dash_frag.glsl +1 -1
  195. package/lib/line/shaders/line_arc2d_vert.glsl +1 -1
  196. package/lib/line/shaders/line_arc_3d_frag.glsl +1 -1
  197. package/lib/line/shaders/line_arc_3d_vert.glsl +3 -3
  198. package/lib/line/shaders/line_arc_frag.glsl +1 -1
  199. package/lib/line/shaders/line_arc_great_circle_frag.glsl +1 -1
  200. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -1
  201. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  202. package/lib/line/shaders/line_bezier_vert.glsl +1 -1
  203. package/lib/line/shaders/line_frag.glsl +1 -2
  204. package/lib/line/shaders/line_vert.glsl +1 -1
  205. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +1 -1
  206. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +3 -3
  207. package/lib/line/shaders/linear/arc_linear_frag.glsl +1 -1
  208. package/lib/line/shaders/tile/line_tile_map_vert.glsl +25 -0
  209. package/lib/line/shaders/tile/line_tile_vert.glsl +19 -177
  210. package/lib/line/shaders/tile/simpleline_map_vert.glsl +15 -0
  211. package/lib/line/shaders/tile/simpleline_vert.glsl +21 -0
  212. package/lib/line/shaders/{wall_frag.glsl → wall/wall_frag.glsl} +17 -21
  213. package/lib/line/shaders/wall/wall_vert.glsl +77 -0
  214. package/lib/mask/index.js +82 -5
  215. package/lib/mask/models/fill.js +14 -10
  216. package/lib/mask/shaders/mask_vert.glsl +0 -6
  217. package/lib/plugins/DataMappingPlugin.js +127 -57
  218. package/lib/plugins/DataSourcePlugin.js +3 -2
  219. package/lib/plugins/FeatureScalePlugin.js +6 -50
  220. package/lib/plugins/LayerAnimateStylePlugin.js +6 -29
  221. package/lib/plugins/LayerModelPlugin.js +2 -6
  222. package/lib/plugins/LightingPlugin.js +1 -7
  223. package/lib/plugins/MultiPassRendererPlugin.js +3 -19
  224. package/lib/plugins/PixelPickingPlugin.js +8 -28
  225. package/lib/plugins/RegisterStyleAttributePlugin.js +56 -5
  226. package/lib/plugins/UpdateStyleAttributePlugin.js +2 -9
  227. package/lib/point/index.js +6 -2
  228. package/lib/point/models/fill.js +2 -2
  229. package/lib/point/models/fillmage.js +1 -1
  230. package/lib/point/models/image.js +1 -1
  231. package/lib/point/models/normal.js +8 -59
  232. package/lib/point/models/radar.js +4 -69
  233. package/lib/point/models/simplePoint.js +1 -10
  234. package/lib/point/models/text.js +6 -7
  235. package/lib/point/models/tile.js +21 -156
  236. package/lib/point/models/tileText.js +97 -184
  237. package/lib/point/shaders/animate/wave_frag.glsl +3 -3
  238. package/lib/point/shaders/earth/fill_vert.glsl +0 -1
  239. package/lib/point/shaders/fill_vert.glsl +0 -1
  240. package/lib/point/shaders/normal_frag.glsl +1 -10
  241. package/lib/point/shaders/normal_vert.glsl +5 -60
  242. package/lib/point/shaders/radar/radar_frag.glsl +4 -15
  243. package/lib/point/shaders/radar/radar_vert.glsl +4 -54
  244. package/lib/point/shaders/tile/fill_tile_frag.glsl +10 -17
  245. package/lib/point/shaders/tile/fill_tile_vert.glsl +20 -123
  246. package/lib/point/shaders/tile/text_frag.glsl +33 -0
  247. package/lib/point/shaders/tile/text_map_frag.glsl +31 -0
  248. package/lib/point/shaders/tile/text_map_vert.glsl +38 -0
  249. package/lib/point/shaders/tile/text_vert.glsl +48 -0
  250. package/lib/polygon/index.js +6 -2
  251. package/lib/polygon/models/extrude.js +1 -3
  252. package/lib/polygon/models/fill.js +3 -4
  253. package/lib/polygon/models/ocean.js +14 -47
  254. package/lib/polygon/models/tile.js +24 -57
  255. package/lib/polygon/models/water.js +14 -47
  256. package/lib/polygon/shaders/polygon_frag.glsl +2 -2
  257. package/lib/polygon/shaders/polygon_vert.glsl +2 -2
  258. package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +16 -0
  259. package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +20 -60
  260. package/lib/polygon/shaders/water/polygon_ocean_frag.glsl +1 -2
  261. package/lib/polygon/shaders/water/polygon_ocean_vert.glsl +0 -31
  262. package/lib/polygon/shaders/water/polygon_water_frag.glsl +1 -3
  263. package/lib/polygon/shaders/water/polygon_water_vert.glsl +0 -29
  264. package/lib/raster/buffers/triangulation.js +1 -4
  265. package/lib/raster/index.js +6 -2
  266. package/lib/raster/models/raster.js +3 -2
  267. package/lib/shader/minify_frag.glsl +7 -0
  268. package/lib/shader/minify_picking_frag.glsl +10 -0
  269. package/lib/tile/manager/baseMapTileLayerManager.js +222 -0
  270. package/lib/tile/manager/tileLayerManager.js +2 -2
  271. package/lib/tile/manager/tilePickerManager.js +1 -2
  272. package/lib/tile/models/tileModel.js +19 -2
  273. package/lib/tile/tileFactory/base.js +60 -33
  274. package/lib/tile/tileFactory/line.js +3 -0
  275. package/lib/tile/tileFactory/point.js +3 -0
  276. package/lib/tile/tileFactory/polygon.js +3 -0
  277. package/lib/tile/tileFactory/raster.js +3 -0
  278. package/lib/tile/tileFactory/rasterData.js +3 -0
  279. package/lib/tile/tileFactory/rasterDataLayer.js +6 -2
  280. package/lib/tile/tileFactory/test.js +26 -5
  281. package/lib/tile/tileFactory/vectorLayer.js +112 -8
  282. package/lib/tile/tileLayer/baseMapTileLayer.js +195 -0
  283. package/lib/tile/tileLayer/baseTileLayer.js +46 -75
  284. package/lib/tile/tileTest.js +3 -2
  285. package/lib/tile/tmsMapTileLayer.js +136 -0
  286. package/lib/tile/tmsTileLayer.js +25 -2
  287. package/lib/tile/utils.js +38 -0
  288. package/lib/utils/dataMappingStyle.js +3 -0
  289. package/lib/utils/layerData.js +2 -2
  290. package/lib/utils/updateShape.js +2 -2
  291. package/lib/wind/index.js +6 -2
  292. package/lib/wind/models/wind.js +7 -7
  293. package/lib/wind/shaders/wind_vert.glsl +1 -1
  294. package/package.json +8 -7
  295. package/es/line/shaders/tile/line_tile_frag.glsl +0 -79
  296. package/es/line/shaders/wall_vert.glsl +0 -111
  297. package/es/mask/shaders/mask_frag.glsl +0 -7
  298. package/es/polygon/shaders/tile/polygon_tile_frag.glsl +0 -12
  299. package/lib/line/shaders/tile/line_tile_frag.glsl +0 -79
  300. package/lib/line/shaders/wall_vert.glsl +0 -111
  301. package/lib/mask/shaders/mask_frag.glsl +0 -7
  302. package/lib/polygon/shaders/tile/polygon_tile_frag.glsl +0 -12
@@ -10,16 +10,17 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
 
12
12
  import { AttributeType, gl } from '@antv/l7-core';
13
+ import { Version } from '@antv/l7-maps';
13
14
  import { getMask, rgb2arr } from '@antv/l7-utils';
14
15
  import { isNumber } from 'lodash';
15
16
  import BaseModel from "../../core/BaseModel";
16
17
  import { polygonTriangulation } from "../../core/triangulation";
17
18
 
18
19
  /* babel-plugin-inline-import '../shaders/water/polygon_ocean_frag.glsl' */
19
- var ocean_frag = "\nuniform float u_time: 0.0;\nuniform float u_opacity: 1.0;\n\nvarying vec2 v_uv;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\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 = styleMappingMat[0][0];\n gl_FragColor = vec4(col, opacity); \n}\n";
20
+ 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";
20
21
 
21
22
  /* babel-plugin-inline-import '../shaders/water/polygon_ocean_vert.glsl' */
22
- var ocean_vert = "attribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec2 v_uv;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n 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 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\n";
23
+ var ocean_vert = "attribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\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\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\n";
23
24
 
24
25
  var OceanModel = /*#__PURE__*/function (_BaseModel) {
25
26
  _inherits(OceanModel, _BaseModel);
@@ -43,47 +44,12 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
43
44
  _ref$watercolor2 = _ref.watercolor2,
44
45
  watercolor2 = _ref$watercolor2 === void 0 ? '#0F121C' : _ref$watercolor2;
45
46
 
46
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
47
- opacity: opacity
48
- })) {
49
- this.judgeStyleAttributes({
50
- opacity: opacity
51
- });
52
- var encodeData = this.layer.getEncodedData();
53
-
54
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
55
- data = _this$calDataFrame.data,
56
- width = _this$calDataFrame.width,
57
- height = _this$calDataFrame.height;
58
-
59
- this.rowCount = height; // 当前数据纹理有多少行
60
-
61
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
62
- flipY: true,
63
- data: data,
64
- format: gl.LUMINANCE,
65
- type: gl.FLOAT,
66
- width: width,
67
- height: height
68
- }) : this.createTexture2D({
69
- flipY: true,
70
- data: [1],
71
- format: gl.LUMINANCE,
72
- type: gl.FLOAT,
73
- width: 1,
74
- height: 1
75
- });
76
- }
77
-
78
47
  return {
79
48
  u_texture1: this.texture1,
80
49
  u_texture2: this.texture2,
81
50
  u_texture3: this.texture3,
82
51
  u_watercolor: rgb2arr(watercolor),
83
52
  u_watercolor2: rgb2arr(watercolor2),
84
- u_dataTexture: this.dataTexture,
85
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
86
- u_cellTypeLayout: this.getCellTypeLayout(),
87
53
  u_opacity: isNumber(opacity) ? opacity : 1.0
88
54
  };
89
55
  }
@@ -118,7 +84,8 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
118
84
  depth: {
119
85
  enable: false
120
86
  },
121
- stencil: getMask(mask, maskInside)
87
+ stencil: getMask(mask, maskInside),
88
+ pick: false
122
89
  }).then(function (model) {
123
90
  callbackModel([model]);
124
91
  }).catch(function (err) {
@@ -129,12 +96,11 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
129
96
  }, {
130
97
  key: "clearModels",
131
98
  value: function clearModels() {
132
- var _this$texture, _this$texture2, _this$texture3, _this$dataTexture;
99
+ var _this$texture, _this$texture2, _this$texture3;
133
100
 
134
101
  (_this$texture = this.texture1) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
135
102
  (_this$texture2 = this.texture2) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
136
103
  (_this$texture3 = this.texture3) === null || _this$texture3 === void 0 ? void 0 : _this$texture3.destroy();
137
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
138
104
  }
139
105
  }, {
140
106
  key: "registerBuiltinAttributes",
@@ -161,10 +127,12 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
161
127
  type: gl.FLOAT
162
128
  },
163
129
  size: 2,
164
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
165
- var _vertex = _slicedToArray(vertex, 2),
166
- lng = _vertex[0],
167
- lat = _vertex[1];
130
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
131
+ var v = feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex;
132
+
133
+ var _v = _slicedToArray(v, 2),
134
+ lng = _v[0],
135
+ lat = _v[1];
168
136
 
169
137
  return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
170
138
  }
@@ -191,9 +159,7 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
191
159
  _this.texture2 = initTex(images[1]);
192
160
  _this.texture3 = initTex(images[2]);
193
161
 
194
- _this.layerService.updateLayerRenderList();
195
-
196
- _this.layerService.renderLayers();
162
+ _this.layerService.reRender();
197
163
  });
198
164
 
199
165
  function initImage(callback) {
@@ -2,11 +2,8 @@ import { 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_tileOrigin: number[];
6
- u_coord: number;
7
- u_dataTexture: import("@antv/l7-core").ITexture2D;
8
- u_cellTypeLayout: number[];
9
5
  u_opacity: number;
6
+ u_color: number[];
10
7
  };
11
8
  initModels(callbackModel: (models: IModel[]) => void): void;
12
9
  buildModels(callbackModel: (models: IModel[]) => void): void;
@@ -8,16 +8,21 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
8
8
 
9
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
10
 
11
- import { gl } from '@antv/l7-core';
12
- import { getMask } from '@antv/l7-utils';
11
+ import { getMask, rgb2arr } from '@antv/l7-utils';
13
12
  import BaseModel from "../../core/BaseModel";
14
13
  import { polygonTriangulation } from "../../core/triangulation";
15
14
 
16
- /* babel-plugin-inline-import '../shaders/tile/polygon_tile_frag.glsl' */
17
- var polygon_tile_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
15
+ /* babel-plugin-inline-import '../../shader/minify_picking_frag.glsl' */
16
+ var polygon_tile_frag = "uniform float u_opacity : 1.0;\nvarying vec4 v_color;\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n gl_FragColor.a *= u_opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
18
17
 
19
18
  /* babel-plugin-inline-import '../shaders/tile/polygon_tile_vert.glsl' */
20
- var polygon_tile_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_opacity: 1.0;\n\nuniform vec2 u_tileOrigin;\nuniform float u_coord;\n\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\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 }\n\nif(u_coord > 0.0) {\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} else {\n vec2 pointPos = a_Position.xy;\n vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n world.xy += pointOffset;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n world.w *= u_PixelsPerMeter.z;\n }\n\n gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;\n}\n\n\n setPickingColor(a_PickingColor);\n}\n\n";
19
+ var polygon_tile_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n// uniform vec2 u_tileOrigin;\n// uniform float u_coord;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n v_color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n // if(u_coord > 0.0) {\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 // } else {\n // vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n // vec2 pointOffset = a_Position.xy * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n // world.xy += pointOffset;\n\n // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // // Needs to be divided with project_uCommonUnitsPerMeter\n // world.w *= u_PixelsPerMeter.z;\n // }\n\n // gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;\n // }\n\n setPickingColor(a_PickingColor);\n}\n\n";
20
+
21
+ /* babel-plugin-inline-import '../../shader/minify_frag.glsl' */
22
+ var polygon_tile_map_frag = "uniform float u_opacity : 1.0;\nuniform vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n gl_FragColor.a *= u_opacity;\n}\n";
23
+
24
+ /* babel-plugin-inline-import '../shaders/tile/polygon_tile_map_vert.glsl' */
25
+ var polygon_tile_map_vert = "attribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\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}";
21
26
 
22
27
  var FillModel = /*#__PURE__*/function (_BaseModel) {
23
28
  _inherits(FillModel, _BaseModel);
@@ -36,49 +41,15 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
36
41
  var _ref = this.layer.getLayerConfig(),
37
42
  _ref$opacity = _ref.opacity,
38
43
  opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
39
- tileOrigin = _ref.tileOrigin,
40
- _ref$coord = _ref.coord,
41
- coord = _ref$coord === void 0 ? 'lnglat' : _ref$coord;
42
-
43
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
44
- opacity: opacity
45
- })) {
46
- this.judgeStyleAttributes({
47
- opacity: opacity
48
- });
49
- var encodeData = this.layer.getEncodedData();
50
-
51
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
52
- data = _this$calDataFrame.data,
53
- width = _this$calDataFrame.width,
54
- height = _this$calDataFrame.height;
55
-
56
- this.rowCount = height; // 当前数据纹理有多少行
57
-
58
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
59
- flipY: true,
60
- data: data,
61
- format: gl.LUMINANCE,
62
- type: gl.FLOAT,
63
- width: width,
64
- height: height
65
- }) : this.createTexture2D({
66
- flipY: true,
67
- data: [1],
68
- format: gl.LUMINANCE,
69
- type: gl.FLOAT,
70
- width: 1,
71
- height: 1
72
- });
73
- }
44
+ usage = _ref.usage,
45
+ _ref$color = _ref.color,
46
+ color = _ref$color === void 0 ? '#fff' : _ref$color;
74
47
 
75
48
  return {
76
- u_tileOrigin: tileOrigin || [0, 0],
77
- u_coord: coord === 'lnglat' ? 1.0 : 0.0,
78
- u_dataTexture: this.dataTexture,
79
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
80
- u_cellTypeLayout: this.getCellTypeLayout(),
81
- u_opacity: opacity
49
+ // u_tileOrigin: tileOrigin || [0, 0],
50
+ // u_coord: coord === 'lnglat' ? 1.0 : 0.0,
51
+ u_opacity: opacity,
52
+ u_color: usage === 'basemap' ? rgb2arr(color) : [0, 0, 0, 0]
82
53
  };
83
54
  }
84
55
  }, {
@@ -93,20 +64,21 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
93
64
  _ref2$mask = _ref2.mask,
94
65
  mask = _ref2$mask === void 0 ? false : _ref2$mask,
95
66
  _ref2$maskInside = _ref2.maskInside,
96
- maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
67
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside,
68
+ usage = _ref2.usage;
97
69
 
98
70
  this.layer.triangulation = polygonTriangulation;
99
71
  this.layer.buildLayerModel({
100
- moduleName: 'polygonTile',
101
- vertexShader: polygon_tile_vert,
102
- fragmentShader: polygon_tile_frag,
72
+ moduleName: 'polygonTile_' + usage,
73
+ vertexShader: usage === 'basemap' ? polygon_tile_map_vert : polygon_tile_vert,
74
+ fragmentShader: usage === 'basemap' ? polygon_tile_map_frag : polygon_tile_frag,
103
75
  triangulation: polygonTriangulation,
104
- primitive: gl.TRIANGLES,
105
76
  depth: {
106
77
  enable: false
107
78
  },
108
79
  blend: this.getBlend(),
109
- stencil: getMask(mask, maskInside)
80
+ stencil: getMask(mask, maskInside),
81
+ pick: usage !== 'basemap'
110
82
  }).then(function (model) {
111
83
  callbackModel([model]);
112
84
  }).catch(function (err) {
@@ -116,11 +88,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
116
88
  }
117
89
  }, {
118
90
  key: "clearModels",
119
- value: function clearModels() {
120
- var _this$dataTexture;
121
-
122
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
123
- }
91
+ value: function clearModels() {}
124
92
  }, {
125
93
  key: "registerBuiltinAttributes",
126
94
  value: function registerBuiltinAttributes() {//
@@ -4,8 +4,6 @@ export default class WaterModel extends BaseModel {
4
4
  private texture;
5
5
  getUninforms(): {
6
6
  u_texture: ITexture2D;
7
- u_dataTexture: ITexture2D;
8
- u_cellTypeLayout: number[];
9
7
  u_speed: number;
10
8
  u_opacity: number;
11
9
  };
@@ -10,16 +10,17 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
 
12
12
  import { AttributeType, gl } from '@antv/l7-core';
13
+ import { Version } from '@antv/l7-maps';
13
14
  import { getMask } from '@antv/l7-utils';
14
15
  import { isNumber } from 'lodash';
15
16
  import BaseModel from "../../core/BaseModel";
16
17
  import { polygonTriangulation } from "../../core/triangulation";
17
18
 
18
19
  /* babel-plugin-inline-import '../shaders/water/polygon_water_frag.glsl' */
19
- var water_frag = "uniform sampler2D u_texture;\nuniform float u_time: 0.0;\nuniform float u_speed: 1.0;\nuniform float u_opacity: 1.0;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture2D(u_texture, p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n\n float spc = calSpc();\n gl_FragColor += spc * 0.4;\n}\n";
20
+ var water_frag = "uniform sampler2D u_texture;\nuniform float u_time: 0.0;\nuniform float u_speed: 1.0;\nuniform float u_opacity: 1.0;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture2D(u_texture, p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n float opacity = u_opacity;\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n\n float spc = calSpc();\n gl_FragColor += spc * 0.4;\n}\n";
20
21
 
21
22
  /* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
22
- var water_vert = "attribute vec4 a_Color;\nattribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n 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\n";
23
+ var water_vert = "attribute vec4 a_Color;\nattribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\nuniform float u_opacity: 1.0;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\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\n";
23
24
 
24
25
  var WaterModel = /*#__PURE__*/function (_BaseModel) {
25
26
  _inherits(WaterModel, _BaseModel);
@@ -41,43 +42,8 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
41
42
  _ref$speed = _ref.speed,
42
43
  speed = _ref$speed === void 0 ? 0.5 : _ref$speed;
43
44
 
44
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
45
- opacity: opacity
46
- })) {
47
- this.judgeStyleAttributes({
48
- opacity: opacity
49
- });
50
- var encodeData = this.layer.getEncodedData();
51
-
52
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
53
- data = _this$calDataFrame.data,
54
- width = _this$calDataFrame.width,
55
- height = _this$calDataFrame.height;
56
-
57
- this.rowCount = height; // 当前数据纹理有多少行
58
-
59
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
60
- flipY: true,
61
- data: data,
62
- format: gl.LUMINANCE,
63
- type: gl.FLOAT,
64
- width: width,
65
- height: height
66
- }) : this.createTexture2D({
67
- flipY: true,
68
- data: [1],
69
- format: gl.LUMINANCE,
70
- type: gl.FLOAT,
71
- width: 1,
72
- height: 1
73
- });
74
- }
75
-
76
45
  return {
77
46
  u_texture: this.texture,
78
- u_dataTexture: this.dataTexture,
79
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
80
- u_cellTypeLayout: this.getCellTypeLayout(),
81
47
  u_speed: speed,
82
48
  u_opacity: isNumber(opacity) ? opacity : 1.0
83
49
  };
@@ -113,7 +79,8 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
113
79
  depth: {
114
80
  enable: false
115
81
  },
116
- stencil: getMask(mask, maskInside)
82
+ stencil: getMask(mask, maskInside),
83
+ pick: false
117
84
  }).then(function (model) {
118
85
  callbackModel([model]);
119
86
  }).catch(function (err) {
@@ -124,10 +91,9 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
124
91
  }, {
125
92
  key: "clearModels",
126
93
  value: function clearModels() {
127
- var _this$texture, _this$dataTexture;
94
+ var _this$texture;
128
95
 
129
96
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
130
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
131
97
  }
132
98
  }, {
133
99
  key: "registerBuiltinAttributes",
@@ -154,10 +120,12 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
154
120
  type: gl.FLOAT
155
121
  },
156
122
  size: 2,
157
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
158
- var _vertex = _slicedToArray(vertex, 2),
159
- lng = _vertex[0],
160
- lat = _vertex[1];
123
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
124
+ var v = feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex;
125
+
126
+ var _v = _slicedToArray(v, 2),
127
+ lng = _v[0],
128
+ lat = _v[1];
161
129
 
162
130
  return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
163
131
  }
@@ -200,9 +168,7 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
200
168
  mag: gl.LINEAR
201
169
  });
202
170
 
203
- _this.layerService.updateLayerRenderList();
204
-
205
- _this.layerService.renderLayers();
171
+ _this.layerService.reRender();
206
172
  };
207
173
  }
208
174
  }]);
@@ -1,12 +1,12 @@
1
1
  uniform float u_opacity: 1.0;
2
- varying vec4 v_Color;
2
+ varying vec4 v_color;
3
3
  varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
4
4
 
5
5
  #pragma include "picking"
6
6
 
7
7
  void main() {
8
8
  float opacity = styleMappingMat[0][0];
9
- gl_FragColor = v_Color;
9
+ gl_FragColor = v_color;
10
10
  gl_FragColor.a *= opacity;
11
11
  gl_FragColor = filterColor(gl_FragColor);
12
12
  }
@@ -7,7 +7,7 @@ uniform mat4 u_Mvp;
7
7
  uniform float u_opacity: 1.0;
8
8
  uniform float u_raisingHeight: 0.0;
9
9
 
10
- varying vec4 v_Color;
10
+ varying vec4 v_color;
11
11
  varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
12
12
 
13
13
  #pragma include "styleMapping"
@@ -43,7 +43,7 @@ styleMappingMat = mat4(
43
43
  textureOffset = opacityAndOffset.g;
44
44
  // cal style mapping - 数据纹理映射部分的计算
45
45
 
46
- v_Color = a_Color;
46
+ v_color = a_Color;
47
47
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
48
48
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
49
49
 
@@ -0,0 +1,16 @@
1
+ attribute vec3 a_Position;
2
+
3
+ uniform mat4 u_ModelMatrix;
4
+ uniform mat4 u_Mvp;
5
+
6
+ #pragma include "projection"
7
+
8
+ void main() {
9
+ vec4 project_pos = project_position(vec4(a_Position, 1.0));
10
+
11
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
12
+ gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
13
+ } else {
14
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
15
+ }
16
+ }
@@ -4,78 +4,38 @@ attribute vec3 a_Position;
4
4
  uniform mat4 u_ModelMatrix;
5
5
  uniform mat4 u_Mvp;
6
6
 
7
- uniform float u_opacity: 1.0;
7
+ // uniform vec2 u_tileOrigin;
8
+ // uniform float u_coord;
8
9
 
9
- uniform vec2 u_tileOrigin;
10
- uniform float u_coord;
11
-
12
- varying vec4 v_Color;
13
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
14
-
15
- #pragma include "styleMapping"
16
- #pragma include "styleMappingCalOpacity"
10
+ varying vec4 v_color;
17
11
 
18
12
  #pragma include "projection"
19
13
  #pragma include "picking"
20
14
 
21
15
  void main() {
22
- // cal style mapping - 数据纹理映射部分的计算
23
- styleMappingMat = mat4(
24
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
25
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
26
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
27
- 0.0, 0.0, 0.0, 0.0
28
- );
29
-
30
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
31
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
32
- float columnWidth = 1.0/columnCount; // 列宽
33
- float rowHeight = 1.0/rowCount; // 行高
34
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
35
- float id = a_vertexId; // 第n个顶点
36
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
37
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
38
-
39
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
40
- // 按顺序从 cell 中取值、若没有则自动往下取值
41
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
42
-
43
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
44
- styleMappingMat[0][0] = opacityAndOffset.r;
45
- textureOffset = opacityAndOffset.g;
46
- // cal style mapping - 数据纹理映射部分的计算
47
-
48
- v_Color = a_Color;
16
+ v_color = a_Color;
49
17
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
50
18
 
19
+ // if(u_coord > 0.0) {
20
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
21
+ gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
22
+ } else {
23
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
24
+ }
25
+ // } else {
26
+ // vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
51
27
 
52
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
53
- float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
54
- project_pos.z *= mapboxZoomScale;
55
- }
56
-
57
- if(u_coord > 0.0) {
58
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
59
- gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
60
- } else {
61
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
62
- }
63
- } else {
64
- vec2 pointPos = a_Position.xy;
65
- vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
66
-
67
- vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
28
+ // vec2 pointOffset = a_Position.xy * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
68
29
 
69
- world.xy += pointOffset;
30
+ // world.xy += pointOffset;
70
31
 
71
- if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
72
- // Needs to be divided with project_uCommonUnitsPerMeter
73
- world.w *= u_PixelsPerMeter.z;
74
- }
75
-
76
- gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
77
- }
32
+ // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
33
+ // // Needs to be divided with project_uCommonUnitsPerMeter
34
+ // world.w *= u_PixelsPerMeter.z;
35
+ // }
78
36
 
37
+ // gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
38
+ // }
79
39
 
80
40
  setPickingColor(a_PickingColor);
81
41
  }
@@ -3,7 +3,6 @@ uniform float u_time: 0.0;
3
3
  uniform float u_opacity: 1.0;
4
4
 
5
5
  varying vec2 v_uv;
6
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
7
6
 
8
7
  float coast2water_fadedepth = 0.10;
9
8
  float large_waveheight = .750; // change to adjust the "heavy" waves
@@ -243,6 +242,6 @@ void main() {
243
242
  }
244
243
 
245
244
 
246
- float opacity = styleMappingMat[0][0];
245
+ float opacity = u_opacity;
247
246
  gl_FragColor = vec4(col, opacity);
248
247
  }