The STL loader uses the following regular expression to identify solids:
/solid (\S*)([\S\s])endsolid[ ](\S*)/g
This works in the case of a single solid. However, if fails with a valid STL file when multiple solids are present. For example:
solid name1
…
endsolid name1
solid name2
…
endsolid name2
will lead to an error in importMesh, because with this example the code will compare:
var meshName = matches[1]; // matches to name1 in the example
var meshNameFromEnd = matches[3]; // matches to name2 in the example
Also, it is not clear what the while loop does, since with this regex, the match can only be one or none at all.
The correct regex should be:
/solid (\S*)([\S\s]?)endsolid[ ](\S*)/g
Thanks!