@antv/l7-layers 2.19.10 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/es/canvas/models/canvas.js +2 -2
  2. package/es/core/BaseLayer.d.ts +1 -1
  3. package/es/core/BaseLayer.js +22 -15
  4. package/es/core/BaseModel.d.ts +3 -1
  5. package/es/core/BaseModel.js +28 -4
  6. package/es/core/CommonStyleAttribute.d.ts +15 -0
  7. package/es/core/CommonStyleAttribute.js +21 -0
  8. package/es/core/TextureService.js +2 -2
  9. package/es/core/interface.d.ts +13 -9
  10. package/es/core/line_trangluation.d.ts +19 -0
  11. package/es/core/line_trangluation.js +91 -0
  12. package/es/core/shape/arrow.d.ts +25 -0
  13. package/es/core/shape/arrow.js +160 -0
  14. package/es/core/triangulation.d.ts +2 -8
  15. package/es/core/triangulation.js +6 -34
  16. package/es/earth/index.js +1 -1
  17. package/es/geometry/index.js +1 -1
  18. package/es/geometry/models/billboard.js +1 -1
  19. package/es/geometry/models/plane.js +2 -2
  20. package/es/geometry/models/sprite.js +2 -2
  21. package/es/heatmap/index.js +1 -1
  22. package/es/heatmap/models/heatmap.js +4 -4
  23. package/es/image/models/image.js +1 -1
  24. package/es/line/index.js +3 -2
  25. package/es/line/models/arc.js +6 -4
  26. package/es/line/models/arc_3d.js +4 -2
  27. package/es/line/models/earthArc_3d.js +4 -2
  28. package/es/line/models/flow.js +4 -5
  29. package/es/line/models/great_circle.js +1 -1
  30. package/es/line/models/line.js +3 -15
  31. package/es/line/models/linearline.js +1 -1
  32. package/es/line/models/wall.js +1 -1
  33. package/es/line/shaders/dash/arc_dash_vert.glsl +2 -5
  34. package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
  35. package/es/line/shaders/linear/arc_linear_vert.glsl +2 -3
  36. package/es/plugins/DataMappingPlugin.js +3 -20
  37. package/es/plugins/PixelPickingPlugin.d.ts +4 -1
  38. package/es/plugins/PixelPickingPlugin.js +91 -22
  39. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  40. package/es/plugins/RegisterStyleAttributePlugin.js +4 -22
  41. package/es/plugins/ShaderUniformPlugin.d.ts +2 -0
  42. package/es/plugins/ShaderUniformPlugin.js +74 -6
  43. package/es/point/index.js +1 -1
  44. package/es/point/models/fill.js +31 -7
  45. package/es/point/models/fillmage.js +1 -1
  46. package/es/point/models/image.js +1 -1
  47. package/es/point/models/normal.js +30 -12
  48. package/es/point/models/text.js +1 -1
  49. package/es/point/shaders/fill_frag.glsl +20 -14
  50. package/es/point/shaders/fill_vert.glsl +19 -18
  51. package/es/point/shaders/normal_frag.glsl +4 -3
  52. package/es/point/shaders/normal_vert.glsl +12 -11
  53. package/es/polygon/index.js +1 -1
  54. package/es/polygon/models/extrude.js +1 -1
  55. package/es/polygon/models/extrusion.js +1 -1
  56. package/es/polygon/models/ocean.js +3 -3
  57. package/es/polygon/models/water.js +1 -1
  58. package/es/raster/models/raster.js +2 -2
  59. package/es/raster/models/rasterRgb.js +1 -1
  60. package/es/raster/models/rasterTerrainRgb.js +1 -1
  61. package/es/tile/core/BaseLayer.js +4 -4
  62. package/es/tile/interaction/getRasterData.js +4 -4
  63. package/es/tile/service/TileLayerService.js +4 -4
  64. package/es/tile/service/TilePickService.js +3 -3
  65. package/es/tile/tile/Tile.d.ts +3 -1
  66. package/es/tile/tile/Tile.js +2 -2
  67. package/es/wind/models/wind.js +5 -6
  68. package/lib/canvas/index.js +2 -3
  69. package/lib/canvas/models/canvas.js +4 -5
  70. package/lib/canvas/models/index.js +1 -2
  71. package/lib/citybuliding/building.js +2 -3
  72. package/lib/citybuliding/models/build.js +2 -3
  73. package/lib/core/BaseLayer.js +23 -17
  74. package/lib/core/BaseModel.js +30 -7
  75. package/lib/core/CommonStyleAttribute.js +22 -0
  76. package/lib/core/LayerPickService.js +2 -3
  77. package/lib/core/TextureService.js +4 -5
  78. package/lib/core/constant.js +3 -5
  79. package/lib/core/interface.js +6 -11
  80. package/lib/core/line_trangluation.js +99 -0
  81. package/lib/core/schema.js +2 -3
  82. package/lib/core/shape/Path.js +3 -6
  83. package/lib/core/shape/arrow.js +174 -0
  84. package/lib/core/triangulation.js +8 -37
  85. package/lib/earth/index.js +3 -4
  86. package/lib/earth/models/atmosphere.js +2 -3
  87. package/lib/earth/models/base.js +2 -3
  88. package/lib/earth/models/bloomsphere.js +2 -3
  89. package/lib/earth/utils.js +3 -6
  90. package/lib/geometry/index.js +3 -4
  91. package/lib/geometry/models/billboard.js +3 -4
  92. package/lib/geometry/models/index.js +1 -2
  93. package/lib/geometry/models/plane.js +4 -5
  94. package/lib/geometry/models/sprite.js +4 -5
  95. package/lib/heatmap/index.js +3 -4
  96. package/lib/heatmap/models/grid.js +2 -3
  97. package/lib/heatmap/models/grid3d.js +2 -3
  98. package/lib/heatmap/models/heatmap.js +6 -7
  99. package/lib/heatmap/models/hexagon.js +2 -3
  100. package/lib/heatmap/models/index.js +1 -2
  101. package/lib/image/index.js +2 -3
  102. package/lib/image/models/image.js +3 -4
  103. package/lib/image/models/index.js +1 -2
  104. package/lib/line/index.js +5 -5
  105. package/lib/line/models/arc.js +8 -7
  106. package/lib/line/models/arc_3d.js +6 -5
  107. package/lib/line/models/earthArc_3d.js +6 -5
  108. package/lib/line/models/flow.js +6 -8
  109. package/lib/line/models/great_circle.js +3 -4
  110. package/lib/line/models/index.js +1 -2
  111. package/lib/line/models/line.js +5 -18
  112. package/lib/line/models/linearline.js +3 -4
  113. package/lib/line/models/simpleLine.js +2 -3
  114. package/lib/line/models/wall.js +3 -4
  115. package/lib/line/shaders/dash/arc_dash_vert.glsl +2 -5
  116. package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
  117. package/lib/line/shaders/linear/arc_linear_vert.glsl +2 -3
  118. package/lib/mask/index.js +2 -3
  119. package/lib/mask/models/fill.js +2 -3
  120. package/lib/mask/models/index.js +1 -2
  121. package/lib/plugins/DataMappingPlugin.js +5 -23
  122. package/lib/plugins/DataSourcePlugin.js +2 -3
  123. package/lib/plugins/FeatureScalePlugin.js +4 -5
  124. package/lib/plugins/LayerAnimateStylePlugin.js +2 -3
  125. package/lib/plugins/LayerMaskPlugin.js +2 -3
  126. package/lib/plugins/LayerModelPlugin.js +2 -3
  127. package/lib/plugins/LayerStylePlugin.js +2 -3
  128. package/lib/plugins/LightingPlugin.js +2 -3
  129. package/lib/plugins/MultiPassRendererPlugin.js +2 -3
  130. package/lib/plugins/PixelPickingPlugin.js +93 -25
  131. package/lib/plugins/RegisterStyleAttributePlugin.js +6 -25
  132. package/lib/plugins/ShaderUniformPlugin.js +75 -8
  133. package/lib/plugins/UpdateModelPlugin.js +2 -3
  134. package/lib/plugins/UpdateStyleAttributePlugin.js +2 -3
  135. package/lib/point/index.js +3 -4
  136. package/lib/point/models/billboard_point.js +2 -3
  137. package/lib/point/models/earthExtrude.js +2 -3
  138. package/lib/point/models/earthFill.js +2 -3
  139. package/lib/point/models/extrude.js +2 -3
  140. package/lib/point/models/fill.js +33 -10
  141. package/lib/point/models/fillmage.js +3 -4
  142. package/lib/point/models/image.js +3 -4
  143. package/lib/point/models/index.js +1 -2
  144. package/lib/point/models/normal.js +32 -15
  145. package/lib/point/models/radar.js +2 -3
  146. package/lib/point/models/text.js +3 -4
  147. package/lib/point/shaders/fill_frag.glsl +20 -14
  148. package/lib/point/shaders/fill_vert.glsl +19 -18
  149. package/lib/point/shaders/normal_frag.glsl +4 -3
  150. package/lib/point/shaders/normal_vert.glsl +12 -11
  151. package/lib/polygon/index.js +3 -4
  152. package/lib/polygon/models/extrude.js +3 -4
  153. package/lib/polygon/models/extrusion.js +3 -4
  154. package/lib/polygon/models/fill.js +2 -3
  155. package/lib/polygon/models/index.js +1 -2
  156. package/lib/polygon/models/ocean.js +5 -6
  157. package/lib/polygon/models/water.js +3 -4
  158. package/lib/raster/index.js +2 -3
  159. package/lib/raster/models/index.js +1 -2
  160. package/lib/raster/models/raster.js +4 -5
  161. package/lib/raster/models/rasterRgb.js +3 -4
  162. package/lib/raster/models/rasterTerrainRgb.js +3 -4
  163. package/lib/tile/core/BaseLayer.js +6 -7
  164. package/lib/tile/core/TileDebugLayer.js +2 -3
  165. package/lib/tile/interaction/getRasterData.js +4 -4
  166. package/lib/tile/service/TileLayerService.js +6 -7
  167. package/lib/tile/service/TilePickService.js +5 -6
  168. package/lib/tile/service/TileSourceService.js +4 -5
  169. package/lib/tile/tile/DebugTile.js +2 -3
  170. package/lib/tile/tile/ImageTile.js +2 -3
  171. package/lib/tile/tile/MaskTile.js +2 -3
  172. package/lib/tile/tile/RasterRGBTile.js +2 -3
  173. package/lib/tile/tile/RasterTerrainRGBTile.js +2 -3
  174. package/lib/tile/tile/RasterTile.js +2 -3
  175. package/lib/tile/tile/Tile.js +4 -5
  176. package/lib/tile/tile/VectorTile.js +2 -3
  177. package/lib/tile/utils/constants.js +2 -3
  178. package/lib/tile/utils/utils.js +1 -2
  179. package/lib/utils/blend.js +2 -3
  180. package/lib/utils/collision-index.js +2 -3
  181. package/lib/utils/extrude_polyline.js +2 -3
  182. package/lib/utils/grid-index.js +1 -2
  183. package/lib/utils/simpleLine.js +2 -3
  184. package/lib/wind/index.js +2 -3
  185. package/lib/wind/models/index.js +1 -2
  186. package/lib/wind/models/wind.js +7 -9
  187. package/lib/wind/models/windRender.js +4 -5
  188. package/lib/wind/models/windShader.js +6 -12
  189. package/package.json +7 -7
@@ -104,7 +104,7 @@ var CanvaModel = /*#__PURE__*/function (_BaseModel) {
104
104
  value: function clearModels() {
105
105
  if (this.canvas) {
106
106
  var _this$mapService$getC;
107
- (_this$mapService$getC = this.mapService.getContainer()) === null || _this$mapService$getC === void 0 ? void 0 : _this$mapService$getC.removeChild(this.canvas);
107
+ (_this$mapService$getC = this.mapService.getContainer()) === null || _this$mapService$getC === void 0 || _this$mapService$getC.removeChild(this.canvas);
108
108
  // @ts-ignore
109
109
  this.canvas = null;
110
110
  }
@@ -161,7 +161,7 @@ var CanvaModel = /*#__PURE__*/function (_BaseModel) {
161
161
  canvas.style.top = '0';
162
162
  canvas.style.left = '0';
163
163
  canvas.style.zIndex = zIndex + '';
164
- (_this$mapService$getC2 = this.mapService.getContainer()) === null || _this$mapService$getC2 === void 0 ? void 0 : _this$mapService$getC2.appendChild(canvas);
164
+ (_this$mapService$getC2 = this.mapService.getContainer()) === null || _this$mapService$getC2 === void 0 || _this$mapService$getC2.appendChild(canvas);
165
165
  var ctx = canvas.getContext('2d');
166
166
  this.ctx = ctx;
167
167
  }
@@ -1,5 +1,5 @@
1
1
  import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
2
- import { BlendType, IActiveOption, IAnimateOption, IAttributeAndElements, ICameraService, ICoordinateSystemService, IDataState, IDebugService, IEncodeFeature, IFontService, IGlobalConfigService, IIconService, IInteractionService, ILayer, ILayerAttributesOption, ILayerConfig, ILayerModel, ILayerModelInitializationOptions, ILayerPickService, ILayerPlugin, ILayerService, ILegend, IMapService, IModel, IModelInitializationOptions, IMultiPassRenderer, IParseDataItem, IPass, IPickingService, IPostProcessingPass, IRendererService, IRenderOptions, IScale, IScaleOptions, IShaderModuleService, ISourceCFG, IStyleAttributeService, IStyleAttributeUpdateOptions, ITextureService, LayerEventType, LegendItems, StyleAttributeField, StyleAttributeOption, Triangulation } from '@antv/l7-core';
2
+ import { BlendType, IActiveOption, IAnimateOption, IAttributeAndElements, ICameraService, ICoordinateSystemService, IDataState, IDebugService, IEncodeFeature, IFontService, IGlobalConfigService, IIconService, IInteractionService, ILayer, ILayerAttributesOption, ILayerConfig, ILayerModel, ILayerModelInitializationOptions, ILayerPickService, ILayerPlugin, ILayerService, ILegend, IMapService, IModel, IModelInitializationOptions, IMultiPassRenderer, IParseDataItem, IPass, IPickingService, IPostProcessingPass, IRenderOptions, IRendererService, IScale, IScaleOptions, IShaderModuleService, ISourceCFG, IStyleAttributeService, IStyleAttributeUpdateOptions, ITextureService, LayerEventType, LegendItems, StyleAttributeField, StyleAttributeOption, Triangulation } from '@antv/l7-core';
3
3
  import Source from '@antv/l7-source';
4
4
  import { EventEmitter } from 'eventemitter3';
5
5
  import { Container } from 'inversify';
@@ -13,7 +13,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
13
13
  import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
14
14
  import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
15
15
  var _excluded = ["passes"],
16
- _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "segmentNumber"];
16
+ _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption"];
17
17
  var _dec, _class, _descriptor;
18
18
  import _regeneratorRuntime from "@babel/runtime/regenerator";
19
19
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -23,7 +23,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
23
23
  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; } }
24
24
  // @ts-ignore
25
25
  import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
26
- import { BlendType, IDebugLog, ILayerStage, lazyInject, TYPES } from '@antv/l7-core';
26
+ import { BlendType, IDebugLog, ILayerStage, TYPES, lazyInject } from '@antv/l7-core';
27
27
  import Source from '@antv/l7-source';
28
28
  import { encodePickingColor, lodashUtil } from '@antv/l7-utils';
29
29
  import { EventEmitter } from 'eventemitter3';
@@ -375,7 +375,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
375
375
  id: this.id,
376
376
  type: this.type
377
377
  };
378
- (_this$debugService = this.debugService) === null || _this$debugService === void 0 ? void 0 : _this$debugService.log(key, values);
378
+ (_this$debugService = this.debugService) === null || _this$debugService === void 0 || _this$debugService.log(key, values);
379
379
  }
380
380
  }, {
381
381
  key: "updateModelData",
@@ -951,6 +951,12 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
951
951
  if (this.isDestroyed) {
952
952
  return;
953
953
  }
954
+
955
+ // destroy all UBOs
956
+ this.layerModel.uniformBuffers.forEach(function (buffer) {
957
+ buffer.destroy();
958
+ });
959
+
954
960
  // remove child layer
955
961
  this.layerChildren.map(function (child) {
956
962
  return child.destroy(false);
@@ -969,7 +975,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
969
975
  this.hooks.beforeDestroy.call();
970
976
  // 清除sources事件
971
977
  this.layerSource.off('update', this.sourceEvent);
972
- (_this$multiPassRender = this.multiPassRenderer) === null || _this$multiPassRender === void 0 ? void 0 : _this$multiPassRender.destroy();
978
+ (_this$multiPassRender = this.multiPassRenderer) === null || _this$multiPassRender === void 0 || _this$multiPassRender.destroy();
973
979
  this.textureService.destroy();
974
980
 
975
981
  // 清除所有属性以及关联的 vao == 销毁所有 => model this.models.forEach((model) => model.destroy());
@@ -979,11 +985,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
979
985
 
980
986
  this.hooks.afterDestroy.call();
981
987
  // Tip: 清除各个图层自定义的 models 资源
982
- (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 ? void 0 : _this$layerModel.clearModels(refresh);
983
- (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 ? void 0 : _this$tileLayer.destroy();
988
+ (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.clearModels(refresh);
989
+ (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 || _this$tileLayer.destroy();
984
990
  this.models = [];
985
991
  // 清除图层日志(如果有的话:非瓦片相关)
986
- (_this$debugService2 = this.debugService) === null || _this$debugService2 === void 0 ? void 0 : _this$debugService2.removeLog(this.id);
992
+ (_this$debugService2 = this.debugService) === null || _this$debugService2 === void 0 || _this$debugService2.removeLog(this.id);
987
993
  this.emit('remove', {
988
994
  target: this,
989
995
  type: 'remove'
@@ -1010,7 +1016,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1010
1016
  this.models.forEach(function (model) {
1011
1017
  return model.destroy();
1012
1018
  });
1013
- (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 ? void 0 : _this$layerModel2.clearModels();
1019
+ (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels();
1014
1020
  this.models = [];
1015
1021
  }
1016
1022
  }, {
@@ -1093,10 +1099,10 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1093
1099
  value: function getLegend(name) {
1094
1100
  var _attribute$scale, _scales$0$option, _attribute$scale2;
1095
1101
  var attribute = this.styleAttributeService.getLayerStyleAttribute(name);
1096
- var scales = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
1102
+ var scales = (attribute === null || attribute === void 0 || (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
1097
1103
  return {
1098
1104
  type: (_scales$0$option = scales[0].option) === null || _scales$0$option === void 0 ? void 0 : _scales$0$option.type,
1099
- field: attribute === null || attribute === void 0 ? void 0 : (_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.field,
1105
+ field: attribute === null || attribute === void 0 || (_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.field,
1100
1106
  items: this.getLegendItems(name)
1101
1107
  };
1102
1108
  }
@@ -1157,11 +1163,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1157
1163
  value: function () {
1158
1164
  var _buildLayerModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
1159
1165
  var _this10 = this;
1160
- var moduleName, vertexShader, fragmentShader, inject, triangulation, segmentNumber, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1166
+ var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1161
1167
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1162
1168
  while (1) switch (_context3.prev = _context3.next) {
1163
1169
  case 0:
1164
- moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, segmentNumber = options.segmentNumber, rest = _objectWithoutProperties(options, _excluded2);
1170
+ moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, rest = _objectWithoutProperties(options, _excluded2);
1165
1171
  this.shaderModuleService.registerModule(moduleName, {
1166
1172
  vs: vertexShader,
1167
1173
  fs: fragmentShader,
@@ -1170,8 +1176,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1170
1176
  _this$shaderModuleSer = this.shaderModuleService.getModule(moduleName), vs = _this$shaderModuleSer.vs, fs = _this$shaderModuleSer.fs, uniforms = _this$shaderModuleSer.uniforms;
1171
1177
  createModel = this.rendererService.createModel;
1172
1178
  return _context3.abrupt("return", new Promise(function (resolve) {
1173
- // console.log(this.encodedData)
1174
- var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, segmentNumber),
1179
+ var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, styleOption),
1175
1180
  attributes = _this10$styleAttribut.attributes,
1176
1181
  elements = _this10$styleAttribut.elements,
1177
1182
  count = _this10$styleAttribut.count;
@@ -1181,7 +1186,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1181
1186
  fs: fs,
1182
1187
  vs: vs,
1183
1188
  elements: elements,
1184
- blend: BlendTypes[BlendType.normal]
1189
+ blend: BlendTypes[BlendType.normal],
1190
+ uniformBuffers: [].concat(_toConsumableArray(_this10.layerModel.uniformBuffers), _toConsumableArray(_this10.rendererService.uniformBuffers)),
1191
+ textures: _this10.layerModel.textures
1185
1192
  }, rest);
1186
1193
  if (count) {
1187
1194
  modelOptions.count = count;
@@ -1,4 +1,4 @@
1
- import { IAnimateOption, IAttribute, IBlendOptions, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, IInject, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
1
+ import { IAnimateOption, IAttribute, IBlendOptions, IBuffer, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, IInject, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
2
2
  export type styleSingle = number | string | [string, (single: any) => number] | [string, [number, number]];
3
3
  export type styleOffset = string | [number, number] | [string, (single: any) => number];
4
4
  export type styleColor = string | [string, (single: any) => string] | [string, [string, string]];
@@ -13,6 +13,8 @@ export interface ICellProperty {
13
13
  }
14
14
  export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerModel {
15
15
  triangulation: Triangulation;
16
+ uniformBuffers: IBuffer[];
17
+ textures: ITexture2D[];
16
18
  createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
17
19
  preStyleAttribute: Record<string, any>;
18
20
  protected encodeStyleAttribute: Record<string, boolean>;
@@ -12,8 +12,16 @@ import { BlendType, lazyInject, MaskOperation, StencilType, TYPES } from '@antv/
12
12
  import { rgb2arr } from '@antv/l7-utils';
13
13
  import { BlendTypes } from "../utils/blend";
14
14
  import { getStencil as _getStencil, getStencilMask } from "../utils/stencil";
15
- import { getCommonStyleAttributeOptions } from "./CommonStyleAttribute";
16
15
  import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
16
+ import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
17
+ var shaderLocationMap = {
18
+ opacity: ShaderLocation.OPACITY,
19
+ stroke: ShaderLocation.STROKE,
20
+ offsets: ShaderLocation.OFFSETS,
21
+ rotation: ShaderLocation.ROTATION,
22
+ extrusionBase: ShaderLocation.EXTRUSION_BASE
23
+ };
24
+
17
25
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
26
  var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__PURE__*/function () {
19
27
  // @lazyInject(TYPES.IIconService)
@@ -28,7 +36,8 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
28
36
 
29
37
  function BaseModel(layer) {
30
38
  _classCallCheck(this, BaseModel);
31
- // style texture data mapping
39
+ _defineProperty(this, "uniformBuffers", []);
40
+ _defineProperty(this, "textures", []);
32
41
  _defineProperty(this, "preStyleAttribute", {});
33
42
  _defineProperty(this, "encodeStyleAttribute", {});
34
43
  _initializerDefineProperty(this, "configService", _descriptor, this);
@@ -208,18 +217,30 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
208
217
  value: function getInject() {
209
218
  var encodeStyleAttribute = this.layer.encodeStyleAttribute;
210
219
  var str = '';
220
+ // a_Position = 0
221
+ // a_Color = 1
222
+ // a_PickingColor = 2
223
+
224
+ var uniforms = [];
225
+ // 支持数据映射的类型
211
226
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
212
227
  if (encodeStyleAttribute[key]) {
228
+ // 配置了数据映射的类型
213
229
  str += "#define USE_ATTRIBUTE_".concat(key.toUpperCase(), " 0.0; \n\n");
230
+ } else {
231
+ uniforms.push(" ".concat(DefaultUniformStyleType[key], " u_").concat(key, ";"));
214
232
  }
215
- str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n attribute ").concat(DefaultUniformStyleType[key], " a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n #else\n uniform ").concat(DefaultUniformStyleType[key], " u_").concat(key, ";\n #endif\n\n ");
233
+ str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n layout(location = ").concat(shaderLocationMap[key], ") in ").concat(DefaultUniformStyleType[key], " a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n #endif\n\n ");
216
234
  });
235
+ var attributeUniforms = uniforms.length ? "\nlayout(std140) uniform AttributeUniforms {\n".concat(uniforms.join('\n'), "\n};\n ") : '';
236
+ str += attributeUniforms;
217
237
  var innerStr = '';
218
238
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
219
- innerStr += "\n\n#ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(DefaultUniformStyleType[key], " ").concat(key, " = a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n#else\n ").concat(DefaultUniformStyleType[key], " ").concat(key, " = u_").concat(key, ";\n#endif\n\n");
239
+ innerStr += "\n\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(DefaultUniformStyleType[key], " ").concat(key, " = a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n #else\n ").concat(DefaultUniformStyleType[key], " ").concat(key, " = u_").concat(key, ";\n #endif\n\n ");
220
240
  });
221
241
  return {
222
242
  'vs:#decl': str,
243
+ 'fs:#decl': attributeUniforms,
223
244
  'vs:#main-start': innerStr
224
245
  };
225
246
  }
@@ -254,6 +275,9 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
254
275
  var options = getCommonStyleAttributeOptions(key);
255
276
  if (options) {
256
277
  _this2.styleAttributeService.registerStyleAttribute(options);
278
+ if (options.descriptor) {
279
+ options.descriptor.shaderLocation = shaderLocationMap[key];
280
+ }
257
281
  }
258
282
  });
259
283
  }
@@ -1,2 +1,17 @@
1
1
  import { IStyleAttribute } from '@antv/l7-core';
2
+ export declare enum ShaderLocation {
3
+ POSITION = 0,
4
+ COLOR = 1,
5
+ VERTEX_ID = 2,
6
+ PICKING_COLOR = 3,
7
+ STROKE = 4,
8
+ OPACITY = 5,
9
+ OFFSETS = 6,
10
+ ROTATION = 7,
11
+ EXTRUSION_BASE = 8,
12
+ SIZE = 9,
13
+ SHAPE = 10,
14
+ EXTRUDE = 11,
15
+ MAX = 12
16
+ }
2
17
  export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
@@ -1,4 +1,20 @@
1
1
  import { AttributeType, gl } from '@antv/l7-core';
2
+ export var ShaderLocation = /*#__PURE__*/function (ShaderLocation) {
3
+ ShaderLocation[ShaderLocation["POSITION"] = 0] = "POSITION";
4
+ ShaderLocation[ShaderLocation["COLOR"] = 1] = "COLOR";
5
+ ShaderLocation[ShaderLocation["VERTEX_ID"] = 2] = "VERTEX_ID";
6
+ ShaderLocation[ShaderLocation["PICKING_COLOR"] = 3] = "PICKING_COLOR";
7
+ ShaderLocation[ShaderLocation["STROKE"] = 4] = "STROKE";
8
+ ShaderLocation[ShaderLocation["OPACITY"] = 5] = "OPACITY";
9
+ ShaderLocation[ShaderLocation["OFFSETS"] = 6] = "OFFSETS";
10
+ ShaderLocation[ShaderLocation["ROTATION"] = 7] = "ROTATION";
11
+ ShaderLocation[ShaderLocation["EXTRUSION_BASE"] = 8] = "EXTRUSION_BASE";
12
+ ShaderLocation[ShaderLocation["SIZE"] = 9] = "SIZE";
13
+ ShaderLocation[ShaderLocation["SHAPE"] = 10] = "SHAPE";
14
+ ShaderLocation[ShaderLocation["EXTRUDE"] = 11] = "EXTRUDE";
15
+ ShaderLocation[ShaderLocation["MAX"] = 12] = "MAX";
16
+ return ShaderLocation;
17
+ }({});
2
18
  export function getCommonStyleAttributeOptions(name) {
3
19
  switch (name) {
4
20
  // // roate
@@ -8,6 +24,7 @@ export function getCommonStyleAttributeOptions(name) {
8
24
  type: AttributeType.Attribute,
9
25
  descriptor: {
10
26
  name: 'a_Rotation',
27
+ shaderLocation: ShaderLocation.ROTATION,
11
28
  buffer: {
12
29
  usage: gl.DYNAMIC_DRAW,
13
30
  data: [],
@@ -27,6 +44,7 @@ export function getCommonStyleAttributeOptions(name) {
27
44
  type: AttributeType.Attribute,
28
45
  descriptor: {
29
46
  name: 'a_Stroke',
47
+ shaderLocation: ShaderLocation.STROKE,
30
48
  buffer: {
31
49
  // give the WebGL driver a hint that this buffer may change
32
50
  usage: gl.DYNAMIC_DRAW,
@@ -47,6 +65,7 @@ export function getCommonStyleAttributeOptions(name) {
47
65
  type: AttributeType.Attribute,
48
66
  descriptor: {
49
67
  name: 'a_Opacity',
68
+ shaderLocation: ShaderLocation.OPACITY,
50
69
  buffer: {
51
70
  // give the WebGL driver a hint that this buffer may change
52
71
  usage: gl.STATIC_DRAW,
@@ -67,6 +86,7 @@ export function getCommonStyleAttributeOptions(name) {
67
86
  type: AttributeType.Attribute,
68
87
  descriptor: {
69
88
  name: 'a_ExtrusionBase',
89
+ shaderLocation: ShaderLocation.EXTRUSION_BASE,
70
90
  buffer: {
71
91
  // give the WebGL driver a hint that this buffer may change
72
92
  usage: gl.STATIC_DRAW,
@@ -87,6 +107,7 @@ export function getCommonStyleAttributeOptions(name) {
87
107
  type: AttributeType.Attribute,
88
108
  descriptor: {
89
109
  name: 'a_Offsets',
110
+ shaderLocation: ShaderLocation.OFFSETS,
90
111
  buffer: {
91
112
  // give the WebGL driver a hint that this buffer may change
92
113
  usage: gl.STATIC_DRAW,
@@ -46,7 +46,7 @@ var TextureService = /*#__PURE__*/function () {
46
46
  key: "destroy",
47
47
  value: function destroy() {
48
48
  var _this$colorTexture;
49
- (_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.destroy();
49
+ (_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 || _this$colorTexture.destroy();
50
50
  }
51
51
  }, {
52
52
  key: "getColorRampBar",
@@ -68,7 +68,7 @@ var TextureService = /*#__PURE__*/function () {
68
68
  key: "getTextureKey",
69
69
  value: function getTextureKey(colorRamp, domain) {
70
70
  var _colorRamp$positions;
71
- return "".concat(colorRamp.colors.join('_'), "_").concat(colorRamp === null || colorRamp === void 0 ? void 0 : (_colorRamp$positions = colorRamp.positions) === null || _colorRamp$positions === void 0 ? void 0 : _colorRamp$positions.join('_'), "_").concat(colorRamp.type, "_").concat(domain === null || domain === void 0 ? void 0 : domain.join('_'));
71
+ return "".concat(colorRamp.colors.join('_'), "_").concat(colorRamp === null || colorRamp === void 0 || (_colorRamp$positions = colorRamp.positions) === null || _colorRamp$positions === void 0 ? void 0 : _colorRamp$positions.join('_'), "_").concat(colorRamp.type, "_").concat(domain === null || domain === void 0 ? void 0 : domain.join('_'));
72
72
  }
73
73
  }]);
74
74
  return TextureService;
@@ -5,12 +5,6 @@ export declare enum lineStyleType {
5
5
  'solid' = 0,
6
6
  'dash' = 1
7
7
  }
8
- interface ILineArrow {
9
- enable: boolean;
10
- arrowWidth: number;
11
- arrowHeight: number;
12
- tailWidth: number;
13
- }
14
8
  export declare enum LinearDir {
15
9
  VERTICAL = "vertical",
16
10
  HORIZONTAL = "horizontal"
@@ -31,7 +25,6 @@ export interface IBaseLayerStyleOptions {
31
25
  zIndex?: number;
32
26
  mask?: boolean;
33
27
  maskInside?: boolean;
34
- usage?: string;
35
28
  color?: string;
36
29
  size?: number;
37
30
  }
@@ -57,7 +50,7 @@ export interface ILineLayerStyleOptions extends IBaseLayerStyleOptions {
57
50
  strokeWidth?: number;
58
51
  storke?: string;
59
52
  blur?: [number, number, number];
60
- arrow?: ILineArrow;
53
+ symbol?: ILineSymbol;
61
54
  rampColors?: IColorRamp;
62
55
  featureId?: string;
63
56
  sourceLayer?: string;
@@ -233,15 +226,26 @@ export interface IRasterTerrainLayerStyleOptions extends IBaseRasterLayerStyleOp
233
226
  bScaler?: number;
234
227
  offset?: number;
235
228
  }
229
+ export type ArrowType = 'circle' | 'triangle' | 'rect' | 'diamond' | 'classic' | 'halfTriangle' | 'none';
230
+ export interface IArrowOptions {
231
+ type: ArrowType;
232
+ width?: number;
233
+ height?: number;
234
+ radius?: number;
235
+ }
236
+ export interface ILineSymbol {
237
+ source: ArrowType | IArrowOptions;
238
+ target: ArrowType | IArrowOptions;
239
+ }
236
240
  export interface IFlowLineStyleOptions extends IBaseLayerStyleOptions {
237
241
  gapWidth?: number;
238
242
  offsets?: [number, number];
239
243
  stroke?: string;
240
244
  strokeOpacity?: number;
241
245
  strokeWidth?: number;
246
+ symbol?: ILineSymbol;
242
247
  }
243
248
  export interface IStyleEncodeAttributeOptions {
244
249
  field: StyleAttributeField;
245
250
  values?: StyleAttributeOption;
246
251
  }
247
- export {};
@@ -0,0 +1,19 @@
1
+ import { IEncodeFeature } from '@antv/l7-core';
2
+ export declare function FlowHalfArrowFillTriangulation(feature: IEncodeFeature): {
3
+ vertices: number[];
4
+ normals: number[];
5
+ indices: number[];
6
+ size: number;
7
+ };
8
+ export declare function FlowLineTriangulation(feature: IEncodeFeature, symbolOption?: unknown): {
9
+ vertices: number[];
10
+ normals: number[];
11
+ indices: number[];
12
+ size: number;
13
+ };
14
+ export declare function ArrowLineTriangulation(feature: IEncodeFeature, symbolOption?: unknown): {
15
+ vertices: number[];
16
+ indices: number[];
17
+ normals: number[];
18
+ size: number;
19
+ };
@@ -0,0 +1,91 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import { getSymbol, lineArrowPath } from "./shape/arrow";
4
+
5
+ // list all arrow shape
6
+
7
+ // Half Edge
8
+ export function FlowHalfArrowFillTriangulation(feature) {
9
+ // @ts-ignore
10
+ var coord = feature.coordinates.flat();
11
+ var tin = 1;
12
+ var tout = 1.0;
13
+ return {
14
+ vertices: [1, 0, 0].concat(_toConsumableArray(coord), [
15
+ // 0
16
+ 1, 2, -3], _toConsumableArray(coord), [
17
+ // 1
18
+ 1, 1, -3], _toConsumableArray(coord), [
19
+ // 2
20
+ 0, 1, 0], _toConsumableArray(coord), [
21
+ // 3
22
+ 0, 0, 0], _toConsumableArray(coord), [
23
+ // 4
24
+ 1, 0, 0], _toConsumableArray(coord), [
25
+ // 0
26
+ 1, 2, -3], _toConsumableArray(coord), [
27
+ // 1
28
+ 1, 1, -3], _toConsumableArray(coord), [
29
+ // 2
30
+ 0, 1, 0], _toConsumableArray(coord), [
31
+ // 3
32
+ 0, 0, 0], _toConsumableArray(coord)),
33
+ normals: [-tin, 2 * tout, 1,
34
+ // 0
35
+ 2 * tout, -tout, 1,
36
+ // 1
37
+ tout, -tout, 1,
38
+ // 2
39
+ tout, -tout, 1,
40
+ // 3
41
+ -tin, -tout, 1,
42
+ // 4
43
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
44
+ indices: [0, 1, 2, 0, 2, 3, 0, 3, 4, 5, 6, 7, 5, 7, 8, 5, 8, 9],
45
+ size: 7
46
+ };
47
+ }
48
+ export function FlowLineTriangulation(feature, symbolOption) {
49
+ return symbolOption ? ArrowLineTriangulation(feature, symbolOption) : FlowHalfArrowFillTriangulation(feature);
50
+ }
51
+ export function ArrowLineTriangulation(feature, symbolOption) {
52
+ // @ts-ignore
53
+ var coord = feature.coordinates.flat();
54
+ var _ref = symbolOption,
55
+ _ref$target = _ref.target,
56
+ target = _ref$target === void 0 ? 'classic' : _ref$target,
57
+ _ref$source = _ref.source,
58
+ source = _ref$source === void 0 ? 'circle' : _ref$source;
59
+ var startSymbol = shape2Vertices(getSymbol(source, 'source'), coord, 0, 0);
60
+ var linePath = lineArrowPath(coord, startSymbol.vertices.length / 7, symbolOption);
61
+ var endSymbol = shape2Vertices(getSymbol(target, 'target'), coord, 1, startSymbol.vertices.length / 7 + linePath.vertices.length / 7);
62
+ var data = {
63
+ vertices: [].concat(_toConsumableArray(startSymbol.vertices), _toConsumableArray(linePath.vertices), _toConsumableArray(endSymbol.vertices)),
64
+ indices: [].concat(_toConsumableArray(startSymbol.outLineIndices), _toConsumableArray(linePath.outLineIndices), _toConsumableArray(endSymbol.outLineIndices), _toConsumableArray(startSymbol.indices), _toConsumableArray(linePath.indices), _toConsumableArray(endSymbol.indices)),
65
+ normals: [].concat(_toConsumableArray(startSymbol.normals), _toConsumableArray(linePath.normals), _toConsumableArray(endSymbol.normals)),
66
+ size: 7
67
+ };
68
+ return data;
69
+ }
70
+ // start 0,end 1;
71
+ function shape2Vertices(shape, coord) {
72
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
73
+ var indexOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
74
+ var shapeVertices = [];
75
+ var vertices = shape.vertices,
76
+ indices = shape.indices,
77
+ dimensions = shape.dimensions,
78
+ outLineIndices = shape.outLineIndices;
79
+ for (var i = 0; i < vertices.length; i += dimensions) {
80
+ shapeVertices.push.apply(shapeVertices, [type, vertices[i + 1], vertices[i]].concat(_toConsumableArray(coord)));
81
+ }
82
+ return _objectSpread(_objectSpread({}, shape), {}, {
83
+ vertices: shapeVertices,
84
+ indices: indices.map(function (i) {
85
+ return i + indexOffset;
86
+ }),
87
+ outLineIndices: outLineIndices.map(function (i) {
88
+ return i + indexOffset;
89
+ })
90
+ });
91
+ }
@@ -0,0 +1,25 @@
1
+ import { ArrowType, IArrowOptions, ILineSymbol } from '../interface';
2
+ export interface IArrowData {
3
+ vertices: number[];
4
+ indices: number[];
5
+ outLineIndices: number[];
6
+ dimensions: number;
7
+ offset?: number[];
8
+ normals: number[];
9
+ }
10
+ export type arrowPosition = -1 | 1;
11
+ export declare function halfTriangleArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
12
+ export declare function triangleArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
13
+ export declare function rectArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
14
+ export declare function diamondArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
15
+ export declare function classicArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
16
+ export declare function circleArraw(dir: arrowPosition, options: IArrowOptions): IArrowData;
17
+ export declare function lineArrowPath(coord: number[], indexOffset: number | undefined, symbol: ILineSymbol): IArrowData;
18
+ export declare function getSymbol(type: ArrowType | IArrowOptions, position: 'source' | 'target'): IArrowData | {
19
+ vertices: never[];
20
+ indices: never[];
21
+ normals: never[];
22
+ dimensions: number;
23
+ outLineIndices: never[];
24
+ outLineNormals: never[];
25
+ };