-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathWorldContext.cs
More file actions
104 lines (87 loc) · 2.62 KB
/
WorldContext.cs
File metadata and controls
104 lines (87 loc) · 2.62 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//Copyright SimBlocks LLC 2016-2022
//https://www.simblocks.io/
//The source code in this file is licensed under the MIT License. See the LICENSE text file for full terms.
using System;
using sbio.Core.Math;
using sbio.owsdk.Geodetic;
using sbio.owsdk.Services;
using sbio.owsdk.Unity.Events;
using UnityEngine;
namespace sbio.owsdk.Unity
{
[CreateAssetMenu(menuName = "OWSDK/World Context", order = 110)]
public class WorldContext : ScriptableObject
, IWorldContext
{
#region ScriptableObject
public Vector3dEvent WorldOriginChanged;
private void OnEnable()
{
m_Ellipsoid = new Ellipsoid(m_RadiusX, m_RadiusY, m_RadiusZ);
m_WorldOrigin = Vec3LeftHandedGeocentric.Zero;
}
private void OnDisable()
{
m_WorldOrigin = Vec3LeftHandedGeocentric.Zero;
m_Ellipsoid = null;
}
#endregion
event Action<Vec3LeftHandedGeocentric> IRTOContext.WorldOriginChanged
{
add { WorldOriginChanged.Event += value; }
remove { WorldOriginChanged.Event -= value; }
}
public event Action<IElevationProvider> ElevationProviderChanged;
public event Action<IFeatureProvider> FeatureProviderChanged;
public Ellipsoid Ellipsoid
{
get { return m_Ellipsoid; }
}
public Vec3LeftHandedGeocentric WorldOrigin
{
get { return m_WorldOrigin; }
set
{
if (value != m_WorldOrigin)
{
m_WorldOrigin = value;
WorldOriginChanged?.Raise(value);
}
}
}
public IElevationProvider ElevationProvider
{
get { return m_ElevationProvider; }
set
{
if (value != ElevationProvider)
{
m_ElevationProvider = value;
ElevationProviderChanged?.Invoke(value);
}
}
}
public IFeatureProvider FeatureProvider
{
get { return m_FeatureProvider; }
set
{
if (value != m_FeatureProvider)
{
m_FeatureProvider = value;
FeatureProviderChanged?.Invoke(value);
}
}
}
[SerializeField] private double m_RadiusX = 6378137.0;
[SerializeField] private double m_RadiusY = 6356752.314245;
[SerializeField] private double m_RadiusZ = 6378137.0;
[NonSerialized] private IElevationProvider m_ElevationProvider;
[NonSerialized] private IFeatureProvider m_FeatureProvider;
[NonSerialized] private Vec3LeftHandedGeocentric m_WorldOrigin;
[NonSerialized] private Ellipsoid m_Ellipsoid;
}
}
//Copyright SimBlocks LLC 2016-2022
//https://www.simblocks.io/
//The source code in this file is licensed under the MIT License. See the LICENSE text file for full terms.