CameraApi (Class)

Namespace: Wrld.MapCamera

Contains endpoints to interact with the map.

Methods

void SetControlledCamera (Camera)

Sets the camera that is then controlled by the Wrld map.

Argument Type Description
camera Camera A Unity camera that can provide the frustum for streaming and is controlled by the Wrld map.

Camera GetControlledCamera ()

Returns the camera that is currently being controlled by the map.

void ClearControlledCamera ()

Removes any Unity camera under control of the Wrld Map.

Vector3 GeographicToWorldPoint (LatLongAltitude, Camera)

Transforms a point from local Unity space to a geographic coordinate using the supplied camera. If no camera is specified, the currently controlled camera will be used. Note: If using the ECEF coordinate system, the returned position will only be valid until the camera is moved. To robustly position an object on the map, use the GeographicTransform component.

Returns: The transformed geographic LatLongAltitude in local space.

Argument Type Description
position LatLongAltitude The geographical coordinates of the position to transform to local space.
camera Camera The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.

LatLongAltitude WorldToGeographicPoint (Vector3, Camera)

Transforms a point from local Unity space to a geographic coordinate using the supplied camera. If no camera is specified, the currently controlled camera will be used. Note: If using the ECEF coordinate system, the returned position will only be valid until the camera is moved. To robustly position an object on the map, use the GeographicTransform component.

Returns: The transformed world position as a LatLongAltitude.

Argument Type Description
position Vector3 The world position to transform into a geographic coordinate.
camera Camera The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.

Vector3 GeographicToViewportPoint (LatLongAltitude, Camera)

Transforms the supplied geographical coordinates into viewport space, using the supplied camera (if specified) or the camera previously set via SetControlledCamera if not.

Returns: The transformed geographic LatLongAltitude in viewport space.

Argument Type Description
position LatLongAltitude The geographical coordinates of the position to transform to viewport space.
camera Camera The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.

LatLongAltitude ViewportToGeographicPoint (Vector3, Camera)

Transforms the supplied viewport space coordinates into LatLongAltitude geographical coordinates, using the supplied camera (if specified) or the camera previously set via SetControlledCamera if not.

Returns: The transformed viewport space coordinates as a LatLongAltitude.

Argument Type Description
viewportSpacePosition Vector3 The viewport-space coordinates to transform to geographical coordinates.
camera Camera The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.

LatLongAltitude ScreenToGeographicPoint (Vector3, Camera)

Transforms the supplied screen space coordinates into LatLongAltitude geographical coordinates, using the supplied camera (if specified) or the camera previously set via SetControlledCamera if not.

Returns: The transformed screen space coordinates as a LatLongAltitude.

Argument Type Description
screenSpacePosition Vector3 The screen space coordinates of the position to transform to geographical coordinates.
camera Camera The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.

Vector3 GeographicToScreenPoint (LatLongAltitude, Camera)

Transforms the supplied geographical coordinates into screen space, using the supplied camera (if specified) or the camera previously set via SetControlledCamera if not.

Returns: The transformed geographic LatLongAltitude in screen space.

Argument Type Description
position LatLongAltitude The geographical coordinates of the position to transform to screen space.
camera Camera The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.

void SetCustomRenderCamera (Camera)

Sets a custom render camera to be used with API points requiring screen space projection & unprojection.

Argument Type Description
camera Camera  

void ClearCustomRenderCamera ()

Unsets the custom render camera to revert screen space API points to their default behaviour

void UpdateInput ()

void Update (float)

Argument Type Description
deltaTime float  

bool MoveTo (LatLong, Nullable<​double​>, Nullable<​double​>, Nullable<​double​>)

Moves the camera to view the supplied interest point instantaneously, without any animation. Requires that a camera has been set using SetControlledCamera.

Returns: Whether the camera successfully moved or not.

Argument Type Description
interestPoint LatLong The latitude and longitude of the point on the ground which the camera should look at.
distanceFromInterest Nullable<​double​> Optional. The distance in metres from the interest point at which the camera should sit. If unspecified/null the altitude is set to 0.0.
headingDegrees Nullable<​double​> Optional. The heading in degrees (0, 360) with which to view the target point, with 0 facing north, 90 east, etc. If unspecified/null the heading with which the camera’s previous interest point was viewed will be maintained.
tiltDegrees Nullable<​double​> Optional. The camera tilt in degrees, where a value of 0 represents a camera looking straight down at the interest point, along the direction of gravity.

bool MoveTo (LatLong, LatLongAltitude)

Moves the camera to view the supplied interest point instantaneously, without any animation. Requires that a camera has been set using SetControlledCamera.

Returns: Whether the camera successfully moved or not.

Argument Type Description
interestPoint LatLong The latitude and longitude of the point on the ground which the camera should look at.
cameraPosition LatLongAltitude The latitude, longitude and altitude from which the camera will look at the interest point.

bool AnimateTo (LatLong, Nullable<​double​>, Nullable<​double​>, Nullable<​double​>, Nullable<​double​>, bool)

Smoothly animates the camera to view the supplied interest point. Requires that a camera has been set using SetControlledCamera.

Returns: Whether the camera successfully animated or not.

Argument Type Description
interestPoint LatLong The latitude and longitude of the point on the ground which the camera should be looking at once the transition is complete.
distanceFromInterest Nullable<​double​> Optional. The distance in metres from the interest point at which the camera should sit. If unspecified/null the distance to the previous interest point is maintained.
headingDegrees Nullable<​double​> Optional. The heading in degrees (0, 360) with which to view the target point, with 0 facing north, 90 east, etc. If unspecified/null the heading with which the camera’s previous interest point was viewed will be maintained.
tiltDegrees Nullable<​double​> Optional. The camera tilt in degrees, where a value of 0 represents a camera looking straight down at the interest point, along the direction of gravity.
transitionDuration Nullable<​double​> Optional. The total duration of the transition, in seconds. If not specified the duration will be calculated from the distance to be travelled and the camera’s maximum speed.
jumpIfFarAway bool Optional. By default AnimateTo will provide a smooth transition for short distances, but an instantaneous transition if there is a large distance to be covered (rather than waiting for a lengthy animation to play). If you want to override this behaviour and force an animation (even over large distances), you can set this to false.

bool AnimateTo (LatLong, LatLongAltitude, Nullable<​double​>, bool)

Smoothly animates the camera to view the supplied interest point. Requires that a camera has been set using SetControlledCamera.

Returns: Whether the camera successfully animated or not.

Argument Type Description
interestPoint LatLong The latitude and longitude of the point on the ground which the camera should be looking at once the transition is complete.
cameraPosition LatLongAltitude The latitude, longitude and altitude from which the camera will look at the interest point when the transition is complete.
transitionDuration Nullable<​double​> Optional. The total duration of the transition, in seconds. If not specified the duration will be calculated from the distance to be travelled and the camera’s maximum speed.
jumpIfFarAway bool Optional. By default AnimateTo will provide a smooth transition for short distances, but an instantaneous transition if there is a large distance to be covered (rather than waiting for a lengthy animation to play). If you want to override this behaviour and force an animation (even over large distances), you can set this to false.

void RegisterShouldConsumeInputDelegate (Func<​bool​>)

Registers a delegate which can control whether or not our built-in camera controls should respond. It is called every frame.

Argument Type Description
function Func<​bool​> The delegate function to use. Should return a boolean value.

void UnregisterShouldConsumeInputDelegate (Func<​bool​>)

Unregisters the delegate which controls whether or not our built-in camera controls should respond.

Argument Type Description
function Func<​bool​> The delegate function to unregister.

void SetShouldConsumeInputDelegate (Func<​int, bool​>)

Sets a delegate to can control whether or not our built-in camera controls should respond to input. It is called once a frame for mouse interfaces, and once for every active touch when using touch controls. The pointer id associated with the input event is passed as a parameter.

Argument Type Description
function Func<​int, bool​> a method returning true if the camera should respond to the supplied input event and false otherwise

void ClearShouldConsumeInputDelegate ()

Clears any delegate previously supplied to SetShouldConsumeInputDelegate, with the result that the camera will always respond to input events if one has been supplied to SetControlledCamera.

Properties

bool IsTransitioning

Checks to see if the Wrld map controlled camera is currently undergoing a transition.

bool IsTransitioning { get; private set; } 

bool IsCameraDrivenFromInput

Controls whether or not to update the controlled camera in response to user mouse & touch events.

bool IsCameraDrivenFromInput { get; set; } 

bool HasControlledCamera

Whether or not a camera has been set via SetControlledCamera.

bool HasControlledCamera { get; private set; } 

Events

TransitionStartHandler OnTransitionStart

Raised when a camera transition begins.

TransitionEndHandler OnTransitionEnd

Raised when a camera transition ends.