瀏覽代碼

Added documentation for OBJLoader2 and WWOBJLoader2 including all sub-classes.

Kai Salmen 8 年之前
父節點
當前提交
583904e4c8
共有 3 個文件被更改,包括 377 次插入0 次删除
  1. 114 0
      docs/examples/loaders/OBJLoader2.html
  2. 261 0
      docs/examples/loaders/WWOBJLoader2.html
  3. 2 0
      docs/list.js

+ 114 - 0
docs/examples/loaders/OBJLoader2.html

@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8" />
+		<base href="../../" />
+		<script src="list.js"></script>
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+
+		<h1>[name]</h1>
+
+		<div class="desc">A loader for loading an <em>.obj</em> resource.</div>
+
+		<h2>Example</h2>
+
+		<code>
+		// instantiate the loader
+		var loader = new THREE.OBJLoader2();
+
+		// function called on successful load
+		var intergrateIntoScene = function ( object ) {
+			scene.add( object );
+		};
+
+		// load a resource from provided URL
+		loader.load( 'obj/female02/female02.obj', intergrateIntoScene );
+		</code>
+
+		[example:webgl_loader_obj2]
+
+
+		<h2>Constructor</h2>
+
+		<h3>[name]( [page:LoadingManager manager] )</h3>
+		<div>
+		[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
+		</div>
+		<div>
+			Use [name] to load OBJ data from files or to parse OBJ data from arraybuffer or text.
+		</div>
+
+		<h2>Properties</h2>
+
+
+		<h2>Methods</h2>
+
+		<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Boolean useArrayBuffer] )</h3>
+		<div>
+			[page:String url] — URL of the file to load<br />
+			[page:Function onLoad] — Called after loading was successfully completed. The argument will be the loaded [page:Object3D].<br />
+			[page:Function onProgress] — Called to report progress of loading. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
+			[page:Function onError]  Called after an error occurred during loading.<br />
+			[page:boolean useArrayBuffer] — Set this to false to force string based parsing<br />
+		</div>
+		<div>
+			Use this convenient method to load an OBJ file at the given URL. Per default the fileLoader uses an arraybuffer
+		</div>
+
+		<h3>[method:Object3D parse]( [page:ArrayBuffer arrayBuffer] )</h3>
+		<div>
+			[page:ArrayBuffer arrayBuffer] — OBJ data as Uint8Array
+		</div>
+		<div>
+			Default parse function: Parses OBJ file content stored in arrayBuffer and returns the [page:Object3D sceneGraphBaseNode].
+		</div>
+
+		<h3>[method:Object3D parseText]( [page:String test] )</h3>
+		<div>
+			[page:String text] — OBJ data as string
+		</div>
+		<div>
+			Legacy parse function: Parses OBJ file content stored in string and returns the [page:Object3D sceneGraphBaseNode].
+		</div>
+
+		<h3>[method:null setMaterials] ( Array of [page:Material materials] )</h3>
+		<div>
+			Array of [page:Material materials] — Array of [page:Material Materials] from MTLLoader
+		</div>
+		<div>
+			Set materials loaded by MTLLoader or any other supplier of an Array of [page:Material Materials].
+		</div>
+
+		<h3>[method:null setPath] ( [page:String path] )</h3>
+		<div>
+			[page:String path] — The basePath
+		</div>
+		<div>
+			Base path to use.
+		</div>
+
+		<h3>[method:null setSceneGraphBaseNode] ( [page:Object3D sceneGraphBaseNode] )</h3>
+		<div>
+			[page:Object3D sceneGraphBaseNode] — Scenegraph object where meshes will be attached
+		</div>
+		<div>
+			Set the node where the loaded objects will be attached.
+		</div>
+
+		<h3>[method:null setDebug]( [page:Boolean parserDebug], [page:Boolean meshCreatorDebug] )</h3>
+		<div>
+			[page:Boolean parserDebug] — Internal Parser will produce debug output<br>
+			[page:Boolean meshCreatorDebug] — Internal MeshCreator will produce debug output
+		</div>
+		<div>
+			Allows to set debug mode for the parser and the meshCreator.
+		</div>
+
+		<h2>Source</h2>
+
+		[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]
+	</body>
+</html>

+ 261 - 0
docs/examples/loaders/WWOBJLoader2.html

@@ -0,0 +1,261 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8" />
+		<base href="../../" />
+		<script src="list.js"></script>
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+
+		<h1>[name]</h1>
+
+		<div class="desc">A loader for loading an <em>.obj</em> resource within a web worker.</div>
+
+		<h2>Sub-Classes</h2>
+		[page:WWOBJLoader2.PrepDataArrayBuffer]<br>
+		[page:WWOBJLoader2.PrepDataFile]<br>
+		[page:WWOBJLoader2.WWOBJLoader2Director]
+
+		<h2>Example</h2>
+
+		<code>
+			// instantiate the loader
+			var loader = new THREE.OBJLoader2.WWOBJLoader2();
+
+			// load an OBJ file by providing a name, the path and the file name
+			var prepData = new THREE.OBJLoader2.WWOBJLoader2.PrepDataFile(
+				'female02',
+				'obj/female02/',
+				'female02.obj'
+			);
+
+			// set where to add the loaded data in the scene graph.
+			prepData.setSceneGraphBaseNode( scene );
+
+			// provide the preparation data to the loader and let it run.
+			loader.prepareRun( prepData );
+			loader.run();
+		</code>
+
+		[example:webgl_loader_obj2_ww] — Simple example that allows to load own models via file selection.<br>
+		[example:webgl_loader_obj2_ww_parallels] — Advanced example using [page:WWOBJLoader2.WWOBJLoader2Director] for orchestration of multiple workers.
+
+
+		<h2>Constructor</h2>
+
+		<h3>[name]()</h3>
+		<div>
+			OBJ data will be loaded by dynamically created web worker.<br>
+			First feed instructions with: [page:WWOBJLoader2.prepareRun prepareRun]<br>
+			Then execute with: [page:WWOBJLoader2.run run]
+		</div>
+
+		<h2>Properties</h2>
+
+
+		<h2>Methods</h2>
+
+		<h3>[method:null prepareRun]( [page:Object params] )</h3>
+		<div>
+			[page:Object params] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
+		</div>
+		<div>
+			Set all parameters for required for execution of [page:WWOBJLoader2.run run].
+		</div>
+
+
+		<h3>[method:null run]()</h3>
+		<div>
+			Run the loader according the preparation instruction provided in [page:WWOBJLoader2.prepareRun prepareRun].
+		</div>
+
+
+		<h3>[method:null setCrossOrigin]( [page:String crossOrigin] )</h3>
+		<div>
+			[page:String crossOrigin] — CORS value
+		</div>
+		<div>
+			Sets the CORS string to be used.
+		</div>
+
+
+		<h3>[method:null setDebug]( [page:Boolean enabled] )</h3>
+		<div>
+			[page:Boolean enabled] — True or false
+		</div>
+		<div>
+			Enable or disable debug logging.
+		</div>
+
+
+		<h3>[method:null setRequestTerminate]( [page:Boolean requestTerminate] )</h3>
+		<div>
+			[page:Boolean requestTerminate] — True or false
+		</div>
+		<div>
+			Call requestTerminate to terminate the web worker and free local resource after execution.
+		</div>
+
+
+		<h3>[method:null registerCallbackCompletedLoading]( [page:Function callbackCompletedLoading] )</h3>
+		<div>
+			[page:Function callbackCompletedLoading] — 	Callback function for described functionality
+		</div>
+		<div>
+			Register callback function that is called once loading of the complete model is completed.
+		</div>
+
+
+		<h3>[method:null registerCallbackProgress]( [page:Function callbackProgress] )</h3>
+		<div>
+			[page:Function callbackProgress] — 	Callback function for described functionality
+		</div>
+		<div>
+			Register callback function that is invoked by internal function "_announceProgress" to print feedback.
+		</div>
+
+
+		<h3>[method:null registerCallbackMaterialsLoaded]( [page:Function callbackMaterialsLoaded] )</h3>
+		<div>
+			[page:Function callbackMaterialsLoaded] — 	Callback function for described functionality
+		</div>
+		<div>
+			Register callback function that is called once materials have been loaded. It allows to alter and return materials.
+		</div>
+
+
+		<h3>[method:null registerCallbackMeshLoaded]( [page:Function callbackMeshLoaded] )</h3>
+		<div>
+			[page:Function callbackMeshLoaded] — 	Callback function for described functionality
+		</div>
+		<div>
+			Register callback function that is called every time a mesh was loaded. Return altered [page:Material] or null from callback.
+		</div>
+
+		<h3>[method:null registerCallbackErrorWhileLoading]( [page:Function callbackErrorWhileLoading] )</h3>
+		<div>
+			[page:Function callbackErrorWhileLoading] — 	Callback function for described functionality
+		</div>
+		<div>
+			Register callback function that is called to report an error that prevented loading.
+		</div>
+
+
+		<h2>Sub-Classes</h2>
+		<br>
+		<a name="PrepDataArrayBuffer"></a><h1>PrepDataArrayBuffer</h1>
+		<h2>Constructor</h2>
+
+		<h3>PrepDataArrayBuffer( [page:String modelName], [page:Uint8Array objAsArrayBuffer], [page:String pathTexture], [page:String mtlAsString] )</h3>
+		<div>
+			[page:String modelName] — Overall name of the model<br>
+			[page:Uint8Array objAsArrayBuffer] — OBJ file content as ArrayBuffer<br>
+			[page:String pathTexture] — Path to texture files<br>
+			[page:String mtlAsString] — MTL file content as string
+			[page:Object3D sceneGraphBaseNode] [page:Object3D] where meshes will be attached
+			[page:Boolean streamMeshes] Singles meshes are directly integrated into scene when loaded or later
+			[page:Boolean requestTerminate] Request termination of web worker and free local resources after execution
+		</div>
+		<div>
+			Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ from given ArrayBuffer and MTL from given String.
+		</div>
+		<br>
+		<br>
+
+
+		<a name="PrepDataFile"></a><h1>PrepDataFile</h1>
+		<h2>Constructor</h2>
+
+		<h3>PrepDataFile( [page:String modelName], [page:String pathObj], [page:String fileObj], [page:String pathTexture], [page:String fileMtl] )</h3>
+		<div>
+			[page:String modelName] — Overall name of the model<br>
+			[page:String pathObj] — Path to OBJ file<br>
+			[page:String fileObj] — OBJ file name<br>
+			[page:String pathTexture] — Path to texture files<br>
+			[page:String fileMtl] — MTL file name
+			[page:Object3D sceneGraphBaseNode] [page:Object3D] where meshes will be attached
+			[page:Boolean streamMeshes] Singles meshes are directly integrated into scene when loaded or later
+			[page:Boolean requestTerminate] Request termination of web worker and free local resources after execution
+		</div>
+		<div>
+			Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ and MTL from files.
+		</div>
+		<br>
+		<br>
+
+
+		<a name="WWOBJLoader2Director"></a><h1>WWOBJLoader2Director</h1>
+		<h2>Constructor</h2>
+
+		<h3>WWOBJLoader2Director()</h3>
+		<div>
+			Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).<br>
+			Workflow:<br>
+				prepareWorkers<br>
+				enqueueForRun<br>
+				processQueue<br>
+				deregister
+		</div>
+
+		<h3>[method:null prepareWorkers]( Array of [page:Function callbacks], [page:Number maxQueueSize], [page:Number maxWebWorkers] )</h3>
+		<div>
+			Array of [page:Function callbacks] — Register callbacks for all web workers: progress, completedLoading, errorWhileLoading, materialsLoaded, meshLoaded<br>
+			[page:Number maxQueueSize] — Set the maximum size of the instruction queue (1-1024)<br>
+			[page:Number maxWebWorkers] — Set the maximum amount of workers (1-16)
+		</div>
+		<div>
+			Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
+		</div>
+
+
+		<h3>[method:null enqueueForRun]( [page:Object runParams] )</h3>
+		<div>
+			[page:Object runParams] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
+		</div>
+		<div>
+			Store run instructions in internal instructionQueue.
+		</div>
+
+
+		<h3>[method:null processQueue]()</h3>
+		<div>
+			Process the instructionQueue until it is depleted.
+		</div>
+
+
+		<h3>[method:null deregister]()</h3>
+		<div>
+			Terminate all workers
+		</div>
+
+
+		<h3>[method:null getMaxQueueSize]()</h3>
+		<div>
+			Returns the maximum length of the instruction queue.
+		</div>
+
+
+		<h3>[method:null getMaxWebWorkers]()</h3>
+		<div>
+			Returns the maximum number of workers.
+		</div>
+
+
+		<h3>[method:null setCrossOrigin]( [page:String crossOrigin] )</h3>
+		<div>
+			[page:String crossOrigin] — CORS value
+		</div>
+		<div>
+			Sets the CORS string to be used.
+		</div>
+
+
+
+		<h2>Source</h2>
+
+		[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]
+
+	</body>
+</html>

+ 2 - 0
docs/list.js

@@ -349,6 +349,8 @@ var list = {
 			"GLTF2Loader": "examples/loaders/GLTF2Loader",
 			"MTLLoader": "examples/loaders/MTLLoader",
 			"OBJLoader": "examples/loaders/OBJLoader",
+			"OBJLoader2": "examples/loaders/OBJLoader2",
+			"WWOBJLoader2": "examples/loaders/WWOBJLoader2",
 			"PCDLoader": "examples/loaders/PCDLoader",
 			"PDBLoader": "examples/loaders/PDBLoader",
 			"SVGLoader": "examples/loaders/SVGLoader",