| 1 |
// Copyright (C) 2017 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.10 |
| 6 |
import Qt3D.Input 2.0 |
| 7 |
import Qt3D.Extras 2.0 |
| 8 |
import QtQuick 2.0 as QQ2; |
| 9 |
|
| 10 |
Entity { |
| 11 |
id: sceneRoot |
| 12 |
|
| 13 |
property real width : 1 |
| 14 |
property alias smooth : lineWidth.smooth |
| 15 |
|
| 16 |
Camera { |
| 17 |
id: camera |
| 18 |
projectionType: CameraLens.PerspectiveProjection |
| 19 |
fieldOfView: 45 |
| 20 |
aspectRatio: 16/9 |
| 21 |
nearPlane : 0.1 |
| 22 |
farPlane : 1000.0 |
| 23 |
position: Qt.vector3d( 0.0, 0.0, 2.0 ) |
| 24 |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) |
| 25 |
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) |
| 26 |
} |
| 27 |
|
| 28 |
FirstPersonCameraController { |
| 29 |
camera: camera |
| 30 |
linearSpeed: 1.0 |
| 31 |
} |
| 32 |
|
| 33 |
components: [ |
| 34 |
RenderSettings { |
| 35 |
activeFrameGraph : RenderStateSet { |
| 36 |
renderStates: [ |
| 37 |
PointSize { |
| 38 |
value: sceneRoot.width |
| 39 |
sizeMode: PointSize.Fixed |
| 40 |
}, |
| 41 |
LineWidth { |
| 42 |
id: lineWidth |
| 43 |
value: sceneRoot.width / 3.0 |
| 44 |
} |
| 45 |
|
| 46 |
] |
| 47 |
|
| 48 |
ForwardRenderer { |
| 49 |
camera: camera |
| 50 |
clearColor: "black" |
| 51 |
} |
| 52 |
} |
| 53 |
}, |
| 54 |
InputSettings { |
| 55 |
} |
| 56 |
] |
| 57 |
|
| 58 |
SphereGeometry { |
| 59 |
id: sphere |
| 60 |
rings: 4 |
| 61 |
slices: 4 |
| 62 |
radius: 1 |
| 63 |
} |
| 64 |
|
| 65 |
Entity { |
| 66 |
components: [ |
| 67 |
GeometryRenderer { |
| 68 |
// abuse PlaneGeometry to give us some lines |
| 69 |
geometry: sphere |
| 70 |
primitiveType: GeometryRenderer.LineStrip |
| 71 |
}, |
| 72 |
PhongMaterial { |
| 73 |
ambient: "white" |
| 74 |
} |
| 75 |
] |
| 76 |
} |
| 77 |
|
| 78 |
Entity { |
| 79 |
components: [ |
| 80 |
GeometryRenderer { |
| 81 |
// abuse PlaneGeometry to give us some points |
| 82 |
geometry: sphere |
| 83 |
primitiveType: GeometryRenderer.Points |
| 84 |
}, |
| 85 |
PhongMaterial { |
| 86 |
ambient: "red" |
| 87 |
} |
| 88 |
] |
| 89 |
} |
| 90 |
|
| 91 |
} |