Browse Source

Merge pull request #6380 from brianpeiris/patch-1

Fix for Firefox WebVR (again)
Ricardo Cabello 10 years ago
parent
commit
8d4ad6948d
2 changed files with 6 additions and 8 deletions
  1. 3 7
      examples/js/controls/VRControls.js
  2. 3 1
      examples/vr_cubes.html

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

@@ -11,15 +11,11 @@ THREE.VRControls = function ( object, onError ) {
 
 	function filterInvalidDevices( devices ) {
 
-		var
-			OculusDeviceName = 'VR Position Device (oculus)',
-			CardboardDeviceName = 'VR Position Device (cardboard)';
-
-
 		// Exclude Cardboard position sensor if Oculus exists.
+
 		var oculusDevices = devices.filter( function ( device ) {
 
-			return device.deviceName === OculusDeviceName;
+			return device.deviceName.toLowerCase().indexOf('oculus') !== -1;
 
 		} );
 
@@ -27,7 +23,7 @@ THREE.VRControls = function ( object, onError ) {
 
 			return devices.filter( function ( device ) {
 
-				return device.deviceName !== CardboardDeviceName;
+				return device.deviceName.toLowerCase().indexOf('cardboard') === -1;
 
 			} );
 

+ 3 - 1
examples/vr_cubes.html

@@ -58,6 +58,7 @@
 			var vrEffect;
 			var vrControls;
 
+			var cubes = [];
 			var INTERSECTED;
 			var radius = 100, theta = 0;
 			var crosshair;
@@ -115,6 +116,7 @@
 					object.scale.z = Math.random() + 0.5;
 
 					scene.add( object );
+					cubes.push( object );
 
 				}
 
@@ -188,7 +190,7 @@
 
 				raycaster.setFromCamera( { x: 0, y: 0 }, camera );
 
-				var intersects = raycaster.intersectObjects( scene.children );
+				var intersects = raycaster.intersectObjects( cubes );
 
 				if ( intersects.length > 0 ) {