| 1 |
// Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.2 as QQ2 |
| 5 |
import QtQuick.Scene3D 2.0 |
| 6 |
import Qt3D.Core 2.0 |
| 7 |
import Qt3D.Render 2.12 |
| 8 |
import Qt3D.Input 2.0 |
| 9 |
import Qt3D.Extras 2.0 |
| 10 |
|
| 11 |
QQ2.Item { |
| 12 |
id: root |
| 13 |
width: 1280 |
| 14 |
height: 720 |
| 15 |
|
| 16 |
property int i: 0 |
| 17 |
readonly property var sources: ["https://codereview.qt-project.org/gitweb?p=qt/qt3d.git;a=blob_plain;hb=refs/heads/dev;f=examples/qt3d/planets-qml/images/solarsystemscope/earthmap2k.jpg", "qrc:/image.jpg", "qrc:/image2.jpg", "qrc:/wrongpath.jpg"] |
| 18 |
readonly property url textureSource: sources[i] |
| 19 |
|
| 20 |
QQ2.Timer { |
| 21 |
interval: 3000 |
| 22 |
repeat: true |
| 23 |
running: true |
| 24 |
onTriggered: i = (i + 1) % sources.length |
| 25 |
} |
| 26 |
|
| 27 |
Scene3D { |
| 28 |
anchors.fill: parent |
| 29 |
focus: true |
| 30 |
|
| 31 |
aspects: ["input", "logic"] |
| 32 |
|
| 33 |
Entity { |
| 34 |
id: sceneRoot |
| 35 |
|
| 36 |
readonly property var textureModel: [texture1, texture2, texture3, texture4] |
| 37 |
|
| 38 |
readonly property Texture texture1: TextureLoader { |
| 39 |
source: textureSource |
| 40 |
} |
| 41 |
|
| 42 |
readonly property Texture texture2: TextureLoader { |
| 43 |
source: textureSource |
| 44 |
} |
| 45 |
|
| 46 |
readonly property Texture texture3: Texture2D { |
| 47 |
format: Texture.RGBA8_UNorm |
| 48 |
textureImages: TextureImage { |
| 49 |
source: textureSource |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
readonly property Texture texture4: Texture2D { |
| 54 |
format: Texture.RGBA8_UNorm |
| 55 |
textureImages: TextureImage { |
| 56 |
source: textureSource |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
Camera { |
| 61 |
id: camera |
| 62 |
projectionType: CameraLens.PerspectiveProjection |
| 63 |
fieldOfView: 45 |
| 64 |
aspectRatio: 16/9 |
| 65 |
nearPlane : 0.1 |
| 66 |
farPlane : 1000.0 |
| 67 |
position: Qt.vector3d( 0.0, 20.0, -40.0 ) |
| 68 |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) |
| 69 |
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) |
| 70 |
} |
| 71 |
|
| 72 |
OrbitCameraController { |
| 73 |
camera: camera |
| 74 |
} |
| 75 |
|
| 76 |
components: [ |
| 77 |
RenderSettings { |
| 78 |
activeFrameGraph: ForwardRenderer { |
| 79 |
clearColor: Qt.rgba(0, 0.5, 1, 1) |
| 80 |
camera: camera |
| 81 |
} |
| 82 |
}, |
| 83 |
// Event Source will be set by the Qt3DQuickWindow |
| 84 |
InputSettings { } |
| 85 |
] |
| 86 |
|
| 87 |
CuboidMesh { id: mesh } |
| 88 |
|
| 89 |
NodeInstantiator { |
| 90 |
id: instantiator |
| 91 |
model: sceneRoot.textureModel |
| 92 |
|
| 93 |
Entity { |
| 94 |
readonly property Transform transform: Transform { |
| 95 |
readonly property real angle: model.index / instantiator.count * Math.PI * 2 |
| 96 |
translation: Qt.vector3d(Math.cos(angle) * 10, 0, Math.sin(angle) * 10) |
| 97 |
scale: 10 |
| 98 |
} |
| 99 |
|
| 100 |
readonly property DiffuseMapMaterial material: DiffuseMapMaterial { |
| 101 |
diffuse: model.modelData |
| 102 |
} |
| 103 |
components: [ mesh, material, transform ] |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
QQ2.Text { |
| 110 |
anchors { |
| 111 |
horizontalCenter: parent.horizontalCenter |
| 112 |
bottom: parent.bottom |
| 113 |
} |
| 114 |
font.pointSize: 20 |
| 115 |
text: "Source (" + (i + 1) + " of " + sources.length + "): " + textureSource |
| 116 |
} |
| 117 |
|
| 118 |
QQ2.ListView { |
| 119 |
anchors { |
| 120 |
left: parent.left |
| 121 |
top: parent.top |
| 122 |
bottom: parent.bottom |
| 123 |
} |
| 124 |
readonly property var targets: [] |
| 125 |
readonly property var status: [] |
| 126 |
|
| 127 |
spacing: 30 |
| 128 |
model: sceneRoot.textureModel |
| 129 |
width: parent.width / 4 |
| 130 |
delegate: QQ2.Grid { |
| 131 |
spacing: 10 |
| 132 |
columns: 2 |
| 133 |
QQ2.Text { text: "Target: " + nameMapper.targetName(model.modelData.target) } |
| 134 |
QQ2.Text { text: "Format: " + nameMapper.formatName(model.modelData.format.toString()) } |
| 135 |
QQ2.Text { text: "Width: " + model.modelData.width } |
| 136 |
QQ2.Text { text: "Height: " + model.modelData.height } |
| 137 |
QQ2.Text { text: "Depth: " + model.modelData.depth} |
| 138 |
QQ2.Text { text: "Layers: " + model.modelData.layers} |
| 139 |
QQ2.Text { text: "Status: " + nameMapper.statusName(model.modelData.status.toString()) } |
| 140 |
QQ2.Text { text: "HandleType: " + nameMapper.handleTypeName(model.modelData.handleType) } |
| 141 |
QQ2.Text { text: "Handle: " + model.modelData.handle } |
| 142 |
} |
| 143 |
} |
| 144 |
} |