CameraApi (Class)

Namespace: Wrld.MapCamera

Contains endpoints to interact with the map.

Methods

void SetControlledCamera (Camera camera)

By default, the WRLD SDK maintains an internal representation of a rendering camera, and uses this to control a UnityEngine.Camera instance, moving it around in response to user input and CameraApi function calls. This function sets which UnityEngine.Camera instance will be controlled by the WRLD SDK.

Argument Type Description
camera Camera A UnityEngine.Camera instance that will be controlled by the Wrld map.

Camera GetControlledCamera ()

Returns the camera that is currently being controlled by the WRLD SDK.

void ClearControlledCamera ()

Releases any UnityEngine.Camera instance currently being controlled by the WRLD SDK.

Vector3 GeographicToWorldPoint (LatLongAltitude position, Camera 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 position, Camera 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 position, Camera 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 viewportSpacePosition, Camera 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 screenSpacePosition, Camera 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 position, Camera 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 camera)

By default, the WRLD SDK maintains an internal representation of a rendering camera. The CameraApi uses this to control a UnityEngine.Camera instance supplied via SetControlledCamera.

Argument Type Description
camera Camera The desired UnityEngine.Camera instance to use as a custom render camera.

void ClearCustomRenderCamera ()

If SetCustomRenderCamera has previously been called, this resets the CameraApi render camera behavior back to its default, where the WRLD SDK controls a UnityEngine.Camera instance supplied via SetControlledCamera.

bool MoveTo (LatLong interestPoint, Nullable<​double​> distanceFromInterest, Nullable<​double​> headingDegrees, Nullable<​double​> tiltDegrees)

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 interestPoint, LatLongAltitude cameraPosition)

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 interestPoint, Nullable<​double​> distanceFromInterest, Nullable<​double​> headingDegrees, Nullable<​double​> tiltDegrees, Nullable<​double​> transitionDuration, bool jumpIfFarAway)

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 interestPoint, LatLongAltitude cameraPosition, Nullable<​double​> transitionDuration, bool jumpIfFarAway)

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​> function)

Sets a delegate to 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<​bool​> The delegate function to use. Should return a boolean value.

void UnregisterShouldConsumeInputDelegate (Func<​bool​> function)

Clears any delegate previously supplied to RegisterShouldConsumeInputDelegate, with the result that the camera will always respond to input events if one has been supplied to SetControlledCamera. This has been deprecated, and ClearShouldConsumeInputDelegate should be used instead.

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

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

Sets a delegate to 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

This property controls whether or not to update the currently controlled camera (if any) 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.

Delegates

void TransitionStartHandler (CameraApi cameraApi, Camera camera)

Argument Type Description
cameraApi CameraApi  
camera Camera  

void TransitionEndHandler (CameraApi cameraApi, Camera camera)

Argument Type Description
cameraApi CameraApi  
camera Camera  
v0.8.17