| 1 |
// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.0 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 |
Entity { |
| 11 |
id : root |
| 12 |
readonly property Camera camera: camera |
| 13 |
readonly property Layer layer: sceneLayer |
| 14 |
|
| 15 |
readonly property vector3d light1Pos : sphere1.transform.translation |
| 16 |
readonly property vector3d light2Pos : sphere2.transform.translation |
| 17 |
readonly property vector3d light3Pos : light3Transform.translation |
| 18 |
readonly property vector3d light4Pos : Qt.vector3d(5, 2, 7) |
| 19 |
|
| 20 |
property PointLight light: PointLight { |
| 21 |
color : "white" |
| 22 |
intensity : 0.0 |
| 23 |
QQ2.ColorAnimation on color { from: "white"; to: "blue"; duration: 4000; loops: 2 } |
| 24 |
QQ2.SequentialAnimation on intensity { |
| 25 |
QQ2.NumberAnimation { |
| 26 |
from: 0; to: 3.0; duration: 500 |
| 27 |
} |
| 28 |
QQ2.NumberAnimation { |
| 29 |
from: 3.0; to: 0.0; duration: 500 |
| 30 |
} |
| 31 |
loops: QQ2.Animation.Infinite |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
// Global elements |
| 36 |
Camera { |
| 37 |
id: camera |
| 38 |
projectionType: CameraLens.PerspectiveProjection |
| 39 |
fieldOfView: 45 |
| 40 |
aspectRatio: 16/9 |
| 41 |
nearPlane : 1.0 |
| 42 |
farPlane : 1000.0 |
| 43 |
position: Qt.vector3d( 0.0, 0.0, -25.0 ) |
| 44 |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) |
| 45 |
viewCenter: Qt.vector3d( 0.0, 0.0, 10.0 ) |
| 46 |
} |
| 47 |
|
| 48 |
SphereMesh { |
| 49 |
id : sphereMesh |
| 50 |
rings: 50 |
| 51 |
slices: 100 |
| 52 |
} |
| 53 |
|
| 54 |
SceneEffect { id : sceneMaterialEffect } |
| 55 |
|
| 56 |
Layer { id: sceneLayer } |
| 57 |
|
| 58 |
// Scene |
| 59 |
Entity { |
| 60 |
id : sphere1 |
| 61 |
|
| 62 |
property Material material : Material { |
| 63 |
effect : sceneMaterialEffect |
| 64 |
parameters : Parameter { name : "meshColor"; value : "dodgerblue" } |
| 65 |
} |
| 66 |
|
| 67 |
property Transform transform: Transform { |
| 68 |
id: sphere1Transform |
| 69 |
property real x: -10.0 |
| 70 |
translation: Qt.vector3d(x, 0, 5) |
| 71 |
} |
| 72 |
|
| 73 |
QQ2.SequentialAnimation { |
| 74 |
loops: QQ2.Animation.Infinite |
| 75 |
running: true |
| 76 |
QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: 3; duration: 2000 } |
| 77 |
QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: -5; duration: 2000 } |
| 78 |
} |
| 79 |
|
| 80 |
components : [ |
| 81 |
sphereMesh, |
| 82 |
sphere1.material, |
| 83 |
sphere1.transform, |
| 84 |
sceneLayer |
| 85 |
] |
| 86 |
} |
| 87 |
|
| 88 |
Entity { |
| 89 |
id : sphere2 |
| 90 |
|
| 91 |
property Material material : Material { |
| 92 |
effect : sceneMaterialEffect |
| 93 |
parameters : Parameter { name : "meshColor"; value : "green" } |
| 94 |
} |
| 95 |
|
| 96 |
property Transform transform: Transform { |
| 97 |
translation: Qt.vector3d(5, 0, 5) |
| 98 |
} |
| 99 |
|
| 100 |
components : [ |
| 101 |
sphereMesh, |
| 102 |
sphere2.transform, |
| 103 |
sphere2.material, |
| 104 |
sceneLayer |
| 105 |
] |
| 106 |
} |
| 107 |
|
| 108 |
Entity { |
| 109 |
id: light3 |
| 110 |
|
| 111 |
property Material material : Material { |
| 112 |
effect : sceneMaterialEffect |
| 113 |
parameters : Parameter { name : "meshColor"; value : "red" } |
| 114 |
} |
| 115 |
|
| 116 |
property Transform transform: Transform { |
| 117 |
id: light3Transform |
| 118 |
property real y: 2.0 |
| 119 |
translation: Qt.vector3d(2, y, 7) |
| 120 |
} |
| 121 |
|
| 122 |
QQ2.SequentialAnimation { |
| 123 |
loops: QQ2.Animation.Infinite |
| 124 |
running: true |
| 125 |
QQ2.NumberAnimation { target: light3Transform; property: "y"; to: 6; duration: 1000; easing.type: QQ2.Easing.InOutQuad } |
| 126 |
QQ2.NumberAnimation { target: light3Transform; property: "y"; to: -6; duration: 1000; easing.type: QQ2.Easing.InOutQuint } |
| 127 |
} |
| 128 |
|
| 129 |
components: [ |
| 130 |
sphereMesh, |
| 131 |
light3.material, |
| 132 |
light3.transform, |
| 133 |
sceneLayer |
| 134 |
] |
| 135 |
} |
| 136 |
} |