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