easy-three-utils 0.0.353 → 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.
@@ -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,8 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom";
3
+
4
+ const BodyPortal: React.FC<{ children: React.ReactNode }> = ({ children }) => {
5
+ return ReactDOM.createPortal(children, document.body);
6
+ };
7
+
8
+ export default BodyPortal;
@@ -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: absolute;
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
- return () => {
31
- }
32
+ sliderBoxRef.current.style.bottom = `calc(-100vh + ${sliderBoxRef.current.clientHeight + 20}px)`
32
33
  }, [])
33
34
 
34
35
  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
- />
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
- </div>
49
- </ConfigProvider>
52
+ </ConfigProvider>
53
+ </BodyPortal>
50
54
  )
51
55
  }
52
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-three-utils",
3
- "version": "0.0.353",
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
  }