Browse Source

Merge branch 'dev' into dev29

Michael Herzog 5 years ago
parent
commit
b480a333b4

+ 68 - 530
build/three.js

@@ -22763,26 +22763,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/
 	 */
@@ -22804,505 +22784,24 @@
 	} );
 
 	/**
-	 * @author jsantell / https://www.jsantell.com/
 	 * @author mrdoob / http://mrdoob.com/
 	 */
 
-	var cameraLPos = new Vector3();
-	var cameraRPos = new Vector3();
-
-	/**
-	 * Assumes 2 cameras that are parallel and share an X-axis, and that
-	 * the cameras' projection and world matrices have already been set.
-	 * And that near and far planes are identical for both cameras.
-	 * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
-	 */
-	function setProjectionFromUnion( camera, cameraL, cameraR ) {
-
-		cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
-		cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
-
-		var ipd = cameraLPos.distanceTo( cameraRPos );
-
-		var projL = cameraL.projectionMatrix.elements;
-		var projR = cameraR.projectionMatrix.elements;
-
-		// VR systems will have identical far and near planes, and
-		// most likely identical top and bottom frustum extents.
-		// Use the left camera for these values.
-		var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
-		var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
-		var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
-		var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
-
-		var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
-		var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
-		var left = near * leftFov;
-		var right = near * rightFov;
-
-		// Calculate the new camera's position offset from the
-		// left camera. xOffset should be roughly half `ipd`.
-		var zOffset = ipd / ( - leftFov + rightFov );
-		var xOffset = zOffset * - leftFov;
-
-		// TODO: Better way to apply this offset?
-		cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
-		camera.translateX( xOffset );
-		camera.translateZ( zOffset );
-		camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
-		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+	function Group() {
 
-		// Find the union of the frustum values of the cameras and scale
-		// the values so that the near plane's position does not change in world space,
-		// although must now be relative to the new union camera.
-		var near2 = near + zOffset;
-		var far2 = far + zOffset;
-		var left2 = left - xOffset;
-		var right2 = right + ( ipd - xOffset );
-		var top2 = topFov * far / far2 * near2;
-		var bottom2 = bottomFov * far / far2 * near2;
+		Object3D.call( this );
 
-		camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
+		this.type = 'Group';
 
 	}
 
-	/**
-	 * @author mrdoob / http://mrdoob.com/
-	 */
-
-	function WebVRManager( renderer ) {
-
-		var renderWidth, renderHeight;
-		var scope = this;
-
-		var device = null;
-		var frameData = null;
-
-		var controllers = [];
-		var standingMatrix = new Matrix4();
-		var standingMatrixInverse = new Matrix4();
-
-		var framebufferScaleFactor = 1.0;
-
-		var referenceSpaceType = 'local-floor';
-
-		if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
-
-			frameData = new window.VRFrameData();
-			window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
-
-		}
-
-		var matrixWorldInverse = new Matrix4();
-		var tempQuaternion = new Quaternion();
-		var tempPosition = new Vector3();
-
-		var tempCamera = new PerspectiveCamera();
-
-		var cameraL = new PerspectiveCamera();
-		cameraL.viewport = new Vector4();
-		cameraL.layers.enable( 1 );
-
-		var cameraR = new PerspectiveCamera();
-		cameraR.viewport = new Vector4();
-		cameraR.layers.enable( 2 );
-
-		var cameraVR = new ArrayCamera( [ cameraL, cameraR ] );
-		cameraVR.layers.enable( 1 );
-		cameraVR.layers.enable( 2 );
-
-		//
-
-		function isPresenting() {
-
-			return device !== null && device.isPresenting === true;
-
-		}
-
-		var currentSize = new Vector2(), currentPixelRatio;
-
-		function onVRDisplayPresentChange() {
-
-			if ( isPresenting() ) {
-
-				var eyeParameters = device.getEyeParameters( 'left' );
-				renderWidth = 2 * eyeParameters.renderWidth * framebufferScaleFactor;
-				renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;
-
-				currentPixelRatio = renderer.getPixelRatio();
-				renderer.getSize( currentSize );
-
-				renderer.setDrawingBufferSize( renderWidth, renderHeight, 1 );
-
-				cameraL.viewport.set( 0, 0, renderWidth / 2, renderHeight );
-				cameraR.viewport.set( renderWidth / 2, 0, renderWidth / 2, renderHeight );
-
-				animation.start();
-
-				scope.dispatchEvent( { type: 'sessionstart' } );
-
-			} else {
-
-				if ( scope.enabled ) {
-
-					renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
-
-				}
-
-				animation.stop();
-
-				scope.dispatchEvent( { type: 'sessionend' } );
-
-			}
-
-		}
-
-		//
-
-		var triggers = [];
-		var grips = [];
-
-		function findGamepad( id ) {
-
-			var gamepads = navigator.getGamepads && navigator.getGamepads();
-
-			for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
-
-				var gamepad = gamepads[ i ];
-
-				if ( gamepad && ( gamepad.id === 'Daydream Controller' ||
-					gamepad.id === 'Gear VR Controller' || gamepad.id === 'Oculus Go Controller' ||
-					gamepad.id === 'OpenVR Gamepad' || gamepad.id.startsWith( 'Oculus Touch' ) ||
-					gamepad.id.startsWith( 'HTC Vive Focus' ) ||
-					gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
-
-					var hand = gamepad.hand;
-
-					if ( id === 0 && ( hand === '' || hand === 'right' ) ) { return gamepad; }
-					if ( id === 1 && ( hand === 'left' ) ) { return gamepad; }
-
-				}
-
-			}
-
-		}
-
-		function updateControllers() {
-
-			for ( var i = 0; i < controllers.length; i ++ ) {
-
-				var controller = controllers[ i ];
-
-				var gamepad = findGamepad( i );
-
-				if ( gamepad !== undefined && gamepad.pose !== undefined ) {
-
-					if ( gamepad.pose === null ) { return; }
-
-					// Pose
-
-					var pose = gamepad.pose;
-
-					if ( pose.hasPosition === false ) { controller.position.set( 0.2, - 0.6, - 0.05 ); }
-
-					if ( pose.position !== null ) { controller.position.fromArray( pose.position ); }
-					if ( pose.orientation !== null ) { controller.quaternion.fromArray( pose.orientation ); }
-					controller.matrix.compose( controller.position, controller.quaternion, controller.scale );
-					controller.matrix.premultiply( standingMatrix );
-					controller.matrix.decompose( controller.position, controller.quaternion, controller.scale );
-					controller.matrixWorldNeedsUpdate = true;
-					controller.visible = true;
-
-					// Trigger
-
-					var buttonId = gamepad.id === 'Daydream Controller' ? 0 : 1;
-
-					if ( triggers[ i ] === undefined ) { triggers[ i ] = false; }
-
-					if ( triggers[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
-
-						triggers[ i ] = gamepad.buttons[ buttonId ].pressed;
-
-						if ( triggers[ i ] === true ) {
-
-							controller.dispatchEvent( { type: 'selectstart' } );
-
-						} else {
-
-							controller.dispatchEvent( { type: 'selectend' } );
-							controller.dispatchEvent( { type: 'select' } );
-
-						}
-
-					}
-
-					// Grip
-					buttonId = 2;
-
-					if ( grips[ i ] === undefined ) { grips[ i ] = false; }
-
-					// Skip if the grip button doesn't exist on this controller
-					if ( gamepad.buttons[ buttonId ] !== undefined ) {
-
-						if ( grips[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
-
-							grips[ i ] = gamepad.buttons[ buttonId ].pressed;
-
-							if ( grips[ i ] === true ) {
-
-								controller.dispatchEvent( { type: 'squeezestart' } );
-
-							} else {
-
-								controller.dispatchEvent( { type: 'squeezeend' } );
-								controller.dispatchEvent( { type: 'squeeze' } );
-
-							}
-
-						}
-
-					}
-
-				} else {
-
-					controller.visible = false;
-
-				}
-
-			}
-
-		}
-
-		function updateViewportFromBounds( viewport, bounds ) {
-
-			if ( bounds !== null && bounds.length === 4 ) {
-
-				viewport.set( bounds[ 0 ] * renderWidth, bounds[ 1 ] * renderHeight, bounds[ 2 ] * renderWidth, bounds[ 3 ] * renderHeight );
-
-			}
-
-		}
-
-		//
-
-		this.enabled = false;
-
-		this.getController = function ( id ) {
-
-			var controller = controllers[ id ];
-
-			if ( controller === undefined ) {
-
-				controller = new Group();
-				controller.matrixAutoUpdate = false;
-				controller.visible = false;
-
-				controllers[ id ] = controller;
-
-			}
-
-			return controller;
-
-		};
-
-		this.getDevice = function () {
-
-			return device;
-
-		};
-
-		this.setDevice = function ( value ) {
-
-			if ( value !== undefined ) { device = value; }
-
-			animation.setContext( value );
-
-		};
-
-		this.setFramebufferScaleFactor = function ( value ) {
-
-			framebufferScaleFactor = value;
-
-		};
-
-		this.setReferenceSpaceType = function ( value ) {
-
-			referenceSpaceType = value;
-
-		};
-
-		this.getCamera = function ( camera ) {
-
-			var userHeight = referenceSpaceType === 'local-floor' ? 1.6 : 0;
-
-			device.depthNear = camera.near;
-			device.depthFar = camera.far;
-
-			device.getFrameData( frameData );
-
-			//
-
-			if ( referenceSpaceType === 'local-floor' ) {
-
-				var stageParameters = device.stageParameters;
-
-				if ( stageParameters ) {
-
-					standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
-
-				} else {
-
-					standingMatrix.makeTranslation( 0, userHeight, 0 );
-
-				}
-
-			}
-
-
-			var pose = frameData.pose;
-
-			tempCamera.matrix.copy( standingMatrix );
-			tempCamera.matrix.decompose( tempCamera.position, tempCamera.quaternion, tempCamera.scale );
-
-			if ( pose.orientation !== null ) {
-
-				tempQuaternion.fromArray( pose.orientation );
-				tempCamera.quaternion.multiply( tempQuaternion );
-
-			}
-
-			if ( pose.position !== null ) {
-
-				tempQuaternion.setFromRotationMatrix( standingMatrix );
-				tempPosition.fromArray( pose.position );
-				tempPosition.applyQuaternion( tempQuaternion );
-				tempCamera.position.add( tempPosition );
-
-			}
-
-			tempCamera.updateMatrixWorld();
-
-			//
-
-			camera.matrixWorld.copy( tempCamera.matrixWorld );
-
-			var children = camera.children;
-
-			for ( var i = 0, l = children.length; i < l; i ++ ) {
-
-				children[ i ].updateMatrixWorld( true );
-
-			}
-
-			//
-
-			cameraL.near = camera.near;
-			cameraR.near = camera.near;
-
-			cameraL.far = camera.far;
-			cameraR.far = camera.far;
-
-			cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
-			cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
-
-			// TODO (mrdoob) Double check this code
-
-			standingMatrixInverse.getInverse( standingMatrix );
-
-			if ( referenceSpaceType === 'local-floor' ) {
-
-				cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
-				cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
-
-			}
-
-			var parent = camera.parent;
-
-			if ( parent !== null ) {
-
-				matrixWorldInverse.getInverse( parent.matrixWorld );
-
-				cameraL.matrixWorldInverse.multiply( matrixWorldInverse );
-				cameraR.matrixWorldInverse.multiply( matrixWorldInverse );
-
-			}
-
-			// envMap and Mirror needs camera.matrixWorld
-
-			cameraL.matrixWorld.getInverse( cameraL.matrixWorldInverse );
-			cameraR.matrixWorld.getInverse( cameraR.matrixWorldInverse );
-
-			cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
-			cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
-
-			setProjectionFromUnion( cameraVR, cameraL, cameraR );
-
-			//
-
-			var layers = device.getLayers();
-
-			if ( layers.length ) {
-
-				var layer = layers[ 0 ];
-
-				updateViewportFromBounds( cameraL.viewport, layer.leftBounds );
-				updateViewportFromBounds( cameraR.viewport, layer.rightBounds );
-
-			}
-
-			updateControllers();
-
-			return cameraVR;
-
-		};
-
-		this.getStandingMatrix = function () {
-
-			return standingMatrix;
-
-		};
-
-		this.isPresenting = isPresenting;
-
-		// Animation Loop
-
-		var animation = new WebGLAnimation();
-
-		this.setAnimationLoop = function ( callback ) {
-
-			animation.setAnimationLoop( callback );
-
-			if ( isPresenting() ) { animation.start(); }
-
-		};
-
-		this.submitFrame = function () {
-
-			if ( isPresenting() ) { device.submitFrame(); }
-
-		};
-
-		this.dispose = function () {
-
-			if ( typeof window !== 'undefined' ) {
-
-				window.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange );
-
-			}
-
-		};
-
-		// DEPRECATED
-
-		this.setFrameOfReferenceType = function () {
-
-			console.warn( 'THREE.WebVRManager: setFrameOfReferenceType() has been deprecated.' );
+	Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
-		};
+		constructor: Group,
 
-	}
+		isGroup: true
 
-	Object.assign( WebVRManager.prototype, EventDispatcher.prototype );
+	} );
 
 	/**
 	 * @author mrdoob / http://mrdoob.com/
@@ -23478,6 +22977,66 @@
 
 		//
 
+		var cameraLPos = new Vector3();
+		var cameraRPos = new Vector3();
+
+		/**
+		 * @author jsantell / https://www.jsantell.com/
+		 *
+		 * Assumes 2 cameras that are parallel and share an X-axis, and that
+		 * the cameras' projection and world matrices have already been set.
+		 * And that near and far planes are identical for both cameras.
+		 * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
+		 */
+		function setProjectionFromUnion( camera, cameraL, cameraR ) {
+
+			cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
+			cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
+
+			var ipd = cameraLPos.distanceTo( cameraRPos );
+
+			var projL = cameraL.projectionMatrix.elements;
+			var projR = cameraR.projectionMatrix.elements;
+
+			// VR systems will have identical far and near planes, and
+			// most likely identical top and bottom frustum extents.
+			// Use the left camera for these values.
+			var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
+			var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
+			var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
+			var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
+
+			var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
+			var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
+			var left = near * leftFov;
+			var right = near * rightFov;
+
+			// Calculate the new camera's position offset from the
+			// left camera. xOffset should be roughly half `ipd`.
+			var zOffset = ipd / ( - leftFov + rightFov );
+			var xOffset = zOffset * - leftFov;
+
+			// TODO: Better way to apply this offset?
+			cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
+			camera.translateX( xOffset );
+			camera.translateZ( zOffset );
+			camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
+			camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+
+			// Find the union of the frustum values of the cameras and scale
+			// the values so that the near plane's position does not change in world space,
+			// although must now be relative to the new union camera.
+			var near2 = near + zOffset;
+			var far2 = far + zOffset;
+			var left2 = left - xOffset;
+			var right2 = right + ( ipd - xOffset );
+			var top2 = topFov * far / far2 * near2;
+			var bottom2 = bottomFov * far / far2 * near2;
+
+			camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
+
+		}
+
 		function updateCamera( camera, parent ) {
 
 			if ( parent === null ) {
@@ -23903,7 +23462,7 @@
 
 		// xr
 
-		var xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
+		var xr = new WebXRManager( _this, _gl );
 
 		this.xr = xr;
 
@@ -49966,27 +49525,6 @@
 
 	//
 
-	Object.defineProperties( WebVRManager.prototype, {
-
-		standing: {
-			set: function ( /* value */ ) {
-
-				console.warn( 'THREE.WebVRManager: .standing has been removed.' );
-
-			}
-		},
-		userHeight: {
-			set: function ( /* value */ ) {
-
-				console.warn( 'THREE.WebVRManager: .userHeight has been removed.' );
-
-			}
-		}
-
-	} );
-
-	//
-
 	Object.defineProperties( Audio.prototype, {
 
 		load: {

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


+ 68 - 530
build/three.module.js

@@ -22755,26 +22755,6 @@ function WebGLMultiview( renderer, gl ) {
 
 }
 
-/**
- * @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/
  */
@@ -22796,505 +22776,24 @@ ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototyp
 } );
 
 /**
- * @author jsantell / https://www.jsantell.com/
  * @author mrdoob / http://mrdoob.com/
  */
 
-var cameraLPos = new Vector3();
-var cameraRPos = new Vector3();
-
-/**
- * Assumes 2 cameras that are parallel and share an X-axis, and that
- * the cameras' projection and world matrices have already been set.
- * And that near and far planes are identical for both cameras.
- * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
- */
-function setProjectionFromUnion( camera, cameraL, cameraR ) {
-
-	cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
-	cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
-
-	var ipd = cameraLPos.distanceTo( cameraRPos );
-
-	var projL = cameraL.projectionMatrix.elements;
-	var projR = cameraR.projectionMatrix.elements;
-
-	// VR systems will have identical far and near planes, and
-	// most likely identical top and bottom frustum extents.
-	// Use the left camera for these values.
-	var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
-	var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
-	var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
-	var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
-
-	var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
-	var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
-	var left = near * leftFov;
-	var right = near * rightFov;
-
-	// Calculate the new camera's position offset from the
-	// left camera. xOffset should be roughly half `ipd`.
-	var zOffset = ipd / ( - leftFov + rightFov );
-	var xOffset = zOffset * - leftFov;
-
-	// TODO: Better way to apply this offset?
-	cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
-	camera.translateX( xOffset );
-	camera.translateZ( zOffset );
-	camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
-	camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+function Group() {
 
-	// Find the union of the frustum values of the cameras and scale
-	// the values so that the near plane's position does not change in world space,
-	// although must now be relative to the new union camera.
-	var near2 = near + zOffset;
-	var far2 = far + zOffset;
-	var left2 = left - xOffset;
-	var right2 = right + ( ipd - xOffset );
-	var top2 = topFov * far / far2 * near2;
-	var bottom2 = bottomFov * far / far2 * near2;
+	Object3D.call( this );
 
-	camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
+	this.type = 'Group';
 
 }
 
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-function WebVRManager( renderer ) {
-
-	var renderWidth, renderHeight;
-	var scope = this;
-
-	var device = null;
-	var frameData = null;
-
-	var controllers = [];
-	var standingMatrix = new Matrix4();
-	var standingMatrixInverse = new Matrix4();
-
-	var framebufferScaleFactor = 1.0;
-
-	var referenceSpaceType = 'local-floor';
-
-	if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
-
-		frameData = new window.VRFrameData();
-		window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
-
-	}
-
-	var matrixWorldInverse = new Matrix4();
-	var tempQuaternion = new Quaternion();
-	var tempPosition = new Vector3();
-
-	var tempCamera = new PerspectiveCamera();
-
-	var cameraL = new PerspectiveCamera();
-	cameraL.viewport = new Vector4();
-	cameraL.layers.enable( 1 );
-
-	var cameraR = new PerspectiveCamera();
-	cameraR.viewport = new Vector4();
-	cameraR.layers.enable( 2 );
-
-	var cameraVR = new ArrayCamera( [ cameraL, cameraR ] );
-	cameraVR.layers.enable( 1 );
-	cameraVR.layers.enable( 2 );
-
-	//
-
-	function isPresenting() {
-
-		return device !== null && device.isPresenting === true;
-
-	}
-
-	var currentSize = new Vector2(), currentPixelRatio;
-
-	function onVRDisplayPresentChange() {
-
-		if ( isPresenting() ) {
-
-			var eyeParameters = device.getEyeParameters( 'left' );
-			renderWidth = 2 * eyeParameters.renderWidth * framebufferScaleFactor;
-			renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;
-
-			currentPixelRatio = renderer.getPixelRatio();
-			renderer.getSize( currentSize );
-
-			renderer.setDrawingBufferSize( renderWidth, renderHeight, 1 );
-
-			cameraL.viewport.set( 0, 0, renderWidth / 2, renderHeight );
-			cameraR.viewport.set( renderWidth / 2, 0, renderWidth / 2, renderHeight );
-
-			animation.start();
-
-			scope.dispatchEvent( { type: 'sessionstart' } );
-
-		} else {
-
-			if ( scope.enabled ) {
-
-				renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
-
-			}
-
-			animation.stop();
-
-			scope.dispatchEvent( { type: 'sessionend' } );
-
-		}
-
-	}
-
-	//
-
-	var triggers = [];
-	var grips = [];
-
-	function findGamepad( id ) {
-
-		var gamepads = navigator.getGamepads && navigator.getGamepads();
-
-		for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
-
-			var gamepad = gamepads[ i ];
-
-			if ( gamepad && ( gamepad.id === 'Daydream Controller' ||
-				gamepad.id === 'Gear VR Controller' || gamepad.id === 'Oculus Go Controller' ||
-				gamepad.id === 'OpenVR Gamepad' || gamepad.id.startsWith( 'Oculus Touch' ) ||
-				gamepad.id.startsWith( 'HTC Vive Focus' ) ||
-				gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
-
-				var hand = gamepad.hand;
-
-				if ( id === 0 && ( hand === '' || hand === 'right' ) ) return gamepad;
-				if ( id === 1 && ( hand === 'left' ) ) return gamepad;
-
-			}
-
-		}
-
-	}
-
-	function updateControllers() {
-
-		for ( var i = 0; i < controllers.length; i ++ ) {
-
-			var controller = controllers[ i ];
-
-			var gamepad = findGamepad( i );
-
-			if ( gamepad !== undefined && gamepad.pose !== undefined ) {
-
-				if ( gamepad.pose === null ) return;
-
-				// Pose
-
-				var pose = gamepad.pose;
-
-				if ( pose.hasPosition === false ) controller.position.set( 0.2, - 0.6, - 0.05 );
-
-				if ( pose.position !== null ) controller.position.fromArray( pose.position );
-				if ( pose.orientation !== null ) controller.quaternion.fromArray( pose.orientation );
-				controller.matrix.compose( controller.position, controller.quaternion, controller.scale );
-				controller.matrix.premultiply( standingMatrix );
-				controller.matrix.decompose( controller.position, controller.quaternion, controller.scale );
-				controller.matrixWorldNeedsUpdate = true;
-				controller.visible = true;
-
-				// Trigger
-
-				var buttonId = gamepad.id === 'Daydream Controller' ? 0 : 1;
-
-				if ( triggers[ i ] === undefined ) triggers[ i ] = false;
-
-				if ( triggers[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
-
-					triggers[ i ] = gamepad.buttons[ buttonId ].pressed;
-
-					if ( triggers[ i ] === true ) {
-
-						controller.dispatchEvent( { type: 'selectstart' } );
-
-					} else {
-
-						controller.dispatchEvent( { type: 'selectend' } );
-						controller.dispatchEvent( { type: 'select' } );
-
-					}
-
-				}
-
-				// Grip
-				buttonId = 2;
-
-				if ( grips[ i ] === undefined ) grips[ i ] = false;
-
-				// Skip if the grip button doesn't exist on this controller
-				if ( gamepad.buttons[ buttonId ] !== undefined ) {
-
-					if ( grips[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
-
-						grips[ i ] = gamepad.buttons[ buttonId ].pressed;
-
-						if ( grips[ i ] === true ) {
-
-							controller.dispatchEvent( { type: 'squeezestart' } );
-
-						} else {
-
-							controller.dispatchEvent( { type: 'squeezeend' } );
-							controller.dispatchEvent( { type: 'squeeze' } );
-
-						}
-
-					}
-
-				}
-
-			} else {
-
-				controller.visible = false;
-
-			}
-
-		}
-
-	}
-
-	function updateViewportFromBounds( viewport, bounds ) {
-
-		if ( bounds !== null && bounds.length === 4 ) {
-
-			viewport.set( bounds[ 0 ] * renderWidth, bounds[ 1 ] * renderHeight, bounds[ 2 ] * renderWidth, bounds[ 3 ] * renderHeight );
-
-		}
-
-	}
-
-	//
-
-	this.enabled = false;
-
-	this.getController = function ( id ) {
-
-		var controller = controllers[ id ];
-
-		if ( controller === undefined ) {
-
-			controller = new Group();
-			controller.matrixAutoUpdate = false;
-			controller.visible = false;
-
-			controllers[ id ] = controller;
-
-		}
-
-		return controller;
-
-	};
-
-	this.getDevice = function () {
-
-		return device;
-
-	};
-
-	this.setDevice = function ( value ) {
-
-		if ( value !== undefined ) device = value;
-
-		animation.setContext( value );
-
-	};
-
-	this.setFramebufferScaleFactor = function ( value ) {
-
-		framebufferScaleFactor = value;
-
-	};
-
-	this.setReferenceSpaceType = function ( value ) {
-
-		referenceSpaceType = value;
-
-	};
-
-	this.getCamera = function ( camera ) {
-
-		var userHeight = referenceSpaceType === 'local-floor' ? 1.6 : 0;
-
-		device.depthNear = camera.near;
-		device.depthFar = camera.far;
-
-		device.getFrameData( frameData );
-
-		//
-
-		if ( referenceSpaceType === 'local-floor' ) {
-
-			var stageParameters = device.stageParameters;
-
-			if ( stageParameters ) {
-
-				standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
-
-			} else {
-
-				standingMatrix.makeTranslation( 0, userHeight, 0 );
-
-			}
-
-		}
-
-
-		var pose = frameData.pose;
-
-		tempCamera.matrix.copy( standingMatrix );
-		tempCamera.matrix.decompose( tempCamera.position, tempCamera.quaternion, tempCamera.scale );
-
-		if ( pose.orientation !== null ) {
-
-			tempQuaternion.fromArray( pose.orientation );
-			tempCamera.quaternion.multiply( tempQuaternion );
-
-		}
-
-		if ( pose.position !== null ) {
-
-			tempQuaternion.setFromRotationMatrix( standingMatrix );
-			tempPosition.fromArray( pose.position );
-			tempPosition.applyQuaternion( tempQuaternion );
-			tempCamera.position.add( tempPosition );
-
-		}
-
-		tempCamera.updateMatrixWorld();
-
-		//
-
-		camera.matrixWorld.copy( tempCamera.matrixWorld );
-
-		var children = camera.children;
-
-		for ( var i = 0, l = children.length; i < l; i ++ ) {
-
-			children[ i ].updateMatrixWorld( true );
-
-		}
-
-		//
-
-		cameraL.near = camera.near;
-		cameraR.near = camera.near;
-
-		cameraL.far = camera.far;
-		cameraR.far = camera.far;
-
-		cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
-		cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
-
-		// TODO (mrdoob) Double check this code
-
-		standingMatrixInverse.getInverse( standingMatrix );
-
-		if ( referenceSpaceType === 'local-floor' ) {
-
-			cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
-			cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
-
-		}
-
-		var parent = camera.parent;
-
-		if ( parent !== null ) {
-
-			matrixWorldInverse.getInverse( parent.matrixWorld );
-
-			cameraL.matrixWorldInverse.multiply( matrixWorldInverse );
-			cameraR.matrixWorldInverse.multiply( matrixWorldInverse );
-
-		}
-
-		// envMap and Mirror needs camera.matrixWorld
-
-		cameraL.matrixWorld.getInverse( cameraL.matrixWorldInverse );
-		cameraR.matrixWorld.getInverse( cameraR.matrixWorldInverse );
-
-		cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
-		cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
-
-		setProjectionFromUnion( cameraVR, cameraL, cameraR );
-
-		//
-
-		var layers = device.getLayers();
-
-		if ( layers.length ) {
-
-			var layer = layers[ 0 ];
-
-			updateViewportFromBounds( cameraL.viewport, layer.leftBounds );
-			updateViewportFromBounds( cameraR.viewport, layer.rightBounds );
-
-		}
-
-		updateControllers();
-
-		return cameraVR;
-
-	};
-
-	this.getStandingMatrix = function () {
-
-		return standingMatrix;
-
-	};
-
-	this.isPresenting = isPresenting;
-
-	// Animation Loop
-
-	var animation = new WebGLAnimation();
-
-	this.setAnimationLoop = function ( callback ) {
-
-		animation.setAnimationLoop( callback );
-
-		if ( isPresenting() ) animation.start();
-
-	};
-
-	this.submitFrame = function () {
-
-		if ( isPresenting() ) device.submitFrame();
-
-	};
-
-	this.dispose = function () {
-
-		if ( typeof window !== 'undefined' ) {
-
-			window.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange );
-
-		}
-
-	};
-
-	// DEPRECATED
-
-	this.setFrameOfReferenceType = function () {
-
-		console.warn( 'THREE.WebVRManager: setFrameOfReferenceType() has been deprecated.' );
+Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
-	};
+	constructor: Group,
 
-}
+	isGroup: true
 
-Object.assign( WebVRManager.prototype, EventDispatcher.prototype );
+} );
 
 /**
  * @author mrdoob / http://mrdoob.com/
@@ -23470,6 +22969,66 @@ function WebXRManager( renderer, gl ) {
 
 	//
 
+	var cameraLPos = new Vector3();
+	var cameraRPos = new Vector3();
+
+	/**
+	 * @author jsantell / https://www.jsantell.com/
+	 *
+	 * Assumes 2 cameras that are parallel and share an X-axis, and that
+	 * the cameras' projection and world matrices have already been set.
+	 * And that near and far planes are identical for both cameras.
+	 * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
+	 */
+	function setProjectionFromUnion( camera, cameraL, cameraR ) {
+
+		cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
+		cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
+
+		var ipd = cameraLPos.distanceTo( cameraRPos );
+
+		var projL = cameraL.projectionMatrix.elements;
+		var projR = cameraR.projectionMatrix.elements;
+
+		// VR systems will have identical far and near planes, and
+		// most likely identical top and bottom frustum extents.
+		// Use the left camera for these values.
+		var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
+		var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
+		var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
+		var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
+
+		var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
+		var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
+		var left = near * leftFov;
+		var right = near * rightFov;
+
+		// Calculate the new camera's position offset from the
+		// left camera. xOffset should be roughly half `ipd`.
+		var zOffset = ipd / ( - leftFov + rightFov );
+		var xOffset = zOffset * - leftFov;
+
+		// TODO: Better way to apply this offset?
+		cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
+		camera.translateX( xOffset );
+		camera.translateZ( zOffset );
+		camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
+		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+
+		// Find the union of the frustum values of the cameras and scale
+		// the values so that the near plane's position does not change in world space,
+		// although must now be relative to the new union camera.
+		var near2 = near + zOffset;
+		var far2 = far + zOffset;
+		var left2 = left - xOffset;
+		var right2 = right + ( ipd - xOffset );
+		var top2 = topFov * far / far2 * near2;
+		var bottom2 = bottomFov * far / far2 * near2;
+
+		camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
+
+	}
+
 	function updateCamera( camera, parent ) {
 
 		if ( parent === null ) {
@@ -23895,7 +23454,7 @@ function WebGLRenderer( parameters ) {
 
 	// xr
 
-	var xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
+	var xr = new WebXRManager( _this, _gl );
 
 	this.xr = xr;
 
@@ -49960,27 +49519,6 @@ Object.defineProperties( WebGLRenderTarget.prototype, {
 
 //
 
-Object.defineProperties( WebVRManager.prototype, {
-
-	standing: {
-		set: function ( /* value */ ) {
-
-			console.warn( 'THREE.WebVRManager: .standing has been removed.' );
-
-		}
-	},
-	userHeight: {
-		set: function ( /* value */ ) {
-
-			console.warn( 'THREE.WebVRManager: .userHeight has been removed.' );
-
-		}
-	}
-
-} );
-
-//
-
 Object.defineProperties( Audio.prototype, {
 
 	load: {

+ 0 - 1
docs/api/en/lights/DirectionalLight.html

@@ -41,7 +41,6 @@
 		<h2>Example</h2>
 		<p>
 			[example:misc_controls_fly controls / fly ]<br />
-			[example:webvr_cubes cubes ]<br />
 			[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]<br />
 			[example:webgl_effects_stereo effects / stereo ]<br />
 			[example:webgl_geometry_extrude_splines geometry / extrude / splines ]<br />

+ 0 - 1
docs/api/zh/lights/DirectionalLight.html

@@ -37,7 +37,6 @@
 		<h2>示例</h2>
 		<p>
 			[example:misc_controls_fly controls / fly ]<br />
-			[example:webvr_cubes cubes ]<br />
 			[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]<br />
 			[example:webgl_effects_stereo effects / stereo ]<br />
 			[example:webgl_geometry_extrude_splines geometry / extrude / splines ]<br />

+ 0 - 263
examples/js/vr/WebVR.js

@@ -1,263 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com
- * @author Mugen87 / https://github.com/Mugen87
- *
- * Based on @tojiro's vr-samples-utils.js
- */
-
-THREE.WEBVR = {
-
-	createButton: function ( renderer, options ) {
-
-		console.warn( 'WEBVR.js has been deprecated. Use VRButton.js instead.' );
-
-		if ( options && options.referenceSpaceType ) {
-
-			renderer.xr.setReferenceSpaceType( options.referenceSpaceType );
-
-		}
-
-		function showEnterVR( device ) {
-
-			button.style.display = '';
-
-			button.style.cursor = 'pointer';
-			button.style.left = 'calc(50% - 50px)';
-			button.style.width = '100px';
-
-			button.textContent = 'ENTER VR';
-
-			button.onmouseenter = function () {
-
-				button.style.opacity = '1.0';
-
-			};
-
-			button.onmouseleave = function () {
-
-				button.style.opacity = '0.5';
-
-			};
-
-			button.onclick = function () {
-
-				device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
-
-			};
-
-			renderer.xr.setDevice( device );
-
-		}
-
-		function showEnterXR( /*device*/ ) {
-
-			var currentSession = null;
-
-			function onSessionStarted( session ) {
-
-				session.addEventListener( 'end', onSessionEnded );
-
-				renderer.xr.setSession( session );
-				button.textContent = 'EXIT XR';
-
-				currentSession = session;
-
-			}
-
-			function onSessionEnded( /*event*/ ) {
-
-				currentSession.removeEventListener( 'end', onSessionEnded );
-
-				renderer.xr.setSession( null );
-				button.textContent = 'ENTER XR';
-
-				currentSession = null;
-
-			}
-
-			//
-
-			button.style.display = '';
-
-			button.style.cursor = 'pointer';
-			button.style.left = 'calc(50% - 50px)';
-			button.style.width = '100px';
-
-			button.textContent = 'ENTER XR';
-
-			button.onmouseenter = function () {
-
-				button.style.opacity = '1.0';
-
-			};
-
-			button.onmouseleave = function () {
-
-				button.style.opacity = '0.5';
-
-			};
-
-			button.onclick = function () {
-
-				if ( currentSession === null ) {
-
-					// WebXR's requestReferenceSpace only works if the corresponding feature
-					// was requested at session creation time. For simplicity, just ask for
-					// the interesting ones as optional features, but be aware that the
-					// requestReferenceSpace call will fail if it turns out to be unavailable.
-					// ('local' is always available for immersive sessions and doesn't need to
-					// be requested separately.)
-
-					var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] };
-					navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
-
-				} else {
-
-					currentSession.end();
-
-				}
-
-			};
-
-		}
-
-		function disableButton() {
-
-			button.style.display = '';
-
-			button.style.cursor = 'auto';
-			button.style.left = 'calc(50% - 75px)';
-			button.style.width = '150px';
-
-			button.onmouseenter = null;
-			button.onmouseleave = null;
-
-			button.onclick = null;
-
-		}
-
-		function showVRNotFound() {
-
-			disableButton();
-
-			button.textContent = 'VR NOT FOUND';
-
-			renderer.xr.setDevice( null );
-
-		}
-
-		function showXRNotFound() {
-
-			disableButton();
-
-			button.textContent = 'XR NOT FOUND';
-
-		}
-
-		function stylizeElement( element ) {
-
-			element.style.position = 'absolute';
-			element.style.bottom = '20px';
-			element.style.padding = '12px 6px';
-			element.style.border = '1px solid #fff';
-			element.style.borderRadius = '4px';
-			element.style.background = 'rgba(0,0,0,0.1)';
-			element.style.color = '#fff';
-			element.style.font = 'normal 13px sans-serif';
-			element.style.textAlign = 'center';
-			element.style.opacity = '0.5';
-			element.style.outline = 'none';
-			element.style.zIndex = '999';
-
-		}
-
-		if ( 'xr' in navigator ) {
-
-			var button = document.createElement( 'button' );
-			button.style.display = 'none';
-
-			stylizeElement( button );
-
-			navigator.xr.isSessionSupported( 'immersive-vr' ).then( function ( supported ) {
-
-				if ( supported ) {
-
-					showEnterXR();
-
-				} else {
-
-					showXRNotFound();
-
-				}
-
-			} );
-
-			return button;
-
-		} else if ( 'getVRDisplays' in navigator ) {
-
-			var button = document.createElement( 'button' );
-			button.style.display = 'none';
-
-			stylizeElement( button );
-
-			window.addEventListener( 'vrdisplayconnect', function ( event ) {
-
-				showEnterVR( event.display );
-
-			}, false );
-
-			window.addEventListener( 'vrdisplaydisconnect', function ( /*event*/ ) {
-
-				showVRNotFound();
-
-			}, false );
-
-			window.addEventListener( 'vrdisplaypresentchange', function ( event ) {
-
-				button.textContent = event.display.isPresenting ? 'EXIT VR' : 'ENTER VR';
-
-			}, false );
-
-			window.addEventListener( 'vrdisplayactivate', function ( event ) {
-
-				event.display.requestPresent( [ { source: renderer.domElement } ] );
-
-			}, false );
-
-			navigator.getVRDisplays()
-				.then( function ( displays ) {
-
-					if ( displays.length > 0 ) {
-
-						showEnterVR( displays[ 0 ] );
-
-					} else {
-
-						showVRNotFound();
-
-					}
-
-				} ).catch( showVRNotFound );
-
-			return button;
-
-		} else {
-
-			var message = document.createElement( 'a' );
-			message.href = 'https://webvr.info';
-			message.innerHTML = 'WEBVR NOT SUPPORTED';
-
-			message.style.left = 'calc(50% - 90px)';
-			message.style.width = '180px';
-			message.style.textDecoration = 'none';
-
-			stylizeElement( message );
-
-			return message;
-
-		}
-
-	}
-
-};

+ 0 - 11
examples/jsm/vr/WebVR.d.ts

@@ -1,11 +0,0 @@
-import {
-	WebGLRenderer
-} from '../../../src/Three';
-
-export interface WEBVROptions {
-	referenceSpaceType: string;
-}
-
-export namespace WEBVR {
-	export function createButton( renderer: WebGLRenderer, options?: WEBVROptions ): HTMLElement;
-}

+ 0 - 267
examples/jsm/vr/WebVR.js

@@ -1,267 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com
- * @author Mugen87 / https://github.com/Mugen87
- *
- * Based on @tojiro's vr-samples-utils.js
- */
-
-
-
-var WEBVR = {
-
-	createButton: function ( renderer, options ) {
-
-		console.warn( 'WEBVR.js has been deprecated. Use VRButton.js instead.' );
-
-		if ( options && options.referenceSpaceType ) {
-
-			renderer.xr.setReferenceSpaceType( options.referenceSpaceType );
-
-		}
-
-		function showEnterVR( device ) {
-
-			button.style.display = '';
-
-			button.style.cursor = 'pointer';
-			button.style.left = 'calc(50% - 50px)';
-			button.style.width = '100px';
-
-			button.textContent = 'ENTER VR';
-
-			button.onmouseenter = function () {
-
-				button.style.opacity = '1.0';
-
-			};
-
-			button.onmouseleave = function () {
-
-				button.style.opacity = '0.5';
-
-			};
-
-			button.onclick = function () {
-
-				device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
-
-			};
-
-			renderer.xr.setDevice( device );
-
-		}
-
-		function showEnterXR( /*device*/ ) {
-
-			var currentSession = null;
-
-			function onSessionStarted( session ) {
-
-				session.addEventListener( 'end', onSessionEnded );
-
-				renderer.xr.setSession( session );
-				button.textContent = 'EXIT XR';
-
-				currentSession = session;
-
-			}
-
-			function onSessionEnded( /*event*/ ) {
-
-				currentSession.removeEventListener( 'end', onSessionEnded );
-
-				renderer.xr.setSession( null );
-				button.textContent = 'ENTER XR';
-
-				currentSession = null;
-
-			}
-
-			//
-
-			button.style.display = '';
-
-			button.style.cursor = 'pointer';
-			button.style.left = 'calc(50% - 50px)';
-			button.style.width = '100px';
-
-			button.textContent = 'ENTER XR';
-
-			button.onmouseenter = function () {
-
-				button.style.opacity = '1.0';
-
-			};
-
-			button.onmouseleave = function () {
-
-				button.style.opacity = '0.5';
-
-			};
-
-			button.onclick = function () {
-
-				if ( currentSession === null ) {
-
-					// WebXR's requestReferenceSpace only works if the corresponding feature
-					// was requested at session creation time. For simplicity, just ask for
-					// the interesting ones as optional features, but be aware that the
-					// requestReferenceSpace call will fail if it turns out to be unavailable.
-					// ('local' is always available for immersive sessions and doesn't need to
-					// be requested separately.)
-
-					var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] };
-					navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
-
-				} else {
-
-					currentSession.end();
-
-				}
-
-			};
-
-		}
-
-		function disableButton() {
-
-			button.style.display = '';
-
-			button.style.cursor = 'auto';
-			button.style.left = 'calc(50% - 75px)';
-			button.style.width = '150px';
-
-			button.onmouseenter = null;
-			button.onmouseleave = null;
-
-			button.onclick = null;
-
-		}
-
-		function showVRNotFound() {
-
-			disableButton();
-
-			button.textContent = 'VR NOT FOUND';
-
-			renderer.xr.setDevice( null );
-
-		}
-
-		function showXRNotFound() {
-
-			disableButton();
-
-			button.textContent = 'XR NOT FOUND';
-
-		}
-
-		function stylizeElement( element ) {
-
-			element.style.position = 'absolute';
-			element.style.bottom = '20px';
-			element.style.padding = '12px 6px';
-			element.style.border = '1px solid #fff';
-			element.style.borderRadius = '4px';
-			element.style.background = 'rgba(0,0,0,0.1)';
-			element.style.color = '#fff';
-			element.style.font = 'normal 13px sans-serif';
-			element.style.textAlign = 'center';
-			element.style.opacity = '0.5';
-			element.style.outline = 'none';
-			element.style.zIndex = '999';
-
-		}
-
-		if ( 'xr' in navigator ) {
-
-			var button = document.createElement( 'button' );
-			button.style.display = 'none';
-
-			stylizeElement( button );
-
-			navigator.xr.isSessionSupported( 'immersive-vr' ).then( function ( supported ) {
-
-				if ( supported ) {
-
-					showEnterXR();
-
-				} else {
-
-					showXRNotFound();
-
-				}
-
-			} );
-
-			return button;
-
-		} else if ( 'getVRDisplays' in navigator ) {
-
-			var button = document.createElement( 'button' );
-			button.style.display = 'none';
-
-			stylizeElement( button );
-
-			window.addEventListener( 'vrdisplayconnect', function ( event ) {
-
-				showEnterVR( event.display );
-
-			}, false );
-
-			window.addEventListener( 'vrdisplaydisconnect', function ( /*event*/ ) {
-
-				showVRNotFound();
-
-			}, false );
-
-			window.addEventListener( 'vrdisplaypresentchange', function ( event ) {
-
-				button.textContent = event.display.isPresenting ? 'EXIT VR' : 'ENTER VR';
-
-			}, false );
-
-			window.addEventListener( 'vrdisplayactivate', function ( event ) {
-
-				event.display.requestPresent( [ { source: renderer.domElement } ] );
-
-			}, false );
-
-			navigator.getVRDisplays()
-				.then( function ( displays ) {
-
-					if ( displays.length > 0 ) {
-
-						showEnterVR( displays[ 0 ] );
-
-					} else {
-
-						showVRNotFound();
-
-					}
-
-				} ).catch( showVRNotFound );
-
-			return button;
-
-		} else {
-
-			var message = document.createElement( 'a' );
-			message.href = 'https://webvr.info';
-			message.innerHTML = 'WEBVR NOT SUPPORTED';
-
-			message.style.left = 'calc(50% - 90px)';
-			message.style.width = '180px';
-			message.style.textDecoration = 'none';
-
-			stylizeElement( message );
-
-			return message;
-
-		}
-
-	}
-
-};
-
-export { WEBVR };

+ 5 - 13
examples/jsm/webxr/ARButton.js

@@ -7,7 +7,7 @@ var ARButton = {
 
 	createButton: function ( renderer ) {
 
-		function showEnterXR( /*device*/ ) {
+		function showStartAR( /*device*/ ) {
 
 			var currentSession = null;
 
@@ -93,11 +93,11 @@ var ARButton = {
 
 		}
 
-		function showXRNotFound() {
+		function showWebXRNotFound() {
 
 			disableButton();
 
-			button.textContent = 'XR NOT FOUND';
+			button.textContent = 'AR NOT SUPPORTED';
 
 		}
 
@@ -127,15 +127,7 @@ var ARButton = {
 
 			navigator.xr.isSessionSupported( 'immersive-ar' ).then( function ( supported ) {
 
-				if ( supported ) {
-
-					showEnterXR();
-
-				} else {
-
-					showXRNotFound();
-
-				}
+				supported ? showStartAR() : showWebXRNotFound();
 
 			} );
 
@@ -144,7 +136,7 @@ var ARButton = {
 		} else {
 
 			var message = document.createElement( 'a' );
-			message.href = 'https://immersive-web.github.io/webxr/';
+			message.href = 'https://immersiveweb.dev/';
 
 			if ( window.isSecureContext === false ) {
 

+ 12 - 101
examples/jsm/webxr/VRButton.js

@@ -13,39 +13,7 @@ var VRButton = {
 
 		}
 
-		function showEnterVR( device ) {
-
-			button.style.display = '';
-
-			button.style.cursor = 'pointer';
-			button.style.left = 'calc(50% - 50px)';
-			button.style.width = '100px';
-
-			button.textContent = 'ENTER_VR';
-
-			button.onmouseenter = function () {
-
-				button.style.opacity = '1.0';
-
-			};
-
-			button.onmouseleave = function () {
-
-				button.style.opacity = '0.5';
-
-			};
-
-			button.onclick = function () {
-
-				device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
-
-			};
-
-			renderer.xr.setDevice( device );
-
-		}
-
-		function showEnterXR( /*device*/ ) {
+		function showEnterVR( /*device*/ ) {
 
 			var currentSession = null;
 
@@ -132,21 +100,11 @@ var VRButton = {
 
 		}
 
-		function showVRNotFound() {
-
-			disableButton();
-
-			button.textContent = 'VR NOT FOUND';
-
-			renderer.xr.setDevice( null );
-
-		}
-
-		function showXRNotFound() {
+		function showWebXRNotFound() {
 
 			disableButton();
 
-			button.textContent = 'VR NOT FOUND';
+			button.textContent = 'VR NOT SUPPORTED';
 
 		}
 
@@ -176,73 +134,26 @@ var VRButton = {
 
 			navigator.xr.isSessionSupported( 'immersive-vr' ).then( function ( supported ) {
 
-				if ( supported ) {
-
-					showEnterXR();
-
-				} else {
-
-					showXRNotFound();
-
-				}
+				supported ? showEnterVR() : showWebXRNotFound();
 
 			} );
 
 			return button;
 
-		} else if ( 'getVRDisplays' in navigator ) {
-
-			var button = document.createElement( 'button' );
-			button.style.display = 'none';
-
-			stylizeElement( button );
-
-			window.addEventListener( 'vrdisplayconnect', function ( event ) {
-
-				showEnterVR( event.display );
-
-			}, false );
-
-			window.addEventListener( 'vrdisplaydisconnect', function ( /*event*/ ) {
-
-				showVRNotFound();
-
-			}, false );
-
-			window.addEventListener( 'vrdisplaypresentchange', function ( event ) {
-
-				button.textContent = event.display.isPresenting ? 'EXIT_VR' : 'ENTER_VR';
-
-			}, false );
-
-			window.addEventListener( 'vrdisplayactivate', function ( event ) {
-
-				event.display.requestPresent( [ { source: renderer.domElement } ] );
-
-			}, false );
-
-			navigator.getVRDisplays()
-				.then( function ( displays ) {
-
-					if ( displays.length > 0 ) {
-
-						showEnterVR( displays[ 0 ] );
-
-					} else {
+		} else {
 
-						showVRNotFound();
+			var message = document.createElement( 'a' );
+			message.href = 'https://immersiveweb.dev/';
 
-					}
+			if ( window.isSecureContext === false ) {
 
-				} ).catch( showVRNotFound );
+				message.innerHTML = 'WEBXR NEEDS HTTPS'; // TODO Improve message
 
-			return button;
+			} else {
 
-		} else {
+				message.innerHTML = 'WEBXR NOT AVAILABLE';
 
-			var message = document.createElement( 'a' );
-			message.href = 'https://immersive-web.github.io/webxr/';
-			message.innerHTML = 'WEBXR NOT SUPPORTED';
+			}
 
 			message.style.left = 'calc(50% - 90px)';
 			message.style.width = '180px';

+ 1 - 23
src/Three.Legacy.js

@@ -84,7 +84,6 @@ import { WebGLRenderer } from './renderers/WebGLRenderer.js';
 import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
 import { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube.js';
 import { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js';
-import { WebVRManager } from './renderers/webvr/WebVRManager.js';
 import { ImageUtils } from './extras/ImageUtils.js';
 import { Shape } from './extras/core/Shape.js';
 import { CubeCamera } from './cameras/CubeCamera.js';
@@ -1715,7 +1714,7 @@ Object.defineProperties( WebGLRenderer.prototype, {
 	vr: {
 		get: function () {
 
-			console.warn( 'THREE.WebGLRenderer: .vr has been removed. Use .xr instead.' );
+			console.warn( 'THREE.WebGLRenderer: .vr has been renamed to .xr' );
 			return this.xr;
 
 		}
@@ -1964,27 +1963,6 @@ Object.defineProperties( WebGLRenderTarget.prototype, {
 
 //
 
-Object.defineProperties( WebVRManager.prototype, {
-
-	standing: {
-		set: function ( /* value */ ) {
-
-			console.warn( 'THREE.WebVRManager: .standing has been removed.' );
-
-		}
-	},
-	userHeight: {
-		set: function ( /* value */ ) {
-
-			console.warn( 'THREE.WebVRManager: .userHeight has been removed.' );
-
-		}
-	}
-
-} );
-
-//
-
 Object.defineProperties( Audio.prototype, {
 
 	load: {

+ 0 - 2
src/Three.d.ts

@@ -172,8 +172,6 @@ export * from './renderers/webgl/WebGLShadowMap';
 export * from './renderers/webgl/WebGLState';
 export * from './renderers/webgl/WebGLTextures';
 export * from './renderers/webgl/WebGLUniforms';
-//export * from './renderers/webgl/WebGLUtils';
-export * from './renderers/webvr/WebVRManager';
 export * from './constants';
 export * from './Three.Legacy';
 

+ 2 - 2
src/renderers/WebGLRenderer.d.ts

@@ -15,7 +15,7 @@ import { Object3D } from './../core/Object3D';
 import { Material } from './../materials/Material';
 import { Fog } from './../scenes/Fog';
 import { ToneMapping, ShadowMapType, CullFace, TextureEncoding } from '../constants';
-import { WebXRManager } from '../renderers/webvr/WebXRManager';
+import { WebXRManager } from '../renderers/webxr/WebXRManager';
 import { RenderTarget } from './webgl/WebGLRenderLists';
 import { Geometry } from './../core/Geometry';
 import { BufferGeometry } from './../core/BufferGeometry';
@@ -319,7 +319,7 @@ export class WebGLRenderer implements Renderer {
 	): void;
 
 	/**
-	 * A build in function that can be used instead of requestAnimationFrame. For WebVR projects this function must be used.
+	 * A build in function that can be used instead of requestAnimationFrame. For WebXR projects this function must be used.
 	 * @param callback The function will be called every available frame. If `null` is passed it will stop any already ongoing animation.
 	 */
 	setAnimationLoop( callback: Function | null ): void;

+ 10 - 11
src/renderers/WebGLRenderer.js

@@ -1,3 +1,11 @@
+/**
+ * @author supereggbert / http://www.paulbrunt.co.uk/
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author szimek / https://github.com/szimek/
+ * @author tschw
+ */
+
 import {
 	RGBAFormat,
 	HalfFloatType,
@@ -39,16 +47,7 @@ import { WebGLTextures } from './webgl/WebGLTextures.js';
 import { WebGLUniforms } from './webgl/WebGLUniforms.js';
 import { WebGLUtils } from './webgl/WebGLUtils.js';
 import { WebGLMultiview } from './webgl/WebGLMultiview.js';
-import { WebVRManager } from './webvr/WebVRManager.js';
-import { WebXRManager } from './webvr/WebXRManager.js';
-
-/**
- * @author supereggbert / http://www.paulbrunt.co.uk/
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author szimek / https://github.com/szimek/
- * @author tschw
- */
+import { WebXRManager } from './webxr/WebXRManager.js';
 
 function WebGLRenderer( parameters ) {
 
@@ -306,7 +305,7 @@ function WebGLRenderer( parameters ) {
 
 	// xr
 
-	var xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
+	var xr = new WebXRManager( _this, _gl );
 
 	this.xr = xr;
 

+ 0 - 25
src/renderers/webvr/WebVRManager.d.ts

@@ -1,25 +0,0 @@
-import { Object3D } from '../../core/Object3D';
-import { Group } from '../../objects/Group';
-import { PerspectiveCamera } from '../../cameras/PerspectiveCamera';
-import { ArrayCamera } from '../../cameras/ArrayCamera';
-import { Matrix4 } from '../../math/Matrix4';
-
-export class WebVRManager {
-
-	constructor( renderer: any );
-
-	enabled: boolean;
-	getController( id: number ): Group;
-	getDevice(): VRDisplay | null;
-	setDevice( device: VRDisplay | null ): void;
-	setFramebufferScaleFactor( value: number ): void;
-	setReferenceSpaceType( value: string ): void;
-	setPoseTarget( object: Object3D | null ): void;
-	getCamera( camera: PerspectiveCamera ): PerspectiveCamera | ArrayCamera;
-	getStandingMatrix(): Matrix4;
-	isPresenting: () => boolean;
-	setAnimationLoop( callback: Function ): void;
-	submitFrame(): void;
-	dispose(): void;
-
-}

+ 0 - 451
src/renderers/webvr/WebVRManager.js

@@ -1,451 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-import { EventDispatcher } from '../../core/EventDispatcher.js';
-import { Group } from '../../objects/Group.js';
-import { Matrix4 } from '../../math/Matrix4.js';
-import { Vector2 } from '../../math/Vector2.js';
-import { Vector3 } from '../../math/Vector3.js';
-import { Vector4 } from '../../math/Vector4.js';
-import { Quaternion } from '../../math/Quaternion.js';
-import { ArrayCamera } from '../../cameras/ArrayCamera.js';
-import { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';
-import { WebGLAnimation } from '../webgl/WebGLAnimation.js';
-import { setProjectionFromUnion } from './WebVRUtils.js';
-
-function WebVRManager( renderer ) {
-
-	var renderWidth, renderHeight;
-	var scope = this;
-
-	var device = null;
-	var frameData = null;
-
-	var controllers = [];
-	var standingMatrix = new Matrix4();
-	var standingMatrixInverse = new Matrix4();
-
-	var framebufferScaleFactor = 1.0;
-
-	var referenceSpaceType = 'local-floor';
-
-	if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
-
-		frameData = new window.VRFrameData();
-		window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
-
-	}
-
-	var matrixWorldInverse = new Matrix4();
-	var tempQuaternion = new Quaternion();
-	var tempPosition = new Vector3();
-
-	var tempCamera = new PerspectiveCamera();
-
-	var cameraL = new PerspectiveCamera();
-	cameraL.viewport = new Vector4();
-	cameraL.layers.enable( 1 );
-
-	var cameraR = new PerspectiveCamera();
-	cameraR.viewport = new Vector4();
-	cameraR.layers.enable( 2 );
-
-	var cameraVR = new ArrayCamera( [ cameraL, cameraR ] );
-	cameraVR.layers.enable( 1 );
-	cameraVR.layers.enable( 2 );
-
-	//
-
-	function isPresenting() {
-
-		return device !== null && device.isPresenting === true;
-
-	}
-
-	var currentSize = new Vector2(), currentPixelRatio;
-
-	function onVRDisplayPresentChange() {
-
-		if ( isPresenting() ) {
-
-			var eyeParameters = device.getEyeParameters( 'left' );
-			renderWidth = 2 * eyeParameters.renderWidth * framebufferScaleFactor;
-			renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;
-
-			currentPixelRatio = renderer.getPixelRatio();
-			renderer.getSize( currentSize );
-
-			renderer.setDrawingBufferSize( renderWidth, renderHeight, 1 );
-
-			cameraL.viewport.set( 0, 0, renderWidth / 2, renderHeight );
-			cameraR.viewport.set( renderWidth / 2, 0, renderWidth / 2, renderHeight );
-
-			animation.start();
-
-			scope.dispatchEvent( { type: 'sessionstart' } );
-
-		} else {
-
-			if ( scope.enabled ) {
-
-				renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
-
-			}
-
-			animation.stop();
-
-			scope.dispatchEvent( { type: 'sessionend' } );
-
-		}
-
-	}
-
-	//
-
-	var triggers = [];
-	var grips = [];
-
-	function findGamepad( id ) {
-
-		var gamepads = navigator.getGamepads && navigator.getGamepads();
-
-		for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
-
-			var gamepad = gamepads[ i ];
-
-			if ( gamepad && ( gamepad.id === 'Daydream Controller' ||
-				gamepad.id === 'Gear VR Controller' || gamepad.id === 'Oculus Go Controller' ||
-				gamepad.id === 'OpenVR Gamepad' || gamepad.id.startsWith( 'Oculus Touch' ) ||
-				gamepad.id.startsWith( 'HTC Vive Focus' ) ||
-				gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
-
-				var hand = gamepad.hand;
-
-				if ( id === 0 && ( hand === '' || hand === 'right' ) ) return gamepad;
-				if ( id === 1 && ( hand === 'left' ) ) return gamepad;
-
-			}
-
-		}
-
-	}
-
-	function updateControllers() {
-
-		for ( var i = 0; i < controllers.length; i ++ ) {
-
-			var controller = controllers[ i ];
-
-			var gamepad = findGamepad( i );
-
-			if ( gamepad !== undefined && gamepad.pose !== undefined ) {
-
-				if ( gamepad.pose === null ) return;
-
-				// Pose
-
-				var pose = gamepad.pose;
-
-				if ( pose.hasPosition === false ) controller.position.set( 0.2, - 0.6, - 0.05 );
-
-				if ( pose.position !== null ) controller.position.fromArray( pose.position );
-				if ( pose.orientation !== null ) controller.quaternion.fromArray( pose.orientation );
-				controller.matrix.compose( controller.position, controller.quaternion, controller.scale );
-				controller.matrix.premultiply( standingMatrix );
-				controller.matrix.decompose( controller.position, controller.quaternion, controller.scale );
-				controller.matrixWorldNeedsUpdate = true;
-				controller.visible = true;
-
-				// Trigger
-
-				var buttonId = gamepad.id === 'Daydream Controller' ? 0 : 1;
-
-				if ( triggers[ i ] === undefined ) triggers[ i ] = false;
-
-				if ( triggers[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
-
-					triggers[ i ] = gamepad.buttons[ buttonId ].pressed;
-
-					if ( triggers[ i ] === true ) {
-
-						controller.dispatchEvent( { type: 'selectstart' } );
-
-					} else {
-
-						controller.dispatchEvent( { type: 'selectend' } );
-						controller.dispatchEvent( { type: 'select' } );
-
-					}
-
-				}
-
-				// Grip
-				buttonId = 2;
-
-				if ( grips[ i ] === undefined ) grips[ i ] = false;
-
-				// Skip if the grip button doesn't exist on this controller
-				if ( gamepad.buttons[ buttonId ] !== undefined ) {
-
-					if ( grips[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
-
-						grips[ i ] = gamepad.buttons[ buttonId ].pressed;
-
-						if ( grips[ i ] === true ) {
-
-							controller.dispatchEvent( { type: 'squeezestart' } );
-
-						} else {
-
-							controller.dispatchEvent( { type: 'squeezeend' } );
-							controller.dispatchEvent( { type: 'squeeze' } );
-
-						}
-
-					}
-
-				}
-
-			} else {
-
-				controller.visible = false;
-
-			}
-
-		}
-
-	}
-
-	function updateViewportFromBounds( viewport, bounds ) {
-
-		if ( bounds !== null && bounds.length === 4 ) {
-
-			viewport.set( bounds[ 0 ] * renderWidth, bounds[ 1 ] * renderHeight, bounds[ 2 ] * renderWidth, bounds[ 3 ] * renderHeight );
-
-		}
-
-	}
-
-	//
-
-	this.enabled = false;
-
-	this.getController = function ( id ) {
-
-		var controller = controllers[ id ];
-
-		if ( controller === undefined ) {
-
-			controller = new Group();
-			controller.matrixAutoUpdate = false;
-			controller.visible = false;
-
-			controllers[ id ] = controller;
-
-		}
-
-		return controller;
-
-	};
-
-	this.getDevice = function () {
-
-		return device;
-
-	};
-
-	this.setDevice = function ( value ) {
-
-		if ( value !== undefined ) device = value;
-
-		animation.setContext( value );
-
-	};
-
-	this.setFramebufferScaleFactor = function ( value ) {
-
-		framebufferScaleFactor = value;
-
-	};
-
-	this.setReferenceSpaceType = function ( value ) {
-
-		referenceSpaceType = value;
-
-	};
-
-	this.getCamera = function ( camera ) {
-
-		var userHeight = referenceSpaceType === 'local-floor' ? 1.6 : 0;
-
-		device.depthNear = camera.near;
-		device.depthFar = camera.far;
-
-		device.getFrameData( frameData );
-
-		//
-
-		if ( referenceSpaceType === 'local-floor' ) {
-
-			var stageParameters = device.stageParameters;
-
-			if ( stageParameters ) {
-
-				standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
-
-			} else {
-
-				standingMatrix.makeTranslation( 0, userHeight, 0 );
-
-			}
-
-		}
-
-
-		var pose = frameData.pose;
-
-		tempCamera.matrix.copy( standingMatrix );
-		tempCamera.matrix.decompose( tempCamera.position, tempCamera.quaternion, tempCamera.scale );
-
-		if ( pose.orientation !== null ) {
-
-			tempQuaternion.fromArray( pose.orientation );
-			tempCamera.quaternion.multiply( tempQuaternion );
-
-		}
-
-		if ( pose.position !== null ) {
-
-			tempQuaternion.setFromRotationMatrix( standingMatrix );
-			tempPosition.fromArray( pose.position );
-			tempPosition.applyQuaternion( tempQuaternion );
-			tempCamera.position.add( tempPosition );
-
-		}
-
-		tempCamera.updateMatrixWorld();
-
-		//
-
-		camera.matrixWorld.copy( tempCamera.matrixWorld );
-
-		var children = camera.children;
-
-		for ( var i = 0, l = children.length; i < l; i ++ ) {
-
-			children[ i ].updateMatrixWorld( true );
-
-		}
-
-		//
-
-		cameraL.near = camera.near;
-		cameraR.near = camera.near;
-
-		cameraL.far = camera.far;
-		cameraR.far = camera.far;
-
-		cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
-		cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
-
-		// TODO (mrdoob) Double check this code
-
-		standingMatrixInverse.getInverse( standingMatrix );
-
-		if ( referenceSpaceType === 'local-floor' ) {
-
-			cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
-			cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
-
-		}
-
-		var parent = camera.parent;
-
-		if ( parent !== null ) {
-
-			matrixWorldInverse.getInverse( parent.matrixWorld );
-
-			cameraL.matrixWorldInverse.multiply( matrixWorldInverse );
-			cameraR.matrixWorldInverse.multiply( matrixWorldInverse );
-
-		}
-
-		// envMap and Mirror needs camera.matrixWorld
-
-		cameraL.matrixWorld.getInverse( cameraL.matrixWorldInverse );
-		cameraR.matrixWorld.getInverse( cameraR.matrixWorldInverse );
-
-		cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
-		cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
-
-		setProjectionFromUnion( cameraVR, cameraL, cameraR );
-
-		//
-
-		var layers = device.getLayers();
-
-		if ( layers.length ) {
-
-			var layer = layers[ 0 ];
-
-			updateViewportFromBounds( cameraL.viewport, layer.leftBounds );
-			updateViewportFromBounds( cameraR.viewport, layer.rightBounds );
-
-		}
-
-		updateControllers();
-
-		return cameraVR;
-
-	};
-
-	this.getStandingMatrix = function () {
-
-		return standingMatrix;
-
-	};
-
-	this.isPresenting = isPresenting;
-
-	// Animation Loop
-
-	var animation = new WebGLAnimation();
-
-	this.setAnimationLoop = function ( callback ) {
-
-		animation.setAnimationLoop( callback );
-
-		if ( isPresenting() ) animation.start();
-
-	};
-
-	this.submitFrame = function () {
-
-		if ( isPresenting() ) device.submitFrame();
-
-	};
-
-	this.dispose = function () {
-
-		if ( typeof window !== 'undefined' ) {
-
-			window.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange );
-
-		}
-
-	};
-
-	// DEPRECATED
-
-	this.setFrameOfReferenceType = function () {
-
-		console.warn( 'THREE.WebVRManager: setFrameOfReferenceType() has been deprecated.' );
-
-	};
-
-}
-
-Object.assign( WebVRManager.prototype, EventDispatcher.prototype );
-
-export { WebVRManager };

+ 0 - 3
src/renderers/webvr/WebVRUtils.d.ts

@@ -1,3 +0,0 @@
-import { Camera } from '../../cameras/Camera';
-
-export function setProjectionFromUnion( camera: Camera, cameraL: Camera, cameraR: Camera ): void;

+ 0 - 66
src/renderers/webvr/WebVRUtils.js

@@ -1,66 +0,0 @@
-/**
- * @author jsantell / https://www.jsantell.com/
- * @author mrdoob / http://mrdoob.com/
- */
-
-import { Vector3 } from '../../math/Vector3.js';
-
-var cameraLPos = new Vector3();
-var cameraRPos = new Vector3();
-
-/**
- * Assumes 2 cameras that are parallel and share an X-axis, and that
- * the cameras' projection and world matrices have already been set.
- * And that near and far planes are identical for both cameras.
- * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
- */
-function setProjectionFromUnion( camera, cameraL, cameraR ) {
-
-	cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
-	cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
-
-	var ipd = cameraLPos.distanceTo( cameraRPos );
-
-	var projL = cameraL.projectionMatrix.elements;
-	var projR = cameraR.projectionMatrix.elements;
-
-	// VR systems will have identical far and near planes, and
-	// most likely identical top and bottom frustum extents.
-	// Use the left camera for these values.
-	var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
-	var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
-	var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
-	var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
-
-	var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
-	var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
-	var left = near * leftFov;
-	var right = near * rightFov;
-
-	// Calculate the new camera's position offset from the
-	// left camera. xOffset should be roughly half `ipd`.
-	var zOffset = ipd / ( - leftFov + rightFov );
-	var xOffset = zOffset * - leftFov;
-
-	// TODO: Better way to apply this offset?
-	cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
-	camera.translateX( xOffset );
-	camera.translateZ( zOffset );
-	camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
-	camera.matrixWorldInverse.getInverse( camera.matrixWorld );
-
-	// Find the union of the frustum values of the cameras and scale
-	// the values so that the near plane's position does not change in world space,
-	// although must now be relative to the new union camera.
-	var near2 = near + zOffset;
-	var far2 = far + zOffset;
-	var left2 = left - xOffset;
-	var right2 = right + ( ipd - xOffset );
-	var top2 = topFov * far / far2 * near2;
-	var bottom2 = bottomFov * far / far2 * near2;
-
-	camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
-
-}
-
-export { setProjectionFromUnion };

+ 0 - 0
src/renderers/webvr/WebXRManager.d.ts → src/renderers/webxr/WebXRManager.d.ts


+ 63 - 3
src/renderers/webvr/WebXRManager.js → src/renderers/webxr/WebXRManager.js

@@ -2,14 +2,14 @@
  * @author mrdoob / http://mrdoob.com/
  */
 
+import { ArrayCamera } from '../../cameras/ArrayCamera.js';
 import { EventDispatcher } from '../../core/EventDispatcher.js';
 import { Group } from '../../objects/Group.js';
 import { Matrix4 } from '../../math/Matrix4.js';
-import { Vector4 } from '../../math/Vector4.js';
-import { ArrayCamera } from '../../cameras/ArrayCamera.js';
 import { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';
+import { Vector3 } from '../../math/Vector3.js';
+import { Vector4 } from '../../math/Vector4.js';
 import { WebGLAnimation } from '../webgl/WebGLAnimation.js';
-import { setProjectionFromUnion } from './WebVRUtils.js';
 
 function WebXRManager( renderer, gl ) {
 
@@ -181,6 +181,66 @@ function WebXRManager( renderer, gl ) {
 
 	//
 
+	var cameraLPos = new Vector3();
+	var cameraRPos = new Vector3();
+
+	/**
+	 * @author jsantell / https://www.jsantell.com/
+	 *
+	 * Assumes 2 cameras that are parallel and share an X-axis, and that
+	 * the cameras' projection and world matrices have already been set.
+	 * And that near and far planes are identical for both cameras.
+	 * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
+	 */
+	function setProjectionFromUnion( camera, cameraL, cameraR ) {
+
+		cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
+		cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
+
+		var ipd = cameraLPos.distanceTo( cameraRPos );
+
+		var projL = cameraL.projectionMatrix.elements;
+		var projR = cameraR.projectionMatrix.elements;
+
+		// VR systems will have identical far and near planes, and
+		// most likely identical top and bottom frustum extents.
+		// Use the left camera for these values.
+		var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
+		var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
+		var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
+		var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
+
+		var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
+		var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
+		var left = near * leftFov;
+		var right = near * rightFov;
+
+		// Calculate the new camera's position offset from the
+		// left camera. xOffset should be roughly half `ipd`.
+		var zOffset = ipd / ( - leftFov + rightFov );
+		var xOffset = zOffset * - leftFov;
+
+		// TODO: Better way to apply this offset?
+		cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
+		camera.translateX( xOffset );
+		camera.translateZ( zOffset );
+		camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
+		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+
+		// Find the union of the frustum values of the cameras and scale
+		// the values so that the near plane's position does not change in world space,
+		// although must now be relative to the new union camera.
+		var near2 = near + zOffset;
+		var far2 = far + zOffset;
+		var left2 = left - xOffset;
+		var right2 = right + ( ipd - xOffset );
+		var top2 = topFov * far / far2 * near2;
+		var bottom2 = bottomFov * far / far2 * near2;
+
+		camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
+
+	}
+
 	function updateCamera( camera, parent ) {
 
 		if ( parent === null ) {

+ 0 - 3
test/three.source.unit.js

@@ -266,9 +266,6 @@ import './unit/src/renderers/webgl/WebGLTextures.tests';
 import './unit/src/renderers/webgl/WebGLUniforms.tests';
 import './unit/src/renderers/webgl/WebGLUtils.tests';
 
-//src/renderers/webvr
-import './unit/src/renderers/webvr/WebVRManager.tests';
-
 
 //src/scenes
 import './unit/src/scenes/Fog.tests';

+ 0 - 56
test/unit/src/renderers/webvr/WebVRManager.tests.js

@@ -1,56 +0,0 @@
-/**
- * @author TristanVALCKE / https://github.com/Itee
- */
-/* global QUnit */
-
-import { WebVRManager } from '../../../../../src/renderers/webvr/WebVRManager';
-
-export default QUnit.module( 'Renderers', () => {
-
-	QUnit.module( 'WebGL', () => {
-
-		QUnit.module( 'WebVRManager', () => {
-
-			// INSTANCING
-			QUnit.todo( "Instancing", ( assert ) => {
-
-				assert.ok( false, "everything's gonna be alright" );
-
-			} );
-
-			// PUBLIC STUFF
-			QUnit.todo( "getDevice", ( assert ) => {
-
-				assert.ok( false, "everything's gonna be alright" );
-
-			} );
-
-			QUnit.todo( "setDevice", ( assert ) => {
-
-				assert.ok( false, "everything's gonna be alright" );
-
-			} );
-
-			QUnit.todo( "getCamera", ( assert ) => {
-
-				assert.ok( false, "everything's gonna be alright" );
-
-			} );
-
-			QUnit.todo( "submitFrame", ( assert ) => {
-
-				assert.ok( false, "everything's gonna be alright" );
-
-			} );
-
-			QUnit.todo( "dispose", ( assert ) => {
-
-				assert.ok( false, "everything's gonna be alright" );
-
-			} );
-
-		} );
-
-	} );
-
-} );

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