Debian Codegraph @

tests/manual/mouseinput-qml/main.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.0
5 import Qt3D.Render 2.0
6 import Qt3D.Input 2.0
7 import Qt3D.Extras 2.0
8
9 Entity {
10 id: sceneRoot
11
12 Camera {
13 id: camera
14 projectionType: CameraLens.PerspectiveProjection
15 fieldOfView: 45
16 aspectRatio: 16/9
17 nearPlane : 0.1
18 farPlane : 1000.0
19 position: Qt.vector3d( 0.0, 0.0, 40.0 )
20 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
21 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
22 }
23
24 OrbitCameraController { camera: camera }
25
26 components: [
27 RenderSettings {
28 ForwardRenderer {
29 camera: camera
30 clearColor: "black"
31 }
32 renderPolicy: RenderSettings.Always
33 },
34 InputSettings {}
35 ]
36
37 SphereMesh{
38 id: sphereMesh
39 radius: 3
40 }
41
42 PhongMaterial {
43 id: material
44 diffuse: "green"
45 }
46
47 MouseDevice {
48 id: mouseDevice
49 }
50
51 Entity {
52 id: sphere1
53
54 property real scaleFactor: 1.0
55
56 property Transform transform: Transform {
57 scale: sphere1.scaleFactor
58 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
59 }
60
61 property MouseHandler mouseHandler : MouseHandler {
62 sourceDevice: mouseDevice
63
64 onClicked: {
65 //Signal not implemented yet
66 }
67
68 onReleased: {
69 switch (mouse.button) {
70 case Qt.LeftButton:
71 sphere1.scaleFactor += 0.5;
72 break;
73
74 case Qt.RightButton:
75 sphere1.scaleFactor -= 0.5;
76 break;
77 }
78 }
79 }
80
81 components: [sphereMesh, material, transform, mouseHandler]
82 }
83 }