Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebXR Plane Detection #3068

Merged
merged 17 commits into from
Jun 15, 2021
Merged

Conversation

Maksims
Copy link
Contributor

@Maksims Maksims commented Apr 7, 2021

Implementation of an experimental draft spec: https://immersive-web.github.io/real-world-geometry/plane-detection.html

It is available in Chrome for Android 89, with enabled chrome://flags#webxr-incubations flag.

Plane detection provides information about real-world surfaces estimations in form of planes.
Each plane can have its position, rotation and a list of edge points making a complex polygon.

New APIs:

// pc.XrManager
app.xr.planeDetection // interface to access plane detection
app.xr.start(camera, ..., ..., {
    planeDetection: true
}); // new option to enable plane detection

// pc.XrPlaneDetection
planeDetection.supported // true if plane detection is supported
planeDetection.available // true if plane detection is available
planeDetection.planes // a list of pc.XrPlane's

planeDetection.on('available', () => { }); // fired when plane detection becomes available, due to spec design it is not possible to know if it is available before a first XR session update
planeDetection.on('unavailable', () => { }); // fired when plane detection becomes unavailable, for example when session is ended
planeDetection.on('add', (plane) => { }); // fired when a new plane is added
planeDetection.on('remove', (plane) => { }); // fired when a plane is removed

// pc.XrPlane
plane.id // numerical id of a plane
plane.orientation // 'horizontal' or 'vertical' orientation of a plane, or null if any other orientation
plane.points // a list of edge points of a plane. Their coords are in local space to a plane
plane.getPosition() // get world position of a plane
plane.getRotation() // get world rotation of a plane

plane.once('remove', () => { }); // fired when plane is removed
plane.on('change', () => { }); // fired when plane orientation or points have been changed

Test project:

https://playcanvas.com/project/782753/overview/webxr-plane-detection
This project builds mesh, updates it when the plane is changed and draw lines for each detected plane.

Test build:

https://playcanv.as/p/f2ESRGge/
Ensure you have chrome://flags#webxr-incubations enabled

Video:

https://twitter.com/mrmaxm/status/1379802592163864581

thumb

I confirm I have signed the Contributor License Agreement.

@Maksims
Copy link
Contributor Author

Maksims commented Apr 7, 2021

I'm not sure how to deal with a TypeScript error as it fails to find XRPlane, and not sure where to add a "polyfill" for such a test. Please advice @mvaligursky

#typescript-problems

src/xr/xr-plane.js Outdated Show resolved Hide resolved
src/xr/xr-plane.js Outdated Show resolved Hide resolved
@yaustar
Copy link
Contributor

yaustar commented Apr 14, 2021

Self note: add project https://playcanvas.com/project/782753/overview/webxr-plane-detection to tutorials section

@willeastcott willeastcott added this to the v1.41.0 milestone Apr 14, 2021
@willeastcott willeastcott self-assigned this Apr 21, 2021
@yaustar yaustar removed this from the v1.41.0 milestone May 10, 2021
@yaustar yaustar added the release: next minor Ticket marked for the next minor release label May 10, 2021
src/xr/xr-plane.js Outdated Show resolved Hide resolved
src/xr/xr-plane.js Outdated Show resolved Hide resolved
src/xr/xr-plane.js Outdated Show resolved Hide resolved
src/xr/xr-plane.js Outdated Show resolved Hide resolved
@willeastcott
Copy link
Contributor

OK, LGTM now, @Maksims. Can you resolve the xr-manager.js conflict and I'll merge.

@willeastcott
Copy link
Contributor

Looks like Typescript definitions are failing:

image

@Maksims
Copy link
Contributor Author

Maksims commented Jun 15, 2021

Looks like Typescript definitions are failing:

image

I have no idea how to fix those TypeScript issues.

@@ -181,6 +183,9 @@ 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}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate of the param definition at line 190

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except that declaration is an object

@willeastcott willeastcott merged commit 6a58246 into playcanvas:master Jun 15, 2021
@Maksims Maksims deleted the webxr-plane-detection branch June 15, 2021 11:28
@Maksims Maksims mentioned this pull request Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: xr XR related issue release: next minor Ticket marked for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants