Debian Codegraph @

tests/manual/animation-keyframe-blendtree/main.qml

raw
1 // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import Qt3D.Core 2.0
5 import Qt3D.Render 2.0
6 import Qt3D.Input 2.0
7 import Qt3D.Animation 2.9
8 import Qt3D.Extras 2.0
9
10 DefaultSceneEntity {
11 id: scene
12
13 KeyboardDevice { id: kyb }
14 KeyboardHandler {
15 id: keyboardHandler
16 sourceDevice: kyb
17 focus: true
18 onLeftPressed:blendedAnimator.normalizedTime -= 0.02
19 onRightPressed: blendedAnimator.normalizedTime += 0.02
20 }
21
22 Entity {
23 id: cube
24
25 components: [
26 Transform {
27 id: cubeTransform
28 translation: Qt.vector3d(5, 0, 0)
29 onTranslationChanged: console.log("t = " + translation)
30 },
31 CuboidMesh {
32 },
33 PhongMaterial {
34 id: cubeMaterial
35 ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0)
36 diffuse: "red"
37 shininess: 50
38 },
39 ObjectPicker {
40 onClicked: {
41 if (blendedAnimator.running == false) {
42 blendedAnimator.running = true;
43 } else {
44 switch (pick.button) {
45 case PickEvent.RightButton:
46 animatorClock.playbackRate *= 2.0;
47 break;
48 case PickEvent.LeftButton:
49 animatorClock.playbackRate /= 2.0;
50 break;
51 default:
52 break;
53 }
54 }
55 }
56 },
57 BlendedClipAnimator {
58 id: blendedAnimator
59 loops: 3
60 clock: Clock {
61 id: animatorClock
62 playbackRate: 0.5
63 }
64
65 onRunningChanged: console.log("running = " + running)
66
67 blendTree: LerpClipBlend {
68 blendFactor: 0.8
69 startClip: ClipBlendValue {
70 clip: AnimationClipLoader { source: "sliding-cube.json" }
71 }
72 endClip: ClipBlendValue {
73 clip: AnimationClipLoader { source: "sliding-pulsing-cube.json" }
74 }
75 }
76
77 channelMapper: ChannelMapper {
78 mappings: [
79 ChannelMapping { channelName: "Location"; target: cubeTransform; property: "translation" },
80 ChannelMapping { channelName: "Scale"; target: cubeTransform; property: "scale3D" }
81 ]
82 }
83 }
84 ]
85 }
86
87 camera: Camera {
88 position: Qt.vector3d(10, 3, 15)
89 viewCenter: Qt.vector3d(2.5, 1, 0)
90 }
91 }