CustomCamera QML Type
定义一个带有自定义投影矩阵的相机。更多内容...
| Import Statement: | import QtQuick3D |
| Inherits: |
属性
- projection : matrix4x4
详细说明
Camera 定义了 3D 场景的内容如何投影到 2D 表面上,例如View3D 。一个场景至少需要一个Camera 才能将其内容可视化。
Camera 可以像场景中的其他空间Node 一样进行定位和旋转。Node 的位置和方向决定了Camera 在场景中的位置及其朝向。Camera 的默认方向是:其前进向量沿负Z轴方向,向上向量沿正Y轴方向。
CustomCamera 类型提供了一个Camera ,其中投影矩阵可以自由定制。
以下示例在场景中坐标 [0, 200, 300] 的位置创建了一个 CustomCamera,其俯仰角为 30 度,并基于自定义的近平面和远平面距离以及自定义视场角,使用自定义投影矩阵。
CustomCamera {
position: Qt.vector3d(0, 200, 300)
eulerRotation.x: -30
property real near: 10.0
property real far: 10000.0
property real fov: 60.0 * Math.PI / 180.0
projection: Qt.matrix4x4(Math.cos(fov / 2) / Math.sin(fov / 2) * (window.height / window.width), 0, 0, 0,
0, Math.cos(fov / 2) / Math.sin(fov / 2), 0, 0,
0, 0, -(near + far) / (far - near), -(2.0 * near * far) / (far - near),
0, 0, -1, 0);
}注意: 使用 CustomCamera时, 某些抗锯齿模式(时间抗锯齿和渐进式抗锯齿)无法正确应用。
另请参阅 PerspectiveCamera 、OrthographicCamera 和FrustumCamera 。
属性文档
projection : matrix4x4
该属性定义了CustomCamera 的投影矩阵。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.