I try to show a Scene3d in a Qt Quick so that it just fits into this Item, considering the aspect ratio of the scene. The scene is loaded with Qt Quick's SceneLoader.
I experimented with aspect ratio, width, implicitHeight in Camera, Entities and so on.
But I do not succeed. The scene is principally depicted but with wrong scaling.
Does anybody know how could it be solved? Thank you.
My current solution approach is like this snippet:
Item {
id: item
Layout.fillWidth: true
Layout.fillHeight: true
Scene3D {
id: scene
width: height / myObject.aspectRatio
anchors.top: item.top
anchors.bottom: item.bottom
aspects: ["input", "logic", "render"]
cameraAspectRatioMode: Scene3D.UserAspectRatio
Entity {
id: mainEntity
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer
{
clearColor: Qt.rgba(0, 0.5, 1, 1)
camera: camera
}
},
]
Camera {
id: camera
projectionType: CameraLens.OrthographicProjection
aspectRatio: myObject.aspectRatio
position: Qt.vector3d(0.0, 0.0, 5.0)
viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
}
Entity {
id: myObject
property real aspectRatio: 1.0
components: [
SceneLoader {
id: sceneLoader
source: "file:///xxx/myObject.obj"
onStatusChanged: {
if (status === SceneLoader.Ready) {
myObject.aspectRatio = computeAspectRatio();
}
}
}
]
function computeAspectRatio() {
...
}
}
}
}
}