@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.
- package/es/core/BaseLayer.js +4 -4
- package/es/core/interface.d.ts +13 -9
- package/es/core/line_trangluation.d.ts +19 -0
- package/es/core/line_trangluation.js +91 -0
- package/es/core/shape/arrow.d.ts +25 -0
- package/es/core/shape/arrow.js +160 -0
- package/es/core/triangulation.d.ts +2 -8
- package/es/core/triangulation.js +6 -34
- package/es/line/index.js +2 -1
- package/es/line/models/arc.js +5 -3
- package/es/line/models/arc_3d.js +3 -1
- package/es/line/models/earthArc_3d.js +3 -1
- package/es/line/models/flow.js +4 -5
- package/es/line/models/line.js +2 -14
- package/es/line/shaders/dash/arc_dash_vert.glsl +2 -5
- package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
- package/es/line/shaders/linear/arc_linear_vert.glsl +2 -3
- package/es/plugins/DataMappingPlugin.js +2 -19
- package/es/tile/tile/Tile.d.ts +0 -1
- package/lib/core/BaseLayer.js +4 -4
- package/lib/core/line_trangluation.js +99 -0
- package/lib/core/shape/arrow.js +174 -0
- package/lib/core/triangulation.js +6 -35
- package/lib/line/index.js +2 -1
- package/lib/line/models/arc.js +5 -3
- package/lib/line/models/arc_3d.js +3 -1
- package/lib/line/models/earthArc_3d.js +3 -1
- package/lib/line/models/flow.js +4 -5
- package/lib/line/models/line.js +2 -14
- package/lib/line/shaders/dash/arc_dash_vert.glsl +2 -5
- package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
- package/lib/line/shaders/linear/arc_linear_vert.glsl +2 -3
- package/lib/plugins/DataMappingPlugin.js +2 -19
- package/package.json +7 -7
|
@@ -13,9 +13,6 @@ uniform vec4 u_dash_array: [10.0, 5., 0, 0];
|
|
|
13
13
|
uniform float u_lineDir: 1.0;
|
|
14
14
|
varying vec4 v_dash_array;
|
|
15
15
|
varying float v_distance_ratio;
|
|
16
|
-
|
|
17
|
-
uniform float u_thetaOffset: 0.314;
|
|
18
|
-
|
|
19
16
|
#pragma include "projection"
|
|
20
17
|
#pragma include "project"
|
|
21
18
|
#pragma include "picking"
|
|
@@ -92,8 +89,8 @@ void main() {
|
|
|
92
89
|
|
|
93
90
|
v_distance_ratio = segmentIndex / segmentNumber;
|
|
94
91
|
|
|
95
|
-
vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio,
|
|
96
|
-
vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio,
|
|
92
|
+
vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
|
|
93
|
+
vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
|
|
97
94
|
|
|
98
95
|
|
|
99
96
|
vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
|
|
@@ -8,29 +8,59 @@ uniform mat4 u_ModelMatrix;
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
#pragma include "projection"
|
|
11
|
+
#pragma include "project"
|
|
11
12
|
#pragma include "picking"
|
|
12
13
|
varying vec4 v_color;
|
|
13
14
|
uniform float u_gap_width: 1.0;
|
|
14
15
|
uniform float u_stroke_width: 1.0;
|
|
15
16
|
uniform float u_stroke_opacity: 1.0;
|
|
16
17
|
|
|
18
|
+
vec2 project_pixel_offset(vec2 offsets) {
|
|
19
|
+
|
|
20
|
+
vec2 data = project_pixel(offsets);
|
|
21
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
|
|
22
|
+
// P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return vec2(data.x, -data.y);;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
vec2 line_dir(vec2 target, vec2 source) {
|
|
30
|
+
|
|
31
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
|
|
32
|
+
// P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
|
|
33
|
+
return normalize(target - source);
|
|
34
|
+
}
|
|
35
|
+
return normalize(ProjectFlat(target) - ProjectFlat(source));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
float flag_gap() {
|
|
39
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
|
|
40
|
+
// P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
|
|
41
|
+
return 1.;
|
|
42
|
+
}
|
|
43
|
+
return -1.;
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
17
47
|
|
|
18
48
|
void main() {
|
|
19
49
|
|
|
20
50
|
// 透明度计算
|
|
21
51
|
vec2 source = a_Instance.rg; // 起始点
|
|
22
52
|
vec2 target = a_Instance.ba; // 终点
|
|
23
|
-
vec2 flowlineDir =
|
|
24
|
-
vec2 perpendicularDir = vec2(
|
|
53
|
+
vec2 flowlineDir = line_dir(target,source);
|
|
54
|
+
vec2 perpendicularDir = vec2(flowlineDir.y, flowlineDir.x); // mapbox || 高德
|
|
25
55
|
|
|
26
56
|
|
|
27
57
|
vec2 position = mix(source, target, a_Position.x);
|
|
28
58
|
|
|
29
59
|
float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); //
|
|
30
|
-
vec2 offsetDistances = a_Size.x *
|
|
60
|
+
vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || 高德
|
|
31
61
|
vec2 limitedOffsetDistances = clamp(
|
|
32
62
|
offsetDistances,
|
|
33
|
-
project_pixel(-lengthCommon*.
|
|
63
|
+
project_pixel(-lengthCommon*.2), project_pixel(lengthCommon*.2)
|
|
34
64
|
);
|
|
35
65
|
|
|
36
66
|
|
|
@@ -42,9 +72,9 @@ void main() {
|
|
|
42
72
|
a_Position.x
|
|
43
73
|
);
|
|
44
74
|
|
|
45
|
-
vec2 normalsCommon = u_stroke_width *
|
|
75
|
+
vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || 高德
|
|
46
76
|
|
|
47
|
-
float gapCommon =
|
|
77
|
+
float gapCommon = flag_gap() * project_pixel(u_gap_width);
|
|
48
78
|
vec3 offsetCommon = vec3(
|
|
49
79
|
flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -
|
|
50
80
|
perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),
|
|
@@ -11,7 +11,6 @@ varying float v_segmentIndex;
|
|
|
11
11
|
|
|
12
12
|
uniform float u_lineDir: 1.0;
|
|
13
13
|
|
|
14
|
-
uniform float u_thetaOffset: 0.314;
|
|
15
14
|
uniform vec4 u_sourceColor;
|
|
16
15
|
uniform vec4 u_targetColor;
|
|
17
16
|
|
|
@@ -80,8 +79,8 @@ void main() {
|
|
|
80
79
|
float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
|
|
81
80
|
float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
|
|
82
81
|
float d_distance_ratio;
|
|
83
|
-
vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio,
|
|
84
|
-
vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio,
|
|
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));
|
|
85
84
|
// v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
|
|
86
85
|
//unProjCustomCoord
|
|
87
86
|
|
|
@@ -140,11 +140,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
140
140
|
key: "mapping",
|
|
141
141
|
value: function mapping(layer, attributes, data, predata) {
|
|
142
142
|
var _this3 = this;
|
|
143
|
-
var _ref5 = layer.getLayerConfig(),
|
|
144
|
-
_ref5$arrow = _ref5.arrow,
|
|
145
|
-
arrow = _ref5$arrow === void 0 ? {
|
|
146
|
-
enable: false
|
|
147
|
-
} : _ref5$arrow;
|
|
148
143
|
var usedAttributes = attributes.filter(function (attribute) {
|
|
149
144
|
return attribute.scale !== undefined;
|
|
150
145
|
}).filter(function (attribute) {
|
|
@@ -172,18 +167,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
172
167
|
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
173
168
|
}
|
|
174
169
|
});
|
|
175
|
-
if (arrow.enable && encodeRecord.shape === 'line') {
|
|
176
|
-
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
177
|
-
var coords = encodeRecord.coordinates;
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
if (layer.arrowInsertCount < layer.encodeDataLength) {
|
|
180
|
-
// Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
|
|
181
|
-
var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
|
|
182
|
-
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
layer.arrowInsertCount++;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
170
|
return encodeRecord;
|
|
188
171
|
});
|
|
189
172
|
attributes.forEach(function (attribute) {
|
|
@@ -273,9 +256,9 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
273
256
|
}
|
|
274
257
|
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
275
258
|
var params = [];
|
|
276
|
-
scalers.forEach(function (
|
|
259
|
+
scalers.forEach(function (_ref5) {
|
|
277
260
|
var _attribute$scale2;
|
|
278
|
-
var field =
|
|
261
|
+
var field = _ref5.field;
|
|
279
262
|
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
280
263
|
// TODO:多字段,常量
|
|
281
264
|
params.push(record[field]);
|
package/es/tile/tile/Tile.d.ts
CHANGED
|
@@ -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;
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -30,7 +30,7 @@ var _multiPassRender = require("../utils/multiPassRender");
|
|
|
30
30
|
var _LayerPickService = _interopRequireDefault(require("./LayerPickService"));
|
|
31
31
|
var _TextureService = _interopRequireDefault(require("./TextureService"));
|
|
32
32
|
var _excluded = ["passes"],
|
|
33
|
-
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "
|
|
33
|
+
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption"];
|
|
34
34
|
var _dec, _class, _descriptor; // @ts-ignore
|
|
35
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; } } }; }
|
|
36
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); }
|
|
@@ -1163,11 +1163,11 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
1163
1163
|
value: function () {
|
|
1164
1164
|
var _buildLayerModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options) {
|
|
1165
1165
|
var _this10 = this;
|
|
1166
|
-
var moduleName, vertexShader, fragmentShader, inject, triangulation,
|
|
1166
|
+
var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
|
|
1167
1167
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
1168
1168
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1169
1169
|
case 0:
|
|
1170
|
-
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation,
|
|
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);
|
|
1171
1171
|
this.shaderModuleService.registerModule(moduleName, {
|
|
1172
1172
|
vs: vertexShader,
|
|
1173
1173
|
fs: fragmentShader,
|
|
@@ -1177,7 +1177,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
1177
1177
|
createModel = this.rendererService.createModel;
|
|
1178
1178
|
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
1179
1179
|
// console.log(this.encodedData)
|
|
1180
|
-
var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation,
|
|
1180
|
+
var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, styleOption),
|
|
1181
1181
|
attributes = _this10$styleAttribut.attributes,
|
|
1182
1182
|
elements = _this10$styleAttribut.elements,
|
|
1183
1183
|
count = _this10$styleAttribut.count;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.circleArraw = circleArraw;
|
|
8
|
+
exports.classicArrow = classicArrow;
|
|
9
|
+
exports.diamondArrow = diamondArrow;
|
|
10
|
+
exports.getSymbol = getSymbol;
|
|
11
|
+
exports.halfTriangleArrow = halfTriangleArrow;
|
|
12
|
+
exports.lineArrowPath = lineArrowPath;
|
|
13
|
+
exports.rectArrow = rectArrow;
|
|
14
|
+
exports.triangleArrow = triangleArrow;
|
|
15
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
var _Path = require("./Path");
|
|
18
|
+
var _earcut = _interopRequireDefault(require("earcut"));
|
|
19
|
+
var maxArrowWidthMap = {
|
|
20
|
+
circle: 2,
|
|
21
|
+
triangle: 2,
|
|
22
|
+
diamond: 4,
|
|
23
|
+
rect: 2,
|
|
24
|
+
classic: 3,
|
|
25
|
+
halfTriangle: 2,
|
|
26
|
+
'none': 0
|
|
27
|
+
};
|
|
28
|
+
var PathHeight = 1 / 2;
|
|
29
|
+
function halfTriangleArrow(dir, options) {
|
|
30
|
+
var _options$width = options.width,
|
|
31
|
+
width = _options$width === void 0 ? 2 : _options$width,
|
|
32
|
+
_options$height = options.height,
|
|
33
|
+
height = _options$height === void 0 ? 1 : _options$height;
|
|
34
|
+
return {
|
|
35
|
+
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],
|
|
36
|
+
indices: [3, 4, 5],
|
|
37
|
+
outLineIndices: [0, 1, 2],
|
|
38
|
+
normals: [1 * dir, -2 * dir, 1,
|
|
39
|
+
// y,x
|
|
40
|
+
-2 * dir, 1.5 * dir, 1, 1 * dir, 1.5 * dir, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
41
|
+
dimensions: 2
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function triangleArrow(dir, options) {
|
|
45
|
+
var _options$width2 = options.width,
|
|
46
|
+
width = _options$width2 === void 0 ? 2 : _options$width2,
|
|
47
|
+
_options$height2 = options.height,
|
|
48
|
+
height = _options$height2 === void 0 ? 3 : _options$height2;
|
|
49
|
+
return {
|
|
50
|
+
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],
|
|
51
|
+
outLineIndices: [0, 1, 2],
|
|
52
|
+
indices: [3, 4, 5],
|
|
53
|
+
normals: [0, -1.5 * dir, 1, 2, 1 * dir, 1, -2, 1 * dir, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
54
|
+
dimensions: 2
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function rectArrow(dir, options) {
|
|
58
|
+
var _options$width3 = options.width,
|
|
59
|
+
width = _options$width3 === void 0 ? 2 : _options$width3,
|
|
60
|
+
_options$height3 = options.height,
|
|
61
|
+
height = _options$height3 === void 0 ? 2 : _options$height3;
|
|
62
|
+
return {
|
|
63
|
+
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],
|
|
64
|
+
dimensions: 2,
|
|
65
|
+
indices: [4, 5, 6, 4, 6, 7],
|
|
66
|
+
outLineIndices: [0, 1, 2, 0, 2, 3],
|
|
67
|
+
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]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function diamondArrow(dir, options) {
|
|
71
|
+
var _options$width4 = options.width,
|
|
72
|
+
width = _options$width4 === void 0 ? 2 : _options$width4,
|
|
73
|
+
_options$height4 = options.height,
|
|
74
|
+
height = _options$height4 === void 0 ? 3 : _options$height4;
|
|
75
|
+
return {
|
|
76
|
+
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],
|
|
77
|
+
dimensions: 2,
|
|
78
|
+
indices: [4, 5, 6, 4, 6, 7],
|
|
79
|
+
outLineIndices: [0, 1, 2, 0, 2, 3],
|
|
80
|
+
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]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function classicArrow(dir, options) {
|
|
84
|
+
var _options$width5 = options.width,
|
|
85
|
+
width = _options$width5 === void 0 ? 2 : _options$width5,
|
|
86
|
+
_options$height5 = options.height,
|
|
87
|
+
height = _options$height5 === void 0 ? 3 : _options$height5;
|
|
88
|
+
return {
|
|
89
|
+
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],
|
|
90
|
+
dimensions: 2,
|
|
91
|
+
indices: [4, 5, 6, 4, 6, 7],
|
|
92
|
+
outLineIndices: [0, 1, 2, 0, 2, 3],
|
|
93
|
+
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]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function circleArraw(dir, options) {
|
|
97
|
+
var _options$width6 = options.width,
|
|
98
|
+
width = _options$width6 === void 0 ? 2 : _options$width6,
|
|
99
|
+
_options$height6 = options.height,
|
|
100
|
+
height = _options$height6 === void 0 ? 2 : _options$height6;
|
|
101
|
+
var path = (0, _Path.circle)();
|
|
102
|
+
var flattengeo = _earcut.default.flatten([path]);
|
|
103
|
+
var triangles = (0, _earcut.default)(flattengeo.vertices, flattengeo.holes, flattengeo.dimensions);
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
var vertice = path.map(function (t) {
|
|
106
|
+
return [t[0] * width * dir, t[1] * height];
|
|
107
|
+
}).flat();
|
|
108
|
+
return {
|
|
109
|
+
vertices: [].concat((0, _toConsumableArray2.default)(vertice), (0, _toConsumableArray2.default)(vertice)),
|
|
110
|
+
dimensions: 2,
|
|
111
|
+
indices: triangles.map(function (v) {
|
|
112
|
+
return v + path.length;
|
|
113
|
+
}),
|
|
114
|
+
outLineIndices: triangles,
|
|
115
|
+
normals: [].concat((0, _toConsumableArray2.default)(path.map(function (t) {
|
|
116
|
+
return [t[1] * height, t[0] * width * dir, 1];
|
|
117
|
+
}).flat()), (0, _toConsumableArray2.default)(new Array(path.length * 3).fill(0)))
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function lineArrowPath(coord) {
|
|
121
|
+
var indexOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
122
|
+
var symbol = arguments.length > 2 ? arguments[2] : undefined;
|
|
123
|
+
var sourceType = (0, _typeof2.default)(symbol['source']) === 'object' ? symbol['source'].type : symbol['source'];
|
|
124
|
+
var targetType = (0, _typeof2.default)(symbol['target']) === 'object' ? symbol['target'].type : symbol['target'];
|
|
125
|
+
var _ref = (0, _typeof2.default)(symbol['source']) === 'object' ? symbol['source'] : {},
|
|
126
|
+
_ref$width = _ref.width,
|
|
127
|
+
sourceWidth = _ref$width === void 0 ? sourceType ? maxArrowWidthMap[sourceType] : 0 : _ref$width,
|
|
128
|
+
_ref$height = _ref.height,
|
|
129
|
+
sourceHeight = _ref$height === void 0 ? 2 : _ref$height;
|
|
130
|
+
var _ref2 = (0, _typeof2.default)(symbol['target']) === 'object' ? symbol['target'] : {},
|
|
131
|
+
_ref2$width = _ref2.width,
|
|
132
|
+
targetWidth = _ref2$width === void 0 ? targetType ? maxArrowWidthMap[targetType] : 0 : _ref2$width,
|
|
133
|
+
_ref2$height = _ref2.height,
|
|
134
|
+
targetHeight = _ref2$height === void 0 ? 2 : _ref2$height;
|
|
135
|
+
return {
|
|
136
|
+
vertices: [0, PathHeight, 1 * sourceWidth].concat((0, _toConsumableArray2.default)(coord), [1, PathHeight, -1 * targetWidth], (0, _toConsumableArray2.default)(coord), [1, -PathHeight, -1 * targetWidth], (0, _toConsumableArray2.default)(coord), [0, -PathHeight, 1 * sourceWidth], (0, _toConsumableArray2.default)(coord), [0, PathHeight, 1 * sourceWidth], (0, _toConsumableArray2.default)(coord), [1, PathHeight, -1 * targetWidth], (0, _toConsumableArray2.default)(coord), [1, -PathHeight, -1 * targetWidth], (0, _toConsumableArray2.default)(coord), [0, -PathHeight, 1 * sourceWidth], (0, _toConsumableArray2.default)(coord)),
|
|
137
|
+
outLineIndices: [0, 1, 2, 0, 2, 3].map(function (t) {
|
|
138
|
+
return t + indexOffset;
|
|
139
|
+
}),
|
|
140
|
+
indices: [4, 5, 6, 4, 6, 7].map(function (t) {
|
|
141
|
+
return t + indexOffset;
|
|
142
|
+
}),
|
|
143
|
+
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],
|
|
144
|
+
dimensions: 2
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function getSymbol(type, position) {
|
|
148
|
+
var shape = (0, _typeof2.default)(type) === 'object' ? type.type : type;
|
|
149
|
+
var dir = position === 'source' ? 1 : -1;
|
|
150
|
+
var option = (0, _typeof2.default)(type) === 'object' ? type : {};
|
|
151
|
+
switch (shape) {
|
|
152
|
+
case 'circle':
|
|
153
|
+
return circleArraw(dir, option);
|
|
154
|
+
case 'triangle':
|
|
155
|
+
return triangleArrow(dir, option);
|
|
156
|
+
case 'diamond':
|
|
157
|
+
return diamondArrow(dir, option);
|
|
158
|
+
case 'rect':
|
|
159
|
+
return rectArrow(dir, option);
|
|
160
|
+
case 'classic':
|
|
161
|
+
return classicArrow(dir, option);
|
|
162
|
+
case 'halfTriangle':
|
|
163
|
+
return halfTriangleArrow(dir, option);
|
|
164
|
+
default:
|
|
165
|
+
return {
|
|
166
|
+
vertices: [],
|
|
167
|
+
indices: [],
|
|
168
|
+
normals: [],
|
|
169
|
+
dimensions: 2,
|
|
170
|
+
outLineIndices: [],
|
|
171
|
+
outLineNormals: []
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.FlowLineFillTriangulation = FlowLineFillTriangulation;
|
|
9
|
-
exports.FlowLineStrokeTriangulation = FlowLineStrokeTriangulation;
|
|
10
9
|
exports.GlobelPointFillTriangulation = GlobelPointFillTriangulation;
|
|
11
10
|
exports.HeatmapGridTriangulation = HeatmapGridTriangulation;
|
|
12
11
|
exports.HeatmapTriangulation = HeatmapTriangulation;
|
|
@@ -191,36 +190,6 @@ function FlowLineFillTriangulation(feature) {
|
|
|
191
190
|
size: 7
|
|
192
191
|
};
|
|
193
192
|
}
|
|
194
|
-
function FlowLineStrokeTriangulation(feature) {
|
|
195
|
-
// @ts-ignore
|
|
196
|
-
var coord = feature.coordinates.flat();
|
|
197
|
-
var tin = 1;
|
|
198
|
-
var tout = 1;
|
|
199
|
-
return {
|
|
200
|
-
vertices: [1, 0, 0].concat((0, _toConsumableArray2.default)(coord), [
|
|
201
|
-
// 0
|
|
202
|
-
1, 2, -3], (0, _toConsumableArray2.default)(coord), [
|
|
203
|
-
// 1
|
|
204
|
-
1, 1, -3], (0, _toConsumableArray2.default)(coord), [
|
|
205
|
-
// 2
|
|
206
|
-
0, 1, 0], (0, _toConsumableArray2.default)(coord), [
|
|
207
|
-
// 3
|
|
208
|
-
0, 0, 0], (0, _toConsumableArray2.default)(coord)),
|
|
209
|
-
normals: [-tin, 2 * tout, 1,
|
|
210
|
-
// 0
|
|
211
|
-
2 * tout, -tout, 1,
|
|
212
|
-
// 1
|
|
213
|
-
tout, -tout, 1,
|
|
214
|
-
// 2
|
|
215
|
-
tout, -tout, 1,
|
|
216
|
-
// 3
|
|
217
|
-
-tin, -tout, 1 // 4
|
|
218
|
-
],
|
|
219
|
-
|
|
220
|
-
indices: [0, 1, 1, 2, 2, 3, 3, 4, 4, 0],
|
|
221
|
-
size: 7
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
193
|
function SimpleLineTriangulation(feature) {
|
|
225
194
|
var coordinates = feature.coordinates;
|
|
226
195
|
var pos = [];
|
|
@@ -422,8 +391,10 @@ function RasterImageTriangulation(feature) {
|
|
|
422
391
|
* @param feature 映射数据
|
|
423
392
|
* @param segNum 弧线线段数
|
|
424
393
|
*/
|
|
425
|
-
function LineArcTriangulation(feature,
|
|
426
|
-
|
|
394
|
+
function LineArcTriangulation(feature, styleOption) {
|
|
395
|
+
// @ts-ignore
|
|
396
|
+
var _styleOption$segmentN = styleOption.segmentNumber,
|
|
397
|
+
segmentNumber = _styleOption$segmentN === void 0 ? 30 : _styleOption$segmentN;
|
|
427
398
|
var coordinates = feature.coordinates;
|
|
428
399
|
var positions = [];
|
|
429
400
|
var indexArray = [];
|
|
@@ -431,13 +402,13 @@ function LineArcTriangulation(feature, segmentNumber) {
|
|
|
431
402
|
// 上线两个顶点
|
|
432
403
|
// [ x, y, z, sx,sy, tx,ty]
|
|
433
404
|
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]);
|
|
434
|
-
if (i !==
|
|
405
|
+
if (i !== segmentNumber - 1) {
|
|
435
406
|
indexArray.push.apply(indexArray, (0, _toConsumableArray2.default)([0, 1, 2, 1, 3, 2].map(function (v) {
|
|
436
407
|
return i * 2 + v;
|
|
437
408
|
})));
|
|
438
409
|
}
|
|
439
410
|
};
|
|
440
|
-
for (var i = 0; i <
|
|
411
|
+
for (var i = 0; i < segmentNumber; i++) {
|
|
441
412
|
_loop(i);
|
|
442
413
|
}
|
|
443
414
|
return {
|
package/lib/line/index.js
CHANGED
package/lib/line/models/arc.js
CHANGED
|
@@ -25,7 +25,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
25
25
|
// arc dash line
|
|
26
26
|
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}";
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/dash/arc_dash_vert.glsl' */
|
|
28
|
-
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
|
|
28
|
+
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
|
|
29
29
|
/* babel-plugin-inline-import '../shaders/line_arc_frag.glsl' */
|
|
30
30
|
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}";
|
|
31
31
|
/* babel-plugin-inline-import '../shaders/line_arc_vert.glsl' */
|
|
@@ -33,7 +33,7 @@ var arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\n\nattribute v
|
|
|
33
33
|
/* babel-plugin-inline-import '../shaders/linear/arc_linear_frag.glsl' */
|
|
34
34
|
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}";
|
|
35
35
|
/* babel-plugin-inline-import '../shaders/linear/arc_linear_vert.glsl' */
|
|
36
|
-
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
|
|
36
|
+
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";
|
|
37
37
|
var lineStyleObj = {
|
|
38
38
|
solid: 0.0,
|
|
39
39
|
dash: 1.0
|
|
@@ -214,7 +214,9 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
214
214
|
depth: {
|
|
215
215
|
enable: false
|
|
216
216
|
},
|
|
217
|
-
|
|
217
|
+
styleOption: {
|
|
218
|
+
segmentNumber: segmentNumber
|
|
219
|
+
}
|
|
218
220
|
});
|
|
219
221
|
case 4:
|
|
220
222
|
model = _context2.sent;
|
|
@@ -201,7 +201,9 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
201
201
|
fragmentShader: frag,
|
|
202
202
|
inject: this.getInject(),
|
|
203
203
|
triangulation: _triangulation.LineArcTriangulation,
|
|
204
|
-
|
|
204
|
+
styleOption: {
|
|
205
|
+
segmentNumber: segmentNumber
|
|
206
|
+
}
|
|
205
207
|
});
|
|
206
208
|
case 4:
|
|
207
209
|
model = _context2.sent;
|