src/loaders/support/LoaderWorkerSupport.js
function ( functionCodeBuilder, parserName, libLocations, libPath, runnerImpl ) {
		if ( THREE.LoaderSupport.Validator.isValid( this.loaderWorker.worker ) ) return;

		if ( this.logging.enabled ) {

			console.info( 'WorkerSupport: Building worker code...' );
			console.time( 'buildWebWorkerCode' );

		}
		if ( THREE.LoaderSupport.Validator.isValid( runnerImpl ) ) {

			if ( this.logging.enabled ) console.info( 'WorkerSupport: Using "' + runnerImpl.runnerName + '" as Runner class for worker.' );

		// Browser implementation
		} else if ( typeof window !== "undefined" ) {

			runnerImpl = THREE.LoaderSupport.WorkerRunnerRefImpl;
			if ( this.logging.enabled ) console.info( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.WorkerRunnerRefImpl" as Runner class for worker.' );

		// NodeJS implementation
		} else {

			runnerImpl = THREE.LoaderSupport.NodeWorkerRunnerRefImpl;
			if ( this.logging.enabled ) console.info( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.NodeWorkerRunnerRefImpl" as Runner class for worker.' );

		}
		var userWorkerCode = functionCodeBuilder( THREE.LoaderSupport.WorkerSupport.CodeSerializer );
		userWorkerCode += 'var Parser = '+ parserName +  ';\n\n';
		userWorkerCode += THREE.LoaderSupport.WorkerSupport.CodeSerializer.serializeClass( runnerImpl.runnerName, runnerImpl );
		userWorkerCode += 'new ' + runnerImpl.runnerName + '();\n\n';

		var scope = this;
		if ( THREE.LoaderSupport.Validator.isValid( libLocations ) && libLocations.length > 0 ) {

			var libsContent = '';
			var loadAllLibraries = function ( path, locations ) {
				if ( locations.length === 0 ) {

					scope.loaderWorker.initWorker( libsContent + userWorkerCode, runnerImpl.runnerName );
					if ( scope.logging.enabled ) console.timeEnd( 'buildWebWorkerCode' );

				} else {

					var loadedLib = function ( contentAsString ) {
						libsContent += contentAsString;
						loadAllLibraries( path, locations );
					};

					var fileLoader = new THREE.FileLoader();
					fileLoader.setPath( path );
					fileLoader.setResponseType( 'text' );
					fileLoader.load( locations[ 0 ], loadedLib );
					locations.shift();

				}
			};
			loadAllLibraries( libPath, libLocations );

		} else {

			this.loaderWorker.initWorker( userWorkerCode, runnerImpl.runnerName );
			if ( this.logging.enabled ) console.timeEnd( 'buildWebWorkerCode' );

		}
	}
function ( functionCodeBuilder, parserName, libLocations, libPath, runnerImpl ) {
		if ( THREE.LoaderSupport.Validator.isValid( this.loaderWorker.worker ) ) return;

		if ( this.logging.enabled ) {

			console.info( 'WorkerSupport: Building worker code...' );
			console.time( 'buildWebWorkerCode' );

		}
		if ( THREE.LoaderSupport.Validator.isValid( runnerImpl ) ) {

			if ( this.logging.enabled ) console.info( 'WorkerSupport: Using "' + runnerImpl.runnerName + '" as Runner class for worker.' );

		// Browser implementation
		} else if ( typeof window !== "undefined" ) {

			runnerImpl = THREE.LoaderSupport.WorkerRunnerRefImpl;
			if ( this.logging.enabled ) console.info( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.WorkerRunnerRefImpl" as Runner class for worker.' );

		// NodeJS implementation
		} else {

			runnerImpl = THREE.LoaderSupport.NodeWorkerRunnerRefImpl;
			if ( this.logging.enabled ) console.info( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.NodeWorkerRunnerRefImpl" as Runner class for worker.' );

		}
		var userWorkerCode = functionCodeBuilder( THREE.LoaderSupport.WorkerSupport.CodeSerializer );
		userWorkerCode += 'var Parser = '+ parserName +  ';\n\n';
		userWorkerCode += THREE.LoaderSupport.WorkerSupport.CodeSerializer.serializeClass( runnerImpl.runnerName, runnerImpl );
		userWorkerCode += 'new ' + runnerImpl.runnerName + '();\n\n';

		var scope = this;
		if ( THREE.LoaderSupport.Validator.isValid( libLocations ) && libLocations.length > 0 ) {

			var libsContent = '';
			var loadAllLibraries = function ( path, locations ) {
				if ( locations.length === 0 ) {

					scope.loaderWorker.initWorker( libsContent + userWorkerCode, runnerImpl.runnerName );
					if ( scope.logging.enabled ) console.timeEnd( 'buildWebWorkerCode' );

				} else {

					var loadedLib = function ( contentAsString ) {
						libsContent += contentAsString;
						loadAllLibraries( path, locations );
					};

					var fileLoader = new THREE.FileLoader();
					fileLoader.setPath( path );
					fileLoader.setResponseType( 'text' );
					fileLoader.load( locations[ 0 ], loadedLib );
					locations.shift();

				}
			};
			loadAllLibraries( libPath, libLocations );

		} else {

			this.loaderWorker.initWorker( userWorkerCode, runnerImpl.runnerName );
			if ( this.logging.enabled ) console.timeEnd( 'buildWebWorkerCode' );

		}
	}
function ( functionCodeBuilder , parserName , libLocations , libPath , runnerImpl ) { if ( THREE . LoaderSupport . Validator . isValid ( this . loaderWorker . worker ) ) return ; if ( this . logging . enabled ) { console . info ( 'WorkerSupport: Building worker code...' ) ; console . time ( 'buildWebWorkerCode' ) ; } if ( THREE . LoaderSupport . Validator . isValid ( runnerImpl ) ) { if ( this . logging . enabled ) console . info ( 'WorkerSupport: Using "' + runnerImpl . runnerName + '" as Runner class for worker.' ) ; // Browser implementation } else if ( typeof window !== "undefined" ) { runnerImpl = THREE . LoaderSupport . WorkerRunnerRefImpl ; if ( this . logging . enabled ) console . info ( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.WorkerRunnerRefImpl" as Runner class for worker.' ) ; // NodeJS implementation } else { runnerImpl = THREE . LoaderSupport . NodeWorkerRunnerRefImpl ; if ( this . logging . enabled ) console . info ( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.NodeWorkerRunnerRefImpl" as Runner class for worker.' ) ; } var userWorkerCode = functionCodeBuilder ( THREE . LoaderSupport . WorkerSupport . CodeSerializer ) ; userWorkerCode += 'var Parser = ' + parserName + ';\n\n' ; userWorkerCode += THREE . LoaderSupport . WorkerSupport . CodeSerializer . serializeClass ( runnerImpl . runnerName , runnerImpl ) ; userWorkerCode += 'new ' + runnerImpl . runnerName + '();\n\n' ; var scope = this ; if ( THREE . LoaderSupport . Validator . isValid ( libLocations ) && libLocations . length > 0 ) { var libsContent = '' ; var loadAllLibraries = function ( path , locations ) { if ( locations . length === 0 ) { scope . loaderWorker . initWorker ( libsContent + userWorkerCode , runnerImpl . runnerName ) ; if ( scope . logging . enabled ) console . timeEnd ( 'buildWebWorkerCode' ) ; } else { var loadedLib = function ( contentAsString ) { libsContent += contentAsString ; loadAllLibraries ( path , locations ) ; } ; var fileLoader = new THREE . FileLoader ( ) ; fileLoader . setPath ( path ) ; fileLoader . setResponseType ( 'text' ) ; fileLoader . load ( locations [ 0 ] , loadedLib ) ; locations . shift ( ) ; } } ; loadAllLibraries ( libPath , libLocations ) ; } else { this . loaderWorker . initWorker ( userWorkerCode , runnerImpl . runnerName ) ; if ( this . logging . enabled ) console . timeEnd ( 'buildWebWorkerCode' ) ; } }
Validate the status of worker code and the derived worker.

@param {Function} functionCodeBuilder Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons.
@param {String} parserName Name of the Parser object
@param {String[]} libLocations URL of libraries that shall be added to worker code relative to libPath
@param {String} libPath Base path used for loading libraries
@param {THREE.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 .