Class: Qgs3DMapScene¶
Entity that encapsulates our 3D scene - contains all other entities
Class Hierarchy¶
Base classes¶
Methods
Returns camera controller |
|
Returns list of clipping planes if clipping is enabled, otherwise an empty list. |
|
Disables OpenGL clipping. |
|
Returns the scene's elevation range |
|
Enables OpenGL clipping based on the planes equations defined in clipPlaneEquations. |
|
Exports the scene according to the scene export settings Returns |
|
Returns whether the 3D scene is allowed to automatically move the scene's origin. |
|
Returns whether updates of the 3D scene's entities are allowed. |
|
Returns the 3D map settings. |
|
Returns the scene extent in the map's CRS |
|
Returns the current state of the scene |
|
Returns whether the 3D scene is allowed to automatically move the scene's origin. |
|
Sets whether updates of the 3D scene's entities are allowed. |
|
Resets camera view to show the extent extent (top view) |
|
Returns number of pending jobs for all chunked entities |
|
Updates the temporale entities |
|
Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid |
|
Resets camera view to show the whole scene (top view) |
|
Given screen error (in pixels) and distance from camera (in 3D world coordinates), this function estimates the error in world space. |
Static Methods
Returns a map of 3D map scenes (by name) open in the QGIS application. |
Signals
Emitted when the FPS count changes |
|
Emitted when the FPS counter is activated or deactivated |
|
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. |
|
Emitted when the scene's state has changed |
|
Emitted when the current terrain entity is replaced by a new one |
|
Emitted when the total number of pending jobs changes |
|
Emitted when the viewed 2D extent seen by the 3D camera has changed |
Attributes
- 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]
- 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:
- 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 ofclipPlaneEquations
. 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 equationax+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.See also
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:
- sceneState(self) Qgs3DMapScene.SceneState [source]¶
Returns the current state of the scene
- Return type:
- 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.
- 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]
- 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