瀏覽代碼

Updated builds.

Mr.doob 7 年之前
父節點
當前提交
99d5b58a77
共有 3 個文件被更改,包括 694 次插入535 次删除
  1. 147 68
      build/three.js
  2. 400 399
      build/three.min.js
  3. 147 68
      build/three.module.js

+ 147 - 68
build/three.js

@@ -7249,6 +7249,61 @@
 
 	};
 
+	/**
+	 * @author mrdoob / http://mrdoob.com/
+	 */
+
+	function WebGLAnimation() {
+
+		var context = null;
+		var isAnimating = false;
+		var animationLoop = null;
+
+		function onAnimationFrame( time, frame ) {
+
+			if ( isAnimating === false ) return;
+
+			animationLoop( time, frame );
+
+			context.requestAnimationFrame( onAnimationFrame );
+
+		}
+
+		return {
+
+			start: function () {
+
+				if ( isAnimating === true ) return;
+				if ( animationLoop === null ) return;
+
+				context.requestAnimationFrame( onAnimationFrame );
+
+				isAnimating = true;
+
+			},
+
+			stop: function () {
+
+				isAnimating = false;
+
+			},
+
+			setAnimationLoop: function ( callback ) {
+
+				animationLoop = callback;
+
+			},
+
+			setContext: function ( value ) {
+
+				context = value;
+
+			}
+
+		}
+
+	}
+
 	/**
 	 * @author mrdoob / http://mrdoob.com/
 	 */
@@ -21218,10 +21273,14 @@
 
 				renderer.setDrawingBufferSize( renderWidth * 2, renderHeight, 1 );
 
+				animation.start();
+
 			} else if ( scope.enabled ) {
 
 				renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
 
+				animation.stop();
+
 			}
 
 		}
@@ -21241,6 +21300,8 @@
 
 			if ( value !== undefined ) device = value;
 
+			animation.setContext( value );
+
 		};
 
 		this.setPoseTarget = function ( object ) {
@@ -21379,9 +21440,13 @@
 
 		this.isPresenting = isPresenting;
 
-		this.requestAnimationFrame = function ( callback ) {
+		// Animation Loop
+
+		var animation = new WebGLAnimation();
 
-			device.requestAnimationFrame( callback );
+		this.setAnimationLoop = function ( callback ) {
+
+			animation.setAnimationLoop( callback );
 
 		};
 
@@ -21401,6 +21466,14 @@
 
 		};
 
+		// DEPRECATED
+
+		this.requestAnimationFrame = function ( callback ) {
+
+			// device.requestAnimationFrame( callback );
+
+		};
+
 	}
 
 	/**
@@ -21455,18 +21528,30 @@
 
 		};
 
+		//
+
 		this.setSession = function ( value ) {
 
 			session = value;
 
 			if ( session !== null ) {
 
+				session.addEventListener( 'end', function () {
+
+					gl.bindFramebuffer( gl.FRAMEBUFFER, null );
+					animation.stop();
+
+				} );
+
 				session.baseLayer = new XRWebGLLayer( session, gl );
 				session.requestFrameOfReference( 'stage' ).then( function ( value ) {
 
 					frameOfRef = value;
 					isExclusive = session.exclusive;
 
+					animation.setContext( session );
+					animation.start();
+
 				} );
 
 			}
@@ -21481,48 +21566,55 @@
 
 		this.isPresenting = isPresenting;
 
-		this.requestAnimationFrame = function ( callback ) {
+		// Animation Loop
 
-			function onFrame( time, frame ) {
+		var onAnimationFrameCallback = null;
 
-				pose = frame.getDevicePose( frameOfRef );
+		function onAnimationFrame( time, frame ) {
 
-				var layer = session.baseLayer;
-				var views = frame.views;
+			pose = frame.getDevicePose( frameOfRef );
 
-				for ( var i = 0; i < views.length; i ++ ) {
+			var layer = session.baseLayer;
+			var views = frame.views;
 
-					var view = views[ i ];
-					var viewport = layer.getViewport( view );
-					var viewMatrix = pose.getViewMatrix( view );
+			for ( var i = 0; i < views.length; i ++ ) {
 
-					var camera = cameraVR.cameras[ i ];
-					camera.projectionMatrix.fromArray( view.projectionMatrix );
-					camera.matrixWorldInverse.fromArray( viewMatrix );
-					camera.matrixWorld.getInverse( camera.matrixWorldInverse );
-					camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
+				var view = views[ i ];
+				var viewport = layer.getViewport( view );
+				var viewMatrix = pose.getViewMatrix( view );
 
-					if ( i === 0 ) {
+				var camera = cameraVR.cameras[ i ];
+				camera.projectionMatrix.fromArray( view.projectionMatrix );
+				camera.matrixWorldInverse.fromArray( viewMatrix );
+				camera.matrixWorld.getInverse( camera.matrixWorldInverse );
+				camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
 
-						cameraVR.matrixWorld.copy( camera.matrixWorld );
-						cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
+				if ( i === 0 ) {
 
-						// HACK (mrdoob)
-						// https://github.com/w3c/webvr/issues/203
+					cameraVR.matrixWorld.copy( camera.matrixWorld );
+					cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
 
-						cameraVR.projectionMatrix.copy( camera.projectionMatrix );
+					// HACK (mrdoob)
+					// https://github.com/w3c/webvr/issues/203
 
-					}
+					cameraVR.projectionMatrix.copy( camera.projectionMatrix );
 
 				}
 
-				gl.bindFramebuffer( gl.FRAMEBUFFER, session.baseLayer.framebuffer );
+			}
 
-				callback();
+			gl.bindFramebuffer( gl.FRAMEBUFFER, session.baseLayer.framebuffer );
 
-			}
+			if ( onAnimationFrameCallback ) onAnimationFrameCallback();
+
+		}
 
-			session.requestAnimationFrame( onFrame );
+		var animation = new WebGLAnimation();
+		animation.setAnimationLoop( onAnimationFrame );
+
+		this.setAnimationLoop = function ( callback ) {
+
+			onAnimationFrameCallback = callback;
 
 		};
 
@@ -21535,6 +21627,8 @@
 
 		};
 
+		this.requestAnimationFrame = function () {};
+
 		this.submitFrame = function () {};
 
 	}
@@ -21999,7 +22093,7 @@
 
 			vr.dispose();
 
-			stopAnimation();
+			animation.stop();
 
 		};
 
@@ -22510,53 +22604,25 @@
 
 		// Animation Loop
 
-		var isAnimating = false;
-		var onAnimationFrame = null;
-
-		function startAnimation() {
-
-			if ( isAnimating ) return;
-
-			requestAnimationLoopFrame();
-
-			isAnimating = true;
-
-		}
+		var onAnimationFrameCallback = null;
 
-		function stopAnimation() {
+		function onAnimationFrame() {
 
-			isAnimating = false;
+			if ( vr.isPresenting() ) return;
+			if ( onAnimationFrameCallback ) onAnimationFrameCallback();
 
 		}
 
-		function requestAnimationLoopFrame() {
-
-			if ( vr.isPresenting() ) {
-
-				vr.requestAnimationFrame( animationLoop );
-
-			} else {
-
-				window.requestAnimationFrame( animationLoop );
+		var animation = new WebGLAnimation();
+		animation.setAnimationLoop( onAnimationFrame );
+		animation.setContext( window );
 
-			}
-
-		}
-
-		function animationLoop( time ) {
-
-			if ( isAnimating === false ) return;
+		this.setAnimationLoop = function ( callback ) {
 
-			onAnimationFrame( time );
+			onAnimationFrameCallback = callback;
+			vr.setAnimationLoop( callback );
 
-			requestAnimationLoopFrame();
-
-		}
-
-		this.animate = function ( callback ) {
-
-			onAnimationFrame = callback;
-			onAnimationFrame !== null ? startAnimation() : stopAnimation();
+			animation.start();
 
 		};
 
@@ -25839,6 +25905,12 @@
 
 		var i, j;
 
+		if ( func.length < 3 ) {
+
+			console.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' );
+
+		}
+
 		// generate vertices, normals and uvs
 
 		var sliceCount = slices + 1;
@@ -38352,7 +38424,7 @@
 
 	function createPaths( text, size, divisions, data ) {
 
-		var chars = String( text ).split( '' );
+		var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // see #13988
 		var scale = size / data.resolution;
 		var line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;
 
@@ -45742,6 +45814,13 @@
 
 	Object.assign( WebGLRenderer.prototype, {
 
+		animate: function ( callback ) {
+
+			console.warn( 'THREE.WebGLRenderer: .animate() is now .setAnimationLoop().' );
+			this.setAnimationLoop( callback );
+
+		},
+
 		getCurrentRenderTarget: function () {
 
 			console.warn( 'THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().' );

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


+ 147 - 68
build/three.module.js

@@ -7243,6 +7243,61 @@ ShaderLib.physical = {
 
 };
 
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+function WebGLAnimation() {
+
+	var context = null;
+	var isAnimating = false;
+	var animationLoop = null;
+
+	function onAnimationFrame( time, frame ) {
+
+		if ( isAnimating === false ) return;
+
+		animationLoop( time, frame );
+
+		context.requestAnimationFrame( onAnimationFrame );
+
+	}
+
+	return {
+
+		start: function () {
+
+			if ( isAnimating === true ) return;
+			if ( animationLoop === null ) return;
+
+			context.requestAnimationFrame( onAnimationFrame );
+
+			isAnimating = true;
+
+		},
+
+		stop: function () {
+
+			isAnimating = false;
+
+		},
+
+		setAnimationLoop: function ( callback ) {
+
+			animationLoop = callback;
+
+		},
+
+		setContext: function ( value ) {
+
+			context = value;
+
+		}
+
+	}
+
+}
+
 /**
  * @author mrdoob / http://mrdoob.com/
  */
@@ -21212,10 +21267,14 @@ function WebVRManager( renderer ) {
 
 			renderer.setDrawingBufferSize( renderWidth * 2, renderHeight, 1 );
 
+			animation.start();
+
 		} else if ( scope.enabled ) {
 
 			renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
 
+			animation.stop();
+
 		}
 
 	}
@@ -21235,6 +21294,8 @@ function WebVRManager( renderer ) {
 
 		if ( value !== undefined ) device = value;
 
+		animation.setContext( value );
+
 	};
 
 	this.setPoseTarget = function ( object ) {
@@ -21373,9 +21434,13 @@ function WebVRManager( renderer ) {
 
 	this.isPresenting = isPresenting;
 
-	this.requestAnimationFrame = function ( callback ) {
+	// Animation Loop
+
+	var animation = new WebGLAnimation();
 
-		device.requestAnimationFrame( callback );
+	this.setAnimationLoop = function ( callback ) {
+
+		animation.setAnimationLoop( callback );
 
 	};
 
@@ -21395,6 +21460,14 @@ function WebVRManager( renderer ) {
 
 	};
 
+	// DEPRECATED
+
+	this.requestAnimationFrame = function ( callback ) {
+
+		// device.requestAnimationFrame( callback );
+
+	};
+
 }
 
 /**
@@ -21449,18 +21522,30 @@ function WebXRManager( gl ) {
 
 	};
 
+	//
+
 	this.setSession = function ( value ) {
 
 		session = value;
 
 		if ( session !== null ) {
 
+			session.addEventListener( 'end', function () {
+
+				gl.bindFramebuffer( gl.FRAMEBUFFER, null );
+				animation.stop();
+
+			} );
+
 			session.baseLayer = new XRWebGLLayer( session, gl );
 			session.requestFrameOfReference( 'stage' ).then( function ( value ) {
 
 				frameOfRef = value;
 				isExclusive = session.exclusive;
 
+				animation.setContext( session );
+				animation.start();
+
 			} );
 
 		}
@@ -21475,48 +21560,55 @@ function WebXRManager( gl ) {
 
 	this.isPresenting = isPresenting;
 
-	this.requestAnimationFrame = function ( callback ) {
+	// Animation Loop
 
-		function onFrame( time, frame ) {
+	var onAnimationFrameCallback = null;
 
-			pose = frame.getDevicePose( frameOfRef );
+	function onAnimationFrame( time, frame ) {
 
-			var layer = session.baseLayer;
-			var views = frame.views;
+		pose = frame.getDevicePose( frameOfRef );
 
-			for ( var i = 0; i < views.length; i ++ ) {
+		var layer = session.baseLayer;
+		var views = frame.views;
 
-				var view = views[ i ];
-				var viewport = layer.getViewport( view );
-				var viewMatrix = pose.getViewMatrix( view );
+		for ( var i = 0; i < views.length; i ++ ) {
 
-				var camera = cameraVR.cameras[ i ];
-				camera.projectionMatrix.fromArray( view.projectionMatrix );
-				camera.matrixWorldInverse.fromArray( viewMatrix );
-				camera.matrixWorld.getInverse( camera.matrixWorldInverse );
-				camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
+			var view = views[ i ];
+			var viewport = layer.getViewport( view );
+			var viewMatrix = pose.getViewMatrix( view );
 
-				if ( i === 0 ) {
+			var camera = cameraVR.cameras[ i ];
+			camera.projectionMatrix.fromArray( view.projectionMatrix );
+			camera.matrixWorldInverse.fromArray( viewMatrix );
+			camera.matrixWorld.getInverse( camera.matrixWorldInverse );
+			camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
 
-					cameraVR.matrixWorld.copy( camera.matrixWorld );
-					cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
+			if ( i === 0 ) {
 
-					// HACK (mrdoob)
-					// https://github.com/w3c/webvr/issues/203
+				cameraVR.matrixWorld.copy( camera.matrixWorld );
+				cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
 
-					cameraVR.projectionMatrix.copy( camera.projectionMatrix );
+				// HACK (mrdoob)
+				// https://github.com/w3c/webvr/issues/203
 
-				}
+				cameraVR.projectionMatrix.copy( camera.projectionMatrix );
 
 			}
 
-			gl.bindFramebuffer( gl.FRAMEBUFFER, session.baseLayer.framebuffer );
+		}
 
-			callback();
+		gl.bindFramebuffer( gl.FRAMEBUFFER, session.baseLayer.framebuffer );
 
-		}
+		if ( onAnimationFrameCallback ) onAnimationFrameCallback();
+
+	}
 
-		session.requestAnimationFrame( onFrame );
+	var animation = new WebGLAnimation();
+	animation.setAnimationLoop( onAnimationFrame );
+
+	this.setAnimationLoop = function ( callback ) {
+
+		onAnimationFrameCallback = callback;
 
 	};
 
@@ -21529,6 +21621,8 @@ function WebXRManager( gl ) {
 
 	};
 
+	this.requestAnimationFrame = function () {};
+
 	this.submitFrame = function () {};
 
 }
@@ -21993,7 +22087,7 @@ function WebGLRenderer( parameters ) {
 
 		vr.dispose();
 
-		stopAnimation();
+		animation.stop();
 
 	};
 
@@ -22504,53 +22598,25 @@ function WebGLRenderer( parameters ) {
 
 	// Animation Loop
 
-	var isAnimating = false;
-	var onAnimationFrame = null;
-
-	function startAnimation() {
-
-		if ( isAnimating ) return;
-
-		requestAnimationLoopFrame();
-
-		isAnimating = true;
-
-	}
+	var onAnimationFrameCallback = null;
 
-	function stopAnimation() {
+	function onAnimationFrame() {
 
-		isAnimating = false;
+		if ( vr.isPresenting() ) return;
+		if ( onAnimationFrameCallback ) onAnimationFrameCallback();
 
 	}
 
-	function requestAnimationLoopFrame() {
-
-		if ( vr.isPresenting() ) {
-
-			vr.requestAnimationFrame( animationLoop );
-
-		} else {
-
-			window.requestAnimationFrame( animationLoop );
+	var animation = new WebGLAnimation();
+	animation.setAnimationLoop( onAnimationFrame );
+	animation.setContext( window );
 
-		}
-
-	}
-
-	function animationLoop( time ) {
-
-		if ( isAnimating === false ) return;
+	this.setAnimationLoop = function ( callback ) {
 
-		onAnimationFrame( time );
+		onAnimationFrameCallback = callback;
+		vr.setAnimationLoop( callback );
 
-		requestAnimationLoopFrame();
-
-	}
-
-	this.animate = function ( callback ) {
-
-		onAnimationFrame = callback;
-		onAnimationFrame !== null ? startAnimation() : stopAnimation();
+		animation.start();
 
 	};
 
@@ -25833,6 +25899,12 @@ function ParametricBufferGeometry( func, slices, stacks ) {
 
 	var i, j;
 
+	if ( func.length < 3 ) {
+
+		console.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' );
+
+	}
+
 	// generate vertices, normals and uvs
 
 	var sliceCount = slices + 1;
@@ -38346,7 +38418,7 @@ Object.assign( Font.prototype, {
 
 function createPaths( text, size, divisions, data ) {
 
-	var chars = String( text ).split( '' );
+	var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // see #13988
 	var scale = size / data.resolution;
 	var line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;
 
@@ -45736,6 +45808,13 @@ Object.defineProperties( ShaderMaterial.prototype, {
 
 Object.assign( WebGLRenderer.prototype, {
 
+	animate: function ( callback ) {
+
+		console.warn( 'THREE.WebGLRenderer: .animate() is now .setAnimationLoop().' );
+		this.setAnimationLoop( callback );
+
+	},
+
 	getCurrentRenderTarget: function () {
 
 		console.warn( 'THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().' );

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