@antv/l7-layers 2.9.27-alpha.2 → 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 (300) hide show
  1. package/es/Geometry/index.js +6 -2
  2. package/es/Geometry/models/billboard.js +1 -2
  3. package/es/Geometry/models/plane.js +2 -4
  4. package/es/Geometry/models/sprite.js +2 -4
  5. package/es/canvas/index.d.ts +4 -0
  6. package/es/canvas/index.js +38 -2
  7. package/es/citybuliding/building.js +6 -2
  8. package/es/citybuliding/models/build.js +2 -3
  9. package/es/core/BaseLayer.d.ts +15 -6
  10. package/es/core/BaseLayer.js +51 -69
  11. package/es/core/BaseModel.d.ts +1 -1
  12. package/es/core/BaseModel.js +7 -3
  13. package/es/core/interface.d.ts +18 -0
  14. package/es/core/triangulation.d.ts +6 -0
  15. package/es/core/triangulation.js +64 -2
  16. package/es/earth/index.js +3 -1
  17. package/es/earth/models/base.js +2 -4
  18. package/es/earth/shaders/atmosphere_frag.glsl +1 -1
  19. package/es/earth/shaders/bloomsphere_frag.glsl +1 -1
  20. package/es/heatmap/index.js +6 -2
  21. package/es/heatmap/models/heatmap.js +5 -3
  22. package/es/image/index.js +6 -2
  23. package/es/image/models/dataImage.js +4 -7
  24. package/es/image/models/image.js +4 -7
  25. package/es/line/index.d.ts +1 -0
  26. package/es/line/index.js +8 -2
  27. package/es/line/models/arc.js +6 -5
  28. package/es/line/models/half.js +3 -4
  29. package/es/line/models/line.js +9 -8
  30. package/es/line/models/simpleLine.js +2 -1
  31. package/es/line/models/simpleTileLine.d.ts +9 -0
  32. package/es/line/models/simpleTileLine.js +100 -0
  33. package/es/line/models/tile.d.ts +1 -4
  34. package/es/line/models/tile.js +49 -222
  35. package/es/line/models/wall.js +10 -46
  36. package/es/line/shaders/dash/arc_dash_vert.glsl +2 -0
  37. package/es/line/shaders/dash/line_dash_frag.glsl +1 -1
  38. package/es/line/shaders/line_arc2d_vert.glsl +1 -1
  39. package/es/line/shaders/line_arc_3d_frag.glsl +1 -1
  40. package/es/line/shaders/line_arc_3d_vert.glsl +3 -3
  41. package/es/line/shaders/line_arc_frag.glsl +1 -1
  42. package/es/line/shaders/line_arc_great_circle_frag.glsl +1 -1
  43. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -1
  44. package/es/line/shaders/line_arc_vert.glsl +5 -3
  45. package/es/line/shaders/line_bezier_vert.glsl +1 -1
  46. package/es/line/shaders/line_frag.glsl +1 -2
  47. package/es/line/shaders/line_vert.glsl +1 -1
  48. package/es/line/shaders/linear/arc3d_linear_frag.glsl +1 -1
  49. package/es/line/shaders/linear/arc3d_linear_vert.glsl +3 -3
  50. package/es/line/shaders/linear/arc_linear_frag.glsl +1 -1
  51. package/es/line/shaders/tile/line_tile_map_vert.glsl +25 -0
  52. package/es/line/shaders/tile/line_tile_vert.glsl +19 -177
  53. package/es/line/shaders/tile/simpleline_map_vert.glsl +15 -0
  54. package/es/line/shaders/tile/simpleline_vert.glsl +21 -0
  55. package/es/line/shaders/{wall_frag.glsl → wall/wall_frag.glsl} +17 -21
  56. package/es/line/shaders/wall/wall_vert.glsl +77 -0
  57. package/es/mask/index.d.ts +1 -0
  58. package/es/mask/index.js +80 -5
  59. package/es/mask/models/fill.d.ts +2 -1
  60. package/es/mask/models/fill.js +13 -10
  61. package/es/mask/shaders/mask_vert.glsl +0 -6
  62. package/es/plugins/DataMappingPlugin.d.ts +4 -3
  63. package/es/plugins/DataMappingPlugin.js +129 -58
  64. package/es/plugins/DataSourcePlugin.js +3 -2
  65. package/es/plugins/FeatureScalePlugin.d.ts +0 -2
  66. package/es/plugins/FeatureScalePlugin.js +8 -51
  67. package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -2
  68. package/es/plugins/LayerAnimateStylePlugin.js +7 -27
  69. package/es/plugins/LayerModelPlugin.js +2 -6
  70. package/es/plugins/LightingPlugin.js +1 -7
  71. package/es/plugins/MultiPassRendererPlugin.d.ts +0 -1
  72. package/es/plugins/MultiPassRendererPlugin.js +4 -16
  73. package/es/plugins/PixelPickingPlugin.d.ts +1 -1
  74. package/es/plugins/PixelPickingPlugin.js +8 -28
  75. package/es/plugins/RegisterStyleAttributePlugin.d.ts +4 -0
  76. package/es/plugins/RegisterStyleAttributePlugin.js +56 -5
  77. package/es/plugins/UpdateStyleAttributePlugin.js +2 -9
  78. package/es/point/index.js +6 -2
  79. package/es/point/models/fill.js +2 -2
  80. package/es/point/models/fillmage.js +1 -1
  81. package/es/point/models/image.js +1 -1
  82. package/es/point/models/normal.d.ts +0 -1
  83. package/es/point/models/normal.js +9 -60
  84. package/es/point/models/radar.js +4 -69
  85. package/es/point/models/simplePoint.d.ts +0 -1
  86. package/es/point/models/simplePoint.js +2 -11
  87. package/es/point/models/text.js +6 -7
  88. package/es/point/models/tile.d.ts +0 -7
  89. package/es/point/models/tile.js +22 -155
  90. package/es/point/models/tileText.d.ts +0 -4
  91. package/es/point/models/tileText.js +98 -185
  92. package/es/point/shaders/animate/wave_frag.glsl +3 -3
  93. package/es/point/shaders/earth/fill_vert.glsl +0 -1
  94. package/es/point/shaders/fill_vert.glsl +0 -1
  95. package/es/point/shaders/normal_frag.glsl +1 -10
  96. package/es/point/shaders/normal_vert.glsl +5 -60
  97. package/es/point/shaders/radar/radar_frag.glsl +4 -15
  98. package/es/point/shaders/radar/radar_vert.glsl +4 -54
  99. package/es/point/shaders/tile/fill_tile_frag.glsl +10 -17
  100. package/es/point/shaders/tile/fill_tile_vert.glsl +20 -123
  101. package/es/point/shaders/tile/text_frag.glsl +33 -0
  102. package/es/point/shaders/tile/text_map_frag.glsl +31 -0
  103. package/es/point/shaders/tile/text_map_vert.glsl +38 -0
  104. package/es/point/shaders/tile/text_vert.glsl +48 -0
  105. package/es/polygon/index.js +6 -2
  106. package/es/polygon/models/extrude.js +1 -3
  107. package/es/polygon/models/fill.js +3 -4
  108. package/es/polygon/models/ocean.d.ts +0 -2
  109. package/es/polygon/models/ocean.js +13 -47
  110. package/es/polygon/models/tile.d.ts +1 -4
  111. package/es/polygon/models/tile.js +25 -57
  112. package/es/polygon/models/water.d.ts +0 -2
  113. package/es/polygon/models/water.js +13 -47
  114. package/es/polygon/shaders/polygon_frag.glsl +2 -2
  115. package/es/polygon/shaders/polygon_vert.glsl +2 -2
  116. package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +16 -0
  117. package/es/polygon/shaders/tile/polygon_tile_vert.glsl +20 -60
  118. package/es/polygon/shaders/water/polygon_ocean_frag.glsl +1 -2
  119. package/es/polygon/shaders/water/polygon_ocean_vert.glsl +0 -31
  120. package/es/polygon/shaders/water/polygon_water_frag.glsl +1 -3
  121. package/es/polygon/shaders/water/polygon_water_vert.glsl +0 -29
  122. package/es/raster/buffers/triangulation.js +1 -4
  123. package/es/raster/index.js +6 -2
  124. package/es/raster/models/raster.js +3 -2
  125. package/es/shader/minify_frag.glsl +7 -0
  126. package/es/shader/minify_picking_frag.glsl +10 -0
  127. package/es/tile/manager/baseMapTileLayerManager.d.ts +29 -0
  128. package/es/tile/manager/baseMapTileLayerManager.js +207 -0
  129. package/es/tile/manager/tileLayerManager.d.ts +2 -2
  130. package/es/tile/manager/tileLayerManager.js +2 -2
  131. package/es/tile/manager/tilePickerManager.d.ts +2 -3
  132. package/es/tile/manager/tilePickerManager.js +1 -2
  133. package/es/tile/models/tileModel.d.ts +1 -0
  134. package/es/tile/models/tileModel.js +18 -2
  135. package/es/tile/tileFactory/base.d.ts +1 -1
  136. package/es/tile/tileFactory/base.js +58 -33
  137. package/es/tile/tileFactory/line.js +3 -0
  138. package/es/tile/tileFactory/point.js +3 -0
  139. package/es/tile/tileFactory/polygon.js +3 -0
  140. package/es/tile/tileFactory/raster.js +3 -0
  141. package/es/tile/tileFactory/rasterData.js +3 -0
  142. package/es/tile/tileFactory/rasterDataLayer.js +6 -2
  143. package/es/tile/tileFactory/test.js +26 -5
  144. package/es/tile/tileFactory/vectorLayer.d.ts +4 -1
  145. package/es/tile/tileFactory/vectorLayer.js +110 -7
  146. package/es/tile/tileLayer/baseMapTileLayer.d.ts +29 -0
  147. package/es/tile/tileLayer/baseMapTileLayer.js +188 -0
  148. package/es/tile/tileLayer/baseTileLayer.d.ts +4 -4
  149. package/es/tile/tileLayer/baseTileLayer.js +46 -75
  150. package/es/tile/tileTest.d.ts +1 -0
  151. package/es/tile/tileTest.js +3 -2
  152. package/es/tile/tmsMapTileLayer.d.ts +9 -0
  153. package/es/tile/tmsMapTileLayer.js +119 -0
  154. package/es/tile/tmsTileLayer.d.ts +2 -0
  155. package/es/tile/tmsTileLayer.js +24 -2
  156. package/es/tile/utils.d.ts +4 -0
  157. package/es/tile/utils.js +30 -0
  158. package/es/utils/dataMappingStyle.js +3 -0
  159. package/es/utils/layerData.js +2 -2
  160. package/es/utils/updateShape.js +2 -2
  161. package/es/wind/index.js +6 -2
  162. package/es/wind/models/wind.js +8 -8
  163. package/es/wind/shaders/wind_vert.glsl +1 -1
  164. package/lib/Geometry/index.js +6 -2
  165. package/lib/Geometry/models/billboard.js +1 -2
  166. package/lib/Geometry/models/plane.js +2 -4
  167. package/lib/Geometry/models/sprite.js +2 -4
  168. package/lib/canvas/index.js +37 -2
  169. package/lib/citybuliding/building.js +6 -2
  170. package/lib/citybuliding/models/build.js +2 -3
  171. package/lib/core/BaseLayer.js +51 -69
  172. package/lib/core/BaseModel.js +7 -3
  173. package/lib/core/triangulation.js +66 -2
  174. package/lib/earth/index.js +3 -1
  175. package/lib/earth/models/base.js +2 -4
  176. package/lib/earth/shaders/atmosphere_frag.glsl +1 -1
  177. package/lib/earth/shaders/bloomsphere_frag.glsl +1 -1
  178. package/lib/heatmap/index.js +6 -2
  179. package/lib/heatmap/models/heatmap.js +5 -3
  180. package/lib/image/index.js +6 -2
  181. package/lib/image/models/dataImage.js +4 -7
  182. package/lib/image/models/image.js +4 -7
  183. package/lib/line/index.js +7 -2
  184. package/lib/line/models/arc.js +6 -5
  185. package/lib/line/models/half.js +3 -4
  186. package/lib/line/models/line.js +9 -8
  187. package/lib/line/models/simpleLine.js +2 -1
  188. package/lib/line/models/simpleTileLine.js +115 -0
  189. package/lib/line/models/tile.js +49 -223
  190. package/lib/line/models/wall.js +10 -46
  191. package/lib/line/shaders/dash/arc_dash_vert.glsl +2 -0
  192. package/lib/line/shaders/dash/line_dash_frag.glsl +1 -1
  193. package/lib/line/shaders/line_arc2d_vert.glsl +1 -1
  194. package/lib/line/shaders/line_arc_3d_frag.glsl +1 -1
  195. package/lib/line/shaders/line_arc_3d_vert.glsl +3 -3
  196. package/lib/line/shaders/line_arc_frag.glsl +1 -1
  197. package/lib/line/shaders/line_arc_great_circle_frag.glsl +1 -1
  198. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -1
  199. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  200. package/lib/line/shaders/line_bezier_vert.glsl +1 -1
  201. package/lib/line/shaders/line_frag.glsl +1 -2
  202. package/lib/line/shaders/line_vert.glsl +1 -1
  203. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +1 -1
  204. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +3 -3
  205. package/lib/line/shaders/linear/arc_linear_frag.glsl +1 -1
  206. package/lib/line/shaders/tile/line_tile_map_vert.glsl +25 -0
  207. package/lib/line/shaders/tile/line_tile_vert.glsl +19 -177
  208. package/lib/line/shaders/tile/simpleline_map_vert.glsl +15 -0
  209. package/lib/line/shaders/tile/simpleline_vert.glsl +21 -0
  210. package/lib/line/shaders/{wall_frag.glsl → wall/wall_frag.glsl} +17 -21
  211. package/lib/line/shaders/wall/wall_vert.glsl +77 -0
  212. package/lib/mask/index.js +82 -5
  213. package/lib/mask/models/fill.js +14 -10
  214. package/lib/mask/shaders/mask_vert.glsl +0 -6
  215. package/lib/plugins/DataMappingPlugin.js +127 -57
  216. package/lib/plugins/DataSourcePlugin.js +3 -2
  217. package/lib/plugins/FeatureScalePlugin.js +6 -50
  218. package/lib/plugins/LayerAnimateStylePlugin.js +6 -29
  219. package/lib/plugins/LayerModelPlugin.js +2 -6
  220. package/lib/plugins/LightingPlugin.js +1 -7
  221. package/lib/plugins/MultiPassRendererPlugin.js +3 -19
  222. package/lib/plugins/PixelPickingPlugin.js +8 -28
  223. package/lib/plugins/RegisterStyleAttributePlugin.js +56 -5
  224. package/lib/plugins/UpdateStyleAttributePlugin.js +2 -9
  225. package/lib/point/index.js +6 -2
  226. package/lib/point/models/fill.js +2 -2
  227. package/lib/point/models/fillmage.js +1 -1
  228. package/lib/point/models/image.js +1 -1
  229. package/lib/point/models/normal.js +8 -59
  230. package/lib/point/models/radar.js +4 -69
  231. package/lib/point/models/simplePoint.js +1 -10
  232. package/lib/point/models/text.js +6 -7
  233. package/lib/point/models/tile.js +21 -156
  234. package/lib/point/models/tileText.js +97 -184
  235. package/lib/point/shaders/animate/wave_frag.glsl +3 -3
  236. package/lib/point/shaders/earth/fill_vert.glsl +0 -1
  237. package/lib/point/shaders/fill_vert.glsl +0 -1
  238. package/lib/point/shaders/normal_frag.glsl +1 -10
  239. package/lib/point/shaders/normal_vert.glsl +5 -60
  240. package/lib/point/shaders/radar/radar_frag.glsl +4 -15
  241. package/lib/point/shaders/radar/radar_vert.glsl +4 -54
  242. package/lib/point/shaders/tile/fill_tile_frag.glsl +10 -17
  243. package/lib/point/shaders/tile/fill_tile_vert.glsl +20 -123
  244. package/lib/point/shaders/tile/text_frag.glsl +33 -0
  245. package/lib/point/shaders/tile/text_map_frag.glsl +31 -0
  246. package/lib/point/shaders/tile/text_map_vert.glsl +38 -0
  247. package/lib/point/shaders/tile/text_vert.glsl +48 -0
  248. package/lib/polygon/index.js +6 -2
  249. package/lib/polygon/models/extrude.js +1 -3
  250. package/lib/polygon/models/fill.js +3 -4
  251. package/lib/polygon/models/ocean.js +14 -47
  252. package/lib/polygon/models/tile.js +24 -57
  253. package/lib/polygon/models/water.js +14 -47
  254. package/lib/polygon/shaders/polygon_frag.glsl +2 -2
  255. package/lib/polygon/shaders/polygon_vert.glsl +2 -2
  256. package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +16 -0
  257. package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +20 -60
  258. package/lib/polygon/shaders/water/polygon_ocean_frag.glsl +1 -2
  259. package/lib/polygon/shaders/water/polygon_ocean_vert.glsl +0 -31
  260. package/lib/polygon/shaders/water/polygon_water_frag.glsl +1 -3
  261. package/lib/polygon/shaders/water/polygon_water_vert.glsl +0 -29
  262. package/lib/raster/buffers/triangulation.js +1 -4
  263. package/lib/raster/index.js +6 -2
  264. package/lib/raster/models/raster.js +3 -2
  265. package/lib/shader/minify_frag.glsl +7 -0
  266. package/lib/shader/minify_picking_frag.glsl +10 -0
  267. package/lib/tile/manager/baseMapTileLayerManager.js +222 -0
  268. package/lib/tile/manager/tileLayerManager.js +2 -2
  269. package/lib/tile/manager/tilePickerManager.js +1 -2
  270. package/lib/tile/models/tileModel.js +19 -2
  271. package/lib/tile/tileFactory/base.js +60 -33
  272. package/lib/tile/tileFactory/line.js +3 -0
  273. package/lib/tile/tileFactory/point.js +3 -0
  274. package/lib/tile/tileFactory/polygon.js +3 -0
  275. package/lib/tile/tileFactory/raster.js +3 -0
  276. package/lib/tile/tileFactory/rasterData.js +3 -0
  277. package/lib/tile/tileFactory/rasterDataLayer.js +6 -2
  278. package/lib/tile/tileFactory/test.js +26 -5
  279. package/lib/tile/tileFactory/vectorLayer.js +112 -8
  280. package/lib/tile/tileLayer/baseMapTileLayer.js +195 -0
  281. package/lib/tile/tileLayer/baseTileLayer.js +46 -75
  282. package/lib/tile/tileTest.js +3 -2
  283. package/lib/tile/tmsMapTileLayer.js +136 -0
  284. package/lib/tile/tmsTileLayer.js +25 -2
  285. package/lib/tile/utils.js +38 -0
  286. package/lib/utils/dataMappingStyle.js +3 -0
  287. package/lib/utils/layerData.js +2 -2
  288. package/lib/utils/updateShape.js +2 -2
  289. package/lib/wind/index.js +6 -2
  290. package/lib/wind/models/wind.js +7 -7
  291. package/lib/wind/shaders/wind_vert.glsl +1 -1
  292. package/package.json +8 -7
  293. package/es/line/shaders/tile/line_tile_frag.glsl +0 -79
  294. package/es/line/shaders/wall_vert.glsl +0 -111
  295. package/es/mask/shaders/mask_frag.glsl +0 -7
  296. package/es/polygon/shaders/tile/polygon_tile_frag.glsl +0 -12
  297. package/lib/line/shaders/tile/line_tile_frag.glsl +0 -79
  298. package/lib/line/shaders/wall_vert.glsl +0 -111
  299. package/lib/mask/shaders/mask_frag.glsl +0 -7
  300. package/lib/polygon/shaders/tile/polygon_tile_frag.glsl +0 -12
@@ -50,11 +50,17 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
50
50
 
51
51
  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; } }
52
52
 
53
- /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
54
- var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
53
+ /* babel-plugin-inline-import '../shaders/tile/text_frag.glsl' */
54
+ var text_frag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n#pragma include \"picking\"\nvoid main() {\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n \n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
55
55
 
56
- /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
57
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\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\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\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 styleMappingMat = 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\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
56
+ /* babel-plugin-inline-import '../shaders/tile/text_vert.glsl' */
57
+ var text_vert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
58
+
59
+ /* babel-plugin-inline-import '../shaders/tile/text_map_frag.glsl' */
60
+ var text_map_frag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\nuniform vec4 u_color;\n\nvoid main() {\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n \n gl_FragColor = mix(vec4(u_color.rgb, u_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n}\n";
61
+
62
+ /* babel-plugin-inline-import '../shaders/tile/text_map_vert.glsl' */
63
+ var text_map_vert = "#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_size;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = u_size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n\n}\n";
58
64
 
59
65
  function TextTriangulation(feature) {
60
66
  // @ts-ignore
@@ -109,26 +115,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
109
115
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preTextStyle", {});
110
116
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "buildModels", /*#__PURE__*/function () {
111
117
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(callbackModel) {
112
- var _ref2, _ref2$mask, mask, _ref2$maskInside, maskInside;
118
+ var _this$layer$getLayerC, usage;
113
119
 
114
120
  return _regenerator.default.wrap(function _callee$(_context) {
115
121
  while (1) {
116
122
  switch (_context.prev = _context.next) {
117
123
  case 0:
118
- _ref2 = _this.layer.getLayerConfig(), _ref2$mask = _ref2.mask, mask = _ref2$mask === void 0 ? false : _ref2$mask, _ref2$maskInside = _ref2.maskInside, maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
119
-
120
124
  _this.mapping();
121
125
 
126
+ _this$layer$getLayerC = _this.layer.getLayerConfig(), usage = _this$layer$getLayerC.usage;
127
+
122
128
  _this.layer.buildLayerModel({
123
- moduleName: 'pointText',
124
- vertexShader: textVert,
125
- fragmentShader: textFrag,
129
+ moduleName: 'pointTileText_' + usage,
130
+ vertexShader: usage === 'basemap' ? text_map_vert : text_vert,
131
+ fragmentShader: usage === 'basemap' ? text_map_frag : text_frag,
126
132
  triangulation: TextTriangulation.bind((0, _assertThisInitialized2.default)(_this)),
127
133
  depth: {
128
134
  enable: false
129
135
  },
130
136
  blend: _this.getBlend(),
131
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
137
+ pick: usage !== 'basemap'
132
138
  }).then(function (model) {
133
139
  callbackModel([model]);
134
140
  }).catch(function (err) {
@@ -163,23 +169,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
163
169
  (0, _createClass2.default)(TextModel, [{
164
170
  key: "getUninforms",
165
171
  value: function getUninforms() {
166
- var _ref3 = this.layer.getLayerConfig(),
167
- _ref3$opacity = _ref3.opacity,
168
- opacity = _ref3$opacity === void 0 ? 1.0 : _ref3$opacity,
169
- _ref3$stroke = _ref3.stroke,
170
- stroke = _ref3$stroke === void 0 ? '#fff' : _ref3$stroke,
171
- _ref3$strokeWidth = _ref3.strokeWidth,
172
- strokeWidth = _ref3$strokeWidth === void 0 ? 0 : _ref3$strokeWidth,
173
- _ref3$textAnchor = _ref3.textAnchor,
174
- textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor,
175
- _ref3$textAllowOverla = _ref3.textAllowOverlap,
176
- textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla,
177
- _ref3$halo = _ref3.halo,
178
- halo = _ref3$halo === void 0 ? 0.5 : _ref3$halo,
179
- _ref3$gamma = _ref3.gamma,
180
- gamma = _ref3$gamma === void 0 ? 2.0 : _ref3$gamma,
181
- _ref3$raisingHeight = _ref3.raisingHeight,
182
- raisingHeight = _ref3$raisingHeight === void 0 ? 0 : _ref3$raisingHeight;
172
+ var _ref2 = this.layer.getLayerConfig(),
173
+ _ref2$opacity = _ref2.opacity,
174
+ opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
175
+ _ref2$stroke = _ref2.stroke,
176
+ stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
177
+ _ref2$strokeWidth = _ref2.strokeWidth,
178
+ strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
179
+ _ref2$textAnchor = _ref2.textAnchor,
180
+ textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
181
+ _ref2$textAllowOverla = _ref2.textAllowOverlap,
182
+ textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
183
+ _ref2$halo = _ref2.halo,
184
+ halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
185
+ _ref2$gamma = _ref2.gamma,
186
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
187
+ usage = _ref2.usage,
188
+ _ref2$color = _ref2.color,
189
+ color = _ref2$color === void 0 ? '#fff' : _ref2$color,
190
+ _ref2$size = _ref2.size,
191
+ size = _ref2$size === void 0 ? 1 : _ref2$size;
183
192
 
184
193
  var _this$fontService = this.fontService,
185
194
  canvas = _this$fontService.canvas,
@@ -194,68 +203,28 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
194
203
  textAnchor: textAnchor,
195
204
  textAllowOverlap: textAllowOverlap
196
205
  };
197
-
198
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
199
- opacity: opacity,
200
- strokeWidth: strokeWidth,
201
- stroke: stroke
202
- })) {
203
- this.judgeStyleAttributes({
204
- opacity: opacity,
205
- strokeWidth: strokeWidth,
206
- stroke: stroke
207
- });
208
- var encodeData = this.layer.getEncodedData();
209
-
210
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
211
- data = _this$calDataFrame.data,
212
- width = _this$calDataFrame.width,
213
- height = _this$calDataFrame.height;
214
-
215
- this.rowCount = height; // 当前数据纹理有多少行
216
-
217
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
218
- flipY: true,
219
- data: data,
220
- format: _l7Core.gl.LUMINANCE,
221
- type: _l7Core.gl.FLOAT,
222
- width: width,
223
- height: height
224
- }) : this.createTexture2D({
225
- flipY: true,
226
- data: [1],
227
- format: _l7Core.gl.LUMINANCE,
228
- type: _l7Core.gl.FLOAT,
229
- width: 1,
230
- height: 1
231
- });
232
- }
233
-
234
206
  return {
235
- u_dataTexture: this.dataTexture,
236
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
237
- u_cellTypeLayout: this.getCellTypeLayout(),
238
- u_raisingHeight: Number(raisingHeight),
239
207
  u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
240
208
  u_stroke_width: (0, _lodash.isNumber)(strokeWidth) ? strokeWidth : 1.0,
241
209
  u_stroke_color: this.getStrokeColor(stroke),
242
210
  u_sdf_map: this.texture,
243
211
  u_halo_blur: halo,
244
212
  u_gamma_scale: gamma,
245
- u_sdf_map_size: [canvas.width, canvas.height]
213
+ u_sdf_map_size: [canvas.width, canvas.height],
214
+ u_color: usage === 'basemap' ? (0, _l7Utils.rgb2arr)(color) : [0, 0, 0, 0],
215
+ u_size: usage === 'basemap' ? size : 1
246
216
  };
247
217
  }
248
218
  }, {
249
219
  key: "initModels",
250
220
  value: function initModels(callbackModel) {
251
- this.layer.on('remapping', this.mapping);
252
221
  this.extent = this.textExtent();
253
222
 
254
- var _ref4 = this.layer.getLayerConfig(),
255
- _ref4$textAnchor = _ref4.textAnchor,
256
- textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor,
257
- _ref4$textAllowOverla = _ref4.textAllowOverlap,
258
- textAllowOverlap = _ref4$textAllowOverla === void 0 ? true : _ref4$textAllowOverla;
223
+ var _ref3 = this.layer.getLayerConfig(),
224
+ _ref3$textAnchor = _ref3.textAnchor,
225
+ textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor,
226
+ _ref3$textAllowOverla = _ref3.textAllowOverlap,
227
+ textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla;
259
228
 
260
229
  this.preTextStyle = {
261
230
  textAnchor: textAnchor,
@@ -266,40 +235,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
266
235
  }, {
267
236
  key: "clearModels",
268
237
  value: function clearModels() {
269
- var _this$texture, _this$dataTexture;
238
+ var _this$texture;
270
239
 
271
240
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
272
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
273
- this.layer.off('remapping', this.mapping);
274
241
  }
275
242
  }, {
276
243
  key: "registerBuiltinAttributes",
277
244
  value: function registerBuiltinAttributes() {
278
- this.styleAttributeService.registerStyleAttribute({
279
- name: 'rotate',
280
- type: _l7Core.AttributeType.Attribute,
281
- descriptor: {
282
- name: 'a_Rotate',
283
- buffer: {
284
- usage: _l7Core.gl.DYNAMIC_DRAW,
285
- data: [],
286
- type: _l7Core.gl.FLOAT
287
- },
288
- size: 1,
289
- update: function update(feature, featureIdx, vertex, attributeIdx) {
290
- var _feature$rotate = feature.rotate,
291
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
292
- return Array.isArray(rotate) ? [rotate[0]] : [rotate];
293
- }
294
- }
295
- });
245
+ var _this$layer$getLayerC2 = this.layer.getLayerConfig(),
246
+ usage = _this$layer$getLayerC2.usage;
247
+
296
248
  this.styleAttributeService.registerStyleAttribute({
297
249
  name: 'textOffsets',
298
250
  type: _l7Core.AttributeType.Attribute,
299
251
  descriptor: {
300
252
  name: 'a_textOffsets',
301
253
  buffer: {
302
- // give the WebGL driver a hint that this buffer may change
303
254
  usage: _l7Core.gl.STATIC_DRAW,
304
255
  data: [],
305
256
  type: _l7Core.gl.FLOAT
@@ -309,27 +260,29 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
309
260
  return [vertex[5], vertex[6]];
310
261
  }
311
262
  }
312
- }); // point layer size;
263
+ });
313
264
 
314
- this.styleAttributeService.registerStyleAttribute({
315
- name: 'size',
316
- type: _l7Core.AttributeType.Attribute,
317
- descriptor: {
318
- name: 'a_Size',
319
- buffer: {
320
- // give the WebGL driver a hint that this buffer may change
321
- usage: _l7Core.gl.DYNAMIC_DRAW,
322
- data: [],
323
- type: _l7Core.gl.FLOAT
324
- },
325
- size: 1,
326
- update: function update(feature, featureIdx, vertex, attributeIdx) {
327
- var _feature$size = feature.size,
328
- size = _feature$size === void 0 ? 12 : _feature$size;
329
- return Array.isArray(size) ? [size[0]] : [size];
265
+ if (usage !== 'basemap') {
266
+ this.styleAttributeService.registerStyleAttribute({
267
+ name: 'size',
268
+ type: _l7Core.AttributeType.Attribute,
269
+ descriptor: {
270
+ name: 'a_Size',
271
+ buffer: {
272
+ // give the WebGL driver a hint that this buffer may change
273
+ usage: _l7Core.gl.DYNAMIC_DRAW,
274
+ data: [],
275
+ type: _l7Core.gl.FLOAT
276
+ },
277
+ size: 1,
278
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
279
+ var _feature$size = feature.size,
280
+ size = _feature$size === void 0 ? 12 : _feature$size;
281
+ return Array.isArray(size) ? [size[0]] : [size];
282
+ }
330
283
  }
331
- }
332
- }); // point layer size;
284
+ });
285
+ }
333
286
 
334
287
  this.styleAttributeService.registerStyleAttribute({
335
288
  name: 'textUv',
@@ -362,11 +315,11 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
362
315
  }, {
363
316
  key: "initTextFont",
364
317
  value: function initTextFont() {
365
- var _ref5 = this.layer.getLayerConfig(),
366
- _ref5$fontWeight = _ref5.fontWeight,
367
- fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
368
- _ref5$fontFamily = _ref5.fontFamily,
369
- fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily;
318
+ var _ref4 = this.layer.getLayerConfig(),
319
+ _ref4$fontWeight = _ref4.fontWeight,
320
+ fontWeight = _ref4$fontWeight === void 0 ? '400' : _ref4$fontWeight,
321
+ _ref4$fontFamily = _ref4.fontFamily,
322
+ fontFamily = _ref4$fontFamily === void 0 ? 'sans-serif' : _ref4$fontFamily;
370
323
 
371
324
  var data = this.layer.getEncodedData();
372
325
  var characterSet = [];
@@ -400,54 +353,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
400
353
  iconfont: false
401
354
  });
402
355
  }
403
- /**
404
- * 生成 iconfont 纹理字典
405
- */
406
-
407
- }, {
408
- key: "initIconFontTex",
409
- value: function initIconFontTex() {
410
- var _ref6 = this.layer.getLayerConfig(),
411
- _ref6$fontWeight = _ref6.fontWeight,
412
- fontWeight = _ref6$fontWeight === void 0 ? '400' : _ref6$fontWeight,
413
- _ref6$fontFamily = _ref6.fontFamily,
414
- fontFamily = _ref6$fontFamily === void 0 ? 'sans-serif' : _ref6$fontFamily;
415
-
416
- var data = this.layer.getEncodedData();
417
- var characterSet = [];
418
- data.forEach(function (item) {
419
- var _item$shape2 = item.shape,
420
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
421
- shape = "".concat(shape);
422
-
423
- if (characterSet.indexOf(shape) === -1) {
424
- characterSet.push(shape);
425
- }
426
- });
427
- this.fontService.setFontOptions({
428
- characterSet: characterSet,
429
- fontWeight: fontWeight,
430
- fontFamily: fontFamily,
431
- iconfont: true
432
- });
433
- }
434
356
  /**
435
357
  * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
436
358
  */
437
359
 
438
360
  }, {
439
361
  key: "generateGlyphLayout",
440
- value: function generateGlyphLayout(iconfont) {
362
+ value: function generateGlyphLayout() {
441
363
  var _this2 = this;
442
364
 
443
- // TODO:更新文字布局
444
365
  var mapping = this.fontService.mapping;
445
366
 
446
- var _ref7 = this.layer.getLayerConfig(),
447
- _ref7$spacing = _ref7.spacing,
448
- spacing = _ref7$spacing === void 0 ? 2 : _ref7$spacing,
449
- _ref7$textAnchor = _ref7.textAnchor,
450
- textAnchor = _ref7$textAnchor === void 0 ? 'center' : _ref7$textAnchor;
367
+ var _ref5 = this.layer.getLayerConfig(),
368
+ _ref5$spacing = _ref5.spacing,
369
+ spacing = _ref5$spacing === void 0 ? 2 : _ref5$spacing,
370
+ _ref5$textAnchor = _ref5.textAnchor,
371
+ textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor;
451
372
 
452
373
  var data = this.layer.getEncodedData();
453
374
  this.glyphInfo = data.map(function (feature) {
@@ -459,7 +380,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
459
380
  _feature$textOffset = feature.textOffset,
460
381
  textOffset = _feature$textOffset === void 0 ? [0, 0] : _feature$textOffset;
461
382
  var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping, // @ts-ignore
462
- size, textAnchor, 'left', spacing, textOffset, iconfont);
383
+ size, textAnchor, 'left', spacing, textOffset, false);
463
384
  var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
464
385
  feature.shaping = shaping;
465
386
  feature.glyphQuads = glyphQuads;
@@ -483,11 +404,11 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
483
404
  value: function filterGlyphs() {
484
405
  var _this3 = this;
485
406
 
486
- var _ref8 = this.layer.getLayerConfig(),
487
- _ref8$padding = _ref8.padding,
488
- padding = _ref8$padding === void 0 ? [4, 4] : _ref8$padding,
489
- _ref8$textAllowOverla = _ref8.textAllowOverlap,
490
- textAllowOverlap = _ref8$textAllowOverla === void 0 ? false : _ref8$textAllowOverla;
407
+ var _ref6 = this.layer.getLayerConfig(),
408
+ _ref6$padding = _ref6.padding,
409
+ padding = _ref6$padding === void 0 ? [4, 4] : _ref6$padding,
410
+ _ref6$textAllowOverla = _ref6.textAllowOverlap,
411
+ textAllowOverlap = _ref6$textAllowOverla === void 0 ? false : _ref6$textAllowOverla;
491
412
 
492
413
  if (textAllowOverlap) {
493
414
  // 如果允许文本覆盖
@@ -524,7 +445,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
524
445
  box = _collisionIndex$place.box;
525
446
 
526
447
  if (box && box.length) {
527
- // TODO:featureIndex
528
448
  collisionIndex.insertCollisionBox(box, id);
529
449
  return true;
530
450
  } else {
@@ -543,14 +463,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
543
463
  }, {
544
464
  key: "initGlyph",
545
465
  value: function initGlyph() {
546
- var _this$layer$getLayerC = this.layer.getLayerConfig(),
547
- _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
548
- iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
549
-
550
-
551
- iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
466
+ // 1.生成文字纹理
467
+ this.initTextFont(); // 2.生成文字布局
552
468
 
553
- this.generateGlyphLayout(iconfont);
469
+ this.generateGlyphLayout();
554
470
  }
555
471
  /**
556
472
  * 更新文字纹理
@@ -580,27 +496,24 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
580
496
  value: function reBuildModel() {
581
497
  var _this4 = this;
582
498
 
583
- var _ref9 = this.layer.getLayerConfig(),
584
- _ref9$mask = _ref9.mask,
585
- mask = _ref9$mask === void 0 ? false : _ref9$mask,
586
- _ref9$maskInside = _ref9.maskInside,
587
- maskInside = _ref9$maskInside === void 0 ? true : _ref9$maskInside;
499
+ var _this$layer$getLayerC3 = this.layer.getLayerConfig(),
500
+ usage = _this$layer$getLayerC3.usage;
588
501
 
589
502
  this.filterGlyphs();
590
503
  this.layer.buildLayerModel({
591
- moduleName: 'pointTileText',
592
- vertexShader: textVert,
593
- fragmentShader: textFrag,
504
+ moduleName: 'pointTileText_' + usage,
505
+ vertexShader: usage === 'basemap' ? text_map_vert : text_vert,
506
+ fragmentShader: usage === 'basemap' ? text_map_frag : text_frag,
594
507
  triangulation: TextTriangulation.bind(this),
595
508
  depth: {
596
509
  enable: false
597
510
  },
598
511
  blend: this.getBlend(),
599
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
512
+ pick: usage !== 'basemap'
600
513
  }).then(function (model) {
601
514
  _this4.layer.models = [model];
602
515
 
603
- _this4.layer.renderLayers();
516
+ _this4.layerService.throttleRenderLayers();
604
517
  }).catch(function (err) {
605
518
  console.warn(err);
606
519
  _this4.layer.models = [];
@@ -7,7 +7,7 @@ varying vec4 v_data;
7
7
  varying vec4 v_color;
8
8
  varying float v_radius;
9
9
  uniform float u_time;
10
- uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
10
+ uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
11
11
 
12
12
  #pragma include "sdf_2d"
13
13
  #pragma include "picking"
@@ -53,10 +53,10 @@ void main() {
53
53
  }
54
54
  float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);
55
55
 
56
- // TODO: 根据叠加模式选择效果
56
+ // 根据叠加模式选择效果
57
57
  if(u_additive > 0.0) {
58
58
  gl_FragColor *= intensity;
59
- // TODO: 优化水波点 blend additive 模式下有的拾取效果
59
+ // 优化水波点 blend additive 模式下有的拾取效果
60
60
  gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);
61
61
  } else {
62
62
  gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);
@@ -111,7 +111,6 @@ void main() {
111
111
  // radius(16-bit)
112
112
  v_radius = newSize;
113
113
 
114
- // TODO: billboard
115
114
  // anti-alias
116
115
  // float antialiased_blur = -max(u_blur, antialiasblur);
117
116
  float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);
@@ -130,7 +130,6 @@ void main() {
130
130
  // radius(16-bit)
131
131
  v_radius = newSize;
132
132
 
133
- // TODO: billboard
134
133
  // anti-alias
135
134
  // float antialiased_blur = -max(u_blur, antialiasblur);
136
135
  float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);
@@ -1,15 +1,6 @@
1
-
2
1
  uniform float u_opacity : 1;
3
- uniform vec2 u_offsets;
4
2
  varying vec4 v_color;
5
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
6
-
7
- #pragma include "picking"
8
3
  void main() {
9
- float opacity = styleMappingMat[0][0];
10
-
11
4
  gl_FragColor = v_color;
12
- // gl_FragColor.a =gl_FragColor.a * u_opacity;
13
- gl_FragColor.a =gl_FragColor.a * opacity;
14
- gl_FragColor = filterColor(gl_FragColor);
5
+ gl_FragColor.a *= u_opacity;
15
6
  }
@@ -4,76 +4,21 @@ uniform mat4 u_ModelMatrix;
4
4
  uniform mat4 u_Mvp;
5
5
  attribute float a_Size;
6
6
  attribute vec4 a_Color;
7
- varying vec4 v_color;
8
-
9
- uniform float u_opacity : 1;
10
- uniform vec2 u_offsets;
11
7
 
12
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
13
-
14
- #pragma include "styleMapping"
15
- #pragma include "styleMappingCalOpacity"
8
+ varying vec4 v_color;
16
9
 
17
10
  #pragma include "projection"
18
- #pragma include "picking"
19
11
  #pragma include "project"
12
+
20
13
  void main() {
21
14
  v_color = a_Color;
22
15
 
23
- // cal style mapping - 数据纹理映射部分的计算
24
- styleMappingMat = mat4(
25
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
26
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
27
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
28
- 0.0, 0.0, 0.0, 0.0
29
- );
30
-
31
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
32
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
33
- float columnWidth = 1.0/columnCount; // 列宽
34
- float rowHeight = 1.0/rowCount; // 行高
35
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
36
- float id = a_vertexId; // 第n个顶点
37
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
38
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
39
-
40
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
41
- // 按顺序从 cell 中取值、若没有则自动往下取值
42
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
43
-
44
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
45
- styleMappingMat[0][0] = opacityAndOffset.r;
46
- textureOffset = opacityAndOffset.g;
47
-
48
- vec2 textrueOffsets = vec2(0.0, 0.0);
49
- if(hasOffsets()) {
50
- vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
51
- textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
52
- textureOffset += 1.0;
53
-
54
- vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
55
- textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
56
- textureOffset += 1.0;
57
- } else {
58
- textrueOffsets = u_offsets;
59
- }
60
-
61
- // cal style mapping
62
-
63
- // vec2 offset = project_pixel(u_offsets);
64
- vec2 offset = project_pixel(textrueOffsets);
65
- // vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);
66
- // gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\
67
- //
68
16
  if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
69
- // vec2 offset = project_pixel((u_offsets));
70
- gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);
71
- } else { // else
72
- // vec2 offset = project_pixel(u_offsets);
17
+ gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);
18
+ } else {
73
19
  vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);
74
- gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
20
+ gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));
75
21
  }
76
22
 
77
23
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
78
- setPickingColor(a_PickingColor);
79
24
  }
@@ -1,26 +1,15 @@
1
1
 
2
2
  uniform float u_additive;
3
-
4
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
3
+ uniform float u_opacity: 1.0;
5
4
 
6
5
  varying vec4 v_data;
7
6
  varying vec4 v_color;
8
7
  varying float v_radius;
9
-
8
+ varying vec2 v_exteude;
10
9
  #pragma include "sdf_2d"
11
10
  #pragma include "picking"
12
11
 
13
12
  void main() {
14
- int shape = int(floor(v_data.w + 0.5));
15
-
16
- vec4 textrueStroke = vec4(
17
- styleMappingMat[1][0],
18
- styleMappingMat[1][1],
19
- styleMappingMat[1][2],
20
- styleMappingMat[1][3]
21
- );
22
-
23
- float opacity = styleMappingMat[0][0];
24
13
 
25
14
  lowp float antialiasblur = v_data.z;
26
15
  float r = v_radius / (v_radius);
@@ -30,7 +19,7 @@ void main() {
30
19
 
31
20
  float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
32
21
 
33
- gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);
22
+ gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);
34
23
 
35
24
  if(u_additive > 0.0) {
36
25
  gl_FragColor *= opacity_t;
@@ -42,7 +31,7 @@ void main() {
42
31
  gl_FragColor = filterColor(gl_FragColor);
43
32
  }
44
33
 
45
- vec2 extrude = styleMappingMat[2].ba;
34
+ vec2 extrude = v_exteude;
46
35
  vec2 dir = normalize(extrude);
47
36
  vec2 baseDir = vec2(1.0, 0.0);
48
37
  float pi = 3.14159265359;