Skip to main content

Module camera

Module camera 

Source
Expand description

The camera: its options, momentum and limits, bound options, the transform that moves it, the transform state, and the view it shows and draws with.

Re-exports§

pub use transform::CameraCommandId;
pub use transform::CommandEnd;
pub use transform::FrameClock;
pub use view::NorthOrientation;
pub use view::View;
pub use view::scale_zoom;
pub use view::zoom_scale;

Modules§

constants
The camera’s limits: its pitch, field of view and zoom.
transform
The map’s camera: the commands, animations, gestures and momentum that move it within its limits.

Structs§

AnchoredMomentum
How a gesture’s zoom, bearing or pitch keeps changing after release.
AnimationOptions
Various options for describing a transition between viewpoints with animation. All fields are optional; the default values depend on how this struct is used.
BoundOptions
Holds options to limit what parts of a map are visible. All fields are optional.
Camera
A camera with every member set: the camera that a map has, where CameraOptions is a change to one.
CameraDelta
A change to the camera from where it is now, as a gesture makes it (the C API’s mln_camera_delta).
CameraLimits
The limits a map’s camera moves within.
CameraMomentum
Camera motion that continues a gesture after its last contact lifts.
CameraOptions
Various options for describing the viewpoint of a map. All fields are optional. A partial command replaces animations of its specified fields. Omitted fields keep their original animation timing. Flights couple center and zoom; anchored commands couple center with their specified fields. Replacing any member of a coupled group stops that group. Anchor and center points are mutually exclusive, with preference for the center point when both are set.
CameraUpdate
Moves the camera to absolute values, as the C API’s mln_camera_update does: the counterpart of CameraDelta for commands and gestures that know where the camera should go.
CameraVelocity
How fast each part of a camera change moves, in its own unit per second.
CenterAndBearing
FrameProjection
Where a frame drew the map, and the depth its 3D layers wrote there.
FreeCameraOptions
Various options for accessing physical properties of the underlying camera entity. A direct access to these properties allows more flexible and precise controlling of the camera while also being fully compatible and interchangeable with CameraOptions. All fields are optional.
InvalidMomentum
Why a momentum setting is out of range.
LogicalExtent
A size in logical pixels, and the physical pixels in each logical pixel.
MapProjection
Converts coordinates for one camera and size, without a map: on the ground a renderer drew of a terrain (with_ground), or else on the flat map. It holds only a transform state and the ground, so it can move to another thread.
MapView
One view of a map: its camera, size, and projection.
MomentumDecay
How one part of a release glides, in the part’s unit: logical pixels for pan, zoom levels for zoom, and degrees for bearing and pitch, with speeds per second.
MomentumEasing
A unit cubic Bézier, from (0, 0) to (1, 1), with these control points.
MomentumGlide
How one part glides after release: from velocity, per second, by decay. A pan’s decay applies to its speed.
MomentumSnap
Where a part settles once its glide ends: on the nearest of the targets every spacing from offset, when it is within tolerance of one. Bearing targets lie within one turn from offset, and the bearing takes the shorter way around to the nearest.
ProjectedTilePoint
A tile point in clip space, as the vertex shaders would place it.
ProjectionData
ProjectionMode
Holds values for Axonometric rendering. All fields are optional.
TileCoordinate
Has floating point x/y coordinates. Used for computing the tiles that need to be visible in the viewport. In mapbox-gl-js, this is named MercatorCoordinate.
TileProjector
Projects the points of one tile through the current projection, the way the vertex shaders do it.
TransformState
A map’s camera with the limits that constrain it: the View it shows now, and the bounds, zoom, pitch and field of view it may move within.
TransitionEnd
How a camera command ended, once every field of it has: completed, cancelled, replaced by later commands, or closed with the map. Other commands may still be animating. It replaces C++’s transitionFinishFn, which can’t tell those apart; the C API reports the same outcomes.
VerticalPerspectiveProjection
The globe: tile geometry projected onto a unit sphere, viewed with a vertical perspective camera. Port of MapLibre GL JS vertical_perspective_transform.ts.
View
One view of a map: its camera, size and projection, and the matrices it draws with. A view never changes: a map that moves its camera makes a new one.
Viewport
How a map orients and constrains its view.

Enums§

AxonometricMode
Whether axonometric rendering is enabled.
CameraError
Why a CameraDelta was rejected.
CameraUpdateMode
How CameraUpdate moves the camera.
ClipDepthRange
How a graphics API’s clip space holds depth.
ConstrainMode
We can choose to constrain the map both horizontally or vertically, only vertically e.g. while panning, or screen to the specified bounds.
GesturePhase
Where a camera change stands in a gesture, as the C API’s mln_gesture_phase defines it. Begin and Update mark a gesture in progress, and End and Cancel end it; a gesture whose end starts momentum stays in progress until the momentum ends.
MomentumDecayModel
How a glide unfolds from its release speed.
Projection
How a View places tiles on the screen. Both variants project locations onto the same Mercator plane, so the tile-to-world matrix is mercator_tile_matrix on either.
TransitionOutcome
How a camera command ended, as the C API’s mln_camera_transition_outcome reports it. A command that ended in more than one way reports Cancelled if any of it was cancelled, otherwise Closed if any of it was closed, and otherwise Replaced if any of it was replaced.
ViewportMode
Satisfies embedding platforms that requires the viewport coordinate systems to be set according to its standards.

Constants§

MAX_FIELD_OF_VIEW
The widest field of view a camera may take, in radians.
MIN_FIELD_OF_VIEW
The narrowest field of view a camera may take, in radians.

Traits§

Elevation
The ground of a terrain as a frame drew it, which the map’s camera stands on. A renderer makes it and hands it to the map; it doesn’t change once made, so the map reads it on its own thread.

Functions§

scale_zoom
The zoom of scale: its base-2 logarithm.
zoom_scale
The scale of zoom: 2 to its power.