Class: Qgs3DMapScene

Entity that encapsulates our 3D scene - contains all other entities

Class Hierarchy

Inheritance diagram of qgis._3d.Qgs3DMapScene

Base classes

QObject

Methods

cameraController

Returns camera controller

clipPlaneEquations

Returns list of clipping planes if clipping is enabled, otherwise an empty list.

disableClipping

Disables OpenGL clipping.

elevationRange

Returns the scene's elevation range

enableClipping

Enables OpenGL clipping based on the planes equations defined in clipPlaneEquations.

exportScene

Exports the scene according to the scene export settings Returns False if the operation failed

hasSceneOriginShiftEnabled

Returns whether the 3D scene is allowed to automatically move the scene's origin.

hasSceneUpdatesEnabled

Returns whether updates of the 3D scene's entities are allowed.

mapSettings

Returns the 3D map settings.

sceneExtent

Returns the scene extent in the map's CRS

sceneState

Returns the current state of the scene

setSceneOriginShiftEnabled

Returns whether the 3D scene is allowed to automatically move the scene's origin.

setSceneUpdatesEnabled

Sets whether updates of the 3D scene's entities are allowed.

setViewFrom2DExtent

Resets camera view to show the extent extent (top view)

totalPendingJobsCount

Returns number of pending jobs for all chunked entities

updateTemporal

Updates the temporale entities

viewFrustum2DExtent

Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid

viewZoomFull

Resets camera view to show the whole scene (top view)

worldSpaceError

Given screen error (in pixels) and distance from camera (in 3D world coordinates), this function estimates the error in world space.

Static Methods

openScenes

Returns a map of 3D map scenes (by name) open in the QGIS application.

Signals

fpsCountChanged

Emitted when the FPS count changes

fpsCounterEnabledChanged

Emitted when the FPS counter is activated or deactivated

gpuMemoryLimitReached

Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU memory use by unloading data that's not currently needed.

sceneStateChanged

Emitted when the scene's state has changed

terrainEntityChanged

Emitted when the current terrain entity is replaced by a new one

totalPendingJobsCountChanged

Emitted when the total number of pending jobs changes

viewed2DExtentFrom3DChanged

Emitted when the viewed 2D extent seen by the 3D camera has changed

Attributes

Ready

Updating

class qgis._3d.Qgs3DMapScene[source]

Bases: QObject

Ready = 0
class SceneState

Bases: int

Updating = 1
cameraController(self) QgsCameraController | None[source]

Returns camera controller

Return type:

Optional[QgsCameraController]

clipPlaneEquations(self) List[QVector4D]

Returns list of clipping planes if clipping is enabled, otherwise an empty list.

Added in version 3.44.

Return type:

List[QVector4D]

disableClipping(self)[source]

Disables OpenGL clipping.

See also

enableClipping()

Added in version 3.40.

elevationRange(self, ignoreTerrain: bool = False) QgsDoubleRange[source]

Returns the scene’s elevation range

Note

Only some layer types are considered by this method (e.g. terrain, point cloud and mesh layers)

Parameters:

ignoreTerrain (bool = False) – indicates whether the calculation will ignore terrain

Added in version 3.30.

Return type:

QgsDoubleRange

enableClipping(self, clipPlaneEquations: Iterable[QVector4D])[source]

Enables OpenGL clipping based on the planes equations defined in clipPlaneEquations. The number of planes is equal to the size of clipPlaneEquations. A plane equation contains 4 elements. A simple way to define a clip plane equation is to define a normalized normal to the plane and its distance from the origin of the scene. In that case, the first 3 elements are the coordinates of the normal of the plane as (X, Y, Z). They need to be normalized. The last element is the distance of the plane from the origin of the scene. In mathematical terms, a 3d plane can be defined with the equation ax+by+cz+d=0 The normal is (a, b, c) with |a, b, c| = 1 The distance is -d.

The number of available clip planes depends on the OpenGL implementation. It should at least handle 6 additional clip planes. When the map scene is created, this number is retrieved. If clipPlaneEquations contains more than this maximum, only the first ones will be kept.

Added in version 3.40.

Parameters:

clipPlaneEquations (Iterable[QVector4D])

exportScene(self, exportSettings: Qgs3DMapExportSettings) bool[source]

Exports the scene according to the scene export settings Returns False if the operation failed

Parameters:

exportSettings (Qgs3DMapExportSettings)

Return type:

bool

signal fpsCountChanged(fpsCount: float)[source]

Emitted when the FPS count changes

Parameters:

fpsCount (float)

signal fpsCounterEnabledChanged(fpsCounterEnabled: bool)[source]

Emitted when the FPS counter is activated or deactivated

Parameters:

fpsCounterEnabled (bool)

signal gpuMemoryLimitReached[source]

Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU memory use by unloading data that’s not currently needed.

hasSceneOriginShiftEnabled(self) bool[source]

Returns whether the 3D scene is allowed to automatically move the scene’s origin. This is necessary in large scenes (e.g. more than 50km across) to avoid issues with numerical precision (due to the use of 32-bit floats in rendering), that may cause jitter in camera position or object location. When 3D scene moves the origin (because the camera is far from it), user should not see any change - transforms of 3D entities should be updated accordingly.

Normally, origin shifts are enabled. But for debugging purposes, it may be useful to temporarily disable origin shifts.

Added in version 3.44.

Return type:

bool

hasSceneUpdatesEnabled(self) bool[source]

Returns whether updates of the 3D scene’s entities are allowed. Normally, scene updates are enabled. But for debugging purposes, it may be useful to temporarily disable scene updates.

Added in version 3.40.

Return type:

bool

mapSettings(self) Qgs3DMapSettings | None[source]

Returns the 3D map settings.

Added in version 3.30.

Return type:

Optional[Qgs3DMapSettings]

static openScenes() Any

Returns a map of 3D map scenes (by name) open in the QGIS application.

Note

Only available from the QGIS desktop application.

Deprecated since version 3.36: Use QgisAppInterface.mapCanvases3D() instead.

Added in version 3.30.

Return type:

Any

sceneExtent(self) QgsRectangle[source]

Returns the scene extent in the map’s CRS

Added in version 3.20.

Return type:

QgsRectangle

sceneState(self) Qgs3DMapScene.SceneState[source]

Returns the current state of the scene

Return type:

Qgs3DMapScene.SceneState

signal sceneStateChanged[source]

Emitted when the scene’s state has changed

setSceneOriginShiftEnabled(self, enabled: bool)[source]

Returns whether the 3D scene is allowed to automatically move the scene’s origin. See hasSceneOriginShiftEnabled() for more details.

Normally, origin shifts are enabled. But for debugging purposes, it may be useful to temporarily disable origin shifts.

Added in version 3.44.

Parameters:

enabled (bool)

setSceneUpdatesEnabled(self, enabled: bool)[source]

Sets whether updates of the 3D scene’s entities are allowed. Normally, scene updates are enabled. But for debugging purposes, it may be useful to temporarily disable scene updates.

Added in version 3.40.

Parameters:

enabled (bool)

setViewFrom2DExtent(self, extent: QgsRectangle)[source]

Resets camera view to show the extent extent (top view)

Added in version 3.26.

Parameters:

extent (QgsRectangle)

signal terrainEntityChanged[source]

Emitted when the current terrain entity is replaced by a new one

totalPendingJobsCount(self) int[source]

Returns number of pending jobs for all chunked entities

Added in version 3.12.

Return type:

int

signal totalPendingJobsCountChanged[source]

Emitted when the total number of pending jobs changes

Added in version 3.12.

updateTemporal(self)[source]

Updates the temporale entities

viewFrustum2DExtent(self) List[QgsPointXY]

Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid

Added in version 3.26.

Return type:

List[QgsPointXY]

viewZoomFull(self)[source]

Resets camera view to show the whole scene (top view)

signal viewed2DExtentFrom3DChanged(extent: List[QgsPointXY])[source]

Emitted when the viewed 2D extent seen by the 3D camera has changed

Added in version 3.26.

Parameters:

extent (List[QgsPointXY])

worldSpaceError(self, epsilon: float, distance: float) float[source]

Given screen error (in pixels) and distance from camera (in 3D world coordinates), this function estimates the error in world space. Takes into account camera’s field of view and the screen (3D view) size.

Parameters:
  • epsilon (float)

  • distance (float)

Return type:

float