We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I am searching for a way to import STL files into p5.js .. any idea? I try to stay away from three.js.. but seems like that framework makes more sense for 3D stuff.
Thanks!
Answers
Nobody?
Googling "processing stl files" returns a ton of results, including these:
http://stackoverflow.com/questions/28885437/reading-or-open-stl-file-on-processing
https://forum.processing.org/two/discussion/9414/import-stl-file-using-toxiclibs
https://forum.processing.org/one/topic/importing-stl-file-into-processing-gui-using-the-new-modelbuilder-library.html
https://github.com/technicolorenvy/Processing-Libraries/blob/master/toxiclibscore/examples/mesh/STLImportTest/STLImportTest.pde
https://gist.github.com/atduskgreg/1151193
Why don't you try those and let us know if you get stuck?
Hey KevinWorkman,
Thanks for your answer. I found these results before but they are all target to processing not p5.js. They are using the toxiclibs library to import. How could I use it for p5.js without toxiclib? Sorry.. maybe I just don't get it :)
Sorry, I didn't see the p5.js part. I don't see an out of the box way to load an STL file into p5.js.
You might be able to write your own loader if you understand the file format though.
The STL file format is extremely simple. However, if you don't want to parse it yourself, I would be surprised if you couldn't just adapt the relevant import function from the toxiclib source without using the whole library (I haven't looked).
However, given that the p5.js loadModel() for more complex OBJ files was added in the last year, perhaps you could submit a feature request?
Not knowing the details of your project -- would it be possible to use OBJ files instead, or use an STL-to-OBJ transcoder before using loadModel()?
Addendum: The toxiclibs STLReader and STLWriter classes are a bit more complex than I thought, but not much -- and they have test code for using it as well. Whether taking it on yourself or just submitting a p5.js feature request, they are a good place to start for adding STL support to p5.js.
Sorry - ignore this post.
Submitted as feature request: https://github.com/processing/p5.js/issues/2734
A suggestion is to convert the STL file to an obj file. Not tested in js, but I did tested a while ago in the java side.
Kf
there is a new forum
please post there too...
https://discourse.processing.org