What is the preferred method for loading STL files

2019-03-20 03:45发布

问题:

I'm writing an application that is designed to be used as part of a mechanical design and simulation workflow, and we'd like to be able to use Three.js to load and visualize parts designed in Solidworks, which can be exported as STL (text or binary).

** I fully recognize that one can use something like Meshlab to convert to OBJ or some other format, but this seems like an unnecessary additional step that encumbers the workflow. **

It seems Three.js has good loading solutions for Collada, OBJ, UTF-8, VTK, and JSON, but there is no clean STL support example. I saw some things floating around that have been used in the past, such as https://github.com/tbuser/thingiview.js/blob/master/javascripts/thingiloader.js which I'd like to avoid because of the license, and https://github.com/tbuser/three.js/blob/master/utils/stl_geometry.js which seems not fully integrated.

Am I missing something?

回答1:

There is an STLLoader and an example of how to use it. These were added to Three.js in August of 2012, a mere month or so after this question was originally posted. Since then, there have been several commits involving the STLLoader.