| 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 |
|
| 7 |
Entity { |
| 8 |
id: root |
| 9 |
|
| 10 |
property vector3d pos: Qt.vector3d(0.0, 0.0, 0.0) |
| 11 |
property vector3d viewCenter: Qt.vector3d(0.0, 0.0, -10.0) |
| 12 |
property vector3d up: Qt.vector3d(0.0, 1.0, 0.0) |
| 13 |
|
| 14 |
components: [ transform, lens ] |
| 15 |
|
| 16 |
Transform { |
| 17 |
id: transform |
| 18 |
|
| 19 |
matrix: { |
| 20 |
var m = Qt.matrix4x4(); |
| 21 |
m.lookAt( root.pos, root.viewCenter, root.up ); |
| 22 |
return m; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
CameraLens { |
| 27 |
id: lens |
| 28 |
projectionType: CameraLens.PerspectiveProjection |
| 29 |
fieldOfView: 45 |
| 30 |
aspectRatio: _view.width / _view.height |
| 31 |
nearPlane: 0.1 |
| 32 |
farPlane: 1000.0 |
| 33 |
} |
| 34 |
} |