Debian Codegraph @

tests/manual/shadow-map-qml/Toyplane.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.1 as QQ2
5 import Qt3D.Core 2.0
6 import Qt3D.Render 2.0
7
8 Entity {
9 id: root
10 property Material material
11
12 Mesh {
13 id: toyplaneMesh
14 source: "qrc:///assets/obj/toyplane.obj"
15 }
16
17 Transform {
18 id: toyplaneTransform
19
20 property real rollAngle: 0
21 property real pitchAngle: 15
22 property real altitude: 5
23 property real angle: 0
24 property real scaleFactor: 10
25
26 QQ2.Behavior on rollAngle { QQ2.SpringAnimation { spring: 2; damping: 0.2} }
27
28 matrix: {
29 var m = Qt.matrix4x4();
30 m.translate(Qt.vector3d(Math.sin(angle * Math.PI / 180) * scaleFactor,
31 altitude,
32 Math.cos(angle * Math.PI / 180) * scaleFactor));
33 m.rotate(angle, Qt.vector3d(0, 1, 0));
34 m.rotate(pitchAngle, Qt.vector3d(0, 0, 1));
35 m.rotate(rollAngle, Qt.vector3d(1, 0, 0));
36 m.scale(1.0 / toyplaneTransform.scaleFactor);
37 return m;
38 }
39 }
40
41 QQ2.NumberAnimation {
42 target: toyplaneTransform
43
44 running: true
45 loops: QQ2.Animation.Infinite
46
47 property: "angle"
48 duration: 10000
49 from: 0
50 to: 360
51 }
52
53 // Altitude / Pitch animation
54 QQ2.SequentialAnimation {
55 running: true
56 loops: QQ2.Animation.Infinite
57 QQ2.ParallelAnimation {
58 QQ2.SequentialAnimation {
59 QQ2.NumberAnimation { target: toyplaneTransform; property: "pitchAngle"; from: 0; to: 30; duration: 2000; easing.type: QQ2.Easing.OutQuad }
60 QQ2.NumberAnimation { target: toyplaneTransform; property: "pitchAngle"; from: 30; to: 0; duration: 2000; easing.type: QQ2.Easing.OutSine }
61 }
62 QQ2.NumberAnimation { target: toyplaneTransform; property: "altitude"; to: 5; duration: 4000; easing.type: QQ2.Easing.InOutCubic }
63 }
64 QQ2.PauseAnimation { duration: 1500 }
65 QQ2.ParallelAnimation {
66 QQ2.SequentialAnimation {
67 QQ2.NumberAnimation { target: toyplaneTransform; property: "pitchAngle"; from: 0; to: -30; duration: 1000; easing.type: QQ2.Easing.OutQuad }
68 QQ2.NumberAnimation { target: toyplaneTransform; property: "pitchAngle"; from: -30; to: 0; duration: 5000; easing.type: QQ2.Easing.OutSine }
69 }
70 QQ2.NumberAnimation { target: toyplaneTransform; property: "altitude"; to: 0; duration: 6000; easing.type: QQ2.Easing.InOutCubic}
71 }
72 QQ2.PauseAnimation { duration: 1500 }
73 }
74
75 // Roll Animation
76 QQ2.SequentialAnimation {
77 running: true
78 loops: QQ2.Animation.Infinite
79 QQ2.NumberAnimation { target: toyplaneTransform; property: "rollAngle"; to: 360; duration: 1500; easing.type: QQ2.Easing.InOutQuad }
80 QQ2.PauseAnimation { duration: 1000 }
81 QQ2.NumberAnimation { target: toyplaneTransform; property: "rollAngle"; from: 0; to: 30; duration: 1000; easing.type: QQ2.Easing.OutQuart }
82 QQ2.PauseAnimation { duration: 1500 }
83 QQ2.NumberAnimation { target: toyplaneTransform; property: "rollAngle"; from: 30; to: -30; duration: 1000; easing.type: QQ2.Easing.OutQuart }
84 QQ2.PauseAnimation { duration: 1500 }
85 QQ2.NumberAnimation { target: toyplaneTransform; property: "rollAngle"; from: -30; to: 0; duration: 750; easing.type: QQ2.Easing.OutQuart }
86 QQ2.PauseAnimation { duration: 2000 }
87 }
88
89 components: [
90 toyplaneMesh,
91 toyplaneTransform,
92 material
93 ]
94 }