easy-three-utils 0.0.353 → 0.0.355
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 +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/utils/useCloud.ts +95 -0
- package/cesium/utils/useSeawater.ts +1 -1
- package/package.json +2 -2
|
@@ -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/utils/useCloud.ts
CHANGED
|
@@ -5,6 +5,9 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
5
5
|
|
|
6
6
|
let cloudsCollection = []
|
|
7
7
|
|
|
8
|
+
let globalClouds
|
|
9
|
+
let cloudData = []
|
|
10
|
+
|
|
8
11
|
const getRandomPoints = (polygonCartesian: Cesium.Cartesian3[], numPoints: number, h: number) => {
|
|
9
12
|
|
|
10
13
|
const polygon = polygonCartesian.map(cartesian => {
|
|
@@ -87,6 +90,7 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
87
90
|
const width = Math.max(...points.map(p => p.x)) - Math.min(...points.map(p => p.x))
|
|
88
91
|
const length = Math.max(...points.map(p => p.y)) - Math.min(...points.map(p => p.y))
|
|
89
92
|
const num = Math.floor(width * length / (options.cloudLength * options.cloudWidth)) * options.density
|
|
93
|
+
|
|
90
94
|
const _points = getRandomPoints(points, num, 5000 + (options.cloudLength + options.cloudWidth) / 2)
|
|
91
95
|
|
|
92
96
|
_points.forEach(point => {
|
|
@@ -120,6 +124,95 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
120
124
|
})
|
|
121
125
|
}
|
|
122
126
|
|
|
127
|
+
|
|
128
|
+
let angle = 0
|
|
129
|
+
const speedDegPerSec = 0.1
|
|
130
|
+
const speed = Cesium.Math.toRadians(speedDegPerSec)
|
|
131
|
+
let prevTime = Cesium.JulianDate.clone(viewer.clock.currentTime)
|
|
132
|
+
|
|
133
|
+
const onTick = (clock) => {
|
|
134
|
+
const now = clock.currentTime;
|
|
135
|
+
const dt = Cesium.JulianDate.secondsDifference(now, prevTime)
|
|
136
|
+
prevTime = Cesium.JulianDate.clone(now)
|
|
137
|
+
|
|
138
|
+
if (dt <= 0) return
|
|
139
|
+
|
|
140
|
+
angle += speed * dt
|
|
141
|
+
const rot = Cesium.Matrix3.fromRotationZ(angle)
|
|
142
|
+
|
|
143
|
+
for (const d of cloudData) {
|
|
144
|
+
const rotated = new Cesium.Cartesian3()
|
|
145
|
+
Cesium.Matrix3.multiplyByVector(rot, d.orig, rotated)
|
|
146
|
+
d.cloud.position = rotated
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const enabledGlobalCloud = (options?: {
|
|
151
|
+
color?: string;
|
|
152
|
+
number?: number;
|
|
153
|
+
}) => {
|
|
154
|
+
|
|
155
|
+
globalClouds = viewer.scene.primitives.add(new Cesium.CloudCollection())
|
|
156
|
+
const maxLength = 3000000
|
|
157
|
+
const minLength = 2000000
|
|
158
|
+
|
|
159
|
+
const coords = [
|
|
160
|
+
{ lon: -180, lat: -90 },
|
|
161
|
+
{ lon: 180, lat: -90 },
|
|
162
|
+
{ lon: 180, lat: 90 },
|
|
163
|
+
{ lon: -180, lat: 90 },
|
|
164
|
+
{ lon: -180, lat: -90 },
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
const points = coords.map(c =>
|
|
168
|
+
Cesium.Cartesian3.fromDegrees(c.lon, c.lat)
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
const _points = getRandomPoints(points, (options && options.number) ? options.number : 500, Math.floor(Math.random() * (900000 - 700000 + 1)) + 700000)
|
|
172
|
+
_points.forEach(point => {
|
|
173
|
+
const r = Math.random()
|
|
174
|
+
const cloud = globalClouds.add({
|
|
175
|
+
show: true,
|
|
176
|
+
position: point,
|
|
177
|
+
maximumSize: new Cesium.Cartesian3(
|
|
178
|
+
5 + r * 15,
|
|
179
|
+
4 + r * 10,
|
|
180
|
+
3 + r * 5
|
|
181
|
+
),
|
|
182
|
+
scale: new Cesium.Cartesian2(maxLength, Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength),
|
|
183
|
+
slice: 0.2 + Math.random() * 0.3,
|
|
184
|
+
brightness: 0.8 + Math.random() * 0.4,
|
|
185
|
+
color: Cesium.Color.fromCssColorString((options && options.color) ? options.color : 'rgba(255, 255, 255)'),
|
|
186
|
+
noiseDetail: 3.0 + Math.random(),
|
|
187
|
+
noiseOffset: new Cesium.Cartesian3(
|
|
188
|
+
Math.random() * 100,
|
|
189
|
+
Math.random() * 100,
|
|
190
|
+
Math.random() * 100
|
|
191
|
+
),
|
|
192
|
+
orientation: Cesium.Quaternion.fromAxisAngle(
|
|
193
|
+
Cesium.Cartesian3.UNIT_Z,
|
|
194
|
+
Math.random() * Cesium.Math.TWO_PI
|
|
195
|
+
)
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
cloudData.push({
|
|
199
|
+
cloud,
|
|
200
|
+
orig: Cesium.Cartesian3.clone(point)
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
viewer.clock.onTick.addEventListener(onTick)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const disabledGlobalCloud = () => {
|
|
208
|
+
if (globalClouds) {
|
|
209
|
+
globalClouds.removeAll()
|
|
210
|
+
globalClouds = null
|
|
211
|
+
}
|
|
212
|
+
cloudData = []
|
|
213
|
+
viewer.clock.onTick.removeEventListener(onTick)
|
|
214
|
+
}
|
|
215
|
+
|
|
123
216
|
const removeAll = () => {
|
|
124
217
|
cloudsCollection.forEach(item => item.clouds.removeAll())
|
|
125
218
|
viewer.scene.primitives.removeAll()
|
|
@@ -128,6 +221,8 @@ const useCloud = (viewer: Cesium.Viewer) => {
|
|
|
128
221
|
|
|
129
222
|
return {
|
|
130
223
|
draw,
|
|
224
|
+
enabledGlobalCloud,
|
|
225
|
+
disabledGlobalCloud,
|
|
131
226
|
removeAll
|
|
132
227
|
}
|
|
133
228
|
}
|
|
@@ -20,7 +20,7 @@ const useSeawater = (viewer: Cesium.Viewer) => {
|
|
|
20
20
|
fabric: {
|
|
21
21
|
type: 'Water',
|
|
22
22
|
uniforms: {
|
|
23
|
-
specularMap: __POLT__URL__ + '/assets/image/earthspec.jpg',
|
|
23
|
+
specularMap: (window as any).__POLT__URL__ + '/assets/image/earthspec.jpg',
|
|
24
24
|
normalMap: Cesium.buildModuleUrl('Assets/Textures/waterNormals.jpg'),
|
|
25
25
|
frequency: 10000.0,
|
|
26
26
|
animationSpeed: 0.01,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-three-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.355",
|
|
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
|
}
|