Debian Codegraph @

tests/manual/loader-qml/main.qml

raw
1 // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import QtQuick 2.2 as QQ2
5 import Qt3D.Core 2.0
6 import Qt3D.Render 2.0
7 import Qt3D.Input 2.0
8 import Qt3D.Extras 2.0
9
10 Entity {
11 id: sceneRoot
12
13 Camera {
14 id: camera
15 projectionType: CameraLens.PerspectiveProjection
16 fieldOfView: 45
17 aspectRatio: 16/9
18 nearPlane : 0.1
19 farPlane : 1000.0
20 position: Qt.vector3d( 0.0, 0.0, 40.0 )
21 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
22 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
23 }
24
25 OrbitCameraController { camera: camera }
26
27 components: [
28 RenderSettings {
29 activeFrameGraph: ForwardRenderer {
30 camera: camera
31 }
32 },
33 // Event Source will be set by the Qt3DQuickWindow
34 InputSettings { }
35 ]
36
37
38 PhongMaterial {
39 id: material
40 diffuse: "yellow"
41 }
42
43 TorusMesh {
44 id: torusMesh
45 radius: 5
46 minorRadius: 1
47 rings: 100
48 slices: 20
49 }
50
51 Transform {
52 id: torusTransform
53 scale3D: Qt.vector3d(1.5, 1, 0.5)
54 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
55 }
56
57 Entity {
58 id: torusEntity
59 components: [ torusMesh, material, torusTransform ]
60 }
61
62 QQ2.Timer {
63 interval: 1000
64 running: true
65 repeat: true
66 property bool hasSphere: true
67
68 onTriggered: {
69 loader.source = hasSphere ? "qrc:/SphereEntity.qml" : "qrc:/CuboidEntity.qml"
70 hasSphere = !hasSphere
71 }
72 }
73
74 EntityLoader {
75 id: loader
76 components: [ revolutionTransform ]
77 }
78
79 Transform {
80 id: revolutionTransform
81 property real userAngle: 0.0
82 matrix: {
83 var m = Qt.matrix4x4();
84 m.rotate(userAngle, Qt.vector3d(0, 1, 0));
85 m.translate(Qt.vector3d(20, 0, 0));
86 return m;
87 }
88 }
89
90 QQ2.NumberAnimation {
91 target: revolutionTransform
92 property: "userAngle"
93 duration: 10000
94 from: 0
95 to: 360
96
97 loops: QQ2.Animation.Infinite
98 running: true
99 }
100 }