diff options
-rw-r--r-- | examples/quick3d/xr_anchors/main.qml | 12 | ||||
-rw-r--r-- | src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel.cpp | 13 |
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) |