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
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick3D
import QtQuick3D.Helpers
import QtQuick.Controls
import QtQuick.Layouts
Window {
width: 1280
height: 720
visible: true
title: qsTr("Input in 3D")
objectName: "root window"
color: "green"
Shortcut {
sequence: StandardKey.Quit
onActivated: Qt.quit()
}
// DebugView {
// anchors.top: parent.top
// anchors.left: parent.left
// source: view3D
// }
View3D {
id: view3D
objectName: "Viewport3D"
anchors.left: parent.left
//anchors.leftMargin: 256
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
environment: SceneEnvironment {
clearColor: "white"
backgroundMode: SceneEnvironment.Color
}
PerspectiveCamera {
z: 600
}
DirectionalLight {
}
DirectionalLight {
eulerRotation.y: -90
}
Node {
x: 0
z: 300
eulerRotation.y: 15
Model {
objectName: "middle cube in middle stack"
source: "#Cube"
pickable: true
materials: DefaultMaterial {
diffuseMap: Texture {
sourceItem: InputDebugger {
objectName: "middle InputDebugger on middle stack of cubes"
}
}
}
}
Model {
objectName: "bottom cube in middle stack"
y: -100
source: "#Cube"
pickable: true
materials: PrincipledMaterial {
baseColorMap: Texture {
sourceItem: InputDebugger {
objectName: "bottom InputDebugger on middle stack of cubes"
}
}
}
}
Model {
objectName: "top cube in middle stack"
y: 100
source: "#Cube"
pickable: true
materials: CustomMaterial {
property TextureInput diffuse: TextureInput {
texture: Texture {
sourceItem: InputDebugger {
objectName: "top InputDebugger on middle stack of cubes"
}
}
}
fragmentShader: "custom.frag"
}
}
}
Node {
x: 200
z: 300
Model {
source: "#Cube"
pickable: true
objectName: "middle cube in right stack"
materials: DefaultMaterial {
diffuseMap: Texture {
sourceItem: InputDebugger {
objectName: "lower-left InputDebugger, layer mapped onto right stack of cubes"
layer.enabled: true
layer.textureSize: Qt.size(512, 512)
id: sharedItem
x: 10; y: 400
}
}
}
// eulerRotation.z: 30
// PropertyAnimation on eulerRotation.y {
// from: 0
// to: 360
// duration: 15000
// running: true
// loops: Animation.Infinite
// }
}
Model {
objectName: "bottom cube in right stack"
y: -100
source: "#Cube"
pickable: true
materials: PrincipledMaterial {
baseColorMap: Texture {
sourceItem: sharedItem
}
}
}
Model {
objectName: "top cube in right stack"
y: 100
source: "#Cube"
pickable: true
materials: CustomMaterial {
property TextureInput diffuse: TextureInput {
texture: Texture {
sourceItem: sharedItem
}
}
fragmentShader: "custom.frag"
}
}
}
Model {
objectName: "rotating cube"
source: "#Cube"
x: 50
z: 400
scale: Qt.vector3d(0.2, 0.2, 0.2)
materials: DefaultMaterial {
diffuseColor: "tomato"
}
pickable: true
eulerRotation.z: 20
PropertyAnimation on eulerRotation.y {
from: 0
to: 360
duration: 5000
running: true
loops: Animation.Infinite
}
}
// Node {
// x: -512
// y: 256
// eulerRotation.y: 65
// InputDebugger {
// objectName: "top-left rotated planar InputDebugger"
// }
// }
}
}
|