easy-three-utils 0.0.350 → 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 +12 -2
- package/cesium/plot/usePlot.d.ts +2 -0
- package/cesium/utils/index.ts +4 -0
- package/cesium/utils/useCloud.ts +43 -19
- package/cesium/utils/useCustomCollection.ts +3 -0
- package/cesium/utils/useDrawPolygon.ts +13 -7
- package/cesium/utils/useProfileAnalysis.ts +7 -6
- package/cesium/utils/useViewshedAnalysis.ts +303 -0
- package/package.json +2 -2
- package/cesium/utils/useDrawTools.ts +0 -50
- package/cesium/utils/useViewShed.ts +0 -199
|
@@ -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
|
@@ -15,6 +15,8 @@ type TCesiumUtilsType = {
|
|
|
15
15
|
measure: ReturnType<typeof hooks.useMeasure>;
|
|
16
16
|
slope: ReturnType<typeof hooks.useSlope>;
|
|
17
17
|
profileAnalysis: ReturnType<typeof hooks.useProfileAnalysis>;
|
|
18
|
+
viewshedAnalysis: ReturnType<typeof hooks.useViewshedAnalysis>;
|
|
19
|
+
cloud: ReturnType<typeof hooks.useCloud>;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
let config;
|
|
@@ -77,7 +79,9 @@ const useCesium = () => {
|
|
|
77
79
|
})
|
|
78
80
|
} else if (config.terrain.status === cesiumConfigDict.ETerrainStatus.ENABLEDOFFLINE) {
|
|
79
81
|
viewer.imageryLayers.get(0).show = false
|
|
80
|
-
const terrainProvider = Cesium.CesiumTerrainProvider.fromUrl(config.terrain.config.url
|
|
82
|
+
const terrainProvider = Cesium.CesiumTerrainProvider.fromUrl(config.terrain.config.url, {
|
|
83
|
+
requestVertexNormals: true
|
|
84
|
+
})
|
|
81
85
|
viewer.terrainProvider = await terrainProvider
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -100,6 +104,10 @@ const useCesium = () => {
|
|
|
100
104
|
const profileAnalysis = hooks.useProfileAnalysis(viewer, {
|
|
101
105
|
collection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.PROFILEANALYSIS)
|
|
102
106
|
})
|
|
107
|
+
const viewshedAnalysis = hooks.useViewshedAnalysis(viewer, {
|
|
108
|
+
collection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.VIEWSHEDANALYSIS)
|
|
109
|
+
})
|
|
110
|
+
const cloud = hooks.useCloud(viewer)
|
|
103
111
|
|
|
104
112
|
if (config.controllerStyle === cesiumConfigDict.EControllerStyle.THREE) {
|
|
105
113
|
updateController(viewer)
|
|
@@ -113,7 +121,9 @@ const useCesium = () => {
|
|
|
113
121
|
weather,
|
|
114
122
|
measure,
|
|
115
123
|
slope,
|
|
116
|
-
profileAnalysis
|
|
124
|
+
profileAnalysis,
|
|
125
|
+
viewshedAnalysis,
|
|
126
|
+
cloud
|
|
117
127
|
})
|
|
118
128
|
|
|
119
129
|
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
|
package/cesium/plot/usePlot.d.ts
CHANGED
package/cesium/utils/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { useWeather, EWeatherType } from './useWeather'
|
|
|
5
5
|
import { useMeasure } from './useMeasure'
|
|
6
6
|
import { useSlope } from './useSlope'
|
|
7
7
|
import { useProfileAnalysis } from './useProfileAnalysis'
|
|
8
|
+
import { useViewshedAnalysis } from './useViewshedAnalysis'
|
|
9
|
+
import { useCloud } from './useCloud'
|
|
8
10
|
|
|
9
11
|
const dict = {
|
|
10
12
|
ECollectionWhiteListNames,
|
|
@@ -19,6 +21,8 @@ export {
|
|
|
19
21
|
useMeasure,
|
|
20
22
|
useSlope,
|
|
21
23
|
useProfileAnalysis,
|
|
24
|
+
useViewshedAnalysis,
|
|
25
|
+
useCloud,
|
|
22
26
|
|
|
23
27
|
dict
|
|
24
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
|
}
|
|
@@ -8,7 +8,9 @@ enum ECollectionWhiteListNames {
|
|
|
8
8
|
MEASURE_HEIGHT = 'measure_height',
|
|
9
9
|
MEASURE_AREA = 'measure_area',
|
|
10
10
|
MEASURE_ALTITUDE = 'measure_altitude',
|
|
11
|
+
|
|
11
12
|
PROFILEANALYSIS = 'profileAnalysis',
|
|
13
|
+
VIEWSHEDANALYSIS = 'viewshedAnalysis',
|
|
12
14
|
|
|
13
15
|
SLOPE = 'slope'
|
|
14
16
|
}
|
|
@@ -24,6 +26,7 @@ const useCustomCollection = (viewer: Cesium.Viewer) => {
|
|
|
24
26
|
'measure_area',
|
|
25
27
|
'measure_altitude',
|
|
26
28
|
'profileAnalysis',
|
|
29
|
+
'viewshedAnalysis',
|
|
27
30
|
'slope'
|
|
28
31
|
]
|
|
29
32
|
|
|
@@ -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
|
|
|
@@ -110,13 +110,14 @@ const useProfileAnalysis = (viewer: Cesium.Viewer, options: {
|
|
|
110
110
|
},
|
|
111
111
|
label: {
|
|
112
112
|
text: textDisance,
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
scale: 0.5,
|
|
114
|
+
font: "normal 28px MicroSoft YaHei",
|
|
115
115
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
heightReference: Cesium.HeightReference.
|
|
116
|
+
pixelOffset: new Cesium.Cartesian2(0, -30),
|
|
117
|
+
outlineWidth: 9,
|
|
118
|
+
outlineColor: Cesium.Color.WHITE,
|
|
119
|
+
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
120
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
120
121
|
}
|
|
121
122
|
})
|
|
122
123
|
}) as Cesium.ScreenSpaceEventHandler.PositionedEventCallback, Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import * as Cesium from 'cesium'
|
|
2
|
+
import glsl from "../glsl/viewable"
|
|
3
|
+
|
|
4
|
+
const useViewshedAnalysis = (viewer: Cesium.Viewer, options: {
|
|
5
|
+
collection: Cesium.CustomDataSource
|
|
6
|
+
}) => {
|
|
7
|
+
|
|
8
|
+
let i = 0
|
|
9
|
+
let handler: Cesium.ScreenSpaceEventHandler | null = null
|
|
10
|
+
let viewPosition = null
|
|
11
|
+
let viewDistance = 100.0
|
|
12
|
+
let viewHeading = 0.0
|
|
13
|
+
let viewPitch = 0.0
|
|
14
|
+
let horizontalViewAngle = 90.0
|
|
15
|
+
let verticalViewAngle = 60.0
|
|
16
|
+
let visibleAreaColor = Cesium.Color.GREEN
|
|
17
|
+
let invisibleAreaColor = Cesium.Color.RED
|
|
18
|
+
let enabled = true
|
|
19
|
+
let softShadows = true
|
|
20
|
+
let size = 2048
|
|
21
|
+
let lightCamera = null
|
|
22
|
+
let shadowMap = null
|
|
23
|
+
let sketch = null
|
|
24
|
+
let postStage = null
|
|
25
|
+
let frustumOutline = null
|
|
26
|
+
|
|
27
|
+
const add = () => {
|
|
28
|
+
createLightCamera()
|
|
29
|
+
createShadowMap()
|
|
30
|
+
drawFrustumOutline()
|
|
31
|
+
drawSketch()
|
|
32
|
+
createPostStage()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const update = () => {
|
|
36
|
+
removeAll()
|
|
37
|
+
add()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const removeAll = () => {
|
|
41
|
+
stopDraw()
|
|
42
|
+
|
|
43
|
+
if (sketch) {
|
|
44
|
+
options.collection.entities.remove(sketch)
|
|
45
|
+
sketch = null
|
|
46
|
+
}
|
|
47
|
+
if (postStage) {
|
|
48
|
+
viewer.scene.postProcessStages.remove(postStage)
|
|
49
|
+
postStage = null
|
|
50
|
+
}
|
|
51
|
+
if (frustumOutline) {
|
|
52
|
+
viewer.scene.primitives.remove(frustumOutline)
|
|
53
|
+
frustumOutline = null
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const updatePosition = (position) => {
|
|
58
|
+
viewDistance = Cesium.Cartesian3.distance(viewPosition, position)
|
|
59
|
+
viewHeading = getHeading(viewPosition, position)
|
|
60
|
+
viewPitch = getPitch(viewPosition, position)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const createLightCamera = () => {
|
|
64
|
+
const camera = new Cesium.Camera(viewer.scene)
|
|
65
|
+
camera.position = viewPosition
|
|
66
|
+
camera.frustum.near = viewDistance * 0.001
|
|
67
|
+
camera.frustum.far = viewDistance
|
|
68
|
+
|
|
69
|
+
const hr = Cesium.Math.toRadians(horizontalViewAngle)
|
|
70
|
+
const vr = Cesium.Math.toRadians(verticalViewAngle)
|
|
71
|
+
const aspectRatio = (viewDistance * Math.tan(hr / 2) * 2) / (viewDistance * Math.tan(vr / 2) * 2);
|
|
72
|
+
(camera.frustum as any).aspectRatio = aspectRatio;
|
|
73
|
+
(camera.frustum as any).fov = Math.max(hr, vr)
|
|
74
|
+
|
|
75
|
+
camera.setView({
|
|
76
|
+
destination: viewPosition,
|
|
77
|
+
orientation: {
|
|
78
|
+
heading: Cesium.Math.toRadians(viewHeading || 0),
|
|
79
|
+
pitch: Cesium.Math.toRadians(viewPitch || 0),
|
|
80
|
+
roll: 0
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
lightCamera = camera
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const createShadowMap = () => {
|
|
87
|
+
const shadow = new (Cesium.ShadowMap as any)({
|
|
88
|
+
context: (viewer.scene as any).context,
|
|
89
|
+
lightCamera: lightCamera,
|
|
90
|
+
enabled: enabled,
|
|
91
|
+
isPointLight: true,
|
|
92
|
+
pointLightRadius: viewDistance,
|
|
93
|
+
cascadesEnabled: false,
|
|
94
|
+
size: size,
|
|
95
|
+
softShadows: softShadows,
|
|
96
|
+
normalOffset: false,
|
|
97
|
+
fromLightSource: false
|
|
98
|
+
})
|
|
99
|
+
viewer.scene.shadowMap = shadow
|
|
100
|
+
shadowMap = shadow
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const createPostStage = () => {
|
|
104
|
+
const fs = glsl
|
|
105
|
+
const cutomPostStage = new Cesium.PostProcessStage({
|
|
106
|
+
fragmentShader: fs,
|
|
107
|
+
uniforms: {
|
|
108
|
+
shadowMap_textureCube: () => {
|
|
109
|
+
shadowMap.update(Reflect.get(viewer.scene, '_frameState'))
|
|
110
|
+
return Reflect.get(shadowMap, '_shadowMapTexture')
|
|
111
|
+
},
|
|
112
|
+
shadowMap_matrix: () => {
|
|
113
|
+
shadowMap.update(Reflect.get(viewer.scene, '_frameState'))
|
|
114
|
+
return Reflect.get(shadowMap, '_shadowMapMatrix')
|
|
115
|
+
},
|
|
116
|
+
shadowMap_lightPositionEC: () => {
|
|
117
|
+
shadowMap.update(Reflect.get(viewer.scene, '_frameState'))
|
|
118
|
+
return Reflect.get(shadowMap, '_lightPositionEC')
|
|
119
|
+
},
|
|
120
|
+
shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness: () => {
|
|
121
|
+
shadowMap.update(Reflect.get(viewer.scene, '_frameState'))
|
|
122
|
+
const bias = shadowMap._pointBias
|
|
123
|
+
return Cesium.Cartesian4.fromElements(
|
|
124
|
+
bias.normalOffsetScale,
|
|
125
|
+
shadowMap._distance,
|
|
126
|
+
shadowMap.maximumDistance,
|
|
127
|
+
0.0,
|
|
128
|
+
new Cesium.Cartesian4()
|
|
129
|
+
)
|
|
130
|
+
},
|
|
131
|
+
shadowMap_texelSizeDepthBiasAndNormalShadingSmooth: () => {
|
|
132
|
+
shadowMap.update(Reflect.get(viewer.scene, '_frameState'))
|
|
133
|
+
const bias = shadowMap._pointBias
|
|
134
|
+
const texelStepSize = new Cesium.Cartesian2(
|
|
135
|
+
1.0 / shadowMap._textureSize.x,
|
|
136
|
+
1.0 / shadowMap._textureSize.y
|
|
137
|
+
)
|
|
138
|
+
return Cesium.Cartesian4.fromElements(
|
|
139
|
+
texelStepSize.x,
|
|
140
|
+
texelStepSize.y,
|
|
141
|
+
bias.depthBias,
|
|
142
|
+
bias.normalShadingSmooth,
|
|
143
|
+
new Cesium.Cartesian4()
|
|
144
|
+
)
|
|
145
|
+
},
|
|
146
|
+
camera_projection_matrix: lightCamera.frustum.projectionMatrix,
|
|
147
|
+
camera_view_matrix: lightCamera.viewMatrix,
|
|
148
|
+
helsing_viewDistance: () => viewDistance,
|
|
149
|
+
helsing_visibleAreaColor: visibleAreaColor,
|
|
150
|
+
helsing_invisibleAreaColor: invisibleAreaColor
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
postStage = viewer.scene.postProcessStages.add(cutomPostStage)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const drawFrustumOutline = () => {
|
|
157
|
+
const direction = lightCamera.directionWC
|
|
158
|
+
const up = lightCamera.upWC
|
|
159
|
+
const right = Cesium.Cartesian3.negate(lightCamera.rightWC, new Cesium.Cartesian3())
|
|
160
|
+
const rotation = Cesium.Matrix3.setColumn(
|
|
161
|
+
new Cesium.Matrix3(),
|
|
162
|
+
0,
|
|
163
|
+
right,
|
|
164
|
+
new Cesium.Matrix3()
|
|
165
|
+
)
|
|
166
|
+
Cesium.Matrix3.setColumn(rotation, 1, up, rotation)
|
|
167
|
+
Cesium.Matrix3.setColumn(rotation, 2, direction, rotation)
|
|
168
|
+
const orientation = Cesium.Quaternion.fromRotationMatrix(rotation, new Cesium.Quaternion())
|
|
169
|
+
|
|
170
|
+
const instance = new Cesium.GeometryInstance({
|
|
171
|
+
geometry: new Cesium.FrustumOutlineGeometry({
|
|
172
|
+
frustum: lightCamera.frustum,
|
|
173
|
+
origin: viewPosition,
|
|
174
|
+
orientation
|
|
175
|
+
}),
|
|
176
|
+
attributes: {
|
|
177
|
+
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.YELLOWGREEN),
|
|
178
|
+
show: new Cesium.ShowGeometryInstanceAttribute(true)
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
frustumOutline = viewer.scene.primitives.add(
|
|
183
|
+
new Cesium.Primitive({
|
|
184
|
+
geometryInstances: [instance],
|
|
185
|
+
appearance: new Cesium.PerInstanceColorAppearance({
|
|
186
|
+
flat: true,
|
|
187
|
+
translucent: false
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const drawSketch = () => {
|
|
194
|
+
sketch = options.collection.entities.add({
|
|
195
|
+
name: 'sketch',
|
|
196
|
+
position: viewPosition,
|
|
197
|
+
orientation: new Cesium.CallbackProperty(() => {
|
|
198
|
+
return Cesium.Transforms.headingPitchRollQuaternion(
|
|
199
|
+
viewPosition,
|
|
200
|
+
Cesium.HeadingPitchRoll.fromDegrees(
|
|
201
|
+
viewHeading - horizontalViewAngle,
|
|
202
|
+
viewPitch,
|
|
203
|
+
0.5
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
}, false),
|
|
207
|
+
ellipsoid: {
|
|
208
|
+
radii: new Cesium.CallbackProperty(
|
|
209
|
+
() => new Cesium.Cartesian3(viewDistance, viewDistance, viewDistance),
|
|
210
|
+
false
|
|
211
|
+
),
|
|
212
|
+
innerRadii: new Cesium.Cartesian3(2.0, 2.0, 2.0),
|
|
213
|
+
minimumClock: Cesium.Math.toRadians(-horizontalViewAngle / 2),
|
|
214
|
+
maximumClock: Cesium.Math.toRadians(horizontalViewAngle / 2),
|
|
215
|
+
minimumCone: Cesium.Math.toRadians(verticalViewAngle + 7.75),
|
|
216
|
+
maximumCone: Cesium.Math.toRadians(180 - verticalViewAngle - 7.75),
|
|
217
|
+
fill: false,
|
|
218
|
+
outline: true,
|
|
219
|
+
subdivisions: 256,
|
|
220
|
+
stackPartitions: 64,
|
|
221
|
+
slicePartitions: 64,
|
|
222
|
+
outlineColor: Cesium.Color.YELLOWGREEN
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const getHeading = (from, to) => {
|
|
228
|
+
const result = new Cesium.Cartesian3()
|
|
229
|
+
const matrix4 = Cesium.Matrix4.inverse(Cesium.Transforms.eastNorthUpToFixedFrame(from), new Cesium.Matrix4())
|
|
230
|
+
Cesium.Matrix4.multiplyByPoint(matrix4, to, result)
|
|
231
|
+
Cesium.Cartesian3.normalize(result, result)
|
|
232
|
+
return Cesium.Math.toDegrees(Math.atan2(result.x, result.y))
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const getPitch = (from, to) => {
|
|
236
|
+
const result = new Cesium.Cartesian3()
|
|
237
|
+
const matrix4 = Cesium.Matrix4.inverse(Cesium.Transforms.eastNorthUpToFixedFrame(from), new Cesium.Matrix4())
|
|
238
|
+
Cesium.Matrix4.multiplyByPoint(matrix4, to, result)
|
|
239
|
+
Cesium.Cartesian3.normalize(result, result)
|
|
240
|
+
return Cesium.Math.toDegrees(Math.asin(result.z))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const leftClickEvent = () => {
|
|
244
|
+
handler.setInputAction(((movement) => {
|
|
245
|
+
i++
|
|
246
|
+
if (i === 1) {
|
|
247
|
+
let startPosition = viewer.scene.pickPosition(movement.position)
|
|
248
|
+
if (!startPosition) return
|
|
249
|
+
viewPosition = startPosition
|
|
250
|
+
mouseMoveEvent()
|
|
251
|
+
}
|
|
252
|
+
if (i === 2) {
|
|
253
|
+
i = 0
|
|
254
|
+
let endPosition = viewer.scene.pickPosition(movement.position)
|
|
255
|
+
updatePosition(endPosition)
|
|
256
|
+
update()
|
|
257
|
+
stopDraw()
|
|
258
|
+
}
|
|
259
|
+
}) as Cesium.ScreenSpaceEventHandler.PositionedEventCallback, Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const mouseMoveEvent = () => {
|
|
263
|
+
handler.setInputAction(((movement) => {
|
|
264
|
+
const endPosition = viewer.scene.pickPosition(movement.endPosition)
|
|
265
|
+
if (!endPosition) return
|
|
266
|
+
updatePosition(endPosition)
|
|
267
|
+
if (!sketch) {
|
|
268
|
+
drawSketch()
|
|
269
|
+
}
|
|
270
|
+
}) as Cesium.ScreenSpaceEventHandler.MotionEventCallback, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const draw = () => {
|
|
274
|
+
if (handler) {
|
|
275
|
+
console.log('请先结束上次测量!')
|
|
276
|
+
return
|
|
277
|
+
}
|
|
278
|
+
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
|
|
279
|
+
leftClickEvent()
|
|
280
|
+
viewer.scene.camera.frustum.near = 100.0
|
|
281
|
+
viewer.scene.logarithmicDepthBuffer = true
|
|
282
|
+
viewer.scene.globe.enableLighting = false
|
|
283
|
+
viewer.scene.globe.showGroundAtmosphere = false
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const stopDraw = () => {
|
|
287
|
+
if (handler) {
|
|
288
|
+
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
|
289
|
+
handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)
|
|
290
|
+
handler.destroy()
|
|
291
|
+
handler = null
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
draw,
|
|
297
|
+
removeAll
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export {
|
|
302
|
+
useViewshedAnalysis
|
|
303
|
+
}
|
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
|
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as Cesium from 'cesium'
|
|
2
|
-
|
|
3
|
-
enum ECollectionWhiteListNames {
|
|
4
|
-
POLYGON = 'polygon',
|
|
5
|
-
POLYGON_NODE = 'polygon_node'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const useCustomCollection = (viewer: Cesium.Viewer) => {
|
|
9
|
-
|
|
10
|
-
let collectionNames: string[] = ([])
|
|
11
|
-
let whiteList: string[] = ['polygon', 'polygon_node']
|
|
12
|
-
|
|
13
|
-
const addCollection = (name: string) => {
|
|
14
|
-
const index = collectionNames.findIndex(item => item === name)
|
|
15
|
-
if (index !== -1) return
|
|
16
|
-
collectionNames.push(name)
|
|
17
|
-
const dataSource = new Cesium.CustomDataSource(name);
|
|
18
|
-
viewer.dataSources.add(dataSource);
|
|
19
|
-
return dataSource
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const getCollection = (name: ECollectionWhiteListNames | string) => {
|
|
23
|
-
const collection = viewer.dataSources.getByName(name)
|
|
24
|
-
if (collection.length) {
|
|
25
|
-
return collection[0]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const removeCollection = (name: string) => {
|
|
30
|
-
const collection = viewer.dataSources.getByName(name)
|
|
31
|
-
viewer.dataSources.remove(collection[0], false)
|
|
32
|
-
collectionNames = collectionNames.filter(item => item !== name && !whiteList.includes(item))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const getCollectionNames = () => {
|
|
36
|
-
return collectionNames.filter(item => !whiteList.includes(item))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
addCollection,
|
|
41
|
-
getCollection,
|
|
42
|
-
removeCollection,
|
|
43
|
-
getCollectionNames
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
ECollectionWhiteListNames,
|
|
49
|
-
useCustomCollection
|
|
50
|
-
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import glsl from "../glsl/viewable";
|
|
2
|
-
import * as Cesium from 'cesium'
|
|
3
|
-
|
|
4
|
-
export default class viewShader {
|
|
5
|
-
constructor(viewer, options) {
|
|
6
|
-
this.viewer = viewer;
|
|
7
|
-
this.viewPosition = options.viewPosition;
|
|
8
|
-
this.viewPositionEnd = options.viewPositionEnd;
|
|
9
|
-
this.viewDistance = this.viewPositionEnd ? Cesium.Cartesian3.distance(this.viewPosition, this.viewPositionEnd) : (options.viewDistance || 100.0);
|
|
10
|
-
this.viewHeading = this.viewPositionEnd ? this.getHeading(this.viewPosition, this.viewPositionEnd) : (options.viewHeading || 0.0);
|
|
11
|
-
this.viewPitch = this.viewPositionEnd ? this.getPitch(this.viewPosition, this.viewPositionEnd) : (options.viewPitch || 0.0);
|
|
12
|
-
this.horizontalViewAngle = options.horizontalViewAngle || 90.0;
|
|
13
|
-
this.verticalViewAngle = options.verticalViewAngle || 60.0;
|
|
14
|
-
this.visibleAreaColor = options.visibleAreaColor || Cesium.Color.GREEN;
|
|
15
|
-
this.invisibleAreaColor = options.invisibleAreaColor || Cesium.Color.RED;
|
|
16
|
-
this.enabled = (typeof options.enabled === "boolean") ? options.enabled : true;
|
|
17
|
-
this.softShadows = (typeof options.softShadows === "boolean") ? options.softShadows : true;
|
|
18
|
-
this.size = options.size || 2048;
|
|
19
|
-
|
|
20
|
-
this.update();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
add() {
|
|
24
|
-
this.createLightCamera();
|
|
25
|
-
this.createShadowMap();
|
|
26
|
-
this.createPostStage();
|
|
27
|
-
this.drawSketch();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
update() {
|
|
31
|
-
this.clear();
|
|
32
|
-
this.add();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
updatePosition(viewPositionEnd) {
|
|
36
|
-
this.viewPositionEnd = viewPositionEnd
|
|
37
|
-
this.viewDistance = Cesium.Cartesian3.distance(this.viewPosition, this.viewPositionEnd)
|
|
38
|
-
this.viewHeading = this.getHeading(this.viewPosition, this.viewPositionEnd)
|
|
39
|
-
this.viewPitch = this.getPitch(this.viewPosition, this.viewPositionEnd)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
clear() {
|
|
43
|
-
if (this.sketch) {
|
|
44
|
-
this.viewer.entities.removeById(this.sketch.id);
|
|
45
|
-
this.sketch = null;
|
|
46
|
-
}
|
|
47
|
-
if (this.postStage) {
|
|
48
|
-
this.viewer.scene.postProcessStages.remove(this.postStage);
|
|
49
|
-
this.postStage = null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
createLightCamera() {
|
|
54
|
-
this.lightCamera = new Cesium.Camera(this.viewer.scene);
|
|
55
|
-
this.lightCamera.position = this.viewPosition;
|
|
56
|
-
if (this.viewDistance == 0) {
|
|
57
|
-
this.viewDistance = 1
|
|
58
|
-
}
|
|
59
|
-
this.lightCamera.frustum.near = this.viewDistance * 0.001;
|
|
60
|
-
this.lightCamera.frustum.far = this.viewDistance;
|
|
61
|
-
const hr = Cesium.Math.toRadians(this.horizontalViewAngle);
|
|
62
|
-
const vr = Cesium.Math.toRadians(this.verticalViewAngle);
|
|
63
|
-
const aspectRatio =
|
|
64
|
-
(this.viewDistance * Math.tan(hr / 2) * 2) /
|
|
65
|
-
(this.viewDistance * Math.tan(vr / 2) * 2);
|
|
66
|
-
this.lightCamera.frustum.aspectRatio = aspectRatio;
|
|
67
|
-
if (hr > vr) {
|
|
68
|
-
this.lightCamera.frustum.fov = hr;
|
|
69
|
-
} else {
|
|
70
|
-
this.lightCamera.frustum.fov = vr;
|
|
71
|
-
}
|
|
72
|
-
this.lightCamera.setView({
|
|
73
|
-
destination: this.viewPosition,
|
|
74
|
-
orientation: {
|
|
75
|
-
heading: Cesium.Math.toRadians(this.viewHeading || 0),
|
|
76
|
-
pitch: Cesium.Math.toRadians(this.viewPitch || 0),
|
|
77
|
-
roll: 0
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
createShadowMap() {
|
|
83
|
-
this.shadowMap = new Cesium.ShadowMap({
|
|
84
|
-
context: (this.viewer.scene).context,
|
|
85
|
-
lightCamera: this.lightCamera,
|
|
86
|
-
enabled: this.enabled,
|
|
87
|
-
isPointLight: true,
|
|
88
|
-
pointLightRadius: this.viewDistance,
|
|
89
|
-
cascadesEnabled: false,
|
|
90
|
-
size: this.size,
|
|
91
|
-
softShadows: this.softShadows,
|
|
92
|
-
normalOffset: false,
|
|
93
|
-
fromLightSource: false
|
|
94
|
-
});
|
|
95
|
-
this.viewer.scene.shadowMap = this.shadowMap;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
createPostStage() {
|
|
99
|
-
const postStage = new Cesium.PostProcessStage({
|
|
100
|
-
fragmentShader: glsl,
|
|
101
|
-
uniforms: {
|
|
102
|
-
shadowMap_textureCube: () => {
|
|
103
|
-
this.shadowMap.update(Reflect.get(this.viewer.scene, "_frameState"));
|
|
104
|
-
return Reflect.get(this.shadowMap, "_shadowMapTexture");
|
|
105
|
-
},
|
|
106
|
-
shadowMap_matrix: () => {
|
|
107
|
-
this.shadowMap.update(Reflect.get(this.viewer.scene, "_frameState"));
|
|
108
|
-
return Reflect.get(this.shadowMap, "_shadowMapMatrix");
|
|
109
|
-
},
|
|
110
|
-
shadowMap_lightPositionEC: () => {
|
|
111
|
-
this.shadowMap.update(Reflect.get(this.viewer.scene, "_frameState"));
|
|
112
|
-
return Reflect.get(this.shadowMap, "_lightPositionEC");
|
|
113
|
-
},
|
|
114
|
-
shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness: () => {
|
|
115
|
-
this.shadowMap.update(Reflect.get(this.viewer.scene, "_frameState"));
|
|
116
|
-
const bias = this.shadowMap._pointBias;
|
|
117
|
-
return Cesium.Cartesian4.fromElements(
|
|
118
|
-
bias.normalOffsetScale,
|
|
119
|
-
this.shadowMap._distance,
|
|
120
|
-
this.shadowMap.maximumDistance,
|
|
121
|
-
0.0,
|
|
122
|
-
new Cesium.Cartesian4()
|
|
123
|
-
);
|
|
124
|
-
},
|
|
125
|
-
shadowMap_texelSizeDepthBiasAndNormalShadingSmooth: () => {
|
|
126
|
-
this.shadowMap.update(Reflect.get(this.viewer.scene, "_frameState"));
|
|
127
|
-
const bias = this.shadowMap._pointBias;
|
|
128
|
-
const scratchTexelStepSize = new Cesium.Cartesian2();
|
|
129
|
-
const texelStepSize = scratchTexelStepSize;
|
|
130
|
-
texelStepSize.x = 1.0 / this.shadowMap._textureSize.x;
|
|
131
|
-
texelStepSize.y = 1.0 / this.shadowMap._textureSize.y;
|
|
132
|
-
|
|
133
|
-
return Cesium.Cartesian4.fromElements(
|
|
134
|
-
texelStepSize.x,
|
|
135
|
-
texelStepSize.y,
|
|
136
|
-
bias.depthBias,
|
|
137
|
-
bias.normalShadingSmooth,
|
|
138
|
-
new Cesium.Cartesian4()
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
camera_projection_matrix: this.lightCamera.frustum.projectionMatrix,
|
|
142
|
-
camera_view_matrix: this.lightCamera.viewMatrix,
|
|
143
|
-
helsing_viewDistance: () => {
|
|
144
|
-
return this.viewDistance;
|
|
145
|
-
},
|
|
146
|
-
helsing_visibleAreaColor: this.visibleAreaColor,
|
|
147
|
-
helsing_invisibleAreaColor: this.invisibleAreaColor,
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
this.postStage = this.viewer.scene.postProcessStages.add(postStage);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
drawSketch() {
|
|
155
|
-
this.sketch = this.viewer.entities.add({
|
|
156
|
-
name: 'sketch',
|
|
157
|
-
position: this.viewPosition,
|
|
158
|
-
orientation: Cesium.Transforms.headingPitchRollQuaternion(
|
|
159
|
-
this.viewPosition,
|
|
160
|
-
Cesium.HeadingPitchRoll.fromDegrees(this.viewHeading - this.horizontalViewAngle, this.viewPitch, 0.0)
|
|
161
|
-
),
|
|
162
|
-
ellipsoid: {
|
|
163
|
-
radii: new Cesium.Cartesian3(
|
|
164
|
-
this.viewDistance,
|
|
165
|
-
this.viewDistance,
|
|
166
|
-
this.viewDistance
|
|
167
|
-
),
|
|
168
|
-
minimumClock: Cesium.Math.toRadians(-this.horizontalViewAngle / 2),
|
|
169
|
-
maximumClock: Cesium.Math.toRadians(this.horizontalViewAngle / 2),
|
|
170
|
-
minimumCone: Cesium.Math.toRadians(this.verticalViewAngle + 7.75),
|
|
171
|
-
maximumCone: Cesium.Math.toRadians(180 - this.verticalViewAngle - 7.75),
|
|
172
|
-
fill: false,
|
|
173
|
-
outline: true,
|
|
174
|
-
subdivisions: 256,
|
|
175
|
-
stackPartitions: 64,
|
|
176
|
-
slicePartitions: 64,
|
|
177
|
-
outlineColor: Cesium.Color.YELLOWGREEN
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
getHeading(fromPosition, toPosition) {
|
|
183
|
-
let finalPosition = new Cesium.Cartesian3();
|
|
184
|
-
let matrix4 = Cesium.Transforms.eastNorthUpToFixedFrame(fromPosition);
|
|
185
|
-
Cesium.Matrix4.inverse(matrix4, matrix4);
|
|
186
|
-
Cesium.Matrix4.multiplyByPoint(matrix4, toPosition, finalPosition);
|
|
187
|
-
Cesium.Cartesian3.normalize(finalPosition, finalPosition);
|
|
188
|
-
return Cesium.Math.toDegrees(Math.atan2(finalPosition.x, finalPosition.y));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
getPitch(fromPosition, toPosition) {
|
|
192
|
-
let finalPosition = new Cesium.Cartesian3();
|
|
193
|
-
let matrix4 = Cesium.Transforms.eastNorthUpToFixedFrame(fromPosition);
|
|
194
|
-
Cesium.Matrix4.inverse(matrix4, matrix4);
|
|
195
|
-
Cesium.Matrix4.multiplyByPoint(matrix4, toPosition, finalPosition);
|
|
196
|
-
Cesium.Cartesian3.normalize(finalPosition, finalPosition);
|
|
197
|
-
return Cesium.Math.toDegrees(Math.asin(finalPosition.z));
|
|
198
|
-
}
|
|
199
|
-
}
|