Debian Codegraph @

tests/manual/animation-keyframe-programmatic/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 Entity {
14 id: cube
15
16 components: [
17 Transform {
18 id: cubeTransform
19
20 onTranslationChanged: console.log("t = " + translation)
21 },
22 CuboidMesh {
23 },
24 PhongMaterial {
25 id: cubeMaterial
26 ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0)
27 diffuse: "blue"
28 shininess: 50
29 },
30 ObjectPicker {
31 onClicked: animator.running = true
32 },
33 ClipAnimator {
34 id: animator
35 loops: 3
36 onRunningChanged: console.log("running = " + running)
37
38 clip: AnimationClip {
39 clipData: _animationFactory.clipData
40 onDurationChanged: console.log("duration = " + duration)
41 }
42
43 // By default introspect parent Entity and try
44 // to map fcurve groups to properties of QTransform
45 // mapping: AutomaticAnimationMapping {}
46
47 // To do more, we can be explicit
48 channelMapper: ChannelMapper {
49 mappings: [
50 ChannelMapping { channelName: "Location"; target: cubeTransform; property: "translation" },
51 ChannelMapping { channelName: "Rotation"; target: cubeTransform; property: "rotation" },
52 ChannelMapping { channelName: "Diffuse Color"; target: cubeMaterial; property: "diffuse" }
53 ]
54 }
55 }
56 ]
57 }
58
59 camera: Camera {
60 position: Qt.vector3d(10, 3, 15)
61 viewCenter: Qt.vector3d(2.5, 1, 0)
62 }
63
64 OrbitCameraController {
65 camera: scene.camera
66 linearSpeed: 8
67 lookSpeed: 180
68 }
69 }