Skip to content

Commit

Permalink
USDZLoader: Avoid recursive calls of parseNextLine().
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Nov 10, 2023
1 parent d981731 commit e7b6848
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions examples/jsm/loaders/USDZLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ class USDAParser {
const data = {};

const lines = text.split( '\n' );
const length = lines.length;

let current = 0;
let string = null;
let target = data;

const stack = [ data ];

// debugger;

function parseNextLine() {

const line = lines[ current ];
for ( const line of lines ) {

// console.log( line );

Expand Down Expand Up @@ -74,7 +70,7 @@ class USDAParser {

stack.pop();

if ( stack.length === 0 ) return;
if ( stack.length === 0 ) continue;

target = stack[ stack.length - 1 ];

Expand All @@ -100,18 +96,8 @@ class USDAParser {

}

current ++;

if ( current < length ) {

parseNextLine();

}

}

parseNextLine();

return data;

}
Expand Down Expand Up @@ -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' ] );

Expand Down

0 comments on commit e7b6848

Please sign in to comment.