Bladeren bron

Updated builds

Mr.doob 5 jaren geleden
bovenliggende
commit
f9630d64e5
3 gewijzigde bestanden met toevoegingen van 360 en 333 verwijderingen
  1. 33 16
      build/three.js
  2. 294 301
      build/three.min.js
  3. 33 16
      build/three.module.js

+ 33 - 16
build/three.js

@@ -22763,7 +22763,7 @@
 
 			var gamepads = navigator.getGamepads && navigator.getGamepads();
 
-			for ( var i = 0, j = 0, l = gamepads.length; i < l; i ++ ) {
+			for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
 
 				var gamepad = gamepads[ i ];
 
@@ -22773,9 +22773,10 @@
 					gamepad.id.startsWith( 'HTC Vive Focus' ) ||
 					gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
 
-					if ( j === id ) { return gamepad; }
+					var hand = gamepad.hand;
 
-					j ++;
+					if ( id === 0 && ( hand === '' || hand === 'right' ) ) { return gamepad; }
+					if ( id === 1 && ( hand === 'left' ) ) { return gamepad; }
 
 				}
 
@@ -23096,7 +23097,7 @@
 		var pose = null;
 
 		var controllers = [];
-		var inputSources = [];
+		var sortedInputSources = [];
 
 		function isPresenting() {
 
@@ -23146,7 +23147,7 @@
 
 			for ( var i = 0; i < controllers.length; i ++ ) {
 
-				if ( inputSources[ i ] === event.inputSource ) {
+				if ( sortedInputSources[ i ] === event.inputSource ) {
 
 					controllers[ i ].dispatchEvent( { type: event.type } );
 
@@ -23213,25 +23214,41 @@
 
 				//
 
-				inputSources = session.inputSources;
+				session.addEventListener( 'inputsourceschange', updateInputSources );
 
-				session.addEventListener( 'inputsourceschange', function () {
+				updateInputSources();
 
-					inputSources = session.inputSources;
-					console.log( inputSources );
+			}
 
-					for ( var i = 0; i < controllers.length; i ++ ) {
+		};
 
-						var controller = controllers[ i ];
-						controller.userData.inputSource = inputSources[ i ];
+		function updateInputSources() {
 
-					}
+			for ( var i = 0; i < controllers.length; i ++ ) {
 
-				} );
+				sortedInputSources[ i ] = findInputSource( i );
 
 			}
 
-		};
+		}
+
+		function findInputSource( id ) {
+
+			var inputSources = session.inputSources;
+
+			for ( var i = 0; i < inputSources.length; i ++ ) {
+
+				var inputSource = inputSources[ i ];
+				var handedness = inputSource.handedness;
+
+				if ( id === 0 && ( handedness === 'none' || handedness === 'right' ) ) { return inputSource; }
+				if ( id === 1 && ( handedness === 'left' ) ) { return inputSource; }
+
+			}
+
+		}
+
+		//
 
 		function updateCamera( camera, parent ) {
 
@@ -23330,7 +23347,7 @@
 
 				var controller = controllers[ i ];
 
-				var inputSource = inputSources[ i ];
+				var inputSource = sortedInputSources[ i ];
 
 				if ( inputSource ) {
 

File diff suppressed because it is too large
+ 294 - 301
build/three.min.js


+ 33 - 16
build/three.module.js

@@ -22750,7 +22750,7 @@ function WebVRManager( renderer ) {
 
 		var gamepads = navigator.getGamepads && navigator.getGamepads();
 
-		for ( var i = 0, j = 0, l = gamepads.length; i < l; i ++ ) {
+		for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
 
 			var gamepad = gamepads[ i ];
 
@@ -22760,9 +22760,10 @@ function WebVRManager( renderer ) {
 				gamepad.id.startsWith( 'HTC Vive Focus' ) ||
 				gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
 
-				if ( j === id ) return gamepad;
+				var hand = gamepad.hand;
 
-				j ++;
+				if ( id === 0 && ( hand === '' || hand === 'right' ) ) return gamepad;
+				if ( id === 1 && ( hand === 'left' ) ) return gamepad;
 
 			}
 
@@ -23083,7 +23084,7 @@ function WebXRManager( renderer, gl ) {
 	var pose = null;
 
 	var controllers = [];
-	var inputSources = [];
+	var sortedInputSources = [];
 
 	function isPresenting() {
 
@@ -23133,7 +23134,7 @@ function WebXRManager( renderer, gl ) {
 
 		for ( var i = 0; i < controllers.length; i ++ ) {
 
-			if ( inputSources[ i ] === event.inputSource ) {
+			if ( sortedInputSources[ i ] === event.inputSource ) {
 
 				controllers[ i ].dispatchEvent( { type: event.type } );
 
@@ -23200,25 +23201,41 @@ function WebXRManager( renderer, gl ) {
 
 			//
 
-			inputSources = session.inputSources;
+			session.addEventListener( 'inputsourceschange', updateInputSources );
 
-			session.addEventListener( 'inputsourceschange', function () {
+			updateInputSources();
 
-				inputSources = session.inputSources;
-				console.log( inputSources );
+		}
 
-				for ( var i = 0; i < controllers.length; i ++ ) {
+	};
 
-					var controller = controllers[ i ];
-					controller.userData.inputSource = inputSources[ i ];
+	function updateInputSources() {
 
-				}
+		for ( var i = 0; i < controllers.length; i ++ ) {
 
-			} );
+			sortedInputSources[ i ] = findInputSource( i );
 
 		}
 
-	};
+	}
+
+	function findInputSource( id ) {
+
+		var inputSources = session.inputSources;
+
+		for ( var i = 0; i < inputSources.length; i ++ ) {
+
+			var inputSource = inputSources[ i ];
+			var handedness = inputSource.handedness;
+
+			if ( id === 0 && ( handedness === 'none' || handedness === 'right' ) ) return inputSource;
+			if ( id === 1 && ( handedness === 'left' ) ) return inputSource;
+
+		}
+
+	}
+
+	//
 
 	function updateCamera( camera, parent ) {
 
@@ -23317,7 +23334,7 @@ function WebXRManager( renderer, gl ) {
 
 			var controller = controllers[ i ];
 
-			var inputSource = inputSources[ i ];
+			var inputSource = sortedInputSources[ i ];
 
 			if ( inputSource ) {
 

Some files were not shown because too many files changed in this diff