forked from qt-creator/qt-creator
QmlDesigner: Fix 3D import preview camera FOV
Adjust FOV orientation depending on width and height of the rendered viewport to ensure rendered scene stays within the viewport. Change-Id: I83ed2b547e3bdaeb106dd938b94c72c0b2b8c2e5 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#ifdef QUICK3D_MODULE
|
||||
#include <private/qquick3dnode_p.h>
|
||||
#include <private/qquick3dviewport_p.h>
|
||||
#include <private/qquick3dperspectivecamera_p.h>
|
||||
#endif
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -84,6 +85,12 @@ void Qt5Import3dNodeInstanceServer::view3DAction([[maybe_unused]] const View3DAc
|
||||
QQmlProperty hProp(obj, "height", context());
|
||||
wProp.write(size.width());
|
||||
hProp.write(size.height());
|
||||
if (auto camera = qobject_cast<QQuick3DPerspectiveCamera *>(m_view3D->camera())) {
|
||||
if (size.width() >= size.height())
|
||||
camera->setFieldOfViewOrientation(QQuick3DPerspectiveCamera::Vertical);
|
||||
else
|
||||
camera->setFieldOfViewOrientation(QQuick3DPerspectiveCamera::Horizontal);
|
||||
}
|
||||
resizeCanvasToRootItem();
|
||||
addCurrentNodeToRenderQueue();
|
||||
}
|
||||
|
Reference in New Issue
Block a user