@antv/l7-layers 2.9.23 → 2.9.25
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/Geometry/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
|
@@ -1,65 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/extrude_polyline.ts
|
|
20
|
-
var extrude_polyline_exports = {};
|
|
21
|
-
__export(extrude_polyline_exports, {
|
|
22
|
-
computeMiter: () => computeMiter,
|
|
23
|
-
computeNormal: () => computeNormal,
|
|
24
|
-
default: () => ExtrudePolyline,
|
|
25
|
-
direction: () => direction
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
var
|
|
8
|
+
exports.computeMiter = computeMiter;
|
|
9
|
+
exports.computeNormal = computeNormal;
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
exports.direction = direction;
|
|
12
|
+
|
|
13
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
|
+
|
|
15
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
16
|
+
|
|
17
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
+
|
|
19
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
20
|
+
|
|
21
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
22
|
+
|
|
23
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
24
|
+
|
|
25
|
+
var _glMatrix = require("gl-matrix");
|
|
26
|
+
|
|
27
|
+
var tmp = _glMatrix.vec2.create();
|
|
28
|
+
|
|
29
|
+
var capEnd = _glMatrix.vec2.create();
|
|
30
|
+
|
|
31
|
+
var lineA = _glMatrix.vec2.create();
|
|
32
|
+
|
|
33
|
+
var lineB = _glMatrix.vec2.create();
|
|
34
|
+
|
|
35
|
+
var tangent = _glMatrix.vec2.create();
|
|
36
|
+
|
|
35
37
|
function computeMiter(lineTangent, miter, start, end, halfThick) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
_glMatrix.vec2.add(lineTangent, start, end);
|
|
39
|
+
|
|
40
|
+
_glMatrix.vec2.normalize(lineTangent, lineTangent);
|
|
41
|
+
|
|
42
|
+
miter = _glMatrix.vec2.fromValues(-lineTangent[1], lineTangent[0]);
|
|
43
|
+
|
|
44
|
+
var tmpvec = _glMatrix.vec2.fromValues(-start[1], start[0]);
|
|
45
|
+
|
|
46
|
+
return [halfThick / _glMatrix.vec2.dot(miter, tmpvec), miter];
|
|
41
47
|
}
|
|
48
|
+
|
|
42
49
|
function computeNormal(out, dir) {
|
|
43
|
-
return
|
|
50
|
+
return _glMatrix.vec2.set(out, -dir[1], dir[0]);
|
|
44
51
|
}
|
|
52
|
+
|
|
45
53
|
function direction(out, a, b) {
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
_glMatrix.vec2.sub(out, a, b);
|
|
55
|
+
|
|
56
|
+
_glMatrix.vec2.normalize(out, out);
|
|
57
|
+
|
|
48
58
|
return out;
|
|
49
59
|
}
|
|
60
|
+
|
|
50
61
|
function isPointEqual(a, b) {
|
|
51
62
|
return a[0] === b[0] && a[1] === b[1];
|
|
52
63
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
|
|
65
|
+
function getArrayUnique(matrix) {
|
|
66
|
+
var map = new Map();
|
|
67
|
+
|
|
68
|
+
for (var i = 0; i < matrix.length; i++) {
|
|
69
|
+
var key = matrix[0].toString() + '-' + matrix[1].toString();
|
|
70
|
+
|
|
71
|
+
if (map.get(key)) {
|
|
72
|
+
matrix.splice(i, 1);
|
|
73
|
+
i++;
|
|
74
|
+
} else {
|
|
75
|
+
map.set(key, key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return matrix;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var ExtrudePolyline = /*#__PURE__*/function () {
|
|
83
|
+
function ExtrudePolyline() {
|
|
84
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
85
|
+
(0, _classCallCheck2.default)(this, ExtrudePolyline);
|
|
86
|
+
(0, _defineProperty2.default)(this, "lastFlip", -1);
|
|
87
|
+
(0, _defineProperty2.default)(this, "miter", _glMatrix.vec2.fromValues(0, 0));
|
|
88
|
+
(0, _defineProperty2.default)(this, "started", false);
|
|
89
|
+
(0, _defineProperty2.default)(this, "dash", false);
|
|
90
|
+
(0, _defineProperty2.default)(this, "totalDistance", 0);
|
|
91
|
+
(0, _defineProperty2.default)(this, "currentIndex", 0);
|
|
92
|
+
this.join = opts.join || 'miter';
|
|
93
|
+
this.cap = opts.cap || 'butt';
|
|
63
94
|
this.miterLimit = opts.miterLimit || 10;
|
|
64
95
|
this.thickness = opts.thickness || 1;
|
|
65
96
|
this.dash = opts.dash || false;
|
|
@@ -71,381 +102,552 @@ var ExtrudePolyline = class {
|
|
|
71
102
|
indexes: []
|
|
72
103
|
};
|
|
73
104
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.totalDistance = 0;
|
|
83
|
-
const total = points.length;
|
|
84
|
-
let count = complex.startIndex;
|
|
85
|
-
for (let i = 1; i < total; i++) {
|
|
86
|
-
const last = points[i - 1];
|
|
87
|
-
const cur = points[i];
|
|
88
|
-
const next = i < points.length - 1 ? points[i + 1] : null;
|
|
89
|
-
const amt = this.simpleSegment(complex, count, last, cur, next);
|
|
90
|
-
count += amt;
|
|
91
|
-
}
|
|
92
|
-
if (this.dash) {
|
|
93
|
-
for (let i = 0; i < complex.positions.length / 6; i++) {
|
|
94
|
-
complex.positions[i * 6 + 5] = this.totalDistance;
|
|
105
|
+
|
|
106
|
+
(0, _createClass2.default)(ExtrudePolyline, [{
|
|
107
|
+
key: "simpleExtrude",
|
|
108
|
+
value: function simpleExtrude(points) {
|
|
109
|
+
var complex = this.complex;
|
|
110
|
+
|
|
111
|
+
if (points.length <= 1) {
|
|
112
|
+
return complex;
|
|
95
113
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
|
|
115
|
+
this.lastFlip = -1;
|
|
116
|
+
this.started = false;
|
|
117
|
+
this.normal = null;
|
|
118
|
+
this.totalDistance = 0;
|
|
119
|
+
var total = points.length;
|
|
120
|
+
var count = complex.startIndex;
|
|
121
|
+
|
|
122
|
+
for (var i = 1; i < total; i++) {
|
|
123
|
+
var last = points[i - 1];
|
|
124
|
+
var cur = points[i];
|
|
125
|
+
var next = i < points.length - 1 ? points[i + 1] : null;
|
|
126
|
+
var amt = this.simpleSegment(complex, count, last, cur, next);
|
|
127
|
+
count += amt;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.dash) {
|
|
131
|
+
for (var _i = 0; _i < complex.positions.length / 6; _i++) {
|
|
132
|
+
complex.positions[_i * 6 + 5] = this.totalDistance;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
complex.startIndex = complex.positions.length / 6;
|
|
103
137
|
return complex;
|
|
104
138
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const last = points[i - 1];
|
|
113
|
-
last.push(originPoints[i - 1][2] ?? 0);
|
|
114
|
-
const originLast = originPoints[i - 1];
|
|
115
|
-
const cur = points[i];
|
|
116
|
-
cur.push(originPoints[i][2] ?? 0);
|
|
117
|
-
const originCur = originPoints[i];
|
|
118
|
-
const next = i < points.length - 1 ? [...points[i + 1], originPoints[i + 1][2] ?? 0] : null;
|
|
119
|
-
const originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
|
|
120
|
-
const amt = this.simpleSegment(complex, count, last, cur, next, originLast, originCur, originNext);
|
|
121
|
-
count += amt;
|
|
122
|
-
}
|
|
123
|
-
if (this.dash) {
|
|
124
|
-
for (let i = 0; i < complex.positions.length / 6; i++) {
|
|
125
|
-
complex.positions[i * 6 + 5] = this.totalDistance;
|
|
139
|
+
}, {
|
|
140
|
+
key: "simpleExtrude_gaode2",
|
|
141
|
+
value: function simpleExtrude_gaode2(points, originPoints) {
|
|
142
|
+
var complex = this.complex;
|
|
143
|
+
|
|
144
|
+
if (points.length <= 1) {
|
|
145
|
+
return complex;
|
|
126
146
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
|
|
148
|
+
this.lastFlip = -1;
|
|
149
|
+
this.started = false;
|
|
150
|
+
this.normal = null;
|
|
151
|
+
this.totalDistance = 0; // 去除数组里重复的点
|
|
152
|
+
// points = getArrayUnique(points);
|
|
153
|
+
|
|
154
|
+
var total = points.length;
|
|
155
|
+
var count = complex.startIndex;
|
|
156
|
+
|
|
157
|
+
for (var i = 1; i < total; i++) {
|
|
158
|
+
var _originPoints$, _originPoints$i$, _originPoints$2;
|
|
159
|
+
|
|
160
|
+
var last = points[i - 1];
|
|
161
|
+
last.push((_originPoints$ = originPoints[i - 1][2]) !== null && _originPoints$ !== void 0 ? _originPoints$ : 0); // @ts-ignore
|
|
162
|
+
|
|
163
|
+
var originLast = originPoints[i - 1];
|
|
164
|
+
var cur = points[i];
|
|
165
|
+
cur.push((_originPoints$i$ = originPoints[i][2]) !== null && _originPoints$i$ !== void 0 ? _originPoints$i$ : 0); // @ts-ignore
|
|
166
|
+
|
|
167
|
+
var originCur = originPoints[i];
|
|
168
|
+
var next = i < points.length - 1 ? [].concat((0, _toConsumableArray2.default)(points[i + 1]), [(_originPoints$2 = originPoints[i + 1][2]) !== null && _originPoints$2 !== void 0 ? _originPoints$2 : 0]) : null;
|
|
169
|
+
var originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
|
|
170
|
+
var amt = this.simpleSegment(complex, count, // @ts-ignore
|
|
171
|
+
last, // @ts-ignore
|
|
172
|
+
cur, // @ts-ignore
|
|
173
|
+
next, // @ts-ignore
|
|
174
|
+
originLast, originCur, // @ts-ignore
|
|
175
|
+
originNext);
|
|
176
|
+
count += amt;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.dash) {
|
|
180
|
+
for (var _i2 = 0; _i2 < complex.positions.length / 6; _i2++) {
|
|
181
|
+
complex.positions[_i2 * 6 + 5] = this.totalDistance;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
complex.startIndex = complex.positions.length / 6;
|
|
134
186
|
return complex;
|
|
135
187
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const last = points[i - 1];
|
|
144
|
-
last.push(originPoints[i - 1][2] ?? 0);
|
|
145
|
-
const originLast = originPoints[i - 1];
|
|
146
|
-
const cur = points[i];
|
|
147
|
-
cur.push(originPoints[i][2] ?? 0);
|
|
148
|
-
const originCur = originPoints[i];
|
|
149
|
-
const next = i < points.length - 1 ? [...points[i + 1], originPoints[i + 1][2] ?? 0] : null;
|
|
150
|
-
const originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
|
|
151
|
-
const amt = this.segment_gaode2(complex, count, last, cur, next, originLast, originCur, originNext);
|
|
152
|
-
count += amt;
|
|
153
|
-
}
|
|
154
|
-
if (this.dash) {
|
|
155
|
-
for (let i = 0; i < complex.positions.length / 6; i++) {
|
|
156
|
-
complex.positions[i * 6 + 5] = this.totalDistance;
|
|
188
|
+
}, {
|
|
189
|
+
key: "extrude_gaode2",
|
|
190
|
+
value: function extrude_gaode2(points, originPoints) {
|
|
191
|
+
var complex = this.complex;
|
|
192
|
+
|
|
193
|
+
if (points.length <= 1) {
|
|
194
|
+
return complex;
|
|
157
195
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
196
|
+
|
|
197
|
+
this.lastFlip = -1;
|
|
198
|
+
this.started = false;
|
|
199
|
+
this.normal = null;
|
|
200
|
+
this.totalDistance = 0; // 去除数组里重复的点
|
|
201
|
+
// points = getArrayUnique(points);
|
|
202
|
+
|
|
203
|
+
var total = points.length;
|
|
204
|
+
var count = complex.startIndex;
|
|
205
|
+
|
|
206
|
+
for (var i = 1; i < total; i++) {
|
|
207
|
+
var _originPoints$3, _originPoints$i$2, _originPoints$4;
|
|
208
|
+
|
|
209
|
+
var last = points[i - 1];
|
|
210
|
+
last.push((_originPoints$3 = originPoints[i - 1][2]) !== null && _originPoints$3 !== void 0 ? _originPoints$3 : 0); // @ts-ignore
|
|
211
|
+
|
|
212
|
+
var originLast = originPoints[i - 1];
|
|
213
|
+
var cur = points[i];
|
|
214
|
+
cur.push((_originPoints$i$2 = originPoints[i][2]) !== null && _originPoints$i$2 !== void 0 ? _originPoints$i$2 : 0); // @ts-ignore
|
|
215
|
+
|
|
216
|
+
var originCur = originPoints[i];
|
|
217
|
+
var next = i < points.length - 1 ? [].concat((0, _toConsumableArray2.default)(points[i + 1]), [(_originPoints$4 = originPoints[i + 1][2]) !== null && _originPoints$4 !== void 0 ? _originPoints$4 : 0]) : null;
|
|
218
|
+
var originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
|
|
219
|
+
var amt = this.segment_gaode2(complex, count, // @ts-ignore
|
|
220
|
+
last, // @ts-ignore
|
|
221
|
+
cur, // @ts-ignore
|
|
222
|
+
next, // @ts-ignore
|
|
223
|
+
originLast, originCur, // @ts-ignore
|
|
224
|
+
originNext);
|
|
225
|
+
count += amt;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (this.dash) {
|
|
229
|
+
for (var _i3 = 0; _i3 < complex.positions.length / 6; _i3++) {
|
|
230
|
+
complex.positions[_i3 * 6 + 5] = this.totalDistance;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
complex.startIndex = complex.positions.length / 6;
|
|
165
235
|
return complex;
|
|
166
236
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const last = points[i - 1];
|
|
175
|
-
const cur = points[i];
|
|
176
|
-
const next = i < points.length - 1 ? points[i + 1] : null;
|
|
177
|
-
const amt = this.segment(complex, count, last, cur, next);
|
|
178
|
-
count += amt;
|
|
179
|
-
}
|
|
180
|
-
if (this.dash) {
|
|
181
|
-
for (let i = 0; i < complex.positions.length / 6; i++) {
|
|
182
|
-
complex.positions[i * 6 + 5] = this.totalDistance;
|
|
237
|
+
}, {
|
|
238
|
+
key: "extrude",
|
|
239
|
+
value: function extrude(points) {
|
|
240
|
+
var complex = this.complex;
|
|
241
|
+
|
|
242
|
+
if (points.length <= 1) {
|
|
243
|
+
return complex;
|
|
183
244
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
if (!this.normal) {
|
|
202
|
-
this.normal = import_gl_matrix.vec2.create();
|
|
203
|
-
computeNormal(this.normal, lineA);
|
|
204
|
-
}
|
|
205
|
-
if (!this.started) {
|
|
206
|
-
this.started = true;
|
|
207
|
-
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
208
|
-
}
|
|
209
|
-
indices.push(index + 0, index + 1, index + 2);
|
|
210
|
-
if (!next) {
|
|
211
|
-
computeNormal(this.normal, lineA);
|
|
212
|
-
this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
|
|
213
|
-
indices.push(...this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]);
|
|
214
|
-
count += 2;
|
|
215
|
-
} else {
|
|
216
|
-
const flatNext = (0, import_l7_utils.aProjectFlat)([next[0], next[1]]);
|
|
217
|
-
if (isPointEqual(flatCur, flatNext)) {
|
|
218
|
-
import_gl_matrix.vec2.add(flatNext, flatCur, import_gl_matrix.vec2.normalize(flatNext, import_gl_matrix.vec2.subtract(flatNext, flatCur, flatLast)));
|
|
245
|
+
|
|
246
|
+
this.lastFlip = -1;
|
|
247
|
+
this.started = false;
|
|
248
|
+
this.normal = null;
|
|
249
|
+
this.totalDistance = 0; // 去除数组里重复的点
|
|
250
|
+
// points = getArrayUnique(points);
|
|
251
|
+
|
|
252
|
+
var total = points.length;
|
|
253
|
+
var count = complex.startIndex;
|
|
254
|
+
|
|
255
|
+
for (var i = 1; i < total; i++) {
|
|
256
|
+
var last = points[i - 1];
|
|
257
|
+
var cur = points[i];
|
|
258
|
+
var next = i < points.length - 1 ? points[i + 1] : null;
|
|
259
|
+
var amt = this.segment(complex, count, last, cur, next);
|
|
260
|
+
count += amt;
|
|
219
261
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
flip = -1;
|
|
226
|
-
import_gl_matrix.vec2.copy(this.normal, miter);
|
|
227
|
-
count += 2;
|
|
228
|
-
this.lastFlip = flip;
|
|
229
|
-
}
|
|
230
|
-
return count;
|
|
231
|
-
}
|
|
232
|
-
segment_gaode2(complex, index, last, cur, next, originLast, originCur, originNext) {
|
|
233
|
-
let count = 0;
|
|
234
|
-
const indices = complex.indices;
|
|
235
|
-
const positions = complex.positions;
|
|
236
|
-
const normals = complex.normals;
|
|
237
|
-
const capSquare = this.cap === "square";
|
|
238
|
-
const joinBevel = this.join === "bevel";
|
|
239
|
-
const flatCur = (0, import_l7_utils.aProjectFlat)([originCur[0], originCur[1]]);
|
|
240
|
-
const flatLast = (0, import_l7_utils.aProjectFlat)([originLast[0], originLast[1]]);
|
|
241
|
-
direction(lineA, cur, last);
|
|
242
|
-
let segmentDistance = 0;
|
|
243
|
-
if (this.dash) {
|
|
244
|
-
segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
|
|
245
|
-
this.totalDistance += segmentDistance;
|
|
246
|
-
}
|
|
247
|
-
if (!this.normal) {
|
|
248
|
-
this.normal = import_gl_matrix.vec2.create();
|
|
249
|
-
computeNormal(this.normal, lineA);
|
|
250
|
-
}
|
|
251
|
-
if (!this.started) {
|
|
252
|
-
this.started = true;
|
|
253
|
-
if (capSquare) {
|
|
254
|
-
const out1 = import_gl_matrix.vec2.create();
|
|
255
|
-
const out2 = import_gl_matrix.vec2.create();
|
|
256
|
-
import_gl_matrix.vec2.add(out1, this.normal, lineA);
|
|
257
|
-
import_gl_matrix.vec2.add(out2, this.normal, lineA);
|
|
258
|
-
normals.push(out2[0], out2[1], 0);
|
|
259
|
-
normals.push(out1[0], out1[1], 0);
|
|
260
|
-
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
|
|
261
|
-
this.complex.indexes.push(this.currentIndex);
|
|
262
|
-
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, this.thickness, last[2] | 0);
|
|
263
|
-
this.complex.indexes.push(this.currentIndex);
|
|
264
|
-
this.currentIndex++;
|
|
265
|
-
} else {
|
|
266
|
-
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
262
|
+
|
|
263
|
+
if (this.dash) {
|
|
264
|
+
for (var _i4 = 0; _i4 < complex.positions.length / 6; _i4++) {
|
|
265
|
+
complex.positions[_i4 * 6 + 5] = this.totalDistance;
|
|
266
|
+
}
|
|
267
267
|
}
|
|
268
|
+
|
|
269
|
+
complex.startIndex = complex.positions.length / 6;
|
|
270
|
+
return complex;
|
|
268
271
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
this.
|
|
272
|
+
}, {
|
|
273
|
+
key: "simpleSegment",
|
|
274
|
+
value: function simpleSegment(complex, index, last, cur, next) {
|
|
275
|
+
var count = 0;
|
|
276
|
+
var indices = complex.indices;
|
|
277
|
+
var positions = complex.positions;
|
|
278
|
+
var normals = complex.normals;
|
|
279
|
+
var flatCur = (0, _l7Utils.aProjectFlat)([cur[0], cur[1]]);
|
|
280
|
+
var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]); // @ts-ignore
|
|
281
|
+
|
|
282
|
+
direction(lineA, flatCur, flatLast);
|
|
283
|
+
var segmentDistance = 0;
|
|
284
|
+
|
|
285
|
+
if (this.dash) {
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
|
|
288
|
+
this.totalDistance += segmentDistance;
|
|
286
289
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
import_gl_matrix.vec2.add(next, cur, import_gl_matrix.vec2.normalize(next, import_gl_matrix.vec2.subtract(next, cur, last)));
|
|
290
|
+
|
|
291
|
+
if (!this.normal) {
|
|
292
|
+
this.normal = _glMatrix.vec2.create();
|
|
293
|
+
computeNormal(this.normal, lineA);
|
|
292
294
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (!bevel && this.join === "miter") {
|
|
298
|
-
const limit = miterLen;
|
|
299
|
-
if (limit > this.miterLimit) {
|
|
300
|
-
bevel = true;
|
|
301
|
-
}
|
|
295
|
+
|
|
296
|
+
if (!this.started) {
|
|
297
|
+
this.started = true;
|
|
298
|
+
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
302
299
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
indices.push(...this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]);
|
|
312
|
-
indices.push(index + 2, index + 3, index + 4);
|
|
313
|
-
computeNormal(tmp, lineB);
|
|
314
|
-
import_gl_matrix.vec2.copy(this.normal, tmp);
|
|
315
|
-
normals.push(this.normal[0], this.normal[1], 0);
|
|
316
|
-
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
317
|
-
this.complex.indexes.push(this.currentIndex);
|
|
318
|
-
this.currentIndex++;
|
|
319
|
-
count += 3;
|
|
300
|
+
|
|
301
|
+
indices.push(index + 0, index + 1, index + 2);
|
|
302
|
+
|
|
303
|
+
if (!next) {
|
|
304
|
+
computeNormal(this.normal, lineA);
|
|
305
|
+
this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
|
|
306
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
307
|
+
count += 2;
|
|
320
308
|
} else {
|
|
309
|
+
var flatNext = (0, _l7Utils.aProjectFlat)([next[0], next[1]]);
|
|
310
|
+
|
|
311
|
+
if (isPointEqual(flatCur, flatNext)) {
|
|
312
|
+
_glMatrix.vec2.add(flatNext, flatCur, _glMatrix.vec2.normalize(flatNext, _glMatrix.vec2.subtract(flatNext, flatCur, flatLast)));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
direction(lineB, flatNext, flatCur); // stores tangent & miter
|
|
316
|
+
|
|
317
|
+
var _computeMiter = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
|
|
318
|
+
_computeMiter2 = (0, _slicedToArray2.default)(_computeMiter, 2),
|
|
319
|
+
miterLen = _computeMiter2[0],
|
|
320
|
+
miter = _computeMiter2[1]; // normal(tmp, lineA)
|
|
321
|
+
// get orientation
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
var flip = _glMatrix.vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
|
|
321
325
|
this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
|
|
322
|
-
indices.push(
|
|
323
|
-
flip = -1;
|
|
324
|
-
|
|
326
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
327
|
+
flip = -1; // the miter is now the normal for our next join
|
|
328
|
+
|
|
329
|
+
_glMatrix.vec2.copy(this.normal, miter);
|
|
330
|
+
|
|
325
331
|
count += 2;
|
|
332
|
+
this.lastFlip = flip;
|
|
326
333
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
return count;
|
|
330
|
-
}
|
|
331
|
-
segment(complex, index, last, cur, next) {
|
|
332
|
-
let count = 0;
|
|
333
|
-
const indices = complex.indices;
|
|
334
|
-
const positions = complex.positions;
|
|
335
|
-
const normals = complex.normals;
|
|
336
|
-
const capSquare = this.cap === "square";
|
|
337
|
-
const joinBevel = this.join === "bevel";
|
|
338
|
-
const flatCur = (0, import_l7_utils.aProjectFlat)([cur[0], cur[1]]);
|
|
339
|
-
const flatLast = (0, import_l7_utils.aProjectFlat)([last[0], last[1]]);
|
|
340
|
-
direction(lineA, flatCur, flatLast);
|
|
341
|
-
let segmentDistance = 0;
|
|
342
|
-
if (this.dash) {
|
|
343
|
-
segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
|
|
344
|
-
this.totalDistance += segmentDistance;
|
|
345
|
-
}
|
|
346
|
-
if (!this.normal) {
|
|
347
|
-
this.normal = import_gl_matrix.vec2.create();
|
|
348
|
-
computeNormal(this.normal, lineA);
|
|
334
|
+
|
|
335
|
+
return count;
|
|
349
336
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
337
|
+
}, {
|
|
338
|
+
key: "segment_gaode2",
|
|
339
|
+
value: function segment_gaode2(complex, index, last, cur, next, originLast, originCur, originNext) {
|
|
340
|
+
var count = 0;
|
|
341
|
+
var indices = complex.indices;
|
|
342
|
+
var positions = complex.positions;
|
|
343
|
+
var normals = complex.normals;
|
|
344
|
+
var capSquare = this.cap === 'square';
|
|
345
|
+
var joinBevel = this.join === 'bevel';
|
|
346
|
+
var flatCur = (0, _l7Utils.aProjectFlat)([originCur[0], originCur[1]]);
|
|
347
|
+
var flatLast = (0, _l7Utils.aProjectFlat)([originLast[0], originLast[1]]); // @ts-ignore
|
|
348
|
+
|
|
349
|
+
direction(lineA, cur, last);
|
|
350
|
+
var segmentDistance = 0;
|
|
351
|
+
|
|
352
|
+
if (this.dash) {
|
|
353
|
+
// @ts-ignore
|
|
354
|
+
segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
|
|
355
|
+
this.totalDistance += segmentDistance;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (!this.normal) {
|
|
359
|
+
this.normal = _glMatrix.vec2.create();
|
|
360
|
+
computeNormal(this.normal, lineA);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (!this.started) {
|
|
364
|
+
this.started = true; // if the end cap is type square, we can just push the verts out a bit
|
|
365
|
+
|
|
366
|
+
if (capSquare) {
|
|
367
|
+
// vec2.scaleAndAdd(capEnd, last, lineA, -this.thickness);
|
|
368
|
+
var out1 = _glMatrix.vec2.create();
|
|
369
|
+
|
|
370
|
+
var out2 = _glMatrix.vec2.create();
|
|
371
|
+
|
|
372
|
+
_glMatrix.vec2.add(out1, this.normal, lineA);
|
|
373
|
+
|
|
374
|
+
_glMatrix.vec2.add(out2, this.normal, lineA);
|
|
375
|
+
|
|
376
|
+
normals.push(out2[0], out2[1], 0);
|
|
377
|
+
normals.push(out1[0], out1[1], 0);
|
|
378
|
+
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
|
|
379
|
+
this.complex.indexes.push(this.currentIndex);
|
|
380
|
+
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, this.thickness, last[2] | 0);
|
|
381
|
+
this.complex.indexes.push(this.currentIndex);
|
|
382
|
+
this.currentIndex++;
|
|
383
|
+
} else {
|
|
384
|
+
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
indices.push(index + 0, index + 1, index + 2);
|
|
389
|
+
|
|
390
|
+
if (!next) {
|
|
391
|
+
computeNormal(this.normal, lineA);
|
|
392
|
+
|
|
393
|
+
if (capSquare) {
|
|
394
|
+
var _out = _glMatrix.vec2.create();
|
|
395
|
+
|
|
396
|
+
var _out2 = _glMatrix.vec2.create();
|
|
397
|
+
|
|
398
|
+
_glMatrix.vec2.sub(_out2, lineA, this.normal);
|
|
399
|
+
|
|
400
|
+
_glMatrix.vec2.add(_out, lineA, this.normal);
|
|
401
|
+
|
|
402
|
+
normals.push(_out2[0], _out2[1], 0);
|
|
403
|
+
normals.push(_out[0], _out[1], 0);
|
|
404
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
405
|
+
this.complex.indexes.push(this.currentIndex);
|
|
406
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
407
|
+
this.complex.indexes.push(this.currentIndex);
|
|
408
|
+
this.currentIndex++;
|
|
409
|
+
} else {
|
|
410
|
+
this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
414
|
+
count += 2;
|
|
364
415
|
} else {
|
|
365
|
-
|
|
416
|
+
// @ts-ignore
|
|
417
|
+
if (isPointEqual(cur, next)) {
|
|
418
|
+
_glMatrix.vec2.add( // @ts-ignore
|
|
419
|
+
next, // @ts-ignore
|
|
420
|
+
cur, _glMatrix.vec2.normalize( // @ts-ignore
|
|
421
|
+
next, // @ts-ignore
|
|
422
|
+
_glMatrix.vec2.subtract(next, cur, last)));
|
|
423
|
+
} // @ts-ignore
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
direction(lineB, next, cur); // stores tangent & miter
|
|
427
|
+
|
|
428
|
+
var _computeMiter3 = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
|
|
429
|
+
_computeMiter4 = (0, _slicedToArray2.default)(_computeMiter3, 2),
|
|
430
|
+
miterLen = _computeMiter4[0],
|
|
431
|
+
miter = _computeMiter4[1]; // normal(tmp, lineA)
|
|
432
|
+
// get orientation
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
var flip = _glMatrix.vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
|
|
436
|
+
var bevel = joinBevel;
|
|
437
|
+
|
|
438
|
+
if (!bevel && this.join === 'miter') {
|
|
439
|
+
var limit = miterLen;
|
|
440
|
+
|
|
441
|
+
if (limit > this.miterLimit) {
|
|
442
|
+
bevel = true;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (bevel) {
|
|
447
|
+
normals.push(this.normal[0], this.normal[1], 0);
|
|
448
|
+
normals.push(miter[0], miter[1], 0);
|
|
449
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
450
|
+
this.complex.indexes.push(this.currentIndex);
|
|
451
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness * flip, cur[2] | 0);
|
|
452
|
+
this.complex.indexes.push(this.currentIndex);
|
|
453
|
+
this.currentIndex++;
|
|
454
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3])); // now add the bevel triangle
|
|
455
|
+
|
|
456
|
+
indices.push(index + 2, index + 3, index + 4);
|
|
457
|
+
computeNormal(tmp, lineB);
|
|
458
|
+
|
|
459
|
+
_glMatrix.vec2.copy(this.normal, tmp); // store normal for next round
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
normals.push(this.normal[0], this.normal[1], 0);
|
|
463
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
464
|
+
this.complex.indexes.push(this.currentIndex);
|
|
465
|
+
this.currentIndex++;
|
|
466
|
+
count += 3;
|
|
467
|
+
} else {
|
|
468
|
+
this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
|
|
469
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
470
|
+
flip = -1; // the miter is now the normal for our next join
|
|
471
|
+
|
|
472
|
+
_glMatrix.vec2.copy(this.normal, miter);
|
|
473
|
+
|
|
474
|
+
count += 2;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
this.lastFlip = flip;
|
|
366
478
|
}
|
|
479
|
+
|
|
480
|
+
return count;
|
|
367
481
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
482
|
+
}, {
|
|
483
|
+
key: "segment",
|
|
484
|
+
value: function segment(complex, index, last, cur, next) {
|
|
485
|
+
var count = 0;
|
|
486
|
+
var indices = complex.indices;
|
|
487
|
+
var positions = complex.positions;
|
|
488
|
+
var normals = complex.normals;
|
|
489
|
+
var capSquare = this.cap === 'square';
|
|
490
|
+
var joinBevel = this.join === 'bevel';
|
|
491
|
+
var flatCur = (0, _l7Utils.aProjectFlat)([cur[0], cur[1]]);
|
|
492
|
+
var flatLast = (0, _l7Utils.aProjectFlat)([last[0], last[1]]); // @ts-ignore
|
|
493
|
+
|
|
494
|
+
direction(lineA, flatCur, flatLast);
|
|
495
|
+
var segmentDistance = 0;
|
|
496
|
+
|
|
497
|
+
if (this.dash) {
|
|
498
|
+
// @ts-ignore
|
|
499
|
+
segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
|
|
500
|
+
this.totalDistance += segmentDistance;
|
|
385
501
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (isPointEqual(flatCur, flatNext)) {
|
|
391
|
-
import_gl_matrix.vec2.add(flatNext, flatCur, import_gl_matrix.vec2.normalize(flatNext, import_gl_matrix.vec2.subtract(flatNext, flatCur, flatLast)));
|
|
502
|
+
|
|
503
|
+
if (!this.normal) {
|
|
504
|
+
this.normal = _glMatrix.vec2.create();
|
|
505
|
+
computeNormal(this.normal, lineA);
|
|
392
506
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
507
|
+
|
|
508
|
+
if (!this.started) {
|
|
509
|
+
this.started = true; // if the end cap is type square, we can just push the verts out a bit
|
|
510
|
+
|
|
511
|
+
if (capSquare) {
|
|
512
|
+
// vec2.scaleAndAdd(capEnd, last, lineA, -this.thickness);
|
|
513
|
+
var out1 = _glMatrix.vec2.create();
|
|
514
|
+
|
|
515
|
+
var out2 = _glMatrix.vec2.create();
|
|
516
|
+
|
|
517
|
+
_glMatrix.vec2.add(out1, this.normal, lineA);
|
|
518
|
+
|
|
519
|
+
_glMatrix.vec2.add(out2, this.normal, lineA);
|
|
520
|
+
|
|
521
|
+
normals.push(out2[0], out2[1], 0);
|
|
522
|
+
normals.push(out1[0], out1[1], 0);
|
|
523
|
+
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, -this.thickness, last[2] | 0);
|
|
524
|
+
this.complex.indexes.push(this.currentIndex);
|
|
525
|
+
positions.push(last[0], last[1], last[2] | 0, this.totalDistance - segmentDistance, this.thickness, last[2] | 0);
|
|
526
|
+
this.complex.indexes.push(this.currentIndex);
|
|
527
|
+
this.currentIndex++; // this.extrusions(positions, normals, last, out, this.thickness);
|
|
528
|
+
// last = capEnd;
|
|
529
|
+
} else {
|
|
530
|
+
this.extrusions(positions, normals, last, this.normal, this.thickness, this.totalDistance - segmentDistance);
|
|
401
531
|
}
|
|
402
532
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
533
|
+
|
|
534
|
+
indices.push(index + 0, index + 1, index + 2);
|
|
535
|
+
|
|
536
|
+
if (!next) {
|
|
537
|
+
computeNormal(this.normal, lineA);
|
|
538
|
+
|
|
539
|
+
if (capSquare) {
|
|
540
|
+
// vec2.scaleAndAdd(capEnd, cur, lineA, this.thickness);
|
|
541
|
+
// cur = capEnd;
|
|
542
|
+
var _out3 = _glMatrix.vec2.create();
|
|
543
|
+
|
|
544
|
+
var _out4 = _glMatrix.vec2.create();
|
|
545
|
+
|
|
546
|
+
_glMatrix.vec2.sub(_out4, lineA, this.normal);
|
|
547
|
+
|
|
548
|
+
_glMatrix.vec2.add(_out3, lineA, this.normal); // this.extrusions(positions, normals, cur, out, this.thickness);
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
normals.push(_out4[0], _out4[1], 0);
|
|
552
|
+
normals.push(_out3[0], _out3[1], 0);
|
|
553
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
554
|
+
this.complex.indexes.push(this.currentIndex);
|
|
555
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness, cur[2] | 0);
|
|
556
|
+
this.complex.indexes.push(this.currentIndex);
|
|
557
|
+
this.currentIndex++;
|
|
558
|
+
} else {
|
|
559
|
+
this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
|
|
560
|
+
} // this.extrusions(positions, normals, cur, this.normal, this.thickness);
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
425
564
|
count += 2;
|
|
565
|
+
} else {
|
|
566
|
+
var flatNext = (0, _l7Utils.aProjectFlat)([next[0], next[1]]);
|
|
567
|
+
|
|
568
|
+
if (isPointEqual(flatCur, flatNext)) {
|
|
569
|
+
_glMatrix.vec2.add(flatNext, flatCur, _glMatrix.vec2.normalize(flatNext, _glMatrix.vec2.subtract(flatNext, flatCur, flatLast)));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
direction(lineB, flatNext, flatCur); // stores tangent & miter
|
|
573
|
+
|
|
574
|
+
var _computeMiter5 = computeMiter(tangent, _glMatrix.vec2.create(), lineA, lineB, this.thickness),
|
|
575
|
+
_computeMiter6 = (0, _slicedToArray2.default)(_computeMiter5, 2),
|
|
576
|
+
miterLen = _computeMiter6[0],
|
|
577
|
+
miter = _computeMiter6[1]; // normal(tmp, lineA)
|
|
578
|
+
// get orientation
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
var flip = _glMatrix.vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
|
|
582
|
+
var bevel = joinBevel;
|
|
583
|
+
|
|
584
|
+
if (!bevel && this.join === 'miter') {
|
|
585
|
+
var limit = miterLen;
|
|
586
|
+
|
|
587
|
+
if (limit > this.miterLimit) {
|
|
588
|
+
bevel = true;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
if (bevel) {
|
|
593
|
+
normals.push(this.normal[0], this.normal[1], 0);
|
|
594
|
+
normals.push(miter[0], miter[1], 0);
|
|
595
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
596
|
+
this.complex.indexes.push(this.currentIndex);
|
|
597
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, this.thickness * flip, cur[2] | 0);
|
|
598
|
+
this.complex.indexes.push(this.currentIndex);
|
|
599
|
+
this.currentIndex++;
|
|
600
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3])); // now add the bevel triangle
|
|
601
|
+
|
|
602
|
+
indices.push(index + 2, index + 3, index + 4);
|
|
603
|
+
computeNormal(tmp, lineB);
|
|
604
|
+
|
|
605
|
+
_glMatrix.vec2.copy(this.normal, tmp); // store normal for next round
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
normals.push(this.normal[0], this.normal[1], 0);
|
|
609
|
+
positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);
|
|
610
|
+
this.complex.indexes.push(this.currentIndex);
|
|
611
|
+
this.currentIndex++;
|
|
612
|
+
count += 3;
|
|
613
|
+
} else {
|
|
614
|
+
this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
|
|
615
|
+
indices.push.apply(indices, (0, _toConsumableArray2.default)(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
|
|
616
|
+
flip = -1; // the miter is now the normal for our next join
|
|
617
|
+
|
|
618
|
+
_glMatrix.vec2.copy(this.normal, miter);
|
|
619
|
+
|
|
620
|
+
count += 2;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
this.lastFlip = flip;
|
|
426
624
|
}
|
|
427
|
-
|
|
625
|
+
|
|
626
|
+
return count;
|
|
428
627
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
628
|
+
}, {
|
|
629
|
+
key: "extrusions",
|
|
630
|
+
value: function extrusions(positions, normals, point, // 顶点
|
|
631
|
+
normal, // 法向量
|
|
632
|
+
thickness, // 高度
|
|
633
|
+
distanceRadio) {
|
|
634
|
+
normals.push(normal[0], normal[1], 0);
|
|
635
|
+
normals.push(normal[0], normal[1], 0);
|
|
636
|
+
positions.push(point[0], point[1], point[2] | 0, distanceRadio, -thickness, point[2] | 0);
|
|
637
|
+
this.complex.indexes.push(this.currentIndex);
|
|
638
|
+
positions.push(point[0], point[1], point[2] | 0, distanceRadio, thickness, point[2] | 0);
|
|
639
|
+
this.complex.indexes.push(this.currentIndex);
|
|
640
|
+
this.currentIndex++;
|
|
641
|
+
}
|
|
642
|
+
}, {
|
|
643
|
+
key: "lineSegmentDistance",
|
|
644
|
+
value: function lineSegmentDistance(b1, a1) {
|
|
645
|
+
var dx = a1[0] - b1[0];
|
|
646
|
+
var dy = a1[1] - b1[1];
|
|
647
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
648
|
+
}
|
|
649
|
+
}]);
|
|
650
|
+
return ExtrudePolyline;
|
|
651
|
+
}();
|
|
652
|
+
|
|
653
|
+
exports.default = ExtrudePolyline;
|