Skip to content
Snippets Groups Projects
Commit 765398e6 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

add some 2D/3D items

parent f4d5bf4b
No related branches found
No related tags found
No related merge requests found
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import QtQuick3D 1.15
Window { Window {
id: root
property int tick: 0
width: 640 width: 640
height: 480 height: 480
visible: true visible: true
title: qsTr("Hello World") title: qsTr("Hello World")
RowLayout {
anchors.fill: parent
Item {
Layout.fillWidth: true
Layout.fillHeight: true
Item {
anchors.centerIn: parent
Rectangle {
x: -120 - width / 2
y: -height / 2
width: 100
height: 100
color: "lightgray"
Text {
anchors.centerIn: parent
text: root.tick
}
}
ShaderEffectSource {
x: 120 - width / 2
y: -height / 2
width: 100
height: 100
sourceItem: Rectangle {
width: 100
height: 100
color: "lightblue"
Text {
anchors.centerIn: parent
text: root.tick
}
}
}
}
}
View3D {
Layout.fillWidth: true
Layout.fillHeight: true
OrthographicCamera {
position: Qt.vector3d(0, 0, 100)
}
DirectionalLight {
position: Qt.vector3d(0, 0, 100)
brightness: 100
}
Node {
position: Qt.vector3d(-120, 0, 0)
Rectangle {
anchors.centerIn: parent // default of Qt 5
width: 100
height: 100
color: "lightgray"
Text {
anchors.centerIn: parent
text: root.tick
}
}
}
Node {
position: Qt.vector3d(0, 0, 0)
Rectangle {
anchors.centerIn: parent // default of Qt 5
width: 100
height: 100
color: "lightcyan"
layer.enabled: true
Text {
anchors.centerIn: parent
text: root.tick
}
}
}
Node {
position: Qt.vector3d(120, 0, 0)
ShaderEffectSource {
anchors.centerIn: parent // default of Qt 5
width: 100
height: 100
sourceItem: Rectangle {
width: 100
height: 100
color: "lightblue"
Text {
anchors.centerIn: parent
text: root.tick
}
}
}
}
Model {
position: Qt.vector3d(0, 0, 10)
scale: Qt.vector3d(0.2, 0.2, 0.2)
source: "#Sphere"
opacity: 0.1
materials: DefaultMaterial {
diffuseColor: "blue"
}
}
}
}
Timer {
interval: 1000
repeat: true
running: true
onTriggered: {
root.tick += 1
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment