Browse Source

USDZLoader: Avoid recursive calls of `parseNextLine()`. (#27169)

Michael Herzog 1 year ago
parent
commit
23084519ff
1 changed files with 3 additions and 17 deletions
  1. 3 17
      examples/jsm/loaders/USDZLoader.js

+ 3 - 17
examples/jsm/loaders/USDZLoader.js

@@ -25,9 +25,7 @@ class USDAParser {
 		const data = {};
 
 		const lines = text.split( '\n' );
-		const length = lines.length;
 
-		let current = 0;
 		let string = null;
 		let target = data;
 
@@ -35,9 +33,7 @@ class USDAParser {
 
 		// debugger;
 
-		function parseNextLine() {
-
-			const line = lines[ current ];
+		for ( const line of lines ) {
 
 			// console.log( line );
 
@@ -74,7 +70,7 @@ class USDAParser {
 
 				stack.pop();
 
-				if ( stack.length === 0 ) return;
+				if ( stack.length === 0 ) continue;
 
 				target = stack[ stack.length - 1 ];
 
@@ -100,18 +96,8 @@ class USDAParser {
 
 			}
 
-			current ++;
-
-			if ( current < length ) {
-
-				parseNextLine();
-
-			}
-
 		}
 
-		parseNextLine();
-
 		return data;
 
 	}
@@ -640,7 +626,7 @@ class USDZLoader extends Loader {
 
 						}
 
-					} else  if ( 'float inputs:clearcoat' in surface ) {
+					} else if ( 'float inputs:clearcoat' in surface ) {
 
 						material.clearcoat = parseFloat( surface[ 'float inputs:clearcoat' ] );