Cesium for Unity 1.15.2
Loading...
Searching...
No Matches
CesiumForUnity.CesiumGeoreference Class Reference

Controls how global geospatial coordinates are mapped to coordinates in the Unity scene. More...

Inheritance diagram for CesiumForUnity.CesiumGeoreference:

Public Member Functions

void SetOriginEarthCenteredEarthFixed (double x, double y, double z)
 Sets the origin of the coordinate system to particular ecefX, ecefY, ecefZ coordinates in the Earth-Centered, Earth-Fixed (ECEF) frame.
 
void SetOriginLongitudeLatitudeHeight (double longitude, double latitude, double height)
 Sets the origin of the coordinate system to a particular longitude, latitude, and height.
 
void AddGlobeAnchor (CesiumGlobeAnchor globeAnchor)
 Register a globe anchor with this georeference.
 
void RemoveGlobeAnchor (CesiumGlobeAnchor globeAnchor)
 Deregisters a globe anchor with this georeference, so the globe anchor will no longer be updated when the georeference origin changes.
 
void Initialize ()
 Initializes this georeference so that other objects may use it to locate the globe in the world.
 
void ReloadEllipsoid ()
 Called when the ellipsoid override property has changed.
 
void MoveOrigin ()
 Recomputes the coordinate system based on an updated origin.
 
double3 TransformUnityPositionToEarthCenteredEarthFixed (double3 unityPosition)
 Transform a Unity position to Earth-Centered, Earth-Fixed (ECEF) coordinates.
 
double3 TransformEarthCenteredEarthFixedPositionToUnity (double3 earthCenteredEarthFixed)
 Transform an Earth-Centered, Earth-Fixed position to Unity coordinates.
 
double3 TransformUnityDirectionToEarthCenteredEarthFixed (double3 unityDirection)
 Transform a Unity direction to a direction in Earth-Centered, Earth-Fixed (ECEF) coordinates.
 
double3 TransformEarthCenteredEarthFixedDirectionToUnity (double3 earthCenteredEarthFixedDirection)
 Transform an Earth-Centered, Earth-Fixed direction to Unity coordinates.
 

Properties

CesiumGeoreferenceOriginPlacement originPlacement [get, set]
 The placement of this GameObject's origin (coordinate 0,0,0) within the tileset.
 
CesiumGeoreferenceOriginAuthority originAuthority [get, set]
 Identifies which set of coordinates authoritatively defines the origin of this georeference.
 
double latitude [get, set]
 The latitude of the origin of the coordinate system, in degrees, in the range -90 to 90.
 
double longitude [get, set]
 The longitude of the origin of the coordinate system, in degrees, in the range -180 to 180.
 
double height [get, set]
 The height in the origin of the coordinate system, in meters above the ellipsoid.
 
double ecefX [get, set]
 The Earth-Centered, Earth-Fixed X coordinate of the origin of the coordinate system, in meters.
 
double ecefY [get, set]
 The Earth-Centered, Earth-Fixed Y coordinate of the origin of the coordinate system, in meters.
 
double ecefZ [get, set]
 The Earth-Centered, Earth-Fixed Z coordinate of the origin of the coordinate system, in meters.
 
double scale [get, set]
 The scale of the globe in the Unity world.
 
double4x4 localToEcefMatrix [get]
 
double4x4 ecefToLocalMatrix [get]
 
CesiumEllipsoid ellipsoid [get, set]
 The CesiumEllipsoid that is referenced.
 

Events

Action changed
 An event raised when the georeference changes.
 

Detailed Description

Controls how global geospatial coordinates are mapped to coordinates in the Unity scene.

This component should be added to a GameObject that is a parent of all GameObjects with the Cesium3DTileset or CesiumGlobeAnchor components.

Internally, Cesium uses a global Earth-centered, Earth-fixed (ECEF) ellipsoid-centered coordinate system, where the ellipsoid is usually the World Geodetic System 1984 (WGS84) ellipsoid. This is a right-handed system centered at the Earth's center of mass, where +X is in the direction of the intersection of the Equator and the Prime Meridian (zero degrees longitude), +Y is in the direction of the intersection of the Equator and +90 degrees longitude, and +Z is through the North Pole.

This component controls how this coordinate system is mapped into the Unity world. It creates a left-handed, Unity-friendly coordinate system centered at the specified georeference origin, where +X points East, +Y points up, and +Z points North, and transforms coordinates between that coordinate system and ECEF.

The Unity

Transform

is applied after the georeference transformation, in the normal way. For example, if a Cesium3DTileset's

position

property is set to

(5000.0, 100.0, 0.0)

, then that tileset will be shifted East 5000 units and up 100 units. If the CesiumGeoreference has a scale of 0.5, the entire globe will be half of its normal size in the Unity world.

Definition at line 89 of file CesiumGeoreference.cs.

Member Function Documentation

◆ AddGlobeAnchor()

void CesiumForUnity.CesiumGeoreference.AddGlobeAnchor ( CesiumGlobeAnchor globeAnchor)
inline

Register a globe anchor with this georeference.

When the georeference origin changes, the registered anchor will be updated accordingly.

This is called automatically by CesiumGlobeAnchor.OnEnable and usually does not need to be called directly.

Parameters
globeAnchorThe globe anchor.

Definition at line 417 of file CesiumGeoreference.cs.

◆ Initialize()

void CesiumForUnity.CesiumGeoreference.Initialize ( )
inline

Initializes this georeference so that other objects may use it to locate the globe in the world.

It is not usually necessary to call this directly because it is called automatically in OnEnable. However, when other objects in the same scene need to use this georeference from their own

OnEnable

, it is possible that the other object's OnEnable will be called before the georeference's, leading to incorrect georeferencing. Calling this method explicitly will avoid this problem.

However, this method should not be called prior to the scene's

OnEnable

phase.

If this component has already been initialized, this method does nothing.

Definition at line 454 of file CesiumGeoreference.cs.

◆ MoveOrigin()

void CesiumForUnity.CesiumGeoreference.MoveOrigin ( )
inline

Recomputes the coordinate system based on an updated origin.

It is usually not necessary to call this directly as it is called automatically when needed.

Definition at line 491 of file CesiumGeoreference.cs.

◆ ReloadEllipsoid()

void CesiumForUnity.CesiumGeoreference.ReloadEllipsoid ( )
inline

Called when the ellipsoid override property has changed.

Definition at line 467 of file CesiumGeoreference.cs.

◆ RemoveGlobeAnchor()

void CesiumForUnity.CesiumGeoreference.RemoveGlobeAnchor ( CesiumGlobeAnchor globeAnchor)
inline

Deregisters a globe anchor with this georeference, so the globe anchor will no longer be updated when the georeference origin changes.

This is called automatically by CesiumGlobeAnchor.OnDisable and usually does not need to be called directly.

Parameters
globeAnchorThe globe anchor.

Definition at line 431 of file CesiumGeoreference.cs.

◆ SetOriginEarthCenteredEarthFixed()

void CesiumForUnity.CesiumGeoreference.SetOriginEarthCenteredEarthFixed ( double x,
double y,
double z )
inline

Sets the origin of the coordinate system to particular ecefX, ecefY, ecefZ coordinates in the Earth-Centered, Earth-Fixed (ECEF) frame.

Calling this method is more efficient than setting the properties individually.

Parameters
xThe X coordinate in meters.
yThe Y coordinate in meters.
zThe Z coordinate in meters.

Definition at line 378 of file CesiumGeoreference.cs.

◆ SetOriginLongitudeLatitudeHeight()

void CesiumForUnity.CesiumGeoreference.SetOriginLongitudeLatitudeHeight ( double longitude,
double latitude,
double height )
inline

Sets the origin of the coordinate system to a particular longitude, latitude, and height.

Calling this method is more efficient than setting the properties individually.

Parameters
longitudeThe longitude in degrees, in the range -180 to 180.
latitudeThe latitude in degrees, in the range -90 to 90.
heightThe height in meters above the ellipsoid. Do not confuse this with a geoid height or height above mean sea level, which can be tens of meters higher or lower depending on where in the world the object is located.

Definition at line 400 of file CesiumGeoreference.cs.

◆ TransformEarthCenteredEarthFixedDirectionToUnity()

double3 CesiumForUnity.CesiumGeoreference.TransformEarthCenteredEarthFixedDirectionToUnity ( double3 earthCenteredEarthFixedDirection)
inline

Transform an Earth-Centered, Earth-Fixed direction to Unity coordinates.

The resulting direction should generally not be interpreted as a Unity world direction, but rather a direction expressed in some parent GameObject's reference frame as defined by its Transform. This way, the chain of Unity transforms orients the "globe" in the Unity world.

Parameters
earthCenteredEarthFixedDirectionThe direction in ECEF coordinates.
Returns
The corresponding Unity direction.

Definition at line 620 of file CesiumGeoreference.cs.

◆ TransformEarthCenteredEarthFixedPositionToUnity()

double3 CesiumForUnity.CesiumGeoreference.TransformEarthCenteredEarthFixedPositionToUnity ( double3 earthCenteredEarthFixed)
inline

Transform an Earth-Centered, Earth-Fixed position to Unity coordinates.

The resulting position should generally not be interpreted as a Unity world position, but rather a position expressed in some parent GameObject's reference frame as defined by its Transform. This way, the chain of Unity transforms places and orients the "globe" in the Unity world.

Parameters
earthCenteredEarthFixedThe ECEF coordinates in meters.
Returns
The corresponding Unity coordinates.

Definition at line 590 of file CesiumGeoreference.cs.

◆ TransformUnityDirectionToEarthCenteredEarthFixed()

double3 CesiumForUnity.CesiumGeoreference.TransformUnityDirectionToEarthCenteredEarthFixed ( double3 unityDirection)
inline

Transform a Unity direction to a direction in Earth-Centered, Earth-Fixed (ECEF) coordinates.

The direction should generally not be a Unity world direction, but rather a direction expressed in some parent GameObject's reference frame as defined by its Transform. This way, the chain of Unity transforms orients the "globe" in the Unity world.

Parameters
unityDirectionThe Unity direction to convert.
Returns
The ECEF direction.

Definition at line 605 of file CesiumGeoreference.cs.

◆ TransformUnityPositionToEarthCenteredEarthFixed()

double3 CesiumForUnity.CesiumGeoreference.TransformUnityPositionToEarthCenteredEarthFixed ( double3 unityPosition)
inline

Transform a Unity position to Earth-Centered, Earth-Fixed (ECEF) coordinates.

The position should generally not be a Unity world position, but rather a position expressed in some parent GameObject's reference frame as defined by its Transform. This way, the chain of Unity transforms places and orients the "globe" in the Unity world.

Parameters
unityPositionThe Unity position to convert.
Returns
The ECEF coordinates in meters.

Definition at line 575 of file CesiumGeoreference.cs.

Property Documentation

◆ ecefToLocalMatrix

double4x4 CesiumForUnity.CesiumGeoreference.ecefToLocalMatrix
get

Definition at line 331 of file CesiumGeoreference.cs.

◆ ecefX

double CesiumForUnity.CesiumGeoreference.ecefX
getset

The Earth-Centered, Earth-Fixed X coordinate of the origin of the coordinate system, in meters.

This property only takes effect if CesiumGeoreference.originPlacement is set to CesiumGeoreferenceOriginPlacement.CartographicOrigin and originAuthority is set to CesiumGeoreferenceOriginAuthority.EarthCenteredEarthFixed. Setting this property changes the originAuthority accordingly.

Definition at line 254 of file CesiumGeoreference.cs.

◆ ecefY

double CesiumForUnity.CesiumGeoreference.ecefY
getset

The Earth-Centered, Earth-Fixed Y coordinate of the origin of the coordinate system, in meters.

This property only takes effect if CesiumGeoreference.originPlacement is set to CesiumGeoreferenceOriginPlacement.CartographicOrigin and originAuthority is set to CesiumGeoreferenceOriginAuthority.EarthCenteredEarthFixed. Setting this property changes the originAuthority accordingly.

Definition at line 274 of file CesiumGeoreference.cs.

◆ ecefZ

double CesiumForUnity.CesiumGeoreference.ecefZ
getset

The Earth-Centered, Earth-Fixed Z coordinate of the origin of the coordinate system, in meters.

This property only takes effect if CesiumGeoreference.originPlacement is set to CesiumGeoreferenceOriginPlacement.CartographicOrigin and originAuthority is set to CesiumGeoreferenceOriginAuthority.EarthCenteredEarthFixed. Setting this property changes the originAuthority accordingly.

Definition at line 294 of file CesiumGeoreference.cs.

◆ ellipsoid

CesiumEllipsoid CesiumForUnity.CesiumGeoreference.ellipsoid
getset

The CesiumEllipsoid that is referenced.

Definition at line 343 of file CesiumGeoreference.cs.

◆ height

double CesiumForUnity.CesiumGeoreference.height
getset

The height in the origin of the coordinate system, in meters above the ellipsoid.

Do not confuse this with a geoid height or height above mean sea level, which can be tens of meters higher or lower depending on where in the world the object is located.

This property only takes effect if CesiumGeoreference.originPlacement is set to CesiumGeoreferenceOriginPlacement.CartographicOrigin and originAuthority is set to CesiumGeoreferenceOriginAuthority.LongitudeLatitudeHeight. Setting this property changes the originAuthority accordingly.

Definition at line 234 of file CesiumGeoreference.cs.

◆ latitude

double CesiumForUnity.CesiumGeoreference.latitude
getset

The latitude of the origin of the coordinate system, in degrees, in the range -90 to 90.

This property only takes effect if CesiumGeoreference.originPlacement is set to CesiumGeoreferenceOriginPlacement.CartographicOrigin and originAuthority is set to CesiumGeoreferenceOriginAuthority.LongitudeLatitudeHeight. Setting this property changes the originAuthority accordingly.

Definition at line 192 of file CesiumGeoreference.cs.

◆ localToEcefMatrix

double4x4 CesiumForUnity.CesiumGeoreference.localToEcefMatrix
get

Definition at line 322 of file CesiumGeoreference.cs.

◆ longitude

double CesiumForUnity.CesiumGeoreference.longitude
getset

The longitude of the origin of the coordinate system, in degrees, in the range -180 to 180.

This property only takes effect if CesiumGeoreference.originPlacement is set to CesiumGeoreferenceOriginPlacement.CartographicOrigin and originAuthority is set to CesiumGeoreferenceOriginAuthority.LongitudeLatitudeHeight. Setting this property changes the originAuthority accordingly.

Definition at line 212 of file CesiumGeoreference.cs.

◆ originAuthority

CesiumGeoreferenceOriginAuthority CesiumForUnity.CesiumGeoreference.originAuthority
getset

Identifies which set of coordinates authoritatively defines the origin of this georeference.

Setting this property changes the originPlacement accordingly.

Definition at line 172 of file CesiumGeoreference.cs.

◆ originPlacement

CesiumGeoreferenceOriginPlacement CesiumForUnity.CesiumGeoreference.originPlacement
getset

The placement of this GameObject's origin (coordinate 0,0,0) within the tileset.

3D Tiles tilesets often use Earth-centered, Earth-fixed coordinates, such that the tileset content is in a small bounding volume 6-7 million meters (the radius of the Earth) away from the coordinate system origin. This property allows an alternative position, other than the tileset's true origin, to be treated as the origin for the purpose of this GameObject. Using this property will preserve vertex precision (and thus avoid jittering) much better than setting the GameObject's Transform property.

Definition at line 155 of file CesiumGeoreference.cs.

◆ scale

double CesiumForUnity.CesiumGeoreference.scale
getset

The scale of the globe in the Unity world.

If this value is 0.5, for example, one meter on the globe occupies half a meter in the Unity world.

The globe can also be scaled by modifying the georeference's Transform, but setting this property instead will do a better job of preserving precision.

Definition at line 312 of file CesiumGeoreference.cs.

Event Documentation

◆ changed

Action CesiumForUnity.CesiumGeoreference.changed

An event raised when the georeference changes.

Definition at line 366 of file CesiumGeoreference.cs.


The documentation for this class was generated from the following file: