@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
@@ -21,17 +21,23 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
21
21
  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; } }
22
22
 
23
23
  import { AttributeType, gl } from '@antv/l7-core';
24
- import { calculateCentroid, getMask, padBounds } from '@antv/l7-utils';
24
+ import { calculateCentroid, padBounds, rgb2arr } from '@antv/l7-utils';
25
25
  import { isNumber } from 'lodash';
26
26
  import BaseModel from "../../core/BaseModel";
27
27
  import CollisionIndex from "../../utils/collision-index";
28
28
  import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
29
29
 
30
- /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
31
- 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";
30
+ /* babel-plugin-inline-import '../shaders/tile/text_frag.glsl' */
31
+ 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";
32
32
 
33
- /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
34
- 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";
33
+ /* babel-plugin-inline-import '../shaders/tile/text_vert.glsl' */
34
+ 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";
35
+
36
+ /* babel-plugin-inline-import '../shaders/tile/text_map_frag.glsl' */
37
+ 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";
38
+
39
+ /* babel-plugin-inline-import '../shaders/tile/text_map_vert.glsl' */
40
+ 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";
35
41
  export function TextTriangulation(feature) {
36
42
  // @ts-ignore
37
43
  var that = this;
@@ -91,26 +97,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
91
97
 
92
98
  _defineProperty(_assertThisInitialized(_this), "buildModels", /*#__PURE__*/function () {
93
99
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(callbackModel) {
94
- var _ref2, _ref2$mask, mask, _ref2$maskInside, maskInside;
100
+ var _this$layer$getLayerC, usage;
95
101
 
96
102
  return _regeneratorRuntime.wrap(function _callee$(_context) {
97
103
  while (1) {
98
104
  switch (_context.prev = _context.next) {
99
105
  case 0:
100
- _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;
101
-
102
106
  _this.mapping();
103
107
 
108
+ _this$layer$getLayerC = _this.layer.getLayerConfig(), usage = _this$layer$getLayerC.usage;
109
+
104
110
  _this.layer.buildLayerModel({
105
- moduleName: 'pointText',
106
- vertexShader: textVert,
107
- fragmentShader: textFrag,
111
+ moduleName: 'pointTileText_' + usage,
112
+ vertexShader: usage === 'basemap' ? text_map_vert : text_vert,
113
+ fragmentShader: usage === 'basemap' ? text_map_frag : text_frag,
108
114
  triangulation: TextTriangulation.bind(_assertThisInitialized(_this)),
109
115
  depth: {
110
116
  enable: false
111
117
  },
112
118
  blend: _this.getBlend(),
113
- stencil: getMask(mask, maskInside)
119
+ pick: usage !== 'basemap'
114
120
  }).then(function (model) {
115
121
  callbackModel([model]);
116
122
  }).catch(function (err) {
@@ -147,23 +153,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
147
153
  _createClass(TextModel, [{
148
154
  key: "getUninforms",
149
155
  value: function getUninforms() {
150
- var _ref3 = this.layer.getLayerConfig(),
151
- _ref3$opacity = _ref3.opacity,
152
- opacity = _ref3$opacity === void 0 ? 1.0 : _ref3$opacity,
153
- _ref3$stroke = _ref3.stroke,
154
- stroke = _ref3$stroke === void 0 ? '#fff' : _ref3$stroke,
155
- _ref3$strokeWidth = _ref3.strokeWidth,
156
- strokeWidth = _ref3$strokeWidth === void 0 ? 0 : _ref3$strokeWidth,
157
- _ref3$textAnchor = _ref3.textAnchor,
158
- textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor,
159
- _ref3$textAllowOverla = _ref3.textAllowOverlap,
160
- textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla,
161
- _ref3$halo = _ref3.halo,
162
- halo = _ref3$halo === void 0 ? 0.5 : _ref3$halo,
163
- _ref3$gamma = _ref3.gamma,
164
- gamma = _ref3$gamma === void 0 ? 2.0 : _ref3$gamma,
165
- _ref3$raisingHeight = _ref3.raisingHeight,
166
- raisingHeight = _ref3$raisingHeight === void 0 ? 0 : _ref3$raisingHeight;
156
+ var _ref2 = this.layer.getLayerConfig(),
157
+ _ref2$opacity = _ref2.opacity,
158
+ opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
159
+ _ref2$stroke = _ref2.stroke,
160
+ stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
161
+ _ref2$strokeWidth = _ref2.strokeWidth,
162
+ strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
163
+ _ref2$textAnchor = _ref2.textAnchor,
164
+ textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
165
+ _ref2$textAllowOverla = _ref2.textAllowOverlap,
166
+ textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
167
+ _ref2$halo = _ref2.halo,
168
+ halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
169
+ _ref2$gamma = _ref2.gamma,
170
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
171
+ usage = _ref2.usage,
172
+ _ref2$color = _ref2.color,
173
+ color = _ref2$color === void 0 ? '#fff' : _ref2$color,
174
+ _ref2$size = _ref2.size,
175
+ size = _ref2$size === void 0 ? 1 : _ref2$size;
167
176
 
168
177
  var _this$fontService = this.fontService,
169
178
  canvas = _this$fontService.canvas,
@@ -178,68 +187,28 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
178
187
  textAnchor: textAnchor,
179
188
  textAllowOverlap: textAllowOverlap
180
189
  };
181
-
182
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
183
- opacity: opacity,
184
- strokeWidth: strokeWidth,
185
- stroke: stroke
186
- })) {
187
- this.judgeStyleAttributes({
188
- opacity: opacity,
189
- strokeWidth: strokeWidth,
190
- stroke: stroke
191
- });
192
- var encodeData = this.layer.getEncodedData();
193
-
194
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
195
- data = _this$calDataFrame.data,
196
- width = _this$calDataFrame.width,
197
- height = _this$calDataFrame.height;
198
-
199
- this.rowCount = height; // 当前数据纹理有多少行
200
-
201
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
202
- flipY: true,
203
- data: data,
204
- format: gl.LUMINANCE,
205
- type: gl.FLOAT,
206
- width: width,
207
- height: height
208
- }) : this.createTexture2D({
209
- flipY: true,
210
- data: [1],
211
- format: gl.LUMINANCE,
212
- type: gl.FLOAT,
213
- width: 1,
214
- height: 1
215
- });
216
- }
217
-
218
190
  return {
219
- u_dataTexture: this.dataTexture,
220
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
221
- u_cellTypeLayout: this.getCellTypeLayout(),
222
- u_raisingHeight: Number(raisingHeight),
223
191
  u_opacity: isNumber(opacity) ? opacity : 1.0,
224
192
  u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,
225
193
  u_stroke_color: this.getStrokeColor(stroke),
226
194
  u_sdf_map: this.texture,
227
195
  u_halo_blur: halo,
228
196
  u_gamma_scale: gamma,
229
- u_sdf_map_size: [canvas.width, canvas.height]
197
+ u_sdf_map_size: [canvas.width, canvas.height],
198
+ u_color: usage === 'basemap' ? rgb2arr(color) : [0, 0, 0, 0],
199
+ u_size: usage === 'basemap' ? size : 1
230
200
  };
231
201
  }
232
202
  }, {
233
203
  key: "initModels",
234
204
  value: function initModels(callbackModel) {
235
- this.layer.on('remapping', this.mapping);
236
205
  this.extent = this.textExtent();
237
206
 
238
- var _ref4 = this.layer.getLayerConfig(),
239
- _ref4$textAnchor = _ref4.textAnchor,
240
- textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor,
241
- _ref4$textAllowOverla = _ref4.textAllowOverlap,
242
- textAllowOverlap = _ref4$textAllowOverla === void 0 ? true : _ref4$textAllowOverla;
207
+ var _ref3 = this.layer.getLayerConfig(),
208
+ _ref3$textAnchor = _ref3.textAnchor,
209
+ textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor,
210
+ _ref3$textAllowOverla = _ref3.textAllowOverlap,
211
+ textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla;
243
212
 
244
213
  this.preTextStyle = {
245
214
  textAnchor: textAnchor,
@@ -250,40 +219,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
250
219
  }, {
251
220
  key: "clearModels",
252
221
  value: function clearModels() {
253
- var _this$texture, _this$dataTexture;
222
+ var _this$texture;
254
223
 
255
224
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
256
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
257
- this.layer.off('remapping', this.mapping);
258
225
  }
259
226
  }, {
260
227
  key: "registerBuiltinAttributes",
261
228
  value: function registerBuiltinAttributes() {
262
- this.styleAttributeService.registerStyleAttribute({
263
- name: 'rotate',
264
- type: AttributeType.Attribute,
265
- descriptor: {
266
- name: 'a_Rotate',
267
- buffer: {
268
- usage: gl.DYNAMIC_DRAW,
269
- data: [],
270
- type: gl.FLOAT
271
- },
272
- size: 1,
273
- update: function update(feature, featureIdx, vertex, attributeIdx) {
274
- var _feature$rotate = feature.rotate,
275
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
276
- return Array.isArray(rotate) ? [rotate[0]] : [rotate];
277
- }
278
- }
279
- });
229
+ var _this$layer$getLayerC2 = this.layer.getLayerConfig(),
230
+ usage = _this$layer$getLayerC2.usage;
231
+
280
232
  this.styleAttributeService.registerStyleAttribute({
281
233
  name: 'textOffsets',
282
234
  type: AttributeType.Attribute,
283
235
  descriptor: {
284
236
  name: 'a_textOffsets',
285
237
  buffer: {
286
- // give the WebGL driver a hint that this buffer may change
287
238
  usage: gl.STATIC_DRAW,
288
239
  data: [],
289
240
  type: gl.FLOAT
@@ -293,27 +244,29 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
293
244
  return [vertex[5], vertex[6]];
294
245
  }
295
246
  }
296
- }); // point layer size;
247
+ });
297
248
 
298
- this.styleAttributeService.registerStyleAttribute({
299
- name: 'size',
300
- type: AttributeType.Attribute,
301
- descriptor: {
302
- name: 'a_Size',
303
- buffer: {
304
- // give the WebGL driver a hint that this buffer may change
305
- usage: gl.DYNAMIC_DRAW,
306
- data: [],
307
- type: gl.FLOAT
308
- },
309
- size: 1,
310
- update: function update(feature, featureIdx, vertex, attributeIdx) {
311
- var _feature$size = feature.size,
312
- size = _feature$size === void 0 ? 12 : _feature$size;
313
- return Array.isArray(size) ? [size[0]] : [size];
249
+ if (usage !== 'basemap') {
250
+ this.styleAttributeService.registerStyleAttribute({
251
+ name: 'size',
252
+ type: AttributeType.Attribute,
253
+ descriptor: {
254
+ name: 'a_Size',
255
+ buffer: {
256
+ // give the WebGL driver a hint that this buffer may change
257
+ usage: gl.DYNAMIC_DRAW,
258
+ data: [],
259
+ type: gl.FLOAT
260
+ },
261
+ size: 1,
262
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
263
+ var _feature$size = feature.size,
264
+ size = _feature$size === void 0 ? 12 : _feature$size;
265
+ return Array.isArray(size) ? [size[0]] : [size];
266
+ }
314
267
  }
315
- }
316
- }); // point layer size;
268
+ });
269
+ }
317
270
 
318
271
  this.styleAttributeService.registerStyleAttribute({
319
272
  name: 'textUv',
@@ -346,11 +299,11 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
346
299
  }, {
347
300
  key: "initTextFont",
348
301
  value: function initTextFont() {
349
- var _ref5 = this.layer.getLayerConfig(),
350
- _ref5$fontWeight = _ref5.fontWeight,
351
- fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
352
- _ref5$fontFamily = _ref5.fontFamily,
353
- fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily;
302
+ var _ref4 = this.layer.getLayerConfig(),
303
+ _ref4$fontWeight = _ref4.fontWeight,
304
+ fontWeight = _ref4$fontWeight === void 0 ? '400' : _ref4$fontWeight,
305
+ _ref4$fontFamily = _ref4.fontFamily,
306
+ fontFamily = _ref4$fontFamily === void 0 ? 'sans-serif' : _ref4$fontFamily;
354
307
 
355
308
  var data = this.layer.getEncodedData();
356
309
  var characterSet = [];
@@ -384,54 +337,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
384
337
  iconfont: false
385
338
  });
386
339
  }
387
- /**
388
- * 生成 iconfont 纹理字典
389
- */
390
-
391
- }, {
392
- key: "initIconFontTex",
393
- value: function initIconFontTex() {
394
- var _ref6 = this.layer.getLayerConfig(),
395
- _ref6$fontWeight = _ref6.fontWeight,
396
- fontWeight = _ref6$fontWeight === void 0 ? '400' : _ref6$fontWeight,
397
- _ref6$fontFamily = _ref6.fontFamily,
398
- fontFamily = _ref6$fontFamily === void 0 ? 'sans-serif' : _ref6$fontFamily;
399
-
400
- var data = this.layer.getEncodedData();
401
- var characterSet = [];
402
- data.forEach(function (item) {
403
- var _item$shape2 = item.shape,
404
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
405
- shape = "".concat(shape);
406
-
407
- if (characterSet.indexOf(shape) === -1) {
408
- characterSet.push(shape);
409
- }
410
- });
411
- this.fontService.setFontOptions({
412
- characterSet: characterSet,
413
- fontWeight: fontWeight,
414
- fontFamily: fontFamily,
415
- iconfont: true
416
- });
417
- }
418
340
  /**
419
341
  * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
420
342
  */
421
343
 
422
344
  }, {
423
345
  key: "generateGlyphLayout",
424
- value: function generateGlyphLayout(iconfont) {
346
+ value: function generateGlyphLayout() {
425
347
  var _this2 = this;
426
348
 
427
- // TODO:更新文字布局
428
349
  var mapping = this.fontService.mapping;
429
350
 
430
- var _ref7 = this.layer.getLayerConfig(),
431
- _ref7$spacing = _ref7.spacing,
432
- spacing = _ref7$spacing === void 0 ? 2 : _ref7$spacing,
433
- _ref7$textAnchor = _ref7.textAnchor,
434
- textAnchor = _ref7$textAnchor === void 0 ? 'center' : _ref7$textAnchor;
351
+ var _ref5 = this.layer.getLayerConfig(),
352
+ _ref5$spacing = _ref5.spacing,
353
+ spacing = _ref5$spacing === void 0 ? 2 : _ref5$spacing,
354
+ _ref5$textAnchor = _ref5.textAnchor,
355
+ textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor;
435
356
 
436
357
  var data = this.layer.getEncodedData();
437
358
  this.glyphInfo = data.map(function (feature) {
@@ -443,7 +364,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
443
364
  _feature$textOffset = feature.textOffset,
444
365
  textOffset = _feature$textOffset === void 0 ? [0, 0] : _feature$textOffset;
445
366
  var shaping = shapeText(shape.toString(), mapping, // @ts-ignore
446
- size, textAnchor, 'left', spacing, textOffset, iconfont);
367
+ size, textAnchor, 'left', spacing, textOffset, false);
447
368
  var glyphQuads = getGlyphQuads(shaping, textOffset, false);
448
369
  feature.shaping = shaping;
449
370
  feature.glyphQuads = glyphQuads;
@@ -467,11 +388,11 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
467
388
  value: function filterGlyphs() {
468
389
  var _this3 = this;
469
390
 
470
- var _ref8 = this.layer.getLayerConfig(),
471
- _ref8$padding = _ref8.padding,
472
- padding = _ref8$padding === void 0 ? [4, 4] : _ref8$padding,
473
- _ref8$textAllowOverla = _ref8.textAllowOverlap,
474
- textAllowOverlap = _ref8$textAllowOverla === void 0 ? false : _ref8$textAllowOverla;
391
+ var _ref6 = this.layer.getLayerConfig(),
392
+ _ref6$padding = _ref6.padding,
393
+ padding = _ref6$padding === void 0 ? [4, 4] : _ref6$padding,
394
+ _ref6$textAllowOverla = _ref6.textAllowOverlap,
395
+ textAllowOverlap = _ref6$textAllowOverla === void 0 ? false : _ref6$textAllowOverla;
475
396
 
476
397
  if (textAllowOverlap) {
477
398
  // 如果允许文本覆盖
@@ -508,7 +429,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
508
429
  box = _collisionIndex$place.box;
509
430
 
510
431
  if (box && box.length) {
511
- // TODO:featureIndex
512
432
  collisionIndex.insertCollisionBox(box, id);
513
433
  return true;
514
434
  } else {
@@ -527,14 +447,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
527
447
  }, {
528
448
  key: "initGlyph",
529
449
  value: function initGlyph() {
530
- var _this$layer$getLayerC = this.layer.getLayerConfig(),
531
- _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
532
- iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
533
-
534
-
535
- iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
450
+ // 1.生成文字纹理
451
+ this.initTextFont(); // 2.生成文字布局
536
452
 
537
- this.generateGlyphLayout(iconfont);
453
+ this.generateGlyphLayout();
538
454
  }
539
455
  /**
540
456
  * 更新文字纹理
@@ -564,27 +480,24 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
564
480
  value: function reBuildModel() {
565
481
  var _this4 = this;
566
482
 
567
- var _ref9 = this.layer.getLayerConfig(),
568
- _ref9$mask = _ref9.mask,
569
- mask = _ref9$mask === void 0 ? false : _ref9$mask,
570
- _ref9$maskInside = _ref9.maskInside,
571
- maskInside = _ref9$maskInside === void 0 ? true : _ref9$maskInside;
483
+ var _this$layer$getLayerC3 = this.layer.getLayerConfig(),
484
+ usage = _this$layer$getLayerC3.usage;
572
485
 
573
486
  this.filterGlyphs();
574
487
  this.layer.buildLayerModel({
575
- moduleName: 'pointTileText',
576
- vertexShader: textVert,
577
- fragmentShader: textFrag,
488
+ moduleName: 'pointTileText_' + usage,
489
+ vertexShader: usage === 'basemap' ? text_map_vert : text_vert,
490
+ fragmentShader: usage === 'basemap' ? text_map_frag : text_frag,
578
491
  triangulation: TextTriangulation.bind(this),
579
492
  depth: {
580
493
  enable: false
581
494
  },
582
495
  blend: this.getBlend(),
583
- stencil: getMask(mask, maskInside)
496
+ pick: usage !== 'basemap'
584
497
  }).then(function (model) {
585
498
  _this4.layer.models = [model];
586
499
 
587
- _this4.layer.renderLayers();
500
+ _this4.layerService.throttleRenderLayers();
588
501
  }).catch(function (err) {
589
502
  console.warn(err);
590
503
  _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;