| 1 |
// Copyright (C) 2020 The Qt Company. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.2 as QQ2 |
| 5 |
import Qt3D.Core 2.0 |
| 6 |
import Qt3D.Render 2.0 |
| 7 |
import Qt3D.Input 2.0 |
| 8 |
import Qt3D.Extras 2.0 |
| 9 |
|
| 10 |
import QtQuick.Scene3D 2.0 |
| 11 |
|
| 12 |
QQ2.Item { |
| 13 |
id: mioitem |
| 14 |
width: 300 |
| 15 |
height: 300 |
| 16 |
Scene3D { |
| 17 |
id: scene3d |
| 18 |
anchors.fill: parent |
| 19 |
Entity { |
| 20 |
id: sceneRoot |
| 21 |
|
| 22 |
Camera { |
| 23 |
id: camera |
| 24 |
projectionType: CameraLens.PerspectiveProjection |
| 25 |
fieldOfView: 45 |
| 26 |
aspectRatio: 16/9 |
| 27 |
nearPlane : 0.1 |
| 28 |
farPlane : 1000.0 |
| 29 |
position: Qt.vector3d( 0.0, 0.0, -40.0 ) |
| 30 |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) |
| 31 |
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) |
| 32 |
} |
| 33 |
|
| 34 |
OrbitCameraController { |
| 35 |
camera: camera |
| 36 |
} |
| 37 |
|
| 38 |
components: [ |
| 39 |
RenderSettings { |
| 40 |
activeFrameGraph: ForwardRenderer { |
| 41 |
clearColor: Qt.rgba(0, 0.5, 1, 1) |
| 42 |
camera: camera |
| 43 |
} |
| 44 |
}, |
| 45 |
// Event Source will be set by the Qt3DQuickWindow |
| 46 |
InputSettings { } |
| 47 |
] |
| 48 |
|
| 49 |
PhongMaterial { |
| 50 |
id: material |
| 51 |
} |
| 52 |
|
| 53 |
TorusMesh { |
| 54 |
id: torusMesh |
| 55 |
radius: 5 |
| 56 |
minorRadius: 1 |
| 57 |
rings: 100 |
| 58 |
slices: 20 |
| 59 |
} |
| 60 |
|
| 61 |
Transform { |
| 62 |
id: torusTransform |
| 63 |
scale3D: Qt.vector3d(1.5, 1, 0.5) |
| 64 |
rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) |
| 65 |
} |
| 66 |
|
| 67 |
Entity { |
| 68 |
id: torusEntity |
| 69 |
components: [ torusMesh, material, torusTransform ] |
| 70 |
} |
| 71 |
|
| 72 |
SphereMesh { |
| 73 |
id: sphereMesh |
| 74 |
radius: 3 |
| 75 |
} |
| 76 |
|
| 77 |
Transform { |
| 78 |
id: sphereTransform |
| 79 |
property real userAngle: 0.0 |
| 80 |
matrix: { |
| 81 |
var m = Qt.matrix4x4(); |
| 82 |
m.rotate(userAngle, Qt.vector3d(0, 1, 0)); |
| 83 |
m.translate(Qt.vector3d(20, 0, 0)); |
| 84 |
return m; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
QQ2.NumberAnimation { |
| 89 |
target: sphereTransform |
| 90 |
property: "userAngle" |
| 91 |
duration: 10000 |
| 92 |
from: 0 |
| 93 |
to: 360 |
| 94 |
|
| 95 |
loops: QQ2.Animation.Infinite |
| 96 |
running: true |
| 97 |
} |
| 98 |
|
| 99 |
Entity { |
| 100 |
id: sphereEntity |
| 101 |
components: [ sphereMesh, material, sphereTransform ] |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
} |