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

Anchors this game object to the globe. More...

Inheritance diagram for CesiumForUnity.CesiumGlobeAnchor:
CesiumForUnity.ICesiumRestartable

Public Member Functions

void SetPositionLongitudeLatitudeHeight (double longitude, double latitude, double height)
 
void SetPositionEarthCenteredEarthFixed (double x, double y, double z)
 
void Sync ()
 Synchronizes the properties of this CesiumGlobeAnchor.
 
void Restart ()
 Completely re-initializes the state of this object from its serialized properties.
 
- Public Member Functions inherited from CesiumForUnity.ICesiumRestartable

Properties

bool adjustOrientationForGlobeWhenMoving [get, set]
 Gets or sets whether to adjust the game object's orientation based on globe curvature as the game object moves.
 
bool detectTransformChanges [get, set]
 Gets or sets whether to automatically detect changes in the game object's.
 
double4x4 localToGlobeFixedMatrix [get, set]
 Gets or sets the 4x4 transformation matrix from this game object's local coordinate system to the Earth-Centered, Earth-Fixed (ECEF) coordinate system.
 
double3 longitudeLatitudeHeight [get, set]
 Gets or sets the longitude, latitude, and height of this object.
 
double3 positionGlobeFixed [get, set]
 Gets or sets the game object's position in the Earth-Centered, Earth-Fixed (ECEF) coordinates in meters.
 
quaternion rotationGlobeFixed [get, set]
 Gets or sets the rotation from the game object's coordinate system to the Earth-Centered, Earth-Fixed axes.
 
quaternion rotationEastUpNorth [get, set]
 Gets or sets the rotation from the game object's coordinate system to a local coordinate system centered on this object where the +X points in the local East direction, the +Y axis points in the local Up direction, and the +Z axis points in the local North direction.
 
double3 scaleGlobeFixed [get, set]
 Gets the scale from the game object's coordinate system to the Earth-Centered, Earth-Fixed coordinate system.
 
double3 scaleEastUpNorth [get, set]
 Gets or sets the scale from the game object's coordinate system to a local coordinate system centered on this object where the +X points in the local East direction, the +Y axis points in the local Up direction, and the +Z axis points in the local North direction.
 
double ecefX [get, set]
 
double ecefY [get, set]
 
double ecefZ [get, set]
 
double longitude [get, set]
 
double latitude [get, set]
 
double height [get, set]
 

Detailed Description

Anchors this game object to the globe.

An anchored game object can be placed anywhere on the globe with high precision, and it will stay in its proper place on the globe when the CesiumGeoreference origin changes.

A game object with this component must be nested inside a CesiumGeoreference. That is, the game object itself, or one of its ancestors, must have a CesiumGeoreference attached. Otherwise, this component will throw an exception in OnEnable.

An anchored game object is still allowed to move. It may be moved either by setting properties on this instance, or by updating the game object's Transform. If the object is expected to move outside of the Editor via a Transform change, be sure that the detectTransformChanges property is set to true so that this instance updates accordingly.

When this component is moved relative to the globe and adjustOrientationForGlobeWhenMoving is enabled, the orientation of the game object will also be updated in order to keep the object upright.

In most cases, the Transform of the ancestors of the GameObject that contains this component should be an identity transform: 0 position, 0 rotation, 1 scale. Otherwise, this globe anchor's position will be misaligned with other globe-aligned objects that are transformed differently. However, it is sometimes useful to purposely offset an object or group of objects.

Definition at line 47 of file CesiumGlobeAnchor.cs.

Member Function Documentation

◆ Restart()

void CesiumForUnity.CesiumGlobeAnchor.Restart ( )
inline

Completely re-initializes the state of this object from its serialized properties.

This is called automatically by OnEnable and is not usually necessary to call directly. It can sometimes be useful after Unity has modified the private, serializable fields of this instance. For example: after an undo or redo operation.

Implements CesiumForUnity.ICesiumRestartable.

Definition at line 499 of file CesiumGlobeAnchor.cs.

◆ SetPositionEarthCenteredEarthFixed()

void CesiumForUnity.CesiumGlobeAnchor.SetPositionEarthCenteredEarthFixed ( double x,
double y,
double z )
inline

Definition at line 423 of file CesiumGlobeAnchor.cs.

◆ SetPositionLongitudeLatitudeHeight()

void CesiumForUnity.CesiumGlobeAnchor.SetPositionLongitudeLatitudeHeight ( double longitude,
double latitude,
double height )
inline

Definition at line 416 of file CesiumGlobeAnchor.cs.

◆ Sync()

void CesiumForUnity.CesiumGlobeAnchor.Sync ( )
inline

Synchronizes the properties of this CesiumGlobeAnchor.

It is usually not necessary to call this method because it is called automatically when needed. However, it may be be useful in special situations or when the timing of the automatic calls is not ideal.

For example, if the Transform is updated via a coroutine, then the globe anchor's check for a change in the Transform may run before the change, in which case the new Transform won't be noted until the next frame. Calling this method after modifying the Transform will avoid the one frame delay.

This method performs the following actions:

  • If the localToGlobeFixedMatrix transform has not yet been set, it is computed from the game object's current Transform.
  • If the game object's Transform has changed since the last time OnEnable, or if a position setter was called, this method updates all of this instance's position properties from the current transform. This works even if detectTransformChanges is disabled. It will also update the object's orientation if adjustOrientationForGlobeWhenMoving is enabled.
  • If the origin of the CesiumGeoreference has changed, the game object's Transform is updated based on the localToGlobeFixedMatrix transform and the new georeference origin.

Definition at line 467 of file CesiumGlobeAnchor.cs.

Property Documentation

◆ adjustOrientationForGlobeWhenMoving

bool CesiumForUnity.CesiumGlobeAnchor.adjustOrientationForGlobeWhenMoving
getset

Gets or sets whether to adjust the game object's orientation based on globe curvature as the game object moves.

The Earth is not flat, so as we move across its surface, the direction of "up" changes. If we ignore this fact and leave an object's orientation unchanged as it moves over the globe surface, the object will become increasingly tilted and eventually be completely upside-down when we arrive at the opposite side of the globe.

When this setting is enabled, this component will automatically apply a rotation to the game object to account for globe curvature any time the game object's position on the globe changes.

This property should usually be enabled, but it may be useful to disable it when your application already accounts for globe curvature itself when it updates a game object's position and orientation, because in that case the game object would be over-rotated.

Definition at line 118 of file CesiumGlobeAnchor.cs.

◆ detectTransformChanges

bool CesiumForUnity.CesiumGlobeAnchor.detectTransformChanges
getset

Gets or sets whether to automatically detect changes in the game object's.

Transform

and update the precise globe coordinates accordingly.

Setting this property to true runs a coroutine to poll for an update to the

Transform

so that it can be reflected in the precise coordinates. When this is property is false, the coroutine and polling are not necessary, but the precise coordinates may become out of sync with the

Transform

.

When this is false, you can still directly set the precise coordinates, and the

Transform

will update accordingly. You can also call Sync after setting the

Transform

to manually update the precise coordinates.

Definition at line 141 of file CesiumGlobeAnchor.cs.

◆ ecefX

double CesiumForUnity.CesiumGlobeAnchor.ecefX
getset

Definition at line 344 of file CesiumGlobeAnchor.cs.

◆ ecefY

double CesiumForUnity.CesiumGlobeAnchor.ecefY
getset

Definition at line 356 of file CesiumGlobeAnchor.cs.

◆ ecefZ

double CesiumForUnity.CesiumGlobeAnchor.ecefZ
getset

Definition at line 368 of file CesiumGlobeAnchor.cs.

◆ height

double CesiumForUnity.CesiumGlobeAnchor.height
getset

Definition at line 404 of file CesiumGlobeAnchor.cs.

◆ latitude

double CesiumForUnity.CesiumGlobeAnchor.latitude
getset

Definition at line 392 of file CesiumGlobeAnchor.cs.

◆ localToGlobeFixedMatrix

double4x4 CesiumForUnity.CesiumGlobeAnchor.localToGlobeFixedMatrix
getset

Gets or sets the 4x4 transformation matrix from this game object's local coordinate system to the Earth-Centered, Earth-Fixed (ECEF) coordinate system.

The ECEF coordinate system is a right-handed system located at the center of the Earth. The +X axis points to the intersection of the Equator and Prime Meridian (zero degrees longitude). The +Y axis points to the intersection of the Equator and +90 degrees longitude. The +Z axis points up through the North Pole.

Definition at line 161 of file CesiumGlobeAnchor.cs.

◆ longitude

double CesiumForUnity.CesiumGlobeAnchor.longitude
getset

Definition at line 380 of file CesiumGlobeAnchor.cs.

◆ longitudeLatitudeHeight

double3 CesiumForUnity.CesiumGlobeAnchor.longitudeLatitudeHeight
getset

Gets or sets the longitude, latitude, and height of this object.

The Longitude (X) is in the range -180 to 180 degrees. The Latitude (Y) is in the range -90 to 90 degrees. The Height (Z) is measured in meters above the WGS84 ellipsoid. Do not confused an ellipsoidal height 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.

When the position is set via this property, it is internally converted to and stored in Earth-Centered, Earth-Fixed Coordinates. As a result, getting this property will not necessarily return the exact value that was set.

Definition at line 186 of file CesiumGlobeAnchor.cs.

◆ positionGlobeFixed

double3 CesiumForUnity.CesiumGlobeAnchor.positionGlobeFixed
getset

Gets or sets the game object's position in the Earth-Centered, Earth-Fixed (ECEF) coordinates in meters.

See localToGlobeFixedMatrix for an explanation of the ECEF coordinate system.

Definition at line 220 of file CesiumGlobeAnchor.cs.

◆ rotationEastUpNorth

quaternion CesiumForUnity.CesiumGlobeAnchor.rotationEastUpNorth
getset

Gets or sets the rotation from the game object's coordinate system to a local coordinate system centered on this object where the +X points in the local East direction, the +Y axis points in the local Up direction, and the +Z axis points in the local North direction.

When the rotation is set via this property, it is internally converted to and stored in the localToGlobeFixedMatrix property. As a result, getting this property will not necessarily return the exact value that was set.

Definition at line 278 of file CesiumGlobeAnchor.cs.

◆ rotationGlobeFixed

quaternion CesiumForUnity.CesiumGlobeAnchor.rotationGlobeFixed
getset

Gets or sets the rotation from the game object's coordinate system to the Earth-Centered, Earth-Fixed axes.

See localToGlobeFixedMatrix for an explanation of the ECEF coordinate system.

When the rotation is set via this property, it is internally converted to and stored in the localToGlobeFixedMatrix property. As a result, getting this property will not necessarily return the exact value that was set.

Definition at line 245 of file CesiumGlobeAnchor.cs.

◆ scaleEastUpNorth

double3 CesiumForUnity.CesiumGlobeAnchor.scaleEastUpNorth
getset

Gets or sets the scale from the game object's coordinate system to a local coordinate system centered on this object where the +X points in the local East direction, the +Y axis points in the local Up direction, and the +Z axis points in the local North direction.

When the rotation is set via this property, it is internally converted to and stored in the localToGlobeFixedMatrix property. As a result, getting this property will not necessarily return the exact value that was set.

Definition at line 333 of file CesiumGlobeAnchor.cs.

◆ scaleGlobeFixed

double3 CesiumForUnity.CesiumGlobeAnchor.scaleGlobeFixed
getset

Gets the scale from the game object's coordinate system to the Earth-Centered, Earth-Fixed coordinate system.

Because ECEF is right-handed and Unity is left-handed, this scale will almost always be negative.

See localToGlobeFixedMatrix for an explanation of the ECEF coordinate system.

Definition at line 300 of file CesiumGlobeAnchor.cs.


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