-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathGeocentricTransform.cs
More file actions
45 lines (36 loc) · 1.18 KB
/
GeocentricTransform.cs
File metadata and controls
45 lines (36 loc) · 1.18 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
//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 sbio.Core.Math;
using UnityEngine;
using sbio.owsdk.Unity.Extensions;
namespace sbio.owsdk.Unity
{
public class GeocentricTransform : MonoBehaviour
{
#region MonoBehaviour
public WorldContext WorldContext;
public double X;
public double Y;
public double Z;
private void OnEnable()
{
OnWorldOriginChanged(WorldContext.WorldOrigin);
WorldContext.WorldOriginChanged.Event += OnWorldOriginChanged;
}
private void OnDisable()
{
WorldContext.WorldOriginChanged.Event -= OnWorldOriginChanged;
OnWorldOriginChanged(Vec3LeftHandedGeocentric.Zero);
}
#endregion
private void OnWorldOriginChanged(Vec3LeftHandedGeocentric newOrigin)
{
var globalPos = new Vec3LeftHandedGeocentric(X, Y, Z);
transform.position = (globalPos - newOrigin).ToVector3();
}
}
}
//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.