Skip to content

Commit 2308451

Browse files
authored
USDZLoader: Avoid recursive calls of parseNextLine(). (#27169)
1 parent d981731 commit 2308451

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

examples/jsm/loaders/USDZLoader.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,15 @@ class USDAParser {
2525
const data = {};
2626

2727
const lines = text.split( '\n' );
28-
const length = lines.length;
2928

30-
let current = 0;
3129
let string = null;
3230
let target = data;
3331

3432
const stack = [ data ];
3533

3634
// debugger;
3735

38-
function parseNextLine() {
39-
40-
const line = lines[ current ];
36+
for ( const line of lines ) {
4137

4238
// console.log( line );
4339

@@ -74,7 +70,7 @@ class USDAParser {
7470

7571
stack.pop();
7672

77-
if ( stack.length === 0 ) return;
73+
if ( stack.length === 0 ) continue;
7874

7975
target = stack[ stack.length - 1 ];
8076

@@ -100,18 +96,8 @@ class USDAParser {
10096

10197
}
10298

103-
current ++;
104-
105-
if ( current < length ) {
106-
107-
parseNextLine();
108-
109-
}
110-
11199
}
112100

113-
parseNextLine();
114-
115101
return data;
116102

117103
}
@@ -640,7 +626,7 @@ class USDZLoader extends Loader {
640626

641627
}
642628

643-
} else if ( 'float inputs:clearcoat' in surface ) {
629+
} else if ( 'float inputs:clearcoat' in surface ) {
644630

645631
material.clearcoat = parseFloat( surface[ 'float inputs:clearcoat' ] );
646632

0 commit comments

Comments
 (0)