Browse Source

#12397 Flipped position of logger and manager in LoaderBase, MeshSpray and OBJLoader2.
WWParallels demo use the same logger everywhere now.
Updated documentation.

Kai Salmen 7 years ago
parent
commit
eb4003ef0b

+ 2 - 2
docs/examples/loaders/LoaderSupport.html

@@ -398,10 +398,10 @@
 		<a name="LoaderBase"></a><h1>LoaderBase</h1>
 		<h2>Constructor</h2>
 
-		<h3>LoaderBase( [page:LoaderSupport.ConsoleLogger logger], [page:LoadingManager manager] )</h3>
+		<h3>LoaderBase( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger logger] )</h3>
 		<div>
-			[page:LoaderSupport.ConsoleLogger logger] - logger to be used
 			[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
+			[page:LoaderSupport.ConsoleLogger logger] - logger to be used
 		</div>
 		<div>
 			Base class to be used by loaders.

+ 7 - 6
docs/examples/loaders/OBJLoader2.html

@@ -12,10 +12,10 @@
 		<h1>[name]</h1>
 
 		<div class="desc">A loader for loading a <em>.obj</em> resource. <br />
-		The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> is a simple data-format 
-		that represents 3D geometry in a human redeable format as, the position of each vertex, the UV position of 
-		each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of 
-		vertices, and texture vertices.
+			The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> is a simple data-format
+			that represents 3D geometry in a human redeable format as, the position of each vertex, the UV position of
+			each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of
+			vertices, and texture vertices.
 		</div>
 
 		<h2>Examples</h2>
@@ -40,9 +40,10 @@
 
 		<h2>Constructor</h2>
 
-		<h3>[name]( [page:LoadingManager manager] )</h3>
+		<h3>[name]( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger logger] )</h3>
 		<div>
 			[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
+			[page:LoaderSupport.ConsoleLogger logger] - logger to be used
 		</div>
 		<div>
 			Use [name] to load OBJ data from files or to parse OBJ data from arraybuffer or text.
@@ -73,7 +74,7 @@
 		<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )</h3>
 		<div>
 			[page:String url] - A string containing the path/URL of the <em>.obj</em> file.<br>
-			[page:Function onLoad] - (optional) A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
+			[page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
 			[page:Function onProgress] - (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br>
 			[page:Function onError] - (optional) A function to be called if an error occurrs during loading. The function receives the error as an argument.<br>
 			[page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>

+ 4 - 4
examples/js/loaders/LoaderSupport.js

@@ -714,17 +714,17 @@ THREE.LoaderSupport.Builder = (function () {
  * Base class to be used by loaders.
  * @class
  *
- * @param {THREE.LoaderSupport.ConsoleLogger} logger logger to be used
  * @param {THREE.DefaultLoadingManager} [manager] The loadingManager for the loader to use. Default is {@link THREE.DefaultLoadingManager}
+ * @param {THREE.LoaderSupport.ConsoleLogger} logger logger to be used
  */
 THREE.LoaderSupport.LoaderBase = (function () {
 
 	var Validator = THREE.LoaderSupport.Validator;
 	var ConsoleLogger = THREE.LoaderSupport.ConsoleLogger;
 
-	function LoaderBase( logger, manager ) {
-		this.logger = Validator.verifyInput( logger, new ConsoleLogger() );
+	function LoaderBase( manager, logger ) {
 		this.manager = Validator.verifyInput( manager, THREE.DefaultLoadingManager );
+		this.logger = Validator.verifyInput( logger, new ConsoleLogger() );
 
 		this.modelName = '';
 		this.instanceNo = 0;
@@ -1429,7 +1429,7 @@ THREE.LoaderSupport.WorkerDirector = (function () {
 	WorkerDirector.prototype._buildLoader = function ( instanceNo ) {
 		var classDef = this.workerDescription.classDef;
 		var loader = Object.create( classDef.prototype );
-		this.workerDescription.classDef.call( loader, this.logger );
+		this.workerDescription.classDef.call( loader, null, this.logger );
 
 		// verify that all required functions are implemented
 		if ( ! loader.hasOwnProperty( 'instanceNo' ) ) throw classDef.name + ' has no property "instanceNo".';

+ 10 - 9
examples/js/loaders/OBJLoader2.js

@@ -12,6 +12,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
  * @class
  *
  * @param {THREE.DefaultLoadingManager} [manager] The loadingManager for the loader to use. Default is {@link THREE.DefaultLoadingManager}
+ * @param {THREE.LoaderSupport.ConsoleLogger} logger logger to be used
  */
 THREE.OBJLoader2 = (function () {
 
@@ -23,8 +24,8 @@ THREE.OBJLoader2 = (function () {
 	OBJLoader2.prototype = Object.create( THREE.LoaderSupport.LoaderBase.prototype );
 	OBJLoader2.prototype.constructor = OBJLoader2;
 
-	function OBJLoader2( logger, manager ) {
-		THREE.LoaderSupport.LoaderBase.call( this, logger, manager );
+	function OBJLoader2( manager, logger ) {
+		THREE.LoaderSupport.LoaderBase.call( this, manager, logger );
 		this.logger.logInfo( 'Using THREE.OBJLoader2 version: ' + OBJLOADER2_VERSION );
 
 		this.materialPerSmoothingGroup = false;
@@ -45,15 +46,15 @@ THREE.OBJLoader2 = (function () {
 	};
 
 	/**
-	 * Use this convenient method to load an OBJ file at the given URL. Per default the fileLoader uses an arraybuffer.
+	 * Use this convenient method to load an OBJ file at the given URL. By default the fileLoader uses an arraybuffer.
 	 * @memberOf THREE.OBJLoader2
 	 *
-	 * @param {string} url URL of the file to load
-	 * @param {callback} onLoad Called after loading was successfully completed
-	 * @param {callback} onProgress Called to report progress of loading. The argument will be the XMLHttpRequest instance, which contains {integer total} and {integer loaded} bytes.
-	 * @param {callback} onError Called after an error occurred during loading
-	 * @param {callback} onMeshAlter Called after a new mesh raw data becomes available to allow alteration
-	 * @param {boolean} useAsync If true uses async loading with worker, if false loads data synchronously
+	 * @param {string}  url A string containing the path/URL of the .obj file.
+	 * @param {callback} onLoad A function to be called after loading is successfully completed. The function receives loaded Object3D as an argument.
+	 * @param {callback} [onProgress] A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains total and Integer bytes.
+	 * @param {callback} [onError] A function to be called if an error occurs during loading. The function receives the error as an argument.
+	 * @param {callback} [onMeshAlter] A function to be called after a new mesh raw data becomes available for alteration.
+	 * @param {boolean} [useAsync] If true, uses async loading with worker, if false loads data synchronously.
 	 */
 	OBJLoader2.prototype.load = function ( url, onLoad, onProgress, onError, onMeshAlter, useAsync ) {
 		var scope = this;

+ 2 - 2
examples/webgl_loader_obj2_meshspray.html

@@ -91,8 +91,8 @@
 				MeshSpray.prototype = Object.create( THREE.LoaderSupport.LoaderBase.prototype );
 				MeshSpray.prototype.constructor = MeshSpray;
 
-				function MeshSpray( manager ) {
-					THREE.LoaderSupport.LoaderBase.call( this, manager );
+				function MeshSpray( manager, logger ) {
+					THREE.LoaderSupport.LoaderBase.call( this, manager, logger );
 					this.workerSupport = null;
 					this.logger = new ConsoleLogger();
 				};

+ 8 - 8
examples/webgl_loader_obj2_run_director.html

@@ -111,9 +111,9 @@
 					this.camera = null;
 					this.cameraTarget = this.cameraDefaults.posCameraTarget;
 
-					var logger = new THREE.LoaderSupport.ConsoleLogger();
-					logger.setEnabled( false );
-					this.workerDirector = new THREE.LoaderSupport.WorkerDirector( THREE.OBJLoader2, logger  );
+					this.logger = new THREE.LoaderSupport.ConsoleLogger();
+					this.logger.setEnabled( false );
+					this.workerDirector = new THREE.LoaderSupport.WorkerDirector( THREE.OBJLoader2, this.logger  );
 					this.workerDirector.setCrossOrigin( 'anonymous' );
 
 					this.controls = null;
@@ -199,7 +199,7 @@
 					if ( Validator.isValid( content ) && Validator.isValid( content.detail ) ) output = content.detail.text;
 
 					output = Validator.verifyInput( output, '' );
-					console.log( 'Progress:\n\t' + output.replace(/\<br\>/g, '\n\t' ) );
+					this.logger.logInfo( 'Progress:\n\t' + output.replace(/\<br\>/g, '\n\t' ) );
 					document.getElementById( 'feedback' ).innerHTML = output;
 				};
 
@@ -234,7 +234,7 @@
 						scope.allAssets.push( event.detail.loaderRootNode );
 
 						var msg = 'Worker #' + instanceNo + ': Completed loading: ' + event.detail.modelName + ' (#' + scope.workerDirector.objectsCompleted + ')';
-						console.log( msg );
+						scope.logger.logInfo( msg );
 						scope.feedbackArray[ instanceNo ] = msg;
 						scope._reportProgress( scope.feedbackArray.join( '\<br\>' ) );
 
@@ -247,7 +247,7 @@
 
 						if ( scope.reportDonwload[ instanceNo ] ) {
 							var msg = 'Worker #' + instanceNo + ': ' + text;
-							console.log( msg );
+							scope.logger.logInfo( msg );
 
 							scope.feedbackArray[ instanceNo ] = msg;
 							scope._reportProgress( scope.feedbackArray.join( '\<br\>' ) );
@@ -279,7 +279,7 @@
 					callbacks.setCallbackOnMeshAlter( callbackMeshAlter );
 
 					this.workerDirector.prepareWorkers( callbacks, maxQueueSize, maxWebWorkers );
-					console.log( 'Configuring WWManager with queue size ' + this.workerDirector.getMaxQueueSize() + ' and ' + this.workerDirector.getMaxWebWorkers() + ' workers.' );
+					this.logger.logInfo( 'Configuring WWManager with queue size ' + this.workerDirector.getMaxQueueSize() + ' and ' + this.workerDirector.getMaxWebWorkers() + ' workers.' );
 
 					var modelPrepDatas = [];
 					prepData = new THREE.LoaderSupport.PrepData( 'male02' );
@@ -349,7 +349,7 @@
 
 							if ( storedObject3d === object3d ) return;
 
-							console.log( 'Removing ' + object3d.name );
+							scope.logger.logInfo( 'Removing ' + object3d.name );
 							scope.scene.remove( object3d );
 
 							if ( object3d.hasOwnProperty( 'geometry' ) ) object3d.geometry.dispose();