1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick3D
Window {
width: 800
height: 480
visible: true
title: qsTr("Quick Items Example")
View3D {
anchors.fill: parent
environment: SceneEnvironment {
clearColor: "#808080"
backgroundMode: SceneEnvironment.Color
antialiasingMode: SceneEnvironment.MSAA
antialiasingQuality: SceneEnvironment.High
}
PerspectiveCamera {
id: camera
property real cameraAnimation: 1
SequentialAnimation {
loops: Animation.Infinite
running: true
NumberAnimation {
target: camera
property: "cameraAnimation"
to: -1
duration: 5000
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: camera
property: "cameraAnimation"
to: 1
duration: 5000
easing.type: Easing.InOutQuad
}
}
position: Qt.vector3d(200 * cameraAnimation, 300, 500)
eulerRotation.x: -20
eulerRotation.y: 20 * cameraAnimation
}
DirectionalLight {
eulerRotation: Qt.vector3d(-135, -110, 0)
brightness: 1
}
SpotLight {
position: Qt.vector3d(0, 500, 600)
eulerRotation.x: -45
brightness: 30
}
//! [walls models]
Model {
source: "#Rectangle"
y: -500
scale: Qt.vector3d(12, 12, 12)
eulerRotation.x: -90
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.5, 0.5, 0.5, 1.0)
}
}
Model {
source: "#Rectangle"
x: -600
scale: Qt.vector3d(12, 10, 12)
eulerRotation.y: 90
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.8, 0.8, 0.6, 1.0)
}
}
Model {
source: "#Rectangle"
z: -600
scale: Qt.vector3d(12, 10, 12)
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.8, 0.8, 0.6, 1.0)
}
}
//! [walls models]
//! [background item]
Node {
position: Qt.vector3d(0, 100, -120)
Item {
width: 400
height: 400
anchors.centerIn: parent
Rectangle {
anchors.fill: parent
opacity: 0.4
color: "#202020"
radius: 10
border.width: 2
border.color: "#f0f0f0"
}
Text {
anchors.top: parent.top
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 20
color: "#e0e0e0"
style: Text.Raised
text: qsTr("Background Item")
}
Image {
anchors.centerIn: parent
source: "Built_with_Qt_RGB_logo_vertical"
}
}
}
//! [background item]
//! [circles item]
Node {
position: Qt.vector3d(0, 150, 100)
SequentialAnimation on x {
loops: Animation.Infinite
NumberAnimation {
to: -200
duration: 1500
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: 200
duration: 1500
easing.type: Easing.InOutQuad
}
}
NumberAnimation on eulerRotation.z {
loops: Animation.Infinite
from: 0
to: 360
duration: 4000
easing.type: Easing.InOutBack
}
Item {
width: 400
height: 400
anchors.centerIn: parent
// This allows rendering into offscreen surface and caching it.
layer.enabled: true
Rectangle {
x: 150
y: 100
width: 100
height: 100
radius: 50
color: "#80808020"
border.color: "black"
border.width: 2
}
Rectangle {
x: 90
y: 200
width: 100
height: 100
radius: 50
color: "#80808020"
border.color: "black"
border.width: 2
}
Rectangle {
x: 210
y: 200
width: 100
height: 100
radius: 50
color: "#80808020"
border.color: "black"
border.width: 2
}
}
}
//! [circles item]
//! [text item]
Node {
position: Qt.vector3d(0, 80, 250)
Text {
anchors.centerIn: parent
width: 300
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignJustify
font.pixelSize: 14
color: "#e0e0e0"
style: Text.Raised
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " +
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " +
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea " +
"commodo consequat."
SequentialAnimation on opacity {
loops: Animation.Infinite
NumberAnimation {
to: 0
duration: 1500
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: 1
duration: 1500
easing.type: Easing.InOutQuad
}
}
}
}
//! [text item]
//! [wrecking ball model]
Node {
position: Qt.vector3d(0, 800, 0)
SequentialAnimation on eulerRotation.x {
loops: Animation.Infinite
NumberAnimation {
to: 20
duration: 3500
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: -20
duration: 3500
easing.type: Easing.InOutQuad
}
}
Model {
source: "#Cylinder"
y: -300
scale: Qt.vector3d(0.1, 6.1, 0.1)
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.9, 0.9, 0.9, 1.0)
}
}
Model {
source: "#Sphere"
y: -700
scale: Qt.vector3d(2, 2, 2)
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.4, 0.4, 0.4, 1.0)
}
}
}
//! [wrecking ball model]
}
}
|