Skip to content

Commit

Permalink
WebXR manual room capture (#5774)
Browse files Browse the repository at this point in the history
* provide webxr manual room capture method

* XrRoomCapture > XrRoomCaptureCallback
  • Loading branch information
Maksims authored Nov 6, 2023
1 parent 7566b03 commit 5a128c3
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/framework/xr/xr-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import { XrAnchors } from './xr-anchors.js';
* @param {Error|null} err - The Error object or null if operation was successful.
*/

/**
* Callback used by manual room capturing.
*
* @callback XrRoomCaptureCallback
* @param {Error|null} err - The Error object or null if manual room capture was successful.
*/

/**
* Manage and update XR session and its states.
*
Expand Down Expand Up @@ -551,6 +558,40 @@ class XrManager extends EventHandler {
}
}

/**
* Initiate manual room capture. If the underlying XR system supports manual capture of the
* room, it will start the capturing process, which can affect plane and mesh detection,
* and improve hit-test quality against real-world geometry.
*
* @param {XrRoomCaptureCallback} callback - Callback that will be fired once capture is complete
* or failed.
*
* @example
* this.app.xr.initiateRoomCapture((err) => {
* if (err) {
* // capture failed
* return;
* }
* // capture was successful
* });
*/
initiateRoomCapture(callback) {
if (!this._session) {
callback(new Error('Session is not active'));
return;
}
if (!this._session.initiateRoomCapture) {
callback(new Error('Session does not support manual room capture'));
return;
}

this._session.initiateRoomCapture().then(() => {
if (callback) callback(null);
}).catch((err) => {
if (callback) callback(err);
});
}

/**
* @param {string} type - Session type.
* @private
Expand Down

0 comments on commit 5a128c3

Please sign in to comment.