Class: Qgs3DMapScene

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

Class Hierarchy

Inheritance diagram of qgis._3d.Qgs3DMapScene

Base classes

QObject

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[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal fpsCounterEnabledChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal gpuMemoryLimitReached[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

totalPendingJobsCount(self) int[source]

Returns number of pending jobs for all chunked entities

Added in version 3.12.

Return type:

int

signal totalPendingJobsCountChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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