-
import QtQuick.Controls 2.2 ApplicationWindow { visible: true width: 640 id:_window height: 480 title: qsTr("3D Viewer") MainPage{} }
MainPage.qml
import QtQuick 2.12 import QtQuick.Scene3D 2.0 import Qt3D.Core 2.12 import Qt3D.Render 2.12 import Qt3D.Input 2.12 import Qt3D.Extras 2.12 Scene3D { anchors.fill: parent aspects: ["input", "logic"] cameraAspectRatioMode: Scene3D.AutomaticAspectRatio Entity { id: sceneRoot Camera { id: camera projectionType: CameraLens.PerspectiveProjection fieldOfView: 45 aspectRatio: 16/9 nearPlane : 0.1 farPlane : 1000.0 position: Qt.vector3d( 0.0, 0.0, -40.0 ) upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } OrbitCameraController { camera: camera } components: [ RenderSettings { activeFrameGraph: ForwardRenderer { clearColor: Qt.rgba(0, 0.5, 1, 1) camera: camera } }, InputSettings { } ] Entity { id: topplane PhongMaterial { id: material } Mesh { id: toyplaneMesh source: "qrc:/asstes/test.obj" } components: [toyplaneMesh, material] } } }
项目目录
控制台输出:
使用SceneLoader 加载test.obj 是可以显示得
运行环境:
Ubuntu 20.04
Qt 5.12.8 -