[name]

A loader for loading an .obj resource within a web worker.

Sub-Classes

[page:WWOBJLoader2.PrepDataArrayBuffer]
[page:WWOBJLoader2.PrepDataFile]
[page:WWOBJLoader2.PrepDataCallbacks]
[page:WWOBJLoader2.LoadedMeshUserOverride]
[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. Use [page:WWOBJLoader2.LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).

[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.

[method:null clearAllCallbacks]()

Clears all registered callbacks.

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
Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ from given ArrayBuffer and MTL from given String.

Methods

[method:PrepDataCallbacks getCallbacks]()

Returns all callbacks as [page:WWOBJLoader2.PrepDataCallbacks].

[method:null setRequestTerminate]( [page:Boolean requestTerminate] )

[page:Boolean requestTerminate] — Default is false
Request termination of web worker and free local resources after execution.

[method:null setSceneGraphBaseNode]( [page:THREE.Object3D sceneGraphBaseNode] )

[page:Object3D sceneGraphBaseNode] — Scene graph object
[page:Object3D] where meshes will be attached.

[method:null setStreamMeshes]( [page:Boolean streamMeshes] )

[page:Boolean streamMeshes] — Default is true
Singles meshes are directly integrated into scene when loaded or later.


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
Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ and MTL from files.

Methods

[method:PrepDataCallbacks getCallbacks]()

Returns all callbacks as [page:WWOBJLoader2.PrepDataCallbacks].

[method:null setRequestTerminate]( [page:Boolean requestTerminate] )

[page:Boolean requestTerminate] — Default is false
Request termination of web worker and free local resources after execution.

[method:null setSceneGraphBaseNode]( [page:THREE.Object3D sceneGraphBaseNode] )

[page:Object3D sceneGraphBaseNode] — Scene graph object
[page:Object3D] where meshes will be attached.

[method:null setStreamMeshes]( [page:Boolean streamMeshes] )

[page:Boolean streamMeshes] — Default is true
Singles meshes are directly integrated into scene when loaded or later.


PrepDataCallbacks

Constructor

PrepDataCallbacks()

Callbacks utilized by functions working with [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile].

Methods

[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 registerCallbackErrorWhileLoading]( [page:Function callbackErrorWhileLoading] )

[page:Function callbackErrorWhileLoading] — Callback function for described functionality
Report if an error prevented loading.

[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. Use [page:WWOBJLoader2.LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).


LoadedMeshUserOverride

Constructor

LoadedMeshUserOverride( [page:Boolean disregardMesh], [page:THREE.BufferGeometry bufferGeometry], [page:THREE.Material material] )

[page:Boolean disregardMesh] — Tell [page:WWOBJLoader2] to completely disregard this mesh
[page:BufferGeometry bufferGeometry] — The [page:BufferGeometry] to be used
[page:Material material] — The [page:Material] to be used
Object to return by THREE.OBJLoader2.WWOBJLoader2.callbacks.meshLoaded. Used to adjust bufferGeometry or material or prevent complete loading of mesh.


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]( [page:WWOBJLoader2.PrepDataCallbacks globalCallbacks], [page:Number maxQueueSize], [page:Number maxWebWorkers] )

[page:WWOBJLoader2.PrepDataCallbacks globalCallbacks] — Register global callbacks used by all web workers
[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]