Explorar o código

Updated builds.

Mr.doob %!s(int64=5) %!d(string=hai) anos
pai
achega
4ddd90c97c
Modificáronse 3 ficheiros con 476 adicións e 432 borrados
  1. 58 36
      build/three.js
  2. 360 360
      build/three.min.js
  3. 58 36
      build/three.module.js

+ 58 - 36
build/three.js

@@ -22863,13 +22863,7 @@
 		var pose = null;
 
 		var controllers = [];
-		var sortedInputSources = [];
-
-		function isPresenting() {
-
-			return session !== null && referenceSpace !== null;
-
-		}
+		var inputSourcesMap = new Map();
 
 		//
 
@@ -22889,6 +22883,8 @@
 
 		this.enabled = false;
 
+		this.isPresenting = false;
+
 		this.getController = function ( id ) {
 
 			var controller = controllers[ id ];
@@ -22911,13 +22907,11 @@
 
 		function onSessionEvent( event ) {
 
-			for ( var i = 0; i < controllers.length; i ++ ) {
+			var controller = inputSourcesMap.get( event.inputSource );
 
-				if ( sortedInputSources[ i ] === event.inputSource ) {
+			if ( controller ) {
 
-					controllers[ i ].dispatchEvent( { type: event.type } );
-
-				}
+				controller.dispatchEvent( { type: event.type } );
 
 			}
 
@@ -22925,12 +22919,24 @@
 
 		function onSessionEnd() {
 
+			inputSourcesMap.forEach( function ( controller, inputSource ) {
+
+				controller.dispatchEvent( { type: 'disconnected', data: inputSource } );
+
+			} );
+
+			inputSourcesMap.clear();
+
+			//
+
 			renderer.setFramebuffer( null );
 			renderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830
 			animation.stop();
 
 			scope.dispatchEvent( { type: 'sessionend' } );
 
+			scope.isPresenting = false;
+
 		}
 
 		function onRequestReferenceSpace( value ) {
@@ -22942,6 +22948,8 @@
 
 			scope.dispatchEvent( { type: 'sessionstart' } );
 
+			scope.isPresenting = true;
+
 		}
 
 		this.setFramebufferScaleFactor = function ( /* value */ ) {
@@ -22996,33 +23004,52 @@
 
 				session.addEventListener( 'inputsourceschange', updateInputSources );
 
-				updateInputSources();
-
 			}
 
 		};
 
-		function updateInputSources() {
+		function updateInputSources( event ) {
+
+			console.log( 'inputsourceschange', event, session.inputSources );
+
+			var inputSources = session.inputSources;
+
+			// Assign inputSources to available controllers
 
 			for ( var i = 0; i < controllers.length; i ++ ) {
 
-				sortedInputSources[ i ] = findInputSource( i );
+				inputSourcesMap.set( inputSources[ i ], controllers[ i ] );
 
 			}
 
-		}
+			// Notify disconnected
 
-		function findInputSource( id ) {
+			for ( var i = 0; i < event.removed.length; i ++ ) {
 
-			var inputSources = session.inputSources;
+				var inputSource = event.removed[ i ];
+				var controller = inputSourcesMap.get( inputSource );
 
-			for ( var i = 0; i < inputSources.length; i ++ ) {
+				if ( controller ) {
 
-				var inputSource = inputSources[ i ];
-				var handedness = inputSource.handedness;
+					controller.dispatchEvent( { type: 'disconnected', data: inputSource } );
+					inputSourcesMap.delete( inputSource );
 
-				if ( id === 0 && ( handedness === 'none' || handedness === 'right' ) ) { return inputSource; }
-				if ( id === 1 && ( handedness === 'left' ) ) { return inputSource; }
+				}
+
+			}
+
+			// Notify connected
+
+			for ( var i = 0; i < event.added.length; i ++ ) {
+
+				var inputSource = event.added[ i ];
+				var controller = inputSourcesMap.get( inputSource );
+
+				if ( controller ) {
+
+					controller.dispatchEvent( { type: 'connected', data: inputSource } );
+
+				}
 
 			}
 
@@ -23137,8 +23164,6 @@
 
 		};
 
-		this.isPresenting = isPresenting;
-
 		// Animation Loop
 
 		var onAnimationFrameCallback = null;
@@ -23177,11 +23202,13 @@
 
 			//
 
+			var inputSources = session.inputSources;
+
 			for ( var i = 0; i < controllers.length; i ++ ) {
 
 				var controller = controllers[ i ];
 
-				var inputSource = sortedInputSources[ i ];
+				var inputSource = inputSources[ i ];
 
 				if ( inputSource ) {
 
@@ -23191,12 +23218,7 @@
 
 						controller.matrix.fromArray( inputPose.transform.matrix );
 						controller.matrix.decompose( controller.position, controller.rotation, controller.scale );
-
-						if ( inputSource.targetRayMode === 'pointing' ) {
-
-							controller.visible = true;
-
-						}
+						controller.visible = true;
 
 						continue;
 
@@ -23567,7 +23589,7 @@
 
 		this.setSize = function ( width, height, updateStyle ) {
 
-			if ( xr.isPresenting() ) {
+			if ( xr.isPresenting ) {
 
 				console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
 				return;
@@ -24272,7 +24294,7 @@
 
 		function onAnimationFrame( time ) {
 
-			if ( xr.isPresenting() ) { return; }
+			if ( xr.isPresenting ) { return; }
 			if ( onAnimationFrameCallback ) { onAnimationFrameCallback( time ); }
 
 		}
@@ -24336,7 +24358,7 @@
 
 			if ( camera.parent === null ) { camera.updateMatrixWorld(); }
 
-			if ( xr.enabled && xr.isPresenting() ) {
+			if ( xr.enabled && xr.isPresenting ) {
 
 				camera = xr.getCamera( camera );
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 360 - 360
build/three.min.js


+ 58 - 36
build/three.module.js

@@ -22855,13 +22855,7 @@ function WebXRManager( renderer, gl ) {
 	var pose = null;
 
 	var controllers = [];
-	var sortedInputSources = [];
-
-	function isPresenting() {
-
-		return session !== null && referenceSpace !== null;
-
-	}
+	var inputSourcesMap = new Map();
 
 	//
 
@@ -22881,6 +22875,8 @@ function WebXRManager( renderer, gl ) {
 
 	this.enabled = false;
 
+	this.isPresenting = false;
+
 	this.getController = function ( id ) {
 
 		var controller = controllers[ id ];
@@ -22903,13 +22899,11 @@ function WebXRManager( renderer, gl ) {
 
 	function onSessionEvent( event ) {
 
-		for ( var i = 0; i < controllers.length; i ++ ) {
+		var controller = inputSourcesMap.get( event.inputSource );
 
-			if ( sortedInputSources[ i ] === event.inputSource ) {
+		if ( controller ) {
 
-				controllers[ i ].dispatchEvent( { type: event.type } );
-
-			}
+			controller.dispatchEvent( { type: event.type } );
 
 		}
 
@@ -22917,12 +22911,24 @@ function WebXRManager( renderer, gl ) {
 
 	function onSessionEnd() {
 
+		inputSourcesMap.forEach( function ( controller, inputSource ) {
+
+			controller.dispatchEvent( { type: 'disconnected', data: inputSource } );
+
+		} );
+
+		inputSourcesMap.clear();
+
+		//
+
 		renderer.setFramebuffer( null );
 		renderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830
 		animation.stop();
 
 		scope.dispatchEvent( { type: 'sessionend' } );
 
+		scope.isPresenting = false;
+
 	}
 
 	function onRequestReferenceSpace( value ) {
@@ -22934,6 +22940,8 @@ function WebXRManager( renderer, gl ) {
 
 		scope.dispatchEvent( { type: 'sessionstart' } );
 
+		scope.isPresenting = true;
+
 	}
 
 	this.setFramebufferScaleFactor = function ( /* value */ ) {
@@ -22988,33 +22996,52 @@ function WebXRManager( renderer, gl ) {
 
 			session.addEventListener( 'inputsourceschange', updateInputSources );
 
-			updateInputSources();
-
 		}
 
 	};
 
-	function updateInputSources() {
+	function updateInputSources( event ) {
+
+		console.log( 'inputsourceschange', event, session.inputSources );
+
+		var inputSources = session.inputSources;
+
+		// Assign inputSources to available controllers
 
 		for ( var i = 0; i < controllers.length; i ++ ) {
 
-			sortedInputSources[ i ] = findInputSource( i );
+			inputSourcesMap.set( inputSources[ i ], controllers[ i ] );
 
 		}
 
-	}
+		// Notify disconnected
 
-	function findInputSource( id ) {
+		for ( var i = 0; i < event.removed.length; i ++ ) {
 
-		var inputSources = session.inputSources;
+			var inputSource = event.removed[ i ];
+			var controller = inputSourcesMap.get( inputSource );
 
-		for ( var i = 0; i < inputSources.length; i ++ ) {
+			if ( controller ) {
 
-			var inputSource = inputSources[ i ];
-			var handedness = inputSource.handedness;
+				controller.dispatchEvent( { type: 'disconnected', data: inputSource } );
+				inputSourcesMap.delete( inputSource );
 
-			if ( id === 0 && ( handedness === 'none' || handedness === 'right' ) ) return inputSource;
-			if ( id === 1 && ( handedness === 'left' ) ) return inputSource;
+			}
+
+		}
+
+		// Notify connected
+
+		for ( var i = 0; i < event.added.length; i ++ ) {
+
+			var inputSource = event.added[ i ];
+			var controller = inputSourcesMap.get( inputSource );
+
+			if ( controller ) {
+
+				controller.dispatchEvent( { type: 'connected', data: inputSource } );
+
+			}
 
 		}
 
@@ -23129,8 +23156,6 @@ function WebXRManager( renderer, gl ) {
 
 	};
 
-	this.isPresenting = isPresenting;
-
 	// Animation Loop
 
 	var onAnimationFrameCallback = null;
@@ -23169,11 +23194,13 @@ function WebXRManager( renderer, gl ) {
 
 		//
 
+		var inputSources = session.inputSources;
+
 		for ( var i = 0; i < controllers.length; i ++ ) {
 
 			var controller = controllers[ i ];
 
-			var inputSource = sortedInputSources[ i ];
+			var inputSource = inputSources[ i ];
 
 			if ( inputSource ) {
 
@@ -23183,12 +23210,7 @@ function WebXRManager( renderer, gl ) {
 
 					controller.matrix.fromArray( inputPose.transform.matrix );
 					controller.matrix.decompose( controller.position, controller.rotation, controller.scale );
-
-					if ( inputSource.targetRayMode === 'pointing' ) {
-
-						controller.visible = true;
-
-					}
+					controller.visible = true;
 
 					continue;
 
@@ -23559,7 +23581,7 @@ function WebGLRenderer( parameters ) {
 
 	this.setSize = function ( width, height, updateStyle ) {
 
-		if ( xr.isPresenting() ) {
+		if ( xr.isPresenting ) {
 
 			console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
 			return;
@@ -24264,7 +24286,7 @@ function WebGLRenderer( parameters ) {
 
 	function onAnimationFrame( time ) {
 
-		if ( xr.isPresenting() ) return;
+		if ( xr.isPresenting ) return;
 		if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
 
 	}
@@ -24328,7 +24350,7 @@ function WebGLRenderer( parameters ) {
 
 		if ( camera.parent === null ) camera.updateMatrixWorld();
 
-		if ( xr.enabled && xr.isPresenting() ) {
+		if ( xr.enabled && xr.isPresenting ) {
 
 			camera = xr.getCamera( camera );
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio