Gravity Gravity.x Gravity.y Gravity.z
This global variable represents the current direction and amount of gravity relative to the screen orientation while the viewer is running. The y component of this vector will almost always be negative, indicating that the device is being held upright.
x | float, the amount of gravity in the x direction |
y | float, the amount of gravity in the y direction |
z | float, the amount of gravity in the z direction |
UserAcceleration UserAcceleration.x UserAcceleration.y UserAcceleration.z
This global variable represents the current acceleration relative to the device while the viewer is running. You can use this to detect things such as shaking.
x | float, the amount of acceleration in the x direction |
y | float, the amount of acceleration in the y direction |
z | float, the amount of acceleration in the z direction |
RotationRate RotationRate.x RotationRate.y RotationRate.z
This global variable represents the rotation rate of the device around three axes. Internally, this makes use of the device gyroscope (if available). On devices where a gyroscope is not available, RotationRate
is a zero vector.
x | float, the amount of rotation around the x axis |
y | float, the amount of rotation around the y axis |
z | float, the amount of rotation around the z axis |
location.enable()
Calling this function requests that the device should begin monitoring its physical location. You must call this before you can reliably read location data. Upon first activation the device will request permission to access its location, permission must be granted in order to use location functions. Location updates are disabled by default.
location.disable()
Calling this function requests that the device should stop monitoring its physical location. Disabling location updates preserves battery power.
location.available()
This function returns whether location data is available. If location updating has not been enabled, or is not permitted, this function will return false.
A boolean value specifying whether location data is available
location.distanceTo(lat, lon)
This function returns the distance in meters from the current location (if available) to the specified latitude
and longitude
.
Distance in meters between the current location and specified coordinates
location.distanceBetween(lat1, lon1, lat2, lon2)
This function returns the distance in meters between two locations specified by the coordinates lat1
, lon1
, lat2
, lon2
.
Distance in meters between the two specified coordinates
location.latitude
This value specifies the current latitude if location is available.
Current latitude, if available. Nil if not.
location.longitude
This value specifies the current longitude if location is available.
Current longitude, if available. Nil if not.
location.altitude
This value specifies the current altitude if location is available. Positive values indicate altitudes above sea level. Negative values indicate altitudes below sea level.
Current altitude, if available. Nil if not.
location.horizontalAccuracy
This value specifies the horizontal accuracy of the latitude and longitude of the current location. This value indicates the radius of the circle in which the latitude and longitude are at the center.
A negative value indicates that the location’s latitude and longitude are invalid.
Current horizontal accuracy, if available. Nil if not.
location.verticalAccuracy
This value specifies the accuracy of the altitude of the current location. The altitude value could be plus or minus this value.
A negative value indicates that the current altitude is invalid.
Current vertical accuracy, if available. Nil if not.
location.speed
This value specifies the current speed of the device in meters per second. A negative value indicates an invalid speed.
Current speed, if available. Nil if not.
location.course
This variable specifies the current heading of the device measured in degrees starting at due north and moving clockwise around the compass. A negative value indicates an invalid direction.
Current course, if available. Nil if not.