[name]

Supporting classes for file loaders and web worker based loaders.

Sub-Classes

[page:LoaderSupport.Builder]
[page:LoaderSupport.LoadedMeshUserOverride]
[page:LoaderSupport.WorkerSupport]
[page:LoaderSupport.WorkerRunnerRefImpl]
[page:LoaderSupport.WorkerDirector]
[page:LoaderSupport.PrepData]
[page:LoaderSupport.LoaderBase]
[page:LoaderSupport.Callbacks]
[page:LoaderSupport.Validator]
[page:LoaderSupport.ConsoleLogger]

Example

[example:webgl_loader_obj2_meshspray] - Example using [page:LoaderSupport.LoaderWorkerDirector] and [page:LoaderSupport.LoaderWorkerSupport].

Classes


Builder

Constructor

Builder()

Builds one or many [page:Mesh] from one raw set of Arraybuffers, materialGroup descriptions and further parameters. Supports vertex, vertexColor, normal, uv and index buffers.

Methods

[method:null setMaterials] ( Array of [page:Material materials] )

Array of [page:Material materials] - Array of [page:Material Materials]
Set materials loaded by any supplier of an Array of [page:Material Materials].

[method:Array processPayload] ( Object payload )

[page:Object payload] - Raw Mesh or Material descriptions.
Delegates processing of the payload (mesh building or material update) to the corresponding functions (BW-compatibility).


[method:Array buildMeshes] ( Object meshPayload )

[page:Object meshPayload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
Builds one or multiple meshes from the data described in the payload (buffers, params, material info).


[method:null updateMaterials] ( Object materialPayload )

[page:Object materialPayload] - Material update instructions
Updates the materials with contained material objects (sync) or from alteration instructions (async).


[method:Object getMaterialsJSON] ()

Returns the mapping object of material name and corresponding jsonified material.


[method:Object getMaterials] ()

Returns the mapping object of material name and corresponding material.


LoadedMeshUserOverride

Constructor

LoadedMeshUserOverride( [page:Boolean disregardMesh], [page:BufferGeometry bufferGeometry] )

[page:Boolean disregardMesh] - Tell implementation to completely disregard this mesh
[page:Boolean alteredMesh] - Tell implementation that mesh(es) have been altered or added
Object to return by callback onMeshAlter. Used to disregard a certain mesh or to return one to many meshes.

Methods

[method:null addMesh] ( [page:Mesh mesh] )

[page:Mesh mesh] - Mesh
Add a mesh created within callback.

[method:boolean isDisregardMesh] ()

Answers if mesh shall be disregarded completely.

[method:boolean providesAlteredMeshes] ()

Answers if new mesh(es) were created.


WorkerSupport

Constructor

WorkerSupport( [page:LoaderSupport.ConsoleLogger logger] )

[page:LoaderSupport.ConsoleLogger logger] - logger to be used
This class provides means to transform existing parser code into a web worker. It defines a simple communication protocol which allows to configure the worker and receive raw mesh data during execution.

Methods

[method:null validate] ( [page:Function functionCodeBuilder], Array of [page:String libLocations], [page:String libPath], [page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] )

[page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingelton that allows stringification of objects and singletons.
Array of [page:String libLocations] - URL of libraries that shall be added to worker code relative to libPath.
[page:String libPath] - Base path used for loading libraries.
[page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] - The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
Validate the status of worker code and the derived worker.

[method:null setTerminateRequested] ( [page:Boolean terminateRequested] )

[page:Boolean terminateRequested] - True or false.
Request termination of worker once parser is finished.

[method:null setCallbacks] ( [page:Function builder], [page:Function onLoad] )

[page:Function builder] - The builder function. Default is [page:LoaderSupport.Builder].
[page:Function onLoad] - The function that is called when parsing is complete.
Specify functions that should be build when new raw mesh data becomes available and when the parser is finished.

[method:null run] ( [page:Object payload] )

[page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
Runs the parser with the provided configuration.


WorkerRunnerRefImpl

Constructor

WorkerRunnerRefImpl()

Default implementation of the WorkerRunner responsible for creation and configuration of the parser within the worker.

Methods

[method:null applyProperties] ( [page:Object parser], [page:Object params] )

[page:Object parser] - The parser instance
[page:Object params] - The parameter object
Applies values from parameter object via set functions or via direct assignment.

[method:null run] ( [page:Object payload] )

[page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
Configures the Parser implementation according the supplied configuration object.


WorkerDirector

Constructor

WorkerDirector( [page:String classDef], [page:LoaderSupport.ConsoleLogger logger] )

[page:String classDef] - Class definition to be used for construction
[page:LoaderSupport.ConsoleLogger logger] - logger to be used
Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).
- Workflow:
- prepareWorkers
- enqueueForRun
- processQueue
- tearDown

Methods

[method:null prepareWorkers]( [page:WWOBJLoader2.Callbacks globalCallbacks], [page:Number maxQueueSize], [page:Number maxWebWorkers] )

[page:LoaderSupport.Callbacks 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:LoaderSupport.PrepData runParams] )

[page:LoaderSupport.PrepData runParams]
Store run instructions in internal instructionQueue.

[method:null processQueue]()

Process the instructionQueue until it is depleted.

[method:null tearDown]( [page:Function callbackOnFinishedProcessing] )

[page:Function callbackOnFinishedProcessing] - Function called once all workers finished processing.
Terminate all workers.

[method:null getMaxQueueSize]()

Returns the maximum length of the instruction queue.

[method:null getMaxWebWorkers]()

Returns the maximum number of workers.

[method:Boolean isRunning]()

Returns if any workers are running.

[method:null setCrossOrigin]( [page:String crossOrigin] )

[page:String crossOrigin] - CORS value
Sets the CORS string to be used.

PrepData

Constructor

PrepData( [page:String modelName] )

[page:String modelName] - Overall name of the model
Configuration instructions to be used by run method.

Methods

[method:null setStreamMeshesTo] ( [page:Object3D streamMeshesTo] )

[page:Object3D streamMeshesTo] - Object already attached to scenegraph where new meshes will be attached to
Set the node where the loaded objects will be attached directly.

[method:null setMaterialPerSmoothingGroup] ( [page:boolean materialPerSmoothingGroup] )

[page:boolean materialPerSmoothingGroup]
Tells whether a material shall be created per smoothing group.

[method:null setUseIndices]( [page:Boolean useIndices] )

[page:Boolean useIndices] - Default is false
Instructs loaders to create indexed [page:BufferGeometry].

[method:null setDisregardNormals]( [page:Boolean disregardNormals] )

[page:Boolean disregardNormals]
Tells whether normals should be completely disregarded and regenerated.

[method:Callbacks getCallbacks]()

Returns all callbacks as [page:LoaderSupport.Callbacks].

[method:null setCrossOrigin]( [page:String crossOrigin] )

[page:String crossOrigin] - CORS value
Sets the CORS string to be used.

[method:null addResource]( [page:LoaderSupport.ResourceDescriptor resource] )

[page:LoaderSupport.ResourceDescriptor resource]
Add a resource description.

[method:null setUseAsync]( [page:Boolean useAsync] )

[page:Boolean useAsync]
If true uses async loading with worker, if false loads data synchronously.


LoaderBase

Constructor

LoaderBase( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger logger] )

[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
Base class to be used by loaders.

Methods

[method:ConsoleLogger getLogger] ()

Returns [page:LoaderSupport.ConsoleLogger].

[method:null setModelName] ( [page:String modelName] )

[page:String modelName]
Set the name of the model.

[method:null setPath] ( [page:String path] )

[page:String path] - URL
The URL of the base path.

[method:null setStreamMeshesTo] ( [page:Object3D streamMeshesTo] )

[page:Object3D streamMeshesTo] - Object already attached to scenegraph where new meshes will be attached to
Set the node where the loaded objects will be attached directly.

[method:null setMaterials] ( Array of [page:Material materials] )

Array of [page:Material materials] - Array of [page:Material Materials]
Set materials loaded by MTLLoader or any other supplier of an Array of [page:Material Materials].

[method:null setUseIndices]( [page:Boolean useIndices] )

[page:Boolean useIndices]
Instructs loaders to create indexed [page:BufferGeometry].

[method:null setDisregardNormals]( [page:Boolean disregardNormals] )

[page:Boolean disregardNormals]
Tells whether normals should be completely disregarded and regenerated.

[method:null onProgress]( [page:String type], [page:String text], [page:Number numericalValue] )

[page:String type] - The type of event
[page:String text] - Textual description of the event
[page:Number numericalValue] - Numerical value describing the progress
Announce feedback which is give to the registered [page:LoaderSupport.Callbacks].


Callbacks

Constructor

Callbacks()

Callbacks utilized by loaders and builder.

Methods

[method:null setCallbackOnProgress]( [page:Function callbackOnProgress] )

[page:Function callbackOnProgress] - Callback function for described functionality
Register callback function that is invoked by internal function "announceProgress" to print feedback.

[method:null setCallbackOnMeshAlter]( [page:Function callbackOnMeshAlter] )

[page:Function callbackOnMeshAlter] - Callback function for described functionality
Register callback function that is called every time a mesh was loaded. Use [page:LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).

[method:null setCallbackOnLoad]( [page:Function callbackOnLoad] )

[page:Function callbackOnLoad] - Callback function for described functionality
Register callback function that is called once loading of the complete OBJ file is completed.

[method:null setCallbackOnLoadMaterials]( [page:Function callbackOnLoadMaterials] )

[page:Function callbackOnLoadMaterials] - Callback function for described functionality
Register callback function that is called when materials have been loaded.


Validator

Constructor

Validator()

Validation functions.

Methods

[method:Boolean isValid]( [page:Object input] )

[page:Object input] - Can be anything
If given input is null or undefined, false is returned otherwise true.

[method:null verifyInput]( [page:Object input], [page:Object defaultValue] )

[page:Object input] - Can be anything [page:Object defaultValue] - Can be anything
If given input is null or undefined, the defaultValue is returned otherwise the given input.


ConsoleLogger

Constructor

ConsoleLogger( [page:Boolean enabled], [page:Boolean debug] )

[page:Boolean enabled] - Tell if logger is enabled. [page:Boolean debug] - Toggle debug logging.
Logging wrapper for console.

Methods

[method:null setDebug]( [page:Boolean debug] )

[page:Boolean debug] - True or False
Enable or disable debug logging.

[method:Boolean isDebug]()

Returns if is enabled and debug.

[method:null setEnabled]( [page:Boolean enabled] )

[page:Boolean enabled] - True or False
Enable or disable info, debug and time logging.

[method:Boolean isEnabled]()

Returns if is enabled.

[method:null logDebug]( [page:String message] )

[page:String message] - Message to log
Log a debug message if enabled and debug is set.

[method:null logInfo]( [page:String message] )

[page:String message] - Message to log
Log an info message if enabled.

[method:null logWarn]( [page:String message] )

[page:String message] - Message to log
Log a warn message (always).

[method:null logError]( [page:String message] )

[page:String message] - Message to log
Log an error message (always).

[method:null logTimeStart]( [page:String id] )

[page:String id] - Time identification
Start time measurement with provided id.

[method:null logTimeEnd]( [page:String id] )

[page:String id] - Time identification
Stop time measurement started with provided id.


Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/LoaderSupport.js examples/js/loaders/LoaderSupport.js]