Debian Codegraph @

tests/manual/scene3d/AnimatedEntity.qml

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