瀏覽代碼

Use the first VR position sensor we see.

This fixes things for Firefox since the latest builds include both an
Oculus device and a Cardboard device, even if you're on a desktop PC.
Brian Peiris 10 年之前
父節點
當前提交
329082c70d
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      examples/js/controls/VRControls.js

+ 5 - 3
examples/js/controls/VRControls.js

@@ -19,13 +19,15 @@ THREE.VRControls = function ( object, onError ) {
 
 
 				vrInputs.push( devices[ i ] );
 				vrInputs.push( devices[ i ] );
 
 
+				break; // We keep the first we encounter
+
 			}
 			}
 
 
 		}
 		}
 
 
 		if ( onError ) onError( 'HMD not available' );
 		if ( onError ) onError( 'HMD not available' );
 
 
-	};
+	}
 
 
 	if ( navigator.getVRDevices ) {
 	if ( navigator.getVRDevices ) {
 
 
@@ -41,7 +43,7 @@ THREE.VRControls = function ( object, onError ) {
 
 
 	this.update = function () {
 	this.update = function () {
 
 
-		for ( var i = 0; i < vrInputs.length; i++ ) {
+		for ( var i = 0; i < vrInputs.length; i ++ ) {
 
 
 			var vrInput = vrInputs[ i ];
 			var vrInput = vrInputs[ i ];
 
 
@@ -65,7 +67,7 @@ THREE.VRControls = function ( object, onError ) {
 
 
 	this.resetSensor = function () {
 	this.resetSensor = function () {
 
 
-		for ( var i = 0; i < vrInputs.length; i++ ) {
+		for ( var i = 0; i < vrInputs.length; i ++ ) {
 
 
 			var vrInput = vrInputs[ i ];
 			var vrInput = vrInputs[ i ];