src/loaders/OBJLoader2.js
function ( content, onLoad ) {
		var scope = this;
		var measureTime = false;
		var scopedOnLoad = function () {
			onLoad(
				{
					detail: {
						loaderRootNode: scope.loaderRootNode,
						modelName: scope.modelName,
						instanceNo: scope.instanceNo
					}
				}
			);
			if ( measureTime && scope.logging.enabled ) console.timeEnd( 'OBJLoader2 parseAsync: ' + scope.modelName );
		};
		// fast-fail in case of illegal data
		if ( content === null || content === undefined ) {

			throw 'Provided content is not a valid ArrayBuffer or String. Unable to continue parsing';

		} else {

			measureTime = true;

		}
		if ( measureTime && this.logging.enabled ) console.time( 'OBJLoader2 parseAsync: ' + this.modelName );
		this.meshBuilder.init();

		var scopedOnMeshLoaded = function ( payload ) {
			var meshes = scope.meshBuilder.processPayload( payload );
			var mesh;
			for ( var i in meshes ) {
				mesh = meshes[ i ];
				scope.loaderRootNode.add( mesh );
			}
		};
		var buildCode = function ( codeSerializer ) {
			var workerCode = '';
			workerCode += '/**\n';
			workerCode += '  * This code was constructed by OBJLoader2 buildCode.\n';
			workerCode += '  */\n\n';
			workerCode += 'THREE = { LoaderSupport: {}, OBJLoader2: {} };\n\n';
			workerCode += codeSerializer.serializeClass( 'THREE.OBJLoader2.Parser', THREE.OBJLoader2.Parser );

			return workerCode;
		};
		this.workerSupport.validate( buildCode, 'THREE.OBJLoader2.Parser' );
		this.workerSupport.setCallbacks( scopedOnMeshLoaded, scopedOnLoad );
		if ( scope.terminateWorkerOnLoad ) this.workerSupport.setTerminateRequested( true );

		var materialNames = {};
		var materials = this.meshBuilder.getMaterials();
		for ( var materialName in materials ) {

			materialNames[ materialName ] = materialName;

		}
		this.workerSupport.run(
			{
				params: {
					useAsync: true,
					materialPerSmoothingGroup: this.materialPerSmoothingGroup,
					useOAsMesh: this.useOAsMesh,
					useIndices: this.useIndices,
					disregardNormals: this.disregardNormals
				},
				logging: {
					enabled: this.logging.enabled,
					debug: this.logging.debug
				},
				materials: {
					// in async case only material names are supplied to parser
					materials: materialNames
				},
				data: {
					input: content,
					options: null
				}
			}
		);
	}
function ( content, onLoad ) {
		var scope = this;
		var measureTime = false;
		var scopedOnLoad = function () {
			onLoad(
				{
					detail: {
						loaderRootNode: scope.loaderRootNode,
						modelName: scope.modelName,
						instanceNo: scope.instanceNo
					}
				}
			);
			if ( measureTime && scope.logging.enabled ) console.timeEnd( 'OBJLoader2 parseAsync: ' + scope.modelName );
		};
		// fast-fail in case of illegal data
		if ( content === null || content === undefined ) {

			throw 'Provided content is not a valid ArrayBuffer or String. Unable to continue parsing';

		} else {

			measureTime = true;

		}
		if ( measureTime && this.logging.enabled ) console.time( 'OBJLoader2 parseAsync: ' + this.modelName );
		this.meshBuilder.init();

		var scopedOnMeshLoaded = function ( payload ) {
			var meshes = scope.meshBuilder.processPayload( payload );
			var mesh;
			for ( var i in meshes ) {
				mesh = meshes[ i ];
				scope.loaderRootNode.add( mesh );
			}
		};
		var buildCode = function ( codeSerializer ) {
			var workerCode = '';
			workerCode += '/**\n';
			workerCode += '  * This code was constructed by OBJLoader2 buildCode.\n';
			workerCode += '  */\n\n';
			workerCode += 'THREE = { LoaderSupport: {}, OBJLoader2: {} };\n\n';
			workerCode += codeSerializer.serializeClass( 'THREE.OBJLoader2.Parser', THREE.OBJLoader2.Parser );

			return workerCode;
		};
		this.workerSupport.validate( buildCode, 'THREE.OBJLoader2.Parser' );
		this.workerSupport.setCallbacks( scopedOnMeshLoaded, scopedOnLoad );
		if ( scope.terminateWorkerOnLoad ) this.workerSupport.setTerminateRequested( true );

		var materialNames = {};
		var materials = this.meshBuilder.getMaterials();
		for ( var materialName in materials ) {

			materialNames[ materialName ] = materialName;

		}
		this.workerSupport.run(
			{
				params: {
					useAsync: true,
					materialPerSmoothingGroup: this.materialPerSmoothingGroup,
					useOAsMesh: this.useOAsMesh,
					useIndices: this.useIndices,
					disregardNormals: this.disregardNormals
				},
				logging: {
					enabled: this.logging.enabled,
					debug: this.logging.debug
				},
				materials: {
					// in async case only material names are supplied to parser
					materials: materialNames
				},
				data: {
					input: content,
					options: null
				}
			}
		);
	}
function ( content , onLoad ) { var scope = this ; var measureTime = false ; var scopedOnLoad = function ( ) { onLoad ( { detail : { loaderRootNode : scope . loaderRootNode , modelName : scope . modelName , instanceNo : scope . instanceNo } } ) ; if ( measureTime && scope . logging . enabled ) console . timeEnd ( 'OBJLoader2 parseAsync: ' + scope . modelName ) ; } ; // fast-fail in case of illegal data if ( content === null || content === undefined ) { throw 'Provided content is not a valid ArrayBuffer or String. Unable to continue parsing' ; } else { measureTime = true ; } if ( measureTime && this . logging . enabled ) console . time ( 'OBJLoader2 parseAsync: ' + this . modelName ) ; this . meshBuilder . init ( ) ; var scopedOnMeshLoaded = function ( payload ) { var meshes = scope . meshBuilder . processPayload ( payload ) ; var mesh ; for ( var i in meshes ) { mesh = meshes [ i ] ; scope . loaderRootNode . add ( mesh ) ; } } ; var buildCode = function ( codeSerializer ) { var workerCode = '' ; workerCode += '/**\n' ; workerCode += '  * This code was constructed by OBJLoader2 buildCode.\n' ; workerCode += '  */\n\n' ; workerCode += 'THREE = { LoaderSupport: {}, OBJLoader2: {} };\n\n' ; workerCode += codeSerializer . serializeClass ( 'THREE.OBJLoader2.Parser' , THREE . OBJLoader2 . Parser ) ; return workerCode ; } ; this . workerSupport . validate ( buildCode , 'THREE.OBJLoader2.Parser' ) ; this . workerSupport . setCallbacks ( scopedOnMeshLoaded , scopedOnLoad ) ; if ( scope . terminateWorkerOnLoad ) this . workerSupport . setTerminateRequested ( true ) ; var materialNames = { } ; var materials = this . meshBuilder . getMaterials ( ) ; for ( var materialName in materials ) { materialNames [ materialName ] = materialName ; } this . workerSupport . run ( { params : { useAsync : true , materialPerSmoothingGroup : this . materialPerSmoothingGroup , useOAsMesh : this . useOAsMesh , useIndices : this . useIndices , disregardNormals : this . disregardNormals } , logging : { enabled : this . logging . enabled , debug : this . logging . debug } , materials : { // in async case only material names are supplied to parser materials : materialNames } , data : { input : content , options : null } } ) ; }
Parses OBJ content asynchronously from arraybuffer.

@param {arraybuffer} content OBJ data as Uint8Array
@param {callback} onLoad Called after worker successfully completed loading
Parses OBJ content asynchronously from arraybuffer .