blob: 32c4752b0ad4137b7021d1d36929e9f2bba3b838 (
plain)
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
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick3D
import QtQuick3D.Helpers
import QtQuick3D.Xr
import xr_shared
XrView {
id: xrView
referenceSpace: XrView.ReferenceSpaceLocalFloor
depthSubmissionEnabled: true
environment: SceneEnvironment {
id: sceneEnvironment
lightProbe: Texture {
textureData: ProceduralSkyTextureData {
}
}
antialiasingMode: SceneEnvironment.MSAA
antialiasingQuality: SceneEnvironment.High
backgroundMode: SceneEnvironment.Color
clearColor: "skyblue"
probeHorizon: 0.5
}
DirectionalLight {
eulerRotation.x: -30
eulerRotation.y: -70
}
//! [origin]
XrOrigin {
id: theOrigin
z: 50
TouchHand {
id: rightHandModel
hand: XrHandModel.RightHand
view: xrView
touchId: 0
onTouchPositionChanged: buttons.handleTouch(touchPosition)
}
TouchHand {
id: leftHandModel
hand: XrHandModel.LeftHand
view: xrView
touchId: 1
onTouchPositionChanged: buttons.handleTouch(touchPosition)
}
}
xrOrigin: theOrigin
//! [origin]
Model {
id: floor
source: "#Rectangle"
eulerRotation.x: -90
scale: Qt.vector3d(5,5,5)
materials: [ PrincipledMaterial {
baseColor: "green"
}
]
}
Model {
id: table
property real height: 70
position: Qt.vector3d(0, height - 2.5, 0)
source: "#Cube"
scale: Qt.vector3d(1.5, 0.05, 0.6)
materials: PrincipledMaterial {
baseColor: "white"
}
}
Node {
id: buttons
y: table.height
z: 20
property ExampleButton activeButton: midButton
function handleTouch(touchPos : vector3d) {
for (const b of [leftButton, midButton, rightButton]) {
if (b.hit(touchPos)) {
if (buttons.activeButton !== b) {
buttons.activeButton = b
monitor.monitorRotation = b.degrees
}
break
}
}
}
ExampleButton {
id: leftButton
x: -20
on: buttons.activeButton === this
objectName: "Button 1"
degrees: -20
}
ExampleButton {
id: midButton
x: 0
on: buttons.activeButton === this
objectName: "Button 2"
degrees: 0
}
ExampleButton {
id: rightButton
x: 20
on: buttons.activeButton === this
objectName: "Button 3"
degrees: 20
}
}
Monitor {
id: monitor
y: table.height
eulerRotation.y: monitorRotation
property real monitorRotation: 0
Behavior on monitorRotation {
NumberAnimation { duration: 500 }
}
XrItem {
id: theScreen
y: monitor.yOffset + height
x: -width / 2
width: monitor.width
height: monitor.height
contentItem: ScreenContent {}
}
}
}
|