Skip to content

Commit

Permalink
Save window.requestAnimationFrame to prevent recursion in Unity WebVR…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsantell committed Feb 23, 2018
1 parent 18251cf commit 6f6a0c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var nextDisplayId = 1000;
var defaultLeftBounds = [0, 0, 0.5, 1];
var defaultRightBounds = [0.5, 0, 0.5, 1];

var raf = window.requestAnimationFrame;
var caf = window.cancelAnimationFrame;

/**
* The base class for all VR frame data.
*/
Expand Down Expand Up @@ -146,11 +149,11 @@ VRDisplay.prototype.getImmediatePose = function() {
};

VRDisplay.prototype.requestAnimationFrame = function(callback) {
return window.requestAnimationFrame(callback);
return raf(callback);
};

VRDisplay.prototype.cancelAnimationFrame = function(id) {
return window.cancelAnimationFrame(id);
return caf(id);
};

VRDisplay.prototype.wrapForFullscreen = function(element) {
Expand Down

0 comments on commit 6f6a0c1

Please sign in to comment.