|
@@ -142,6 +142,8 @@
|
|
|
|
|
|
//
|
|
|
|
|
|
+ window.addEventListener( 'vrdisplaypointerrestricted', onPointerRestricted, false );
|
|
|
+ window.addEventListener( 'vrdisplaypointerunrestricted', onPointerUnrestricted, false );
|
|
|
window.addEventListener( 'resize', onWindowResize, false );
|
|
|
|
|
|
}
|
|
@@ -158,6 +160,22 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function onPointerRestricted() {
|
|
|
+ var pointerLockElement = renderer.domElement;
|
|
|
+ if ( pointerLockElement && typeof(pointerLockElement.requestPointerLock) === 'function' ) {
|
|
|
+ pointerLockElement.requestPointerLock();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function onPointerUnrestricted() {
|
|
|
+ var currentPointerLockElement = document.pointerLockElement;
|
|
|
+ var expectedPointerLockElement = renderer.domElement;
|
|
|
+ if ( currentPointerLockElement && currentPointerLockElement === expectedPointerLockElement && typeof(document.exitPointerLock) === 'function' ) {
|
|
|
+ document.exitPointerLock();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function onWindowResize() {
|
|
|
|
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|