Defines an abstract base for Cameras. 更多...
导入语句: | import QtQuick3D |
继承: | Node |
继承者: | CustomCamera , OrthographicCamera ,和 PerspectiveCamera |
A Camera defines how the content of the 3D scene is projected onto a 2D surface, such as a View3D . A scene needs at least one Camera in order to visualize its contents.
It is possible to position and rotate the Camera like any other spatial Node in the scene. The Node 's location and orientation determines where the Camera is in the scene, and what direction it is facing. The default orientation of the camera has its forward vector pointing along the negative Z axis and its up vector along the positive Y axis.
Together with the position and orientation, the frustum defines which parts of a scene are visible to the Camera and how they are projected onto the 2D surface. The different Camera subtypes provide multiple options to determine the shape of the Camera's frustum.
To illustrate the difference, these screenshots show the same scene as projected by a PerspectiveCamera 和 OrthographicCamera . Notice how the red box is smaller than the green box in the image rendered using the perspective projection.
Perspective camera | Orthographic camera |
---|---|
![]() |
![]() |
另请参阅 Qt Quick 3D - View3D 范例 .
frustumCullingEnabled : bool |
When this property is
true
, objects outside the camera frustum will be culled, meaning they will not be passed to the renderer. By default this property is set to
false
. For scenes where all or most objects are inside the camera frustum, frustum culling is an unnecessary performance overhead. But for complex scenes where large parts are located outside the camera's view, enabling frustum culling may improve performance.
[since 5.15]
vector3d
lookAt
(
QtQuick3D::Node
node
)
|
Sets the rotation value of the Camera so that it is pointing at node .
该方法在 Qt 5.15 引入。
[since 5.15]
vector3d
lookAt
(
vector3d
scenePos
)
|
Sets the rotation value of the Camera so that it is pointing at scenePos .
该方法在 Qt 5.15 引入。
vector3d mapFromViewport ( vector3d viewportPos ) |
变换 viewportPos from viewport space (2D) into global scene space (3D).
The x- and y-values of viewportPos must be normalized, with the top-left of the viewport at [0, 0] and the bottom-right at [1, 1]. The z-value is interpreted as the distance from the near clip plane of the frustum (clipNear).
若 viewportPos cannot successfully be mapped to a position in the scene, a position of [0, 0, 0] is returned.
另请参阅 mapToViewport and View3D.mapTo3DScene() .
vector3d mapToViewport ( vector3d scenePos ) |
变换 scenePos from global scene space (3D) into viewport space (2D).
The returned position is normalized, with the top-left of the viewport at [0, 0] and the bottom-right at [1, 1]. The returned z-value will contain the distance from the near clip plane of the frustum (clipNear) to scenePos in scene coordinates. If the distance is negative, the point is behind camera.
若 scenePos cannot successfully be mapped to a position in the viewport, a position of [0, 0, 0] is returned.
另请参阅 mapFromViewport() and View3D.mapFrom3DScene() .