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

redo #2991: extend PR #2985 (moved canvas init) to also solve issue #2967 (vr2vr traversal in Oculus Browser) #2996

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ module.exports.AScene = registerElement('a-scene', {
this.exitVRBound = function () { self.exitVR(); };
this.exitVRTrueBound = function () { self.exitVR(true); };

// Enter VR on `vrdisplayactivate` (e.g. putting on Rift headset).
window.addEventListener('vrdisplayactivate', this.enterVRBound);
// There is already a listener for `vrdisplayactivate` (e.g. putting on Rift headset),
// since that event is also used for in-VR traversal, much earlier in the lifecycle.

// Exit VR on `vrdisplaydeactivate` (e.g. taking off Rift headset).
window.addEventListener('vrdisplaydeactivate', this.exitVRBound);
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ module.exports = window.AFRAME = {
utils: utils,
version: pkg.version
};

// Enter VR on `vrdisplayactivate`, to handle in-VR traversal much earlier in the lifecycle.
// This event may also fire in other circumstances (e.g. putting on the Rift headset).
window.addEventListener('vrdisplayactivate', function (evt) {
var s = window.AFRAME.scenes[0];
if (s.effect) { s.enterVR(); } else { setTimeout(s.enterVRBound); }
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it is guaranteed that in the next tick the effect is going to be defined. I'm trying to find a more robust way to do this.

Copy link
Member

@dmarcos dmarcos Aug 29, 2017

Choose a reason for hiding this comment

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

Also is not what I would expect the event to behave following the spec. The user action policy should not apply to the next tick logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you find a more robust way, great. I tried several things and did not find another way for gesture permission to survive. See WICG/interventions#12

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(More specifically, WICG/interventions#12 (comment))

});