@antv/l7-layers 2.19.10 → 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.
@@ -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; } } }; }
@@ -1157,11 +1157,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1157
1157
  value: function () {
1158
1158
  var _buildLayerModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
1159
1159
  var _this10 = this;
1160
- var moduleName, vertexShader, fragmentShader, inject, triangulation, segmentNumber, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1160
+ var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1161
1161
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1162
1162
  while (1) switch (_context3.prev = _context3.next) {
1163
1163
  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);
1164
+ moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, rest = _objectWithoutProperties(options, _excluded2);
1165
1165
  this.shaderModuleService.registerModule(moduleName, {
1166
1166
  vs: vertexShader,
1167
1167
  fs: fragmentShader,
@@ -1171,7 +1171,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1171
1171
  createModel = this.rendererService.createModel;
1172
1172
  return _context3.abrupt("return", new Promise(function (resolve) {
1173
1173
  // console.log(this.encodedData)
1174
- var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, segmentNumber),
1174
+ var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, styleOption),
1175
1175
  attributes = _this10$styleAttribut.attributes,
1176
1176
  elements = _this10$styleAttribut.elements,
1177
1177
  count = _this10$styleAttribut.count;
@@ -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
+ };
@@ -0,0 +1,160 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import { circle } from "./Path";
4
+ import earcut from 'earcut';
5
+ var maxArrowWidthMap = {
6
+ circle: 2,
7
+ triangle: 2,
8
+ diamond: 4,
9
+ rect: 2,
10
+ classic: 3,
11
+ halfTriangle: 2,
12
+ 'none': 0
13
+ };
14
+ var PathHeight = 1 / 2;
15
+ export function halfTriangleArrow(dir, options) {
16
+ var _options$width = options.width,
17
+ width = _options$width === void 0 ? 2 : _options$width,
18
+ _options$height = options.height,
19
+ height = _options$height === void 0 ? 1 : _options$height;
20
+ return {
21
+ vertices: [0, PathHeight * dir, 1 * dir * width, -(height + PathHeight) * dir, 1 * dir * width, (height - PathHeight) * dir, 0, PathHeight * dir, 1 * dir * width, -(height + PathHeight) * dir, 1 * dir * width, (height - PathHeight) * dir],
22
+ indices: [3, 4, 5],
23
+ outLineIndices: [0, 1, 2],
24
+ normals: [1 * dir, -2 * dir, 1,
25
+ // y,x
26
+ -2 * dir, 1.5 * dir, 1, 1 * dir, 1.5 * dir, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
27
+ dimensions: 2
28
+ };
29
+ }
30
+ export function triangleArrow(dir, options) {
31
+ var _options$width2 = options.width,
32
+ width = _options$width2 === void 0 ? 2 : _options$width2,
33
+ _options$height2 = options.height,
34
+ height = _options$height2 === void 0 ? 3 : _options$height2;
35
+ return {
36
+ vertices: [0, 0, 1 * dir * width, 1 * height, 1 * dir * width, -1 * height, 0, 0, 1 * dir * width, 1 * height, 1 * dir * width, -1 * height],
37
+ outLineIndices: [0, 1, 2],
38
+ indices: [3, 4, 5],
39
+ normals: [0, -1.5 * dir, 1, 2, 1 * dir, 1, -2, 1 * dir, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
40
+ dimensions: 2
41
+ };
42
+ }
43
+ export function rectArrow(dir, options) {
44
+ var _options$width3 = options.width,
45
+ width = _options$width3 === void 0 ? 2 : _options$width3,
46
+ _options$height3 = options.height,
47
+ height = _options$height3 === void 0 ? 2 : _options$height3;
48
+ return {
49
+ vertices: [0, height / 2, dir * width * 1, height / 2, dir * width * 1, -height / 2, 0, -height / 2, 0, height / 2, dir * width * 1, height / 2, dir * width * 1, -height / 2, 0, -height / 2],
50
+ dimensions: 2,
51
+ indices: [4, 5, 6, 4, 6, 7],
52
+ outLineIndices: [0, 1, 2, 0, 2, 3],
53
+ normals: [0, -dir, 1, 1, 0, 1, 0, -dir, 1, -1, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
54
+ };
55
+ }
56
+ export function diamondArrow(dir, options) {
57
+ var _options$width4 = options.width,
58
+ width = _options$width4 === void 0 ? 2 : _options$width4,
59
+ _options$height4 = options.height,
60
+ height = _options$height4 === void 0 ? 3 : _options$height4;
61
+ return {
62
+ vertices: [0, 0, 1 * width * dir, 0.5 * height, 2 * width * dir, 0, 1 * width * dir, -0.5 * height, 0, 0, 1 * width * dir, 0.5 * height, 2 * width * dir, 0, 1 * width * dir, -0.5 * height],
63
+ dimensions: 2,
64
+ indices: [4, 5, 6, 4, 6, 7],
65
+ outLineIndices: [0, 1, 2, 0, 2, 3],
66
+ normals: [0, -dir, 1, 1, 0, 1, 0, -dir, 1, -1, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
67
+ };
68
+ }
69
+ export function classicArrow(dir, options) {
70
+ var _options$width5 = options.width,
71
+ width = _options$width5 === void 0 ? 2 : _options$width5,
72
+ _options$height5 = options.height,
73
+ height = _options$height5 === void 0 ? 3 : _options$height5;
74
+ return {
75
+ vertices: [0, 0, 2 * dir * width, 1 * height, 1.5 * dir * width, 0, 2 * dir * width, -1 * height, 0, 0, 2 * dir * width, 1 * height, 1.5 * dir * width, 0, 2 * dir * width, -1 * height],
76
+ dimensions: 2,
77
+ indices: [4, 5, 6, 4, 6, 7],
78
+ outLineIndices: [0, 1, 2, 0, 2, 3],
79
+ normals: [0, -dir, 1, 1, 0, 1, 0, -dir, 1, -1, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
80
+ };
81
+ }
82
+ export function circleArraw(dir, options) {
83
+ var _options$width6 = options.width,
84
+ width = _options$width6 === void 0 ? 2 : _options$width6,
85
+ _options$height6 = options.height,
86
+ height = _options$height6 === void 0 ? 2 : _options$height6;
87
+ var path = circle();
88
+ var flattengeo = earcut.flatten([path]);
89
+ var triangles = earcut(flattengeo.vertices, flattengeo.holes, flattengeo.dimensions);
90
+ // @ts-ignore
91
+ var vertice = path.map(function (t) {
92
+ return [t[0] * width * dir, t[1] * height];
93
+ }).flat();
94
+ return {
95
+ vertices: [].concat(_toConsumableArray(vertice), _toConsumableArray(vertice)),
96
+ dimensions: 2,
97
+ indices: triangles.map(function (v) {
98
+ return v + path.length;
99
+ }),
100
+ outLineIndices: triangles,
101
+ normals: [].concat(_toConsumableArray(path.map(function (t) {
102
+ return [t[1] * height, t[0] * width * dir, 1];
103
+ }).flat()), _toConsumableArray(new Array(path.length * 3).fill(0)))
104
+ };
105
+ }
106
+ export function lineArrowPath(coord) {
107
+ var indexOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
108
+ var symbol = arguments.length > 2 ? arguments[2] : undefined;
109
+ var sourceType = _typeof(symbol['source']) === 'object' ? symbol['source'].type : symbol['source'];
110
+ var targetType = _typeof(symbol['target']) === 'object' ? symbol['target'].type : symbol['target'];
111
+ var _ref = _typeof(symbol['source']) === 'object' ? symbol['source'] : {},
112
+ _ref$width = _ref.width,
113
+ sourceWidth = _ref$width === void 0 ? sourceType ? maxArrowWidthMap[sourceType] : 0 : _ref$width,
114
+ _ref$height = _ref.height,
115
+ sourceHeight = _ref$height === void 0 ? 2 : _ref$height;
116
+ var _ref2 = _typeof(symbol['target']) === 'object' ? symbol['target'] : {},
117
+ _ref2$width = _ref2.width,
118
+ targetWidth = _ref2$width === void 0 ? targetType ? maxArrowWidthMap[targetType] : 0 : _ref2$width,
119
+ _ref2$height = _ref2.height,
120
+ targetHeight = _ref2$height === void 0 ? 2 : _ref2$height;
121
+ return {
122
+ vertices: [0, PathHeight, 1 * sourceWidth].concat(_toConsumableArray(coord), [1, PathHeight, -1 * targetWidth], _toConsumableArray(coord), [1, -PathHeight, -1 * targetWidth], _toConsumableArray(coord), [0, -PathHeight, 1 * sourceWidth], _toConsumableArray(coord), [0, PathHeight, 1 * sourceWidth], _toConsumableArray(coord), [1, PathHeight, -1 * targetWidth], _toConsumableArray(coord), [1, -PathHeight, -1 * targetWidth], _toConsumableArray(coord), [0, -PathHeight, 1 * sourceWidth], _toConsumableArray(coord)),
123
+ outLineIndices: [0, 1, 2, 0, 2, 3].map(function (t) {
124
+ return t + indexOffset;
125
+ }),
126
+ indices: [4, 5, 6, 4, 6, 7].map(function (t) {
127
+ return t + indexOffset;
128
+ }),
129
+ normals: [1, -1, 1, 1, 1, 1, -1, 0, 1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
130
+ dimensions: 2
131
+ };
132
+ }
133
+ export function getSymbol(type, position) {
134
+ var shape = _typeof(type) === 'object' ? type.type : type;
135
+ var dir = position === 'source' ? 1 : -1;
136
+ var option = _typeof(type) === 'object' ? type : {};
137
+ switch (shape) {
138
+ case 'circle':
139
+ return circleArraw(dir, option);
140
+ case 'triangle':
141
+ return triangleArrow(dir, option);
142
+ case 'diamond':
143
+ return diamondArrow(dir, option);
144
+ case 'rect':
145
+ return rectArrow(dir, option);
146
+ case 'classic':
147
+ return classicArrow(dir, option);
148
+ case 'halfTriangle':
149
+ return halfTriangleArrow(dir, option);
150
+ default:
151
+ return {
152
+ vertices: [],
153
+ indices: [],
154
+ normals: [],
155
+ dimensions: 2,
156
+ outLineIndices: [],
157
+ outLineNormals: []
158
+ };
159
+ }
160
+ }
@@ -48,13 +48,7 @@ export declare function LineTriangulation(feature: IEncodeFeature): {
48
48
  size: number;
49
49
  };
50
50
  export declare function FlowLineFillTriangulation(feature: IEncodeFeature): {
51
- vertices: any[];
52
- normals: number[];
53
- indices: number[];
54
- size: number;
55
- };
56
- export declare function FlowLineStrokeTriangulation(feature: IEncodeFeature): {
57
- vertices: any[];
51
+ vertices: number[];
58
52
  normals: number[];
59
53
  indices: number[];
60
54
  size: number;
@@ -107,7 +101,7 @@ export declare function RasterImageTriangulation(feature: IEncodeFeature): {
107
101
  * @param feature 映射数据
108
102
  * @param segNum 弧线线段数
109
103
  */
110
- export declare function LineArcTriangulation(feature: IEncodeFeature, segmentNumber?: number): {
104
+ export declare function LineArcTriangulation(feature: IEncodeFeature, styleOption?: unknown): {
111
105
  vertices: number[];
112
106
  indices: number[];
113
107
  size: number;
@@ -161,36 +161,6 @@ export function FlowLineFillTriangulation(feature) {
161
161
  size: 7
162
162
  };
163
163
  }
164
- export function FlowLineStrokeTriangulation(feature) {
165
- // @ts-ignore
166
- var coord = feature.coordinates.flat();
167
- var tin = 1;
168
- var tout = 1;
169
- return {
170
- vertices: [1, 0, 0].concat(_toConsumableArray(coord), [
171
- // 0
172
- 1, 2, -3], _toConsumableArray(coord), [
173
- // 1
174
- 1, 1, -3], _toConsumableArray(coord), [
175
- // 2
176
- 0, 1, 0], _toConsumableArray(coord), [
177
- // 3
178
- 0, 0, 0], _toConsumableArray(coord)),
179
- normals: [-tin, 2 * tout, 1,
180
- // 0
181
- 2 * tout, -tout, 1,
182
- // 1
183
- tout, -tout, 1,
184
- // 2
185
- tout, -tout, 1,
186
- // 3
187
- -tin, -tout, 1 // 4
188
- ],
189
-
190
- indices: [0, 1, 1, 2, 2, 3, 3, 4, 4, 0],
191
- size: 7
192
- };
193
- }
194
164
  export function SimpleLineTriangulation(feature) {
195
165
  var coordinates = feature.coordinates;
196
166
  var pos = [];
@@ -392,8 +362,10 @@ export function RasterImageTriangulation(feature) {
392
362
  * @param feature 映射数据
393
363
  * @param segNum 弧线线段数
394
364
  */
395
- export function LineArcTriangulation(feature, segmentNumber) {
396
- var segNum = segmentNumber ? segmentNumber : 30;
365
+ export function LineArcTriangulation(feature, styleOption) {
366
+ // @ts-ignore
367
+ var _styleOption$segmentN = styleOption.segmentNumber,
368
+ segmentNumber = _styleOption$segmentN === void 0 ? 30 : _styleOption$segmentN;
397
369
  var coordinates = feature.coordinates;
398
370
  var positions = [];
399
371
  var indexArray = [];
@@ -401,13 +373,13 @@ export function LineArcTriangulation(feature, segmentNumber) {
401
373
  // 上线两个顶点
402
374
  // [ x, y, z, sx,sy, tx,ty]
403
375
  positions.push(i, 1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1], i, -1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1]);
404
- if (i !== segNum - 1) {
376
+ if (i !== segmentNumber - 1) {
405
377
  indexArray.push.apply(indexArray, _toConsumableArray([0, 1, 2, 1, 3, 2].map(function (v) {
406
378
  return i * 2 + v;
407
379
  })));
408
380
  }
409
381
  };
410
- for (var i = 0; i < segNum; i++) {
382
+ for (var i = 0; i < segmentNumber; i++) {
411
383
  _loop(i);
412
384
  }
413
385
  return {
package/es/line/index.js CHANGED
@@ -87,7 +87,8 @@ var LineLayer = /*#__PURE__*/function (_BaseLayer) {
87
87
  },
88
88
  tileLine: {},
89
89
  earthArc3d: {},
90
- flowline: {}
90
+ flowline: {},
91
+ arrow: {}
91
92
  };
92
93
  return defaultConfig[type];
93
94
  }
@@ -18,7 +18,7 @@ import { LineArcTriangulation } from "../../core/triangulation";
18
18
  /* babel-plugin-inline-import '../shaders/dash/arc_dash_frag.glsl' */
19
19
  var arc_dash_frag = "varying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying float v_distance_ratio;\n\nuniform float segmentNumber;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n\n float flag = 0.;\n float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n };\n gl_FragColor.a *=flag;\n \n gl_FragColor = filterColor(gl_FragColor);\n}";
20
20
  /* babel-plugin-inline-import '../shaders/dash/arc_dash_vert.glsl' */
21
- var arc_dash_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nvarying vec4 v_color;\n\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_lineDir: 1.0;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\n\nuniform float u_thetaOffset: 0.314;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n\n v_distance_ratio = segmentIndex / segmentNumber;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));\n \n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n gl_PointSize = 5.0;\n setPickingColor(a_PickingColor);\n}\n"; // arc normal line
21
+ var arc_dash_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nvarying vec4 v_color;\n\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_lineDir: 1.0;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n\n v_distance_ratio = segmentIndex / segmentNumber;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n \n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n gl_PointSize = 5.0;\n setPickingColor(a_PickingColor);\n}\n"; // arc normal line
22
22
  /* babel-plugin-inline-import '../shaders/line_arc_frag.glsl' */
23
23
  var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float segmentNumber;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_lineData;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n gl_FragColor = v_color;\n \n\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n \n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}";
24
24
  /* babel-plugin-inline-import '../shaders/line_arc_vert.glsl' */
@@ -26,7 +26,7 @@ var arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\n\nattribute v
26
26
  /* babel-plugin-inline-import '../shaders/linear/arc_linear_frag.glsl' */
27
27
  var arc_linear_frag = "varying vec4 v_color;\n\n#pragma include \"picking\"\n\nvoid main() {\n// \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n\n gl_FragColor = v_color;\n gl_FragColor = filterColor(gl_FragColor);\n}";
28
28
  /* babel-plugin-inline-import '../shaders/linear/arc_linear_vert.glsl' */
29
- var arc_linear_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nvarying vec4 v_color;\nvarying float v_segmentIndex;\n\nuniform float u_lineDir: 1.0;\n\nuniform float u_thetaOffset: 0.314;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n v_color.a *= opacity;\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
29
+ var arc_linear_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nvarying vec4 v_color;\nvarying float v_segmentIndex;\n\nuniform float u_lineDir: 1.0;\n\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n v_color.a *= opacity;\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
30
30
  var lineStyleObj = {
31
31
  solid: 0.0,
32
32
  dash: 1.0
@@ -207,7 +207,9 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
207
207
  depth: {
208
208
  enable: false
209
209
  },
210
- segmentNumber: segmentNumber
210
+ styleOption: {
211
+ segmentNumber: segmentNumber
212
+ }
211
213
  });
212
214
  case 4:
213
215
  model = _context2.sent;
@@ -194,7 +194,9 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
194
194
  fragmentShader: frag,
195
195
  inject: this.getInject(),
196
196
  triangulation: LineArcTriangulation,
197
- segmentNumber: segmentNumber
197
+ styleOption: {
198
+ segmentNumber: segmentNumber
199
+ }
198
200
  });
199
201
  case 4:
200
202
  model = _context2.sent;
@@ -196,7 +196,9 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
196
196
  depth: {
197
197
  enable: true
198
198
  },
199
- segmentNumber: segmentNumber
199
+ styleOption: {
200
+ segmentNumber: segmentNumber
201
+ }
200
202
  });
201
203
  case 4:
202
204
  model = _context2.sent;
@@ -11,11 +11,11 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
12
  import { rgb2arr } from '@antv/l7-utils';
13
13
  import BaseModel from "../../core/BaseModel";
14
- import { FlowLineFillTriangulation } from "../../core/triangulation";
14
+ import { FlowLineTriangulation } from "../../core/line_trangluation";
15
15
  /* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
16
16
  var flow_line_frag = "#extension GL_OES_standard_derivatives : enable\n\nvarying vec4 v_color;\n\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\ngl_FragColor = v_color;\ngl_FragColor = filterColor(gl_FragColor);\n}\n"; // linear simple line shader
17
17
  /* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
18
- var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvarying vec4 v_color;\nuniform float u_gap_width: 1.0;\nuniform float u_stroke_width: 1.0;\nuniform float u_stroke_opacity: 1.0;\n\n\nvoid main() {\n\n// \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = normalize(target - source);\n vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);\n\n\n vec2 position = mix(source, target, a_Position.x);\n \n float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); // \n vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);\n vec2 limitedOffsetDistances = clamp( \n offsetDistances,\n project_pixel(-lengthCommon*.8), project_pixel(lengthCommon*.8)\n );\n\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon*.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon*.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);\n\n float gapCommon = project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
18
+ var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\nvarying vec4 v_color;\nuniform float u_gap_width: 1.0;\nuniform float u_stroke_width: 1.0;\nuniform float u_stroke_opacity: 1.0;\n\nvec2 project_pixel_offset(vec2 offsets) {\n\n vec2 data = project_pixel(offsets);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return data;\n }\n\n return vec2(data.x, -data.y);;\n}\n\nvec2 line_dir(vec2 target, vec2 source) {\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return normalize(target - source);\n }\n return normalize(ProjectFlat(target) - ProjectFlat(source));\n}\n\nfloat flag_gap() {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return 1.;\n }\n return -1.;\n\n}\n\n\nvoid main() {\n\n// \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = line_dir(target,source);\n vec2 perpendicularDir = vec2(flowlineDir.y, flowlineDir.x); // mapbox || \u9AD8\u5FB7\n\n\n vec2 position = mix(source, target, a_Position.x);\n \n float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); // \n vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || \u9AD8\u5FB7\n vec2 limitedOffsetDistances = clamp( \n offsetDistances,\n project_pixel(-lengthCommon*.2), project_pixel(lengthCommon*.2)\n );\n\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon*.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon*.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || \u9AD8\u5FB7\n\n float gapCommon = flag_gap() * project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
19
19
  var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
20
20
  _inherits(FlowLineModel, _BaseModel);
21
21
  var _super = _createSuper(FlowLineModel);
@@ -36,8 +36,6 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
36
36
  _ref$strokeOpacity = _ref.strokeOpacity,
37
37
  strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity;
38
38
  return _objectSpread({
39
- // u_opacity: opacity,
40
- // u_offsets: offsets,
41
39
  u_gap_width: gapWidth,
42
40
  u_stroke_width: strokeWidth,
43
41
  u_stroke: rgb2arr(stroke),
@@ -77,7 +75,8 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
77
75
  vertexShader: flow_line_vert,
78
76
  fragmentShader: flow_line_frag,
79
77
  inject: this.getInject(),
80
- triangulation: FlowLineFillTriangulation,
78
+ triangulation: FlowLineTriangulation,
79
+ styleOption: this.layer.getLayerConfig().symbol,
81
80
  primitive: gl.TRIANGLES,
82
81
  depth: {
83
82
  enable: false
@@ -96,14 +96,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
96
96
  _ref$linearDir = _ref.linearDir,
97
97
  linearDir = _ref$linearDir === void 0 ? LinearDir.VERTICAL : _ref$linearDir,
98
98
  _ref$blur = _ref.blur,
99
- blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur,
100
- _ref$arrow = _ref.arrow,
101
- arrow = _ref$arrow === void 0 ? {
102
- enable: false,
103
- arrowWidth: 2,
104
- arrowHeight: 3,
105
- tailWidth: 1
106
- } : _ref$arrow;
99
+ blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur;
107
100
  if (dashArray.length === 2) {
108
101
  dashArray.push(0, 0);
109
102
  }
@@ -144,12 +137,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
144
137
  u_heightfixed: Number(heightfixed),
145
138
  // 顶点高度 scale
146
139
  u_vertexScale: vertexHeightScale,
147
- u_raisingHeight: Number(raisingHeight),
148
- // arrow
149
- u_arrow: Number(arrow.enable),
150
- u_arrowHeight: arrow.arrowHeight || 3,
151
- u_arrowWidth: arrow.arrowWidth || 2,
152
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
140
+ u_raisingHeight: Number(raisingHeight)
153
141
  }, this.getStyleAttribute());
154
142
  }
155
143
  }, {