1
- import { AppBar , Box , Button , Slider , Switch , Typography } from "@mui/material" ;
2
- import React , { useState } from "react" ;
1
+ import { Box , Button , Slider , Switch , Typography } from "@mui/material" ;
2
+ import React , { useEffect , useState } from "react" ;
3
3
import { Sidebar , TopToolbar } from "@mapcomponents/react-maplibre" ;
4
4
5
5
export default function PointCloudSettings ( props ) {
@@ -12,6 +12,18 @@ export default function PointCloudSettings(props) {
12
12
13
13
const [ sidebarOpen , setSidebarOpen ] = useState ( false ) ;
14
14
15
+ function debounce ( func , timeout = 300 ) {
16
+ let timer ;
17
+ return ( ...args ) => {
18
+ clearTimeout ( timer ) ;
19
+ timer = setTimeout ( ( ) => {
20
+ func . apply ( this , args ) ;
21
+ } , timeout ) ;
22
+ } ;
23
+ }
24
+
25
+ const processChange = debounce ( ( ) => saveData ( ) ) ;
26
+
15
27
const saveData = ( ) => {
16
28
props . setPointSize ( pointSize ) ;
17
29
props . setLight ( light ) ;
@@ -21,31 +33,39 @@ export default function PointCloudSettings(props) {
21
33
props . setBlue ( blue ) ;
22
34
}
23
35
36
+ useEffect ( ( ) => {
37
+ processChange ( ) ;
38
+ } , [ pointSize , light , intensity , red , green , blue ] ) ;
39
+
24
40
return (
25
41
< >
26
42
< TopToolbar buttons = {
27
43
< Button
28
- variant = { sidebarOpen ? "outlined" : "contained" }
29
- onClick = { ( ) => setSidebarOpen ( true ) }
44
+ variant = { sidebarOpen ? "outlined" : "contained" }
45
+ onClick = { ( ) => setSidebarOpen ( ! sidebarOpen ) }
30
46
> PointCloud settings</ Button >
31
- } />
32
- < Sidebar open = { sidebarOpen } setOpen = { setSidebarOpen } >
47
+ } />
48
+ < Sidebar open = { sidebarOpen } setOpen = { setSidebarOpen } >
33
49
< Box
34
50
sx = { {
35
51
marginTop : '20px' ,
36
52
} }
37
53
>
38
54
{ /* Headline */ }
39
55
< Typography
40
- variant = "h4"
56
+ sx = { {
57
+ fontSize : '1.25rem' ,
58
+ marginBottom : '5px' ,
59
+ } }
41
60
>
42
61
PointCloud Settings
43
62
</ Typography >
44
- < hr width = '99%' />
45
-
46
63
{ /* PointSize */ }
47
64
< Typography
48
65
variant = "h6"
66
+ sx = { {
67
+ fontSize : '1rem' ,
68
+ } }
49
69
>
50
70
Point Size
51
71
</ Typography >
@@ -63,6 +83,9 @@ export default function PointCloudSettings(props) {
63
83
{ /* Light */ }
64
84
< Typography
65
85
variant = "h6"
86
+ sx = { {
87
+ fontSize : '1rem' ,
88
+ } }
66
89
>
67
90
Light
68
91
</ Typography >
@@ -73,27 +96,38 @@ export default function PointCloudSettings(props) {
73
96
} }
74
97
/>
75
98
76
- { /* Lightintensity */ }
77
- < Typography
78
- variant = "h6"
79
- >
80
- Light intensity
81
- </ Typography >
82
- < Slider
83
- defaultValue = { 1.7 }
84
- onChange = { ( e ) => {
85
- setIntensity ( e . target . value )
86
- } }
87
- aria-label = "small"
88
- valueLabelDisplay = "auto"
89
- min = { 0 }
90
- max = { 3 }
91
- step = { 0.1 }
92
- />
99
+ { /* Lightintensity */
100
+ light &&
101
+ < >
102
+ < Typography
103
+ variant = "h6"
104
+ sx = { {
105
+ fontSize : '1rem' ,
106
+ } }
107
+ >
108
+ Light intensity
109
+ </ Typography >
110
+ < Slider
111
+ defaultValue = { 1.7 }
112
+ onChange = { ( e ) => {
113
+ setIntensity ( e . target . value )
114
+ } }
115
+ aria-label = "small"
116
+ valueLabelDisplay = "auto"
117
+ min = { 0 }
118
+ max = { 3 }
119
+ step = { 0.1 }
120
+ />
121
+ </ >
122
+
123
+ }
93
124
94
125
{ /* Color */ }
95
126
< Typography
96
127
variant = "h6"
128
+ sx = { {
129
+ fontSize : '1rem' ,
130
+ } }
97
131
>
98
132
Color
99
133
</ Typography >
@@ -102,15 +136,17 @@ export default function PointCloudSettings(props) {
102
136
< Box
103
137
sx = { {
104
138
display : 'flex' ,
139
+ alignItems : 'center' ,
105
140
} }
106
141
>
107
142
< Typography
108
143
variant = "body1"
109
144
sx = { {
110
145
width : '10px' ,
146
+ fontSize : '1rem' ,
111
147
} }
112
148
>
113
- r :
149
+ R :
114
150
</ Typography >
115
151
< Slider
116
152
sx = { {
@@ -133,15 +169,17 @@ export default function PointCloudSettings(props) {
133
169
< Box
134
170
sx = { {
135
171
display : 'flex' ,
172
+ alignItems : 'center' ,
136
173
} }
137
174
>
138
175
< Typography
139
176
variant = "body1"
140
177
sx = { {
141
178
width : '10px' ,
179
+ fontSize : '1rem' ,
142
180
} }
143
181
>
144
- g :
182
+ G :
145
183
</ Typography >
146
184
< Slider
147
185
sx = { {
@@ -164,15 +202,17 @@ export default function PointCloudSettings(props) {
164
202
< Box
165
203
sx = { {
166
204
display : 'flex' ,
205
+ alignItems : 'center' ,
167
206
} }
168
207
>
169
208
< Typography
170
209
variant = "body1"
171
210
sx = { {
172
211
width : '10px' ,
212
+ fontSize : '1rem' ,
173
213
} }
174
214
>
175
- b :
215
+ B :
176
216
</ Typography >
177
217
< Slider
178
218
sx = { {
@@ -190,27 +230,9 @@ export default function PointCloudSettings(props) {
190
230
step = { 1 }
191
231
/>
192
232
</ Box >
193
- < Box
194
- sx = { {
195
- display : 'flex' ,
196
- justifyContent : 'right' ,
197
- marginTop : "25px"
198
- } }
199
- >
200
- < Button
201
- variant = "contained"
202
- disabled = { props . loading }
203
- sx = { {
204
- color : 'white' ,
205
- } }
206
- onClick = { ( ) => saveData ( ) }
207
- >
208
- Apply
209
- </ Button >
210
- </ Box >
211
-
212
233
</ Box >
213
234
</ Sidebar >
214
235
</ >
215
- ) ;
236
+ )
237
+ ;
216
238
}
0 commit comments