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
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
import QtQuick3D
import QtQuick3D.Xr
import QtQuick3D.Helpers
import "../../../examples/quick3d/xr_shared/"
pragma ComponentBehavior: Bound
Window {
id: window
width: 1280
height: 720
visible: true
View3D {
id: view
anchors.fill: parent
environment: SceneEnvironment {
clearColor: "#002266"
backgroundMode: SceneEnvironment.Color
lightProbe: Texture {
textureData: ProceduralSkyTextureData {
}
}
}
Node {
id: originNode
PerspectiveCamera {
id: cameraNode
z: 150
}
}
DirectionalLight {
eulerRotation.x: -30
eulerRotation.y: -70
}
RandomInstancing {
id: randomTable
instanceCount: 150
position: InstanceRange {
from: Qt.vector3d(-200, -50, -100)
to: Qt.vector3d(200, 50, 20)
}
scale: InstanceRange {
from: Qt.vector3d(0.08, 0.08, 0.08)
to: Qt.vector3d(0.15, 0.15, 0.15)
proportional: true
}
rotation: InstanceRange {
from: Qt.vector3d(0, 0, 0)
to: Qt.vector3d(360, 360, 360)
}
color: InstanceRange {
from: Qt.rgba(0.1, 0.1, 0.1, 1.0)
to: Qt.rgba(1, 1, 1, 1.0)
}
}
InstanceRepeater {
instancingTable: randomTable
Model {
id: delegate
required property int index
source: "#Cube"
materials: PrincipledMaterial { baseColor: randomTable.instanceColor(delegate.index) }
pickable: true
}
}
property string lorem: "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains. "
XrItem {
eulerRotation.y: 60
pivot.x: 100
x: -150
y: 50
width: 100
height: 100
contentItem: Rectangle {
color: "white"
width: 500
height: 500
Text {
anchors.fill: parent
anchors.margins: 20
text: view.lorem + view.lorem
wrapMode: Text.WordWrap
}
}
}
XrItem {
x: -100
y: 50
width: 100
height: 100
contentItem: Rectangle {
color: "white"
width: 500
height: 500
Text {
anchors.fill: parent
anchors.margins: 20
text: view.lorem + view.lorem
wrapMode: Text.WordWrap
}
}
}
XrItem {
x: 50
y: 50
z: -100
width: 100
height: 100
contentItem: Rectangle {
color: "white"
width: 500
height: 500
Text {
anchors.fill: parent
anchors.margins: 20
text: view.lorem + view.lorem
wrapMode: Text.WordWrap
}
}
}
AimController {
id: controller
z: 100
x: -30
eulerRotation.x: 0
view: view
xrCursor: cursor
Model {
source: "#Cylinder"
scale: "0.05, 0.1, 0.05"
eulerRotation.x: 90
materials: PrincipledMaterial {
baseColor: "black"
}
}
SequentialAnimation on eulerRotation {
id: controllerAnimation
PropertyAnimation {
from: Qt.vector3d(-10, -60, 0)
to: Qt.vector3d(10, 60, 0)
duration: 8000
}
PropertyAnimation {
from: Qt.vector3d(10, 60, 0)
to: Qt.vector3d(-10, -60, 0)
duration: 8000
}
loops: -1
}
}
XrCursor {
id: cursor
cameraNode: cameraNode
size: 3
opacity: 0.7
cursorStyle: controller.pickStatus === PickResult.Model ? XrGadget.CursorStyle.Sphere : XrGadget.CursorStyle.Flat
}
} // View3D
OrbitCameraController {
id: occ
origin: originNode
camera: cameraNode
Keys.onPressed: event => {
if (event.key === Qt.Key_Space) {
controllerAnimation.running = !controllerAnimation.running
}
}
}
} // Window
|