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