-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Description
I think I've found an issue on the STL loader. The parseASCII(data) function parses the content of a STL ascii file, and the problematic line looks the following:
var patternFloat = /[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source;
it seems that 99.9...% of times it works well, however I have a STL file that contains faces like the following:
text: facet normal 1.29316e-07 3.66792e-08 1
outer loop
vertex -0.1641 -0.5387 -2.152e-08
vertex -0.1813 -0.5195 -2e-08
vertex -0.1881 -0.5446 -1.82e-08
end loop
endfacet
The problems happens when the parser gets the 2nd face vertex, i.e. the line
vertex -0.1813 -0.5195 -2e-08
please note that the Z coordinate does not have the dot. Of course, this should be fine, but the patternVertex.exec( text ) call returns a somehow corrupted result:
-0.1813,-0.5195,-2e
which is finally converted by the final "parseFloat" call to:
-0.1813,-0.5195,-2
In conclusion, what originally was -2e-08 is finally stored as -2 with all the evident consequences. I'm not expert enough on regex expressions to propose a solution, however I'm pretty sure there should be something to fix here
Three.js version
- r87
Browser
- Chrome
OS
- Linux