@antv/l7-layers 2.19.9 → 2.19.11

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 (89) hide show
  1. package/es/core/BaseLayer.d.ts +0 -2
  2. package/es/core/BaseLayer.js +19 -38
  3. package/es/core/BaseModel.js +4 -19
  4. package/es/core/CommonStyleAttribute.js +20 -0
  5. package/es/core/constant.d.ts +6 -0
  6. package/es/core/constant.js +19 -0
  7. package/es/core/interface.d.ts +15 -9
  8. package/es/core/line_trangluation.d.ts +19 -0
  9. package/es/core/line_trangluation.js +91 -0
  10. package/es/core/shape/arrow.d.ts +25 -0
  11. package/es/core/shape/arrow.js +160 -0
  12. package/es/core/triangulation.d.ts +2 -8
  13. package/es/core/triangulation.js +6 -34
  14. package/es/geometry/models/plane.js +1 -2
  15. package/es/geometry/models/sprite.js +1 -2
  16. package/es/line/index.js +3 -2
  17. package/es/line/models/arc.js +13 -14
  18. package/es/line/models/arc_3d.js +5 -3
  19. package/es/line/models/earthArc_3d.js +5 -3
  20. package/es/line/models/flow.js +4 -5
  21. package/es/line/models/great_circle.js +6 -7
  22. package/es/line/models/line.js +9 -24
  23. package/es/line/models/linearline.js +5 -4
  24. package/es/line/models/simpleLine.js +6 -5
  25. package/es/line/models/wall.js +4 -5
  26. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -4
  27. package/es/line/shaders/dash/arc_dash_vert.glsl +3 -8
  28. package/es/line/shaders/dash/line_dash_frag.glsl +0 -1
  29. package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
  30. package/es/line/shaders/line_arc_3d_frag.glsl +2 -4
  31. package/es/line/shaders/line_arc_3d_vert.glsl +2 -1
  32. package/es/line/shaders/line_arc_frag.glsl +1 -4
  33. package/es/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  34. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  35. package/es/line/shaders/line_arc_vert.glsl +3 -5
  36. package/es/line/shaders/line_frag.glsl +12 -12
  37. package/es/line/shaders/line_vert.glsl +2 -0
  38. package/es/line/shaders/linear/arc_linear_vert.glsl +3 -5
  39. package/es/line/shaders/linear/line_linear_frag.glsl +0 -1
  40. package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  41. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  42. package/es/line/shaders/simple/simpleline_vert.glsl +1 -2
  43. package/es/plugins/DataMappingPlugin.js +5 -23
  44. package/es/polygon/models/ocean.js +1 -2
  45. package/es/polygon/models/water.js +1 -2
  46. package/es/tile/tile/Tile.d.ts +0 -1
  47. package/lib/core/BaseLayer.js +19 -38
  48. package/lib/core/BaseModel.js +4 -19
  49. package/lib/core/CommonStyleAttribute.js +20 -0
  50. package/lib/core/constant.js +27 -0
  51. package/lib/core/line_trangluation.js +99 -0
  52. package/lib/core/shape/arrow.js +174 -0
  53. package/lib/core/triangulation.js +6 -35
  54. package/lib/geometry/models/plane.js +1 -2
  55. package/lib/geometry/models/sprite.js +1 -2
  56. package/lib/line/index.js +3 -2
  57. package/lib/line/models/arc.js +13 -14
  58. package/lib/line/models/arc_3d.js +5 -3
  59. package/lib/line/models/earthArc_3d.js +5 -3
  60. package/lib/line/models/flow.js +4 -5
  61. package/lib/line/models/great_circle.js +6 -7
  62. package/lib/line/models/line.js +9 -24
  63. package/lib/line/models/linearline.js +5 -4
  64. package/lib/line/models/simpleLine.js +6 -5
  65. package/lib/line/models/wall.js +4 -5
  66. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -4
  67. package/lib/line/shaders/dash/arc_dash_vert.glsl +3 -8
  68. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -1
  69. package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
  70. package/lib/line/shaders/line_arc_3d_frag.glsl +2 -4
  71. package/lib/line/shaders/line_arc_3d_vert.glsl +2 -1
  72. package/lib/line/shaders/line_arc_frag.glsl +1 -4
  73. package/lib/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  74. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  75. package/lib/line/shaders/line_arc_vert.glsl +3 -5
  76. package/lib/line/shaders/line_frag.glsl +12 -12
  77. package/lib/line/shaders/line_vert.glsl +2 -0
  78. package/lib/line/shaders/linear/arc_linear_vert.glsl +3 -5
  79. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -1
  80. package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  81. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  82. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -2
  83. package/lib/plugins/DataMappingPlugin.js +5 -23
  84. package/lib/polygon/models/ocean.js +1 -2
  85. package/lib/polygon/models/water.js +1 -2
  86. package/package.json +7 -7
  87. package/es/utils/layerData.d.ts +0 -2
  88. package/es/utils/layerData.js +0 -159
  89. package/lib/utils/layerData.js +0 -166
@@ -10,9 +10,7 @@ varying vec4 v_color;
10
10
  varying float v_segmentIndex;
11
11
 
12
12
  uniform float u_lineDir: 1.0;
13
- uniform float u_opacity: 1.0;
14
13
 
15
- uniform float u_thetaOffset: 0.314;
16
14
  uniform vec4 u_sourceColor;
17
15
  uniform vec4 u_targetColor;
18
16
 
@@ -81,8 +79,8 @@ void main() {
81
79
  float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
82
80
  float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
83
81
  float d_distance_ratio;
84
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
85
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
82
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
83
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
86
84
  // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
87
85
  //unProjCustomCoord
88
86
 
@@ -92,7 +90,7 @@ void main() {
92
90
  float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
93
91
 
94
92
  v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
95
- v_color.a *= u_opacity;
93
+ v_color.a *= opacity;
96
94
 
97
95
  gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
98
96
 
@@ -4,7 +4,6 @@ uniform float u_linearDir: 1.0;
4
4
  uniform float u_linearColor: 0;
5
5
  uniform vec4 u_sourceColor;
6
6
  uniform vec4 u_targetColor;
7
- uniform float u_opacity: 1.0;
8
7
 
9
8
  #pragma include "picking"
10
9
 
@@ -14,7 +14,6 @@ uniform mat4 u_ModelMatrix;
14
14
  uniform float u_heightfixed: 0.0;
15
15
  uniform float u_vertexScale: 1.0;
16
16
  uniform float u_raisingHeight: 0.0;
17
- uniform float u_opacity : 1.0;
18
17
  uniform sampler2D u_texture;
19
18
  uniform float u_linearDir: 1.0;
20
19
  varying vec4 v_Color;
@@ -46,7 +45,7 @@ void main() {
46
45
 
47
46
  v_Color = texture2D(u_texture, vec2(linearRadio, 0.5));
48
47
 
49
- v_Color.a *= u_opacity; // 全局透明度
48
+ v_Color.a *= opacity; // 全局透明度
50
49
 
51
50
 
52
51
 
@@ -1,8 +1,8 @@
1
1
  uniform vec4 u_sourceColor;
2
2
  uniform vec4 u_targetColor;
3
3
  varying float v_distanceScale;
4
- uniform float u_opacity: 1.0;
4
+ varying vec4 v_color;
5
5
  void main() {
6
6
  gl_FragColor = mix(u_sourceColor, u_targetColor, v_distanceScale);
7
- gl_FragColor.a *= u_opacity; // 全局透明度
7
+ gl_FragColor.a *= v_color.a; // 全局透明度
8
8
  }
@@ -8,7 +8,6 @@ attribute float a_Distance;
8
8
  uniform mat4 u_ModelMatrix;
9
9
 
10
10
 
11
- uniform float u_opacity: 1.0;
12
11
  uniform float u_vertexScale: 1.0;
13
12
  uniform vec4 u_sourceColor;
14
13
  uniform vec4 u_targetColor;
@@ -24,7 +23,7 @@ void main() {
24
23
 
25
24
  v_color = a_Color;
26
25
  v_distanceScale = a_Distance / a_Total_Distance;
27
- v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
26
+ v_color.a = v_color.a * opacity;
28
27
  vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
29
28
 
30
29
  float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况
@@ -9,7 +9,6 @@ import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWar
9
9
  var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
10
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
11
  import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
12
- import { Version } from '@antv/l7-maps';
13
12
  import { lodashUtil, normalize, rgb2arr } from '@antv/l7-utils';
14
13
  import { inject, injectable } from 'inversify';
15
14
  import 'reflect-metadata';
@@ -141,11 +140,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
141
140
  key: "mapping",
142
141
  value: function mapping(layer, attributes, data, predata) {
143
142
  var _this3 = this;
144
- var _ref5 = layer.getLayerConfig(),
145
- _ref5$arrow = _ref5.arrow,
146
- arrow = _ref5$arrow === void 0 ? {
147
- enable: false
148
- } : _ref5$arrow;
149
143
  var usedAttributes = attributes.filter(function (attribute) {
150
144
  return attribute.scale !== undefined;
151
145
  }).filter(function (attribute) {
@@ -173,18 +167,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
173
167
  encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
174
168
  }
175
169
  });
176
- if (arrow.enable && encodeRecord.shape === 'line') {
177
- // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
178
- var coords = encodeRecord.coordinates;
179
- // @ts-ignore
180
- if (layer.arrowInsertCount < layer.encodeDataLength) {
181
- // Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
182
- var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
183
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
184
- // @ts-ignore
185
- layer.arrowInsertCount++;
186
- }
187
- }
188
170
  return encodeRecord;
189
171
  });
190
172
  attributes.forEach(function (attribute) {
@@ -202,7 +184,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
202
184
  value: function adjustData2Amap2Coordinates(mappedData, layer) {
203
185
  var _this4 = this;
204
186
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
205
- if (mappedData.length > 0 && this.mapService.version === Version['GAODE2.x']) {
187
+ if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {
206
188
  var layerCenter = layer.coordCenter || layer.getSource().center;
207
189
  // 单个的点数据
208
190
  // @ts-ignore
@@ -211,7 +193,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
211
193
  .filter(function (d) {
212
194
  return !d.originCoordinates;
213
195
  }).map(function (d) {
214
- d.version = Version['GAODE2.x'];
196
+ d.version = 'GAODE2.x';
215
197
  // @ts-ignore
216
198
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
217
199
  // @ts-ignore
@@ -224,7 +206,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
224
206
  key: "adjustData2SimpleCoordinates",
225
207
  value: function adjustData2SimpleCoordinates(mappedData) {
226
208
  var _this5 = this;
227
- if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
209
+ if (mappedData.length > 0 && this.mapService.version === 'SIMPLE') {
228
210
  mappedData.map(function (d) {
229
211
  if (!d.simpleCoordinate) {
230
212
  d.coordinates = _this5.unProjectCoordinates(d.coordinates);
@@ -274,9 +256,9 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
274
256
  }
275
257
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
276
258
  var params = [];
277
- scalers.forEach(function (_ref6) {
259
+ scalers.forEach(function (_ref5) {
278
260
  var _attribute$scale2;
279
- var field = _ref6.field;
261
+ var field = _ref5.field;
280
262
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
281
263
  // TODO:多字段,常量
282
264
  params.push(record[field]);
@@ -9,7 +9,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
- import { Version } from '@antv/l7-maps';
13
12
  import { lodashUtil, rgb2arr } from '@antv/l7-utils';
14
13
  import BaseModel from "../../core/BaseModel";
15
14
  import { polygonTriangulation } from "../../core/triangulation";
@@ -136,7 +135,7 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
136
135
  },
137
136
  size: 2,
138
137
  update: function update(feature, featureIdx, vertex, attributeIdx) {
139
- var v = feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex;
138
+ var v = feature.version === 'GAODE2.x' ? feature.originCoordinates[0][attributeIdx] : vertex;
140
139
  var _v = _slicedToArray(v, 2),
141
140
  lng = _v[0],
142
141
  lat = _v[1];
@@ -9,7 +9,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
- import { Version } from '@antv/l7-maps';
13
12
  import { lodashUtil } from '@antv/l7-utils';
14
13
  import BaseModel from "../../core/BaseModel";
15
14
  import { polygonTriangulation } from "../../core/triangulation";
@@ -129,7 +128,7 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
129
128
  },
130
129
  size: 2,
131
130
  update: function update(feature, featureIdx, vertex, attributeIdx) {
132
- var v = feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex;
131
+ var v = feature.version === 'GAODE2.x' ? feature.originCoordinates[0][attributeIdx] : vertex;
133
132
  var _v = _slicedToArray(v, 2),
134
133
  lng = _v[0],
135
134
  lat = _v[1];
@@ -58,7 +58,6 @@ export default abstract class Tile extends EventEmitter implements ITile {
58
58
  cursorEnabled?: boolean | undefined;
59
59
  cursor?: string | undefined;
60
60
  forward?: boolean | undefined;
61
- usage?: string | undefined;
62
61
  enableMask?: boolean | undefined;
63
62
  enablePicking?: boolean | undefined;
64
63
  enableHighlight?: boolean | undefined;
@@ -26,12 +26,11 @@ var _l7Source = _interopRequireDefault(require("@antv/l7-source"));
26
26
  var _l7Utils = require("@antv/l7-utils");
27
27
  var _eventemitter = require("eventemitter3");
28
28
  var _blend = require("../utils/blend");
29
- var _layerData = require("../utils/layerData");
30
29
  var _multiPassRender = require("../utils/multiPassRender");
31
30
  var _LayerPickService = _interopRequireDefault(require("./LayerPickService"));
32
31
  var _TextureService = _interopRequireDefault(require("./TextureService"));
33
32
  var _excluded = ["passes"],
34
- _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "segmentNumber"];
33
+ _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption"];
35
34
  var _dec, _class, _descriptor; // @ts-ignore
36
35
  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; } } }; }
37
36
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -395,40 +394,11 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
395
394
  console.warn('data error');
396
395
  }
397
396
  }
398
- }, {
399
- key: "createModelData",
400
- value: function createModelData(data, option) {
401
- var _this$layerModel;
402
- if ((_this$layerModel = this.layerModel) !== null && _this$layerModel !== void 0 && _this$layerModel.createModelData) {
403
- // 在某些特殊图层中单独构建 attribute & elements
404
- return this.layerModel.createModelData(option);
405
- }
406
- var calEncodeData = this.calculateEncodeData(data, option);
407
- var triangulation = this.triangulation;
408
- if (calEncodeData && triangulation) {
409
- return this.styleAttributeService.createAttributesAndIndices(calEncodeData, triangulation);
410
- } else {
411
- return {
412
- attributes: undefined,
413
- elements: undefined
414
- };
415
- }
416
- }
417
397
  }, {
418
398
  key: "setLayerPickService",
419
399
  value: function setLayerPickService(layerPickService) {
420
400
  this.layerPickService = layerPickService;
421
401
  }
422
- }, {
423
- key: "calculateEncodeData",
424
- value: function calculateEncodeData(data, option) {
425
- if (this.inited) {
426
- return (0, _layerData.calculateData)(this, this.fontService, this.mapService, this.styleAttributeService, data, option);
427
- } else {
428
- console.warn('layer not inited!');
429
- return null;
430
- }
431
- }
432
402
  /**
433
403
  * Model初始化前需要更新Model样式
434
404
  */
@@ -574,6 +544,17 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
574
544
  }
575
545
  });
576
546
  }
547
+ // 兼容 borderColor borderWidth
548
+ // @ts-ignore
549
+ if (rest.borderColor) {
550
+ // @ts-ignore
551
+ rest.stroke = rest.borderColor;
552
+ }
553
+ // @ts-ignore
554
+ if (rest.borderWidth) {
555
+ // @ts-ignore
556
+ rest.strokeWidth = rest.borderWidth;
557
+ }
577
558
 
578
559
  // 兼容老版本的写法 ['field, 'value']
579
560
  var newOption = rest;
@@ -971,7 +952,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
971
952
  }, {
972
953
  key: "destroy",
973
954
  value: function destroy() {
974
- var _this$multiPassRender, _this$layerModel2, _this$tileLayer, _this$debugService2;
955
+ var _this$multiPassRender, _this$layerModel, _this$tileLayer, _this$debugService2;
975
956
  var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
976
957
  if (this.isDestroyed) {
977
958
  return;
@@ -1004,7 +985,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1004
985
 
1005
986
  this.hooks.afterDestroy.call();
1006
987
  // Tip: 清除各个图层自定义的 models 资源
1007
- (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 ? void 0 : _this$layerModel2.clearModels(refresh);
988
+ (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 ? void 0 : _this$layerModel.clearModels(refresh);
1008
989
  (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 ? void 0 : _this$tileLayer.destroy();
1009
990
  this.models = [];
1010
991
  // 清除图层日志(如果有的话:非瓦片相关)
@@ -1031,11 +1012,11 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1031
1012
  }, {
1032
1013
  key: "clearModels",
1033
1014
  value: function clearModels() {
1034
- var _this$layerModel3;
1015
+ var _this$layerModel2;
1035
1016
  this.models.forEach(function (model) {
1036
1017
  return model.destroy();
1037
1018
  });
1038
- (_this$layerModel3 = this.layerModel) === null || _this$layerModel3 === void 0 ? void 0 : _this$layerModel3.clearModels();
1019
+ (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 ? void 0 : _this$layerModel2.clearModels();
1039
1020
  this.models = [];
1040
1021
  }
1041
1022
  }, {
@@ -1182,11 +1163,11 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1182
1163
  value: function () {
1183
1164
  var _buildLayerModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options) {
1184
1165
  var _this10 = this;
1185
- 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;
1186
1167
  return _regenerator.default.wrap(function _callee3$(_context3) {
1187
1168
  while (1) switch (_context3.prev = _context3.next) {
1188
1169
  case 0:
1189
- moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, segmentNumber = options.segmentNumber, rest = (0, _objectWithoutProperties2.default)(options, _excluded2);
1170
+ moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, rest = (0, _objectWithoutProperties2.default)(options, _excluded2);
1190
1171
  this.shaderModuleService.registerModule(moduleName, {
1191
1172
  vs: vertexShader,
1192
1173
  fs: fragmentShader,
@@ -1196,7 +1177,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1196
1177
  createModel = this.rendererService.createModel;
1197
1178
  return _context3.abrupt("return", new Promise(function (resolve) {
1198
1179
  // console.log(this.encodedData)
1199
- var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, segmentNumber),
1180
+ var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, styleOption),
1200
1181
  attributes = _this10$styleAttribut.attributes,
1201
1182
  elements = _this10$styleAttribut.elements,
1202
1183
  count = _this10$styleAttribut.count;
@@ -19,6 +19,7 @@ var _l7Utils = require("@antv/l7-utils");
19
19
  var _blend = require("../utils/blend");
20
20
  var _stencil = require("../utils/stencil");
21
21
  var _CommonStyleAttribute = require("./CommonStyleAttribute");
22
+ var _constant = require("./constant");
22
23
  var _dec, _class, _descriptor;
23
24
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
25
  var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigService), (_class = /*#__PURE__*/function () {
@@ -214,23 +215,15 @@ var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
214
215
  value: function getInject() {
215
216
  var encodeStyleAttribute = this.layer.encodeStyleAttribute;
216
217
  var str = '';
217
- var attrType = {
218
- opacity: 'float',
219
- stroke: 'vec4',
220
- offsets: 'vec2',
221
- textOffset: 'vec2',
222
- rotation: 'float',
223
- extrusionBase: 'float'
224
- };
225
218
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
226
219
  if (encodeStyleAttribute[key]) {
227
220
  str += "#define USE_ATTRIBUTE_".concat(key.toUpperCase(), " 0.0; \n\n");
228
221
  }
229
- str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n attribute ").concat(attrType[key], " a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n #else\n uniform ").concat(attrType[key], " u_").concat(key, ";\n #endif\n\n ");
222
+ str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n attribute ").concat(_constant.DefaultUniformStyleType[key], " a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n #else\n uniform ").concat(_constant.DefaultUniformStyleType[key], " u_").concat(key, ";\n #endif\n\n ");
230
223
  });
231
224
  var innerStr = '';
232
225
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
233
- innerStr += "\n\n#ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(attrType[key], " ").concat(key, " = a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n#else\n ").concat(attrType[key], " ").concat(key, " = u_").concat(key, ";\n#endif\n\n");
226
+ innerStr += "\n\n#ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(_constant.DefaultUniformStyleType[key], " ").concat(key, " = a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n#else\n ").concat(_constant.DefaultUniformStyleType[key], " ").concat(key, " = u_").concat(key, ";\n#endif\n\n");
234
227
  });
235
228
  return {
236
229
  'vs:#decl': str,
@@ -245,20 +238,12 @@ var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
245
238
  var _this = this;
246
239
  var options = {};
247
240
  // TODO: 优化
248
-
249
- var defualtValue = {
250
- opacity: 1,
251
- stroke: [1, 0, 0, 1],
252
- offsets: [0, 0],
253
- rotation: 0,
254
- extrusionBase: 0
255
- };
256
241
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
257
242
  if (!_this.layer.encodeStyleAttribute[key]) {
258
243
  // 没有设置样式映射
259
244
  // @ts-ignore
260
245
  var keyValue = _this.layer.getLayerConfig()[key];
261
- var value = typeof keyValue === 'undefined' ? defualtValue[key] : keyValue;
246
+ var value = typeof keyValue === 'undefined' ? _constant.DefaultUniformStyleValue[key] : keyValue;
262
247
  if (key === 'stroke') {
263
248
  value = (0, _l7Utils.rgb2arr)(value);
264
249
  }
@@ -106,6 +106,26 @@ function getCommonStyleAttributeOptions(name) {
106
106
  }
107
107
  }
108
108
  };
109
+ case 'thetaOffset':
110
+ return {
111
+ name: 'thetaOffset',
112
+ type: _l7Core.AttributeType.Attribute,
113
+ descriptor: {
114
+ name: 'a_ThetaOffset',
115
+ buffer: {
116
+ // give the WebGL driver a hint that this buffer may change
117
+ usage: _l7Core.gl.STATIC_DRAW,
118
+ data: [],
119
+ type: _l7Core.gl.FLOAT
120
+ },
121
+ size: 1,
122
+ update: function update(feature) {
123
+ var _feature$thetaOffset = feature.thetaOffset,
124
+ op = _feature$thetaOffset === void 0 ? 1 : _feature$thetaOffset;
125
+ return [op];
126
+ }
127
+ }
128
+ };
109
129
  default:
110
130
  return undefined;
111
131
  }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DefaultUniformStyleValue = exports.DefaultUniformStyleType = void 0;
7
+ var DefaultUniformStyleValue = {
8
+ opacity: 1,
9
+ stroke: [1, 0, 0, 1],
10
+ offsets: [0, 0],
11
+ rotation: 0,
12
+ extrusionBase: 0,
13
+ strokeOpacity: 1,
14
+ thetaOffset: 0.314
15
+ };
16
+ exports.DefaultUniformStyleValue = DefaultUniformStyleValue;
17
+ var DefaultUniformStyleType = {
18
+ opacity: 'float',
19
+ stroke: 'vec4',
20
+ offsets: 'vec2',
21
+ textOffset: 'vec2',
22
+ rotation: 'float',
23
+ extrusionBase: 'float',
24
+ strokeOpacity: 'float',
25
+ thetaOffset: 'float'
26
+ };
27
+ exports.DefaultUniformStyleType = DefaultUniformStyleType;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ArrowLineTriangulation = ArrowLineTriangulation;
8
+ exports.FlowHalfArrowFillTriangulation = FlowHalfArrowFillTriangulation;
9
+ exports.FlowLineTriangulation = FlowLineTriangulation;
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+ var _arrow = require("./shape/arrow");
13
+ // list all arrow shape
14
+
15
+ // Half Edge
16
+ function FlowHalfArrowFillTriangulation(feature) {
17
+ // @ts-ignore
18
+ var coord = feature.coordinates.flat();
19
+ var tin = 1;
20
+ var tout = 1.0;
21
+ return {
22
+ vertices: [1, 0, 0].concat((0, _toConsumableArray2.default)(coord), [
23
+ // 0
24
+ 1, 2, -3], (0, _toConsumableArray2.default)(coord), [
25
+ // 1
26
+ 1, 1, -3], (0, _toConsumableArray2.default)(coord), [
27
+ // 2
28
+ 0, 1, 0], (0, _toConsumableArray2.default)(coord), [
29
+ // 3
30
+ 0, 0, 0], (0, _toConsumableArray2.default)(coord), [
31
+ // 4
32
+ 1, 0, 0], (0, _toConsumableArray2.default)(coord), [
33
+ // 0
34
+ 1, 2, -3], (0, _toConsumableArray2.default)(coord), [
35
+ // 1
36
+ 1, 1, -3], (0, _toConsumableArray2.default)(coord), [
37
+ // 2
38
+ 0, 1, 0], (0, _toConsumableArray2.default)(coord), [
39
+ // 3
40
+ 0, 0, 0], (0, _toConsumableArray2.default)(coord)),
41
+ normals: [-tin, 2 * tout, 1,
42
+ // 0
43
+ 2 * tout, -tout, 1,
44
+ // 1
45
+ tout, -tout, 1,
46
+ // 2
47
+ tout, -tout, 1,
48
+ // 3
49
+ -tin, -tout, 1,
50
+ // 4
51
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
52
+ indices: [0, 1, 2, 0, 2, 3, 0, 3, 4, 5, 6, 7, 5, 7, 8, 5, 8, 9],
53
+ size: 7
54
+ };
55
+ }
56
+ function FlowLineTriangulation(feature, symbolOption) {
57
+ return symbolOption ? ArrowLineTriangulation(feature, symbolOption) : FlowHalfArrowFillTriangulation(feature);
58
+ }
59
+ function ArrowLineTriangulation(feature, symbolOption) {
60
+ // @ts-ignore
61
+ var coord = feature.coordinates.flat();
62
+ var _ref = symbolOption,
63
+ _ref$target = _ref.target,
64
+ target = _ref$target === void 0 ? 'classic' : _ref$target,
65
+ _ref$source = _ref.source,
66
+ source = _ref$source === void 0 ? 'circle' : _ref$source;
67
+ var startSymbol = shape2Vertices((0, _arrow.getSymbol)(source, 'source'), coord, 0, 0);
68
+ var linePath = (0, _arrow.lineArrowPath)(coord, startSymbol.vertices.length / 7, symbolOption);
69
+ var endSymbol = shape2Vertices((0, _arrow.getSymbol)(target, 'target'), coord, 1, startSymbol.vertices.length / 7 + linePath.vertices.length / 7);
70
+ var data = {
71
+ vertices: [].concat((0, _toConsumableArray2.default)(startSymbol.vertices), (0, _toConsumableArray2.default)(linePath.vertices), (0, _toConsumableArray2.default)(endSymbol.vertices)),
72
+ indices: [].concat((0, _toConsumableArray2.default)(startSymbol.outLineIndices), (0, _toConsumableArray2.default)(linePath.outLineIndices), (0, _toConsumableArray2.default)(endSymbol.outLineIndices), (0, _toConsumableArray2.default)(startSymbol.indices), (0, _toConsumableArray2.default)(linePath.indices), (0, _toConsumableArray2.default)(endSymbol.indices)),
73
+ normals: [].concat((0, _toConsumableArray2.default)(startSymbol.normals), (0, _toConsumableArray2.default)(linePath.normals), (0, _toConsumableArray2.default)(endSymbol.normals)),
74
+ size: 7
75
+ };
76
+ return data;
77
+ }
78
+ // start 0,end 1;
79
+ function shape2Vertices(shape, coord) {
80
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
81
+ var indexOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
82
+ var shapeVertices = [];
83
+ var vertices = shape.vertices,
84
+ indices = shape.indices,
85
+ dimensions = shape.dimensions,
86
+ outLineIndices = shape.outLineIndices;
87
+ for (var i = 0; i < vertices.length; i += dimensions) {
88
+ shapeVertices.push.apply(shapeVertices, [type, vertices[i + 1], vertices[i]].concat((0, _toConsumableArray2.default)(coord)));
89
+ }
90
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shape), {}, {
91
+ vertices: shapeVertices,
92
+ indices: indices.map(function (i) {
93
+ return i + indexOffset;
94
+ }),
95
+ outLineIndices: outLineIndices.map(function (i) {
96
+ return i + indexOffset;
97
+ })
98
+ });
99
+ }