2022-06-08 12:47:24 +00:00
|
|
|
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
|
2024-02-23 14:41:04 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2017-03-02 10:09:32 +00:00
|
|
|
|
|
|
|
import Qt3D.Core 2.0
|
|
|
|
import Qt3D.Render 2.0
|
|
|
|
import Qt3D.Input 2.0
|
|
|
|
import Qt3D.Animation 2.9
|
|
|
|
import Qt3D.Extras 2.0
|
|
|
|
|
|
|
|
DefaultSceneEntity {
|
|
|
|
id: scene
|
|
|
|
|
2017-11-21 11:23:55 +00:00
|
|
|
KeyboardDevice { id: kyb }
|
|
|
|
KeyboardHandler {
|
|
|
|
id: keyboardHandler
|
|
|
|
sourceDevice: kyb
|
|
|
|
focus: true
|
|
|
|
onLeftPressed:blendedAnimator.normalizedTime -= 0.02
|
|
|
|
onRightPressed: blendedAnimator.normalizedTime += 0.02
|
|
|
|
}
|
|
|
|
|
2017-03-02 10:09:32 +00:00
|
|
|
Entity {
|
|
|
|
id: cube
|
|
|
|
|
|
|
|
components: [
|
|
|
|
Transform {
|
|
|
|
id: cubeTransform
|
2017-03-24 11:16:36 +00:00
|
|
|
translation: Qt.vector3d(5, 0, 0)
|
2017-03-02 10:09:32 +00:00
|
|
|
onTranslationChanged: console.log("t = " + translation)
|
|
|
|
},
|
2020-07-30 11:03:46 +00:00
|
|
|
CuboidMesh {
|
2017-03-02 10:09:32 +00:00
|
|
|
},
|
|
|
|
PhongMaterial {
|
|
|
|
id: cubeMaterial
|
|
|
|
ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0)
|
|
|
|
diffuse: "red"
|
|
|
|
shininess: 50
|
|
|
|
},
|
|
|
|
ObjectPicker {
|
2017-09-10 12:52:46 +00:00
|
|
|
onClicked: {
|
|
|
|
if (blendedAnimator.running == false) {
|
|
|
|
blendedAnimator.running = true;
|
|
|
|
} else {
|
|
|
|
switch (pick.button) {
|
|
|
|
case PickEvent.RightButton:
|
|
|
|
animatorClock.playbackRate *= 2.0;
|
|
|
|
break;
|
|
|
|
case PickEvent.LeftButton:
|
|
|
|
animatorClock.playbackRate /= 2.0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-02 10:09:32 +00:00
|
|
|
},
|
|
|
|
BlendedClipAnimator {
|
|
|
|
id: blendedAnimator
|
2017-09-10 12:52:46 +00:00
|
|
|
loops: 3
|
|
|
|
clock: Clock {
|
|
|
|
id: animatorClock
|
|
|
|
playbackRate: 0.5
|
|
|
|
}
|
2017-03-02 10:09:32 +00:00
|
|
|
|
|
|
|
onRunningChanged: console.log("running = " + running)
|
|
|
|
|
2017-03-24 11:16:36 +00:00
|
|
|
blendTree: LerpClipBlend {
|
2017-09-10 12:52:46 +00:00
|
|
|
blendFactor: 0.8
|
2017-03-24 11:16:36 +00:00
|
|
|
startClip: ClipBlendValue {
|
2017-04-03 10:21:55 +00:00
|
|
|
clip: AnimationClipLoader { source: "sliding-cube.json" }
|
2017-03-02 10:09:32 +00:00
|
|
|
}
|
2017-03-24 11:16:36 +00:00
|
|
|
endClip: ClipBlendValue {
|
2017-04-03 10:21:55 +00:00
|
|
|
clip: AnimationClipLoader { source: "sliding-pulsing-cube.json" }
|
2017-03-02 10:09:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
channelMapper: ChannelMapper {
|
|
|
|
mappings: [
|
2017-03-24 11:16:36 +00:00
|
|
|
ChannelMapping { channelName: "Location"; target: cubeTransform; property: "translation" },
|
|
|
|
ChannelMapping { channelName: "Scale"; target: cubeTransform; property: "scale3D" }
|
2017-03-02 10:09:32 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
camera: Camera {
|
|
|
|
position: Qt.vector3d(10, 3, 15)
|
|
|
|
viewCenter: Qt.vector3d(2.5, 1, 0)
|
|
|
|
}
|
|
|
|
}
|