Browse Source

Updated builds.

Mr.doob 7 years ago
parent
commit
42049d3b7e
3 changed files with 462 additions and 319 deletions
  1. 112 41
      build/three.js
  2. 238 237
      build/three.min.js
  3. 112 41
      build/three.module.js

+ 112 - 41
build/three.js

@@ -21127,6 +21127,26 @@
 
 	}
 
+	/**
+	 * @author mrdoob / http://mrdoob.com/
+	 */
+
+	function Group() {
+
+		Object3D.call( this );
+
+		this.type = 'Group';
+
+	}
+
+	Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
+
+		constructor: Group,
+
+		isGroup: true
+
+	} );
+
 	/**
 	 * @author mrdoob / http://mrdoob.com/
 	 * @author greggman / http://games.greggman.com/
@@ -21463,6 +21483,13 @@
 		this.enabled = false;
 		this.userHeight = 1.6;
 
+		this.getController = function ( id ) {
+
+			console.warn( 'WebVRManager: getController() not yet implemented.' );
+			return new Group();
+
+		};
+
 		this.getDevice = function () {
 
 			return device;
@@ -21653,13 +21680,16 @@
 		var session = null;
 
 		var frameOfRef = null;
+		var inputSources = [];
 
 		var pose = null;
+		var controllers = {};
 
 		function isPresenting() {
 
 			return session !== null && frameOfRef !== null;
 
+
 		}
 
 		//
@@ -21680,6 +21710,23 @@
 
 		this.enabled = false;
 
+		this.getController = function ( id ) {
+
+			var controller = controllers[ id ];
+
+			if ( controller === undefined ) {
+
+				controller = new Group();
+				controller.matrixAutoUpdate = false;
+
+				controllers[ id ] = controller;
+
+			}
+
+			return controller;
+
+		};
+
 		this.getDevice = function () {
 
 			return device;
@@ -21696,18 +21743,30 @@
 
 		//
 
+		function onSessionEvent( event ) {
+
+			var controller = controllers[ inputSources.indexOf( event.inputSource ) ];
+			if ( controller ) controller.dispatchEvent( { type: event.type } );
+
+		}
+
+		function onSessionEnd () {
+
+			renderer.setFramebuffer( null );
+			animation.stop();
+
+		}
+
 		this.setSession = function ( value, options ) {
 
 			session = value;
 
 			if ( session !== null ) {
 
-				session.addEventListener( 'end', function () {
-
-					renderer.setFramebuffer( null );
-					animation.stop();
-
-				} );
+				session.addEventListener( 'select', onSessionEvent );
+				session.addEventListener( 'selectstart', onSessionEvent );
+				session.addEventListener( 'selectend', onSessionEvent );
+				session.addEventListener( 'end', onSessionEnd );
 
 				session.baseLayer = new XRWebGLLayer( session, gl );
 				session.requestFrameOfReference( options.frameOfReferenceType ).then( function ( value ) {
@@ -21721,6 +21780,17 @@
 
 				} );
 
+				//
+
+				inputSources = session.getInputSources();
+
+				session.addEventListener( 'inputsourceschange', function () {
+
+					inputSources = session.getInputSources();
+					console.log( inputSources );
+
+				} );
+
 			}
 
 		};
@@ -21788,28 +21858,49 @@
 
 			pose = frame.getDevicePose( frameOfRef );
 
-			var layer = session.baseLayer;
-			var views = frame.views;
+			if ( pose !== null ) {
+
+				var layer = session.baseLayer;
+				var views = frame.views;
 
-			for ( var i = 0; i < views.length; i ++ ) {
+				for ( var i = 0; i < views.length; i ++ ) {
 
-				var view = views[ i ];
-				var viewport = layer.getViewport( view );
-				var viewMatrix = pose.getViewMatrix( view );
+					var view = views[ i ];
+					var viewport = layer.getViewport( view );
+					var viewMatrix = pose.getViewMatrix( view );
 
-				var camera = cameraVR.cameras[ i ];
-				camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
-				camera.projectionMatrix.fromArray( view.projectionMatrix );
-				camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
+					var camera = cameraVR.cameras[ i ];
+					camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
+					camera.projectionMatrix.fromArray( view.projectionMatrix );
+					camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
 
-				if ( i === 0 ) {
+					if ( i === 0 ) {
 
-					cameraVR.matrix.copy( camera.matrix );
+						cameraVR.matrix.copy( camera.matrix );
 
-					// HACK (mrdoob)
-					// https://github.com/w3c/webvr/issues/203
+						// HACK (mrdoob)
+						// https://github.com/w3c/webvr/issues/203
 
-					cameraVR.projectionMatrix.copy( camera.projectionMatrix );
+						cameraVR.projectionMatrix.copy( camera.projectionMatrix );
+
+					}
+
+				}
+
+			}
+
+			//
+
+			for ( var i = 0; i < inputSources.length; i ++ ) {
+
+				var inputSource = inputSources[ i ];
+				var inputPose = frame.getInputPose( inputSource, frameOfRef );
+
+				if ( inputPose !== null && controllers[ i ] ) {
+
+					var controller = controllers[ i ];
+					controller.matrix.elements = inputPose.gripMatrix;
+					controller.matrix.decompose( controller.position, controller.rotation, controller.scale );
 
 				}
 
@@ -25779,26 +25870,6 @@
 
 	} );
 
-	/**
-	 * @author mrdoob / http://mrdoob.com/
-	 */
-
-	function Group() {
-
-		Object3D.call( this );
-
-		this.type = 'Group';
-
-	}
-
-	Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
-
-		constructor: Group,
-
-		isGroup: true
-
-	} );
-
 	/**
 	 * @author mrdoob / http://mrdoob.com/
 	 */

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


+ 112 - 41
build/three.module.js

@@ -21121,6 +21121,26 @@ function WebGLUtils( gl, extensions ) {
 
 }
 
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+function Group() {
+
+	Object3D.call( this );
+
+	this.type = 'Group';
+
+}
+
+Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
+
+	constructor: Group,
+
+	isGroup: true
+
+} );
+
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author greggman / http://games.greggman.com/
@@ -21457,6 +21477,13 @@ function WebVRManager( renderer ) {
 	this.enabled = false;
 	this.userHeight = 1.6;
 
+	this.getController = function ( id ) {
+
+		console.warn( 'WebVRManager: getController() not yet implemented.' );
+		return new Group();
+
+	};
+
 	this.getDevice = function () {
 
 		return device;
@@ -21647,13 +21674,16 @@ function WebXRManager( renderer ) {
 	var session = null;
 
 	var frameOfRef = null;
+	var inputSources = [];
 
 	var pose = null;
+	var controllers = {};
 
 	function isPresenting() {
 
 		return session !== null && frameOfRef !== null;
 
+
 	}
 
 	//
@@ -21674,6 +21704,23 @@ function WebXRManager( renderer ) {
 
 	this.enabled = false;
 
+	this.getController = function ( id ) {
+
+		var controller = controllers[ id ];
+
+		if ( controller === undefined ) {
+
+			controller = new Group();
+			controller.matrixAutoUpdate = false;
+
+			controllers[ id ] = controller;
+
+		}
+
+		return controller;
+
+	};
+
 	this.getDevice = function () {
 
 		return device;
@@ -21690,18 +21737,30 @@ function WebXRManager( renderer ) {
 
 	//
 
+	function onSessionEvent( event ) {
+
+		var controller = controllers[ inputSources.indexOf( event.inputSource ) ];
+		if ( controller ) controller.dispatchEvent( { type: event.type } );
+
+	}
+
+	function onSessionEnd () {
+
+		renderer.setFramebuffer( null );
+		animation.stop();
+
+	}
+
 	this.setSession = function ( value, options ) {
 
 		session = value;
 
 		if ( session !== null ) {
 
-			session.addEventListener( 'end', function () {
-
-				renderer.setFramebuffer( null );
-				animation.stop();
-
-			} );
+			session.addEventListener( 'select', onSessionEvent );
+			session.addEventListener( 'selectstart', onSessionEvent );
+			session.addEventListener( 'selectend', onSessionEvent );
+			session.addEventListener( 'end', onSessionEnd );
 
 			session.baseLayer = new XRWebGLLayer( session, gl );
 			session.requestFrameOfReference( options.frameOfReferenceType ).then( function ( value ) {
@@ -21715,6 +21774,17 @@ function WebXRManager( renderer ) {
 
 			} );
 
+			//
+
+			inputSources = session.getInputSources();
+
+			session.addEventListener( 'inputsourceschange', function () {
+
+				inputSources = session.getInputSources();
+				console.log( inputSources );
+
+			} );
+
 		}
 
 	};
@@ -21782,28 +21852,49 @@ function WebXRManager( renderer ) {
 
 		pose = frame.getDevicePose( frameOfRef );
 
-		var layer = session.baseLayer;
-		var views = frame.views;
+		if ( pose !== null ) {
+
+			var layer = session.baseLayer;
+			var views = frame.views;
 
-		for ( var i = 0; i < views.length; i ++ ) {
+			for ( var i = 0; i < views.length; i ++ ) {
 
-			var view = views[ i ];
-			var viewport = layer.getViewport( view );
-			var viewMatrix = pose.getViewMatrix( view );
+				var view = views[ i ];
+				var viewport = layer.getViewport( view );
+				var viewMatrix = pose.getViewMatrix( view );
 
-			var camera = cameraVR.cameras[ i ];
-			camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
-			camera.projectionMatrix.fromArray( view.projectionMatrix );
-			camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
+				var camera = cameraVR.cameras[ i ];
+				camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
+				camera.projectionMatrix.fromArray( view.projectionMatrix );
+				camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
 
-			if ( i === 0 ) {
+				if ( i === 0 ) {
 
-				cameraVR.matrix.copy( camera.matrix );
+					cameraVR.matrix.copy( camera.matrix );
 
-				// HACK (mrdoob)
-				// https://github.com/w3c/webvr/issues/203
+					// HACK (mrdoob)
+					// https://github.com/w3c/webvr/issues/203
 
-				cameraVR.projectionMatrix.copy( camera.projectionMatrix );
+					cameraVR.projectionMatrix.copy( camera.projectionMatrix );
+
+				}
+
+			}
+
+		}
+
+		//
+
+		for ( var i = 0; i < inputSources.length; i ++ ) {
+
+			var inputSource = inputSources[ i ];
+			var inputPose = frame.getInputPose( inputSource, frameOfRef );
+
+			if ( inputPose !== null && controllers[ i ] ) {
+
+				var controller = controllers[ i ];
+				controller.matrix.elements = inputPose.gripMatrix;
+				controller.matrix.decompose( controller.position, controller.rotation, controller.scale );
 
 			}
 
@@ -25773,26 +25864,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 } );
 
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-function Group() {
-
-	Object3D.call( this );
-
-	this.type = 'Group';
-
-}
-
-Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
-
-	constructor: Group,
-
-	isGroup: true
-
-} );
-
 /**
  * @author mrdoob / http://mrdoob.com/
  */

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