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