@antv/l7-layers 2.17.2 → 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 +114 -64
- 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 +138 -86
- package/es/line/models/linearline.js +76 -43
- package/es/line/models/simpleLine.js +69 -39
- 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 +124 -62
- 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 +146 -84
- package/lib/line/models/linearline.js +88 -43
- package/lib/line/models/simpleLine.js +79 -39
- 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/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,
|
|
@@ -127,35 +136,21 @@ export function FlowLineFillTriangulation(feature) {
|
|
|
127
136
|
var tin = 1;
|
|
128
137
|
var tout = 1.0;
|
|
129
138
|
return {
|
|
130
|
-
vertices: [1, 0, 0].concat(_toConsumableArray(coord), [
|
|
131
|
-
//
|
|
132
|
-
1,
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
//
|
|
138
|
-
0,
|
|
139
|
-
// 4
|
|
140
|
-
1, 0, 0], _toConsumableArray(coord), [
|
|
141
|
-
// 0
|
|
142
|
-
1, 2, -3], _toConsumableArray(coord), [
|
|
143
|
-
// 1
|
|
144
|
-
1, 1, -3], _toConsumableArray(coord), [
|
|
145
|
-
// 2
|
|
146
|
-
0, 1, 0], _toConsumableArray(coord), [
|
|
147
|
-
// 3
|
|
139
|
+
vertices: [1, 0, 0].concat(_toConsumableArray(coord), [// 0
|
|
140
|
+
1, 2, -3], _toConsumableArray(coord), [// 1
|
|
141
|
+
1, 1, -3], _toConsumableArray(coord), [// 2
|
|
142
|
+
0, 1, 0], _toConsumableArray(coord), [// 3
|
|
143
|
+
0, 0, 0], _toConsumableArray(coord), [// 4
|
|
144
|
+
1, 0, 0], _toConsumableArray(coord), [// 0
|
|
145
|
+
1, 2, -3], _toConsumableArray(coord), [// 1
|
|
146
|
+
1, 1, -3], _toConsumableArray(coord), [// 2
|
|
147
|
+
0, 1, 0], _toConsumableArray(coord), [// 3
|
|
148
148
|
0, 0, 0], _toConsumableArray(coord)),
|
|
149
|
-
normals: [-tin, 2 * tout, 1,
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
// 2
|
|
155
|
-
tout, -tout, 1,
|
|
156
|
-
// 3
|
|
157
|
-
-tin, -tout, 1,
|
|
158
|
-
// 4
|
|
149
|
+
normals: [-tin, 2 * tout, 1, // 0
|
|
150
|
+
2 * tout, -tout, 1, // 1
|
|
151
|
+
tout, -tout, 1, // 2
|
|
152
|
+
tout, -tout, 1, // 3
|
|
153
|
+
-tin, -tout, 1, // 4
|
|
159
154
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
160
155
|
indices: [0, 1, 2, 0, 2, 3, 0, 3, 4, 5, 6, 7, 5, 7, 8, 5, 8, 9],
|
|
161
156
|
size: 7
|
|
@@ -167,26 +162,17 @@ export function FlowLineStrokeTriangulation(feature) {
|
|
|
167
162
|
var tin = 1;
|
|
168
163
|
var tout = 1;
|
|
169
164
|
return {
|
|
170
|
-
vertices: [1, 0, 0].concat(_toConsumableArray(coord), [
|
|
171
|
-
//
|
|
172
|
-
1,
|
|
173
|
-
//
|
|
174
|
-
1, 1, -3], _toConsumableArray(coord), [
|
|
175
|
-
// 2
|
|
176
|
-
0, 1, 0], _toConsumableArray(coord), [
|
|
177
|
-
// 3
|
|
165
|
+
vertices: [1, 0, 0].concat(_toConsumableArray(coord), [// 0
|
|
166
|
+
1, 2, -3], _toConsumableArray(coord), [// 1
|
|
167
|
+
1, 1, -3], _toConsumableArray(coord), [// 2
|
|
168
|
+
0, 1, 0], _toConsumableArray(coord), [// 3
|
|
178
169
|
0, 0, 0], _toConsumableArray(coord)),
|
|
179
|
-
normals: [-tin, 2 * tout, 1,
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
//
|
|
183
|
-
tout, -tout, 1,
|
|
184
|
-
// 2
|
|
185
|
-
tout, -tout, 1,
|
|
186
|
-
// 3
|
|
170
|
+
normals: [-tin, 2 * tout, 1, // 0
|
|
171
|
+
2 * tout, -tout, 1, // 1
|
|
172
|
+
tout, -tout, 1, // 2
|
|
173
|
+
tout, -tout, 1, // 3
|
|
187
174
|
-tin, -tout, 1 // 4
|
|
188
175
|
],
|
|
189
|
-
|
|
190
176
|
indices: [0, 1, 1, 2, 2, 3, 3, 4, 4, 0],
|
|
191
177
|
size: 7
|
|
192
178
|
};
|
|
@@ -194,6 +180,7 @@ export function FlowLineStrokeTriangulation(feature) {
|
|
|
194
180
|
export function SimpleLineTriangulation(feature) {
|
|
195
181
|
var coordinates = feature.coordinates;
|
|
196
182
|
var pos = [];
|
|
183
|
+
|
|
197
184
|
if (!Array.isArray(coordinates[0])) {
|
|
198
185
|
return {
|
|
199
186
|
vertices: [],
|
|
@@ -203,9 +190,11 @@ export function SimpleLineTriangulation(feature) {
|
|
|
203
190
|
count: 0
|
|
204
191
|
};
|
|
205
192
|
}
|
|
193
|
+
|
|
206
194
|
var _getSimpleLineVertice = getSimpleLineVertices(coordinates),
|
|
207
|
-
|
|
208
|
-
|
|
195
|
+
results = _getSimpleLineVertice.results,
|
|
196
|
+
totalDistance = _getSimpleLineVertice.totalDistance;
|
|
197
|
+
|
|
209
198
|
results.map(function (point) {
|
|
210
199
|
pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
|
|
211
200
|
});
|
|
@@ -220,6 +209,7 @@ export function SimpleLineTriangulation(feature) {
|
|
|
220
209
|
export function TileSimpleLineTriangulation(feature) {
|
|
221
210
|
var coordinates = feature.coordinates;
|
|
222
211
|
var pos = [];
|
|
212
|
+
|
|
223
213
|
if (!Array.isArray(coordinates[0])) {
|
|
224
214
|
return {
|
|
225
215
|
vertices: [],
|
|
@@ -228,8 +218,10 @@ export function TileSimpleLineTriangulation(feature) {
|
|
|
228
218
|
count: 0
|
|
229
219
|
};
|
|
230
220
|
}
|
|
221
|
+
|
|
231
222
|
var _getTileSimpleLineVer = getTileSimpleLineVertices(coordinates),
|
|
232
|
-
|
|
223
|
+
results = _getTileSimpleLineVer.results;
|
|
224
|
+
|
|
233
225
|
results.map(function (point) {
|
|
234
226
|
pos.push(point[0], point[1], point[2], point[3]);
|
|
235
227
|
});
|
|
@@ -240,27 +232,35 @@ export function TileSimpleLineTriangulation(feature) {
|
|
|
240
232
|
count: results.length
|
|
241
233
|
};
|
|
242
234
|
}
|
|
235
|
+
|
|
243
236
|
function lineSegmentDistance(b1, a1) {
|
|
244
237
|
var dx = a1[0] - b1[0];
|
|
245
238
|
var dy = a1[1] - b1[1];
|
|
246
239
|
return Math.sqrt(dx * dx + dy * dy);
|
|
247
240
|
}
|
|
241
|
+
|
|
248
242
|
function pushDis(point, n) {
|
|
249
243
|
if (point.length < 3) {
|
|
250
244
|
point.push(0);
|
|
251
245
|
}
|
|
246
|
+
|
|
252
247
|
if (n !== undefined) {
|
|
253
248
|
point.push(n);
|
|
254
249
|
}
|
|
250
|
+
|
|
255
251
|
return point;
|
|
256
252
|
}
|
|
253
|
+
|
|
257
254
|
function getSimpleLineVertices(coordinates) {
|
|
258
255
|
var points = coordinates;
|
|
256
|
+
|
|
259
257
|
if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
|
|
260
258
|
// @ts-ignore
|
|
261
259
|
points = coordinates.flat();
|
|
262
260
|
}
|
|
261
|
+
|
|
263
262
|
var distance = 0;
|
|
263
|
+
|
|
264
264
|
if (points.length < 2) {
|
|
265
265
|
return {
|
|
266
266
|
results: points,
|
|
@@ -270,6 +270,7 @@ function getSimpleLineVertices(coordinates) {
|
|
|
270
270
|
var results = [];
|
|
271
271
|
var point = pushDis(points[0], distance);
|
|
272
272
|
results.push(point);
|
|
273
|
+
|
|
273
274
|
for (var i = 1; i < points.length - 1; i++) {
|
|
274
275
|
var subDistance = lineSegmentDistance(points[i - 1], points[i]);
|
|
275
276
|
distance += subDistance;
|
|
@@ -277,6 +278,7 @@ function getSimpleLineVertices(coordinates) {
|
|
|
277
278
|
results.push(mulPoint);
|
|
278
279
|
results.push(mulPoint);
|
|
279
280
|
}
|
|
281
|
+
|
|
280
282
|
var pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
|
|
281
283
|
distance += pointDistance;
|
|
282
284
|
results.push(pushDis(points[points.length - 1], distance));
|
|
@@ -286,6 +288,7 @@ function getSimpleLineVertices(coordinates) {
|
|
|
286
288
|
};
|
|
287
289
|
}
|
|
288
290
|
}
|
|
291
|
+
|
|
289
292
|
function getTileSimpleLineVertices(points) {
|
|
290
293
|
if (points.length < 2) {
|
|
291
294
|
return {
|
|
@@ -295,61 +298,70 @@ function getTileSimpleLineVertices(points) {
|
|
|
295
298
|
var results = [];
|
|
296
299
|
var point = pushDis(points[0]);
|
|
297
300
|
results.push(point);
|
|
301
|
+
|
|
298
302
|
for (var i = 1; i < points.length - 1; i++) {
|
|
299
303
|
var mulPoint = pushDis(points[i]);
|
|
300
304
|
results.push(mulPoint);
|
|
301
305
|
results.push(mulPoint);
|
|
302
306
|
}
|
|
307
|
+
|
|
303
308
|
results.push(pushDis(points[points.length - 1]));
|
|
304
309
|
return {
|
|
305
310
|
results: results
|
|
306
311
|
};
|
|
307
312
|
}
|
|
308
313
|
}
|
|
314
|
+
|
|
309
315
|
export function polygonTriangulation(feature) {
|
|
310
316
|
var coordinates = feature.coordinates;
|
|
311
317
|
var flattengeo = earcut.flatten(coordinates);
|
|
312
318
|
var vertices = flattengeo.vertices,
|
|
313
|
-
|
|
314
|
-
|
|
319
|
+
dimensions = flattengeo.dimensions,
|
|
320
|
+
holes = flattengeo.holes;
|
|
315
321
|
return {
|
|
316
322
|
indices: earcut(vertices, holes, dimensions),
|
|
317
323
|
vertices: vertices,
|
|
318
324
|
size: dimensions
|
|
319
325
|
};
|
|
320
|
-
}
|
|
326
|
+
} // 构建几何图形(带有中心点和大小)
|
|
321
327
|
|
|
322
|
-
// 构建几何图形(带有中心点和大小)
|
|
323
328
|
export function polygonTriangulationWithCenter(feature) {
|
|
324
329
|
var coordinates = feature.coordinates;
|
|
325
330
|
var flattengeo = earcut.flatten(coordinates);
|
|
326
331
|
var vertices = flattengeo.vertices,
|
|
327
|
-
|
|
328
|
-
|
|
332
|
+
dimensions = flattengeo.dimensions,
|
|
333
|
+
holes = flattengeo.holes;
|
|
329
334
|
return {
|
|
330
335
|
indices: earcut(vertices, holes, dimensions),
|
|
331
336
|
vertices: getVerticesWithCenter(vertices),
|
|
332
337
|
size: dimensions + 4
|
|
333
338
|
};
|
|
334
339
|
}
|
|
340
|
+
|
|
335
341
|
function getVerticesWithCenter(vertices) {
|
|
336
342
|
var verticesWithCenter = [];
|
|
343
|
+
|
|
337
344
|
var _calculatePointsCente = calculatePointsCenterAndRadius(vertices),
|
|
338
|
-
|
|
339
|
-
|
|
345
|
+
center = _calculatePointsCente.center,
|
|
346
|
+
radius = _calculatePointsCente.radius;
|
|
347
|
+
|
|
340
348
|
for (var i = 0; i < vertices.length; i += 2) {
|
|
341
349
|
var lng = vertices[i];
|
|
342
350
|
var lat = vertices[i + 1];
|
|
343
351
|
verticesWithCenter.push.apply(verticesWithCenter, [lng, lat, 0].concat(_toConsumableArray(center), [radius]));
|
|
344
352
|
}
|
|
353
|
+
|
|
345
354
|
return verticesWithCenter;
|
|
346
355
|
}
|
|
356
|
+
|
|
347
357
|
export function PolygonExtrudeTriangulation(feature) {
|
|
348
358
|
var coordinates = feature.coordinates;
|
|
359
|
+
|
|
349
360
|
var _extrude_PolygonNorma = extrude_PolygonNormal(coordinates, true),
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
361
|
+
positions = _extrude_PolygonNorma.positions,
|
|
362
|
+
index = _extrude_PolygonNorma.index,
|
|
363
|
+
normals = _extrude_PolygonNorma.normals;
|
|
364
|
+
|
|
353
365
|
return {
|
|
354
366
|
vertices: positions,
|
|
355
367
|
// [ x, y, z, uv.x,uv.y ]
|
|
@@ -360,9 +372,11 @@ export function PolygonExtrudeTriangulation(feature) {
|
|
|
360
372
|
}
|
|
361
373
|
export function HeatmapGridTriangulation(feature) {
|
|
362
374
|
var shape = feature.shape;
|
|
375
|
+
|
|
363
376
|
var _getHeatmapGeometry = getHeatmapGeometry(shape),
|
|
364
|
-
|
|
365
|
-
|
|
377
|
+
positions = _getHeatmapGeometry.positions,
|
|
378
|
+
index = _getHeatmapGeometry.index;
|
|
379
|
+
|
|
366
380
|
return {
|
|
367
381
|
vertices: positions,
|
|
368
382
|
// [ x, y, z ] 多边形顶点
|
|
@@ -370,14 +384,14 @@ export function HeatmapGridTriangulation(feature) {
|
|
|
370
384
|
size: 3
|
|
371
385
|
};
|
|
372
386
|
}
|
|
373
|
-
|
|
374
387
|
/**
|
|
375
388
|
* 图片图层顶点构造
|
|
376
389
|
* @param feature 数据
|
|
377
390
|
*/
|
|
391
|
+
|
|
378
392
|
export function RasterImageTriangulation(feature) {
|
|
379
|
-
var coordinates = feature.coordinates;
|
|
380
|
-
|
|
393
|
+
var coordinates = feature.coordinates; // [ x, y, z. uv.x, uv.y]
|
|
394
|
+
|
|
381
395
|
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]);
|
|
382
396
|
var indexs = [0, 1, 2, 3, 4, 5];
|
|
383
397
|
return {
|
|
@@ -386,52 +400,58 @@ export function RasterImageTriangulation(feature) {
|
|
|
386
400
|
size: 5
|
|
387
401
|
};
|
|
388
402
|
}
|
|
389
|
-
|
|
390
403
|
/**
|
|
391
404
|
* 计算3D弧线顶点
|
|
392
405
|
* @param feature 映射数据
|
|
393
406
|
* @param segNum 弧线线段数
|
|
394
407
|
*/
|
|
408
|
+
|
|
395
409
|
export function LineArcTriangulation(feature, segmentNumber) {
|
|
396
410
|
var segNum = segmentNumber ? segmentNumber : 30;
|
|
397
411
|
var coordinates = feature.coordinates;
|
|
398
412
|
var positions = [];
|
|
399
413
|
var indexArray = [];
|
|
414
|
+
|
|
400
415
|
var _loop = function _loop(i) {
|
|
401
416
|
// 上线两个顶点
|
|
402
417
|
// [ x, y, z, sx,sy, tx,ty]
|
|
403
418
|
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]);
|
|
419
|
+
|
|
404
420
|
if (i !== segNum - 1) {
|
|
405
421
|
indexArray.push.apply(indexArray, _toConsumableArray([0, 1, 2, 1, 3, 2].map(function (v) {
|
|
406
422
|
return i * 2 + v;
|
|
407
423
|
})));
|
|
408
424
|
}
|
|
409
425
|
};
|
|
426
|
+
|
|
410
427
|
for (var i = 0; i < segNum; i++) {
|
|
411
428
|
_loop(i);
|
|
412
429
|
}
|
|
430
|
+
|
|
413
431
|
return {
|
|
414
432
|
vertices: positions,
|
|
415
433
|
indices: indexArray,
|
|
416
434
|
size: 7
|
|
417
435
|
};
|
|
418
436
|
}
|
|
419
|
-
|
|
420
437
|
/**
|
|
421
438
|
* 构建热力图密度图的顶点
|
|
422
439
|
* @param feature
|
|
423
440
|
* @returns
|
|
424
441
|
*/
|
|
442
|
+
|
|
425
443
|
export function HeatmapTriangulation(feature) {
|
|
426
444
|
var coordinates = feature.coordinates;
|
|
445
|
+
|
|
427
446
|
if (coordinates.length === 2) {
|
|
428
447
|
coordinates.push(0);
|
|
429
448
|
}
|
|
449
|
+
|
|
430
450
|
var dir = addDir(-1, 1);
|
|
431
451
|
var dir1 = addDir(1, 1);
|
|
432
452
|
var dir2 = addDir(-1, -1);
|
|
433
|
-
var dir3 = addDir(1, -1);
|
|
434
|
-
|
|
453
|
+
var dir3 = addDir(1, -1); // [x,y,z, dirx ,diry, weight]
|
|
454
|
+
|
|
435
455
|
var positions = [].concat(_toConsumableArray(coordinates), _toConsumableArray(dir), _toConsumableArray(coordinates), _toConsumableArray(dir2), _toConsumableArray(coordinates), _toConsumableArray(dir3), _toConsumableArray(coordinates), _toConsumableArray(dir1));
|
|
436
456
|
var indexArray = [0, 1, 2, 3, 0, 2];
|
|
437
457
|
return {
|
|
@@ -440,21 +460,24 @@ export function HeatmapTriangulation(feature) {
|
|
|
440
460
|
size: 5
|
|
441
461
|
};
|
|
442
462
|
}
|
|
443
|
-
|
|
444
463
|
/**
|
|
445
464
|
* 点图层3d geomerty
|
|
446
465
|
* @param shape 3D形状
|
|
447
466
|
*/
|
|
467
|
+
|
|
448
468
|
function getGeometry(shape) {
|
|
449
469
|
var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
470
|
+
|
|
450
471
|
if (GeometryCache && GeometryCache[shape]) {
|
|
451
472
|
return GeometryCache[shape];
|
|
452
473
|
}
|
|
474
|
+
|
|
453
475
|
var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.cylinder();
|
|
454
476
|
var geometry = extrude_PolygonNormal([path], needFlat);
|
|
455
477
|
GeometryCache[shape] = geometry;
|
|
456
478
|
return geometry;
|
|
457
479
|
}
|
|
480
|
+
|
|
458
481
|
export function computeVertexNormals(positions, indexArray) {
|
|
459
482
|
var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
|
|
460
483
|
var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
@@ -465,6 +488,7 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
465
488
|
var cb = vec3.create();
|
|
466
489
|
var ab = vec3.create();
|
|
467
490
|
var normal = vec3.create();
|
|
491
|
+
|
|
468
492
|
for (var i = 0, li = indexArray.length; i < li; i += 3) {
|
|
469
493
|
vA = indexArray[i + 0] * 3;
|
|
470
494
|
vB = indexArray[i + 1] * 3;
|
|
@@ -472,25 +496,32 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
472
496
|
var p1 = [positions[vA], positions[vA + 1]];
|
|
473
497
|
var p2 = [positions[vB], positions[vB + 1]];
|
|
474
498
|
var p3 = [positions[vC], positions[vC + 1]];
|
|
499
|
+
|
|
475
500
|
if (needFlat) {
|
|
476
501
|
p1 = lngLatToMeters(p1);
|
|
477
502
|
p2 = lngLatToMeters(p2);
|
|
478
503
|
p3 = lngLatToMeters(p3);
|
|
479
504
|
}
|
|
505
|
+
|
|
480
506
|
var _p = p1,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
507
|
+
_p2 = _slicedToArray(_p, 2),
|
|
508
|
+
ax = _p2[0],
|
|
509
|
+
ay = _p2[1];
|
|
510
|
+
|
|
484
511
|
var pA = vec3.fromValues(ax, ay, positions[vA + 2]);
|
|
512
|
+
|
|
485
513
|
var _p3 = p2,
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
514
|
+
_p4 = _slicedToArray(_p3, 2),
|
|
515
|
+
bx = _p4[0],
|
|
516
|
+
by = _p4[1];
|
|
517
|
+
|
|
489
518
|
var pB = vec3.fromValues(bx, by, positions[vB + 2]);
|
|
519
|
+
|
|
490
520
|
var _p5 = p3,
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
521
|
+
_p6 = _slicedToArray(_p5, 2),
|
|
522
|
+
cx = _p6[0],
|
|
523
|
+
cy = _p6[1];
|
|
524
|
+
|
|
494
525
|
var pC = vec3.fromValues(cx, cy, positions[vC + 2]);
|
|
495
526
|
vec3.sub(cb, pC, pB);
|
|
496
527
|
vec3.sub(ab, pA, pB);
|
|
@@ -505,9 +536,11 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
505
536
|
normals[vC + 1] += cb[1];
|
|
506
537
|
normals[vC + 2] += cb[2];
|
|
507
538
|
}
|
|
539
|
+
|
|
508
540
|
normalizeNormals(normals);
|
|
509
541
|
return normals;
|
|
510
542
|
}
|
|
543
|
+
|
|
511
544
|
function normalizeNormals(normals) {
|
|
512
545
|
for (var i = 0, li = normals.length; i < li; i += 3) {
|
|
513
546
|
var normal = vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
|
|
@@ -516,36 +549,40 @@ function normalizeNormals(normals) {
|
|
|
516
549
|
normals.set(newNormal, i);
|
|
517
550
|
}
|
|
518
551
|
}
|
|
552
|
+
|
|
519
553
|
export function checkIsClosed(points) {
|
|
520
554
|
var p1 = points[0][0];
|
|
521
555
|
var p2 = points[0][points[0].length - 1];
|
|
522
556
|
return p1[0] === p2[0] && p1[1] === p2[1];
|
|
523
557
|
}
|
|
558
|
+
|
|
524
559
|
function getHeatmapGeometry(shape) {
|
|
525
560
|
var shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
|
|
526
561
|
var path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.circle();
|
|
527
|
-
var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]);
|
|
528
|
-
|
|
562
|
+
var geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]); // const geometry = fillPolygon([path]);
|
|
563
|
+
|
|
529
564
|
return geometry;
|
|
530
|
-
}
|
|
531
|
-
|
|
565
|
+
} // 热力图计算范围
|
|
566
|
+
|
|
567
|
+
|
|
532
568
|
function addDir(dirX, dirY) {
|
|
533
569
|
var x = (dirX + 1) / 2;
|
|
534
570
|
var y = (dirY + 1) / 2;
|
|
535
571
|
return [x, y];
|
|
536
572
|
}
|
|
537
|
-
|
|
538
573
|
/**
|
|
539
574
|
* 构建地球三角网格
|
|
540
575
|
* @returns
|
|
541
576
|
*/
|
|
577
|
+
|
|
578
|
+
|
|
542
579
|
export function earthTriangulation() {
|
|
543
580
|
var earthmesh = primitiveSphere(EARTH_RADIUS, {
|
|
544
581
|
segments: EARTH_SEGMENTS
|
|
545
582
|
});
|
|
546
583
|
var positionsArr = earthmesh.positionsArr,
|
|
547
|
-
|
|
548
|
-
|
|
584
|
+
indicesArr = earthmesh.indicesArr,
|
|
585
|
+
normalArr = earthmesh.normalArr;
|
|
549
586
|
return {
|
|
550
587
|
vertices: positionsArr,
|
|
551
588
|
indices: indicesArr,
|
|
@@ -558,8 +595,8 @@ export function earthOuterTriangulation() {
|
|
|
558
595
|
segments: EARTH_SEGMENTS
|
|
559
596
|
});
|
|
560
597
|
var positionsArr = earthmesh.positionsArr,
|
|
561
|
-
|
|
562
|
-
|
|
598
|
+
indicesArr = earthmesh.indicesArr,
|
|
599
|
+
normalArr = earthmesh.normalArr;
|
|
563
600
|
return {
|
|
564
601
|
vertices: positionsArr,
|
|
565
602
|
indices: indicesArr,
|