From 6f6a0c1e8b28eb4a3c861aeab4f814e93207fb85 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Fri, 23 Feb 2018 10:03:52 -0800 Subject: [PATCH] Save window.requestAnimationFrame to prevent recursion in Unity WebVR exporter immersive-web/webvr-polyfill#308 --- src/base.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/base.js b/src/base.js index 3de0a35..bd2ac32 100644 --- a/src/base.js +++ b/src/base.js @@ -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. */ @@ -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) {