diff --git a/src/tools/qml2puppet/mockfiles/qt6/EditView3D.qml b/src/tools/qml2puppet/mockfiles/qt6/EditView3D.qml index 964f47941bf..05bc0f5e2c7 100644 --- a/src/tools/qml2puppet/mockfiles/qt6/EditView3D.qml +++ b/src/tools/qml2puppet/mockfiles/qt6/EditView3D.qml @@ -747,7 +747,8 @@ Item { clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1 position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0) rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.quaternion(1, 0, 0, 0) - scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0) + horizontalMagnification: viewRoot.editView ? viewRoot.editView.orthoCamera.horizontalMagnification : 1 + verticalMagnification: viewRoot.editView ? viewRoot.editView.orthoCamera.verticalMagnification : 1 } MouseArea3D { diff --git a/src/tools/qml2puppet/qml2puppet/editor3d/generalhelper.cpp b/src/tools/qml2puppet/qml2puppet/editor3d/generalhelper.cpp index bfa2fcb1ae8..b057b6e1f96 100644 --- a/src/tools/qml2puppet/qml2puppet/editor3d/generalhelper.cpp +++ b/src/tools/qml2puppet/qml2puppet/editor3d/generalhelper.cpp @@ -154,16 +154,16 @@ float GeneralHelper::zoomCamera([[maybe_unused]] QQuick3DViewport *viewPort, float newZoomFactor = relative ? qBound(.01f, zoomFactor * multiplier, 100.f) : zoomFactor; - if (qobject_cast(camera)) { - // Ortho camera we can simply scale - float orthoFactor = newZoomFactor; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (viewPort) { - if (const QQuickWindow *w = viewPort->window()) - orthoFactor *= w->devicePixelRatio(); + if (auto orthoCamera = qobject_cast(camera)) { + // Ortho camera we can simply magnify + if (newZoomFactor != 0.f) { + orthoCamera->setHorizontalMagnification(1.f / newZoomFactor); + orthoCamera->setVerticalMagnification(1.f / newZoomFactor); + // Force update on transform, so gizmos get correctly scaled and positioned + float x = orthoCamera->x(); + orthoCamera->setX(x + 1.f); + orthoCamera->setX(x); } -#endif - camera->setScale(QVector3D(orthoFactor, orthoFactor, orthoFactor)); } else if (qobject_cast(camera)) { // Perspective camera is zoomed by moving camera forward or backward while keeping the // look-at point the same