File: main.qml

package info (click to toggle)
qt6-quick3d 6.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 140,860 kB
  • sloc: cpp: 380,464; ansic: 36,078; xml: 252; sh: 241; makefile: 29
file content (111 lines) | stat: -rw-r--r-- 2,884 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import QtQuick3D
import QtQuick3D.Helpers
import QtQuick3DTest.RhiRendering

Window {
    width: 1280
    height: 720
    visible: true
    title: qsTr("QRhi-based rendering with combined extensions within a View3D")

    View3D {
        id: view3d
        anchors.fill: parent

        environment: SceneEnvironment {
            clearColor: "skyblue"
            backgroundMode: SceneEnvironment.Color
            antialiasingMode: cbMsaa.checked ? SceneEnvironment.MSAA : SceneEnvironment.NoAA
            antialiasingQuality: SceneEnvironment.High // 4x
        }

        extensions: [
            MyExtension {
                id: renderer
                x: 300
                SequentialAnimation on x {
                    running: cbAnim.checked
                    NumberAnimation { from: 300; to: -300; duration: 4000 }
                    NumberAnimation { from: -300; to: 300; duration: 4000 }
                    loops: -1
                }
                NumberAnimation on subSceneRotation {
                    running: cbSubAnim.checked
                    from: 0
                    to: 360
                    loops: -1
                    duration: 5000
                }
            }
        ]

        PerspectiveCamera {
            id: camera
            z: 300
        }

        DirectionalLight {
        }

        Model {
            source: "#Sphere"
            materials: PrincipledMaterial {
                baseColorMap: Texture {
                    textureProvider: renderer
                }
            }
        }
    }

    WasdController {
        controlledObject: camera
    }

    Item {
        width: debugViewToggleText.implicitWidth
        height: debugViewToggleText.implicitHeight
        anchors.right: parent.right
        Label {
            id: debugViewToggleText
            text: "Click here " + (dbg.visible ? "to hide DebugView" : "for DebugView")
            anchors.right: parent.right
            anchors.top: parent.top
        }
        MouseArea {
            anchors.fill: parent
            onClicked: dbg.visible = !dbg.visible
            DebugView {
                y: debugViewToggleText.height * 2
                anchors.right: parent.right
                source: view3d
                id: dbg
                visible: false
            }
        }
    }

    ColumnLayout {
        CheckBox {
            id: cbMsaa
            text: "MSAA (4x) on View3D"
            checked: false
        }
        CheckBox {
            id: cbAnim
            text: "Animate"
            checked: true
        }
        CheckBox {
            id: cbSubAnim
            text: "Animate sub-scene"
            checked: true
        }
    }
}