1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /**
- * @author mrdoob / http://mrdoob.com
- * Based on @tojiro's vr-samples-utils.js
- */
- var WEBVR = {
- button: function ( effect ) {
- var button = document.createElement( 'button' );
- button.style.position = 'absolute';
- button.style.left = 'calc(50% - 30px)';
- button.style.bottom = '20px';
- button.style.border = '0';
- button.style.padding = '8px';
- button.style.cursor = 'pointer';
- button.style.backgroundColor = '#000';
- button.style.color = '#fff';
- button.style.fontFamily = 'sans-serif';
- button.style.fontSize = '13px';
- button.style.fontStyle = 'normal';
- button.style.zIndex = '999';
- button.textContent = 'ENTER VR';
- button.onclick = function() {
- effect.setFullScreen( true );
- };
- document.body.appendChild( button );
- },
- test: function () {
- var message;
- if ( navigator.getVRDisplays ) {
- navigator.getVRDisplays().then( function ( displays ) {
- if ( displays.length === 0 ) message = 'WebVR supported, but no VRDisplays found.';
- } );
- } else if ( navigator.getVRDevices ) {
- message = 'Your browser supports WebVR but not the latest version. See <a href="http://webvr.info">webvr.info</a> for more info.';
- } else {
- message = 'Your browser does not support WebVR. See <a href="http://webvr.info">webvr.info</a> for assistance.';
- }
- if ( message !== undefined ) {
- var container = document.createElement( 'div' );
- container.style.position = 'absolute';
- container.style.left = '0';
- container.style.top = '0';
- container.style.right = '0';
- container.style.zIndex = '999';
- container.align = 'center';
- document.body.appendChild( container );
- var error = document.createElement( 'div' );
- error.style.fontFamily = 'sans-serif';
- error.style.fontSize = '16px';
- error.style.fontStyle = 'normal';
- error.style.lineHeight = '26px';
- error.style.backgroundColor = '#fff';
- error.style.color = '#000';
- error.style.padding = '10px 20px';
- error.style.margin = '40px';
- error.style.display = 'inline-block';
- error.innerHTML = message;
- container.appendChild( error );
- }
- }
- };
|