@@ -93,39 +93,52 @@ THREE.LoaderSupport.ConsoleLogger = (function () {
9393 * @memberOf THREE.LoaderSupport.ConsoleLogger
9494 *
9595 * @param {string } message Message to log
96+ * @param {string[] } additional Array of strings containing additional content to be logged
97+ *
9698 */
97- ConsoleLogger . prototype . logDebug = function ( message ) {
98- if ( this . enabled && this . debug ) console . info ( message ) ;
99+ ConsoleLogger . prototype . logDebug = function ( message , additional ) {
100+ if ( this . enabled && this . debug ) {
101+
102+ this . _createStatement ( message , 'Additional content:' , additional , function ( output ) { console . debug ( output ) } ) ;
103+
104+ }
99105 } ;
100106
101107 /**
102108 * Log an info message if enabled.
103109 * @memberOf THREE.LoaderSupport.ConsoleLogger
104110 *
105111 * @param {string } message Message to log
112+ * @param {string[] } additional Array of strings containing additional content to be logged
106113 */
107- ConsoleLogger . prototype . logInfo = function ( message ) {
108- if ( this . enabled ) console . info ( message ) ;
114+ ConsoleLogger . prototype . logInfo = function ( message , additional ) {
115+ if ( this . enabled ) {
116+
117+ this . _createStatement ( message , 'Additional content:' , additional , function ( output ) { console . info ( output ) } ) ;
118+
119+ }
109120 } ;
110121
111122 /**
112123 * Log a warn message (always).
113124 * @memberOf THREE.LoaderSupport.ConsoleLogger
114125 *
115126 * @param {string } message Message to log
127+ * @param {string[] } additional Array of strings containing additional content to be logged
116128 */
117- ConsoleLogger . prototype . logWarn = function ( message ) {
118- console . warn ( message ) ;
129+ ConsoleLogger . prototype . logWarn = function ( message , additional ) {
130+ this . _createStatement ( message , 'Additional content:' , additional , function ( output ) { console . warn ( output ) } ) ;
119131 } ;
120132
121133 /**
122134 * Log an error message (always).
123135 * @memberOf THREE.LoaderSupport.ConsoleLogger
124136 *
125137 * @param {string } message Message to log
138+ * @param {string[] } additional Array of strings containing additional content to be logged
126139 */
127- ConsoleLogger . prototype . logError = function ( message ) {
128- console . error ( message ) ;
140+ ConsoleLogger . prototype . logError = function ( message , additional ) {
141+ this . _createStatement ( message , 'Additional content:' , additional , function ( output ) { console . error ( output ) } ) ;
129142 } ;
130143
131144 /**
@@ -148,6 +161,16 @@ THREE.LoaderSupport.ConsoleLogger = (function () {
148161 if ( this . enabled ) console . timeEnd ( id ) ;
149162 } ;
150163
164+ ConsoleLogger . prototype . _createStatement = function ( message , addHeader , additional , logFunction ) {
165+ var output = message ;
166+ if ( Array . isArray ( additional ) ) {
167+
168+ output += '\n' + addHeader + '\n' + additional . join ( '\n' ) ;
169+
170+ }
171+ logFunction ( output ) ;
172+ } ;
173+
151174 return ConsoleLogger ;
152175} ) ( ) ;
153176
@@ -428,6 +451,10 @@ THREE.LoaderSupport.PrepData = (function () {
428451 return PrepData ;
429452} ) ( ) ;
430453
454+ THREE . LoaderSupport . Parser = {
455+ Obj : null
456+ } ;
457+
431458/**
432459 * Builds one or many THREE.Mesh from one raw set of Arraybuffers, materialGroup descriptions and further parameters.
433460 * Supports vertex, vertexColor, normal, uv and index buffers.
@@ -989,7 +1016,7 @@ THREE.LoaderSupport.WorkerRunnerRefImpl = (function () {
9891016 */
9901017THREE . LoaderSupport . WorkerSupport = ( function ( ) {
9911018
992- var WORKER_SUPPORT_VERSION = '2.0.1 ' ;
1019+ var WORKER_SUPPORT_VERSION = '2.1.2 ' ;
9931020
9941021 var Validator = THREE . LoaderSupport . Validator ;
9951022
@@ -1159,11 +1186,12 @@ THREE.LoaderSupport.WorkerSupport = (function () {
11591186 * @memberOf THREE.LoaderSupport.WorkerSupport
11601187 *
11611188 * @param {Function } functionCodeBuilder Function that is invoked with funcBuildObject and funcBuildSingelton that allows stringification of objects and singletons.
1189+ * @param {String } parserName Name of the Parser object
11621190 * @param {String[] } libLocations URL of libraries that shall be added to worker code relative to libPath
11631191 * @param {String } libPath Base path used for loading libraries
11641192 * @param {THREE.LoaderSupport.WorkerRunnerRefImpl } runnerImpl The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
11651193 */
1166- WorkerSupport . prototype . validate = function ( functionCodeBuilder , libLocations , libPath , runnerImpl ) {
1194+ WorkerSupport . prototype . validate = function ( functionCodeBuilder , parserName , libLocations , libPath , runnerImpl ) {
11671195 if ( Validator . isValid ( this . loaderWorker . worker ) ) return ;
11681196
11691197 this . logger . logInfo ( 'WorkerSupport: Building worker code...' ) ;
@@ -1181,7 +1209,8 @@ THREE.LoaderSupport.WorkerSupport = (function () {
11811209 }
11821210
11831211 var userWorkerCode = functionCodeBuilder ( buildObject , buildSingelton ) ;
1184- userWorkerCode += buildSingelton ( runnerImpl . name , runnerImpl . name , runnerImpl ) ;
1212+ userWorkerCode += 'var Parser = ' + parserName + ';\n\n' ;
1213+ userWorkerCode += buildSingelton ( runnerImpl . name , runnerImpl ) ;
11851214 userWorkerCode += 'new ' + runnerImpl . name + '();\n\n' ;
11861215
11871216 var scope = this ;
@@ -1282,10 +1311,9 @@ THREE.LoaderSupport.WorkerSupport = (function () {
12821311 return objectString ;
12831312 } ;
12841313
1285- var buildSingelton = function ( fullName , internalName , object ) {
1314+ var buildSingelton = function ( fullName , object ) {
12861315 var objectString = fullName + ' = (function () {\n\n' ;
12871316 objectString += '\t' + object . prototype . constructor . toString ( ) + '\n\n' ;
1288- objectString = objectString . replace ( object . name , internalName ) ;
12891317
12901318 var funcString ;
12911319 var objectPart ;
@@ -1295,12 +1323,12 @@ THREE.LoaderSupport.WorkerSupport = (function () {
12951323 if ( typeof objectPart === 'function' ) {
12961324
12971325 funcString = objectPart . toString ( ) ;
1298- objectString += '\t' + internalName + '.prototype.' + name + ' = ' + funcString + ';\n\n' ;
1326+ objectString += '\t' + object . name + '.prototype.' + name + ' = ' + funcString + ';\n\n' ;
12991327
13001328 }
13011329
13021330 }
1303- objectString += '\treturn ' + internalName + ';\n' ;
1331+ objectString += '\treturn ' + object . name + ';\n' ;
13041332 objectString += '})();\n\n' ;
13051333
13061334 return objectString ;
0 commit comments