[name]
A loader for loading an .obj resource within a web worker.
Sub-Classes
[page:WWOBJLoader2.PrepDataArrayBuffer]
[page:WWOBJLoader2.PrepDataFile]
[page:WWOBJLoader2.WWOBJLoader2Director]
Example
// 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();
[example:webgl_loader_obj2_ww] — Simple example that allows to load own models via file selection.
[example:webgl_loader_obj2_ww_parallels] — Advanced example using [page:WWOBJLoader2.WWOBJLoader2Director] for orchestration of multiple workers.
Constructor
[name]()
OBJ data will be loaded by dynamically created web worker.
First feed instructions with: [page:WWOBJLoader2.prepareRun prepareRun]
Then execute with: [page:WWOBJLoader2.run run]
Properties
Methods
[method:null prepareRun]( [page:Object params] )
[page:Object params] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
Set all parameters for required for execution of [page:WWOBJLoader2.run run].
[method:null run]()
Run the loader according the preparation instruction provided in [page:WWOBJLoader2.prepareRun prepareRun].
[method:null setCrossOrigin]( [page:String crossOrigin] )
[page:String crossOrigin] — CORS value
Sets the CORS string to be used.
[method:null setDebug]( [page:Boolean enabled] )
[page:Boolean enabled] — True or false
Enable or disable debug logging.
[method:null setRequestTerminate]( [page:Boolean requestTerminate] )
[page:Boolean requestTerminate] — True or false
Call requestTerminate to terminate the web worker and free local resource after execution.
[method:null registerCallbackCompletedLoading]( [page:Function callbackCompletedLoading] )
[page:Function callbackCompletedLoading] — Callback function for described functionality
Register callback function that is called once loading of the complete model is completed.
[method:null registerCallbackProgress]( [page:Function callbackProgress] )
[page:Function callbackProgress] — Callback function for described functionality
Register callback function that is invoked by internal function "_announceProgress" to print feedback.
[method:null registerCallbackMaterialsLoaded]( [page:Function callbackMaterialsLoaded] )
[page:Function callbackMaterialsLoaded] — Callback function for described functionality
Register callback function that is called once materials have been loaded. It allows to alter and return materials.
[method:null registerCallbackMeshLoaded]( [page:Function callbackMeshLoaded] )
[page:Function callbackMeshLoaded] — Callback function for described functionality
Register callback function that is called every time a mesh was loaded. Return altered [page:Material] or null from callback.
[method:null registerCallbackErrorWhileLoading]( [page:Function callbackErrorWhileLoading] )
[page:Function callbackErrorWhileLoading] — Callback function for described functionality
Register callback function that is called to report an error that prevented loading.
Sub-Classes
PrepDataArrayBuffer
Constructor
PrepDataArrayBuffer( [page:String modelName], [page:Uint8Array objAsArrayBuffer], [page:String pathTexture], [page:String mtlAsString] )
[page:String modelName] — Overall name of the model
[page:Uint8Array objAsArrayBuffer] — OBJ file content as ArrayBuffer
[page:String pathTexture] — Path to texture files
[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
Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ from given ArrayBuffer and MTL from given String.
PrepDataFile
Constructor
PrepDataFile( [page:String modelName], [page:String pathObj], [page:String fileObj], [page:String pathTexture], [page:String fileMtl] )
[page:String modelName] — Overall name of the model
[page:String pathObj] — Path to OBJ file
[page:String fileObj] — OBJ file name
[page:String pathTexture] — Path to texture files
[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
Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ and MTL from files.
WWOBJLoader2Director
Constructor
WWOBJLoader2Director()
Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).
Workflow:
prepareWorkers
enqueueForRun
processQueue
deregister
[method:null prepareWorkers]( Array of [page:Function callbacks], [page:Number maxQueueSize], [page:Number maxWebWorkers] )
Array of [page:Function callbacks] — Register callbacks for all web workers: progress, completedLoading, errorWhileLoading, materialsLoaded, meshLoaded
[page:Number maxQueueSize] — Set the maximum size of the instruction queue (1-1024)
[page:Number maxWebWorkers] — Set the maximum amount of workers (1-16)
Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
[method:null enqueueForRun]( [page:Object runParams] )
[page:Object runParams] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
Store run instructions in internal instructionQueue.
[method:null processQueue]()
Process the instructionQueue until it is depleted.
[method:null deregister]()
Terminate all workers
[method:null getMaxQueueSize]()
Returns the maximum length of the instruction queue.
[method:null getMaxWebWorkers]()
Returns the maximum number of workers.
[method:null setCrossOrigin]( [page:String crossOrigin] )
[page:String crossOrigin] — CORS value
Sets the CORS string to be used.
Source
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]