copied from https://github.com/envisprecisely/THREE2STL/blob/master/THREE2STL.js