easy-three-utils 0.0.351 → 0.0.352
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/cesium/components/index.ts +2 -0
- package/cesium/components/react/TerrainLine/index.module.less +45 -0
- package/cesium/components/react/TerrainLine/index.tsx +53 -0
- package/cesium/index.ts +7 -3
- package/cesium/utils/index.ts +2 -0
- package/cesium/utils/useCloud.ts +43 -19
- package/cesium/utils/useDrawPolygon.ts +13 -7
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Timeline from './react/Timeline/index.tsx'
|
|
2
|
+
import TerrainLine from './react/TerrainLine/index.tsx'
|
|
2
3
|
import ProFileEcharts from './react/ProFileEcharts/index.tsx'
|
|
3
4
|
|
|
4
5
|
const components = {
|
|
@@ -6,6 +7,7 @@ const components = {
|
|
|
6
7
|
},
|
|
7
8
|
react: {
|
|
8
9
|
Timeline,
|
|
10
|
+
TerrainLine,
|
|
9
11
|
ProFileEcharts
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.slider-box {
|
|
2
|
+
position: absolute;
|
|
3
|
+
z-index: 2;
|
|
4
|
+
bottom: 0;
|
|
5
|
+
width: 360px;
|
|
6
|
+
padding: 10px;
|
|
7
|
+
background: rgba(6, 38, 68, 0.7);
|
|
8
|
+
border: solid 1px #26a1ff;
|
|
9
|
+
display: flex;
|
|
10
|
+
left: calc(50vw - 180px);
|
|
11
|
+
|
|
12
|
+
.left-content {
|
|
13
|
+
color: white;
|
|
14
|
+
font-size: 13px;
|
|
15
|
+
writing-mode: vertical-rl;
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
padding-right: 12px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.right-content {
|
|
22
|
+
flex: 1;
|
|
23
|
+
|
|
24
|
+
.time-text {
|
|
25
|
+
color: white;
|
|
26
|
+
font-size: 12px;
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: flex-end;
|
|
29
|
+
width: 98%;
|
|
30
|
+
margin-bottom: 11px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.control-btn {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
|
|
38
|
+
img {
|
|
39
|
+
padding: 0 12px;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Slider, ConfigProvider } from "antd";
|
|
3
|
+
import * as Cesium from "cesium";
|
|
4
|
+
|
|
5
|
+
import Styles from './index.module.less'
|
|
6
|
+
|
|
7
|
+
const Timeline: React.FC<{
|
|
8
|
+
getViewer: () => Cesium.Viewer
|
|
9
|
+
}> = (props) => {
|
|
10
|
+
|
|
11
|
+
const { getViewer } = props
|
|
12
|
+
const [percent, setPercent] = useState(1)
|
|
13
|
+
|
|
14
|
+
const theme = {
|
|
15
|
+
components: {
|
|
16
|
+
Slider: {
|
|
17
|
+
railBg: '#bfbfbf',
|
|
18
|
+
railHoverBg: '#bfbfbf',
|
|
19
|
+
trackBg: '#176fdbff'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const onSliderChange = (value: number) => {
|
|
25
|
+
setPercent(() => value);
|
|
26
|
+
getViewer().scene.verticalExaggeration = value
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
return () => {
|
|
31
|
+
}
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<ConfigProvider theme={{
|
|
36
|
+
...theme
|
|
37
|
+
}}>
|
|
38
|
+
<div className={Styles['slider-box']}>
|
|
39
|
+
<div className={Styles['right-content']}>
|
|
40
|
+
<Slider
|
|
41
|
+
min={0}
|
|
42
|
+
max={10}
|
|
43
|
+
step={1}
|
|
44
|
+
value={percent}
|
|
45
|
+
onChange={(value: number) => onSliderChange(value)}
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</ConfigProvider>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default Timeline
|
package/cesium/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ type TCesiumUtilsType = {
|
|
|
16
16
|
slope: ReturnType<typeof hooks.useSlope>;
|
|
17
17
|
profileAnalysis: ReturnType<typeof hooks.useProfileAnalysis>;
|
|
18
18
|
viewshedAnalysis: ReturnType<typeof hooks.useViewshedAnalysis>;
|
|
19
|
+
cloud: ReturnType<typeof hooks.useCloud>;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
let config;
|
|
@@ -78,7 +79,9 @@ const useCesium = () => {
|
|
|
78
79
|
})
|
|
79
80
|
} else if (config.terrain.status === cesiumConfigDict.ETerrainStatus.ENABLEDOFFLINE) {
|
|
80
81
|
viewer.imageryLayers.get(0).show = false
|
|
81
|
-
const terrainProvider = Cesium.CesiumTerrainProvider.fromUrl(config.terrain.config.url
|
|
82
|
+
const terrainProvider = Cesium.CesiumTerrainProvider.fromUrl(config.terrain.config.url, {
|
|
83
|
+
requestVertexNormals: true
|
|
84
|
+
})
|
|
82
85
|
viewer.terrainProvider = await terrainProvider
|
|
83
86
|
}
|
|
84
87
|
|
|
@@ -104,7 +107,7 @@ const useCesium = () => {
|
|
|
104
107
|
const viewshedAnalysis = hooks.useViewshedAnalysis(viewer, {
|
|
105
108
|
collection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.VIEWSHEDANALYSIS)
|
|
106
109
|
})
|
|
107
|
-
|
|
110
|
+
const cloud = hooks.useCloud(viewer)
|
|
108
111
|
|
|
109
112
|
if (config.controllerStyle === cesiumConfigDict.EControllerStyle.THREE) {
|
|
110
113
|
updateController(viewer)
|
|
@@ -119,7 +122,8 @@ const useCesium = () => {
|
|
|
119
122
|
measure,
|
|
120
123
|
slope,
|
|
121
124
|
profileAnalysis,
|
|
122
|
-
viewshedAnalysis
|
|
125
|
+
viewshedAnalysis,
|
|
126
|
+
cloud
|
|
123
127
|
})
|
|
124
128
|
|
|
125
129
|
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
|
package/cesium/utils/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { useMeasure } from './useMeasure'
|
|
|
6
6
|
import { useSlope } from './useSlope'
|
|
7
7
|
import { useProfileAnalysis } from './useProfileAnalysis'
|
|
8
8
|
import { useViewshedAnalysis } from './useViewshedAnalysis'
|
|
9
|
+
import { useCloud } from './useCloud'
|
|
9
10
|
|
|
10
11
|
const dict = {
|
|
11
12
|
ECollectionWhiteListNames,
|
|
@@ -21,6 +22,7 @@ export {
|
|
|
21
22
|
useSlope,
|
|
22
23
|
useProfileAnalysis,
|
|
23
24
|
useViewshedAnalysis,
|
|
25
|
+
useCloud,
|
|
24
26
|
|
|
25
27
|
dict
|
|
26
28
|
}
|
package/cesium/utils/useCloud.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Cesium from 'cesium'
|
|
2
|
+
import { v7 as uuidv7 } from 'uuid'
|
|
2
3
|
|
|
3
4
|
const useCloud = (viewer: Cesium.Viewer) => {
|
|
4
5
|
|
|
@@ -11,7 +12,7 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
11
12
|
return {
|
|
12
13
|
lon: Cesium.Math.toDegrees(cartographic.longitude),
|
|
13
14
|
lat: Cesium.Math.toDegrees(cartographic.latitude),
|
|
14
|
-
height: cartographic.height + h
|
|
15
|
+
height: cartographic.height + h
|
|
15
16
|
}
|
|
16
17
|
})
|
|
17
18
|
|
|
@@ -45,7 +46,7 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
45
46
|
return inside;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
const points = []
|
|
49
|
+
const points = []
|
|
49
50
|
while (points.length < numPoints) {
|
|
50
51
|
const lon = Math.random() * (maxLon - minLon) + minLon
|
|
51
52
|
const lat = Math.random() * (maxLat - minLat) + minLat
|
|
@@ -57,20 +58,39 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
57
58
|
return points;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const draw = (points: Cesium.Cartesian3[], params: {
|
|
62
|
+
cloudWidth?: number,
|
|
63
|
+
cloudLength?: number,
|
|
64
|
+
density?: number,
|
|
65
|
+
color?: string
|
|
66
|
+
} = {
|
|
67
|
+
cloudWidth: 100000,
|
|
68
|
+
cloudLength: 100000,
|
|
69
|
+
density: 0.8,
|
|
70
|
+
color: 'rgba(255, 255, 255, 0.8)'
|
|
71
|
+
}) => {
|
|
72
|
+
|
|
73
|
+
const options = Object.assign({}, {
|
|
74
|
+
cloudWidth: 100000,
|
|
75
|
+
cloudLength: 100000,
|
|
76
|
+
density: 0.8,
|
|
77
|
+
color: 'rgba(255, 255, 255, 0.8)'
|
|
78
|
+
}, params)
|
|
79
|
+
|
|
61
80
|
const clouds = viewer.scene.primitives.add(new Cesium.CloudCollection())
|
|
62
81
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
cloudsCollection.push({
|
|
83
|
+
id: uuidv7(),
|
|
84
|
+
clouds
|
|
85
|
+
})
|
|
66
86
|
|
|
67
87
|
const width = Math.max(...points.map(p => p.x)) - Math.min(...points.map(p => p.x))
|
|
68
88
|
const length = Math.max(...points.map(p => p.y)) - Math.min(...points.map(p => p.y))
|
|
69
|
-
const num = Math.floor(width * length / (cloudLength * cloudWidth)) * density
|
|
70
|
-
const _points = getRandomPoints(points, num, 5000 + (cloudLength + cloudWidth) / 2)
|
|
89
|
+
const num = Math.floor(width * length / (options.cloudLength * options.cloudWidth)) * options.density
|
|
90
|
+
const _points = getRandomPoints(points, num, 5000 + (options.cloudLength + options.cloudWidth) / 2)
|
|
71
91
|
|
|
72
92
|
_points.forEach(point => {
|
|
73
|
-
const r = Math.random()
|
|
93
|
+
const r = Math.random()
|
|
74
94
|
clouds.add({
|
|
75
95
|
show: true,
|
|
76
96
|
position: point,
|
|
@@ -80,17 +100,12 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
80
100
|
3 + r * 5
|
|
81
101
|
),
|
|
82
102
|
scale: new Cesium.Cartesian2(
|
|
83
|
-
cloudWidth * (0.8 + Math.random() * 0.4),
|
|
84
|
-
cloudLength * (0.8 + Math.random() * 0.4)
|
|
103
|
+
options.cloudWidth * (0.8 + Math.random() * 0.4),
|
|
104
|
+
options.cloudLength * (0.8 + Math.random() * 0.4)
|
|
85
105
|
),
|
|
86
106
|
slice: 0.2 + Math.random() * 0.3,
|
|
87
107
|
brightness: 0.8 + Math.random() * 0.4,
|
|
88
|
-
color:
|
|
89
|
-
0.9 + Math.random() * 0.1,
|
|
90
|
-
0.7 + Math.random() * 0.2,
|
|
91
|
-
0.6 + Math.random() * 0.2,
|
|
92
|
-
0.8
|
|
93
|
-
),
|
|
108
|
+
color: Cesium.Color.fromCssColorString(options.color),
|
|
94
109
|
noiseDetail: 3.0 + Math.random(),
|
|
95
110
|
noiseOffset: new Cesium.Cartesian3(
|
|
96
111
|
Math.random() * 100,
|
|
@@ -103,11 +118,20 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
103
118
|
)
|
|
104
119
|
})
|
|
105
120
|
})
|
|
106
|
-
|
|
107
121
|
}
|
|
108
122
|
|
|
109
|
-
const
|
|
123
|
+
const removeAll = () => {
|
|
124
|
+
cloudsCollection.forEach(item => item.clouds.removeAll())
|
|
125
|
+
viewer.scene.primitives.removeAll()
|
|
126
|
+
cloudsCollection = []
|
|
127
|
+
}
|
|
110
128
|
|
|
129
|
+
return {
|
|
130
|
+
draw,
|
|
131
|
+
removeAll
|
|
111
132
|
}
|
|
133
|
+
}
|
|
112
134
|
|
|
135
|
+
export {
|
|
136
|
+
useCloud
|
|
113
137
|
}
|
|
@@ -10,7 +10,10 @@ const useDrawPolygon = (viewer: Cesium.Viewer, options: {
|
|
|
10
10
|
const moveHandler: Cesium.ScreenSpaceEventHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
|
|
11
11
|
let pointPosData: Cesium.Cartesian3[][] = []
|
|
12
12
|
|
|
13
|
-
const start = (cb: (
|
|
13
|
+
const start = (cb: (data: {
|
|
14
|
+
geoJSON: string;
|
|
15
|
+
points: Cesium.Cartesian3[];
|
|
16
|
+
}) => void) => {
|
|
14
17
|
|
|
15
18
|
const points: Cesium.Cartesian3[] = []
|
|
16
19
|
|
|
@@ -69,12 +72,15 @@ const useDrawPolygon = (viewer: Cesium.Viewer, options: {
|
|
|
69
72
|
return [lon, lat]
|
|
70
73
|
})
|
|
71
74
|
|
|
72
|
-
cb(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
cb({
|
|
76
|
+
geoJSON: JSON.stringify({
|
|
77
|
+
"type": "Polygon",
|
|
78
|
+
"coordinates": [
|
|
79
|
+
[...coordinates, coordinates[0]]
|
|
80
|
+
]
|
|
81
|
+
}),
|
|
82
|
+
points: [...points, points[0]]
|
|
83
|
+
})
|
|
78
84
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK)
|
|
79
85
|
}
|
|
80
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-three-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.352",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"types": "./index.d.ts",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "新增区域云和地形测量"
|
|
12
12
|
}
|