From b17be69895e19a14ce7af1c34ff89a06488dab06 Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Wed, 7 Apr 2021 16:45:57 +0300 Subject: [PATCH 01/15] webxr plane detection --- src/xr/xr-depth-sensing.js | 6 +- src/xr/xr-manager.js | 17 ++++- src/xr/xr-plane-detection.js | 129 +++++++++++++++++++++++++++++++++++ src/xr/xr-plane.js | 108 +++++++++++++++++++++++++++++ 4 files changed, 256 insertions(+), 4 deletions(-) create mode 100644 src/xr/xr-plane-detection.js create mode 100644 src/xr/xr-plane.js diff --git a/src/xr/xr-depth-sensing.js b/src/xr/xr-depth-sensing.js index 1ee72548c04..e5112fd20c8 100644 --- a/src/xr/xr-depth-sensing.js +++ b/src/xr/xr-depth-sensing.js @@ -152,7 +152,11 @@ class XrDepthSensing extends EventHandler { update(frame, view) { if (view) { if (! this._depthInfo) this._matrixDirty = true; - this._depthInfo = frame.getDepthInformation(view); + try { + this._depthInfo = frame.getDepthInformation(view); + } catch (ex) { + this._depthInfo = null; + } } else { if (this._depthInfo) this._matrixDirty = true; this._depthInfo = null; diff --git a/src/xr/xr-manager.js b/src/xr/xr-manager.js index 17dd4ca33cd..9fa1ff14c9d 100644 --- a/src/xr/xr-manager.js +++ b/src/xr/xr-manager.js @@ -13,6 +13,7 @@ import { XrLightEstimation } from './xr-light-estimation.js'; import { XrImageTracking } from './xr-image-tracking.js'; import { XrDomOverlay } from './xr-dom-overlay.js'; import { XrDepthSensing } from './xr-depth-sensing.js'; +import { XrPlaneDetection } from './xr-plane-detection.js'; /** * @class @@ -59,6 +60,7 @@ class XrManager extends EventHandler { this.domOverlay = new XrDomOverlay(this); this.hitTest = new XrHitTest(this); this.imageTracking = new XrImageTracking(this); + this.planeDetection = new XrPlaneDetection(this); this.input = new XrInput(this); this.lightEstimation = new XrLightEstimation(this); @@ -219,10 +221,16 @@ class XrManager extends EventHandler { if (type === XRTYPE_AR) { opts.optionalFeatures.push('light-estimation'); opts.optionalFeatures.push('hit-test'); - opts.optionalFeatures.push('depth-sensing'); - if (options && options.imageTracking) { - opts.optionalFeatures.push('image-tracking'); + if (options) { + if (options.depthSensing) + opts.optionalFeatures.push('depth-sensing'); + + if (options.imageTracking) + opts.optionalFeatures.push('image-tracking'); + + if (options.planeDetection) + opts.optionalFeatures.push('plane-detection'); } if (this.domOverlay.root) { @@ -516,6 +524,9 @@ class XrManager extends EventHandler { if (this.imageTracking.supported) this.imageTracking.update(frame); + + if (this.planeDetection.supported) + this.planeDetection.update(frame); } this.fire('update', frame); diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js new file mode 100644 index 00000000000..3044aab5d76 --- /dev/null +++ b/src/xr/xr-plane-detection.js @@ -0,0 +1,129 @@ +import { EventHandler } from '../core/event-handler.js'; +import { XrPlane } from './xr-plane.js'; + +/** + * @class + * @name XrPlaneDetection + * @classdesc Plane Detection provides the ability to detect real world surfaces based on estimations of underlying AR system. + * @description Plane Detection provides the ability to detect real world surfaces based on estimations of underlying AR system. + * @param {XrManager} manager - WebXR Manager. + * @property {boolean} supported True if Plane Detection is supported. + * @property {boolean} available True if Plane Detection is available. This property can be set to true only during running session. + * @property {XrPlane[]} planes List of {@link XrPlane} that contain individual plane information. + */ +class XrPlaneDetection extends EventHandler { + constructor(manager) { + super(); + + this._manager = manager; + this._supported = !! window.XRPlane; + this._available = false; + + this._planesIndex = new Map(); + this._planes = []; + + if (this._supported) { + this._manager.on('end', this._onSessionEnd, this); + } + } + + /** + * @event + * @name XrPlaneDetection#available + * @description Fired when plane detection becomes available. + */ + + /** + * @event + * @name XrPlaneDetection#unavailable + * @description Fired when plane detection becomes unavailable. + */ + + /** + * @event + * @name XrPlaneDetection#add + * @description Fired when new {@link XrPlane} is added to the list. + * @param {XrPlane} plane - Plane that has been added. + * @example + * app.xr.planeDetection.on('add', function (plane) { + * // new plane is added + * }); + */ + + /** + * @event + * @name XrPlaneDetection#remove + * @description Fired when a {@link XrPlane} is removed to the list. + * @param {XrPlane} plane - Plane that has been removed. + * @example + * app.xr.planeDetection.on('remove', function (plane) { + * // new plane is removed + * }); + */ + + _onSessionEnd() { + for (let i = 0; i < this._planes.length; i++) { + this._planes[i].destroy(); + } + this._planesIndex.clear(); + this._planes = []; + + if (this._available) { + this._available = false; + this.fire('unavailable'); + } + } + + update(frame) { + let detectedPlanes; + + if (! this._available) { + try { + detectedPlanes = frame.detectedPlanes; + this._available = true; + this.fire('available'); + } catch (ex) { + return; + } + } else { + detectedPlanes = frame.detectedPlanes; + } + + for (const [xrPlane, plane] of this._planesIndex) { + if (! detectedPlanes.has(xrPlane)) { + this._planesIndex.delete(xrPlane); + this._planes.splice(this._planes.indexOf(plane), 1); + plane.destroy(); + this.fire('remove', plane); + } + } + + for (const xrPlane of detectedPlanes) { + let plane = this._planesIndex.get(xrPlane); + + if (! plane) { + plane = new XrPlane(this, xrPlane); + this._planesIndex.set(xrPlane, plane); + this._planes.push(plane); + this.fire('add', plane); + plane.update(frame); + } else { + plane.update(frame); + } + } + } + + get supported() { + return this._supported; + } + + get available() { + return this._available; + } + + get planes() { + return this._planes; + } +} + +export { XrPlaneDetection }; diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js new file mode 100644 index 00000000000..eee2f1053e7 --- /dev/null +++ b/src/xr/xr-plane.js @@ -0,0 +1,108 @@ +import { EventHandler } from '../core/event-handler.js'; +import { Vec3 } from '../math/vec3.js'; +import { Quat } from '../math/quat.js'; + +let ids = 0; + +/** + * @class + * @name XrPlane + * @classdesc Detected Plane instance that provides position, rotation and polygon points. Plane is a subject to change during its lifetime. + * @description Detected Plane instance that provides position, rotation and polygon points. Plane is a subject to change during its lifetime. + * @param {XrPlaneDetection} planeDetection - Plane detection system. + * @param {XRPlane} xrPlane - XRPlane that is instantiated by WebXR system. + * @property {number} id Unique identifier of a plane. + * @property {string|null} orientation Plane's pecific orientation (horizontal or vertical) or null if orientation is anything else. + * @property {object[]} points List of DOMPointReadOnly objects that is an object with `x y z` properties that define local point of a planes polygon. + */ +class XrPlane extends EventHandler { + constructor(planeDetection, xrPlane) { + super(); + + this._id = ++ids; + + this._planeDetection = planeDetection; + this._manager = this._planeDetection._manager; + + this._xrPlane = xrPlane; + this._lastChangedTime = this._xrPlane.lastChangedTime; + this._orientation = this._xrPlane.orientation; + + this._position = new Vec3(); + this._rotation = new Quat(); + } + + /** + * @event + * @name XrPlane#remove + * @description Fired when {@link XrPlane} is removed. + * @example + * plane.once('remove', function () { + * // plane is not available anymore + * }); + */ + + /** + * @event + * @name XrPlane#change + * @description Fired when {@link XrPlane} attributes such as: orientation and/or points have been changed. Position and Rotation can change at any time without triggering `change` event. + * @example + * plane.on('change', function () { + * // plane has been changed + * }); + */ + + destroy() { + this.fire('remove'); + } + + update(frame) { + const pose = frame.getPose(this._xrPlane.planeSpace, this._manager._referenceSpace); + if (pose) { + this._position.copy(pose.transform.position); + this._rotation.copy(pose.transform.orientation); + } + + // has not changed + if (this._lastChangedTime !== this._xrPlane.lastChangedTime) { + this._lastChangedTime = this._xrPlane.lastChangedTime; + + // attributes have been changed + this.fire('change'); + } + } + + /** + * @function + * @name XrPlane#getPosition + * @description Get the world space position of a plane. + * @returns {Vec3} The world space position of a plane. + */ + getPosition() { + return this._position; + } + + /** + * @function + * @name XrPlane#getRotation + * @description Get the world space rotation of a plane. + * @returns {Vec3} The world space rotation of a plane. + */ + getRotation() { + return this._rotation; + } + + get id() { + return this.id; + } + + get orientation() { + return this._orientation; + } + + get points() { + return this._xrPlane.polygon; + } +} + +export { XrPlane }; From 025aa9c4197894d3d1f828e93585035737db326c Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Wed, 7 Apr 2021 17:37:57 +0300 Subject: [PATCH 02/15] webxr plane detection imrpoved docs --- src/framework/components/camera/component.js | 3 +++ src/xr/xr-manager.js | 5 +++- src/xr/xr-plane-detection.js | 9 +++++++ src/xr/xr-plane.js | 27 +++++++++++++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/framework/components/camera/component.js b/src/framework/components/camera/component.js index 646bd838244..377540d3fa4 100644 --- a/src/framework/components/camera/component.js +++ b/src/framework/components/camera/component.js @@ -563,6 +563,9 @@ class CameraComponent extends Component { * * @param {object} [options] - Object with options for XR session initialization. * @param {string[]} [options.optionalFeatures] - Optional features for XRSession start. It is used for getting access to additional WebXR spec extensions. + * @param {boolean} [options.depthSensing] - Set to true to attempt to enable {@link XrDepthSensing}. + * @param {boolean} [options.imageTracking] - Set to true to attempt to enable {@link XrImageTracking}. + * @param {boolean} [options.planeDetection] - Set to true to attempt to enable {@link XrPlaneDetection}. * @param {callbacks.XrError} [options.callback] - Optional callback function called once * the session is started. The callback has one argument Error - it is null if the XR * session started successfully. diff --git a/src/xr/xr-manager.js b/src/xr/xr-manager.js index 9fa1ff14c9d..ab97fad3661 100644 --- a/src/xr/xr-manager.js +++ b/src/xr/xr-manager.js @@ -175,10 +175,13 @@ class XrManager extends EventHandler { * * @example * button.on('click', function () { - * app.xr.start(camera, pc.XRTYPE_VR, pc.XRSPACE_LOCAL); + * app.xr.start(camera, pc.XRTYPE_VR, pc.XRSPACE_LOCALFLOOR); * }); * @param {object} [options] - Object with additional options for XR session initialization. * @param {string[]} [options.optionalFeatures] - Optional features for XRSession start. It is used for getting access to additional WebXR spec extensions. + * @param {boolean} [options.depthSensing] - Set to true to attempt to enable {@link XrDepthSensing}. + * @param {boolean} [options.imageTracking] - Set to true to attempt to enable {@link XrImageTracking}. + * @param {boolean} [options.planeDetection] - Set to true to attempt to enable {@link XrPlaneDetection}. * @param {callbacks.XrError} [options.callback] - Optional callback function called once session is started. The callback has one argument Error - it is null if successfully started XR session. */ start(camera, type, spaceType, options) { diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js index 3044aab5d76..852006ece9c 100644 --- a/src/xr/xr-plane-detection.js +++ b/src/xr/xr-plane-detection.js @@ -10,6 +10,15 @@ import { XrPlane } from './xr-plane.js'; * @property {boolean} supported True if Plane Detection is supported. * @property {boolean} available True if Plane Detection is available. This property can be set to true only during running session. * @property {XrPlane[]} planes List of {@link XrPlane} that contain individual plane information. + * @example + * // start session with plane detection enabled + * app.xr.start(camera, pc.XRTYPE_VR, pc.XRSPACE_LOCALFLOOR, { + * planeDetection: true + * }); + * @example + * app.xr.planeDetection.on('add', function (plane) { + * // new plane been added + * }); */ class XrPlaneDetection extends EventHandler { constructor(manager) { diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js index eee2f1053e7..62970ef3438 100644 --- a/src/xr/xr-plane.js +++ b/src/xr/xr-plane.js @@ -13,7 +13,6 @@ let ids = 0; * @param {XRPlane} xrPlane - XRPlane that is instantiated by WebXR system. * @property {number} id Unique identifier of a plane. * @property {string|null} orientation Plane's pecific orientation (horizontal or vertical) or null if orientation is anything else. - * @property {object[]} points List of DOMPointReadOnly objects that is an object with `x y z` properties that define local point of a planes polygon. */ class XrPlane extends EventHandler { constructor(planeDetection, xrPlane) { @@ -100,6 +99,32 @@ class XrPlane extends EventHandler { return this._orientation; } + /** + * @name XrPlane#points + * @type {object[]} + * @description List of DOMPointReadOnly objects that is an object with `x y z` properties that define local point of a planes polygon. + * @example + * // prepare reusable objects + * var vecA = new pc.Vec3(); + * var vecB = new pc.Vec3(); + * var color = new pc.Color(1, 1, 1); + * + * // update Mat4 to plane position and rotation + * transform.setTRS(plane.getPosition(), plane.getRotation(), pc.Vec3.ONE); + * + * // draw lines between points + * for (var i = 0; i < plane.points.length; i++) { + * vecA.copy(plane.points[i]); + * vecB.copy(plane.points[(i + 1) % plane.points.length]); + * + * // transform from planes local to world coords + * transform.transformPoint(vecA, vecA); + * transform.transformPoint(vecB, vecB); + * + * // render line + * app.renderLine(vecA, vecB, color); + * } + */ get points() { return this._xrPlane.polygon; } From 6a23b19c77fec56083c505aa74c3398901aabf17 Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Wed, 7 Apr 2021 17:44:47 +0300 Subject: [PATCH 03/15] fix --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index acd021b0a65..fd3ec4bb85b 100644 --- a/src/index.js +++ b/src/index.js @@ -297,6 +297,8 @@ export { XrHitTestSource } from './xr/xr-hit-test-source.js'; export { XrImageTracking } from './xr/xr-image-tracking.js'; export { XrTrackedImage } from './xr/xr-tracked-image.js'; export { XrDomOverlay } from './xr/xr-dom-overlay.js'; +export { XrPlaneDetection } from './xr/xr-plane-detection.js'; +export { XrPlane } from './xr/xr-plane.js'; // BACKWARDS COMPATIBILITY export * from './deprecated.js'; From b539c6027de3a1a13d05bae9fd12a481e02fac4a Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Wed, 7 Apr 2021 18:05:53 +0300 Subject: [PATCH 04/15] fix typescript-issues --- src/xr/xr-plane.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js index 62970ef3438..c8cd9dd8ec3 100644 --- a/src/xr/xr-plane.js +++ b/src/xr/xr-plane.js @@ -10,7 +10,7 @@ let ids = 0; * @classdesc Detected Plane instance that provides position, rotation and polygon points. Plane is a subject to change during its lifetime. * @description Detected Plane instance that provides position, rotation and polygon points. Plane is a subject to change during its lifetime. * @param {XrPlaneDetection} planeDetection - Plane detection system. - * @param {XRPlane} xrPlane - XRPlane that is instantiated by WebXR system. + * @param {object} xrPlane - XRPlane that is instantiated by WebXR system. * @property {number} id Unique identifier of a plane. * @property {string|null} orientation Plane's pecific orientation (horizontal or vertical) or null if orientation is anything else. */ From 952fc46dcdb9941545c14aff6fef03a7eed4b65b Mon Sep 17 00:00:00 2001 From: Maksims Mihejevs Date: Thu, 8 Apr 2021 14:36:24 +0300 Subject: [PATCH 05/15] comments to clarify behaviour --- src/xr/xr-plane-detection.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js index 852006ece9c..94cd42f9e91 100644 --- a/src/xr/xr-plane-detection.js +++ b/src/xr/xr-plane-detection.js @@ -9,7 +9,7 @@ import { XrPlane } from './xr-plane.js'; * @param {XrManager} manager - WebXR Manager. * @property {boolean} supported True if Plane Detection is supported. * @property {boolean} available True if Plane Detection is available. This property can be set to true only during running session. - * @property {XrPlane[]} planes List of {@link XrPlane} that contain individual plane information. + * @property {XrPlane[]|null} planes List of {@link XrPlane} that contain individual plane information, or null if plane detection isn't available. * @example * // start session with plane detection enabled * app.xr.start(camera, pc.XRTYPE_VR, pc.XRSPACE_LOCALFLOOR, { @@ -28,8 +28,11 @@ class XrPlaneDetection extends EventHandler { this._supported = !! window.XRPlane; this._available = false; + // key - XRPlane (native plane does not have ID's) + // value - XrPlane this._planesIndex = new Map(); - this._planes = []; + + this._planes = null; if (this._supported) { this._manager.on('end', this._onSessionEnd, this); @@ -75,7 +78,7 @@ class XrPlaneDetection extends EventHandler { this._planes[i].destroy(); } this._planesIndex.clear(); - this._planes = []; + this._planes = null; if (this._available) { this._available = false; @@ -89,6 +92,7 @@ class XrPlaneDetection extends EventHandler { if (! this._available) { try { detectedPlanes = frame.detectedPlanes; + this._planes = []; this._available = true; this.fire('available'); } catch (ex) { @@ -98,25 +102,33 @@ class XrPlaneDetection extends EventHandler { detectedPlanes = frame.detectedPlanes; } + // iterate through indexed planes for (const [xrPlane, plane] of this._planesIndex) { - if (! detectedPlanes.has(xrPlane)) { - this._planesIndex.delete(xrPlane); - this._planes.splice(this._planes.indexOf(plane), 1); - plane.destroy(); - this.fire('remove', plane); - } + if (detectedPlanes.has(xrPlane)) + continue; + + // if indexed plane is not listed in detectedPlanes anymore + // then remove it + this._planesIndex.delete(xrPlane); + this._planes.splice(this._planes.indexOf(plane), 1); + plane.destroy(); + this.fire('remove', plane); } + // iterate through detected planes for (const xrPlane of detectedPlanes) { let plane = this._planesIndex.get(xrPlane); if (! plane) { + // detected plane is not indexed + // then create new XrPlane plane = new XrPlane(this, xrPlane); this._planesIndex.set(xrPlane, plane); this._planes.push(plane); - this.fire('add', plane); plane.update(frame); + this.fire('add', plane); } else { + // if already indexed, just update plane.update(frame); } } From cd69a99850c135d0690d8d19fa58c2b626a63185 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:28:22 +0100 Subject: [PATCH 06/15] Update src/xr/xr-plane-detection.js --- src/xr/xr-plane-detection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js index 94cd42f9e91..52b2699d3c1 100644 --- a/src/xr/xr-plane-detection.js +++ b/src/xr/xr-plane-detection.js @@ -65,7 +65,7 @@ class XrPlaneDetection extends EventHandler { /** * @event * @name XrPlaneDetection#remove - * @description Fired when a {@link XrPlane} is removed to the list. + * @description Fired when a {@link XrPlane} is removed from the list. * @param {XrPlane} plane - Plane that has been removed. * @example * app.xr.planeDetection.on('remove', function (plane) { From 62d0ad50a71b0f9bf84cc00ac5d53b4b715d616d Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:28:32 +0100 Subject: [PATCH 07/15] Update src/xr/xr-plane-detection.js --- src/xr/xr-plane-detection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js index 52b2699d3c1..11a90aa04e6 100644 --- a/src/xr/xr-plane-detection.js +++ b/src/xr/xr-plane-detection.js @@ -4,8 +4,8 @@ import { XrPlane } from './xr-plane.js'; /** * @class * @name XrPlaneDetection - * @classdesc Plane Detection provides the ability to detect real world surfaces based on estimations of underlying AR system. - * @description Plane Detection provides the ability to detect real world surfaces based on estimations of underlying AR system. + * @classdesc Plane Detection provides the ability to detect real world surfaces based on estimations of the underlying AR system. + * @description Plane Detection provides the ability to detect real world surfaces based on estimations of the underlying AR system. * @param {XrManager} manager - WebXR Manager. * @property {boolean} supported True if Plane Detection is supported. * @property {boolean} available True if Plane Detection is available. This property can be set to true only during running session. From 10da775007b145af206493693b196b67c31e7a95 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:28:42 +0100 Subject: [PATCH 08/15] Update src/xr/xr-plane-detection.js --- src/xr/xr-plane-detection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js index 11a90aa04e6..7d735fb89a9 100644 --- a/src/xr/xr-plane-detection.js +++ b/src/xr/xr-plane-detection.js @@ -9,7 +9,7 @@ import { XrPlane } from './xr-plane.js'; * @param {XrManager} manager - WebXR Manager. * @property {boolean} supported True if Plane Detection is supported. * @property {boolean} available True if Plane Detection is available. This property can be set to true only during running session. - * @property {XrPlane[]|null} planes List of {@link XrPlane} that contain individual plane information, or null if plane detection isn't available. + * @property {XrPlane[]|null} planes Array of {@link XrPlane} instances that contain individual plane information, or null if plane detection is not available. * @example * // start session with plane detection enabled * app.xr.start(camera, pc.XRTYPE_VR, pc.XRSPACE_LOCALFLOOR, { From edb108776836834fd50b9733ae94a474522e8365 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:28:48 +0100 Subject: [PATCH 09/15] Update src/xr/xr-plane.js --- src/xr/xr-plane.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js index c8cd9dd8ec3..fc2dded1f7c 100644 --- a/src/xr/xr-plane.js +++ b/src/xr/xr-plane.js @@ -12,7 +12,7 @@ let ids = 0; * @param {XrPlaneDetection} planeDetection - Plane detection system. * @param {object} xrPlane - XRPlane that is instantiated by WebXR system. * @property {number} id Unique identifier of a plane. - * @property {string|null} orientation Plane's pecific orientation (horizontal or vertical) or null if orientation is anything else. + * @property {string|null} orientation Plane's specific orientation (horizontal or vertical) or null if orientation is anything else. */ class XrPlane extends EventHandler { constructor(planeDetection, xrPlane) { From a834faa7001469bbf1a8d0602d6a2b3033a1aeb9 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:28:54 +0100 Subject: [PATCH 10/15] Update src/xr/xr-plane-detection.js --- src/xr/xr-plane-detection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane-detection.js b/src/xr/xr-plane-detection.js index 7d735fb89a9..9d44469cd8e 100644 --- a/src/xr/xr-plane-detection.js +++ b/src/xr/xr-plane-detection.js @@ -8,7 +8,7 @@ import { XrPlane } from './xr-plane.js'; * @description Plane Detection provides the ability to detect real world surfaces based on estimations of the underlying AR system. * @param {XrManager} manager - WebXR Manager. * @property {boolean} supported True if Plane Detection is supported. - * @property {boolean} available True if Plane Detection is available. This property can be set to true only during running session. + * @property {boolean} available True if Plane Detection is available. This property can be set to true only during a running session. * @property {XrPlane[]|null} planes Array of {@link XrPlane} instances that contain individual plane information, or null if plane detection is not available. * @example * // start session with plane detection enabled From 3965e96103dad0f08960611a32cfa228acbbbc49 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:28:59 +0100 Subject: [PATCH 11/15] Update src/xr/xr-plane.js --- src/xr/xr-plane.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js index fc2dded1f7c..86eae0ac5a5 100644 --- a/src/xr/xr-plane.js +++ b/src/xr/xr-plane.js @@ -44,7 +44,7 @@ class XrPlane extends EventHandler { /** * @event * @name XrPlane#change - * @description Fired when {@link XrPlane} attributes such as: orientation and/or points have been changed. Position and Rotation can change at any time without triggering `change` event. + * @description Fired when {@link XrPlane} attributes such as: orientation and/or points have been changed. Position and rotation can change at any time without triggering a `change` event. * @example * plane.on('change', function () { * // plane has been changed From 939b3b9676476b08799b5172aa0111b21f7f40ca Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:29:05 +0100 Subject: [PATCH 12/15] Update src/xr/xr-plane.js --- src/xr/xr-plane.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js index 86eae0ac5a5..c28f6acccad 100644 --- a/src/xr/xr-plane.js +++ b/src/xr/xr-plane.js @@ -85,7 +85,7 @@ class XrPlane extends EventHandler { * @function * @name XrPlane#getRotation * @description Get the world space rotation of a plane. - * @returns {Vec3} The world space rotation of a plane. + * @returns {Quat} The world space rotation of a plane. */ getRotation() { return this._rotation; From 4c600d8f2b584c13c512fd826118d487fe5519d4 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Tue, 15 Jun 2021 11:29:10 +0100 Subject: [PATCH 13/15] Update src/xr/xr-plane.js --- src/xr/xr-plane.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xr/xr-plane.js b/src/xr/xr-plane.js index c28f6acccad..1e2051d6349 100644 --- a/src/xr/xr-plane.js +++ b/src/xr/xr-plane.js @@ -102,7 +102,7 @@ class XrPlane extends EventHandler { /** * @name XrPlane#points * @type {object[]} - * @description List of DOMPointReadOnly objects that is an object with `x y z` properties that define local point of a planes polygon. + * @description Array of DOMPointReadOnly objects. DOMPointReadOnly is an object with `x y z` properties that defines a local point of a plane's polygon. * @example * // prepare reusable objects * var vecA = new pc.Vec3(); From a6a39d2638e5cc8f9aceabc914848a2d17477047 Mon Sep 17 00:00:00 2001 From: mrmaxm Date: Tue, 15 Jun 2021 14:06:07 +0300 Subject: [PATCH 14/15] Update xr-manager.js --- src/xr/xr-manager.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/xr/xr-manager.js b/src/xr/xr-manager.js index 8a561ca1fcc..ef4e89ed769 100644 --- a/src/xr/xr-manager.js +++ b/src/xr/xr-manager.js @@ -183,7 +183,6 @@ class XrManager extends EventHandler { * }); * @param {object} [options] - Object with additional options for XR session initialization. * @param {string[]} [options.optionalFeatures] - Optional features for XRSession start. It is used for getting access to additional WebXR spec extensions. - * @param {boolean} [options.depthSensing] - Set to true to attempt to enable {@link XrDepthSensing}. * @param {boolean} [options.imageTracking] - Set to true to attempt to enable {@link XrImageTracking}. * @param {boolean} [options.planeDetection] - Set to true to attempt to enable {@link XrPlaneDetection}. * @param {callbacks.XrError} [options.callback] - Optional callback function called once session is started. The callback has one argument Error - it is null if successfully started XR session. @@ -232,10 +231,7 @@ class XrManager extends EventHandler { opts.optionalFeatures.push('hit-test'); if (options) { - if (options.depthSensing) - opts.optionalFeatures.push('depth-sensing'); - - if (options.imageTracking) + if (options.imageTracking && this.imageTracking.supported) opts.optionalFeatures.push('image-tracking'); if (options.planeDetection) From bb3dbacccce05e99ea65ac7b81a4d78e9ab85f1a Mon Sep 17 00:00:00 2001 From: mrmaxm Date: Tue, 15 Jun 2021 14:06:30 +0300 Subject: [PATCH 15/15] Update component.js --- src/framework/components/camera/component.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/framework/components/camera/component.js b/src/framework/components/camera/component.js index a5fe154706e..08dccf5873c 100644 --- a/src/framework/components/camera/component.js +++ b/src/framework/components/camera/component.js @@ -594,7 +594,6 @@ class CameraComponent extends Component { * * @param {object} [options] - Object with options for XR session initialization. * @param {string[]} [options.optionalFeatures] - Optional features for XRSession start. It is used for getting access to additional WebXR spec extensions. - * @param {boolean} [options.depthSensing] - Set to true to attempt to enable {@link XrDepthSensing}. * @param {boolean} [options.imageTracking] - Set to true to attempt to enable {@link XrImageTracking}. * @param {boolean} [options.planeDetection] - Set to true to attempt to enable {@link XrPlaneDetection}. * @param {callbacks.XrError} [options.callback] - Optional callback function called once