|
@@ -24,12 +24,7 @@ var WEBVR = {
|
|
|
|
|
|
navigator.getVRDisplays()
|
|
|
.then( function ( displays ) {
|
|
|
-
|
|
|
onDisplay( displays[ 0 ] );
|
|
|
-
|
|
|
- } )
|
|
|
- .catch( function () {
|
|
|
- // no displays
|
|
|
} );
|
|
|
|
|
|
}
|
|
@@ -83,12 +78,20 @@ var WEBVR = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- getButton: function ( effect, canvas ) {
|
|
|
+ getButton: function ( display, canvas ) {
|
|
|
+
|
|
|
+ if ( display instanceof VRDisplay === false ) {
|
|
|
+
|
|
|
+ console.error( 'WebVR.getButton() now expects a VRDisplay.' );
|
|
|
+ return document.createElement( 'button' );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
var button = document.createElement( 'button' );
|
|
|
button.style.position = 'absolute';
|
|
|
button.style.left = 'calc(50% - 50px)';
|
|
|
button.style.bottom = '20px';
|
|
|
+ button.style.width = '100px';
|
|
|
button.style.border = '0';
|
|
|
button.style.padding = '8px';
|
|
|
button.style.cursor = 'pointer';
|
|
@@ -100,18 +103,18 @@ var WEBVR = {
|
|
|
button.style.textAlign = 'center';
|
|
|
button.style.zIndex = '999';
|
|
|
|
|
|
- if ( effect.getVRDisplay() ) {
|
|
|
+ if ( display ) {
|
|
|
|
|
|
button.textContent = 'ENTER VR';
|
|
|
button.onclick = function () {
|
|
|
|
|
|
- effect.isPresenting ? effect.exitPresent() : effect.requestPresent( [ { source: canvas } ] );
|
|
|
+ display.isPresenting ? display.exitPresent() : display.requestPresent( [ { source: canvas } ] );
|
|
|
|
|
|
};
|
|
|
|
|
|
window.addEventListener( 'vrdisplaypresentchange', function () {
|
|
|
|
|
|
- button.textContent = effect.isPresenting ? 'EXIT VR' : 'ENTER VR';
|
|
|
+ button.textContent = display.isPresenting ? 'EXIT VR' : 'ENTER VR';
|
|
|
|
|
|
}, false );
|
|
|
|