aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadegh Taghavi <[email protected]>2025-05-12 10:38:25 +0300
committerNicholas Bennett <[email protected]>2025-06-03 07:57:46 +0000
commit90cbbe03e9ab9b070d1403658bb0bb9b806f5af1 (patch)
treebd242d1d952e8eea9b424b27495aec78547aa867
parent41f2fcd036671d2a530dc8d836b4ff0d0b5041a0 (diff)
Enable scene capture request for spatial anchorsHEADdev
Added necessary changes to demonstrate how to trigger a room scan for spatial anchors. Task-number: QTBUG-133988 Pick-to: 6.9 6.10 Change-Id: Ie28585fd2e6e0c9a49e35c8386ee5232bfe2ae23 Reviewed-by: Christian Strømme <[email protected]>
-rw-r--r--examples/quick3d/xr_anchors/main.qml12
-rw-r--r--src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel.cpp13
2 files changed, 23 insertions, 2 deletions
diff --git a/examples/quick3d/xr_anchors/main.qml b/examples/quick3d/xr_anchors/main.qml
index 39b53d3e..fc6acb03 100644
--- a/examples/quick3d/xr_anchors/main.qml
+++ b/examples/quick3d/xr_anchors/main.qml
@@ -76,10 +76,17 @@ XrView {
poseSpace: XrController.AimPose
XrInputAction {
- controller: XrInputAction.RightController
+ hand: XrInputAction.RightHand
actionId: [XrInputAction.Button2Pressed, XrInputAction.MiddleFingerPinch]
onTriggered: xrView.preferPassthrough = !xrView.preferPassthrough
}
+ XrInputAction {
+ hand: XrInputAction.RightHand
+ actionId: [XrInputAction.Button1Pressed]
+ onTriggered: {
+ spatialAnchors.model.requestSceneCapture()
+ }
+ }
onRotationChanged: {
const pickResult = xrView.rayPick(scenePosition, forward)
@@ -161,7 +168,7 @@ XrView {
anchors.fill: parent
anchors.margins: 10
textFormat: Text.StyledText
- text: "Total anchors: " + labelNode.numAnchors + "<br>" + "Selected: " + labelNode.anchorInfo
+ text: "Total anchors: " + labelNode.numAnchors + "<br>" + "Selected: " + labelNode.anchorInfo + "<br>" + "Press A to Capture/Update anchors"
}
}
}
@@ -171,6 +178,7 @@ XrView {
Repeater3D {
id: spatialAnchors
model: XrSpatialAnchorListModel {
+
}
delegate: Node {
id: anchorNode
diff --git a/src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel.cpp b/src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel.cpp
index 7ea6c8dc..cf12eb01 100644
--- a/src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel.cpp
+++ b/src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel.cpp
@@ -97,6 +97,7 @@ QQuick3DXrSpatialAnchorListModel::QQuick3DXrSpatialAnchorListModel(QObject *pare
connect(m_anchorManager, &QQuick3DXrAnchorManager::anchorAdded, this, &QQuick3DXrSpatialAnchorListModel::handleAnchorAdded);
connect(m_anchorManager, &QQuick3DXrAnchorManager::anchorUpdated, this, &QQuick3DXrSpatialAnchorListModel::handleAnchorUpdated);
connect(m_anchorManager, &QQuick3DXrAnchorManager::anchorRemoved, this, &QQuick3DXrSpatialAnchorListModel::handleAnchorRemoved);
+ connect(m_anchorManager, &QQuick3DXrAnchorManager::sceneCaptureCompleted, this, [this]{queryAnchors();});
queryAnchors();
} else {
qWarning("SpatialAnchorModel: Failed to get anchor manager instance");
@@ -140,6 +141,18 @@ QHash<int, QByteArray> QQuick3DXrSpatialAnchorListModel::roleNames() const
return roles;
}
+/*!
+ \qmlmethod void QQuick3DXrSpatialAnchorListModel::requestSceneCapture()
+ \brief This method triggers a scan to capture or update spatial data for the current environment.
+
+ This method triggers the underlying XR system to perform a scene capture of the user's current physical environment,
+ to update or refine the spatial mesh, enabling more accurate placement and tracking of spatial anchors.
+
+ \note Some platforms do not perform this operation automatically.
+ For example, on Quest 3, if the user is in a previously uncaptured space, this method will not be called automatically,
+ resulting in no available anchors until a capture is manually triggered.
+ */
+
void QQuick3DXrSpatialAnchorListModel::requestSceneCapture()
{
if (m_anchorManager == nullptr)