-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEarthSettings.swift
More file actions
78 lines (69 loc) · 2.43 KB
/
EarthSettings.swift
File metadata and controls
78 lines (69 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
Settings for the Earth entity.
*/
import SwiftUI
/// Controls for settings specific to the Earth entity.
struct EarthSettings: View {
@Binding var configuration: EarthEntity.Configuration
private var solarSunAngleBinding: Binding<Double> {
Binding<Double>(
get: { configuration.sunAngle.degrees },
set: { configuration.sunAngle = .degrees($0) }
)
}
var body: some View {
Section("Earth") {
Grid(alignment: .leading, verticalSpacing: 20) {
SliderGridRow(
title: "Scale",
value: $configuration.scale,
range: 0 ... 1e3)
SliderGridRow(
title: "Rotation speed",
value: $configuration.speed,
range: 0 ... 1,
fractionLength: 3)
Divider()
SliderGridRow(
title: "X",
value: $configuration.position.x,
range: -10 ... 10)
SliderGridRow(
title: "Y",
value: $configuration.position.y,
range: -10 ... 10)
SliderGridRow(
title: "Z",
value: $configuration.position.z,
range: -10 ... 10)
Divider()
Toggle("Show Poles", isOn: $configuration.showPoles)
SliderGridRow(
title: "Pole height",
value: $configuration.poleLength,
range: 0 ... 1,
fractionLength: 3)
SliderGridRow(
title: "Pole thickness",
value: $configuration.poleThickness,
range: 0 ... 1,
fractionLength: 3)
}
}
Section("Sun") {
Grid(alignment: .leading, verticalSpacing: 20) {
Toggle("Show Sun", isOn: $configuration.showSun)
SliderGridRow(
title: "Sun intensity",
value: $configuration.sunIntensity,
range: 0 ... 20)
SliderGridRow(
title: "Angle",
value: solarSunAngleBinding,
range: 0 ... 360)
}
}
}
}