@antv/l7-layers 2.17.3 → 2.17.4
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 +478 -313
- package/es/core/BaseModel.js +80 -51
- package/es/core/CommonStyleAttribute.js +5 -2
- 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 +39 -27
- package/es/core/triangulation.js +136 -99
- 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 +149 -92
- 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 +35 -9
- package/es/line/models/arc.js +112 -63
- package/es/line/models/arc_3d.js +102 -58
- package/es/line/models/earthArc_3d.js +105 -60
- package/es/line/models/flow.js +60 -36
- package/es/line/models/great_circle.js +94 -53
- package/es/line/models/line.js +136 -85
- package/es/line/models/linearline.js +74 -42
- package/es/line/models/simpleLine.js +67 -38
- 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 +114 -78
- 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 +108 -69
- 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 +78 -26
- package/es/point/models/earthExtrude.js +95 -58
- package/es/point/models/earthFill.js +80 -52
- package/es/point/models/extrude.js +94 -57
- package/es/point/models/fill.js +81 -56
- package/es/point/models/fillmage.js +100 -60
- package/es/point/models/image.js +83 -47
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +54 -30
- package/es/point/models/radar.js +63 -38
- package/es/point/models/simplePoint.js +62 -38
- package/es/point/models/text.js +296 -199
- package/es/point/shape/extrude.js +13 -4
- package/es/polygon/index.js +41 -11
- package/es/polygon/models/extrude.js +135 -87
- package/es/polygon/models/fill.js +79 -50
- 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/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 +469 -313
- package/lib/core/BaseModel.js +90 -51
- package/lib/core/CommonStyleAttribute.js +7 -2
- 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 +62 -27
- package/lib/core/triangulation.js +177 -98
- 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 +166 -92
- 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 +122 -61
- package/lib/line/models/arc_3d.js +113 -56
- package/lib/line/models/earthArc_3d.js +115 -58
- package/lib/line/models/flow.js +70 -36
- package/lib/line/models/great_circle.js +104 -53
- package/lib/line/models/index.js +11 -0
- package/lib/line/models/line.js +144 -83
- package/lib/line/models/linearline.js +86 -42
- package/lib/line/models/simpleLine.js +77 -38
- 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 +125 -78
- 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 +117 -70
- 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 +106 -58
- package/lib/point/models/earthFill.js +110 -52
- package/lib/point/models/extrude.js +103 -57
- package/lib/point/models/fill.js +90 -54
- package/lib/point/models/fillmage.js +107 -58
- package/lib/point/models/image.js +92 -47
- package/lib/point/models/index.js +12 -1
- package/lib/point/models/normal.js +64 -30
- package/lib/point/models/radar.js +72 -38
- package/lib/point/models/simplePoint.js +72 -38
- package/lib/point/models/text.js +305 -199
- package/lib/point/shape/extrude.js +20 -4
- package/lib/polygon/index.js +48 -11
- package/lib/polygon/models/extrude.js +146 -87
- package/lib/polygon/models/fill.js +89 -50
- 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/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
package/es/utils/grid-index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
|
|
4
5
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
|
+
|
|
5
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* 网格索引,相比 @mapbox/grid-index,在简单计算碰撞检测结果时效率更高
|
|
9
13
|
* @see https://zhuanlan.zhihu.com/p/74373214
|
|
@@ -11,13 +15,17 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
15
|
var GridIndex = /*#__PURE__*/function () {
|
|
12
16
|
function GridIndex(width, height, cellSize) {
|
|
13
17
|
_classCallCheck(this, GridIndex);
|
|
18
|
+
|
|
14
19
|
_defineProperty(this, "boxCells", []);
|
|
20
|
+
|
|
15
21
|
var boxCells = this.boxCells;
|
|
16
22
|
this.xCellCount = Math.ceil(width / cellSize);
|
|
17
23
|
this.yCellCount = Math.ceil(height / cellSize);
|
|
24
|
+
|
|
18
25
|
for (var i = 0; i < this.xCellCount * this.yCellCount; i++) {
|
|
19
26
|
boxCells.push([]);
|
|
20
27
|
}
|
|
28
|
+
|
|
21
29
|
this.boxKeys = [];
|
|
22
30
|
this.bboxes = [];
|
|
23
31
|
this.width = width;
|
|
@@ -26,6 +34,7 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
26
34
|
this.yScale = this.yCellCount / height;
|
|
27
35
|
this.boxUid = 0;
|
|
28
36
|
}
|
|
37
|
+
|
|
29
38
|
_createClass(GridIndex, [{
|
|
30
39
|
key: "insert",
|
|
31
40
|
value: function insert(key, x1, y1, x2, y2) {
|
|
@@ -57,12 +66,15 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
57
66
|
if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {
|
|
58
67
|
return hitTest ? false : [];
|
|
59
68
|
}
|
|
69
|
+
|
|
60
70
|
var result = [];
|
|
71
|
+
|
|
61
72
|
if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {
|
|
62
73
|
// 这一步是高效的关键,后续精确碰撞检测结果在计算文本可见性时并不需要
|
|
63
74
|
if (hitTest) {
|
|
64
75
|
return true;
|
|
65
76
|
}
|
|
77
|
+
|
|
66
78
|
for (var boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {
|
|
67
79
|
result.push({
|
|
68
80
|
key: this.boxKeys[boxUid],
|
|
@@ -72,8 +84,10 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
72
84
|
y2: this.bboxes[boxUid * 4 + 3]
|
|
73
85
|
});
|
|
74
86
|
}
|
|
87
|
+
|
|
75
88
|
return predicate ? result.filter(predicate) : result;
|
|
76
89
|
}
|
|
90
|
+
|
|
77
91
|
var queryArgs = {
|
|
78
92
|
hitTest: hitTest,
|
|
79
93
|
seenUids: {
|
|
@@ -89,21 +103,27 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
89
103
|
value: function queryCell(x1, y1, x2, y2, cellIndex, result, queryArgs, predicate) {
|
|
90
104
|
var seenUids = queryArgs.seenUids;
|
|
91
105
|
var boxCell = this.boxCells[cellIndex];
|
|
106
|
+
|
|
92
107
|
if (boxCell !== null) {
|
|
93
108
|
var bboxes = this.bboxes;
|
|
109
|
+
|
|
94
110
|
var _iterator = _createForOfIteratorHelper(boxCell),
|
|
95
|
-
|
|
111
|
+
_step;
|
|
112
|
+
|
|
96
113
|
try {
|
|
97
114
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
98
115
|
var boxUid = _step.value;
|
|
116
|
+
|
|
99
117
|
if (!seenUids.box[boxUid]) {
|
|
100
118
|
seenUids.box[boxUid] = true;
|
|
101
119
|
var offset = boxUid * 4;
|
|
120
|
+
|
|
102
121
|
if (x1 <= bboxes[offset + 2] && y1 <= bboxes[offset + 3] && x2 >= bboxes[offset + 0] && y2 >= bboxes[offset + 1] && (!predicate || predicate(this.boxKeys[boxUid]))) {
|
|
103
122
|
if (queryArgs.hitTest) {
|
|
104
123
|
result.push(true);
|
|
105
124
|
return true;
|
|
106
125
|
}
|
|
126
|
+
|
|
107
127
|
result.push({
|
|
108
128
|
key: this.boxKeys[boxUid],
|
|
109
129
|
x1: bboxes[offset],
|
|
@@ -120,6 +140,7 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
120
140
|
_iterator.f();
|
|
121
141
|
}
|
|
122
142
|
}
|
|
143
|
+
|
|
123
144
|
return false;
|
|
124
145
|
}
|
|
125
146
|
}, {
|
|
@@ -129,9 +150,11 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
129
150
|
var cy1 = this.convertToYCellCoord(y1);
|
|
130
151
|
var cx2 = this.convertToXCellCoord(x2);
|
|
131
152
|
var cy2 = this.convertToYCellCoord(y2);
|
|
153
|
+
|
|
132
154
|
for (var x = cx1; x <= cx2; x++) {
|
|
133
155
|
for (var y = cy1; y <= cy2; y++) {
|
|
134
156
|
var cellIndex = this.xCellCount * y + x;
|
|
157
|
+
|
|
135
158
|
if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) {
|
|
136
159
|
return;
|
|
137
160
|
}
|
|
@@ -149,6 +172,8 @@ var GridIndex = /*#__PURE__*/function () {
|
|
|
149
172
|
return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));
|
|
150
173
|
}
|
|
151
174
|
}]);
|
|
175
|
+
|
|
152
176
|
return GridIndex;
|
|
153
177
|
}();
|
|
178
|
+
|
|
154
179
|
export default GridIndex;
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
export default function identity(d) {
|
|
2
2
|
var unknown;
|
|
3
3
|
var domain = [];
|
|
4
|
+
|
|
4
5
|
function scale(x) {
|
|
5
6
|
return x == null ? unknown : x;
|
|
6
7
|
}
|
|
8
|
+
|
|
7
9
|
scale.invert = scale;
|
|
10
|
+
|
|
8
11
|
scale.domain = scale.range = function (v) {
|
|
9
12
|
if (v) {
|
|
10
13
|
domain = v;
|
|
11
14
|
return v;
|
|
12
15
|
}
|
|
16
|
+
|
|
13
17
|
return domain;
|
|
14
18
|
};
|
|
19
|
+
|
|
15
20
|
scale.unknown = function (v) {
|
|
16
21
|
if (v) {
|
|
17
22
|
unknown = v;
|
|
18
23
|
return v;
|
|
19
24
|
}
|
|
25
|
+
|
|
20
26
|
return unknown;
|
|
21
27
|
};
|
|
28
|
+
|
|
22
29
|
scale.copy = function () {
|
|
23
30
|
return identity(d).unknown(unknown);
|
|
24
31
|
};
|
|
32
|
+
|
|
25
33
|
return scale;
|
|
26
34
|
}
|
package/es/utils/layerData.js
CHANGED
|
@@ -2,49 +2,53 @@ import { Version } from '@antv/l7-maps';
|
|
|
2
2
|
import Source from '@antv/l7-source';
|
|
3
3
|
import { normalize, rgb2arr } from '@antv/l7-utils';
|
|
4
4
|
import { cloneDeep } from 'lodash';
|
|
5
|
+
|
|
5
6
|
function getArrowPoints(p1, p2) {
|
|
6
7
|
var dir = [p2[0] - p1[0], p2[1] - p1[1]];
|
|
7
8
|
var normalizeDir = normalize(dir);
|
|
8
9
|
var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
|
|
9
10
|
return arrowPoint;
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
function adjustData2Amap2Coordinates(mappedData, mapService, layer) {
|
|
12
14
|
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
13
15
|
if (mappedData.length > 0 && mapService.version === Version['GAODE2.x']) {
|
|
14
16
|
var layerCenter = layer.coordCenter;
|
|
17
|
+
|
|
15
18
|
if (typeof mappedData[0].coordinates[0] === 'number') {
|
|
16
19
|
// 单个的点数据
|
|
17
20
|
// @ts-ignore
|
|
18
|
-
mappedData
|
|
19
|
-
// 避免经纬度被重复计算导致坐标位置偏移
|
|
21
|
+
mappedData // 避免经纬度被重复计算导致坐标位置偏移
|
|
20
22
|
.filter(function (d) {
|
|
21
23
|
return !d.originCoordinates;
|
|
22
24
|
}).map(function (d) {
|
|
23
|
-
d.version = Version['GAODE2.x'];
|
|
24
|
-
|
|
25
|
+
d.version = Version['GAODE2.x']; // @ts-ignore
|
|
26
|
+
|
|
25
27
|
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
26
28
|
// @ts-ignore
|
|
27
29
|
// d.coordinates = mapService.lngLatToCoord(d.coordinates);
|
|
30
|
+
|
|
28
31
|
d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
|
|
29
32
|
});
|
|
30
33
|
} else {
|
|
31
34
|
// 连续的线、面数据
|
|
32
35
|
// @ts-ignore
|
|
33
|
-
mappedData
|
|
34
|
-
// 避免经纬度被重复计算导致坐标位置偏移
|
|
36
|
+
mappedData // 避免经纬度被重复计算导致坐标位置偏移
|
|
35
37
|
.filter(function (d) {
|
|
36
38
|
return !d.originCoordinates;
|
|
37
39
|
}).map(function (d) {
|
|
38
|
-
d.version = Version['GAODE2.x'];
|
|
39
|
-
|
|
40
|
+
d.version = Version['GAODE2.x']; // @ts-ignore
|
|
41
|
+
|
|
40
42
|
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
41
43
|
// @ts-ignore
|
|
42
44
|
// d.coordinates = mapService.lngLatToCoords(d.coordinates);
|
|
45
|
+
|
|
43
46
|
d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
51
|
+
|
|
48
52
|
function adjustData2SimpleCoordinates(mappedData, mapService) {
|
|
49
53
|
if (mappedData.length > 0 && mapService.version === Version.SIMPLE) {
|
|
50
54
|
mappedData.map(function (d) {
|
|
@@ -55,10 +59,12 @@ function adjustData2SimpleCoordinates(mappedData, mapService) {
|
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
}
|
|
62
|
+
|
|
58
63
|
function unProjectCoordinates(coordinates, mapService) {
|
|
59
64
|
if (typeof coordinates[0] === 'number') {
|
|
60
65
|
return mapService.simpleMapCoord.unproject(coordinates);
|
|
61
66
|
}
|
|
67
|
+
|
|
62
68
|
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
63
69
|
// @ts-ignore
|
|
64
70
|
var coords = [];
|
|
@@ -67,33 +73,38 @@ function unProjectCoordinates(coordinates, mapService) {
|
|
|
67
73
|
var c1 = [];
|
|
68
74
|
coord.map(function (co) {
|
|
69
75
|
c1.push(mapService.simpleMapCoord.unproject(co));
|
|
70
|
-
});
|
|
71
|
-
|
|
76
|
+
}); // @ts-ignore
|
|
77
|
+
|
|
72
78
|
coords.push(c1);
|
|
73
|
-
});
|
|
74
|
-
|
|
79
|
+
}); // @ts-ignore
|
|
80
|
+
|
|
75
81
|
return coords;
|
|
76
82
|
} else {
|
|
77
83
|
// @ts-ignore
|
|
78
|
-
var _coords = [];
|
|
79
|
-
|
|
84
|
+
var _coords = []; // @ts-ignore
|
|
85
|
+
|
|
80
86
|
coordinates.map(function (coord) {
|
|
81
87
|
_coords.push(mapService.simpleMapCoord.unproject(coord));
|
|
82
|
-
});
|
|
83
|
-
|
|
88
|
+
}); // @ts-ignore
|
|
89
|
+
|
|
84
90
|
return _coords;
|
|
85
91
|
}
|
|
86
92
|
}
|
|
93
|
+
|
|
87
94
|
function applyAttributeMapping(attribute, record) {
|
|
88
95
|
var _attribute$scale;
|
|
96
|
+
|
|
89
97
|
if (!attribute.scale) {
|
|
90
98
|
return [];
|
|
91
99
|
}
|
|
100
|
+
|
|
92
101
|
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
93
102
|
var params = [];
|
|
94
103
|
scalers.forEach(function (_ref) {
|
|
95
104
|
var _attribute$scale2;
|
|
105
|
+
|
|
96
106
|
var field = _ref.field;
|
|
107
|
+
|
|
97
108
|
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
98
109
|
// TODO:多字段,常量
|
|
99
110
|
params.push(record[field]);
|
|
@@ -102,12 +113,14 @@ function applyAttributeMapping(attribute, record) {
|
|
|
102
113
|
var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
|
|
103
114
|
return mappingResult;
|
|
104
115
|
}
|
|
116
|
+
|
|
105
117
|
function mapping(attributes, data, fontService, mapService, layer) {
|
|
106
118
|
var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
_ref2$arrow = _ref2.arrow,
|
|
120
|
+
arrow = _ref2$arrow === void 0 ? {
|
|
121
|
+
enable: false
|
|
122
|
+
} : _ref2$arrow;
|
|
123
|
+
|
|
111
124
|
var mappedData = data.map(function (record) {
|
|
112
125
|
var encodeRecord = {
|
|
113
126
|
id: record._id,
|
|
@@ -117,37 +130,38 @@ function mapping(attributes, data, fontService, mapService, layer) {
|
|
|
117
130
|
return attribute.scale !== undefined;
|
|
118
131
|
}).forEach(function (attribute) {
|
|
119
132
|
var values = applyAttributeMapping(attribute, record);
|
|
120
|
-
attribute.needRemapping = false;
|
|
133
|
+
attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
|
|
121
134
|
|
|
122
|
-
// TODO: 支持每个属性配置 postprocess
|
|
123
135
|
if (attribute.name === 'color') {
|
|
124
136
|
values = values.map(function (c) {
|
|
125
137
|
return rgb2arr(c);
|
|
126
138
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
} // @ts-ignore
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
|
|
130
143
|
|
|
131
|
-
// 增加对 layer/text/iconfont unicode 映射的解析
|
|
132
144
|
if (attribute.name === 'shape') {
|
|
133
145
|
encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
134
146
|
}
|
|
135
147
|
});
|
|
148
|
+
|
|
136
149
|
if (encodeRecord.shape === 'line' && arrow.enable) {
|
|
137
150
|
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
138
151
|
var coords = encodeRecord.coordinates;
|
|
139
152
|
var arrowPoint = getArrowPoints(coords[0], coords[1]);
|
|
140
153
|
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
141
154
|
}
|
|
155
|
+
|
|
142
156
|
return encodeRecord;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
adjustData2Amap2Coordinates(mappedData, mapService, layer);
|
|
157
|
+
}); // 调整数据兼容 Amap2.0
|
|
158
|
+
|
|
159
|
+
adjustData2Amap2Coordinates(mappedData, mapService, layer); // 调整数据兼容 SimpleCoordinates
|
|
146
160
|
|
|
147
|
-
// 调整数据兼容 SimpleCoordinates
|
|
148
161
|
adjustData2SimpleCoordinates(mappedData, mapService);
|
|
149
162
|
return mappedData;
|
|
150
163
|
}
|
|
164
|
+
|
|
151
165
|
export function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
|
|
152
166
|
var source = new Source(data, options);
|
|
153
167
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* 'blurH' -> ['blurH', {}]
|
|
4
5
|
*/
|
|
@@ -7,41 +8,42 @@ export function normalizePasses(passes) {
|
|
|
7
8
|
if (typeof pass === 'string') {
|
|
8
9
|
pass = [pass, {}];
|
|
9
10
|
}
|
|
11
|
+
|
|
10
12
|
return pass;
|
|
11
13
|
});
|
|
12
14
|
}
|
|
13
|
-
|
|
14
15
|
/**
|
|
15
16
|
* 默认添加 ClearPass、RenderPass
|
|
16
17
|
* 以及 PostProcessing 中的最后一个 CopyPass
|
|
17
18
|
*/
|
|
19
|
+
|
|
18
20
|
export function createMultiPassRenderer(layer, passes, postProcessingPassFactory, normalPassFactory) {
|
|
19
21
|
var multiPassRenderer = layer.multiPassRenderer;
|
|
20
|
-
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
21
|
-
enableTAA = _layer$getLayerConfig.enableTAA;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
24
|
+
enableTAA = _layer$getLayerConfig.enableTAA; // picking pass if enabled
|
|
24
25
|
// if (enablePicking) {
|
|
25
26
|
// multiPassRenderer.add(normalPassFactory('pixelPicking'));
|
|
26
27
|
// }
|
|
27
|
-
|
|
28
28
|
// use TAA pass if enabled instead of render pass
|
|
29
|
+
|
|
30
|
+
|
|
29
31
|
if (enableTAA) {
|
|
30
32
|
multiPassRenderer.add(normalPassFactory('taa'));
|
|
31
33
|
} else {
|
|
32
34
|
// render all layers in this pass
|
|
33
35
|
multiPassRenderer.add(normalPassFactory('render'));
|
|
34
|
-
}
|
|
36
|
+
} // post processing
|
|
37
|
+
|
|
35
38
|
|
|
36
|
-
// post processing
|
|
37
39
|
normalizePasses(passes).forEach(function (pass) {
|
|
38
40
|
var _pass = _slicedToArray(pass, 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
passName = _pass[0],
|
|
42
|
+
initializationOptions = _pass[1];
|
|
43
|
+
|
|
41
44
|
multiPassRenderer.add(postProcessingPassFactory(passName), initializationOptions);
|
|
42
|
-
});
|
|
45
|
+
}); // 末尾为固定的 CopyPass
|
|
43
46
|
|
|
44
|
-
// 末尾为固定的 CopyPass
|
|
45
47
|
multiPassRenderer.add(postProcessingPassFactory('copy'));
|
|
46
48
|
return multiPassRenderer;
|
|
47
49
|
}
|
|
@@ -18,24 +18,29 @@ export function direction(out, a, b) {
|
|
|
18
18
|
vec2.normalize(out, out);
|
|
19
19
|
return out;
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
function extrusions(positions, out, miters, point, normal, scale) {
|
|
22
23
|
addNext(out, miters, normal, -scale);
|
|
23
24
|
addNext(out, miters, normal, scale);
|
|
24
25
|
positions.push(point[0], point[1], 0);
|
|
25
26
|
positions.push(point[0], point[1], 0);
|
|
26
27
|
}
|
|
28
|
+
|
|
27
29
|
function addNext(out, miters, normal, length) {
|
|
28
30
|
out.push(normal[0], normal[1], 0);
|
|
29
31
|
miters.push(length);
|
|
30
32
|
}
|
|
33
|
+
|
|
31
34
|
function lineSegmentDistance(b1, a1) {
|
|
32
35
|
var dx = a1[0] - b1[0];
|
|
33
36
|
var dy = a1[1] - b1[1];
|
|
34
37
|
return Math.sqrt(dx * dx + dy * dy);
|
|
35
38
|
}
|
|
39
|
+
|
|
36
40
|
function isPointEqual(a, b) {
|
|
37
41
|
return a[0] === b[0] && a[1] === b[1];
|
|
38
42
|
}
|
|
43
|
+
|
|
39
44
|
export default function (points, closed, indexOffset) {
|
|
40
45
|
var isDash = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
41
46
|
var lineA = vec2.fromValues(0, 0);
|
|
@@ -52,46 +57,55 @@ export default function (points, closed, indexOffset) {
|
|
|
52
57
|
var attrIndex = [];
|
|
53
58
|
var miters = [];
|
|
54
59
|
var attrDistance = [0, 0];
|
|
60
|
+
|
|
55
61
|
if (closed) {
|
|
56
62
|
points = points.slice();
|
|
57
63
|
points.push(points[0]);
|
|
58
64
|
}
|
|
65
|
+
|
|
59
66
|
var total = points.length;
|
|
67
|
+
|
|
60
68
|
for (var i = 1; i < total; i++) {
|
|
61
69
|
var index = count;
|
|
62
70
|
var last = vec2.fromValues(points[i - 1][0], points[i - 1][1]);
|
|
63
71
|
var cur = vec2.fromValues(points[i][0], points[i][1]);
|
|
64
|
-
var next = i < points.length - 1 ? vec2.fromValues(points[i + 1][0], points[i + 1][1]) : null;
|
|
65
|
-
|
|
72
|
+
var next = i < points.length - 1 ? vec2.fromValues(points[i + 1][0], points[i + 1][1]) : null; // 如果当前点和前一点相同,跳过
|
|
73
|
+
|
|
66
74
|
if (isPointEqual(last, cur)) {
|
|
67
75
|
continue;
|
|
68
76
|
}
|
|
77
|
+
|
|
69
78
|
if (next) {
|
|
70
|
-
var nextIndex = i + 1;
|
|
71
|
-
|
|
79
|
+
var nextIndex = i + 1; // 找到不相同的下一点
|
|
80
|
+
|
|
72
81
|
while (next && isPointEqual(cur, next)) {
|
|
73
82
|
next = nextIndex < points.length - 1 ? vec2.fromValues(points[++nextIndex][0], points[nextIndex][1]) : null;
|
|
74
83
|
}
|
|
75
84
|
}
|
|
85
|
+
|
|
76
86
|
var d = 0;
|
|
77
87
|
var flatCur = aProjectFlat([cur[0], cur[1]]);
|
|
78
88
|
var flatLast = aProjectFlat([last[0], last[1]]);
|
|
89
|
+
|
|
79
90
|
if (isDash) {
|
|
80
91
|
var lineDistance = lineSegmentDistance(flatCur, flatLast);
|
|
81
92
|
d = lineDistance + attrDistance[attrDistance.length - 1];
|
|
82
93
|
}
|
|
94
|
+
|
|
83
95
|
direction(lineA, flatCur, flatLast);
|
|
96
|
+
|
|
84
97
|
if (!lineNormal) {
|
|
85
98
|
lineNormal = vec2.create();
|
|
86
99
|
computeNormal(lineNormal, lineA);
|
|
87
100
|
}
|
|
101
|
+
|
|
88
102
|
if (!started) {
|
|
89
103
|
started = true;
|
|
90
104
|
extrusions(attrPos, out, miters, last, lineNormal, 1);
|
|
91
105
|
}
|
|
92
|
-
attrIndex.push(index + 0, index + 2, index + 1);
|
|
93
106
|
|
|
94
|
-
// no miter, simple segment
|
|
107
|
+
attrIndex.push(index + 0, index + 2, index + 1); // no miter, simple segment
|
|
108
|
+
|
|
95
109
|
if (!next) {
|
|
96
110
|
// reset normal
|
|
97
111
|
computeNormal(lineNormal, lineA);
|
|
@@ -100,18 +114,14 @@ export default function (points, closed, indexOffset) {
|
|
|
100
114
|
attrIndex.push(index + 1, index + 2, index + 3);
|
|
101
115
|
count += 2;
|
|
102
116
|
} else {
|
|
103
|
-
var flatNext = aProjectFlat([next[0], next[1]]);
|
|
104
|
-
// get unit dir of next line
|
|
105
|
-
direction(lineB, flatNext, flatCur);
|
|
117
|
+
var flatNext = aProjectFlat([next[0], next[1]]); // get unit dir of next line
|
|
106
118
|
|
|
107
|
-
// stores tangent & miter
|
|
108
|
-
var miterLen = computeMiter(tangent, vec2.fromValues(miter[0], miter[1]), lineA, lineB, 1);
|
|
119
|
+
direction(lineB, flatNext, flatCur); // stores tangent & miter
|
|
109
120
|
|
|
110
|
-
// get orientation
|
|
111
|
-
var flip = vec2.dot(tangent, lineNormal) < 0 ? -1 : 1;
|
|
112
|
-
var bevel = Math.abs(miterLen) > miterLimit;
|
|
121
|
+
var miterLen = computeMiter(tangent, vec2.fromValues(miter[0], miter[1]), lineA, lineB, 1); // get orientation
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
var flip = vec2.dot(tangent, lineNormal) < 0 ? -1 : 1;
|
|
124
|
+
var bevel = Math.abs(miterLen) > miterLimit; // 处理前后两条线段重合的情况,这种情况不需要使用任何接头(miter/bevel)。
|
|
115
125
|
// 理论上这种情况下 miterLen = Infinity,本应通过 isFinite(miterLen) 判断,
|
|
116
126
|
// 但是 AMap 投影变换后丢失精度,只能通过一个阈值(1000)判断。
|
|
117
127
|
|
|
@@ -123,35 +133,31 @@ export default function (points, closed, indexOffset) {
|
|
|
123
133
|
vec2.copy(lineNormal, tmp); // store normal for next round
|
|
124
134
|
|
|
125
135
|
extrusions(attrPos, out, miters, cur, lineNormal, 1);
|
|
126
|
-
attrDistance.push(d, d, d, d);
|
|
136
|
+
attrDistance.push(d, d, d, d); // the miter is now the normal for our next join
|
|
127
137
|
|
|
128
|
-
// the miter is now the normal for our next join
|
|
129
138
|
count += 4;
|
|
130
139
|
continue;
|
|
131
140
|
}
|
|
141
|
+
|
|
132
142
|
if (bevel) {
|
|
133
|
-
miterLen = miterLimit;
|
|
143
|
+
miterLen = miterLimit; // next two points in our first segment
|
|
134
144
|
|
|
135
|
-
// next two points in our first segment
|
|
136
145
|
extrusions(attrPos, out, miters, cur, lineNormal, 1);
|
|
137
|
-
attrIndex.push(index + 1, index + 2, index + 3);
|
|
146
|
+
attrIndex.push(index + 1, index + 2, index + 3); // now add the bevel triangle
|
|
138
147
|
|
|
139
|
-
// now add the bevel triangle
|
|
140
148
|
attrIndex.push.apply(attrIndex, _toConsumableArray(flip === 1 ? [index + 2, index + 4, index + 5] : [index + 4, index + 5, index + 3]));
|
|
141
149
|
computeNormal(tmp, lineB);
|
|
142
150
|
vec2.copy(lineNormal, tmp); // store normal for next round
|
|
143
151
|
|
|
144
152
|
extrusions(attrPos, out, miters, cur, lineNormal, 1);
|
|
145
|
-
attrDistance.push(d, d, d, d);
|
|
153
|
+
attrDistance.push(d, d, d, d); // the miter is now the normal for our next join
|
|
146
154
|
|
|
147
|
-
// the miter is now the normal for our next join
|
|
148
155
|
count += 4;
|
|
149
156
|
} else {
|
|
150
157
|
// next two points in our first segment
|
|
151
158
|
extrusions(attrPos, out, miters, cur, lineNormal, 1);
|
|
152
|
-
attrIndex.push(index + 1, index + 2, index + 3);
|
|
159
|
+
attrIndex.push(index + 1, index + 2, index + 3); // now add the miter triangles
|
|
153
160
|
|
|
154
|
-
// now add the miter triangles
|
|
155
161
|
addNext(out, miters, lineNormal, miterLen * -flip);
|
|
156
162
|
attrPos.push(cur[0], cur[1], 0);
|
|
157
163
|
attrIndex.push(index + 2, index + 4, index + 3);
|
|
@@ -160,18 +166,18 @@ export default function (points, closed, indexOffset) {
|
|
|
160
166
|
vec2.copy(lineNormal, tmp); // store normal for next round
|
|
161
167
|
|
|
162
168
|
extrusions(attrPos, out, miters, cur, lineNormal, 1);
|
|
163
|
-
attrDistance.push(d, d, d, d, d);
|
|
169
|
+
attrDistance.push(d, d, d, d, d); // the miter is now the normal for our next join
|
|
164
170
|
|
|
165
|
-
// the miter is now the normal for our next join
|
|
166
171
|
count += 5;
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
}
|
|
175
|
+
|
|
170
176
|
var pickData = [];
|
|
177
|
+
|
|
171
178
|
for (var _i = 0; _i < miters.length; _i++) {
|
|
172
179
|
var totalDistance = attrDistance[attrDistance.length - 1];
|
|
173
|
-
pickData.push(attrPos[_i * 3], attrPos[_i * 3 + 1], attrPos[_i * 3 + 2], attrDistance[_i],
|
|
174
|
-
// dash
|
|
180
|
+
pickData.push(attrPos[_i * 3], attrPos[_i * 3 + 1], attrPos[_i * 3 + 2], attrDistance[_i], // dash
|
|
175
181
|
miters[_i], totalDistance // dash
|
|
176
182
|
);
|
|
177
183
|
}
|
|
@@ -180,6 +186,6 @@ export default function (points, closed, indexOffset) {
|
|
|
180
186
|
normals: out,
|
|
181
187
|
attrIndex: attrIndex,
|
|
182
188
|
attrPos: pickData // [x,y,z, distance, miter ,t0tal ]
|
|
189
|
+
|
|
183
190
|
};
|
|
184
|
-
}
|
|
185
|
-
// [x,y,z, distance, miter ]
|
|
191
|
+
} // [x,y,z, distance, miter ]
|
package/es/utils/simpleLine.js
CHANGED
|
@@ -9,12 +9,17 @@ export function direction(out, a, b) {
|
|
|
9
9
|
vec2.normalize(out, out);
|
|
10
10
|
return out;
|
|
11
11
|
}
|
|
12
|
+
|
|
12
13
|
var ExtrudePolyline = /*#__PURE__*/function () {
|
|
13
14
|
function ExtrudePolyline() {
|
|
14
15
|
_classCallCheck(this, ExtrudePolyline);
|
|
16
|
+
|
|
15
17
|
_defineProperty(this, "started", false);
|
|
18
|
+
|
|
16
19
|
_defineProperty(this, "totalDistance", 0);
|
|
20
|
+
|
|
17
21
|
_defineProperty(this, "currentIndex", 0);
|
|
22
|
+
|
|
18
23
|
this.complex = {
|
|
19
24
|
positions: [],
|
|
20
25
|
indices: [],
|
|
@@ -22,26 +27,32 @@ var ExtrudePolyline = /*#__PURE__*/function () {
|
|
|
22
27
|
indexes: []
|
|
23
28
|
};
|
|
24
29
|
}
|
|
30
|
+
|
|
25
31
|
_createClass(ExtrudePolyline, [{
|
|
26
32
|
key: "simpleExtrude",
|
|
27
33
|
value: function simpleExtrude(points) {
|
|
28
34
|
var complex = this.complex;
|
|
35
|
+
|
|
29
36
|
if (points.length <= 1) {
|
|
30
37
|
return complex;
|
|
31
38
|
}
|
|
39
|
+
|
|
32
40
|
this.started = false;
|
|
33
41
|
this.totalDistance = 0;
|
|
34
42
|
var total = points.length;
|
|
35
43
|
var count = complex.startIndex;
|
|
44
|
+
|
|
36
45
|
for (var i = 1; i < total; i++) {
|
|
37
46
|
var last = points[i - 1];
|
|
38
47
|
var cur = points[i];
|
|
39
48
|
var amt = this.simpleSegment(complex, count, last, cur);
|
|
40
49
|
count += amt;
|
|
41
50
|
}
|
|
51
|
+
|
|
42
52
|
for (var _i = 0; _i < complex.positions.length / 6; _i++) {
|
|
43
53
|
complex.positions[_i * 6 + 5] = this.totalDistance;
|
|
44
54
|
}
|
|
55
|
+
|
|
45
56
|
return complex;
|
|
46
57
|
}
|
|
47
58
|
}, {
|
|
@@ -55,10 +66,12 @@ var ExtrudePolyline = /*#__PURE__*/function () {
|
|
|
55
66
|
direction(lineA, flatCur, flatLast);
|
|
56
67
|
var segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
|
|
57
68
|
this.totalDistance += segmentDistance;
|
|
69
|
+
|
|
58
70
|
if (!this.started) {
|
|
59
71
|
this.started = true;
|
|
60
72
|
this.extrusions(positions, last, this.totalDistance - segmentDistance);
|
|
61
73
|
}
|
|
74
|
+
|
|
62
75
|
this.extrusions(positions, cur, this.totalDistance);
|
|
63
76
|
indices.push(index + 0, index + 1, index + 2);
|
|
64
77
|
indices.push(index + 2, index + 1, index + 3);
|
|
@@ -67,8 +80,7 @@ var ExtrudePolyline = /*#__PURE__*/function () {
|
|
|
67
80
|
}
|
|
68
81
|
}, {
|
|
69
82
|
key: "extrusions",
|
|
70
|
-
value: function extrusions(positions, point,
|
|
71
|
-
// 顶点
|
|
83
|
+
value: function extrusions(positions, point, // 顶点
|
|
72
84
|
distanceRadio) {
|
|
73
85
|
positions.push(point[0], point[1], point[2] | 0, distanceRadio, 0, point[2] | 0);
|
|
74
86
|
this.complex.indexes.push(this.currentIndex);
|
|
@@ -84,6 +96,8 @@ var ExtrudePolyline = /*#__PURE__*/function () {
|
|
|
84
96
|
return Math.sqrt(dx * dx + dy * dy);
|
|
85
97
|
}
|
|
86
98
|
}]);
|
|
99
|
+
|
|
87
100
|
return ExtrudePolyline;
|
|
88
101
|
}();
|
|
102
|
+
|
|
89
103
|
export { ExtrudePolyline as default };
|