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 Image Tracking #2574

Merged
merged 11 commits into from Dec 30, 2020
Merged

Conversation

Maksims
Copy link
Contributor

@Maksims Maksims commented Nov 21, 2020

Implements experimental draft extension for WebXR Image Tracking: https://github.com/immersive-web/marker-tracking/blob/main/explainer.md
This API is a subject to change, until spec is more solid.
It is available in Chrome for Android 89, with enabled chrome://flags#webxr-incubations flag.

Image Tracking allows to provide few images and their widths, and then track them in real world even if their positions change, tracking will assume that actively tracked images can move in real world.

New APIs:

// pc.XrManager
app.xr.imageTracking // interface to access image tracking

// pc.XrImageTracking
imageTracking.supported // true if image tracking is supported
imageTracking.available // true if image tracking is currently available
imageTracking.images // list of pc.XrTrackedImage's that contain tracked information

imageTracking.add(image, width); // add image for tracking
imageTracking.remove(trackedImage); // remove tracked image from tracking
// modifying tracked images currently is possible only outside of AR session.
// This is by design of API, but a raised issue: https://github.com/immersive-web/marker-tracking/issues/2

imageTracking.on('error', function(err) { }); // fired when image tracking encountered an error

// pc.XrTrackedImage
trackedImage.image // image that been provided for tracking
trackedImage.width // width that been provided, can be changed outside of AR session
trackedImage.trackable // True if image is trackable. It might be untrackable by underlying system if image was provided is not meeting some requirements, like: at least 300x300 resolution.
trackedImage.tracking // True if image is tracking, or False if image tracking is lost.
trackedImage.emulated // True if image is not actively tracking, but recently was actively tracked, and transformation is emulated by underlying system

trackedImage.getPosition(); // get world space position of tracked image
trackedImage.getRotation(); // get world space rotation of tracked image

trackedImage.on('tracked', function() { }); // fired when image becomes actively tracked
trackedImage.on('untracked', function() { }); // fired when image is no more tracked

Test project:

https://playcanvas.com/project/739875/overview/ar-image-tracking
In order to test, fork project, and replace example images with desired ones.

Video:

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

I confirm I have signed the Contributor License Agreement.

@LeXXik
Copy link
Contributor

LeXXik commented Dec 30, 2020

This is a great contribution and really appreciated! I don't think Playcanvas would have WebXR support at the level it is today without Maksims PRs. This also made me think, what would happen if we don't have Maksims available tomorrow for one reason or another? Is there anyone else in the team, who would be able to take over the support of experimental API to make sure the main branch doesn't break after the API changes? Would it make sense to move WebXR to own branch, until WebXR API is stable or perhaps implement only approved API?

@Maksims
Copy link
Contributor Author

Maksims commented Dec 30, 2020

Good concerns @LeXXik, although, not planning to go anywhere ;)
The integration in engine is developed that way, that only affects users who actually start XR Session, so all those experimental APIs, do not affect non XR developers.

Also, WebXR core API is stable, although there are various API extensions are delivered as separate specs. They should be evaluated on individual basis. I'm actually planning to potentially change current way of session start, where developer have to specify which APIs he want optionally to enable, that way when starting XR session, it will be barebones, with options to make it more feature rich.

@willeastcott willeastcott self-assigned this Dec 30, 2020
@willeastcott willeastcott requested a review from a team December 30, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: xr XR related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants