geo.viewport.camera
9 functions / 7 types
Index
| Function | Description |
|---|---|
| fly_to | Animate one viewport to a position on a map, acquiring geographic camera control. Zero duration places the camera on the next frame. An omitted duration uses three seconds. A flight to another map crosses on the globe and lands in the view the camera set out in. A flight asked for during a switch between the views starts at once, and the switch carries the camera to it. |
| get_clearance | Read how near one viewport camera comes to drawn geometry, in meters, as geo.viewport.camera.set_clearance describes it. |
| get_flight | Read how far the last flight geo.viewport.camera.fly_to sent a viewport on has come. |
| get_location | Read where one viewport camera stands over the map, and the ground under the middle of its view. |
| get_zoom_out_limit | Read how far one viewport camera zooms out from the globe, as geo.viewport.camera.set_zoom_out_limit describes it. |
| orbit_to | Fails unless longitude and latitude name a place. Turn viewport cameras about the ground in the middle of their view, which stays in the middle all the way, to look at it from a new heading, pitch or range. |
| set_clearance | Set how near viewport cameras come to drawn geometry, in meters. |
| set_zoom_out_limit | Set how far viewport cameras zoom out from the globe, as the share of the view’s height the body’s disc spans where a zoom out stops. |
| zoom_by | Zoom viewport cameras toward the middle of their view by a number of scroll wheel notches. |
| Type | Description |
|---|---|
| CameraDestination | CameraDestination |
| CameraPose | Camera placement in geographic coordinates. |
| CameraTarget | Position the camera and its target explicitly. Up follows the displayed map normal at the eye. Coincident positions fail. A vertical view uses the local east direction to fix roll. |
| CameraView | Where a camera stands over the map. |
| FlightStage | How far a flight from one map’s body to another has come. |
| FlightState | The last flight a camera was sent on with geo.viewport.camera.fly_to. |
| LookAt | Frame a geographic target from a range in meters. A camera in the flat view lands straight over the target at the range with north up, whatever heading and pitch are asked for. |
fly_to
def fly_to(
*,
map: types.scene.Node,
destination: types.geo.viewport.camera.CameraDestination,
duration_seconds: float | None = None,
viewport: str | None = None,
_transaction_id: str | None = None
) -> NoneAnimate one viewport to a position on a map, acquiring geographic camera control. Zero duration places the camera on the next frame. An omitted duration uses three seconds. A flight to another map crosses on the globe and lands in the view the camera set out in. A flight asked for during a switch between the views starts at once, and the switch carries the camera to it.
Returns None.
map : Node
destination : CameraDestination
duration_seconds optional : float | None
Defaults to None.
viewport optional : str | None
Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
get_clearance
def get_clearance(
*,
viewport: str | None = None,
_transaction_id: str | None = None
) -> floatRead how near one viewport camera comes to drawn geometry, in meters, as
geo.viewport.camera.set_clearance describes it.
Fails unless exactly one viewport matches viewport.
Returns float.
viewport optional : str | None
Label of the viewport to read. Absent, the only viewport is read. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
get_flight
def get_flight(
*,
viewport: str | None = None,
_transaction_id: str | None = None
) -> types.geo.viewport.camera.FlightState | NoneRead how far the last flight geo.viewport.camera.fly_to sent a viewport on has come.
Returns nothing when the viewport’s camera was never sent on one. Fails unless exactly one
viewport matches viewport.
Returns FlightState | None.
viewport optional : str | None
Label of the viewport to read. Absent, the only viewport is read. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
get_location
def get_location(
*,
viewport: str | None = None,
_transaction_id: str | None = None
) -> types.geo.viewport.camera.CameraView | NoneRead where one viewport camera stands over the map, and the ground under the middle of its view.
The reading uses the conventions geo.viewport.camera.fly_to takes, so passing it back
puts the camera where it was. Returns nothing before the map has been built. Fails unless
exactly one viewport matches viewport.
Returns CameraView | None.
viewport optional : str | None
Label of the viewport to read. Absent, the only viewport is read. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
get_zoom_out_limit
def get_zoom_out_limit(
*,
viewport: str | None = None,
_transaction_id: str | None = None
) -> floatRead how far one viewport camera zooms out from the globe, as
geo.viewport.camera.set_zoom_out_limit describes it.
Fails unless exactly one viewport matches viewport.
Returns float.
viewport optional : str | None
Label of the viewport to read. Absent, the only viewport is read. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
orbit_to
def orbit_to(
*,
heading: float | None = None,
pitch: float | None = None,
range_scale: float | None = None,
duration_seconds: float | None = None,
viewport: str | None = None,
_transaction_id: str | None = None
) -> NoneFails unless longitude and latitude name a place.
Turn viewport cameras about the ground in the middle of their view, which stays in the middle
all the way, to look at it from a new heading, pitch or range.
The cameras read where they stand and what they look at themselves, so a caller does not pass back a reading that may be a frame old. The heading and pitch ease from where they are, the heading the short way round, and the range evenly in its logarithm, starting and ending at rest. Fails where the middle of a view shows no ground, and in the flat view, which only pans and zooms.
Returns None.
heading optional : float | None
Degrees clockwise from north to look toward. Absent, the heading now. Defaults to None.
pitch optional : float | None
Degrees below the horizon to look down at the ground, from 0 to 90. Absent, the pitch now. Defaults to None.
range_scale optional : float | None
How many times as far from the ground to stand. Absent, as far as now. Defaults to None.
duration_seconds optional : float | None
How long the turn takes. Zero turns at once on the next frame. Absent, three seconds. Defaults to None.
viewport optional : str | None
Label of the viewports to turn. Absent, exactly one viewport must exist. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
set_clearance
def set_clearance(
*,
meters: float,
viewport: str | None = None,
_transaction_id: str | None = None
) -> NoneSet how near viewport cameras come to drawn geometry, in meters.
The clearance is the one distance a camera keeps from what it would hit: the ground under it,
an object it zooms toward, and the ground under the flights
geo.viewport.camera.fly_to start. A camera
keeps it on every map it is put on, including maps opened later. A camera never given a
clearance keeps 5 m. The setting belongs to the viewport, so it is not saved in the project and
undo does not take it back.
Fails without changing anything unless meters is a finite number above zero and at most
100,000.
Returns None.
meters : float
Meters the camera keeps from drawn geometry.
viewport optional : str | None
Label of the viewports to change. Absent, exactly one viewport must exist. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
set_zoom_out_limit
def set_zoom_out_limit(
*,
span: float,
viewport: str | None = None,
_transaction_id: str | None = None
) -> NoneSet how far viewport cameras zoom out from the globe, as the share of the view’s height the body’s disc spans where a zoom out stops.
The limit is a share of the view rather than a distance, so it stops a camera over each body at a distance in proportion to that body’s radius, and at the same size on the screen through any field of view. A camera keeps it on every map it is put on, including maps opened later. A camera never given a limit stops where the body’s map, pole to pole, fills the height of the view, about 0.64 of it. A flat map stops a zoom out at its own edges whatever this is set to. The setting belongs to the viewport, so it is not saved in the project and undo does not take it back.
Fails without changing anything unless span is a number from 0.00001 to 1.
Returns None.
span : float
The share of the view’s height the body’s disc spans where a zoom out stops.
viewport optional : str | None
Label of the viewports to change. Absent, exactly one viewport must exist. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
zoom_by
def zoom_by(
*,
steps: float,
viewport: str | None = None,
_transaction_id: str | None = None
) -> NoneZoom viewport cameras toward the middle of their view by a number of scroll wheel notches.
The zoom is the one a scroll wheel over the middle of the view makes, with the same limits, speed and easing, in the 2D view as in 3D, and over the sky as over the ground. Steps sent while an earlier zoom is still under way add to it.
Returns None.
steps : float
How many notches to zoom: in for a positive count, out for a negative one. A fraction zooms that share of a notch.
viewport optional : str | None
Label of the viewports to zoom. Absent, exactly one viewport must exist. Defaults to None.
_transaction_id optional : str | None
Transaction to join. Omit to submit without an explicit transaction. Defaults to None.
CameraDestination
CameraDestination()CameraDestination
Construct one of the nested classes. Use isinstance to check its type.
CameraDestination.CameraPose
CameraDestination.CameraPose(value: types.geo.viewport.camera.CameraPose)CameraDestination.CameraPose
value : CameraPose
CameraDestination.LookAt
CameraDestination.LookAt(value: types.geo.viewport.camera.LookAt)CameraDestination.LookAt
value : LookAt
CameraDestination.CameraTarget
CameraDestination.CameraTarget(value: types.geo.viewport.camera.CameraTarget)CameraDestination.CameraTarget
value : CameraTarget
CameraPose
CameraPose(
*,
camera_position: types.geo.GeoPosition,
camera_heading: float,
camera_pitch: float
)Camera placement in geographic coordinates.
camera_position : GeoPosition
The camera’s geographic position, not its target. Omitted elevation uses displayed ground.
camera_heading : float
Degrees clockwise from north at the camera.
camera_pitch : float
Degrees below the camera’s local horizon: 0 horizontal, 90 down, and -90 up.
CameraTarget
CameraTarget(
*,
camera_position: types.geo.GeoPosition,
target: types.geo.GeoPosition
)Position the camera and its target explicitly. Up follows the displayed map normal at the eye. Coincident positions fail. A vertical view uses the local east direction to fix roll.
camera_position : GeoPosition
target : GeoPosition
CameraView
CameraView(
*,
camera_position: types.geo.GeoPosition,
camera_heading: float,
camera_pitch: float,
center: types.geo.GeoPosition | None = None,
map: types.scene.Node | None = None,
flat_view_span: float | None = None
)Where a camera stands over the map.
camera_position : GeoPosition
camera_heading : float
Degrees clockwise from north.
camera_pitch : float
Degrees below the horizon the camera looks down, so 90 looks straight down.
center optional : GeoPosition | None
The displayed ground under the viewport center, absent over sky or before presentation. Defaults to None.
map optional : Node | None
The node geo.map.spawn_map answered for the map the camera stands on, absent while it stands on none. Defaults to None.
flat_view_span optional : float | None
In the flat view, meters of ground the view’s height spans at the middle of the view, which follows the zoom where the height of camera_position does not. It depends on neither the window’s size nor a field of view, and LookAt.flat_view_span restores it. Absent in the 3D view and during a switch between the views. Defaults to None.
FlightStage
Enum
class FlightStage(IntEnum)How far a flight from one map’s body to another has come.
Values: DEPARTING = 0 Asked for, and not started yet. CLIMBING = 1 Climbing off the body the camera stood on. CRUISING = 2 Crossing open space toward the other body. LANDING = 3 The camera stands on the destination’s map and descends to its landing. LANDED = 4 The camera has landed on the destination’s map. CANCELED = 5 The flight ended before it reached the destination, such as when the map was deleted.
DEPARTING = 0
Asked for, and not started yet.
CLIMBING = 1
Climbing off the body the camera stood on.
CRUISING = 2
Crossing open space toward the other body.
LANDING = 3
The camera stands on the destination’s map and descends to its landing.
LANDED = 4
The camera has landed on the destination’s map.
CANCELED = 5
The flight ended before it reached the destination, such as when the map was deleted.
FlightState
FlightState(
*,
map: types.scene.Node,
stage: types.geo.viewport.camera.FlightStage
)The last flight a camera was sent on with geo.viewport.camera.fly_to.
map : Node
The map flown to.
stage : FlightStage
LookAt
LookAt(
*,
target: types.geo.GeoPosition,
camera_range: float,
camera_heading: float,
camera_pitch: float,
exact: bool | None = None,
flat_view_span: float | None = None
)Frame a geographic target from a range in meters. A camera in the flat view lands straight over the target at the range with north up, whatever heading and pitch are asked for.
target : GeoPosition
The point the camera faces. Omitted elevation uses displayed ground.
camera_range : float
Requested camera-to-target distance in ground meters. Flat projection scales scene distance. Unless exact is true, ground clearance can increase the distance or steepen the viewing angle.
camera_heading : float
Degrees clockwise from north at the target, measured in the direction the camera faces.
camera_pitch : float
Degrees below the target’s local horizon: 0 horizontal, 90 down, and -90 up.
exact optional : bool | None
True lands the camera at exactly this range, heading and pitch, as when restoring a view that was read back, however near the drawn ground that puts it, short of its clearance over the ground under it. A camera that would stand lower is raised straight up to the clearance without turning. Absent means false. Defaults to None.
flat_view_span optional : float | None
Meters of ground the view’s height spans where a camera lands in the flat view, as get_location reads flat_view_span. It takes the place of camera_range there, whatever the window’s size and the field of view. Absent, the flat view frames what a 3D camera at camera_range shows. The 3D view ignores it. Defaults to None.