@antv/l7-layers 2.16.0 → 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 +485 -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.js +301 -198
- 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 +479 -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 +309 -198
- 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
package/es/core/triangulation.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import { calculateCentroid, calculatePointsCenterAndRadius, lngLatToMeters } from '@antv/l7-utils';
|
|
4
|
-
import earcut from 'earcut';
|
|
5
|
-
|
|
4
|
+
import earcut from 'earcut'; // @ts-ignore
|
|
5
|
+
|
|
6
6
|
import { vec3 } from 'gl-matrix';
|
|
7
7
|
import { EARTH_RADIUS, EARTH_RADIUS_OUTER, EARTH_SEGMENTS, lglt2xyz, primitiveSphere } from "../earth/utils";
|
|
8
8
|
import ExtrudePolyline from "../utils/extrude_polyline";
|
|
9
9
|
import extrudePolygon, { extrude_PolygonNormal, fillPolygon } from "./shape/extrude";
|
|
10
10
|
import { geometryShape } from "./shape/Path";
|
|
11
11
|
var GeometryCache = {};
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* 计算2D 填充点图顶点
|
|
15
14
|
* @param feature 映射feature
|
|
@@ -27,6 +26,7 @@ export function PointFillTriangulation(feature) {
|
|
|
27
26
|
* 计算2D 填充点图顶点 (地球模式)
|
|
28
27
|
* @param feature 映射feature
|
|
29
28
|
*/
|
|
29
|
+
|
|
30
30
|
export function GlobelPointFillTriangulation(feature) {
|
|
31
31
|
var coordinates = calculateCentroid(feature.coordinates);
|
|
32
32
|
var xyz = lglt2xyz(coordinates);
|
|
@@ -36,17 +36,19 @@ export function GlobelPointFillTriangulation(feature) {
|
|
|
36
36
|
size: xyz.length
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
|
|
40
39
|
/**
|
|
41
40
|
* 计算3D 拉伸点图
|
|
42
41
|
* @param feature 映射feature
|
|
43
42
|
*/
|
|
43
|
+
|
|
44
44
|
export function PointExtrudeTriangulation(feature) {
|
|
45
45
|
var shape = feature.shape;
|
|
46
|
+
|
|
46
47
|
var _getGeometry = getGeometry(shape, false),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
positions = _getGeometry.positions,
|
|
49
|
+
index = _getGeometry.index,
|
|
50
|
+
normals = _getGeometry.normals;
|
|
51
|
+
|
|
50
52
|
return {
|
|
51
53
|
vertices: positions,
|
|
52
54
|
indices: index,
|
|
@@ -54,11 +56,11 @@ export function PointExtrudeTriangulation(feature) {
|
|
|
54
56
|
size: 5
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
|
-
|
|
58
59
|
/**
|
|
59
60
|
* 计算图片标注
|
|
60
61
|
* @param feature 映射feature
|
|
61
62
|
*/
|
|
63
|
+
|
|
62
64
|
export function PointImageTriangulation(feature) {
|
|
63
65
|
var coordinates = calculateCentroid(feature.coordinates);
|
|
64
66
|
return {
|
|
@@ -67,16 +69,15 @@ export function PointImageTriangulation(feature) {
|
|
|
67
69
|
size: coordinates.length
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
|
-
|
|
71
72
|
/**
|
|
72
73
|
* 线三角化
|
|
73
74
|
* @param feature 映射feature
|
|
74
75
|
*/
|
|
76
|
+
|
|
75
77
|
export function LineTriangulation(feature) {
|
|
76
78
|
var coordinates = feature.coordinates,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// let path = coordinates as number[][][] | number[][];
|
|
79
|
+
originCoordinates = feature.originCoordinates,
|
|
80
|
+
version = feature.version; // let path = coordinates as number[][][] | number[][];
|
|
80
81
|
// if (!Array.isArray(path[0][0])) {
|
|
81
82
|
// path = [coordinates] as number[][][];
|
|
82
83
|
// }
|
|
@@ -85,16 +86,21 @@ export function LineTriangulation(feature) {
|
|
|
85
86
|
dash: true,
|
|
86
87
|
join: 'bevel'
|
|
87
88
|
});
|
|
89
|
+
|
|
88
90
|
if (version === 'GAODE2.x') {
|
|
89
91
|
// 处理高德2.0几何体构建
|
|
90
92
|
var path1 = coordinates; // 计算位置
|
|
93
|
+
|
|
91
94
|
if (!Array.isArray(path1[0][0])) {
|
|
92
95
|
path1 = [coordinates];
|
|
93
96
|
}
|
|
97
|
+
|
|
94
98
|
var path2 = originCoordinates; // 计算法线
|
|
99
|
+
|
|
95
100
|
if (!Array.isArray(path2[0][0])) {
|
|
96
101
|
path2 = [originCoordinates];
|
|
97
102
|
}
|
|
103
|
+
|
|
98
104
|
for (var i = 0; i < path1.length; i++) {
|
|
99
105
|
// 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
|
|
100
106
|
var item1 = path1[i];
|
|
@@ -104,13 +110,16 @@ export function LineTriangulation(feature) {
|
|
|
104
110
|
} else {
|
|
105
111
|
// 处理非高德2.0的几何体构建
|
|
106
112
|
var path = coordinates;
|
|
113
|
+
|
|
107
114
|
if (path[0] && !Array.isArray(path[0][0])) {
|
|
108
115
|
path = [coordinates];
|
|
109
116
|
}
|
|
117
|
+
|
|
110
118
|
path.forEach(function (item) {
|
|
111
119
|
line.extrude(item);
|
|
112
120
|
});
|
|
113
121
|
}
|
|
122
|
+
|
|
114
123
|
var linebuffer = line.complex;
|
|
115
124
|
return {
|
|
116
125
|
vertices: linebuffer.positions,
|
|
@@ -124,6 +133,7 @@ export function LineTriangulation(feature) {
|
|
|
124
133
|
export function SimpleLineTriangulation(feature) {
|
|
125
134
|
var coordinates = feature.coordinates;
|
|
126
135
|
var pos = [];
|
|
136
|
+
|
|
127
137
|
if (!Array.isArray(coordinates[0])) {
|
|
128
138
|
return {
|
|
129
139
|
vertices: [],
|
|
@@ -133,9 +143,11 @@ export function SimpleLineTriangulation(feature) {
|
|
|
133
143
|
count: 0
|
|
134
144
|
};
|
|
135
145
|
}
|
|
146
|
+
|
|
136
147
|
var _getSimpleLineVertice = getSimpleLineVertices(coordinates),
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
results = _getSimpleLineVertice.results,
|
|
149
|
+
totalDistance = _getSimpleLineVertice.totalDistance;
|
|
150
|
+
|
|
139
151
|
results.map(function (point) {
|
|
140
152
|
pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
|
|
141
153
|
});
|
|
@@ -150,6 +162,7 @@ export function SimpleLineTriangulation(feature) {
|
|
|
150
162
|
export function TileSimpleLineTriangulation(feature) {
|
|
151
163
|
var coordinates = feature.coordinates;
|
|
152
164
|
var pos = [];
|
|
165
|
+
|
|
153
166
|
if (!Array.isArray(coordinates[0])) {
|
|
154
167
|
return {
|
|
155
168
|
vertices: [],
|
|
@@ -158,8 +171,10 @@ export function TileSimpleLineTriangulation(feature) {
|
|
|
158
171
|
count: 0
|
|
159
172
|
};
|
|
160
173
|
}
|
|
174
|
+
|
|
161
175
|
var _getTileSimpleLineVer = getTileSimpleLineVertices(coordinates),
|
|
162
|
-
|
|
176
|
+
results = _getTileSimpleLineVer.results;
|
|
177
|
+
|
|
163
178
|
results.map(function (point) {
|
|
164
179
|
pos.push(point[0], point[1], point[2], point[3]);
|
|
165
180
|
});
|
|
@@ -170,27 +185,35 @@ export function TileSimpleLineTriangulation(feature) {
|
|
|
170
185
|
count: results.length
|
|
171
186
|
};
|
|
172
187
|
}
|
|
188
|
+
|
|
173
189
|
function lineSegmentDistance(b1, a1) {
|
|
174
190
|
var dx = a1[0] - b1[0];
|
|
175
191
|
var dy = a1[1] - b1[1];
|
|
176
192
|
return Math.sqrt(dx * dx + dy * dy);
|
|
177
193
|
}
|
|
194
|
+
|
|
178
195
|
function pushDis(point, n) {
|
|
179
196
|
if (point.length < 3) {
|
|
180
197
|
point.push(0);
|
|
181
198
|
}
|
|
199
|
+
|
|
182
200
|
if (n !== undefined) {
|
|
183
201
|
point.push(n);
|
|
184
202
|
}
|
|
203
|
+
|
|
185
204
|
return point;
|
|
186
205
|
}
|
|
206
|
+
|
|
187
207
|
function getSimpleLineVertices(coordinates) {
|
|
188
208
|
var points = coordinates;
|
|
209
|
+
|
|
189
210
|
if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
|
|
190
211
|
// @ts-ignore
|
|
191
212
|
points = coordinates.flat();
|
|
192
213
|
}
|
|
214
|
+
|
|
193
215
|
var distance = 0;
|
|
216
|
+
|
|
194
217
|
if (points.length < 2) {
|
|
195
218
|
return {
|
|
196
219
|
results: points,
|
|
@@ -200,6 +223,7 @@ function getSimpleLineVertices(coordinates) {
|
|
|
200
223
|
var results = [];
|
|
201
224
|
var point = pushDis(points[0], distance);
|
|
202
225
|
results.push(point);
|
|
226
|
+
|
|
203
227
|
for (var i = 1; i < points.length - 1; i++) {
|
|
204
228
|
var subDistance = lineSegmentDistance(points[i - 1], points[i]);
|
|
205
229
|
distance += subDistance;
|
|
@@ -207,6 +231,7 @@ function getSimpleLineVertices(coordinates) {
|
|
|
207
231
|
results.push(mulPoint);
|
|
208
232
|
results.push(mulPoint);
|
|
209
233
|
}
|
|
234
|
+
|
|
210
235
|
var pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
|
|
211
236
|
distance += pointDistance;
|
|
212
237
|
results.push(pushDis(points[points.length - 1], distance));
|
|
@@ -216,6 +241,7 @@ function getSimpleLineVertices(coordinates) {
|
|
|
216
241
|
};
|
|
217
242
|
}
|
|
218
243
|
}
|
|
244
|
+
|
|
219
245
|
function getTileSimpleLineVertices(points) {
|
|
220
246
|
if (points.length < 2) {
|
|
221
247
|
return {
|
|
@@ -225,61 +251,70 @@ function getTileSimpleLineVertices(points) {
|
|
|
225
251
|
var results = [];
|
|
226
252
|
var point = pushDis(points[0]);
|
|
227
253
|
results.push(point);
|
|
254
|
+
|
|
228
255
|
for (var i = 1; i < points.length - 1; i++) {
|
|
229
256
|
var mulPoint = pushDis(points[i]);
|
|
230
257
|
results.push(mulPoint);
|
|
231
258
|
results.push(mulPoint);
|
|
232
259
|
}
|
|
260
|
+
|
|
233
261
|
results.push(pushDis(points[points.length - 1]));
|
|
234
262
|
return {
|
|
235
263
|
results: results
|
|
236
264
|
};
|
|
237
265
|
}
|
|
238
266
|
}
|
|
267
|
+
|
|
239
268
|
export function polygonTriangulation(feature) {
|
|
240
269
|
var coordinates = feature.coordinates;
|
|
241
270
|
var flattengeo = earcut.flatten(coordinates);
|
|
242
271
|
var vertices = flattengeo.vertices,
|
|
243
|
-
|
|
244
|
-
|
|
272
|
+
dimensions = flattengeo.dimensions,
|
|
273
|
+
holes = flattengeo.holes;
|
|
245
274
|
return {
|
|
246
275
|
indices: earcut(vertices, holes, dimensions),
|
|
247
276
|
vertices: vertices,
|
|
248
277
|
size: dimensions
|
|
249
278
|
};
|
|
250
|
-
}
|
|
279
|
+
} // 构建几何图形(带有中心点和大小)
|
|
251
280
|
|
|
252
|
-
// 构建几何图形(带有中心点和大小)
|
|
253
281
|
export function polygonTriangulationWithCenter(feature) {
|
|
254
282
|
var coordinates = feature.coordinates;
|
|
255
283
|
var flattengeo = earcut.flatten(coordinates);
|
|
256
284
|
var vertices = flattengeo.vertices,
|
|
257
|
-
|
|
258
|
-
|
|
285
|
+
dimensions = flattengeo.dimensions,
|
|
286
|
+
holes = flattengeo.holes;
|
|
259
287
|
return {
|
|
260
288
|
indices: earcut(vertices, holes, dimensions),
|
|
261
289
|
vertices: getVerticesWithCenter(vertices),
|
|
262
290
|
size: dimensions + 4
|
|
263
291
|
};
|
|
264
292
|
}
|
|
293
|
+
|
|
265
294
|
function getVerticesWithCenter(vertices) {
|
|
266
295
|
var verticesWithCenter = [];
|
|
296
|
+
|
|
267
297
|
var _calculatePointsCente = calculatePointsCenterAndRadius(vertices),
|
|
268
|
-
|
|
269
|
-
|
|
298
|
+
center = _calculatePointsCente.center,
|
|
299
|
+
radius = _calculatePointsCente.radius;
|
|
300
|
+
|
|
270
301
|
for (var i = 0; i < vertices.length; i += 2) {
|
|
271
302
|
var lng = vertices[i];
|
|
272
303
|
var lat = vertices[i + 1];
|
|
273
304
|
verticesWithCenter.push.apply(verticesWithCenter, [lng, lat, 0].concat(_toConsumableArray(center), [radius]));
|
|
274
305
|
}
|
|
306
|
+
|
|
275
307
|
return verticesWithCenter;
|
|
276
308
|
}
|
|
309
|
+
|
|
277
310
|
export function PolygonExtrudeTriangulation(feature) {
|
|
278
311
|
var coordinates = feature.coordinates;
|
|
312
|
+
|
|
279
313
|
var _extrude_PolygonNorma = extrude_PolygonNormal(coordinates, true),
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
314
|
+
positions = _extrude_PolygonNorma.positions,
|
|
315
|
+
index = _extrude_PolygonNorma.index,
|
|
316
|
+
normals = _extrude_PolygonNorma.normals;
|
|
317
|
+
|
|
283
318
|
return {
|
|
284
319
|
vertices: positions,
|
|
285
320
|
// [ x, y, z, uv.x,uv.y ]
|
|
@@ -290,9 +325,11 @@ export function PolygonExtrudeTriangulation(feature) {
|
|
|
290
325
|
}
|
|
291
326
|
export function HeatmapGridTriangulation(feature) {
|
|
292
327
|
var shape = feature.shape;
|
|
328
|
+
|
|
293
329
|
var _getHeatmapGeometry = getHeatmapGeometry(shape),
|
|
294
|
-
|
|
295
|
-
|
|
330
|
+
positions = _getHeatmapGeometry.positions,
|
|
331
|
+
index = _getHeatmapGeometry.index;
|
|
332
|
+
|
|
296
333
|
return {
|
|
297
334
|
vertices: positions,
|
|
298
335
|
// [ x, y, z ] 多边形顶点
|
|
@@ -300,14 +337,14 @@ export function HeatmapGridTriangulation(feature) {
|
|
|
300
337
|
size: 3
|
|
301
338
|
};
|
|
302
339
|
}
|
|
303
|
-
|
|
304
340
|
/**
|
|
305
341
|
* 图片图层顶点构造
|
|
306
342
|
* @param feature 数据
|
|
307
343
|
*/
|
|
344
|
+
|
|
308
345
|
export function RasterImageTriangulation(feature) {
|
|
309
|
-
var coordinates = feature.coordinates;
|
|
310
|
-
|
|
346
|
+
var coordinates = feature.coordinates; // [ x, y, z. uv.x, uv.y]
|
|
347
|
+
|
|
311
348
|
var positions = [].concat(_toConsumableArray(coordinates[0]), [0, 0, 1, coordinates[1][0], coordinates[0][1], 0, 1, 1], _toConsumableArray(coordinates[1]), [0, 1, 0], _toConsumableArray(coordinates[0]), [0, 0, 1], _toConsumableArray(coordinates[1]), [0, 1, 0, coordinates[0][0], coordinates[1][1], 0, 0, 0]);
|
|
312
349
|
var indexs = [0, 1, 2, 3, 4, 5];
|
|
313
350
|
return {
|
|
@@ -316,52 +353,58 @@ export function RasterImageTriangulation(feature) {
|
|
|
316
353
|
size: 5
|
|
317
354
|
};
|
|
318
355
|
}
|
|
319
|
-
|
|
320
356
|
/**
|
|
321
357
|
* 计算3D弧线顶点
|
|
322
358
|
* @param feature 映射数据
|
|
323
359
|
* @param segNum 弧线线段数
|
|
324
360
|
*/
|
|
361
|
+
|
|
325
362
|
export function LineArcTriangulation(feature, segmentNumber) {
|
|
326
363
|
var segNum = segmentNumber ? segmentNumber : 30;
|
|
327
364
|
var coordinates = feature.coordinates;
|
|
328
365
|
var positions = [];
|
|
329
366
|
var indexArray = [];
|
|
367
|
+
|
|
330
368
|
var _loop = function _loop(i) {
|
|
331
369
|
// 上线两个顶点
|
|
332
370
|
// [ x, y, z, sx,sy, tx,ty]
|
|
333
371
|
positions.push(i, 1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1], i, -1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1]);
|
|
372
|
+
|
|
334
373
|
if (i !== segNum - 1) {
|
|
335
374
|
indexArray.push.apply(indexArray, _toConsumableArray([0, 1, 2, 1, 3, 2].map(function (v) {
|
|
336
375
|
return i * 2 + v;
|
|
337
376
|
})));
|
|
338
377
|
}
|
|
339
378
|
};
|
|
379
|
+
|
|
340
380
|
for (var i = 0; i < segNum; i++) {
|
|
341
381
|
_loop(i);
|
|
342
382
|
}
|
|
383
|
+
|
|
343
384
|
return {
|
|
344
385
|
vertices: positions,
|
|
345
386
|
indices: indexArray,
|
|
346
387
|
size: 7
|
|
347
388
|
};
|
|
348
389
|
}
|
|
349
|
-
|
|
350
390
|
/**
|
|
351
391
|
* 构建热力图密度图的顶点
|
|
352
392
|
* @param feature
|
|
353
393
|
* @returns
|
|
354
394
|
*/
|
|
395
|
+
|
|
355
396
|
export function HeatmapTriangulation(feature) {
|
|
356
397
|
var coordinates = feature.coordinates;
|
|
398
|
+
|
|
357
399
|
if (coordinates.length === 2) {
|
|
358
400
|
coordinates.push(0);
|
|
359
401
|
}
|
|
402
|
+
|
|
360
403
|
var dir = addDir(-1, 1);
|
|
361
404
|
var dir1 = addDir(1, 1);
|
|
362
405
|
var dir2 = addDir(-1, -1);
|
|
363
|
-
var dir3 = addDir(1, -1);
|
|
364
|
-
|
|
406
|
+
var dir3 = addDir(1, -1); // [x,y,z, dirx ,diry, weight]
|
|
407
|
+
|
|
365
408
|
var positions = [].concat(_toConsumableArray(coordinates), _toConsumableArray(dir), _toConsumableArray(coordinates), _toConsumableArray(dir2), _toConsumableArray(coordinates), _toConsumableArray(dir3), _toConsumableArray(coordinates), _toConsumableArray(dir1));
|
|
366
409
|
var indexArray = [0, 1, 2, 3, 0, 2];
|
|
367
410
|
return {
|
|
@@ -370,21 +413,24 @@ export function HeatmapTriangulation(feature) {
|
|
|
370
413
|
size: 5
|
|
371
414
|
};
|
|
372
415
|
}
|
|
373
|
-
|
|
374
416
|
/**
|
|
375
417
|
* 点图层3d geomerty
|
|
376
418
|
* @param shape 3D形状
|
|
377
419
|
*/
|
|
420
|
+
|
|
378
421
|
function getGeometry(shape) {
|
|
379
422
|
var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
423
|
+
|
|
380
424
|
if (GeometryCache && GeometryCache[shape]) {
|
|
381
425
|
return GeometryCache[shape];
|
|
382
426
|
}
|
|
427
|
+
|
|
383
428
|
var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.cylinder();
|
|
384
429
|
var geometry = extrude_PolygonNormal([path], needFlat);
|
|
385
430
|
GeometryCache[shape] = geometry;
|
|
386
431
|
return geometry;
|
|
387
432
|
}
|
|
433
|
+
|
|
388
434
|
export function computeVertexNormals(positions, indexArray) {
|
|
389
435
|
var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
|
|
390
436
|
var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
@@ -395,6 +441,7 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
395
441
|
var cb = vec3.create();
|
|
396
442
|
var ab = vec3.create();
|
|
397
443
|
var normal = vec3.create();
|
|
444
|
+
|
|
398
445
|
for (var i = 0, li = indexArray.length; i < li; i += 3) {
|
|
399
446
|
vA = indexArray[i + 0] * 3;
|
|
400
447
|
vB = indexArray[i + 1] * 3;
|
|
@@ -402,25 +449,32 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
402
449
|
var p1 = [positions[vA], positions[vA + 1]];
|
|
403
450
|
var p2 = [positions[vB], positions[vB + 1]];
|
|
404
451
|
var p3 = [positions[vC], positions[vC + 1]];
|
|
452
|
+
|
|
405
453
|
if (needFlat) {
|
|
406
454
|
p1 = lngLatToMeters(p1);
|
|
407
455
|
p2 = lngLatToMeters(p2);
|
|
408
456
|
p3 = lngLatToMeters(p3);
|
|
409
457
|
}
|
|
458
|
+
|
|
410
459
|
var _p = p1,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
460
|
+
_p2 = _slicedToArray(_p, 2),
|
|
461
|
+
ax = _p2[0],
|
|
462
|
+
ay = _p2[1];
|
|
463
|
+
|
|
414
464
|
var pA = vec3.fromValues(ax, ay, positions[vA + 2]);
|
|
465
|
+
|
|
415
466
|
var _p3 = p2,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
467
|
+
_p4 = _slicedToArray(_p3, 2),
|
|
468
|
+
bx = _p4[0],
|
|
469
|
+
by = _p4[1];
|
|
470
|
+
|
|
419
471
|
var pB = vec3.fromValues(bx, by, positions[vB + 2]);
|
|
472
|
+
|
|
420
473
|
var _p5 = p3,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
474
|
+
_p6 = _slicedToArray(_p5, 2),
|
|
475
|
+
cx = _p6[0],
|
|
476
|
+
cy = _p6[1];
|
|
477
|
+
|
|
424
478
|
var pC = vec3.fromValues(cx, cy, positions[vC + 2]);
|
|
425
479
|
vec3.sub(cb, pC, pB);
|
|
426
480
|
vec3.sub(ab, pA, pB);
|
|
@@ -435,9 +489,11 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
435
489
|
normals[vC + 1] += cb[1];
|
|
436
490
|
normals[vC + 2] += cb[2];
|
|
437
491
|
}
|
|
492
|
+
|
|
438
493
|
normalizeNormals(normals);
|
|
439
494
|
return normals;
|
|
440
495
|
}
|
|
496
|
+
|
|
441
497
|
function normalizeNormals(normals) {
|
|
442
498
|
for (var i = 0, li = normals.length; i < li; i += 3) {
|
|
443
499
|
var normal = vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
|
|
@@ -446,36 +502,40 @@ function normalizeNormals(normals) {
|
|
|
446
502
|
normals.set(newNormal, i);
|
|
447
503
|
}
|
|
448
504
|
}
|
|
505
|
+
|
|
449
506
|
export function checkIsClosed(points) {
|
|
450
507
|
var p1 = points[0][0];
|
|
451
508
|
var p2 = points[0][points[0].length - 1];
|
|
452
509
|
return p1[0] === p2[0] && p1[1] === p2[1];
|
|
453
510
|
}
|
|
511
|
+
|
|
454
512
|
function getHeatmapGeometry(shape) {
|
|
455
513
|
var shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
|
|
456
514
|
var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.circle();
|
|
457
|
-
var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]);
|
|
458
|
-
|
|
515
|
+
var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]); // const geometry = fillPolygon([path]);
|
|
516
|
+
|
|
459
517
|
return geometry;
|
|
460
|
-
}
|
|
461
|
-
|
|
518
|
+
} // 热力图计算范围
|
|
519
|
+
|
|
520
|
+
|
|
462
521
|
function addDir(dirX, dirY) {
|
|
463
522
|
var x = (dirX + 1) / 2;
|
|
464
523
|
var y = (dirY + 1) / 2;
|
|
465
524
|
return [x, y];
|
|
466
525
|
}
|
|
467
|
-
|
|
468
526
|
/**
|
|
469
527
|
* 构建地球三角网格
|
|
470
528
|
* @returns
|
|
471
529
|
*/
|
|
530
|
+
|
|
531
|
+
|
|
472
532
|
export function earthTriangulation() {
|
|
473
533
|
var earthmesh = primitiveSphere(EARTH_RADIUS, {
|
|
474
534
|
segments: EARTH_SEGMENTS
|
|
475
535
|
});
|
|
476
536
|
var positionsArr = earthmesh.positionsArr,
|
|
477
|
-
|
|
478
|
-
|
|
537
|
+
indicesArr = earthmesh.indicesArr,
|
|
538
|
+
normalArr = earthmesh.normalArr;
|
|
479
539
|
return {
|
|
480
540
|
vertices: positionsArr,
|
|
481
541
|
indices: indicesArr,
|
|
@@ -488,8 +548,8 @@ export function earthOuterTriangulation() {
|
|
|
488
548
|
segments: EARTH_SEGMENTS
|
|
489
549
|
});
|
|
490
550
|
var positionsArr = earthmesh.positionsArr,
|
|
491
|
-
|
|
492
|
-
|
|
551
|
+
indicesArr = earthmesh.indicesArr,
|
|
552
|
+
normalArr = earthmesh.normalArr;
|
|
493
553
|
return {
|
|
494
554
|
vertices: positionsArr,
|
|
495
555
|
indices: indicesArr,
|
package/es/earth/index.js
CHANGED
|
@@ -7,8 +7,11 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
|
|
10
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
|
|
11
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
|
|
12
15
|
import BaseLayer from "../core/BaseLayer";
|
|
13
16
|
import EarthAtomSphereModel from "./models/atmosphere";
|
|
14
17
|
import BaseEarthModel from "./models/base";
|
|
@@ -19,17 +22,25 @@ var EarthModels = {
|
|
|
19
22
|
bloomSphere: EarthBloomSphereModel
|
|
20
23
|
};
|
|
21
24
|
var earthLayerTypes = ['base', 'atomSphere', 'bloomSphere'];
|
|
25
|
+
|
|
22
26
|
var EarthLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
23
27
|
_inherits(EarthLayer, _BaseLayer);
|
|
28
|
+
|
|
24
29
|
var _super = _createSuper(EarthLayer);
|
|
30
|
+
|
|
25
31
|
function EarthLayer() {
|
|
26
32
|
var _this;
|
|
33
|
+
|
|
27
34
|
_classCallCheck(this, EarthLayer);
|
|
35
|
+
|
|
28
36
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
37
|
args[_key] = arguments[_key];
|
|
30
38
|
}
|
|
39
|
+
|
|
31
40
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
|
+
|
|
32
42
|
_defineProperty(_assertThisInitialized(_this), "type", 'EarthLayer');
|
|
43
|
+
|
|
33
44
|
_defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
|
|
34
45
|
data: [],
|
|
35
46
|
options: {
|
|
@@ -38,35 +49,43 @@ var EarthLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
51
|
});
|
|
52
|
+
|
|
41
53
|
return _this;
|
|
42
54
|
}
|
|
55
|
+
|
|
43
56
|
_createClass(EarthLayer, [{
|
|
44
57
|
key: "buildModels",
|
|
45
58
|
value: function () {
|
|
46
59
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
47
60
|
var shape;
|
|
48
61
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
-
while (1)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
while (1) {
|
|
63
|
+
switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
shape = this.getModelType();
|
|
66
|
+
this.layerModel = new EarthModels[shape](this);
|
|
67
|
+
_context.next = 4;
|
|
68
|
+
return this.initLayerModels();
|
|
69
|
+
|
|
70
|
+
case 4:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context.stop();
|
|
73
|
+
}
|
|
58
74
|
}
|
|
59
75
|
}, _callee, this);
|
|
60
76
|
}));
|
|
77
|
+
|
|
61
78
|
function buildModels() {
|
|
62
79
|
return _buildModels.apply(this, arguments);
|
|
63
80
|
}
|
|
81
|
+
|
|
64
82
|
return buildModels;
|
|
65
83
|
}()
|
|
66
84
|
/**
|
|
67
85
|
* 设置当前地球时间
|
|
68
86
|
* @param time
|
|
69
87
|
*/
|
|
88
|
+
|
|
70
89
|
}, {
|
|
71
90
|
key: "setEarthTime",
|
|
72
91
|
value: function setEarthTime(time) {
|
|
@@ -80,14 +99,19 @@ var EarthLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
80
99
|
key: "getModelType",
|
|
81
100
|
value: function getModelType() {
|
|
82
101
|
var _shapeAttribute$scale;
|
|
102
|
+
|
|
83
103
|
var shapeAttribute = this.styleAttributeService.getLayerStyleAttribute('shape');
|
|
84
104
|
var shape = (shapeAttribute === null || shapeAttribute === void 0 ? void 0 : (_shapeAttribute$scale = shapeAttribute.scale) === null || _shapeAttribute$scale === void 0 ? void 0 : _shapeAttribute$scale.field) || 'base';
|
|
105
|
+
|
|
85
106
|
if (earthLayerTypes.indexOf(shape) < 0) {
|
|
86
107
|
shape = 'base';
|
|
87
108
|
}
|
|
109
|
+
|
|
88
110
|
return shape;
|
|
89
111
|
}
|
|
90
112
|
}]);
|
|
113
|
+
|
|
91
114
|
return EarthLayer;
|
|
92
115
|
}(BaseLayer);
|
|
116
|
+
|
|
93
117
|
export { EarthLayer as default };
|