| 1 |
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.9 |
| 5 |
import Qt3D.Core 2.10 |
| 6 |
import Qt3D.Render 2.10 |
| 7 |
import Qt3D.Input 2.0 |
| 8 |
import Qt3D.Extras 2.9 |
| 9 |
|
| 10 |
Entity { |
| 11 |
id: sceneRoot |
| 12 |
|
| 13 |
Camera { |
| 14 |
id: camera |
| 15 |
projectionType: CameraLens.PerspectiveProjection |
| 16 |
fieldOfView: 45 |
| 17 |
aspectRatio: 16/9 |
| 18 |
nearPlane : 0.1 |
| 19 |
farPlane : 1000.0 |
| 20 |
position: Qt.vector3d( 0.0, 0.0, 150.0 ) |
| 21 |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) |
| 22 |
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) |
| 23 |
} |
| 24 |
|
| 25 |
OrbitCameraController { camera: camera } |
| 26 |
|
| 27 |
components: [ |
| 28 |
RenderSettings { |
| 29 |
activeFrameGraph: RenderSurfaceSelector { |
| 30 |
Viewport { |
| 31 |
normalizedRect: Qt.rect(0, 0, 1, 1) |
| 32 |
|
| 33 |
ClearBuffers { |
| 34 |
buffers: ClearBuffers.ColorDepthBuffer |
| 35 |
clearColor: Qt.rgba(0.6, 0.6, 0.6, 1.0) |
| 36 |
NoDraw {} |
| 37 |
} |
| 38 |
|
| 39 |
FrustumCulling { |
| 40 |
CameraSelector { |
| 41 |
camera: camera |
| 42 |
ProximityFilter { |
| 43 |
entity: proximityTarget |
| 44 |
distanceThreshold: 30 |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
}, |
| 51 |
// Event Source will be set by the Qt3DQuickWindow |
| 52 |
InputSettings { } |
| 53 |
] |
| 54 |
|
| 55 |
SphereMesh { |
| 56 |
id: sphereMesh |
| 57 |
} |
| 58 |
|
| 59 |
PhongMaterial { |
| 60 |
id: phongMaterial |
| 61 |
diffuse: "orange" |
| 62 |
} |
| 63 |
|
| 64 |
NodeInstantiator { |
| 65 |
id: instantiator |
| 66 |
model: 64 |
| 67 |
Entity { |
| 68 |
readonly property real angle: Math.PI * 2.0 * model.index % 8 |
| 69 |
readonly property real radius: 20 |
| 70 |
readonly property real verticalStep: 10 |
| 71 |
readonly property color meshColor: Qt.hsla(model.index / instantiator.count, 0.5, 0.5, 1.0); |
| 72 |
|
| 73 |
readonly property Transform transform: Transform { |
| 74 |
translation: Qt.vector3d(radius * Math.cos(angle), |
| 75 |
(-(instantiator.count / (8 * 2)) + model.index / 8) * verticalStep, |
| 76 |
radius * Math.sin(angle)) |
| 77 |
} |
| 78 |
readonly property Material material: Material { |
| 79 |
effect: phongMaterial.effect |
| 80 |
parameters: Parameter { name: "kd"; value: meshColor } |
| 81 |
} |
| 82 |
readonly property GeometryRenderer mesh: sphereMesh |
| 83 |
components: [ transform, mesh, material ] |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
Entity { |
| 88 |
id: proximityTarget |
| 89 |
readonly property Transform transform: Transform |
| 90 |
{ |
| 91 |
property real y: 0; |
| 92 |
SequentialAnimation on y { |
| 93 |
NumberAnimation { from: -50; to: 50; duration: 2000; easing.type: Easing.InOutQuart } |
| 94 |
NumberAnimation { from: 50; to: -50; duration: 2000; easing.type: Easing.InOutQuart } |
| 95 |
loops: Animation.Infinite |
| 96 |
} |
| 97 |
translation: Qt.vector3d(0.0, y, 0.0) |
| 98 |
} |
| 99 |
components: [ sphereMesh, phongMaterial, transform ] |
| 100 |
} |
| 101 |
} |