(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WebVRManager = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o %s', this.mode, mode); this.mode = mode; this.button.setMode(mode, this.isVRCompatible); // Emit an event indicating the mode changed. this.emit('modechange', mode, oldMode); }; /** * Main button was clicked. */ WebVRManager.prototype.onFSClick_ = function() { switch (this.mode) { case Modes.NORMAL: // TODO: Remove this hack if/when iOS gets real fullscreen mode. // If this is an iframe on iOS, break out and open in no_fullscreen mode. if (Util.isIOS() && Util.isIFrame()) { if (this.fullscreenCallback) { this.fullscreenCallback(); } else { var url = window.location.href; url = Util.appendQueryParameter(url, 'no_fullscreen', 'true'); url = Util.appendQueryParameter(url, 'start_mode', Modes.MAGIC_WINDOW); top.location.href = url; return; } } this.setMode_(Modes.MAGIC_WINDOW); this.requestFullscreen_(); break; case Modes.MAGIC_WINDOW: if (this.isFullscreenDisabled) { window.history.back(); return; } if (this.exitFullscreenCallback) { this.exitFullscreenCallback(); } this.setMode_(Modes.NORMAL); this.exitFullscreen_(); break; } }; /** * The VR button was clicked. */ WebVRManager.prototype.onVRClick_ = function() { // TODO: Remove this hack when iOS has fullscreen mode. // If this is an iframe on iOS, break out and open in no_fullscreen mode. if (this.mode == Modes.NORMAL && Util.isIOS() && Util.isIFrame()) { if (this.vrCallback) { this.vrCallback(); } else { var url = window.location.href; url = Util.appendQueryParameter(url, 'no_fullscreen', 'true'); url = Util.appendQueryParameter(url, 'start_mode', Modes.VR); top.location.href = url; return; } } this.enterVRMode_(); }; WebVRManager.prototype.requestFullscreen_ = function() { var canvas = document.body; //var canvas = this.renderer.domElement; if (canvas.requestFullscreen) { canvas.requestFullscreen(); } else if (canvas.mozRequestFullScreen) { canvas.mozRequestFullScreen(); } else if (canvas.webkitRequestFullscreen) { canvas.webkitRequestFullscreen(); } else if (canvas.msRequestFullscreen) { canvas.msRequestFullscreen(); } }; WebVRManager.prototype.exitFullscreen_ = function() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } }; WebVRManager.prototype.onVRDisplayPresentChange_ = function(e) { console.log('onVRDisplayPresentChange_', e); if (this.hmd.isPresenting) { this.setMode_(Modes.VR); } else { this.setMode_(Modes.NORMAL); } }; WebVRManager.prototype.onVRDisplayDeviceParamsChange_ = function(e) { console.log('onVRDisplayDeviceParamsChange_', e); }; WebVRManager.prototype.onFullscreenChange_ = function(e) { // If we leave full-screen, go back to normal mode. if (document.webkitFullscreenElement === null || document.mozFullScreenElement === null) { this.setMode_(Modes.NORMAL); } }; module.exports = WebVRManager; },{"./button-manager.js":1,"./emitter.js":2,"./modes.js":3,"./util.js":4}]},{},[5])(5) });