-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 Support #1834
WebXR Support #1834
Conversation
Some progress here, added ability to choose session type. Tested AR on Android with chrome://flags/#webxr enabled. Surprised to see how well it works already. |
This PR already implements what WebVR was providing - starting/ending XR sessions. So this can be merged, as it will provide ability to start experimenting with VR/AR. Basic example: var XrBasic = pc.createScript('xrBasic');
// entity with button element
XrBasic.attributes.add('button', {
type: 'entity'
});
// entity with camera component
XrBasic.attributes.add('cameraEntity', {
type: 'entity'
});
XrBasic.prototype.initialize = function() {
// click button
this.button.element.on('click', function() {
// check support
if (this.app.xr.isAvailable(pc.XRTYPE_VR)) {
// start session
this.cameraEntity.camera.startXr(pc.XRTYPE_VR);
}
}, this);
}; |
Great stuff! The unit tests are failing. Can you fix please? |
Added deprecation warnings, and fixed tests. |
Excellent. Can you also update this please: https://github.com/playcanvas/engine/blob/master/examples/graphics/virtual-reality.html Maybe even consider creating a new subfolder 'xr' and move it there (we'll probably add an AR and other related examples too!). 😄 |
A few lint errors. You can auto-fix most/all:
|
Fixed lint and added two examples for basic VR and basic AR. |
Hm, noticed one issue with Box Projected CubeMaps, they are not projected correctly in VR. |
Interesting. Screenshot? |
Fixed normals issue. I believe this is ready now. |
This is great - we're so close to merging. Last outstanding thing for me: If I merged this and deployed as v1.25.0, what will VR developers face? Especially those with PlayCanvas projects based on the old WebVR integration?
|
Currently this PR only enough for HMD (including mobile). WebVR is getting deprecated in most browsers, new Chrome wont even have its support behind the flag.
We will need migration guide once we have all the functionality in place.
Previously, WebVR had controllers implemented through GamePad API. WebXR implements own interfaces to interact with physical devices (even mouse and touch) and is done through XRInputSource. We can deprecate WebVR later, and deploy this, allowing developers to play with WebXR straight away. Later deprecate WebVR, as browsers slowly deprecate its APIs as well. |
Updated: WebVR is brought back. So we will deprecate it later. |
I definitely like how you've simplified some of the API now - nice move. |
Tested on Oculus Quest, works as intended. |
* master: (31 commits) WebXR Input Sources (playcanvas#1873) Simplified constants definition in Math classes (playcanvas#1876) Improve batching to handle 8-bit and 32-bit index buffers (playcanvas#1872) Add particle start frame example to browser [FIX] Update WebXR examples to use latest enums (playcanvas#1870) [FIX] Add XRWebGLLayer to externs for Closure compiler (playcanvas#1869) update paths in the particle system start frame example (playcanvas#1868) add a animation start frame variable to the particle system which def… (playcanvas#1864) point cloud example using engine directly, and custom shader changing size and color of points (playcanvas#1867) WebXR Support (playcanvas#1834) Hardware Instancing fixes / sample (playcanvas#1846) (playcanvas#1856) [VERSION] v1.25.0-dev [RELEASE] v1.24.7 Recompiled basis, now works on IE (playcanvas#1865) Small mesh cleanup (playcanvas#1866) [FIX] Revert memory-leak change (playcanvas#1862) [FIX] Flag model as immutable when it's added to a ModelComponent (playcanvas#1861) [FIX] Fix calculation of deprecated pc.MouseEvent#wheel (playcanvas#1859) [DOCS] Adjust Vec3.normalize docs to reflect behavior better (playcanvas#1849) pc.BatchManager.markGroupDirty is now public (playcanvas#1848) ...
This PR removes VR APIs from engine, and adds XR support.
Currently it implements only starting/ending XR sessions (VR/AR). Input devices and reference space features will be added in another PR.
New APIs:
Fixes #1748
I confirm I have signed the Contributor License Agreement.