Skip to main content

flywave-mapview.mapviewutils

Home > @flywave/flywave-mapview > MapViewUtils

MapViewUtils namespace

MapView utilities: View transformations, camera setup, view bounds computation...

Signature:

export declare namespace MapViewUtils 

Functions

Function

Description

calculateDepthFromClipDistance(clipDistance, camera)

calculateDistanceFromZoomLevel(options, zoomLevel)

Calculates and returns the distance to the target point.

calculateDistanceToGroundFromZoomLevel(mapView, zoomLevel)

Calculates and returns the distance from the ground, which is needed to put the camera to this height, to see the size of the area that would be covered by one tile for the given zoom level.

calculateFocalLengthByVerticalFov(vFov, height)

calculateFovByFocalLength(focalLength, height)

calculateHorizontalFovByVerticalFov(vFov, aspect)

calculateVerticalFovByHorizontalFov(hFov, aspect)

calculateZoomLevelFromDistance(options, distance)

Calculates the zoom level, which corresponds to the current distance from camera to lookAt point. Therefore the zoom level is a float and not an int. The height of the camera can be in between zoom levels. By setting the zoom level, you change the height position of the camera in away that the field of view of the camera should be able to cover one tile for the given zoom level.

As an example for this, when you have a tile of zoom level 14 in front of the camera and you set the zoom level of the camera to 14, then you are able to see the whole tile in front of you.

cameraToWorldDistance(distance, camera)

closeToFrustum(point, camera, eps)

constrainTargetAndDistanceToViewBounds(target, distance, mapView)

Constrains given camera target and distance to .

extractAttitude(mapView, object)

Extracts yaw, pitch, and roll rotation in radians. - Yaw : Rotation around the vertical axis, counter-clockwise (as opposed to azimuth), starting north. - Pitch :Rotation around the horizontal axis. - Roll : Rotation around the view axis.

extractCameraTilt(camera, projection)

Extracts current camera tilt angle in radians.

extractSphericalCoordinatesFromLocation(mapView, object, location)

Gets the spherical coordinates in radian of the object to the coordinates of point.

Note: this method can be used to get the direction that an object points to, when location is the target of that object, by adding PI to it. Otherwise it only returns the spherical coordinates of object in the tangent space of location.

extractTiltAngleFromLocation(projection, object, location, tiltAxis)

Gets the tilt angle (in radians) of the object relative to the coordinates of location.

Note: this method can be used to get the direction that an object points to, when location is the target of that object, by adding PI to it. Otherwise it only returns the tilt angle (in radians) of object in the tangent space of location.

getCameraCoordinatesFromTargetCoordinates(targetCoordinates, distance, yawDeg, pitchDeg, mapView)

getCameraFrustumPlanes(camera)

Get perspective camera frustum planes distances.

getCameraPositionFromTargetCoordinates(targetCoordinates, distance, yawDeg, pitchDeg, projection, result)

getCameraRotationAtTarget(projection, target, yawDeg, pitchDeg, result)

Computes the rotation of the camera according to yaw and pitch in degrees. The computations hinge on the current projection and target, because yaw and pitch are defined in tangent space of the target point.

**Note:** yaw == 0 && pitch == 0 will north up the map and you will look downwards onto the map.

getGeoTargetFromCamera(camera, projection, elevation)

Calculate target (focus) point geo-coordinates for given camera.

getWorldTargetFromCamera(camera, projection, elevation)

Calculate target (focus) point world coordinates for given camera position and orientation.

mapViewIsLoading(mapView)

Check if tiles or other content is currently being loaded.

This method can be removed once FLYWAVE-7932 is implemented.

orbitAroundScreenPoint(mapView, offsetX, offsetY, deltaAzimuth, deltaTilt, maxTiltAngle)

Orbits the camera around a given point on the screen.

orbitAroundScreenPoint(mapView, orbitParams)

Orbits the camera around a given point on the screen.

panCameraAboveFlatMap(mapView, offsetX, offsetY)

Pans the camera according to the projection.

panCameraAroundGlobe(mapView, fromWorld, toWorld)

The function doing a pan in the spherical space when MapView's active [[ProjectionType]] is spherical. In other words, the function that rotates the camera around the globe.

rayCastGeoCoordinates(mapView, pointOnScreenXinNDC, pointOnScreenYinNDC)

Casts a ray in NDC space from the current view of the camera and returns the intersection point of that ray against the map in geo coordinates. The return value can be null when the raycast is above the horizon.

rayCastWorldCoordinates(mapView, pointOnScreenXinNDC, pointOnScreenYinNDC, elevation)

Casts a ray in NDC space from the current map view and returns the intersection point of that ray wih the map in world space.

rotate(mapView, deltaYawDeg, deltaPitchDeg, maxTiltAngleRad)

Rotates the camera by the given delta yaw and delta pitch. The pitch will be clamped to the maximum possible tilt to the new target, and under the horizon in sphere projection.

setRotation(mapView, yawDeg, pitchDeg)

Sets the rotation of the camera according to yaw and pitch in degrees. The computations hinge on the current projection and geoCenter, because yaw and pitch are defined in tangent space. In particular, MapView#geoCenter needs to be set before calling setRotation.

**Note:** yaw == 0 && pitch == 0 will north up the map and you will look downwards onto the map.

zoomOnTargetPosition(mapView, targetNDCx, targetNDCy, zoomLevel, maxTiltAngle)

Zooms and moves the map in such a way that the given target position remains at the same position after the zoom.

Interfaces

Interface

Description

Attitude

The anti clockwise rotation of an object along the axes of its tangent space, with itself as origin.

MemoryUsage

OrbitParams

Parameters for .

Variables

Variable

Description

calculateScreenSizeByFocalLength

calculateWorldSizeByFocalLength

estimateObject3dSize

getBrowserLanguages

MAX_TILT_DEG

MAX_TILT_RAD