easy-three-utils 0.0.352 → 0.0.354
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/assets/image/earthspec.jpg +0 -0
- package/cesium/components/index.ts +3 -1
- package/cesium/components/react/Body/index.tsx +8 -0
- package/cesium/components/react/SunshineLine/index.module.less +50 -0
- package/cesium/components/react/SunshineLine/index.tsx +70 -0
- package/cesium/components/react/TerrainLine/index.module.less +7 -2
- package/cesium/components/react/TerrainLine/index.tsx +21 -17
- package/cesium/index.ts +4 -1
- package/cesium/utils/index.ts +2 -0
- package/cesium/utils/useSeawater.ts +50 -0
- package/package.json +2 -2
|
Binary file
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Timeline from './react/Timeline/index.tsx'
|
|
2
2
|
import TerrainLine from './react/TerrainLine/index.tsx'
|
|
3
3
|
import ProFileEcharts from './react/ProFileEcharts/index.tsx'
|
|
4
|
+
import SunshineLine from './react/SunshineLine/index.tsx'
|
|
4
5
|
|
|
5
6
|
const components = {
|
|
6
7
|
vue: {
|
|
@@ -8,7 +9,8 @@ const components = {
|
|
|
8
9
|
react: {
|
|
9
10
|
Timeline,
|
|
10
11
|
TerrainLine,
|
|
11
|
-
ProFileEcharts
|
|
12
|
+
ProFileEcharts,
|
|
13
|
+
SunshineLine
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.slider-box {
|
|
2
|
+
position: relative;
|
|
3
|
+
z-index: 2;
|
|
4
|
+
width: 360px;
|
|
5
|
+
padding: 10px;
|
|
6
|
+
background: rgba(6, 38, 68, 0.7);
|
|
7
|
+
border: solid 1px #26a1ff;
|
|
8
|
+
display: flex;
|
|
9
|
+
left: calc(50vw - 180px);
|
|
10
|
+
|
|
11
|
+
.left-content {
|
|
12
|
+
color: white;
|
|
13
|
+
font-size: 13px;
|
|
14
|
+
writing-mode: vertical-rl;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
padding-right: 12px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.right-content {
|
|
21
|
+
flex: 1;
|
|
22
|
+
|
|
23
|
+
.title {
|
|
24
|
+
color: white;
|
|
25
|
+
font-size: 13px;
|
|
26
|
+
padding: 5px 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.time-text {
|
|
30
|
+
color: white;
|
|
31
|
+
font-size: 12px;
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: flex-end;
|
|
34
|
+
width: 98%;
|
|
35
|
+
margin-bottom: 11px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.control-btn {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
|
|
43
|
+
img {
|
|
44
|
+
padding: 0 12px;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as Cesium from 'cesium'
|
|
2
|
+
import { Slider, ConfigProvider } from "antd"
|
|
3
|
+
import React, { useState, useEffect, useRef } from "react"
|
|
4
|
+
import BodyPortal from "../Body"
|
|
5
|
+
|
|
6
|
+
import Styles from './index.module.less'
|
|
7
|
+
|
|
8
|
+
const SunshineLine: React.FC<{
|
|
9
|
+
getViewer: () => Cesium.Viewer
|
|
10
|
+
}> = (props) => {
|
|
11
|
+
|
|
12
|
+
const { getViewer } = props
|
|
13
|
+
const [azimuth, setAzimuth] = useState(135)
|
|
14
|
+
const [elevation, setElevation] = useState(30)
|
|
15
|
+
const [intensity, setIntensity] = useState(2)
|
|
16
|
+
|
|
17
|
+
const theme = {
|
|
18
|
+
components: {
|
|
19
|
+
Slider: {
|
|
20
|
+
railBg: '#bfbfbf',
|
|
21
|
+
railHoverBg: '#bfbfbf',
|
|
22
|
+
trackBg: '#176fdbff'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const az = Cesium.Math.toRadians(azimuth)
|
|
29
|
+
const el = Cesium.Math.toRadians(elevation)
|
|
30
|
+
|
|
31
|
+
const dir = new Cesium.Cartesian3(
|
|
32
|
+
Math.cos(el) * Math.sin(az),
|
|
33
|
+
Math.cos(el) * Math.cos(az),
|
|
34
|
+
Math.sin(el)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
getViewer().scene.light = new Cesium.DirectionalLight({
|
|
38
|
+
direction: dir,
|
|
39
|
+
intensity,
|
|
40
|
+
});
|
|
41
|
+
}, [azimuth, elevation, intensity])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const sliderBoxRef = useRef(null)
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
sliderBoxRef.current.style.bottom = `calc(-100vh + ${sliderBoxRef.current.clientHeight + 20}px)`
|
|
47
|
+
}, [])
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<BodyPortal>
|
|
51
|
+
<ConfigProvider theme={{
|
|
52
|
+
...theme
|
|
53
|
+
}}>
|
|
54
|
+
<div ref={sliderBoxRef} className={Styles['slider-box']}>
|
|
55
|
+
<div className={Styles['right-content']}>
|
|
56
|
+
<div className={Styles['title']}>时间</div>
|
|
57
|
+
<Slider min={0} max={360} value={azimuth} onChange={setAzimuth} />
|
|
58
|
+
<div className={Styles['title']}>角度</div>
|
|
59
|
+
<Slider min={0} max={180} value={elevation} onChange={setElevation} />
|
|
60
|
+
<div className={Styles['title']}>强度</div>
|
|
61
|
+
<Slider min={0} max={1} step={0.1} value={intensity} onChange={setIntensity} />
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
</ConfigProvider>
|
|
66
|
+
</BodyPortal>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default SunshineLine
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
.slider-box {
|
|
2
|
-
position:
|
|
2
|
+
position: relative;
|
|
3
3
|
z-index: 2;
|
|
4
|
-
bottom: 0;
|
|
5
4
|
width: 360px;
|
|
6
5
|
padding: 10px;
|
|
7
6
|
background: rgba(6, 38, 68, 0.7);
|
|
@@ -21,6 +20,12 @@
|
|
|
21
20
|
.right-content {
|
|
22
21
|
flex: 1;
|
|
23
22
|
|
|
23
|
+
.title {
|
|
24
|
+
color: white;
|
|
25
|
+
font-size: 13px;
|
|
26
|
+
padding: 5px 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
.time-text {
|
|
25
30
|
color: white;
|
|
26
31
|
font-size: 12px;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
2
|
import { Slider, ConfigProvider } from "antd";
|
|
3
3
|
import * as Cesium from "cesium";
|
|
4
|
+
import BodyPortal from "../Body";
|
|
4
5
|
|
|
5
6
|
import Styles from './index.module.less'
|
|
6
7
|
|
|
@@ -26,27 +27,30 @@ const Timeline: React.FC<{
|
|
|
26
27
|
getViewer().scene.verticalExaggeration = value
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
const sliderBoxRef = useRef(null)
|
|
29
31
|
useEffect(() => {
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
+
sliderBoxRef.current.style.bottom = `calc(-100vh + ${sliderBoxRef.current.clientHeight + 20}px)`
|
|
32
33
|
}, [])
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div className={Styles['
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
<BodyPortal>
|
|
37
|
+
<ConfigProvider theme={{
|
|
38
|
+
...theme
|
|
39
|
+
}}>
|
|
40
|
+
<div ref={sliderBoxRef} className={Styles['slider-box']}>
|
|
41
|
+
<div className={Styles['right-content']}>
|
|
42
|
+
<div className={Styles['title']}>地形夸张系数控制</div>
|
|
43
|
+
<Slider
|
|
44
|
+
min={0}
|
|
45
|
+
max={10}
|
|
46
|
+
step={1}
|
|
47
|
+
value={percent}
|
|
48
|
+
onChange={(value: number) => onSliderChange(value)}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
47
51
|
</div>
|
|
48
|
-
</
|
|
49
|
-
</
|
|
52
|
+
</ConfigProvider>
|
|
53
|
+
</BodyPortal>
|
|
50
54
|
)
|
|
51
55
|
}
|
|
52
56
|
|
package/cesium/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ type TCesiumUtilsType = {
|
|
|
17
17
|
profileAnalysis: ReturnType<typeof hooks.useProfileAnalysis>;
|
|
18
18
|
viewshedAnalysis: ReturnType<typeof hooks.useViewshedAnalysis>;
|
|
19
19
|
cloud: ReturnType<typeof hooks.useCloud>;
|
|
20
|
+
seawater: ReturnType<typeof hooks.useSeawater>;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
let config;
|
|
@@ -108,6 +109,7 @@ const useCesium = () => {
|
|
|
108
109
|
collection: customCollection.addCollection(hooks.dict.ECollectionWhiteListNames.VIEWSHEDANALYSIS)
|
|
109
110
|
})
|
|
110
111
|
const cloud = hooks.useCloud(viewer)
|
|
112
|
+
const seawater = hooks.useSeawater(viewer)
|
|
111
113
|
|
|
112
114
|
if (config.controllerStyle === cesiumConfigDict.EControllerStyle.THREE) {
|
|
113
115
|
updateController(viewer)
|
|
@@ -123,7 +125,8 @@ const useCesium = () => {
|
|
|
123
125
|
slope,
|
|
124
126
|
profileAnalysis,
|
|
125
127
|
viewshedAnalysis,
|
|
126
|
-
cloud
|
|
128
|
+
cloud,
|
|
129
|
+
seawater
|
|
127
130
|
})
|
|
128
131
|
|
|
129
132
|
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
|
package/cesium/utils/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { useSlope } from './useSlope'
|
|
|
7
7
|
import { useProfileAnalysis } from './useProfileAnalysis'
|
|
8
8
|
import { useViewshedAnalysis } from './useViewshedAnalysis'
|
|
9
9
|
import { useCloud } from './useCloud'
|
|
10
|
+
import { useSeawater } from './useSeawater'
|
|
10
11
|
|
|
11
12
|
const dict = {
|
|
12
13
|
ECollectionWhiteListNames,
|
|
@@ -23,6 +24,7 @@ export {
|
|
|
23
24
|
useProfileAnalysis,
|
|
24
25
|
useViewshedAnalysis,
|
|
25
26
|
useCloud,
|
|
27
|
+
useSeawater,
|
|
26
28
|
|
|
27
29
|
dict
|
|
28
30
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as Cesium from 'cesium'
|
|
2
|
+
|
|
3
|
+
const useSeawater = (viewer: Cesium.Viewer) => {
|
|
4
|
+
let water;
|
|
5
|
+
|
|
6
|
+
const enabled = () => {
|
|
7
|
+
if (water) return
|
|
8
|
+
water = viewer.scene.primitives.add(
|
|
9
|
+
new Cesium.Primitive({
|
|
10
|
+
geometryInstances: new Cesium.GeometryInstance({
|
|
11
|
+
geometry: new Cesium.RectangleGeometry({
|
|
12
|
+
rectangle: Cesium.Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0),
|
|
13
|
+
vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
|
|
14
|
+
height: 450
|
|
15
|
+
})
|
|
16
|
+
}),
|
|
17
|
+
appearance: new Cesium.EllipsoidSurfaceAppearance({
|
|
18
|
+
aboveGround: false,
|
|
19
|
+
material: new Cesium.Material({
|
|
20
|
+
fabric: {
|
|
21
|
+
type: 'Water',
|
|
22
|
+
uniforms: {
|
|
23
|
+
specularMap: __POLT__URL__ + '/assets/image/earthspec.jpg',
|
|
24
|
+
normalMap: Cesium.buildModuleUrl('Assets/Textures/waterNormals.jpg'),
|
|
25
|
+
frequency: 10000.0,
|
|
26
|
+
animationSpeed: 0.01,
|
|
27
|
+
amplitude: 1.0,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
show: true
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const disabled = () => {
|
|
38
|
+
viewer.scene.primitives.remove(water)
|
|
39
|
+
water = null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
enabled,
|
|
44
|
+
disabled
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
useSeawater
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-three-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.354",
|
|
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
|
}
|